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