From 5b21fb68799d40a830fc0b25ea665e8c36481671 Mon Sep 17 00:00:00 2001 From: Stu Grossman Date: Mon, 14 Nov 1994 16:59:16 +0000 Subject: [PATCH] * Makefile.in: Install gdbtk.tcl. * configure.in: Add ENABLE_GDBTK flag. * gdbtk.c (gdb_sourcelines): Returns list of source lines containing code. (gdb_regnames): Returns list of register names. --- gdb/ChangeLog | 7 ++++ gdb/Makefile.in | 7 ++-- gdb/configure.in | 1 + gdb/gdbtk.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 18d13c9db0e..83988acd305 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +Mon Nov 14 08:51:29 1994 Stu Grossman (grossman@cygnus.com) + + * Makefile.in: Install gdbtk.tcl. + * configure.in: Add ENABLE_GDBTK flag. + * gdbtk.c (gdb_sourcelines): Returns list of source lines + containing code. (gdb_regnames): Returns list of register names. + Sat Nov 12 21:55:47 1994 Jeff Law (law@snake.cs.utah.edu) * somsolib.c: Add TODO list. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 5ac86ef0392..7fd2621eb74 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -187,8 +187,8 @@ INSTALLED_LIBS=-lbfd -lreadline $(TERMCAP) -lopcodes -lmmalloc \ CLIBS = $(BFD) $(READLINE) $(OPCODES) $(MMALLOC) \ $(LIBIBERTY) $(TERMCAP) $(XM_CLIBS) $(TM_CLIBS) $(NAT_CLIBS) \ $(ENABLE_CLIBS) -CDEPS = $(XM_CDEPS) $(TM_CDEPS) $(NAT_CDEPS) \ - $(BFD) $(READLINE) $(OPCODES) $(MMALLOC) $(LIBIBERTY) +CDEPS = $(XM_CDEPS) $(TM_CDEPS) $(NAT_CDEPS) $(BFD) $(READLINE) $(OPCODES) \ + $(MMALLOC) $(LIBIBERTY) ADD_FILES = $(REGEX) $(XM_ADD_FILES) $(TM_ADD_FILES) $(NAT_ADD_FILES) ADD_DEPS = $(REGEX1) $(XM_ADD_FILES) $(TM_ADD_FILES) $(NAT_ADD_FILES) @@ -537,6 +537,9 @@ install-only: fi ; \ $(INSTALL_PROGRAM) gdb $(bindir)/$$transformed_name ; \ $(INSTALL_DATA) $(srcdir)/gdb.1 $(man1dir)/$$transformed_name.1 + if [ -n $(ENABLE_GDBTK) ] ; then \ + $(INSTALL_DATA) $(srcdir)/gdbtk.tcl $(libdir)/gdbtk.tcl ; \ + fi @$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do uninstall: force diff --git a/gdb/configure.in b/gdb/configure.in index 4f63e1af4d2..f3ee9c03f74 100644 --- a/gdb/configure.in +++ b/gdb/configure.in @@ -416,6 +416,7 @@ fi if [ "${enable_gdbtk}" = "yes" ] ; then sed -e '/# End of host and/i\ \ +ENABLE_GDBTK = 1\ ENABLE_DEPFILES = gdbtk.o\ ENABLE_CLIBS = $(TCL) $(TK) -lX11 -lm ' < Makefile > Makefile.tem diff --git a/gdb/gdbtk.c b/gdb/gdbtk.c index 291476d7d6b..c2a1e383aa6 100644 --- a/gdb/gdbtk.c +++ b/gdb/gdbtk.c @@ -291,6 +291,87 @@ gdb_loc (clientData, interp, argc, argv) return TCL_OK; } +/* This implements the TCL command `gdb_sourcelines', which returns a list of + all of the lines containing executable code for the specified source file + (ie: lines where you can put breakpoints). */ + +static int +gdb_sourcelines (clientData, interp, argc, argv) + ClientData clientData; + Tcl_Interp *interp; + int argc; + char *argv[]; +{ + struct symtab *symtab; + struct linetable_entry *le; + int nlines; + char buf[100]; + + if (argc != 2) + { + Tcl_SetResult (interp, "wrong # args", TCL_STATIC); + return TCL_ERROR; + } + + symtab = lookup_symtab (argv[1]); + + if (!symtab) + { + Tcl_SetResult (interp, "No such file", TCL_STATIC); + return TCL_ERROR; + } + + /* If there's no linetable, or no entries, then we are done. */ + + if (!symtab->linetable + || symtab->linetable->nitems == 0) + { + Tcl_AppendElement (interp, ""); + return TCL_OK; + } + + le = symtab->linetable->item; + nlines = symtab->linetable->nitems; + + for (;nlines > 0; nlines--, le++) + { + /* If the pc of this line is the same as the pc of the next line, then + just skip it. */ + if (nlines > 1 + && le->pc == (le + 1)->pc) + continue; + + sprintf (buf, "%d", le->line); + Tcl_AppendElement (interp, buf); + } + + return TCL_OK; +} + +/* This implements the TCL command `gdb_regnames', which returns a list of + all of the register names. */ + +static int +gdb_regnames (clientData, interp, argc, argv) + ClientData clientData; + Tcl_Interp *interp; + int argc; + char *argv[]; +{ + int i; + + if (argc != 1) + { + Tcl_SetResult (interp, "wrong # args", TCL_STATIC); + return TCL_ERROR; + } + + for (i = 0; i < NUM_REGS; i++) + Tcl_AppendElement (interp, reg_names[i]); + + return TCL_OK; +} + static int gdb_cmd_stub (cmd) char *cmd; @@ -481,6 +562,8 @@ gdbtk_init () Tcl_CreateCommand (interp, "gdb_cmd", gdb_cmd, NULL, NULL); Tcl_CreateCommand (interp, "gdb_loc", gdb_loc, NULL, NULL); + Tcl_CreateCommand (interp, "gdb_sourcelines", gdb_sourcelines, NULL, NULL); + Tcl_CreateCommand (interp, "gdb_regnames", gdb_regnames, NULL, NULL); Tcl_CreateCommand (interp, "gdb_listfiles", gdb_listfiles, NULL, NULL); Tcl_CreateCommand (interp, "gdb_stop", gdb_stop, NULL, NULL); -- 2.30.2