]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / continue-after-aborted-step-over.exp
1 # Copyright 2018-2024 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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/>.
15
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:
19 #
20 # (gdb) b *0
21 # Breakpoint 2 at 0x0
22 # continue
23 # Continuing.
24 # Warning:
25 # Cannot insert breakpoint 2.
26 # Cannot access memory at address 0x0
27 #
28 # Command aborted.
29 # delete breakpoints
30 # Delete all breakpoints? (y or n) y
31 # (gdb) b function
32 # Breakpoint 3 at 0x40048b: file test.c, line 33.
33 # continue
34 # Continuing.
35 # *GDB hangs forever*
36
37 standard_testfile
38
39 if {[build_executable "failed to prepare" $testfile $srcfile debug]} {
40 return -1
41 }
42
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
47
48 clean_restart $binfile
49
50 gdb_test_no_output "set displaced-stepping $displaced"
51 gdb_test_no_output "set breakpoint always-inserted $breakpoint_always_inserted"
52
53 if ![runto_main] {
54 return -1
55 }
56
57 # We rely on not being able to set a breakpoint at 0, as proxy for
58 # any kind of breakpoint insertion failure. If we can examine
59 # what's at memory address 0, it is possible that we could also
60 # execute it.
61 if [is_address_zero_readable] {
62 untested "memory at address 0 is possibly executable"
63 return
64 }
65
66 # Set a breakpoint that fails to insert.
67 if { $breakpoint_always_inserted == "on" } {
68 gdb_test "b *0" "Breakpoint $decimal at 0x0.*"
69 } else {
70 gdb_test "b *0" "Breakpoint $decimal at 0x0"
71 }
72
73 gdb_test "continue" \
74 "Command aborted\\." \
75 "continue aborts"
76
77 # Delete the "bad" breakpoint and try continuing again.
78 delete_breakpoints
79 gdb_test "b function" "Breakpoint $decimal .*$srcfile.*"
80
81 gdb_test "continue" \
82 "Breakpoint $decimal, function \\(\\) at .*$srcfile:.*" \
83 "continue to function"
84 }
85
86 # This testcase exercises a regression with the in-line step-over
87 # machinery. So make sure this runs with displaced stepping disabled,
88 # and for good measure, also try with displaced stepping enabled.
89 foreach_with_prefix displaced-stepping {"off" "on"} {
90 foreach_with_prefix breakpoint-always-inserted {"off" "on"} {
91 do_test ${displaced-stepping} ${breakpoint-always-inserted}
92 }
93 }