From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id mQXgLKMM4WnAbxwAWB0awg (envelope-from ) for ; Thu, 16 Apr 2026 12:21:55 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=i9bsZc9T; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id AAADA1E0C3; Thu, 16 Apr 2026 12:21:55 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.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,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 BAAF31E04F for ; Thu, 16 Apr 2026 12:21:54 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 45A734C318A4 for ; Thu, 16 Apr 2026 16:21:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 45A734C318A4 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=i9bsZc9T Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 9C3044BA9000 for ; Thu, 16 Apr 2026 16:21:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9C3044BA9000 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9C3044BA9000 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776356487; cv=none; b=iAkfxiWAXQg/MIvbL9fDuhkhrb1AK6elbe9C/af48zIuMS3l9a1sc2RUk/2vtTwbifatkUQYT5sexsP1/AHXXLkpv8dIgvYcvifxpl4IDe4PhQ7+6WOhVcsXCDkNEjWDP3leYgV32E9Fn6U4zygmFUX80lxxE61YECmSUJU5EnA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776356487; c=relaxed/simple; bh=Vj8t98RfDhNt8Hmu8xCsVk575kk1loylEyWYnnFU8yA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=itqaRxHBLm1KG57wCF/D9BdwIHeeR8ymzhXXGg2b4FCgiRJLmB4hc8I/4QI34D3pFzbHeBH9+rSIU+dOWJVqVAIIFf/Dp+Vb4VK+jYiPQIZHjDheaj5b981a4gFWpLw7x6ZxpATCml/iDjC7ecmNc8xbyROIiK9LWbCV/Awn8fU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C3044BA9000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776356487; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AsX8x0Ij8oSdd7jvAMfW4tArWslwid7xttPShIo/ZhA=; b=i9bsZc9Ti9WgGgdhQrU0EhZhKBKbWaOxw3jy2SI2Es7QfWx6ClZ0jF+ZpHrfR40eu1mJvU ebhVvOv65pNPZ0AiWB4EKnoxiBa+aO3yNKOZg1Jl2wN0k56tS0Q7jy5sdQHooK/di2yMLz 0XqUTd2KFxrfOAqirL5J7rO3d/WPONQ= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-237-decr26H_NXSogvqYVMcvuA-1; Thu, 16 Apr 2026 12:21:26 -0400 X-MC-Unique: decr26H_NXSogvqYVMcvuA-1 X-Mimecast-MFC-AGG-ID: decr26H_NXSogvqYVMcvuA_1776356485 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-488c2a4e257so53123325e9.3 for ; Thu, 16 Apr 2026 09:21:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776356484; x=1776961284; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AsX8x0Ij8oSdd7jvAMfW4tArWslwid7xttPShIo/ZhA=; b=p5spXjVsb904AhwsY1puevl+1GVAvpu9epu4919zfPM31IvX65Bq5LWGB4T554CVu4 DPkfF/+5nRx+B/YryTk97cLwkBwMM6F6s61zNH4Xd/liPGdR3ySHUSJFs4JMpjDLhj3X LIMOReVK1lxc2T9jUIZ3JnMN2u4RGVuiZH1qsxS5F58le8rDSePCaRTvgS8n2h3QLJ5O zFAWupIFsHSrRNYKT6qg/2M0S55E67PrQapd0BRMPFMA6sAclt32Ahc31rTaHElYkQH4 N+IKhDQhb9dc5jI8Uy2/2OiHX5vjYKYMX4Y7P5zKA/H2U5h2xIMqxh8e1H4PmhdY/uUh P9dw== X-Forwarded-Encrypted: i=1; AFNElJ9t0c9VMkcw+Dz+FU/HIWNYUBIpRbl8QshAwz2sXhY7cjS8MXhFgP6Che41nDbK/KInP9+IHf7dcxFwUg==@sourceware.org X-Gm-Message-State: AOJu0YyyREPMtusXVWwFao8un+PhGBxUPZPWD2wo0i6N4MhYHJ/WUOMj ERE/gTBzoma3C5g2HY+nGSQgtdQIdZ5uQlggDYmKDsMSewInjluX5J8v8a4AIq+11Gttyd4vEoB 4qkukbUhC9iDSdGrLy2PC9vUYIaKF0yfTeByM+eLfEgRh3wicTEYoHJFsnDKFtUiYd0tK0qE= X-Gm-Gg: AeBDievXTwXwaMAD0VS0sDmsAxh2XzN++NUWL6616GBKA7M57K0217sDEwS8+exE9+/ 2zYziBdGK2MqDCyYPeBM9Nl7+8FUEmjSGgYhF6TEiXXgjVDtqkx6vU7MEO8UrUQ/G8i+e0avvjz w8fNjvA+sbhdqKwRgcHZ69NCUA/VFJ7m79xw06whSNto3yucYQthbPUrVwbefBuWobd3LV9mLnc wvkzAv7SJY2I0A0E08BY/mMymU79snh+Nh+iZM2t78AHQrHi7na1zSdSVYBnwnA9+0agu4KoQN3 uUQ92lq9PkONjtVx0mRApkK4pOyxT7AMC3kEt4iOljnPB8eQhnlBkjCfuOU5e3YvMcmFbI8ElzA vfDWbtAzWvagTJSkSmTxycM+oYa8= X-Received: by 2002:a05:600c:8585:b0:486:fc5f:1ab9 with SMTP id 5b1f17b1804b1-488d68398femr258522895e9.14.1776356484103; Thu, 16 Apr 2026 09:21:24 -0700 (PDT) X-Received: by 2002:a05:600c:8585:b0:486:fc5f:1ab9 with SMTP id 5b1f17b1804b1-488d68398femr258522555e9.14.1776356483513; Thu, 16 Apr 2026 09:21:23 -0700 (PDT) Received: from localhost ([31.111.84.232]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488f58233f6sm60919205e9.10.2026.04.16.09.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Apr 2026 09:21:23 -0700 (PDT) From: Andrew Burgess To: Abhay Kandpal , gdb-patches@sourceware.org Cc: Ulrich.Weigand@de.ibm.com, cel@linux.ibm.com, abhay.k@ibm.com, Abhay Kandpal Subject: Re: [PATCH v1] gdb/testsuite: Fix skip-tree.exp for PowerPC post-call NOP In-Reply-To: <20260415055144.2729164-1-abhay@linux.ibm.com> References: <20260415055144.2729164-1-abhay@linux.ibm.com> Date: Thu, 16 Apr 2026 17:21:22 +0100 Message-ID: <875x5qg9kt.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: F_C35S7O3Ly6Rz2uWRH8XUd8Q_GDZCOJQS4jVUt2C_A_1776356485 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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 Abhay Kandpal writes: > The skip-tree.exp test was recently added in commit 5ed98c177f9a > and fails on PowerPC due to architectural differences in function > return handling. > > On PowerPC64 ELFv2, calls to external functions are followed by a > `nop` instruction that serves as a placeholder for TOC pointer > restoration. Since this `nop` typically has no DWARF line entry, > `finish` reports the call line instead of the next line. > > This patch adds a PowerPC-specific `next` command after `finish` in > skip-tree.exp to advance to the expected source line. This handles > the architectural difference without changing GDB's core behavior. > > Tested on ppc64le, x86_64-linux. Abhay, Thanks for looking at this, and apologies for adding a failing PPC test. While I think your proposal is fine, I'd like to suggest the patch below as an alternative. While your change is PPC specific, the patch below is more general and works by spotting the 'finish' returns us to the call line, or the next line. This way, if there are other targets that have the same problem, they will also be fixed by this patch. Would you be OK with me pushing this instead? Thanks, Andrew --- commit 3feb7845032e48bd010291f80591cead065ece40 Author: Andrew Burgess Date: Thu Apr 16 17:55:27 2026 +0200 gdb/testsuite fix skip-tree.exp test for PowerPC The gdb.base/skip-tree.exp test was added in commit: commit 5ed98c177f9a2381fe5c6ab873d05f1e5dcb8f7f Date: Wed Feb 4 20:31:31 2026 +0000 gdb: introduce '**' for skip globs This test currently fails on PowerPC due to architectural differences in function return handling. On PowerPC64 ELFv2, calls to external functions are followed by a `nop` instruction that serves as a placeholder for TOC pointer restoration. Since this `nop` typically has no DWARF line entry, `finish` reports the call line instead of the next line. This issue was reported here: https://inbox.sourceware.org/gdb-patches/20260415055144.2729164-1-abhay@linux.ibm.com The fix proposed there was to add a PowerPC specific check so that the test would send a `next` command after using `finish` to advance to the expected source line. This commit actually takes a more general approach. After calling `finish` we check which line we ended up on. If it was the caller line then we send GDB a `next` to move to the expected line. If we arrive directly at the next line, then no `next` is needed. I've tested this change on x86-64, where no `next` is needed, and PowerPC, where `next` is now used as required to get the test passing. To simplify the pattern matching in the exp file, I tweaked the source file slightly. But adding a call to a dummy 'func5' it's now easy to pattern match as we step through 'func1', 'func2', etc. Co-Authored-By: Abhay Kandpal diff --git a/gdb/testsuite/gdb.base/skip-tree.c b/gdb/testsuite/gdb.base/skip-tree.c index 4a254b860b1..3bedc397a85 100644 --- a/gdb/testsuite/gdb.base/skip-tree.c +++ b/gdb/testsuite/gdb.base/skip-tree.c @@ -22,17 +22,26 @@ extern void func4 (void); static volatile int global_var; +void +func5 (void) +{ + /* Nothing. */ +} + int main (void) { + /* Some filler before the real work starts. */ ++global_var; func1 (); /* In aa/bb/file.c */ func2 (); /* In cc/bb/file.c */ func3 (); /* In dd/ee/file.c */ func4 (); /* In dd/ee/ff/file.c */ + func5 (); /* Makes exp file simpler. */ - ++global_var; /* End marker. */ + /* Some filler before the function ends. */ + ++global_var; return 0; } diff --git a/gdb/testsuite/gdb.base/skip-tree.exp b/gdb/testsuite/gdb.base/skip-tree.exp index dc93c4cef84..b1d42ffa87e 100644 --- a/gdb/testsuite/gdb.base/skip-tree.exp +++ b/gdb/testsuite/gdb.base/skip-tree.exp @@ -48,7 +48,7 @@ set lineno_f1 [gdb_get_line_number "func1 ();" $srcfile] set lineno_f2 [gdb_get_line_number "func2 ();" $srcfile] set lineno_f3 [gdb_get_line_number "func3 ();" $srcfile] set lineno_f4 [gdb_get_line_number "func4 ();" $srcfile] -set lineno_end [gdb_get_line_number "End marker" $srcfile] +set lineno_f5 [gdb_get_line_number "func5 ();" $srcfile] # Compile all the source files into DESTFILE. If RELATIVE_FILENAMES # is true then the compilation is done using relative filenames to the @@ -139,19 +139,29 @@ proc run_test { file_glob skip_func1 skip_func2 skip_func3 skip_func4 \ "$::decimal\\s+\\+\\+global_var_$i;"] \ "step into func$i" - # Now finish the function, returning to the caller. - gdb_test "finish" ".*" \ - "finish from func$i" + # Now finish the function, returning to the caller. Some + # targets, after the finish, will place the inferior back + # on the calling line. We spot this and issue a 'next' to + # move forward to the next function call. + set saw_next_line false + set saw_previous_line false + gdb_test_multiple "finish" "finish from func$i" { + -re -wrap "\r\n$::decimal\\s+func[expr {$i + 1}] \\(\\);\[^\r\n\]*" { + pass $gdb_test_name + } + -re -wrap "\r\n$::decimal\\s+func$i \\(\\);\[^\r\n\]*" { + # After 'finish' this target reports the inferior + # as still on the calling line. Use 'next' to + # prepare for the next test. + send_gdb "next\n" + exp_continue + } + } } else { # After skipping the function, on which line should we # stop, and what does the line look like. - if { $j < 5 } { - set lineno [set "::lineno_f$j"] - set after_skip_re "func$j \\(\\);\[^\r\n\]+" - } else { - set lineno $::lineno_end - set after_skip_re "\\+\\+global_var;\[^\r\n\]+" - } + set lineno [set "::lineno_f$j"] + set after_skip_re "func$j \\(\\);\[^\r\n\]+" # Step the inferior, we expect to skip the function. gdb_test "step" \