From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 25D46385B836 for ; Tue, 24 Mar 2020 11:22:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 25D46385B836 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 10BE5ADD3 for ; Tue, 24 Mar 2020 11:22:44 +0000 (UTC) Date: Tue, 24 Mar 2020 12:22:42 +0100 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH][gdb] Print user/includes fields for maint commands Message-ID: <20200324112241.GA23197@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-37.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Mar 2020 11:22:46 -0000 Hi, The type struct compunit_symtab contains two fields (disregarding field next) that express relations with other compunit_symtabs: user and includes. These fields are currently not printed with "maint info symtabs" and "maint print symbols". Fix this such that for "maint info symtabs" we print: ... { ((struct compunit_symtab *) 0x23e8450) debugformat DWARF 2 producer (null) dirname (null) blockvector ((struct blockvector *) 0x23e8590) + user ((struct compunit_symtab *) 0x2336280) + ( includes + ((struct compunit_symtab *) 0x23e85e0) + ((struct compunit_symtab *) 0x23e8960) + ) { symtab ((struct symtab *) 0x23e85b0) fullname (null) linetable ((struct linetable *) 0x0) } } ... And for "maint print symbols" we print: ... -Symtab for file +Symtab for file at 0x23e85b0 Read from object file /data/gdb_versions/devel/a.out (0x233ccf0) Language: c Blockvector: block #000, object at 0x23e8530, 0 syms/buckets in 0x0..0x0 block #001, object at 0x23e84d0 under 0x23e8530, 0 syms/buckets in 0x0..0x0 +Compunit user: 0x2336300 +Compunit include: 0x23e8900 +Compunit include: 0x23dd970 ... Note: for user and includes we don't list the actual compunit_symtab address, but instead the corresponding symtab address, which allows us to find that symtab elsewhere in the output (given that we also now print the address of symtabs). OK for trunk? Thanks, - Tom [gdb] Print user/includes fields for maint commands gdb/ChangeLog: 2020-03-24 Tom de Vries * symmisc.c (dump_symtab_1): Print user and includes fields. (maintenance_info_symtabs): Same. --- gdb/symmisc.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 3df526bddb..f7a36905f2 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -279,8 +279,12 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) const struct block *b; int depth; - fprintf_filtered (outfile, "\nSymtab for file %s\n", + fprintf_filtered (outfile, "\nSymtab for file %s", symtab_to_filename_for_display (symtab)); + fprintf_filtered (outfile, " at "); + gdb_print_host_address (symtab, outfile); + fprintf_filtered (outfile, "\n"); + if (SYMTAB_DIRNAME (symtab) != NULL) fprintf_filtered (outfile, "Compilation directory is %s\n", SYMTAB_DIRNAME (symtab)); @@ -371,6 +375,32 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) "\nBlockvector same as owning compunit: %s\n\n", compunit_filename); } + + if (symtab == COMPUNIT_FILETABS (SYMTAB_COMPUNIT (symtab))) + { + struct compunit_symtab *cust = SYMTAB_COMPUNIT (symtab); + + if (cust->user) + { + fprintf_filtered (outfile, "Compunit user: "); + gdb_print_host_address (COMPUNIT_FILETABS (cust->user), outfile); + fprintf_filtered (outfile, "\n"); + } + if (cust->includes) + { + struct compunit_symtab *include; + for (i = 0; ; ++i) + { + include = cust->includes[i]; + if (!include) + break; + fprintf_filtered (outfile, "Compunit include: "); + gdb_print_host_address (COMPUNIT_FILETABS (include), outfile); + fprintf_filtered (outfile, "\n"); + } + } + } + } static void @@ -809,6 +839,30 @@ maintenance_info_symtabs (const char *regexp, int from_tty) " ((struct blockvector *) %s)\n", host_address_to_string (COMPUNIT_BLOCKVECTOR (cust))); + printf_filtered (" user" + " ((struct compunit_symtab *) %s)\n", + cust->user + ? host_address_to_string (cust->user) + : "(null)"); + if (cust->includes) + { + struct compunit_symtab *include; + int i; + + printf_filtered (" ( includes\n"); + for (i = 0; ; ++i) + { + include = cust->includes[i]; + if (!include) + break; + const char *addr + = host_address_to_string (include); + printf_filtered (" (%s %s)\n", + "(struct compunit_symtab *)", + addr); + } + printf_filtered (" )\n"); + } printed_compunit_symtab_start = 1; }