* [pushed] [gdb/testsuite] Eliminate return -code
@ 2026-09-24 21:29 Tom de Vries
0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2026-09-24 21:29 UTC (permalink / raw)
To: gdb-patches
A statement:
...
return -code return
...
is equivalent to:
...
transparent_uplevel {
return
}
...
The -code stuff is shorter and native Tcl, but hard to understand.
The transparent_uplevel is more intuitive, so replace the former with the
latter.
Likewise for continue and break.
---
gdb/testsuite/gdb.base/commands.exp | 4 +++-
gdb/testsuite/gdb.base/foll-vfork.exp | 24 +++++++++----------
gdb/testsuite/gdb.base/hook-stop.exp | 4 +++-
gdb/testsuite/gdb.cp/breakpoint.exp | 4 +++-
gdb/testsuite/gdb.mi/mi-nonstop.exp | 4 +++-
gdb/testsuite/gdb.mi/mi-ns-stale-regcache.exp | 4 +++-
gdb/testsuite/gdb.mi/mi-watch-nonstop.exp | 4 +++-
.../access-mem-running-thread-exit.exp | 6 +++--
.../gdb.threads/interrupt-while-step-over.exp | 4 +++-
.../process-dies-while-detaching.exp | 4 +++-
gdb/testsuite/lib/compile-support.exp | 4 +++-
gdb/testsuite/lib/gdb.exp | 18 ++++++++------
12 files changed, 54 insertions(+), 30 deletions(-)
diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp
index c64c5fa3135..f7e6f3a4c5b 100644
--- a/gdb/testsuite/gdb.base/commands.exp
+++ b/gdb/testsuite/gdb.base/commands.exp
@@ -41,7 +41,9 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile $flags] } {
proc runto_or_return {function} {
if { ![runto factorial] } {
- return -code return
+ transparent_uplevel {
+ return
+ }
}
}
diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp
index c4eac8bb4f6..cacf61ad755 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.exp
+++ b/gdb/testsuite/gdb.base/foll-vfork.exp
@@ -50,11 +50,16 @@ if { [is_remote target] } {
# Start with a fresh GDB, with verbosity enabled, and run to main. On
# error, behave as "return", so we don't try to continue testing with
# a borked session.
-proc setup_gdb { binfile srcfile } {
+proc setup_gdb { binfile srcfile {message ""} } {
clean_restart $binfile
if {![runto_main]} {
- return -code return
+ if {$message != ""} {
+ unsupported $message
+ }
+ transparent_uplevel {
+ return
+ }
}
gdb_breakpoint [gdb_get_line_number " VFORK " $srcfile] -temporary
@@ -62,14 +67,7 @@ proc setup_gdb { binfile srcfile } {
}
proc check_vfork_catchpoints {} {
- # Because setup_gdb uses 'return -code return' which would return to
- # our caller we need to wrap this call, spot when setup_gdb failed
- # (with return code 2), and then issue our own 'return -code return'.
- set code [catch {setup_gdb $::binfile $::srcfile} string]
- if { $code == 2 } {
- unsupported "vfork catchpoints"
- return -code return
- }
+ setup_gdb $::binfile $::srcfile "vfork catchpoints"
# Verify that the system supports "catch vfork".
gdb_test "catch vfork" "Catchpoint \[0-9\]* \\(vfork\\)" "insert first vfork catchpoint"
@@ -85,8 +83,10 @@ proc check_vfork_catchpoints {} {
}
if {$has_vfork_catchpoints == 0} {
- unsupported "vfork catchpoints"
- return -code return
+ unsupported "vfork catchpoints"
+ transparent_uplevel {
+ return
+ }
}
}
diff --git a/gdb/testsuite/gdb.base/hook-stop.exp b/gdb/testsuite/gdb.base/hook-stop.exp
index de2fd14c703..27016db3c87 100644
--- a/gdb/testsuite/gdb.base/hook-stop.exp
+++ b/gdb/testsuite/gdb.base/hook-stop.exp
@@ -40,7 +40,9 @@ proc setup {commands} {
clean_restart $::testfile
if {![runto_main]} {
- return -code return
+ transparent_uplevel {
+ return
+ }
}
gdb_test "break func" \
diff --git a/gdb/testsuite/gdb.cp/breakpoint.exp b/gdb/testsuite/gdb.cp/breakpoint.exp
index 936015e6709..57db933b03a 100644
--- a/gdb/testsuite/gdb.cp/breakpoint.exp
+++ b/gdb/testsuite/gdb.cp/breakpoint.exp
@@ -33,7 +33,9 @@ proc test_breakpoint {name} {
# Restart the program every time, so that a single failure doesn't
# lead to a cascade.
if {![runto_main]} {
- return -code continue
+ transparent_uplevel {
+ continue
+ }
} else {
gdb_breakpoint "${name}"
gdb_test "continue" "Continuing.\r\n\r\nBreakpoint \[0-9\]*, ${name}.*" "continue to ${name}"
diff --git a/gdb/testsuite/gdb.mi/mi-nonstop.exp b/gdb/testsuite/gdb.mi/mi-nonstop.exp
index 970b11a2f8e..d350de2df62 100644
--- a/gdb/testsuite/gdb.mi/mi-nonstop.exp
+++ b/gdb/testsuite/gdb.mi/mi-nonstop.exp
@@ -24,7 +24,9 @@ proc mi_nonstop_resume { command test } {
# If a resume fails, assume non-stop is broken or unsupported
# for this target. We have logged a FAIL or UNSUPPORTED; skip
# the remaining tests to limit timeouts.
- return -code continue
+ transparent_uplevel {
+ continue
+ }
}
}
diff --git a/gdb/testsuite/gdb.mi/mi-ns-stale-regcache.exp b/gdb/testsuite/gdb.mi/mi-ns-stale-regcache.exp
index d5f6a1ec16b..7e72b456ce2 100644
--- a/gdb/testsuite/gdb.mi/mi-ns-stale-regcache.exp
+++ b/gdb/testsuite/gdb.mi/mi-ns-stale-regcache.exp
@@ -26,7 +26,9 @@ proc mi_nonstop_resume { command test } {
# If a resume fails, assume non-stop is broken or unsupported
# for this target. We have logged a FAIL or UNSUPPORTED; skip
# the remaining tests to limit timeouts.
- return -code continue
+ transparent_uplevel {
+ continue
+ }
}
}
diff --git a/gdb/testsuite/gdb.mi/mi-watch-nonstop.exp b/gdb/testsuite/gdb.mi/mi-watch-nonstop.exp
index 7f972ea6ea6..da9c24618eb 100644
--- a/gdb/testsuite/gdb.mi/mi-watch-nonstop.exp
+++ b/gdb/testsuite/gdb.mi/mi-watch-nonstop.exp
@@ -23,7 +23,9 @@ proc mi_nonstop_resume { command test } {
# If a resume fails, assume non-stop is broken or unsupported
# for this target. We have logged a FAIL or UNSUPPORTED; skip
# the remaining tests to limit timeouts.
- return -code continue
+ transparent_uplevel {
+ continue
+ }
}
}
diff --git a/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp b/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp
index d0db40c4be5..d8e431fee7b 100644
--- a/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp
+++ b/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp
@@ -144,8 +144,10 @@ proc test { non_stop } {
if {[gdb_test -nopass \
$cmd $pattern "access mem ($message, inf=$inf, iter=$iter)"] \
!= 0} {
- uplevel 1 {set ok 0}
- return -code break
+ transparent_uplevel {
+ set ok 0
+ break
+ }
}
}
diff --git a/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp b/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
index e8b29dce2fa..ee5a0a7b218 100644
--- a/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
+++ b/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
@@ -63,7 +63,9 @@ proc enable_debug {enable} {
proc return_if_nonzero { result } {
if {$result != 0} {
- return -code return $result
+ transparent_uplevel {
+ return $result
+ }
}
}
diff --git a/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp b/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp
index edc15f25b06..edc5d0b1da7 100644
--- a/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp
+++ b/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp
@@ -68,7 +68,9 @@ proc test_server_exit {} {
proc return_if_fail { result } {
if {$result != 0} {
- return -code return
+ transparent_uplevel {
+ return
+ }
}
}
diff --git a/gdb/testsuite/lib/compile-support.exp b/gdb/testsuite/lib/compile-support.exp
index 8b6e7f8c9fb..e673088c972 100644
--- a/gdb/testsuite/lib/compile-support.exp
+++ b/gdb/testsuite/lib/compile-support.exp
@@ -210,7 +210,9 @@ namespace eval ::CompileExpression {
}
}
if {!$ok} {
- return -code return 0
+ transparent_uplevel {
+ return 0
+ }
}
}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 0c697b0b976..9ade9a16818 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -11581,14 +11581,18 @@ proc require { args } {
error "proc $fn returned a list of unexpected length $len"
}
- if {$required_val != !!$actual_val} {
- if { [string length $msg] > 0 } {
- unsupported "require failed: $arg ($msg)"
- } else {
- unsupported "require failed: $arg"
- }
+ if {$required_val == !!$actual_val} {
+ continue
+ }
- return -code return 0
+ if { [string length $msg] > 0 } {
+ unsupported "require failed: $arg ($msg)"
+ } else {
+ unsupported "require failed: $arg"
+ }
+
+ transparent_uplevel {
+ return 0
}
}
}
base-commit: 1b4798a583207d0f65ada393ac43d2b81f422961
--
2.51.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-24 21:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-24 21:29 [pushed] [gdb/testsuite] Eliminate return -code Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox