From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id l9BSNIrKOmn9zzMAWB0awg (envelope-from ) for ; Thu, 11 Dec 2025 08:43:38 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=kRghq6Q4; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=7KjvyguB; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=pqlKAZTA; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=wSEUVTwq; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id C7CF71E0B6; Thu, 11 Dec 2025 08:43:38 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED 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 B12051E048 for ; Thu, 11 Dec 2025 08:43:37 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id D6ABC4BA2E2F for ; Thu, 11 Dec 2025 13:43:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D6ABC4BA2E2F Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=kRghq6Q4; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=7KjvyguB; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=pqlKAZTA; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=wSEUVTwq Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 6E2824BA2E06 for ; Thu, 11 Dec 2025 13:39:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6E2824BA2E06 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6E2824BA2E06 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765460390; cv=none; b=G58gUfW108RLkZBn68yq0W/ucvNfWt7SYZYamU/6VjyVMWUCVXLoRa80ikc9Adb2B5qRUYpx0w/IS5j65BM7eIUFJ23lV+keXoM0Za3HTi6vzn0jUd4MhSaBprB/fIbdQ2qECS7plAZlD9jj/kDMQUFoViNWvwmBT9XdxFWIZK8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765460390; c=relaxed/simple; bh=ODgq/He1BedSAXKwT/GGStpm2LSZXoLeglokPs2rLlQ=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=TCMjwC/lk2X1v6ea/wPlwQ3WBLBkLmwGSfk+4F5ln9+4MaJY3z2hIhDUWDL3SvbRuieICGl3/dABJZMRyfeqTsCDND7gdXqHNMWROwT0zsE1Ia2lZX2oMe01yG3+9ajb24inXgBPhcTvzyJ/dVs0CetOog/bhUBmzL3rMTWfOiU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E2824BA2E06 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0EE2E3371B for ; Thu, 11 Dec 2025 13:39:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1765460388; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=O0sm/HBFaIS8AJjOHf0BpSc5uT7Yg3RJ8pKPmtMRthg=; b=kRghq6Q4MqjUqydFepAKVXWK94i6eQzyYdKS6m+6V7hADwvsqF6pbEtd2zxYJck8BFjuRO N9VvJq/q9Rg0GBjPBKmZtIBI7SMQe4p680l3U3Vcb24fK6Pm8Sb5lsO/WJRN/80sXP24LX Y6pILdMKermia3+UF9NsenS02a7SIl0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1765460388; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=O0sm/HBFaIS8AJjOHf0BpSc5uT7Yg3RJ8pKPmtMRthg=; b=7KjvyguB/38OaQ7SHOnKzKaPnnuu+jYDNbVcCBKGoRElJJK1Zx4YAphY52/j4JJqlhrMiT DNgRHYJFp589ibBg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=pqlKAZTA; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=wSEUVTwq DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1765460387; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=O0sm/HBFaIS8AJjOHf0BpSc5uT7Yg3RJ8pKPmtMRthg=; b=pqlKAZTA1ocSkAZcL6g9a6upe91x1cSo1+UsyZpH2K6GE84ESVH/qCLbu/uvP/gAjLMKpQ QAWbZXvd/uvwJi1TLc7yFNbIy/QQE67wpYgL1+Bd9IookDX3sayRckS6zizeU/0fIsvETD Md5cc/vv+BUSbvLLRI9VQfigw+JJ9gk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1765460387; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=O0sm/HBFaIS8AJjOHf0BpSc5uT7Yg3RJ8pKPmtMRthg=; b=wSEUVTwqeuAH2bQe/ZCJhPB2viG1SqCXS8ZigC66BLWabEgrPOJY5aQ9m9lNDooXm7t/9H RqlxSp3sgjHqobDQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id EEA553EA63 for ; Thu, 11 Dec 2025 13:39:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id cwb5OKLJOmnTZAAAD6G6ig (envelope-from ) for ; Thu, 11 Dec 2025 13:39:46 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/testsuite] Fix gdb.base/inline-frame-cycle-unwind.exp for s390x (alternative) Date: Thu, 11 Dec 2025 14:39:46 +0100 Message-ID: <20251211133946.962934-1-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 0EE2E3371B X-Spamd-Result: default: False [-4.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; DWL_DNSWL_LOW(-1.00)[suse.de:dkim]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; TO_DN_NONE(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:dkim,suse.de:mid]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Action: no action 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 With test-case gdb.base/inline-frame-cycle-unwind.exp on s390x-linux, I run into: ... (gdb) bt^M #0 inline_func () at inline-frame-cycle-unwind.c:49^M #1 normal_func () at inline-frame-cycle-unwind.c:32^M #2 0x000000000100065c in inline_func () at inline-frame-cycle-unwind.c:45^M #3 normal_func () at inline-frame-cycle-unwind.c:32^M Backtrace stopped: previous frame identical to this frame (corrupt stack?)^M (gdb) FAIL: $exp: bt: cycle at level 5: backtrace when the unwind is broken \ at frame 5 ... In contrast, on x86_64-linux, I get: ... (gdb) bt^M #0 inline_func () at inline-frame-cycle-unwind.c:49^M #1 normal_func () at inline-frame-cycle-unwind.c:32^M #2 0x0000000000401157 in inline_func () at inline-frame-cycle-unwind.c:45^M #3 normal_func () at inline-frame-cycle-unwind.c:32^M #4 0x0000000000401157 in inline_func () at inline-frame-cycle-unwind.c:45^M #5 normal_func () at inline-frame-cycle-unwind.c:32^M Backtrace stopped: previous frame identical to this frame (corrupt stack?)^M (gdb) PASS: $exp: bt: cycle at level 5: backtrace when the unwind is broken \ at frame 5 ... AFAIU, the mechanism of the test is as follows: the custom unwinder produces the frame-id for frame #5 at frame #4. Consequently, when arriving at frame #5, a cycle is detected. [ It took me a while to understand this because of the following off-by-one confusion: for frame #0, we get pending_frame.level() == 1. So when stop_at_level == 5, the custom unwinder calculates a frame-id for frame #4, not frame #5. But the frame-id it calculates is the one for frame #5, so unwinding will stop at frame #5 because the frame-ids for frame #4 and frame #5 are identical. ] This relies on the test-case to calculate the offending frame-id, and the problem on s390x is that that calculation is incorrect. Fix this by using "maint print frame-id" to get all frame-ids, and using those instead. Tested on x86_64-linux and s390x-linux. --- .../gdb.base/inline-frame-cycle-unwind.exp | 13 +++++++++++++ gdb/testsuite/gdb.base/inline-frame-cycle-unwind.py | 8 +++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp index 7fc47af624f..5c6504323ee 100644 --- a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp +++ b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp @@ -72,6 +72,19 @@ gdb_continue_to_breakpoint "stop at test breakpoint" gdb_test_no_output "source ${pyfile}"\ "import python scripts" +foreach_with_prefix n { 0 1 2 3 4 5 6 } { + set sp 0x0 + set pc 0x0 + gdb_test_multiple "maint print frame-id $n" "" { + -re -wrap "frame-id for frame #$n: {stack=($hex),code=($hex),.*}" { + set sp $expect_out(1,string) + set pc $expect_out(2,string) + gdb_test_no_output "python frame_id_sp.append($sp)" + gdb_test_no_output "python frame_id_pc.append($pc)" + } + } +} + # Test with and without filters. foreach bt_cmd { "bt" "bt -no-filters" } { with_test_prefix "$bt_cmd" { diff --git a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.py b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.py index 55dea989512..25a67b1a7c9 100644 --- a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.py +++ b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.py @@ -26,6 +26,9 @@ stop_at_level = None # function called recursively. stack_adjust = None +frame_id_sp = [] +frame_id_pc = [] + class FrameId(object): def __init__(self, sp, pc): @@ -55,9 +58,8 @@ class TestUnwinder(Unwinder): if stop_at_level not in [1, 3, 5]: raise gdb.GdbError("invalid stop_at_level") - sp_desc = pending_frame.architecture().registers().find("sp") - sp = pending_frame.read_register(sp_desc) + stack_adjust - pc = (gdb.lookup_symbol("normal_func"))[0].value().address + sp = frame_id_sp[stop_at_level] + pc = frame_id_pc[stop_at_level] unwinder = pending_frame.create_unwind_info(FrameId(sp, pc)) for reg in pending_frame.architecture().registers("general"): base-commit: 2271dee682787051c0628c869d7cdb220bdd0e67 -- 2.51.0