[07/11,gdb/testsuite] Refactor exception handling in gdb_expect

Message ID 20260824135855.1195963-8-tdevries@suse.de
State New
Headers
Series Refactor exception handling |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Tom de Vries Aug. 24, 2026, 1:58 p.m. UTC
  Simplify gdb_expect using transparent_uplevel.
---
 gdb/testsuite/lib/gdb.exp | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
  

Patch

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 2cd2603e39f..479d1229142 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -7531,16 +7531,9 @@  proc gdb_expect { args } {
 	set tmt [get_largest_timeout]
     }
 
-    set code [catch \
-	{uplevel remote_expect host $tmt $expcode} string]
-
-    if {$code == 1} {
-	global errorInfo errorCode
-
-	return -code error -errorinfo $errorInfo -errorcode $errorCode $string
-    } else {
-	return -code $code $string
-    }
+    transparent_uplevel [subst_vars {
+	remote_expect host $tmt $expcode
+    }]
 }
 
 # gdb_expect_list TEST SENTINEL LIST -- expect a sequence of outputs