From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19020 invoked by alias); 8 May 2013 01:03:04 -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 19009 invoked by uid 89); 8 May 2013 01:03:03 -0000 X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD,SPF_PASS,TW_BJ,TW_EG autolearn=ham version=3.3.1 Received: from mail-qc0-f202.google.com (HELO mail-qc0-f202.google.com) (209.85.216.202) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 08 May 2013 01:03:01 +0000 Received: by mail-qc0-f202.google.com with SMTP id d1so132359qcz.3 for ; Tue, 07 May 2013 18:03:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:date:message-id:from:to:subject:x-gm-message-state; bh=GOq+9Q1QOpPPD/Rhae57SaMCoDGcJnFhnXkoiuPFDWo=; b=Tid4oVpK7bBBwA9n1bAGOJUyoFIpPHkrULsvh2QjKtFNBI99Sb74t8GhNU+tWNAywj Y6euXiYJCPH/j80yrvduKV84Rf9wv01td7jjC3QSO3fejmQV055dB6KbaIt6fKlc1j3f kuraPnrlIR5dLwQ6X9GgfbrZbjQ58Vp1rTwGrHc1bGycKlPNGXVJMOtI6g8AQBLBeq9r 2sRhjOtxU+RrP6oQld4JIUNJ6saBwu1fcipOYftVPshyriMxbJEQrZWkINkN8gMetbQZ 1rLM3c8SeuLTWX7GdPFipnF1zp88HLCqoYq6ModCLCfI97xmWXLapJ0zQxA7OAKOjbWB KwWQ== X-Received: by 10.236.46.50 with SMTP id q38mr2613576yhb.44.1367974980080; Tue, 07 May 2013 18:03:00 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id n78si3221700yhh.1.2013.05.07.18.03.00 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Tue, 07 May 2013 18:03:00 -0700 (PDT) Received: from ruffy2.mtv.corp.google.com (ruffy2.mtv.corp.google.com [172.17.128.107]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id ABAE631C078 for ; Tue, 7 May 2013 18:02:59 -0700 (PDT) Date: Wed, 08 May 2013 01:03:00 -0000 Message-Id: From: Doug Evans To: gdb-patches@sourceware.org Subject: [RFA, doc RFA] Rename "maint check-symtabs" to "maint check-psymtabs" X-Gm-Message-State: ALoCoQn1yYd/du7BFio6nWEY6HSh6lKXntDsiTHMvyXbrZIIgewIg4M91TfVAH4pnoSsgEhht61v+cKrwBnJveWQth88Q3FnmoBw1u7M8hp5zv7g23Zf0nkOpTv0F2NHQuAmtG0lk8VS7AbcQVswsSXtZa0SsqsFlmhQknfPn9txYh59nIwMjaRant4PQKOsUO0jZOYZzNDuICld8drYCETKL+fElRXesykKnNb6gsQd2DyjbtzLheE= X-SW-Source: 2013-05/txt/msg00261.txt.bz2 Hi. While debugging a gdb segv due to a SIGINT arriving while expanding symtabs, I found it useful to have a command that did symtab consistency/ sanity checks. There is already "maint check-symtabs" but it really is "maint check-psymtabs" (e.g., it only loops over all psymtabs). Plus, when debugging gdb I'd like to be able to do "maint check-foo" *without* it changing gdb's state (e.g., resulting in more symtab expansion). So this patch does three things: 1) Rename "maint check-symtabs" to "maint check-psymtabs". 2) Add -n option to "maint check-psymtabs" to prevent symtab expansion. 3) Add "maint check-symtabs". The new "maint check-symtabs" command is pretty minimal at the moment, it only contains what I need at present. We can always add whatever other consistency/sanity checks we want to it in the future. Ok to check in? 2013-05-07 Doug Evans * NEWS: Mention "maint check-symtabs", "maint check-psymtabs". * psymtab.c (maintenance_check_psymtabs): Renamed from maintenance_check_symtabs. Handle -n argument: avoid side effects like symtab expansion. (_initialize_psymtab): Update. * symmisc.c (maintenance_check_symtabs): New function. (_initialize_symmisc): Add "mt check-symtabs" command. doc/ * gdb.texinfo (Maintenance Commands): Update doc for "maint check-psymtabs". Add doc for "maint check-symtabs". Index: NEWS =================================================================== RCS file: /cvs/src/src/gdb/NEWS,v retrieving revision 1.593 diff -u -p -r1.593 NEWS --- NEWS 16 Apr 2013 14:36:53 -0000 1.593 +++ NEWS 8 May 2013 00:50:11 -0000 @@ -6,6 +6,10 @@ * 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. 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.74 diff -u -p -r1.74 psymtab.c --- psymtab.c 6 May 2013 19:15:17 -0000 1.74 +++ psymtab.c 8 May 2013 00:39:56 -0000 @@ -2001,10 +2006,10 @@ maintenance_info_psymtabs (char *regexp, } } -/* Check consistency of psymtabs and symtabs. */ +/* Check consistency of psymtabs vs symtabs. */ static void -maintenance_check_symtabs (char *ignore, int from_tty) +maintenance_check_psymtabs (char *args, int from_tty) { struct symbol *sym; struct partial_symbol **psym; @@ -2014,12 +2019,24 @@ maintenance_check_symtabs (char *ignore, struct objfile *objfile; struct block *b; int length; + int allow_side_effects = 1; + + if (args) + { + if (strcmp (args, "-n") == 0) + allow_side_effects = 0; + else + error (_("Invalid option.")); + } ALL_PSYMTABS (objfile, ps) { struct gdbarch *gdbarch = get_objfile_arch (objfile); - s = psymtab_to_symtab (objfile, ps); + if (allow_side_effects) + s = psymtab_to_symtab (objfile, ps); + else + s = ps->symtab; if (s == NULL) continue; bv = BLOCKVECTOR (s); @@ -2134,7 +2151,11 @@ 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 psymtabs versus symtabs.\n\ +Usage: maint check-psymtabs [-n]\n\ +Options:\n\ + -n Do not cause any side effects such as symtab expansion."), &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 8 May 2013 00:39:57 -0000 @@ -771,6 +771,62 @@ 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"); + } +} /* Return the nexting depth of a block within other blocks in its symtab. */ @@ -819,4 +875,10 @@ 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 symtabs.\n\ +Usage: maint check-symtabs"), + &maintenancelist); } Index: doc/gdb.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v retrieving revision 1.1084 diff -u -p -r1.1084 gdb.texinfo --- doc/gdb.texinfo 29 Apr 2013 17:32:43 -0000 1.1084 +++ doc/gdb.texinfo 8 May 2013 00:39:57 -0000 @@ -35487,9 +35487,16 @@ only if non-stop mode is active (@pxref{ architecture supports displaced stepping. @end table +@kindex maint check-psymtabs +@item maint check-psymtabs [-n] +Check the consistency of psymtabs versus symtabs. +Use this to check, for example, whether a symbol is one but not the other. +If optional parameter @code{-n} is specified, do not do anything +that will have side effects such as expanding symbol tables. + @kindex maint check-symtabs @item maint check-symtabs -Check the consistency of psymtabs and symtabs. +Check the consistency of symtabs. @kindex maint cplus first_component @item maint cplus first_component @var{name}