1 # Copyright
2016-2019 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
/>.
16 # Test that
on a separate MI UI
(new
-ui mi
<tty
>), the printing of an
17 # asynchronous event
(e.g.
=library
-loaded
) during the synchronous
18 # execution of a command
(e.g.
-exec
-run or
-exec
-continue) does not
19 # prematurely re
-enable MI input. After executing synchronous
20 # commands
, MI should not process further commands until the inferior
21 # stops again. See PR gdb
/20418.
23 load_lib mi
-support.exp
27 if {[build_executable $testfile.exp $testfile $
{srcfile
} "debug"] == -1} {
28 untested
"failed to compile"
32 # The test driver. SYNC_COMMAND specifies which command is used to
33 # synchronously start the
program running.
35 proc do_test
{sync_command
} {
36 global srcdir subdir binfile srcfile
37 global gdb_spawn_id gdb_main_spawn_id mi_spawn_id inferior_spawn_id
38 global gdb_prompt mi_gdb_prompt
42 if {[mi_gdb_start
"separate-mi-tty"] != 0} {
43 fail
"could not start gdb"
48 mi_gdb_reinitialize_dir $srcdir
/$subdir
51 # Start a synchronous run
/continue on the MI UI.
52 set test
"send synchronous execution command"
53 if {$sync_command
== "run"} {
54 if {[mi_run_cmd
] >= 0} {
60 if {[mi_runto main
] < 0} {
63 if {[mi_send_resuming_command_raw
"123-exec-continue" $test] >= 0} {
70 # Send
-thread
-info immediately after.
If everything works
71 # correctly
, this is only serviced by GDB when the execution
73 send_gdb
"456-thread-info\n"
74 pass
"send -thread-info"
76 # Make sure we trigger an asynchronous event
(=thread
-group
-added
)
77 # in the separate MI UI. Note the
"run" variant usually triggers
78 #
=thread
-group
-started
/=thread
-created
/=library
-loaded as well.
79 with_spawn_id $gdb_main_spawn_id
{
80 gdb_test
"add-inferior" "Added inferior 2"
83 # Interrupt the
program.
84 with_spawn_id $gdb_main_spawn_id
{
85 set message
"interrupt on the CLI"
86 gdb_test_multiple
"interrupt" "$message" {
88 gdb_test_multiple
"" "$message" {
89 -re
"received signal SIGINT" {
97 #
On the MI channel
, we should see the interrupt output _before_
98 # the
-thread
-info output.
99 with_spawn_id $mi_spawn_id
{
100 mi_expect_interrupt
"got MI interrupt output"
103 # Look
for the result of our
-thread
-info.
If input were
104 # re
-enabled too soon
, the thread would incorrectly
show up with
106 with_spawn_id $mi_spawn_id
{
107 mi_gdb_test
"" "456\\^.*state=\"stopped\".*" \
108 "got -thread-info output and thread is stopped"
112 foreach_with_prefix sync
-command
{"run" "continue"} {
113 do_test $
{sync
-command
}