public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Make sure to update registers if frame information has changed
@ 2015-07-01 12:37 Patrick Palka
  2015-07-01 12:42 ` Patrick Palka
  2015-07-01 15:55 ` Pedro Alves
  0 siblings, 2 replies; 3+ messages in thread
From: Patrick Palka @ 2015-07-01 12:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Patrick Palka

When I removed 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, I added 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.
---
 gdb/tui/tui-hooks.c | 14 +++++++++-----
 gdb/tui/tui-stack.c | 15 +++++++++++----
 gdb/tui/tui-stack.h |  2 +-
 3 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index 5987209..0eb2f07 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -122,7 +122,8 @@ tui_about_to_proceed (void)
 /* 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.
 
-   REGISTERS_TOO_P controls whether to refresh our register information.  */
+   REGISTERS_TOO_P controls whether to refresh our register information even
+   if frame information hasn't changed.  */
 
 static void
 tui_refresh_frame_and_register_information (int registers_too_p)
@@ -130,6 +131,7 @@ tui_refresh_frame_and_register_information (int registers_too_p)
   struct frame_info *fi;
   CORE_ADDR pc;
   struct cleanup *old_chain;
+  int frame_info_changed_p;
 
   if (!has_stack_frames ())
     return;
@@ -156,10 +158,11 @@ tui_refresh_frame_and_register_information (int registers_too_p)
 
   /* Display the frame position (even if there is no symbols or the PC
      is not known).  */
-  tui_show_frame_info (fi);
+  frame_info_changed_p = tui_show_frame_info (fi);
 
   /* Refresh the register window if it's visible.  */
-  if (tui_is_window_visible (DATA_WIN) && registers_too_p)
+  if (tui_is_window_visible (DATA_WIN)
+      && (frame_info_changed_p || registers_too_p))
     {
       tui_refreshing_registers = 1;
       tui_check_data_values (fi);
@@ -199,8 +202,9 @@ 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
-     refresh registers here as they could not have changed.  Registers will be
-     refreshed after a normal stop or by our tui_register_changed_hook.  */
+     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.  */
   tui_refresh_frame_and_register_information (/*registers_too_p=*/0);
 }
 
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index 5b12330..910842d 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -349,9 +349,12 @@ tui_update_locator_fullname (const char *fullname)
 }
 
 /* Function to print the frame information for the TUI.  The windows are
-   refreshed only if frame information has changed since the last refresh.  */
+   refreshed only if frame information has changed since the last refresh.
 
-void
+   Return 1 if frame information has changed (and windows subsequently
+   refreshed), 0 otherwise.  */
+
+int
 tui_show_frame_info (struct frame_info *fi)
 {
   struct tui_win_info *win_info;
@@ -389,7 +392,7 @@ tui_show_frame_info (struct frame_info *fi)
 	 not changed.  If frame information has not changed, then the windows'
 	 contents will not change.  So don't bother refreshing the windows.  */
       if (!locator_changed_p)
-	return;
+	return 0;
 
       tui_show_locator_content ();
       start_line = 0;
@@ -460,6 +463,8 @@ tui_show_frame_info (struct frame_info *fi)
 	    }
 	  tui_update_exec_info (win_info);
 	}
+
+      return 1;
     }
   else
     {
@@ -467,7 +472,7 @@ tui_show_frame_info (struct frame_info *fi)
 	= tui_set_locator_info (NULL, NULL, NULL, 0, (CORE_ADDR) 0);
 
       if (!locator_changed_p)
-	return;
+	return 0;
 
       tui_show_locator_content ();
       for (i = 0; i < (tui_source_windows ())->count; i++)
@@ -476,6 +481,8 @@ tui_show_frame_info (struct frame_info *fi)
 	  tui_clear_source_content (win_info, EMPTY_SOURCE_PROMPT);
 	  tui_update_exec_info (win_info);
 	}
+
+      return 1;
     }
 }
 
diff --git a/gdb/tui/tui-stack.h b/gdb/tui/tui-stack.h
index 2a34f9e..b89ddc4 100644
--- a/gdb/tui/tui-stack.h
+++ b/gdb/tui/tui-stack.h
@@ -26,6 +26,6 @@ struct frame_info;
 
 extern void tui_update_locator_fullname (const char *);
 extern void tui_show_locator_content (void);
-extern void tui_show_frame_info (struct frame_info *);
+extern int tui_show_frame_info (struct frame_info *);
 
 #endif
-- 
2.5.0.rc0.5.g91e10c5.dirty

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Make sure to update registers if frame information has changed
  2015-07-01 12:37 [PATCH] Make sure to update registers if frame information has changed Patrick Palka
@ 2015-07-01 12:42 ` Patrick Palka
  2015-07-01 15:55 ` Pedro Alves
  1 sibling, 0 replies; 3+ messages in thread
From: Patrick Palka @ 2015-07-01 12:42 UTC (permalink / raw)
  To: gdb-patches; +Cc: Patrick Palka

On Wed, Jul 1, 2015 at 8:36 AM, Patrick Palka <patrick@parcs.ath.cx> wrote:
> When I removed 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, I added another (sufficient) condition for

To be more precise, s/I added/this patch adds/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Make sure to update registers if frame information has changed
  2015-07-01 12:37 [PATCH] Make sure to update registers if frame information has changed Patrick Palka
  2015-07-01 12:42 ` Patrick Palka
@ 2015-07-01 15:55 ` Pedro Alves
  1 sibling, 0 replies; 3+ messages in thread
From: Pedro Alves @ 2015-07-01 15:55 UTC (permalink / raw)
  To: Patrick Palka, gdb-patches

On 07/01/2015 01:36 PM, Patrick Palka wrote:
> When I removed 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.

Whoops, sorry, should have noticed that myself too.

Patch is OK.  Thanks for the quick fixing.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-01 15:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-01 12:37 [PATCH] Make sure to update registers if frame information has changed Patrick Palka
2015-07-01 12:42 ` Patrick Palka
2015-07-01 15:55 ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).