Commit | Line | Data |
---|---|---|
7b6bb8da JB |
1 | # Copyright 1999, 2007, 2008, 2009, 2010, 2011 |
2 | # Free Software Foundation, Inc. | |
104c1213 JM |
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 |
104c1213 | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
104c1213 JM |
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 | # |
104c1213 | 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/>. |
104c1213 | 16 | |
104c1213 JM |
17 | |
18 | if $tracelevel then { | |
19 | strace $tracelevel | |
20 | } | |
21 | ||
22 | # | |
23 | # test running programs | |
24 | # | |
104c1213 JM |
25 | |
26 | set testfile "async" | |
27 | set srcfile ${testfile}.c | |
28 | set binfile ${objdir}/${subdir}/${testfile} | |
29 | ||
fc91c6c2 | 30 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { |
b60f0898 JB |
31 | untested async.exp |
32 | return -1 | |
104c1213 JM |
33 | } |
34 | ||
35 | if [get_compiler_info ${binfile}] { | |
36 | return -1 | |
37 | } | |
38 | ||
39 | ######################################## | |
40 | ## | |
41 | ## Don't do any of these tests until we reach consensus on this file. | |
42 | ## | |
43 | return 0 | |
44 | ######################################## | |
45 | ||
46 | set board [target_info name] | |
47 | set current_target [target_info gdb_protocol] | |
48 | if { $current_target == "remote" } { | |
49 | unset_board_info "gdb_protocol" | |
50 | set_board_info "gdb_protocol" "async" | |
51 | } else { | |
52 | return 0 | |
53 | } | |
54 | ||
55 | gdb_exit | |
56 | gdb_start | |
57 | gdb_reinitialize_dir $srcdir/$subdir | |
58 | gdb_load ${binfile} | |
59 | if [target_info exists gdb_stub] { | |
60 | gdb_step_for_stub; | |
61 | } | |
62 | ||
63 | # | |
64 | # set it up at a breakpoint so we can play with it | |
65 | # | |
66 | if ![runto_main] then { | |
67 | perror "couldn't run to breakpoint" | |
68 | continue | |
69 | } | |
70 | ||
de7ff789 | 71 | gdb_test "break baz" ".*" "" |
104c1213 JM |
72 | |
73 | # | |
74 | # Make sure we get a 'completed' message when the target is done. | |
75 | # | |
de7ff789 | 76 | gdb_test "set display-exec-done on" ".*" "" |
104c1213 JM |
77 | |
78 | ||
79 | send_gdb "next&\n" | |
80 | gdb_expect { | |
81 | -re "^next&\r\n$gdb_prompt.*z = 9.*completed\.\r\n" { pass "next &" } | |
82 | -re "$gdb_prompt.*completed\.$" { fail "next &" } | |
83 | timeout { fail "(timeout) next &" } | |
84 | } | |
85 | ||
86 | send_gdb "step&\n" | |
87 | gdb_expect { | |
88 | -re "^step&\r\n$gdb_prompt.*y = foo \\(\\).*completed\.\r\n" { pass "step &" } | |
89 | -re "$gdb_prompt.*completed\.$" { fail "step &" } | |
90 | timeout { fail "(timeout) step &" } | |
91 | } | |
92 | ||
93 | send_gdb "step&\n" | |
94 | gdb_expect { | |
95 | -re "^step&\r\n$gdb_prompt foo \\(\\) at .*async.c.*x = 5.*completed\.\r\n" \ | |
96 | { pass "step &" } | |
97 | -re "$gdb_prompt.*completed\.$" { fail "step &" } | |
98 | timeout { fail "(timeout) step &" } | |
99 | } | |
100 | ||
101 | send_gdb "stepi&\n" | |
102 | gdb_expect { | |
103 | -re "^stepi&\r\n$gdb_prompt.*$hex.*x = 5.*completed\.\r\n" { pass "stepi &" } | |
104 | -re "$gdb_prompt.*completed\.$" { fail "stepi &" } | |
105 | timeout { fail "(timeout) stepi &" } | |
106 | } | |
107 | ||
108 | send_gdb "nexti&\n" | |
109 | gdb_expect { | |
110 | -re "^nexti&\r\n$gdb_prompt.*y = 3.*completed\.\r\n" { pass "nexti &" } | |
111 | -re "$gdb_prompt.*completed\.$" { fail "nexti &" } | |
112 | timeout { fail "(timeout) nexti &" } | |
113 | } | |
114 | ||
115 | send_gdb "finish&\n" | |
116 | gdb_expect { | |
117 | -re "^finish&\r\nRun till exit from #0 foo \\(\\) at.*async.c.*\r\n$gdb_prompt.*$hex in main \\(\\) at.*async.c.*y = foo \\(\\).*Value returned is.*= 8.*completed\.\r\n" \ | |
118 | { pass "finish &" } | |
119 | -re "$gdb_prompt.*completed\.$" { fail "finish &" } | |
120 | timeout { fail "(timeout) finish &" } | |
121 | } | |
122 | ||
123 | send_gdb "jump 33&\n" | |
124 | gdb_expect { | |
125 | -re "^jump 33&.*Continuing at $hex.*$gdb_prompt.*Breakpoint 2, baz \\(\\) at.*async.c.*return 5.*completed\.\r\n" \ | |
126 | { pass "jump &" } | |
127 | -re ".*$gdb_prompt.*completed\.$" { fail "jump &" } | |
128 | timeout { fail "(timeout) jump &" } | |
129 | } | |
130 | ||
131 | send_gdb "until 35&\n" | |
132 | gdb_expect { | |
133 | -re "^until 35&.*$gdb_prompt.*$hex in main \\(\\) at.*async.c.*y = baz \\(\\).*completed\.\r\n" \ | |
134 | { pass "until &" } | |
135 | -re "$gdb_prompt.*completed\.$" { fail "until &" } | |
136 | timeout { fail "(timeout) until &" } | |
137 | } | |
138 | ||
de7ff789 | 139 | gdb_test "set display-exec-done off" ".*" "" |
104c1213 JM |
140 | |
141 | unset_board_info "gdb_protocol" | |
142 | set_board_info "gdb_protocol" "remote" | |
143 | ||
144 | ||
145 | ||
146 | ||
147 | ||
148 |