diff options
-rw-r--r-- | gdb/ChangeLog | 15 | ||||
-rw-r--r-- | gdb/Makefile.in | 2 | ||||
-rw-r--r-- | gdb/cli/cli-cmds.c | 5 | ||||
-rw-r--r-- | gdb/cli/cli-cmds.h | 4 | ||||
-rw-r--r-- | gdb/doc/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 58 | ||||
-rw-r--r-- | gdb/gdbcmd.h | 4 | ||||
-rw-r--r-- | gdb/maint.c | 30 | ||||
-rw-r--r-- | gdb/symmisc.c | 140 | ||||
-rw-r--r-- | gdb/symtab.h | 4 |
10 files changed, 266 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b2220573285..35e0c333cc8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,18 @@ +2003-04-14 Jim Blandy <jimb@redhat.com> + + * symmisc.c: #include "gdb_regex.h". + (maintenance_list_symtabs, maintenance_list_psymtabs): New + functions. + * maint.c (maintenance_list_command): New function. + (_initialize_maint_cmds): Register the above as commands. + * symtab.h (maintenance_list_symtabs, + maintenance_list_psymtabs): New declarations. + * cli/cli-cmds.c (maintenancelistlist): New variable. + (init_cmd_lists): Initialize it. + * cli/cli-cmds.h (maintenancelistlist): New declaration. + * gdbcmd.h (maintenancelistlist): New declaration. + * Makefile.in (symmisc.o): Update dependencies. + 2003-04-14 Elena Zannoni <ezannoni@redhat.com> * s390-nat.c: Include asm/types.h for addr_t. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index a9c2a2c2d6e..bb55a1d406e 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -2255,7 +2255,7 @@ symm-tdep.o: symm-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(symtab_h) \ symmisc.o: symmisc.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(bfd_h) \ $(symfile_h) $(objfiles_h) $(breakpoint_h) $(command_h) \ $(gdb_obstack_h) $(language_h) $(bcache_h) $(gdb_string_h) \ - $(readline_h) $(block_h) + $(readline_h) $(block_h) $(gdb_regex_h) symtab.o: symtab.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(gdbcore_h) \ $(frame_h) $(target_h) $(value_h) $(symfile_h) $(objfiles_h) \ $(gdbcmd_h) $(call_cmds_h) $(gdb_regex_h) $(expression_h) \ diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 108329a50c7..c33c242bad5 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -171,6 +171,10 @@ struct cmd_list_element *maintenanceinfolist; struct cmd_list_element *maintenanceprintlist; +/* Chain containing all defined "maintenance list" subcommands. */ + +struct cmd_list_element *maintenancelistlist; + struct cmd_list_element *setprintlist; struct cmd_list_element *showprintlist; @@ -1032,6 +1036,7 @@ init_cmd_lists (void) maintenancelist = NULL; maintenanceinfolist = NULL; maintenanceprintlist = NULL; + maintenancelistlist = NULL; setprintlist = NULL; showprintlist = NULL; setchecklist = NULL; diff --git a/gdb/cli/cli-cmds.h b/gdb/cli/cli-cmds.h index a6e574edd71..1f340efa101 100644 --- a/gdb/cli/cli-cmds.h +++ b/gdb/cli/cli-cmds.h @@ -87,6 +87,10 @@ extern struct cmd_list_element *maintenanceinfolist; extern struct cmd_list_element *maintenanceprintlist; +/* Chain containing all defined "maintenance list" subcommands. */ + +extern struct cmd_list_element *maintenancelistlist; + extern struct cmd_list_element *setprintlist; extern struct cmd_list_element *showprintlist; diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index ff3023614cb..473eb155d0e 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2003-04-09 Jim Blandy <jimb@redhat.com> + + * gdb.texinfo (Symbols): Document 'maint list symtabs' and 'maint + list psymtabs'. + 2003-04-08 Andrew Cagney <cagney@redhat.com> * gdbint.texinfo (Target Architecture Definition): Delete diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index f00cf2b287c..00a4ac7f9fc 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -9033,8 +9033,66 @@ files that @value{GDBN} has skimmed, but not yet read completely. Finally, required for each object file from which @value{GDBN} has read some symbols. @xref{Files, ,Commands to specify files}, for a discussion of how @value{GDBN} reads symbols (in the description of @code{symbol-file}). + +@kindex maint list symtabs +@kindex maint list psymtabs +@cindex listing @value{GDBN}'s internal symbol tables +@cindex symbol tables, listing @value{GDBN}'s internal +@cindex full symbol tables, listing @value{GDBN}'s internal +@cindex partial symbol tables, listing @value{GDBN}'s internal +@item maint list symtabs @r{[} @var{regexp} @r{]} +@itemx maint list psymtabs @r{[} @var{regexp} @r{]} + +List the @code{struct symtab} or @code{struct partial_symtab} +structures whose names match @var{regexp}. If @var{regexp} is not +given, list them all. The output includes expressions which you can +copy into a @value{GDBN} debugging this one to examine a particular +structure in more detail. For example: + +@smallexample +(@value{GDBP}) maint list psymtabs dwarf2read +@{ objfile /home/gnu/build/gdb/gdb + ((struct objfile *) 0x82e69d0) + @{ psymtab /home/gnu/src/gdb/dwarf2read.c + ((struct partial_symtab *) 0x8474b10) + readin no + fullname (null) + text addresses 0x814d3c8 -- 0x8158074 + globals (* (struct partial_symbol **) 0x8507a08 @@ 9) + statics (* (struct partial_symbol **) 0x40e95b78 @@ 2882) + dependencies (none) + @} +@} +(@value{GDBP}) maint list symtabs +(@value{GDBP}) +@end smallexample +@noindent +We see that there is one partial symbol table whose filename contains +the string @samp{dwarf2read}, belonging to the @samp{gdb} executable; +and we see that @value{GDBN} has not read in any symtabs yet at all. +If we set a breakpoint on a function, that will cause @value{GDBN} to +read the symtab for the compilation unit containing that function: + +@smallexample +(@value{GDBP}) break dwarf2_psymtab_to_symtab +Breakpoint 1 at 0x814e5da: file /home/gnu/src/gdb/dwarf2read.c, +line 1574. +(@value{GDBP}) maint list symtabs +@{ objfile /home/gnu/build/gdb/gdb + ((struct objfile *) 0x82e69d0) + @{ symtab /home/gnu/src/gdb/dwarf2read.c + ((struct symtab *) 0x86c1f38) + dirname (null) + fullname (null) + blockvector ((struct blockvector *) 0x86c1bd0) (primary) + debugformat DWARF 2 + @} +@} +(@value{GDBP}) +@end smallexample @end table + @node Altering @chapter Altering Execution diff --git a/gdb/gdbcmd.h b/gdb/gdbcmd.h index 8c4490ec940..e626eb5f9e4 100644 --- a/gdb/gdbcmd.h +++ b/gdb/gdbcmd.h @@ -98,6 +98,10 @@ extern struct cmd_list_element *maintenanceinfolist; extern struct cmd_list_element *maintenanceprintlist; +/* Chain containing all defined "maintenance list" subcommands. */ + +extern struct cmd_list_element *maintenancelistlist; + extern struct cmd_list_element *setprintlist; extern struct cmd_list_element *showprintlist; diff --git a/gdb/maint.c b/gdb/maint.c index 166acdb2ea9..2eb59ee5e3a 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -434,6 +434,18 @@ maintenance_print_command (char *arg, int from_tty) help_list (maintenanceprintlist, "maintenance print ", -1, gdb_stdout); } +/* The "maintenance list" command is defined as a prefix, with + allow_unknown 0. Therefore, its own definition is called only for + "maintenance list" with no args. */ + +/* ARGSUSED */ +static void +maintenance_list_command (char *arg, int from_tty) +{ + printf_unfiltered ("\"maintenance list\" must be followed by the name of a list command.\n"); + help_list (maintenancelistlist, "maintenance list ", -1, gdb_stdout); +} + /* The "maintenance translate-address" command converts a section and address to a symbol. This can be called in two ways: maintenance translate-address <secname> <addr> @@ -732,6 +744,11 @@ lists all sections from all object files, including shared libraries.", &maintenanceprintlist, "maintenance print ", 0, &maintenancelist); + add_prefix_cmd ("list", class_maintenance, maintenance_list_command, + "Maintenance command for listing GDB internal state.", + &maintenancelistlist, "maintenance list ", 0, + &maintenancelist); + add_prefix_cmd ("set", class_maintenance, maintenance_set_cmd, "\ Set GDB internal variables used by the GDB maintainer.\n\ Configure variables internal to GDB that aid in GDB's maintenance", @@ -810,6 +827,19 @@ If a SOURCE file is specified, dump only that file's partial symbols.", "Print dump of current object file definitions.", &maintenanceprintlist); + add_cmd ("symtabs", class_maintenance, maintenance_list_symtabs, + "List the full symbol tables for all object files.\n\ +This does not include information about individual symbols, blocks, or\n\ +linetables --- just the symbol table structures themselves.\n\ +With an argument REGEXP, list the symbol tables whose names that match that.", + &maintenancelistlist); + + add_cmd ("psymtabs", class_maintenance, maintenance_list_psymtabs, + "List the partial symbol tables for all object files.\n\ +This does not include information about individual partial symbols,\n\ +just the symbol table structures themselves.", + &maintenancelistlist); + add_cmd ("statistics", class_maintenance, maintenance_print_statistics, "Print statistics about internal gdb state.", &maintenanceprintlist); diff --git a/gdb/symmisc.c b/gdb/symmisc.c index f6e78ebc98e..70eb125c1ba 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -33,6 +33,7 @@ #include "language.h" #include "bcache.h" #include "block.h" +#include "gdb_regex.h" #include "gdb_string.h" #include <readline/readline.h> @@ -985,6 +986,145 @@ maintenance_print_objfiles (char *ignore, int from_tty) immediate_quit--; } + +/* List all the symbol tables. */ +void +maintenance_list_symtabs (char *regexp, int from_tty) +{ + struct objfile *objfile; + + if (regexp) + re_comp (regexp); + + ALL_OBJFILES (objfile) + { + struct symtab *symtab; + + /* We don't want to print anything for this objfile until we + actually find a symtab whose name matches. */ + int printed_objfile_start = 0; + + ALL_OBJFILE_SYMTABS (objfile, symtab) + if (! regexp + || re_exec (symtab->filename)) + { + if (! printed_objfile_start) + { + printf_filtered ("{ objfile %s ", objfile->name); + wrap_here (" "); + printf_filtered ("((struct objfile *) %p)\n", objfile); + printed_objfile_start = 1; + } + + printf_filtered (" { symtab %s ", symtab->filename); + wrap_here (" "); + printf_filtered ("((struct symtab *) %p)\n", symtab); + printf_filtered (" dirname %s\n", + symtab->dirname ? symtab->dirname : "(null)"); + printf_filtered (" fullname %s\n", + symtab->fullname ? symtab->fullname : "(null)"); + printf_filtered (" blockvector ((struct blockvector *) %p)%s\n", + symtab->blockvector, + symtab->primary ? " (primary)" : ""); + printf_filtered (" debugformat %s\n", symtab->debugformat); + printf_filtered (" }\n"); + } + + if (printed_objfile_start) + printf_filtered ("}\n"); + } +} + + +/* List all the partial symbol tables. */ +void +maintenance_list_psymtabs (char *regexp, int from_tty) +{ + struct objfile *objfile; + + if (regexp) + re_comp (regexp); + + ALL_OBJFILES (objfile) + { + struct partial_symtab *psymtab; + + /* We don't want to print anything for this objfile until we + actually find a symtab whose name matches. */ + int printed_objfile_start = 0; + + ALL_OBJFILE_PSYMTABS (objfile, psymtab) + if (! regexp + || re_exec (psymtab->filename)) + { + if (! printed_objfile_start) + { + printf_filtered ("{ objfile %s ", objfile->name); + wrap_here (" "); + printf_filtered ("((struct objfile *) %p)\n", objfile); + printed_objfile_start = 1; + } + + printf_filtered (" { psymtab %s ", psymtab->filename); + wrap_here (" "); + printf_filtered ("((struct partial_symtab *) %p)\n", psymtab); + printf_filtered (" readin %s\n", + psymtab->readin ? "yes" : "no"); + printf_filtered (" fullname %s\n", + psymtab->fullname ? psymtab->fullname : "(null)"); + printf_filtered (" text addresses "); + print_address_numeric (psymtab->textlow, 1, gdb_stdout); + printf_filtered (" -- "); + print_address_numeric (psymtab->texthigh, 1, gdb_stdout); + printf_filtered ("\n"); + printf_filtered (" globals "); + if (psymtab->n_global_syms) + { + printf_filtered ("(* (struct partial_symbol **) %p @ %d)\n", + (psymtab->objfile->global_psymbols.list + + psymtab->globals_offset), + psymtab->n_global_syms); + } + else + printf_filtered ("(none)\n"); + printf_filtered (" statics "); + if (psymtab->n_static_syms) + { + printf_filtered ("(* (struct partial_symbol **) %p @ %d)\n", + (psymtab->objfile->static_psymbols.list + + psymtab->statics_offset), + psymtab->n_static_syms); + } + else + printf_filtered ("(none)\n"); + printf_filtered (" dependencies "); + if (psymtab->number_of_dependencies) + { + int i; + + printf_filtered ("{\n"); + for (i = 0; i < psymtab->number_of_dependencies; i++) + { + struct partial_symtab *dep = psymtab->dependencies[i]; + + /* Note the string concatenation there --- no comma. */ + printf_filtered (" psymtab %s " + "((struct partial_symtab *) %p)\n", + dep->filename, dep); + } + printf_filtered (" }\n"); + } + else + printf_filtered ("(none)\n"); + printf_filtered (" }\n"); + } + + if (printed_objfile_start) + printf_filtered ("}\n"); + } +} + + /* Check consistency of psymtabs and symtabs. */ void diff --git a/gdb/symtab.h b/gdb/symtab.h index bb9525cf067..49ec2b548d8 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1233,6 +1233,10 @@ void maintenance_print_msymbols (char *, int); void maintenance_print_objfiles (char *, int); +void maintenance_list_symtabs (char *, int); + +void maintenance_list_psymtabs (char *, int); + void maintenance_check_symtabs (char *, int); /* maint.c */ |