warn if "source" fails to open the file when from_tty == 0
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / jump.exp
1 # Copyright 1998-2013 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
17 clear_xfail "*-*-*"
18
19 standard_testfile .c
20
21 # Build the test case
22 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
23 untested jump.exp
24 return -1
25 }
26
27
28 # Start with a fresh gdb
29
30 clean_restart ${binfile}
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 #
40 set bp_on_non_call 0
41 gdb_test_multiple "break 22" "break before jump to non-call" {
42 -re "\[Bb\]reakpoint (\[0-9\]*) at 0x\[0-9a-fA-F\]*: file .*${srcfile}, line 22.*$gdb_prompt $" {
43 set bp_on_non_call $expect_out(1,string)
44 pass "break before jump to non-call"
45 }
46 }
47
48 # Can we jump to the statement? Do we stop there?
49 #
50 gdb_test "jump 22" "Breakpoint \[0-9\]*, .*${srcfile}:22.*" \
51 "jump to non-call"
52
53 # Set a breakpoint on the statement that we're about to jump to.
54 # The statement does contain a function call.
55 #
56 set bp_on_call 0
57 gdb_test_multiple "break 21" "break before jump to call" {
58 -re "\[Bb\]reakpoint (\[0-9\]*) at 0x\[0-9a-fA-F\]*: file .*${srcfile}, line 21.*$gdb_prompt $" {
59 set bp_on_call $expect_out(1,string)
60 pass "break before jump to call"
61 }
62 }
63
64 # Can we jump to the statement? Do we stop there?
65 #
66 gdb_test "jump 21" \
67 "Breakpoint \[0-9\]*, .*${srcfile}:21.*" \
68 "jump to call"
69
70 # If we disable the breakpoint at the function call, and then
71 # if we jump to that statement, do we not stop there, but at
72 # the following breakpoint?
73 #
74 gdb_test_no_output "disable $bp_on_call" "disable breakpoint on call"
75
76 gdb_test "jump 21" "Breakpoint \[0-9\]*, .*${srcfile}:22.*" \
77 "jump to call with disabled breakpoint"
78
79 # Verify that GDB responds gracefully to the "jump" command without
80 # an argument.
81 #
82 gdb_test "jump" "Argument required .starting address.*" \
83 "jump without argument disallowed"
84
85
86 # Verify that GDB responds gracefully to the "jump" command with
87 # trailing junk.
88 #
89 gdb_test "jump 21 100" \
90 "malformed linespec error: unexpected number, \"100\"" \
91 "jump with trailing argument junk"
92
93
94 # Verify that GDB responds gracefully to a request to jump out of
95 # the current function. (Note that this will very likely cause the
96 # inferior to die. Be prepared to rerun the inferior, if further
97 # testing is desired.)
98 #
99 # Try it both ways: confirming and not confirming the jump.
100 #
101
102 gdb_test "jump 12" \
103 "Not confirmed.*" \
104 "aborted jump out of current function" \
105 "Line 12 is not in `main'. Jump anyway.*y or n. $" \
106 "n"
107
108 gdb_test "jump 12" \
109 "Continuing at.*" \
110 "jump out of current function" \
111 "Line 12 is not in `main'. Jump anyway.*y or n. $" \
112 "y"
113
114 gdb_exit
115 return 0
This page took 0.036645 seconds and 4 git commands to generate.