]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/step-over-no-symbols.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / step-over-no-symbols.exp
1 # Copyright (C) 2015-2023 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 # Test that GDB can step past a breakpoint even if GDB doesn't have
17 # symbols for the main binary. PR gdb/13858.
18
19 standard_testfile start.c
20
21 if { [build_executable "failed to build" ${testfile} $srcfile] } {
22 return -1
23 }
24
25 # Get the current PC. MSG is used as test message.
26
27 proc get_pc { msg } {
28 global hex gdb_prompt
29
30 set addr ""
31 gdb_test_multiple "p /x \$pc" "$msg" {
32 -re " = ($hex).*$gdb_prompt $" {
33 set addr $expect_out(1,string)
34 pass "$msg"
35 }
36 }
37
38 return $addr
39 }
40
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.
45
46 proc test_step_over { displaced } {
47 global hex
48 global binfile
49
50 clean_restart $binfile
51
52 if ![runto_main] {
53 return -1
54 }
55
56 delete_breakpoints
57
58 set msg "purging symbols"
59 gdb_test_multiple "file" "$msg" {
60 -re "Are you sure you want to change the file.*y or n. $" {
61 send_gdb "y\n"
62 exp_continue
63 }
64 -re "Discard symbol table.*y or n. $" {
65 gdb_test "y" "No symbol file now." "$msg"
66 }
67 }
68
69 set before_addr [get_pc "get before PC"]
70
71 gdb_test "break *\$pc" "Breakpoint .* at $hex"
72
73 gdb_test_no_output "set displaced-stepping $displaced"
74
75 gdb_test "stepi" "$hex in \?\? .*"
76
77 set after_addr [get_pc "get after PC"]
78
79 gdb_assert {{[regexp "^${hex}$" $before_addr] \
80 && [regexp "^${hex}$" $after_addr] \
81 && $before_addr != $after_addr}} "advanced"
82 }
83
84 foreach displaced { "off" "on" "auto" } {
85 if { $displaced != "off" && ![support_displaced_stepping] } {
86 continue
87 }
88
89 with_test_prefix "displaced=$displaced" {
90 test_step_over $displaced
91 }
92 }