aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2024-05-03 15:07:33 +0200
committerTom de Vries <tdevries@suse.de>2024-05-03 15:07:33 +0200
commit9dd1e642084cae1caed0a4a3af7bf93804d89530 (patch)
treed8c82ff8877a7c34da534d7ee2cc72f3010b4953
parentbab7860fa71715f7b4f68cddf79c420ee30f04fe (diff)
downloadgdb-9dd1e642084cae1caed0a4a3af7bf93804d89530.zip
gdb-9dd1e642084cae1caed0a4a3af7bf93804d89530.tar.gz
gdb-9dd1e642084cae1caed0a4a3af7bf93804d89530.tar.bz2
[gdb/testsuite] Use save_vars to restore GDBFLAGS
There's a pattern of using: ... set saved_gdbflags $GDBFLAGS set GDBFLAGS "$GDBFLAGS ..." <do something with GDBFLAGS> set GDBFLAGS $saved_gdbflags ... Simplify this by using save_vars: ... save_vars { GDBFLAGS } { set GDBFLAGS "$GDBFLAGS ..." <do something with GDBFLAGS> } ... Tested on x86_64-linux.
-rw-r--r--gdb/testsuite/gdb.base/batch-preserve-term-settings.exp4
-rw-r--r--gdb/testsuite/gdb.base/bp-cmds-execution-x-script.exp20
-rw-r--r--gdb/testsuite/gdb.base/break-main-file-remove-fail.exp30
-rw-r--r--gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp8
-rw-r--r--gdb/testsuite/gdb.base/break-unload-file.exp32
-rw-r--r--gdb/testsuite/gdb.base/code_elim.exp9
-rw-r--r--gdb/testsuite/gdb.base/paginate-execution-startup.exp50
-rw-r--r--gdb/testsuite/gdb.base/remotetimeout.exp14
-rw-r--r--gdb/testsuite/gdb.base/write_mem.exp24
-rw-r--r--gdb/testsuite/gdb.cp/readnow-language.exp8
-rw-r--r--gdb/testsuite/gdb.dwarf2/count.exp9
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-icycle.exp8
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp8
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw4-sig-type-unused.exp8
-rw-r--r--gdb/testsuite/gdb.dwarf2/implptrconst.exp8
-rw-r--r--gdb/testsuite/gdb.dwarf2/implptrpiece.exp8
-rw-r--r--gdb/testsuite/gdb.dwarf2/nostaticblock.exp8
-rw-r--r--gdb/testsuite/gdb.dwarf2/symtab-producer.exp14
-rw-r--r--gdb/testsuite/gdb.fortran/info-main.exp17
-rw-r--r--gdb/testsuite/gdb.mi/mi-async.exp15
-rw-r--r--gdb/testsuite/gdb.python/py-prompt.exp6
-rw-r--r--gdb/testsuite/gdb.threads/fork-plus-threads.exp14
-rw-r--r--gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp8
-rw-r--r--gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp8
-rw-r--r--gdb/testsuite/lib/gdb.exp14
25 files changed, 165 insertions, 187 deletions
diff --git a/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp b/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp
index dc2b1ce..d4ceba6 100644
--- a/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp
+++ b/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp
@@ -228,8 +228,6 @@ proc test_terminal_settings_preserved_after_cli_exit { cmds } {
return
}
- set saved_gdbflags $GDBFLAGS
-
set stty_supported [run_stty "stty before" stty_before]
set test "start gdb"
@@ -296,8 +294,6 @@ proc test_terminal_settings_preserved_after_sigterm { } {
return
}
- set saved_gdbflags $GDBFLAGS
-
set stty_supported [run_stty "stty before" stty_before]
set test "start gdb"
diff --git a/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.exp b/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.exp
index 25adf01..1d91958 100644
--- a/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.exp
+++ b/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.exp
@@ -25,30 +25,24 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug]} {
set x_file ${srcdir}/${subdir}/$testfile.gdb
-global GDBFLAGS
-set saved_gdbflags $GDBFLAGS
-
# Run the test proper.
proc test {} {
global inferior_exited_re
global binfile
global gdb_prompt
- global saved_gdbflags GDBFLAGS
+ global GDBFLAGS
global x_file
gdb_exit
- set GDBFLAGS "$GDBFLAGS -x $x_file $binfile"
-
- set GDBFLAGS $saved_gdbflags
- append GDBFLAGS " -x \"$x_file\""
- append GDBFLAGS " --args \"$binfile\""
-
set test "run to end"
- gdb_exit
- set res [gdb_spawn]
+ save_vars { GDBFLAGS } {
+ append GDBFLAGS " -x \"$x_file\""
+ append GDBFLAGS " --args \"$binfile\""
+ set res [gdb_spawn]
+ }
if { $res != 0} {
fail $test
return -1
@@ -65,5 +59,3 @@ proc test {} {
}
test
-
-set GDBFLAGS $saved_gdbflags
diff --git a/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp b/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp
index 8a8c508..97b662c 100644
--- a/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp
+++ b/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp
@@ -35,25 +35,25 @@ proc test_remove_bp { initial_load } {
gdb_exit
- set saved_gdbflags $GDBFLAGS
+ save_vars { GDBFLAGS } {
- # See "used to behave differently" further below.
- if { $initial_load == "file" } {
- gdb_start
- gdb_file_cmd $binfile
- } else {
- global last_loaded_file
+ # See "used to behave differently" further below.
+ if { $initial_load == "file" } {
+ gdb_start
+ gdb_file_cmd $binfile
+ } else {
+ global last_loaded_file
- # gdb_file_cmd sets this. This is what gdb_reload
- # implementations use as binary.
- set last_loaded_file $binfile
+ # gdb_file_cmd sets this. This is what gdb_reload
+ # implementations use as binary.
+ set last_loaded_file $binfile
- set GDBFLAGS "$GDBFLAGS $binfile"
- gdb_start
+ set GDBFLAGS "$GDBFLAGS $binfile"
+ gdb_start
+ }
+ gdb_reinitialize_dir $srcdir/$subdir
+ gdb_reload
}
- gdb_reinitialize_dir $srcdir/$subdir
- gdb_reload
- set GDBFLAGS $saved_gdbflags
if ![runto start] {
return
diff --git a/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp b/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp
index 613c9dc..67afe4c 100644
--- a/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp
+++ b/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp
@@ -48,10 +48,10 @@ proc set_breakpoint_on_gcd_function {} {
set_breakpoint_on_gcd_function
-set saved_gdbflags $GDBFLAGS
-set GDBFLAGS "$GDBFLAGS --readnow"
-clean_restart ${testfile}
-set GDBFLAGS $saved_gdbflags
+save_vars { GDBFLAGS } {
+ set GDBFLAGS "$GDBFLAGS --readnow"
+ clean_restart ${testfile}
+}
with_test_prefix "readnow" {
set_breakpoint_on_gcd_function
diff --git a/gdb/testsuite/gdb.base/break-unload-file.exp b/gdb/testsuite/gdb.base/break-unload-file.exp
index 2d62cc5..fb9874b 100644
--- a/gdb/testsuite/gdb.base/break-unload-file.exp
+++ b/gdb/testsuite/gdb.base/break-unload-file.exp
@@ -38,26 +38,26 @@ proc test_break { initial_load always_inserted break_command } {
with_test_prefix "$prefix" {
gdb_exit
- set saved_gdbflags $GDBFLAGS
+ save_vars { GDBFLAGS } {
- # See "used to behave differently" further below.
- if { $initial_load == "file" } {
- gdb_start
- gdb_file_cmd $binfile
- } else {
- global last_loaded_file
+ # See "used to behave differently" further below.
+ if { $initial_load == "file" } {
+ gdb_start
+ gdb_file_cmd $binfile
+ } else {
+ global last_loaded_file
- # gdb_file_cmd sets this. This is what gdb_reload
- # implementations use as binary.
- set last_loaded_file $binfile
+ # gdb_file_cmd sets this. This is what gdb_reload
+ # implementations use as binary.
+ set last_loaded_file $binfile
- set GDBFLAGS "$GDBFLAGS $binfile"
- gdb_start
- }
+ set GDBFLAGS "$GDBFLAGS $binfile"
+ gdb_start
+ }
- gdb_reinitialize_dir $srcdir/$subdir
- gdb_reload
- set GDBFLAGS $saved_gdbflags
+ gdb_reinitialize_dir $srcdir/$subdir
+ gdb_reload
+ }
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.base/code_elim.exp b/gdb/testsuite/gdb.base/code_elim.exp
index e66382f..8ead31d 100644
--- a/gdb/testsuite/gdb.base/code_elim.exp
+++ b/gdb/testsuite/gdb.base/code_elim.exp
@@ -93,11 +93,10 @@ with_test_prefix "single psymtabs" {
# Same thing for symtabs
gdb_exit
-global GDBFLAGS
-set saved_gdbflags $GDBFLAGS
-set GDBFLAGS "$GDBFLAGS --readnow $binfile1"
-gdb_start
-set GDBFLAGS $saved_gdbflags
+save_vars { GDBFLAGS } {
+ set GDBFLAGS "$GDBFLAGS --readnow $binfile1"
+ gdb_start
+}
with_test_prefix "single symtabs" {
test_eliminated_var my_global_symbol
diff --git a/gdb/testsuite/gdb.base/paginate-execution-startup.exp b/gdb/testsuite/gdb.base/paginate-execution-startup.exp
index f0f7db5..134cf64 100644
--- a/gdb/testsuite/gdb.base/paginate-execution-startup.exp
+++ b/gdb/testsuite/gdb.base/paginate-execution-startup.exp
@@ -27,25 +27,22 @@ if [is_remote host] {
set file_arg [remote_download host $file_arg]
}
-global GDBFLAGS
-set saved_gdbflags $GDBFLAGS
-
# Returns true if the board can 'gdb -ex "start"', false otherwise.
proc probe_can_run_cmdline {} {
global srcfile file_arg
- global saved_gdbflags GDBFLAGS
+ global GDBFLAGS
global gdb_prompt
- set GDBFLAGS $saved_gdbflags
- append GDBFLAGS " -ex \"start\""
- append GDBFLAGS " --args \"$file_arg\""
-
with_test_prefix "probe support" {
set test "run to main"
gdb_exit
- set res [gdb_spawn]
+ save_vars { GDBFLAGS } {
+ append GDBFLAGS " -ex \"start\""
+ append GDBFLAGS " --args \"$file_arg\""
+ set res [gdb_spawn]
+ }
if { $res != 0} {
fail $test
return -1
@@ -74,23 +71,25 @@ proc probe_can_run_cmdline {} {
proc test_fg_execution_pagination_return {} {
global file_arg
- global saved_gdbflags GDBFLAGS
+ global GDBFLAGS
global gdb_prompt pagination_prompt
- set GDBFLAGS $saved_gdbflags
- append GDBFLAGS " -ex \"set height 2\""
- append GDBFLAGS " -ex \"start\""
- append GDBFLAGS " --args \"$file_arg\""
-
with_test_prefix "return" {
set test "run to pagination"
gdb_exit
- set res [gdb_spawn]
+
+ save_vars { GDBFLAGS } {
+ append GDBFLAGS " -ex \"set height 2\""
+ append GDBFLAGS " -ex \"start\""
+ append GDBFLAGS " --args \"$file_arg\""
+ set res [gdb_spawn]
+ }
if { $res != 0} {
fail $test
return $res
}
+
gdb_test_multiple "" $test {
-re "$pagination_prompt$" {
pass $test
@@ -127,24 +126,25 @@ proc test_fg_execution_pagination_return {} {
proc test_fg_execution_pagination_cancel { how } {
global file_arg
- global saved_gdbflags GDBFLAGS
+ global GDBFLAGS
global gdb_prompt pagination_prompt
- set GDBFLAGS $saved_gdbflags
-
- append GDBFLAGS " -ex \"set height 2\""
- append GDBFLAGS " -ex \"start\""
- append GDBFLAGS " --args \"$file_arg\""
-
with_test_prefix "cancel with $how" {
set test "run to pagination"
gdb_exit
- set res [gdb_spawn]
+
+ save_vars { GDBFLAGS } {
+ append GDBFLAGS " -ex \"set height 2\""
+ append GDBFLAGS " -ex \"start\""
+ append GDBFLAGS " --args \"$file_arg\""
+ set res [gdb_spawn]
+ }
if { $res != 0} {
fail $test
return $res
}
+
gdb_test_multiple "" $test {
-re "$pagination_prompt$" {
pass $test
@@ -182,5 +182,3 @@ save_vars { INTERNAL_GDBFLAGS } {
test_fg_execution_pagination_cancel "quit"
}
}
-
-set GDBFLAGS $saved_gdbflags
diff --git a/gdb/testsuite/gdb.base/remotetimeout.exp b/gdb/testsuite/gdb.base/remotetimeout.exp
index 27f0295..b7d8c90 100644
--- a/gdb/testsuite/gdb.base/remotetimeout.exp
+++ b/gdb/testsuite/gdb.base/remotetimeout.exp
@@ -19,18 +19,16 @@
# This is a test for the gdb invocation option -l.
-global GDBFLAGS
+gdb_exit
#
# Test that -l is processed correctly.
#
-set old_gdbflags $GDBFLAGS
-set GDBFLAGS "$GDBFLAGS -l 42"
-gdb_exit
-gdb_start
+save_vars { GDBFLAGS } {
+ set GDBFLAGS "$GDBFLAGS -l 42"
+ gdb_start
+}
+
gdb_test "show remotetimeout" \
"Timeout limit to wait for target to respond is 42\." \
"correct remotetimeout printed"
-
-set GDBFLAGS $old_gdbflags
-
diff --git a/gdb/testsuite/gdb.base/write_mem.exp b/gdb/testsuite/gdb.base/write_mem.exp
index 89c0647..3f2380c 100644
--- a/gdb/testsuite/gdb.base/write_mem.exp
+++ b/gdb/testsuite/gdb.base/write_mem.exp
@@ -27,21 +27,27 @@ if {[build_executable $testfile.exp $testfile \
return -1
}
-set old_gdbflags $GDBFLAGS
+save_vars { GDBFLAGS } {
+ set GDBFLAGS "$GDBFLAGS $binfile"
+ clean_restart
+}
# Expect a failure before --write has been added to the command line
-set GDBFLAGS "$old_gdbflags $binfile"
-clean_restart
test_print_reject "set {int}main = 0x4242" "Cannot access memory at address"
+save_vars { GDBFLAGS } {
+ set GDBFLAGS "$GDBFLAGS --write $binfile"
+ clean_restart
+}
+
# Setting memory should now work correctly after adding --write
-set GDBFLAGS "$old_gdbflags --write $binfile"
-clean_restart
gdb_test_no_output "set {int}main = 0x4242"
-# Check that memory write persists after quitting GDB
gdb_exit
-gdb_start
-gdb_test "x /x main" "<main>:.*4242"
+save_vars { GDBFLAGS } {
+ set GDBFLAGS "$GDBFLAGS --write $binfile"
+ gdb_start
+}
-set GDBFLAGS $old_gdbflags
+# Check that memory write persists after quitting GDB
+gdb_test "x /x main" "<main>:.*4242"
diff --git a/gdb/testsuite/gdb.cp/readnow-language.exp b/gdb/testsuite/gdb.cp/readnow-language.exp
index 05193ec..a9cd645 100644
--- a/gdb/testsuite/gdb.cp/readnow-language.exp
+++ b/gdb/testsuite/gdb.cp/readnow-language.exp
@@ -19,9 +19,9 @@ if {[build_executable ${testfile}.exp $testfile ${testfile}.cc {c++ debug}] == -
return -1
}
-set old_gdbflags $GDBFLAGS
-set GDBFLAGS "$GDBFLAGS -readnow"
-clean_restart $testfile
-set GDBFLAGS $old_gdbflags
+save_vars { GDBFLAGS } {
+ set GDBFLAGS "$GDBFLAGS -readnow"
+ clean_restart $testfile
+}
gdb_test "show language" {The current source language is "auto; currently c\+\+"\.}
diff --git a/gdb/testsuite/gdb.dwarf2/count.exp b/gdb/testsuite/gdb.dwarf2/count.exp
index 99c52d2..52deb19 100644
--- a/gdb/testsuite/gdb.dwarf2/count.exp
+++ b/gdb/testsuite/gdb.dwarf2/count.exp
@@ -138,11 +138,10 @@ if { [gdb_compile [list ${binfile}1.o ${binfile}2.o] \
return -1
}
-global GDBFLAGS
-set saved_gdbflags $GDBFLAGS
-set GDBFLAGS [concat $GDBFLAGS " -readnow"]
-clean_restart ${testfile}
-set GDBFLAGS $saved_gdbflags
+save_vars { GDBFLAGS } {
+ set GDBFLAGS [concat $GDBFLAGS " -readnow"]
+ clean_restart ${testfile}
+}
if ![runto_main] {
return -1
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-icycle.exp b/gdb/testsuite/gdb.dwarf2/dw2-icycle.exp
index 9c00456..2675f70 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-icycle.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-icycle.exp
@@ -33,10 +33,10 @@ if { [build_executable "failed to prepare" ${testfile} \
# start the debugger with -readnow. This force expansion as soon as
# the objfile is loaded.
-set saved_gdbflags $GDBFLAGS
-set GDBFLAGS "$GDBFLAGS -readnow"
-clean_restart ${testfile}
-set GDBFLAGS $saved_gdbflags
+save_vars { GDBFLAGS } {
+ set GDBFLAGS "$GDBFLAGS -readnow"
+ clean_restart ${testfile}
+}
# And just to be sure that the debugger did not crash after having
# expanded our symbols, do a life-check.
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp b/gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp
index 2a5aa3e..9b89b8c 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp
@@ -32,10 +32,10 @@ proc test { } {
test
-set saved_gdbflags $GDBFLAGS
-set GDBFLAGS "$GDBFLAGS --readnow"
-clean_restart ${binfile}
-set GDBFLAGS $saved_gdbflags
+save_vars { GDBFLAGS } {
+ set GDBFLAGS "$GDBFLAGS --readnow"
+ clean_restart ${binfile}
+}
with_test_prefix "readnow" {
test
diff --git a/gdb/testsuite/gdb.dwarf2/dw4-sig-type-unused.exp b/gdb/testsuite/gdb.dwarf2/dw4-sig-type-unused.exp
index 63c834b..24dc132 100644
--- a/gdb/testsuite/gdb.dwarf2/dw4-sig-type-unused.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw4-sig-type-unused.exp
@@ -24,9 +24,9 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != ""
return -1
}
-set saved_gdbflags $GDBFLAGS
-set GDBFLAGS "$GDBFLAGS --readnow"
-clean_restart $executable
-set GDBFLAGS $saved_gdbflags
+save_vars { GDBFLAGS } {
+ set GDBFLAGS "$GDBFLAGS --readnow"
+ clean_restart $executable
+}
gdb_test "p 1" " = 1" "alive"
diff --git a/gdb/testsuite/gdb.dwarf2/implptrconst.exp b/gdb/testsuite/gdb.dwarf2/implptrconst.exp
index 796b8b7..8e6dbf0 100644
--- a/gdb/testsuite/gdb.dwarf2/implptrconst.exp
+++ b/gdb/testsuite/gdb.dwarf2/implptrconst.exp
@@ -90,10 +90,10 @@ if { [build_executable ${testfile}.exp ${testfile} \
# We need --readnow because otherwise we never read in the CU we
# created above.
-set saved_gdbflags $GDBFLAGS
-set GDBFLAGS "$GDBFLAGS -readnow"
-clean_restart ${testfile}
-set GDBFLAGS $saved_gdbflags
+save_vars { GDBFLAGS } {
+ set GDBFLAGS "$GDBFLAGS -readnow"
+ clean_restart ${testfile}
+}
if ![runto_main] {
return -1
diff --git a/gdb/testsuite/gdb.dwarf2/implptrpiece.exp b/gdb/testsuite/gdb.dwarf2/implptrpiece.exp
index 83bdf99..585cd74 100644
--- a/gdb/testsuite/gdb.dwarf2/implptrpiece.exp
+++ b/gdb/testsuite/gdb.dwarf2/implptrpiece.exp
@@ -108,10 +108,10 @@ if { [build_executable ${testfile}.exp ${testfile} \
# We need --readnow because otherwise we never read in the CU we
# created above.
-set saved_gdbflags $GDBFLAGS
-set GDBFLAGS "$GDBFLAGS -readnow"
-clean_restart ${testfile}
-set GDBFLAGS $saved_gdbflags
+save_vars { GDBFLAGS } {
+ set GDBFLAGS "$GDBFLAGS -readnow"
+ clean_restart ${testfile}
+}
if ![runto_main] {
return -1
diff --git a/gdb/testsuite/gdb.dwarf2/nostaticblock.exp b/gdb/testsuite/gdb.dwarf2/nostaticblock.exp
index 46e2b4c..e8d41f04 100644
--- a/gdb/testsuite/gdb.dwarf2/nostaticblock.exp
+++ b/gdb/testsuite/gdb.dwarf2/nostaticblock.exp
@@ -38,9 +38,9 @@ if { [build_executable ${testfile}.exp ${testfile} \
return -1
}
-set saved_gdbflags $GDBFLAGS
-set GDBFLAGS "$GDBFLAGS --readnow"
-clean_restart $testfile
-set GDBFLAGS $saved_gdbflags
+save_vars { GDBFLAGS } {
+ set GDBFLAGS "$GDBFLAGS --readnow"
+ clean_restart $testfile
+}
gdb_test "p 1" " = 1" "alive"
diff --git a/gdb/testsuite/gdb.dwarf2/symtab-producer.exp b/gdb/testsuite/gdb.dwarf2/symtab-producer.exp
index 756b1d6..ac16c95 100644
--- a/gdb/testsuite/gdb.dwarf2/symtab-producer.exp
+++ b/gdb/testsuite/gdb.dwarf2/symtab-producer.exp
@@ -73,17 +73,15 @@ Dwarf::assemble $asm_file {
# We need --readnow because otherwise we never read in the CUs we
# created above.
-set saved_gdbflags $GDBFLAGS
-set GDBFLAGS "$GDBFLAGS -readnow"
+save_vars { GDBFLAGS } {
+ set GDBFLAGS "$GDBFLAGS -readnow"
-if { [prepare_for_testing "failed to prepare" ${testfile} \
- [list $srcfile $asm_file] {nodebug}] } {
- set GDBFLAGS $saved_gdbflags
- return -1
+ if { [prepare_for_testing "failed to prepare" ${testfile} \
+ [list $srcfile $asm_file] {nodebug}] } {
+ return -1
+ }
}
-set GDBFLAGS $saved_gdbflags
-
gdb_py_test_silent_cmd "python with_producer = gdb.lookup_global_symbol(\"with_producer\")" \
"get with_producer symbol" 0
diff --git a/gdb/testsuite/gdb.fortran/info-main.exp b/gdb/testsuite/gdb.fortran/info-main.exp
index e8583f3..7d11235b 100644
--- a/gdb/testsuite/gdb.fortran/info-main.exp
+++ b/gdb/testsuite/gdb.fortran/info-main.exp
@@ -19,11 +19,12 @@ load_lib fortran.exp
standard_testfile .f90
-set old_gdbflags $GDBFLAGS
-set GDBFLAGS [string map {"-readnow" ""} "$GDBFLAGS"]
+save_vars { GDBFLAGS } {
+ set GDBFLAGS [string map {"-readnow" ""} "$GDBFLAGS"]
-if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}]} {
- return -1
+ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}]} {
+ return -1
+ }
}
gdb_test "info main" "simple" "info main prior to start"
@@ -35,8 +36,8 @@ if ![fortran_runto_main] {
gdb_test "info main" "simple" "info main post start"
-set GDBFLAGS "$GDBFLAGS -readnow"
-clean_restart $testfile
+save_vars { GDBFLAGS } {
+ set GDBFLAGS "$GDBFLAGS -readnow"
+ clean_restart $testfile
+}
gdb_test "info main" "simple" "info main with readnow"
-
-set GDBFLAGS $old_gdbflags
diff --git a/gdb/testsuite/gdb.mi/mi-async.exp b/gdb/testsuite/gdb.mi/mi-async.exp
index fc138a6..74aff56 100644
--- a/gdb/testsuite/gdb.mi/mi-async.exp
+++ b/gdb/testsuite/gdb.mi/mi-async.exp
@@ -29,10 +29,6 @@ if {![istarget *-linux*]} {
# Check if start command is supported.
require !use_gdb_stub
-# The plan is for async mode to become the default but toggle for now.
-set saved_gdbflags $GDBFLAGS
-set GDBFLAGS [concat $GDBFLAGS " -ex \"set mi-async on\""]
-
load_lib mi-support.exp
standard_testfile basics.c
@@ -42,8 +38,13 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if {[mi_clean_restart $binfile]} {
- return
+# The plan is for async mode to become the default but toggle for now.
+save_vars { GDBFLAGS } {
+ set GDBFLAGS [concat $GDBFLAGS " -ex \"set mi-async on\""]
+
+ if {[mi_clean_restart $binfile]} {
+ return
+ }
}
# mi_gdb_test cannot be used for asynchronous commands because there are
@@ -75,5 +76,3 @@ proc linux_async_tests {} {
linux_async_tests
mi_gdb_exit
-
-set GDBFLAGS $saved_gdbflags
diff --git a/gdb/testsuite/gdb.python/py-prompt.exp b/gdb/testsuite/gdb.python/py-prompt.exp
index f1f93bf..614fe9d 100644
--- a/gdb/testsuite/gdb.python/py-prompt.exp
+++ b/gdb/testsuite/gdb.python/py-prompt.exp
@@ -27,11 +27,9 @@ if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
return -1
}
-save_vars { INTERNAL_GDBFLAGS } {
+save_vars { INTERNAL_GDBFLAGS GDBFLAGS } {
set INTERNAL_GDBFLAGS [string map {"-q" ""} $INTERNAL_GDBFLAGS]
- global GDBFLAGS
- set saved_gdbflags $GDBFLAGS
set GDBFLAGS [concat $GDBFLAGS " -ex \"python p = list()\""]
set prompt_func "python def foo(x): global p; p.append(x); return \'(Foo) \'"
set GDBFLAGS [concat $GDBFLAGS " -ex \"$prompt_func\""]
@@ -72,7 +70,6 @@ save_vars { INTERNAL_GDBFLAGS } {
}
if {![can_spawn_for_attach]} {
- set GDBFLAGS $saved_gdbflags
return 0
}
@@ -115,6 +112,5 @@ save_vars { INTERNAL_GDBFLAGS } {
gdb_exit
}
- set GDBFLAGS $saved_gdbflags
kill_wait_spawned_process $test_spawn_id
}
diff --git a/gdb/testsuite/gdb.threads/fork-plus-threads.exp b/gdb/testsuite/gdb.threads/fork-plus-threads.exp
index 431ad4a..c08b4c1 100644
--- a/gdb/testsuite/gdb.threads/fork-plus-threads.exp
+++ b/gdb/testsuite/gdb.threads/fork-plus-threads.exp
@@ -34,17 +34,15 @@ proc do_test { detach-on-fork } {
global srcfile testfile
global gdb_prompt
- set saved_gdbflags $GDBFLAGS
- set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop on\""]
+ save_vars { GDBFLAGS } {
+ set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop on\""]
- if {[prepare_for_testing "failed to prepare" \
- $testfile $srcfile {debug pthreads}] == -1} {
- set GDBFLAGS $saved_gdbflags
- return -1
+ if {[prepare_for_testing "failed to prepare" \
+ $testfile $srcfile {debug pthreads}] == -1} {
+ return -1
+ }
}
- set GDBFLAGS $saved_gdbflags
-
if {![runto_main]} {
return 0
}
diff --git a/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp b/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp
index 7f01004..66311fe 100644
--- a/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp
+++ b/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp
@@ -72,10 +72,10 @@ proc do_test { cond_bp_target detach_on_fork displaced } {
global linenum
global is_remote_target
- set saved_gdbflags $GDBFLAGS
- set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop on\""]
- clean_restart $binfile
- set GDBFLAGS $saved_gdbflags
+ save_vars { GDBFLAGS } {
+ set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop on\""]
+ clean_restart $binfile
+ }
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp b/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp
index e1bc6fe..4ff68a6 100644
--- a/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp
+++ b/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp
@@ -40,10 +40,10 @@ proc do_test { non_stop cond_bp_target } {
global binfile
global linenum
- set saved_gdbflags $GDBFLAGS
- set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop $non_stop\""]
- clean_restart $binfile
- set GDBFLAGS $saved_gdbflags
+ save_vars { GDBFLAGS } {
+ set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop $non_stop\""]
+ clean_restart $binfile
+ }
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index fe3f05c..4c3097d 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -6128,16 +6128,14 @@ proc gdb_spawn { } {
proc gdb_spawn_with_cmdline_opts { cmdline_flags } {
global GDBFLAGS
- set saved_gdbflags $GDBFLAGS
+ save_vars { GDBFLAGS } {
+ if {$GDBFLAGS != ""} {
+ append GDBFLAGS " "
+ }
+ append GDBFLAGS $cmdline_flags
- if {$GDBFLAGS != ""} {
- append GDBFLAGS " "
+ set res [gdb_spawn]
}
- append GDBFLAGS $cmdline_flags
-
- set res [gdb_spawn]
-
- set GDBFLAGS $saved_gdbflags
return $res
}