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 07/14] Change tui_check_register_values to be a method


This changes tui_check_register_values to be a method on
tui_data_window.  An additional check in tui_register_changed is
needed, because TUI_DATA_WIN could be NULL at this point.

gdb/ChangeLog
2019-08-18  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.h (struct tui_data_window) <check_register_values>:
	Declare.
	(tui_check_register_values): Don't declare.
	* tui/tui-regs.c (tui_data_window::check_register_values): Rename
	from tui_check_register_values.
	* tui/tui-hooks.c (tui_register_changed): Update.
---
 gdb/ChangeLog       |  9 +++++++++
 gdb/tui/tui-hooks.c |  7 +++++--
 gdb/tui/tui-regs.c  | 29 ++++++++++++-----------------
 gdb/tui/tui-regs.h  |  3 ++-
 4 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index 5cc90dd3b6c..2555da7f1ae 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -71,6 +71,9 @@ tui_register_changed (struct frame_info *frame, int regno)
 {
   struct frame_info *fi;
 
+  if (!tui_is_window_visible (DATA_WIN))
+    return;
+
   /* 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
@@ -80,7 +83,7 @@ tui_register_changed (struct frame_info *frame, int regno)
   if (tui_refreshing_registers == 0)
     {
       tui_refreshing_registers = 1;
-      tui_check_register_values (fi);
+      TUI_DATA_WIN->check_register_values (fi);
       tui_refreshing_registers = 0;
     }
 }
@@ -152,7 +155,7 @@ tui_refresh_frame_and_register_information (int registers_too_p)
       && (frame_info_changed_p || registers_too_p))
     {
       tui_refreshing_registers = 1;
-      tui_check_register_values (fi);
+      TUI_DATA_WIN->check_register_values (fi);
       tui_refreshing_registers = 0;
     }
 }
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 147f57a13a2..cd343edc314 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -555,29 +555,24 @@ tui_data_window::refresh_window ()
    given a particular frame.  If the values have changed, they are
    updated with the new value and highlighted.  */
 void
-tui_check_register_values (struct frame_info *frame)
+tui_data_window::check_register_values (struct frame_info *frame)
 {
-  if (TUI_DATA_WIN != NULL
-      && TUI_DATA_WIN->is_visible ())
+  if (regs_content.empty () && display_regs)
+    tui_show_registers (current_group);
+  else
     {
-      if (TUI_DATA_WIN->regs_content.empty ()
-	  && TUI_DATA_WIN->display_regs)
-	tui_show_registers (TUI_DATA_WIN->current_group);
-      else
+      for (auto &&data_item_win_ptr : regs_content)
 	{
-	  for (auto &&data_item_win_ptr : TUI_DATA_WIN->regs_content)
-	    {
-	      int was_hilighted;
+	  int was_hilighted;
 
-	      was_hilighted = data_item_win_ptr->highlight;
+	  was_hilighted = data_item_win_ptr->highlight;
 
-              tui_get_register (frame, data_item_win_ptr.get (),
-                                data_item_win_ptr->item_no,
-				&data_item_win_ptr->highlight);
+	  tui_get_register (frame, data_item_win_ptr.get (),
+			    data_item_win_ptr->item_no,
+			    &data_item_win_ptr->highlight);
 
-	      if (data_item_win_ptr->highlight || was_hilighted)
-		tui_display_register (data_item_win_ptr.get ());
-	    }
+	  if (data_item_win_ptr->highlight || was_hilighted)
+	    tui_display_register (data_item_win_ptr.get ());
 	}
     }
 }
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index b70d8df3620..01c2ea6dad4 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -100,6 +100,8 @@ struct tui_data_window : public tui_win_info
      started from.  If nothing is displayed (-1) is returned.  */
   int display_registers_from_line (int line_no);
 
+  void check_register_values (struct frame_info *frame);
+
 protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
@@ -120,7 +122,6 @@ protected:
   void rerender () override;
 };
 
-extern void tui_check_register_values (struct frame_info *);
 extern void tui_show_registers (struct reggroup *group);
 
 #endif /* TUI_TUI_REGS_H */
-- 
2.17.2


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