From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id cIahLTKFyGhh2gUAWB0awg (envelope-from ) for ; Mon, 15 Sep 2025 17:29:22 -0400 Received: by simark.ca (Postfix, from userid 112) id A8F441E04C; Mon, 15 Sep 2025 17:29:22 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, 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 server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 D296E1E04C for ; Mon, 15 Sep 2025 17:29:21 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2D14A3858C83 for ; Mon, 15 Sep 2025 21:29:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D14A3858C83 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by sourceware.org (Postfix) with ESMTPS id 4759E3858D1E for ; Mon, 15 Sep 2025 21:28:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4759E3858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4759E3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757971730; cv=none; b=AcQ52Fyn0DF1WeUq5x85+d+y7gofU2JCYiw0BK/Tc7+ZaqTf3GzQ5AbzATSPsWn7omkUjJIEfDzmDIKFzM0bIkyKwQT+tHqDIlns0adknVCdG7tUDJVj/R1dr5vbIX09BBLZYSgUu5iii4KdsB5VTz/wmirHxmpZ0qT5v7d1gko= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757971730; c=relaxed/simple; bh=EJ4Qz69umZnUp3RVnMPaigFTHwJF0ZrTyotrKOnfvb0=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=J/VeIArR+1Xw8fyI+mRFKIH5Zz9DpYF/Ev/Q6zLZ14vaqkHB+DMugETgTtE1PDVTeqGHx0s0sV4mjCuTQzVuyPM7Srj6NtrudsjOgsu7pTG/EYLf5peEPieJQnAjBncaJPIQb96ilMCKAQbnIv1eHvzPGEXPn/w9cjOZLrAPk8Y= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4759E3858D1E Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-45f29e5e89bso24934055e9.2 for ; Mon, 15 Sep 2025 14:28:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757971729; x=1758576529; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0muZtwwohsY4EIYkHvvzCz9AazjSDPJXBaa4ZecNZww=; b=fcoJNATEJosmmKTHwc+vDECIX77gGyEnaNtrDFKOUKkMvSQwPbhd62UGyDLFoq3wCQ mm0Lhq64uoAXQsDY9aGdtGsqkBa+8R8nUxJK/7ZJAQl7Qo7gNX6OeUXzzgZczoTLJecF JokE+epBrqEeCgYDsyJQqbXCs8KG1eGpGGujaQN9iySQP9eoiC+AVVs+7cFBet2dXZSJ 7KkYGyWlgh7qHA6MAozN49ClcFPmRezWLaklyomLQB8yyiU2V5rArpAAz+ODN6bPapUo vpWpeE+w0jg/pOcwI0mXaFIAjDioIliu3f5Y+bt7Rxs+obxMLUk3fvH+gXGYji/y8y/1 4/7A== X-Gm-Message-State: AOJu0YwxvZImaBAV2aFsBDeMvzb4GI3VzPAAIp8wgzAAjyE4Ed1wqFC1 yW84lvQF3a+eJJgGmgzpgX3mW3mFVaqtbAb9/cFZ+v/zb7l36CEb4UG+bK1IdG0H X-Gm-Gg: ASbGnctECZKq5U3nWyAxJ1aLrsKOTWuxvif00fwFS08PD0Zo6vmQwMNntQdIc6BlB2x nKAyR1DBeoHOFvw956a24fjVWFrqjbF1DQFFsWiJXMfxT22ST8CWTK7OtOY2c2aAAHJpkSBkPKM bkFKPKCqSv3fK1Pt+L53DYcz6k6q6mPope/CBP+ALhngjLSZHJDvFbFX4aWnjE28qE2wfOBnN+0 94QA9eVBeAgCvLHXRoB/tdRSC/pehUaUcgMKe5ViEv1+DVV+i0Cu98v4E3PJTFZ+lVV68rhD8Eu dyNuwqNrj4+68kPegq7nk0YzErB209i28/7CEd+X70UzeojEGJ37F29KjBLboYlBnMJ3XjbHG8X EhRX5fxPzStsxT+ymgCbwdAVWFR+bWpQ= X-Google-Smtp-Source: AGHT+IHFN9ei9YCaj7QfO0EVTKwEDAcIzZwRKYX5I7lY5M7VEjFGEi0PODN4Hs1HSlq4aoxJP+WV7Q== X-Received: by 2002:a05:600c:8b17:b0:45d:f83b:96aa with SMTP id 5b1f17b1804b1-45f211c493emr119254715e9.7.1757971728577; Mon, 15 Sep 2025 14:28:48 -0700 (PDT) Received: from localhost ([2001:8a0:fad8:400:9f0e:9939:cce1:9ecb]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3e7607878c9sm19344085f8f.26.2025.09.15.14.28.46 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 Sep 2025 14:28:47 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH] Fix nested gdb_caching_proc with args; Fix gdb.rocm/ tests Date: Mon, 15 Sep 2025 22:28:41 +0100 Message-ID: <20250915212841.4161603-1-pedro@palves.net> X-Mailer: git-send-email 2.51.0 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 Commit d09eba07 ("Make get_compiler_info use gdb_caching_proc") regressed the gdb.rocm/ testsuite. E.g.: Running /home/pedro/rocm/gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.rocm/simple.exp ... ERROR: tcl error sourcing /home/pedro/rocm/gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.rocm/simple.exp. ERROR: tcl error code TCL WRONGARGS ERROR: wrong # args: should be "gdb_real__get_compiler_info_1 language" while executing "gdb_real__get_compiler_info_1" ("uplevel" body line 1) invoked from within "uplevel 2 $real_name" (procedure "gdb_do_cache_wrap" line 3) invoked from within "gdb_do_cache_wrap $real_name {*}$args" (procedure "gdb_do_cache" line 98) invoked from within This is actually a latent problem in gdb_do_cache_wrap, introduced in: commit 71f1ab80f1aabd70bce526635f84c7b849e8a0f4 CommitDate: Mon Mar 6 16:49:19 2023 +0100 [gdb/testsuite] Allow args in gdb_caching_proc This change: # Call proc real_name and return the result, while ignoring calls to pass. -proc gdb_do_cache_wrap {real_name} { +proc gdb_do_cache_wrap {real_name args} { if { [info procs save_pass] != "" } { return [uplevel 2 $real_name] <<<<<<<<<<<<<<<<<<<<<<< HERE } @@ -31,7 +31,7 @@ proc gdb_do_cache_wrap {real_name} { rename pass save_pass rename ignore_pass pass - set code [catch {uplevel 2 $real_name} result] + set code [catch {uplevel 2 [list $real_name {*}$args]} result] Missed updating the line marked with HERE above, to pass down $args. So the case of a caching proc calling another caching proc with args isn't handled correctly. We could fix this by fixing the HERE line like so: - return [uplevel 2 $real_name] + return [uplevel 2 [list $real_name {*}$args]] However, we have with_override nowadays that we can use here which eliminates the duplicated logic, which was what was missed originally. A new test that exposes the problem is added to gdb.testsuite/gdb-caching-proc.exp. This also adds a new test to gdb.testsuite/with-override.exp that I think was missing, making sure that the inner foo override restores the outer foo override. Change-Id: I8b2a7366bf910902fe5f547bde58c3b475bf5133 --- .../gdb.testsuite/gdb-caching-proc.exp | 21 +++++++++++++------ gdb/testsuite/gdb.testsuite/with-override.exp | 4 ++++ gdb/testsuite/lib/cache.exp | 21 ++----------------- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp b/gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp index f9610afd076..6b46b1c555a 100644 --- a/gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp +++ b/gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp @@ -22,23 +22,32 @@ gdb_caching_proc gdb_testsuite_gdb_caching_proc_exp_arg { arg } { return $arg } +gdb_caching_proc gdb_testsuite_gdb_caching_proc_exp_arg_nested { arg } { + incr ::count + return [gdb_testsuite_gdb_caching_proc_exp_arg $arg] +} + +# List of "expected $::count after running expression" and +# "expression". set assertions { - { [gdb_testsuite_gdb_caching_proc_exp_noarg] == 1 } - { [gdb_testsuite_gdb_caching_proc_exp_arg 1] == 1 } - { [gdb_testsuite_gdb_caching_proc_exp_arg "foo foo"] == "foo foo" } + 1 { [gdb_testsuite_gdb_caching_proc_exp_noarg] == 1 } + 1 { [gdb_testsuite_gdb_caching_proc_exp_arg 1] == 1 } + 1 { [gdb_testsuite_gdb_caching_proc_exp_arg "foo foo"] == "foo foo" } + 1 { [gdb_testsuite_gdb_caching_proc_exp_arg_nested "foo foo"] == "foo foo" } + 2 { [gdb_testsuite_gdb_caching_proc_exp_arg_nested "bar bar"] == "bar bar" } } set assertion_nr 0 -foreach assertion $assertions { +foreach {expected_count assertion} $assertions { with_test_prefix $assertion_nr { set ::count 0 gdb_assert $assertion - gdb_assert { $::count == 1 } + gdb_assert { $::count == $expected_count } with_test_prefix cached { gdb_assert $assertion - gdb_assert { $::count == 1 } + gdb_assert { $::count == $expected_count } } } incr assertion_nr diff --git a/gdb/testsuite/gdb.testsuite/with-override.exp b/gdb/testsuite/gdb.testsuite/with-override.exp index 1a4ee6adbbb..2a316f904e4 100644 --- a/gdb/testsuite/gdb.testsuite/with-override.exp +++ b/gdb/testsuite/gdb.testsuite/with-override.exp @@ -42,6 +42,10 @@ with_test_prefix no-args { gdb_assert { [foo] == 2 } } } + + with_test_prefix "foo1 again" { + gdb_assert { [foo] == 1 } + } } with_test_prefix after { diff --git a/gdb/testsuite/lib/cache.exp b/gdb/testsuite/lib/cache.exp index 6ca3f183f9f..b4c5fab2b98 100644 --- a/gdb/testsuite/lib/cache.exp +++ b/gdb/testsuite/lib/cache.exp @@ -24,26 +24,9 @@ proc ignore_pass { msg } { # Call proc real_name and return the result, while ignoring calls to pass. proc gdb_do_cache_wrap {real_name args} { - if { [info procs save_pass] != "" } { - return [uplevel 2 $real_name] + with_override pass ignore_pass { + return [$real_name {*}$args] } - - rename pass save_pass - rename ignore_pass pass - - set code [catch {uplevel 2 [list $real_name {*}$args]} result] - - rename pass ignore_pass - rename save_pass pass - - if {$code == 1} { - global errorInfo errorCode - return -code error -errorinfo $errorInfo -errorcode $errorCode $result - } elseif {$code > 1} { - return -code $code $result - } - - return $result } # Global written to by gdb_exit_called proc. Is set to true to base-commit: d09eba07ca013e6b95eeafd67d79c32ebf6f28eb -- 2.51.0