Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH v2] gdb: align siginfo_t with the Linux kernel definition
@ 2026-06-25 19:39 Matthieu Longo
  2026-06-27  7:13 ` Thiago Jung Bauermann
  0 siblings, 1 reply; 4+ messages in thread
From: Matthieu Longo @ 2026-06-25 19:39 UTC (permalink / raw)
  To: gdb-patches
  Cc: Thiago Jung Bauermann, Tom Tromey, Andrew Burgess, Matthieu Longo

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://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
     tree/include/uapi/asm-generic/siginfo.h#n69
[2]: https://lore.kernel.org/all/20160212210213.ABC488FA@viggo.jf.intel.com/

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
---
 gdb/linux-tdep.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 44 insertions(+), 2 deletions(-)

diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index a7381677498..19289cf4b3f 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -275,7 +275,7 @@ linux_get_siginfo_type (struct gdbarch *gdbarch)
   struct type *void_ptr_type;
   struct type *uid_type, *pid_type;
   struct type *sigval_type, *clock_type;
-  struct type *siginfo_type, *sifields_type;
+  struct type *siginfo_type, *sifields_type, *sigfault_union_type;
   struct type *type;
 
   linux_gdbarch_data = get_linux_gdbarch_data (gdbarch);
@@ -285,11 +285,21 @@ linux_get_siginfo_type (struct gdbarch *gdbarch)
   type_allocator alloc (gdbarch);
 
   const struct builtin_type *builtin_types = builtin_type (gdbarch);
+  struct type *short_type = builtin_types->builtin_short;
   struct type *int_type = builtin_types->builtin_int;
   struct type *uint_type = builtin_types->builtin_unsigned_int;
   struct type *long_type = builtin_types->builtin_long;
+  struct type *unsigned_long_type = builtin_types->builtin_unsigned_long;
+  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);
+  struct type *addr_bnd_pkey_padding_type
+    = init_vector_type (builtin_types->builtin_uint8, padding_size);
 
   /* sival_t */
   sigval_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
@@ -364,9 +374,41 @@ linux_get_siginfo_type (struct gdbarch *gdbarch)
   append_composite_type_field (type, "si_stime", clock_type);
   append_composite_type_field (sifields_type, "_sigchld", type);
 
-  /* _sigfault */
+  /* Begin _sigfault's anonymous union.  */
+  sigfault_union_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
+  /* used on alpha and sparc */
+  append_composite_type_field (sigfault_union_type, "si_trapno", int_type);
+  /* used when si_code=BUS_MCEERR_AR or used when si_code=BUS_MCEERR_AO */
+  append_composite_type_field (sigfault_union_type, "si_addr_lsb", short_type);
+
+  /* used when si_code=SEGV_BNDERR */
+  type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+  append_composite_type_field (type, "_dummy_bnd", addr_bnd_pkey_padding_type);
+  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", addr_bnd_pkey_padding_type);
+  append_composite_type_field (type, "si_pkey", uint32_type);
+  append_composite_type_field (sigfault_union_type, "_addr_pkey", type);
+
+  /* used when si_code=TRAP_PERF */
+  type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+  append_composite_type_field (type, "si_perf_data", unsigned_long_type);
+  append_composite_type_field (type, "si_perf_type", uint32_type);
+  append_composite_type_field (type, "si_perf_flags", uint32_type);
+  append_composite_type_field (sigfault_union_type, "_perf", type);
+
+  /* End _sigfault's anonymous union.  */
+
+  /* _sigfault is set by SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */
   type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
   append_composite_type_field (type, "si_addr", void_ptr_type);
+  /* Since there is no possiblity to declare an anonymous union,
+     using '_' instead.  */
+  append_composite_type_field (type, "_", sigfault_union_type);
   append_composite_type_field (sifields_type, "_sigfault", type);
 
   /* _sigpoll */
-- 
2.54.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] gdb: align siginfo_t with the Linux kernel definition
  2026-06-25 19:39 [PATCH v2] gdb: align siginfo_t with the Linux kernel definition Matthieu Longo
@ 2026-06-27  7:13 ` Thiago Jung Bauermann
  2026-06-29  9:56   ` Matthieu Longo
  0 siblings, 1 reply; 4+ messages in thread
From: Thiago Jung Bauermann @ 2026-06-27  7:13 UTC (permalink / raw)
  To: Matthieu Longo; +Cc: gdb-patches, Tom Tromey, Andrew Burgess

Hello Matthieu,

Sorry, I just noticed one small nit now:

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

> +  /* End _sigfault's anonymous union.  */
> +
> +  /* _sigfault is set by SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */
>    type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
>    append_composite_type_field (type, "si_addr", void_ptr_type);
> +  /* Since there is no possiblity to declare an anonymous union,

Typo: possiblity

No need to send a v3 just because of this. You can adjust this locally
before committing if this version is approved.

> +     using '_' instead.  */
> +  append_composite_type_field (type, "_", sigfault_union_type);
>    append_composite_type_field (sifields_type, "_sigfault", type);
>  
>    /* _sigpoll */

-- 
Thiago
(he/him)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] gdb: align siginfo_t with the Linux kernel definition
  2026-06-27  7:13 ` Thiago Jung Bauermann
@ 2026-06-29  9:56   ` Matthieu Longo
  2026-07-01  5:28     ` Thiago Jung Bauermann
  0 siblings, 1 reply; 4+ messages in thread
From: Matthieu Longo @ 2026-06-29  9:56 UTC (permalink / raw)
  To: Thiago Jung Bauermann; +Cc: gdb-patches, Tom Tromey, Andrew Burgess

On 27/06/2026 08:13, Thiago Jung Bauermann wrote:
> Hello Matthieu,
> 
> Sorry, I just noticed one small nit now:
> 
> Matthieu Longo <matthieu.longo@arm.com> writes:
> 
>> +  /* End _sigfault's anonymous union.  */
>> +
>> +  /* _sigfault is set by SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */
>>    type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
>>    append_composite_type_field (type, "si_addr", void_ptr_type);
>> +  /* Since there is no possiblity to declare an anonymous union,
> 
> Typo: possiblity
> 
> No need to send a v3 just because of this. You can adjust this locally
> before committing if this version is approved.
> 
>> +     using '_' instead.  */
>> +  append_composite_type_field (type, "_", sigfault_union_type);
>>    append_composite_type_field (sifields_type, "_sigfault", type);
>>  
>>    /* _sigpoll */
> 

Fixed locally.
Thanks.

Do you know by any chance of a specific maintainer that should be tagged to review this patch ?
Are the people in copy the right ones ?

Matthieu

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] gdb: align siginfo_t with the Linux kernel definition
  2026-06-29  9:56   ` Matthieu Longo
@ 2026-07-01  5:28     ` Thiago Jung Bauermann
  0 siblings, 0 replies; 4+ messages in thread
From: Thiago Jung Bauermann @ 2026-07-01  5:28 UTC (permalink / raw)
  To: Matthieu Longo; +Cc: gdb-patches, Tom Tromey, Andrew Burgess

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

> Do you know by any chance of a specific maintainer that should be tagged to review this
> patch ?

We don't have a maintainer specifically for the Linux target. My
understanding is that this patch needs to be approved by a global maintainer.

> Are the people in copy the right ones ?

Yes, they're global maintainers.

If there's no additional review after one or two weeks, it's fine to
ping the patch.

Alternatively, you can post a v3 with the typo fix. It then becomes easy
for them to notice that there's no reply to the patch and it needs
review.

-- 
Thiago
(he/him)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-07-01  5:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-25 19:39 [PATCH v2] gdb: align siginfo_t with the Linux kernel definition Matthieu Longo
2026-06-27  7:13 ` Thiago Jung Bauermann
2026-06-29  9:56   ` Matthieu Longo
2026-07-01  5:28     ` Thiago Jung Bauermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox