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