diff options
author | Jan Vrany <jan.vrany@labware.com> | 2022-03-16 15:08:22 +0000 |
---|---|---|
committer | Jan Vrany <jan.vrany@labware.com> | 2022-03-16 15:08:22 +0000 |
commit | a2757c4ed693cef4ecc4dcdcb2518353eb6b3c3f (patch) | |
tree | cc8e1e5c872fb3c59bd0e934749f4cfd317f9d2d /gdb/stack.c | |
parent | f4be26838dc9937a4ae3e9cf4fbec50efd7786a2 (diff) | |
download | binutils-a2757c4ed693cef4ecc4dcdcb2518353eb6b3c3f.zip binutils-a2757c4ed693cef4ecc4dcdcb2518353eb6b3c3f.tar.gz binutils-a2757c4ed693cef4ecc4dcdcb2518353eb6b3c3f.tar.bz2 |
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
Diffstat (limited to 'gdb/stack.c')
-rw-r--r-- | gdb/stack.c | 8 |
1 files changed, 0 insertions, 8 deletions
diff --git a/gdb/stack.c b/gdb/stack.c index 8855ed8..10da88b 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1841,14 +1841,6 @@ select_frame_command_core (struct frame_info *fi, bool ignored) gdb::observers::user_selected_context_changed.notify (USER_SELECTED_FRAME); } -/* See stack.h. */ - -void -select_frame_for_mi (struct frame_info *fi) -{ - select_frame_command_core (fi, false /* Ignored. */); -} - /* The core of all the "frame" sub-commands. Select frame FI, and if this means we change frame send out a change notification (otherwise, just reprint the current frame summary). */ |