1 # Copyright (C) 2015-2019 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 # Test that GDB can step past a breakpoint even if GDB doesn't have
17 # symbols for the main binary. PR gdb/13858.
19 standard_testfile start.c
21 if { [build_executable "failed to build" ${testfile} $srcfile] } {
25 # Get the current PC. MSG is used as test message.
31 gdb_test_multiple "p /x \$pc" "$msg" {
32 -re " = ($hex).*$gdb_prompt $" {
33 set addr $expect_out(1,string)
41 # Test stepping past a breakpoint with no symbols. DISPLACED is one
42 # of the "set displaced-stepping" options. If GDB can't find where to
43 # put the scratch pad, GDB should be able to fall back to stepping
44 # past the breakpoint using an in-line step-over.
46 proc test_step_over { displaced } {
50 clean_restart $binfile
53 fail "couldn't run to main"
54 untested "stepping over breakpoint with displaced=$displaced"
60 set msg "purging symbols"
61 gdb_test_multiple "file" "$msg" {
62 -re "Are you sure you want to change the file.*y or n. $" {
66 -re "Discard symbol table.*y or n. $" {
67 gdb_test "y" "No symbol file now." "$msg"
71 set before_addr [get_pc "get before PC"]
73 gdb_test "break *\$pc" "Breakpoint .* at $hex"
75 gdb_test_no_output "set displaced-stepping $displaced"
77 gdb_test "stepi" "$hex in \?\? .*"
79 set after_addr [get_pc "get after PC"]
81 gdb_assert {$before_addr != $after_addr} "advanced"
84 foreach displaced { "off" "on" "auto" } {
85 if { $displaced != "off" && ![support_displaced_stepping] } {
89 with_test_prefix "displaced=$displaced" {
90 test_step_over $displaced