This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 3/3] Replace TUI's select_frame hook (PR tui/13378)


Actually, we should not call tui_show_frame_info(NULL) when there are no
stack frames, because doing so empties the source window after invoking
"continue&". That was a last-minute change with no justification anyway.

Here is a revised patch with a much smaller diffstat.

gdb/ChangeLog:

	* 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.
	(tui_before_prompt): New function.
	(tui_before_prompt_observer): New observer.
	(tui_install_hooks): Register tui_before_prompt_observer to
	call tui_before_prompt.  Remove reference to
	deprecated_selected_frame_level_changed_hook.
	(tui_remove_hooks): Detach and unset tui_before_prompt_observer.
	Remove reference to
	deprecated_selected_frame_level_changed_hook.
	* tui/tui-hooks.h (tui_refresh_frame_and_register_information):
	Export.
	* tui/tui-interp.c: Include "tui/tui-hooks.h".
	(tui_on_sync_execution_done): Call
	tui_refresh_frame_and_register_information if tui_active.
---
 gdb/frame.c          |  2 --
 gdb/frame.h          |  2 --
 gdb/stack.c          |  2 --
 gdb/tui/tui-hooks.c  | 28 ++++++++++++++++++----------
 gdb/tui/tui-hooks.h  |  5 +++++
 gdb/tui/tui-interp.c |  4 ++++
 6 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/gdb/frame.c b/gdb/frame.c
index b3cbf23..da5bfb9 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1576,8 +1576,6 @@ select_frame (struct frame_info *fi)
   selected_frame = fi;
   /* NOTE: cagney/2002-05-04: FI can be NULL.  This occurs when the
      frame is being invalidated.  */
-  if (deprecated_selected_frame_level_changed_hook)
-    deprecated_selected_frame_level_changed_hook (frame_relative_level (fi));
 
   /* FIXME: kseitz/2002-08-28: It would be nice to call
      selected_frame_level_changed_event() right here, but due to limitations
diff --git a/gdb/frame.h b/gdb/frame.h
index 53a93e0..be64c57 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -763,8 +763,6 @@ extern void args_info (char *, int);
 
 extern void locals_info (char *, int);
 
-extern void (*deprecated_selected_frame_level_changed_hook) (int);
-
 extern void return_command (char *, int);
 
 /* Set FRAME's unwinder temporarily, so that we can call a sniffer.
diff --git a/gdb/stack.c b/gdb/stack.c
index eea575a..39803d9 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -52,8 +52,6 @@
 #include "symfile.h"
 #include "extension.h"
 
-void (*deprecated_selected_frame_level_changed_hook) (int);
-
 /* The possible choices of "set print frame-arguments", and the value
    of this setting.  */
 
diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index 8d84551..16c177b 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -119,18 +119,16 @@ tui_about_to_proceed (void)
   tui_target_has_run = 1;
 }
 
-/* The selected frame has changed.  This is happens after a target
-   stop or when the user explicitly changes the frame
-   (up/down/thread/...).  */
-static void
-tui_selected_frame_level_changed_hook (int level)
+/* See tui-hooks.h.  */
+
+void
+tui_refresh_frame_and_register_information (void)
 {
   struct frame_info *fi;
   CORE_ADDR pc;
   struct cleanup *old_chain;
 
-  /* Negative level means that the selected frame was cleared.  */
-  if (level < 0)
+  if (!has_stack_frames ())
     return;
 
   old_chain = make_cleanup_restore_target_terminal ();
@@ -191,19 +189,26 @@ tui_inferior_exit (struct inferior *inf)
   tui_display_main ();
 }
 
+/* Observer for the before_prompt notification.  */
+
+static void
+tui_before_prompt (const char *current_gdb_prompt)
+{
+  tui_refresh_frame_and_register_information ();
+}
+
 /* Observers created when installing TUI hooks.  */
 static struct observer *tui_bp_created_observer;
 static struct observer *tui_bp_deleted_observer;
 static struct observer *tui_bp_modified_observer;
 static struct observer *tui_inferior_exit_observer;
 static struct observer *tui_about_to_proceed_observer;
+static struct observer *tui_before_prompt_observer;
 
 /* Install the TUI specific hooks.  */
 void
 tui_install_hooks (void)
 {
-  deprecated_selected_frame_level_changed_hook
-    = tui_selected_frame_level_changed_hook;
   deprecated_print_frame_info_listing_hook
     = tui_print_frame_info_listing_hook;
 
@@ -218,6 +223,8 @@ tui_install_hooks (void)
     = observer_attach_inferior_exit (tui_inferior_exit);
   tui_about_to_proceed_observer
     = observer_attach_about_to_proceed (tui_about_to_proceed);
+  tui_before_prompt_observer
+    = observer_attach_before_prompt (tui_before_prompt);
 
   deprecated_register_changed_hook = tui_register_changed_hook;
 }
@@ -226,7 +233,6 @@ tui_install_hooks (void)
 void
 tui_remove_hooks (void)
 {
-  deprecated_selected_frame_level_changed_hook = 0;
   deprecated_print_frame_info_listing_hook = 0;
   deprecated_query_hook = 0;
   deprecated_register_changed_hook = 0;
@@ -242,6 +248,8 @@ tui_remove_hooks (void)
   tui_inferior_exit_observer = NULL;
   observer_detach_about_to_proceed (tui_about_to_proceed_observer);
   tui_about_to_proceed_observer = NULL;
+  observer_detach_before_prompt (tui_before_prompt_observer);
+  tui_before_prompt_observer = NULL;
 }
 
 void _initialize_tui_hooks (void);
diff --git a/gdb/tui/tui-hooks.h b/gdb/tui/tui-hooks.h
index ab6afc9..303d9bb 100644
--- a/gdb/tui/tui-hooks.h
+++ b/gdb/tui/tui-hooks.h
@@ -20,6 +20,11 @@
 #ifndef TUI_HOOKS_H
 #define TUI_HOOKS_H
 
+/* 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.  */
+
+extern void tui_refresh_frame_and_register_information (void);
+
 extern void tui_install_hooks (void);
 extern void tui_remove_hooks (void);
 
diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c
index 1a5639d..4284037 100644
--- a/gdb/tui/tui-interp.c
+++ b/gdb/tui/tui-interp.c
@@ -27,6 +27,7 @@
 #include "tui/tui-data.h"
 #include "readline/readline.h"
 #include "tui/tui-win.h"
+#include "tui/tui-hooks.h"
 #include "tui/tui.h"
 #include "tui/tui-io.h"
 #include "infrun.h"
@@ -107,6 +108,9 @@ tui_on_sync_execution_done (void)
 {
   if (!interp_quiet_p (tui_interp))
     display_gdb_prompt (NULL);
+
+  if (tui_active)
+    tui_refresh_frame_and_register_information ();
 }
 
 /* Observer for the command_error notification.  */
-- 
2.5.0.rc0.5.g91e10c5.dirty


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]