From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 05D71385B834 for ; Tue, 24 Mar 2020 17:04:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 05D71385B834 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 83F221E5F8; Tue, 24 Mar 2020 13:04:50 -0400 (EDT) Subject: Re: [PATCH][gdb] Print user/includes fields for maint commands To: Tom de Vries , gdb-patches@sourceware.org References: <20200324112241.GA23197@delia> From: Simon Marchi Message-ID: <0e3c47b7-9cec-5efa-c3cf-8bff63042886@simark.ca> Date: Tue, 24 Mar 2020 13:04:49 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200324112241.GA23197@delia> Content-Type: text/plain; charset=utf-8 Content-Language: en-US-large Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-28.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, SPF_HELO_PASS, 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 17:04:52 -0000 On 2020-03-24 7:22 a.m., Tom de Vries wrote: > 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"); You could use a single fprintf_filtered call, with host_address_to_string. > + > 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))) I find it hard to understand the intent of this line. Would it be possible to introduce a helper function (probably in symtab.h)? Something like /* Return true if this symtab is the "main" symtab of its compunit_symtab. */ static inline bool is_main_symtab_of_compunit_symtab (struct symtab *symtab) { return symtab == COMPUNIT_FILETABS (SYMTAB_COMPUNIT (symtab)); } > + { > + struct compunit_symtab *cust = SYMTAB_COMPUNIT (symtab); > + > + if (cust->user) != nullptr > + { > + fprintf_filtered (outfile, "Compunit user: "); > + gdb_print_host_address (COMPUNIT_FILETABS (cust->user), outfile); > + fprintf_filtered (outfile, "\n"); Single fprintf_filtered call, with host_address_to_string. > + } > + if (cust->includes) != nullptr > + { > + struct compunit_symtab *include; Declare this within loop, when it's initialized. > + for (i = 0; ; ++i) > + { > + include = cust->includes[i]; > + if (!include) include == nullptr > + break; > + fprintf_filtered (outfile, "Compunit include: "); > + gdb_print_host_address (COMPUNIT_FILETABS (include), outfile); > + fprintf_filtered (outfile, "\n"); Single fprintf_filtered called here too. > + } > + } > + } > + > } > > 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 != nullptr > + ? host_address_to_string (cust->user) > + : "(null)"); > + if (cust->includes) != nullptr > + { > + struct compunit_symtab *include; > + int i; Declare both variables at initialize-time. > + > + printf_filtered (" ( includes\n"); > + for (i = 0; ; ++i) > + { > + include = cust->includes[i]; > + if (!include) include == nullptr Simon