From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 2SCTMsnZCGsxhwEAWB0awg (envelope-from ) for ; Thu, 26 Nov 2026 20:15:53 -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=RilvNOsc; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id C97211E166; Thu, 26 Nov 2026 20:15:53 -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 DA58A1E023 for ; Thu, 26 Nov 2026 20:15:52 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8AA2443EAFC2 for ; Fri, 27 Nov 2026 01:15:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8AA2443EAFC2 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=RilvNOsc Received: from mail-dy1-x1329.google.com (mail-dy1-x1329.google.com [IPv6:2607:f8b0:4864:20::1329]) by sourceware.org (Postfix) with ESMTPS id 0F9F8477CE69 for ; Fri, 27 Nov 2026 01:15:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0F9F8477CE69 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 0F9F8477CE69 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1329 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795742113; cv=none; b=x6NigSsMg0vRdBtsoqLIbf8dGzMTpuiG077BkOkIHhcyKfXFh8QXrYzXyisOtBr1JNryZEf6gvn/44pNwmV72rCES1ASkJIdVe1c+G6ZBmeupjQxTVLP9HUF+HO9P1pEU5Tch8U2mjXKvOko4CQ/Fzggs6aptzsvWcw2s4Szr3M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795742113; c=relaxed/simple; bh=wJK8thSprEdIxgJ7/9c17w84lHpEhUXH2sCpCMLW4FU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=XuyPzy7pTttUCWAemLtBqHTzOumwdOFWI/t7wyg+3QZAAzeFVxMi6LNGDSuEF1mMvzWaolFiuRhsrxgbXjIYiqa/z9USDuSyeu/pkrBUiW2UmpdJhdtoiEPYWuiyfJ2ioHGfXZs7dLM7w7a2R/HsycR5LXryK5vlLbViZeOyDKw= 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=RilvNOsc DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0F9F8477CE69 Received: by mail-dy1-x1329.google.com with SMTP id 5a478bee46e88-385c497bf94so6724998eec.1 for ; Thu, 26 Nov 2026 17:15:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795742112; x=1796346912; 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=6HRv9Y02C/hDQ3dNFmaT1Sk0QbKFbDP4LRRDKA+VEL8=; b=RilvNOscnAmUfLbZyWorearoYG3zMQomuAPzWy8cEhuzxrIDE+HO/CC9Gdywsk99Ye yVBlXUiIyHpEeujj07s3SfqeqdYIpLGkvX5Bl6pnqnDiZg+vy2KR6RP7S5V8ya8wRs3d /o4Ls/72R1cVTtMP7O0e9poBSozd/gkRBNxHvDia5ACzS1x0bm3ujuYrH6+x6xLu7Lrt aJG0RdeUpeNRhKeiFsHnQAuJhxgVWzxx+GlozxVGX3+maAHxGM6jsPddZHGoj81RVqTm umKsxG5Gb1TKatyFNp5q90FWOOLgg9WwmKnG+z3xfYUbyWc9SBw3TAyg1fFJUJoycJHB 6Sxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795742112; x=1796346912; 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=6HRv9Y02C/hDQ3dNFmaT1Sk0QbKFbDP4LRRDKA+VEL8=; b=vK4quCyQI8ohHaWTonimY8vujO21a6TfqG5upacpjRvy1Ea+RsIC14wJtjA/bUfUV/ I4JVyQS9jhCEDStHA1G/cJptSUokKRYTd60b/j5e7QXb/7R7ZMubxVx/ehdyxziM6sUU 3rnsoXt5r/AXOEdEOCeiHY16wbbxLCDqtP8hECUw9dDKKj7rOETHlq9i/zKvy4JoZfkF jAZpiJZIxjeHwRWlCOLiyURl2GEoccbU/VBl62m3pqu6Kh9UzyvMDh3iDXgAn+E6LFOH hmfsc+aPoqSt5CZtv8SEDlWrUA+AX+wGMSEiZ42mzlFVr1/268W86Ws+vVgH5e7hlUHc OHAA== X-Gm-Message-State: APuU4Z9ZCpHvGMi+z+4ih5Wu51EhaHlzny4NsOv//gZzR0dnFWe07ACv JOHErjPtk5GQ+TMcWEX6vi39JIQz5N58cQ4xJeB0mcUZtvK9v7oe3V1wmJw2zYXE X-Gm-Gg: AZFdTZdhS3i0mxjPYyGUdAtly0yMB5WBddFT9vk0XzOnIThAYEWYEk8WTJHoZEV3Etk oIxSp0BZriJOaCV483YZV3LSv/SvluhzUJ7dpKlP95AkOZWRntBj9Xu5sYsCPdMI+/rwo57TkPz ZLGPg/FURMDq6heu7eUQ7SVdeC+8WndJgLeCVSWgMyTxVPcMTiAp6SrDd1YgdUGQ2HqfusMco5K D7rJBlIpzDMqjjZ9TGrVsoh3wbpVUO+0gXmc14DpHBxksQoLtRHjtDJQKNkxqGCJxYuQilXULp7 58VE3eZko8yawS90qu6DxbXMU37XTVFLmbwR6JzyKrd3kb6WM06lWWDrGY3m7Z569r0s2TIGbvU oi1BeV5HzReCmIfDGIzeJGF3+boLYUtbqN4J4W6lYBIAlEyyxkt3Rcp+NITRceyKIY17qvkT9Md LVXuP0iSNP/ABtn+3Ge2SfgX0n+VNsnxdPvVXB4HRTbk7iMi87SLAUagV76LdeCXG1erKI5LtHO OLr0/BZyUKWm2Svvbki8ZDKOsvtPIOg5Q1azkkrHVAIxj52tJWBRz6+jMQEO/53z2iMlMo1ey6t RZnkLgNN4CEp1Tq/XToL1r8isFNQfXc2K1ozS818aygbtA== X-Received: by 2002:a05:693c:87cc:20b0:358:3426:d601 with SMTP id 5a478bee46e88-3856c0d0961mr23368747eec.2.1795742111979; Thu, 26 Nov 2026 17:15:11 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2026 17:15:11 -0800 (PST) From: ajrojas To: gdb-patches@sourceware.org Cc: bug-hurd@gnu.org, Samuel Thibault , Flavio Cruz , ajrojas Subject: [PATCH 1/2] gdb/hurd: fix the gregset offsets for x86_64 core files Date: Thu, 26 Nov 2026 22:14:49 -0300 Message-ID: <20261127011450.60158-2-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_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. --- 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