Files
binutils-gdb/gdb/testsuite/gdb.base/hbreak-unmapped.exp
Tom de Vries 3169d00612 [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
2024-09-23 09:34:48 +02:00

75 lines
2.2 KiB
Plaintext

# Copyright 2014-2024 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
require allow_hw_breakpoint_tests
standard_testfile
if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} {
return -1
}
if ![runto_main] {
return -1
}
# If we can read the memory at address 0, skip the test.
if { [is_address_zero_readable] } {
untested "memory at address 0 is readable"
return
}
delete_breakpoints
# Test whether the target supports hardware breakpoints at all.
set supports_hbreak 0
set test "probe hardware breakpoint support"
gdb_test_multiple "hbreak -q main" $test {
-re "No hardware breakpoint support in the target.*$gdb_prompt $" {
pass $test
}
-re "Hardware breakpoints used exceeds limit.*$gdb_prompt $" {
pass $test
}
-re "Hardware assisted breakpoint.*at.* file .*$srcfile, line.*$gdb_prompt $" {
set supports_hbreak 1
pass $test
}
}
if {!$supports_hbreak} {
unsupported "hardware breakpoints"
return
}
delete_breakpoints
# Force immediate breakpoint insertion.
gdb_test_no_output "set breakpoint always-inserted on"
# Hardware breakpoints are implemented using a mechanism that is not
# dependent on being able to modify the target's memory, we should be
# able to set them even in unmapped memory areas.
gdb_test "hbreak *0" "Hardware assisted breakpoint \[0-9\]+ at 0x0"
gdb_test "info break" "hw breakpoint.*y.*0x0\+\[ \t\]\+" \
"info break shows hw breakpoint"
gdb_test_no_output "delete \$bpnum" "delete hw breakpoint"
gdb_test "info break" "No breakpoints, watchpoints, tracepoints, or catchpoints\." \
"info break shows no breakpoints, watchpoints, tracepoints, or catchpoints"