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