1 # Copyright 1998-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/>. */
22 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
23 untested "failed to compile"
28 # Start with a fresh gdb
30 clean_restart ${binfile}
32 if ![runto_main] then {
33 perror "Couldn't run to main"
37 # Set a breakpoint on the statement that we're about to jump to.
38 # The statement doesn't contain a function call.
41 set non_call_line [gdb_get_line_number "bp-on-non-call"]
42 gdb_test_multiple "break $non_call_line" "break before jump to non-call" {
43 -re "\[Bb\]reakpoint (${decimal}) at ${hex}: file .*${srcfile}, line $non_call_line.*$gdb_prompt $" {
44 set bp_on_non_call $expect_out(1,string)
45 pass "break before jump to non-call"
49 # Can we jump to the statement? Do we stop there?
51 gdb_test "jump $non_call_line" "Breakpoint ${decimal}, .*${srcfile}:$non_call_line.*" \
54 # Set a breakpoint on the statement that we're about to jump to.
55 # The statement does contain a function call.
58 set call_line [gdb_get_line_number "bp-on-call"]
59 gdb_test_multiple "break $call_line" "break before jump to call" {
60 -re "\[Bb\]reakpoint (${decimal}) at ${hex}: file .*${srcfile}, line $call_line.*$gdb_prompt $" {
61 set bp_on_call $expect_out(1,string)
62 pass "break before jump to call"
66 # Can we jump to the statement? Do we stop there?
68 gdb_test "jump $call_line" \
69 "Breakpoint ${decimal}, .*${srcfile}:$call_line.*" \
72 # If we disable the breakpoint at the function call, and then
73 # if we jump to that statement, do we not stop there, but at
74 # the following breakpoint?
76 gdb_test_no_output "disable $bp_on_call" "disable breakpoint on call"
78 gdb_test "jump $call_line" "Breakpoint ${decimal}, .*${srcfile}:$non_call_line.*" \
79 "jump to call with disabled breakpoint"
81 # Verify that GDB responds gracefully to the "jump" command without
84 gdb_test "jump" "Argument required .starting address.*" \
85 "jump without argument disallowed"
88 # Verify that GDB responds gracefully to the "jump" command with
91 gdb_test "jump $call_line 100" \
92 "malformed linespec error: unexpected number, \"100\"" \
93 "jump with trailing argument junk"
96 # Verify that GDB responds gracefully to a request to jump out of
97 # the current function. (Note that this will very likely cause the
98 # inferior to die. Be prepared to rerun the inferior, if further
99 # testing is desired.)
101 # Try it both ways: confirming and not confirming the jump.
104 set out_line [gdb_get_line_number "out-of-func"]
105 gdb_test "jump $out_line" \
107 "aborted jump out of current function" \
108 "Line $out_line is not in `main'. Jump anyway.*y or n. $" \
111 gdb_test "jump $out_line" \
113 "jump out of current function" \
114 "Line $out_line is not in `main'. Jump anyway.*y or n. $" \