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