gdb/doc/
[external/binutils.git] / gdb / testsuite / gdb.base / async.exp
1 #   Copyright 1999, 2007, 2008, 2009, 2010, 2011
2 #   Free Software Foundation, Inc.
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
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
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.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17
18 if $tracelevel then {
19     strace $tracelevel
20 }
21
22 #
23 # test running programs
24 #
25
26 set testfile "async"
27 set srcfile ${testfile}.c
28 set binfile ${objdir}/${subdir}/${testfile}
29
30 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
31     untested async.exp
32     return -1
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
60 #
61 # set it up at a breakpoint so we can play with it
62 #
63 if ![runto_main] then {
64     perror "couldn't run to breakpoint"
65     continue
66 }
67
68 gdb_test "break baz" ".*" ""
69
70 #
71 # Make sure we get a 'completed' message when the target is done.
72 #
73 gdb_test "set display-exec-done on" ".*" ""
74
75
76 send_gdb "next&\n" 
77 gdb_expect {
78     -re "^next&\r\n$gdb_prompt.*z = 9.*completed\.\r\n" { pass "next &" }
79     -re "$gdb_prompt.*completed\.$" { fail "next &" }
80     timeout  { fail "(timeout) next &" }
81 }
82
83 send_gdb "step&\n" 
84 gdb_expect {
85     -re "^step&\r\n$gdb_prompt.*y = foo \\(\\).*completed\.\r\n" { pass "step &" }
86     -re "$gdb_prompt.*completed\.$" { fail "step &" }
87     timeout  { fail "(timeout) step &" }
88 }
89
90 send_gdb "step&\n" 
91 gdb_expect {
92     -re "^step&\r\n$gdb_prompt foo \\(\\) at .*async.c.*x = 5.*completed\.\r\n" \
93             { pass "step &" }
94     -re "$gdb_prompt.*completed\.$" { fail "step &" }
95     timeout  { fail "(timeout) step &" }
96 }
97
98 send_gdb "stepi&\n" 
99 gdb_expect {
100     -re "^stepi&\r\n$gdb_prompt.*$hex.*x = 5.*completed\.\r\n" { pass "stepi &" }
101     -re "$gdb_prompt.*completed\.$" { fail "stepi &" }
102     timeout  { fail "(timeout) stepi &" }
103 }
104
105 send_gdb "nexti&\n" 
106 gdb_expect {
107     -re "^nexti&\r\n$gdb_prompt.*y = 3.*completed\.\r\n" { pass "nexti &" }
108     -re "$gdb_prompt.*completed\.$" { fail "nexti &" }
109     timeout  { fail "(timeout) nexti &" }
110 }
111
112 send_gdb "finish&\n" 
113 gdb_expect {
114     -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" \
115             { pass "finish &" }
116     -re "$gdb_prompt.*completed\.$" { fail "finish &" }
117     timeout  { fail "(timeout) finish &" }
118 }
119
120 send_gdb "jump 33&\n" 
121 gdb_expect {
122     -re "^jump 33&.*Continuing at $hex.*$gdb_prompt.*Breakpoint 2, baz \\(\\) at.*async.c.*return 5.*completed\.\r\n" \
123             { pass "jump &" }
124     -re ".*$gdb_prompt.*completed\.$" { fail "jump &" }
125     timeout  { fail "(timeout) jump &" }
126 }
127
128 send_gdb "until 35&\n" 
129 gdb_expect {
130     -re "^until 35&.*$gdb_prompt.*$hex in main \\(\\) at.*async.c.*y = baz \\(\\).*completed\.\r\n" \
131             { pass "until &" }
132     -re "$gdb_prompt.*completed\.$" { fail "until &" }
133     timeout  { fail "(timeout) until &" }
134 }
135
136 gdb_test "set display-exec-done off" ".*" ""
137
138 unset_board_info "gdb_protocol"
139 set_board_info "gdb_protocol" "remote"
140
141
142
143
144
145