* [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs
@ 2013-05-13 20:21 Doug Evans
2013-05-14 14:19 ` Tom Tromey
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Doug Evans @ 2013-05-13 20:21 UTC (permalink / raw)
To: gdb-patches
Hi.
This is a revised version of this patch:
http://sourceware.org/ml/gdb-patches/2013-05/msg00261.html
It makes "check-psymtabs" only check already expanded symtabs,
and adds new maint commands check-symtabs and expand-symtabs.
Regression tested on amd64-linux.
Ok to check in?
2013-05-13 Doug Evans <dje@google.com>
* 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".
Index: NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.594
diff -u -p -r1.594 NEWS
--- NEWS 7 May 2013 01:09:27 -0000 1.594
+++ NEWS 9 May 2013 20:45:40 -0000
@@ -11,6 +11,12 @@ Nios II GNU/Linux nios2*-*-linux
* New commands:
catch rethrow
Like "catch throw", but catches a re-thrown exception.
+maint check-psymtabs
+ Renamed from old "maint check-symtabs".
+maint check-symtabs
+ Perform consistency checks on symtabs.
+maint expand-symtabs
+ Expand symtabs matching an optional regexp.
show configuration
Display the details of GDB configure-time options.
Index: psymtab.c
===================================================================
RCS file: /cvs/src/src/gdb/psymtab.c,v
retrieving revision 1.75
diff -u -p -r1.75 psymtab.c
--- psymtab.c 8 May 2013 22:38:19 -0000 1.75
+++ psymtab.c 9 May 2013 20:58:19 -0000
@@ -2007,10 +2012,10 @@ maintenance_info_psymtabs (char *regexp,
}
}
-/* Check consistency of psymtabs and symtabs. */
+/* Check consistency of currently expanded psymtabs vs symtabs. */
static void
-maintenance_check_symtabs (char *ignore, int from_tty)
+maintenance_check_psymtabs (char *ignore, int from_tty)
{
struct symbol *sym;
struct partial_symbol **psym;
@@ -2025,7 +2030,25 @@ maintenance_check_symtabs (char *ignore,
{
struct gdbarch *gdbarch = get_objfile_arch (objfile);
- s = psymtab_to_symtab (objfile, ps);
+ /* We don't call psymtab_to_symtab here because that may cause symtab
+ expansion. When debugging a problem it helps if checkers leave
+ things unchanged. */
+ s = ps->symtab;
+
+ /* First do some checks that don't require the associated symtab. */
+ if (ps->texthigh < ps->textlow)
+ {
+ printf_filtered ("Psymtab ");
+ puts_filtered (ps->filename);
+ printf_filtered (" covers bad range ");
+ fputs_filtered (paddress (gdbarch, ps->textlow), gdb_stdout);
+ printf_filtered (" - ");
+ fputs_filtered (paddress (gdbarch, ps->texthigh), gdb_stdout);
+ printf_filtered ("\n");
+ continue;
+ }
+
+ /* Now do checks requiring the associated symtab. */
if (s == NULL)
continue;
bv = BLOCKVECTOR (s);
@@ -2063,20 +2086,8 @@ maintenance_check_symtabs (char *ignore,
}
psym++;
}
- if (ps->texthigh < ps->textlow)
- {
- printf_filtered ("Psymtab ");
- puts_filtered (ps->filename);
- printf_filtered (" covers bad range ");
- fputs_filtered (paddress (gdbarch, ps->textlow), gdb_stdout);
- printf_filtered (" - ");
- fputs_filtered (paddress (gdbarch, ps->texthigh), gdb_stdout);
- printf_filtered ("\n");
- continue;
- }
- if (ps->texthigh == 0)
- continue;
- if (ps->textlow < BLOCK_START (b) || ps->texthigh > BLOCK_END (b))
+ if (ps->texthigh != 0
+ && (ps->textlow < BLOCK_START (b) || ps->texthigh > BLOCK_END (b)))
{
printf_filtered ("Psymtab ");
puts_filtered (ps->filename);
@@ -2140,7 +2151,8 @@ This does not include information about
just the symbol table structures themselves."),
&maintenanceinfolist);
- add_cmd ("check-symtabs", class_maintenance, maintenance_check_symtabs,
- _("Check consistency of psymtabs and symtabs."),
+ add_cmd ("check-psymtabs", class_maintenance, maintenance_check_psymtabs,
+ _("\
+Check consistency of currently expanded psymtabs versus symtabs."),
&maintenancelist);
}
Index: symmisc.c
===================================================================
RCS file: /cvs/src/src/gdb/symmisc.c,v
retrieving revision 1.96
diff -u -p -r1.96 symmisc.c
--- symmisc.c 9 Apr 2013 02:17:17 -0000 1.96
+++ symmisc.c 9 May 2013 20:45:40 -0000
@@ -771,6 +771,134 @@ maintenance_info_symtabs (char *regexp,
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);
+ }
+ }
+}
\f
/* Return the nexting depth of a block within other blocks in its symtab. */
@@ -819,4 +947,14 @@ This does not include information about
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);
}
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.1086
diff -u -p -r1.1086 gdb.texinfo
--- doc/gdb.texinfo 8 May 2013 05:40:44 -0000 1.1086
+++ doc/gdb.texinfo 9 May 2013 20:45:40 -0000
@@ -35512,9 +35512,20 @@ only if non-stop mode is active (@pxref{
architecture supports displaced stepping.
@end table
+@kindex maint check-psymtabs
+@item maint check-psymtabs
+Check the consistency of currently expanded psymtabs versus symtabs.
+Use this to check, for example, whether a symbol is in one but not the other.
+
@kindex maint check-symtabs
@item maint check-symtabs
-Check the consistency of psymtabs and symtabs.
+Check the consistency of currently expanded symtabs.
+
+@kindex maint expand-symtabs
+@item maint expand-symtabs [@var{regexp}]
+Expand symbol tables.
+If @var{regexp} is specified, only expand symbol tables for file
+names matching @var{regexp}.
@kindex maint cplus first_component
@item maint cplus first_component @var{name}
Index: testsuite/gdb.base/maint.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/maint.exp,v
retrieving revision 1.63
diff -u -p -r1.63 maint.exp
--- testsuite/gdb.base/maint.exp 29 Mar 2013 00:11:10 -0000 1.63
+++ testsuite/gdb.base/maint.exp 13 May 2013 19:22:19 -0000
@@ -20,7 +20,9 @@
# source file used is break.c
-#maintenance check-symtabs -- Check consistency of psymtabs and symtabs
+#maintenance check-psymtabs -- Check consistency of psymtabs vs symtabs
+#maintenance check-symtabs -- Check consistency of symtabs
+#maintenance expand-symtabs -- Expand symtabs matching a file regexp
#maintenance set -- Set GDB internal variables used by the GDB maintainer
#maintenance show -- Show GDB internal variables used by the GDB maintainer
#maintenance demangle -- Demangle a C++ mangled name
@@ -82,6 +84,18 @@ gdb_file_cmd ${binfile}
# program wasn't running.
gdb_test "maint print registers" "Name.*Nr.*Rel.*Offset.*Size.*Type.*"
+# Test "mt expand-symtabs" here as it's easier to verify before we
+# run the program.
+gdb_test_no_output "mt set per on" "mt set per on for expand-symtabs"
+gdb_test_multiple "mt expand-symtabs $subdir/break\[.\]c$" \
+ "mt expand-symtabs" {
+ -re "#primary symtabs: 1 \\(\[+\]1\\),.*$gdb_prompt $" {
+ # This should expand exactly one (primary) symtab.
+ pass "mt expand-symtabs"
+ }
+ }
+gdb_test "mt set per off" ".*" "mt set per off for expand-symtabs"
+
# Tests that can or should be done with a running program
gdb_load ${binfile}
@@ -110,20 +124,25 @@ gdb_test_multiple "maint info sections .
# guo: on linux this command output is huge. for some reason splitting up
# the regexp checks works.
#
-send_gdb "maint check-symtabs\n"
+send_gdb "maint check-psymtabs\n"
gdb_expect {
- -re "^maint check-symtabs" {
+ -re "^maint check-psymtabs" {
gdb_expect {
-re "$gdb_prompt $" {
- pass "maint check-symtabs"
+ pass "maint check-psymtabs"
}
- timeout { fail "(timeout) maint check-symtabs" }
+ timeout { fail "(timeout) maint check-psymtabs" }
}
}
- -re ".*$gdb_prompt $" { fail "maint check-symtabs" }
- timeout { fail "(timeout) maint check-symtabs" }
+ -re ".*$gdb_prompt $" { fail "maint check-psymtabs" }
+ timeout { fail "(timeout) maint check-psymtabs" }
}
+# This command does not produce any output unless there is some problem
+# with the symtabs, so that branch will really never be covered in the
+# tests here!!
+gdb_test_no_output "maint check-symtabs"
+
gdb_test_no_output "maint set per-command on"
gdb_test "maint set per-command off" \
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs
2013-05-13 20:21 [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs Doug Evans
@ 2013-05-14 14:19 ` Tom Tromey
2013-05-15 15:24 ` Doug Evans
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2013-05-14 14:19 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
>>>>> "Doug" == Doug Evans <dje@google.com> writes:
Doug> This is a revised version of this patch:
Doug> http://sourceware.org/ml/gdb-patches/2013-05/msg00261.html
Doug> It makes "check-psymtabs" only check already expanded symtabs,
Doug> and adds new maint commands check-symtabs and expand-symtabs.
Doug> Regression tested on amd64-linux.
Doug> Ok to check in?
It looks good to me.
Tom
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs
2013-05-13 20:21 [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs Doug Evans
2013-05-14 14:19 ` Tom Tromey
@ 2013-05-15 15:24 ` Doug Evans
2013-05-15 15:42 ` Eli Zaretskii
2013-05-19 11:23 ` new maint.exp FAIL w/-fdebug-types-section [Re: [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs] Jan Kratochvil
2013-05-24 15:50 ` [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs Tom Tromey
3 siblings, 1 reply; 8+ messages in thread
From: Doug Evans @ 2013-05-15 15:24 UTC (permalink / raw)
To: gdb-patches, Eli Zaretskii
On Mon, May 13, 2013 at 1:20 PM, Doug Evans <dje@google.com> wrote:
> Hi.
>
> This is a revised version of this patch:
> http://sourceware.org/ml/gdb-patches/2013-05/msg00261.html
>
> It makes "check-psymtabs" only check already expanded symtabs,
> and adds new maint commands check-symtabs and expand-symtabs.
>
> Regression tested on amd64-linux.
>
> Ok to check in?
>
> 2013-05-13 Doug Evans <dje@google.com>
>
> * 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".
>
> Index: NEWS
> ===================================================================
> RCS file: /cvs/src/src/gdb/NEWS,v
> retrieving revision 1.594
> diff -u -p -r1.594 NEWS
> --- NEWS 7 May 2013 01:09:27 -0000 1.594
> +++ NEWS 9 May 2013 20:45:40 -0000
> @@ -11,6 +11,12 @@ Nios II GNU/Linux nios2*-*-linux
> * New commands:
> catch rethrow
> Like "catch throw", but catches a re-thrown exception.
> +maint check-psymtabs
> + Renamed from old "maint check-symtabs".
> +maint check-symtabs
> + Perform consistency checks on symtabs.
> +maint expand-symtabs
> + Expand symtabs matching an optional regexp.
>
> show configuration
> Display the details of GDB configure-time options.
> Index: psymtab.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/psymtab.c,v
> retrieving revision 1.75
> diff -u -p -r1.75 psymtab.c
> --- psymtab.c 8 May 2013 22:38:19 -0000 1.75
> +++ psymtab.c 9 May 2013 20:58:19 -0000
> @@ -2007,10 +2012,10 @@ maintenance_info_psymtabs (char *regexp,
> }
> }
>
> -/* Check consistency of psymtabs and symtabs. */
> +/* Check consistency of currently expanded psymtabs vs symtabs. */
>
> static void
> -maintenance_check_symtabs (char *ignore, int from_tty)
> +maintenance_check_psymtabs (char *ignore, int from_tty)
> {
> struct symbol *sym;
> struct partial_symbol **psym;
> @@ -2025,7 +2030,25 @@ maintenance_check_symtabs (char *ignore,
> {
> struct gdbarch *gdbarch = get_objfile_arch (objfile);
>
> - s = psymtab_to_symtab (objfile, ps);
> + /* We don't call psymtab_to_symtab here because that may cause symtab
> + expansion. When debugging a problem it helps if checkers leave
> + things unchanged. */
> + s = ps->symtab;
> +
> + /* First do some checks that don't require the associated symtab. */
> + if (ps->texthigh < ps->textlow)
> + {
> + printf_filtered ("Psymtab ");
> + puts_filtered (ps->filename);
> + printf_filtered (" covers bad range ");
> + fputs_filtered (paddress (gdbarch, ps->textlow), gdb_stdout);
> + printf_filtered (" - ");
> + fputs_filtered (paddress (gdbarch, ps->texthigh), gdb_stdout);
> + printf_filtered ("\n");
> + continue;
> + }
> +
> + /* Now do checks requiring the associated symtab. */
> if (s == NULL)
> continue;
> bv = BLOCKVECTOR (s);
> @@ -2063,20 +2086,8 @@ maintenance_check_symtabs (char *ignore,
> }
> psym++;
> }
> - if (ps->texthigh < ps->textlow)
> - {
> - printf_filtered ("Psymtab ");
> - puts_filtered (ps->filename);
> - printf_filtered (" covers bad range ");
> - fputs_filtered (paddress (gdbarch, ps->textlow), gdb_stdout);
> - printf_filtered (" - ");
> - fputs_filtered (paddress (gdbarch, ps->texthigh), gdb_stdout);
> - printf_filtered ("\n");
> - continue;
> - }
> - if (ps->texthigh == 0)
> - continue;
> - if (ps->textlow < BLOCK_START (b) || ps->texthigh > BLOCK_END (b))
> + if (ps->texthigh != 0
> + && (ps->textlow < BLOCK_START (b) || ps->texthigh > BLOCK_END (b)))
> {
> printf_filtered ("Psymtab ");
> puts_filtered (ps->filename);
> @@ -2140,7 +2151,8 @@ This does not include information about
> just the symbol table structures themselves."),
> &maintenanceinfolist);
>
> - add_cmd ("check-symtabs", class_maintenance, maintenance_check_symtabs,
> - _("Check consistency of psymtabs and symtabs."),
> + add_cmd ("check-psymtabs", class_maintenance, maintenance_check_psymtabs,
> + _("\
> +Check consistency of currently expanded psymtabs versus symtabs."),
> &maintenancelist);
> }
> Index: symmisc.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/symmisc.c,v
> retrieving revision 1.96
> diff -u -p -r1.96 symmisc.c
> --- symmisc.c 9 Apr 2013 02:17:17 -0000 1.96
> +++ symmisc.c 9 May 2013 20:45:40 -0000
> @@ -771,6 +771,134 @@ maintenance_info_symtabs (char *regexp,
> 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
> 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);
> }
> Index: doc/gdb.texinfo
> ===================================================================
> RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
> retrieving revision 1.1086
> diff -u -p -r1.1086 gdb.texinfo
> --- doc/gdb.texinfo 8 May 2013 05:40:44 -0000 1.1086
> +++ doc/gdb.texinfo 9 May 2013 20:45:40 -0000
> @@ -35512,9 +35512,20 @@ only if non-stop mode is active (@pxref{
> architecture supports displaced stepping.
> @end table
>
> +@kindex maint check-psymtabs
> +@item maint check-psymtabs
> +Check the consistency of currently expanded psymtabs versus symtabs.
> +Use this to check, for example, whether a symbol is in one but not the other.
> +
> @kindex maint check-symtabs
> @item maint check-symtabs
> -Check the consistency of psymtabs and symtabs.
> +Check the consistency of currently expanded symtabs.
> +
> +@kindex maint expand-symtabs
> +@item maint expand-symtabs [@var{regexp}]
> +Expand symbol tables.
> +If @var{regexp} is specified, only expand symbol tables for file
> +names matching @var{regexp}.
>
> @kindex maint cplus first_component
> @item maint cplus first_component @var{name}
> Index: testsuite/gdb.base/maint.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.base/maint.exp,v
> retrieving revision 1.63
> diff -u -p -r1.63 maint.exp
> --- testsuite/gdb.base/maint.exp 29 Mar 2013 00:11:10 -0000 1.63
> +++ testsuite/gdb.base/maint.exp 13 May 2013 19:22:19 -0000
> @@ -20,7 +20,9 @@
> # source file used is break.c
>
>
> -#maintenance check-symtabs -- Check consistency of psymtabs and symtabs
> +#maintenance check-psymtabs -- Check consistency of psymtabs vs symtabs
> +#maintenance check-symtabs -- Check consistency of symtabs
> +#maintenance expand-symtabs -- Expand symtabs matching a file regexp
> #maintenance set -- Set GDB internal variables used by the GDB maintainer
> #maintenance show -- Show GDB internal variables used by the GDB maintainer
> #maintenance demangle -- Demangle a C++ mangled name
> @@ -82,6 +84,18 @@ gdb_file_cmd ${binfile}
> # program wasn't running.
> gdb_test "maint print registers" "Name.*Nr.*Rel.*Offset.*Size.*Type.*"
>
> +# Test "mt expand-symtabs" here as it's easier to verify before we
> +# run the program.
> +gdb_test_no_output "mt set per on" "mt set per on for expand-symtabs"
> +gdb_test_multiple "mt expand-symtabs $subdir/break\[.\]c$" \
> + "mt expand-symtabs" {
> + -re "#primary symtabs: 1 \\(\[+\]1\\),.*$gdb_prompt $" {
> + # This should expand exactly one (primary) symtab.
> + pass "mt expand-symtabs"
> + }
> + }
> +gdb_test "mt set per off" ".*" "mt set per off for expand-symtabs"
> +
> # Tests that can or should be done with a running program
>
> gdb_load ${binfile}
> @@ -110,20 +124,25 @@ gdb_test_multiple "maint info sections .
> # guo: on linux this command output is huge. for some reason splitting up
> # the regexp checks works.
> #
> -send_gdb "maint check-symtabs\n"
> +send_gdb "maint check-psymtabs\n"
> gdb_expect {
> - -re "^maint check-symtabs" {
> + -re "^maint check-psymtabs" {
> gdb_expect {
> -re "$gdb_prompt $" {
> - pass "maint check-symtabs"
> + pass "maint check-psymtabs"
> }
> - timeout { fail "(timeout) maint check-symtabs" }
> + timeout { fail "(timeout) maint check-psymtabs" }
> }
> }
> - -re ".*$gdb_prompt $" { fail "maint check-symtabs" }
> - timeout { fail "(timeout) maint check-symtabs" }
> + -re ".*$gdb_prompt $" { fail "maint check-psymtabs" }
> + timeout { fail "(timeout) maint check-psymtabs" }
> }
>
> +# This command does not produce any output unless there is some problem
> +# with the symtabs, so that branch will really never be covered in the
> +# tests here!!
> +gdb_test_no_output "maint check-symtabs"
> +
> gdb_test_no_output "maint set per-command on"
>
> gdb_test "maint set per-command off" \
Hi.
Does this need another doc RFA?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs
2013-05-15 15:24 ` Doug Evans
@ 2013-05-15 15:42 ` Eli Zaretskii
0 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2013-05-15 15:42 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
> Date: Wed, 15 May 2013 08:24:24 -0700
> From: Doug Evans <dje@google.com>
>
> Does this need another doc RFA?
I don't think so, not unless you made significant changes since the
last time I reviewed the patch.
^ permalink raw reply [flat|nested] 8+ messages in thread
* new maint.exp FAIL w/-fdebug-types-section [Re: [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs]
2013-05-13 20:21 [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs Doug Evans
2013-05-14 14:19 ` Tom Tromey
2013-05-15 15:24 ` Doug Evans
@ 2013-05-19 11:23 ` Jan Kratochvil
2013-05-20 20:27 ` Doug Evans
2013-05-24 15:50 ` [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs Tom Tromey
3 siblings, 1 reply; 8+ messages in thread
From: Jan Kratochvil @ 2013-05-19 11:23 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
On Mon, 13 May 2013 22:20:59 +0200, Doug Evans wrote:
> +# Test "mt expand-symtabs" here as it's easier to verify before we
> +# run the program.
> +gdb_test_no_output "mt set per on" "mt set per on for expand-symtabs"
> +gdb_test_multiple "mt expand-symtabs $subdir/break\[.\]c$" \
> + "mt expand-symtabs" {
> + -re "#primary symtabs: 1 \\(\[+\]1\\),.*$gdb_prompt $" {
> + # This should expand exactly one (primary) symtab.
> + pass "mt expand-symtabs"
> + }
> + }
> +gdb_test "mt set per off" ".*" "mt set per off for expand-symtabs"
$ runtest CC_FOR_TARGET="gcc -gdwarf-4 -fdebug-types-section -g0" gdb.base/maint.exp
FAIL: gdb.base/maint.exp: mt expand-symtabs
mt expand-symtabs gdb.base/break[.]c$
Command execution time: 0.001000 (cpu), 0.000717 (wall)
Space used: 4292608 (+0 for this command)
#symtabs: 11 (+11), #primary symtabs: 2 (+2), #blocks: 9 (+9)
(gdb) FAIL: gdb.base/maint.exp: mt expand-symtabs
Jan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: new maint.exp FAIL w/-fdebug-types-section [Re: [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs]
2013-05-19 11:23 ` new maint.exp FAIL w/-fdebug-types-section [Re: [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs] Jan Kratochvil
@ 2013-05-20 20:27 ` Doug Evans
0 siblings, 0 replies; 8+ messages in thread
From: Doug Evans @ 2013-05-20 20:27 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
Jan Kratochvil writes:
> On Mon, 13 May 2013 22:20:59 +0200, Doug Evans wrote:
> > +# Test "mt expand-symtabs" here as it's easier to verify before we
> > +# run the program.
> > +gdb_test_no_output "mt set per on" "mt set per on for expand-symtabs"
> > +gdb_test_multiple "mt expand-symtabs $subdir/break\[.\]c$" \
> > + "mt expand-symtabs" {
> > + -re "#primary symtabs: 1 \\(\[+\]1\\),.*$gdb_prompt $" {
> > + # This should expand exactly one (primary) symtab.
> > + pass "mt expand-symtabs"
> > + }
> > + }
> > +gdb_test "mt set per off" ".*" "mt set per off for expand-symtabs"
>
> $ runtest CC_FOR_TARGET="gcc -gdwarf-4 -fdebug-types-section -g0" gdb.base/maint.exp
> FAIL: gdb.base/maint.exp: mt expand-symtabs
>
> mt expand-symtabs gdb.base/break[.]c$
> Command execution time: 0.001000 (cpu), 0.000717 (wall)
> Space used: 4292608 (+0 for this command)
> #symtabs: 11 (+11), #primary symtabs: 2 (+2), #blocks: 9 (+9)
> (gdb) FAIL: gdb.base/maint.exp: mt expand-symtabs
Blech. My normal testing uses .debug_types as a matter of course.
Committed.
2013-05-20 Doug Evans <dje@google.com>
* gdb.base/maint.exp: Fix test for "mt expand-symtabs" to account for
-fdebug-types-section.
diff -u -p -r1.65 maint.exp
--- testsuite/gdb.base/maint.exp 17 May 2013 18:09:06 -0000 1.65
+++ testsuite/gdb.base/maint.exp 20 May 2013 20:19:16 -0000
@@ -89,8 +89,11 @@ gdb_test "maint print registers" "Name.*
gdb_test_no_output "mt set per on" "mt set per on for expand-symtabs"
gdb_test_multiple "mt expand-symtabs $subdir/break\[.\]c$" \
"mt expand-symtabs" {
- -re "#primary symtabs: 1 \\(\[+\]1\\),.*$gdb_prompt $" {
- # This should expand exactly one (primary) symtab.
+ -re "#primary symtabs: (1|2) \\(\[+\](1|2)\\),.*$gdb_prompt $" {
+ # This should expand one or at most two primary symtabs.
+ # "Normally" it will expand just the one for break.c, but if the
+ # file is compiled with -fdebug-types-section then a second primary
+ # symtab for break.c will be created for any types.
pass "mt expand-symtabs"
}
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs
2013-05-13 20:21 [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs Doug Evans
` (2 preceding siblings ...)
2013-05-19 11:23 ` new maint.exp FAIL w/-fdebug-types-section [Re: [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs] Jan Kratochvil
@ 2013-05-24 15:50 ` Tom Tromey
2013-05-30 17:43 ` Tom Tromey
3 siblings, 1 reply; 8+ messages in thread
From: Tom Tromey @ 2013-05-24 15:50 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
>>>>> "Doug" == Doug Evans <dje@google.com> writes:
Doug> +static void
Doug> +maintenance_expand_symtabs (char *args, int from_tty)
Doug> +{
Doug> + struct program_space *pspace;
Doug> + struct objfile *objfile;
Doug> + struct cleanup *cleanups;
Doug> + char **argv;
Doug> + char *regexp = NULL;
Doug> +
Doug> + /* We use buildargv here so that we handle spaces in the regexp
Doug> + in a way that allows adding more arguments later. */
Doug> + argv = gdb_buildargv (args);
Doug> + cleanups = make_cleanup_freeargv (argv);
The cleanup checker noticed that this function doesn't call do_cleanups.
Tom
* symmisc.c (maintenance_expand_symtabs): Call do_cleanups.
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index eb8bbbf..a1ae7bd 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -898,6 +898,8 @@ maintenance_expand_symtabs (char *args, int from_tty)
maintenance_expand_name_matcher, ALL_DOMAIN, regexp);
}
}
+
+ do_cleanups (cleanups);
}
\f
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs
2013-05-24 15:50 ` [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs Tom Tromey
@ 2013-05-30 17:43 ` Tom Tromey
0 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2013-05-30 17:43 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
Tom> * symmisc.c (maintenance_expand_symtabs): Call do_cleanups.
I'm checking this in .
Tom
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-05-30 17:43 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-13 20:21 [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs Doug Evans
2013-05-14 14:19 ` Tom Tromey
2013-05-15 15:24 ` Doug Evans
2013-05-15 15:42 ` Eli Zaretskii
2013-05-19 11:23 ` new maint.exp FAIL w/-fdebug-types-section [Re: [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs] Jan Kratochvil
2013-05-20 20:27 ` Doug Evans
2013-05-24 15:50 ` [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs Tom Tromey
2013-05-30 17:43 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox