binutils-gdb/gdb/testsuite/gdb.mi
Simon Marchi f818c32ba4 gdb/mi: fix ^running record with multiple MI interpreters
I stumbled on the mi_proceeded and running_result_record_printed
globals, which are shared by all MI interpreter instances (it's unlikely
that people use multiple MI interpreter instances, but it's possible).
After poking at it, I found this bug:

1. Start GDB in MI mode
2. Add a second MI interpreter with the new-ui command
3. Use -exec-run on the second interpreter

This is the output I get on the first interpreter:

    =thread-group-added,id="i1"
    ~"Reading symbols from a.out...\n"
    ~"New UI allocated\n"
    (gdb)
    =thread-group-started,id="i1",pid="94718"
    =thread-created,id="1",group-id="i1"
    ^running
    *running,thread-id="all"

And this is the output I get on the second intepreter:

    =thread-group-added,id="i1"
    (gdb)
    -exec-run
    =thread-group-started,id="i1",pid="94718"
    =thread-created,id="1",group-id="i1"
    *running,thread-id="all"

The problem here is that the `^running` reply to the -exec-run command
is printed on the wrong UI.  It is printed on the first one, it should
be printed on the second (the one on which we sent the -exec-run).

What happens under the hood is that captured_mi_execute_command, while
executing a command for the second intepreter, clears the
running_result_record_printed and mi_proceeded globals.
mi_about_to_proceed then sets mi_proceeded.  Then, mi_on_resume_1 gets
called for the first intepreter first.  Since the

    !running_result_record_printed && mi_proceeded

condition is true, it prints a ^running, and sets
running_result_record_printed.  When mi_on_resume_1 gets called for the
second interpreter, running_result_record_printed is already set, so
^running is not printed there.

It took me a while to understand the relationship between these two
variables.  I think that in the end, this is what we want to track:

 1. When executing an MI command, take note if that command causes a
    "proceed".  This is done in mi_about_to_proceed.
 2. In mi_on_resume_1, if the command indeed caused a "proceed", we want
    to output a ^running record.  And we want to remember that we did,
    because...
 3. Back in captured_mi_execute_command, if we did not output a
    ^running, we want to output a ^done.

Moving those two variables to the mi_interp struture appears to fix it.
Only for the interpreter doing the -exec-run command does the
running_result_record_printed flag get cleared, and therefore only or
that one does the ^running record get printed.

Add a new test for this, that does pretty much what the reproducer above
shows.  Without the fix, the test fails because
mi_send_resuming_command_raw never sees the ^running record.

Change-Id: I63ea30e6cb61a8e1dd5ef03377e6003381a9209b
Tested-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
2023-05-29 10:09:24 -04:00
..
array.f90 Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
basics.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
ChangeLog-1999-2003
dw2-ref-missing-frame-func.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
dw2-ref-missing-frame-main.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
dw2-ref-missing-frame.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
dw2-ref-missing-frame.S Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb669.exp Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
gdb680.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
gdb701.c
gdb701.exp Eliminate spurious returns from the test suite 2023-01-26 18:28:31 -07:00
gdb792.cc
gdb792.exp Eliminate spurious returns from the test suite 2023-01-26 18:28:31 -07:00
gdb2549.exp Eliminate spurious returns from the test suite 2023-01-26 18:28:31 -07:00
interrupt-thread-group.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
interrupt-thread-group.exp Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
list-thread-groups-available.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
list-thread-groups-available.exp Minor "require" fixups 2023-01-26 18:28:31 -07:00
list-thread-groups-no-inferior.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-add-inferior.exp Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-async-run.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-async-run.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-async.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-basics.exp Start gdb after building executable in mi-basics.exp 2023-01-26 18:28:31 -07:00
mi-break-qualified.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-break-qualified.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-break.exp gdb/testsuite introduce foreach_mi_ui_mode helper proc 2023-02-28 10:56:28 +00:00
mi-breakpoint-changed.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-breakpoint-multiple-locations.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-breakpoint-multiple-locations.exp Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-breakpoint-script.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-breakpoint-script.exp Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-catch-cpp-exceptions.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-catch-cpp-exceptions.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-catch-load-so.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-catch-load.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-catch-load.exp [gdb/testsuite] Fix gdb.mi/*.exp with remote-gdbserver-on-localhost 2023-03-07 09:59:56 +01:00
mi-cli.exp Eliminate spurious returns from the test suite 2023-01-26 18:28:31 -07:00
mi-cmd-error.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-cmd-param-changed.exp Eliminate spurious returns from the test suite 2023-01-26 18:28:31 -07:00
mi-cmd-user-context.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-cmd-user-context.exp Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-complete.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-complete.exp Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-condbreak-call-thr-state-mt.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-condbreak-call-thr-state-st.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-condbreak-call-thr-state.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-condbreak-call-thr-state.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-console.c
mi-console.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-corefile.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-corefile.exp Use require isnative 2023-01-13 13:18:56 -07:00
mi-detach.exp Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-disassemble.exp Eliminate spurious returns from the test suite 2023-01-26 18:28:31 -07:00
mi-dprintf-pending.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-dprintf-pending.exp gdb/testsuite: accept script argument for mi_make_breakpoint_pending 2023-04-14 22:16:17 +01:00
mi-dprintf-pendshr.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-dprintf.c [gdb/testsuite] Handle unbuffer_output.c for remote host 2023-03-18 17:50:56 +01:00
mi-dprintf.exp [gdb/testsuite] Handle unbuffer_output.c for remote host 2023-03-18 17:50:56 +01:00
mi-editing.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-eval.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-exec-run.exp gdb/testsuite: extend the use of mi_clean_restart 2023-02-28 10:56:28 +00:00
mi-exit-code.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-exit-code.exp Eliminate spurious returns from the test suite 2023-01-26 18:28:31 -07:00
mi-file-transfer.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-file.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-fill-memory.exp Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-fortran-modules-2.f90 Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-fortran-modules.exp Rename to allow_fortran_tests 2023-01-13 13:18:57 -07:00
mi-fortran-modules.f90 Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-frame-regs.exp Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-fullname-deleted.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-hack-cli.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-i-cmd.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-info-os.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-info-sources-base.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-info-sources.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-info-sources.exp Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-inheritance-syntax-error.cc
mi-inheritance-syntax-error.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-language.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-linespec-err-cp.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-linespec-err-cp.exp Rename to allow_cplus_tests and allow_stl_tests 2023-01-13 13:18:57 -07:00
mi-logging.exp Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-memory-changed.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-multi-commands.exp gdb/testsuite: extend the use of mi_clean_restart 2023-02-28 10:56:28 +00:00
mi-nonstop-exit.exp Use require support_displaced_stepping 2023-01-13 13:18:55 -07:00
mi-nonstop.exp Use require support_displaced_stepping 2023-01-13 13:18:55 -07:00
mi-ns-stale-regcache.exp Use require support_displaced_stepping 2023-01-13 13:18:55 -07:00
mi-nsintrall.exp Use require support_displaced_stepping 2023-01-13 13:18:55 -07:00
mi-nsmoribund.exp gdb/testsuite: make more use of mi-support.exp 2023-02-28 10:56:28 +00:00
mi-nsthrexec.exp Use require support_displaced_stepping 2023-01-13 13:18:55 -07:00
mi-pending.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-pending.exp gdb/testsuite: accept script argument for mi_make_breakpoint_pending 2023-04-14 22:16:17 +01:00
mi-pendshr.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-pendshr2.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-pthreads.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-read-memory.c
mi-read-memory.exp Eliminate spurious returns from the test suite 2023-01-26 18:28:31 -07:00
mi-record-changed.exp Eliminate spurious returns from the test suite 2023-01-26 18:28:31 -07:00
mi-reg-undefined.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-reg-undefined.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-reg-undefined.S Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-regs.exp Eliminate spurious returns from the test suite 2023-01-26 18:28:31 -07:00
mi-return.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-reverse.exp Eliminate spurious returns from the test suite 2023-01-26 18:28:31 -07:00
mi-simplerun.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-solib.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-stack.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-stack.exp Don't treat references to compound values as "simple". 2023-05-04 08:58:18 -06:00
mi-start.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-start.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-stepi.exp Eliminate spurious returns from the test suite 2023-01-26 18:28:31 -07:00
mi-stepn.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-stepn.exp Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-sym-info-1.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-sym-info-2.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-sym-info.exp Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-syn-frame.c
mi-syn-frame.exp Use require with target_info 2023-03-10 08:21:46 -07:00
mi-thread-bp-deleted.c gdb: fix mi breakpoint-deleted notifications for thread-specific b/p 2023-02-28 10:56:28 +00:00
mi-thread-bp-deleted.exp gdb: fix mi breakpoint-deleted notifications for thread-specific b/p 2023-02-28 10:56:28 +00:00
mi-thread-specific-bp.c gdb: don't duplicate 'thread' field in MI breakpoint output 2023-02-28 10:56:28 +00:00
mi-thread-specific-bp.exp gdb/mi: check thread exists when creating thread-specific b/p 2023-04-29 00:15:42 +01:00
mi-threads-interrupt.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-threads-interrupt.exp Use require with target_info 2023-03-10 08:21:46 -07:00
mi-undefined-cmd.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-until.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-var-block.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-var-child-f.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-var-child.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-var-child.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-var-cmd.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-var-cp.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-var-cp.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-var-create-rtti.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-var-create-rtti.exp Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-var-display.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-var-invalidate-shlib-lib.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-var-invalidate-shlib.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-var-invalidate-shlib.exp [gdb/testsuite] Fix gdb.mi/*.exp with remote-gdbserver-on-localhost 2023-03-07 09:59:56 +01:00
mi-var-invalidate.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-var-list-children-invalid-grandchild.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-var-list-children-invalid-grandchild.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-var-rtti.cc Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi-var-rtti.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-vla-c99.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-vla-fortran.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi-watch-nonstop.exp Rename to allow_hw_watchpoint_tests 2023-01-13 13:18:58 -07:00
mi-watch.exp gdb/testsuite introduce foreach_mi_ui_mode helper proc 2023-02-28 10:56:28 +00:00
mi2-amd64-entry-value.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi2-amd64-entry-value.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi2-amd64-entry-value.s Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi2-cli-display.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
mi2-cli-display.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi2-prompt.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
mi2-var-child.exp Use mi_clean_restart more 2023-01-26 18:28:31 -07:00
new-ui-mi-sync.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
new-ui-mi-sync.exp gdb/testsuite: extend the use of mi_clean_restart 2023-02-28 10:56:28 +00:00
non-stop-exit.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
non-stop.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
ns-stale-regcache.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
nsintrall.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
nsmoribund.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
nsthrexec.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
pending.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
pendshr1.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
pendshr2.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
pr11022.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
pr11022.exp Rename to allow_hw_watchpoint_tests 2023-01-13 13:18:58 -07:00
print-simple-values.cc Don't treat references to compound values as "simple". 2023-05-04 08:58:18 -06:00
print-simple-values.exp Don't treat references to compound values as "simple". 2023-05-04 08:58:18 -06:00
pthreads.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
run-with-two-mi-uis.c gdb/mi: fix ^running record with multiple MI interpreters 2023-05-29 10:09:24 -04:00
run-with-two-mi-uis.exp gdb/mi: fix ^running record with multiple MI interpreters 2023-05-29 10:09:24 -04:00
solib-lib.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
solib-main.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
testcmds
until.c
user-selected-context-sync.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
user-selected-context-sync.exp gdb/testsuite: special case '^' in gdb_test pattern 2023-04-27 13:56:38 +01:00
var-cmd.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
vla.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
vla.f90 Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00
watch-nonstop.c Update copyright year range in header of all files managed by GDB 2023-01-01 17:01:16 +04:00