Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH v3] gdb: align siginfo_t with the Linux kernel definition
@ 2026-07-02 16:52 Matthieu Longo
  2026-07-08 15:54 ` Matthieu Longo
  2026-07-21 21:09 ` Luis
  0 siblings, 2 replies; 12+ messages in thread
From: Matthieu Longo @ 2026-07-02 16:52 UTC (permalink / raw)
  To: gdb-patches
  Cc: Thiago Jung Bauermann, Luis Machado, Luis Machado, 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..d5b0e6e7011 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 possibility 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.55.0


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

* Re: [PATCH v3] gdb: align siginfo_t with the Linux kernel definition
  2026-07-02 16:52 [PATCH v3] gdb: align siginfo_t with the Linux kernel definition Matthieu Longo
@ 2026-07-08 15:54 ` Matthieu Longo
  2026-07-21  9:17   ` Matthieu Longo
  2026-07-21 21:09 ` Luis
  1 sibling, 1 reply; 12+ messages in thread
From: Matthieu Longo @ 2026-07-08 15:54 UTC (permalink / raw)
  To: gdb-patches
  Cc: Thiago Jung Bauermann, Luis Machado, Luis Machado, Tom Tromey,
	Andrew Burgess

On 02/07/2026 17:52, Matthieu Longo wrote:
> 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>
> ---
Ping

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

* Re: [PATCH v3] gdb: align siginfo_t with the Linux kernel definition
  2026-07-08 15:54 ` Matthieu Longo
@ 2026-07-21  9:17   ` Matthieu Longo
  2026-07-21  9:23     ` Luis
  0 siblings, 1 reply; 12+ messages in thread
From: Matthieu Longo @ 2026-07-21  9:17 UTC (permalink / raw)
  To: Thiago Jung Bauermann
  Cc: Luis Machado, Luis Machado, Tom Tromey, Andrew Burgess, gdb-patches

On 08/07/2026 16:54, Matthieu Longo wrote:
> On 02/07/2026 17:52, Matthieu Longo wrote:
>> 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>
>> ---
> Ping

Hi Thiago,

Please can you advise ?
I haven't manage to get any approval from maintainers up until now.

Matthieu

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

* Re: [PATCH v3] gdb: align siginfo_t with the Linux kernel definition
  2026-07-21  9:17   ` Matthieu Longo
@ 2026-07-21  9:23     ` Luis
  0 siblings, 0 replies; 12+ messages in thread
From: Luis @ 2026-07-21  9:23 UTC (permalink / raw)
  To: Matthieu Longo
  Cc: Thiago Jung Bauermann, Luis Machado, Tom Tromey, Andrew Burgess,
	gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1319 bytes --]

Hi Matthieu,

Bear with me as I go through this one and I can share some feedback/updates.

On Tue, Jul 21, 2026, 10:19 Matthieu Longo <matthieu.longo@arm.com> wrote:

> On 08/07/2026 16:54, Matthieu Longo wrote:
> > On 02/07/2026 17:52, Matthieu Longo wrote:
> >> 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>
> >> ---
> > Ping
>
> Hi Thiago,
>
> Please can you advise ?
> I haven't manage to get any approval from maintainers up until now.
>
> Matthieu
>

[-- Attachment #2: Type: text/html, Size: 2217 bytes --]

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

* Re: [PATCH v3] gdb: align siginfo_t with the Linux kernel definition
  2026-07-02 16:52 [PATCH v3] gdb: align siginfo_t with the Linux kernel definition Matthieu Longo
  2026-07-08 15:54 ` Matthieu Longo
@ 2026-07-21 21:09 ` Luis
  2026-07-22 15:00   ` Matthieu Longo
  1 sibling, 1 reply; 12+ messages in thread
From: Luis @ 2026-07-21 21:09 UTC (permalink / raw)
  To: Matthieu Longo, gdb-patches
  Cc: Thiago Jung Bauermann, Luis Machado, Tom Tromey, Andrew Burgess

On 02/07/2026 17:52, Matthieu Longo wrote:
> 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..d5b0e6e7011 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);

Nit: Blank line here for cleanliness.

> +  /* 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)

Logic: Are we mixing host-side sizeof (short) with target-side 
type_align (void_ptr_type) here?

Formatting: Space between sizeof and parens. Multiple cases of this one.

> +			   ? 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 */

Nit: Odd phrase. Maybe rewrite as...

"used when si_code is BUS_MCEERR_AR or 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 possibility to declare an anonymous union,
> +     using '_' instead.  */
> +  append_composite_type_field (type, "_", sigfault_union_type);

Could we name this in a better way? Simply using _ is a bit strange.

>     append_composite_type_field (sifields_type, "_sigfault", type);
>   
>     /* _sigpoll */

Do we need to add some extra tests to validate that gdb can read these 
new fields?

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

* Re: [PATCH v3] gdb: align siginfo_t with the Linux kernel definition
  2026-07-21 21:09 ` Luis
@ 2026-07-22 15:00   ` Matthieu Longo
  2026-07-22 23:09     ` Luis
  0 siblings, 1 reply; 12+ messages in thread
From: Matthieu Longo @ 2026-07-22 15:00 UTC (permalink / raw)
  To: Luis, gdb-patches
  Cc: Thiago Jung Bauermann, Luis Machado, Tom Tromey, Andrew Burgess,
	Srinath Parvathaneni

On 21/07/2026 22:09, Luis wrote:
> On 02/07/2026 17:52, Matthieu Longo wrote:
>> 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..d5b0e6e7011 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);
> 
> Nit: Blank line here for cleanliness.
> 

Fixed.

>> +  /* 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)
> 
> Logic: Are we mixing host-side sizeof (short) with target-side type_align (void_ptr_type) here?
> 

Yes, you're right. Sorry, I missed that. The below should be better.

--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -295,8 +295,8 @@ linux_get_siginfo_type (struct gdbarch *gdbarch)

   /* 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)
+  unsigned padding_size = (alignof_void_ptr < short_type->length ()
+                          ? short_type->length ()
                           : alignof_void_ptr);
   struct type *addr_bnd_pkey_padding_type
     = init_vector_type (builtin_types->builtin_uint8, padding_size);

> Formatting: Space between sizeof and parens. Multiple cases of this one.
> 
>> +               ? 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 */
> 
> Nit: Odd phrase. Maybe rewrite as...
> 
> "used when si_code is BUS_MCEERR_AR or BUS_MCEERR_AO"
> 

Fixed.

>> +  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 possibility to declare an anonymous union,
>> +     using '_' instead.  */
>> +  append_composite_type_field (type, "_", sigfault_union_type);
> 
> Could we name this in a better way? Simply using _ is a bit strange.
> 

What about "_union" ?

>>     append_composite_type_field (sifields_type, "_sigfault", type);
>>       /* _sigpoll */
> 
> Do we need to add some extra tests to validate that gdb can read these new fields?

Indeed, I can add some, but I would like to avoid adding a test for all the new fields.
Can we stick with the original purpose of this change, i.e. adding si_pkey ?

diff --git a/gdb/testsuite/gdb.base/siginfo-obj.c b/gdb/testsuite/gdb.base/siginfo-obj.c
index 43dc979bc50..960e5b8e9cd 100644
--- a/gdb/testsuite/gdb.base/siginfo-obj.c
+++ b/gdb/testsuite/gdb.base/siginfo-obj.c
@@ -35,6 +35,7 @@ handler (int sig, siginfo_t *info, void *context)
   int ssi_signo = info->si_signo;
   int ssi_code = info->si_code;
   void *ssi_addr = info->si_addr;
+  unsigned int ssi_pkey = info->si_pkey;

   _exit (0); /* set breakpoint here */
 }
diff --git a/gdb/testsuite/gdb.base/siginfo-obj.exp b/gdb/testsuite/gdb.base/siginfo-obj.exp
index a94bf0e33ba..6c43d30b7b8 100644
--- a/gdb/testsuite/gdb.base/siginfo-obj.exp
+++ b/gdb/testsuite/gdb.base/siginfo-obj.exp
@@ -78,6 +78,14 @@ gdb_test_multiple "p \$_siginfo" "$test" {
     }
 }

+set test "extract si_pkey"
+gdb_test_multiple "p \$_siginfo" "$test" {
+    -re "si_pkey = (\[0-9\]\+).*$gdb_prompt $" {
+       set ssi_pkey $expect_out(1,string)
+       pass "$test"
+    }
+}
+
 set bp_location [gdb_get_line_number "set breakpoint here"]

 with_test_prefix "validate siginfo fields" {
@@ -87,6 +95,7 @@ with_test_prefix "validate siginfo fields" {
     gdb_test "p ssi_errno" " = $ssi_errno"
     gdb_test "p ssi_code" " = $ssi_code"
     gdb_test "p ssi_signo" " = $ssi_signo"
+    gdb_test "p ssi_pkey" " = $ssi_pkey"
 }

 # Again, but this time, patch si_addr and check that the inferior sees
@@ -106,6 +115,7 @@ gdb_test "p \$_siginfo._sifields._sigfault.si_addr = 0x666" " = \\(void \\*\\) 0
 gdb_test "p \$_siginfo.si_errno = 666" " = 666"
 gdb_test "p \$_siginfo.si_code = 999" " = 999"
 gdb_test "p \$_siginfo.si_signo = 11" " = 11"
+gdb_test "p \$_siginfo._sifields._sigfault._union._addr_pkey.si_pkey = 123" " = 123"

 with_test_prefix "validate modified siginfo fields" {
     gdb_test "break $bp_location"
@@ -114,6 +124,7 @@ with_test_prefix "validate modified siginfo fields" {
     gdb_test "p ssi_errno" " = 666"
     gdb_test "p ssi_code" " = 999"
     gdb_test "p ssi_signo" " = 11"
+    gdb_test "p ssi_pkey" " = 123"
 }

 # Test siginfo preservation in core files.
@@ -132,4 +143,7 @@ if {$gcore_created} {
     gdb_test "p \$_siginfo._sifields._sigfault.si_addr" \
        " = \\(void \\*\\) $ssi_addr" \
        "p \$_siginfo._sifields._sigfault.si_addr from core file"
+    gdb_test "p \$_siginfo._sifields._sigfault._union._addr_pkey.si_pkey" \
+       " = $ssi_pkey" \
+       "p \$_siginfo._sifields._sigfault._union._addr_pkey.si_pkey from core file"
 }


Matthieu

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

* Re: [PATCH v3] gdb: align siginfo_t with the Linux kernel definition
  2026-07-22 15:00   ` Matthieu Longo
@ 2026-07-22 23:09     ` Luis
  2026-07-24  9:18       ` Matthieu Longo
  0 siblings, 1 reply; 12+ messages in thread
From: Luis @ 2026-07-22 23:09 UTC (permalink / raw)
  To: Matthieu Longo, gdb-patches
  Cc: Thiago Jung Bauermann, Luis Machado, Tom Tromey, Andrew Burgess,
	Srinath Parvathaneni

Hi Matthieu,

On 22/07/2026 16:00, Matthieu Longo wrote:
> On 21/07/2026 22:09, Luis wrote:
>> On 02/07/2026 17:52, Matthieu Longo wrote:
>>> 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..d5b0e6e7011 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);
>>
>> Nit: Blank line here for cleanliness.
>>
> 
> Fixed.
> 
>>> +  /* 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)
>>
>> Logic: Are we mixing host-side sizeof (short) with target-side type_align (void_ptr_type) here?
>>
> 
> Yes, you're right. Sorry, I missed that. The below should be better.
> 
> --- a/gdb/linux-tdep.c
> +++ b/gdb/linux-tdep.c
> @@ -295,8 +295,8 @@ linux_get_siginfo_type (struct gdbarch *gdbarch)
> 
>     /* 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)
> +  unsigned padding_size = (alignof_void_ptr < short_type->length ()
> +                          ? short_type->length ()
>                             : alignof_void_ptr);
>     struct type *addr_bnd_pkey_padding_type
>       = init_vector_type (builtin_types->builtin_uint8, padding_size);
> 
>> Formatting: Space between sizeof and parens. Multiple cases of this one.
>>
>>> +               ? 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 */
>>
>> Nit: Odd phrase. Maybe rewrite as...
>>
>> "used when si_code is BUS_MCEERR_AR or BUS_MCEERR_AO"
>>
> 
> Fixed.
> 
>>> +  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 possibility to declare an anonymous union,
>>> +     using '_' instead.  */
>>> +  append_composite_type_field (type, "_", sigfault_union_type);
>>
>> Could we name this in a better way? Simply using _ is a bit strange.
>>
> 
> What about "_union" ?
> 

Naming is hard. Given it is an anonymous union, should it have something 
anonymous in the name?

If we're going to access this by hand, it might be worth having some 
easy to use too.

>>>      append_composite_type_field (sifields_type, "_sigfault", type);
>>>        /* _sigpoll */
>>
>> Do we need to add some extra tests to validate that gdb can read these new fields?
> 
> Indeed, I can add some, but I would like to avoid adding a test for all the new fields.
> Can we stick with the original purpose of this change, i.e. adding si_pkey ?
> 

Sure. I'm fine with having the proper coverage as a follow up patch. But 
it would be nice to at least have the coverage for what you plan to use, 
like si_pkey.

> diff --git a/gdb/testsuite/gdb.base/siginfo-obj.c b/gdb/testsuite/gdb.base/siginfo-obj.c
> index 43dc979bc50..960e5b8e9cd 100644
> --- a/gdb/testsuite/gdb.base/siginfo-obj.c
> +++ b/gdb/testsuite/gdb.base/siginfo-obj.c
> @@ -35,6 +35,7 @@ handler (int sig, siginfo_t *info, void *context)
>     int ssi_signo = info->si_signo;
>     int ssi_code = info->si_code;
>     void *ssi_addr = info->si_addr;
> +  unsigned int ssi_pkey = info->si_pkey;
> 
>     _exit (0); /* set breakpoint here */
>   }
> diff --git a/gdb/testsuite/gdb.base/siginfo-obj.exp b/gdb/testsuite/gdb.base/siginfo-obj.exp
> index a94bf0e33ba..6c43d30b7b8 100644
> --- a/gdb/testsuite/gdb.base/siginfo-obj.exp
> +++ b/gdb/testsuite/gdb.base/siginfo-obj.exp
> @@ -78,6 +78,14 @@ gdb_test_multiple "p \$_siginfo" "$test" {
>       }
>   }
> 
> +set test "extract si_pkey"
> +gdb_test_multiple "p \$_siginfo" "$test" {
> +    -re "si_pkey = (\[0-9\]\+).*$gdb_prompt $" {
> +       set ssi_pkey $expect_out(1,string)
> +       pass "$test"
> +    }
> +}
> +
>   set bp_location [gdb_get_line_number "set breakpoint here"]
> 
>   with_test_prefix "validate siginfo fields" {
> @@ -87,6 +95,7 @@ with_test_prefix "validate siginfo fields" {
>       gdb_test "p ssi_errno" " = $ssi_errno"
>       gdb_test "p ssi_code" " = $ssi_code"
>       gdb_test "p ssi_signo" " = $ssi_signo"
> +    gdb_test "p ssi_pkey" " = $ssi_pkey"
>   }
> 
>   # Again, but this time, patch si_addr and check that the inferior sees
> @@ -106,6 +115,7 @@ gdb_test "p \$_siginfo._sifields._sigfault.si_addr = 0x666" " = \\(void \\*\\) 0
>   gdb_test "p \$_siginfo.si_errno = 666" " = 666"
>   gdb_test "p \$_siginfo.si_code = 999" " = 999"
>   gdb_test "p \$_siginfo.si_signo = 11" " = 11"
> +gdb_test "p \$_siginfo._sifields._sigfault._union._addr_pkey.si_pkey = 123" " = 123"
> 
>   with_test_prefix "validate modified siginfo fields" {
>       gdb_test "break $bp_location"
> @@ -114,6 +124,7 @@ with_test_prefix "validate modified siginfo fields" {
>       gdb_test "p ssi_errno" " = 666"
>       gdb_test "p ssi_code" " = 999"
>       gdb_test "p ssi_signo" " = 11"
> +    gdb_test "p ssi_pkey" " = 123"
>   }
> 
>   # Test siginfo preservation in core files.
> @@ -132,4 +143,7 @@ if {$gcore_created} {
>       gdb_test "p \$_siginfo._sifields._sigfault.si_addr" \
>          " = \\(void \\*\\) $ssi_addr" \
>          "p \$_siginfo._sifields._sigfault.si_addr from core file"
> +    gdb_test "p \$_siginfo._sifields._sigfault._union._addr_pkey.si_pkey" \
> +       " = $ssi_pkey" \
> +       "p \$_siginfo._sifields._sigfault._union._addr_pkey.si_pkey from core file"
>   }
> 
> 
> Matthieu


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

* Re: [PATCH v3] gdb: align siginfo_t with the Linux kernel definition
  2026-07-22 23:09     ` Luis
@ 2026-07-24  9:18       ` Matthieu Longo
  2026-07-24  9:42         ` Matthieu Longo
  2026-07-25  7:46         ` Luis
  0 siblings, 2 replies; 12+ messages in thread
From: Matthieu Longo @ 2026-07-24  9:18 UTC (permalink / raw)
  To: Luis, gdb-patches
  Cc: Thiago Jung Bauermann, Luis Machado, Tom Tromey, Andrew Burgess,
	Srinath Parvathaneni

On 23/07/2026 00:09, Luis wrote:
> Hi Matthieu,
> 
> On 22/07/2026 16:00, Matthieu Longo wrote:
>> On 21/07/2026 22:09, Luis wrote:
>>> On 02/07/2026 17:52, Matthieu Longo wrote:
>> --- a/gdb/linux-tdep.c
>> +++ b/gdb/linux-tdep.c
>>>> +  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 possibility to declare an anonymous union,
>>>> +     using '_' instead.  */
>>>> +  append_composite_type_field (type, "_", sigfault_union_type);
>>>
>>> Could we name this in a better way? Simply using _ is a bit strange.
>>>
>>
>> What about "_union" ?
>>
> 
> Naming is hard. Given it is an anonymous union, should it have something anonymous in the name?
> 

I understand your point, but the name is going to start getting very lengthy.
What about "_anon_union" ?

> If we're going to access this by hand, it might be worth having some easy to use too.
> 

What type of accessors do you have in mind ? Compile-time ones ? Or runtime ones at the destination
of the GDB users when accessing _siginfo ?

For the compile-time ones, I propose to add those defines:

diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index f11eccc1bc1..1a03e6897d6 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -2689,7 +2689,7 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch,
       si_errno = parse_and_eval_long ("$_siginfo.si_errno");

       fault_addr
-       = parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr");
+       = parse_and_eval_long ("$_siginfo."si_addr);
     }
   catch (const gdb_exception_error &exception)
     {
diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h
index c19839fde2c..f739cc69111 100644
--- a/gdb/linux-tdep.h
+++ b/gdb/linux-tdep.h
@@ -98,4 +98,18 @@ extern CORE_ADDR linux_get_hwcap2 ();
 extern bool linux_address_in_shadow_stack_mem_range
   (CORE_ADDR addr, std::pair<CORE_ADDR, CORE_ADDR> *range);

+/* How the fields from siginfo_t's _sigfault can be accessed.  */
+#ifdef si_addr
+#error "Matthieu: this should not happen"
+#endif
+#define si_addr       "_sifields._sigfault.si_addr"
+#define si_trapno     "_sifields._sigfault._anon_union.si_trapno"
+#define si_addr_lsb   "_sifields._sigfault._anon_union.si_addr_lsb"
+#define si_lower      "_sifields._sigfault._anon_union._addr_bnd.si_lower"
+#define si_upper      "_sifields._sigfault._anon_union._addr_bnd.si_upper"
+#define si_pkey       "_sifields._sigfault._anon_union._addr_pkey.si_pkey"
+#define si_perf_data  "_sifields._sigfault._anon_union._perf.si_perf_data"
+#define si_perf_type  "_sifields._sigfault._anon_union._perf.si_perf_type"
+#define si_perf_flags "_sifields._sigfault._anon_union._perf.si_perf_flags"
+
 #endif /* GDB_LINUX_TDEP_H */
diff --git a/gdb/testsuite/gdb.base/siginfo-obj.exp b/gdb/testsuite/gdb.base/siginfo-obj.exp
index 6c43d30b7b8..5e36b334068 100644
--- a/gdb/testsuite/gdb.base/siginfo-obj.exp
+++ b/gdb/testsuite/gdb.base/siginfo-obj.exp
@@ -115,7 +115,7 @@ gdb_test "p \$_siginfo._sifields._sigfault.si_addr = 0x666" " = \\(void \\*\\) 0
 gdb_test "p \$_siginfo.si_errno = 666" " = 666"
 gdb_test "p \$_siginfo.si_code = 999" " = 999"
 gdb_test "p \$_siginfo.si_signo = 11" " = 11"
-gdb_test "p \$_siginfo._sifields._sigfault._union._addr_pkey.si_pkey = 123" " = 123"
+gdb_test "p \$_siginfo._sifields._sigfault._anon_union._addr_pkey.si_pkey = 123" " = 123"

 with_test_prefix "validate modified siginfo fields" {
     gdb_test "break $bp_location"
@@ -143,7 +143,7 @@ if {$gcore_created} {
     gdb_test "p \$_siginfo._sifields._sigfault.si_addr" \
        " = \\(void \\*\\) $ssi_addr" \
        "p \$_siginfo._sifields._sigfault.si_addr from core file"
-    gdb_test "p \$_siginfo._sifields._sigfault._union._addr_pkey.si_pkey" \
+    gdb_test "p \$_siginfo._sifields._sigfault._anon_union._addr_pkey.si_pkey" \
        " = $ssi_pkey" \
-       "p \$_siginfo._sifields._sigfault._union._addr_pkey.si_pkey from core file"
+       "p \$_siginfo._sifields._sigfault._anon_union._addr_pkey.si_pkey from core file"
 }

>>>>      append_composite_type_field (sifields_type, "_sigfault", type);
>>>>        /* _sigpoll */
>>>
>>> Do we need to add some extra tests to validate that gdb can read these new fields?
>>
>> Indeed, I can add some, but I would like to avoid adding a test for all the new fields.
>> Can we stick with the original purpose of this change, i.e. adding si_pkey ?
>>
> 
> Sure. I'm fine with having the proper coverage as a follow up patch. But it would be nice to at
> least have the coverage for what you plan to use, like si_pkey.
> 

The proper coverage is not easy. The test gdb/testsuite/gdb.base/siginfo-obj.exp relies on
definitions of those fields via the glibc header <signal.h>. It creates local variables that GDB can
print to test the values. Since the definitions of siginfo_t are not aligned, and some fields are
missing, I don't think there is an easy way to do a full coverage.

I propose to add a few fields from the anonymous union, like si_pkey, and the rest should implicitly
work if si_pkey works.

PS: I will publish a new revision once I get your confirmation about the naming, the compile-time
accessors and whether I need to implement runtime accessors.
For those last ones, please point me into the right direction for the implementation.

Matthieu

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

* Re: [PATCH v3] gdb: align siginfo_t with the Linux kernel definition
  2026-07-24  9:18       ` Matthieu Longo
@ 2026-07-24  9:42         ` Matthieu Longo
  2026-07-25  7:46         ` Luis
  1 sibling, 0 replies; 12+ messages in thread
From: Matthieu Longo @ 2026-07-24  9:42 UTC (permalink / raw)
  To: Luis, gdb-patches
  Cc: Thiago Jung Bauermann, Luis Machado, Tom Tromey, Andrew Burgess,
	Srinath Parvathaneni

On 24/07/2026 10:18, Matthieu Longo wrote:

Sorry, the previous email left by mistake.

> On 23/07/2026 00:09, Luis wrote:
>> Hi Matthieu,
>>
>> On 22/07/2026 16:00, Matthieu Longo wrote:
>>> On 21/07/2026 22:09, Luis wrote:
>>>> On 02/07/2026 17:52, Matthieu Longo wrote:
>>> --- a/gdb/linux-tdep.c
>>> +++ b/gdb/linux-tdep.c
>>>>> +  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 possibility to declare an anonymous union,
>>>>> +     using '_' instead.  */
>>>>> +  append_composite_type_field (type, "_", sigfault_union_type);
>>>>
>>>> Could we name this in a better way? Simply using _ is a bit strange.
>>>>
>>>
>>> What about "_union" ?
>>>
>>
>> Naming is hard. Given it is an anonymous union, should it have something anonymous in the name?
>>
> 
> I understand your point, but the name is going to start getting very lengthy.
> What about "_anon_union" ?
> 
>> If we're going to access this by hand, it might be worth having some easy to use too.
>>
> 
> What type of accessors do you have in mind ? Compile-time ones ? Or runtime ones at the destination
> of the GDB users when accessing _siginfo ?
> 
> For the compile-time ones, I propose to add those defines:
> --- a/gdb/linux-tdep.h
> +++ b/gdb/linux-tdep.h
> @@ -98,4 +98,18 @@ extern CORE_ADDR linux_get_hwcap2 ();
>  extern bool linux_address_in_shadow_stack_mem_range
>    (CORE_ADDR addr, std::pair<CORE_ADDR, CORE_ADDR> *range);
> 
> +/* How the fields from siginfo_t's _sigfault can be accessed.  */
> +#ifdef si_addr
> +#error "Matthieu: this should not happen"
> +#endif
> +#define si_addr       "_sifields._sigfault.si_addr"
> +#define si_trapno     "_sifields._sigfault._anon_union.si_trapno"
> +#define si_addr_lsb   "_sifields._sigfault._anon_union.si_addr_lsb"
> +#define si_lower      "_sifields._sigfault._anon_union._addr_bnd.si_lower"
> +#define si_upper      "_sifields._sigfault._anon_union._addr_bnd.si_upper"
> +#define si_pkey       "_sifields._sigfault._anon_union._addr_pkey.si_pkey"
> +#define si_perf_data  "_sifields._sigfault._anon_union._perf.si_perf_data"
> +#define si_perf_type  "_sifields._sigfault._anon_union._perf.si_perf_type"
> +#define si_perf_flags "_sifields._sigfault._anon_union._perf.si_perf_flags"
> +

This solution for accessors does not work because the si_* defines conflict with the ones from
/usr/include/aarch64-linux-gnu/bits/types/siginfo_t.h

I will come back to you with another approach that does not conflict with the linux kernel headers
(potentially with <signal.h> too).

Matthieu

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

* Re: [PATCH v3] gdb: align siginfo_t with the Linux kernel definition
  2026-07-24  9:18       ` Matthieu Longo
  2026-07-24  9:42         ` Matthieu Longo
@ 2026-07-25  7:46         ` Luis
  2026-07-26  5:12           ` Maciej W. Rozycki
  2026-07-27 12:23           ` Matthieu Longo
  1 sibling, 2 replies; 12+ messages in thread
From: Luis @ 2026-07-25  7:46 UTC (permalink / raw)
  To: Matthieu Longo, gdb-patches
  Cc: Thiago Jung Bauermann, Luis Machado, Tom Tromey, Andrew Burgess,
	Srinath Parvathaneni

On 24/07/2026 10:18, Matthieu Longo wrote:
> On 23/07/2026 00:09, Luis wrote:
>> Hi Matthieu,
>>
>> On 22/07/2026 16:00, Matthieu Longo wrote:
>>> On 21/07/2026 22:09, Luis wrote:
>>>> On 02/07/2026 17:52, Matthieu Longo wrote:
>>> --- a/gdb/linux-tdep.c
>>> +++ b/gdb/linux-tdep.c
>>>>> +  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 possibility to declare an anonymous union,
>>>>> +     using '_' instead.  */
>>>>> +  append_composite_type_field (type, "_", sigfault_union_type);
>>>>
>>>> Could we name this in a better way? Simply using _ is a bit strange.
>>>>
>>>
>>> What about "_union" ?
>>>
>>
>> Naming is hard. Given it is an anonymous union, should it have something anonymous in the name?
>>
> 
> I understand your point, but the name is going to start getting very lengthy.
> What about "_anon_union" ?
> 

That reads fine to me.

>> If we're going to access this by hand, it might be worth having some easy to use too.
>>
> 
> What type of accessors do you have in mind ? Compile-time ones ? Or runtime ones at the destination
> of the GDB users when accessing _siginfo ?
> 

I meant when users go and try to print this struct by hand. The other 
cases where gdb uses these we don´t care too much about the length of 
the names, right?

> For the compile-time ones, I propose to add those defines:
> 
> diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
> index f11eccc1bc1..1a03e6897d6 100644
> --- a/gdb/aarch64-linux-tdep.c
> +++ b/gdb/aarch64-linux-tdep.c
> @@ -2689,7 +2689,7 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch,
>         si_errno = parse_and_eval_long ("$_siginfo.si_errno");
> 
>         fault_addr
> -       = parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr");
> +       = parse_and_eval_long ("$_siginfo."si_addr);
>       }
>     catch (const gdb_exception_error &exception)
>       {
> diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h
> index c19839fde2c..f739cc69111 100644
> --- a/gdb/linux-tdep.h
> +++ b/gdb/linux-tdep.h
> @@ -98,4 +98,18 @@ extern CORE_ADDR linux_get_hwcap2 ();
>   extern bool linux_address_in_shadow_stack_mem_range
>     (CORE_ADDR addr, std::pair<CORE_ADDR, CORE_ADDR> *range);
> 
> +/* How the fields from siginfo_t's _sigfault can be accessed.  */
> +#ifdef si_addr
> +#error "Matthieu: this should not happen"
> +#endif
> +#define si_addr       "_sifields._sigfault.si_addr"
> +#define si_trapno     "_sifields._sigfault._anon_union.si_trapno"
> +#define si_addr_lsb   "_sifields._sigfault._anon_union.si_addr_lsb"
> +#define si_lower      "_sifields._sigfault._anon_union._addr_bnd.si_lower"
> +#define si_upper      "_sifields._sigfault._anon_union._addr_bnd.si_upper"
> +#define si_pkey       "_sifields._sigfault._anon_union._addr_pkey.si_pkey"
> +#define si_perf_data  "_sifields._sigfault._anon_union._perf.si_perf_data"
> +#define si_perf_type  "_sifields._sigfault._anon_union._perf.si_perf_type"
> +#define si_perf_flags "_sifields._sigfault._anon_union._perf.si_perf_flags"
> +
>   #endif /* GDB_LINUX_TDEP_H */
> diff --git a/gdb/testsuite/gdb.base/siginfo-obj.exp b/gdb/testsuite/gdb.base/siginfo-obj.exp
> index 6c43d30b7b8..5e36b334068 100644
> --- a/gdb/testsuite/gdb.base/siginfo-obj.exp
> +++ b/gdb/testsuite/gdb.base/siginfo-obj.exp
> @@ -115,7 +115,7 @@ gdb_test "p \$_siginfo._sifields._sigfault.si_addr = 0x666" " = \\(void \\*\\) 0
>   gdb_test "p \$_siginfo.si_errno = 666" " = 666"
>   gdb_test "p \$_siginfo.si_code = 999" " = 999"
>   gdb_test "p \$_siginfo.si_signo = 11" " = 11"
> -gdb_test "p \$_siginfo._sifields._sigfault._union._addr_pkey.si_pkey = 123" " = 123"
> +gdb_test "p \$_siginfo._sifields._sigfault._anon_union._addr_pkey.si_pkey = 123" " = 123"
> 
>   with_test_prefix "validate modified siginfo fields" {
>       gdb_test "break $bp_location"
> @@ -143,7 +143,7 @@ if {$gcore_created} {
>       gdb_test "p \$_siginfo._sifields._sigfault.si_addr" \
>          " = \\(void \\*\\) $ssi_addr" \
>          "p \$_siginfo._sifields._sigfault.si_addr from core file"
> -    gdb_test "p \$_siginfo._sifields._sigfault._union._addr_pkey.si_pkey" \
> +    gdb_test "p \$_siginfo._sifields._sigfault._anon_union._addr_pkey.si_pkey" \
>          " = $ssi_pkey" \
> -       "p \$_siginfo._sifields._sigfault._union._addr_pkey.si_pkey from core file"
> +       "p \$_siginfo._sifields._sigfault._anon_union._addr_pkey.si_pkey from core file"
>   }
> 
>>>>>       append_composite_type_field (sifields_type, "_sigfault", type);
>>>>>         /* _sigpoll */
>>>>
>>>> Do we need to add some extra tests to validate that gdb can read these new fields?
>>>
>>> Indeed, I can add some, but I would like to avoid adding a test for all the new fields.
>>> Can we stick with the original purpose of this change, i.e. adding si_pkey ?
>>>
>>
>> Sure. I'm fine with having the proper coverage as a follow up patch. But it would be nice to at
>> least have the coverage for what you plan to use, like si_pkey.
>>
> 
> The proper coverage is not easy. The test gdb/testsuite/gdb.base/siginfo-obj.exp relies on
> definitions of those fields via the glibc header <signal.h>. It creates local variables that GDB can
> print to test the values. Since the definitions of siginfo_t are not aligned, and some fields are
> missing, I don't think there is an easy way to do a full coverage.
> 
> I propose to add a few fields from the anonymous union, like si_pkey, and the rest should implicitly
> work if si_pkey works.
> 
> PS: I will publish a new revision once I get your confirmation about the naming, the compile-time
> accessors and whether I need to implement runtime accessors.
> For those last ones, please point me into the right direction for the implementation.
Just a suggestion. If it makes it easier this could be a unit test to 
make sure we have the proper fields at least. But checking runtime 
values would need something more involved.

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

* Re: [PATCH v3] gdb: align siginfo_t with the Linux kernel definition
  2026-07-25  7:46         ` Luis
@ 2026-07-26  5:12           ` Maciej W. Rozycki
  2026-07-27 12:23           ` Matthieu Longo
  1 sibling, 0 replies; 12+ messages in thread
From: Maciej W. Rozycki @ 2026-07-26  5:12 UTC (permalink / raw)
  To: Luis
  Cc: Matthieu Longo, gdb-patches, Thiago Jung Bauermann, Luis Machado,
	Tom Tromey, Andrew Burgess, Srinath Parvathaneni

On Sat, 25 Jul 2026, Luis wrote:

> > > Naming is hard. Given it is an anonymous union, should it have something
> > > anonymous in the name?
> > > 
> > 
> > I understand your point, but the name is going to start getting very
> > lengthy.
> > What about "_anon_union" ?
> > 
> 
> That reads fine to me.

 Hmm, if this union is anonymous, then why does it have to be named on the 
GDB side in the first place?

  Maciej

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

* Re: [PATCH v3] gdb: align siginfo_t with the Linux kernel definition
  2026-07-25  7:46         ` Luis
  2026-07-26  5:12           ` Maciej W. Rozycki
@ 2026-07-27 12:23           ` Matthieu Longo
  1 sibling, 0 replies; 12+ messages in thread
From: Matthieu Longo @ 2026-07-27 12:23 UTC (permalink / raw)
  To: Luis, gdb-patches
  Cc: Thiago Jung Bauermann, Luis Machado, Tom Tromey, Andrew Burgess,
	Srinath Parvathaneni

On 25/07/2026 08:46, Luis wrote:
> On 24/07/2026 10:18, Matthieu Longo wrote:
>> On 23/07/2026 00:09, Luis wrote:
>>> Hi Matthieu,
>>> If we're going to access this by hand, it might be worth having some easy to use too.
>>>
>>
>> What type of accessors do you have in mind ? Compile-time ones ? Or runtime ones at the destination
>> of the GDB users when accessing _siginfo ?
>>
> 
> I meant when users go and try to print this struct by hand. The other cases where gdb uses these we
> don´t care too much about the length of the names, right?
> 

I could not find any existing utils to declare such an alias.
After a first glance at the code, it does not look obvious to implement such a feature.
The way to implement this would be to add an new field to "enum internalvar_kind", and then handle
this somehow in value_of_internalvar() to resolve the alias. And then trigger again the evaluation
expression:

      expression_up expr = parse_expression (exp, nullptr, flags);
      return expr->evaluate ();

Then there is also the registration of the aliases. Those aliases should not be defined unless
$_siginfo is available, i.e. inside siginfo_make_value() ?
The aliases to be defined to should be target-specific, so some handlers should be added inside gdbarch.

Given my first investigation, it looks really out of scope of the original patch. Specifically
because those aliases are conveniences for the users, and they do not exist today so no regression
in term of user experience compared to today.

>> For the compile-time ones, I propose to add those defines:
>>
>> diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
>> index f11eccc1bc1..1a03e6897d6 100644
>> --- a/gdb/aarch64-linux-tdep.c
>> +++ b/gdb/aarch64-linux-tdep.c
>> @@ -2689,7 +2689,7 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch,
>>         si_errno = parse_and_eval_long ("$_siginfo.si_errno");
>>
>>         fault_addr
>> -       = parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr");
>> +       = parse_and_eval_long ("$_siginfo."si_addr);
>>       }
>>     catch (const gdb_exception_error &exception)
>>       {
>> diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h
>> index c19839fde2c..f739cc69111 100644
>> --- a/gdb/linux-tdep.h
>> +++ b/gdb/linux-tdep.h
>> @@ -98,4 +98,18 @@ extern CORE_ADDR linux_get_hwcap2 ();
>>   extern bool linux_address_in_shadow_stack_mem_range
>>     (CORE_ADDR addr, std::pair<CORE_ADDR, CORE_ADDR> *range);
>>
>> +/* How the fields from siginfo_t's _sigfault can be accessed.  */
>> +#ifdef si_addr
>> +#error "Matthieu: this should not happen"
>> +#endif
>> +#define si_addr       "_sifields._sigfault.si_addr"
>> +#define si_trapno     "_sifields._sigfault._anon_union.si_trapno"
>> +#define si_addr_lsb   "_sifields._sigfault._anon_union.si_addr_lsb"
>> +#define si_lower      "_sifields._sigfault._anon_union._addr_bnd.si_lower"
>> +#define si_upper      "_sifields._sigfault._anon_union._addr_bnd.si_upper"
>> +#define si_pkey       "_sifields._sigfault._anon_union._addr_pkey.si_pkey"
>> +#define si_perf_data  "_sifields._sigfault._anon_union._perf.si_perf_data"
>> +#define si_perf_type  "_sifields._sigfault._anon_union._perf.si_perf_type"
>> +#define si_perf_flags "_sifields._sigfault._anon_union._perf.si_perf_flags"
>> +
>>   #endif /* GDB_LINUX_TDEP_H */
>> diff --git a/gdb/testsuite/gdb.base/siginfo-obj.exp b/gdb/testsuite/gdb.base/siginfo-obj.exp
>> index 6c43d30b7b8..5e36b334068 100644
>> --- a/gdb/testsuite/gdb.base/siginfo-obj.exp
>> +++ b/gdb/testsuite/gdb.base/siginfo-obj.exp
>> @@ -115,7 +115,7 @@ gdb_test "p \$_siginfo._sifields._sigfault.si_addr = 0x666" " = \\(void \\*\\) 0
>>   gdb_test "p \$_siginfo.si_errno = 666" " = 666"
>>   gdb_test "p \$_siginfo.si_code = 999" " = 999"
>>   gdb_test "p \$_siginfo.si_signo = 11" " = 11"
>> -gdb_test "p \$_siginfo._sifields._sigfault._union._addr_pkey.si_pkey = 123" " = 123"
>> +gdb_test "p \$_siginfo._sifields._sigfault._anon_union._addr_pkey.si_pkey = 123" " = 123"
>>
>>   with_test_prefix "validate modified siginfo fields" {
>>       gdb_test "break $bp_location"
>> @@ -143,7 +143,7 @@ if {$gcore_created} {
>>       gdb_test "p \$_siginfo._sifields._sigfault.si_addr" \
>>          " = \\(void \\*\\) $ssi_addr" \
>>          "p \$_siginfo._sifields._sigfault.si_addr from core file"
>> -    gdb_test "p \$_siginfo._sifields._sigfault._union._addr_pkey.si_pkey" \
>> +    gdb_test "p \$_siginfo._sifields._sigfault._anon_union._addr_pkey.si_pkey" \
>>          " = $ssi_pkey" \
>> -       "p \$_siginfo._sifields._sigfault._union._addr_pkey.si_pkey from core file"
>> +       "p \$_siginfo._sifields._sigfault._anon_union._addr_pkey.si_pkey from core file"
>>   }
>>
>>>>>>       append_composite_type_field (sifields_type, "_sigfault", type);
>>>>>>         /* _sigpoll */
>>>>>
>>>>> Do we need to add some extra tests to validate that gdb can read these new fields?
>>>>
>>>> Indeed, I can add some, but I would like to avoid adding a test for all the new fields.
>>>> Can we stick with the original purpose of this change, i.e. adding si_pkey ?
>>>>
>>>
>>> Sure. I'm fine with having the proper coverage as a follow up patch. But it would be nice to at
>>> least have the coverage for what you plan to use, like si_pkey.
>>>
>>
>> The proper coverage is not easy. The test gdb/testsuite/gdb.base/siginfo-obj.exp relies on
>> definitions of those fields via the glibc header <signal.h>. It creates local variables that GDB can
>> print to test the values. Since the definitions of siginfo_t are not aligned, and some fields are
>> missing, I don't think there is an easy way to do a full coverage.
>>
>> I propose to add a few fields from the anonymous union, like si_pkey, and the rest should implicitly
>> work if si_pkey works.
>>
>> PS: I will publish a new revision once I get your confirmation about the naming, the compile-time
>> accessors and whether I need to implement runtime accessors.
>> For those last ones, please point me into the right direction for the implementation.
> Just a suggestion. If it makes it easier this could be a unit test to make sure we have the proper
> fields at least. But checking runtime values would need something more involved.

I will include the test as a part of this patch in the next revision.

Matthieu


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

end of thread, other threads:[~2026-07-27 12:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-02 16:52 [PATCH v3] gdb: align siginfo_t with the Linux kernel definition Matthieu Longo
2026-07-08 15:54 ` Matthieu Longo
2026-07-21  9:17   ` Matthieu Longo
2026-07-21  9:23     ` Luis
2026-07-21 21:09 ` Luis
2026-07-22 15:00   ` Matthieu Longo
2026-07-22 23:09     ` Luis
2026-07-24  9:18       ` Matthieu Longo
2026-07-24  9:42         ` Matthieu Longo
2026-07-25  7:46         ` Luis
2026-07-26  5:12           ` Maciej W. Rozycki
2026-07-27 12:23           ` Matthieu Longo

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