1 # Copyright 2018-2021 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/>.
16 # This testcase is a regression test for a regression in the in-line
17 # step-over machinery. If a resumption that starts a step-over
18 # failed, a following resumption would make GDB hang forever:
25 # Cannot insert breakpoint 2.
26 # Cannot access memory at address 0x0
30 # Delete all breakpoints? (y or n) y
32 # Breakpoint 3 at 0x40048b: file test.c, line 33.
39 if {[build_executable "failed to prepare" $testfile $srcfile debug]} {
43 # DISPLACED indicates whether to use displaced-stepping.
44 proc do_test {displaced breakpoint_always_inserted} {
45 global gdb_prompt decimal
46 global srcfile binfile
48 clean_restart $binfile
50 gdb_test_no_output "set displaced-stepping $displaced"
51 gdb_test_no_output "set breakpoint always-inserted $breakpoint_always_inserted"
58 # We rely on not being able to set a breakpoint at 0, as proxy for
59 # any kind of breakpoint insertion failure. If we can examine
60 # what's at memory address 0, it is possible that we could also
62 if [is_address_zero_readable] {
63 untested "memory at address 0 is possibly executable"
67 # Set a breakpoint that fails to insert.
68 if { $breakpoint_always_inserted == "on" } {
69 gdb_test "b *0" "Breakpoint $decimal at 0x0.*"
71 gdb_test "b *0" "Breakpoint $decimal at 0x0"
75 "Command aborted\\." \
78 # Delete the "bad" breakpoint and try continuing again.
80 gdb_test "b function" "Breakpoint $decimal .*$srcfile.*"
83 "Breakpoint $decimal, function \\(\\) at .*$srcfile:.*" \
84 "continue to function"
87 # This testcase exercises a regression with the in-line step-over
88 # machinery. So make sure this runs with displaced stepping disabled,
89 # and for good measure, also try with displaced stepping enabled.
90 foreach_with_prefix displaced-stepping {"off" "on"} {
91 foreach_with_prefix breakpoint-always-inserted {"off" "on"} {
92 do_test ${displaced-stepping} ${breakpoint-always-inserted}