From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id sdYkO8bZCGsxhwEAWB0awg (envelope-from ) for ; Thu, 26 Nov 2026 20:15:50 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=k5x+JdlV; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id EF1C81E023; Thu, 26 Nov 2026 20:15:50 -0500 (EST) 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 7786D1E023 for ; Thu, 26 Nov 2026 20:15:50 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 941CE4B7CD42 for ; Fri, 27 Nov 2026 01:15:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 941CE4B7CD42 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=k5x+JdlV Received: from mail-dy1-x132e.google.com (mail-dy1-x132e.google.com [IPv6:2607:f8b0:4864:20::132e]) by sourceware.org (Postfix) with ESMTPS id 4B19043F498A for ; Fri, 27 Nov 2026 01:15:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4B19043F498A 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 4B19043F498A Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::132e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795742120; cv=none; b=vVUEsp855lstKzdPrRwk5LB6uUsr+yOVGtaoaB2lQJKAHYlulFfIPQnxFbPZHqjvlN2W32Fxl5RH4SS4dfSnqgiaAczx4oHhFtv6Jy5l2W4c3o1Pe4R4c0kyslgBczJfzU4AMr9iKFi6NB0YhKaugUqAqQyih6hG/5LwJmEOlr4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795742120; c=relaxed/simple; bh=oF64sivXt1CJzVSUOsVLN9e4pVP4CaTI7m5CtaOVJ60=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=SwcSMev2cpvjxBQE2dhPq9dU7h94wHmtk7ag1BcyPkjMxb+6hb9u51w5y2ajZFFKffllavexPk7mA7YKMX67UDTTIZ1/mrh+BlJ/Yt6JJl0OTFpk3F3UGcacK8Tu571rdjo19bqXzWP5SX1Eo83K/J/M+fqtAK4x8ffNNrI8MGE= 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=20260707 header.b=k5x+JdlV DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B19043F498A Received: by mail-dy1-x132e.google.com with SMTP id 5a478bee46e88-38644aedba1so11187240eec.0 for ; Thu, 26 Nov 2026 17:15:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795742119; x=1796346919; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=E4fNO8YNPmoAKZSxzrq9pDQ2sYvxjExXQk0PyKf4EMo=; b=k5x+JdlVOchadOQduGcRE9Ztfm3rsblgT2qq8j5nldyeDrf9vM9bta4UanJz4eWxw/ aode/OaRFpLZqDOSC4x+krStYg4a+JuxMIO2EcxxPOgZnoZUrT1RVvyHsVSPg6ETXoiZ I/c0+xGzC96+30Ir0pXzFlbo6Z7Ck0yrAao7A251c758a8xrvEt+nUZDCotFGeIG4gQC KRp5WpNj0j9sIiO3Zu3NHM6XjQDGppbPYnhjeSPUvfmkkNgP2uEL9JFa01xhSlvU8Rtz Bu4V5QqNctscHW0VWVTN1mWfog3/X+YEzBG7nr9zIlaDaWG7UbPR234CBRjPcyrAHoTe KHKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795742119; x=1796346919; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=E4fNO8YNPmoAKZSxzrq9pDQ2sYvxjExXQk0PyKf4EMo=; b=Py9Fb+YI8pC9fnDomGzj7FPEDX1GtYENGBMPM1Qxj6BLEfzcWTuboqlrWKId1WIFoP cGu5kgKC+1tRp9oUdLgHOVsS5giiILx8e6lWYNWWLAAo1VKmUk5ON4sLTPkh0lvDF8Oe 3DYjVDZivwstvf7+sVwVmVFtUyJlrgAN1YpR/e7YKB0pg5QTwjmiTcd0UejerPts6T4V PVqQq7wy6lYMXWvy0YuWzJR+xQKWPSpz9+ySxIKMYMjq44vMC/5vwbxiNGhefBI2XEff gkPDQ0gbdIlXvNbRbH7eLYZZKV7oQinmdFGmFojkwzDlGL+ynxDyDSdNDZDM+JpF6dbX 0rog== X-Gm-Message-State: APuU4Z87CroNi7EAaQEn0JtMWHHzAf6TErJy/FjCOBbSCw5UG1b+33pw OYBeiDiXLGBb6B4u8OJuTYW/pQTSCsO97Ai2sJKBfmSg8P238zck80bsALvw3XTQ X-Gm-Gg: AZFdTZeR58jyJJvrpIGSWrf6ut0eeX9OHKziBVUgi7NL+uN/4qJ3Nj0XVA6dyFjropR teCRnftdU8uwOE3qu64k0bteLxGWrWMdU+yU6ISUSYIHH9PNQWLcCibZ5prStmYWxT3thuWp4IC Cy0H8v0Fwf3DSUQZbPRUuNZUaiXq/LyeBfolQGFT3f17fBPoXCrSlxvm+6zf82RrRsGnmuaVB9N rEvTnxJzeFTrDeSFB/fU5dPh+P6OL3byAmdP8KDZ0VUx923Zj7w4f5dB/lrouENLxu3FAnGS+iq XSIFamIIpNa3GoxBNML7pInz2kHdbL9Us01D4cCIdowBNjWNLBDIPdmTGsSivLQQLn+pE0V8gtn 5IczrtAGCp8cyek3OtmxImabnW3GRWv2MRgwp3/utoPqJg6T/u935xSsewC3kKkGZlSQQDffvII UY4YySyLJIBR/nJYR0C6ce64FwkuO74G4+smcfxeKwG/oZagPRE9vGruOt4KjDuIndYO1tXCI2g jnZc5vrYx8M2ucOqE8wbOIXKnb77mLbFRISPjuEpykKqgMflkrkk+T0xL6RCt8AqHP2B1nw39d3 HOF81SCOuN7DeSdRvJ7XuOOWnqXnUNNQ0vvcxJ5/L5tjTg== X-Received: by 2002:a05:7301:488d:b0:366:83dd:46f7 with SMTP id 5a478bee46e88-3856f85220amr24514627eec.17.1795742119073; Thu, 26 Nov 2026 17:15:19 -0800 (PST) Received: from localhost.localdomain ([186.143.175.102]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385677c371esm66427587eec.23.2026.11.26.17.15.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2026 17:15:18 -0800 (PST) From: ajrojas To: gdb-patches@sourceware.org Cc: bug-hurd@gnu.org, Samuel Thibault , Flavio Cruz , ajrojas Subject: [PATCH 2/2] gdb/hurd: fix the sigcontext offsets for x86_64 Date: Thu, 26 Nov 2026 22:14:50 -0300 Message-ID: <20261127011450.60158-3-ajrojas.lab@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261127011450.60158-1-ajrojas.lab@gmail.com> References: <20261127011450.60158-1-ajrojas.lab@gmail.com> MIME-Version: 1.0 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 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. --- 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