binutils-gdb/gdb/tui/tui-hooks.c

275 lines
7.9 KiB
C
Raw Normal View History

/* GDB hooks for TUI.
2002-03-01 07:19:28 +01:00
Copyright (C) 2001-2018 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/>. */
#include "defs.h"
#include "symtab.h"
#include "inferior.h"
#include "command.h"
#include "bfd.h"
#include "symfile.h"
#include "objfiles.h"
#include "target.h"
#include "gdbcore.h"
#include "event-loop.h"
#include "event-top.h"
#include "frame.h"
#include "breakpoint.h"
#include "ui-out.h"
#include "top.h"
Convert observers to C++ This converts observers from using a special source-generating script to be plain C++. This version of the patch takes advantage of C++11 by using std::function and variadic templates; incorporates Pedro's patches; and renames the header file to "observable.h" (this change eliminates the need for a clean rebuild). Note that Pedro's patches used a template lambda in tui-hooks.c, but this failed to compile on some buildbot instances (presumably due to differing C++ versions); I replaced this with an ordinary template function. Regression tested on the buildbot. gdb/ChangeLog 2018-03-19 Pedro Alves <palves@redhat.com> Tom Tromey <tom@tromey.com> * unittests/observable-selftests.c: New file. * common/observable.h: New file. * observable.h: New file. * ada-lang.c, ada-tasks.c, agent.c, aix-thread.c, annotate.c, arm-tdep.c, auto-load.c, auxv.c, break-catch-syscall.c, breakpoint.c, bsd-uthread.c, cli/cli-interp.c, cli/cli-setshow.c, corefile.c, dummy-frame.c, event-loop.c, event-top.c, exec.c, extension.c, frame.c, gdbarch.c, guile/scm-breakpoint.c, infcall.c, infcmd.c, inferior.c, inflow.c, infrun.c, jit.c, linux-tdep.c, linux-thread-db.c, m68klinux-tdep.c, mi/mi-cmd-break.c, mi/mi-interp.c, mi/mi-main.c, objfiles.c, ppc-linux-nat.c, ppc-linux-tdep.c, printcmd.c, procfs.c, python/py-breakpoint.c, python/py-finishbreakpoint.c, python/py-inferior.c, python/py-unwind.c, ravenscar-thread.c, record-btrace.c, record-full.c, record.c, regcache.c, remote.c, riscv-tdep.c, sol-thread.c, solib-aix.c, solib-spu.c, solib.c, spu-multiarch.c, spu-tdep.c, stack.c, symfile-mem.c, symfile.c, symtab.c, thread.c, top.c, tracepoint.c, tui/tui-hooks.c, tui/tui-interp.c, valops.c: Update all users. * tui/tui-hooks.c (tui_bp_created_observer) (tui_bp_deleted_observer, tui_bp_modified_observer) (tui_inferior_exit_observer, tui_before_prompt_observer) (tui_normal_stop_observer, tui_register_changed_observer): Remove. (tui_observers_token): New global. (attach_or_detach, tui_attach_detach_observers): New functions. (tui_install_hooks, tui_remove_hooks): Use tui_attach_detach_observers. * record-btrace.c (record_btrace_thread_observer): Remove. (record_btrace_thread_observer_token): New global. * observer.sh: Remove. * observer.c: Rename to observable.c. * observable.c (namespace gdb_observers): Define new objects. (observer_debug): Move into gdb_observers namespace. (struct observer, struct observer_list, xalloc_observer_list_node) (xfree_observer_list_node, generic_observer_attach) (generic_observer_detach, generic_observer_notify): Remove. (_initialize_observer): Update. Don't include observer.inc. * Makefile.in (generated_files): Remove observer.h, observer.inc. (clean mostlyclean): Likewise. (observer.h, observer.inc): Remove targets. (SUBDIR_UNITTESTS_SRCS): Add observable-selftests.c. (COMMON_SFILES): Use observable.c, not observer.c. * .gitignore: Remove observer.h. gdb/doc/ChangeLog 2018-03-19 Tom Tromey <tom@tromey.com> * observer.texi: Remove. gdb/testsuite/ChangeLog 2018-03-19 Tom Tromey <tom@tromey.com> * gdb.gdb/observer.exp: Remove.
2016-10-02 18:50:20 +02:00
#include "observable.h"
#include <unistd.h>
#include <fcntl.h>
#include "tui/tui.h"
#include "tui/tui-hooks.h"
#include "tui/tui-data.h"
#include "tui/tui-layout.h"
#include "tui/tui-io.h"
#include "tui/tui-regs.h"
#include "tui/tui-win.h"
#include "tui/tui-stack.h"
#include "tui/tui-windata.h"
#include "tui/tui-winsource.h"
#include "gdb_curses.h"
/* This redefines CTRL if it is not already defined, so it must come
after terminal state releated include files like <term.h> and
"gdb_curses.h". */
#include "readline/readline.h"
static void
tui_new_objfile_hook (struct objfile* objfile)
{
if (tui_active)
tui_display_main ();
}
/* Prevent recursion of deprecated_register_changed_hook(). */
static int tui_refreshing_registers = 0;
/* Observer for the register_changed notification. */
static void
tui_register_changed (struct frame_info *frame, int regno)
{
struct frame_info *fi;
/* The frame of the register that was changed may differ from the selected
frame, but we only want to show the register values of the selected frame.
And even if the frames differ a register change made in one can still show
up in the other. So we always use the selected frame here, and ignore
FRAME. */
fi = get_selected_frame (NULL);
if (tui_refreshing_registers == 0)
{
tui_refreshing_registers = 1;
tui_check_data_values (fi);
tui_refreshing_registers = 0;
}
}
/* Breakpoint creation hook.
Update the screen to show the new breakpoint. */
static void
MI breakpoint notifications. * annotate.c (breakpoint_changed): Adjust parameter type. * breakpoint.c (set_breakpoint_condition): Adjust to change in breakpoint_modified type. (breakpoint_set_commands): Likewise. (do_map_commands_command): Likewise. (bpstat_check_breakpoint_conditions): Notify that breakpoint has changed after bumping hit count. (bpstat_stop_status): Likewise. (print_one_breakpoint_location): Don't wrap in tuple here. (print_one_breakpoint): Always print individual locations. For locations, use unnamed tuple. (disable_breakpoints_in_unloaded_shlib): Notify that breakpoint has changed. (create_catchpoint, create_syscall_event_catchpoint): Call breakpoint_created obsever. (mention): Don't call breakpoint_created observer. (create_breakpoint_sal): Call breakpoint_created observer. (create_breakpoint, watch_command_1): Likewise. (create_ada_exception_breakpoint): Likewise. (delete_breakpoint): Call breakpoint_deleted breakpoint. (locations_are_equal): New. (update_breakpoint_locations): If locations were changed, notify. (set_ignore_count, disable_breakpoint, do_enable_breakpoint): Call breakpoint_modified observer. * mi/mi-cmd-break.c (breakpoint_notify): Adjust. (mi_cmd_break_insert): Don't set observers for modify and delete. * mi/mi-interp.c (mi_suppress_breakpoint_notifications): New. (mi_breakpoint_created, mi_breakpoint_deleted) (mi_breakpoint_modified): New. (mi_interpreter_init): Hook the above. * mi/mi-main.c (mi_cmd_execute): Disable breakpoint notifications while -break-* commands are executing. * mi/mi-main.h (mi_suppress_breakpoint_notifications): New. * mi/mi-out.c (struct ui_out_data): New field original_buffer. (mi_redirect): New. (mi_ui_out_impl): Hook in mi_redirect. (mi_field_skip): True to the name, skip the field, don't output a field with an empty value. * python/py-breakpoint.c (gdbpy_breakpoint_created) (gdbpy_breakpoint_deleted): Adjust. * tui/tui-hooks.c (tui_event_create_breakpoint) (tui_event_delete_breakpoint, tui_event_modify_breakpoint): Adjust.
2011-04-27 12:17:39 +02:00
tui_event_create_breakpoint (struct breakpoint *b)
{
tui_update_all_breakpoint_info ();
}
/* Breakpoint deletion hook.
Refresh the screen to update the breakpoint marks. */
static void
MI breakpoint notifications. * annotate.c (breakpoint_changed): Adjust parameter type. * breakpoint.c (set_breakpoint_condition): Adjust to change in breakpoint_modified type. (breakpoint_set_commands): Likewise. (do_map_commands_command): Likewise. (bpstat_check_breakpoint_conditions): Notify that breakpoint has changed after bumping hit count. (bpstat_stop_status): Likewise. (print_one_breakpoint_location): Don't wrap in tuple here. (print_one_breakpoint): Always print individual locations. For locations, use unnamed tuple. (disable_breakpoints_in_unloaded_shlib): Notify that breakpoint has changed. (create_catchpoint, create_syscall_event_catchpoint): Call breakpoint_created obsever. (mention): Don't call breakpoint_created observer. (create_breakpoint_sal): Call breakpoint_created observer. (create_breakpoint, watch_command_1): Likewise. (create_ada_exception_breakpoint): Likewise. (delete_breakpoint): Call breakpoint_deleted breakpoint. (locations_are_equal): New. (update_breakpoint_locations): If locations were changed, notify. (set_ignore_count, disable_breakpoint, do_enable_breakpoint): Call breakpoint_modified observer. * mi/mi-cmd-break.c (breakpoint_notify): Adjust. (mi_cmd_break_insert): Don't set observers for modify and delete. * mi/mi-interp.c (mi_suppress_breakpoint_notifications): New. (mi_breakpoint_created, mi_breakpoint_deleted) (mi_breakpoint_modified): New. (mi_interpreter_init): Hook the above. * mi/mi-main.c (mi_cmd_execute): Disable breakpoint notifications while -break-* commands are executing. * mi/mi-main.h (mi_suppress_breakpoint_notifications): New. * mi/mi-out.c (struct ui_out_data): New field original_buffer. (mi_redirect): New. (mi_ui_out_impl): Hook in mi_redirect. (mi_field_skip): True to the name, skip the field, don't output a field with an empty value. * python/py-breakpoint.c (gdbpy_breakpoint_created) (gdbpy_breakpoint_deleted): Adjust. * tui/tui-hooks.c (tui_event_create_breakpoint) (tui_event_delete_breakpoint, tui_event_modify_breakpoint): Adjust.
2011-04-27 12:17:39 +02:00
tui_event_delete_breakpoint (struct breakpoint *b)
{
tui_update_all_breakpoint_info ();
}
static void
MI breakpoint notifications. * annotate.c (breakpoint_changed): Adjust parameter type. * breakpoint.c (set_breakpoint_condition): Adjust to change in breakpoint_modified type. (breakpoint_set_commands): Likewise. (do_map_commands_command): Likewise. (bpstat_check_breakpoint_conditions): Notify that breakpoint has changed after bumping hit count. (bpstat_stop_status): Likewise. (print_one_breakpoint_location): Don't wrap in tuple here. (print_one_breakpoint): Always print individual locations. For locations, use unnamed tuple. (disable_breakpoints_in_unloaded_shlib): Notify that breakpoint has changed. (create_catchpoint, create_syscall_event_catchpoint): Call breakpoint_created obsever. (mention): Don't call breakpoint_created observer. (create_breakpoint_sal): Call breakpoint_created observer. (create_breakpoint, watch_command_1): Likewise. (create_ada_exception_breakpoint): Likewise. (delete_breakpoint): Call breakpoint_deleted breakpoint. (locations_are_equal): New. (update_breakpoint_locations): If locations were changed, notify. (set_ignore_count, disable_breakpoint, do_enable_breakpoint): Call breakpoint_modified observer. * mi/mi-cmd-break.c (breakpoint_notify): Adjust. (mi_cmd_break_insert): Don't set observers for modify and delete. * mi/mi-interp.c (mi_suppress_breakpoint_notifications): New. (mi_breakpoint_created, mi_breakpoint_deleted) (mi_breakpoint_modified): New. (mi_interpreter_init): Hook the above. * mi/mi-main.c (mi_cmd_execute): Disable breakpoint notifications while -break-* commands are executing. * mi/mi-main.h (mi_suppress_breakpoint_notifications): New. * mi/mi-out.c (struct ui_out_data): New field original_buffer. (mi_redirect): New. (mi_ui_out_impl): Hook in mi_redirect. (mi_field_skip): True to the name, skip the field, don't output a field with an empty value. * python/py-breakpoint.c (gdbpy_breakpoint_created) (gdbpy_breakpoint_deleted): Adjust. * tui/tui-hooks.c (tui_event_create_breakpoint) (tui_event_delete_breakpoint, tui_event_modify_breakpoint): Adjust.
2011-04-27 12:17:39 +02:00
tui_event_modify_breakpoint (struct breakpoint *b)
{
tui_update_all_breakpoint_info ();
}
Replace TUI's select_frame hook (PR tui/13378) The select_frame hook is used by TUI to update TUI's frame and register information following changes to the selected frame. The problem with this hook is that it gets called after every single frame change, even if the frame change is only temporary or internal. This is the primary cause of flickering and slowdown when running the inferior under TUI with conditional breakpoints set. Internal GDB events are the source of many calls to select_frame and these internal events are triggered frequently, especially when a few conditional breakpoints are set. This patch removes the select_frame hook altogether and instead makes the frame and register information get updated in two key places (using observers): after an inferior stops, and right before displaying a prompt. The latter hook covers the case when frame information must be updated following a call to "up", "down" or "frame", and the former covers the case when frame and register information must be updated after a call to "continue", "step", etc. or after the inferior stops in async execution mode. Together these hooks should cover all the cases when frame information ought to be refreshed (and when the relevant windows ought to be subsequently updated). The print_frame_info_listing hook is also effectively obsolete now, but it still must be set while the TUI is active because its caller print_frame_info will otherwise assume that the CLI is active, and will print the frame informaion accordingly. So this patch also sets the print_frame_info_listing hook to a dummy callback, in lieu of outright removing it yet. Effectively, with this patch, frame/PC changes that do not immediately precede an inferior-stop event or a prompt display event no longer cause TUI's frame and register information to be updated. And as a result of this change and of the previous change to tui_show_frame_info, the TUI is much more disciplined about updating the screen, and so the flicker as described in the PR is totally gone. gdb/ChangeLog: PR tui/13378 * frame.c (select_frame): Remove reference to deprecated_selected_frame_level_changed_hook. * frame.h (deprecated_selected_frame_level_changed_hook): Remove declaration. * stack.c (deprecated_selected_frame_level_changed_hook): Likewise. * tui/tui-hooks.c (tui_selected_frame_level_changed_hook): Rename to ... (tui_refresh_frame_and_register_information): ... this. Bail out if there is no stack. Don't update register information unless registers_too_p is true. (tui_print_frame_info_listing_hook): Rename to ... (tui_dummy_print_frame_info_listing_hook): ... this. (tui_before_prompt): New function. (tui_normal_stop): New function. (tui_before_prompt_observer): New observer. (tui_normal_stop_observer): New observer. (tui_install_hooks): Set deprecated_print_frame_info_listing_hook to tui_dummy_print_frame_info_listing_hook. Register tui_before_prompt_observer to call tui_before_prompt and tui_normal_stop_observer to call tui_normal_stop. Remove reference to deprecated_selected_frame_level_changed_hook. (tui_remove_hooks): Detach and unset tui_before_prompt_observer and tui_normal_stop_observer. Remove reference to deprecated_selected_frame_level_changed_hook.
2015-06-30 19:56:49 +02:00
/* Refresh TUI's frame and register information. This is a hook intended to be
used to update the screen after potential frame and register changes.
TUI: Make sure to update registers if frame information has changed When I replaced TUI's frame_changed hook to fix PR tui/13378 I assumed that there's no reason to refresh register information following a call to "up", "down" or "frame". This assumption was made to fix the problem of refreshing frame information twice following a sync-execution normal stop (once in tui_normal_stop and then in tui_before_prompt) -- the second refresh removing any highlights made by the first. I was wrong about that -- GDB's snapshot of register information is per-frame, and when the frame changes, registers do too (most prominently the %rip and %rsp registers). So e.g. GDB 7.8 would highlight such register changes after invoking "up", "down" or "frame", and current GDB does not. To fix this regression, this patch adds another (sufficient) condition for refreshing register information: in tui_refresh_frame_and_register_information, always refresh register information if frame information has changed. This makes register information get refreshed following a call to "up", "down" or "frame" while still avoiding the "double refresh" issue following a normal stop. This condition may seem to obsolete the existing registers_too_p parameter, but it does not: following a normal stop, it is possible that registers may have changed while frame information had not. We could be on the exact same PC with different register values. The new condition would not catch such a case, but the registers_too_p condition will. So both conditions seem necessary (and either one is sufficient). gdb/ChangeLog: * tui/tui-hooks.c (tui_refresh_frame_and_register_information): Update commentary. Always refresh the registers when frame information has changed. * tui/tui-stack.c (tui_show_frame_info): Update commentary. Change return type to int. Return 1 if frame information has changed, 1 otherwise. (tui_before_prompt): Update commentary. * tui/tui-stack.h (tui_show_frame_info): Change return type to int.
2015-07-01 14:02:09 +02:00
REGISTERS_TOO_P controls whether to refresh our register information even
if frame information hasn't changed. */
Replace TUI's select_frame hook (PR tui/13378) The select_frame hook is used by TUI to update TUI's frame and register information following changes to the selected frame. The problem with this hook is that it gets called after every single frame change, even if the frame change is only temporary or internal. This is the primary cause of flickering and slowdown when running the inferior under TUI with conditional breakpoints set. Internal GDB events are the source of many calls to select_frame and these internal events are triggered frequently, especially when a few conditional breakpoints are set. This patch removes the select_frame hook altogether and instead makes the frame and register information get updated in two key places (using observers): after an inferior stops, and right before displaying a prompt. The latter hook covers the case when frame information must be updated following a call to "up", "down" or "frame", and the former covers the case when frame and register information must be updated after a call to "continue", "step", etc. or after the inferior stops in async execution mode. Together these hooks should cover all the cases when frame information ought to be refreshed (and when the relevant windows ought to be subsequently updated). The print_frame_info_listing hook is also effectively obsolete now, but it still must be set while the TUI is active because its caller print_frame_info will otherwise assume that the CLI is active, and will print the frame informaion accordingly. So this patch also sets the print_frame_info_listing hook to a dummy callback, in lieu of outright removing it yet. Effectively, with this patch, frame/PC changes that do not immediately precede an inferior-stop event or a prompt display event no longer cause TUI's frame and register information to be updated. And as a result of this change and of the previous change to tui_show_frame_info, the TUI is much more disciplined about updating the screen, and so the flicker as described in the PR is totally gone. gdb/ChangeLog: PR tui/13378 * frame.c (select_frame): Remove reference to deprecated_selected_frame_level_changed_hook. * frame.h (deprecated_selected_frame_level_changed_hook): Remove declaration. * stack.c (deprecated_selected_frame_level_changed_hook): Likewise. * tui/tui-hooks.c (tui_selected_frame_level_changed_hook): Rename to ... (tui_refresh_frame_and_register_information): ... this. Bail out if there is no stack. Don't update register information unless registers_too_p is true. (tui_print_frame_info_listing_hook): Rename to ... (tui_dummy_print_frame_info_listing_hook): ... this. (tui_before_prompt): New function. (tui_normal_stop): New function. (tui_before_prompt_observer): New observer. (tui_normal_stop_observer): New observer. (tui_install_hooks): Set deprecated_print_frame_info_listing_hook to tui_dummy_print_frame_info_listing_hook. Register tui_before_prompt_observer to call tui_before_prompt and tui_normal_stop_observer to call tui_normal_stop. Remove reference to deprecated_selected_frame_level_changed_hook. (tui_remove_hooks): Detach and unset tui_before_prompt_observer and tui_normal_stop_observer. Remove reference to deprecated_selected_frame_level_changed_hook.
2015-06-30 19:56:49 +02:00
static void
Replace TUI's select_frame hook (PR tui/13378) The select_frame hook is used by TUI to update TUI's frame and register information following changes to the selected frame. The problem with this hook is that it gets called after every single frame change, even if the frame change is only temporary or internal. This is the primary cause of flickering and slowdown when running the inferior under TUI with conditional breakpoints set. Internal GDB events are the source of many calls to select_frame and these internal events are triggered frequently, especially when a few conditional breakpoints are set. This patch removes the select_frame hook altogether and instead makes the frame and register information get updated in two key places (using observers): after an inferior stops, and right before displaying a prompt. The latter hook covers the case when frame information must be updated following a call to "up", "down" or "frame", and the former covers the case when frame and register information must be updated after a call to "continue", "step", etc. or after the inferior stops in async execution mode. Together these hooks should cover all the cases when frame information ought to be refreshed (and when the relevant windows ought to be subsequently updated). The print_frame_info_listing hook is also effectively obsolete now, but it still must be set while the TUI is active because its caller print_frame_info will otherwise assume that the CLI is active, and will print the frame informaion accordingly. So this patch also sets the print_frame_info_listing hook to a dummy callback, in lieu of outright removing it yet. Effectively, with this patch, frame/PC changes that do not immediately precede an inferior-stop event or a prompt display event no longer cause TUI's frame and register information to be updated. And as a result of this change and of the previous change to tui_show_frame_info, the TUI is much more disciplined about updating the screen, and so the flicker as described in the PR is totally gone. gdb/ChangeLog: PR tui/13378 * frame.c (select_frame): Remove reference to deprecated_selected_frame_level_changed_hook. * frame.h (deprecated_selected_frame_level_changed_hook): Remove declaration. * stack.c (deprecated_selected_frame_level_changed_hook): Likewise. * tui/tui-hooks.c (tui_selected_frame_level_changed_hook): Rename to ... (tui_refresh_frame_and_register_information): ... this. Bail out if there is no stack. Don't update register information unless registers_too_p is true. (tui_print_frame_info_listing_hook): Rename to ... (tui_dummy_print_frame_info_listing_hook): ... this. (tui_before_prompt): New function. (tui_normal_stop): New function. (tui_before_prompt_observer): New observer. (tui_normal_stop_observer): New observer. (tui_install_hooks): Set deprecated_print_frame_info_listing_hook to tui_dummy_print_frame_info_listing_hook. Register tui_before_prompt_observer to call tui_before_prompt and tui_normal_stop_observer to call tui_normal_stop. Remove reference to deprecated_selected_frame_level_changed_hook. (tui_remove_hooks): Detach and unset tui_before_prompt_observer and tui_normal_stop_observer. Remove reference to deprecated_selected_frame_level_changed_hook.
2015-06-30 19:56:49 +02:00
tui_refresh_frame_and_register_information (int registers_too_p)
{
struct frame_info *fi;
CORE_ADDR pc;
TUI: Make sure to update registers if frame information has changed When I replaced TUI's frame_changed hook to fix PR tui/13378 I assumed that there's no reason to refresh register information following a call to "up", "down" or "frame". This assumption was made to fix the problem of refreshing frame information twice following a sync-execution normal stop (once in tui_normal_stop and then in tui_before_prompt) -- the second refresh removing any highlights made by the first. I was wrong about that -- GDB's snapshot of register information is per-frame, and when the frame changes, registers do too (most prominently the %rip and %rsp registers). So e.g. GDB 7.8 would highlight such register changes after invoking "up", "down" or "frame", and current GDB does not. To fix this regression, this patch adds another (sufficient) condition for refreshing register information: in tui_refresh_frame_and_register_information, always refresh register information if frame information has changed. This makes register information get refreshed following a call to "up", "down" or "frame" while still avoiding the "double refresh" issue following a normal stop. This condition may seem to obsolete the existing registers_too_p parameter, but it does not: following a normal stop, it is possible that registers may have changed while frame information had not. We could be on the exact same PC with different register values. The new condition would not catch such a case, but the registers_too_p condition will. So both conditions seem necessary (and either one is sufficient). gdb/ChangeLog: * tui/tui-hooks.c (tui_refresh_frame_and_register_information): Update commentary. Always refresh the registers when frame information has changed. * tui/tui-stack.c (tui_show_frame_info): Update commentary. Change return type to int. Return 1 if frame information has changed, 1 otherwise. (tui_before_prompt): Update commentary. * tui/tui-stack.h (tui_show_frame_info): Change return type to int.
2015-07-01 14:02:09 +02:00
int frame_info_changed_p;
Replace TUI's select_frame hook (PR tui/13378) The select_frame hook is used by TUI to update TUI's frame and register information following changes to the selected frame. The problem with this hook is that it gets called after every single frame change, even if the frame change is only temporary or internal. This is the primary cause of flickering and slowdown when running the inferior under TUI with conditional breakpoints set. Internal GDB events are the source of many calls to select_frame and these internal events are triggered frequently, especially when a few conditional breakpoints are set. This patch removes the select_frame hook altogether and instead makes the frame and register information get updated in two key places (using observers): after an inferior stops, and right before displaying a prompt. The latter hook covers the case when frame information must be updated following a call to "up", "down" or "frame", and the former covers the case when frame and register information must be updated after a call to "continue", "step", etc. or after the inferior stops in async execution mode. Together these hooks should cover all the cases when frame information ought to be refreshed (and when the relevant windows ought to be subsequently updated). The print_frame_info_listing hook is also effectively obsolete now, but it still must be set while the TUI is active because its caller print_frame_info will otherwise assume that the CLI is active, and will print the frame informaion accordingly. So this patch also sets the print_frame_info_listing hook to a dummy callback, in lieu of outright removing it yet. Effectively, with this patch, frame/PC changes that do not immediately precede an inferior-stop event or a prompt display event no longer cause TUI's frame and register information to be updated. And as a result of this change and of the previous change to tui_show_frame_info, the TUI is much more disciplined about updating the screen, and so the flicker as described in the PR is totally gone. gdb/ChangeLog: PR tui/13378 * frame.c (select_frame): Remove reference to deprecated_selected_frame_level_changed_hook. * frame.h (deprecated_selected_frame_level_changed_hook): Remove declaration. * stack.c (deprecated_selected_frame_level_changed_hook): Likewise. * tui/tui-hooks.c (tui_selected_frame_level_changed_hook): Rename to ... (tui_refresh_frame_and_register_information): ... this. Bail out if there is no stack. Don't update register information unless registers_too_p is true. (tui_print_frame_info_listing_hook): Rename to ... (tui_dummy_print_frame_info_listing_hook): ... this. (tui_before_prompt): New function. (tui_normal_stop): New function. (tui_before_prompt_observer): New observer. (tui_normal_stop_observer): New observer. (tui_install_hooks): Set deprecated_print_frame_info_listing_hook to tui_dummy_print_frame_info_listing_hook. Register tui_before_prompt_observer to call tui_before_prompt and tui_normal_stop_observer to call tui_normal_stop. Remove reference to deprecated_selected_frame_level_changed_hook. (tui_remove_hooks): Detach and unset tui_before_prompt_observer and tui_normal_stop_observer. Remove reference to deprecated_selected_frame_level_changed_hook.
2015-06-30 19:56:49 +02:00
if (!has_stack_frames ())
return;
Remove make_cleanup_restore_target_terminal This removes make_cleanup_restore_target_terminal and generally C++-ifies target terminal handling. It changes all target_terminal_* functions to be static members of a new target_terminal class and changes the cleanup to be a scoped_* class. make_cleanup_override_quit_handler is also removed in favor of simply using scoped_restore. Note that there are some files in this patch that I could not compile. Considering that some of the rewrites were automated, and that none of these files involed cleanups, I feel that this is relatively safe. Regression tested by the buildbot. gdb/ChangeLog 2017-09-20 Tom Tromey <tom@tromey.com> * windows-nat.c (get_windows_debug_event, windows_wait) (do_initial_windows_stuff, windows_attach): Update. * utils.c (vwarning, internal_vproblem): Update. (ui_unregister_input_event_handler_cleanup) (prepare_to_handle_input): Remove. (class scoped_input_handler): New. (defaulted_query, prompt_for_continue): Update. * tui/tui-hooks.c (tui_refresh_frame_and_register_information): Update. * top.c (undo_terminal_modifications_before_exit): Update. * target/target.h (target_terminal_init, target_terminal_inferior) (target_terminal_ours): Don't declare. (class target_terminal): New. * target.h (target_terminal_is_inferior, target_terminal_is_ours) (target_terminal_ours_for_output) (make_cleanup_restore_target_terminal): Don't declare. (target_terminal_info): Remove. * target.c (enum terminal_state, terminal_state): Remove. (target_terminal::terminal_state): Define. (target_terminal::init): Rename from target_terminal_init. (target_terminal::inferior): Rename from target_terminal_inferior. (target_terminal::ours): Rename from target_terminal_ours. (target_terminal::ours_for_output): Rename from target_terminal_ours_for_output. (target_terminal::info): New method. (cleanup_restore_target_terminal) (make_cleanup_restore_target_terminal): Remove. * solib.c (handle_solib_event): Update. * remote.c (remote_serial_quit_handler): Update. (remote_terminal_inferior, remote_wait_as): Update. * record-full.c (record_full_wait_1): Update. * nto-procfs.c (procfs_create_inferior): Update. * nat/fork-inferior.c (startup_inferior): Update. * mi/mi-interp.c (mi_new_thread, mi_thread_exit) (mi_record_changed, mi_inferior_added, mi_inferior_appeared) (mi_inferior_exit, mi_inferior_removed, mi_traceframe_changed) (mi_tsv_created, mi_tsv_deleted, mi_tsv_modified) (mi_breakpoint_created, mi_breakpoint_deleted) (mi_breakpoint_modified, mi_on_resume, mi_solib_loaded) (mi_solib_unloaded, mi_command_param_changed, mi_memory_changed) (mi_user_selected_context_changed, report_initial_inferior): Update. * linux-nat.c (linux_nat_attach, linux_nat_terminal_ours) (linux_nat_terminal_inferior): Update. * infrun.c (follow_fork_inferior) (handle_vfork_child_exec_or_exit, do_target_resume) (check_curr_ui_sync_execution_done, handle_inferior_event_1) (handle_signal_stop, maybe_remove_breakpoints, normal_stop): Update. * inflow.c (child_terminal_init, info_terminal_command): Update. * infcmd.c (post_create_inferior, continue_1, prepare_one_step) (attach_command): Update. * infcall.c (call_thread_fsm_should_stop): Update. * gnu-nat.c (gnu_attach): Update. * extension.c (struct active_ext_lang_state) (restore_active_ext_lang): Update. * exceptions.c (print_flush): Update. * event-top.c (async_enable_stdin, default_quit_handler): Update. (struct quit_handler_cleanup_data, restore_quit_handler) (restore_quit_handler_dtor, make_cleanup_override_quit_handler): Remove. * cp-support.c (gdb_demangle): Update. * breakpoint.c (update_inserted_breakpoint_locations) (insert_breakpoint_locations, handle_jit_event) (disable_breakpoints_in_unloaded_shlib): Update. * annotate.c (annotate_breakpoints_invalid) (annotate_frames_invalid): Update. gdb/gdbserver/ChangeLog 2017-09-20 Tom Tromey <tom@tromey.com> * target.c (target_terminal::terminal_state): Define. (target_terminal::init): Rename from target_terminal_init. (target_terminal::inferior): Rename from target_terminal_inferior. (target_terminal::ours): Rename from target_terminal_ours. (target_terminal::ours_for_output, target_terminal::info): New.
2017-09-20 05:56:36 +02:00
target_terminal::scoped_restore_terminal_state term_state;
target_terminal::ours_for_output ();
Call target_terminal_ours_for_output() before refreshing TUI's frame info In some cases tui_show_frame_info() may get called while the inferior's terminal settings are still in effect. But when we call this function we absolutely need to have our terminal settings in effect because the function is responsible for redrawing TUI's windows following a change in the selected frame or a change in the PC. If our terminal settings are not in effect, the screen does not get redrawn properly, causing temporary display artifacts (which can be fixed via ^L). This scenario happens most prominently when stepping through a program in TUI while a watchpoint is in effect. Here is an example backtrace for when tui_show_frame_info() gets called while target_terminal_is_inferior() == 1: #1 0x00000000004988ee in tui_selected_frame_level_changed_hook (level=0) #2 0x0000000000617b99 in select_frame (fi=0x18c9820) #3 0x0000000000617c3f in get_selected_frame (message=message@entry=0x0) #4 0x00000000004ce534 in update_watchpoint (b=b@entry=0x2d9a760, reparse=reparse@entry=0) #5 0x00000000004d625e in insert_breakpoints () #6 0x0000000000531cfe in keep_going (ecs=ecs@entry=0x7ffea7884ac0) #7 0x00000000005326d7 in process_event_stop_test (ecs=ecs@entry=0x7ffea7884ac0) #8 0x000000000053596e in handle_inferior_event_1 (ecs=0x7ffea7884ac0) The fix is simple: call target_terminal_ours_for_output() before calling tui_show_frame_info() in TUI's frame-changed hook, making sure to restore the original terminal settings afterwards. gdb/ChangeLog: * tui/tui-hooks.c (tui_selected_frame_level_changed_hook): Call target_terminal_ours_for_output() before calling tui_show_frame_info(), and restore the original terminal settings afterwards.
2015-06-02 03:30:50 +02:00
fi = get_selected_frame (NULL);
/* Ensure that symbols for this frame are read in. Also, determine
the source language of this frame, and switch to it if
desired. */
if (get_frame_pc_if_available (fi, &pc))
{
struct symtab *s;
s = find_pc_line_symtab (pc);
/* elz: This if here fixes the problem with the pc not being
displayed in the tui asm layout, with no debug symbols. The
value of s would be 0 here, and select_source_symtab would
abort the command by calling the 'error' function. */
if (s)
select_source_symtab (s);
}
/* Display the frame position (even if there is no symbols or the PC
is not known). */
TUI: Make sure to update registers if frame information has changed When I replaced TUI's frame_changed hook to fix PR tui/13378 I assumed that there's no reason to refresh register information following a call to "up", "down" or "frame". This assumption was made to fix the problem of refreshing frame information twice following a sync-execution normal stop (once in tui_normal_stop and then in tui_before_prompt) -- the second refresh removing any highlights made by the first. I was wrong about that -- GDB's snapshot of register information is per-frame, and when the frame changes, registers do too (most prominently the %rip and %rsp registers). So e.g. GDB 7.8 would highlight such register changes after invoking "up", "down" or "frame", and current GDB does not. To fix this regression, this patch adds another (sufficient) condition for refreshing register information: in tui_refresh_frame_and_register_information, always refresh register information if frame information has changed. This makes register information get refreshed following a call to "up", "down" or "frame" while still avoiding the "double refresh" issue following a normal stop. This condition may seem to obsolete the existing registers_too_p parameter, but it does not: following a normal stop, it is possible that registers may have changed while frame information had not. We could be on the exact same PC with different register values. The new condition would not catch such a case, but the registers_too_p condition will. So both conditions seem necessary (and either one is sufficient). gdb/ChangeLog: * tui/tui-hooks.c (tui_refresh_frame_and_register_information): Update commentary. Always refresh the registers when frame information has changed. * tui/tui-stack.c (tui_show_frame_info): Update commentary. Change return type to int. Return 1 if frame information has changed, 1 otherwise. (tui_before_prompt): Update commentary. * tui/tui-stack.h (tui_show_frame_info): Change return type to int.
2015-07-01 14:02:09 +02:00
frame_info_changed_p = tui_show_frame_info (fi);
/* Refresh the register window if it's visible. */
TUI: Make sure to update registers if frame information has changed When I replaced TUI's frame_changed hook to fix PR tui/13378 I assumed that there's no reason to refresh register information following a call to "up", "down" or "frame". This assumption was made to fix the problem of refreshing frame information twice following a sync-execution normal stop (once in tui_normal_stop and then in tui_before_prompt) -- the second refresh removing any highlights made by the first. I was wrong about that -- GDB's snapshot of register information is per-frame, and when the frame changes, registers do too (most prominently the %rip and %rsp registers). So e.g. GDB 7.8 would highlight such register changes after invoking "up", "down" or "frame", and current GDB does not. To fix this regression, this patch adds another (sufficient) condition for refreshing register information: in tui_refresh_frame_and_register_information, always refresh register information if frame information has changed. This makes register information get refreshed following a call to "up", "down" or "frame" while still avoiding the "double refresh" issue following a normal stop. This condition may seem to obsolete the existing registers_too_p parameter, but it does not: following a normal stop, it is possible that registers may have changed while frame information had not. We could be on the exact same PC with different register values. The new condition would not catch such a case, but the registers_too_p condition will. So both conditions seem necessary (and either one is sufficient). gdb/ChangeLog: * tui/tui-hooks.c (tui_refresh_frame_and_register_information): Update commentary. Always refresh the registers when frame information has changed. * tui/tui-stack.c (tui_show_frame_info): Update commentary. Change return type to int. Return 1 if frame information has changed, 1 otherwise. (tui_before_prompt): Update commentary. * tui/tui-stack.h (tui_show_frame_info): Change return type to int.
2015-07-01 14:02:09 +02:00
if (tui_is_window_visible (DATA_WIN)
&& (frame_info_changed_p || registers_too_p))
{
tui_refreshing_registers = 1;
tui_check_data_values (fi);
tui_refreshing_registers = 0;
}
}
Replace TUI's select_frame hook (PR tui/13378) The select_frame hook is used by TUI to update TUI's frame and register information following changes to the selected frame. The problem with this hook is that it gets called after every single frame change, even if the frame change is only temporary or internal. This is the primary cause of flickering and slowdown when running the inferior under TUI with conditional breakpoints set. Internal GDB events are the source of many calls to select_frame and these internal events are triggered frequently, especially when a few conditional breakpoints are set. This patch removes the select_frame hook altogether and instead makes the frame and register information get updated in two key places (using observers): after an inferior stops, and right before displaying a prompt. The latter hook covers the case when frame information must be updated following a call to "up", "down" or "frame", and the former covers the case when frame and register information must be updated after a call to "continue", "step", etc. or after the inferior stops in async execution mode. Together these hooks should cover all the cases when frame information ought to be refreshed (and when the relevant windows ought to be subsequently updated). The print_frame_info_listing hook is also effectively obsolete now, but it still must be set while the TUI is active because its caller print_frame_info will otherwise assume that the CLI is active, and will print the frame informaion accordingly. So this patch also sets the print_frame_info_listing hook to a dummy callback, in lieu of outright removing it yet. Effectively, with this patch, frame/PC changes that do not immediately precede an inferior-stop event or a prompt display event no longer cause TUI's frame and register information to be updated. And as a result of this change and of the previous change to tui_show_frame_info, the TUI is much more disciplined about updating the screen, and so the flicker as described in the PR is totally gone. gdb/ChangeLog: PR tui/13378 * frame.c (select_frame): Remove reference to deprecated_selected_frame_level_changed_hook. * frame.h (deprecated_selected_frame_level_changed_hook): Remove declaration. * stack.c (deprecated_selected_frame_level_changed_hook): Likewise. * tui/tui-hooks.c (tui_selected_frame_level_changed_hook): Rename to ... (tui_refresh_frame_and_register_information): ... this. Bail out if there is no stack. Don't update register information unless registers_too_p is true. (tui_print_frame_info_listing_hook): Rename to ... (tui_dummy_print_frame_info_listing_hook): ... this. (tui_before_prompt): New function. (tui_normal_stop): New function. (tui_before_prompt_observer): New observer. (tui_normal_stop_observer): New observer. (tui_install_hooks): Set deprecated_print_frame_info_listing_hook to tui_dummy_print_frame_info_listing_hook. Register tui_before_prompt_observer to call tui_before_prompt and tui_normal_stop_observer to call tui_normal_stop. Remove reference to deprecated_selected_frame_level_changed_hook. (tui_remove_hooks): Detach and unset tui_before_prompt_observer and tui_normal_stop_observer. Remove reference to deprecated_selected_frame_level_changed_hook.
2015-06-30 19:56:49 +02:00
/* Dummy callback for deprecated_print_frame_info_listing_hook which is called
from print_frame_info. */
static void
Replace TUI's select_frame hook (PR tui/13378) The select_frame hook is used by TUI to update TUI's frame and register information following changes to the selected frame. The problem with this hook is that it gets called after every single frame change, even if the frame change is only temporary or internal. This is the primary cause of flickering and slowdown when running the inferior under TUI with conditional breakpoints set. Internal GDB events are the source of many calls to select_frame and these internal events are triggered frequently, especially when a few conditional breakpoints are set. This patch removes the select_frame hook altogether and instead makes the frame and register information get updated in two key places (using observers): after an inferior stops, and right before displaying a prompt. The latter hook covers the case when frame information must be updated following a call to "up", "down" or "frame", and the former covers the case when frame and register information must be updated after a call to "continue", "step", etc. or after the inferior stops in async execution mode. Together these hooks should cover all the cases when frame information ought to be refreshed (and when the relevant windows ought to be subsequently updated). The print_frame_info_listing hook is also effectively obsolete now, but it still must be set while the TUI is active because its caller print_frame_info will otherwise assume that the CLI is active, and will print the frame informaion accordingly. So this patch also sets the print_frame_info_listing hook to a dummy callback, in lieu of outright removing it yet. Effectively, with this patch, frame/PC changes that do not immediately precede an inferior-stop event or a prompt display event no longer cause TUI's frame and register information to be updated. And as a result of this change and of the previous change to tui_show_frame_info, the TUI is much more disciplined about updating the screen, and so the flicker as described in the PR is totally gone. gdb/ChangeLog: PR tui/13378 * frame.c (select_frame): Remove reference to deprecated_selected_frame_level_changed_hook. * frame.h (deprecated_selected_frame_level_changed_hook): Remove declaration. * stack.c (deprecated_selected_frame_level_changed_hook): Likewise. * tui/tui-hooks.c (tui_selected_frame_level_changed_hook): Rename to ... (tui_refresh_frame_and_register_information): ... this. Bail out if there is no stack. Don't update register information unless registers_too_p is true. (tui_print_frame_info_listing_hook): Rename to ... (tui_dummy_print_frame_info_listing_hook): ... this. (tui_before_prompt): New function. (tui_normal_stop): New function. (tui_before_prompt_observer): New observer. (tui_normal_stop_observer): New observer. (tui_install_hooks): Set deprecated_print_frame_info_listing_hook to tui_dummy_print_frame_info_listing_hook. Register tui_before_prompt_observer to call tui_before_prompt and tui_normal_stop_observer to call tui_normal_stop. Remove reference to deprecated_selected_frame_level_changed_hook. (tui_remove_hooks): Detach and unset tui_before_prompt_observer and tui_normal_stop_observer. Remove reference to deprecated_selected_frame_level_changed_hook.
2015-06-30 19:56:49 +02:00
tui_dummy_print_frame_info_listing_hook (struct symtab *s,
int line,
int stopline,
int noerror)
{
}
/* Perform all necessary cleanups regarding our module's inferior data
that is required after the inferior INF just exited. */
static void
tui_inferior_exit (struct inferior *inf)
{
/* Leave the SingleKey mode to make sure the gdb prompt is visible. */
tui_set_key_mode (TUI_COMMAND_MODE);
tui_show_frame_info (0);
tui_display_main ();
}
Replace TUI's select_frame hook (PR tui/13378) The select_frame hook is used by TUI to update TUI's frame and register information following changes to the selected frame. The problem with this hook is that it gets called after every single frame change, even if the frame change is only temporary or internal. This is the primary cause of flickering and slowdown when running the inferior under TUI with conditional breakpoints set. Internal GDB events are the source of many calls to select_frame and these internal events are triggered frequently, especially when a few conditional breakpoints are set. This patch removes the select_frame hook altogether and instead makes the frame and register information get updated in two key places (using observers): after an inferior stops, and right before displaying a prompt. The latter hook covers the case when frame information must be updated following a call to "up", "down" or "frame", and the former covers the case when frame and register information must be updated after a call to "continue", "step", etc. or after the inferior stops in async execution mode. Together these hooks should cover all the cases when frame information ought to be refreshed (and when the relevant windows ought to be subsequently updated). The print_frame_info_listing hook is also effectively obsolete now, but it still must be set while the TUI is active because its caller print_frame_info will otherwise assume that the CLI is active, and will print the frame informaion accordingly. So this patch also sets the print_frame_info_listing hook to a dummy callback, in lieu of outright removing it yet. Effectively, with this patch, frame/PC changes that do not immediately precede an inferior-stop event or a prompt display event no longer cause TUI's frame and register information to be updated. And as a result of this change and of the previous change to tui_show_frame_info, the TUI is much more disciplined about updating the screen, and so the flicker as described in the PR is totally gone. gdb/ChangeLog: PR tui/13378 * frame.c (select_frame): Remove reference to deprecated_selected_frame_level_changed_hook. * frame.h (deprecated_selected_frame_level_changed_hook): Remove declaration. * stack.c (deprecated_selected_frame_level_changed_hook): Likewise. * tui/tui-hooks.c (tui_selected_frame_level_changed_hook): Rename to ... (tui_refresh_frame_and_register_information): ... this. Bail out if there is no stack. Don't update register information unless registers_too_p is true. (tui_print_frame_info_listing_hook): Rename to ... (tui_dummy_print_frame_info_listing_hook): ... this. (tui_before_prompt): New function. (tui_normal_stop): New function. (tui_before_prompt_observer): New observer. (tui_normal_stop_observer): New observer. (tui_install_hooks): Set deprecated_print_frame_info_listing_hook to tui_dummy_print_frame_info_listing_hook. Register tui_before_prompt_observer to call tui_before_prompt and tui_normal_stop_observer to call tui_normal_stop. Remove reference to deprecated_selected_frame_level_changed_hook. (tui_remove_hooks): Detach and unset tui_before_prompt_observer and tui_normal_stop_observer. Remove reference to deprecated_selected_frame_level_changed_hook.
2015-06-30 19:56:49 +02:00
/* Observer for the before_prompt notification. */
static void
tui_before_prompt (const char *current_gdb_prompt)
{
/* This refresh is intended to catch changes to the selected frame following
a call to "up", "down" or "frame". As such we don't necessarily want to
TUI: Make sure to update registers if frame information has changed When I replaced TUI's frame_changed hook to fix PR tui/13378 I assumed that there's no reason to refresh register information following a call to "up", "down" or "frame". This assumption was made to fix the problem of refreshing frame information twice following a sync-execution normal stop (once in tui_normal_stop and then in tui_before_prompt) -- the second refresh removing any highlights made by the first. I was wrong about that -- GDB's snapshot of register information is per-frame, and when the frame changes, registers do too (most prominently the %rip and %rsp registers). So e.g. GDB 7.8 would highlight such register changes after invoking "up", "down" or "frame", and current GDB does not. To fix this regression, this patch adds another (sufficient) condition for refreshing register information: in tui_refresh_frame_and_register_information, always refresh register information if frame information has changed. This makes register information get refreshed following a call to "up", "down" or "frame" while still avoiding the "double refresh" issue following a normal stop. This condition may seem to obsolete the existing registers_too_p parameter, but it does not: following a normal stop, it is possible that registers may have changed while frame information had not. We could be on the exact same PC with different register values. The new condition would not catch such a case, but the registers_too_p condition will. So both conditions seem necessary (and either one is sufficient). gdb/ChangeLog: * tui/tui-hooks.c (tui_refresh_frame_and_register_information): Update commentary. Always refresh the registers when frame information has changed. * tui/tui-stack.c (tui_show_frame_info): Update commentary. Change return type to int. Return 1 if frame information has changed, 1 otherwise. (tui_before_prompt): Update commentary. * tui/tui-stack.h (tui_show_frame_info): Change return type to int.
2015-07-01 14:02:09 +02:00
refresh registers here unless the frame actually changed by one of these
commands. Registers will otherwise be refreshed after a normal stop or by
our tui_register_changed_hook. */
Replace TUI's select_frame hook (PR tui/13378) The select_frame hook is used by TUI to update TUI's frame and register information following changes to the selected frame. The problem with this hook is that it gets called after every single frame change, even if the frame change is only temporary or internal. This is the primary cause of flickering and slowdown when running the inferior under TUI with conditional breakpoints set. Internal GDB events are the source of many calls to select_frame and these internal events are triggered frequently, especially when a few conditional breakpoints are set. This patch removes the select_frame hook altogether and instead makes the frame and register information get updated in two key places (using observers): after an inferior stops, and right before displaying a prompt. The latter hook covers the case when frame information must be updated following a call to "up", "down" or "frame", and the former covers the case when frame and register information must be updated after a call to "continue", "step", etc. or after the inferior stops in async execution mode. Together these hooks should cover all the cases when frame information ought to be refreshed (and when the relevant windows ought to be subsequently updated). The print_frame_info_listing hook is also effectively obsolete now, but it still must be set while the TUI is active because its caller print_frame_info will otherwise assume that the CLI is active, and will print the frame informaion accordingly. So this patch also sets the print_frame_info_listing hook to a dummy callback, in lieu of outright removing it yet. Effectively, with this patch, frame/PC changes that do not immediately precede an inferior-stop event or a prompt display event no longer cause TUI's frame and register information to be updated. And as a result of this change and of the previous change to tui_show_frame_info, the TUI is much more disciplined about updating the screen, and so the flicker as described in the PR is totally gone. gdb/ChangeLog: PR tui/13378 * frame.c (select_frame): Remove reference to deprecated_selected_frame_level_changed_hook. * frame.h (deprecated_selected_frame_level_changed_hook): Remove declaration. * stack.c (deprecated_selected_frame_level_changed_hook): Likewise. * tui/tui-hooks.c (tui_selected_frame_level_changed_hook): Rename to ... (tui_refresh_frame_and_register_information): ... this. Bail out if there is no stack. Don't update register information unless registers_too_p is true. (tui_print_frame_info_listing_hook): Rename to ... (tui_dummy_print_frame_info_listing_hook): ... this. (tui_before_prompt): New function. (tui_normal_stop): New function. (tui_before_prompt_observer): New observer. (tui_normal_stop_observer): New observer. (tui_install_hooks): Set deprecated_print_frame_info_listing_hook to tui_dummy_print_frame_info_listing_hook. Register tui_before_prompt_observer to call tui_before_prompt and tui_normal_stop_observer to call tui_normal_stop. Remove reference to deprecated_selected_frame_level_changed_hook. (tui_remove_hooks): Detach and unset tui_before_prompt_observer and tui_normal_stop_observer. Remove reference to deprecated_selected_frame_level_changed_hook.
2015-06-30 19:56:49 +02:00
tui_refresh_frame_and_register_information (/*registers_too_p=*/0);
}
/* Observer for the normal_stop notification. */
static void
tui_normal_stop (struct bpstats *bs, int print_frame)
{
/* This refresh is intended to catch changes to the selected frame and to
registers following a normal stop. */
tui_refresh_frame_and_register_information (/*registers_too_p=*/1);
}
Convert observers to C++ This converts observers from using a special source-generating script to be plain C++. This version of the patch takes advantage of C++11 by using std::function and variadic templates; incorporates Pedro's patches; and renames the header file to "observable.h" (this change eliminates the need for a clean rebuild). Note that Pedro's patches used a template lambda in tui-hooks.c, but this failed to compile on some buildbot instances (presumably due to differing C++ versions); I replaced this with an ordinary template function. Regression tested on the buildbot. gdb/ChangeLog 2018-03-19 Pedro Alves <palves@redhat.com> Tom Tromey <tom@tromey.com> * unittests/observable-selftests.c: New file. * common/observable.h: New file. * observable.h: New file. * ada-lang.c, ada-tasks.c, agent.c, aix-thread.c, annotate.c, arm-tdep.c, auto-load.c, auxv.c, break-catch-syscall.c, breakpoint.c, bsd-uthread.c, cli/cli-interp.c, cli/cli-setshow.c, corefile.c, dummy-frame.c, event-loop.c, event-top.c, exec.c, extension.c, frame.c, gdbarch.c, guile/scm-breakpoint.c, infcall.c, infcmd.c, inferior.c, inflow.c, infrun.c, jit.c, linux-tdep.c, linux-thread-db.c, m68klinux-tdep.c, mi/mi-cmd-break.c, mi/mi-interp.c, mi/mi-main.c, objfiles.c, ppc-linux-nat.c, ppc-linux-tdep.c, printcmd.c, procfs.c, python/py-breakpoint.c, python/py-finishbreakpoint.c, python/py-inferior.c, python/py-unwind.c, ravenscar-thread.c, record-btrace.c, record-full.c, record.c, regcache.c, remote.c, riscv-tdep.c, sol-thread.c, solib-aix.c, solib-spu.c, solib.c, spu-multiarch.c, spu-tdep.c, stack.c, symfile-mem.c, symfile.c, symtab.c, thread.c, top.c, tracepoint.c, tui/tui-hooks.c, tui/tui-interp.c, valops.c: Update all users. * tui/tui-hooks.c (tui_bp_created_observer) (tui_bp_deleted_observer, tui_bp_modified_observer) (tui_inferior_exit_observer, tui_before_prompt_observer) (tui_normal_stop_observer, tui_register_changed_observer): Remove. (tui_observers_token): New global. (attach_or_detach, tui_attach_detach_observers): New functions. (tui_install_hooks, tui_remove_hooks): Use tui_attach_detach_observers. * record-btrace.c (record_btrace_thread_observer): Remove. (record_btrace_thread_observer_token): New global. * observer.sh: Remove. * observer.c: Rename to observable.c. * observable.c (namespace gdb_observers): Define new objects. (observer_debug): Move into gdb_observers namespace. (struct observer, struct observer_list, xalloc_observer_list_node) (xfree_observer_list_node, generic_observer_attach) (generic_observer_detach, generic_observer_notify): Remove. (_initialize_observer): Update. Don't include observer.inc. * Makefile.in (generated_files): Remove observer.h, observer.inc. (clean mostlyclean): Likewise. (observer.h, observer.inc): Remove targets. (SUBDIR_UNITTESTS_SRCS): Add observable-selftests.c. (COMMON_SFILES): Use observable.c, not observer.c. * .gitignore: Remove observer.h. gdb/doc/ChangeLog 2018-03-19 Tom Tromey <tom@tromey.com> * observer.texi: Remove. gdb/testsuite/ChangeLog 2018-03-19 Tom Tromey <tom@tromey.com> * gdb.gdb/observer.exp: Remove.
2016-10-02 18:50:20 +02:00
/* Token associated with observers registered while TUI hooks are
installed. */
static const gdb::observers::token tui_observers_token;
/* Attach or detach a single observer, according to ATTACH. */
template<typename T>
static void
attach_or_detach (T &observable, typename T::func_type func, bool attach)
{
if (attach)
observable.attach (func, tui_observers_token);
else
observable.detach (tui_observers_token);
}
/* Attach or detach TUI observers, according to ATTACH. */
static void
tui_attach_detach_observers (bool attach)
{
attach_or_detach (gdb::observers::breakpoint_created,
tui_event_create_breakpoint, attach);
attach_or_detach (gdb::observers::breakpoint_deleted,
tui_event_delete_breakpoint, attach);
attach_or_detach (gdb::observers::breakpoint_modified,
tui_event_modify_breakpoint, attach);
attach_or_detach (gdb::observers::inferior_exit,
tui_inferior_exit, attach);
attach_or_detach (gdb::observers::before_prompt,
tui_before_prompt, attach);
attach_or_detach (gdb::observers::normal_stop,
tui_normal_stop, attach);
attach_or_detach (gdb::observers::register_changed,
tui_register_changed, attach);
}
gdb: * tui/tui-hooks.c: Include observer.h. (tui_event_default, tui_old_event_hooks, tui_event_hooks): Remove. (tui_bp_created_observer, tui_bp_deleted_observer, tui_bp_modified_observer): New globals. (tui_install_hooks): Use observers, not events. (tui_remove_hooks): Likewise. * mi/mi-cmd-break.c: Include observer.h, not gdb-events.h. (mi_breakpoint_observers_installed, mi_can_breakpoint_notify): New globals. (breakpoint_notify): Check mi_can_breakpoint_notify. (breakpoint_hooks): Remove. (mi_cmd_break_insert): Attach observers. Don't use events. * tracepoint.c: Include observer.h, not gdb-events.h. (tracepoint_operation, trace_pass_command): Notify observer. * interps.c: Don't include gdb-events.h. (clear_interpreter_hooks): Don't call clear_gdb_event_hooks. * gdbarch.c: Rebuild. * gdbarch.sh: Emit include for observer.h, not gdb-events.h. (deprecated_current_gdbarch_select_hack): Notify observer. * breakpoint.h: Don't include gdb-events.h. * breakpoint.c: Don't include gdb-events.h. (condition_command): Notify observer. (commands_command): Likewise. (commands_from_control_command): Likewise. (mention, delete_breakpoint, set_ignore_count): Likewise. (disable_breakpoint, do_enable_breakpoint): Likewise. * Makefile.in (gdb_events_h): Remove. (breakpoint_h): Update. (COMMON_OBS): Remove gdb-events.o. (gdb-events.o): Remove. (breakpoint.o, gdbarch.o, interps.o, tracepoint.o, gdbtk-bp.o, gdbtk-hooks.o, mi-cmd-break.o, tui-hooks.o): Update. * gdb-events.c: Remove. * gdb-events.h: Remove. * gdb-events.sh: Remove. gdb/doc: * observer.texi (GDB Observers): Document new observers: breakpoint_created, breakpoint_deleted, breakpoint_modified, tracepoint_created, tracepoint_deleted, tracepoint_modified, architecture_changed. gdb/gdbtk: * generic/gdbtk-hooks.c: Include observer.h, not gdb-events.h. (gdbtk_add_hooks): Use observers, not events. (gdbtk_architecture_changed): Add argument, for observer. * generic/gdbtk-bp.c: Include observer.h. (gdb_set_bp): Notify observer. (gdb_set_bp_addr): Likewise.
2008-07-25 18:12:03 +02:00
/* Install the TUI specific hooks. */
void
tui_install_hooks (void)
{
Replace TUI's select_frame hook (PR tui/13378) The select_frame hook is used by TUI to update TUI's frame and register information following changes to the selected frame. The problem with this hook is that it gets called after every single frame change, even if the frame change is only temporary or internal. This is the primary cause of flickering and slowdown when running the inferior under TUI with conditional breakpoints set. Internal GDB events are the source of many calls to select_frame and these internal events are triggered frequently, especially when a few conditional breakpoints are set. This patch removes the select_frame hook altogether and instead makes the frame and register information get updated in two key places (using observers): after an inferior stops, and right before displaying a prompt. The latter hook covers the case when frame information must be updated following a call to "up", "down" or "frame", and the former covers the case when frame and register information must be updated after a call to "continue", "step", etc. or after the inferior stops in async execution mode. Together these hooks should cover all the cases when frame information ought to be refreshed (and when the relevant windows ought to be subsequently updated). The print_frame_info_listing hook is also effectively obsolete now, but it still must be set while the TUI is active because its caller print_frame_info will otherwise assume that the CLI is active, and will print the frame informaion accordingly. So this patch also sets the print_frame_info_listing hook to a dummy callback, in lieu of outright removing it yet. Effectively, with this patch, frame/PC changes that do not immediately precede an inferior-stop event or a prompt display event no longer cause TUI's frame and register information to be updated. And as a result of this change and of the previous change to tui_show_frame_info, the TUI is much more disciplined about updating the screen, and so the flicker as described in the PR is totally gone. gdb/ChangeLog: PR tui/13378 * frame.c (select_frame): Remove reference to deprecated_selected_frame_level_changed_hook. * frame.h (deprecated_selected_frame_level_changed_hook): Remove declaration. * stack.c (deprecated_selected_frame_level_changed_hook): Likewise. * tui/tui-hooks.c (tui_selected_frame_level_changed_hook): Rename to ... (tui_refresh_frame_and_register_information): ... this. Bail out if there is no stack. Don't update register information unless registers_too_p is true. (tui_print_frame_info_listing_hook): Rename to ... (tui_dummy_print_frame_info_listing_hook): ... this. (tui_before_prompt): New function. (tui_normal_stop): New function. (tui_before_prompt_observer): New observer. (tui_normal_stop_observer): New observer. (tui_install_hooks): Set deprecated_print_frame_info_listing_hook to tui_dummy_print_frame_info_listing_hook. Register tui_before_prompt_observer to call tui_before_prompt and tui_normal_stop_observer to call tui_normal_stop. Remove reference to deprecated_selected_frame_level_changed_hook. (tui_remove_hooks): Detach and unset tui_before_prompt_observer and tui_normal_stop_observer. Remove reference to deprecated_selected_frame_level_changed_hook.
2015-06-30 19:56:49 +02:00
/* If this hook is not set to something then print_frame_info will
assume that the CLI, not the TUI, is active, and will print the frame info
for us in such a way that we are not prepared to handle. This hook is
otherwise effectively obsolete. */
deprecated_print_frame_info_listing_hook
Replace TUI's select_frame hook (PR tui/13378) The select_frame hook is used by TUI to update TUI's frame and register information following changes to the selected frame. The problem with this hook is that it gets called after every single frame change, even if the frame change is only temporary or internal. This is the primary cause of flickering and slowdown when running the inferior under TUI with conditional breakpoints set. Internal GDB events are the source of many calls to select_frame and these internal events are triggered frequently, especially when a few conditional breakpoints are set. This patch removes the select_frame hook altogether and instead makes the frame and register information get updated in two key places (using observers): after an inferior stops, and right before displaying a prompt. The latter hook covers the case when frame information must be updated following a call to "up", "down" or "frame", and the former covers the case when frame and register information must be updated after a call to "continue", "step", etc. or after the inferior stops in async execution mode. Together these hooks should cover all the cases when frame information ought to be refreshed (and when the relevant windows ought to be subsequently updated). The print_frame_info_listing hook is also effectively obsolete now, but it still must be set while the TUI is active because its caller print_frame_info will otherwise assume that the CLI is active, and will print the frame informaion accordingly. So this patch also sets the print_frame_info_listing hook to a dummy callback, in lieu of outright removing it yet. Effectively, with this patch, frame/PC changes that do not immediately precede an inferior-stop event or a prompt display event no longer cause TUI's frame and register information to be updated. And as a result of this change and of the previous change to tui_show_frame_info, the TUI is much more disciplined about updating the screen, and so the flicker as described in the PR is totally gone. gdb/ChangeLog: PR tui/13378 * frame.c (select_frame): Remove reference to deprecated_selected_frame_level_changed_hook. * frame.h (deprecated_selected_frame_level_changed_hook): Remove declaration. * stack.c (deprecated_selected_frame_level_changed_hook): Likewise. * tui/tui-hooks.c (tui_selected_frame_level_changed_hook): Rename to ... (tui_refresh_frame_and_register_information): ... this. Bail out if there is no stack. Don't update register information unless registers_too_p is true. (tui_print_frame_info_listing_hook): Rename to ... (tui_dummy_print_frame_info_listing_hook): ... this. (tui_before_prompt): New function. (tui_normal_stop): New function. (tui_before_prompt_observer): New observer. (tui_normal_stop_observer): New observer. (tui_install_hooks): Set deprecated_print_frame_info_listing_hook to tui_dummy_print_frame_info_listing_hook. Register tui_before_prompt_observer to call tui_before_prompt and tui_normal_stop_observer to call tui_normal_stop. Remove reference to deprecated_selected_frame_level_changed_hook. (tui_remove_hooks): Detach and unset tui_before_prompt_observer and tui_normal_stop_observer. Remove reference to deprecated_selected_frame_level_changed_hook.
2015-06-30 19:56:49 +02:00
= tui_dummy_print_frame_info_listing_hook;
/* Install the event hooks. */
Convert observers to C++ This converts observers from using a special source-generating script to be plain C++. This version of the patch takes advantage of C++11 by using std::function and variadic templates; incorporates Pedro's patches; and renames the header file to "observable.h" (this change eliminates the need for a clean rebuild). Note that Pedro's patches used a template lambda in tui-hooks.c, but this failed to compile on some buildbot instances (presumably due to differing C++ versions); I replaced this with an ordinary template function. Regression tested on the buildbot. gdb/ChangeLog 2018-03-19 Pedro Alves <palves@redhat.com> Tom Tromey <tom@tromey.com> * unittests/observable-selftests.c: New file. * common/observable.h: New file. * observable.h: New file. * ada-lang.c, ada-tasks.c, agent.c, aix-thread.c, annotate.c, arm-tdep.c, auto-load.c, auxv.c, break-catch-syscall.c, breakpoint.c, bsd-uthread.c, cli/cli-interp.c, cli/cli-setshow.c, corefile.c, dummy-frame.c, event-loop.c, event-top.c, exec.c, extension.c, frame.c, gdbarch.c, guile/scm-breakpoint.c, infcall.c, infcmd.c, inferior.c, inflow.c, infrun.c, jit.c, linux-tdep.c, linux-thread-db.c, m68klinux-tdep.c, mi/mi-cmd-break.c, mi/mi-interp.c, mi/mi-main.c, objfiles.c, ppc-linux-nat.c, ppc-linux-tdep.c, printcmd.c, procfs.c, python/py-breakpoint.c, python/py-finishbreakpoint.c, python/py-inferior.c, python/py-unwind.c, ravenscar-thread.c, record-btrace.c, record-full.c, record.c, regcache.c, remote.c, riscv-tdep.c, sol-thread.c, solib-aix.c, solib-spu.c, solib.c, spu-multiarch.c, spu-tdep.c, stack.c, symfile-mem.c, symfile.c, symtab.c, thread.c, top.c, tracepoint.c, tui/tui-hooks.c, tui/tui-interp.c, valops.c: Update all users. * tui/tui-hooks.c (tui_bp_created_observer) (tui_bp_deleted_observer, tui_bp_modified_observer) (tui_inferior_exit_observer, tui_before_prompt_observer) (tui_normal_stop_observer, tui_register_changed_observer): Remove. (tui_observers_token): New global. (attach_or_detach, tui_attach_detach_observers): New functions. (tui_install_hooks, tui_remove_hooks): Use tui_attach_detach_observers. * record-btrace.c (record_btrace_thread_observer): Remove. (record_btrace_thread_observer_token): New global. * observer.sh: Remove. * observer.c: Rename to observable.c. * observable.c (namespace gdb_observers): Define new objects. (observer_debug): Move into gdb_observers namespace. (struct observer, struct observer_list, xalloc_observer_list_node) (xfree_observer_list_node, generic_observer_attach) (generic_observer_detach, generic_observer_notify): Remove. (_initialize_observer): Update. Don't include observer.inc. * Makefile.in (generated_files): Remove observer.h, observer.inc. (clean mostlyclean): Likewise. (observer.h, observer.inc): Remove targets. (SUBDIR_UNITTESTS_SRCS): Add observable-selftests.c. (COMMON_SFILES): Use observable.c, not observer.c. * .gitignore: Remove observer.h. gdb/doc/ChangeLog 2018-03-19 Tom Tromey <tom@tromey.com> * observer.texi: Remove. gdb/testsuite/ChangeLog 2018-03-19 Tom Tromey <tom@tromey.com> * gdb.gdb/observer.exp: Remove.
2016-10-02 18:50:20 +02:00
tui_attach_detach_observers (true);
}
/* Remove the TUI specific hooks. */
void
tui_remove_hooks (void)
{
2004-04-21 Andrew Cagney <cagney@redhat.com> * annotate.h (deprecated_annotate_starting_hook) (deprecated_annotate_stopped_hook) (deprecated_annotate_exited_hook) (deprecated_annotate_signal_hook) (deprecated_annotate_signalled_hook): Deprecate. * tracepoint.h (deprecated_create_tracepoint_hook) (deprecated_delete_tracepoint_hook) (deprecated_modify_tracepoint_hook) (deprecated_trace_find_hook) (deprecated_trace_start_stop_hook): Deprecate. * target.h (deprecated_target_new_objfile_hook): Deprecate. * remote.h (deprecated_target_resume_hook) (deprecated_target_wait_loop_hook): Deprecate. * gdbcore.h (deprecated_exec_file_display_hook) (deprecated_file_changed_hook): Deprecate. * frame.h (deprecated_selected_frame_level_changed_hook): Deprecate. * defs.h (deprecated_modify_breakpoint_hook) (deprecated_command_loop_hook, deprecated_show_load_progress) (deprecated_print_frame_info_listing_hook) (deprecated_query_hook, deprecated_warning_hook) (deprecated_flush_hook, deprecated_create_breakpoint_hook) (deprecated_delete_breakpoint_hook) (deprecated_interactive_hook, deprecated_registers_changed_hook) (deprecated_readline_begin_hook, deprecated_readline_hook) (deprecated_readline_end_hook, deprecated_register_changed_hook) (deprecated_memory_changed_hook, deprecated_init_ui_hook) (deprecated_context_hook, deprecated_target_wait_hook) (deprecated_attach_hook, deprecated_detach_hook) (deprecated_call_command_hook, deprecated_set_hook) (deprecated_error_hook, deprecated_error_begin_hook) (deprecated_ui_load_progress_hook): Deprecate. * valops.c, uw-thread.c, utils.c, tui/tui-io.c: Update. * tui/tui-hooks.c, tracepoint.c, top.c, thread-db.c: Update. * target.c, symfile.c, stack.c, sol-thread.c, rs6000-nat.c: Update. * remote.c, remote-mips.c, regcache.c, mi/mi-interp.c: Update. * main.c, interps.c, infcmd.c, hpux-thread.c, frame.c: Update. * exec.c, dsrec.c, d10v-tdep.c, corefile.c, complaints.c: Update. * cli/cli-script.c, cli/cli-setshow.c, breakpoint.c: Update. * annotate.c, aix-thread.c: Update.
2004-04-22 01:52:21 +02:00
deprecated_print_frame_info_listing_hook = 0;
deprecated_query_hook = 0;
Convert observers to C++ This converts observers from using a special source-generating script to be plain C++. This version of the patch takes advantage of C++11 by using std::function and variadic templates; incorporates Pedro's patches; and renames the header file to "observable.h" (this change eliminates the need for a clean rebuild). Note that Pedro's patches used a template lambda in tui-hooks.c, but this failed to compile on some buildbot instances (presumably due to differing C++ versions); I replaced this with an ordinary template function. Regression tested on the buildbot. gdb/ChangeLog 2018-03-19 Pedro Alves <palves@redhat.com> Tom Tromey <tom@tromey.com> * unittests/observable-selftests.c: New file. * common/observable.h: New file. * observable.h: New file. * ada-lang.c, ada-tasks.c, agent.c, aix-thread.c, annotate.c, arm-tdep.c, auto-load.c, auxv.c, break-catch-syscall.c, breakpoint.c, bsd-uthread.c, cli/cli-interp.c, cli/cli-setshow.c, corefile.c, dummy-frame.c, event-loop.c, event-top.c, exec.c, extension.c, frame.c, gdbarch.c, guile/scm-breakpoint.c, infcall.c, infcmd.c, inferior.c, inflow.c, infrun.c, jit.c, linux-tdep.c, linux-thread-db.c, m68klinux-tdep.c, mi/mi-cmd-break.c, mi/mi-interp.c, mi/mi-main.c, objfiles.c, ppc-linux-nat.c, ppc-linux-tdep.c, printcmd.c, procfs.c, python/py-breakpoint.c, python/py-finishbreakpoint.c, python/py-inferior.c, python/py-unwind.c, ravenscar-thread.c, record-btrace.c, record-full.c, record.c, regcache.c, remote.c, riscv-tdep.c, sol-thread.c, solib-aix.c, solib-spu.c, solib.c, spu-multiarch.c, spu-tdep.c, stack.c, symfile-mem.c, symfile.c, symtab.c, thread.c, top.c, tracepoint.c, tui/tui-hooks.c, tui/tui-interp.c, valops.c: Update all users. * tui/tui-hooks.c (tui_bp_created_observer) (tui_bp_deleted_observer, tui_bp_modified_observer) (tui_inferior_exit_observer, tui_before_prompt_observer) (tui_normal_stop_observer, tui_register_changed_observer): Remove. (tui_observers_token): New global. (attach_or_detach, tui_attach_detach_observers): New functions. (tui_install_hooks, tui_remove_hooks): Use tui_attach_detach_observers. * record-btrace.c (record_btrace_thread_observer): Remove. (record_btrace_thread_observer_token): New global. * observer.sh: Remove. * observer.c: Rename to observable.c. * observable.c (namespace gdb_observers): Define new objects. (observer_debug): Move into gdb_observers namespace. (struct observer, struct observer_list, xalloc_observer_list_node) (xfree_observer_list_node, generic_observer_attach) (generic_observer_detach, generic_observer_notify): Remove. (_initialize_observer): Update. Don't include observer.inc. * Makefile.in (generated_files): Remove observer.h, observer.inc. (clean mostlyclean): Likewise. (observer.h, observer.inc): Remove targets. (SUBDIR_UNITTESTS_SRCS): Add observable-selftests.c. (COMMON_SFILES): Use observable.c, not observer.c. * .gitignore: Remove observer.h. gdb/doc/ChangeLog 2018-03-19 Tom Tromey <tom@tromey.com> * observer.texi: Remove. gdb/testsuite/ChangeLog 2018-03-19 Tom Tromey <tom@tromey.com> * gdb.gdb/observer.exp: Remove.
2016-10-02 18:50:20 +02:00
gdb: * tui/tui-hooks.c: Include observer.h. (tui_event_default, tui_old_event_hooks, tui_event_hooks): Remove. (tui_bp_created_observer, tui_bp_deleted_observer, tui_bp_modified_observer): New globals. (tui_install_hooks): Use observers, not events. (tui_remove_hooks): Likewise. * mi/mi-cmd-break.c: Include observer.h, not gdb-events.h. (mi_breakpoint_observers_installed, mi_can_breakpoint_notify): New globals. (breakpoint_notify): Check mi_can_breakpoint_notify. (breakpoint_hooks): Remove. (mi_cmd_break_insert): Attach observers. Don't use events. * tracepoint.c: Include observer.h, not gdb-events.h. (tracepoint_operation, trace_pass_command): Notify observer. * interps.c: Don't include gdb-events.h. (clear_interpreter_hooks): Don't call clear_gdb_event_hooks. * gdbarch.c: Rebuild. * gdbarch.sh: Emit include for observer.h, not gdb-events.h. (deprecated_current_gdbarch_select_hack): Notify observer. * breakpoint.h: Don't include gdb-events.h. * breakpoint.c: Don't include gdb-events.h. (condition_command): Notify observer. (commands_command): Likewise. (commands_from_control_command): Likewise. (mention, delete_breakpoint, set_ignore_count): Likewise. (disable_breakpoint, do_enable_breakpoint): Likewise. * Makefile.in (gdb_events_h): Remove. (breakpoint_h): Update. (COMMON_OBS): Remove gdb-events.o. (gdb-events.o): Remove. (breakpoint.o, gdbarch.o, interps.o, tracepoint.o, gdbtk-bp.o, gdbtk-hooks.o, mi-cmd-break.o, tui-hooks.o): Update. * gdb-events.c: Remove. * gdb-events.h: Remove. * gdb-events.sh: Remove. gdb/doc: * observer.texi (GDB Observers): Document new observers: breakpoint_created, breakpoint_deleted, breakpoint_modified, tracepoint_created, tracepoint_deleted, tracepoint_modified, architecture_changed. gdb/gdbtk: * generic/gdbtk-hooks.c: Include observer.h, not gdb-events.h. (gdbtk_add_hooks): Use observers, not events. (gdbtk_architecture_changed): Add argument, for observer. * generic/gdbtk-bp.c: Include observer.h. (gdb_set_bp): Notify observer. (gdb_set_bp_addr): Likewise.
2008-07-25 18:12:03 +02:00
/* Remove our observers. */
Convert observers to C++ This converts observers from using a special source-generating script to be plain C++. This version of the patch takes advantage of C++11 by using std::function and variadic templates; incorporates Pedro's patches; and renames the header file to "observable.h" (this change eliminates the need for a clean rebuild). Note that Pedro's patches used a template lambda in tui-hooks.c, but this failed to compile on some buildbot instances (presumably due to differing C++ versions); I replaced this with an ordinary template function. Regression tested on the buildbot. gdb/ChangeLog 2018-03-19 Pedro Alves <palves@redhat.com> Tom Tromey <tom@tromey.com> * unittests/observable-selftests.c: New file. * common/observable.h: New file. * observable.h: New file. * ada-lang.c, ada-tasks.c, agent.c, aix-thread.c, annotate.c, arm-tdep.c, auto-load.c, auxv.c, break-catch-syscall.c, breakpoint.c, bsd-uthread.c, cli/cli-interp.c, cli/cli-setshow.c, corefile.c, dummy-frame.c, event-loop.c, event-top.c, exec.c, extension.c, frame.c, gdbarch.c, guile/scm-breakpoint.c, infcall.c, infcmd.c, inferior.c, inflow.c, infrun.c, jit.c, linux-tdep.c, linux-thread-db.c, m68klinux-tdep.c, mi/mi-cmd-break.c, mi/mi-interp.c, mi/mi-main.c, objfiles.c, ppc-linux-nat.c, ppc-linux-tdep.c, printcmd.c, procfs.c, python/py-breakpoint.c, python/py-finishbreakpoint.c, python/py-inferior.c, python/py-unwind.c, ravenscar-thread.c, record-btrace.c, record-full.c, record.c, regcache.c, remote.c, riscv-tdep.c, sol-thread.c, solib-aix.c, solib-spu.c, solib.c, spu-multiarch.c, spu-tdep.c, stack.c, symfile-mem.c, symfile.c, symtab.c, thread.c, top.c, tracepoint.c, tui/tui-hooks.c, tui/tui-interp.c, valops.c: Update all users. * tui/tui-hooks.c (tui_bp_created_observer) (tui_bp_deleted_observer, tui_bp_modified_observer) (tui_inferior_exit_observer, tui_before_prompt_observer) (tui_normal_stop_observer, tui_register_changed_observer): Remove. (tui_observers_token): New global. (attach_or_detach, tui_attach_detach_observers): New functions. (tui_install_hooks, tui_remove_hooks): Use tui_attach_detach_observers. * record-btrace.c (record_btrace_thread_observer): Remove. (record_btrace_thread_observer_token): New global. * observer.sh: Remove. * observer.c: Rename to observable.c. * observable.c (namespace gdb_observers): Define new objects. (observer_debug): Move into gdb_observers namespace. (struct observer, struct observer_list, xalloc_observer_list_node) (xfree_observer_list_node, generic_observer_attach) (generic_observer_detach, generic_observer_notify): Remove. (_initialize_observer): Update. Don't include observer.inc. * Makefile.in (generated_files): Remove observer.h, observer.inc. (clean mostlyclean): Likewise. (observer.h, observer.inc): Remove targets. (SUBDIR_UNITTESTS_SRCS): Add observable-selftests.c. (COMMON_SFILES): Use observable.c, not observer.c. * .gitignore: Remove observer.h. gdb/doc/ChangeLog 2018-03-19 Tom Tromey <tom@tromey.com> * observer.texi: Remove. gdb/testsuite/ChangeLog 2018-03-19 Tom Tromey <tom@tromey.com> * gdb.gdb/observer.exp: Remove.
2016-10-02 18:50:20 +02:00
tui_attach_detach_observers (false);
}
void
_initialize_tui_hooks (void)
{
/* Install the permanent hooks. */
Convert observers to C++ This converts observers from using a special source-generating script to be plain C++. This version of the patch takes advantage of C++11 by using std::function and variadic templates; incorporates Pedro's patches; and renames the header file to "observable.h" (this change eliminates the need for a clean rebuild). Note that Pedro's patches used a template lambda in tui-hooks.c, but this failed to compile on some buildbot instances (presumably due to differing C++ versions); I replaced this with an ordinary template function. Regression tested on the buildbot. gdb/ChangeLog 2018-03-19 Pedro Alves <palves@redhat.com> Tom Tromey <tom@tromey.com> * unittests/observable-selftests.c: New file. * common/observable.h: New file. * observable.h: New file. * ada-lang.c, ada-tasks.c, agent.c, aix-thread.c, annotate.c, arm-tdep.c, auto-load.c, auxv.c, break-catch-syscall.c, breakpoint.c, bsd-uthread.c, cli/cli-interp.c, cli/cli-setshow.c, corefile.c, dummy-frame.c, event-loop.c, event-top.c, exec.c, extension.c, frame.c, gdbarch.c, guile/scm-breakpoint.c, infcall.c, infcmd.c, inferior.c, inflow.c, infrun.c, jit.c, linux-tdep.c, linux-thread-db.c, m68klinux-tdep.c, mi/mi-cmd-break.c, mi/mi-interp.c, mi/mi-main.c, objfiles.c, ppc-linux-nat.c, ppc-linux-tdep.c, printcmd.c, procfs.c, python/py-breakpoint.c, python/py-finishbreakpoint.c, python/py-inferior.c, python/py-unwind.c, ravenscar-thread.c, record-btrace.c, record-full.c, record.c, regcache.c, remote.c, riscv-tdep.c, sol-thread.c, solib-aix.c, solib-spu.c, solib.c, spu-multiarch.c, spu-tdep.c, stack.c, symfile-mem.c, symfile.c, symtab.c, thread.c, top.c, tracepoint.c, tui/tui-hooks.c, tui/tui-interp.c, valops.c: Update all users. * tui/tui-hooks.c (tui_bp_created_observer) (tui_bp_deleted_observer, tui_bp_modified_observer) (tui_inferior_exit_observer, tui_before_prompt_observer) (tui_normal_stop_observer, tui_register_changed_observer): Remove. (tui_observers_token): New global. (attach_or_detach, tui_attach_detach_observers): New functions. (tui_install_hooks, tui_remove_hooks): Use tui_attach_detach_observers. * record-btrace.c (record_btrace_thread_observer): Remove. (record_btrace_thread_observer_token): New global. * observer.sh: Remove. * observer.c: Rename to observable.c. * observable.c (namespace gdb_observers): Define new objects. (observer_debug): Move into gdb_observers namespace. (struct observer, struct observer_list, xalloc_observer_list_node) (xfree_observer_list_node, generic_observer_attach) (generic_observer_detach, generic_observer_notify): Remove. (_initialize_observer): Update. Don't include observer.inc. * Makefile.in (generated_files): Remove observer.h, observer.inc. (clean mostlyclean): Likewise. (observer.h, observer.inc): Remove targets. (SUBDIR_UNITTESTS_SRCS): Add observable-selftests.c. (COMMON_SFILES): Use observable.c, not observer.c. * .gitignore: Remove observer.h. gdb/doc/ChangeLog 2018-03-19 Tom Tromey <tom@tromey.com> * observer.texi: Remove. gdb/testsuite/ChangeLog 2018-03-19 Tom Tromey <tom@tromey.com> * gdb.gdb/observer.exp: Remove.
2016-10-02 18:50:20 +02:00
gdb::observers::new_objfile.attach (tui_new_objfile_hook);
}