]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/jump.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / jump.exp
CommitLineData
213516ef 1# Copyright 1998-2023 Free Software Foundation, Inc.
c906108c
SS
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
c906108c 6# (at your option) any later version.
e22f8b7c 7#
c906108c
SS
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.
e22f8b7c 12#
c906108c 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c 15
c906108c 16
c906108c
SS
17clear_xfail "*-*-*"
18
f8b41b00 19standard_testfile .c
c906108c
SS
20
21# Build the test case
fc91c6c2 22if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
84c93cd5 23 untested "failed to compile"
b60f0898 24 return -1
c906108c
SS
25 }
26
27
28# Start with a fresh gdb
29
f8b41b00 30clean_restart ${binfile}
c906108c 31
65a33d75 32if {![runto_main]} {
c906108c
SS
33 return -1
34}
35
36# Set a breakpoint on the statement that we're about to jump to.
37# The statement doesn't contain a function call.
38#
c906108c 39set bp_on_non_call 0
78f98cca
AA
40set non_call_line [gdb_get_line_number "bp-on-non-call"]
41gdb_test_multiple "break $non_call_line" "break before jump to non-call" {
42 -re "\[Bb\]reakpoint (${decimal}) at ${hex}: file .*${srcfile}, line $non_call_line.*$gdb_prompt $" {
a76e022a
MS
43 set bp_on_non_call $expect_out(1,string)
44 pass "break before jump to non-call"
45 }
c906108c
SS
46}
47
48# Can we jump to the statement? Do we stop there?
49#
78f98cca 50gdb_test "jump $non_call_line" "Breakpoint ${decimal}, .*${srcfile}:$non_call_line.*" \
a76e022a 51 "jump to non-call"
c906108c
SS
52
53# Set a breakpoint on the statement that we're about to jump to.
54# The statement does contain a function call.
55#
c906108c 56set bp_on_call 0
78f98cca
AA
57set call_line [gdb_get_line_number "bp-on-call"]
58gdb_test_multiple "break $call_line" "break before jump to call" {
59 -re "\[Bb\]reakpoint (${decimal}) at ${hex}: file .*${srcfile}, line $call_line.*$gdb_prompt $" {
a76e022a
MS
60 set bp_on_call $expect_out(1,string)
61 pass "break before jump to call"
62 }
c906108c
SS
63}
64
65# Can we jump to the statement? Do we stop there?
66#
78f98cca
AA
67gdb_test "jump $call_line" \
68 "Breakpoint ${decimal}, .*${srcfile}:$call_line.*" \
a76e022a 69 "jump to call"
c906108c
SS
70
71# If we disable the breakpoint at the function call, and then
72# if we jump to that statement, do we not stop there, but at
73# the following breakpoint?
74#
a76e022a 75gdb_test_no_output "disable $bp_on_call" "disable breakpoint on call"
c906108c 76
78f98cca 77gdb_test "jump $call_line" "Breakpoint ${decimal}, .*${srcfile}:$non_call_line.*" \
a76e022a 78 "jump to call with disabled breakpoint"
c906108c
SS
79
80# Verify that GDB responds gracefully to the "jump" command without
81# an argument.
82#
a76e022a
MS
83gdb_test "jump" "Argument required .starting address.*" \
84 "jump without argument disallowed"
85
c906108c
SS
86
87# Verify that GDB responds gracefully to the "jump" command with
88# trailing junk.
89#
78f98cca 90gdb_test "jump $call_line 100" \
40e084e1 91 "malformed linespec error: unexpected number, \"100\"" \
a76e022a
MS
92 "jump with trailing argument junk"
93
c906108c
SS
94
95# Verify that GDB responds gracefully to a request to jump out of
96# the current function. (Note that this will very likely cause the
97# inferior to die. Be prepared to rerun the inferior, if further
98# testing is desired.)
99#
100# Try it both ways: confirming and not confirming the jump.
101#
c906108c 102
78f98cca
AA
103set out_line [gdb_get_line_number "out-of-func"]
104gdb_test "jump $out_line" \
a76e022a
MS
105 "Not confirmed.*" \
106 "aborted jump out of current function" \
78f98cca 107 "Line $out_line is not in `main'. Jump anyway.*y or n. $" \
a76e022a
MS
108 "n"
109
78f98cca 110gdb_test "jump $out_line" \
a76e022a
MS
111 "Continuing at.*" \
112 "jump out of current function" \
78f98cca 113 "Line $out_line is not in `main'. Jump anyway.*y or n. $" \
a76e022a 114 "y"
c906108c
SS
115
116gdb_exit
117return 0