[gdb/testsuite] Reduce errors after gdb exit in default_gdb_start
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / continue-after-aborted-step-over.exp
CommitLineData
b811d2c2 1# Copyright 2018-2020 Free Software Foundation, Inc.
eea61984
PA
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
37standard_testfile
38
39if {[build_executable "failed to prepare" $testfile $srcfile debug]} {
40 return -1
41}
42
43# DISPLACED indicates whether to use displaced-stepping.
44proc do_test {displaced} {
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
52 if ![runto_main] {
53 fail "run to 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 gdb_test "b *0" "Breakpoint $decimal at 0x0"
68
69 gdb_test "continue" \
70 "Command aborted\\." \
71 "continue aborts"
72
73 # Delete the "bad" breakpoint and try continuing again.
74 delete_breakpoints
75 gdb_test "b function" "Breakpoint $decimal .*$srcfile.*"
76
77 gdb_test "continue" \
78 "Breakpoint $decimal, function \\(\\) at .*$srcfile:.*" \
79 "continue to function"
80}
81
82# This testcase exercises a regression with the in-line step-over
83# machinery. So make sure this runs with displaced stepping disabled,
84# and for good measure, also try with displaced stepping enabled.
85foreach_with_prefix displaced-stepping {"off" "on"} {
86 do_test ${displaced-stepping}
87}
This page took 0.319557 seconds and 4 git commands to generate.