mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 12:34:43 +00:00
[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 <tom@tromey.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -143,7 +143,7 @@ proc load_core { filename } {
|
||||
}
|
||||
|
||||
foreach name { corefile core0file } {
|
||||
set filename [subst $$name]
|
||||
set filename [subst_vars $$name]
|
||||
if { $filename == "" } {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -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" \
|
||||
|
||||
@@ -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}]
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user