1 # Copyright 2014-2022 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Regression test for a bug where GDB would internal error if a thread
18 # runs into a breakpoint that needs stepping over, just after stepping
19 # over another breakpoint, without a user visible stop in between.
23 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
27 if ![runto_main] then {
31 # Make sure the target doesn't hide the breakpoint hits (that don't
32 # cause a user visible stop) from GDB.
33 gdb_test_no_output "set breakpoint condition-evaluation host"
35 set up_to_nl "\[^\r\n\]+\[\r\n\]+"
37 # Number of consecutive breakpoints in a row to try.
40 # Extract addresses of a few consecutive instructions.
41 set test "get breakpoint addresses"
42 if { [gdb_test_multiple "x /[expr $n_insns + 1]i \$pc" $test {
43 -re "=> $hex${up_to_nl} ($hex)${up_to_nl} ($hex)${up_to_nl} ($hex)${up_to_nl}$gdb_prompt $" {
44 for {set i 1} {$i <= $n_insns} {incr i} {
45 set bp_addrs($i) $expect_out($i,string)
50 # No use proceeding if bp_addrs wasn't set.
54 for {set i 1} {$i <= $n_insns} {incr i} {
55 with_test_prefix "insn $i" {
56 gdb_test "break \*$bp_addrs($i)" \
57 "Breakpoint $decimal at $bp_addrs($i): file .*" \
60 # Give the breakpoint a condition that always fails, so that
61 # the thread is immediately re-resumed.
62 gdb_test_no_output "condition \$bpnum condition" \
67 set lineno [gdb_get_line_number "break here"]
68 gdb_breakpoint $lineno
69 gdb_continue_to_breakpoint "break here" ".*break here.*"