]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/testsuite] Make parse_args error out on remaining args
authorTom de Vries <tdevries@suse.de>
Mon, 23 Sep 2024 07:34:48 +0000 (09:34 +0200)
committerTom de Vries <tdevries@suse.de>
Mon, 23 Sep 2024 07:34:48 +0000 (09:34 +0200)
commit3169d006121af0316903bb05f72ca52b40083834
tree5b49cc8a8a96f1c3cca404793829222c20066799
parentbe32af158ade53f91caeb1951e8cbf7578d08b52
[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
gdb/testsuite/gdb.base/hbreak-unmapped.exp
gdb/testsuite/gdb.mi/mi-break-qualified.exp
gdb/testsuite/gdb.mi/mi-break.exp
gdb/testsuite/gdb.mi/mi-nsmoribund.exp
gdb/testsuite/gdb.mi/mi-nsthrexec.exp
gdb/testsuite/gdb.mi/mi-pending.exp
gdb/testsuite/gdb.mi/mi-vla-c99.exp
gdb/testsuite/gdb.mi/mi-vla-fortran.exp
gdb/testsuite/gdb.testsuite/parse_options_args.exp
gdb/testsuite/lib/gdb.exp
gdb/testsuite/lib/mi-support.exp