public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 12/15] Make tui_locator_window::set_locator_fullname re-render
  2019-08-21  2:27 [PATCH 00/15] More TUI Refactorings Tom Tromey
                   ` (2 preceding siblings ...)
  2019-08-21  2:25 ` [PATCH 04/15] Remove some calls in tui_data_window Tom Tromey
@ 2019-08-21  2:25 ` Tom Tromey
  2019-08-21  2:25 ` [PATCH 01/15] Remove NO_DATA_STRING Tom Tromey
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2019-08-21  2:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_locator_window::set_locator_fullname to re-render the
locator window, so that the callers don't need to do this.

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

	* tui/tui-stack.c (tui_locator_window::set_locator_fullname): Call
	rerender.
	(tui_update_locator_fullname, tui_show_frame_info): Don't call
	tui_show_locator_content.
---
 gdb/ChangeLog       | 7 +++++++
 gdb/tui/tui-stack.c | 4 +---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index 48062fed712..f6b6bb72b2a 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -284,6 +284,7 @@ tui_locator_window::set_locator_fullname (const char *fullname)
 
   locator->full_name[0] = 0;
   strcat_to_buf (locator->full_name, MAX_LOCATOR_ELEMENT_LEN, fullname);
+  rerender ();
 }
 
 /* See tui-stack.h.  */
@@ -328,7 +329,6 @@ tui_update_locator_fullname (const char *fullname)
   struct tui_locator_window *locator = tui_locator_win_info_ptr ();
 
   locator->set_locator_fullname (fullname);
-  tui_show_locator_content ();
 }
 
 /* Function to print the frame information for the TUI.  The windows are
@@ -372,7 +372,6 @@ tui_show_frame_info (struct frame_info *fi)
       if (!locator_changed_p)
 	return 0;
 
-      tui_show_locator_content ();
       for (struct tui_source_window_base *win_info : tui_source_windows ())
 	{
 	  win_info->maybe_update (fi, sal, locator->line_no, locator->addr);
@@ -389,7 +388,6 @@ tui_show_frame_info (struct frame_info *fi)
       if (!locator_changed_p)
 	return 0;
 
-      tui_show_locator_content ();
       for (struct tui_source_window_base *win_info : tui_source_windows ())
 	{
 	  win_info->erase_source_content ();
-- 
2.17.2

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

* [PATCH 06/15] Simplify register display
  2019-08-21  2:27 [PATCH 00/15] More TUI Refactorings Tom Tromey
                   ` (4 preceding siblings ...)
  2019-08-21  2:25 ` [PATCH 01/15] Remove NO_DATA_STRING Tom Tromey
@ 2019-08-21  2:25 ` Tom Tromey
  2019-08-21  2:25 ` [PATCH 05/15] Private data members in tui_data_window Tom Tromey
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2019-08-21  2:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This patch starts with the observation that the code in
tui_data_window::display_registers_from can all be replaced with a
call to resize.  To make this work propertly, it also changes
tui_display_register to be the "rerender" method on
tui_data_item_window.

The refresh_window method is needed due to the use of nested windows
here.  The ncurses man page makes it sound like this is not very well
supported; and experience bears this out: negelecting the touchwin
call in this path will cause the register window to blank when
switching focus.

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

	* tui/tui-regs.h (struct tui_data_item_window) <rerender,
	refresh_window>: Declare.
	* tui/tui-regs.c (tui_data_window::display_registers_from): Call
	resize.
	(tui_data_item_window::rerender): Rename from
	tui_display_register.
	(tui_data_item_window::refresh_window): New method.
	* tui/tui-layout.c (tui_gen_win_info::resize): Do nothing on
	no-op.
---
 gdb/ChangeLog        |  12 ++++++
 gdb/tui/tui-layout.c |   5 +++
 gdb/tui/tui-regs.c   | 100 ++++++++++++++++++-------------------------
 gdb/tui/tui-regs.h   |   4 ++
 4 files changed, 63 insertions(+), 58 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 387a4f51aff..7ec704e52f0 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -580,6 +580,11 @@ void
 tui_gen_win_info::resize (int height_, int width_,
 			  int origin_x_, int origin_y_)
 {
+  if (width == width_ && height == height_
+      && origin.x == origin_x_ && origin.y == origin_y_
+      && handle != nullptr)
+    return;
+
   width = width_;
   height = height_;
   if (height > 1)
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 98096e2cdc4..f62ba065ebe 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -42,8 +42,6 @@
 
 #include "gdb_curses.h"
 
-static void tui_display_register (struct tui_data_item_window *data);
-
 /* Get the register from the frame and return a printable
    representation of it.  */
 
@@ -274,34 +272,9 @@ tui_data_window::display_registers_from (int start_element_no)
 	   j < regs_column_count && i < regs_content.size ();
 	   j++)
 	{
-	  struct tui_data_item_window *data_item_win;
-
 	  /* Create the window if necessary.  */
-	  data_item_win = &regs_content[i];
-	  if (data_item_win->handle != NULL
-	      && (data_item_win->height != 1
-		  || data_item_win->width != item_win_width
-		  || data_item_win->origin.x != (item_win_width * j) + 1
-		  || data_item_win->origin.y != cur_y))
-	    {
-	      tui_delete_win (data_item_win->handle);
-	      data_item_win->handle = 0;
-	    }
-                  
-	  if (data_item_win->handle == NULL)
-	    {
-	      data_item_win->height = 1;
-	      data_item_win->width = item_win_width;
-	      data_item_win->origin.x = (item_win_width * j) + 1;
-	      data_item_win->origin.y = cur_y;
-	      data_item_win->make_visible (true);
-	      scrollok (data_item_win->handle, FALSE);
-	    }
-	  touchwin (data_item_win->handle);
-
-	  /* Get the printable representation of the register
-	     and display it.  */
-	  tui_display_register (data_item_win);
+	  regs_content[i].resize (1, item_win_width,
+				  (item_win_width * j) + 1, cur_y);
 	  i++;		/* Next register.  */
 	}
       cur_y++;		/* Next row.  */
@@ -508,43 +481,54 @@ tui_data_window::check_register_values (struct frame_info *frame)
 			    &data_item_win.highlight);
 
 	  if (data_item_win.highlight || was_hilighted)
-	    tui_display_register (&data_item_win);
+	    data_item_win.rerender ();
 	}
     }
 }
 
 /* Display a register in a window.  If hilite is TRUE, then the value
    will be displayed in reverse video.  */
-static void
-tui_display_register (struct tui_data_item_window *data)
+void
+tui_data_item_window::rerender ()
 {
-  if (data->handle != NULL)
-    {
-      int i;
-
-      if (data->highlight)
-	/* We ignore the return value, casting it to void in order to avoid
-	   a compiler warning.  The warning itself was introduced by a patch
-	   to ncurses 5.7 dated 2009-08-29, changing this macro to expand
-	   to code that causes the compiler to generate an unused-value
-	   warning.  */
-	(void) wstandout (data->handle);
+  int i;
+
+  scrollok (handle, FALSE);
+  if (highlight)
+    /* We ignore the return value, casting it to void in order to avoid
+       a compiler warning.  The warning itself was introduced by a patch
+       to ncurses 5.7 dated 2009-08-29, changing this macro to expand
+       to code that causes the compiler to generate an unused-value
+       warning.  */
+    (void) wstandout (handle);
       
-      wmove (data->handle, 0, 0);
-      for (i = 1; i < data->width; i++)
-        waddch (data->handle, ' ');
-      wmove (data->handle, 0, 0);
-      if (data->content)
-        waddstr (data->handle, data->content.get ());
-
-      if (data->highlight)
-	/* We ignore the return value, casting it to void in order to avoid
-	   a compiler warning.  The warning itself was introduced by a patch
-	   to ncurses 5.7 dated 2009-08-29, changing this macro to expand
-	   to code that causes the compiler to generate an unused-value
-	   warning.  */
-	(void) wstandend (data->handle);
-      data->refresh_window ();
+  wmove (handle, 0, 0);
+  for (i = 1; i < width; i++)
+    waddch (handle, ' ');
+  wmove (handle, 0, 0);
+  if (content)
+    waddstr (handle, content.get ());
+
+  if (highlight)
+    /* We ignore the return value, casting it to void in order to avoid
+       a compiler warning.  The warning itself was introduced by a patch
+       to ncurses 5.7 dated 2009-08-29, changing this macro to expand
+       to code that causes the compiler to generate an unused-value
+       warning.  */
+    (void) wstandend (handle);
+  refresh_window ();
+}
+
+void
+tui_data_item_window::refresh_window ()
+{
+  if (handle != nullptr)
+    {
+      /* This seems to be needed because the data items are nested
+	 windows, which according to the ncurses man pages aren't well
+	 supported.  */
+      touchwin (handle);
+      wrefresh (handle);
     }
 }
 
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index 2606c39f5a1..1f9fa73f1cc 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -37,6 +37,10 @@ struct tui_data_item_window : public tui_gen_win_info
 
   tui_data_item_window (tui_data_item_window &&) = default;
 
+  void rerender () override;
+
+  void refresh_window () override;
+
   const char *name = nullptr;
   /* The register number, or data display number.  */
   int item_no = -1;
-- 
2.17.2

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

* [PATCH 09/15] Don't call tui_refresh_all from show_layout
  2019-08-21  2:27 [PATCH 00/15] More TUI Refactorings Tom Tromey
                   ` (8 preceding siblings ...)
  2019-08-21  2:25 ` [PATCH 10/15] Turn two locator functions into methods Tom Tromey
@ 2019-08-21  2:25 ` Tom Tromey
  2019-08-21  2:25 ` [PATCH 03/15] Remove some checks of .empty() Tom Tromey
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2019-08-21  2:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

show_layout calls tui_refresh_all in one case.  However, it doesn't
need to any more, because the resize method on each window will also
update the contents.

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

	* tui/tui-layout.c (show_layout): Don't call tui_refresh_all.
---
 gdb/ChangeLog        | 4 ++++
 gdb/tui/tui-layout.c | 1 -
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 7ec704e52f0..df7056ae97b 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -82,7 +82,6 @@ show_layout (enum tui_layout_type layout)
 	case SRC_DATA_COMMAND:
 	case DISASSEM_DATA_COMMAND:
 	  show_data (layout);
-	  tui_refresh_all ();
 	  break;
 	  /* Now show the new layout.  */
 	case SRC_COMMAND:
-- 
2.17.2

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

* [PATCH 02/15] Remove tui_data_window::display_all_data
  2019-08-21  2:27 [PATCH 00/15] More TUI Refactorings Tom Tromey
  2019-08-21  2:25 ` [PATCH 15/15] Remove tui_win_info::refresh_all Tom Tromey
@ 2019-08-21  2:25 ` Tom Tromey
  2019-08-21  2:25 ` [PATCH 04/15] Remove some calls in tui_data_window Tom Tromey
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2019-08-21  2:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_data_window::rerender clears the data item windows, and then calls
display_all_data.  However, that method only does anything if the
contents are not empty.  So, display_all_data can be renamed and the
wrapper removed.

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

	* tui/tui-regs.h (struct tui_data_window) <display_all_data>:
	Don't declare.
	* tui/tui-regs.c (tui_data_window::show_registers): Call
	rerender.
	(tui_data_window::rerender): Rename from display_all_data.
	(tui_data_window::rerender): Remove old implementation.
---
 gdb/ChangeLog      |  9 +++++++++
 gdb/tui/tui-regs.c | 18 ++----------------
 gdb/tui/tui-regs.h |  4 ----
 3 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 24b182f2aec..7bac19da281 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -161,7 +161,7 @@ tui_data_window::show_registers (struct reggroup *group)
       for (auto &&data_item_win : regs_content)
 	data_item_win.highlight = false;
       current_group = group;
-      display_all_data ();
+      rerender ();
     }
   else
     {
@@ -434,7 +434,7 @@ tui_data_window::erase_data_content (const char *prompt)
 /* See tui-regs.h.  */
 
 void
-tui_data_window::display_all_data ()
+tui_data_window::rerender ()
 {
   if (regs_content.empty ())
     erase_data_content (_("[ Register Values Unavailable ]"));
@@ -500,20 +500,6 @@ tui_data_window::do_scroll_vertical (int num_to_scroll)
 
 /* See tui-regs.h.  */
 
-void
-tui_data_window::rerender ()
-{
-  /* Delete all data item windows.  */
-  for (auto &&win : regs_content)
-    {
-      tui_delete_win (win.handle);
-      win.handle = NULL;
-    }
-  display_all_data ();
-}
-
-/* See tui-regs.h.  */
-
 void
 tui_data_window::refresh_window ()
 {
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index 95e944038c7..fa76cae0b18 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -121,10 +121,6 @@ private:
      past the register area (-1) is returned.  */
   int first_reg_element_no_inline (int line_no) const;
 
-  /* Displays the data that is in the data window's content.  It does
-     not set the content.  */
-  void display_all_data ();
-
   /* Delete all the item windows in the data window.  This is usually
      done when the data window is scrolled.  */
   void delete_data_content_windows ();
-- 
2.17.2

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

* [PATCH 05/15] Private data members in tui_data_window
  2019-08-21  2:27 [PATCH 00/15] More TUI Refactorings Tom Tromey
                   ` (5 preceding siblings ...)
  2019-08-21  2:25 ` [PATCH 06/15] Simplify register display Tom Tromey
@ 2019-08-21  2:25 ` Tom Tromey
  2019-08-26 14:06   ` Pedro Alves
  2019-08-21  2:25 ` [PATCH 07/15] Remove NULL checks from box_win Tom Tromey
                   ` (8 subsequent siblings)
  15 siblings, 1 reply; 20+ messages in thread
From: Tom Tromey @ 2019-08-21  2:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_data_window so that the data members are private.
This required the addition of a simple accessor method in one case.

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

	* tui/tui-regs.h (struct tui_data_window) <regs_content,
	regs_column_count, current_group>: Move later.  Now private.
	<get_current_group>: New method.
	* tui/tui-regs.c (tui_reg_command): Update.
	* tui/tui-layout.c (tui_set_layout): Update.
---
 gdb/ChangeLog        |  8 ++++++++
 gdb/tui/tui-layout.c |  2 +-
 gdb/tui/tui-regs.c   |  2 +-
 gdb/tui/tui-regs.h   | 15 ++++++++++-----
 4 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 01d50e437e5..387a4f51aff 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -189,7 +189,7 @@ tui_set_layout (enum tui_layout_type layout_type)
       tui_update_source_windows_with_addr (gdbarch, addr);
       if (new_layout == SRC_DATA_COMMAND
 	  || new_layout == DISASSEM_DATA_COMMAND)
-	TUI_DATA_WIN->show_registers (TUI_DATA_WIN->current_group);
+	TUI_DATA_WIN->show_registers (TUI_DATA_WIN->get_current_group ());
     }
 }
 
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 4a09a590446..98096e2cdc4 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -622,7 +622,7 @@ tui_reg_command (const char *args, int from_tty)
       if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->is_visible ())
 	tui_reg_layout ();
 
-      struct reggroup *current_group = TUI_DATA_WIN->current_group;
+      struct reggroup *current_group = TUI_DATA_WIN->get_current_group ();
       if (strncmp (args, "next", len) == 0)
 	match = tui_reg_next (current_group, gdbarch);
       else if (strncmp (args, "prev", len) == 0)
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index fa76cae0b18..2606c39f5a1 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -63,15 +63,15 @@ struct tui_data_window : public tui_win_info
     return DATA_NAME;
   }
 
-  /* Windows that are used to display registers.  */
-  std::vector<tui_data_item_window> regs_content;
-  int regs_column_count = 0;
-  struct reggroup *current_group = nullptr;
-
   void check_register_values (struct frame_info *frame);
 
   void show_registers (struct reggroup *group);
 
+  struct reggroup *get_current_group () const
+  {
+    return current_group;
+  }
+
 protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
@@ -126,6 +126,11 @@ private:
   void delete_data_content_windows ();
 
   void erase_data_content (const char *prompt);
+
+  /* Windows that are used to display registers.  */
+  std::vector<tui_data_item_window> regs_content;
+  int regs_column_count = 0;
+  struct reggroup *current_group = nullptr;
 };
 
 #endif /* TUI_TUI_REGS_H */
-- 
2.17.2

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

* [PATCH 07/15] Remove NULL checks from box_win
  2019-08-21  2:27 [PATCH 00/15] More TUI Refactorings Tom Tromey
                   ` (6 preceding siblings ...)
  2019-08-21  2:25 ` [PATCH 05/15] Private data members in tui_data_window Tom Tromey
@ 2019-08-21  2:25 ` Tom Tromey
  2019-08-21  2:25 ` [PATCH 10/15] Turn two locator functions into methods Tom Tromey
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2019-08-21  2:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

box_win can't be called with a NULL window, or with an invisible
window.  So, the NULL checks in that function can be removed.

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

	* tui/tui-wingeneral.c (box_win): Assume win_info and
	win_info->handle cannot be NULL.
---
 gdb/ChangeLog            |  5 +++++
 gdb/tui/tui-wingeneral.c | 35 ++++++++++++++++-------------------
 2 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index ab0363f856c..01f288be862 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -58,30 +58,27 @@ static void
 box_win (struct tui_win_info *win_info, 
 	 bool highlight_flag)
 {
-  if (win_info && win_info->handle)
-    {
-      WINDOW *win;
-      int attrs;
+  WINDOW *win;
+  int attrs;
 
-      win = win_info->handle;
-      if (highlight_flag)
-        attrs = tui_active_border_attrs;
-      else
-        attrs = tui_border_attrs;
+  win = win_info->handle;
+  if (highlight_flag)
+    attrs = tui_active_border_attrs;
+  else
+    attrs = tui_border_attrs;
 
-      wattron (win, attrs);
+  wattron (win, attrs);
 #ifdef HAVE_WBORDER
-      wborder (win, tui_border_vline, tui_border_vline,
-               tui_border_hline, tui_border_hline,
-               tui_border_ulcorner, tui_border_urcorner,
-               tui_border_llcorner, tui_border_lrcorner);
+  wborder (win, tui_border_vline, tui_border_vline,
+	   tui_border_hline, tui_border_hline,
+	   tui_border_ulcorner, tui_border_urcorner,
+	   tui_border_llcorner, tui_border_lrcorner);
 #else
-      box (win, tui_border_vline, tui_border_hline);
+  box (win, tui_border_vline, tui_border_hline);
 #endif
-      if (!win_info->title.empty ())
-        mvwaddstr (win, 0, 3, win_info->title.c_str ());
-      wattroff (win, attrs);
-    }
+  if (!win_info->title.empty ())
+    mvwaddstr (win, 0, 3, win_info->title.c_str ());
+  wattroff (win, attrs);
 }
 
 
-- 
2.17.2

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

* [PATCH 03/15] Remove some checks of .empty()
  2019-08-21  2:27 [PATCH 00/15] More TUI Refactorings Tom Tromey
                   ` (9 preceding siblings ...)
  2019-08-21  2:25 ` [PATCH 09/15] Don't call tui_refresh_all from show_layout Tom Tromey
@ 2019-08-21  2:25 ` Tom Tromey
  2019-08-21  2:27 ` [PATCH 13/15] Minor rearrangement of tui-stack.c Tom Tromey
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2019-08-21  2:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

A few methods in tui_data_window check whether the contents are empty;
but all the callers already check this, so these calls can be removed.

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

	* tui/tui-regs.c (tui_data_window::last_regs_line_no)
	(tui_data_window::display_registers_from)
	(tui_data_window::display_reg_element_at_line)
	(tui_data_window::display_registers_from_line): Remove checks of
	"empty".
---
 gdb/ChangeLog      |   8 ++
 gdb/tui/tui-regs.c | 207 +++++++++++++++++++++------------------------
 2 files changed, 104 insertions(+), 111 deletions(-)

diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 7bac19da281..636ae101483 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -98,14 +98,9 @@ tui_get_register (struct frame_info *frame,
 int
 tui_data_window::last_regs_line_no () const
 {
-  int num_lines = (-1);
-
-  if (!regs_content.empty ())
-    {
-      num_lines = regs_content.size () / regs_column_count;
-      if (regs_content.size () % regs_column_count)
-	num_lines++;
-    }
+  int num_lines = regs_content.size () / regs_column_count;
+  if (regs_content.size () % regs_column_count)
+    num_lines++;
   return num_lines;
 }
 
@@ -245,74 +240,71 @@ tui_data_window::show_register_group (struct reggroup *group,
 void
 tui_data_window::display_registers_from (int start_element_no)
 {
-  if (!regs_content.empty ())
+  int j, item_win_width, cur_y;
+
+  int max_len = 0;
+  for (auto &&data_item_win : regs_content)
     {
-      int j, item_win_width, cur_y;
+      const char *p;
+      int len;
 
-      int max_len = 0;
-      for (auto &&data_item_win : regs_content)
-        {
-          const char *p;
-          int len;
-
-          len = 0;
-          p = data_item_win.content.get ();
-          if (p != 0)
-	    len = strlen (p);
-
-          if (len > max_len)
-            max_len = len;
-        }
-      item_win_width = max_len + 1;
-      int i = start_element_no;
-
-      regs_column_count = (width - 2) / item_win_width;
-      if (regs_column_count == 0)
-        regs_column_count = 1;
-      item_win_width = (width - 2) / regs_column_count;
-
-      /* Now create each data "sub" window, and write the display into
-	 it.  */
-      cur_y = 1;
-      while (i < regs_content.size ()
-	     && cur_y <= viewport_height)
+      len = 0;
+      p = data_item_win.content.get ();
+      if (p != 0)
+	len = strlen (p);
+
+      if (len > max_len)
+	max_len = len;
+    }
+  item_win_width = max_len + 1;
+  int i = start_element_no;
+
+  regs_column_count = (width - 2) / item_win_width;
+  if (regs_column_count == 0)
+    regs_column_count = 1;
+  item_win_width = (width - 2) / regs_column_count;
+
+  /* Now create each data "sub" window, and write the display into
+     it.  */
+  cur_y = 1;
+  while (i < regs_content.size ()
+	 && cur_y <= viewport_height)
+    {
+      for (j = 0;
+	   j < regs_column_count && i < regs_content.size ();
+	   j++)
 	{
-	  for (j = 0;
-	       j < regs_column_count && i < regs_content.size ();
-	       j++)
+	  struct tui_data_item_window *data_item_win;
+
+	  /* Create the window if necessary.  */
+	  data_item_win = &regs_content[i];
+	  if (data_item_win->handle != NULL
+	      && (data_item_win->height != 1
+		  || data_item_win->width != item_win_width
+		  || data_item_win->origin.x != (item_win_width * j) + 1
+		  || data_item_win->origin.y != cur_y))
 	    {
-	      struct tui_data_item_window *data_item_win;
-
-	      /* Create the window if necessary.  */
-	      data_item_win = &regs_content[i];
-              if (data_item_win->handle != NULL
-                  && (data_item_win->height != 1
-                      || data_item_win->width != item_win_width
-                      || data_item_win->origin.x != (item_win_width * j) + 1
-                      || data_item_win->origin.y != cur_y))
-                {
-                  tui_delete_win (data_item_win->handle);
-                  data_item_win->handle = 0;
-                }
+	      tui_delete_win (data_item_win->handle);
+	      data_item_win->handle = 0;
+	    }
                   
-	      if (data_item_win->handle == NULL)
-		{
-		  data_item_win->height = 1;
-		  data_item_win->width = item_win_width;
-		  data_item_win->origin.x = (item_win_width * j) + 1;
-		  data_item_win->origin.y = cur_y;
-		  data_item_win->make_visible (true);
-                  scrollok (data_item_win->handle, FALSE);
-		}
-              touchwin (data_item_win->handle);
-
-	      /* Get the printable representation of the register
-                 and display it.  */
-              tui_display_register (data_item_win);
-	      i++;		/* Next register.  */
+	  if (data_item_win->handle == NULL)
+	    {
+	      data_item_win->height = 1;
+	      data_item_win->width = item_win_width;
+	      data_item_win->origin.x = (item_win_width * j) + 1;
+	      data_item_win->origin.y = cur_y;
+	      data_item_win->make_visible (true);
+	      scrollok (data_item_win->handle, FALSE);
 	    }
-	  cur_y++;		/* Next row.  */
+	  touchwin (data_item_win->handle);
+
+	  /* Get the printable representation of the register
+	     and display it.  */
+	  tui_display_register (data_item_win);
+	  i++;		/* Next register.  */
 	}
+      cur_y++;		/* Next row.  */
     }
 }
 
@@ -322,27 +314,24 @@ void
 tui_data_window::display_reg_element_at_line (int start_element_no,
 					      int start_line_no)
 {
-  if (!regs_content.empty ())
-    {
-      int element_no = start_element_no;
+  int element_no = start_element_no;
 
-      if (start_element_no != 0 && start_line_no != 0)
-	{
-	  int last_line_no, first_line_on_last_page;
-
-	  last_line_no = last_regs_line_no ();
-	  first_line_on_last_page = last_line_no - (height - 2);
-	  if (first_line_on_last_page < 0)
-	    first_line_on_last_page = 0;
-
-	  /* If the element_no causes us to scroll past the end of the
-	     registers, adjust what element to really start the
-	     display at.  */
-	  if (start_line_no > first_line_on_last_page)
-	    element_no = first_reg_element_no_inline (first_line_on_last_page);
-	}
-      display_registers_from (element_no);
+  if (start_element_no != 0 && start_line_no != 0)
+    {
+      int last_line_no, first_line_on_last_page;
+
+      last_line_no = last_regs_line_no ();
+      first_line_on_last_page = last_line_no - (height - 2);
+      if (first_line_on_last_page < 0)
+	first_line_on_last_page = 0;
+
+      /* If the element_no causes us to scroll past the end of the
+	 registers, adjust what element to really start the
+	 display at.  */
+      if (start_line_no > first_line_on_last_page)
+	element_no = first_reg_element_no_inline (first_line_on_last_page);
     }
+  display_registers_from (element_no);
 }
 
 /* See tui-regs.h.  */
@@ -351,34 +340,30 @@ int
 tui_data_window::display_registers_from_line (int line_no)
 {
   check_and_display_highlight_if_needed ();
-  if (!regs_content.empty ())
-    {
-      int element_no;
 
-      if (line_no < 0)
-	line_no = 0;
-      else
+  int element_no;
+
+  if (line_no < 0)
+    line_no = 0;
+  else
+    {
+      /* Make sure that we don't display off the end of the
+	 registers.  */
+      if (line_no >= last_regs_line_no ())
 	{
-	  /* Make sure that we don't display off the end of the
-	     registers.  */
-	  if (line_no >= last_regs_line_no ())
-	    {
-	      line_no = line_from_reg_element_no (regs_content.size () - 1);
-	      if (line_no < 0)
-		line_no = 0;
-	    }
+	  line_no = line_from_reg_element_no (regs_content.size () - 1);
+	  if (line_no < 0)
+	    line_no = 0;
 	}
-
-      element_no = first_reg_element_no_inline (line_no);
-      if (element_no < regs_content.size ())
-	display_reg_element_at_line (element_no, line_no);
-      else
-	line_no = (-1);
-
-      return line_no;
     }
 
-  return (-1);			/* Nothing was displayed.  */
+  element_no = first_reg_element_no_inline (line_no);
+  if (element_no < regs_content.size ())
+    display_reg_element_at_line (element_no, line_no);
+  else
+    line_no = (-1);
+
+  return line_no;
 }
 
 
-- 
2.17.2

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

* [PATCH 04/15] Remove some calls in tui_data_window
  2019-08-21  2:27 [PATCH 00/15] More TUI Refactorings Tom Tromey
  2019-08-21  2:25 ` [PATCH 15/15] Remove tui_win_info::refresh_all Tom Tromey
  2019-08-21  2:25 ` [PATCH 02/15] Remove tui_data_window::display_all_data Tom Tromey
@ 2019-08-21  2:25 ` Tom Tromey
  2019-08-21  2:25 ` [PATCH 12/15] Make tui_locator_window::set_locator_fullname re-render Tom Tromey
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2019-08-21  2:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This patch removes a call to erase_data_content in refresh_all and
then removes some other calls that are more clearly unnecessary once
one follows calls from that point.

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

	* tui/tui-regs.c (tui_data_window::display_registers_from_line)
	(tui_data_window::rerender): Don't call
	check_and_display_highlight_if_needed.
	(tui_data_window::refresh_all): Remove call to
	erase_data_content.
---
 gdb/ChangeLog      | 8 ++++++++
 gdb/tui/tui-regs.c | 8 +-------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 636ae101483..4a09a590446 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -339,8 +339,6 @@ tui_data_window::display_reg_element_at_line (int start_element_no,
 int
 tui_data_window::display_registers_from_line (int line_no)
 {
-  check_and_display_highlight_if_needed ();
-
   int element_no;
 
   if (line_no < 0)
@@ -427,7 +425,6 @@ tui_data_window::rerender ()
     {
       erase_data_content (NULL);
       delete_data_content_windows ();
-      check_and_display_highlight_if_needed ();
       display_registers_from (0);
     }
 }
@@ -450,10 +447,7 @@ tui_data_window::refresh_all ()
 	    first_line = line_from_reg_element_no (first_element);
 
 	  if (first_line >= 0)
-	    {
-	      erase_data_content (NULL);
-	      display_registers_from_line (first_line);
-	    }
+	    display_registers_from_line (first_line);
 	}
     }
 }
-- 
2.17.2

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

* [PATCH 01/15] Remove NO_DATA_STRING
  2019-08-21  2:27 [PATCH 00/15] More TUI Refactorings Tom Tromey
                   ` (3 preceding siblings ...)
  2019-08-21  2:25 ` [PATCH 12/15] Make tui_locator_window::set_locator_fullname re-render Tom Tromey
@ 2019-08-21  2:25 ` Tom Tromey
  2019-08-21  2:25 ` [PATCH 06/15] Simplify register display Tom Tromey
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2019-08-21  2:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

NO_DATA_STRING shouldn't be used.  It's referenced in a single spot,
in tui_data_window::display_all_data.  This patch removes the use and
replaces it with the more correct text.  A later patch (though not in
this series) will remove this call entirely, when it's more obviously
correct to do so.

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

	* tui/tui-regs.c (tui_data_window::display_all_data): Change
	text.
	* tui/tui-data.h (NO_DATA_STRING): Remove define.
---
 gdb/ChangeLog      | 6 ++++++
 gdb/tui/tui-data.h | 1 -
 gdb/tui/tui-regs.c | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 6dfea41d49e..698acac338f 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -97,7 +97,6 @@ public:
 
 /* Constant definitions.  */
 #define DEFAULT_TAB_LEN         8
-#define NO_DATA_STRING          "[ No Data Values Displayed ]"
 #define SRC_NAME                "src"
 #define CMD_NAME                "cmd"
 #define DATA_NAME               "regs"
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 71037d41047..24b182f2aec 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -437,7 +437,7 @@ void
 tui_data_window::display_all_data ()
 {
   if (regs_content.empty ())
-    erase_data_content (NO_DATA_STRING);
+    erase_data_content (_("[ Register Values Unavailable ]"));
   else
     {
       erase_data_content (NULL);
-- 
2.17.2

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

* [PATCH 10/15] Turn two locator functions into methods
  2019-08-21  2:27 [PATCH 00/15] More TUI Refactorings Tom Tromey
                   ` (7 preceding siblings ...)
  2019-08-21  2:25 ` [PATCH 07/15] Remove NULL checks from box_win Tom Tromey
@ 2019-08-21  2:25 ` Tom Tromey
  2019-08-21  2:25 ` [PATCH 09/15] Don't call tui_refresh_all from show_layout Tom Tromey
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2019-08-21  2:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_set_locator_fullname and tui_set_locator_info to be
methods on tui_locator_window.  This enables some subsequent
cleannups.

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

	* tui/tui-stack.h (struct tui_locator_window) <set_locator_info,
	set_locator_fullname>: New methods.
	* tui/tui-stack.c (tui_locator_window::set_locator_fullname):
	Rename from tui_set_locator_fullname.
	(tui_locator_window::set_locator_info): Rename from
	tui_set_locator_info.  Return bool.
	(tui_update_locator_fullname, tui_show_frame_info): Update.
---
 gdb/ChangeLog       | 10 ++++++
 gdb/tui/tui-stack.c | 84 ++++++++++++++++++++-------------------------
 gdb/tui/tui-stack.h | 12 +++++++
 3 files changed, 59 insertions(+), 47 deletions(-)

diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index 0d411331bba..a4adf36365e 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -58,15 +58,6 @@ static struct tui_locator_window _locator;
    Returns a pointer to a static area holding the result.  */
 static char *tui_get_function_from_frame (struct frame_info *fi);
 
-/* Set the full_name portion of the locator.  */
-static void tui_set_locator_fullname (const char *fullname);
-
-/* Update the locator, with the provided arguments.  */
-static int tui_set_locator_info (struct gdbarch *gdbarch,
-				 const char *fullname,
-				 const char *procname,
-                                 int lineno, CORE_ADDR addr);
-
 static void tui_update_command (const char *, int);
 \f
 
@@ -295,9 +286,10 @@ tui_locator_window::rerender ()
   tui_show_locator_content ();
 }
 
-/* Set the filename portion of the locator.  */
-static void
-tui_set_locator_fullname (const char *fullname)
+/* See tui-stack.h.  */
+
+void
+tui_locator_window::set_locator_fullname (const char *fullname)
 {
   struct tui_locator_window *locator = tui_locator_win_info_ptr ();
 
@@ -305,20 +297,16 @@ tui_set_locator_fullname (const char *fullname)
   strcat_to_buf (locator->full_name, MAX_LOCATOR_ELEMENT_LEN, fullname);
 }
 
-/* Update the locator, with the provided arguments.
+/* See tui-stack.h.  */
 
-   Returns 1 if any of the locator's fields were actually changed,
-   and 0 otherwise.  */
-
-static int
-tui_set_locator_info (struct gdbarch *gdbarch,
-		      const char *fullname,
-		      const char *procname, 
-		      int lineno,
-                      CORE_ADDR addr)
+bool
+tui_locator_window::set_locator_info (struct gdbarch *gdbarch_in,
+				      const char *fullname,
+				      const char *procname, 
+				      int lineno,
+				      CORE_ADDR addr_in)
 {
-  struct tui_locator_window *locator = tui_locator_win_info_ptr ();
-  int locator_changed_p = 0;
+  bool locator_changed_p = false;
 
   if (procname == NULL)
     procname = "";
@@ -326,20 +314,20 @@ tui_set_locator_info (struct gdbarch *gdbarch,
   if (fullname == NULL)
     fullname = "";
 
-  locator_changed_p |= strncmp (locator->proc_name, procname,
+  locator_changed_p |= strncmp (proc_name, procname,
 				MAX_LOCATOR_ELEMENT_LEN) != 0;
-  locator_changed_p |= lineno != locator->line_no;
-  locator_changed_p |= addr != locator->addr;
-  locator_changed_p |= gdbarch != locator->gdbarch;
-  locator_changed_p |= strncmp (locator->full_name, fullname,
+  locator_changed_p |= lineno != line_no;
+  locator_changed_p |= addr_in != addr;
+  locator_changed_p |= gdbarch_in != gdbarch;
+  locator_changed_p |= strncmp (full_name, fullname,
 				MAX_LOCATOR_ELEMENT_LEN) != 0;
 
-  locator->proc_name[0] = (char) 0;
-  strcat_to_buf (locator->proc_name, MAX_LOCATOR_ELEMENT_LEN, procname);
-  locator->line_no = lineno;
-  locator->addr = addr;
-  locator->gdbarch = gdbarch;
-  tui_set_locator_fullname (fullname);
+  proc_name[0] = (char) 0;
+  strcat_to_buf (proc_name, MAX_LOCATOR_ELEMENT_LEN, procname);
+  line_no = lineno;
+  addr = addr_in;
+  gdbarch = gdbarch_in;
+  set_locator_fullname (fullname);
 
   return locator_changed_p;
 }
@@ -348,7 +336,9 @@ tui_set_locator_info (struct gdbarch *gdbarch,
 void
 tui_update_locator_fullname (const char *fullname)
 {
-  tui_set_locator_fullname (fullname);
+  struct tui_locator_window *locator = tui_locator_win_info_ptr ();
+
+  locator->set_locator_fullname (fullname);
   tui_show_locator_content ();
 }
 
@@ -361,11 +351,11 @@ tui_update_locator_fullname (const char *fullname)
 int
 tui_show_frame_info (struct frame_info *fi)
 {
-  int locator_changed_p;
+  bool locator_changed_p;
+  struct tui_locator_window *locator = tui_locator_win_info_ptr ();
 
   if (fi)
     {
-      struct tui_locator_window *locator = tui_locator_win_info_ptr ();
       CORE_ADDR pc;
 
       symtab_and_line sal = find_frame_sal (fi);
@@ -376,16 +366,16 @@ tui_show_frame_info (struct frame_info *fi)
 
       if (get_frame_pc_if_available (fi, &pc))
 	locator_changed_p
-	  = tui_set_locator_info (get_frame_arch (fi),
-				  (sal.symtab == 0
-				   ? "??" : fullname),
-				  tui_get_function_from_frame (fi),
-				  sal.line,
-				  pc);
+	  = locator->set_locator_info (get_frame_arch (fi),
+				       (sal.symtab == 0
+					? "??" : fullname),
+				       tui_get_function_from_frame (fi),
+				       sal.line,
+				       pc);
       else
 	locator_changed_p
-	  = tui_set_locator_info (get_frame_arch (fi),
-				  "??", _("<unavailable>"), sal.line, 0);
+	  = locator->set_locator_info (get_frame_arch (fi),
+				       "??", _("<unavailable>"), sal.line, 0);
 
       /* If the locator information has not changed, then frame information has
 	 not changed.  If frame information has not changed, then the windows'
@@ -405,7 +395,7 @@ tui_show_frame_info (struct frame_info *fi)
   else
     {
       locator_changed_p
-	= tui_set_locator_info (NULL, NULL, NULL, 0, (CORE_ADDR) 0);
+	= locator->set_locator_info (NULL, NULL, NULL, 0, (CORE_ADDR) 0);
 
       if (!locator_changed_p)
 	return 0;
diff --git a/gdb/tui/tui-stack.h b/gdb/tui/tui-stack.h
index 951cf2c407b..86239b0d284 100644
--- a/gdb/tui/tui-stack.h
+++ b/gdb/tui/tui-stack.h
@@ -45,6 +45,18 @@ struct tui_locator_window : public tui_gen_win_info
 
   void rerender () override;
 
+  /* Update the locator, with the provided arguments.
+
+     Returns true if any of the locator's fields were actually
+     changed, and false otherwise.  */
+  bool set_locator_info (struct gdbarch *gdbarch,
+			 const char *fullname,
+			 const char *procname,
+			 int lineno, CORE_ADDR addr);
+
+  /* Set the full_name portion of the locator.  */
+  void set_locator_fullname (const char *fullname);
+
   char full_name[MAX_LOCATOR_ELEMENT_LEN];
   char proc_name[MAX_LOCATOR_ELEMENT_LEN];
   int line_no = 0;
-- 
2.17.2

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

* [PATCH 15/15] Remove tui_win_info::refresh_all
  2019-08-21  2:27 [PATCH 00/15] More TUI Refactorings Tom Tromey
@ 2019-08-21  2:25 ` Tom Tromey
  2019-08-21  2:25 ` [PATCH 02/15] Remove tui_data_window::display_all_data Tom Tromey
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2019-08-21  2:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The TUI has two duplicate "re-render this window" methods, "rerender"
and "refresh_all".  They differ only slightly in semantics, so I
wanted to see if they could be unified.

After looking into this, I decided that refresh_all was not needed.
There are 4 calls to tui_refresh_all_win (the only caller of this
method):

1. tui_enable.  This sets the layout, which renders the windows.

2. tui_cont_sig.  Here, I think it's sufficient to simply redraw the
   current window contents from the curses backing store, because gdb
   state didn't change while it was suspended

3. tui_dispatch_ctrl_char.  This is the C-l handler, and here it's
   explicitly enough to just refresh the screen (as above).

4. tui_refresh_all_command.  This is the command equivalent of C-l.

So, this patch removes this method entirely and simplifies
tui_refresh_all_win.

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

	* tui/tui-winsource.h (struct tui_source_window_base)
	<refresh_all>: Don't declare.
	* tui/tui-winsource.c (tui_source_window_base::refresh_all):
	Remove.
	* tui/tui-win.c (tui_refresh_all_win): Don't call refresh_all or
	tui_show_locator_content.
	* tui/tui-regs.h (struct tui_data_window) <refresh_all>: Don't
	declare.
	* tui/tui-regs.c (tui_data_window::refresh_all): Remove.
	* tui/tui-data.h (struct tui_win_info) <refresh_all>: Don't
	declare.
---
 gdb/ChangeLog           | 14 ++++++++++++++
 gdb/tui/tui-data.h      |  6 ------
 gdb/tui/tui-regs.c      | 23 -----------------------
 gdb/tui/tui-regs.h      |  2 --
 gdb/tui/tui-win.c       |  6 ------
 gdb/tui/tui-winsource.c | 10 ----------
 gdb/tui/tui-winsource.h |  2 --
 7 files changed, 14 insertions(+), 49 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 698acac338f..262cb595d4d 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -161,12 +161,6 @@ public:
   {
   }
 
-  /* Called after all the TUI windows are refreshed, to let this
-     window have a chance to update itself further.  */
-  virtual void refresh_all ()
-  {
-  }
-
   /* Compute the maximum height of this window.  */
   virtual int max_height () const;
 
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index f62ba065ebe..48e78fc9dbc 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -403,29 +403,6 @@ tui_data_window::rerender ()
 }
 
 
-/* Function to redisplay the contents of the data window.  */
-void
-tui_data_window::refresh_all ()
-{
-  erase_data_content (NULL);
-  if (!regs_content.empty ())
-    {
-      int first_element = first_data_item_displayed ();
-
-      if (first_element >= 0)	/* Re-use existing windows.  */
-	{
-	  int first_line = (-1);
-
-	  if (first_element < regs_content.size ())
-	    first_line = line_from_reg_element_no (first_element);
-
-	  if (first_line >= 0)
-	    display_registers_from_line (first_line);
-	}
-    }
-}
-
-
 /* Scroll the data window vertically forward or backward.  */
 void
 tui_data_window::do_scroll_vertical (int num_to_scroll)
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index 1f9fa73f1cc..abf44c88b68 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -58,8 +58,6 @@ struct tui_data_window : public tui_win_info
 
   DISABLE_COPY_AND_ASSIGN (tui_data_window);
 
-  void refresh_all () override;
-
   void refresh_window () override;
 
   const char *name () const override
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 64e38880a2c..8d41372cf90 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -504,12 +504,6 @@ tui_refresh_all_win (void)
 {
   clearok (curscr, TRUE);
   tui_refresh_all ();
-  for (tui_win_info *win_info : all_tui_windows ())
-    {
-      if (win_info->is_visible ())
-	win_info->refresh_all ();
-    }
-  tui_show_locator_content ();
 }
 
 void
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 0a3eb78bb5a..7a4821dc52c 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -280,16 +280,6 @@ tui_source_window_base::~tui_source_window_base ()
 
 /* See tui-data.h.  */
 
-void
-tui_source_window_base::refresh_all ()
-{
-  show_source_content ();
-  check_and_display_highlight_if_needed ();
-  update_exec_info ();
-}
-
-/* See tui-data.h.  */
-
 void
 tui_source_window_base::update_tab_width ()
 {
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 1804ca7224a..4c98ca3ceb2 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -103,8 +103,6 @@ public:
 
   void clear_detail ();
 
-  void refresh_all () override;
-
   /* Refill the source window's source cache and update it.  If this
      is a disassembly window, then just update it.  */
   void refill ();
-- 
2.17.2

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

* [PATCH 08/15] Don't call touchwin in tui_gen_win_info::refresh_window
  2019-08-21  2:27 [PATCH 00/15] More TUI Refactorings Tom Tromey
                   ` (11 preceding siblings ...)
  2019-08-21  2:27 ` [PATCH 13/15] Minor rearrangement of tui-stack.c Tom Tromey
@ 2019-08-21  2:27 ` Tom Tromey
  2019-08-21  2:27 ` [PATCH 11/15] Swap tui_show_locator_content and tui_locator_window::rerender Tom Tromey
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2019-08-21  2:27 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The call to touchwin in tui_gen_win_info::refresh_window was an
artifact of some earlier refactorings.  Testing shows it isn't needed
any more -- I believe it was only ever needed for the data item window
display problem; but that's been solved more locally.

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

	* tui/tui-wingeneral.c (tui_gen_win_info::refresh_window): Don't
	call touchwin.
---
 gdb/ChangeLog            | 5 +++++
 gdb/tui/tui-wingeneral.c | 5 +----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 01f288be862..f900eab0133 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -38,10 +38,7 @@ void
 tui_gen_win_info::refresh_window ()
 {
   if (handle != NULL)
-    {
-      touchwin (handle);
-      wrefresh (handle);
-    }
+    wrefresh (handle);
 }
 
 /* Function to delete the curses window, checking for NULL.  */
-- 
2.17.2

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

* [PATCH 11/15] Swap tui_show_locator_content and tui_locator_window::rerender
  2019-08-21  2:27 [PATCH 00/15] More TUI Refactorings Tom Tromey
                   ` (12 preceding siblings ...)
  2019-08-21  2:27 ` [PATCH 08/15] Don't call touchwin in tui_gen_win_info::refresh_window Tom Tromey
@ 2019-08-21  2:27 ` Tom Tromey
  2019-08-21  2:31 ` [PATCH 14/15] Don't call wrefresh from tui_cont_sig Tom Tromey
  2019-08-26 14:08 ` [PATCH 00/15] More TUI Refactorings Pedro Alves
  15 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2019-08-21  2:27 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This swaps the bodies ot tui_show_locator_content and
tui_locator_window::rerender, so that the latter does the work, and
the former is now just an exported convenience wrapper.

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

	* tui/tui-stack.c (tui_show_locator_content): Move lower.  Rewrite.
	(tui_locator_window::rerender): Rewrite using body of previous
	tui_show_locator_content.
---
 gdb/ChangeLog       |  6 ++++++
 gdb/tui/tui-stack.c | 38 +++++++++++++++++---------------------
 2 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index a4adf36365e..48062fed712 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -254,38 +254,27 @@ tui_get_function_from_frame (struct frame_info *fi)
 }
 
 void
-tui_show_locator_content (void)
+tui_locator_window::rerender ()
 {
-  char *string;
-  struct tui_locator_window *locator;
-
-  locator = tui_locator_win_info_ptr ();
-
-  if (locator != NULL && locator->handle != NULL)
+  if (handle != NULL)
     {
-      string = tui_make_status_line (locator);
-      wmove (locator->handle, 0, 0);
+      char *string = tui_make_status_line (this);
+      wmove (handle, 0, 0);
       /* We ignore the return value from wstandout and wstandend, casting
 	 them to void in order to avoid a compiler warning.  The warning
 	 itself was introduced by a patch to ncurses 5.7 dated 2009-08-29,
 	 changing these macro to expand to code that causes the compiler
 	 to generate an unused-value warning.  */
-      (void) wstandout (locator->handle);
-      waddstr (locator->handle, string);
-      wclrtoeol (locator->handle);
-      (void) wstandend (locator->handle);
-      locator->refresh_window ();
-      wmove (locator->handle, 0, 0);
+      (void) wstandout (handle);
+      waddstr (handle, string);
+      wclrtoeol (handle);
+      (void) wstandend (handle);
+      refresh_window ();
+      wmove (handle, 0, 0);
       xfree (string);
     }
 }
 
-void
-tui_locator_window::rerender ()
-{
-  tui_show_locator_content ();
-}
-
 /* See tui-stack.h.  */
 
 void
@@ -411,6 +400,13 @@ tui_show_frame_info (struct frame_info *fi)
     }
 }
 
+void
+tui_show_locator_content ()
+{
+  struct tui_locator_window *locator = tui_locator_win_info_ptr ();
+  locator->rerender ();
+}
+
 /* Function to initialize gdb commands, for tui window stack
    manipulation.  */
 
-- 
2.17.2

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

* [PATCH 13/15] Minor rearrangement of tui-stack.c
  2019-08-21  2:27 [PATCH 00/15] More TUI Refactorings Tom Tromey
                   ` (10 preceding siblings ...)
  2019-08-21  2:25 ` [PATCH 03/15] Remove some checks of .empty() Tom Tromey
@ 2019-08-21  2:27 ` Tom Tromey
  2019-08-21  2:27 ` [PATCH 08/15] Don't call touchwin in tui_gen_win_info::refresh_window Tom Tromey
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2019-08-21  2:27 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This move _initialize_tui_stack to the end of tui-stack.c, per the gdb
style; and then removes two unnecessary forward declarations.

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

	* tui/tui-stack.c (_initialize_tui_stack): Move later.
	Remove unnecessary forward declarations.
---
 gdb/ChangeLog       |  5 +++++
 gdb/tui/tui-stack.c | 20 +++++++-------------
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index f6b6bb72b2a..36208d0cac0 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -53,12 +53,6 @@
 
 static struct tui_locator_window _locator;
 
-/* Get a printable name for the function at the address.
-   The symbol name is demangled if demangling is turned on.
-   Returns a pointer to a static area holding the result.  */
-static char *tui_get_function_from_frame (struct frame_info *fi);
-
-static void tui_update_command (const char *, int);
 \f
 
 /* Accessor for the locator win info.  Answers a pointer to the static
@@ -405,6 +399,13 @@ tui_show_locator_content ()
   locator->rerender ();
 }
 
+/* Command to update the display with the current execution point.  */
+static void
+tui_update_command (const char *arg, int from_tty)
+{
+  execute_command ("frame 0", from_tty);
+}
+
 /* Function to initialize gdb commands, for tui window stack
    manipulation.  */
 
@@ -415,10 +416,3 @@ _initialize_tui_stack (void)
 	   _("Update the source window and locator to "
 	     "display the current execution point."));
 }
-
-/* Command to update the display with the current execution point.  */
-static void
-tui_update_command (const char *arg, int from_tty)
-{
-  execute_command ("frame 0", from_tty);
-}
-- 
2.17.2

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

* [PATCH 00/15] More TUI Refactorings
@ 2019-08-21  2:27 Tom Tromey
  2019-08-21  2:25 ` [PATCH 15/15] Remove tui_win_info::refresh_all Tom Tromey
                   ` (15 more replies)
  0 siblings, 16 replies; 20+ messages in thread
From: Tom Tromey @ 2019-08-21  2:27 UTC (permalink / raw)
  To: gdb-patches

Here is another series of TUI refactorings.  There should be no
user-visible changes in this series (patch #1 changes a message, but I
don't believe it can actually be seen).

I tested each one using the gdb.tui tests.  This worked here, though
as we learned recently, at least empty.exp is not very reliable.

There's about one more series of this size waiting to be submitted,
plus one (or maybe two) patches that change the TUI in small
user-visible ways.

Tom


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

* [PATCH 14/15] Don't call wrefresh from tui_cont_sig
  2019-08-21  2:27 [PATCH 00/15] More TUI Refactorings Tom Tromey
                   ` (13 preceding siblings ...)
  2019-08-21  2:27 ` [PATCH 11/15] Swap tui_show_locator_content and tui_locator_window::rerender Tom Tromey
@ 2019-08-21  2:31 ` Tom Tromey
  2019-08-26 14:08 ` [PATCH 00/15] More TUI Refactorings Pedro Alves
  15 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2019-08-21  2:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_cont_sig does not need to call wrefresh, because this is already
done by tui_refresh_all_win.

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

	* tui/tui-io.c (tui_cont_sig): Don't call wrefresh.
---
 gdb/ChangeLog    | 4 ++++
 gdb/tui/tui-io.c | 2 --
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index ac7f0982755..ee581a2ff66 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -851,8 +851,6 @@ tui_cont_sig (int sig)
 
       /* Force a refresh of the screen.  */
       tui_refresh_all_win ();
-
-      wrefresh (TUI_CMD_WIN->handle);
     }
   signal (sig, tui_cont_sig);
 }
-- 
2.17.2

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

* Re: [PATCH 05/15] Private data members in tui_data_window
  2019-08-21  2:25 ` [PATCH 05/15] Private data members in tui_data_window Tom Tromey
@ 2019-08-26 14:06   ` Pedro Alves
  2019-08-30 19:06     ` Tom Tromey
  0 siblings, 1 reply; 20+ messages in thread
From: Pedro Alves @ 2019-08-26 14:06 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 8/21/19 3:25 AM, Tom Tromey wrote:
> This changes tui_data_window so that the data members are private.
> This required the addition of a simple accessor method in one case.

OOC, do you have plans at some point later in the series to rename
local variables to m_xxx ?

(I understand not doing this now, and am not suggesting it.)

Thanks,
Pedro Alves

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

* Re: [PATCH 00/15] More TUI Refactorings
  2019-08-21  2:27 [PATCH 00/15] More TUI Refactorings Tom Tromey
                   ` (14 preceding siblings ...)
  2019-08-21  2:31 ` [PATCH 14/15] Don't call wrefresh from tui_cont_sig Tom Tromey
@ 2019-08-26 14:08 ` Pedro Alves
  2019-08-30 19:06   ` Tom Tromey
  15 siblings, 1 reply; 20+ messages in thread
From: Pedro Alves @ 2019-08-26 14:08 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 8/21/19 3:25 AM, Tom Tromey wrote:
> Here is another series of TUI refactorings.  There should be no
> user-visible changes in this series (patch #1 changes a message, but I
> don't believe it can actually be seen).
> 
> I tested each one using the gdb.tui tests.  This worked here, though
> as we learned recently, at least empty.exp is not very reliable.
> 
> There's about one more series of this size waiting to be submitted,
> plus one (or maybe two) patches that change the TUI in small
> user-visible ways.

LGTM.  

Nice to see the number of rerender/refresh methods down.

Thanks,
Pedro Alves

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

* Re: [PATCH 00/15] More TUI Refactorings
  2019-08-26 14:08 ` [PATCH 00/15] More TUI Refactorings Pedro Alves
@ 2019-08-30 19:06   ` Tom Tromey
  0 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2019-08-30 19:06 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> On 8/21/19 3:25 AM, Tom Tromey wrote:
>> Here is another series of TUI refactorings.  There should be no
>> user-visible changes in this series (patch #1 changes a message, but I
>> don't believe it can actually be seen).
>> 
>> I tested each one using the gdb.tui tests.  This worked here, though
>> as we learned recently, at least empty.exp is not very reliable.
>> 
>> There's about one more series of this size waiting to be submitted,
>> plus one (or maybe two) patches that change the TUI in small
>> user-visible ways.

Pedro> LGTM.  

Thanks.  I'm checking this in now.

Tom

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

* Re: [PATCH 05/15] Private data members in tui_data_window
  2019-08-26 14:06   ` Pedro Alves
@ 2019-08-30 19:06     ` Tom Tromey
  0 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2019-08-30 19:06 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> On 8/21/19 3:25 AM, Tom Tromey wrote:
>> This changes tui_data_window so that the data members are private.
>> This required the addition of a simple accessor method in one case.

Pedro> OOC, do you have plans at some point later in the series to rename
Pedro> local variables to m_xxx ?

Pedro> (I understand not doing this now, and am not suggesting it.)

I didn't but it's no trouble.

Tom

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

end of thread, other threads:[~2019-08-30 19:06 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-21  2:27 [PATCH 00/15] More TUI Refactorings Tom Tromey
2019-08-21  2:25 ` [PATCH 15/15] Remove tui_win_info::refresh_all Tom Tromey
2019-08-21  2:25 ` [PATCH 02/15] Remove tui_data_window::display_all_data Tom Tromey
2019-08-21  2:25 ` [PATCH 04/15] Remove some calls in tui_data_window Tom Tromey
2019-08-21  2:25 ` [PATCH 12/15] Make tui_locator_window::set_locator_fullname re-render Tom Tromey
2019-08-21  2:25 ` [PATCH 01/15] Remove NO_DATA_STRING Tom Tromey
2019-08-21  2:25 ` [PATCH 06/15] Simplify register display Tom Tromey
2019-08-21  2:25 ` [PATCH 05/15] Private data members in tui_data_window Tom Tromey
2019-08-26 14:06   ` Pedro Alves
2019-08-30 19:06     ` Tom Tromey
2019-08-21  2:25 ` [PATCH 07/15] Remove NULL checks from box_win Tom Tromey
2019-08-21  2:25 ` [PATCH 10/15] Turn two locator functions into methods Tom Tromey
2019-08-21  2:25 ` [PATCH 09/15] Don't call tui_refresh_all from show_layout Tom Tromey
2019-08-21  2:25 ` [PATCH 03/15] Remove some checks of .empty() Tom Tromey
2019-08-21  2:27 ` [PATCH 13/15] Minor rearrangement of tui-stack.c Tom Tromey
2019-08-21  2:27 ` [PATCH 08/15] Don't call touchwin in tui_gen_win_info::refresh_window Tom Tromey
2019-08-21  2:27 ` [PATCH 11/15] Swap tui_show_locator_content and tui_locator_window::rerender Tom Tromey
2019-08-21  2:31 ` [PATCH 14/15] Don't call wrefresh from tui_cont_sig Tom Tromey
2019-08-26 14:08 ` [PATCH 00/15] More TUI Refactorings Pedro Alves
2019-08-30 19:06   ` Tom Tromey

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).