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