From: Tom Tromey <tromey@adacore.com>
To: Andrew Burgess <aburgess@redhat.com>
Cc: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Handle DW_AT_encoding on DW_TAG_enumeration_type
Date: Fri, 15 May 2026 14:33:31 -0600 [thread overview]
Message-ID: <87v7cofm5g.fsf@tromey.com> (raw)
In-Reply-To: <87se7scx26.fsf@redhat.com> (Andrew Burgess's message of "Fri, 15 May 2026 20:06:09 +0100")
>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:
>> First, this is yet another instance of a general problem with DWARF.
>> See https://sourceware.org/bugzilla/show_bug.cgi?id=32680 for the
>> analysis.
Andrew> Should there be a Bug: .... tag for this bug?
Yeah. At first I wasn't sure but see below.
Andrew> I tried running your new test against GDB 17 and can confirm that it
Andrew> fails. But I also tried against GDB 16, and the test passes, and the
Andrew> output looks fine.
Andrew> You commit message seemed (to me) to indicate that you didn't think this
Andrew> should have ever worked, but it looks like something changed 16 to 17
Andrew> that broke this. It would be nice (maybe?) to understand what changed.
I looked into this and I introduced this difference in
commit 5363deffcfb1c1825db3a8446d377a0ad56eff70
Author: Tom Tromey <tromey@adacore.com>
Date: Thu Mar 20 09:52:08 2025 -0600
Use correct sign extension for enumeration types
... without a test, which is disappointing.
Anyway, though, I still think that patch is probably correct, at least
as far as *this* test case is concerned. Consider one of the
enumeration literals, dumped by eu-readelf to show the form:
[ 13b6] enumerator abbrev: 1
name (strp) "value_129"
const_value (data1) 129
"data1" is inherently ambiguous, from DWARF:
The data in DW_FORM_data1, DW_FORM_data2, DW_FORM_data4,
DW_FORM_data8 and DW_FORM_data16 can be anything. Depending on
context, it may be a signed integer, an unsigned integer, a
floating-point constant, or anything else. A consumer must use
context to know how to interpret the bits, which if they are target
machine data (such as an integer or floating-point constant) will be
in target machine byte order.
... which is the aforementioned bug.
Now, we could change update_enumeration_type_from_children to also
examine the attribute forms, with the idea that if we see DW_FORM_sdata
then it is definitely signed. While that wouldn't help this particular
test, it's possible to construct one where it does. In fact I happened
recently to be investigating this for gnat-llvm, where there's a type:
[ 10cf] enumeration_type abbrev: 21
name (strp) "tag_t"
byte_size (data1) 1
decl_file (data1) p.adb (1)
decl_line (data1) 20
alignment (udata) 1
...
[ 10de] enumerator abbrev: 22
name (strp) "object"
const_value (sdata) 18446744073709551615 (-1)
Here the enumeration type doesn't specify a sign, but there's a constant
that is clearly signed. FWIW this occurs in array_of_variant.exp.
I'll address this in a separate patch.
Tom
next prev parent reply other threads:[~2026-05-15 20:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-13 14:27 Tom Tromey
2026-05-15 19:06 ` Andrew Burgess
2026-05-15 20:33 ` Tom Tromey [this message]
2026-05-16 11:13 ` Andrew Burgess
2026-05-18 15:29 ` Tom Tromey
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=87v7cofm5g.fsf@tromey.com \
--to=tromey@adacore.com \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
/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