@@ -229,8 +229,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"
@@ -297,8 +295,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"
@@ -25,23 +25,17 @@ 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 " -ex \"set height unlimited\""
append GDBFLAGS " -x \"$x_file\""
append GDBFLAGS " --args \"$binfile\""
@@ -65,6 +59,6 @@ proc test {} {
}
}
-test
-
-set GDBFLAGS $saved_gdbflags
+save_vars {GDBFLAGS} {
+ test
+}
@@ -35,8 +35,6 @@ proc test_remove_bp { initial_load } {
gdb_exit
- set saved_gdbflags $GDBFLAGS
-
# See "used to behave differently" further below.
if { $initial_load == "file" } {
gdb_start
@@ -48,12 +46,13 @@ proc test_remove_bp { initial_load } {
# implementations use as binary.
set last_loaded_file $binfile
- set GDBFLAGS "$GDBFLAGS $binfile"
- gdb_start
+ save_vars {GDBFLAGS} {
+ append GDBFLAGS " $binfile"
+ gdb_start
+ }
}
gdb_reinitialize_dir $srcdir/$subdir
gdb_reload
- set GDBFLAGS $saved_gdbflags
if ![runto start] {
return
@@ -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} {
+ append GDBFLAGS " --readnow"
+ clean_restart ${testfile}
+}
with_test_prefix "readnow" {
set_breakpoint_on_gcd_function
@@ -38,8 +38,6 @@ proc test_break { initial_load always_inserted break_command } {
with_test_prefix "$prefix" {
gdb_exit
- set saved_gdbflags $GDBFLAGS
-
# See "used to behave differently" further below.
if { $initial_load == "file" } {
gdb_start
@@ -51,13 +49,14 @@ proc test_break { initial_load always_inserted break_command } {
# implementations use as binary.
set last_loaded_file $binfile
- set GDBFLAGS "$GDBFLAGS $binfile"
- gdb_start
+ save_vars {GDBFLAGS} {
+ append GDBFLAGS " $binfile"
+ gdb_start
+ }
}
gdb_reinitialize_dir $srcdir/$subdir
gdb_reload
- set GDBFLAGS $saved_gdbflags
if {![runto_main]} {
return
@@ -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} {
+ append GDBFLAGS " --readnow $binfile1"
+ gdb_start
+}
with_test_prefix "single symtabs" {
test_eliminated_var my_global_symbol
@@ -27,9 +27,6 @@ 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 {} {
@@ -172,7 +169,8 @@ proc test_fg_execution_pagination_cancel { how } {
}
}
-save_vars { INTERNAL_GDBFLAGS } {
+save_vars { GDBFLAGS INTERNAL_GDBFLAGS } {
+ set saved_gdbflags $GDBFLAGS
set INTERNAL_GDBFLAGS [string map {"-q" ""} $INTERNAL_GDBFLAGS]
if {[probe_can_run_cmdline] > 0} {
@@ -183,5 +181,3 @@ save_vars { INTERNAL_GDBFLAGS } {
test_fg_execution_pagination_cancel "quit"
}
}
-
-set GDBFLAGS $saved_gdbflags
@@ -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} {
+ append GDBFLAGS " -readnow"
+ clean_restart ${testfile}
+}
if ![runto_main] {
return -1
@@ -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} {
+ append 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.
@@ -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} {
+ append GDBFLAGS " --readnow"
+ clean_restart ${binfile}
+}
with_test_prefix "readnow" {
test
@@ -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} {
+ append GDBFLAGS " --readnow"
+ clean_restart $executable
+}
gdb_test "p 1" " = 1" "alive"
@@ -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} {
+ append GDBFLAGS " -readnow"
+ clean_restart ${testfile}
+}
if ![runto_main] {
return -1
@@ -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} {
+ append GDBFLAGS " -readnow"
+ clean_restart ${testfile}
+}
if ![runto_main] {
return -1
@@ -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} {
+ append GDBFLAGS " --readnow"
+ clean_restart $testfile
+}
gdb_test "p 1" " = 1" "alive"
@@ -73,17 +73,14 @@ 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"
-
-if { [prepare_for_testing "failed to prepare" ${testfile} \
- [list $srcfile $asm_file] {nodebug}] } {
- set GDBFLAGS $saved_gdbflags
- return -1
+save_vars {GDBFLAGS} {
+ append GDBFLAGS " -readnow"
+ 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
@@ -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,11 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if {[mi_clean_restart $binfile]} {
- return
+save_vars {GDBFLAGS} {
+ append 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 +74,3 @@ proc linux_async_tests {} {
linux_async_tests
mi_gdb_exit
-
-set GDBFLAGS $saved_gdbflags
@@ -27,11 +27,9 @@ if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
return -1
}
-save_vars { INTERNAL_GDBFLAGS } {
+save_vars { GDBFLAGS INTERNAL_GDBFLAGS } {
set INTERNAL_GDBFLAGS [string map {"-q" ""} $INTERNAL_GDBFLAGS]
- global GDBFLAGS
- set saved_gdbflags $GDBFLAGS
set GDBFLAGS [concat $GDBFLAGS " -ex \"set height 0\""]
set GDBFLAGS [concat $GDBFLAGS " -ex \"set width 0\""]
set GDBFLAGS [concat $GDBFLAGS " -ex \"python p = list()\""]
@@ -74,7 +72,6 @@ save_vars { INTERNAL_GDBFLAGS } {
}
if {![can_spawn_for_attach]} {
- set GDBFLAGS $saved_gdbflags
return 0
}
@@ -117,6 +114,5 @@ save_vars { INTERNAL_GDBFLAGS } {
gdb_exit
}
- set GDBFLAGS $saved_gdbflags
kill_wait_spawned_process $test_spawn_id
}
@@ -34,17 +34,14 @@ 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\""]
-
- if {[prepare_for_testing "failed to prepare" \
- $testfile $srcfile {debug pthreads}] == -1} {
- set GDBFLAGS $saved_gdbflags
- return -1
+ save_vars {GDBFLAGS} {
+ append GDBFLAGS " -ex \"set non-stop on\""
+ if {[prepare_for_testing "failed to prepare" \
+ $testfile $srcfile {debug pthreads}] == -1} {
+ return -1
+ }
}
- set GDBFLAGS $saved_gdbflags
-
if {![runto_main]} {
return 0
}
@@ -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} {
+ append GDBFLAGS " -ex \"set non-stop on\""
+ clean_restart $binfile
+ }
if {![runto_main]} {
return 0
@@ -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} {
+ append GDBFLAGS " -ex \"set non-stop $non_stop\""
+ clean_restart $binfile
+ }
if {![runto_main]} {
return 0
@@ -6050,18 +6050,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 " "
+ return [gdb_spawn]
}
- append GDBFLAGS $cmdline_flags
-
- set res [gdb_spawn]
-
- set GDBFLAGS $saved_gdbflags
-
- return $res
}
# Start gdb running, wait for prompt, and disable the pagers.