gdb/testsuite: special case '^' in gdb_test pattern
[binutils-gdb.git] / gdb / testsuite / gdb.mi / user-selected-context-sync.exp
1 # Copyright 2016-2023 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 # This test checks that the "thread", "select-frame", "frame" and "inferior"
17 # CLI commands, as well as the "-thread-select" and "-stack-select-frame" MI
18 # commands send the appropriate user-selection-change events to all UIs.
19 #
20 # This test considers the case where console and MI are two different UIs,
21 # and MI is created with the new-ui command.
22 #
23 # It also considers the case where the console commands are sent directly in
24 # the MI channel as described in PR 20487.
25 #
26 # It does so by starting 2 inferiors with 3 threads each.
27 # - Thread 1 of each inferior is the main thread, starting the others.
28 # - Thread 2 of each inferior is stopped at /* thread loop line */.
29 # - Thread 3 of each inferior is either stopped at /* thread loop line */, if we
30 # are using all-stop, or running, if we are using non-stop.
31
32 # Do not run if gdb debug is enabled as it doesn't work for separate-mi-tty.
33 require !gdb_debug_enabled
34
35 load_lib mi-support.exp
36
37 standard_testfile
38
39 # Multiple inferiors are needed, therefore only native gdb and extended
40 # gdbserver modes are supported.
41 require !use_gdb_stub
42
43 set compile_options "debug pthreads"
44 if {[build_executable $testfile.exp $testfile ${srcfile} ${compile_options}] == -1} {
45 untested "failed to compile"
46 return -1
47 }
48
49 set main_break_line [gdb_get_line_number "main break line"]
50 set thread_loop_line [gdb_get_line_number "thread loop line"]
51 set thread_caller_line [gdb_get_line_number "thread caller line"]
52
53 # Return whether we expect thread THREAD to be running in mode MODE.
54 #
55 # MODE can be either "all-stop" or "non-stop".
56 # THREAD can be either a CLI thread id (e.g. 2.3) or an MI thread id (e.g. 6).
57
58 proc thread_is_running { mode thread } {
59 if { $mode != "non-stop" } {
60 return 0
61 }
62
63 return [expr {
64 $thread == 1.3
65 || $thread == 2.3
66 || $thread == 3
67 || $thread == 6
68 }]
69 }
70
71 # Make a regular expression to match the various inferior/thread/frame selection
72 # events for CLI.
73 #
74 # MODE can be either "all-stop" or "non-stop", indicating which one is currently
75 # in use.
76 # INF is the inferior number we are expecting GDB to switch to, or -1 if we are
77 # not expecting GDB to announce an inferior switch.
78 # THREAD is the thread number we are expecting GDB to switch to, or -1 if we are
79 # not expecting GDB to announce a thread switch.
80 # FRAME is the frame number we are expecting GDB to switch to, or -1 if we are
81 # not expecting GDB to announce a frame switch. See the FRAME_RE variable for
82 # details.
83
84 proc make_cli_re { mode inf thread frame } {
85 global srcfile
86 global thread_caller_line
87 global thread_loop_line
88 global main_break_line
89 global decimal
90
91 set any "\[^\r\n\]*"
92
93 set cli_re ""
94
95 set inf_re "\\\[Switching to inferior $inf${any}\\\]"
96 set all_stop_thread_re "\\\[Switching to thread [string_to_regexp $thread]${any}\\\]"
97
98 set frame_re(0) "#0${any}child_sub_function$any$srcfile:$thread_loop_line\r\n${any}thread loop line \\\*/"
99 set frame_re(1) "#1${any}child_function \\\(args=0x0\\\) at ${any}$srcfile:$thread_caller_line\r\n$thread_caller_line${any}/\\\* thread caller line \\\*/"
100
101 # Special frame for main thread.
102 set frame_re(2) "#0${any}\r\n${main_break_line}${any}"
103
104 if { $inf != -1 } {
105 append cli_re $inf_re
106 }
107
108 if { $thread != -1 } {
109 if { $inf != -1 } {
110 append cli_re "\r\n"
111 }
112 set thread_re $all_stop_thread_re
113
114 if [thread_is_running $mode $thread] {
115 set thread_re "$thread_re\\\(running\\\)"
116 }
117
118 append cli_re $thread_re
119 }
120
121 if { $frame != -1 } {
122 if { $thread != -1 } {
123 append cli_re "\r\n"
124 }
125 append cli_re $frame_re($frame)
126 }
127
128 return $cli_re
129 }
130
131 # Make a regular expression to match the various inferior/thread/frame selection
132 # events for MI.
133 #
134 # MODE can be either "all-stop" or "non-stop", indicating which one is currently
135 # in use.
136 # THREAD is the thread number we are expecting GDB to switch to, or -1 if we are
137 # not expecting GDB to announce a thread switch.
138 # If EVENT is 1, build a regex for an "=thread-selected" async event.
139 # Otherwise, build a regex for a response to a command.
140 # FRAME is the frame number we are expecting GDB to switch to, or -1 if we are
141 # not expecting GDB to announce a frame switch. See the FRAME_RE variable for
142 # details.
143
144 proc make_mi_re { mode thread frame type } {
145 global srcfile
146 global hex
147 global decimal
148 global thread_loop_line
149 global main_break_line
150 global thread_caller_line
151
152 set any "\[^\r\n\]*"
153
154 set mi_re ""
155
156 set thread_event_re "=thread-selected,id=\"$thread\""
157 set thread_answer_re "\\^done,new-thread-id=\"$thread\""
158
159 set frame_re(0) ",frame=\{level=\"0\",addr=\"$hex\",func=\"child_sub_function\",args=\\\[\\\],file=\"${any}${srcfile}\",fullname=\"${any}${srcfile}\",line=\"$thread_loop_line\",arch=\"$any\"\}"
160 set frame_re(1) ",frame=\{level=\"1\",addr=\"$hex\",func=\"child_function\",args=\\\[\{name=\"args\",value=\"0x0\"\}\\\],file=\"${any}${srcfile}\",fullname=\"${any}${srcfile}\",line=\"$thread_caller_line\",arch=\"$any\"\}"
161
162 # Special frame for main thread.
163 set frame_re(2) ",frame=\{level=\"0\",addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\"${any}${srcfile}\",fullname=\"${any}${srcfile}\",line=\"${main_break_line}\",arch=\"$any\"\}"
164
165 if { $thread != -1 } {
166 if { $type == "event" } {
167 append mi_re $thread_event_re
168 } elseif { $type == "response" } {
169 append mi_re $thread_answer_re
170 } else {
171 error "Invalid value for EVENT."
172 }
173 }
174
175 if { $frame != -1 } {
176 append mi_re $frame_re($frame)
177 }
178
179 if { $type == "event" } {
180 append mi_re "\r\n"
181 }
182
183 return $mi_re
184 }
185
186 # Make a regular expression to match the various inferior/thread/frame selection
187 # events when issuing CLI commands inside MI.
188 #
189 # COMMAND is the CLI command that was sent to GDB, which will be output in the
190 # console output stream.
191 # CLI_IN_MI_MODE indicates which method of CLI-in-MI command is used. It can be
192 # either "direct" of "interpreter-exec".
193 # MODE can be either "all-stop" or "non-stop", indicating which one is currently
194 # in use.
195 # If EVENT is 1, expect a =thread-select MI event.
196 # INF is the inferior number we are expecting GDB to switch to, or -1 if we are
197 # not expecting GDB to announce an inferior switch.
198 # CLI_THREAD is the thread number as seen in the CLI (inferior-qualified) we are
199 # expecting GDB to switch to, or -1 if we are not expecting GDB to announce a
200 # thread switch.
201 # MI_THREAD is the thread number as seen in the MI (global number) we are
202 # expecting GDB to switch to, or -1 if we are not expecting GDB to announce a
203 # thread switch.
204 # FRAME is the frame number we are expecting GDB to switch to, or -1 if we are
205 # not expecting GDB to announce a frame switch. See the FRAME_RE variable for
206 # details.
207
208 proc make_cli_in_mi_re { command cli_in_mi_mode mode event inf cli_thread
209 mi_thread frame } {
210 global srcfile
211 global thread_loop_line
212 global main_break_line
213 global thread_caller_line
214
215 set any "\[^\r\n\]*"
216
217 set command_re [string_to_regexp $command]
218 set cli_in_mi_re "$command_re\r\n"
219
220 if { $cli_in_mi_mode == "direct" } {
221 append cli_in_mi_re "&\"$command_re\\\\n\"\r\n"
222 }
223
224 set frame_re(0) "~\"#0${any}child_sub_function${any}$srcfile:$thread_loop_line\\\\n\"\r\n~\"${thread_loop_line}${any}thread loop line \\\*/\\\\n\"\r\n"
225 set frame_re(1) "~\"#1${any}child_function \\\(args=0x0\\\) at ${any}$srcfile:$thread_caller_line\\\\n\"\r\n~\"$thread_caller_line${any}thread caller line \\\*/\\\\n\"\r\n"
226
227 # Special frame for main thread.
228 set frame_re(2) "~\"#0${any}main${any}\\\\n\"\r\n~\"${main_break_line}${any}\"\r\n"
229
230 if { $inf != -1 } {
231 append cli_in_mi_re "~\""
232 append cli_in_mi_re [make_cli_re $mode $inf -1 -1]
233 append cli_in_mi_re "\\\\n\"\r\n"
234 }
235
236 if { $cli_thread != "-1" } {
237 append cli_in_mi_re "~\""
238 append cli_in_mi_re [make_cli_re $mode -1 $cli_thread -1]
239 append cli_in_mi_re "\\\\n\"\r\n"
240 }
241
242 if { $frame != -1 } {
243 append cli_in_mi_re $frame_re($frame)
244 }
245
246 if { $event == 1 } {
247 append cli_in_mi_re [make_mi_re $mode $mi_thread $frame event]
248 }
249
250 append cli_in_mi_re "\\^done"
251
252 return $cli_in_mi_re
253 }
254
255 # Return the current value of the "scheduler-locking" parameter.
256
257 proc show_scheduler_locking { } {
258 global gdb_prompt
259 global expect_out
260
261 set any "\[^\r\n\]*"
262
263 set test "show scheduler-locking"
264 gdb_test_multiple $test $test {
265 -re ".*Mode for locking scheduler during execution is \"(${any})\".\r\n$gdb_prompt " {
266 pass $test
267 return $expect_out(1,string)
268 }
269 }
270
271 error "Couldn't get current scheduler-locking value."
272 }
273
274 # Prepare inferior INF so it is in the state we expect (see comment at the top).
275
276 proc test_continue_to_start { mode inf } {
277 global gdb_spawn_id
278 global mi_spawn_id
279 global gdb_main_spawn_id
280 global srcfile
281 global main_break_line
282 global thread_loop_line
283 global decimal
284 global gdb_prompt
285
286 set any "\[^\r\n\]*"
287
288 if { $gdb_spawn_id != $gdb_main_spawn_id } {
289 error "This should not happen."
290 }
291
292 with_test_prefix "inferior $inf" {
293 with_spawn_id $gdb_main_spawn_id {
294 # Continue to the point where we know for sure the threads are
295 # started.
296 gdb_test "tbreak $srcfile:$main_break_line" \
297 "Temporary breakpoint ${any}" \
298 "set breakpoint in main"
299
300 gdb_continue_to_breakpoint "main breakpoint"
301
302 # Consume MI event output.
303 with_spawn_id $mi_spawn_id {
304 if { $inf == 1 } {
305 mi_expect_stop "breakpoint-hit" "main" "" "$srcfile" \
306 "$decimal" {"" "disp=\"del\""} "stop at breakpoint in main"
307 } else {
308 mi_expect_stop "breakpoint-hit" "main" "" "$srcfile" \
309 "$decimal" {"" "disp=\"del\"" "locno=\"[0-9]+\""} "stop at breakpoint in main"
310 }
311 }
312
313 if { $mode == "all-stop" } {
314 set previous_schedlock_val [show_scheduler_locking]
315
316 # Set scheduler-locking on, so that we can control threads
317 # independently.
318 gdb_test_no_output "set scheduler-locking on"
319
320 # Continue each child thread to the point we want them to be.
321 foreach thread { 2 3 } {
322 gdb_test "thread $inf.$thread" ".*" "select child thread $inf.$thread"
323
324 gdb_test "tbreak $srcfile:$thread_loop_line" \
325 "Temporary breakpoint ${any}" \
326 "set breakpoint for thread $inf.$thread"
327
328 gdb_continue_to_breakpoint "continue thread $inf.$thread to infinite loop breakpoint"
329
330 # Consume MI output.
331 with_spawn_id $mi_spawn_id {
332 if { $inf == 1} {
333 mi_expect_stop "breakpoint-hit" "child_sub_function" \
334 "" "$srcfile" "$decimal" {"" "disp=\"del\""} \
335 "thread $inf.$thread stops MI"
336 } else {
337 mi_expect_stop "breakpoint-hit" "child_sub_function" \
338 "" "$srcfile" "$decimal" {"" "disp=\"del\"" "locno=\"[0-9]+\""} \
339 "thread $inf.$thread stops MI"
340 }
341 }
342 }
343
344 # Restore scheduler-locking to its original value.
345 gdb_test_no_output "set scheduler-locking $previous_schedlock_val"
346 } else { # $mode == "non-stop"
347 # Put a thread-specific breakpoint for thread 2 of the current
348 # inferior. We don't put a breakpoint for thread 3, since we
349 # want to let it run.
350 set test "set thread-specific breakpoint, thread $inf.2"
351 gdb_test_multiple "tbreak $srcfile:$thread_loop_line thread $inf.2" $test {
352 -re "Temporary breakpoint ${any}\r\n$gdb_prompt " {
353 pass $test
354 }
355 }
356
357 # Confirm the stop of thread $inf.2.
358 set test "thread $inf.2 stops CLI"
359 gdb_test_multiple "" $test {
360 -re "Thread $inf.2 ${any} hit Temporary breakpoint ${any}\r\n$thread_loop_line${any}\r\n" {
361 pass $test
362 }
363 }
364
365 # Consume MI output.
366 with_spawn_id $mi_spawn_id {
367 if { $inf == 1} {
368 mi_expect_stop "breakpoint-hit" "child_sub_function" \
369 "" "$srcfile" "$decimal" {"" "disp=\"del\""} \
370 "thread $inf.2 stops MI"
371 } else {
372 mi_expect_stop "breakpoint-hit" "child_sub_function" \
373 "" "$srcfile" "$decimal" {"" "disp=\"del\"" "locno=\"[0-9]+\""} \
374 "thread $inf.2 stops MI"
375 }
376 }
377 }
378 }
379 }
380 }
381
382 # Prepare the test environment.
383 #
384 # MODE can be either "all-stop" or "non-stop".
385
386 proc_with_prefix test_setup { mode } {
387 global srcfile
388 global srcdir
389 global subdir
390 global gdb_main_spawn_id
391 global mi_spawn_id
392 global decimal
393 global binfile
394 global GDBFLAGS
395 global async
396
397 set any "\[^\r\n\]*"
398
399 save_vars { GDBFLAGS } {
400 if { $mode == "non-stop" } {
401 set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop 1\""]
402 }
403
404 if { [mi_clean_restart $binfile "separate-mi-tty"] != 0 } {
405 return -1
406 }
407 }
408
409 if { [mi_runto_main] < 0 } {
410 return -1
411 }
412
413 # When using mi_expect_stop, we don't expect a prompt after the *stopped
414 # event, since the blocking commands are done from the CLI. Setting async
415 # to 1 makes it not expect the prompt.
416 set async 1
417
418 with_spawn_id $gdb_main_spawn_id {
419 # Add the second inferior now. While this is not mandatory, it allows
420 # us to assume that per-inferior thread numbering will be used,
421 # simplifying test_continue_to_start a bit (Thread 1.2 and not Thread 2).
422 gdb_test "add-inferior" "Added inferior 2 on connection .*" "add inferior 2"
423
424 # Prepare the first inferior for the test.
425 test_continue_to_start $mode 1
426
427 # Switch to and start the second inferior.
428 gdb_test "inferior 2" "\\\[Switching to inferior 2${any}\\\]" "switch to inferior 2"
429 gdb_load ${binfile}
430
431 # Doing "start" on the CLI generates a ton of MI output. At some point,
432 # if we don't consume/match it, the buffer between GDB's MI channel and
433 # Expect will get full, GDB will block on a write system call and we'll
434 # deadlock, waiting for CLI output that will never arrive. And then
435 # we're sad. So instead of using gdb_test and expect CLI output, send
436 # the start command first, then consume MI output, and finally consume
437 # CLI output.
438 send_gdb "start\n"
439
440 with_spawn_id $mi_spawn_id {
441 mi_expect_stop "breakpoint-hit" "main" "" "$srcfile" "$decimal" \
442 {"" "disp=\"del\"" "locno=\"[0-9]+\""} "main stop"
443 }
444
445 # Consume CLI output.
446 gdb_test "" "Temporary breakpoint.*Starting program.*"
447
448 # Prepare the second inferior for the test.
449 test_continue_to_start $mode 2
450 }
451
452 return 0
453 }
454
455 # Reset the selection to frame #0 of thread THREAD.
456
457 proc reset_selection { thread } {
458 global gdb_main_spawn_id
459
460 set any "\[^\r\n\]*"
461
462 with_spawn_id $gdb_main_spawn_id {
463 gdb_test "thread $thread" \
464 "\\\[Switching to thread $thread ${any}\\\].*" \
465 "reset selection to thread $thread"
466 gdb_test "frame 0" ".*" "reset selection to frame 0"
467 }
468 }
469
470 # Flush Expect's internal buffers for both CLI and MI.
471 #
472 # The idea here is to send a command, and to consume all the characters that we
473 # expect that command to output, including the following prompt. Using gdb_test
474 # and mi_gdb_test should do that.
475
476 proc flush_buffers { } {
477 global gdb_main_spawn_id mi_spawn_id
478
479 with_spawn_id $gdb_main_spawn_id {
480 gdb_test "print 444" "= 444" "flush CLI"
481 }
482
483 with_spawn_id $mi_spawn_id {
484 mi_gdb_test "555-data-evaluate-expression 666" ".*done,value=\"666\"" "flush MI"
485 }
486 }
487
488 # Run a command on the current spawn id, to confirm that no output is pending
489 # in Expect's internal buffer. This is used to ensure that nothing was output
490 # on the spawn id since the call to gdb_test/mi_gdb_test/flush_buffers.
491 #
492 # The key here is that the regexes use start-of-buffer anchors (^), ensuring
493 # that they match the entire buffer, confirming that there was nothing in it
494 # before.
495
496 proc ensure_no_output { test } {
497 global gdb_spawn_id gdb_main_spawn_id mi_spawn_id
498 global decimal
499
500 if { $gdb_spawn_id == $gdb_main_spawn_id } {
501 # CLI
502 gdb_test "print 666" \
503 "^\\\$$decimal = 666" \
504 "$test, ensure no output CLI"
505 } elseif { $gdb_spawn_id == $mi_spawn_id } {
506 # MI
507 mi_gdb_test "777-data-evaluate-expression 888" \
508 "^777-data-evaluate-expression 888\r\n777\\^done,value=\"888\"" \
509 "$test, ensure no output MI"
510 } else {
511 error "Unexpected gdb_spawn_id value."
512 }
513 }
514
515 # Match a regular expression, or ensure that there was no output.
516 #
517 # If RE is non-empty, try to match the content of the program output (using the
518 # current spawn_id) and pass/fail TEST accordingly.
519 # If RE is empty, ensure that the program did not output anything.
520
521 proc match_re_or_ensure_no_output { re test } {
522 if { $re != "" } {
523 gdb_expect {
524 -re "$re" {
525 pass $test
526 }
527
528 default {
529 fail $test
530 }
531 }
532 } else {
533 ensure_no_output $test
534 }
535 }
536
537 # Test selecting an inferior from CLI.
538
539 proc_with_prefix test_cli_inferior { mode } {
540 global gdb_main_spawn_id mi_spawn_id
541
542 reset_selection "1.1"
543
544 set mi_re [make_mi_re $mode 4 2 event]
545 set cli_re [make_cli_re $mode 2 2.1 2]
546
547 flush_buffers
548
549 # Do the 'inferior' command.
550 with_spawn_id $gdb_main_spawn_id {
551 gdb_test "inferior 2" $cli_re "CLI select inferior"
552 }
553
554 with_spawn_id $mi_spawn_id {
555 match_re_or_ensure_no_output $mi_re "event on MI"
556 }
557
558 # Do the 'inferior' command on the currently selected inferior. For now,
559 # GDB naively re-outputs everything.
560 with_spawn_id $gdb_main_spawn_id {
561 gdb_test "inferior 2" $cli_re "CLI select inferior again"
562 }
563
564 with_spawn_id $mi_spawn_id {
565 match_re_or_ensure_no_output $mi_re "event on MI again"
566 }
567 }
568
569 # Test thread selection from CLI.
570
571 proc_with_prefix test_cli_thread { mode } {
572 global gdb_main_spawn_id
573 global mi_spawn_id
574
575 set any "\[^\r\n\]*"
576
577 reset_selection "1.1"
578 flush_buffers
579
580 with_test_prefix "thread 1.2" {
581 # Do the 'thread' command to select a stopped thread.
582
583 set mi_re [make_mi_re $mode 2 0 event]
584 set cli_re [make_cli_re $mode -1 1.2 0]
585
586 with_spawn_id $gdb_main_spawn_id {
587 gdb_test "thread 1.2" $cli_re "select thread"
588 }
589
590 with_spawn_id $mi_spawn_id {
591 match_re_or_ensure_no_output $mi_re "select thread, event on MI "
592 }
593
594 # Do the 'thread' command to select the same thread. We shouldn't receive
595 # an event on MI, since we won't actually switch thread.
596
597 set mi_re ""
598
599 with_spawn_id $gdb_main_spawn_id {
600 gdb_test "thread 1.2" $cli_re "select thread again"
601 }
602
603 with_spawn_id $mi_spawn_id {
604 match_re_or_ensure_no_output $mi_re "select thread, event on MI again"
605 }
606
607 # Try the 'thread' command without arguments.
608
609 set cli_re "\\\[Current thread is 1\\.2.*\\\]"
610 set mi_re ""
611
612 with_spawn_id $gdb_main_spawn_id {
613 gdb_test "thread" $cli_re "thread without args"
614 }
615
616 with_spawn_id $mi_spawn_id {
617 match_re_or_ensure_no_output $mi_re "thread without args, event on MI"
618 }
619 }
620
621 with_test_prefix "thread 1.3" {
622 # Do the 'thread' command to select the third thread, stopped on all-stop,
623 # running on non-stop.
624
625 if { $mode == "all-stop" } {
626 set cli_re [make_cli_re $mode -1 1.3 0]
627 set mi_re [make_mi_re $mode 3 0 event]
628 } else {
629 set cli_re [make_cli_re $mode -1 1.3 -1]
630 set mi_re [make_mi_re $mode 3 -1 event]
631 }
632
633 with_spawn_id $gdb_main_spawn_id {
634 gdb_test "thread 1.3" $cli_re "select thread"
635 }
636
637 with_spawn_id $mi_spawn_id {
638 match_re_or_ensure_no_output $mi_re "select thread, event on MI"
639 }
640
641 # Do the 'thread' command to select the third thread again. Again, we
642 # shouldn't receive an event on MI.
643
644 set mi_re ""
645
646 with_spawn_id $gdb_main_spawn_id {
647 gdb_test "thread 1.3" $cli_re "select thread again"
648 }
649
650 with_spawn_id $mi_spawn_id {
651 match_re_or_ensure_no_output $mi_re "select thread again, event on MI"
652 }
653
654 # Try the 'thread' command without arguments.
655
656 set cli_re "\\\[Current thread is 1\\.3 ${any}\\\]"
657 set mi_re ""
658
659 with_spawn_id $gdb_main_spawn_id {
660 gdb_test "thread" $cli_re "thread without args"
661 }
662
663 with_spawn_id $mi_spawn_id {
664 match_re_or_ensure_no_output $mi_re "thread without args, event on MI"
665 }
666 }
667
668 # Idea for the future: selecting a thread in a different inferior. For now,
669 # GDB doesn't show an inferior switch, but if it did, it would be a nice
670 # place to test it.
671 }
672
673 # Test frame selection from CLI.
674
675 proc_with_prefix test_cli_frame { mode } {
676 global gdb_main_spawn_id mi_spawn_id
677
678 with_test_prefix "thread 1.2" {
679 reset_selection "1.2"
680 flush_buffers
681
682 # Do the 'frame' command to select frame 1.
683
684 set mi_re [make_mi_re $mode 2 1 event]
685 set cli_re [make_cli_re $mode -1 -1 1]
686
687 with_spawn_id $gdb_main_spawn_id {
688 gdb_test "frame 1" $cli_re "select frame 1"
689 }
690
691 with_spawn_id $mi_spawn_id {
692 match_re_or_ensure_no_output $mi_re "select frame 1, event on MI"
693 }
694
695 # Do the 'frame' command to select the same frame. This time we don't
696 # expect an event on MI, since we won't actually change frame.
697
698 set mi_re ""
699
700 with_spawn_id $gdb_main_spawn_id {
701 gdb_test "frame 1" $cli_re "select frame 1 again"
702 }
703
704 with_spawn_id $mi_spawn_id {
705 match_re_or_ensure_no_output $mi_re "select frame 1 again, event on MI"
706 }
707
708 # Do the 'frame' command without arguments. We shouldn't see anything on MI.
709
710 with_spawn_id $gdb_main_spawn_id {
711 gdb_test "frame" $cli_re "frame without args"
712 }
713
714 with_spawn_id $mi_spawn_id {
715 match_re_or_ensure_no_output $mi_re "frame without args, event on MI"
716 }
717 }
718
719 with_test_prefix "thread 1.3" {
720 # Now, try the 'frame' command on thread 3, which is running if we are in
721 # non-stop mode.
722 reset_selection "1.3"
723 flush_buffers
724
725 if {$mode == "all-stop"} {
726 set mi_re [make_mi_re $mode 3 1 event]
727 set cli_re [make_cli_re $mode -1 -1 1]
728 } elseif {$mode == "non-stop"} {
729 set mi_re ""
730 set cli_re "Selected thread is running\\."
731 }
732
733 with_spawn_id $gdb_main_spawn_id {
734 gdb_test "frame 1" $cli_re "select frame 1"
735 }
736
737 with_spawn_id $mi_spawn_id {
738 match_re_or_ensure_no_output $mi_re "select frame 1, event on MI"
739 }
740
741 # Do the 'frame' command without arguments.
742
743 if { $mode == "non-stop" } {
744 set cli_re "No stack\\."
745 }
746 set mi_re ""
747
748 with_spawn_id $gdb_main_spawn_id {
749 gdb_test "frame" $cli_re "frame without args"
750 }
751
752 with_spawn_id $mi_spawn_id {
753 match_re_or_ensure_no_output $mi_re "frame without args, event on MI"
754 }
755 }
756 }
757
758 # Test frame selection from CLI with the select-frame command.
759
760 proc_with_prefix test_cli_select_frame { mode } {
761 global gdb_main_spawn_id mi_spawn_id expect_out
762
763 with_test_prefix "thread 1.2" {
764 reset_selection "1.2"
765 flush_buffers
766
767 # Do the 'select-frame' command to select frame 1.
768
769 set mi_re [make_mi_re $mode 2 1 event]
770
771 with_spawn_id $gdb_main_spawn_id {
772 gdb_test_no_output "select-frame 1" "select frame 1"
773 }
774
775 with_spawn_id $mi_spawn_id {
776 match_re_or_ensure_no_output $mi_re "select frame 1, event on MI"
777 }
778
779 # Do the 'select-frame' command to select the same frame. This time we expect to
780 # event on MI, since we won't actually change frame.
781
782 set mi_re ""
783
784 with_spawn_id $gdb_main_spawn_id {
785 gdb_test_no_output "select-frame 1" "select frame 1 again"
786 }
787
788 with_spawn_id $mi_spawn_id {
789 match_re_or_ensure_no_output $mi_re "select frame 1 again, event on MI"
790 }
791 }
792
793 with_test_prefix "thread 1.3" {
794 # Now, try the 'select-frame' command on thread 3, which is running if we are in
795 # non-stop mode.
796 reset_selection "1.3"
797 flush_buffers
798
799 if {$mode == "all-stop"} {
800 set mi_re [make_mi_re $mode 3 1 event]
801 } elseif {$mode == "non-stop"} {
802 set mi-re ""
803 set cli_re "Selected thread is running\\."
804 }
805
806 with_spawn_id $gdb_main_spawn_id {
807 if { $mode == "all-stop" } {
808 gdb_test_no_output "select-frame 1" "select frame 1"
809 } else {
810 gdb_test "select-frame 1" $cli_re "select frame 1"
811 }
812 }
813
814 with_spawn_id $mi_spawn_id {
815 match_re_or_ensure_no_output $mi_re "select frame 1, event on MI"
816 }
817 }
818 }
819
820 # Test doing an up and then down command from CLI.
821
822 proc_with_prefix test_cli_up_down { mode } {
823 global gdb_main_spawn_id mi_spawn_id
824
825 reset_selection "1.2"
826 flush_buffers
827
828 # Try doing an 'up'.
829
830 set mi_re [make_mi_re $mode 2 1 event]
831 set cli_re [make_cli_re $mode -1 -1 1]
832
833 with_spawn_id $gdb_main_spawn_id {
834 gdb_test "up" $cli_re "frame up"
835 }
836
837 with_spawn_id $mi_spawn_id {
838 match_re_or_ensure_no_output $mi_re "frame up, event on MI"
839 }
840
841 # Try doing a 'down'.
842
843 set mi_re [make_mi_re $mode 2 0 event]
844 set cli_re [make_cli_re $mode -1 -1 0]
845
846 with_spawn_id $gdb_main_spawn_id {
847 gdb_test "down" $cli_re "frame down"
848 }
849
850 with_spawn_id $mi_spawn_id {
851 match_re_or_ensure_no_output $mi_re "frame down, event on MI"
852 }
853 }
854
855 # Test selecting a thread from MI.
856
857 proc_with_prefix test_mi_thread_select { mode } {
858 global gdb_main_spawn_id mi_spawn_id
859
860 reset_selection "1.1"
861 flush_buffers
862
863 with_test_prefix "thread 1.2" {
864 # Do the '-thread-select' command to select a stopped thread.
865
866 set mi_re [make_mi_re $mode 2 0 response]
867 set cli_re [make_cli_re $mode -1 1.2 0]
868
869 with_spawn_id $mi_spawn_id {
870 mi_gdb_test "-thread-select 2" $mi_re "-thread-select"
871 }
872
873 with_spawn_id $gdb_main_spawn_id {
874 match_re_or_ensure_no_output "$cli_re\r\n" "-thread-select, event on CLI"
875 }
876
877 # Do the '-thread-select' command to select the same thread. We
878 # shouldn't receive an event on CLI, since we won't actually switch
879 # thread.
880
881 set cli_re ""
882
883 with_spawn_id $mi_spawn_id {
884 mi_gdb_test "-thread-select 2" $mi_re "-thread-select again"
885 }
886
887 with_spawn_id $gdb_main_spawn_id {
888 match_re_or_ensure_no_output $cli_re "-thread-select again, event on CLI"
889 }
890 }
891
892 with_test_prefix "thread 1.3" {
893 # Do the '-thread-select' command to select the third thread, stopped on all-stop,
894 # running on non-stop.
895
896 if { $mode == "all-stop" } {
897 set mi_re [make_mi_re $mode 3 0 response]
898 set cli_re [make_cli_re $mode -1 1.3 0]
899 } else {
900 set mi_re [make_mi_re $mode 3 -1 response]
901 set cli_re [make_cli_re $mode -1 1.3 -1]
902 }
903
904 with_spawn_id $mi_spawn_id {
905 mi_gdb_test "-thread-select 3" $mi_re "-thread-select"
906 }
907
908 with_spawn_id $gdb_main_spawn_id {
909 match_re_or_ensure_no_output "$cli_re\r\n" "-thread-select, event on CLI"
910 }
911
912 # Do the 'thread' command to select the third thread again. Again, we
913 # shouldn't receive an event on MI.
914
915 set cli_re ""
916
917 with_spawn_id $mi_spawn_id {
918 mi_gdb_test "-thread-select 3" $mi_re "-thread-select again"
919 }
920
921 with_spawn_id $gdb_main_spawn_id {
922 match_re_or_ensure_no_output $cli_re "-thread-select again, event on CLI"
923 }
924 }
925
926 with_test_prefix "thread 1.2 with --thread 2" {
927 # Test selecting a thread from MI with a --thread option. This test
928 # verifies that even if the thread GDB would switch to is the same as
929 # the thread specified with --thread, an event is still sent to CLI.
930 # In this case this is thread 1.2
931
932 set mi_re [make_mi_re $mode 2 0 response]
933 set cli_re [make_cli_re $mode -1 1.2 0]
934
935 with_spawn_id $mi_spawn_id {
936 mi_gdb_test "-thread-select --thread 2 2" $mi_re "-thread-select"
937 }
938
939 with_spawn_id $gdb_main_spawn_id {
940 match_re_or_ensure_no_output "$cli_re\r\n" "-thread-select, event on cli"
941 }
942 }
943
944 with_test_prefix "thread 1.2 with --thread 3" {
945 # Test selecting a thread from MI with a --thread option.
946 # This test verifies that when different thread numbers are
947 # passed to the --thread option and the underlying
948 # -thread-select command, the correct thread is selected.
949 # In this case this is thread 1.2
950
951 reset_selection "1.1"
952
953 set mi_re [make_mi_re $mode 2 0 response]
954 set cli_re [make_cli_re $mode -1 1.2 0]
955
956 with_spawn_id $mi_spawn_id {
957 mi_gdb_test "-thread-select --thread 3 2" $mi_re "-thread-select"
958 }
959
960 with_spawn_id $gdb_main_spawn_id {
961 match_re_or_ensure_no_output "$cli_re\r\n" "-thread-select, event on cli"
962 }
963 }
964
965 # Idea for the future: selecting a thread in a different inferior. For now,
966 # GDB doesn't show an inferior switch, but if it did, it would be a nice
967 # place to test it.
968 }
969
970 proc_with_prefix test_mi_stack_select_frame { mode } {
971 global gdb_main_spawn_id mi_spawn_id
972
973 with_test_prefix "thread 1.2" {
974 reset_selection "1.2"
975 flush_buffers
976
977 # Do the '-stack-select-frame' command to select frame 1.
978
979 set mi_re "\\^done"
980 set cli_re [make_cli_re $mode -1 -1 1]
981
982 with_spawn_id $mi_spawn_id {
983 mi_gdb_test "-stack-select-frame 1" $mi_re "-stack-select-frame"
984 }
985
986 with_spawn_id $gdb_main_spawn_id {
987 match_re_or_ensure_no_output "$cli_re\r\n" "-stack-select-frame, event on CLI"
988 }
989
990 # Do the '-stack-select-frame' command to select the same frame. This time we don't
991 # expect an event on CLI, since we won't actually change frame.
992
993 set cli_re ""
994
995 with_spawn_id $mi_spawn_id {
996 mi_gdb_test "-stack-select-frame 1" $mi_re "-stack-select-frame again"
997 }
998
999 with_spawn_id $gdb_main_spawn_id {
1000 match_re_or_ensure_no_output $cli_re "-stack-select-frame again, event on CLI"
1001 }
1002
1003 # Now use the '-stack-select-frame' command with the --frame
1004 # option, this verifies that even when the frame GDB would
1005 # swith to is the same as the frame specified with --frame, an
1006 # event is still sent to the CLI.
1007
1008 set cli_re [make_cli_re $mode -1 -1 0]
1009
1010 with_spawn_id $mi_spawn_id {
1011 mi_gdb_test "-stack-select-frame --thread 2 --frame 0 0" $mi_re
1012 }
1013
1014 with_spawn_id $gdb_main_spawn_id {
1015 match_re_or_ensure_no_output "$cli_re\r\n" "-stack-select-frame with --frame 0, event on CLI"
1016 }
1017
1018 # Now use the '-stack-select-frame' command with the --frame
1019 # option, this verifies that the correct event is sent to the
1020 # CLI when the frame specified with --frame is different to
1021 # the actual frame selected.
1022
1023 set cli_re [make_cli_re $mode -1 -1 1]
1024
1025 with_spawn_id $mi_spawn_id {
1026 mi_gdb_test "-stack-select-frame --thread 2 --frame 2 1" $mi_re
1027 }
1028
1029 with_spawn_id $gdb_main_spawn_id {
1030 match_re_or_ensure_no_output "$cli_re\r\n" "-stack-select-frame with --frame 2, event on CLI"
1031 }
1032 }
1033
1034 with_test_prefix "thread 1.3" {
1035 # Now, try the '-stack-select-frame' command on thread 3, which is
1036 # running if we are in non-stop mode.
1037 reset_selection "1.3"
1038 flush_buffers
1039
1040 if {$mode == "all-stop"} {
1041 set mi_re "\\^done"
1042 set cli_re [make_cli_re $mode -1 -1 1]
1043 append cli_re "\r\n"
1044 } elseif {$mode == "non-stop"} {
1045 set cli_re ""
1046 set mi_re "\\^error,msg=\"Selected thread is running\\.\""
1047 }
1048
1049 with_spawn_id $mi_spawn_id {
1050 mi_gdb_test "-stack-select-frame 1" $mi_re "-stack-select-frame"
1051 }
1052
1053 with_spawn_id $gdb_main_spawn_id {
1054 match_re_or_ensure_no_output $cli_re "-stack-select-frame, event on CLI"
1055 }
1056 }
1057 }
1058
1059 proc make_cli_in_mi_command { cli_in_mi_mode command } {
1060 if { $cli_in_mi_mode == "direct" } {
1061 return $command
1062 } elseif { $cli_in_mi_mode == "interpreter-exec" } {
1063 return "-interpreter-exec console \"$command\""
1064 } else {
1065 error "Invalid value for CLI_IN_MI_MODE."
1066 }
1067 }
1068
1069 # Test selecting the inferior using a CLI command in the MI channel.
1070
1071 proc_with_prefix test_cli_in_mi_inferior { mode cli_in_mi_mode } {
1072 global gdb_main_spawn_id mi_spawn_id
1073
1074 reset_selection "1.1"
1075 flush_buffers
1076
1077 set command [make_cli_in_mi_command $cli_in_mi_mode "inferior 2"]
1078
1079 set mi_re [make_cli_in_mi_re $command $cli_in_mi_mode $mode 1 2 2.1 4 2]
1080 set cli_re [make_cli_re $mode 2 "2.1" 2]
1081
1082 with_spawn_id $mi_spawn_id {
1083 mi_gdb_test $command $mi_re "select inferior"
1084 }
1085
1086 with_spawn_id $gdb_main_spawn_id {
1087 match_re_or_ensure_no_output "$cli_re\r\n" "select inferior, event on CLI"
1088 }
1089
1090 # Do the 'inferior' command on the currently selected inferior. For now,
1091 # GDB naively re-outputs everything.
1092 with_spawn_id $mi_spawn_id {
1093 mi_gdb_test $command $mi_re "select inferior again"
1094 }
1095
1096 with_spawn_id $gdb_main_spawn_id {
1097 match_re_or_ensure_no_output $cli_re "select inferior again, event on CLI"
1098 }
1099 }
1100
1101 # Test selecting the thread using a CLI command in the MI channel.
1102
1103 proc_with_prefix test_cli_in_mi_thread { mode cli_in_mi_mode } {
1104 global gdb_main_spawn_id mi_spawn_id
1105
1106 reset_selection "1.1"
1107 flush_buffers
1108
1109 with_test_prefix "thread 1.2" {
1110 # Do the 'thread' command to select a stopped thread.
1111
1112 set command [make_cli_in_mi_command $cli_in_mi_mode "thread 1.2"]
1113 set mi_re [make_cli_in_mi_re $command $cli_in_mi_mode $mode 1 -1 1.2 2 0]
1114 set cli_re [make_cli_re $mode -1 1.2 0]
1115
1116 with_spawn_id $mi_spawn_id {
1117 mi_gdb_test $command $mi_re "select thread"
1118 }
1119
1120 with_spawn_id $gdb_main_spawn_id {
1121 match_re_or_ensure_no_output "$cli_re\r\n" "select thread, event on CLI"
1122 }
1123
1124 # Do the 'thread' command to select the same thread. We shouldn't
1125 # receive an event on CLI, since we won't actually switch thread.
1126
1127 set mi_re [make_cli_in_mi_re $command $cli_in_mi_mode $mode 0 -1 1.2 2 0]
1128 set cli_re ""
1129
1130 with_spawn_id $mi_spawn_id {
1131 mi_gdb_test $command $mi_re "select thread again"
1132 }
1133
1134 with_spawn_id $gdb_main_spawn_id {
1135 match_re_or_ensure_no_output $cli_re "select thread again, event on CLI"
1136 }
1137
1138 # Try the 'thread' command without arguments.
1139
1140 set command [make_cli_in_mi_command $cli_in_mi_mode "thread"]
1141
1142 set mi_re "${command}.*~\"\\\[Current thread is 1\\.2.*\\\]\\\\n\".*\\^done"
1143 set cli_re ""
1144
1145 with_spawn_id $mi_spawn_id {
1146 mi_gdb_test $command $mi_re "thread without args"
1147 }
1148
1149 with_spawn_id $gdb_main_spawn_id {
1150 match_re_or_ensure_no_output $cli_re "thread without args, event on CLI"
1151 }
1152 }
1153
1154 with_test_prefix "thread 1.3" {
1155 # Do the 'thread' command to select the third thread, stopped on
1156 # all-stop, running on non-stop.
1157
1158 set command [make_cli_in_mi_command $cli_in_mi_mode "thread 1.3"]
1159 if { $mode == "all-stop" } {
1160 set mi_re [make_cli_in_mi_re $command $cli_in_mi_mode $mode 1 -1 1.3 3 0]
1161 set cli_re [make_cli_re $mode -1 "1.3" 0]
1162 } else {
1163 set mi_re [make_cli_in_mi_re $command $cli_in_mi_mode $mode 1 -1 1.3 3 -1]
1164 set cli_re [make_cli_re $mode -1 "1.3" -1]
1165 }
1166
1167 with_spawn_id $mi_spawn_id {
1168 mi_gdb_test $command $mi_re "select thread"
1169 }
1170
1171 with_spawn_id $gdb_main_spawn_id {
1172 match_re_or_ensure_no_output "$cli_re\r\n" "select thread, event on CLI"
1173 }
1174
1175 # Do the 'thread' command to select the third thread again. Again, we
1176 # shouldn't receive an event on MI.
1177
1178 if { $mode == "all-stop" } {
1179 set mi_re [make_cli_in_mi_re $command $cli_in_mi_mode $mode 0 -1 1.3 3 0]
1180 } else {
1181 set mi_re [make_cli_in_mi_re $command $cli_in_mi_mode $mode 0 -1 1.3 3 -1]
1182 }
1183 set cli_re ""
1184
1185 with_spawn_id $mi_spawn_id {
1186 mi_gdb_test $command $mi_re "select thread again"
1187 }
1188
1189 with_spawn_id $gdb_main_spawn_id {
1190 match_re_or_ensure_no_output $cli_re "select thread again, event on CLI"
1191 }
1192
1193 # Try the 'thread' command without arguments.
1194
1195 set command [make_cli_in_mi_command $cli_in_mi_mode "thread"]
1196
1197 set mi_re "${command}.*~\"\\\[Current thread is 1\\.3.*\\\]\\\\n\".*\\^done"
1198 set cli_re ""
1199
1200 with_spawn_id $mi_spawn_id {
1201 mi_gdb_test $command $mi_re "thread without args"
1202 }
1203
1204 with_spawn_id $gdb_main_spawn_id {
1205 match_re_or_ensure_no_output $cli_re "thread without args, event on CLI"
1206 }
1207 }
1208
1209 # Idea for the future: selecting a thread in a different inferior. For now,
1210 # GDB doesn't show an inferior switch, but if it did, it would be a nice
1211 # place to test it.
1212 }
1213
1214 # Test selecting the frame using a CLI command in the MI channel.
1215
1216 proc_with_prefix test_cli_in_mi_frame { mode cli_in_mi_mode } {
1217 global gdb_main_spawn_id mi_spawn_id
1218
1219 with_test_prefix "thread 1.2" {
1220 reset_selection "1.2"
1221 flush_buffers
1222
1223 # Do the 'frame' command to select frame 1.
1224
1225 set command [make_cli_in_mi_command $cli_in_mi_mode "frame 1"]
1226 set cli_re [make_cli_re $mode -1 -1 1]
1227 set mi_re [make_cli_in_mi_re $command $cli_in_mi_mode $mode 1 -1 -1 2 1]
1228
1229 with_spawn_id $mi_spawn_id {
1230 mi_gdb_test $command $mi_re "select frame 1"
1231 }
1232
1233 with_spawn_id $gdb_main_spawn_id {
1234 match_re_or_ensure_no_output "$cli_re\r\n" "select frame 1, event on CLI"
1235 }
1236
1237 # Do the 'frame' command to select the same frame. This time we don't
1238 # expect an event on MI, since we won't actually change frame.
1239
1240 set mi_re [make_cli_in_mi_re $command $cli_in_mi_mode $mode 0 -1 -1 2 1]
1241 set cli_re ""
1242
1243 with_spawn_id $mi_spawn_id {
1244 mi_gdb_test $command $mi_re "select frame 1 again"
1245 }
1246
1247 with_spawn_id $gdb_main_spawn_id {
1248 match_re_or_ensure_no_output $cli_re "select frame 1 again, event on CLI"
1249 }
1250
1251 # Do the 'frame' command without arguments. We shouldn't see anything on MI.
1252
1253 set command [make_cli_in_mi_command $cli_in_mi_mode "frame"]
1254 set mi_re [make_cli_in_mi_re $command $cli_in_mi_mode $mode 0 -1 -1 2 1]
1255
1256 with_spawn_id $mi_spawn_id {
1257 mi_gdb_test $command $mi_re "frame without args"
1258 }
1259
1260 with_spawn_id $gdb_main_spawn_id {
1261 match_re_or_ensure_no_output $cli_re "frame without args, event on CLI"
1262 }
1263 }
1264
1265 with_test_prefix "thread 1.3" {
1266 # Now, try the 'frame' command on thread 3, which is running if we are in
1267 # non-stop mode.
1268 reset_selection "1.3"
1269 flush_buffers
1270
1271 set command [make_cli_in_mi_command $cli_in_mi_mode "frame 1"]
1272 if {$mode == "all-stop"} {
1273 set cli_re [make_cli_re $mode -1 -1 1]
1274 append cli_re "\r\n"
1275 set mi_re [make_cli_in_mi_re $command $cli_in_mi_mode $mode 1 -1 -1 3 1]
1276 } elseif {$mode == "non-stop"} {
1277 set cli_re ""
1278 set mi_re "\\^error,msg=\"Selected thread is running\\.\".*"
1279 }
1280
1281 with_spawn_id $mi_spawn_id {
1282 mi_gdb_test $command $mi_re "select frame 1"
1283 }
1284
1285 with_spawn_id $gdb_main_spawn_id {
1286 match_re_or_ensure_no_output $cli_re "select frame 1, event on CLI"
1287 }
1288
1289 # Do the 'frame' command without arguments.
1290
1291 set command [make_cli_in_mi_command $cli_in_mi_mode "frame"]
1292 if { $mode == "all-stop" } {
1293 set mi_re [make_cli_in_mi_re $command $cli_in_mi_mode $mode 0 -1 -1 -1 1]
1294 } else {
1295 set mi_re "\\^error,msg=\"No stack\\.\""
1296 }
1297 set cli_re ""
1298
1299 with_spawn_id $mi_spawn_id {
1300 mi_gdb_test $command $mi_re "frame without args"
1301 }
1302
1303 with_spawn_id $gdb_main_spawn_id {
1304 match_re_or_ensure_no_output $cli_re "frame without args, event on CLI"
1305 }
1306 }
1307 }
1308
1309 foreach_with_prefix mode { "all-stop" "non-stop" } {
1310 set test "setup done"
1311 if { [test_setup $mode] == -1 } {
1312 fail $test
1313 continue
1314 }
1315 pass $test
1316
1317 # Test selecting inferior, thread and frame from CLI
1318
1319 test_cli_inferior $mode
1320 test_cli_thread $mode
1321 test_cli_frame $mode
1322 test_cli_select_frame $mode
1323 test_cli_up_down $mode
1324
1325 # Test selecting thread and frame from MI
1326
1327 test_mi_thread_select $mode
1328 test_mi_stack_select_frame $mode
1329
1330 # Test some CLI commands sent through MI, both with a "direct" command,
1331 # such as "thread 1", and with -interpreter-exec, such as
1332 # '-interpreter-exec console "thread 1"'.
1333
1334 foreach_with_prefix exec_mode {"direct" "interpreter-exec"} {
1335 test_cli_in_mi_inferior $mode $exec_mode
1336 test_cli_in_mi_thread $mode $exec_mode
1337 test_cli_in_mi_frame $mode $exec_mode
1338 }
1339 }