binutils-gdb/gdb/testsuite/gdb.mi
Jan Vrany a2757c4ed6 gdb/mi: consistently notify user when GDB/MI client uses -thread-select
GDB notifies users about user selected thread changes somewhat
inconsistently as mentioned on gdb-patches mailing list here:

  https://sourceware.org/pipermail/gdb-patches/2022-February/185989.html

Consider GDB debugging a multi-threaded inferior with both CLI and GDB/MI
interfaces connected to separate terminals.

Assuming inferior is stopped and thread 1 is selected, when a thread
2 is selected using '-thread-select 2' command on GDB/MI terminal:

    -thread-select 2
    ^done,new-thread-id="2",frame={level="0",addr="0x00005555555551cd",func="child_sub_function",args=[],file="/home/jv/Projects/gdb/users_jv_patches/gdb/testsuite/gdb.mi/user-selected-context-sync.c",fullname="/home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c",line="30",arch="i386:x86-64"}
    (gdb)

and on CLI terminal we get the notification (as expected):

    [Switching to thread 2 (Thread 0x7ffff7daa640 (LWP 389659))]
    #0  child_sub_function () at /home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:30
    30        volatile int dummy = 0;

However, now that thread 2 is selected, if thread 1 is selected
using 'thread-select --thread 1 1' command on GDB/MI terminal
terminal:

   -thread-select --thread 1 1
   ^done,new-thread-id="1",frame={level="0",addr="0x0000555555555294",func="main",args=[],file="/home/jv/Projects/gdb/users_jv_patches/gdb/testsuite/gdb.mi/user-selected-context-sync.c",fullname="/home/jv/Projects/gdb/users_jv_patches/gdb/testsuite/gdb.mi/user-selected-context-sync.c",line="66",arch="i386:x86-64"}
   (gdb)

but no notification is printed on CLI terminal, despite the fact
that user selected thread has changed.

The problem is that when `-thread-select --thread 1 1` is executed
then thread is switched to thread 1 before mi_cmd_thread_select () is
called, therefore the condition "inferior_ptid != previous_ptid"
there does not hold.

To address this problem, we have to move notification logic up to
mi_cmd_execute () where --thread option is processed and notify
user selected contents observers there if context changes.

However, this in itself breaks GDB/MI because it would cause context
notification to be sent on MI channel. This is because by the time
we notify, MI notification suppression is already restored (done in
mi_command::invoke(). Therefore we had to lift notification suppression
logic also up to mi_cmd_execute (). This change in made distinction
between mi_command::invoke() and mi_command::do_invoke() unnecessary
as all mi_command::invoke() did (after the change) was to call
do_invoke(). So this patches removes do_invoke() and moves the command
execution logic directly to invoke().

With this change, all gdb.mi tests pass, tested on x86_64-linux.

Co-authored-by: Andrew Burgess <aburgess@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=20631
2022-03-16 15:08:22 +00:00
..
array.f90 Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
basics.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
ChangeLog-1999-2003
dw2-ref-missing-frame-func.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
dw2-ref-missing-frame-main.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
dw2-ref-missing-frame.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
dw2-ref-missing-frame.S Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb669.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb680.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb701.c
gdb701.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb792.cc
gdb792.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb2549.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
interrupt-thread-group.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
interrupt-thread-group.exp gdb/mi: add --no-connection to MI -add-inferior command 2022-03-07 19:39:04 +00:00
list-thread-groups-available.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
list-thread-groups-available.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
list-thread-groups-no-inferior.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi2-amd64-entry-value.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi2-amd64-entry-value.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi2-amd64-entry-value.s Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi2-cli-display.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi2-cli-display.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi2-prompt.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi2-var-child.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-add-inferior.exp gdb/mi: add --no-connection to MI -add-inferior command 2022-03-07 19:39:04 +00:00
mi-async-run.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-async-run.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-async.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-basics.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-break-qualified.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-break-qualified.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-break.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-breakpoint-changed.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-breakpoint-multiple-locations.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-breakpoint-multiple-locations.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-catch-cpp-exceptions.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-catch-cpp-exceptions.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-catch-load-so.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-catch-load.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-catch-load.exp gdb/testsuite: Remove duplicates from gdb.mi/mi-catch-load.exp 2022-01-07 22:43:34 +00:00
mi-cli.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-cmd-error.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-cmd-param-changed.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-cmd-user-context.exp gdb/mi: preserve user selected thread and frame when invoking MI commands 2022-03-08 16:55:37 +00:00
mi-complete.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-complete.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-condbreak-call-thr-state-mt.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-condbreak-call-thr-state-st.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-condbreak-call-thr-state.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-condbreak-call-thr-state.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-console.c
mi-console.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-detach.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-disassemble.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-dprintf-pending.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-dprintf-pending.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-dprintf-pendshr.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-dprintf.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-dprintf.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-editing.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-eval.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-exec-run.exp Fix "spawn id XYZ not open" errors in gdb.mi/mi-exec-run.exp 2022-02-28 11:55:51 -08:00
mi-exit-code.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-exit-code.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-file-transfer.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-file.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-fill-memory.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-fortran-modules-2.f90 Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-fortran-modules.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-fortran-modules.f90 Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-frame-regs.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-fullname-deleted.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-hack-cli.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-i-cmd.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-info-os.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-info-sources-base.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-info-sources.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-info-sources.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-inheritance-syntax-error.cc
mi-inheritance-syntax-error.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-language.exp gdb/testsuite: Remove duplicates from gdb.mi/mi-language.exp 2022-01-07 22:43:34 +00:00
mi-linespec-err-cp.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-linespec-err-cp.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-logging.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-memory-changed.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-multi-commands.exp gdb/testsuite: relax pattern in new gdb.mi/mi-multi-commands.exp test 2022-02-21 12:52:25 +00:00
mi-nonstop-exit.exp gdb/testsuite: Remove duplicates from gdb.mi/mi-nonstop-exit.exp 2022-01-07 22:43:34 +00:00
mi-nonstop.exp gdb/testsuite: Remove duplicates from gdb.mi/mi-nonstop.exp 2022-01-07 22:43:34 +00:00
mi-ns-stale-regcache.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-nsintrall.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-nsmoribund.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-nsthrexec.exp gdb/testsuite: Remove duplicates from gdb.mi/mi-nsthrexec.exp 2022-01-07 22:43:34 +00:00
mi-pending.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-pending.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-pendshr2.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-pendshr.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-pthreads.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-read-memory.c
mi-read-memory.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-record-changed.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-reg-undefined.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-reg-undefined.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-reg-undefined.S Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-regs.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-return.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-reverse.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-simplerun.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-solib.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-stack.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-stack.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-start.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-start.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-stepi.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-stepn.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-stepn.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-sym-info-1.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-sym-info-2.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-sym-info.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-syn-frame.c
mi-syn-frame.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-threads-interrupt.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-threads-interrupt.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-undefined-cmd.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-until.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-var-block.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-var-child-f.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-var-child.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-var-child.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-var-cmd.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-var-cp.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-var-cp.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-var-create-rtti.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-var-create-rtti.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-var-display.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-var-invalidate.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-var-list-children-invalid-grandchild.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-var-list-children-invalid-grandchild.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-var-rtti.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-var-rtti.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-vla-c99.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-vla-fortran.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-watch-nonstop.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
mi-watch.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
new-ui-mi-sync.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
new-ui-mi-sync.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
non-stop-exit.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
non-stop.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
ns-stale-regcache.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
nsintrall.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
nsmoribund.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
nsthrexec.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
pending.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
pendshr1.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
pendshr2.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
pr11022.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
pr11022.exp Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
pthreads.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
solib-lib.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
solib-main.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
testcmds
until.c
user-selected-context-sync.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
user-selected-context-sync.exp gdb/mi: consistently notify user when GDB/MI client uses -thread-select 2022-03-16 15:08:22 +00:00
var-cmd.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
vla.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
vla.f90 Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
watch-nonstop.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00