From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id exESFOVpZGr9hywAWB0awg (envelope-from ) for ; Sat, 25 Jul 2026 03:46:45 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=s60CKn+p; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 41B2F1E099; Sat, 25 Jul 2026 03:46:45 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-4.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FORGED_GMAIL_RCVD,FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 9A7FD1E099 for ; Sat, 25 Jul 2026 03:46:43 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E054C4BA7996 for ; Sat, 25 Jul 2026 07:46:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E054C4BA7996 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=s60CKn+p Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id DCB104BA2E2F for ; Sat, 25 Jul 2026 07:46:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DCB104BA2E2F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DCB104BA2E2F Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::435 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784965578; cv=none; b=IppOFHWKa92a+NXn9td5fBVcL8UzTG+XOuiutLGxBcfATvpYgsfcmwh3h133BSp4wK5k5+jsc/zI15FddO7aYVzLY9afVisuMcPgC0nQktoKr/6xJYkCWx4iTpnHic5Iaj2UljpbIM9LWqvb+ZNSm45OL0662/2hoWe+Kt67F/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784965578; c=relaxed/simple; bh=zD6PzZGGDDbS834rQZQpxopTJejK8xVnq/SfJpYqG3M=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=h7oUEhJEfTmKdv+PLMEONJPww9CpcF9s0MMZDC+EyoDLVstaFJ6Cmz7h5e+mEJb0HoL4yoPCWReWsFP5/EYHFwWwHVzR4fbhKTug0OizzaLZIq7L4qTr3+RBbzAOEGN2h0ol2R3NuruGkRACdYp6+FokhY/e3I8h404GnqGpbgc= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=s60CKn+p DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DCB104BA2E2F Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-47f904e80eeso945316f8f.1 for ; Sat, 25 Jul 2026 00:46:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784965577; x=1785570377; darn=sourceware.org; h=content-transfer-encoding:content-type:in-reply-to:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=jVJAuxBKQaor0ZwJO5k46BOO1r3BBOkiLOsN3yU6WCI=; b=s60CKn+p0vBNUGMPayFEnh6PAu2qNQq7Fvybwtaw6qMU0N16iDWeix9m1dUb7yVcOx 46NUn7TZLmyUDfCPsf+J1XdrXbfKAINXh5QzvA+K+4RKaRzwozznNTBAGCWLzVDHVnoz bj7AVjha5m4ZELmQJE6z4S4ov99hOd/mKgpNvC28nWgasjXEC4GodfXvUkMUGx4KtBvj YVrxIwKb1GgoW80E5Gyv1/sISIc4pAKHyg2VRII9Y2x+rba3+dWlA0tm2gkKtQV098yY wZPd+8co2qUsppV52fzU5WD84jfgy5OLmzNDsfWXICI7iXapoMa/IYmEmipllK45aZ1K X0dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784965577; x=1785570377; h=content-transfer-encoding:content-type:in-reply-to:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=jVJAuxBKQaor0ZwJO5k46BOO1r3BBOkiLOsN3yU6WCI=; b=lkOvwA16V8DLhhu105XHnYTlaRbeuQwjWowTPMu7mCWVVDQZ1gldL2PUZWiS0hfdRR /fA5cvCp0v7cl6QOzO+R4d1zqDYc1KbJo9H7x+wgKhzuyoAusT2VCWcEX5hJFurfiP21 d/i/tEU9TUd10W4Phng0YeF1kFbJPgtdnX6VN7rY83FczTg2A1xZDnaBjOSrjeKruz+m CSACxdO2MbBvIiIQYrxkctlJ4Kd4P7hNUZQFtgpFQOg/S+TV4r07folPmft/PHYPde3+ mfkgtDJVGruRFAx5+SL3+CMtYvoM8tbh8mc42ON6OM1z2niJ1vWc29yREZ9AdIO0nJH+ KkTg== X-Forwarded-Encrypted: i=1; AHgh+RpoY6/Owxl7Ni3Kh8B/k1psbNLUPJboldXa78qooXiXb4RX7XV8iG/OCFs+hmoRRJSHF2d+21L6Oh0MkA==@sourceware.org X-Gm-Message-State: AOJu0YxIcJfnqTrcbvBAD1SZ0qLaGlncK7Ed5WEtlJ/T3EtV6SiYNCiU XUiFRN7a7dzEjjX/r5PXLwlhYPAU3ebbnYATJhcDwKGh2Mn8YfqzBAfzGGUJNw== X-Gm-Gg: AR+sD10yiHoZuxKpomDMoDTUEnWD0x763WyyXspBa4BMOFnMsi80EK2X1a9uB3cHa2l VbymfA9C+c+UZo4zkJ4t+58ZW3VouM2wzRLeAoqe1IM4EkOd4aiuwnfdw1feNLli7eR8Mg1a6Ab TZHALCp082wTM7ch26tlte7gljYafBTdx4LQuMIGJi36yf7tpYedwbzwTPaL0D5R6kRxZzVtMff SK1tpsZcGy9/xlP8wMrqPtoF9u5+uKxbnFUvReF3lSuIjJwjmdz3z97pP6OLhJavhTZ9EAHUwxb oXwKlbrFUTvkUZ3YxviSHOL3g7jyEip9c0pymhUH9JQT93C4LTbs+56YJqvLudc3JkgMqb+5m2O Q4uPNKI2QmTand3C4Na22KQaJI8/hESCMBD8aqWHZiJ08zD9UrbmgyuKPRhvur4ms5xvHxr5Re7 ++GmIhiNgWlmiGxDs= X-Received: by 2002:a5d:5d0e:0:b0:47e:9f03:e542 with SMTP id ffacd0b85a97d-47f9feabcb5mr1523289f8f.45.1784965576539; Sat, 25 Jul 2026 00:46:16 -0700 (PDT) Received: from [192.168.0.38] ([86.12.216.189]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f96b9abc0sm11284410f8f.32.2026.07.25.00.46.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 25 Jul 2026 00:46:16 -0700 (PDT) Message-ID: Date: Sat, 25 Jul 2026 08:46:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] gdb: align siginfo_t with the Linux kernel definition Content-Language: en-US To: Matthieu Longo , gdb-patches@sourceware.org Cc: Thiago Jung Bauermann , Luis Machado , Tom Tromey , Andrew Burgess , Srinath Parvathaneni References: <20260702165231.331169-1-matthieu.longo@arm.com> <82f5d130-cfa5-46e1-b640-f575f6ab00b9@gmail.com> <8cb28dc2-6e51-4ce8-b785-fd66470e2e40@arm.com> From: Luis In-Reply-To: <8cb28dc2-6e51-4ce8-b785-fd66470e2e40@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org 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 *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 . 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.