From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id YdejFDjgX2pz6SEAWB0awg (envelope-from ) for ; Tue, 21 Jul 2026 17:10:16 -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=REOkxzQ0; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 3E1D71E033; Tue, 21 Jul 2026 17:10:16 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 [IPv6:2620:52:6:3111::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 63D0D1E033 for ; Tue, 21 Jul 2026 17:10:15 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8DA2E4BA2E0A for ; Tue, 21 Jul 2026 21:10:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8DA2E4BA2E0A 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=REOkxzQ0 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id B2C924BA540B for ; Tue, 21 Jul 2026 21:09:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B2C924BA540B 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 B2C924BA540B Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::333 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784668189; cv=none; b=eZv3FgEbIva7Jskr48HxtPQ0UlSCpzSgO7lMXIbER7jAlYz/XUDghEcNLmPKEg1zn9rmOqYxIZblL4e8MfHxREsEUfpPNJSyWAvhm+RBekXFT2+RrVEYyBtrYcghlMmAcX52sacuFDqwRATckmKvxxk3Ghj22UitvvjZhnowND0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784668189; c=relaxed/simple; bh=WFB16Aat0DtplPe7jQfEsVPm/maFAdY4j61OBm1DwTs=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=ogbv8R3jOwKtUEbPeUhUm5JEwi6B6GlkhX1H2IWj0H4Ykr3SXOIlRa8xZ+vlQyz/Gn0wJNX3hnPqERs/nBVAOBpkXb7RqRcOlqCJUMayhkUsxa7XgYNEQKtkf5VuaixnfRzjzwfCrW35GHdWCwMasxKsuxky1qbvFfGit1sdbPE= 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=REOkxzQ0 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B2C924BA540B Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-49548e01d02so22080485e9.0 for ; Tue, 21 Jul 2026 14:09:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784668187; x=1785272987; 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=qXnCy9r9MbF/2fcnsH4NrqdjEDoB00Mu7TnIvbTndUU=; b=REOkxzQ0g7nDToKkxO+8z1Ac5ZZ5vr/qX7Bh67IZhaPuav/iGyMdwsrpa67mdFJz4V ztkO7J8jj3hMucdMRlQJ9/gDpwpCtLTMoMocNPeOCl05ZMMOLQRFE935WMejLPmo5Sh4 z8C4BaPpedktK4hXIQ5RgIx2aCvZHmKUnxV6zqQtHiOkEe8lEypqeNMD2S6ZICdwej0b oMMfkXRZtEdbeipioB606X0wVZQA1H4Roz1MNCueujkJuaIkaA+6w1qkW/I8XMoUVc3N 2XUcvvLEY1ClQf4FiqLym8FhPJKN7Zbh91ctdnYq8K5yLgdUahP3wtcoHvbDtHg3b32T Oamw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784668187; x=1785272987; 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=qXnCy9r9MbF/2fcnsH4NrqdjEDoB00Mu7TnIvbTndUU=; b=IHQkznDfhdjOEKfILPAen+4fkF15cyl1PO4dOwD1RVVDQ72OytvDrNM+WyCLdUOysE NRZdDPGonFOqXWQ4fjCBGU+afz5uwcHYqz+wfM2Rer7nebweDpHmh2LBIz/i/SR0Eb9f z5LJwXQfDYVxneHmaSnWC8wymwA9Bz+vfrR1E8YGLygW3ee5Vhz60X8WJTbNne1kvZxQ Vjj3qiIXy+1NGPseEi7/roFgfj4wuYufUs7nFxJ8PaXV7/3VWNyC9fz/58AVuNsYP4A8 rVyBaXr4JwRDs7PB9pc9OKque4FaWCu/jOmjhOYRL+Qj0t7pmlqwtS1if/0Z2DBAjEzP gLSw== X-Forwarded-Encrypted: i=1; AHgh+Ro5S0WfYNTtgJGnXE0pTEopEE809RkqzJ1mk8hpepDG1tmwaH/GsmmmGOoxar5WplU1DvsOmaFZULFH1g==@sourceware.org X-Gm-Message-State: AOJu0Yz70okli3d1hzeuCQQaoRgnTLMP0Kwu9cHtxCVkSc4B4Kf1V8aP yQ7VeMH8mOxb+dj/94LTc+6RJE0E7xiuGNeM5WXo1diFm6Fd4eKjHVRzlLqiuw== X-Gm-Gg: AfdE7clWqRy8afFEQgA4DiTUVFBrDE8ULZ/0bUUKxMOBnkWNptT5xhwVeZ5BR1GTgHU f/7R+OeetJ0bkS4mNnbeZi630cuGcWiKjXOD1Se37MopnQeUgQWidwEGyjwgCtKl2bY5NVQ7DkB 8SRaxXueNpYyxClR2/Fsy6yPKz5pB5ZlZHx0V8htF+tSaaPWVJgQQGxVA4mv9UUlIDAlDXD/oCM McIWggRPtHcJlyqztuSSAEwlNte+fHnceATu0O3j8Hq2jVUF+5Gxw8QI+8HY5ZyCwPisJAkfBWs mjDkj14oc2rxwTAsXpToruZJllCTJp63b4A0SuLWAbDnDpURUYBc1A27WQLFAZO+GylIpys3DbR JASEMs7Qi6PNw/xcjrt4Z+MhqJvxC5FLiqs5IgDdXGM3SiATixBxupTKqk2dDN4xsUaIUBm+cCc M9EXqA89oJNWW0/0M= X-Received: by 2002:a05:600c:1382:b0:495:49da:e15a with SMTP id 5b1f17b1804b1-4954a40d1d4mr221284095e9.30.1784668187334; Tue, 21 Jul 2026 14:09:47 -0700 (PDT) Received: from [192.168.0.38] ([86.12.216.189]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4956b016382sm5228215e9.2.2026.07.21.14.09.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Jul 2026 14:09:46 -0700 (PDT) Message-ID: Date: Tue, 21 Jul 2026 22:09:45 +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 References: <20260702165231.331169-1-matthieu.longo@arm.com> From: Luis In-Reply-To: <20260702165231.331169-1-matthieu.longo@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 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 > --- > 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?