Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
To: Matthieu Longo <matthieu.longo@arm.com>
Cc: gdb-patches@sourceware.org,  Tom Tromey <tom@tromey.com>,
	 Andrew Burgess <aburgess@redhat.com>
Subject: Re: [PATCH v1] gdb: align siginfo_t with the Linux kernel definition
Date: Wed, 24 Jun 2026 21:45:40 +0000	[thread overview]
Message-ID: <87zf0jwr23.fsf@linaro.org> (raw)
In-Reply-To: <9c509d3f-280f-42d8-b12f-100a3d018f09@arm.com> (Matthieu Longo's message of "Mon, 22 Jun 2026 09:42:06 +0100")

Hello Matthieu,

Sorry for the delay in responding.

Matthieu Longo <matthieu.longo@arm.com> writes:

> On 19/06/2026 11:45, Matthieu Longo wrote:
>> On 19/06/2026 04:58, Thiago Jung Bauermann wrote:
>>>
>>> Matthieu Longo <matthieu.longo@arm.com> writes:
>>>
>>>> GDB's current definition of siginfo_t is missing many fields present in
>>>> the Linux kernel definition [1].
>>>>
>>>> These fields are useful for providing detailed, user-friendly diagnostics
>>>> when a fault occurs. Some new AArch64 extensions, such as Permission
>>>> Overlay Enhancement used to implement Protection Keys [2], require the
>>>> debugger to inspect 'si_pkey' alongside 'si_addr' to help the user identify
>>>> the problematic key.
>>>>
>>>> This patch aligns GDB's definition of the __sifields._sigfault member of
>>>> siginfo_t with the definition from the Linux kernel master branch.
>>>>
>>>> [1]: https://github.com/torvalds/linux/blob/2b414a95b8f7307d42173ba9e580d6
>>>>       d3e2bcbfce/include/uapi/asm-generic/siginfo.h#L69-L100
>>>
>>> Nit: https://github.com/torvalds/linux/ is a mirror. It's better to use
>>> the official address at
>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>>>
>> Fixed.

Thank you for the fixes!

>>>> +  /* used when si_code=SEGV_BNDERR */
>>>> +  type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
>>>> +  append_composite_type_field (type, "_dummy_bnd", short_type);
>>>
>>> The type of _dummy_bnd isn't that important in practice because the
>>> field is just for padding, but its size is wrong AFAICS:
>>>
>>> $ cat siginfo_t.c
>>> #include <stdio.h>
>>> #include <asm/siginfo.h>
>>>
>>> int main (int argc, char *argv[]) {
>>>      siginfo_t siginfo;
>>>
>>>      printf ("sizeof dummy_bnd = %lu\n",
>>>              sizeof(siginfo._sifields._sigfault._addr_bnd._dummy_bnd));
>>>
>>>      return 0;
>>> }
>>> $ make siginfo_t
>>> cc     siginfo_t.c   -o siginfo_t
>>> $ ./siginfo_t
>>> sizeof dummy_bnd = 8
>>>
>> Sorry, I misread the macro __ADDR_BND_PKEY_PAD.
>> 
>>>> +  append_composite_type_field (type, "si_lower", void_ptr_type);
>>>> +  append_composite_type_field (type, "si_upper", void_ptr_type);
>>>> +  append_composite_type_field (sigfault_union_type, "_addr_bnd", type);
>>>> +
>>>> +  /* used when si_code=SEGV_PKUERR */
>>>> +  type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
>>>> +  append_composite_type_field (type, "_dummy_pkey", short_type);
>>>
>>> This one also has the wrong size, because <asm/siginfo.h> uses the same
>>> __ADDR_BND_PKEY_PAD constant for the size of _dummy_bnd and of
>>> _dummy_pkey.
>>>
>> Fixed as follows:
>> diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
>> index 5baad41a083..19289cf4b3f 100644
>> --- a/gdb/linux-tdep.c
>> +++ b/gdb/linux-tdep.c
>> @@ -293,6 +293,13 @@ linux_get_siginfo_type (struct gdbarch *gdbarch)
>>     struct type *uint32_type = builtin_types->builtin_uint32;
>>     void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void);
>> +  /* Compute padding length, i.e. __ADDR_BND_PKEY_PAD.  */
>> +  unsigned alignof_void_ptr = type_align (void_ptr_type);
>> +  unsigned padding_size = (alignof_void_ptr < sizeof(short)
>> +                          ? sizeof(short)
>> +                          : alignof_void_ptr);

Nit: the two lines above are indented with spaces rather than tabs.

The binutils-gdb repo has an .editorconfig file, so one way to make it
easier to follow the project coding style is to make your editor follow
it. Many editors have built-in support for the file, others have plugins
available:

https://editorconfig.org/

> By the way, I forgot to ask.
> Would you prefer me to publish a v2 instead of the diff above ?

Yes, please. Also note that I can't approve this patch. With the above
whitespace issue fixed, you can add to it:

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>

-- 
Thiago
(he/him)

  reply	other threads:[~2026-06-24 21:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-12 10:16 Matthieu Longo
2026-06-12 10:42 ` Matthieu Longo
2026-06-17  6:07   ` Thiago Jung Bauermann
2026-06-17  9:11     ` Matthieu Longo
2026-06-18  3:02       ` Thiago Jung Bauermann
2026-06-18 14:02         ` Matthieu Longo
2026-06-18 16:23           ` Thiago Jung Bauermann
2026-06-19  3:58 ` Thiago Jung Bauermann
2026-06-19 10:45   ` Matthieu Longo
2026-06-22  8:42     ` Matthieu Longo
2026-06-24 21:45       ` Thiago Jung Bauermann [this message]
2026-06-25  9:55         ` Matthieu Longo

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=87zf0jwr23.fsf@linaro.org \
    --to=thiago.bauermann@linaro.org \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=matthieu.longo@arm.com \
    --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