Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [pushed] [gdb/testsuite] Factor out unproc
Date: Wed, 23 Sep 2026 17:53:06 +0200	[thread overview]
Message-ID: <20260923155306.386212-1-tdevries@suse.de> (raw)

I noticed in gdb.rocm/hcc-amdgpu-targets.exp:
...
    rename find_amdgpu_devices {}
...

This deletes the proc find_amdgpu_devices.

Unlike something like unset, it's not obvious what this does.

Fix this by:
- factoring out the rename into a new proc unproc, named using the set/unset
  pattern, and
- adding a comment in unproc explaining what the effect of a rename to empty
  string is.

Apply it using:
...
$ find gdb/testsuite -type f -name *.exp* \
      | xargs sed -i 's/rename \(.*\) {}/unproc \1/'
...
and likewise for "".

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.guile/scm-parameter.exp     |  2 +-
 gdb/testsuite/gdb.python/py-parameter.exp     |  2 +-
 gdb/testsuite/gdb.rocm/hcc-amdgpu-targets.exp |  2 +-
 gdb/testsuite/lib/dwarf.exp                   |  4 ++--
 gdb/testsuite/lib/future.exp                  | 16 ++++++++--------
 gdb/testsuite/lib/gdb.exp                     | 10 ++++++++--
 6 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/gdb/testsuite/gdb.guile/scm-parameter.exp b/gdb/testsuite/gdb.guile/scm-parameter.exp
index 123f45dbb49..c659ac2752b 100644
--- a/gdb/testsuite/gdb.guile/scm-parameter.exp
+++ b/gdb/testsuite/gdb.guile/scm-parameter.exp
@@ -562,7 +562,7 @@ with_test_prefix "set/show parameter" {
     gdb_test "show test-prefix-2" "^invoke -- show"
 }
 
-rename scm_param_test_maybe_no_output ""
+unproc scm_param_test_maybe_no_output
 
 # Test a color parameter.
 
diff --git a/gdb/testsuite/gdb.python/py-parameter.exp b/gdb/testsuite/gdb.python/py-parameter.exp
index b606b13b4ec..2a7a9b13fb6 100644
--- a/gdb/testsuite/gdb.python/py-parameter.exp
+++ b/gdb/testsuite/gdb.python/py-parameter.exp
@@ -912,4 +912,4 @@ test_ambiguous_parameter
 test_unknown_prefix
 test_set_show_parameters
 
-rename py_param_test_maybe_no_output ""
+unproc py_param_test_maybe_no_output
diff --git a/gdb/testsuite/gdb.rocm/hcc-amdgpu-targets.exp b/gdb/testsuite/gdb.rocm/hcc-amdgpu-targets.exp
index 8f04cca7981..690ecb8af32 100644
--- a/gdb/testsuite/gdb.rocm/hcc-amdgpu-targets.exp
+++ b/gdb/testsuite/gdb.rocm/hcc-amdgpu-targets.exp
@@ -28,7 +28,7 @@ proc with_stub_devices {devices body} {
     # tclint-disable-next-line command-args
     proc find_amdgpu_devices {} [list return $devices]
     set code [catch {uplevel 1 $body} result]
-    rename find_amdgpu_devices {}
+    unproc find_amdgpu_devices
     rename __saved_find_amdgpu_devices find_amdgpu_devices
     return -code $code $result
 }
diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index 839c5174265..b37d63b868f 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -3060,8 +3060,8 @@ namespace eval Dwarf {
 	variable _level
 	uplevel $_level $body
 
-	rename include_dir ""
-	rename file_name ""
+	unproc include_dir
+	unproc file_name
 
 	_line_finalize_header
 
diff --git a/gdb/testsuite/lib/future.exp b/gdb/testsuite/lib/future.exp
index fbe517f116b..44fc17b3f00 100644
--- a/gdb/testsuite/lib/future.exp
+++ b/gdb/testsuite/lib/future.exp
@@ -705,7 +705,7 @@ if {[info procs find_gnatmake] == ""} {
     set use_gdb_compile(ada) 1
     gdb_note [join [list $note_prefix "Ada" $note_suffix] ""]
 } else {
-    rename gdb_find_gnatmake ""
+    unproc gdb_find_gnatmake
 }
 
 if {[info procs find_gfortran] == ""} {
@@ -713,7 +713,7 @@ if {[info procs find_gfortran] == ""} {
     set use_gdb_compile(fortran) 1
     gdb_note [join [list $note_prefix "Fortran" $note_suffix] ""]
 } else {
-    rename gdb_find_gfortran ""
+    unproc gdb_find_gfortran
 }
 
 if {[info procs find_go_linker] == ""} {
@@ -722,8 +722,8 @@ if {[info procs find_go_linker] == ""} {
     set use_gdb_compile(go) 1
     gdb_note [join [list $note_prefix "Go" $note_suffix] ""]
 } else {
-    rename gdb_find_go ""
-    rename gdb_find_go_linker ""
+    unproc gdb_find_go
+    unproc gdb_find_go_linker
 }
 
 if {[info procs find_gdc] == ""} {
@@ -731,7 +731,7 @@ if {[info procs find_gdc] == ""} {
     set use_gdb_compile(d) 1
     gdb_note [join [list $note_prefix "D" $note_suffix] ""]
 } else {
-    rename gdb_find_gdc ""
+    unproc gdb_find_gdc
 }
 
 if {[info procs find_rustc] == ""} {
@@ -739,7 +739,7 @@ if {[info procs find_rustc] == ""} {
     set use_gdb_compile(rust) 1
     gdb_note [join [list $note_prefix "Rust" $note_suffix] ""]
 } else {
-    rename gdb_find_rustc ""
+    unproc gdb_find_rustc
 }
 
 if {[info procs find_hip_compiler] == ""} {
@@ -747,7 +747,7 @@ if {[info procs find_hip_compiler] == ""} {
     set use_gdb_compile(hip) 1
     gdb_note [join [list $note_prefix "HIP" $note_suffix] ""]
 } else {
-    rename gdb_find_hip_compiler ""
+    unproc gdb_find_hip_compiler
 }
 
 # If dejagnu's default_target_compile is missing support for any language,
@@ -756,7 +756,7 @@ if { [array size use_gdb_compile] != 0 } {
     catch {rename default_target_compile dejagnu_default_target_compile}
     rename gdb_default_target_compile default_target_compile
 } else {
-    rename gdb_default_target_compile ""
+    unproc gdb_default_target_compile
 }
 
 # Various ccache versions provide incorrect debug info such as ignoring
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 1ebdaf6ba10..58753e721fd 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -8930,7 +8930,7 @@ proc gdb_finish { } {
 
     if { [info procs ::gdb_tcl_unknown] != "" } {
 	# Restore dejagnu's version of proc unknown.
-	rename ::unknown ""
+	unproc ::unknown
 	rename ::dejagnu_unknown ::unknown
     }
 
@@ -11351,7 +11351,7 @@ proc with_override { name override body } {
 	# tclint-disable-next-line command-args
 	proc $name $old_args $old_body
     } else {
-	rename $name ""
+	unproc $name
     }
 
     # Return as appropriate.
@@ -12466,6 +12466,12 @@ proc unprintable_to_octal { input_string } {
 # Ignore args and don't do anything.  Can be used with proc with_override.
 proc nop {args} {}
 
+# Delete proc P.
+proc unproc {p} {
+    # Renaming to an empty string deletes proc P.
+    uplevel 1 [list rename $p {}]
+}
+
 require {tcl_version_at_least 8 6 2}
 
 # Always load compatibility stuff.

base-commit: 441953ac9d0b2902be92906817c68feadccd190f
-- 
2.51.0


             reply	other threads:[~2026-09-23 15:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23 15:53 Tom de Vries [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-09-23 15:25 Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260923155306.386212-1-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox