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 27FE8385B834 for ; Tue, 24 Mar 2020 22:55:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 27FE8385B834 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 45131ACB8; Tue, 24 Mar 2020 22:55:10 +0000 (UTC) Subject: Re: [PATCH][gdb] Print user/includes fields for maint commands To: Simon Marchi , gdb-patches@sourceware.org References: <20200324112241.GA23197@delia> <0e3c47b7-9cec-5efa-c3cf-8bff63042886@simark.ca> <2b576b9e-82c4-a76b-ce54-b6828d1f49af@suse.de> <9dcaf2a7-e591-5a5a-9464-b3913f435700@simark.ca> From: Tom de Vries Autocrypt: addr=tdevries@suse.de; keydata= xsBNBF0ltCcBCADDhsUnMMdEXiHFfqJdXeRvgqSEUxLCy/pHek88ALuFnPTICTwkf4g7uSR7 HvOFUoUyu8oP5mNb4VZHy3Xy8KRZGaQuaOHNhZAT1xaVo6kxjswUi3vYgGJhFMiLuIHdApoc u5f7UbV+egYVxmkvVLSqsVD4pUgHeSoAcIlm3blZ1sDKviJCwaHxDQkVmSsGXImaAU+ViJ5l CwkvyiiIifWD2SoOuFexZyZ7RUddLosgsO0npVUYbl6dEMq2a5ijGF6/rBs1m3nAoIgpXk6P TCKlSWVW6OCneTaKM5C387972qREtiArTakRQIpvDJuiR2soGfdeJ6igGA1FZjU+IsM5ABEB AAHNH1RvbSBkZSBWcmllcyA8dGRldnJpZXNAc3VzZS5kZT7CwKsEEwEIAD4WIQSsnSe5hKbL MK1mGmjuhV2rbOJEoAUCXSW0JwIbAwUJA8JnAAULCQgHAgYVCgkIC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cCKhIoMygPTA3U yGaIvI/BGOtHZ7bEBVUCFDFfOWJ26IOCoPnSVUvKPEOH9dv+sNy7jyBsP5QxeTqwxC/1ZtNS DUCSFQjqA6bEGwM22dP8OUY6SC94x1G81A9/xbtm9LQxKm0EiDH8KBMLfQ== Message-ID: <8831bf74-3132-4a67-30f0-86887bf37865@suse.de> Date: Tue, 24 Mar 2020 23:55:09 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <9dcaf2a7-e591-5a5a-9464-b3913f435700@simark.ca> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-37.2 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 22:55:12 -0000 On 24-03-2020 23:41, Simon Marchi wrote: > On 2020-03-24 6:28 p.m., Tom de Vries wrote: >> On 24-03-2020 18:04, Simon Marchi wrote: >> >> Hi, >> >> thanks for the review, I've followed up on all the comments. >> >> Updated patch attached below. >> >> Thanks, >> - Tom >> >> >> 0001-gdb-Print-user-includes-fields-for-maint-commands.patch >> >> [gdb] Print user/includes fields for maint commands >> >> 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). >> >> gdb/ChangeLog: >> >> 2020-03-24 Tom de Vries >> >> * symtab.h (is_main_symtab_of_compunit_symtab): New function. >> * symmisc.c (dump_symtab_1): Print user and includes fields. >> (maintenance_info_symtabs): Same. >> >> --- >> gdb/symmisc.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++--- >> gdb/symtab.h | 7 +++++++ >> 2 files changed, 56 insertions(+), 3 deletions(-) >> >> diff --git a/gdb/symmisc.c b/gdb/symmisc.c >> index 3df526bddb..6ee1b5edfd 100644 >> --- a/gdb/symmisc.c >> +++ b/gdb/symmisc.c >> @@ -279,8 +279,10 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) >> const struct block *b; >> int depth; >> >> - fprintf_filtered (outfile, "\nSymtab for file %s\n", >> - symtab_to_filename_for_display (symtab)); >> + fprintf_filtered (outfile, "\nSymtab for file %s at %s\n", >> + symtab_to_filename_for_display (symtab), >> + host_address_to_string (symtab)); >> + >> if (SYMTAB_DIRNAME (symtab) != NULL) >> fprintf_filtered (outfile, "Compilation directory is %s\n", >> SYMTAB_DIRNAME (symtab)); >> @@ -308,7 +310,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) >> } >> /* Now print the block info, but only for compunit symtabs since we will >> print lots of duplicate info otherwise. */ >> - if (symtab == COMPUNIT_FILETABS (SYMTAB_COMPUNIT (symtab))) >> + if (is_main_symtab_of_compunit_symtab (symtab)) >> { >> fprintf_filtered (outfile, "\nBlockvector:\n\n"); >> bv = SYMTAB_BLOCKVECTOR (symtab); >> @@ -371,6 +373,28 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) >> "\nBlockvector same as owning compunit: %s\n\n", >> compunit_filename); >> } >> + >> + if (is_main_symtab_of_compunit_symtab (symtab)) >> + { > > Hmm, if this is the exact same condition as the previous `if`, what's the point of > having a separate `if`? > The first if-else covers printing the block info. If we'd merge the if-else and the following if, we'd have: - the true clause related to block info - the code related to user/includes - the false clause related to block info which I find confusing. > Now that I read this code a bit more, I realize that it's written in this way because > it dates from the time where there wasn't a distinction between compunit_symtabs and > symtabs. Nowadays, it would probably be preferable to print the compunit_symtab > information at some level higher, in maintenance_print_symbols. If you want to take the > time to do things right, you can try do to that, otherwise I'm also fine with this > patch (one the question above about the `if` is answered). > Perhaps later, right now I don't feel knowledgeable enough in this area to do refactoring. Thanks, - Tom