gdb/testsuite/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / jump.exp
CommitLineData
0fb0cc75 1# Copyright 1998, 1999, 2007, 2008, 2009 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
SS
16if $tracelevel then {
17 strace $tracelevel
18 }
19
20set prms_id 0
21set bug_id 0
22
c906108c
SS
23clear_xfail "*-*-*"
24
25set testfile "jump"
26set srcfile ${testfile}.c
27set binfile ${objdir}/${subdir}/${testfile}
28
29# Build the test case
fc91c6c2 30if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
b60f0898
JB
31 untested jump.exp
32 return -1
c906108c
SS
33 }
34
35
36# Start with a fresh gdb
37
38gdb_exit
39gdb_start
40gdb_reinitialize_dir $srcdir/$subdir
41gdb_load ${binfile}
42
43if ![runto_main] then {
44 perror "Couldn't run to main"
45 return -1
46}
47
48# Set a breakpoint on the statement that we're about to jump to.
49# The statement doesn't contain a function call.
50#
085dd6e6 51send_gdb "break 22\n"
c906108c
SS
52set bp_on_non_call 0
53gdb_expect {
085dd6e6 54 -re "\[Bb\]reakpoint (\[0-9\]*) at 0x\[0-9a-fA-F\]*: file .*${srcfile}, line 22.*$gdb_prompt $"\
c906108c
SS
55 {set bp_on_non_call $expect_out(1,string)
56 pass "break before jump to non-call"}
57 -re "$gdb_prompt $"\
58 {fail "break before jump to non-call"}
59 timeout {fail "(timeout) break before jump to non-call"}
60}
61
62# Can we jump to the statement? Do we stop there?
63#
085dd6e6 64send_gdb "jump 22\n"
c906108c 65gdb_expect {
085dd6e6 66 -re "Breakpoint \[0-9\]*, .*${srcfile}:22.*$gdb_prompt $"\
c906108c
SS
67 {pass "jump to non-call"}
68 -re "$gdb_prompt $"\
69 {fail "jump to non-call"}
70 timeout {fail "(timeout) jump to non-call"}
71}
72
73# Set a breakpoint on the statement that we're about to jump to.
74# The statement does contain a function call.
75#
085dd6e6 76send_gdb "break 21\n"
c906108c
SS
77set bp_on_call 0
78gdb_expect {
085dd6e6 79 -re "\[Bb\]reakpoint (\[0-9\]*) at 0x\[0-9a-fA-F\]*: file .*${srcfile}, line 21.*$gdb_prompt $"\
c906108c
SS
80 {set bp_on_call $expect_out(1,string)
81 pass "break before jump to call"}
82 -re "$gdb_prompt $"\
83 {fail "break before jump to call"}
84 timeout {fail "(timeout) break before jump to call"}
85}
86
87# Can we jump to the statement? Do we stop there?
88#
085dd6e6 89send_gdb "jump 21\n"
c906108c 90gdb_expect {
085dd6e6 91 -re "Breakpoint \[0-9\]*, .*${srcfile}:21.*$gdb_prompt $"\
c906108c
SS
92 {pass "jump to call"}
93 -re "$gdb_prompt $"\
94 {fail "jump to call"}
95 timeout {fail "(timeout) jump to call"}
96}
97
98# If we disable the breakpoint at the function call, and then
99# if we jump to that statement, do we not stop there, but at
100# the following breakpoint?
101#
102send_gdb "disable $bp_on_call\n"
103gdb_expect {
104 -re "$gdb_prompt $"\
105 {pass "disable breakpoint on call"}
106 timeout {fail "(timeout) disable breakpoint on call"}
107}
108
085dd6e6 109send_gdb "jump 21\n"
c906108c 110gdb_expect {
085dd6e6 111 -re "Breakpoint \[0-9\]*, .*${srcfile}:22.*$gdb_prompt $"\
c906108c
SS
112 {pass "jump to call with disabled breakpoint"}
113 -re "$gdb_prompt $"\
114 {fail "jump to call with disabled breakpoint"}
115 timeout {fail "(timeout) jump to call with disabled breakpoint"}
116}
117
118# Verify that GDB responds gracefully to the "jump" command without
119# an argument.
120#
121send_gdb "jump\n"
122gdb_expect {
123 -re "Argument required .starting address..*$gdb_prompt $"\
124 {pass "jump without argument disallowed"}
125 -re "$gdb_prompt $"\
126 {fail "jump without argument disallowed"}
127 timeout {fail "(timeout) jump without argument disallowed"}
128}
129
130# Verify that GDB responds gracefully to the "jump" command with
131# trailing junk.
132#
085dd6e6 133send_gdb "jump 21 100\n"
c906108c
SS
134gdb_expect {
135 -re "Junk at end of line specification: 100.*$gdb_prompt $"\
136 {pass "jump with trailing argument junk"}
137 -re "$gdb_prompt $"\
138 {fail "jump with trailing argument junk"}
139 timeout {fail "(timeout) jump with trailing argument junk"}
140}
141
142# Verify that GDB responds gracefully to a request to jump out of
143# the current function. (Note that this will very likely cause the
144# inferior to die. Be prepared to rerun the inferior, if further
145# testing is desired.)
146#
147# Try it both ways: confirming and not confirming the jump.
148#
085dd6e6 149send_gdb "jump 12\n"
c906108c 150gdb_expect {
085dd6e6 151 -re "Line 12 is not in `main'. Jump anyway.*y or n. $"\
c906108c
SS
152 {send_gdb "n\n"
153 gdb_expect {
154 -re "Not confirmed.*$gdb_prompt $"\
155 {pass "aborted jump out of current function"}
156 -re "$gdb_prompt $"\
157 {fail "aborted jump out of current function"}
158 timeout {fail "(timeout) aborted jump out of current function"}
159 }
160 }
161 -re "$gdb_prompt $"\
162 {fail "aborted jump out of current function"}
163 timeout {fail "(timeout) aborted jump out of current function"}
164}
165
085dd6e6 166send_gdb "jump 12\n"
c906108c 167gdb_expect {
085dd6e6 168 -re "Line 12 is not in `main'. Jump anyway.*y or n. $"\
c906108c
SS
169 {send_gdb "y\n"
170 gdb_expect {
171 -re "Continuing at.*$gdb_prompt $"\
172 {pass "jump out of current function"}
173 -re "$gdb_prompt $"\
174 {fail "jump out of current function"}
175 timeout {fail "(timeout) jump out of current function"}
176 }
177 }
178 -re "$gdb_prompt $"\
179 {fail "jump out of current function"}
180 timeout {fail "(timeout) jump out of current function"}
181}
182
183gdb_exit
184return 0
This page took 0.899716 seconds and 4 git commands to generate.