From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id B49C03858D38 for ; Wed, 6 Dec 2023 14:38:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B49C03858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B49C03858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701873500; cv=none; b=JWUEti9FyZb00P2LobMs7R49Spw3+nMqS7u1fUB6ZTh6DoOCP7riZ388obZVuPJX1TF0X2FRuX2Mz6LGJeXdsZsVUFreKVGe9RmG0eN7aW8+l9hkCyGLKaxYwy/o7bgX3K84YWzwFrt2KAKSwp7r0DlrRZRZ8xWEaPm7XrdIgcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701873500; c=relaxed/simple; bh=NfpojM5fk6uNmzp4kqb3eSMxJb6WVPAvsv7tGpgXQa4=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=AeFbPxay6raKZoTZK35/OcWWSZoZLHESCPWJYOxljf7K1jUdsPrPIwEaq8yv0RxqwYADdn8+IB9v3j9uF45k5Lt+70aO+7CMO7TYHHsuUNMBSbybT6qya8byN11ywiGD39xvLbwazE8y2zpu+ESONO52yAk7ix6umuqGQlw/Rm4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5FA221FD14; Wed, 6 Dec 2023 14:38:16 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3C393136CD; Wed, 6 Dec 2023 14:38:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id IB1lDViHcGUjOwAAD6G6ig (envelope-from ); Wed, 06 Dec 2023 14:38:16 +0000 Message-ID: <68ec55d5-f8a6-4a79-803b-ea05687ad49f@suse.de> Date: Wed, 6 Dec 2023 15:38:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Start abbrevs at 1 in DWARF assembler Content-Language: en-US To: Tom Tromey , gdb-patches@sourceware.org References: <20231205212306.1438059-1-tom@tromey.com> From: Tom de Vries In-Reply-To: <20231205212306.1438059-1-tom@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spamd-Bar: +++ Authentication-Results: smtp-out2.suse.de; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=suse.de (policy=none); spf=softfail (smtp-out2.suse.de: 2a07:de40:b281:104:10:150:64:97 is neither permitted nor denied by domain of tdevries@suse.de) smtp.mailfrom=tdevries@suse.de X-Rspamd-Server: rspamd2 X-Spamd-Result: default: False [3.87 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%]; MIME_GOOD(-0.10)[text/plain]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; R_SPF_SOFTFAIL(4.60)[~all:c]; NEURAL_SPAM_SHORT(0.07)[0.022]; RCVD_COUNT_THREE(0.00)[3]; MX_GOOD(-0.01)[]; RCPT_COUNT_TWO(0.00)[2]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; DMARC_POLICY_SOFTFAIL(0.10)[suse.de : No valid SPF, No valid DKIM,none] X-Spam-Score: 3.87 X-Rspamd-Queue-Id: 5FA221FD14 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 12/5/23 22:23, Tom Tromey wrote: > I noticed that the DWARF assembler starts abbrevs at 2. > I think 1 should be preferred. Agreed. How about this approach instead: ... diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp index f09da0430ab..0813bbbda09 100644 --- a/gdb/testsuite/lib/dwarf.exp +++ b/gdb/testsuite/lib/dwarf.exp @@ -958,13 +958,21 @@ namespace eval Dwarf { _handle_macro_at_range $attr_value } + # Return the next available abbrev number in the current CU's abbrev + # table. + proc _get_abbrev_num {} { + variable _abbrev_num + set res $_abbrev_num + incr _abbrev_num + return $res + } + proc _handle_DW_TAG {tag_name {attrs {}} {children {}}} { variable _abbrev_section - variable _abbrev_num variable _constants set has_children [expr {[string length $children] > 0}] - set my_abbrev [incr _abbrev_num] + set my_abbrev [_get_abbrev_num] # We somewhat wastefully emit a new abbrev entry for each tag. # There's no reason for this other than laziness. ... The nit I see with the patch you propose is that it sets _abbrev_num to 0, and then claims that 0 is the most recently assigned abbrev number, while it was never assigned. My feeling is that this solution is more intuitive. Thanks, - Tom > --- > gdb/testsuite/lib/dwarf.exp | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp > index f09da0430ab..19c89c048fe 100644 > --- a/gdb/testsuite/lib/dwarf.exp > +++ b/gdb/testsuite/lib/dwarf.exp > @@ -564,8 +564,8 @@ namespace eval Dwarf { > # for Fission. > variable _abbrev_section > > - # The next available abbrev number in the current CU's abbrev > - # table. > + # The most recently assigned abbrev number in the current CU's > + # abbrev table. > variable _abbrev_num > > # The string table for this assembly. The key is the string; the > @@ -1485,7 +1485,7 @@ namespace eval Dwarf { > > set cu_num [incr _cu_count] > set my_abbrevs [_compute_label "abbrev${cu_num}_begin"] > - set _abbrev_num 1 > + set _abbrev_num 0 > > set _cu_label [_compute_label "cu${cu_num}_begin"] > set start_label [_compute_label "cu${cu_num}_start"] > @@ -1597,7 +1597,7 @@ namespace eval Dwarf { > > set cu_num [incr _cu_count] > set my_abbrevs [_compute_label "abbrev${cu_num}_begin"] > - set _abbrev_num 1 > + set _abbrev_num 0 > > set _cu_label [_compute_label "cu${cu_num}_begin"] > set start_label [_compute_label "cu${cu_num}_start"]