Re: [PATCH v3 2/5] [PATCH 2/5] gdb: Improve SIGSEGV diagnostics for POE faults
Luis <[email protected]> Tue, 21 Jul 2026 21:30:09 +0100
| Newsgroups | gmane.comp.gdb.patches |
|---|---|
| Message-ID | <[email protected]> |
On 14/07/2026 21:15, [email protected] wrote: > From: Srinath Parvathaneni <[email protected]> > > When a SIGSEGV is caused by a Permission Overlay violation, include > additional information in GDB's error message to help identify the > failing address along with the responsible protection key causing > this fault. > > Example: > (gdb) c > Continuing. > > Program received signal SIGSEGV, Segmentation fault > Protection Key Violation while accessing address 0x0000fffff7ff3000 with Protection Key = 1. > 0x0000aaaaaaaa0a3c in main () at poe_sigsegv.c:26 > > Approved-by: Thiago Jung Bauermann <[email protected]> > --- > gdb/aarch64-linux-tdep.c | 21 ++++++++++++++++++--- > 1 file changed, 18 insertions(+), 3 deletions(-) > > diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c > index f11eccc1bc1..b8a02ab9972 100644 > --- a/gdb/aarch64-linux-tdep.c > +++ b/gdb/aarch64-linux-tdep.c > @@ -53,6 +53,7 @@ > > #include "arch/aarch64-fpmr-linux.h" > #include "arch/aarch64-gcs-linux.h" > +#include "arch/aarch64-poe-linux.h" > #include "arch/aarch64-mte.h" > #include "arch/aarch64-mte-linux.h" > #include "arch/aarch64-pauth-linux.h" > @@ -2675,11 +2676,12 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch, > { > aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch); > > - if (!(tdep->has_mte () || tdep->has_gcs ()) || siggnal != GDB_SIGNAL_SEGV) > + if (!(tdep->has_mte () || tdep->has_gcs () || tdep->has_poe ()) > + || siggnal != GDB_SIGNAL_SEGV) > return; > > CORE_ADDR fault_addr = 0; > - long si_code = 0, si_errno = 0; > + long si_code = 0, si_errno = 0, si_pkey = -1; > > try > { > @@ -2687,6 +2689,9 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch, > violation. */ > si_code = parse_and_eval_long ("$_siginfo.si_code"); > si_errno = parse_and_eval_long ("$_siginfo.si_errno"); > + if (tdep->has_poe ()) > + si_pkey = parse_and_eval_long > + ("$_siginfo._sifields._sigfault._._addr_pkey.si_pkey"); > > fault_addr > = parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr"); > @@ -2703,6 +2708,8 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch, > meaning = _("Memory tag violation"); > else if (si_code == AARCH64_SEGV_CPERR && si_errno == 0) > meaning = _("Guarded Control Stack error"); > + else if (si_code == AARCH64_SEGV_PKUERR) > + meaning = _("Protection Key Violation"); > else > return; > > @@ -2734,6 +2741,14 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch, > uiout->field_string ("logical-tag", hex_string (ltag)); > } > } > + /* For POE SEGSEGV, show additional information. */ Is this really supposed to be POE SEGSEGV or is it a typo? > + else if (si_code == AARCH64_SEGV_PKUERR) > + { > + uiout->text (_(" while accessing address ")); > + uiout->field_core_addr ("fault-addr", gdbarch, fault_addr); > + uiout->text (" with Protection Key = "); Missing internationalization above. > + uiout->field_signed ("protection-key", si_pkey); > + } > else if (si_code != AARCH64_SEGV_CPERR) > { > uiout->text ("\n"); > @@ -3054,7 +3069,7 @@ aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) > aarch64_linux_decode_memtag_section); > } > > - if (tdep->has_mte () || tdep->has_gcs ()) > + if (tdep->has_mte () || tdep->has_gcs () || tdep->has_poe ()) > set_gdbarch_report_signal_info (gdbarch, aarch64_linux_report_signal_info); > > /* Initialize the aarch64_linux_record_tdep. */