run copyright.sh for 2011.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / jump.exp
CommitLineData
7b6bb8da 1# Copyright 1998, 1999, 2007, 2008, 2009, 2010, 2011
4c38e0a4 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#
c906108c 50set bp_on_non_call 0
a76e022a
MS
51gdb_test_multiple "break 22" "break before jump to non-call" {
52 -re "\[Bb\]reakpoint (\[0-9\]*) at 0x\[0-9a-fA-F\]*: file .*${srcfile}, line 22.*$gdb_prompt $" {
53 set bp_on_non_call $expect_out(1,string)
54 pass "break before jump to non-call"
55 }
c906108c
SS
56}
57
58# Can we jump to the statement? Do we stop there?
59#
a76e022a
MS
60gdb_test "jump 22" "Breakpoint \[0-9\]*, .*${srcfile}:22.*" \
61 "jump to non-call"
c906108c
SS
62
63# Set a breakpoint on the statement that we're about to jump to.
64# The statement does contain a function call.
65#
c906108c 66set bp_on_call 0
a76e022a
MS
67gdb_test_multiple "break 21" "break before jump to call" {
68 -re "\[Bb\]reakpoint (\[0-9\]*) at 0x\[0-9a-fA-F\]*: file .*${srcfile}, line 21.*$gdb_prompt $" {
69 set bp_on_call $expect_out(1,string)
70 pass "break before jump to call"
71 }
c906108c
SS
72}
73
74# Can we jump to the statement? Do we stop there?
75#
a76e022a
MS
76gdb_test "jump 21" \
77 "Breakpoint \[0-9\]*, .*${srcfile}:21.*" \
78 "jump to call"
c906108c
SS
79
80# If we disable the breakpoint at the function call, and then
81# if we jump to that statement, do we not stop there, but at
82# the following breakpoint?
83#
a76e022a 84gdb_test_no_output "disable $bp_on_call" "disable breakpoint on call"
c906108c 85
a76e022a
MS
86gdb_test "jump 21" "Breakpoint \[0-9\]*, .*${srcfile}:22.*" \
87 "jump to call with disabled breakpoint"
c906108c
SS
88
89# Verify that GDB responds gracefully to the "jump" command without
90# an argument.
91#
a76e022a
MS
92gdb_test "jump" "Argument required .starting address.*" \
93 "jump without argument disallowed"
94
c906108c
SS
95
96# Verify that GDB responds gracefully to the "jump" command with
97# trailing junk.
98#
a76e022a
MS
99gdb_test "jump 21 100" \
100 "Junk at end of line specification: 100.*" \
101 "jump with trailing argument junk"
102
c906108c
SS
103
104# Verify that GDB responds gracefully to a request to jump out of
105# the current function. (Note that this will very likely cause the
106# inferior to die. Be prepared to rerun the inferior, if further
107# testing is desired.)
108#
109# Try it both ways: confirming and not confirming the jump.
110#
c906108c 111
a76e022a
MS
112gdb_test "jump 12" \
113 "Not confirmed.*" \
114 "aborted jump out of current function" \
115 "Line 12 is not in `main'. Jump anyway.*y or n. $" \
116 "n"
117
118gdb_test "jump 12" \
119 "Continuing at.*" \
120 "jump out of current function" \
121 "Line 12 is not in `main'. Jump anyway.*y or n. $" \
122 "y"
c906108c
SS
123
124gdb_exit
125return 0
This page took 1.155759 seconds and 4 git commands to generate.