gdb/testsuite: gdb.base/args.exp: use save_vars

Use save_vars instead of manually saving/restoring.  This ensures that
if anything throws an error, GDBFLAGS will be correctly restored.

Remove the global GDBFLAGS declaration at the top, it's not necessary.

gdb/testsuite/ChangeLog:

	* gdb.base/args.exp: Use save_vars.

Change-Id: I3a45e4fc1635ec0212de2415040f91eecaf4a057
This commit is contained in:
Simon Marchi
2021-06-17 09:41:58 -04:00
committed by Simon Marchi
parent 82a5082ed3
commit 18b5aadea2
2 changed files with 31 additions and 29 deletions
gdb/testsuite

@ -1,3 +1,7 @@
2021-06-17 Simon Marchi <simon.marchi@efficios.com>
* gdb.base/args.exp: Use save_vars.
2021-06-14 Pedro Alves <pedro@palves.net> 2021-06-14 Pedro Alves <pedro@palves.net>
* gdb.base/annota1.exp: Build list using [list] instead of {}. * gdb.base/annota1.exp: Build list using [list] instead of {}.

@ -15,9 +15,6 @@
# This is a test for the gdb invocation option --args. # This is a test for the gdb invocation option --args.
global GDBFLAGS
# Skip test if target does not support argument passing. # Skip test if target does not support argument passing.
if [target_info exists noargs] { if [target_info exists noargs] {
return return
@ -64,6 +61,8 @@ proc args_test { name arglist } {
# #
# Test that the --args are processed correctly. # Test that the --args are processed correctly.
# #
save_vars { GDBFLAGS } {
set old_gdbflags $GDBFLAGS set old_gdbflags $GDBFLAGS
set GDBFLAGS "$old_gdbflags --args $binfile 1 3" set GDBFLAGS "$old_gdbflags --args $binfile 1 3"
@ -98,5 +97,4 @@ args_test "one newline" {{1} {\\n} {3}}
set GDBFLAGS "-nx --args $binfile 1 {\n} {\n} 3" set GDBFLAGS "-nx --args $binfile 1 {\n} {\n} 3"
args_test "two newlines" {{1} {\\n} {\\n} {3}} args_test "two newlines" {{1} {\\n} {\\n} {3}}
}
set GDBFLAGS $old_gdbflags