diff options
author | Doug Evans <dje@google.com> | 2013-05-17 18:09:06 +0000 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2013-05-17 18:09:06 +0000 |
commit | 7d0c9981dc1753663969b47221164504e71676a6 (patch) | |
tree | 7b96437bee3ee6847a00c8cf6a8488cc901766ef /gdb/symmisc.c | |
parent | 8d324e832969c4334524c77df4f94fe54f45ad18 (diff) | |
download | gdb-7d0c9981dc1753663969b47221164504e71676a6.zip gdb-7d0c9981dc1753663969b47221164504e71676a6.tar.gz gdb-7d0c9981dc1753663969b47221164504e71676a6.tar.bz2 |
* NEWS: Mention new maintenance commands check-symtabs, and
expand-symtabs, and renamed check-psymtabs.
* psymtab.c (maintenance_check_psymtabs): Renamed from
maintenance_check_symtabs. Only process already-expanded symbol
tables.
(_initialize_psymtab): Update.
* symmisc.c (maintenance_check_symtabs): New function.
(maintenance_expand_name_matcher): New function
(maintenance_expand_file_matcher): New function
(maintenance_expand_symtabs): New function.
(_initialize_symmisc): Add "mt check-symtabs" and "mt expand-symtabs"
commands.
doc/
* gdb.texinfo (Maintenance Commands): Update doc for
"maint check-psymtabs". Add doc for "maint check-symtabs",
"maint expand-symtabs".
testsuite/
* gdb.base/maint.exp: Update test for "maint check-psymtabs".
Add tests for "maint check-symtabs", "maint expand-symtabs".
Diffstat (limited to 'gdb/symmisc.c')
-rw-r--r-- | gdb/symmisc.c | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 52c934a..eb8bbbf 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -771,6 +771,134 @@ maintenance_info_symtabs (char *regexp, int from_tty) printf_filtered ("}\n"); } } + +/* Check consistency of symtabs. + An example of what this checks for is NULL blockvectors. + They can happen if there's a bug during debug info reading. + GDB assumes they are always non-NULL. + + Note: This does not check for psymtab vs symtab consistency. + Use "maint check-psymtabs" for that. */ + +static void +maintenance_check_symtabs (char *ignore, int from_tty) +{ + struct program_space *pspace; + struct objfile *objfile; + + ALL_PSPACES (pspace) + ALL_PSPACE_OBJFILES (pspace, objfile) + { + struct symtab *symtab; + + /* We don't want to print anything for this objfile until we + actually find something worth printing. */ + int printed_objfile_start = 0; + + ALL_OBJFILE_SYMTABS (objfile, symtab) + { + int found_something = 0; + + QUIT; + + if (symtab->blockvector == NULL) + found_something = 1; + /* Add more checks here. */ + + if (found_something) + { + if (! printed_objfile_start) + { + printf_filtered ("{ objfile %s ", objfile->name); + wrap_here (" "); + printf_filtered ("((struct objfile *) %s)\n", + host_address_to_string (objfile)); + printed_objfile_start = 1; + } + printf_filtered (" { symtab %s\n", + symtab_to_filename_for_display (symtab)); + if (symtab->blockvector == NULL) + printf_filtered (" NULL blockvector\n"); + printf_filtered (" }\n"); + } + } + + if (printed_objfile_start) + printf_filtered ("}\n"); + } +} + +/* Helper function for maintenance_expand_symtabs. + This is the name_matcher function for expand_symtabs_matching. */ + +static int +maintenance_expand_name_matcher (const char *symname, void *data) +{ + /* Since we're not searching on symbols, just return TRUE. */ + return 1; +} + +/* Helper function for maintenance_expand_symtabs. + This is the file_matcher function for expand_symtabs_matching. */ + +static int +maintenance_expand_file_matcher (const char *filename, void *data, + int basenames) +{ + const char *regexp = data; + + QUIT; + + /* KISS: Only apply the regexp to the complete file name. */ + if (basenames) + return 0; + + if (regexp == NULL || re_exec (filename)) + return 1; + + return 0; +} + +/* Expand all symbol tables whose name matches an optional regexp. */ + +static void +maintenance_expand_symtabs (char *args, int from_tty) +{ + struct program_space *pspace; + struct objfile *objfile; + struct cleanup *cleanups; + char **argv; + char *regexp = NULL; + + /* We use buildargv here so that we handle spaces in the regexp + in a way that allows adding more arguments later. */ + argv = gdb_buildargv (args); + cleanups = make_cleanup_freeargv (argv); + + if (argv != NULL) + { + if (argv[0] != NULL) + { + regexp = argv[0]; + if (argv[1] != NULL) + error (_("Extra arguments after regexp.")); + } + } + + if (regexp) + re_comp (regexp); + + ALL_PSPACES (pspace) + ALL_PSPACE_OBJFILES (pspace, objfile) + { + if (objfile->sf) + { + objfile->sf->qf->expand_symtabs_matching + (objfile, maintenance_expand_file_matcher, + maintenance_expand_name_matcher, ALL_DOMAIN, regexp); + } + } +} /* Return the nexting depth of a block within other blocks in its symtab. */ @@ -819,4 +947,14 @@ 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."), &maintenanceinfolist); + + add_cmd ("check-symtabs", class_maintenance, maintenance_check_symtabs, + _("\ +Check consistency of currently expanded symtabs."), + &maintenancelist); + + add_cmd ("expand-symtabs", class_maintenance, maintenance_expand_symtabs, + _("Expand symbol tables.\n\ +With an argument REGEXP, only expand the symbol tables with matching names."), + &maintenancelist); } |