From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id jrAwNZbbCGvpigEAWB0awg (envelope-from ) for ; Thu, 26 Nov 2026 20:23:34 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gnu.org header.i=@gnu.org header.a=rsa-sha256 header.s=fencepost-gnu-org header.b=kedoE0MB; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id C86591E023; Thu, 26 Nov 2026 20:23:34 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 761BC1E023 for ; Thu, 26 Nov 2026 20:23:33 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7732B40B3B60 for ; Fri, 27 Nov 2026 01:23:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7732B40B3B60 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gnu.org header.i=@gnu.org header.a=rsa-sha256 header.s=fencepost-gnu-org header.b=kedoE0MB Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 022CD46C6C47 for ; Fri, 27 Nov 2026 01:23:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 022CD46C6C47 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 022CD46C6C47 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2001:470:142:3::10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795742587; cv=none; b=OxQYaka+cFPXKBpn/oaWRVX1mOMr1jUtmtjg5iJZ7jDSoROYPwXFqyVdQ+lVlrShFStyK88hDDSArMtOuRf8FP4FqkZ9axbP5gibaFbg5Qos7sz+5G9rKij1c/AnK7Hfx6VojHS77YGs+bz+UzFWxoLHaf6yXzgSpcSftq1l6Dk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795742587; c=relaxed/simple; bh=TNAVeGFADvr2y4MnIbYTcRaswqnqBFjyQ1BqWwIjyJM=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=OEsOehAwWx6w3e8kVbFW9xz1FmFig9HLgRcfuSnBB3tdWV40mZNhi+oRvn+N0eVBWIRR9MdrHKA3tDWJyjhrdAs81A5p4UKQE8km2e0XmduQkKgMySHbsV0vEIVl3ntFHup/FLYosUj5rXtCyjGzIK/Stfacphd+aVbEM3Fp9Jw= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gnu.org header.i=@gnu.org header.a=rsa-sha256 header.s=fencepost-gnu-org header.b=kedoE0MB DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 022CD46C6C47 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWkg6-0000lu-FV; Thu, 26 Nov 2026 20:23:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=In-Reply-To:MIME-Version:References:Subject:To:From: Date; bh=aLIaK9XaByvfmsiWoFJM0cUUi/+8InwhnXboiup7+dA=; b=kedoE0MBoIuutNrStjmx 2s4tkbmSeI0Yoqr4l1BLBx0ebGsNneRmIiAIp+Q2JK0lJmwm3aKNNvgXBQ34OP5SUVDETdvB44XaH BxGj/UrALb5gtpgYaDHUM/bBlp3ZFSMbB8ze6NQb5CYCOulHpULzkcRCiOPQnZoWwFTT3Gu+wx+WZ bUoou1bKbV9DXCzGHpTrjC8BbgOcLzZ3bMlesMF+XF+k+1LQg49M4rtP7BrIHQeeyWn8FIdw5aNWX hRfRS656LSm4vXEOjuISSA39GidlA4ttzOF0dmw5TbNRRJI4BrsOXqK7D8eAWBrDPrWkh+5szWbwS RAJElc6k8cnRow==; Date: Fri, 27 Nov 2026 02:23:02 +0100 From: Samuel Thibault To: ajrojas Cc: gdb-patches@sourceware.org, bug-hurd@gnu.org, Flavio Cruz Subject: Re: [PATCH 1/2] gdb/hurd: fix the gregset offsets for x86_64 core files Message-ID: Mail-Followup-To: ajrojas , gdb-patches@sourceware.org, bug-hurd@gnu.org, Flavio Cruz References: <20261127011450.60158-1-ajrojas.lab@gmail.com> <20261127011450.60158-2-ajrojas.lab@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261127011450.60158-2-ajrojas.lab@gmail.com> Organization: I am not organized 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 ajrojas, le jeu. 26 nov. 2026 22:14:49 -0300, a ecrit: > amd64_gnu_gregset_reg_offset is used to read the .reg section of x86_64 > GNU/Hurd core files. Its comment says the offsets come from > , but they are those of amd64_linux_gregset_reg_offset, > and sizeof_gregset is the size of Mach's struct i386_thread_state. The > Hurd writes pr_reg as glibc's gregset_t, which on x86_64 has 23 entries: > r8 to r15, rdi, rsi, rbp, rsp, rbx, rdx, rcx, rax, rip, cs, rfl, err, > trapno, oldmask, cr2. > > Only rip, cs and eflags were read from the right place. GDB warned > about the size of .reg, read rsp as 0 and could not unwind past the > first frame. > > Use the gregset_t offsets and size. > > Tested on x86_64 GNU/Hurd with core files written by the crash server. Reviewed-by: Samuel Thibault Thanks! > --- > The core files need a fix in the Hurd's core writer as well; without it > the notes are misaligned and GDB fails earlier: > https://lists.gnu.org/archive/html/bug-hurd/2026-11/msg00266.html > > Tested with GDB 17.2 on Guix System x86_64 GNU/Hurd in QEMU, with core > files from the crash server and from the Hurd's gcore, of static and > dynamic programs. i386 is not touched. > > For example, a static program that writes through NULL in die (), with > the Hurd fix in the crash server. Before: > > warning: Unexpected size of section `.reg/492' in core file. > #0 die (how=) at src/crash.c:23 > Backtrace stopped: Cannot access memory at address 0x18 > rsp 0x0 0x0 > rbp 0x150dd68 0x150dd68 > > After (the program puts 0x1122334455667788 in rbp): > > #0 die (how=how@entry=0x1013 "segv") at src/crash.c:23 > #1 0x0000000000404199 in main (argc=, argv=) at src/crash.c:49 > rsp 0x150dcb0 0x150dcb0 > rbp 0x1122334455667788 0x1122334455667788 > > The warning that .reg2 is too small stays: the Hurd does not save the > FP state yet, which is a separate problem. > > I have not run the testsuite: these tables are only used for x86_64 > GNU/Hurd, and I have not set it up there. > > gdb/amd64-gnu-tdep.c | 35 ++++++++++++++++++----------------- > 1 file changed, 18 insertions(+), 17 deletions(-) > > diff --git a/gdb/amd64-gnu-tdep.c b/gdb/amd64-gnu-tdep.c > index 8415ce7468..d4a0ac7df5 100644 > --- a/gdb/amd64-gnu-tdep.c > +++ b/gdb/amd64-gnu-tdep.c > @@ -160,25 +160,26 @@ static int amd64_gnu_sc_reg_offset[] = > 17 * 8, /* %cs */ > }; > > -/* From . */ > +/* From : the REG_* order of gregset_t, which is the > + format of pr_reg in the Hurd's core files. */ > static int amd64_gnu_gregset_reg_offset[] = > { > - 10 * 8, /* %rax */ > - 5 * 8, /* %rbx */ > - 11 * 8, /* %rcx */ > - 12 * 8, /* %rdx */ > - 13 * 8, /* %rsi */ > - 14 * 8, /* %rdi */ > - 4 * 8, /* %rbp */ > - 19 * 8, /* %rsp */ > - 9 * 8, /* %r8 ... */ > - 8 * 8, > - 7 * 8, > - 6 * 8, > - 3 * 8, > - 2 * 8, > + 15 * 8, /* %rax */ > + 12 * 8, /* %rbx */ > + 14 * 8, /* %rcx */ > + 13 * 8, /* %rdx */ > + 9 * 8, /* %rsi */ > + 8 * 8, /* %rdi */ > + 10 * 8, /* %rbp */ > + 11 * 8, /* %rsp */ > + 0 * 8, /* %r8 ... */ > 1 * 8, > - 0 * 8, /* ... %r15 */ > + 2 * 8, > + 3 * 8, > + 4 * 8, > + 5 * 8, > + 6 * 8, > + 7 * 8, /* ... %r15 */ > 16 * 8, /* %rip */ > 18 * 8, /* %eflags */ > 17 * 8, /* %cs */ > @@ -209,7 +210,7 @@ amd64_gnu_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) > > tdep->gregset_reg_offset = amd64_gnu_gregset_reg_offset; > tdep->gregset_num_regs = ARRAY_SIZE (amd64_gnu_gregset_reg_offset); > - tdep->sizeof_gregset = 21 * 8; /* sizeof (struct i386_thread_state); */ > + tdep->sizeof_gregset = 23 * 8; /* sizeof (gregset_t). */ > > tdep->sigtramp_p = amd64_gnu_sigtramp_p; > tdep->sigcontext_addr = amd64_gnu_sigcontext_addr; > -- > 2.56.0 > -- Samuel Actually, typing random strings in the Finder does the equivalent of filename completion. (Discussion in comp.os.linux.misc on the intuitiveness of commands: file completion vs. the Mac Finder.)