From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tromey@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Convert dw2-const.exp to use the DWARF assembler
Date: Sat, 30 May 2026 10:13:25 +0200 [thread overview]
Message-ID: <bfb24e0d-26d2-4f97-b340-dab5599c8907@suse.de> (raw)
In-Reply-To: <87zf1i45zn.fsf@tromey.com>
On 5/29/26 4:58 PM, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
>
> Tom> Then I ran it with target board unix/-m32, and ran into:
> Tom> ...
> Tom> (gdb) print/x val8^M
> Tom> $2 = 0x0^M
> Tom> (gdb) FAIL: gdb.dwarf2/dw2-const.exp: print/x val8
> Tom> ...
>
> Yeah, me too.
>
> I wonder if there's some gas oddity here. The DWARF doesn't seem to be
> notably weird or word-size-dependent. I see in the old .S:
>
>>> -#if 0 /* gas encodes it explicitly. */
>>> - .slab128 0xffffffff00000000
>>> -#endif
>>> -#if 0 /* gas encoded it correctly - formed GDB FAILed. */
>>> - .sleb128 -4294967296
>>> -#endif
>>> -#if 1 /* Rather encode sleb128 by hand. */
>>> - .byte 0x80, 0x80, 0x80, 0x80, 0x70
>>> -#endif
>
> So hmm.
>
> But maybe this is some kind of extension we would want to support in the
> DWARF assembler.
>
> Anyway still looking into this.
I found the reason for the discrepancy.
Before the patch, with unix/m32, the adress size is 8:
...
Compilation Unit @ offset 0x2df:
Length: 0x6f (32-bit)
Version: 2
Abbrev Offset: 0x1bb
Pointer Size: 8
<0><2ea>: Abbrev Number: 1 (DW_TAG_compile_unit)
<2eb> DW_AT_stmt_list : 0x200
<2ef> DW_AT_name : file1.txt
<2f9> DW_AT_producer : GNU C 3.3.3
<305> DW_AT_language : 1 (ANSI C)
...
After the patch, it's 4.
In dwarf_expr_context::execute_stack_op, we do:
...
case DW_OP_consts:
op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset);
result = offset;
result_val = value_from_ulongest (address_type, result);
break;
...
and if address_type has size 4, result_val is 0.
Thanks,
- Tom
next prev parent reply other threads:[~2026-05-30 8:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 15:55 Tom Tromey
2026-05-23 8:56 ` Tom de Vries
2026-05-29 14:58 ` Tom Tromey
2026-05-30 8:13 ` Tom de Vries [this message]
2026-06-01 15:31 ` 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=bfb24e0d-26d2-4f97-b340-dab5599c8907@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=tromey@adacore.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