1 # Copyright 2008 Free Software Foundation, Inc.
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.
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.
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.
18 # Test asynchronous Machine Interface (MI) responses.
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 {
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\""]
32 load_lib mi-support.exp
40 set srcfile ${testfile}.c
41 set binfile ${objdir}/${subdir}/${testfile}
42 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
48 mi_gdb_reinitialize_dir $srcdir/$subdir
49 mi_gdb_load ${binfile}
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.
54 proc linux_async_tests {} {
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]
64 -re ".*\\^running\r\n\\^done\r\n$mi_gdb_prompt" {
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"
69 -re ".*$mi_gdb_prompt$" {
70 fail "Asynchronous response after start command (2)"
73 fail "Asynchronous response after start command (timeout 2)"
77 -re ".*$mi_gdb_prompt$" {
78 fail "Asynchronous response after start command (1)"
80 timeout {fail "Asynchronous response after start command (timeout 1)"}
85 -re "\\^running\r\n\\^done\r\n$mi_gdb_prompt" {
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"
90 -re ".*$mi_gdb_prompt$" {
91 fail "Asynchronous response after next command (2)"
94 fail "Asynchronous response after next command (timeout 2)"
98 -re ".*$mi_gdb_prompt$" {
99 fail "Asynchronous response after next command (1)"
101 timeout {fail "Asynchronous response after next command (timeout 1)"}
104 mi_gdb_test "-exec-interrupt" \
110 -re ".*\\^running\r\n\\^done\r\n$mi_gdb_prompt" {
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"
115 -re ".*$mi_gdb_prompt$" {
116 fail "Asynchronous response after (re) start (2)"
119 fail "Asynchronous response after (re) start (timeout 2)"
123 -re ".*$mi_gdb_prompt$" {
124 fail "Asynchronous response after (re) start (1)"
126 timeout {fail "Asynchronous response after (re) start (timeout 1)"}
135 set GDBFLAGS $saved_gdbflags