aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2024-09-23 09:34:48 +0200
committerTom de Vries <tdevries@suse.de>2024-09-23 09:34:48 +0200
commit3169d006121af0316903bb05f72ca52b40083834 (patch)
tree5b49cc8a8a96f1c3cca404793829222c20066799 /gdb/testsuite/lib
parent[gdb/testsuite] Fix gdb.base/empty-host-env-vars.exp (diff)
downloadbinutils-gdb-3169d006121af0316903bb05f72ca52b40083834.tar.gz
binutils-gdb-3169d006121af0316903bb05f72ca52b40083834.tar.bz2
binutils-gdb-3169d006121af0316903bb05f72ca52b40083834.zip
[gdb/testsuite] Make parse_args error out on remaining args
I noticed that introducing a typo here in gdb.mi/mi-breakpoint-changed.exp: ... set bp_re [mi_make_breakpoint \ - -number $bp_nr \ + -nunber $bp_nr \ -type dprintf \ -func marker \ -script [string_to_regexp {["printf \"arg\" \""]}]] ... didn't make the test fail. Proc mi_make_breakpoint uses parse_args, but does not check the remaining args as parse_args suggests: ... proc parse_args { argset } { parse_list 2 args $argset "-" false # The remaining args should be checked to see that they match the # number of items expected to be passed into the procedure } ... We could add the missing check in mi_make_breakpoint, but I think the problem is likely to occur again because the name parse_args does not suggest that further action is required. Fix this instead by: - copying proc parse_args to new proc parse_some_args, - adding new proc check_no_args_left, and - calling check_no_args_left in parse_args. Also be more strict in a few places where we do lassign for remaining args: ... lassign $args a b ... There may be more arguments left in $args, so check that that's not the case using check_no_args_left: ... set args [lassign $args a b] check_no_args_left ... Fix a few test-cases that trigger on the stricter checking. Tested on x86_64-linux. Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com> PR testsuite/32129 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32129
Diffstat (limited to 'gdb/testsuite/lib')
-rw-r--r--gdb/testsuite/lib/gdb.exp33
-rw-r--r--gdb/testsuite/lib/mi-support.exp2
2 files changed, 28 insertions, 7 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index c993f48fd34..7d8d4138f69 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1559,7 +1559,7 @@ proc gdb_test { args } {
global gdb_prompt
upvar timeout timeout
- parse_args {
+ parse_some_args {
{prompt ""}
{no-prompt-anchor}
{lbl}
@@ -1567,7 +1567,8 @@ proc gdb_test { args } {
{nonl}
}
- lassign $args command pattern message question response
+ set args [lassign $args command pattern message question response]
+ check_no_args_left
# Can't have a question without a response.
if { $question != "" && $response == "" || [llength $args] > 5 } {
@@ -1741,13 +1742,14 @@ if { [tcl_version_at_least 8 6 2] == 0 } {
proc gdb_test_no_output { args } {
global gdb_prompt
- parse_args {
+ parse_some_args {
{prompt ""}
{no-prompt-anchor}
{nopass}
}
- lassign $args command message
+ set args [lassign $args command message]
+ check_no_args_left
set prompt [fill_in_default_prompt $prompt [expr !${no-prompt-anchor}]]
@@ -1789,7 +1791,7 @@ proc gdb_test_no_output { args } {
proc gdb_test_sequence { args } {
global gdb_prompt
- parse_args {{prompt ""}}
+ parse_some_args {{prompt ""}}
if { $prompt == "" } {
set prompt "$gdb_prompt $"
@@ -9351,13 +9353,32 @@ proc parse_list { level listname argset prefix eval } {
# Search the caller's args variable and set variables according to the list of
# valid options described by ARGSET.
-proc parse_args { argset } {
+proc parse_some_args { argset } {
parse_list 2 args $argset "-" false
# The remaining args should be checked to see that they match the
# number of items expected to be passed into the procedure...
}
+# Check that the caller's args variable is empty.
+
+proc check_no_args_left {} {
+ # Require no remaining args.
+ upvar 1 args args
+ if { [llength $args] != 0 } {
+ error "Args left unparsed: $args"
+ }
+}
+
+# As parse_some_args, but check that no args remain after parsing.
+
+proc parse_args { argset } {
+ uplevel parse_some_args [list $argset]
+
+ # Require no remaining args.
+ uplevel check_no_args_left
+}
+
# Process the caller's options variable and set variables according
# to the list of valid options described by OPTIONSET.
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index a79b133fa4f..38321379721 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -2680,7 +2680,7 @@ proc mi_make_info_frame_regexp {args} {
# build the regexp for matching against the -stack-info-frame output.
proc mi_info_frame { test args } {
- parse_args {{frame ""} {thread ""}}
+ parse_some_args {{frame ""} {thread ""}}
set re [eval mi_make_info_frame_regexp $args]