From: Tom de Vries Date: Wed, 22 Oct 2025 05:36:07 +0000 (+0200) Subject: [gdb/testsuite] Add proc subst_vars X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc5830d1cf7d88fb17e881957916799678a9f79a;p=thirdparty%2Fbinutils-gdb.git [gdb/testsuite] Add proc subst_vars Add proc subst_vars, an alias of subst -nobackslashes -nocommands. I've used tailcall to implement this: ... proc subst_vars { str } { tailcall subst -nobackslashes -nocommands $str } ... but I found that this also works: ... proc subst_vars { str } { return [uplevel 1 [list subst -nobackslashes -nocommands $str]] } ... I've found other uses of subst that don't add "-nobackslashes -nocommands", but really only use subst to do variable substitution. Also use subst_vars in those cases. Tested on x86_64-linux. Approved-By: Tom Tromey --- diff --git a/gdb/testsuite/gdb.base/coredump-filter.exp b/gdb/testsuite/gdb.base/coredump-filter.exp index 9d99b968aab..8a0652f6bda 100644 --- a/gdb/testsuite/gdb.base/coredump-filter.exp +++ b/gdb/testsuite/gdb.base/coredump-filter.exp @@ -223,7 +223,7 @@ foreach item $all_anon_corefiles { # Generate corefiles for the "anon" case. foreach item $all_anon_corefiles { with_test_prefix "saving corefile for [lindex $item 0]" { - do_save_core [lindex $item 1] [subst [lindex $item 2]] [lindex $item 6] + do_save_core [lindex $item 1] [subst_vars [lindex $item 2]] [lindex $item 6] } } @@ -235,12 +235,12 @@ clean_restart $testfile foreach item $all_anon_corefiles { with_test_prefix "loading and testing corefile for [lindex $item 0]" { - do_load_and_test_core [subst [lindex $item 2]] [lindex $item 3] \ + do_load_and_test_core [subst_vars [lindex $item 2]] [lindex $item 3] \ [lindex $item 4] [lindex $item 5] [lindex $item 6] } with_test_prefix "disassembling function main for [lindex $item 0]" { - test_disasm [subst [lindex $item 2]] $main_addr 0 + test_disasm [subst_vars [lindex $item 2]] $main_addr 0 } } diff --git a/gdb/testsuite/gdb.base/nodebug.exp b/gdb/testsuite/gdb.base/nodebug.exp index 6ed428e6c74..195ad855c5c 100644 --- a/gdb/testsuite/gdb.base/nodebug.exp +++ b/gdb/testsuite/gdb.base/nodebug.exp @@ -145,9 +145,9 @@ if {[nodebug_runto inner]} { set whatis_re [lindex $lang_line 2] set ptype_re [lindex $lang_line 3] - set print_re [subst "$print_re"] - set whatis_re [subst "$whatis_re"] - set ptype_re [subst "$ptype_re"] + set print_re [subst_vars "$print_re"] + set whatis_re [subst_vars "$whatis_re"] + set ptype_re [subst_vars "$ptype_re"] with_test_prefix "$lang" { gdb_test_no_output "set language $lang" @@ -205,9 +205,9 @@ if {[nodebug_runto inner]} { } { set exp [lindex $line 0] # Expand variables. - set fmt [subst -nobackslashes [lindex $line 1]] - set print [subst -nobackslashes [lindex $line 2]] - set whatis [subst -nobackslashes [lindex $line 3]] + set fmt [subst_vars [lindex $line 1]] + set print [subst_vars [lindex $line 2]] + set whatis [subst_vars [lindex $line 3]] if {$fmt == ""} { gdb_test "p $exp" $print } else { diff --git a/gdb/testsuite/gdb.compile/compile-ops.exp b/gdb/testsuite/gdb.compile/compile-ops.exp index e7103bc15de..8a468ca81b9 100644 --- a/gdb/testsuite/gdb.compile/compile-ops.exp +++ b/gdb/testsuite/gdb.compile/compile-ops.exp @@ -37,13 +37,13 @@ set assert_tos_non0 { DW_OP_skip -3 } -set assert_tos_0 [subst { +set assert_tos_0 [subst_vars { DW_OP_lit0 DW_OP_eq $assert_tos_non0 }] -set program [subst { +set program [subst_vars { DW_OP_lit0 DW_OP_nop $assert_tos_0 diff --git a/gdb/testsuite/gdb.cp/local-static.exp b/gdb/testsuite/gdb.cp/local-static.exp index c80c62135c0..183dc8a4db6 100644 --- a/gdb/testsuite/gdb.cp/local-static.exp +++ b/gdb/testsuite/gdb.cp/local-static.exp @@ -170,10 +170,10 @@ proc do_test {lang} { set scope [lindex $scope_line 0] set print_quoted_re [lindex $scope_line 2] - set print_quoted_re [uplevel 1 "subst -nobackslashes -nocommands \"$print_quoted_re\""] + set print_quoted_re [uplevel 1 "subst_vars \"$print_quoted_re\""] set print_unquoted_re [lindex $scope_line 3] - set print_unquoted_re [uplevel 1 "subst -nobackslashes -nocommands \"$print_unquoted_re\""] + set print_unquoted_re [uplevel 1 "subst_vars \"$print_unquoted_re\""] gdb_test "print '${scope}'" $print_quoted_re diff --git a/gdb/testsuite/gdb.dwarf2/dw2-complex-parts.exp b/gdb/testsuite/gdb.dwarf2/dw2-complex-parts.exp index 2ad358fd64c..0abd8d89682 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-complex-parts.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-complex-parts.exp @@ -191,7 +191,7 @@ proc do_test { type {clang 0}} { gdb_test "ptype '$ctype'" \ "type = $ctype" - set type_size [subst \$::${type_id}_size] + set type_size [subst_vars \$::${type_id}_size] gdb_test "p sizeof ('$type')" \ " = $type_size" diff --git a/gdb/testsuite/gdb.threads/gcore-thread.exp b/gdb/testsuite/gdb.threads/gcore-thread.exp index f32e9b41f9c..4b9a1543e8d 100644 --- a/gdb/testsuite/gdb.threads/gcore-thread.exp +++ b/gdb/testsuite/gdb.threads/gcore-thread.exp @@ -143,7 +143,7 @@ proc load_core { filename } { } foreach name { corefile core0file } { - set filename [subst $$name] + set filename [subst_vars $$name] if { $filename == "" } { continue } diff --git a/gdb/testsuite/gdb.trace/save-trace.exp b/gdb/testsuite/gdb.trace/save-trace.exp index 31d976899cd..34a3babffb9 100644 --- a/gdb/testsuite/gdb.trace/save-trace.exp +++ b/gdb/testsuite/gdb.trace/save-trace.exp @@ -53,7 +53,7 @@ set testline6 [expr {$baseline + 9}] gdb_delete_tracepoints foreach x { 1 2 3 4 5 6 } { - set testline [subst \$testline$x] + set testline [subst_vars \$testline$x] set trcpt [gdb_gettpnum $testline] set trcpt$x $trcpt gdb_test "passcount $x" \ diff --git a/gdb/testsuite/gdb.tui/resize-3.exp b/gdb/testsuite/gdb.tui/resize-3.exp index fe07e5c3622..2550046f463 100644 --- a/gdb/testsuite/gdb.tui/resize-3.exp +++ b/gdb/testsuite/gdb.tui/resize-3.exp @@ -69,5 +69,5 @@ with_test_prefix "after resize" { "No Assembly message is not displayed" \ "No Assembly Available" Term::check_contents "Assembler for foo is shown" \ - [subst -nobackslashes -nocommands {$hex\s+<(\.)?foo}] + [subst_vars {$hex\s+<(\.)?foo}] } diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp index f4506a1f92a..e81f35ace79 100644 --- a/gdb/testsuite/lib/gdb-utils.exp +++ b/gdb/testsuite/lib/gdb-utils.exp @@ -246,3 +246,9 @@ proc with_lock { lock_file body } { return -code $code $result } } + +# Alias for subst -nobackslashes -nocommands. + +proc subst_vars { str } { + tailcall subst -nobackslashes -nocommands $str +}