* [PATCH v1] gdb: align siginfo_t with the Linux kernel definition
@ 2026-06-12 10:16 Matthieu Longo
2026-06-12 10:42 ` Matthieu Longo
2026-06-19 3:58 ` Thiago Jung Bauermann
0 siblings, 2 replies; 12+ messages in thread
From: Matthieu Longo @ 2026-06-12 10:16 UTC (permalink / raw)
To: gdb-patches
Cc: Tom Tromey, Andrew Burgess, Thiago Jung Bauermann, 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://github.com/torvalds/linux/blob/2b414a95b8f7307d42173ba9e580d6
d3e2bcbfce/include/uapi/asm-generic/siginfo.h#L69-L100
[2]: https://lore.kernel.org/all/20160212210213.ABC488FA@viggo.jf.intel.com/
---
gdb/linux-tdep.c | 39 +++++++++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index a7381677498..5baad41a083 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,9 +285,12 @@ 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);
@@ -364,9 +367,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", short_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", short_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] 12+ messages in thread* Re: [PATCH v1] gdb: align siginfo_t with the Linux kernel definition 2026-06-12 10:16 [PATCH v1] gdb: align siginfo_t with the Linux kernel definition Matthieu Longo @ 2026-06-12 10:42 ` Matthieu Longo 2026-06-17 6:07 ` Thiago Jung Bauermann 2026-06-19 3:58 ` Thiago Jung Bauermann 1 sibling, 1 reply; 12+ messages in thread From: Matthieu Longo @ 2026-06-12 10:42 UTC (permalink / raw) To: gdb-patches; +Cc: Tom Tromey, Andrew Burgess, Thiago Jung Bauermann On 12/06/2026 11:16, 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://github.com/torvalds/linux/blob/2b414a95b8f7307d42173ba9e580d6 > d3e2bcbfce/include/uapi/asm-generic/siginfo.h#L69-L100 > [2]: https://lore.kernel.org/all/20160212210213.ABC488FA@viggo.jf.intel.com/ > --- > gdb/linux-tdep.c | 39 +++++++++++++++++++++++++++++++++++++-- > 1 file changed, 37 insertions(+), 2 deletions(-) > I was not sure who I should include for the review. Please feel free to CC the right persons if they are not already in the list. I tested the patch above, and it seems to work fine without any change in ./gdb/nat However, in my understanding, compat_siginfo_t should also be impacted. Why is it still working then without any change ? (gdb) print $_siginfo $2 = { si_signo = 4, si_errno = 0, si_code = 12, _sifields = { _pad = {4327056, 0, 0, 1, 0 <repeats 24 times>}, _kill = { si_pid = 4327056, si_uid = 0 }, _timer = { si_tid = 4327056, si_overrun = 0, si_sigval = { sival_int = 0, sival_ptr = 0x100000000 } }, _rt = { si_pid = 4327056, si_uid = 0, si_sigval = { sival_int = 0, sival_ptr = 0x100000000 } }, _sigchld = { si_pid = 4327056, si_uid = 0, si_status = 0, si_utime = 1, si_stime = 0 }, _sigfault = { si_addr = 0x420690 <tchangef(int)+16>, _ = { si_trapno = 0, si_addr_lsb = 0, _addr_bnd = { _dummy_bnd = 0, si_lower = 0x10000, si_upper = 0x0 }, _addr_pkey = { _dummy_pkey = 0, si_pkey = 65536 }, _perf = { si_perf_data = 4294967296, si_perf_type = 0, si_perf_flags = 0 }, _tchange = { si_tchange_target = 0, si_tchange_type = 1, si_tchange_flags = 0 } --Type <RET> for more, q to quit, c to continue without paging-- Note: this dump contains more fields than the Linux kernel master because it has some unmerged patch series on top of it. Please don't pay attention to it. That's just for the example. aarch64_siginfo_from_compat_siginfo (in gdb/nat/aarch64-linux.c) and its friends for each backend seem to provide some conversion logic between the siginfo_t from the system (/usr/include/asm-generic/siginfo.h) and some internal representation compat_siginfo_t. From my research, this seems needed because, if the host and target systems are not using the same ABI (endianness, size of a pointer or int, etc...), GDB cannot rely on the local definition of siginfo_t to interpret correctly the data in the blob that it received from the target. However, I am confused by the definition of compat_siginfo_t in gdb/nat/aarch64-linux.h for instance. I see that addresses like _sigfaul._addr are converted to 'unsigned int' (that should be equivalent to uint32_t I guess). Why is this working ? Please, could you provide explanations on the above, and guidances on the changes required in struct compat_siginfo_t ? Matthieu ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v1] gdb: align siginfo_t with the Linux kernel definition 2026-06-12 10:42 ` Matthieu Longo @ 2026-06-17 6:07 ` Thiago Jung Bauermann 2026-06-17 9:11 ` Matthieu Longo 0 siblings, 1 reply; 12+ messages in thread From: Thiago Jung Bauermann @ 2026-06-17 6:07 UTC (permalink / raw) To: Matthieu Longo; +Cc: gdb-patches, Tom Tromey, Andrew Burgess Hello Matthieu, Matthieu Longo <matthieu.longo@arm.com> writes: > On 12/06/2026 11:16, 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://github.com/torvalds/linux/blob/2b414a95b8f7307d42173ba9e580d6 >> d3e2bcbfce/include/uapi/asm-generic/siginfo.h#L69-L100 >> [2]: https://lore.kernel.org/all/20160212210213.ABC488FA@viggo.jf.intel.com/ >> --- >> gdb/linux-tdep.c | 39 +++++++++++++++++++++++++++++++++++++-- >> 1 file changed, 37 insertions(+), 2 deletions(-) >> > I was not sure who I should include for the review. Please feel free to CC the right > persons if they are not already in the list. > > I tested the patch above, and it seems to work fine without any change in ./gdb/nat > However, in my understanding, compat_siginfo_t should also be impacted. Why is it still > working then without any change ? ⋮ > aarch64_siginfo_from_compat_siginfo (in gdb/nat/aarch64-linux.c) and its friends for each > backend seem to provide some conversion logic between the siginfo_t from the system > (/usr/include/asm-generic/siginfo.h) and some internal representation compat_siginfo_t. > From my research, this seems needed because, if the host and target systems are not using > the same ABI (endianness, size of a pointer or int, etc...), GDB cannot rely on the local > definition of siginfo_t to interpret correctly the data in the blob that it received from > the target. compat_siginfo_t is used when the inferior is an AArch32 process while GDB is AArch64. This will cause the 64-bit kernel to use the syscall compatibility layer — and thus the 32-bit definition of siginfo_t — which GDB's compat_siginfo_t aims to represent. > However, I am confused by the definition of compat_siginfo_t in gdb/nat/aarch64-linux.h > for instance. I see that addresses like _sigfaul._addr are converted to 'unsigned int' > (that should be equivalent to uint32_t I guess). Why is this working ? > > Please, could you provide explanations on the above, and guidances on the changes required > in struct compat_siginfo_t ? I'm not sure I understand why it wouldn't work. In the example of _sigfault._addr, it is an unsigned int (equivalent to uint32_t as you point out) so it will match the width of the void * used for the corresponding void * field in 32-bit userspace. This is converted to siginfo_t's 64-bit void * in aarch64_siginfo_from_compat_siginfo with: to->si_addr = (void *) (intptr_t) from->cpt_si_addr; Do you see a problem in this process? -- Thiago (he/him) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v1] gdb: align siginfo_t with the Linux kernel definition 2026-06-17 6:07 ` Thiago Jung Bauermann @ 2026-06-17 9:11 ` Matthieu Longo 2026-06-18 3:02 ` Thiago Jung Bauermann 0 siblings, 1 reply; 12+ messages in thread From: Matthieu Longo @ 2026-06-17 9:11 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: gdb-patches, Tom Tromey, Andrew Burgess On 17/06/2026 07:07, Thiago Jung Bauermann wrote: > Hello Matthieu, > > Matthieu Longo <matthieu.longo@arm.com> writes: > >> On 12/06/2026 11:16, 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://github.com/torvalds/linux/blob/2b414a95b8f7307d42173ba9e580d6 >>> d3e2bcbfce/include/uapi/asm-generic/siginfo.h#L69-L100 >>> [2]: https://lore.kernel.org/all/20160212210213.ABC488FA@viggo.jf.intel.com/ >>> --- >>> gdb/linux-tdep.c | 39 +++++++++++++++++++++++++++++++++++++-- >>> 1 file changed, 37 insertions(+), 2 deletions(-) >>> >> I was not sure who I should include for the review. Please feel free to CC the right >> persons if they are not already in the list. >> >> I tested the patch above, and it seems to work fine without any change in ./gdb/nat >> However, in my understanding, compat_siginfo_t should also be impacted. Why is it still >> working then without any change ? > > ⋮ > >> aarch64_siginfo_from_compat_siginfo (in gdb/nat/aarch64-linux.c) and its friends for each >> backend seem to provide some conversion logic between the siginfo_t from the system >> (/usr/include/asm-generic/siginfo.h) and some internal representation compat_siginfo_t. >> From my research, this seems needed because, if the host and target systems are not using >> the same ABI (endianness, size of a pointer or int, etc...), GDB cannot rely on the local >> definition of siginfo_t to interpret correctly the data in the blob that it received from >> the target. > > compat_siginfo_t is used when the inferior is an AArch32 process while > GDB is AArch64. This will cause the 64-bit kernel to use the syscall > compatibility layer — and thus the 32-bit definition of siginfo_t — > which GDB's compat_siginfo_t aims to represent. > I imagined that compat_siginfo_t was also used in the case when the inferior is an AArch64 process, while GDB is AArch32. Hence ... >> However, I am confused by the definition of compat_siginfo_t in gdb/nat/aarch64-linux.h >> for instance. I see that addresses like _sigfaul._addr are converted to 'unsigned int' >> (that should be equivalent to uint32_t I guess). Why is this working ? >> >> Please, could you provide explanations on the above, and guidances on the changes required >> in struct compat_siginfo_t ? > > I'm not sure I understand why it wouldn't work. In the example of > _sigfault._addr, it is an unsigned int (equivalent to uint32_t as you > point out) so it will match the width of the void * used for the > corresponding void * field in 32-bit userspace. This is converted to > siginfo_t's 64-bit void * in aarch64_siginfo_from_compat_siginfo with: > > to->si_addr = (void *) (intptr_t) from->cpt_si_addr; > > Do you see a problem in this process? > my surprise when I say the definition of _sigfault._addr as a uint32_t. This would not have worked in my understanding. Matthieu ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v1] gdb: align siginfo_t with the Linux kernel definition 2026-06-17 9:11 ` Matthieu Longo @ 2026-06-18 3:02 ` Thiago Jung Bauermann 2026-06-18 14:02 ` Matthieu Longo 0 siblings, 1 reply; 12+ messages in thread From: Thiago Jung Bauermann @ 2026-06-18 3:02 UTC (permalink / raw) To: Matthieu Longo; +Cc: gdb-patches, Tom Tromey, Andrew Burgess Matthieu Longo <matthieu.longo@arm.com> writes: > On 17/06/2026 07:07, Thiago Jung Bauermann wrote: >> Hello Matthieu, >> Matthieu Longo <matthieu.longo@arm.com> writes: >> >>> On 12/06/2026 11:16, 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://github.com/torvalds/linux/blob/2b414a95b8f7307d42173ba9e580d6 >>>> d3e2bcbfce/include/uapi/asm-generic/siginfo.h#L69-L100 >>>> [2]: https://lore.kernel.org/all/20160212210213.ABC488FA@viggo.jf.intel.com/ >>>> --- >>>> gdb/linux-tdep.c | 39 +++++++++++++++++++++++++++++++++++++-- >>>> 1 file changed, 37 insertions(+), 2 deletions(-) >>>> >>> I was not sure who I should include for the review. Please feel free to CC the right >>> persons if they are not already in the list. >>> >>> I tested the patch above, and it seems to work fine without any change in ./gdb/nat >>> However, in my understanding, compat_siginfo_t should also be impacted. Why is it still >>> working then without any change ? >> ⋮ >> >>> aarch64_siginfo_from_compat_siginfo (in gdb/nat/aarch64-linux.c) and its friends for each >>> backend seem to provide some conversion logic between the siginfo_t from the system >>> (/usr/include/asm-generic/siginfo.h) and some internal representation compat_siginfo_t. >>> From my research, this seems needed because, if the host and target systems are not >>> using >>> the same ABI (endianness, size of a pointer or int, etc...), GDB cannot rely on the local >>> definition of siginfo_t to interpret correctly the data in the blob that it received from >>> the target. >> compat_siginfo_t is used when the inferior is an AArch32 process while >> GDB is AArch64. This will cause the 64-bit kernel to use the syscall >> compatibility layer — and thus the 32-bit definition of siginfo_t — >> which GDB's compat_siginfo_t aims to represent. >> > > I imagined that compat_siginfo_t was also used in the case when the inferior is an AArch64 > process, while GDB is AArch32. > Hence ... Ah, ok. This isn't supported, at least in the Arm port. I think GDB in general doesn't support 32-bit GDB debugging 64-bit inferior, but I could be wrong. It's certainly not well tested though. :) >>> However, I am confused by the definition of compat_siginfo_t in gdb/nat/aarch64-linux.h >>> for instance. I see that addresses like _sigfaul._addr are converted to 'unsigned int' >>> (that should be equivalent to uint32_t I guess). Why is this working ? >>> >>> Please, could you provide explanations on the above, and guidances on the changes >>> required >>> in struct compat_siginfo_t ? >> I'm not sure I understand why it wouldn't work. In the example of >> _sigfault._addr, it is an unsigned int (equivalent to uint32_t as you >> point out) so it will match the width of the void * used for the >> corresponding void * field in 32-bit userspace. This is converted to >> siginfo_t's 64-bit void * in aarch64_siginfo_from_compat_siginfo with: >> to->si_addr = (void *) (intptr_t) from->cpt_si_addr; >> Do you see a problem in this process? >> > > my surprise when I say the definition of _sigfault._addr as a uint32_t. This would not > have worked in my understanding. Yes, indeed in that case it wouldn't work. -- Thiago (he/him) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v1] gdb: align siginfo_t with the Linux kernel definition 2026-06-18 3:02 ` Thiago Jung Bauermann @ 2026-06-18 14:02 ` Matthieu Longo 2026-06-18 16:23 ` Thiago Jung Bauermann 0 siblings, 1 reply; 12+ messages in thread From: Matthieu Longo @ 2026-06-18 14:02 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: gdb-patches, Tom Tromey, Andrew Burgess On 18/06/2026 04:02, Thiago Jung Bauermann wrote: > Matthieu Longo <matthieu.longo@arm.com> writes: > >> On 17/06/2026 07:07, Thiago Jung Bauermann wrote: >>> Hello Matthieu, >>> Matthieu Longo <matthieu.longo@arm.com> writes: >>> >>>> On 12/06/2026 11:16, 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://github.com/torvalds/linux/blob/2b414a95b8f7307d42173ba9e580d6 >>>>> d3e2bcbfce/include/uapi/asm-generic/siginfo.h#L69-L100 >>>>> [2]: https://lore.kernel.org/all/20160212210213.ABC488FA@viggo.jf.intel.com/ >>>>> --- >>>>> gdb/linux-tdep.c | 39 +++++++++++++++++++++++++++++++++++++-- >>>>> 1 file changed, 37 insertions(+), 2 deletions(-) >>>>> >>>> I was not sure who I should include for the review. Please feel free to CC the right >>>> persons if they are not already in the list. >>>> >>>> I tested the patch above, and it seems to work fine without any change in ./gdb/nat >>>> However, in my understanding, compat_siginfo_t should also be impacted. Why is it still >>>> working then without any change ? >>> ⋮ >>> >>>> aarch64_siginfo_from_compat_siginfo (in gdb/nat/aarch64-linux.c) and its friends for each >>>> backend seem to provide some conversion logic between the siginfo_t from the system >>>> (/usr/include/asm-generic/siginfo.h) and some internal representation compat_siginfo_t. >>>> From my research, this seems needed because, if the host and target systems are not >>>> using >>>> the same ABI (endianness, size of a pointer or int, etc...), GDB cannot rely on the local >>>> definition of siginfo_t to interpret correctly the data in the blob that it received from >>>> the target. >>> compat_siginfo_t is used when the inferior is an AArch32 process while >>> GDB is AArch64. This will cause the 64-bit kernel to use the syscall >>> compatibility layer — and thus the 32-bit definition of siginfo_t — >>> which GDB's compat_siginfo_t aims to represent. >>> >> >> I imagined that compat_siginfo_t was also used in the case when the inferior is an AArch64 >> process, while GDB is AArch32. >> Hence ... > > Ah, ok. This isn't supported, at least in the Arm port. I think GDB in > general doesn't support 32-bit GDB debugging 64-bit inferior, but I > could be wrong. It's certainly not well tested though. :) > >>>> However, I am confused by the definition of compat_siginfo_t in gdb/nat/aarch64-linux.h >>>> for instance. I see that addresses like _sigfaul._addr are converted to 'unsigned int' >>>> (that should be equivalent to uint32_t I guess). Why is this working ? >>>> >>>> Please, could you provide explanations on the above, and guidances on the changes >>>> required >>>> in struct compat_siginfo_t ? >>> I'm not sure I understand why it wouldn't work. In the example of >>> _sigfault._addr, it is an unsigned int (equivalent to uint32_t as you >>> point out) so it will match the width of the void * used for the >>> corresponding void * field in 32-bit userspace. This is converted to >>> siginfo_t's 64-bit void * in aarch64_siginfo_from_compat_siginfo with: >>> to->si_addr = (void *) (intptr_t) from->cpt_si_addr; >>> Do you see a problem in this process? >>> >> >> my surprise when I say the definition of _sigfault._addr as a uint32_t. This would not >> have worked in my understanding. > > Yes, indeed in that case it wouldn't work. > If the feature that requires new fields in siginfo_t, is only available AArch64 only, there should not be any reason to change aarch64_siginfo_from_compat_siginfo and aarch64_compat_siginfo_from_siginfo. Is this correct ? If so, then the current patch is complete and ready to be reviewed. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v1] gdb: align siginfo_t with the Linux kernel definition 2026-06-18 14:02 ` Matthieu Longo @ 2026-06-18 16:23 ` Thiago Jung Bauermann 0 siblings, 0 replies; 12+ messages in thread From: Thiago Jung Bauermann @ 2026-06-18 16:23 UTC (permalink / raw) To: Matthieu Longo; +Cc: gdb-patches, Tom Tromey, Andrew Burgess Matthieu Longo <matthieu.longo@arm.com> writes: > On 18/06/2026 04:02, Thiago Jung Bauermann wrote: >> Matthieu Longo <matthieu.longo@arm.com> writes: >> >>> On 17/06/2026 07:07, Thiago Jung Bauermann wrote: >>>> compat_siginfo_t is used when the inferior is an AArch32 process while >>>> GDB is AArch64. This will cause the 64-bit kernel to use the syscall >>>> compatibility layer — and thus the 32-bit definition of siginfo_t — >>>> which GDB's compat_siginfo_t aims to represent. >>> >>> I imagined that compat_siginfo_t was also used in the case when the inferior is an >>> AArch64 >>> process, while GDB is AArch32. >>> Hence ... >> >> Ah, ok. This isn't supported, at least in the Arm port. I think GDB in >> general doesn't support 32-bit GDB debugging 64-bit inferior, but I >> could be wrong. It's certainly not well tested though. :) >> >>>>> However, I am confused by the definition of compat_siginfo_t in gdb/nat/aarch64-linux.h >>>>> for instance. I see that addresses like _sigfaul._addr are converted to 'unsigned int' >>>>> (that should be equivalent to uint32_t I guess). Why is this working ? >>>>> >>>>> Please, could you provide explanations on the above, and guidances on the changes >>>>> required >>>>> in struct compat_siginfo_t ? >>>> I'm not sure I understand why it wouldn't work. In the example of >>>> _sigfault._addr, it is an unsigned int (equivalent to uint32_t as you >>>> point out) so it will match the width of the void * used for the >>>> corresponding void * field in 32-bit userspace. This is converted to >>>> siginfo_t's 64-bit void * in aarch64_siginfo_from_compat_siginfo with: >>>> to->si_addr = (void *) (intptr_t) from->cpt_si_addr; >>>> Do you see a problem in this process? >>> >>> my surprise when I say the definition of _sigfault._addr as a uint32_t. This would not >>> have worked in my understanding. >> >> Yes, indeed in that case it wouldn't work. > > If the feature that requires new fields in siginfo_t, is only available AArch64 only, > there should not be any reason to change aarch64_siginfo_from_compat_siginfo and > aarch64_compat_siginfo_from_siginfo. Is this correct ? Yes, that is correct. compact_siginfo_t only needs to reflect the siginfo_t that the Linux kernel passes to AArch32 processes. > If so, then the current patch is complete and ready to be reviewed. Ok, I will start reviewing it today. -- Thiago (he/him) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v1] gdb: align siginfo_t with the Linux kernel definition 2026-06-12 10:16 [PATCH v1] gdb: align siginfo_t with the Linux kernel definition Matthieu Longo 2026-06-12 10:42 ` Matthieu Longo @ 2026-06-19 3:58 ` Thiago Jung Bauermann 2026-06-19 10:45 ` Matthieu Longo 1 sibling, 1 reply; 12+ messages in thread From: Thiago Jung Bauermann @ 2026-06-19 3:58 UTC (permalink / raw) To: Matthieu Longo; +Cc: gdb-patches, Tom Tromey, Andrew Burgess Hello Matthieu, 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 > [2]: https://lore.kernel.org/all/20160212210213.ABC488FA@viggo.jf.intel.com/ > --- > gdb/linux-tdep.c | 39 +++++++++++++++++++++++++++++++++++++-- > 1 file changed, 37 insertions(+), 2 deletions(-) > > diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c > index a7381677498..5baad41a083 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,9 +285,12 @@ 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); > > @@ -364,9 +367,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", 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 > + 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. -- Thiago (he/him) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v1] gdb: align siginfo_t with the Linux kernel definition 2026-06-19 3:58 ` Thiago Jung Bauermann @ 2026-06-19 10:45 ` Matthieu Longo 2026-06-22 8:42 ` Matthieu Longo 0 siblings, 1 reply; 12+ messages in thread From: Matthieu Longo @ 2026-06-19 10:45 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: gdb-patches, Tom Tromey, Andrew Burgess On 19/06/2026 04:58, Thiago Jung Bauermann wrote: > Hello Matthieu, > > 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. >> [2]: https://lore.kernel.org/all/20160212210213.ABC488FA@viggo.jf.intel.com/ >> --- >> gdb/linux-tdep.c | 39 +++++++++++++++++++++++++++++++++++++-- >> 1 file changed, 37 insertions(+), 2 deletions(-) >> >> diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c >> index a7381677498..5baad41a083 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,9 +285,12 @@ 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); >> >> @@ -364,9 +367,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", 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); + 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); @@ -376,14 +383,14 @@ linux_get_siginfo_type (struct gdbarch *gdbarch) /* used when si_code=SEGV_BNDERR */ type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - append_composite_type_field (type, "_dummy_bnd", short_type); + 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", short_type); + 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); And as expected on AArch64, the padding size is 8 bytes. (gdb) print $_siginfo._sifields._sigfault $2 = { si_addr = 0xfffff7ff5000, _ = { si_trapno = 0, si_addr_lsb = 0, _addr_bnd = { _dummy_bnd = {0, 0, 0, 0, 0, 0, 0, 0}, si_lower = 0x3, si_upper = 0x0 }, _addr_pkey = { _dummy_pkey = {0, 0, 0, 0, 0, 0, 0, 0}, si_pkey = 3 }, _perf = { si_perf_data = 0, si_perf_type = 3, si_perf_flags = 0 }, _tchange = { si_tchange_target = 0, si_tchange_type = 0, si_tchange_flags = 3 } } } (gdb) ptype $_siginfo._sifields._sigfault._._addr_pkey._dummy_pkey type = uint8_t __attribute__ ((vector_size(8))) Matthieu ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v1] gdb: align siginfo_t with the Linux kernel definition 2026-06-19 10:45 ` Matthieu Longo @ 2026-06-22 8:42 ` Matthieu Longo 2026-06-24 21:45 ` Thiago Jung Bauermann 0 siblings, 1 reply; 12+ messages in thread From: Matthieu Longo @ 2026-06-22 8:42 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: gdb-patches, Tom Tromey, Andrew Burgess On 19/06/2026 11:45, Matthieu Longo wrote: > On 19/06/2026 04:58, Thiago Jung Bauermann wrote: >> Hello Matthieu, >> >> 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. > >>> [2]: https://lore.kernel.org/all/20160212210213.ABC488FA@viggo.jf.intel.com/ >>> --- >>> gdb/linux-tdep.c | 39 +++++++++++++++++++++++++++++++++++++-- >>> 1 file changed, 37 insertions(+), 2 deletions(-) >>> >>> diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c >>> index a7381677498..5baad41a083 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,9 +285,12 @@ 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); >>> @@ -364,9 +367,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", 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); > + 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); > @@ -376,14 +383,14 @@ linux_get_siginfo_type (struct gdbarch *gdbarch) > > /* used when si_code=SEGV_BNDERR */ > type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); > - append_composite_type_field (type, "_dummy_bnd", short_type); > + 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", short_type); > + 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); > > And as expected on AArch64, the padding size is 8 bytes. > > (gdb) print $_siginfo._sifields._sigfault > $2 = { > si_addr = 0xfffff7ff5000, > _ = { > si_trapno = 0, > si_addr_lsb = 0, > _addr_bnd = { > _dummy_bnd = {0, 0, 0, 0, 0, 0, 0, 0}, > si_lower = 0x3, > si_upper = 0x0 > }, > _addr_pkey = { > _dummy_pkey = {0, 0, 0, 0, 0, 0, 0, 0}, > si_pkey = 3 > }, > _perf = { > si_perf_data = 0, > si_perf_type = 3, > si_perf_flags = 0 > }, > _tchange = { > si_tchange_target = 0, > si_tchange_type = 0, > si_tchange_flags = 3 > } > } > } > (gdb) ptype $_siginfo._sifields._sigfault._._addr_pkey._dummy_pkey > type = uint8_t __attribute__ ((vector_size(8))) > > > Matthieu By the way, I forgot to ask. Would you prefer me to publish a v2 instead of the diff above ? Matthieu ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v1] gdb: align siginfo_t with the Linux kernel definition 2026-06-22 8:42 ` Matthieu Longo @ 2026-06-24 21:45 ` Thiago Jung Bauermann 2026-06-25 9:55 ` Matthieu Longo 0 siblings, 1 reply; 12+ messages in thread From: Thiago Jung Bauermann @ 2026-06-24 21:45 UTC (permalink / raw) To: Matthieu Longo; +Cc: gdb-patches, Tom Tromey, Andrew Burgess 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) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v1] gdb: align siginfo_t with the Linux kernel definition 2026-06-24 21:45 ` Thiago Jung Bauermann @ 2026-06-25 9:55 ` Matthieu Longo 0 siblings, 0 replies; 12+ messages in thread From: Matthieu Longo @ 2026-06-25 9:55 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: gdb-patches, Tom Tromey, Andrew Burgess [-- Attachment #1: Type: text/plain, Size: 1115 bytes --] On 24/06/2026 22:45, Thiago Jung Bauermann wrote: > Hello Matthieu, > > Sorry for the delay in responding. > > Matthieu Longo <matthieu.longo@arm.com> writes: >>> --- 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. I don't understand why those lines should be using spaces instead of tabs. See the attached screenshots. You can see that the style I used is similar to existing ones in aarch64-linux-tdep.c or elsewhere. Please can you clarify what you meant. Matthieu [-- Attachment #2: Screenshot 2026-06-25 102635.png --] [-- Type: image/png, Size: 18125 bytes --] [-- Attachment #3: Screenshot 2026-06-25 102328.png --] [-- Type: image/png, Size: 28638 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-06-25 9:56 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-06-12 10:16 [PATCH v1] gdb: align siginfo_t with the Linux kernel definition 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 2026-06-25 9:55 ` Matthieu Longo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox