public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Start abbrevs at 1 in DWARF assembler
Date: Wed, 6 Dec 2023 15:38:18 +0100	[thread overview]
Message-ID: <68ec55d5-f8a6-4a79-803b-ea05687ad49f@suse.de> (raw)
In-Reply-To: <20231205212306.1438059-1-tom@tromey.com>

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"]


  reply	other threads:[~2023-12-06 14:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-05 21:23 Tom Tromey
2023-12-06 14:38 ` Tom de Vries [this message]
2023-12-06 15:41   ` Tom Tromey
2023-12-06 16:27     ` Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=68ec55d5-f8a6-4a79-803b-ea05687ad49f@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).