Commit | Line | Data |
---|---|---|
3eb7562a PA |
1 | # Copyright 2016 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 3 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, see <http://www.gnu.org/licenses/>. | |
15 | ||
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. | |
22 | ||
23 | load_lib mi-support.exp | |
24 | ||
25 | standard_testfile | |
26 | ||
27 | if {[build_executable $testfile.exp $testfile ${srcfile} "debug"] == -1} { | |
84c93cd5 | 28 | untested "failed to compile" |
3eb7562a PA |
29 | return -1 |
30 | } | |
31 | ||
32 | # The test driver. SYNC_COMMAND specifies which command is used to | |
33 | # synchronously start the program running. | |
34 | ||
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 | |
39 | ||
40 | mi_gdb_exit | |
41 | ||
42 | if {[mi_gdb_start "separate-mi-tty"] != 0} { | |
bc6c7af4 | 43 | fail "could not start gdb" |
3eb7562a PA |
44 | return |
45 | } | |
46 | ||
47 | mi_delete_breakpoints | |
48 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
49 | mi_gdb_load $binfile | |
50 | ||
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} { | |
55 | pass $test | |
56 | } else { | |
57 | return | |
58 | } | |
59 | } else { | |
60 | if {[mi_runto main] < 0} { | |
61 | return | |
62 | } | |
63 | if {[mi_send_resuming_command_raw "123-exec-continue" $test] >= 0} { | |
64 | pass $test | |
65 | } else { | |
66 | return | |
67 | } | |
68 | } | |
69 | ||
70 | # Send -thread-info immediately after. If everything works | |
71 | # correctly, this is only serviced by GDB when the execution | |
72 | # stops. | |
73 | send_gdb "456-thread-info\n" | |
74 | pass "send -thread-info" | |
75 | ||
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" | |
81 | } | |
82 | ||
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" { | |
87 | -re "$gdb_prompt " { | |
88 | gdb_test_multiple "" "$message" { | |
89 | -re "received signal SIGINT" { | |
90 | pass $message | |
91 | } | |
92 | } | |
93 | } | |
94 | } | |
95 | } | |
96 | ||
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" | |
101 | } | |
102 | ||
103 | # Look for the result of our -thread-info. If input were | |
104 | # re-enabled too soon, the thread would incorrectly show up with | |
105 | # state="running". | |
106 | with_spawn_id $mi_spawn_id { | |
107 | mi_gdb_test "" "456\\^.*state=\"stopped\".*" \ | |
108 | "got -thread-info output and thread is stopped" | |
109 | } | |
110 | } | |
111 | ||
112 | foreach_with_prefix sync-command {"run" "continue"} { | |
113 | do_test ${sync-command} | |
114 | } |