* mi/mi-cmd-var.c (varobj_update_one): Print new
[binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-async.exp
1 # Copyright 2008 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 2 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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 #
18 # Test asynchronous Machine Interface (MI) responses.
19 #
20
21 # This currently only works with native linux and the async remote protocol.
22 if { !([isnative] && [istarget *-linux*]) \
23 && (![target_info exists gdb_protocol] \
24 || [target_info gdb_protocol] != "async") } then {
25 return
26 }
27
28 # The plan is for async mode to become the default but toggle for now.
29 set saved_gdbflags $GDBFLAGS
30 set GDBFLAGS [concat $GDBFLAGS " -ex \"maint set linux-async on\""]
31
32 load_lib mi-support.exp
33
34 gdb_exit
35 if [mi_gdb_start] {
36 continue
37 }
38
39 set testfile "basics"
40 set srcfile ${testfile}.c
41 set binfile ${objdir}/${subdir}/${testfile}
42 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
43 untested mi-async.exp
44 return -1
45 }
46
47 mi_delete_breakpoints
48 mi_gdb_reinitialize_dir $srcdir/$subdir
49 mi_gdb_load ${binfile}
50
51 # mi_gdb_test cannot be used for asynchronous commands because there are
52 # two prompts involved and this can lead to a race condition.
53
54 proc linux_async_tests {} {
55 global mi_gdb_prompt
56 global hex
57
58 set line_main_head [gdb_get_line_number "main ("]
59 set line_main_body [expr $line_main_head + 2]
60 set line_main_next [expr $line_main_head + 3]
61
62 send_gdb "start\n"
63 gdb_expect {
64 -re ".*\\^running\r\n\\^done\r\n$mi_gdb_prompt" {
65 gdb_expect {
66 -re "\\*stopped,thread-id=\"0|1\",frame=\{addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\".*basics.c\",line=\"$line_main_body\"\}\r\n$mi_gdb_prompt$" {
67 pass "Asynchronous response after start command"
68 }
69 -re ".*$mi_gdb_prompt$" {
70 fail "Asynchronous response after start command (2)"
71 }
72 timeout {
73 fail "Asynchronous response after start command (timeout 2)"
74 }
75 }
76 }
77 -re ".*$mi_gdb_prompt$" {
78 fail "Asynchronous response after start command (1)"
79 }
80 timeout {fail "Asynchronous response after start command (timeout 1)"}
81 }
82
83 send_gdb "next\n"
84 gdb_expect {
85 -re "\\^running\r\n\\^done\r\n$mi_gdb_prompt" {
86 gdb_expect {
87 -re "\\*stopped,reason=\"end-stepping-range\",thread-id=\"0|1\",frame=\{addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\".*basics.c\",line=\"$line_main_next\"\}\r\n$mi_gdb_prompt$" {
88 pass "Asynchronous response after next command"
89 }
90 -re ".*$mi_gdb_prompt$" {
91 fail "Asynchronous response after next command (2)"
92 }
93 timeout {
94 fail "Asynchronous response after next command (timeout 2)"
95 }
96 }
97 }
98 -re ".*$mi_gdb_prompt$" {
99 fail "Asynchronous response after next command (1)"
100 }
101 timeout {fail "Asynchronous response after next command (timeout 1)"}
102 }
103
104 mi_gdb_test "-exec-interrupt" \
105 "" \
106 ""
107
108 send_gdb "start\n"
109 gdb_expect {
110 -re ".*\\^running\r\n\\^done\r\n$mi_gdb_prompt" {
111 gdb_expect {
112 -re "\\*stopped,thread-id=\"0|1\",frame=\{addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\".*basics.c\",line=\"$line_main_body\"\}\r\n$mi_gdb_prompt$" {
113 pass "Asynchronous response after (re) start"
114 }
115 -re ".*$mi_gdb_prompt$" {
116 fail "Asynchronous response after (re) start (2)"
117 }
118 timeout {
119 fail "Asynchronous response after (re) start (timeout 2)"
120 }
121 }
122 }
123 -re ".*$mi_gdb_prompt$" {
124 fail "Asynchronous response after (re) start (1)"
125 }
126 timeout {fail "Asynchronous response after (re) start (timeout 1)"}
127 }
128 }
129
130
131 linux_async_tests
132
133 mi_gdb_exit
134
135 set GDBFLAGS $saved_gdbflags
136
137 return 0