From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25053 invoked by alias); 15 May 2013 15:24:28 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 25042 invoked by uid 89); 15 May 2013 15:24:28 -0000 X-Spam-SWARE-Status: No, score=-4.2 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD,SPF_PASS,TW_BJ,TW_RG autolearn=ham version=3.3.1 Received: from mail-ve0-f170.google.com (HELO mail-ve0-f170.google.com) (209.85.128.170) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 15 May 2013 15:24:26 +0000 Received: by mail-ve0-f170.google.com with SMTP id 15so260234vea.1 for ; Wed, 15 May 2013 08:24:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type:x-gm-message-state; bh=C0Wv/Njzq33nnYoJDGLONAoUlXldw9DOMJfbkjZpR6g=; b=nHZYdFJEloFxI0/38DLQw+wFzd+CTMStVWzltgalAtg+tf9rEEXl75tBNeHw5OyJgK nI/5D6lKKgYXfB01Q1eE9t8B8qcmCXZ/H69DSaogWDb2z38Xfg++Lks9036sOVKtdPnI ulT3968bHhOhlRAfN1osgdQSrmQ5WejNnuAw8GGTT5LC3pWBhYiXZUItf8b3AuPAZfHz ui/PLt+MgvBAFE5+cor4a0cSbsqRRTkUj7gdz4mFY+jL4csgIcNUEGktJZe+FvfN5oHP wXlguzTkkpNByLUGz+Ydis4Md44tW3XXVf0Pw3dwWTe0DKaiEldeTZLPtHnq6i0WD1jC bipA== MIME-Version: 1.0 X-Received: by 10.220.71.200 with SMTP id i8mr24889372vcj.44.1368631464554; Wed, 15 May 2013 08:24:24 -0700 (PDT) Received: by 10.220.54.75 with HTTP; Wed, 15 May 2013 08:24:24 -0700 (PDT) In-Reply-To: References: Date: Wed, 15 May 2013 15:24:00 -0000 Message-ID: Subject: Re: [RFA 1/2, doc RFA] maint check-symtabs, maint expand-symtabs From: Doug Evans To: gdb-patches , Eli Zaretskii Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQl7WtU5YzTHpMYBOpSZIL0yQX/+Msdo8at3zUXT58o1aZ/8df3vQlum+7h2CWwdrJo/ByH51LiPRiH1Vd7AhSyJ62X0UD6ysItvlRIx7990YZT+MGKxRgY7qLI+PgypDroMeKejf1cFHquTCIDHJnaHjOesHuPIghcwj78/mkTnLoPeiDgjnIPJTrcpDSppTMcfCptxzRNQBtdSaGLuZvHpcD84BQ== X-SW-Source: 2013-05/txt/msg00535.txt.bz2 On Mon, May 13, 2013 at 1:20 PM, Doug Evans 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 > > * 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?