mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-21 04:42:53 +08:00
a2757c4ed6
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
88 lines
3.0 KiB
C
88 lines
3.0 KiB
C
/* Stack manipulation commands, for GDB the GNU Debugger.
|
|
|
|
Copyright (C) 2003-2022 Free Software Foundation, Inc.
|
|
|
|
This file is part of GDB.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef STACK_H
|
|
#define STACK_H
|
|
|
|
gdb::unique_xmalloc_ptr<char> find_frame_funname (struct frame_info *frame,
|
|
enum language *funlang,
|
|
struct symbol **funcp);
|
|
|
|
typedef gdb::function_view<void (const char *print_name, struct symbol *sym)>
|
|
iterate_over_block_arg_local_vars_cb;
|
|
|
|
void iterate_over_block_arg_vars (const struct block *block,
|
|
iterate_over_block_arg_local_vars_cb cb);
|
|
|
|
void iterate_over_block_local_vars (const struct block *block,
|
|
iterate_over_block_arg_local_vars_cb cb);
|
|
|
|
/* Initialize *WHAT to be a copy of the user desired print what frame info.
|
|
If !WHAT.has_value (), the printing function chooses a default set of
|
|
information to print, otherwise the printing function should print
|
|
the relevant information. */
|
|
|
|
void get_user_print_what_frame_info (gdb::optional<enum print_what> *what);
|
|
|
|
/* Return true if we should display the address in addition to the location,
|
|
because we are in the middle of a statement. */
|
|
|
|
bool frame_show_address (struct frame_info *frame, struct symtab_and_line sal);
|
|
|
|
/* Forget the last sal we displayed. */
|
|
|
|
void clear_last_displayed_sal (void);
|
|
|
|
/* Is our record of the last sal we displayed valid? If not, the
|
|
get_last_displayed_* functions will return NULL or 0, as appropriate. */
|
|
|
|
bool last_displayed_sal_is_valid (void);
|
|
|
|
/* Get the pspace of the last sal we displayed, if it's valid, otherwise
|
|
return nullptr. */
|
|
|
|
struct program_space* get_last_displayed_pspace (void);
|
|
|
|
/* Get the address of the last sal we displayed, if it's valid, otherwise
|
|
return an address of 0. */
|
|
|
|
CORE_ADDR get_last_displayed_addr (void);
|
|
|
|
/* Get the symtab of the last sal we displayed, if it's valid, otherwise
|
|
return nullptr. */
|
|
|
|
struct symtab* get_last_displayed_symtab (void);
|
|
|
|
/* Get the line of the last sal we displayed, if it's valid, otherwise
|
|
return 0. */
|
|
|
|
int get_last_displayed_line (void);
|
|
|
|
/* Get the last sal we displayed, if it's valid, otherwise return a
|
|
symtab_and_line constructed in its default state. */
|
|
|
|
symtab_and_line get_last_displayed_sal ();
|
|
|
|
/* Completer for the "frame apply all" command. */
|
|
void frame_apply_all_cmd_completer (struct cmd_list_element *ignore,
|
|
completion_tracker &tracker,
|
|
const char *text, const char */*word*/);
|
|
|
|
#endif /* #ifndef STACK_H */
|