OSDN Git Service

3ccc334e11e72255ea3518364c92e4e71ec264e1
[pf3gnuchains/pf3gnuchains4x.git] / gdb / testsuite / gdb.base / jump.exp
1 #   Copyright 1998-1999, 2007-2012 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 3 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, see <http://www.gnu.org/licenses/>.  */
15
16 if $tracelevel then {
17         strace $tracelevel
18         }
19
20
21 clear_xfail "*-*-*"
22
23 set testfile "jump"
24 set srcfile ${testfile}.c
25 set binfile ${objdir}/${subdir}/${testfile}
26
27 # Build the test case
28 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
29      untested jump.exp
30      return -1
31     }
32
33
34 # Start with a fresh gdb
35
36 gdb_exit
37 gdb_start
38 gdb_reinitialize_dir $srcdir/$subdir
39 gdb_load ${binfile}
40
41 if ![runto_main] then {
42   perror "Couldn't run to main"
43   return -1
44 }
45
46 # Set a breakpoint on the statement that we're about to jump to.
47 # The statement doesn't contain a function call.
48 #
49 set bp_on_non_call 0
50 gdb_test_multiple "break 22" "break before jump to non-call" {
51     -re "\[Bb\]reakpoint (\[0-9\]*) at 0x\[0-9a-fA-F\]*: file .*${srcfile}, line 22.*$gdb_prompt $" {
52         set bp_on_non_call $expect_out(1,string)
53         pass "break before jump to non-call"
54     }
55 }
56
57 # Can we jump to the statement?  Do we stop there?
58 #
59 gdb_test "jump 22" "Breakpoint \[0-9\]*, .*${srcfile}:22.*" \
60     "jump to non-call"
61
62 # Set a breakpoint on the statement that we're about to jump to.
63 # The statement does contain a function call.
64 #
65 set bp_on_call 0
66 gdb_test_multiple "break 21" "break before jump to call" {
67     -re "\[Bb\]reakpoint (\[0-9\]*) at 0x\[0-9a-fA-F\]*: file .*${srcfile}, line 21.*$gdb_prompt $" {
68         set bp_on_call $expect_out(1,string)
69         pass "break before jump to call"
70     }
71 }
72
73 # Can we jump to the statement?  Do we stop there?
74 #
75 gdb_test "jump 21" \
76     "Breakpoint \[0-9\]*, .*${srcfile}:21.*" \
77     "jump to call"
78
79 # If we disable the breakpoint at the function call, and then
80 # if we jump to that statement, do we not stop there, but at
81 # the following breakpoint?
82 #
83 gdb_test_no_output "disable $bp_on_call" "disable breakpoint on call"
84
85 gdb_test "jump 21" "Breakpoint \[0-9\]*, .*${srcfile}:22.*" \
86     "jump to call with disabled breakpoint"
87
88 # Verify that GDB responds gracefully to the "jump" command without
89 # an argument.
90 #
91 gdb_test "jump" "Argument required .starting address.*" \
92     "jump without argument disallowed"
93
94
95 # Verify that GDB responds gracefully to the "jump" command with
96 # trailing junk.
97 #
98 gdb_test "jump 21 100" \
99     "Junk at end of line specification: 100.*" \
100     "jump with trailing argument junk"
101
102
103 # Verify that GDB responds gracefully to a request to jump out of
104 # the current function.  (Note that this will very likely cause the
105 # inferior to die.  Be prepared to rerun the inferior, if further
106 # testing is desired.)
107 #
108 # Try it both ways: confirming and not confirming the jump.
109 #
110
111 gdb_test "jump 12" \
112     "Not confirmed.*" \
113     "aborted jump out of current function" \
114     "Line 12 is not in `main'.  Jump anyway.*y or n. $" \
115     "n"
116
117 gdb_test "jump 12" \
118     "Continuing at.*" \
119     "jump out of current function" \
120     "Line 12 is not in `main'.  Jump anyway.*y or n. $" \
121     "y"
122
123 gdb_exit
124 return 0