From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id QTXFJPrbCGvpigEAWB0awg (envelope-from ) for ; Thu, 26 Nov 2026 20:25:14 -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=meM5xoYT; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 9075F1E166; Thu, 26 Nov 2026 20:25:14 -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 [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 D11751E023 for ; Thu, 26 Nov 2026 20:25:13 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0AD864B18D54 for ; Fri, 27 Nov 2026 01:25:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0AD864B18D54 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=meM5xoYT Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 1170946AFF1C for ; Fri, 27 Nov 2026 01:24:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1170946AFF1C 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 1170946AFF1C 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=1795742689; cv=none; b=WlGKWQ6fG+KdmhXRH87HTwj8glrQXxydVUMiFsOGfZ9mSKfmbjEqO0P3bmSqm4a8VsiAM5Ko4i+ZMEFbgKb3zkGiYBTDO0jS3huIfUUbqrjk7YuLChscBAa+lTUhlchkF0VMFL0Ux2hBHcB494FQW/jB8GPkrTaAfcWcZdaNzYM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795742689; c=relaxed/simple; bh=VhOyCHwk6w+q+xWTms2NEMgTCUHt+cWMVMfmLs7uzpQ=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=bAVN48zu/z246hIaiXSyjTodp6xMwxkYJSJa5+5usUFHKgPmhqJaBlNG6oEjvzaAYRqeXEv7NOHK7Aw7nMnLwUxVR3LDf+PFBeIO5+jL6U7JD81h0mMy40Fh+TSiwyWPMD2X+Gt0sliE6TvTqtBqc8IoxlkGwRZeRjrw9PT/GaU= 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=meM5xoYT DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1170946AFF1C 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 1xWkhk-0005VD-GF; Thu, 26 Nov 2026 20:24:48 -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=kMrugEdyIMtTH5Dt1nJzc4jAHd3QJQGYldP/wSwoIes=; b=meM5xoYTfd9lQ2YFZkgG 80AZnR/LT1MItb78/WGraZOzaZfkEV7hz7EPI1afz+yJXjrUGXJvIxJgRUB8SAysL9JP2qiPakkNV AgtVMGIQUbdXaeh8uYcak2b/mskCZY5AvbzU/aCjxkAYZar6lHGVb2ybxOjjTXNSwI7d/oIbhcZoR fWtSg9iRXs9zwmdJMZeaQNoXvmm5PsUIIjQuFTDLTLpnioIYHxuRttFII8Xr7ERA3C1Xk1mxtSlDt 3EMx9mNyi083jBoamwYAE/IcAWye9eOHTgYoY0z2ySfY0I5Z9Oax9WXQMi+F0OGv/AJ5mYWHfVjW8 uj1giIvcZbQNlw==; Date: Fri, 27 Nov 2026 02:24:47 +0100 From: Samuel Thibault To: ajrojas Cc: gdb-patches@sourceware.org, bug-hurd@gnu.org, Flavio Cruz Subject: Re: [PATCH 2/2] gdb/hurd: fix the sigcontext offsets for x86_64 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-3-ajrojas.lab@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261127011450.60158-3-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:50 -0300, a ecrit: > amd64_gnu_sc_reg_offset gives the place of each register in struct > sigcontext, from sc_r8 on, and is used to unwind through the signal > trampoline. Some entries do not match : rsi and rdi > are one slot off, and r9 to r15 are in the wrong slots (r9 is read from > sc_rdi, r15 from sc_r8). rip, rsp and rbp were right, so the backtrace > was complete, but in the frame that got the signal GDB showed wrong > values for these registers, and for arguments kept in them in optimized > code. > > Use the order of : r8 to r15, rdi, rsi, rbp, rsp, > rbx, rdx, rcx, rax, rip, cs, rfl. rsp stays at sc_rsp, as on i386 with > sc_esp: the header says it is not used, but _hurd_setup_sighandler > saves the interrupted stack pointer there. > > Tested on x86_64 GNU/Hurd, with core files and with a live process. Reviewed-by: Samuel Thibault Thanks! > --- > Tested with GDB 17.2 on Guix System x86_64 GNU/Hurd in QEMU. A static > program puts known values in rbx, rcx, rdx, rsi, rdi and r8 to r15, > writes through NULL, and aborts or waits in its SIGSEGV handler; I > looked at its core file from the crash server and attached to the > waiting process. A second one, built with -O2, calls > crash2 (NULL, 12345), which reads through its first argument; core > file only. > > Before and after, the backtrace goes through "" > to main. Before, the faulting frame showed rsi, rdi and r9 to r15 with > the values of other registers, and the second program showed > "crash2 (p=0x3039, p@entry=0x0, v=v@entry=1)". After, every value is > in its register and it shows "crash2 (p=p@entry=0x0, v=v@entry=12345)". > > I have not run the testsuite: this table is only used for x86_64 > GNU/Hurd, and I have not set it up there. > > The glibc here has 0d99714680 ("hurd: Clear FP exceptions before > calling signal handler", in 2.42), where the return address is in > _trampoline, so the name check in amd64_gnu_sigtramp_p does not match > and the frame is found by its code. > > gdb/amd64-gnu-tdep.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/gdb/amd64-gnu-tdep.c b/gdb/amd64-gnu-tdep.c > index d4a0ac7df5..d021a18974 100644 > --- a/gdb/amd64-gnu-tdep.c > +++ b/gdb/amd64-gnu-tdep.c > @@ -143,18 +143,18 @@ static int amd64_gnu_sc_reg_offset[] = > 12 * 8, /* %rbx */ > 14 * 8, /* %rcx */ > 13 * 8, /* %rdx */ > - 10 * 8, /* %rsi */ > - 9 * 8, /* %rdi */ > + 9 * 8, /* %rsi */ > + 8 * 8, /* %rdi */ > 10 * 8, /* %rbp */ > 11 * 8, /* %rsp */ > 0 * 8, /* %r8 ... */ > - 8 * 8, > - 7 * 8, > - 6 * 8, > - 3 * 8, > - 2 * 8, > 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 */ > -- > 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.)