Automatic date update in version.in
[binutils-gdb/blckswan.git] / gdb / testsuite / gdb.mi / mi-async.exp
blobaf16b4a243d1a3e73341034bd8829968fe972f7a
1 # Copyright 2008-2022 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 3 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, see <http://www.gnu.org/licenses/>.
17 # Test asynchronous Machine Interface (MI) responses.
20 # Because of the way this test is written, using 'start' and not using
21 # mi_run_cmd, it ignores whatever target the rest of GDB testsuite is
22 # using, and always tries to run natively. So, don't do anything unless
23 # we're actually testing native.
24 if { !([isnative] && [istarget *-linux*]) } then {
25 return
28 # Check if start command is supported.
29 require use_gdb_stub 0
31 # The plan is for async mode to become the default but toggle for now.
32 set saved_gdbflags $GDBFLAGS
33 set GDBFLAGS [concat $GDBFLAGS " -ex \"set mi-async on\""]
35 load_lib mi-support.exp
37 gdb_exit
38 if [mi_gdb_start] {
39 return
42 standard_testfile basics.c
44 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
45 untested "failed to compile"
46 return -1
49 mi_delete_breakpoints
50 mi_gdb_reinitialize_dir $srcdir/$subdir
51 mi_gdb_load ${binfile}
53 # mi_gdb_test cannot be used for asynchronous commands because there are
54 # two prompts involved and this can lead to a race condition.
56 proc linux_async_tests {} {
57 global mi_gdb_prompt
58 global hex
60 set line_main_head [gdb_get_line_number "main ("]
61 set line_main_body [expr $line_main_head + 2]
62 set line_main_next [expr $line_main_head + 3]
64 mi_send_resuming_command_raw "start" "start: send"
65 mi_expect_stop "breakpoint-hit" "main" "" ".*basics.c" "$line_main_body" { "" "disp=\"del\"" } "start: stop"
67 mi_send_resuming_command_raw "next" "CLI next: send"
68 mi_expect_stop "end-stepping-range" "main" "" ".*basics.c" "$line_main_next" "" "CLI next: stop"
70 mi_gdb_test "-exec-interrupt" \
71 "" \
74 mi_send_resuming_command_raw "start" "restart: send"
75 mi_expect_stop "breakpoint-hit" "main" "" ".*basics.c" "$line_main_body" { "" "disp=\"del\"" } "restart: stop"
79 linux_async_tests
81 mi_gdb_exit
83 set GDBFLAGS $saved_gdbflags
85 return 0