Commit | Line | Data |
---|---|---|
61baf725 | 1 | # Copyright 1998-2017 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 | ||
f8b41b00 | 19 | standard_testfile .c |
c906108c SS |
20 | |
21 | # Build the test case | |
fc91c6c2 | 22 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { |
84c93cd5 | 23 | untested "failed to compile" |
b60f0898 | 24 | return -1 |
c906108c SS |
25 | } |
26 | ||
27 | ||
28 | # Start with a fresh gdb | |
29 | ||
f8b41b00 | 30 | clean_restart ${binfile} |
c906108c SS |
31 | |
32 | if ![runto_main] then { | |
33 | perror "Couldn't run to main" | |
34 | return -1 | |
35 | } | |
36 | ||
37 | # Set a breakpoint on the statement that we're about to jump to. | |
38 | # The statement doesn't contain a function call. | |
39 | # | |
c906108c | 40 | set bp_on_non_call 0 |
78f98cca AA |
41 | set non_call_line [gdb_get_line_number "bp-on-non-call"] |
42 | gdb_test_multiple "break $non_call_line" "break before jump to non-call" { | |
43 | -re "\[Bb\]reakpoint (${decimal}) at ${hex}: file .*${srcfile}, line $non_call_line.*$gdb_prompt $" { | |
a76e022a MS |
44 | set bp_on_non_call $expect_out(1,string) |
45 | pass "break before jump to non-call" | |
46 | } | |
c906108c SS |
47 | } |
48 | ||
49 | # Can we jump to the statement? Do we stop there? | |
50 | # | |
78f98cca | 51 | gdb_test "jump $non_call_line" "Breakpoint ${decimal}, .*${srcfile}:$non_call_line.*" \ |
a76e022a | 52 | "jump to non-call" |
c906108c SS |
53 | |
54 | # Set a breakpoint on the statement that we're about to jump to. | |
55 | # The statement does contain a function call. | |
56 | # | |
c906108c | 57 | set bp_on_call 0 |
78f98cca AA |
58 | set call_line [gdb_get_line_number "bp-on-call"] |
59 | gdb_test_multiple "break $call_line" "break before jump to call" { | |
60 | -re "\[Bb\]reakpoint (${decimal}) at ${hex}: file .*${srcfile}, line $call_line.*$gdb_prompt $" { | |
a76e022a MS |
61 | set bp_on_call $expect_out(1,string) |
62 | pass "break before jump to call" | |
63 | } | |
c906108c SS |
64 | } |
65 | ||
66 | # Can we jump to the statement? Do we stop there? | |
67 | # | |
78f98cca AA |
68 | gdb_test "jump $call_line" \ |
69 | "Breakpoint ${decimal}, .*${srcfile}:$call_line.*" \ | |
a76e022a | 70 | "jump to call" |
c906108c SS |
71 | |
72 | # If we disable the breakpoint at the function call, and then | |
73 | # if we jump to that statement, do we not stop there, but at | |
74 | # the following breakpoint? | |
75 | # | |
a76e022a | 76 | gdb_test_no_output "disable $bp_on_call" "disable breakpoint on call" |
c906108c | 77 | |
78f98cca | 78 | gdb_test "jump $call_line" "Breakpoint ${decimal}, .*${srcfile}:$non_call_line.*" \ |
a76e022a | 79 | "jump to call with disabled breakpoint" |
c906108c SS |
80 | |
81 | # Verify that GDB responds gracefully to the "jump" command without | |
82 | # an argument. | |
83 | # | |
a76e022a MS |
84 | gdb_test "jump" "Argument required .starting address.*" \ |
85 | "jump without argument disallowed" | |
86 | ||
c906108c SS |
87 | |
88 | # Verify that GDB responds gracefully to the "jump" command with | |
89 | # trailing junk. | |
90 | # | |
78f98cca | 91 | gdb_test "jump $call_line 100" \ |
40e084e1 | 92 | "malformed linespec error: unexpected number, \"100\"" \ |
a76e022a MS |
93 | "jump with trailing argument junk" |
94 | ||
c906108c SS |
95 | |
96 | # Verify that GDB responds gracefully to a request to jump out of | |
97 | # the current function. (Note that this will very likely cause the | |
98 | # inferior to die. Be prepared to rerun the inferior, if further | |
99 | # testing is desired.) | |
100 | # | |
101 | # Try it both ways: confirming and not confirming the jump. | |
102 | # | |
c906108c | 103 | |
78f98cca AA |
104 | set out_line [gdb_get_line_number "out-of-func"] |
105 | gdb_test "jump $out_line" \ | |
a76e022a MS |
106 | "Not confirmed.*" \ |
107 | "aborted jump out of current function" \ | |
78f98cca | 108 | "Line $out_line is not in `main'. Jump anyway.*y or n. $" \ |
a76e022a MS |
109 | "n" |
110 | ||
78f98cca | 111 | gdb_test "jump $out_line" \ |
a76e022a MS |
112 | "Continuing at.*" \ |
113 | "jump out of current function" \ | |
78f98cca | 114 | "Line $out_line is not in `main'. Jump anyway.*y or n. $" \ |
a76e022a | 115 | "y" |
c906108c SS |
116 | |
117 | gdb_exit | |
118 | return 0 |