public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 12/66] Don't use TUI_DISASM_WIN in tui_disasm_window method
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
@ 2019-06-23 22:43 ` Tom Tromey
  2019-06-23 22:43 ` [PATCH 13/66] Remove tui_clear_win_detail Tom Tromey
                   ` (49 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:43 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The previous patch made it clear that the diassembly window scrolling
method was written to assume there could only ever be a single
disassembly window.  This changes that spot to use "this" rather than
the TUI_DISASM_WIN global.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-disasm.c (tui_disasm_window::do_scroll_vertical): Use
	"this", not TUI_DISASM_WIN.
---
 gdb/ChangeLog        | 5 +++++
 gdb/tui/tui-disasm.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 838f36cf295..efb9d1cb628 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -393,7 +393,7 @@ tui_disasm_window::do_scroll_vertical
 
       val.loa = LOA_ADDRESS;
       val.u.addr = tui_find_disassembly_address (gdbarch, pc, dir);
-      tui_update_source_window_as_is (TUI_DISASM_WIN, gdbarch,
+      tui_update_source_window_as_is (this, gdbarch,
 				      NULL, val, FALSE);
     }
 }
-- 
2.17.2

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

* [PATCH 10/66] Create tui_disasm_window
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (3 preceding siblings ...)
  2019-06-23 22:43 ` [PATCH 05/66] Simplify command window creation Tom Tromey
@ 2019-06-23 22:43 ` Tom Tromey
  2019-06-23 22:43 ` [PATCH 08/66] Remove tui_list Tom Tromey
                   ` (45 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:43 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces the new tui_disasm_window class, which represents a
disassembly window.  It shares a lot of behavior with the source
window, so a new tui_source_window_base class is also created.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (struct tui_source_window_base): New struct.
	(struct tui_source_window): Derive from tui_source_window_base.
	(struct tui_disasm_window): New struct.
	* tui/tui-data.c (tui_source_window_base::clear_detail): Rename
	from tui_source_window::clear_detail.
	(tui_source_window_base): Rename from tui_source_window.
	(~tui_source_window_base): Rename from ~tui_source_window.
	(tui_alloc_win_info): Create a tui_disasm_window.
---
 gdb/ChangeLog      | 11 +++++++++++
 gdb/tui/tui-data.c | 10 ++++++----
 gdb/tui/tui-data.h | 38 ++++++++++++++++++++++++++++++++++----
 3 files changed, 51 insertions(+), 8 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 8993bfe5d47..b3d68df8f3c 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -176,7 +176,7 @@ tui_add_to_source_windows (struct tui_win_info *win_info)
 /* See tui-data.h.  */
 
 void
-tui_source_window::clear_detail ()
+tui_source_window_base::clear_detail ()
 {
   detail.source_info.gdbarch = NULL;
   detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
@@ -503,7 +503,7 @@ tui_win_info::tui_win_info (enum tui_win_type type)
   tui_init_generic_part (&generic);
 }
 
-tui_source_window::tui_source_window (enum tui_win_type type)
+tui_source_window_base::tui_source_window_base (enum tui_win_type type)
   : tui_win_info (type)
 {
   gdb_assert (type == SRC_WIN || type == DISASSEM_WIN);
@@ -539,8 +539,10 @@ tui_alloc_win_info (enum tui_win_type type)
   switch (type)
     {
     case SRC_WIN:
+      return new tui_source_window ();
+
     case DISASSEM_WIN:
-      return new tui_source_window (type);
+      return new tui_disasm_window ();
 
     case DATA_WIN:
       return new tui_data_window ();
@@ -617,7 +619,7 @@ tui_add_content_elements (struct tui_gen_win_info *win_info,
   return index_start;
 }
 
-tui_source_window::~tui_source_window ()
+tui_source_window_base::~tui_source_window_base ()
 {
   if (detail.source_info.fullname)
     {
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 2a775a42be8..fe00d9ed2bd 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -291,15 +291,45 @@ public:
   int is_highlighted = 0;
 };
 
-struct tui_source_window : public tui_win_info
+/* The base class for all source-like windows, namely the source and
+   disassembly windows.  */
+
+struct tui_source_window_base : public tui_win_info
 {
-  tui_source_window (enum tui_win_type type);
-  ~tui_source_window () override;
-  DISABLE_COPY_AND_ASSIGN (tui_source_window);
+protected:
+  tui_source_window_base (enum tui_win_type type);
+  ~tui_source_window_base () override;
+  DISABLE_COPY_AND_ASSIGN (tui_source_window_base);
+
+public:
 
   void clear_detail () override;
 };
 
+/* A TUI source window.  */
+
+struct tui_source_window : public tui_source_window_base
+{
+  tui_source_window ()
+    : tui_source_window_base (SRC_WIN)
+  {
+  }
+
+  DISABLE_COPY_AND_ASSIGN (tui_source_window);
+};
+
+/* A TUI disassembly window.  */
+
+struct tui_disasm_window : public tui_source_window_base
+{
+  tui_disasm_window ()
+    : tui_source_window_base (DISASSEM_WIN)
+  {
+  }
+
+  DISABLE_COPY_AND_ASSIGN (tui_disasm_window);
+};
+
 struct tui_data_window : public tui_win_info
 {
   tui_data_window ();
-- 
2.17.2

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

* [PATCH 01/66] Use new and delete for TUI windows
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
  2019-06-23 22:43 ` [PATCH 12/66] Don't use TUI_DISASM_WIN in tui_disasm_window method Tom Tromey
  2019-06-23 22:43 ` [PATCH 13/66] Remove tui_clear_win_detail Tom Tromey
@ 2019-06-23 22:43 ` Tom Tromey
  2019-06-23 22:43 ` [PATCH 05/66] Simplify command window creation Tom Tromey
                   ` (47 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:43 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_win_info to use new and delete, rather than XNEW and
xfree.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (struct tui_win_info): Add constructor.
	* tui/tui-data.c (tui_alloc_win_info): Use new.
	(tui_free_window): Use delete.
---
 gdb/ChangeLog      | 6 ++++++
 gdb/tui/tui-data.c | 5 ++---
 gdb/tui/tui-data.h | 7 +++++++
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index b67cb48c2e6..117bda3c200 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -531,9 +531,8 @@ init_win_info (struct tui_win_info *win_info)
 struct tui_win_info *
 tui_alloc_win_info (enum tui_win_type type)
 {
-  struct tui_win_info *win_info = XNEW (struct tui_win_info);
+  struct tui_win_info *win_info = new struct tui_win_info (type);
 
-  win_info->generic.type = type;
   init_win_info (win_info);
 
   return win_info;
@@ -654,7 +653,7 @@ tui_free_window (struct tui_win_info *win_info)
     }
   if (win_info->generic.title)
     xfree (win_info->generic.title);
-  xfree (win_info);
+  delete win_info;
 }
 
 
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index c696feed280..34822e2a92d 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -271,6 +271,13 @@ struct tui_command_info
 /* This defines information about each logical window.  */
 struct tui_win_info
 {
+  tui_win_info (enum tui_win_type type)
+  {
+    generic.type = type;
+  }
+
+  DISABLE_COPY_AND_ASSIGN (tui_win_info);
+
   struct tui_gen_win_info generic;	/* General window information.  */
   union
   {
-- 
2.17.2

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

* [PATCH 05/66] Simplify command window creation
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (2 preceding siblings ...)
  2019-06-23 22:43 ` [PATCH 01/66] Use new and delete for TUI windows Tom Tromey
@ 2019-06-23 22:43 ` Tom Tromey
  2019-06-23 22:43 ` [PATCH 10/66] Create tui_disasm_window Tom Tromey
                   ` (46 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:43 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

make_command_window is never called when *win_info_ptr is non-NULL, so
this patch simplifies the function by removing the parameter and
having it return its result directly.  This in turn makes it more
obvious that a NULL check in show_source_disasm_command can be
removed.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (make_command_window): Remove win_info_ptr
	parameter.  Return the new window.
	(show_source_disasm_command): Update and remove NULL check.
	(show_source_or_disasm_and_command): Update.
---
 gdb/ChangeLog        |   7 +++
 gdb/tui/tui-layout.c | 146 ++++++++++++++++++++-----------------------
 2 files changed, 76 insertions(+), 77 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 695c56012c1..3eddc56578b 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -52,7 +52,7 @@ static void show_source_or_disasm_and_command (enum tui_layout_type);
 static void make_source_or_disasm_window (struct tui_win_info **, 
 					  enum tui_win_type, 
 					  int, int);
-static void make_command_window (struct tui_win_info **, int, int);
+static struct tui_win_info *make_command_window (int, int);
 static void make_source_window (struct tui_win_info **, int, int);
 static void make_disasm_window (struct tui_win_info **, int, int);
 static void make_data_window (struct tui_win_info **, int, int);
@@ -540,20 +540,19 @@ prev_layout (void)
 
 
 
-static void
-make_command_window (struct tui_win_info **win_info_ptr, 
-		     int height, int origin_y)
+static struct tui_win_info *
+make_command_window (int height, int origin_y)
 {
-  *win_info_ptr
-    = (struct tui_win_info *) init_and_make_win (*win_info_ptr,
+  struct tui_win_info *result
+    = (struct tui_win_info *) init_and_make_win (NULL,
 						 CMD_WIN,
 						 height,
 						 tui_term_width (),
 						 0,
 						 origin_y,
 						 DONT_BOX_WINDOW);
-
-  (*win_info_ptr)->can_highlight = FALSE;
+  result->can_highlight = FALSE;
+  return result;
 }
 
 
@@ -650,76 +649,69 @@ show_source_disasm_command (void)
 	  tui_make_visible (TUI_SRC_WIN->detail.source_info.execution_info);
 	  TUI_SRC_WIN->detail.source_info.has_locator = FALSE;;
 	}
-      if (TUI_SRC_WIN != NULL)
-	{
-	  struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
 
-	  tui_show_source_content (TUI_SRC_WIN);
-	  if (TUI_DISASM_WIN == NULL)
-	    {
-	      make_disasm_window (&TUI_DISASM_WIN, asm_height, src_height - 1);
-	      locator
-		= ((struct tui_gen_win_info *)
-		   init_and_make_win (locator,
-				      LOCATOR_WIN,
-				      2 /* 1 */ ,
-				      tui_term_width (),
-				      0,
-				      (src_height + asm_height) - 1,
-				      DONT_BOX_WINDOW));
-	    }
-	  else
-	    {
-	      init_gen_win_info (locator,
-				 LOCATOR_WIN,
-				 2 /* 1 */ ,
-				 tui_term_width (),
-				 0,
-				 (src_height + asm_height) - 1);
-	      TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
-	      init_gen_win_info (&TUI_DISASM_WIN->generic,
-				 TUI_DISASM_WIN->generic.type,
-				 asm_height,
-				 TUI_DISASM_WIN->generic.width,
-				 TUI_DISASM_WIN->detail.source_info.execution_info->width,
-				 src_height - 1);
-	      init_gen_win_info (TUI_DISASM_WIN->detail.source_info.execution_info,
-				 EXEC_INFO_WIN,
-				 asm_height,
-				 3,
-				 0,
-				 src_height - 1);
-	      TUI_DISASM_WIN->can_highlight = TRUE;
-	      tui_make_visible (&TUI_DISASM_WIN->generic);
-	      tui_make_visible (TUI_DISASM_WIN->detail.source_info.execution_info);
-	    }
-	  if (TUI_DISASM_WIN != NULL)
-	    {
-	      TUI_SRC_WIN->detail.source_info.has_locator = FALSE;
-	      TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
-	      tui_make_visible (locator);
-	      tui_show_locator_content ();
-	      tui_show_source_content (TUI_DISASM_WIN);
-
-	      if (TUI_CMD_WIN == NULL)
-		make_command_window (&TUI_CMD_WIN,
-				     cmd_height,
-				     tui_term_height () - cmd_height);
-	      else
-		{
-		  init_gen_win_info (&TUI_CMD_WIN->generic,
-				     TUI_CMD_WIN->generic.type,
-				     TUI_CMD_WIN->generic.height,
-				     TUI_CMD_WIN->generic.width,
-				     0,
-				     TUI_CMD_WIN->generic.origin.y);
-		  TUI_CMD_WIN->can_highlight = FALSE;
-		  tui_make_visible (&TUI_CMD_WIN->generic);
-		}
-	      if (TUI_CMD_WIN != NULL)
-		tui_refresh_win (&TUI_CMD_WIN->generic);
-	    }
+      struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+
+      tui_show_source_content (TUI_SRC_WIN);
+      if (TUI_DISASM_WIN == NULL)
+	{
+	  make_disasm_window (&TUI_DISASM_WIN, asm_height, src_height - 1);
+	  locator
+	    = ((struct tui_gen_win_info *)
+	       init_and_make_win (locator,
+				  LOCATOR_WIN,
+				  2 /* 1 */ ,
+				  tui_term_width (),
+				  0,
+				  (src_height + asm_height) - 1,
+				  DONT_BOX_WINDOW));
+	}
+      else
+	{
+	  init_gen_win_info (locator,
+			     LOCATOR_WIN,
+			     2 /* 1 */ ,
+			     tui_term_width (),
+			     0,
+			     (src_height + asm_height) - 1);
+	  TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
+	  init_gen_win_info (&TUI_DISASM_WIN->generic,
+			     TUI_DISASM_WIN->generic.type,
+			     asm_height,
+			     TUI_DISASM_WIN->generic.width,
+			     TUI_DISASM_WIN->detail.source_info.execution_info->width,
+			     src_height - 1);
+	  init_gen_win_info (TUI_DISASM_WIN->detail.source_info.execution_info,
+			     EXEC_INFO_WIN,
+			     asm_height,
+			     3,
+			     0,
+			     src_height - 1);
+	  TUI_DISASM_WIN->can_highlight = TRUE;
+	  tui_make_visible (&TUI_DISASM_WIN->generic);
+	  tui_make_visible (TUI_DISASM_WIN->detail.source_info.execution_info);
+	}
+      TUI_SRC_WIN->detail.source_info.has_locator = FALSE;
+      TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
+      tui_make_visible (locator);
+      tui_show_locator_content ();
+      tui_show_source_content (TUI_DISASM_WIN);
+
+      if (TUI_CMD_WIN == NULL)
+	TUI_CMD_WIN = make_command_window (cmd_height,
+					   tui_term_height () - cmd_height);
+      else
+	{
+	  init_gen_win_info (&TUI_CMD_WIN->generic,
+			     TUI_CMD_WIN->generic.type,
+			     TUI_CMD_WIN->generic.height,
+			     TUI_CMD_WIN->generic.width,
+			     0,
+			     TUI_CMD_WIN->generic.origin.y);
+	  TUI_CMD_WIN->can_highlight = FALSE;
+	  tui_make_visible (&TUI_CMD_WIN->generic);
 	}
+      tui_refresh_win (&TUI_CMD_WIN->generic);
       tui_set_current_layout_to (SRC_DISASSEM_COMMAND);
     }
 }
@@ -964,7 +956,7 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 
 	  if (TUI_CMD_WIN == NULL)
 	    {
-	      make_command_window (&TUI_CMD_WIN, cmd_height, src_height);
+	      TUI_CMD_WIN = make_command_window (cmd_height, src_height);
 	      tui_refresh_win (&TUI_CMD_WIN->generic);
 	    }
 	  else
-- 
2.17.2

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

* [PATCH 08/66] Remove tui_list
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (4 preceding siblings ...)
  2019-06-23 22:43 ` [PATCH 10/66] Create tui_disasm_window Tom Tromey
@ 2019-06-23 22:43 ` Tom Tromey
  2019-06-24 14:12   ` Pedro Alves
  2019-06-23 22:44 ` [PATCH 26/66] Introduce set_new_height method Tom Tromey
                   ` (44 subsequent siblings)
  50 siblings, 1 reply; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:43 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This removes the tui_list type in favor of a std::vector.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_display_main)
	(tui_update_source_windows_with_addr)
	(tui_update_all_breakpoint_info): Update.
	* tui/tui-win.c (tui_resize_all, tui_adjust_win_heights)
	(new_height_ok, parse_scrolling_args): Update.
	* tui/tui-stack.c (tui_show_frame_info): Update.
	* tui/tui-data.h (struct tui_list): Remove.
	(tui_source_windows): Return a reference to a std::vector.
	* tui/tui-data.c (source_windows): Now a std::vector.
	(tui_source_windows): Change return type.
	(tui_clear_source_windows): Rewrite.
	(tui_clear_source_windows_detail, tui_add_to_source_windows)
	(tui_free_all_source_wins_content): Rewrite.
---
 gdb/ChangeLog           | 16 ++++++++++++++++
 gdb/tui/tui-data.c      | 42 +++++++++++++++--------------------------
 gdb/tui/tui-data.h      | 10 +---------
 gdb/tui/tui-stack.c     | 10 +++-------
 gdb/tui/tui-win.c       | 14 +++++++-------
 gdb/tui/tui-winsource.c | 19 +++++--------------
 6 files changed, 47 insertions(+), 64 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 9923a2fb052..d98f916ac5b 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -38,8 +38,7 @@ static enum tui_layout_type current_layout = UNDEFINED_LAYOUT;
 static int term_height, term_width;
 static struct tui_gen_win_info _locator;
 static struct tui_gen_win_info exec_info[2];
-static struct tui_win_info *src_win_list[2];
-static struct tui_list source_windows = {src_win_list, 0};
+static struct std::vector<tui_win_info *> source_windows;
 static struct tui_win_info *win_with_focus = NULL;
 static struct tui_layout_def layout_def = {
   SRC_WIN,			/* DISPLAY_MODE */
@@ -138,10 +137,10 @@ tui_set_win_with_focus (struct tui_win_info *win_info)
 /* Accessor for the current source window.  Usually there is only one
    source window (either source or disassembly), but both can be
    displayed at the same time.  */
-struct tui_list *
-tui_source_windows (void)
+struct std::vector<tui_win_info *> &
+tui_source_windows ()
 {
-  return &source_windows;
+  return source_windows;
 }
 
 
@@ -149,22 +148,18 @@ tui_source_windows (void)
    window (either source or disassembly), but both can be displayed at
    the same time.  */
 void
-tui_clear_source_windows (void)
+tui_clear_source_windows ()
 {
-  source_windows.list[0] = NULL;
-  source_windows.list[1] = NULL;
-  source_windows.count = 0;
+  source_windows.clear ();
 }
 
 
 /* Clear the pertinant detail in the source windows.  */
 void
-tui_clear_source_windows_detail (void)
+tui_clear_source_windows_detail ()
 {
-  int i;
-
-  for (i = 0; i < (tui_source_windows ())->count; i++)
-    tui_clear_win_detail ((tui_source_windows ())->list[i]);
+  for (tui_win_info *win : tui_source_windows ())
+    tui_clear_win_detail (win);
 }
 
 
@@ -174,8 +169,8 @@ tui_clear_source_windows_detail (void)
 void
 tui_add_to_source_windows (struct tui_win_info *win_info)
 {
-  if (source_windows.count < 2)
-    source_windows.list[source_windows.count++] = win_info;
+  if (source_windows.size () < 2)
+    source_windows.push_back (win_info);
 }
 
 /* See tui-data.h.  */
@@ -675,19 +670,12 @@ tui_win_info::~tui_win_info ()
 
 
 void
-tui_free_all_source_wins_content (void)
+tui_free_all_source_wins_content ()
 {
-  int i;
-
-  for (i = 0; i < (tui_source_windows ())->count; i++)
+  for (tui_win_info *win_info : tui_source_windows ())
     {
-      struct tui_win_info *win_info = (tui_source_windows ())->list[i];
-
-      if (win_info != NULL)
-	{
-	  tui_free_win_content (&(win_info->generic));
-	  tui_free_win_content (win_info->detail.source_info.execution_info);
-	}
+      tui_free_win_content (&(win_info->generic));
+      tui_free_win_content (win_info->detail.source_info.execution_info);
     }
 }
 
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 281729f7deb..d07862f29f8 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -102,14 +102,6 @@ enum tui_scroll_direction
 };
 
 
-/* General list struct.  */
-struct tui_list
-{
-  struct tui_win_info **list;
-  int count;
-};
-
-
 /* The kinds of layouts available.  */
 enum tui_layout_type
 {
@@ -360,7 +352,7 @@ extern void tui_set_term_width_to (int);
 extern struct tui_gen_win_info *tui_locator_win_info_ptr (void);
 extern struct tui_gen_win_info *tui_source_exec_info_win_ptr (void);
 extern struct tui_gen_win_info *tui_disassem_exec_info_win_ptr (void);
-extern struct tui_list *tui_source_windows (void);
+extern struct std::vector<tui_win_info *> &tui_source_windows ();
 extern void tui_clear_source_windows (void);
 extern void tui_clear_source_windows_detail (void);
 extern void tui_clear_win_detail (struct tui_win_info *);
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index b7e7ae81dff..d09acd28585 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -360,12 +360,11 @@ tui_update_locator_fullname (const char *fullname)
 int
 tui_show_frame_info (struct frame_info *fi)
 {
-  struct tui_win_info *win_info;
   int locator_changed_p;
 
   if (fi)
     {
-      int start_line, i;
+      int start_line;
       CORE_ADDR low;
       struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
       int source_already_displayed;
@@ -397,12 +396,10 @@ tui_show_frame_info (struct frame_info *fi)
 
       tui_show_locator_content ();
       start_line = 0;
-      for (i = 0; i < (tui_source_windows ())->count; i++)
+      for (struct tui_win_info *win_info : tui_source_windows ())
 	{
 	  union tui_which_element *item;
 
-	  win_info = (tui_source_windows ())->list[i];
-
 	  item = &locator->content[0]->which_element;
 	  if (win_info == TUI_SRC_WIN)
 	    {
@@ -475,9 +472,8 @@ tui_show_frame_info (struct frame_info *fi)
 	return 0;
 
       tui_show_locator_content ();
-      for (int i = 0; i < (tui_source_windows ())->count; i++)
+      for (struct tui_win_info *win_info : tui_source_windows ())
 	{
-	  win_info = (tui_source_windows ())->list[i];
 	  tui_clear_source_content (win_info, EMPTY_SOURCE_PROMPT);
 	  tui_update_exec_info (win_info);
 	}
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index a69e0878eff..21a9946792e 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -686,7 +686,7 @@ tui_resize_all (void)
        {
 	case SRC_COMMAND:
 	case DISASSEM_COMMAND:
-	  first_win = tui_source_windows ()->list[0];
+	  first_win = tui_source_windows ()[0];
 	  first_win->generic.width += width_diff;
 	  locator->width += width_diff;
 	  /* Check for invalid heights.  */
@@ -723,7 +723,7 @@ tui_resize_all (void)
 	    {
 	      first_win = TUI_DATA_WIN;
 	      first_win->generic.width += width_diff;
-	      second_win = tui_source_windows ()->list[0];
+	      second_win = tui_source_windows ()[0];
 	      second_win->generic.width += width_diff;
 	    }
 	  /* Change the first window's height/width.  */
@@ -1204,7 +1204,7 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 	      make_invisible_and_set_new_height (primary_win_info, new_height);
 	      if (primary_win_info->generic.type == CMD_WIN)
 		{
-		  win_info = (tui_source_windows ())->list[0];
+		  win_info = tui_source_windows ()[0];
 		  src_win_info = win_info;
 		}
 	      else
@@ -1233,7 +1233,7 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 	      else
 		{
 		  first_win = TUI_DATA_WIN;
-		  second_win = (tui_source_windows ())->list[0];
+		  second_win = tui_source_windows ()[0];
 		}
 	      if (primary_win_info == TUI_CMD_WIN)
 		{ /* Split the change in height accross the 1st & 2nd
@@ -1490,7 +1490,7 @@ new_height_ok (struct tui_win_info *primary_win_info,
 	      struct tui_win_info *win_info;
 
 	      if (primary_win_info == TUI_CMD_WIN)
-		win_info = (tui_source_windows ())->list[0];
+		win_info = tui_source_windows ()[0];
 	      else
 		win_info = TUI_CMD_WIN;
 	      ok = ((new_height +
@@ -1511,7 +1511,7 @@ new_height_ok (struct tui_win_info *primary_win_info,
 	  else
 	    {
 	      first_win = TUI_DATA_WIN;
-	      second_win = (tui_source_windows ())->list[0];
+	      second_win = tui_source_windows ()[0];
 	    }
 	  /* We could simply add all the heights to obtain the same
 	     result but below is more explicit since we subtract 1 for
@@ -1637,7 +1637,7 @@ parse_scrolling_args (const char *arg,
 	    error (_("Invalid window specified. \n\
 The window name specified must be valid and visible.\n"));
 	  else if (*win_to_scroll == TUI_CMD_WIN)
-	    *win_to_scroll = (tui_source_windows ())->list[0];
+	    *win_to_scroll = tui_source_windows ()[0];
 	}
     }
 }
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index eab422d6cf1..20f39c4fb6e 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -42,9 +42,9 @@
 
 /* Function to display the "main" routine.  */
 void
-tui_display_main (void)
+tui_display_main ()
 {
-  if ((tui_source_windows ())->count > 0)
+  if (!tui_source_windows ().empty ())
     {
       struct gdbarch *gdbarch;
       CORE_ADDR addr;
@@ -159,12 +159,8 @@ tui_update_source_windows_with_addr (struct gdbarch *gdbarch, CORE_ADDR addr)
     }
   else
     {
-      int i;
-
-      for (i = 0; i < (tui_source_windows ())->count; i++)
+      for (struct tui_win_info *win_info : tui_source_windows ())
 	{
-	  struct tui_win_info *win_info = (tui_source_windows ())->list[i];
-
 	  tui_clear_source_content (win_info, EMPTY_SOURCE_PROMPT);
 	  tui_clear_exec_info_content (win_info);
 	}
@@ -406,15 +402,10 @@ tui_set_is_exec_point_at (struct tui_line_or_address l,
    This is called whenever a breakpoint is inserted, removed or
    has its state changed.  */
 void
-tui_update_all_breakpoint_info (void)
+tui_update_all_breakpoint_info ()
 {
-  struct tui_list *list = tui_source_windows ();
-  int i;
-
-  for (i = 0; i < list->count; i++)
+  for (tui_win_info *win : tui_source_windows ())
     {
-      struct tui_win_info *win = list->list[i];
-
       if (tui_update_breakpoint_info (win, FALSE))
         {
           tui_update_exec_info (win);
-- 
2.17.2

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

* [PATCH 00/66] Clean up the TUI
@ 2019-06-23 22:43 Tom Tromey
  2019-06-23 22:43 ` [PATCH 12/66] Don't use TUI_DISASM_WIN in tui_disasm_window method Tom Tromey
                   ` (50 more replies)
  0 siblings, 51 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:43 UTC (permalink / raw)
  To: gdb-patches

My first real encounter with the TUI code was last year, when I added
syntax styling to it.

On the one hand, this experience convinced me that this code was some
of the ugliest in gdb.  It uses two different unions at different
spots in the conceptual class hierarchy, leading to very obscure code.
It also hard-codes both the possible window types but also the
qpossible layout types in a brittle and unextensible way.

On the other hand, working on the TUI changed my mind about the TUI
generally.  I've become a fan.  I think it would be good to improve
the TUI for users, but to do that I think we first have to improve its
code.

This series is a start at this.  It's already quite long,
unfortunately, and yet is still incomplete.  Still, I think it is
progress.  This series:

* Splits tui_win_info into subclasses, one per window type.

* Adds virtual methods, particularly in an attempt to remove all the
  code that switches based on the type of the window.  This is
  important to make it simpler to add new window types.

* Changes tui_gen_win_info into a real base class for tui_win_info.

* Removes the uses of unions from the window class hierarchy.

* Simplifies and C++-ifies various other minor things along the way.

There is still a ways to go, I only stopped here in the interest of
review sanity.  In particular:

* Window layouts should be first-class entities that do not involve
  hard-coding the possible layouts in the C++.

* tui_win_list should be changed to allow multiple types of windows.

* The few remaining checks of the various *_WIN constants should be
  removed.

I think once these things are done it should be possible to move on to
making useful user-visible changes, like allowing custom layouts, or
allowing custom windows to be written in Python.

I tested this by trying the various TUI features by hand.  However,
I'm not sure I managed to test them all.  I've also run the gdb.tui
part of the test suite, though that does not really test very much.

This series fixes one latent bug that I found with valgrind.  I found
two other existing bugs as well, but those I simply filed.

Tom


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

* [PATCH 13/66] Remove tui_clear_win_detail
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
  2019-06-23 22:43 ` [PATCH 12/66] Don't use TUI_DISASM_WIN in tui_disasm_window method Tom Tromey
@ 2019-06-23 22:43 ` Tom Tromey
  2019-06-23 22:43 ` [PATCH 01/66] Use new and delete for TUI windows Tom Tromey
                   ` (48 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:43 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

An earlier patch changed the context of the sole call to
tui_clear_win_detail to make it clear that this can never be called
with a NULL window pointer.  So, remove tui_clear_win_detail in favor
of calling the method directly.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (tui_clear_win_detail): Don't declare.
	* tui/tui-data.c (tui_clear_source_windows_detail): Call the
	clear_detail method directly.
	(tui_clear_win_detail): Remove.
---
 gdb/ChangeLog      |  7 +++++++
 gdb/tui/tui-data.c | 11 +----------
 gdb/tui/tui-data.h |  1 -
 3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index b3d68df8f3c..b5852bed0bb 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -159,7 +159,7 @@ void
 tui_clear_source_windows_detail ()
 {
   for (tui_win_info *win : tui_source_windows ())
-    tui_clear_win_detail (win);
+    win->clear_detail ();
 }
 
 
@@ -205,15 +205,6 @@ tui_data_window::clear_detail ()
   detail.data_display_info.display_regs = FALSE;
 }
 
-/* Clear the pertinant detail in the windows.  */
-void
-tui_clear_win_detail (struct tui_win_info *win_info)
-{
-  if (win_info != NULL)
-    win_info->clear_detail ();
-}
-
-
 /* Accessor for the source execution info ptr.  */
 struct tui_gen_win_info *
 tui_source_exec_info_win_ptr (void)
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index a4dce4d036b..54cd27c2e46 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -439,7 +439,6 @@ extern struct tui_gen_win_info *tui_disassem_exec_info_win_ptr (void);
 extern struct std::vector<tui_win_info *> &tui_source_windows ();
 extern void tui_clear_source_windows (void);
 extern void tui_clear_source_windows_detail (void);
-extern void tui_clear_win_detail (struct tui_win_info *);
 extern void tui_add_to_source_windows (struct tui_win_info *);
 extern struct tui_win_info *tui_win_with_focus (void);
 extern void tui_set_win_with_focus (struct tui_win_info *);
-- 
2.17.2

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

* [PATCH 07/66] Introduce tui_win_info::clear_detail method
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (21 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 11/66] Introduce methods for scrolling Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 23/66] Introduce the refresh method Tom Tromey
                   ` (27 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces the clear_detail method and updates the various
subclasses of tui_win_info to implement it.  A subsequent patch will
remove tui_clear_win_detail, but that isn't done for now because at
this point it isn't readily obvious that the NULL check is not needed.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (struct tui_win_info, struct tui_source_window)
	(struct tui_data_window, struct tui_cmd_window): Declare
	clear_detail method.
	* tui/tui-data.c (tui_source_window::clear_detail)
	(tui_cmd_window::clear_detail, tui_data_window::clear_detail): New
	methods.
	(tui_clear_win_detail): Simplify.
---
 gdb/ChangeLog      | 10 ++++++++
 gdb/tui/tui-data.c | 57 ++++++++++++++++++++++++++--------------------
 gdb/tui/tui-data.h |  9 ++++++++
 3 files changed, 51 insertions(+), 25 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 3320b4fc62a..9923a2fb052 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -178,37 +178,44 @@ tui_add_to_source_windows (struct tui_win_info *win_info)
     source_windows.list[source_windows.count++] = win_info;
 }
 
+/* See tui-data.h.  */
+
+void
+tui_source_window::clear_detail ()
+{
+  detail.source_info.gdbarch = NULL;
+  detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
+  detail.source_info.start_line_or_addr.u.addr = 0;
+  detail.source_info.horizontal_offset = 0;
+}
+
+/* See tui-data.h.  */
+
+void
+tui_cmd_window::clear_detail ()
+{
+  wmove (generic.handle, 0, 0);
+}
+
+/* See tui-data.h.  */
+
+void
+tui_data_window::clear_detail ()
+{
+  detail.data_display_info.data_content = NULL;
+  detail.data_display_info.data_content_count = 0;
+  detail.data_display_info.regs_content = NULL;
+  detail.data_display_info.regs_content_count = 0;
+  detail.data_display_info.regs_column_count = 1;
+  detail.data_display_info.display_regs = FALSE;
+}
 
 /* Clear the pertinant detail in the windows.  */
 void
 tui_clear_win_detail (struct tui_win_info *win_info)
 {
   if (win_info != NULL)
-    {
-      switch (win_info->generic.type)
-	{
-	case SRC_WIN:
-	case DISASSEM_WIN:
-	  win_info->detail.source_info.gdbarch = NULL;
-	  win_info->detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
-	  win_info->detail.source_info.start_line_or_addr.u.addr = 0;
-	  win_info->detail.source_info.horizontal_offset = 0;
-	  break;
-	case CMD_WIN:
-	  wmove (win_info->generic.handle, 0, 0);
-	  break;
-	case DATA_WIN:
-	  win_info->detail.data_display_info.data_content = NULL;
-	  win_info->detail.data_display_info.data_content_count = 0;
-	  win_info->detail.data_display_info.regs_content = NULL;
-	  win_info->detail.data_display_info.regs_content_count = 0;
-	  win_info->detail.data_display_info.regs_column_count = 1;
-	  win_info->detail.data_display_info.display_regs = FALSE;
-	  break;
-	default:
-	  break;
-	}
-    }
+    win_info->clear_detail ();
 }
 
 
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 2c873c26a2f..281729f7deb 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -280,6 +280,9 @@ public:
 
   virtual ~tui_win_info ();
 
+  /* Clear the pertinent detail in the window.  */
+  virtual void clear_detail () = 0;
+
   struct tui_gen_win_info generic;	/* General window information.  */
   union
   {
@@ -300,18 +303,24 @@ struct tui_source_window : public tui_win_info
 {
   tui_source_window (enum tui_win_type type);
   DISABLE_COPY_AND_ASSIGN (tui_source_window);
+
+  void clear_detail () override;
 };
 
 struct tui_data_window : public tui_win_info
 {
   tui_data_window ();
   DISABLE_COPY_AND_ASSIGN (tui_data_window);
+
+  void clear_detail () override;
 };
 
 struct tui_cmd_window : public tui_win_info
 {
   tui_cmd_window ();
   DISABLE_COPY_AND_ASSIGN (tui_cmd_window);
+
+  void clear_detail () override;
 };
 
 extern int tui_win_is_source_type (enum tui_win_type win_type);
-- 
2.17.2

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

* [PATCH 02/66] Add destructor to tui_win_info
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (15 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 04/66] Remove an unnecessary NULL check from the TUI Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 24/66] Introduce two TUI source window methods Tom Tromey
                   ` (33 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_free_window into a destructor for tui_free_window and
then updates the users.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (tui_resize_all): Use delete.
	* tui/tui-data.h (struct tui_win_info) <~tui_win_info>: Declare
	destructor.
	(tui_free_window): Don't declare.
	* tui/tui-data.c (~tui_win_info): Rename from tui_free_window.
	Update.
---
 gdb/ChangeLog      |  9 ++++++++
 gdb/tui/tui-data.c | 52 ++++++++++++++++++++++------------------------
 gdb/tui/tui-data.h |  3 ++-
 gdb/tui/tui-win.c  |  2 +-
 4 files changed, 37 insertions(+), 29 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 117bda3c200..1c96fc1c077 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -603,21 +603,20 @@ tui_add_content_elements (struct tui_gen_win_info *win_info,
   return index_start;
 }
 
-void
-tui_free_window (struct tui_win_info *win_info)
+tui_win_info::~tui_win_info ()
 {
   struct tui_gen_win_info *generic_win;
 
-  switch (win_info->generic.type)
+  switch (generic.type)
     {
     case SRC_WIN:
     case DISASSEM_WIN:
-      if (win_info->detail.source_info.fullname)
+      if (detail.source_info.fullname)
         {
-          xfree (win_info->detail.source_info.fullname);
-          win_info->detail.source_info.fullname = NULL;
+          xfree (detail.source_info.fullname);
+          detail.source_info.fullname = NULL;
         }
-      generic_win = win_info->detail.source_info.execution_info;
+      generic_win = detail.source_info.execution_info;
       if (generic_win != NULL)
 	{
 	  tui_delete_win (generic_win->handle);
@@ -626,34 +625,33 @@ tui_free_window (struct tui_win_info *win_info)
 	}
       break;
     case DATA_WIN:
-      if (win_info->generic.content != NULL)
+      if (generic.content != NULL)
 	{
-	  tui_free_data_content (win_info->detail.data_display_info.regs_content,
-				 win_info->detail.data_display_info.regs_content_count);
-	  win_info->detail.data_display_info.regs_content = NULL;
-	  win_info->detail.data_display_info.regs_content_count = 0;
-	  tui_free_data_content (win_info->detail.data_display_info.data_content,
-				 win_info->detail.data_display_info.data_content_count);
-	  win_info->detail.data_display_info.data_content = NULL;
-	  win_info->detail.data_display_info.data_content_count = 0;
-	  win_info->detail.data_display_info.regs_column_count = 1;
-	  win_info->detail.data_display_info.display_regs = FALSE;
-	  win_info->generic.content = NULL;
-	  win_info->generic.content_size = 0;
+	  tui_free_data_content (detail.data_display_info.regs_content,
+				 detail.data_display_info.regs_content_count);
+	  detail.data_display_info.regs_content = NULL;
+	  detail.data_display_info.regs_content_count = 0;
+	  tui_free_data_content (detail.data_display_info.data_content,
+				 detail.data_display_info.data_content_count);
+	  detail.data_display_info.data_content = NULL;
+	  detail.data_display_info.data_content_count = 0;
+	  detail.data_display_info.regs_column_count = 1;
+	  detail.data_display_info.display_regs = FALSE;
+	  generic.content = NULL;
+	  generic.content_size = 0;
 	}
       break;
     default:
       break;
     }
-  if (win_info->generic.handle != NULL)
+  if (generic.handle != NULL)
     {
-      tui_delete_win (win_info->generic.handle);
-      win_info->generic.handle = NULL;
-      tui_free_win_content (&win_info->generic);
+      tui_delete_win (generic.handle);
+      generic.handle = NULL;
+      tui_free_win_content (&generic);
     }
-  if (win_info->generic.title)
-    xfree (win_info->generic.title);
-  delete win_info;
+  if (generic.title)
+    xfree (generic.title);
 }
 
 
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 34822e2a92d..ef20c02df2b 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -276,6 +276,8 @@ struct tui_win_info
     generic.type = type;
   }
 
+  ~tui_win_info ();
+
   DISABLE_COPY_AND_ASSIGN (tui_win_info);
 
   struct tui_gen_win_info generic;	/* General window information.  */
@@ -313,7 +315,6 @@ extern void tui_init_generic_part (struct tui_gen_win_info *);
 extern tui_win_content tui_alloc_content (int, enum tui_win_type);
 extern int tui_add_content_elements (struct tui_gen_win_info *, 
 				     int);
-extern void tui_free_window (struct tui_win_info *);
 extern void tui_free_win_content (struct tui_gen_win_info *);
 extern void tui_free_data_content (tui_win_content, int);
 extern void tui_free_all_source_wins_content (void);
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index a1329e54a81..a69e0878eff 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -785,7 +785,7 @@ tui_resize_all (void)
 	      && (tui_win_list[win_type] != NULL)
 	      && !tui_win_list[win_type]->generic.is_visible)
 	    {
-	      tui_free_window (tui_win_list[win_type]);
+	      delete tui_win_list[win_type];
 	      tui_win_list[win_type] = NULL;
 	    }
 	}
-- 
2.17.2

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

* [PATCH 27/66] Introduce max_height method
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (11 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 28/66] Remove redundant check from make_visible Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 25/66] Introduce the refresh_all method Tom Tromey
                   ` (37 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces the tui_win_info::max_height method and changes
new_height_ok to use it, rather than checking the window type
directly.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (tui_win_info::max_height)
	(tui_cmd_window::max_height): New methods.
	(new_height_ok): Call max_height.
	* tui/tui-data.h (struct tui_win_info, struct tui_cmd_window)
	<max_height>: New method.
---
 gdb/ChangeLog      |  8 ++++++++
 gdb/tui/tui-data.h |  5 +++++
 gdb/tui/tui-win.c  | 24 ++++++++++++++++++------
 3 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index e0d94d645be..bed28f64b19 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -273,6 +273,9 @@ public:
   {
   }
 
+  /* Compute the maximum height of this window.  */
+  virtual int max_height () const;
+
   /* Methods to scroll the contents of this window.  Note that they
      are named with "_scroll" coming at the end because the more
      obvious "scroll_forward" is defined as a macro in term.h.  */
@@ -426,6 +429,8 @@ struct tui_cmd_window : public tui_win_info
   {
   }
 
+  int max_height () const override;
+
   int start_line = 0;
 
 protected:
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index fe1e901c741..dc40ab7736d 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -1377,6 +1377,22 @@ make_visible_with_new_height (struct tui_win_info *win_info)
 }
 
 
+/* See tui-data.h.  */
+
+int
+tui_win_info::max_height () const
+{
+  return tui_term_height () - 2;
+}
+
+/* See tui-data.h.  */
+
+int
+tui_cmd_window::max_height () const
+{
+  return tui_term_height () - 4;
+}
+
 static int
 new_height_ok (struct tui_win_info *primary_win_info, 
 	       int new_height)
@@ -1391,12 +1407,8 @@ new_height_ok (struct tui_win_info *primary_win_info,
       diff = (new_height - primary_win_info->generic.height) * (-1);
       if (cur_layout == SRC_COMMAND || cur_layout == DISASSEM_COMMAND)
 	{
-	  ok = ((primary_win_info->generic.type == CMD_WIN 
-		 && new_height <= (tui_term_height () - 4) 
-		 && new_height >= MIN_CMD_WIN_HEIGHT) 
-		|| (primary_win_info->generic.type != CMD_WIN 
-		    && new_height <= (tui_term_height () - 2) 
-		    && new_height >= MIN_WIN_HEIGHT));
+	  ok = (new_height <= primary_win_info->max_height ()
+		&& new_height >= MIN_CMD_WIN_HEIGHT);
 	  if (ok)
 	    {			/* Check the total height.  */
 	      struct tui_win_info *win_info;
-- 
2.17.2

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

* [PATCH 16/66] Remove struct tui_command_info
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (6 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 26/66] Introduce set_new_height method Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 15/66] Remove struct tui_source_info Tom Tromey
                   ` (42 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Like the previous patch, this removes tui_command_info in favor of
putting it elements directly into tui_cmd_window.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (show_source_disasm_command)
	(show_source_or_disasm_and_command): Update.
	* tui/tui-io.c (update_cmdwin_start_line)
	(tui_redisplay_readline): Update.
	* tui/tui-data.h (struct tui_command_info): Remove.
	(struct tui_win_info) <detail>: Remove command_info member.
	(struct tui_data_window) <start_line>: New member, from
	tui_command_info.
	(TUI_CMD_WIN): Add casts.
---
 gdb/ChangeLog        | 12 ++++++++++++
 gdb/tui/tui-data.h   | 11 +++--------
 gdb/tui/tui-io.c     | 10 +++++-----
 gdb/tui/tui-layout.c |  7 ++++---
 4 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 081022a2495..4ca3a89b74e 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -238,12 +238,6 @@ struct tui_data_info
 };
 
 
-struct tui_command_info
-{
-  int start_line;
-};
-
-
 /* This defines information about each logical window.  */
 struct tui_win_info
 {
@@ -287,7 +281,6 @@ public:
   union
   {
     struct tui_data_info data_display_info;
-    struct tui_command_info command_info;
   }
   detail;
 
@@ -395,6 +388,8 @@ struct tui_cmd_window : public tui_win_info
 
   void clear_detail () override;
 
+  int start_line;
+
 protected:
 
   void do_scroll_vertical (enum tui_scroll_direction,
@@ -420,7 +415,7 @@ extern struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
 #define TUI_SRC_WIN     ((tui_source_window_base *) tui_win_list[SRC_WIN])
 #define TUI_DISASM_WIN	((tui_source_window_base *) tui_win_list[DISASSEM_WIN])
 #define TUI_DATA_WIN    tui_win_list[DATA_WIN]
-#define TUI_CMD_WIN     tui_win_list[CMD_WIN]
+#define TUI_CMD_WIN     ((tui_cmd_window *) tui_win_list[CMD_WIN])
 
 /* Data Manipulation Functions.  */
 extern void tui_initialize_static_data (void);
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 31c1c769381..cdb14bf5314 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -179,7 +179,7 @@ do_tui_putc (WINDOW *w, char c)
 static void
 update_cmdwin_start_line ()
 {
-  TUI_CMD_WIN->detail.command_info.start_line
+  TUI_CMD_WIN->start_line
     = getcury (TUI_CMD_WIN->generic.handle);
 }
 
@@ -539,7 +539,7 @@ tui_redisplay_readline (void)
   c_pos = -1;
   c_line = -1;
   w = TUI_CMD_WIN->generic.handle;
-  start_line = TUI_CMD_WIN->detail.command_info.start_line;
+  start_line = TUI_CMD_WIN->start_line;
   wmove (w, start_line, 0);
   prev_col = 0;
   height = 1;
@@ -580,17 +580,17 @@ tui_redisplay_readline (void)
           waddch (w, c);
 	}
       if (c == '\n')
-	TUI_CMD_WIN->detail.command_info.start_line = getcury (w);
+	TUI_CMD_WIN->start_line = getcury (w);
       col = getcurx (w);
       if (col < prev_col)
         height++;
       prev_col = col;
     }
   wclrtobot (w);
-  TUI_CMD_WIN->detail.command_info.start_line = getcury (w);
+  TUI_CMD_WIN->start_line = getcury (w);
   if (c_line >= 0)
     wmove (w, c_line, c_pos);
-  TUI_CMD_WIN->detail.command_info.start_line -= height - 1;
+  TUI_CMD_WIN->start_line -= height - 1;
 
   wrefresh (w);
   fflush(stdout);
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 55d737ab315..95b89f8583a 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -692,8 +692,8 @@ show_source_disasm_command (void)
       tui_show_source_content (TUI_DISASM_WIN);
 
       if (TUI_CMD_WIN == NULL)
-	TUI_CMD_WIN = make_command_window (cmd_height,
-					   tui_term_height () - cmd_height);
+	tui_win_list[CMD_WIN]
+	  = make_command_window (cmd_height, tui_term_height () - cmd_height);
       else
 	{
 	  init_gen_win_info (&TUI_CMD_WIN->generic,
@@ -958,7 +958,8 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 
 	  if (TUI_CMD_WIN == NULL)
 	    {
-	      TUI_CMD_WIN = make_command_window (cmd_height, src_height);
+	      tui_win_list[CMD_WIN] = make_command_window (cmd_height,
+							   src_height);
 	      tui_refresh_win (&TUI_CMD_WIN->generic);
 	    }
 	  else
-- 
2.17.2

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

* [PATCH 06/66] Simplify source and disassembly window creation
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (17 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 24/66] Introduce two TUI source window methods Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 14/66] Introduce has_locator method Tom Tromey
                   ` (31 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Similar to the previous patch, neither make_source_window nor
make_disasm_window could be called when *win_info_ptr was non-NULL.
This patch simplifies the functions by removing the parameter and
having them return their results directly.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (make_source_window, make_disasm_window)
	(make_source_or_disasm_window): Remove win_info_ptr parameter.
	Return the new window.
	(show_source_disasm_command, show_data)
	(show_source_or_disasm_and_command): Update.
---
 gdb/ChangeLog        |  8 +++++++
 gdb/tui/tui-layout.c | 54 ++++++++++++++++++++------------------------
 2 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 3eddc56578b..8c3ece0eef8 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -49,12 +49,11 @@ static void init_gen_win_info (struct tui_gen_win_info *,
 static void *init_and_make_win (void *, enum tui_win_type, 
 				int, int, int, int, int);
 static void show_source_or_disasm_and_command (enum tui_layout_type);
-static void make_source_or_disasm_window (struct tui_win_info **, 
-					  enum tui_win_type, 
-					  int, int);
+static struct tui_win_info *make_source_or_disasm_window (enum tui_win_type, 
+							  int, int);
 static struct tui_win_info *make_command_window (int, int);
-static void make_source_window (struct tui_win_info **, int, int);
-static void make_disasm_window (struct tui_win_info **, int, int);
+static struct tui_win_info *make_source_window (int, int);
+static struct tui_win_info *make_disasm_window (int, int);
 static void make_data_window (struct tui_win_info **, int, int);
 static void show_source_command (void);
 static void show_disasm_command (void);
@@ -558,25 +557,19 @@ make_command_window (int height, int origin_y)
 
 /* make_source_window().
  */
-static void
-make_source_window (struct tui_win_info **win_info_ptr, 
-		    int height, int origin_y)
+static struct tui_win_info *
+make_source_window (int height, int origin_y)
 {
-  make_source_or_disasm_window (win_info_ptr, SRC_WIN, height, origin_y);
-
-  return;
+  return make_source_or_disasm_window (SRC_WIN, height, origin_y);
 }				/* make_source_window */
 
 
 /* make_disasm_window().
  */
-static void
-make_disasm_window (struct tui_win_info **win_info_ptr, 
-		    int height, int origin_y)
+static struct tui_win_info *
+make_disasm_window (int height, int origin_y)
 {
-  make_source_or_disasm_window (win_info_ptr, DISASSEM_WIN, height, origin_y);
-
-  return;
+  return make_source_or_disasm_window (DISASSEM_WIN, height, origin_y);
 }				/* make_disasm_window */
 
 
@@ -629,7 +622,7 @@ show_source_disasm_command (void)
       asm_height = tui_term_height () - (src_height + cmd_height);
 
       if (TUI_SRC_WIN == NULL)
-	make_source_window (&TUI_SRC_WIN, src_height, 0);
+	TUI_SRC_WIN = make_source_window (src_height, 0);
       else
 	{
 	  init_gen_win_info (&TUI_SRC_WIN->generic,
@@ -655,7 +648,7 @@ show_source_disasm_command (void)
       tui_show_source_content (TUI_SRC_WIN);
       if (TUI_DISASM_WIN == NULL)
 	{
-	  make_disasm_window (&TUI_DISASM_WIN, asm_height, src_height - 1);
+	  TUI_DISASM_WIN = make_disasm_window (asm_height, src_height - 1);
 	  locator
 	    = ((struct tui_gen_win_info *)
 	       init_and_make_win (locator,
@@ -741,9 +734,11 @@ show_data (enum tui_layout_type new_layout)
   if (tui_win_list[win_type] == NULL)
     {
       if (win_type == SRC_WIN)
-	make_source_window (&tui_win_list[win_type], src_height, data_height - 1);
+	tui_win_list[win_type]
+	  = make_source_window (src_height, data_height - 1);
       else
-	make_disasm_window (&tui_win_list[win_type], src_height, data_height - 1);
+	tui_win_list[win_type]
+	  = make_disasm_window (src_height, data_height - 1);
       locator
 	= ((struct tui_gen_win_info *)
 	   init_and_make_win (locator,
@@ -848,9 +843,8 @@ init_and_make_win (void *opaque_win_info,
 }
 
 
-static void
-make_source_or_disasm_window (struct tui_win_info **win_info_ptr, 
-			      enum tui_win_type type,
+static struct tui_win_info *
+make_source_or_disasm_window (enum tui_win_type type,
 			      int height, int origin_y)
 {
   struct tui_gen_win_info *execution_info = NULL;
@@ -871,17 +865,17 @@ make_source_or_disasm_window (struct tui_win_info **win_info_ptr,
 			  DONT_BOX_WINDOW));
 
   /* Now create the source window.  */
-  *win_info_ptr
+  struct tui_win_info *result
     = ((struct tui_win_info *)
-       init_and_make_win (*win_info_ptr,
+       init_and_make_win (NULL,
 			  type,
 			  height,
 			  tui_term_width () - execution_info->width,
 			  execution_info->width,
 			  origin_y,
 			  BOX_WINDOW));
-
-  (*win_info_ptr)->detail.source_info.execution_info = execution_info;
+  result->detail.source_info.execution_info = execution_info;
+  return result;
 }
 
 
@@ -909,9 +903,9 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
       if ((*win_info_ptr) == NULL)
 	{
 	  if (layout_type == SRC_COMMAND)
-	    make_source_window (win_info_ptr, src_height - 1, 0);
+	    *win_info_ptr = make_source_window (src_height - 1, 0);
 	  else
-	    make_disasm_window (win_info_ptr, src_height - 1, 0);
+	    *win_info_ptr = make_disasm_window (src_height - 1, 0);
 	  locator
 	    = ((struct tui_gen_win_info *)
 	       init_and_make_win (locator,
-- 
2.17.2

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

* [PATCH 26/66] Introduce set_new_height method
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (5 preceding siblings ...)
  2019-06-23 22:43 ` [PATCH 08/66] Remove tui_list Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 16/66] Remove struct tui_command_info Tom Tromey
                   ` (43 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces tui_win_info::set_new_height and implements it in the
subclasses as appropriate.  This removes another switch on the window
type.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (tui_source_window_base::set_new_height)
	(tui_data_window::set_new_height): New methods.
	(make_invisible_and_set_new_height): Call set_new_height method.
	* tui/tui-data.h (struct tui_win_info)
	(struct tui_source_window_base, struct tui_data_window)
	<set_new_height>: New method.
---
 gdb/ChangeLog      |  9 ++++++
 gdb/tui/tui-data.h | 10 ++++++
 gdb/tui/tui-win.c  | 78 ++++++++++++++++++++++------------------------
 3 files changed, 57 insertions(+), 40 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index e838c0e1622..e0d94d645be 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -267,6 +267,12 @@ public:
   {
   }
 
+  /* Called after a TUI window is given a new height; this updates any
+     related auxiliary windows.  */
+  virtual void set_new_height (int height)
+  {
+  }
+
   /* Methods to scroll the contents of this window.  Note that they
      are named with "_scroll" coming at the end because the more
      obvious "scroll_forward" is defined as a macro in term.h.  */
@@ -318,6 +324,8 @@ public:
   /* Set the location of the execution point.  */
   void set_is_exec_point_at (struct tui_line_or_address l);
 
+  void set_new_height (int height) override;
+
   /* Does locator belongs to this window?  */
   bool m_has_locator = false;
   /* Execution information window.  */
@@ -380,6 +388,8 @@ struct tui_data_window : public tui_win_info
   void clear_detail () override;
   void refresh_all () override;
 
+  void set_new_height (int height) override;
+
   /* Start of data display content.  */
   tui_win_content data_content = NULL;
   int data_content_count = 0;
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 383487e5f7a..fe1e901c741 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -1242,6 +1242,43 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 }
 
 
+/* See tui-data.h.  */
+
+void
+tui_source_window_base::set_new_height (int height)
+{
+  tui_make_invisible (execution_info);
+  execution_info->height = height;
+  execution_info->origin.y = generic.origin.y;
+  if (height > 1)
+    execution_info->viewport_height = height - 1;
+  else
+    execution_info->viewport_height = height;
+  execution_info->viewport_height--;
+
+  if (has_locator ())
+    {
+      tui_gen_win_info *gen_win_info = tui_locator_win_info_ptr ();
+      tui_make_invisible (gen_win_info);
+      gen_win_info->origin.y = generic.origin.y + height;
+    }
+}
+
+/* See tui-data.h.  */
+
+void
+tui_data_window::set_new_height (int height)
+{
+  /* Delete all data item windows.  */
+  for (int i = 0; i < generic.content_size; i++)
+    {
+      struct tui_gen_win_info *gen_win_info
+	= &generic.content[i]->which_element.data_window;
+      tui_delete_win (gen_win_info->handle);
+      gen_win_info->handle = NULL;
+    }
+}
+
 /* Function make the target window (and auxillary windows associated
    with the targer) invisible, and set the new height and
    location.  */
@@ -1249,9 +1286,6 @@ static void
 make_invisible_and_set_new_height (struct tui_win_info *win_info, 
 				   int height)
 {
-  int i;
-  struct tui_gen_win_info *gen_win_info;
-
   tui_make_invisible (&win_info->generic);
   win_info->generic.height = height;
   if (height > 1)
@@ -1262,43 +1296,7 @@ make_invisible_and_set_new_height (struct tui_win_info *win_info,
     win_info->generic.viewport_height--;
 
   /* Now deal with the auxillary windows associated with win_info.  */
-  tui_source_window_base *base;
-  switch (win_info->generic.type)
-    {
-    case SRC_WIN:
-    case DISASSEM_WIN:
-      base = (tui_source_window_base *) win_info;
-      gen_win_info = base->execution_info;
-      tui_make_invisible (gen_win_info);
-      gen_win_info->height = height;
-      gen_win_info->origin.y = win_info->generic.origin.y;
-      if (height > 1)
-	gen_win_info->viewport_height = height - 1;
-      else
-	gen_win_info->viewport_height = height;
-      if (win_info != TUI_CMD_WIN)
-	gen_win_info->viewport_height--;
-
-      if (win_info->has_locator ())
-	{
-	  gen_win_info = tui_locator_win_info_ptr ();
-	  tui_make_invisible (gen_win_info);
-	  gen_win_info->origin.y = win_info->generic.origin.y + height;
-	}
-      break;
-    case DATA_WIN:
-      /* Delete all data item windows.  */
-      for (i = 0; i < win_info->generic.content_size; i++)
-	{
-	  gen_win_info
-	    = &win_info->generic.content[i]->which_element.data_window;
-	  tui_delete_win (gen_win_info->handle);
-	  gen_win_info->handle = NULL;
-	}
-      break;
-    default:
-      break;
-    }
+  win_info->set_new_height (height);
 }
 
 
-- 
2.17.2

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

* [PATCH 03/66] Create subclasses for different window types
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (25 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 29/66] Introduce set_highlight method Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-24 22:21   ` Pedro Alves
  2019-06-23 22:44 ` [PATCH 19/66] Inline constructors and initializers Tom Tromey
                   ` (23 subsequent siblings)
  50 siblings, 1 reply; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes the TUI so that each different major window type has its
own subclass.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (struct tui_win_info): Make constructor
	protected.  Make destructor virtual.  Add initializers.
	(tui_source_window, tui_data_window, tui_cmd_window): New
	classes.
	* tui/tui-data.c (tui_win_info): Rename from init_win_info.  Now a
	constructor.  Add "type" parameter.
	(tui_source_window, tui_data_window, tui_cmd_window): New
	constructors.
	(tui_alloc_win_info): Instantiate the appropriate subclass.
---
 gdb/ChangeLog      | 12 ++++++++
 gdb/tui/tui-data.c | 76 +++++++++++++++++++++++++++-------------------
 gdb/tui/tui-data.h | 38 ++++++++++++++++++-----
 3 files changed, 86 insertions(+), 40 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 1c96fc1c077..3320b4fc62a 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -495,47 +495,59 @@ init_content_element (struct tui_win_element *element,
     }
 }
 
-static void
-init_win_info (struct tui_win_info *win_info)
+tui_win_info::tui_win_info (enum tui_win_type type)
 {
-  tui_init_generic_part (&win_info->generic);
-  win_info->can_highlight =
-    win_info->is_highlighted = FALSE;
-  switch (win_info->generic.type)
-    {
-    case SRC_WIN:
-    case DISASSEM_WIN:
-      win_info->detail.source_info.execution_info = NULL;
-      win_info->detail.source_info.has_locator = FALSE;
-      win_info->detail.source_info.horizontal_offset = 0;
-      win_info->detail.source_info.gdbarch = NULL;
-      win_info->detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
-      win_info->detail.source_info.start_line_or_addr.u.addr = 0;
-      win_info->detail.source_info.fullname = NULL;
-      break;
-    case DATA_WIN:
-      win_info->detail.data_display_info.data_content = NULL;
-      win_info->detail.data_display_info.data_content_count = 0;
-      win_info->detail.data_display_info.regs_content = NULL;
-      win_info->detail.data_display_info.regs_content_count = 0;
-      win_info->detail.data_display_info.regs_column_count = 1;
-      win_info->detail.data_display_info.display_regs = FALSE;
-      win_info->detail.data_display_info.current_group = 0;
-      break;
-    case CMD_WIN:
-      break;
-    }
+  generic.type = type;
+  tui_init_generic_part (&generic);
 }
 
+tui_source_window::tui_source_window (enum tui_win_type type)
+  : tui_win_info (type)
+{
+  gdb_assert (type == SRC_WIN || type == DISASSEM_WIN);
+  detail.source_info.execution_info = NULL;
+  detail.source_info.has_locator = FALSE;
+  detail.source_info.horizontal_offset = 0;
+  detail.source_info.gdbarch = NULL;
+  detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
+  detail.source_info.start_line_or_addr.u.addr = 0;
+  detail.source_info.fullname = NULL;
+}
+
+tui_data_window::tui_data_window ()
+  : tui_win_info (DATA_WIN)
+{
+  detail.data_display_info.data_content = (tui_win_content) NULL;
+  detail.data_display_info.data_content_count = 0;
+  detail.data_display_info.regs_content = (tui_win_content) NULL;
+  detail.data_display_info.regs_content_count = 0;
+  detail.data_display_info.regs_column_count = 1;
+  detail.data_display_info.display_regs = FALSE;
+  detail.data_display_info.current_group = 0;
+}
+
+tui_cmd_window::tui_cmd_window ()
+  : tui_win_info (CMD_WIN)
+{
+}
 
 struct tui_win_info *
 tui_alloc_win_info (enum tui_win_type type)
 {
-  struct tui_win_info *win_info = new struct tui_win_info (type);
+  switch (type)
+    {
+    case SRC_WIN:
+    case DISASSEM_WIN:
+      return new tui_source_window (type);
 
-  init_win_info (win_info);
+    case DATA_WIN:
+      return new tui_data_window ();
 
-  return win_info;
+    case CMD_WIN:
+      return new tui_cmd_window ();
+    }
+
+  gdb_assert_not_reached (_("Unhandled window type"));
 }
 
 
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index ef20c02df2b..2c873c26a2f 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -271,15 +271,15 @@ struct tui_command_info
 /* This defines information about each logical window.  */
 struct tui_win_info
 {
-  tui_win_info (enum tui_win_type type)
-  {
-    generic.type = type;
-  }
-
-  ~tui_win_info ();
+protected:
 
+  tui_win_info (enum tui_win_type type);
   DISABLE_COPY_AND_ASSIGN (tui_win_info);
 
+public:
+
+  virtual ~tui_win_info ();
+
   struct tui_gen_win_info generic;	/* General window information.  */
   union
   {
@@ -288,8 +288,30 @@ struct tui_win_info
     struct tui_command_info command_info;
   }
   detail;
-  int can_highlight;	/* Can this window ever be highlighted?  */
-  int is_highlighted;	/* Is this window highlighted?  */
+
+  /* Can this window ever be highlighted?  */
+  int can_highlight = 0;
+
+  /* Is this window highlighted?  */
+  int is_highlighted = 0;
+};
+
+struct tui_source_window : public tui_win_info
+{
+  tui_source_window (enum tui_win_type type);
+  DISABLE_COPY_AND_ASSIGN (tui_source_window);
+};
+
+struct tui_data_window : public tui_win_info
+{
+  tui_data_window ();
+  DISABLE_COPY_AND_ASSIGN (tui_data_window);
+};
+
+struct tui_cmd_window : public tui_win_info
+{
+  tui_cmd_window ();
+  DISABLE_COPY_AND_ASSIGN (tui_cmd_window);
 };
 
 extern int tui_win_is_source_type (enum tui_win_type win_type);
-- 
2.17.2

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

* [PATCH 23/66] Introduce the refresh method
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (22 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 07/66] Introduce tui_win_info::clear_detail method Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 22/66] Use bool for visibility Tom Tromey
                   ` (26 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds tui_win_info::refresh and updates tui_source_window_base to
implement it as well.  This lets us simplify tui_refresh_all, removing
a check of the window type.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (tui_win_info::refresh)
	(tui_source_window_base::refresh): New methods.
	(tui_refresh_all): Call the refresh method.
	* tui/tui-data.h (struct tui_win_info)
	(struct tui_source_window_base) <refresh>: New method.
---
 gdb/ChangeLog            |  8 ++++++++
 gdb/tui/tui-data.h       |  4 ++++
 gdb/tui/tui-wingeneral.c | 31 ++++++++++++++++++++-----------
 3 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 34de67757b0..e25f8888c92 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -258,6 +258,9 @@ public:
   /* Make this window visible or invisible.  */
   virtual void make_visible (bool visible);
 
+  /* Refresh this window and any associated windows.  */
+  virtual void refresh ();
+
   /* Methods to scroll the contents of this window.  Note that they
      are named with "_scroll" coming at the end because the more
      obvious "scroll_forward" is defined as a macro in term.h.  */
@@ -299,6 +302,7 @@ public:
   }
 
   void make_visible (bool visible) override;
+  void refresh () override;
 
   /* Does locator belongs to this window?  */
   bool m_has_locator = false;
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index e802e52ca5b..4d168af0c09 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -256,6 +256,25 @@ tui_make_all_invisible (void)
   make_all_visible (false);
 }
 
+/* See tui-data.h.  */
+
+void
+tui_win_info::refresh ()
+{
+  touchwin (generic.handle);
+  tui_refresh_win (&generic);
+}
+
+/* See tui-data.h.  */
+
+void
+tui_source_window_base::refresh ()
+{
+  touchwin (execution_info->handle);
+  tui_refresh_win (execution_info);
+  tui_win_info::refresh ();
+}
+
 /* Function to refresh all the windows currently displayed.  */
 
 void
@@ -267,17 +286,7 @@ tui_refresh_all (struct tui_win_info **list)
   for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
     {
       if (list[type] && list[type]->generic.is_visible)
-	{
-	  if (type == SRC_WIN || type == DISASSEM_WIN)
-	    {
-	      tui_source_window_base *base
-		= (tui_source_window_base *) list[type];
-	      touchwin (base->execution_info->handle);
-	      tui_refresh_win (base->execution_info);
-	    }
-	  touchwin (list[type]->generic.handle);
-	  tui_refresh_win (&list[type]->generic);
-	}
+	list[type]->refresh ();
     }
   if (locator->is_visible)
     {
-- 
2.17.2

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

* [PATCH 14/66] Introduce has_locator method
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (18 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 06/66] Simplify source and disassembly window creation Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-24 14:13   ` Pedro Alves
  2019-06-23 22:44 ` [PATCH 09/66] Split the tui_win_info destructor Tom Tromey
                   ` (30 subsequent siblings)
  50 siblings, 1 reply; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_win_has_locator to be a method on tui_win_info, and
changes the locator code to use bool rather than int.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (make_invisible_and_set_new_height)
	(make_visible_with_new_height): Call has_locator method.
	* tui/tui-layout.c (show_source_disasm_command, show_data)
	(show_source_or_disasm_and_command): Update for bool change.
	* tui/tui-data.h (struct tui_source_info) <has_locator>: Now bool.
	(tui_win_info) <has_locator>: New method.
	(struct tui_source_window_base) <has_locator>: New method.
	(tui_win_has_locator): Don't declare.
	* tui/tui-data.c (tui_source_window_base::has_locator): Rename
	from tui_win_has_locator.
	(tui_source_window_base): Use false, not FALSE.
---
 gdb/ChangeLog        | 14 ++++++++++++++
 gdb/tui/tui-data.c   | 11 ++++++-----
 gdb/tui/tui-data.h   | 12 ++++++++++--
 gdb/tui/tui-layout.c | 14 +++++++-------
 gdb/tui/tui-win.c    |  4 ++--
 5 files changed, 39 insertions(+), 16 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index b5852bed0bb..6690db351ea 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -75,11 +75,12 @@ tui_win_is_auxillary (enum tui_win_type win_type)
   return (win_type > MAX_MAJOR_WINDOWS);
 }
 
-int
-tui_win_has_locator (struct tui_win_info *win_info)
+/* See tui-data.h.  */
+
+bool
+tui_source_window_base::has_locator () const
 {
-  return (win_info != NULL 
-	  && win_info->detail.source_info.has_locator);
+  return detail.source_info.has_locator;
 }
 
 void
@@ -499,7 +500,7 @@ tui_source_window_base::tui_source_window_base (enum tui_win_type type)
 {
   gdb_assert (type == SRC_WIN || type == DISASSEM_WIN);
   detail.source_info.execution_info = NULL;
-  detail.source_info.has_locator = FALSE;
+  detail.source_info.has_locator = false;
   detail.source_info.horizontal_offset = 0;
   detail.source_info.gdbarch = NULL;
   detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 54cd27c2e46..facd3142503 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -240,7 +240,7 @@ struct tui_data_info
 
 struct tui_source_info
 {
-  int has_locator;		/* Does locator belongs to this window?  */
+  bool has_locator;		/* Does locator belongs to this window?  */
   /* Execution information window.  */
   struct tui_gen_win_info *execution_info;
   int horizontal_offset;	/* Used for horizontal scroll.  */
@@ -285,6 +285,12 @@ public:
   /* Clear the pertinent detail in the window.  */
   virtual void clear_detail () = 0;
 
+  /* Return true if this window has a locator.  */
+  virtual bool has_locator () const
+  {
+    return false;
+  }
+
   /* Methods to scroll the contents of this window.  Note that they
      are named with "_scroll" coming at the end because the more
      obvious "scroll_forward" is defined as a macro in term.h.  */
@@ -325,6 +331,9 @@ protected:
 public:
 
   void clear_detail () override;
+
+  /* Return true if this window has the locator.  */
+  bool has_locator () const override;
 };
 
 /* A TUI source window.  */
@@ -401,7 +410,6 @@ protected:
 
 extern int tui_win_is_source_type (enum tui_win_type win_type);
 extern int tui_win_is_auxillary (enum tui_win_type win_type);
-extern int tui_win_has_locator (struct tui_win_info *win_info);
 extern void tui_set_win_highlight (struct tui_win_info *win_info,
 				   int highlight);
 
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 8c3ece0eef8..f4df49253af 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -640,7 +640,7 @@ show_source_disasm_command (void)
 			     0);
 	  tui_make_visible (&TUI_SRC_WIN->generic);
 	  tui_make_visible (TUI_SRC_WIN->detail.source_info.execution_info);
-	  TUI_SRC_WIN->detail.source_info.has_locator = FALSE;;
+	  TUI_SRC_WIN->detail.source_info.has_locator = false;
 	}
 
       struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
@@ -667,7 +667,7 @@ show_source_disasm_command (void)
 			     tui_term_width (),
 			     0,
 			     (src_height + asm_height) - 1);
-	  TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
+	  TUI_DISASM_WIN->detail.source_info.has_locator = true;
 	  init_gen_win_info (&TUI_DISASM_WIN->generic,
 			     TUI_DISASM_WIN->generic.type,
 			     asm_height,
@@ -684,8 +684,8 @@ show_source_disasm_command (void)
 	  tui_make_visible (&TUI_DISASM_WIN->generic);
 	  tui_make_visible (TUI_DISASM_WIN->detail.source_info.execution_info);
 	}
-      TUI_SRC_WIN->detail.source_info.has_locator = FALSE;
-      TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
+      TUI_SRC_WIN->detail.source_info.has_locator = false;
+      TUI_DISASM_WIN->detail.source_info.has_locator = true;
       tui_make_visible (locator);
       tui_show_locator_content ();
       tui_show_source_content (TUI_DISASM_WIN);
@@ -772,7 +772,7 @@ show_data (enum tui_layout_type new_layout)
 			 0,
 			 total_height - 1);
     }
-  tui_win_list[win_type]->detail.source_info.has_locator = TRUE;
+  tui_win_list[win_type]->detail.source_info.has_locator = true;
   tui_make_visible (locator);
   tui_show_locator_content ();
   tui_add_to_source_windows (tui_win_list[win_type]);
@@ -924,7 +924,7 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 			     tui_term_width (),
 			     0,
 			     src_height - 1);
-	  (*win_info_ptr)->detail.source_info.has_locator = TRUE;
+	  (*win_info_ptr)->detail.source_info.has_locator = true;
 	  init_gen_win_info (&(*win_info_ptr)->generic,
 			     (*win_info_ptr)->generic.type,
 			     src_height - 1,
@@ -943,7 +943,7 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 	}
       if ((*win_info_ptr) != NULL)
 	{
-	  (*win_info_ptr)->detail.source_info.has_locator = TRUE;
+	  (*win_info_ptr)->detail.source_info.has_locator = true;
 	  tui_make_visible (locator);
 	  tui_show_locator_content ();
 	  tui_show_source_content (*win_info_ptr);
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 4dad1443352..5c807ad0324 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -1283,7 +1283,7 @@ make_invisible_and_set_new_height (struct tui_win_info *win_info,
       if (win_info != TUI_CMD_WIN)
 	gen_win_info->viewport_height--;
 
-      if (tui_win_has_locator (win_info))
+      if (win_info->has_locator ())
 	{
 	  gen_win_info = tui_locator_win_info_ptr ();
 	  tui_make_invisible (gen_win_info);
@@ -1355,7 +1355,7 @@ make_visible_with_new_height (struct tui_win_info *win_info)
 	    }
 	  tui_update_source_window (win_info, gdbarch, s, line, TRUE);
 	}
-      if (tui_win_has_locator (win_info))
+      if (win_info->has_locator ())
 	{
 	  tui_make_visible (tui_locator_win_info_ptr ());
 	  tui_show_locator_content ();
-- 
2.17.2

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

* [PATCH 11/66] Introduce methods for scrolling
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (20 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 09/66] Split the tui_win_info destructor Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 07/66] Introduce tui_win_info::clear_detail method Tom Tromey
                   ` (28 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes the TUI to use virtual methods on the various window
types for scrolling.  Window-specific functions for this purpose are
renamed to be methods, and the generic tui_scroll function is removed
as it is no longer called.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_horizontal_source_scroll):  Don't
	declare.
	* tui/tui-winsource.c
	(tui_source_window_base::do_scroll_horizontal): Rename from
	tui_horizontal_source_scroll.
	* tui/tui-windata.h (tui_vertical_data_scroll): Don't declare.
	* tui/tui-windata.c (tui_data_window::do_scroll_vertical): Rename
	from tui_vertical_data_scroll.
	* tui/tui-win.h (tui_scroll): Don't declare.
	* tui/tui-win.c (tui_win_info::forward_scroll)
	(tui_win_info::backward_scroll, tui_win_info::left_scroll)
	(tui_win_info::right_scroll): Rename and update.
	(tui_scroll_forward_command, tui_scroll_backward_command)
	(tui_scroll_left_command, tui_scroll_right_command): Update.
	(tui_scroll): Remove.
	* tui/tui-source.h: Don't declare tui_vertical_source_scroll.
	* tui/tui-source.c (tui_source_window::do_scroll_vertical): Rename
	from tui_vertical_source_scroll.
	* tui/tui-disasm.h (tui_vertical_disassem_scroll): Don't declare.
	* tui/tui-disasm.c (tui_disasm_window::do_scroll_vertical): Rename
	from tui_vertical_disassem_scroll.
	* tui/tui-data.h (struct tui_win_info) <do_scroll_vertical,
	do_scroll_horizontal>: New methods.
	<forward_scroll, backward_scroll, left_scroll, right_scroll>:
	Likewise.
	(struct tui_source_window_base): Add do_scroll_horizontal.
	(struct tui_source_window, struct tui_disasm_window): Add
	do_scroll_vertical.
	(struct tui_data_window, struct tui_cmd_window): Add
	do_scroll_horizontal and do_scroll_vertical.
	* tui/tui-command.c (tui_dispatch_ctrl_char): Use method calls.
---
 gdb/ChangeLog           |  34 +++++++++++
 gdb/tui/tui-command.c   |  12 ++--
 gdb/tui/tui-data.h      |  52 ++++++++++++++++
 gdb/tui/tui-disasm.c    |  10 ++--
 gdb/tui/tui-disasm.h    |   2 -
 gdb/tui/tui-source.c    |   8 +--
 gdb/tui/tui-source.h    |   2 -
 gdb/tui/tui-win.c       | 130 +++++++---------------------------------
 gdb/tui/tui-win.h       |   2 -
 gdb/tui/tui-windata.c   |   6 +-
 gdb/tui/tui-windata.h   |   2 -
 gdb/tui/tui-winsource.c |  15 +++--
 gdb/tui/tui-winsource.h |   3 -
 13 files changed, 134 insertions(+), 144 deletions(-)

diff --git a/gdb/tui/tui-command.c b/gdb/tui/tui-command.c
index 76fe9dad814..9603b3cfdca 100644
--- a/gdb/tui/tui-command.c
+++ b/gdb/tui/tui-command.c
@@ -57,24 +57,24 @@ tui_dispatch_ctrl_char (unsigned int ch)
   switch (ch)
     {
     case KEY_NPAGE:
-      tui_scroll_forward (win_info, 0);
+      win_info->forward_scroll (0);
       break;
     case KEY_PPAGE:
-      tui_scroll_backward (win_info, 0);
+      win_info->backward_scroll (0);
       break;
     case KEY_DOWN:
     case KEY_SF:
-      tui_scroll_forward (win_info, 1);
+      win_info->forward_scroll (1);
       break;
     case KEY_UP:
     case KEY_SR:
-      tui_scroll_backward (win_info, 1);
+      win_info->backward_scroll (1);
       break;
     case KEY_RIGHT:
-      tui_scroll_left (win_info, 1);
+      win_info->left_scroll (1);
       break;
     case KEY_LEFT:
-      tui_scroll_right (win_info, 1);
+      win_info->right_scroll (1);
       break;
     case '\f':
       break;
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index fe00d9ed2bd..a4dce4d036b 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -268,6 +268,16 @@ protected:
   tui_win_info (enum tui_win_type type);
   DISABLE_COPY_AND_ASSIGN (tui_win_info);
 
+  /* Scroll the contents vertically.  This is only called via
+     forward_scroll and backward_scroll.  */
+  virtual void do_scroll_vertical (enum tui_scroll_direction,
+				   int num_to_scroll) = 0;
+
+  /* Scroll the contents horizontally.  This is only called via
+     left_scroll and right_scroll.  */
+  virtual void do_scroll_horizontal (enum tui_scroll_direction,
+				     int num_to_scroll) = 0;
+
 public:
 
   virtual ~tui_win_info ();
@@ -275,6 +285,14 @@ public:
   /* Clear the pertinent detail in the window.  */
   virtual void clear_detail () = 0;
 
+  /* Methods to scroll the contents of this window.  Note that they
+     are named with "_scroll" coming at the end because the more
+     obvious "scroll_forward" is defined as a macro in term.h.  */
+  void forward_scroll (int num_to_scroll);
+  void backward_scroll (int num_to_scroll);
+  void left_scroll (int num_to_scroll);
+  void right_scroll (int num_to_scroll);
+
   struct tui_gen_win_info generic;	/* General window information.  */
   union
   {
@@ -301,6 +319,9 @@ protected:
   ~tui_source_window_base () override;
   DISABLE_COPY_AND_ASSIGN (tui_source_window_base);
 
+  void do_scroll_horizontal (enum tui_scroll_direction,
+			     int num_to_scroll) override;
+
 public:
 
   void clear_detail () override;
@@ -316,6 +337,11 @@ struct tui_source_window : public tui_source_window_base
   }
 
   DISABLE_COPY_AND_ASSIGN (tui_source_window);
+
+protected:
+
+  void do_scroll_vertical (enum tui_scroll_direction,
+			   int num_to_scroll) override;
 };
 
 /* A TUI disassembly window.  */
@@ -328,6 +354,11 @@ struct tui_disasm_window : public tui_source_window_base
   }
 
   DISABLE_COPY_AND_ASSIGN (tui_disasm_window);
+
+protected:
+
+  void do_scroll_vertical (enum tui_scroll_direction,
+			   int num_to_scroll) override;
 };
 
 struct tui_data_window : public tui_win_info
@@ -337,6 +368,15 @@ struct tui_data_window : public tui_win_info
   DISABLE_COPY_AND_ASSIGN (tui_data_window);
 
   void clear_detail () override;
+
+protected:
+
+  void do_scroll_vertical (enum tui_scroll_direction,
+			   int num_to_scroll) override;
+  void do_scroll_horizontal (enum tui_scroll_direction,
+			     int num_to_scroll) override
+  {
+  }
 };
 
 struct tui_cmd_window : public tui_win_info
@@ -345,6 +385,18 @@ struct tui_cmd_window : public tui_win_info
   DISABLE_COPY_AND_ASSIGN (tui_cmd_window);
 
   void clear_detail () override;
+
+protected:
+
+  void do_scroll_vertical (enum tui_scroll_direction,
+			   int num_to_scroll) override
+  {
+  }
+
+  void do_scroll_horizontal (enum tui_scroll_direction,
+			     int num_to_scroll) override
+  {
+  }
 };
 
 extern int tui_win_is_source_type (enum tui_win_type win_type);
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 003462c2244..838f36cf295 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -373,18 +373,18 @@ tui_get_low_disassembly_address (struct gdbarch *gdbarch,
 
 /* Scroll the disassembly forward or backward vertically.  */
 void
-tui_vertical_disassem_scroll (enum tui_scroll_direction scroll_direction,
-			      int num_to_scroll)
+tui_disasm_window::do_scroll_vertical
+  (enum tui_scroll_direction scroll_direction, int num_to_scroll)
 {
-  if (TUI_DISASM_WIN->generic.content != NULL)
+  if (generic.content != NULL)
     {
-      struct gdbarch *gdbarch = TUI_DISASM_WIN->detail.source_info.gdbarch;
+      struct gdbarch *gdbarch = detail.source_info.gdbarch;
       CORE_ADDR pc;
       tui_win_content content;
       struct tui_line_or_address val;
       int dir;
 
-      content = TUI_DISASM_WIN->generic.content;
+      content = generic.content;
 
       pc = content[0]->which_element.source.line_or_addr.u.addr;
       num_to_scroll++;
diff --git a/gdb/tui/tui-disasm.h b/gdb/tui/tui-disasm.h
index b7325917435..925c7495947 100644
--- a/gdb/tui/tui-disasm.h
+++ b/gdb/tui/tui-disasm.h
@@ -28,8 +28,6 @@
 extern enum tui_status tui_set_disassem_content (struct gdbarch *, CORE_ADDR);
 extern void tui_show_disassem (struct gdbarch *, CORE_ADDR);
 extern void tui_show_disassem_and_update_source (struct gdbarch *, CORE_ADDR);
-extern void tui_vertical_disassem_scroll (enum tui_scroll_direction, 
-					  int);
 extern void tui_get_begin_asm_address (struct gdbarch **, CORE_ADDR *);
 
 #endif /* TUI_TUI_DISASM_H */
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 5066c7d7b4f..5c50d2fb794 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -309,14 +309,14 @@ tui_source_is_displayed (const char *fullname)
 
 /* Scroll the source forward or backward vertically.  */
 void
-tui_vertical_source_scroll (enum tui_scroll_direction scroll_direction,
-			    int num_to_scroll)
+tui_source_window::do_scroll_vertical
+  (enum tui_scroll_direction scroll_direction, int num_to_scroll)
 {
-  if (TUI_SRC_WIN->generic.content != NULL)
+  if (generic.content != NULL)
     {
       struct tui_line_or_address l;
       struct symtab *s;
-      tui_win_content content = TUI_SRC_WIN->generic.content;
+      tui_win_content content = generic.content;
       struct symtab_and_line cursal = get_current_source_symtab_and_line ();
 
       if (cursal.symtab == NULL)
diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
index 40fdac5c381..7757373a2a2 100644
--- a/gdb/tui/tui-source.h
+++ b/gdb/tui/tui-source.h
@@ -36,7 +36,5 @@ extern void tui_show_symtab_source (struct gdbarch *, struct symtab *,
 				    struct tui_line_or_address,
 				    int);
 extern int tui_source_is_displayed (const char *);
-extern void tui_vertical_source_scroll (enum tui_scroll_direction,
-					int);
 
 #endif /* TUI_TUI_SOURCE_H */
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 21a9946792e..4dad1443352 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -470,125 +470,41 @@ tui_set_win_focus_to (struct tui_win_info *win_info)
 
 
 void
-tui_scroll_forward (struct tui_win_info *win_to_scroll, 
-		    int num_to_scroll)
+tui_win_info::forward_scroll (int num_to_scroll)
 {
-  if (win_to_scroll != TUI_CMD_WIN)
-    {
-      int _num_to_scroll = num_to_scroll;
-
-      if (num_to_scroll == 0)
-	_num_to_scroll = win_to_scroll->generic.height - 3;
-
-      /* If we are scrolling the source or disassembly window, do a
-         "psuedo" scroll since not all of the source is in memory,
-         only what is in the viewport.  If win_to_scroll is the
-         command window do nothing since the term should handle
-         it.  */
-      if (win_to_scroll == TUI_SRC_WIN)
-	tui_vertical_source_scroll (FORWARD_SCROLL, _num_to_scroll);
-      else if (win_to_scroll == TUI_DISASM_WIN)
-	tui_vertical_disassem_scroll (FORWARD_SCROLL, _num_to_scroll);
-      else if (win_to_scroll == TUI_DATA_WIN)
-	tui_vertical_data_scroll (FORWARD_SCROLL, _num_to_scroll);
-    }
-}
+  if (num_to_scroll == 0)
+    num_to_scroll = generic.height - 3;
 
-void
-tui_scroll_backward (struct tui_win_info *win_to_scroll, 
-		     int num_to_scroll)
-{
-  if (win_to_scroll != TUI_CMD_WIN)
-    {
-      int _num_to_scroll = num_to_scroll;
-
-      if (num_to_scroll == 0)
-	_num_to_scroll = win_to_scroll->generic.height - 3;
-
-      /* If we are scrolling the source or disassembly window, do a
-         "psuedo" scroll since not all of the source is in memory,
-         only what is in the viewport.  If win_to_scroll is the
-         command window do nothing since the term should handle
-         it.  */
-      if (win_to_scroll == TUI_SRC_WIN)
-	tui_vertical_source_scroll (BACKWARD_SCROLL, _num_to_scroll);
-      else if (win_to_scroll == TUI_DISASM_WIN)
-	tui_vertical_disassem_scroll (BACKWARD_SCROLL, _num_to_scroll);
-      else if (win_to_scroll == TUI_DATA_WIN)
-	tui_vertical_data_scroll (BACKWARD_SCROLL, _num_to_scroll);
-    }
+  do_scroll_vertical (FORWARD_SCROLL, num_to_scroll);
 }
 
-
 void
-tui_scroll_left (struct tui_win_info *win_to_scroll,
-		 int num_to_scroll)
+tui_win_info::backward_scroll (int num_to_scroll)
 {
-  if (win_to_scroll != TUI_CMD_WIN)
-    {
-      int _num_to_scroll = num_to_scroll;
-
-      if (_num_to_scroll == 0)
-	_num_to_scroll = 1;
-
-      /* If we are scrolling the source or disassembly window, do a
-         "psuedo" scroll since not all of the source is in memory,
-         only what is in the viewport. If win_to_scroll is the command
-         window do nothing since the term should handle it.  */
-      if (win_to_scroll == TUI_SRC_WIN
-	  || win_to_scroll == TUI_DISASM_WIN)
-	tui_horizontal_source_scroll (win_to_scroll, LEFT_SCROLL,
-				      _num_to_scroll);
-    }
+  if (num_to_scroll == 0)
+    num_to_scroll = generic.height - 3;
+
+  do_scroll_vertical (BACKWARD_SCROLL, num_to_scroll);
 }
 
 
 void
-tui_scroll_right (struct tui_win_info *win_to_scroll, 
-		  int num_to_scroll)
+tui_win_info::left_scroll (int num_to_scroll)
 {
-  if (win_to_scroll != TUI_CMD_WIN)
-    {
-      int _num_to_scroll = num_to_scroll;
-
-      if (_num_to_scroll == 0)
-	_num_to_scroll = 1;
-
-      /* If we are scrolling the source or disassembly window, do a
-         "psuedo" scroll since not all of the source is in memory,
-         only what is in the viewport. If win_to_scroll is the command
-         window do nothing since the term should handle it.  */
-      if (win_to_scroll == TUI_SRC_WIN
-	  || win_to_scroll == TUI_DISASM_WIN)
-	tui_horizontal_source_scroll (win_to_scroll, RIGHT_SCROLL,
-				      _num_to_scroll);
-    }
+  if (num_to_scroll == 0)
+    num_to_scroll = 1;
+
+  do_scroll_horizontal (LEFT_SCROLL, num_to_scroll);
 }
 
 
-/* Scroll a window.  Arguments are passed through a va_list.  */
 void
-tui_scroll (enum tui_scroll_direction direction,
-	    struct tui_win_info *win_to_scroll,
-	    int num_to_scroll)
+tui_win_info::right_scroll (int num_to_scroll)
 {
-  switch (direction)
-    {
-    case FORWARD_SCROLL:
-      tui_scroll_forward (win_to_scroll, num_to_scroll);
-      break;
-    case BACKWARD_SCROLL:
-      tui_scroll_backward (win_to_scroll, num_to_scroll);
-      break;
-    case LEFT_SCROLL:
-      tui_scroll_left (win_to_scroll, num_to_scroll);
-      break;
-    case RIGHT_SCROLL:
-      tui_scroll_right (win_to_scroll, num_to_scroll);
-      break;
-    default:
-      break;
-    }
+  if (num_to_scroll == 0)
+    num_to_scroll = 1;
+
+  do_scroll_horizontal (RIGHT_SCROLL, num_to_scroll);
 }
 
 
@@ -880,7 +796,7 @@ tui_scroll_forward_command (const char *arg, int from_tty)
     parse_scrolling_args (arg, &win_to_scroll, NULL);
   else
     parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
-  tui_scroll (FORWARD_SCROLL, win_to_scroll, num_to_scroll);
+  win_to_scroll->forward_scroll (num_to_scroll);
 }
 
 
@@ -896,7 +812,7 @@ tui_scroll_backward_command (const char *arg, int from_tty)
     parse_scrolling_args (arg, &win_to_scroll, NULL);
   else
     parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
-  tui_scroll (BACKWARD_SCROLL, win_to_scroll, num_to_scroll);
+  win_to_scroll->backward_scroll (num_to_scroll);
 }
 
 
@@ -909,7 +825,7 @@ tui_scroll_left_command (const char *arg, int from_tty)
   /* Make sure the curses mode is enabled.  */
   tui_enable ();
   parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
-  tui_scroll (LEFT_SCROLL, win_to_scroll, num_to_scroll);
+  win_to_scroll->left_scroll (num_to_scroll);
 }
 
 
@@ -922,7 +838,7 @@ tui_scroll_right_command (const char *arg, int from_tty)
   /* Make sure the curses mode is enabled.  */
   tui_enable ();
   parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
-  tui_scroll (RIGHT_SCROLL, win_to_scroll, num_to_scroll);
+  win_to_scroll->right_scroll (num_to_scroll);
 }
 
 
diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h
index 98c497eb07d..e97eb672d78 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -30,8 +30,6 @@ extern void tui_scroll_forward (struct tui_win_info *, int);
 extern void tui_scroll_backward (struct tui_win_info *, int);
 extern void tui_scroll_left (struct tui_win_info *, int);
 extern void tui_scroll_right (struct tui_win_info *, int);
-extern void tui_scroll (enum tui_scroll_direction, 
-			struct tui_win_info *, int);
 extern void tui_set_win_focus_to (struct tui_win_info *);
 extern void tui_resize_all (void);
 extern void tui_refresh_all_win (void);
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index 646adfbb74d..0c9661f1cbe 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -245,15 +245,15 @@ tui_check_data_values (struct frame_info *frame)
 
 /* Scroll the data window vertically forward or backward.  */
 void
-tui_vertical_data_scroll (enum tui_scroll_direction scroll_direction,
-			  int num_to_scroll)
+tui_data_window::do_scroll_vertical
+  (enum tui_scroll_direction scroll_direction, int num_to_scroll)
 {
   int first_element_no;
   int first_line = (-1);
 
   first_element_no = tui_first_data_item_displayed ();
   if (first_element_no 
-      < TUI_DATA_WIN->detail.data_display_info.regs_content_count)
+      < detail.data_display_info.regs_content_count)
     first_line = tui_line_from_reg_element_no (first_element_no);
   else
     { /* Calculate the first line from the element number which is in
diff --git a/gdb/tui/tui-windata.h b/gdb/tui/tui-windata.h
index 56bf1ede9b4..c070f76c392 100644
--- a/gdb/tui/tui-windata.h
+++ b/gdb/tui/tui-windata.h
@@ -32,7 +32,5 @@ extern int tui_first_data_item_displayed (void);
 extern void tui_delete_data_content_windows (void);
 extern void tui_refresh_data_win (void);
 extern void tui_display_data_from (int, int);
-extern void tui_vertical_data_scroll (enum tui_scroll_direction, 
-				      int);
 
 #endif /* TUI_TUI_WINDATA_H */
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 20f39c4fb6e..8c269e2ec4a 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -335,26 +335,25 @@ tui_refill_source_window (struct tui_win_info *win_info)
 /* Scroll the source forward or backward horizontally.  */
 
 void
-tui_horizontal_source_scroll (struct tui_win_info *win_info,
-			      enum tui_scroll_direction direction,
-			      int num_to_scroll)
+tui_source_window_base::do_scroll_horizontal
+  (enum tui_scroll_direction direction, int num_to_scroll)
 {
-  if (win_info->generic.content != NULL)
+  if (generic.content != NULL)
     {
       int offset;
 
       if (direction == LEFT_SCROLL)
-	offset = win_info->detail.source_info.horizontal_offset
+	offset = detail.source_info.horizontal_offset
 	  + num_to_scroll;
       else
 	{
-	  offset = win_info->detail.source_info.horizontal_offset
+	  offset = detail.source_info.horizontal_offset
 	    - num_to_scroll;
 	  if (offset < 0)
 	    offset = 0;
 	}
-      win_info->detail.source_info.horizontal_offset = offset;
-      tui_refill_source_window (win_info);
+      detail.source_info.horizontal_offset = offset;
+      tui_refill_source_window (this);
     }
 }
 
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 920032b04ea..98ce75fb620 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -53,9 +53,6 @@ extern void tui_update_source_windows_with_line (struct symtab *,
 extern void tui_clear_source_content (struct tui_win_info *, int);
 extern void tui_erase_source_content (struct tui_win_info *, int);
 extern void tui_show_source_content (struct tui_win_info *);
-extern void tui_horizontal_source_scroll (struct tui_win_info *,
-					  enum tui_scroll_direction, 
-					  int);
 extern void tui_refill_source_window (struct tui_win_info *);
 extern enum tui_status tui_set_exec_info_content (struct tui_win_info *);
 extern void tui_show_exec_info_content (struct tui_win_info *);
-- 
2.17.2

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

* [PATCH 25/66] Introduce the refresh_all method
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (12 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 27/66] Introduce max_height method Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 17/66] Remove struct tui_data_info Tom Tromey
                   ` (36 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces the tui_win_info::refresh_all method and implements it
as needed in subclasses.  The name and comment are a bit of a guess on
my part.  The main benefit of this patch is removing another switch on
the type of the window.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui.c (tui_rl_other_window): Call the refresh_all method.
	* tui/tui-windata.c (tui_data_window::refresh_all): Rename from
	tui_refresh_data_win.
	* tui/tui-win.c (tui_source_window_base::refresh_all): New
	method.
	(tui_refresh_all_win): Call the refresh_all method.
	(tui_set_focus): Likewise.
	* tui/tui-data.h (struct tui_win_info) <refresh_all>: New method.
	(struct tui_source_window_base, struct tui_data_window) <refresh>:
	Likewise.
---
 gdb/ChangeLog         | 13 +++++++++++++
 gdb/tui/tui-data.h    |  8 ++++++++
 gdb/tui/tui-win.c     | 34 ++++++++++++++--------------------
 gdb/tui/tui-windata.c |  4 ++--
 gdb/tui/tui.c         |  2 +-
 5 files changed, 38 insertions(+), 23 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index c41e812c483..e838c0e1622 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -261,6 +261,12 @@ public:
   /* Refresh this window and any associated windows.  */
   virtual void refresh ();
 
+  /* Called after all the TUI windows are refreshed, to let this
+     window have a chance to update itself further.  */
+  virtual void refresh_all ()
+  {
+  }
+
   /* Methods to scroll the contents of this window.  Note that they
      are named with "_scroll" coming at the end because the more
      obvious "scroll_forward" is defined as a macro in term.h.  */
@@ -303,6 +309,7 @@ public:
 
   void make_visible (bool visible) override;
   void refresh () override;
+  void refresh_all () override;
 
   /* Refill the source window's source cache and update it.  If this
      is a disassembly window, then just update it.  */
@@ -371,6 +378,7 @@ struct tui_data_window : public tui_win_info
   DISABLE_COPY_AND_ASSIGN (tui_data_window);
 
   void clear_detail () override;
+  void refresh_all () override;
 
   /* Start of data display content.  */
   tui_win_content data_content = NULL;
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 9c4f9ad5779..383487e5f7a 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -508,6 +508,17 @@ tui_win_info::right_scroll (int num_to_scroll)
 }
 
 
+/* See tui-data.h.  */
+
+void
+tui_source_window_base::refresh_all ()
+{
+  tui_show_source_content (this);
+  tui_check_and_display_highlight_if_needed (this);
+  tui_erase_exec_info_content (this);
+  tui_update_exec_info (this);
+}
+
 void
 tui_refresh_all_win (void)
 {
@@ -517,25 +528,8 @@ tui_refresh_all_win (void)
   tui_refresh_all (tui_win_list);
   for (type = SRC_WIN; type < MAX_MAJOR_WINDOWS; type++)
     {
-      if (tui_win_list[type] 
-	  && tui_win_list[type]->generic.is_visible)
-	{
-	  switch (type)
-	    {
-	    case SRC_WIN:
-	    case DISASSEM_WIN:
-	      tui_show_source_content (tui_win_list[type]);
-	      tui_check_and_display_highlight_if_needed (tui_win_list[type]);
-	      tui_erase_exec_info_content (tui_win_list[type]);
-	      tui_update_exec_info (tui_win_list[type]);
-	      break;
-	    case DATA_WIN:
-	      tui_refresh_data_win ();
-	      break;
-	    default:
-	      break;
-	    }
-	}
+      if (tui_win_list[type] && tui_win_list[type]->generic.is_visible)
+	tui_win_list[type]->refresh_all ();
     }
   tui_show_locator_content ();
 }
@@ -872,7 +866,7 @@ The window name specified must be valid and visible.\n"));
 	}
 
       if (TUI_DATA_WIN && TUI_DATA_WIN->generic.is_visible)
-	tui_refresh_data_win ();
+	TUI_DATA_WIN->refresh_all ();
       xfree (buf_ptr);
       printf_filtered (_("Focus set to %s window.\n"),
 		       tui_win_name (&tui_win_with_focus ()->generic));
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index 67228a6c5ee..770baf857f6 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -193,10 +193,10 @@ tui_display_data_from (int element_no, int reuse_windows)
 
 /* Function to redisplay the contents of the data window.  */
 void
-tui_refresh_data_win (void)
+tui_data_window::refresh_all ()
 {
   tui_erase_data_content (NULL);
-  if (TUI_DATA_WIN->generic.content_size > 0)
+  if (generic.content_size > 0)
     {
       int first_element = tui_first_data_item_displayed ();
 
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index d7201992ae4..55a44e8840e 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -237,7 +237,7 @@ tui_rl_other_window (int count, int key)
     {
       tui_set_win_focus_to (win_info);
       if (TUI_DATA_WIN && TUI_DATA_WIN->generic.is_visible)
-        tui_refresh_data_win ();
+	TUI_DATA_WIN->refresh_all ();
       keypad (TUI_CMD_WIN->generic.handle, (win_info != TUI_CMD_WIN));
     }
   return 0;
-- 
2.17.2

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

* [PATCH 15/66] Remove struct tui_source_info
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (7 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 16/66] Remove struct tui_command_info Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 21/66] Introduce make_visible method Tom Tromey
                   ` (41 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The tui_source_info struct is used as a member of the "detail" union
in tui_win_info, and this member of the union is only used by source
and disassembly windows.  This patch removes tui_source_info and moves
its members directly to tui_source_window_base.  This simplifies the
code by removing a layer of references from many places.  In a few
spots, a new cast was needed, but most of these will be removed by the
end of the series.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_update_source_window)
	(tui_refill_source_window)
	(tui_source_window_base::do_scroll_horizontal)
	(tui_update_breakpoint_info, tui_set_exec_info_content)
	(tui_show_exec_info_content, tui_erase_exec_info_content)
	(tui_clear_exec_info_content): Update.
	* tui/tui-wingeneral.c (make_all_visible, tui_refresh_all):
	Update.
	* tui/tui-win.c (make_invisible_and_set_new_height)
	(make_visible_with_new_height): Update.
	* tui/tui-source.c (tui_set_source_content)
	(tui_show_symtab_source): Update.
	* tui/tui-layout.c (extract_display_start_addr)
	(show_source_disasm_command, show_data)
	(make_source_or_disasm_window)
	(show_source_or_disasm_and_command): Update.
	* tui/tui-disasm.c (tui_set_disassem_content): Simplify.
	(tui_disasm_window::do_scroll_vertical): Remove shadowing
	"gdbarch".
	* tui/tui-data.h (struct tui_source_info): Remove.  Move contents
	to tui_source_window_base.
	(struct tui_win_info) <detail>: Remove source_info member.
	(struct tui_source_window_base) <has_locator>: Inline.
	Move contents from tui_source_info; rename has_locator member to
	m_has_locator.
	(TUI_SRC_WIN, TUI_DISASM_WIN): Add casts.
	* tui/tui-data.c (tui_source_window_base::has_locator): Move to
	header file.
	(tui_source_window_base::clear_detail, ~tui_source_window_base):
	Simplify.
	(tui_free_all_source_wins_content): Cast to
	tui_source_window_base.
---
 gdb/ChangeLog            | 35 ++++++++++++++++++++
 gdb/tui/tui-data.c       | 36 ++++++---------------
 gdb/tui/tui-data.h       | 40 +++++++++++------------
 gdb/tui/tui-disasm.c     | 10 +++---
 gdb/tui/tui-layout.c     | 70 ++++++++++++++++++++++------------------
 gdb/tui/tui-source.c     |  6 ++--
 gdb/tui/tui-win.c        | 14 +++++---
 gdb/tui/tui-wingeneral.c | 13 +++++---
 gdb/tui/tui-winsource.c  | 33 ++++++++++---------
 9 files changed, 147 insertions(+), 110 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 6690db351ea..ef9c9998930 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -75,14 +75,6 @@ tui_win_is_auxillary (enum tui_win_type win_type)
   return (win_type > MAX_MAJOR_WINDOWS);
 }
 
-/* See tui-data.h.  */
-
-bool
-tui_source_window_base::has_locator () const
-{
-  return detail.source_info.has_locator;
-}
-
 void
 tui_set_win_highlight (struct tui_win_info *win_info, 
 		       int highlight)
@@ -179,10 +171,10 @@ tui_add_to_source_windows (struct tui_win_info *win_info)
 void
 tui_source_window_base::clear_detail ()
 {
-  detail.source_info.gdbarch = NULL;
-  detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
-  detail.source_info.start_line_or_addr.u.addr = 0;
-  detail.source_info.horizontal_offset = 0;
+  gdbarch = NULL;
+  start_line_or_addr.loa = LOA_ADDRESS;
+  start_line_or_addr.u.addr = 0;
+  horizontal_offset = 0;
 }
 
 /* See tui-data.h.  */
@@ -499,13 +491,8 @@ tui_source_window_base::tui_source_window_base (enum tui_win_type type)
   : tui_win_info (type)
 {
   gdb_assert (type == SRC_WIN || type == DISASSEM_WIN);
-  detail.source_info.execution_info = NULL;
-  detail.source_info.has_locator = false;
-  detail.source_info.horizontal_offset = 0;
-  detail.source_info.gdbarch = NULL;
-  detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
-  detail.source_info.start_line_or_addr.u.addr = 0;
-  detail.source_info.fullname = NULL;
+  start_line_or_addr.loa = LOA_ADDRESS;
+  start_line_or_addr.u.addr = 0;
 }
 
 tui_data_window::tui_data_window ()
@@ -613,12 +600,8 @@ tui_add_content_elements (struct tui_gen_win_info *win_info,
 
 tui_source_window_base::~tui_source_window_base ()
 {
-  if (detail.source_info.fullname)
-    {
-      xfree (detail.source_info.fullname);
-      detail.source_info.fullname = NULL;
-    }
-  struct tui_gen_win_info *generic_win = detail.source_info.execution_info;
+  xfree (fullname);
+  struct tui_gen_win_info *generic_win = execution_info;
   if (generic_win != NULL)
     {
       tui_delete_win (generic_win->handle);
@@ -665,7 +648,8 @@ tui_free_all_source_wins_content ()
   for (tui_win_info *win_info : tui_source_windows ())
     {
       tui_free_win_content (&(win_info->generic));
-      tui_free_win_content (win_info->detail.source_info.execution_info);
+      tui_source_window_base *base = (tui_source_window_base *) win_info;
+      tui_free_win_content (base->execution_info);
     }
 }
 
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index facd3142503..081022a2495 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -238,22 +238,6 @@ struct tui_data_info
 };
 
 
-struct tui_source_info
-{
-  bool has_locator;		/* Does locator belongs to this window?  */
-  /* Execution information window.  */
-  struct tui_gen_win_info *execution_info;
-  int horizontal_offset;	/* Used for horizontal scroll.  */
-  struct tui_line_or_address start_line_or_addr;
-
-  /* It is the resolved form as returned by symtab_to_fullname.  */
-  char *fullname;
-
-  /* Architecture associated with code at this location.  */
-  struct gdbarch *gdbarch;
-};
-
-
 struct tui_command_info
 {
   int start_line;
@@ -302,7 +286,6 @@ public:
   struct tui_gen_win_info generic;	/* General window information.  */
   union
   {
-    struct tui_source_info source_info;
     struct tui_data_info data_display_info;
     struct tui_command_info command_info;
   }
@@ -333,7 +316,24 @@ public:
   void clear_detail () override;
 
   /* Return true if this window has the locator.  */
-  bool has_locator () const override;
+  bool has_locator () const override
+  {
+    return m_has_locator;
+  }
+
+  /* Does locator belongs to this window?  */
+  bool m_has_locator = false;
+  /* Execution information window.  */
+  struct tui_gen_win_info *execution_info = nullptr;
+  /* Used for horizontal scroll.  */
+  int horizontal_offset = 0;
+  struct tui_line_or_address start_line_or_addr;
+
+  /* It is the resolved form as returned by symtab_to_fullname.  */
+  char *fullname = nullptr;
+
+  /* Architecture associated with code at this location.  */
+  struct gdbarch *gdbarch = nullptr;
 };
 
 /* A TUI source window.  */
@@ -417,8 +417,8 @@ extern void tui_set_win_highlight (struct tui_win_info *win_info,
 /* Global Data.  */
 extern struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
 
-#define TUI_SRC_WIN     tui_win_list[SRC_WIN]
-#define TUI_DISASM_WIN	tui_win_list[DISASSEM_WIN]
+#define TUI_SRC_WIN     ((tui_source_window_base *) tui_win_list[SRC_WIN])
+#define TUI_DISASM_WIN	((tui_source_window_base *) tui_win_list[DISASSEM_WIN])
 #define TUI_DATA_WIN    tui_win_list[DATA_WIN]
 #define TUI_CMD_WIN     tui_win_list[CMD_WIN]
 
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index efb9d1cb628..8dd156d0907 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -167,7 +167,7 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   enum tui_status ret = TUI_FAILURE;
   int i;
-  int offset = TUI_DISASM_WIN->detail.source_info.horizontal_offset;
+  int offset = TUI_DISASM_WIN->horizontal_offset;
   int max_lines, line_width;
   CORE_ADDR cur_pc;
   struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
@@ -184,9 +184,10 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
   if (ret != TUI_SUCCESS)
     return ret;
 
-  TUI_DISASM_WIN->detail.source_info.gdbarch = gdbarch;
-  TUI_DISASM_WIN->detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
-  TUI_DISASM_WIN->detail.source_info.start_line_or_addr.u.addr = pc;
+  tui_source_window_base *base = TUI_DISASM_WIN;
+  base->gdbarch = gdbarch;
+  base->start_line_or_addr.loa = LOA_ADDRESS;
+  base->start_line_or_addr.u.addr = pc;
   cur_pc = locator->content[0]->which_element.locator.addr;
 
   /* Window size, excluding highlight box.  */
@@ -378,7 +379,6 @@ tui_disasm_window::do_scroll_vertical
 {
   if (generic.content != NULL)
     {
-      struct gdbarch *gdbarch = detail.source_info.gdbarch;
       CORE_ADDR pc;
       tui_win_content content;
       struct tui_line_or_address val;
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index f4df49253af..55d737ab315 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -468,17 +468,17 @@ extract_display_start_addr (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
     {
     case SRC_COMMAND:
     case SRC_DATA_COMMAND:
-      gdbarch = TUI_SRC_WIN->detail.source_info.gdbarch;
+      gdbarch = TUI_SRC_WIN->gdbarch;
       find_line_pc (cursal.symtab,
-		    TUI_SRC_WIN->detail.source_info.start_line_or_addr.u.line_no,
+		    TUI_SRC_WIN->start_line_or_addr.u.line_no,
 		    &pc);
       addr = pc;
       break;
     case DISASSEM_COMMAND:
     case SRC_DISASSEM_COMMAND:
     case DISASSEM_DATA_COMMAND:
-      gdbarch = TUI_DISASM_WIN->detail.source_info.gdbarch;
-      addr = TUI_DISASM_WIN->detail.source_info.start_line_or_addr.u.addr;
+      gdbarch = TUI_DISASM_WIN->gdbarch;
+      addr = TUI_DISASM_WIN->start_line_or_addr.u.addr;
       break;
     default:
       addr = 0;
@@ -622,25 +622,25 @@ show_source_disasm_command (void)
       asm_height = tui_term_height () - (src_height + cmd_height);
 
       if (TUI_SRC_WIN == NULL)
-	TUI_SRC_WIN = make_source_window (src_height, 0);
+	tui_win_list[SRC_WIN] = make_source_window (src_height, 0);
       else
 	{
 	  init_gen_win_info (&TUI_SRC_WIN->generic,
 			     TUI_SRC_WIN->generic.type,
 			     src_height,
 			     TUI_SRC_WIN->generic.width,
-			     TUI_SRC_WIN->detail.source_info.execution_info->width,
+			     TUI_SRC_WIN->execution_info->width,
 			     0);
 	  TUI_SRC_WIN->can_highlight = TRUE;
-	  init_gen_win_info (TUI_SRC_WIN->detail.source_info.execution_info,
+	  init_gen_win_info (TUI_SRC_WIN->execution_info,
 			     EXEC_INFO_WIN,
 			     src_height,
 			     3,
 			     0,
 			     0);
 	  tui_make_visible (&TUI_SRC_WIN->generic);
-	  tui_make_visible (TUI_SRC_WIN->detail.source_info.execution_info);
-	  TUI_SRC_WIN->detail.source_info.has_locator = false;
+	  tui_make_visible (TUI_SRC_WIN->execution_info);
+	  TUI_SRC_WIN->m_has_locator = false;
 	}
 
       struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
@@ -648,7 +648,8 @@ show_source_disasm_command (void)
       tui_show_source_content (TUI_SRC_WIN);
       if (TUI_DISASM_WIN == NULL)
 	{
-	  TUI_DISASM_WIN = make_disasm_window (asm_height, src_height - 1);
+	  tui_win_list[DISASSEM_WIN]
+	    = make_disasm_window (asm_height, src_height - 1);
 	  locator
 	    = ((struct tui_gen_win_info *)
 	       init_and_make_win (locator,
@@ -667,14 +668,14 @@ show_source_disasm_command (void)
 			     tui_term_width (),
 			     0,
 			     (src_height + asm_height) - 1);
-	  TUI_DISASM_WIN->detail.source_info.has_locator = true;
+	  TUI_DISASM_WIN->m_has_locator = true;
 	  init_gen_win_info (&TUI_DISASM_WIN->generic,
 			     TUI_DISASM_WIN->generic.type,
 			     asm_height,
 			     TUI_DISASM_WIN->generic.width,
-			     TUI_DISASM_WIN->detail.source_info.execution_info->width,
+			     TUI_DISASM_WIN->execution_info->width,
 			     src_height - 1);
-	  init_gen_win_info (TUI_DISASM_WIN->detail.source_info.execution_info,
+	  init_gen_win_info (TUI_DISASM_WIN->execution_info,
 			     EXEC_INFO_WIN,
 			     asm_height,
 			     3,
@@ -682,10 +683,10 @@ show_source_disasm_command (void)
 			     src_height - 1);
 	  TUI_DISASM_WIN->can_highlight = TRUE;
 	  tui_make_visible (&TUI_DISASM_WIN->generic);
-	  tui_make_visible (TUI_DISASM_WIN->detail.source_info.execution_info);
+	  tui_make_visible (TUI_DISASM_WIN->execution_info);
 	}
-      TUI_SRC_WIN->detail.source_info.has_locator = false;
-      TUI_DISASM_WIN->detail.source_info.has_locator = true;
+      TUI_SRC_WIN->m_has_locator = false;
+      TUI_DISASM_WIN->m_has_locator = true;
       tui_make_visible (locator);
       tui_show_locator_content ();
       tui_show_source_content (TUI_DISASM_WIN);
@@ -731,6 +732,8 @@ show_data (enum tui_layout_type new_layout)
     win_type = SRC_WIN;
   else
     win_type = DISASSEM_WIN;
+
+  tui_source_window_base *base;
   if (tui_win_list[win_type] == NULL)
     {
       if (win_type == SRC_WIN)
@@ -748,23 +751,25 @@ show_data (enum tui_layout_type new_layout)
 			      0,
 			      total_height - 1,
 			      DONT_BOX_WINDOW));
+      base = (tui_source_window_base *) tui_win_list[win_type];
     }
   else
     {
+      base = (tui_source_window_base *) tui_win_list[win_type];
       init_gen_win_info (&tui_win_list[win_type]->generic,
 			 tui_win_list[win_type]->generic.type,
 			 src_height,
 			 tui_win_list[win_type]->generic.width,
-			 tui_win_list[win_type]->detail.source_info.execution_info->width,
+			 base->execution_info->width,
 			 data_height - 1);
-      init_gen_win_info (tui_win_list[win_type]->detail.source_info.execution_info,
+      init_gen_win_info (base->execution_info,
 			 EXEC_INFO_WIN,
 			 src_height,
 			 3,
 			 0,
 			 data_height - 1);
       tui_make_visible (&tui_win_list[win_type]->generic);
-      tui_make_visible (tui_win_list[win_type]->detail.source_info.execution_info);
+      tui_make_visible (base->execution_info);
       init_gen_win_info (locator,
 			 LOCATOR_WIN,
 			 2 /* 1 */ ,
@@ -772,7 +777,7 @@ show_data (enum tui_layout_type new_layout)
 			 0,
 			 total_height - 1);
     }
-  tui_win_list[win_type]->detail.source_info.has_locator = true;
+  base->m_has_locator = true;
   tui_make_visible (locator);
   tui_show_locator_content ();
   tui_add_to_source_windows (tui_win_list[win_type]);
@@ -865,8 +870,8 @@ make_source_or_disasm_window (enum tui_win_type type,
 			  DONT_BOX_WINDOW));
 
   /* Now create the source window.  */
-  struct tui_win_info *result
-    = ((struct tui_win_info *)
+  struct tui_source_window_base *result
+    = ((struct tui_source_window_base *)
        init_and_make_win (NULL,
 			  type,
 			  height,
@@ -874,7 +879,7 @@ make_source_or_disasm_window (enum tui_win_type type,
 			  execution_info->width,
 			  origin_y,
 			  BOX_WINDOW));
-  result->detail.source_info.execution_info = execution_info;
+  result->execution_info = execution_info;
   return result;
 }
 
@@ -896,10 +901,11 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
       src_height = tui_term_height () - cmd_height;
 
       if (layout_type == SRC_COMMAND)
-	win_info_ptr = &TUI_SRC_WIN;
+	win_info_ptr = &tui_win_list[SRC_WIN];
       else
-	win_info_ptr = &TUI_DISASM_WIN;
+	win_info_ptr = &tui_win_list[DISASSEM_WIN];
 
+      tui_source_window_base *base;
       if ((*win_info_ptr) == NULL)
 	{
 	  if (layout_type == SRC_COMMAND)
@@ -915,35 +921,37 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 				  0,
 				  src_height - 1,
 				  DONT_BOX_WINDOW));
+	  base = (tui_source_window_base *) *win_info_ptr;
 	}
       else
 	{
+	  base = (tui_source_window_base *) *win_info_ptr;
 	  init_gen_win_info (locator,
 			     LOCATOR_WIN,
 			     2 /* 1 */ ,
 			     tui_term_width (),
 			     0,
 			     src_height - 1);
-	  (*win_info_ptr)->detail.source_info.has_locator = true;
+	  base->m_has_locator = true;
 	  init_gen_win_info (&(*win_info_ptr)->generic,
 			     (*win_info_ptr)->generic.type,
 			     src_height - 1,
 			     (*win_info_ptr)->generic.width,
-			     (*win_info_ptr)->detail.source_info.execution_info->width,
+			     base->execution_info->width,
 			     0);
-	  init_gen_win_info ((*win_info_ptr)->detail.source_info.execution_info,
+	  init_gen_win_info (base->execution_info,
 			     EXEC_INFO_WIN,
 			     src_height - 1,
 			     3,
 			     0,
 			     0);
-	  (*win_info_ptr)->can_highlight = TRUE;
+	  base->can_highlight = TRUE;
 	  tui_make_visible (&(*win_info_ptr)->generic);
-	  tui_make_visible ((*win_info_ptr)->detail.source_info.execution_info);
+	  tui_make_visible (base->execution_info);
 	}
       if ((*win_info_ptr) != NULL)
 	{
-	  (*win_info_ptr)->detail.source_info.has_locator = true;
+	  base->m_has_locator = true;
 	  tui_make_visible (locator);
 	  tui_show_locator_content ();
 	  tui_show_source_content (*win_info_ptr);
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 5c50d2fb794..ac3f225e1b1 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -159,8 +159,8 @@ tui_set_source_content (struct symtab *s,
 	      int cur_line_no, cur_line;
 	      struct tui_gen_win_info *locator
 		= tui_locator_win_info_ptr ();
-	      struct tui_source_info *src
-		= &TUI_SRC_WIN->detail.source_info;
+	      struct tui_source_window_base *src
+		= (struct tui_source_window_base *) TUI_SRC_WIN;
 	      const char *s_filename = symtab_to_filename_for_display (s);
 
 	      if (TUI_SRC_WIN->generic.title)
@@ -289,7 +289,7 @@ tui_show_symtab_source (struct gdbarch *gdbarch, struct symtab *s,
 			struct tui_line_or_address line, 
 			int noerror)
 {
-  TUI_SRC_WIN->detail.source_info.horizontal_offset = 0;
+  TUI_SRC_WIN->horizontal_offset = 0;
   tui_update_source_window_as_is (TUI_SRC_WIN, gdbarch, s, line, noerror);
 }
 
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 5c807ad0324..9c4f9ad5779 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -1268,11 +1268,13 @@ make_invisible_and_set_new_height (struct tui_win_info *win_info,
     win_info->generic.viewport_height--;
 
   /* Now deal with the auxillary windows associated with win_info.  */
+  tui_source_window_base *base;
   switch (win_info->generic.type)
     {
     case SRC_WIN:
     case DISASSEM_WIN:
-      gen_win_info = win_info->detail.source_info.execution_info;
+      base = (tui_source_window_base *) win_info;
+      gen_win_info = base->execution_info;
       tui_make_invisible (gen_win_info);
       gen_win_info->height = height;
       gen_win_info->origin.y = win_info->generic.origin.y;
@@ -1316,20 +1318,22 @@ make_visible_with_new_height (struct tui_win_info *win_info)
 
   tui_make_visible (&win_info->generic);
   tui_check_and_display_highlight_if_needed (win_info);
+  tui_source_window_base *base;
   switch (win_info->generic.type)
     {
     case SRC_WIN:
     case DISASSEM_WIN:
-      tui_free_win_content (win_info->detail.source_info.execution_info);
-      tui_make_visible (win_info->detail.source_info.execution_info);
+      base = (tui_source_window_base *) win_info;
+      tui_free_win_content (base->execution_info);
+      tui_make_visible (base->execution_info);
       if (win_info->generic.content != NULL)
 	{
-	  struct gdbarch *gdbarch = win_info->detail.source_info.gdbarch;
+	  struct gdbarch *gdbarch = base->gdbarch;
 	  struct tui_line_or_address line_or_addr;
 	  struct symtab_and_line cursal
 	    = get_current_source_symtab_and_line ();
 
-	  line_or_addr = win_info->detail.source_info.start_line_or_addr;
+	  line_or_addr = base->start_line_or_addr;
 	  tui_free_win_content (&win_info->generic);
 	  tui_update_source_window (win_info, gdbarch,
 				    cursal.symtab, line_or_addr, TRUE);
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index cacc0b84454..542881779fa 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -225,8 +225,11 @@ make_all_visible (int visible)
 	  && ((tui_win_list[i])->generic.type) != CMD_WIN)
 	{
 	  if (tui_win_is_source_type ((tui_win_list[i])->generic.type))
-	    make_visible ((tui_win_list[i])->detail.source_info.execution_info,
-			  visible);
+	    {
+	      tui_source_window_base *base
+		= (tui_source_window_base *) tui_win_list[i];
+	      make_visible (base->execution_info, visible);
+	    }
 	  make_visible (&tui_win_list[i]->generic, visible);
 	}
     }
@@ -260,8 +263,10 @@ tui_refresh_all (struct tui_win_info **list)
 	{
 	  if (type == SRC_WIN || type == DISASSEM_WIN)
 	    {
-	      touchwin (list[type]->detail.source_info.execution_info->handle);
-	      tui_refresh_win (list[type]->detail.source_info.execution_info);
+	      tui_source_window_base *base
+		= (tui_source_window_base *) list[type];
+	      touchwin (base->execution_info->handle);
+	      tui_refresh_win (base->execution_info);
 	    }
 	  touchwin (list[type]->generic.handle);
 	  tui_refresh_win (&list[type]->generic);
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 8c269e2ec4a..fa9e544f206 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -75,7 +75,8 @@ tui_update_source_window (struct tui_win_info *win_info,
 			  struct tui_line_or_address line_or_addr,
 			  int noerror)
 {
-  win_info->detail.source_info.horizontal_offset = 0;
+  tui_source_window_base *base = (tui_source_window_base *) win_info;
+  base->horizontal_offset = 0;
   tui_update_source_window_as_is (win_info, gdbarch, s, line_or_addr, noerror);
 
   return;
@@ -324,8 +325,9 @@ tui_refill_source_window (struct tui_win_info *win_info)
 	   : cursal.symtab);
     }
 
+  tui_source_window_base *base = (tui_source_window_base *) win_info;
   tui_update_source_window_as_is (win_info,
-				  win_info->detail.source_info.gdbarch,
+				  base->gdbarch,
 				  s,
 				  win_info->generic.content[0]
 				    ->which_element.source.line_or_addr,
@@ -343,16 +345,14 @@ tui_source_window_base::do_scroll_horizontal
       int offset;
 
       if (direction == LEFT_SCROLL)
-	offset = detail.source_info.horizontal_offset
-	  + num_to_scroll;
+	offset = horizontal_offset + num_to_scroll;
       else
 	{
-	  offset = detail.source_info.horizontal_offset
-	    - num_to_scroll;
+	  offset = horizontal_offset - num_to_scroll;
 	  if (offset < 0)
 	    offset = 0;
 	}
-      detail.source_info.horizontal_offset = offset;
+      horizontal_offset = offset;
       tui_refill_source_window (this);
     }
 }
@@ -425,7 +425,7 @@ tui_update_breakpoint_info (struct tui_win_info *win,
 {
   int i;
   int need_refresh = 0;
-  struct tui_source_info *src = &win->detail.source_info;
+  tui_source_window_base *src = (tui_source_window_base *) win;
 
   for (i = 0; i < win->generic.content_size; i++)
     {
@@ -494,10 +494,10 @@ tui_set_exec_info_content (struct tui_win_info *win_info)
 {
   enum tui_status ret = TUI_SUCCESS;
 
-  if (win_info->detail.source_info.execution_info != NULL)
+  tui_source_window_base *base = (tui_source_window_base *) win_info;
+  if (base->execution_info != NULL)
     {
-      struct tui_gen_win_info *exec_info_ptr
-	= win_info->detail.source_info.execution_info;
+      struct tui_gen_win_info *exec_info_ptr = base->execution_info;
 
       if (exec_info_ptr->content == NULL)
 	exec_info_ptr->content =
@@ -551,8 +551,8 @@ tui_set_exec_info_content (struct tui_win_info *win_info)
 void
 tui_show_exec_info_content (struct tui_win_info *win_info)
 {
-  struct tui_gen_win_info *exec_info
-    = win_info->detail.source_info.execution_info;
+  tui_source_window_base *base = (tui_source_window_base *) win_info;
+  struct tui_gen_win_info *exec_info = base->execution_info;
   int cur_line;
 
   werase (exec_info->handle);
@@ -571,8 +571,8 @@ tui_show_exec_info_content (struct tui_win_info *win_info)
 void
 tui_erase_exec_info_content (struct tui_win_info *win_info)
 {
-  struct tui_gen_win_info *exec_info
-    = win_info->detail.source_info.execution_info;
+  tui_source_window_base *base = (tui_source_window_base *) win_info;
+  struct tui_gen_win_info *exec_info = base->execution_info;
 
   werase (exec_info->handle);
   tui_refresh_win (exec_info);
@@ -581,7 +581,8 @@ tui_erase_exec_info_content (struct tui_win_info *win_info)
 void
 tui_clear_exec_info_content (struct tui_win_info *win_info)
 {
-  win_info->detail.source_info.execution_info->content_in_use = FALSE;
+  tui_source_window_base *base = (tui_source_window_base *) win_info;
+  base->execution_info->content_in_use = FALSE;
   tui_erase_exec_info_content (win_info);
 
   return;
-- 
2.17.2

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

* [PATCH 18/66] Change tui_data_window::display_regs to bool
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (27 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 19/66] Inline constructors and initializers Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 23:25 ` [PATCH 45/66] Introduce tui_win_info::update_tab_width Tom Tromey
                   ` (21 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_data_window::display_regs to bool and updates the
uses.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.c (tui_show_registers): Update.
	* tui/tui-data.h (struct tui_data_window) <display_regs>: Now
	bool.
	* tui/tui-data.c (tui_data_window::clear_detail)
	(tui_data_window): Update.
---
 gdb/ChangeLog      | 8 ++++++++
 gdb/tui/tui-data.c | 6 +++---
 gdb/tui/tui-data.h | 2 +-
 gdb/tui/tui-regs.c | 2 +-
 4 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 37aee67df0b..fe751574b95 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -195,7 +195,7 @@ tui_data_window::clear_detail ()
   regs_content = NULL;
   regs_content_count = 0;
   regs_column_count = 1;
-  display_regs = FALSE;
+  display_regs = false;
 }
 
 /* Accessor for the source execution info ptr.  */
@@ -503,7 +503,7 @@ tui_data_window::tui_data_window ()
   regs_content = NULL;
   regs_content_count = 0;
   regs_column_count = 1;
-  display_regs = FALSE;
+  display_regs = false;
   current_group = 0;
 }
 
@@ -621,7 +621,7 @@ tui_data_window::~tui_data_window ()
       data_content = NULL;
       data_content_count = 0;
       regs_column_count = 1;
-      display_regs = FALSE;
+      display_regs = false;
       generic.content = NULL;
       generic.content_size = 0;
     }
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 6e50601dd9a..50e926c42ad 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -357,7 +357,7 @@ struct tui_data_window : public tui_win_info
   tui_win_content regs_content;	/* Start of regs display content.  */
   int regs_content_count;
   int regs_column_count;
-  int display_regs;		/* Should regs be displayed at all?  */
+  bool display_regs;		/* Should regs be displayed at all?  */
   struct reggroup *current_group;
 
 protected:
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 451bcdfb364..d7940af984b 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -143,7 +143,7 @@ tui_show_registers (struct reggroup *group)
 
   /* Say that registers should be displayed, even if there is a
      problem.  */
-  TUI_DATA_WIN->display_regs = TRUE;
+  TUI_DATA_WIN->display_regs = true;
 
   if (target_has_registers && target_has_stack && target_has_memory)
     {
-- 
2.17.2

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

* [PATCH 24/66] Introduce two TUI source window methods
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (16 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 02/66] Add destructor to tui_win_info Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 06/66] Simplify source and disassembly window creation Tom Tromey
                   ` (32 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds two methods to the TUI source window.  These are just
renamings of existing functions.  It also changes the source window
list to have a more precise type, letting the code be more type-safe.
This will be useful again later.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_refill_source_window)
	(tui_set_is_exec_point_at): Don't declare.
	* tui/tui-winsource.c (tui_update_source_windows_with_addr)
	(tui_source_window_base::refill): Rename from
	tui_refill_source_window.
	(tui_source_window_base::do_scroll_horizontal): Update.
	(tui_source_window_base::set_is_exec_point_at): Rename from
	tui_set_is_exec_point_at.
	(tui_update_all_breakpoint_info): Update.
	* tui/tui-stack.c (tui_show_frame_info): Update.
	* tui/tui-layout.c (show_data): Add cast.
	* tui/tui-hooks.c (tui_redisplay_source): Call refill method.
	* tui/tui-data.h (struct tui_source_window_base) <refill,
	set_is_exec_point_at>: New methods.
	(tui_source_windows, tui_add_to_source_windows): Update types.
	(tui_add_to_source_windows): Remove redundant declaration.
	* tui/tui-data.c (source_windows): Store tui_source_window_base.
	(tui_source_windows): Change return type.
	(tui_clear_source_windows_detail): Update.
	(tui_add_to_source_windows): Change type of parameter.
	(tui_free_all_source_wins_content): Update.
---
 gdb/ChangeLog           | 24 ++++++++++++++++++++++++
 gdb/tui/tui-data.c      | 13 ++++++-------
 gdb/tui/tui-data.h      | 13 +++++++++----
 gdb/tui/tui-hooks.c     |  2 +-
 gdb/tui/tui-layout.c    |  3 ++-
 gdb/tui/tui-stack.c     |  8 ++++----
 gdb/tui/tui-winsource.c | 31 +++++++++++++------------------
 gdb/tui/tui-winsource.h |  3 ---
 8 files changed, 59 insertions(+), 38 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 89f65bf974f..a48b39eba7e 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -38,7 +38,7 @@ static enum tui_layout_type current_layout = UNDEFINED_LAYOUT;
 static int term_height, term_width;
 static struct tui_gen_win_info _locator;
 static struct tui_gen_win_info exec_info[2];
-static struct std::vector<tui_win_info *> source_windows;
+static struct std::vector<tui_source_window_base *> source_windows;
 static struct tui_win_info *win_with_focus = NULL;
 static struct tui_layout_def layout_def = {
   SRC_WIN,			/* DISPLAY_MODE */
@@ -124,7 +124,7 @@ tui_set_win_with_focus (struct tui_win_info *win_info)
 /* Accessor for the current source window.  Usually there is only one
    source window (either source or disassembly), but both can be
    displayed at the same time.  */
-struct std::vector<tui_win_info *> &
+struct std::vector<tui_source_window_base *> &
 tui_source_windows ()
 {
   return source_windows;
@@ -145,7 +145,7 @@ tui_clear_source_windows ()
 void
 tui_clear_source_windows_detail ()
 {
-  for (tui_win_info *win : tui_source_windows ())
+  for (tui_source_window_base *win : tui_source_windows ())
     win->clear_detail ();
 }
 
@@ -154,7 +154,7 @@ tui_clear_source_windows_detail ()
    one source window (either source or disassembly), but both can be
    displayed at the same time.  */
 void
-tui_add_to_source_windows (struct tui_win_info *win_info)
+tui_add_to_source_windows (struct tui_source_window_base *win_info)
 {
   if (source_windows.size () < 2)
     source_windows.push_back (win_info);
@@ -620,11 +620,10 @@ tui_win_info::~tui_win_info ()
 void
 tui_free_all_source_wins_content ()
 {
-  for (tui_win_info *win_info : tui_source_windows ())
+  for (tui_source_window_base *win_info : tui_source_windows ())
     {
       tui_free_win_content (&(win_info->generic));
-      tui_source_window_base *base = (tui_source_window_base *) win_info;
-      tui_free_win_content (base->execution_info);
+      tui_free_win_content (win_info->execution_info);
     }
 }
 
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index e25f8888c92..c41e812c483 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -304,6 +304,13 @@ public:
   void make_visible (bool visible) override;
   void refresh () override;
 
+  /* Refill the source window's source cache and update it.  If this
+     is a disassembly window, then just update it.  */
+  void refill ();
+
+  /* Set the location of the execution point.  */
+  void set_is_exec_point_at (struct tui_line_or_address l);
+
   /* Does locator belongs to this window?  */
   bool m_has_locator = false;
   /* Execution information window.  */
@@ -451,10 +458,10 @@ extern void tui_set_term_width_to (int);
 extern struct tui_gen_win_info *tui_locator_win_info_ptr (void);
 extern struct tui_gen_win_info *tui_source_exec_info_win_ptr (void);
 extern struct tui_gen_win_info *tui_disassem_exec_info_win_ptr (void);
-extern struct std::vector<tui_win_info *> &tui_source_windows ();
+extern struct std::vector<tui_source_window_base *> &tui_source_windows ();
 extern void tui_clear_source_windows (void);
 extern void tui_clear_source_windows_detail (void);
-extern void tui_add_to_source_windows (struct tui_win_info *);
+extern void tui_add_to_source_windows (struct tui_source_window_base *);
 extern struct tui_win_info *tui_win_with_focus (void);
 extern void tui_set_win_with_focus (struct tui_win_info *);
 extern struct tui_layout_def *tui_layout_def (void);
@@ -464,8 +471,6 @@ extern void tui_set_win_resized_to (int);
 extern struct tui_win_info *tui_next_win (struct tui_win_info *);
 extern struct tui_win_info *tui_prev_win (struct tui_win_info *);
 
-extern void tui_add_to_source_windows (struct tui_win_info *);
-
 extern unsigned int tui_tab_width;
 
 #endif /* TUI_TUI_DATA_H */
diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index 4a1d79e0ad0..7e94a13e901 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -212,7 +212,7 @@ tui_redisplay_source ()
   if (tui_is_window_visible (SRC_WIN))
     {
       /* Force redisplay.  */
-      tui_refill_source_window (tui_win_list[SRC_WIN]);
+      TUI_SRC_WIN->refill ();
     }
 }
 
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index de78c6c0ac8..9b2bd0b7b57 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -776,7 +776,8 @@ show_data (enum tui_layout_type new_layout)
   base->m_has_locator = true;
   tui_make_visible (locator);
   tui_show_locator_content ();
-  tui_add_to_source_windows (tui_win_list[win_type]);
+  tui_add_to_source_windows
+    ((tui_source_window_base *) tui_win_list[win_type]);
   tui_set_current_layout_to (new_layout);
 }
 
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index d09acd28585..125a5b7a8e3 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -396,7 +396,7 @@ tui_show_frame_info (struct frame_info *fi)
 
       tui_show_locator_content ();
       start_line = 0;
-      for (struct tui_win_info *win_info : tui_source_windows ())
+      for (struct tui_source_window_base *win_info : tui_source_windows ())
 	{
 	  union tui_which_element *item;
 
@@ -436,7 +436,7 @@ tui_show_frame_info (struct frame_info *fi)
 	      else
 		{
 		  l.u.line_no = item->locator.line_no;
-		  tui_set_is_exec_point_at (l, win_info);
+		  win_info->set_is_exec_point_at (l);
 		}
 	    }
 	  else
@@ -454,7 +454,7 @@ tui_show_frame_info (struct frame_info *fi)
 		  else
 		    {
 		      a.u.addr = item->locator.addr;
-		      tui_set_is_exec_point_at (a, win_info);
+		      win_info->set_is_exec_point_at (a);
 		    }
 		}
 	    }
@@ -472,7 +472,7 @@ tui_show_frame_info (struct frame_info *fi)
 	return 0;
 
       tui_show_locator_content ();
-      for (struct tui_win_info *win_info : tui_source_windows ())
+      for (struct tui_source_window_base *win_info : tui_source_windows ())
 	{
 	  tui_clear_source_content (win_info, EMPTY_SOURCE_PROMPT);
 	  tui_update_exec_info (win_info);
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index fa9e544f206..5946db75aaf 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -160,7 +160,7 @@ tui_update_source_windows_with_addr (struct gdbarch *gdbarch, CORE_ADDR addr)
     }
   else
     {
-      for (struct tui_win_info *win_info : tui_source_windows ())
+      for (struct tui_source_window_base *win_info : tui_source_windows ())
 	{
 	  tui_clear_source_content (win_info, EMPTY_SOURCE_PROMPT);
 	  tui_clear_exec_info_content (win_info);
@@ -309,15 +309,14 @@ tui_show_source_content (struct tui_win_info *win_info)
   win_info->generic.content_in_use = TRUE;
 }
 
-/* Refill the source window's source cache and update it.  If WIN_INFO
-   is a disassembly window, then just update it.  */
+/* See tui-data.h.  */
 
 void
-tui_refill_source_window (struct tui_win_info *win_info)
+tui_source_window_base::refill ()
 {
   symtab *s = nullptr;
 
-  if (win_info->generic.type == SRC_WIN)
+  if (generic.type == SRC_WIN)
     {
       symtab_and_line cursal = get_current_source_symtab_and_line ();
       s = (cursal.symtab == NULL
@@ -325,11 +324,8 @@ tui_refill_source_window (struct tui_win_info *win_info)
 	   : cursal.symtab);
     }
 
-  tui_source_window_base *base = (tui_source_window_base *) win_info;
-  tui_update_source_window_as_is (win_info,
-				  base->gdbarch,
-				  s,
-				  win_info->generic.content[0]
+  tui_update_source_window_as_is (this, gdbarch, s,
+				  generic.content[0]
 				    ->which_element.source.line_or_addr,
 				  FALSE);
 }
@@ -353,7 +349,7 @@ tui_source_window_base::do_scroll_horizontal
 	    offset = 0;
 	}
       horizontal_offset = offset;
-      tui_refill_source_window (this);
+      refill ();
     }
 }
 
@@ -362,15 +358,14 @@ tui_source_window_base::do_scroll_horizontal
    line_no.  */
 
 void
-tui_set_is_exec_point_at (struct tui_line_or_address l, 
-			  struct tui_win_info *win_info)
+tui_source_window_base::set_is_exec_point_at (struct tui_line_or_address l)
 {
   int changed = 0;
   int i;
-  tui_win_content content = win_info->generic.content;
+  tui_win_content content = generic.content;
 
   i = 0;
-  while (i < win_info->generic.content_size)
+  while (i < generic.content_size)
     {
       int new_state;
       struct tui_line_or_address content_loa =
@@ -389,12 +384,12 @@ tui_set_is_exec_point_at (struct tui_line_or_address l,
         {
           changed++;
           content[i]->which_element.source.is_exec_point = new_state;
-          tui_show_source_line (win_info, i + 1);
+          tui_show_source_line (this, i + 1);
         }
       i++;
     }
   if (changed)
-    tui_refill_source_window (win_info);
+    refill ();
 }
 
 /* Update the execution windows to show the active breakpoints.
@@ -403,7 +398,7 @@ tui_set_is_exec_point_at (struct tui_line_or_address l,
 void
 tui_update_all_breakpoint_info ()
 {
-  for (tui_win_info *win : tui_source_windows ())
+  for (tui_source_window_base *win : tui_source_windows ())
     {
       if (tui_update_breakpoint_info (win, FALSE))
         {
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 98ce75fb620..ada3964ad1a 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -53,15 +53,12 @@ extern void tui_update_source_windows_with_line (struct symtab *,
 extern void tui_clear_source_content (struct tui_win_info *, int);
 extern void tui_erase_source_content (struct tui_win_info *, int);
 extern void tui_show_source_content (struct tui_win_info *);
-extern void tui_refill_source_window (struct tui_win_info *);
 extern enum tui_status tui_set_exec_info_content (struct tui_win_info *);
 extern void tui_show_exec_info_content (struct tui_win_info *);
 extern void tui_erase_exec_info_content (struct tui_win_info *);
 extern void tui_clear_exec_info_content (struct tui_win_info *);
 extern void tui_update_exec_info (struct tui_win_info *);
 
-extern void tui_set_is_exec_point_at (struct tui_line_or_address,
-				      struct tui_win_info *);
 extern enum tui_status tui_alloc_source_buffer (struct tui_win_info *);
 extern int tui_line_is_displayed (int, 
 				  struct tui_win_info *, 
-- 
2.17.2

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

* [PATCH 19/66] Inline constructors and initializers
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (26 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 03/66] Create subclasses for different window types Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 18/66] Change tui_data_window::display_regs to bool Tom Tromey
                   ` (22 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This inlines the constructors and initializers for tui_cmd_window and
tui_data_window.  This makes the code a bit simpler.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (struct tui_data_window, struct tui_cmd_window):
	Inline constructor.  Add initializers for members.
	* tui/tui-data.c (tui_data_window, tui_cmd_window): Remove
	constructors; now inline in class.
---
 gdb/ChangeLog      |  7 +++++++
 gdb/tui/tui-data.c | 17 -----------------
 gdb/tui/tui-data.h | 31 +++++++++++++++++++++----------
 3 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index fe751574b95..c9c0bdf3f21 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -495,23 +495,6 @@ tui_source_window_base::tui_source_window_base (enum tui_win_type type)
   start_line_or_addr.u.addr = 0;
 }
 
-tui_data_window::tui_data_window ()
-  : tui_win_info (DATA_WIN)
-{
-  data_content = NULL;
-  data_content_count = 0;
-  regs_content = NULL;
-  regs_content_count = 0;
-  regs_column_count = 1;
-  display_regs = false;
-  current_group = 0;
-}
-
-tui_cmd_window::tui_cmd_window ()
-  : tui_win_info (CMD_WIN)
-{
-}
-
 struct tui_win_info *
 tui_alloc_win_info (enum tui_win_type type)
 {
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 50e926c42ad..48c92bf99f0 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -346,19 +346,26 @@ protected:
 
 struct tui_data_window : public tui_win_info
 {
-  tui_data_window ();
+  tui_data_window ()
+    : tui_win_info (DATA_WIN)
+  {
+  }
+
   ~tui_data_window () override;
   DISABLE_COPY_AND_ASSIGN (tui_data_window);
 
   void clear_detail () override;
 
-  tui_win_content data_content;	/* Start of data display content.  */
-  int data_content_count;
-  tui_win_content regs_content;	/* Start of regs display content.  */
-  int regs_content_count;
-  int regs_column_count;
-  bool display_regs;		/* Should regs be displayed at all?  */
-  struct reggroup *current_group;
+  /* Start of data display content.  */
+  tui_win_content data_content = NULL;
+  int data_content_count = 0;
+  /* Start of regs display content.  */
+  tui_win_content regs_content = NULL;
+  int regs_content_count = 0;
+  int regs_column_count = 0;
+  /* Should regs be displayed at all?  */
+  bool display_regs = false;
+  struct reggroup *current_group = nullptr;
 
 protected:
 
@@ -372,12 +379,16 @@ protected:
 
 struct tui_cmd_window : public tui_win_info
 {
-  tui_cmd_window ();
+  tui_cmd_window ()
+    : tui_win_info (CMD_WIN)
+  {
+  }
+
   DISABLE_COPY_AND_ASSIGN (tui_cmd_window);
 
   void clear_detail () override;
 
-  int start_line;
+  int start_line = 0;
 
 protected:
 
-- 
2.17.2

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

* [PATCH 22/66] Use bool for visibility
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (23 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 23/66] Introduce the refresh method Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 29/66] Introduce set_highlight method Tom Tromey
                   ` (25 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes the visibility-related functions and data members in the
TUI to use bool rather than int.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui.h (tui_is_window_visible): Return bool.
	* tui/tui.c (tui_is_window_visible): Return bool.
	* tui/tui-wingeneral.c (tui_make_window, make_visible)
	(tui_make_visible, tui_make_invisible)
	(tui_win_info::make_visible)
	(tui_source_window_base::make_visible, make_all_visible)
	(tui_make_all_visible, tui_make_all_invisible): Update.
	* tui/tui-windata.c (tui_delete_data_content_windows): Update.
	* tui/tui-data.h (struct tui_gen_win_info) <is_visible>: Now
	bool.
	(struct tui_win_info, struct tui_source_window_base)
	(struct tui_cmd_window) <make_visible>: Change parameter to bool.
	* tui/tui-data.c (tui_init_generic_part): Update.
---
 gdb/ChangeLog            | 16 ++++++++++++++++
 gdb/tui/tui-data.c       |  4 ++--
 gdb/tui/tui-data.h       |  8 ++++----
 gdb/tui/tui-windata.c    |  2 +-
 gdb/tui/tui-wingeneral.c | 22 +++++++++++-----------
 gdb/tui/tui.c            |  6 +++---
 gdb/tui/tui.h            |  2 +-
 7 files changed, 38 insertions(+), 22 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 39381ea0859..89f65bf974f 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -420,8 +420,8 @@ tui_init_generic_part (struct tui_gen_win_info *win)
     win->last_visible_line = 0;
   win->handle = NULL;
   win->content = NULL;
-  win->content_in_use =
-    win->is_visible = FALSE;
+  win->content_in_use = FALSE;
+  win->is_visible = false;
   win->title = 0;
 }
 
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 249f3cc81f4..34de67757b0 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -49,7 +49,7 @@ struct tui_gen_win_info
   int content_in_use;	    /* Can it be used, or is it already used?  */
   int viewport_height;	    /* Viewport height.  */
   int last_visible_line;    /* Index of last visible line.  */
-  int is_visible;	    /* Whether the window is visible or not.  */
+  bool is_visible;	    /* Whether the window is visible or not.  */
   char *title;              /* Window title to display.  */
 };
 
@@ -256,7 +256,7 @@ public:
   }
 
   /* Make this window visible or invisible.  */
-  virtual void make_visible (int visible);
+  virtual void make_visible (bool visible);
 
   /* Methods to scroll the contents of this window.  Note that they
      are named with "_scroll" coming at the end because the more
@@ -298,7 +298,7 @@ public:
     return m_has_locator;
   }
 
-  void make_visible (int visible) override;
+  void make_visible (bool visible) override;
 
   /* Does locator belongs to this window?  */
   bool m_has_locator = false;
@@ -393,7 +393,7 @@ struct tui_cmd_window : public tui_win_info
 
   void clear_detail () override;
 
-  void make_visible (int visible) override
+  void make_visible (bool visible) override
   {
   }
 
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index a0f20c309e1..67228a6c5ee 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -78,7 +78,7 @@ tui_delete_data_content_windows (void)
 	= &TUI_DATA_WIN->generic.content[i]->which_element.data_window;
       tui_delete_win (data_item_win_ptr->handle);
       data_item_win_ptr->handle = NULL;
-      data_item_win_ptr->is_visible = FALSE;
+      data_item_win_ptr->is_visible = false;
     }
 }
 
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 1308437befd..e802e52ca5b 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -161,7 +161,7 @@ tui_make_window (struct tui_gen_win_info *win_info, int box_it)
     {
       if (box_it == BOX_WINDOW)
 	box_win (win_info, NO_HILITE);
-      win_info->is_visible = TRUE;
+      win_info->is_visible = true;
       scrollok (handle, TRUE);
     }
 }
@@ -171,7 +171,7 @@ tui_make_window (struct tui_gen_win_info *win_info, int box_it)
    delete the entire window when making it visible, and create it
    again when making it visible.  */
 static void
-make_visible (struct tui_gen_win_info *win_info, int visible)
+make_visible (struct tui_gen_win_info *win_info, bool visible)
 {
   /* Don't tear down/recreate command window.  */
   if (win_info->type == CMD_WIN)
@@ -184,14 +184,14 @@ make_visible (struct tui_gen_win_info *win_info, int visible)
 	  tui_make_window (win_info,
 			   (win_info->type != CMD_WIN
 			    && !tui_win_is_auxillary (win_info->type)));
-	  win_info->is_visible = TRUE;
+	  win_info->is_visible = true;
 	}
     }
   else if (!visible
 	   && win_info->is_visible
 	   && win_info->handle != NULL)
     {
-      win_info->is_visible = FALSE;
+      win_info->is_visible = false;
       tui_delete_win (win_info->handle);
       win_info->handle = NULL;
     }
@@ -202,19 +202,19 @@ make_visible (struct tui_gen_win_info *win_info, int visible)
 void
 tui_make_visible (struct tui_gen_win_info *win_info)
 {
-  make_visible (win_info, 1);
+  make_visible (win_info, true);
 }
 
 void
 tui_make_invisible (struct tui_gen_win_info *win_info)
 {
-  make_visible (win_info, 0);
+  make_visible (win_info, false);
 }
 
 /* See tui-data.h.  */
 
 void
-tui_win_info::make_visible (int visible)
+tui_win_info::make_visible (bool visible)
 {
   ::make_visible (&generic, visible);
 }
@@ -222,7 +222,7 @@ tui_win_info::make_visible (int visible)
 /* See tui-data.h.  */
 
 void
-tui_source_window_base::make_visible (int visible)
+tui_source_window_base::make_visible (bool visible)
 {
   ::make_visible (execution_info, visible);
   tui_win_info::make_visible (visible);
@@ -231,7 +231,7 @@ tui_source_window_base::make_visible (int visible)
 /* Makes all windows invisible (except the command and locator
    windows).  */
 static void
-make_all_visible (int visible)
+make_all_visible (bool visible)
 {
   int i;
 
@@ -247,13 +247,13 @@ make_all_visible (int visible)
 void
 tui_make_all_visible (void)
 {
-  make_all_visible (1);
+  make_all_visible (true);
 }
 
 void
 tui_make_all_invisible (void)
 {
-  make_all_visible (0);
+  make_all_visible (false);
 }
 
 /* Function to refresh all the windows currently displayed.  */
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index ce8de72f28d..d7201992ae4 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -655,14 +655,14 @@ tui_show_assembly (struct gdbarch *gdbarch, CORE_ADDR addr)
   tui_update_source_windows_with_addr (gdbarch, addr);
 }
 
-int
+bool
 tui_is_window_visible (enum tui_win_type type)
 {
   if (tui_active == 0)
-    return 0;
+    return false;
 
   if (tui_win_list[type] == 0)
-    return 0;
+    return false;
   
   return tui_win_list[type]->generic.is_visible;
 }
diff --git a/gdb/tui/tui.h b/gdb/tui/tui.h
index 5b8be0cd481..8f6ef64f496 100644
--- a/gdb/tui/tui.h
+++ b/gdb/tui/tui.h
@@ -56,7 +56,7 @@ enum tui_win_type
 extern CORE_ADDR tui_get_low_disassembly_address (struct gdbarch *,
 						  CORE_ADDR, CORE_ADDR);
 extern void tui_show_assembly (struct gdbarch *gdbarch, CORE_ADDR addr);
-extern int tui_is_window_visible (enum tui_win_type type);
+extern bool tui_is_window_visible (enum tui_win_type type);
 extern int tui_get_command_dimension (unsigned int *width,
 				      unsigned int *height);
 
-- 
2.17.2

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

* [PATCH 04/66] Remove an unnecessary NULL check from the TUI
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (14 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 17/66] Remove struct tui_data_info Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 02/66] Add destructor to tui_win_info Tom Tromey
                   ` (34 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

In init_and_make_win, opaque_win_info can't be NULL after a new window
is allocated.  This patch removes an unnecessary NULL check.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (init_and_make_win): Remove NULL check.
---
 gdb/ChangeLog        |  4 ++++
 gdb/tui/tui-layout.c | 18 ++++++++----------
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index bcae819e518..695c56012c1 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -842,18 +842,16 @@ init_and_make_win (void *opaque_win_info,
   else
     generic = &((struct tui_win_info *) opaque_win_info)->generic;
 
-  if (opaque_win_info != NULL)
+  init_gen_win_info (generic, win_type, height, width, origin_x, origin_y);
+  if (!tui_win_is_auxillary (win_type))
     {
-      init_gen_win_info (generic, win_type, height, width, origin_x, origin_y);
-      if (!tui_win_is_auxillary (win_type))
-	{
-	  if (generic->type == CMD_WIN)
-	    ((struct tui_win_info *) opaque_win_info)->can_highlight = FALSE;
-	  else
-	    ((struct tui_win_info *) opaque_win_info)->can_highlight = TRUE;
-	}
-      tui_make_window (generic, box_it);
+      if (generic->type == CMD_WIN)
+	((struct tui_win_info *) opaque_win_info)->can_highlight = FALSE;
+      else
+	((struct tui_win_info *) opaque_win_info)->can_highlight = TRUE;
     }
+  tui_make_window (generic, box_it);
+
   return opaque_win_info;
 }
 
-- 
2.17.2

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

* [PATCH 21/66] Introduce make_visible method
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (8 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 15/66] Remove struct tui_source_info Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 20/66] Remove an unneeded NULL check Tom Tromey
                   ` (40 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduceds the make_visible to tui_win_info and overrides it in
subclasses as appropriate.  This allows the removal of the
tui_win_is_source_type, as it is no longer used.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (tui_win_info::make_visible)
	(tui_source_window_base::make_visible): New methods.
	(make_all_visible): Make method call.
	* tui/tui-data.h (struct tui_win_info) <make_visible>: New method.
	(struct tui_source_window_base, struct tui_cmd_window): Override
	make_visible.
	(tui_win_is_source_type): Don't declare.
	* tui/tui-data.c (tui_win_is_source_type): Remove.
---
 gdb/ChangeLog            | 11 +++++++++++
 gdb/tui/tui-data.c       |  6 ------
 gdb/tui/tui-data.h       | 10 +++++++++-
 gdb/tui/tui-wingeneral.c | 29 ++++++++++++++++++-----------
 4 files changed, 38 insertions(+), 18 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index c9c0bdf3f21..39381ea0859 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -63,12 +63,6 @@ static void free_content_elements (tui_win_content,
 ** PUBLIC FUNCTIONS
 **********************************/
 
-int
-tui_win_is_source_type (enum tui_win_type win_type)
-{
-  return (win_type == SRC_WIN || win_type == DISASSEM_WIN);
-}
-
 int
 tui_win_is_auxillary (enum tui_win_type win_type)
 {
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 48c92bf99f0..249f3cc81f4 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -255,6 +255,9 @@ public:
     return false;
   }
 
+  /* Make this window visible or invisible.  */
+  virtual void make_visible (int visible);
+
   /* Methods to scroll the contents of this window.  Note that they
      are named with "_scroll" coming at the end because the more
      obvious "scroll_forward" is defined as a macro in term.h.  */
@@ -295,6 +298,8 @@ public:
     return m_has_locator;
   }
 
+  void make_visible (int visible) override;
+
   /* Does locator belongs to this window?  */
   bool m_has_locator = false;
   /* Execution information window.  */
@@ -388,6 +393,10 @@ struct tui_cmd_window : public tui_win_info
 
   void clear_detail () override;
 
+  void make_visible (int visible) override
+  {
+  }
+
   int start_line = 0;
 
 protected:
@@ -403,7 +412,6 @@ protected:
   }
 };
 
-extern int tui_win_is_source_type (enum tui_win_type win_type);
 extern int tui_win_is_auxillary (enum tui_win_type win_type);
 extern void tui_set_win_highlight (struct tui_win_info *win_info,
 				   int highlight);
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 542881779fa..1308437befd 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -211,6 +211,22 @@ tui_make_invisible (struct tui_gen_win_info *win_info)
   make_visible (win_info, 0);
 }
 
+/* See tui-data.h.  */
+
+void
+tui_win_info::make_visible (int visible)
+{
+  ::make_visible (&generic, visible);
+}
+
+/* See tui-data.h.  */
+
+void
+tui_source_window_base::make_visible (int visible)
+{
+  ::make_visible (execution_info, visible);
+  tui_win_info::make_visible (visible);
+}
 
 /* Makes all windows invisible (except the command and locator
    windows).  */
@@ -221,17 +237,8 @@ make_all_visible (int visible)
 
   for (i = 0; i < MAX_MAJOR_WINDOWS; i++)
     {
-      if (tui_win_list[i] != NULL
-	  && ((tui_win_list[i])->generic.type) != CMD_WIN)
-	{
-	  if (tui_win_is_source_type ((tui_win_list[i])->generic.type))
-	    {
-	      tui_source_window_base *base
-		= (tui_source_window_base *) tui_win_list[i];
-	      make_visible (base->execution_info, visible);
-	    }
-	  make_visible (&tui_win_list[i]->generic, visible);
-	}
+      if (tui_win_list[i] != NULL)
+	tui_win_list[i]->make_visible (visible);
     }
 
   return;
-- 
2.17.2

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

* [PATCH 28/66] Remove redundant check from make_visible
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (10 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 20/66] Remove an unneeded NULL check Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 27/66] Introduce max_height method Tom Tromey
                   ` (38 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This removes a check of the window type from make_visible.  This
function already checks that the window type is not CMD_WIN near the
top, so this condition can never be false.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (make_visible): Remove check of window
	type.
---
 gdb/ChangeLog            | 5 +++++
 gdb/tui/tui-wingeneral.c | 4 +---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 4d168af0c09..73d77ce19f3 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -181,9 +181,7 @@ make_visible (struct tui_gen_win_info *win_info, bool visible)
     {
       if (!win_info->is_visible)
 	{
-	  tui_make_window (win_info,
-			   (win_info->type != CMD_WIN
-			    && !tui_win_is_auxillary (win_info->type)));
+	  tui_make_window (win_info, !tui_win_is_auxillary (win_info->type));
 	  win_info->is_visible = true;
 	}
     }
-- 
2.17.2

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

* [PATCH 29/66] Introduce set_highlight method
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (24 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 22/66] Use bool for visibility Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 03/66] Create subclasses for different window types Tom Tromey
                   ` (24 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces the tui_win_info::set_highlight method, and changes
the highlighting-related code to use bool rather than int.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (tui_unhighlight_win, tui_highlight_win):
	Update.
	* tui/tui-layout.c (make_command_window)
	(show_source_disasm_command, show_data, init_and_make_win)
	(show_source_or_disasm_and_command): Update.
	* tui/tui-data.h (struct tui_win_info) <set_highlight>: New
	method.
	<can_highight, is_highlighted>: Now bool.
	(tui_set_win_highlight): Don't declare.
	* tui/tui-data.c (tui_set_win_highlight): Remove.
---
 gdb/ChangeLog            | 13 +++++++++++++
 gdb/tui/tui-data.c       |  8 --------
 gdb/tui/tui-data.h       | 12 ++++++++----
 gdb/tui/tui-layout.c     | 18 +++++++++---------
 gdb/tui/tui-wingeneral.c |  4 ++--
 5 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index a48b39eba7e..bdfc2de73af 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -69,14 +69,6 @@ tui_win_is_auxillary (enum tui_win_type win_type)
   return (win_type > MAX_MAJOR_WINDOWS);
 }
 
-void
-tui_set_win_highlight (struct tui_win_info *win_info, 
-		       int highlight)
-{
-  if (win_info != NULL)
-    win_info->is_highlighted = highlight;
-}
-
 /******************************************
 ** ACCESSORS & MUTATORS FOR PRIVATE DATA
 ******************************************/
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index bed28f64b19..98e7a2ca34e 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -276,6 +276,12 @@ public:
   /* Compute the maximum height of this window.  */
   virtual int max_height () const;
 
+  /* Set whether this window is highglighted.  */
+  void set_highlight (bool highlight)
+  {
+    is_highlighted = highlight;
+  }
+
   /* Methods to scroll the contents of this window.  Note that they
      are named with "_scroll" coming at the end because the more
      obvious "scroll_forward" is defined as a macro in term.h.  */
@@ -287,10 +293,10 @@ public:
   struct tui_gen_win_info generic;	/* General window information.  */
 
   /* Can this window ever be highlighted?  */
-  int can_highlight = 0;
+  bool can_highlight = false;
 
   /* Is this window highlighted?  */
-  int is_highlighted = 0;
+  bool is_highlighted = false;
 };
 
 /* The base class for all source-like windows, namely the source and
@@ -447,8 +453,6 @@ protected:
 };
 
 extern int tui_win_is_auxillary (enum tui_win_type win_type);
-extern void tui_set_win_highlight (struct tui_win_info *win_info,
-				   int highlight);
 
 
 /* Global Data.  */
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 9b2bd0b7b57..d060c5c7807 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -546,7 +546,7 @@ make_command_window (int height, int origin_y)
 						 0,
 						 origin_y,
 						 DONT_BOX_WINDOW);
-  result->can_highlight = FALSE;
+  result->can_highlight = false;
   return result;
 }
 
@@ -627,7 +627,7 @@ show_source_disasm_command (void)
 			     TUI_SRC_WIN->generic.width,
 			     TUI_SRC_WIN->execution_info->width,
 			     0);
-	  TUI_SRC_WIN->can_highlight = TRUE;
+	  TUI_SRC_WIN->can_highlight = true;
 	  init_gen_win_info (TUI_SRC_WIN->execution_info,
 			     EXEC_INFO_WIN,
 			     src_height,
@@ -677,7 +677,7 @@ show_source_disasm_command (void)
 			     3,
 			     0,
 			     src_height - 1);
-	  TUI_DISASM_WIN->can_highlight = TRUE;
+	  TUI_DISASM_WIN->can_highlight = true;
 	  tui_make_visible (&TUI_DISASM_WIN->generic);
 	  tui_make_visible (TUI_DISASM_WIN->execution_info);
 	}
@@ -698,7 +698,7 @@ show_source_disasm_command (void)
 			     TUI_CMD_WIN->generic.width,
 			     0,
 			     TUI_CMD_WIN->generic.origin.y);
-	  TUI_CMD_WIN->can_highlight = FALSE;
+	  TUI_CMD_WIN->can_highlight = false;
 	  tui_make_visible (&TUI_CMD_WIN->generic);
 	}
       tui_refresh_win (&TUI_CMD_WIN->generic);
@@ -723,7 +723,7 @@ show_data (enum tui_layout_type new_layout)
   tui_make_all_invisible ();
   tui_make_invisible (locator);
   make_data_window (&tui_win_list[DATA_WIN], data_height, 0);
-  TUI_DATA_WIN->can_highlight = TRUE;
+  TUI_DATA_WIN->can_highlight = true;
   if (new_layout == SRC_DATA_COMMAND)
     win_type = SRC_WIN;
   else
@@ -835,9 +835,9 @@ init_and_make_win (void *opaque_win_info,
   if (!tui_win_is_auxillary (win_type))
     {
       if (generic->type == CMD_WIN)
-	((struct tui_win_info *) opaque_win_info)->can_highlight = FALSE;
+	((struct tui_win_info *) opaque_win_info)->can_highlight = false;
       else
-	((struct tui_win_info *) opaque_win_info)->can_highlight = TRUE;
+	((struct tui_win_info *) opaque_win_info)->can_highlight = true;
     }
   tui_make_window (generic, box_it);
 
@@ -942,7 +942,7 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 			     3,
 			     0,
 			     0);
-	  base->can_highlight = TRUE;
+	  base->can_highlight = true;
 	  tui_make_visible (&(*win_info_ptr)->generic);
 	  tui_make_visible (base->execution_info);
 	}
@@ -966,7 +966,7 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 			     TUI_CMD_WIN->generic.width,
 			     TUI_CMD_WIN->generic.origin.x,
 			     TUI_CMD_WIN->generic.origin.y);
-	  TUI_CMD_WIN->can_highlight = FALSE;
+	  TUI_CMD_WIN->can_highlight = false;
 	  tui_make_visible (&TUI_CMD_WIN->generic);
 	}
       tui_set_current_layout_to (layout_type);
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 73d77ce19f3..c1778289442 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -114,7 +114,7 @@ tui_unhighlight_win (struct tui_win_info *win_info)
     {
       box_win (&win_info->generic, NO_HILITE);
       wrefresh (win_info->generic.handle);
-      tui_set_win_highlight (win_info, 0);
+      win_info->set_highlight (false);
     }
 }
 
@@ -128,7 +128,7 @@ tui_highlight_win (struct tui_win_info *win_info)
     {
       box_win (&win_info->generic, HILITE);
       wrefresh (win_info->generic.handle);
-      tui_set_win_highlight (win_info, 1);
+      win_info->set_highlight (true);
     }
 }
 
-- 
2.17.2

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

* [PATCH 20/66] Remove an unneeded NULL check
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (9 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 21/66] Introduce make_visible method Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 28/66] Remove redundant check from make_visible Tom Tromey
                   ` (39 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

show_source_or_disasm_and_command will either create or reset the
source window, so the final NULL check is not necessary.  This patch
removes it.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (show_source_or_disasm_and_command): Remove
	NULL check.
---
 gdb/ChangeLog        |  5 +++++
 gdb/tui/tui-layout.c | 44 +++++++++++++++++++++-----------------------
 2 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 72ec924f72c..de78c6c0ac8 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -945,30 +945,28 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 	  tui_make_visible (&(*win_info_ptr)->generic);
 	  tui_make_visible (base->execution_info);
 	}
-      if ((*win_info_ptr) != NULL)
-	{
-	  base->m_has_locator = true;
-	  tui_make_visible (locator);
-	  tui_show_locator_content ();
-	  tui_show_source_content (*win_info_ptr);
 
-	  if (TUI_CMD_WIN == NULL)
-	    {
-	      tui_win_list[CMD_WIN] = make_command_window (cmd_height,
-							   src_height);
-	      tui_refresh_win (&TUI_CMD_WIN->generic);
-	    }
-	  else
-	    {
-	      init_gen_win_info (&TUI_CMD_WIN->generic,
-				 TUI_CMD_WIN->generic.type,
-				 TUI_CMD_WIN->generic.height,
-				 TUI_CMD_WIN->generic.width,
-				 TUI_CMD_WIN->generic.origin.x,
-				 TUI_CMD_WIN->generic.origin.y);
-	      TUI_CMD_WIN->can_highlight = FALSE;
-	      tui_make_visible (&TUI_CMD_WIN->generic);
-	    }
+      base->m_has_locator = true;
+      tui_make_visible (locator);
+      tui_show_locator_content ();
+      tui_show_source_content (*win_info_ptr);
+
+      if (TUI_CMD_WIN == NULL)
+	{
+	  tui_win_list[CMD_WIN] = make_command_window (cmd_height,
+						       src_height);
+	  tui_refresh_win (&TUI_CMD_WIN->generic);
+	}
+      else
+	{
+	  init_gen_win_info (&TUI_CMD_WIN->generic,
+			     TUI_CMD_WIN->generic.type,
+			     TUI_CMD_WIN->generic.height,
+			     TUI_CMD_WIN->generic.width,
+			     TUI_CMD_WIN->generic.origin.x,
+			     TUI_CMD_WIN->generic.origin.y);
+	  TUI_CMD_WIN->can_highlight = FALSE;
+	  tui_make_visible (&TUI_CMD_WIN->generic);
 	}
       tui_set_current_layout_to (layout_type);
     }
-- 
2.17.2

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

* [PATCH 17/66] Remove struct tui_data_info
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (13 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 25/66] Introduce the refresh_all method Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 04/66] Remove an unnecessary NULL check from the TUI Tom Tromey
                   ` (35 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Like the previous two patches, this removes struct tui_data_info in
favor of inlining its contents into tui_data_window.  This was the
last member of the tui_win_info detail union, so that is removed.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-windata.c (tui_display_all_data)
	(tui_display_data_from_line, tui_display_data_from)
	(tui_check_data_values, tui_data_window::do_scroll_vertical):
	Update.
	* tui/tui-regs.c (tui_last_regs_line_no)
	(tui_line_from_reg_element_no, tui_first_reg_element_no_inline)
	(tui_show_registers, tui_show_register_group)
	(tui_display_registers_from, tui_display_reg_element_at_line)
	(tui_display_registers_from_line, tui_check_register_values)
	(tui_reg_next, tui_reg_prev): Update.
	* tui/tui-layout.c (tui_set_layout, show_data): Update.
	* tui/tui-data.h (struct tui_data_info): Remove.  Move contents to
	tui_data_window.
	(struct tui_win_info) <detail>: Remove.  Add new fields from
	tui_data_info.
	(TUI_DATA_WIN): Add cast.
	* tui/tui-data.c (tui_data_window::clear_detail, tui_data_window)
	(~tui_data_window): Simplify.
---
 gdb/ChangeLog         |  21 ++++++++
 gdb/tui/tui-data.c    |  44 ++++++++--------
 gdb/tui/tui-data.h    |  29 ++++-------
 gdb/tui/tui-layout.c  |   8 +--
 gdb/tui/tui-regs.c    | 115 +++++++++++++++++++-----------------------
 gdb/tui/tui-windata.c |  17 +++----
 6 files changed, 112 insertions(+), 122 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index ef9c9998930..37aee67df0b 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -190,12 +190,12 @@ tui_cmd_window::clear_detail ()
 void
 tui_data_window::clear_detail ()
 {
-  detail.data_display_info.data_content = NULL;
-  detail.data_display_info.data_content_count = 0;
-  detail.data_display_info.regs_content = NULL;
-  detail.data_display_info.regs_content_count = 0;
-  detail.data_display_info.regs_column_count = 1;
-  detail.data_display_info.display_regs = FALSE;
+  data_content = NULL;
+  data_content_count = 0;
+  regs_content = NULL;
+  regs_content_count = 0;
+  regs_column_count = 1;
+  display_regs = FALSE;
 }
 
 /* Accessor for the source execution info ptr.  */
@@ -498,13 +498,13 @@ tui_source_window_base::tui_source_window_base (enum tui_win_type type)
 tui_data_window::tui_data_window ()
   : tui_win_info (DATA_WIN)
 {
-  detail.data_display_info.data_content = (tui_win_content) NULL;
-  detail.data_display_info.data_content_count = 0;
-  detail.data_display_info.regs_content = (tui_win_content) NULL;
-  detail.data_display_info.regs_content_count = 0;
-  detail.data_display_info.regs_column_count = 1;
-  detail.data_display_info.display_regs = FALSE;
-  detail.data_display_info.current_group = 0;
+  data_content = NULL;
+  data_content_count = 0;
+  regs_content = NULL;
+  regs_content_count = 0;
+  regs_column_count = 1;
+  display_regs = FALSE;
+  current_group = 0;
 }
 
 tui_cmd_window::tui_cmd_window ()
@@ -614,16 +614,14 @@ tui_data_window::~tui_data_window ()
 {
   if (generic.content != NULL)
     {
-      tui_free_data_content (detail.data_display_info.regs_content,
-			     detail.data_display_info.regs_content_count);
-      detail.data_display_info.regs_content = NULL;
-      detail.data_display_info.regs_content_count = 0;
-      tui_free_data_content (detail.data_display_info.data_content,
-			     detail.data_display_info.data_content_count);
-      detail.data_display_info.data_content = NULL;
-      detail.data_display_info.data_content_count = 0;
-      detail.data_display_info.regs_column_count = 1;
-      detail.data_display_info.display_regs = FALSE;
+      tui_free_data_content (regs_content, regs_content_count);
+      regs_content = NULL;
+      regs_content_count = 0;
+      tui_free_data_content (data_content, data_content_count);
+      data_content = NULL;
+      data_content_count = 0;
+      regs_column_count = 1;
+      display_regs = FALSE;
       generic.content = NULL;
       generic.content_size = 0;
     }
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 4ca3a89b74e..6e50601dd9a 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -224,20 +224,6 @@ struct tui_win_element
   union tui_which_element which_element;
 };
 
-/* This struct defines the specific information about a data display
-   window.  */
-struct tui_data_info
-{
-  tui_win_content data_content;	/* Start of data display content.  */
-  int data_content_count;
-  tui_win_content regs_content;	/* Start of regs display content.  */
-  int regs_content_count;
-  int regs_column_count;
-  int display_regs;		/* Should regs be displayed at all?  */
-  struct reggroup *current_group;
-};
-
-
 /* This defines information about each logical window.  */
 struct tui_win_info
 {
@@ -278,11 +264,6 @@ public:
   void right_scroll (int num_to_scroll);
 
   struct tui_gen_win_info generic;	/* General window information.  */
-  union
-  {
-    struct tui_data_info data_display_info;
-  }
-  detail;
 
   /* Can this window ever be highlighted?  */
   int can_highlight = 0;
@@ -371,6 +352,14 @@ struct tui_data_window : public tui_win_info
 
   void clear_detail () override;
 
+  tui_win_content data_content;	/* Start of data display content.  */
+  int data_content_count;
+  tui_win_content regs_content;	/* Start of regs display content.  */
+  int regs_content_count;
+  int regs_column_count;
+  int display_regs;		/* Should regs be displayed at all?  */
+  struct reggroup *current_group;
+
 protected:
 
   void do_scroll_vertical (enum tui_scroll_direction,
@@ -414,7 +403,7 @@ extern struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
 
 #define TUI_SRC_WIN     ((tui_source_window_base *) tui_win_list[SRC_WIN])
 #define TUI_DISASM_WIN	((tui_source_window_base *) tui_win_list[DISASSEM_WIN])
-#define TUI_DATA_WIN    tui_win_list[DATA_WIN]
+#define TUI_DATA_WIN    ((tui_data_window *) tui_win_list[DATA_WIN])
 #define TUI_CMD_WIN     ((tui_cmd_window *) tui_win_list[CMD_WIN])
 
 /* Data Manipulation Functions.  */
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 95b89f8583a..72ec924f72c 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -227,11 +227,7 @@ tui_set_layout (enum tui_layout_type layout_type)
 	  tui_update_source_windows_with_addr (gdbarch, addr);
 
 	  if (regs_populate)
-	    {
-	      struct reggroup *group =
-		TUI_DATA_WIN->detail.data_display_info.current_group;
-	      tui_show_registers (group);
-	    }
+	    tui_show_registers (TUI_DATA_WIN->current_group);
 	}
     }
   else
@@ -726,7 +722,7 @@ show_data (enum tui_layout_type new_layout)
   src_height = total_height - data_height;
   tui_make_all_invisible ();
   tui_make_invisible (locator);
-  make_data_window (&TUI_DATA_WIN, data_height, 0);
+  make_data_window (&tui_win_list[DATA_WIN], data_height, 0);
   TUI_DATA_WIN->can_highlight = TRUE;
   if (new_layout == SRC_DATA_COMMAND)
     win_type = SRC_WIN;
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index b3456113369..451bcdfb364 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -72,12 +72,11 @@ tui_last_regs_line_no (void)
 {
   int num_lines = (-1);
 
-  if (TUI_DATA_WIN->detail.data_display_info.regs_content_count > 0)
+  if (TUI_DATA_WIN->regs_content_count > 0)
     {
-      num_lines = (TUI_DATA_WIN->detail.data_display_info.regs_content_count /
-		  TUI_DATA_WIN->detail.data_display_info.regs_column_count);
-      if (TUI_DATA_WIN->detail.data_display_info.regs_content_count %
-	  TUI_DATA_WIN->detail.data_display_info.regs_column_count)
+      num_lines = (TUI_DATA_WIN->regs_content_count
+		   / TUI_DATA_WIN->regs_column_count);
+      if (TUI_DATA_WIN->regs_content_count % TUI_DATA_WIN->regs_column_count)
 	num_lines++;
     }
   return num_lines;
@@ -90,15 +89,14 @@ tui_last_regs_line_no (void)
 int
 tui_line_from_reg_element_no (int element_no)
 {
-  if (element_no < TUI_DATA_WIN->detail.data_display_info.regs_content_count)
+  if (element_no < TUI_DATA_WIN->regs_content_count)
     {
       int i, line = (-1);
 
       i = 1;
       while (line == (-1))
 	{
-	  if (element_no <
-	      (TUI_DATA_WIN->detail.data_display_info.regs_column_count * i))
+	  if (element_no < TUI_DATA_WIN->regs_column_count * i)
 	    line = i - 1;
 	  else
 	    i++;
@@ -116,11 +114,10 @@ tui_line_from_reg_element_no (int element_no)
 int
 tui_first_reg_element_no_inline (int line_no)
 {
-  if ((line_no * TUI_DATA_WIN->detail.data_display_info.regs_column_count)
-      <= TUI_DATA_WIN->detail.data_display_info.regs_content_count)
-    return ((line_no + 1) *
-	    TUI_DATA_WIN->detail.data_display_info.regs_column_count) -
-      TUI_DATA_WIN->detail.data_display_info.regs_column_count;
+  if ((line_no * TUI_DATA_WIN->regs_column_count)
+      <= TUI_DATA_WIN->regs_content_count)
+    return (((line_no + 1) * TUI_DATA_WIN->regs_column_count) 
+	    - TUI_DATA_WIN->regs_column_count);
   else
     return (-1);
 }
@@ -132,7 +129,6 @@ void
 tui_show_registers (struct reggroup *group)
 {
   enum tui_status ret = TUI_FAILURE;
-  struct tui_data_info *display_info;
 
   /* Make sure the curses mode is enabled.  */
   tui_enable ();
@@ -142,22 +138,21 @@ tui_show_registers (struct reggroup *group)
   if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->generic.is_visible)
     tui_set_layout_by_name (DATA_NAME);
 
-  display_info = &TUI_DATA_WIN->detail.data_display_info;
   if (group == 0)
     group = general_reggroup;
 
   /* Say that registers should be displayed, even if there is a
      problem.  */
-  display_info->display_regs = TRUE;
+  TUI_DATA_WIN->display_regs = TRUE;
 
   if (target_has_registers && target_has_stack && target_has_memory)
     {
       ret = tui_show_register_group (group, get_selected_frame (NULL),
-                                     group == display_info->current_group);
+                                     group == TUI_DATA_WIN->current_group);
     }
   if (ret == TUI_FAILURE)
     {
-      display_info->current_group = 0;
+      TUI_DATA_WIN->current_group = 0;
       tui_erase_data_content (NO_REGS_STRING);
     }
   else
@@ -165,17 +160,17 @@ tui_show_registers (struct reggroup *group)
       int i;
 
       /* Clear all notation of changed values.  */
-      for (i = 0; i < display_info->regs_content_count; i++)
+      for (i = 0; i < TUI_DATA_WIN->regs_content_count; i++)
 	{
 	  struct tui_gen_win_info *data_item_win;
           struct tui_win_element *win;
 
-	  data_item_win = &display_info->regs_content[i]
+	  data_item_win = &TUI_DATA_WIN->regs_content[i]
             ->which_element.data_window;
           win = data_item_win->content[0];
           win->which_element.data.highlight = FALSE;
 	}
-      display_info->current_group = group;
+      TUI_DATA_WIN->current_group = group;
       tui_display_all_data ();
     }
 }
@@ -196,7 +191,6 @@ tui_show_register_group (struct reggroup *group,
   int allocated_here = FALSE;
   int regnum, pos;
   char title[80];
-  struct tui_data_info *display_info = &TUI_DATA_WIN->detail.data_display_info;
 
   /* Make a new title showing which group we display.  */
   snprintf (title, sizeof (title) - 1, "Register group: %s",
@@ -223,29 +217,29 @@ tui_show_register_group (struct reggroup *group,
       nr_regs++;
     }
 
-  if (display_info->regs_content_count > 0 && !refresh_values_only)
+  if (TUI_DATA_WIN->regs_content_count > 0 && !refresh_values_only)
     {
-      tui_free_data_content (display_info->regs_content,
-                             display_info->regs_content_count);
-      display_info->regs_content_count = 0;
+      tui_free_data_content (TUI_DATA_WIN->regs_content,
+                             TUI_DATA_WIN->regs_content_count);
+      TUI_DATA_WIN->regs_content_count = 0;
     }
 
-  if (display_info->regs_content_count <= 0)
+  if (TUI_DATA_WIN->regs_content_count <= 0)
     {
-      display_info->regs_content = tui_alloc_content (nr_regs, DATA_WIN);
+      TUI_DATA_WIN->regs_content = tui_alloc_content (nr_regs, DATA_WIN);
       allocated_here = TRUE;
       refresh_values_only = FALSE;
     }
 
-  if (display_info->regs_content != NULL)
+  if (TUI_DATA_WIN->regs_content != NULL)
     {
       if (!refresh_values_only || allocated_here)
 	{
 	  TUI_DATA_WIN->generic.content = NULL;
 	  TUI_DATA_WIN->generic.content_size = 0;
 	  tui_add_content_elements (&TUI_DATA_WIN->generic, nr_regs);
-	  display_info->regs_content = TUI_DATA_WIN->generic.content;
-	  display_info->regs_content_count = nr_regs;
+	  TUI_DATA_WIN->regs_content = TUI_DATA_WIN->generic.content;
+	  TUI_DATA_WIN->regs_content_count = nr_regs;
 	}
 
       /* Now set the register names and values.  */
@@ -267,7 +261,7 @@ tui_show_register_group (struct reggroup *group,
 	    continue;
 
 	  data_item_win =
-            &display_info->regs_content[pos]->which_element.data_window;
+            &TUI_DATA_WIN->regs_content[pos]->which_element.data_window;
           data = &data_item_win->content[0]->which_element.data;
           if (data)
             {
@@ -283,7 +277,7 @@ tui_show_register_group (struct reggroup *group,
 	}
 
       TUI_DATA_WIN->generic.content_size =
-	display_info->regs_content_count + display_info->data_content_count;
+	TUI_DATA_WIN->regs_content_count + TUI_DATA_WIN->data_content_count;
       ret = TUI_SUCCESS;
     }
 
@@ -297,16 +291,14 @@ tui_show_register_group (struct reggroup *group,
 void
 tui_display_registers_from (int start_element_no)
 {
-  struct tui_data_info *display_info = &TUI_DATA_WIN->detail.data_display_info;
-
-  if (display_info->regs_content != NULL
-      && display_info->regs_content_count > 0)
+  if (TUI_DATA_WIN->regs_content != NULL
+      && TUI_DATA_WIN->regs_content_count > 0)
     {
       int i = start_element_no;
       int j, item_win_width, cur_y;
 
       int max_len = 0;
-      for (i = 0; i < display_info->regs_content_count; i++)
+      for (i = 0; i < TUI_DATA_WIN->regs_content_count; i++)
         {
           struct tui_data_element *data;
           struct tui_gen_win_info *data_item_win;
@@ -314,7 +306,7 @@ tui_display_registers_from (int start_element_no)
           int len;
 
           data_item_win
-	    = &display_info->regs_content[i]->which_element.data_window;
+	    = &TUI_DATA_WIN->regs_content[i]->which_element.data_window;
           data = &data_item_win->content[0]->which_element.data;
           len = 0;
           p = data->content;
@@ -333,29 +325,29 @@ tui_display_registers_from (int start_element_no)
       item_win_width = max_len + 1;
       i = start_element_no;
 
-      display_info->regs_column_count =
+      TUI_DATA_WIN->regs_column_count =
         (TUI_DATA_WIN->generic.width - 2) / item_win_width;
-      if (display_info->regs_column_count == 0)
-        display_info->regs_column_count = 1;
+      if (TUI_DATA_WIN->regs_column_count == 0)
+        TUI_DATA_WIN->regs_column_count = 1;
       item_win_width =
-        (TUI_DATA_WIN->generic.width - 2) / display_info->regs_column_count;
+        (TUI_DATA_WIN->generic.width - 2) / TUI_DATA_WIN->regs_column_count;
 
       /* Now create each data "sub" window, and write the display into
 	 it.  */
       cur_y = 1;
-      while (i < display_info->regs_content_count 
+      while (i < TUI_DATA_WIN->regs_content_count 
 	     && cur_y <= TUI_DATA_WIN->generic.viewport_height)
 	{
 	  for (j = 0;
-	       j < display_info->regs_column_count
-		 && i < display_info->regs_content_count;
+	       j < TUI_DATA_WIN->regs_column_count
+		 && i < TUI_DATA_WIN->regs_content_count;
 	       j++)
 	    {
 	      struct tui_gen_win_info *data_item_win;
 	      struct tui_data_element *data_element_ptr;
 
 	      /* Create the window if necessary.  */
-	      data_item_win = &display_info->regs_content[i]
+	      data_item_win = &TUI_DATA_WIN->regs_content[i]
                 ->which_element.data_window;
 	      data_element_ptr = &data_item_win->content[0]->which_element.data;
               if (data_item_win->handle != NULL
@@ -398,8 +390,8 @@ static void
 tui_display_reg_element_at_line (int start_element_no,
 				 int start_line_no)
 {
-  if (TUI_DATA_WIN->detail.data_display_info.regs_content != NULL
-      && TUI_DATA_WIN->detail.data_display_info.regs_content_count > 0)
+  if (TUI_DATA_WIN->regs_content != NULL
+      && TUI_DATA_WIN->regs_content_count > 0)
     {
       int element_no = start_element_no;
 
@@ -417,7 +409,7 @@ tui_display_reg_element_at_line (int start_element_no,
 	     the element_no causes us to scroll past the end of the
 	     registers, adjust what element to really start the
 	     display at.  */
-	  if (TUI_DATA_WIN->detail.data_display_info.data_content_count <= 0
+	  if (TUI_DATA_WIN->data_content_count <= 0
 	      && start_line_no > first_line_on_last_page)
 	    element_no
 	      = tui_first_reg_element_no_inline (first_line_on_last_page);
@@ -435,7 +427,7 @@ int
 tui_display_registers_from_line (int line_no, 
 				 int force_display)
 {
-  if (TUI_DATA_WIN->detail.data_display_info.regs_content_count > 0)
+  if (TUI_DATA_WIN->regs_content_count > 0)
     {
       int line, element_no;
 
@@ -448,7 +440,7 @@ tui_display_registers_from_line (int line_no,
 	  if (line_no >= tui_last_regs_line_no ())
 	    {
 	      if ((line = tui_line_from_reg_element_no (
-		 TUI_DATA_WIN->detail.data_display_info.regs_content_count - 1)) < 0)
+		 TUI_DATA_WIN->regs_content_count - 1)) < 0)
 		line = 0;
 	    }
 	  else
@@ -459,7 +451,7 @@ tui_display_registers_from_line (int line_no,
 
       element_no = tui_first_reg_element_no_inline (line);
       if (element_no
-	  < TUI_DATA_WIN->detail.data_display_info.regs_content_count)
+	  < TUI_DATA_WIN->regs_content_count)
 	tui_display_reg_element_at_line (element_no, line);
       else
 	line = (-1);
@@ -480,23 +472,20 @@ tui_check_register_values (struct frame_info *frame)
   if (TUI_DATA_WIN != NULL
       && TUI_DATA_WIN->generic.is_visible)
     {
-      struct tui_data_info *display_info
-        = &TUI_DATA_WIN->detail.data_display_info;
-
-      if (display_info->regs_content_count <= 0 
-	  && display_info->display_regs)
-	tui_show_registers (display_info->current_group);
+      if (TUI_DATA_WIN->regs_content_count <= 0 
+	  && TUI_DATA_WIN->display_regs)
+	tui_show_registers (TUI_DATA_WIN->current_group);
       else
 	{
 	  int i;
 
-	  for (i = 0; (i < display_info->regs_content_count); i++)
+	  for (i = 0; (i < TUI_DATA_WIN->regs_content_count); i++)
 	    {
 	      struct tui_data_element *data;
 	      struct tui_gen_win_info *data_item_win_ptr;
 	      int was_hilighted;
 
-	      data_item_win_ptr = &display_info->regs_content[i]->
+	      data_item_win_ptr = &TUI_DATA_WIN->regs_content[i]->
                 which_element.data_window;
 	      data = &data_item_win_ptr->content[0]->which_element.data;
 	      was_hilighted = data->highlight;
@@ -560,7 +549,7 @@ tui_reg_next (struct gdbarch *gdbarch)
 
   if (TUI_DATA_WIN != NULL)
     {
-      group = TUI_DATA_WIN->detail.data_display_info.current_group;
+      group = TUI_DATA_WIN->current_group;
       group = reggroup_next (gdbarch, group);
       if (group == NULL)
         group = reggroup_next (gdbarch, NULL);
@@ -579,7 +568,7 @@ tui_reg_prev (struct gdbarch *gdbarch)
 
   if (TUI_DATA_WIN != NULL)
     {
-      group = TUI_DATA_WIN->detail.data_display_info.current_group;
+      group = TUI_DATA_WIN->current_group;
       group = reggroup_prev (gdbarch, group);
       if (group == NULL)
 	group = reggroup_prev (gdbarch, NULL);
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index 0c9661f1cbe..a0f20c309e1 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -121,8 +121,8 @@ tui_display_all_data (void)
       tui_display_registers_from (0);
 
       /* Then display the other data.  */
-      if (TUI_DATA_WIN->detail.data_display_info.data_content != NULL
-	  && TUI_DATA_WIN->detail.data_display_info.data_content_count > 0)
+      if (TUI_DATA_WIN->data_content != NULL
+	  && TUI_DATA_WIN->data_content_count > 0)
 	{
 	}
     }
@@ -143,7 +143,7 @@ tui_display_data_from_line (int line_no)
 
   /* There is no general data, force regs to display (if there are
      any).  */
-  if (TUI_DATA_WIN->detail.data_display_info.data_content_count <= 0)
+  if (TUI_DATA_WIN->data_content_count <= 0)
     tui_display_registers_from_line (_line_no, TRUE);
   else
     {
@@ -175,7 +175,7 @@ tui_display_data_from (int element_no, int reuse_windows)
 {
   int first_line = (-1);
 
-  if (element_no < TUI_DATA_WIN->detail.data_display_info.regs_content_count)
+  if (element_no < TUI_DATA_WIN->regs_content_count)
     first_line = tui_line_from_reg_element_no (element_no);
   else
     { /* Calculate the first_line from the element number.  */
@@ -218,16 +218,14 @@ tui_check_data_values (struct frame_info *frame)
     {
       int i;
 
-      for (i = 0; 
-	   TUI_DATA_WIN->detail.data_display_info.data_content_count; 
-	   i++)
+      for (i = 0; TUI_DATA_WIN->data_content_count; i++)
 	{
 #ifdef LATER
 	  tui_data_element_ptr data_element_ptr;
 	  struct tui_gen_win_info *data_item_win_ptr;
 	  Opaque new_value;
 
-	  data_item_ptr = &TUI_DATA_WIN->detail.data_display_info.
+	  data_item_ptr = &TUI_DATA_WIN->
 	    data_content[i]->which_element.data_window;
 	  data_element_ptr = &((tui_win_content)
 			       data_item_win_ptr->content)[0]->which_element.data;
@@ -252,8 +250,7 @@ tui_data_window::do_scroll_vertical
   int first_line = (-1);
 
   first_element_no = tui_first_data_item_displayed ();
-  if (first_element_no 
-      < detail.data_display_info.regs_content_count)
+  if (first_element_no < regs_content_count)
     first_line = tui_line_from_reg_element_no (first_element_no);
   else
     { /* Calculate the first line from the element number which is in
-- 
2.17.2

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

* [PATCH 09/66] Split the tui_win_info destructor
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (19 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 14/66] Introduce has_locator method Tom Tromey
@ 2019-06-23 22:44 ` Tom Tromey
  2019-06-23 22:44 ` [PATCH 11/66] Introduce methods for scrolling Tom Tromey
                   ` (29 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 22:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This patch adds destructors to tui_source_window and tui_data_window,
and splits ~tui_win_info as appropriate.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (struct tui_source_window)
	(struct tui_data_window): Declare destructors.
	* tui/tui-data.c (~tui_source_window, ~tui_data_window): New
	destructors.
	(tui_win_info): Simplify.
---
 gdb/ChangeLog      |  8 ++++++
 gdb/tui/tui-data.c | 70 ++++++++++++++++++++++------------------------
 gdb/tui/tui-data.h |  2 ++
 3 files changed, 43 insertions(+), 37 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index d98f916ac5b..8993bfe5d47 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -617,47 +617,43 @@ tui_add_content_elements (struct tui_gen_win_info *win_info,
   return index_start;
 }
 
-tui_win_info::~tui_win_info ()
+tui_source_window::~tui_source_window ()
 {
-  struct tui_gen_win_info *generic_win;
+  if (detail.source_info.fullname)
+    {
+      xfree (detail.source_info.fullname);
+      detail.source_info.fullname = NULL;
+    }
+  struct tui_gen_win_info *generic_win = detail.source_info.execution_info;
+  if (generic_win != NULL)
+    {
+      tui_delete_win (generic_win->handle);
+      generic_win->handle = NULL;
+      tui_free_win_content (generic_win);
+    }
+}  
 
-  switch (generic.type)
+tui_data_window::~tui_data_window ()
+{
+  if (generic.content != NULL)
     {
-    case SRC_WIN:
-    case DISASSEM_WIN:
-      if (detail.source_info.fullname)
-        {
-          xfree (detail.source_info.fullname);
-          detail.source_info.fullname = NULL;
-        }
-      generic_win = detail.source_info.execution_info;
-      if (generic_win != NULL)
-	{
-	  tui_delete_win (generic_win->handle);
-	  generic_win->handle = NULL;
-	  tui_free_win_content (generic_win);
-	}
-      break;
-    case DATA_WIN:
-      if (generic.content != NULL)
-	{
-	  tui_free_data_content (detail.data_display_info.regs_content,
-				 detail.data_display_info.regs_content_count);
-	  detail.data_display_info.regs_content = NULL;
-	  detail.data_display_info.regs_content_count = 0;
-	  tui_free_data_content (detail.data_display_info.data_content,
-				 detail.data_display_info.data_content_count);
-	  detail.data_display_info.data_content = NULL;
-	  detail.data_display_info.data_content_count = 0;
-	  detail.data_display_info.regs_column_count = 1;
-	  detail.data_display_info.display_regs = FALSE;
-	  generic.content = NULL;
-	  generic.content_size = 0;
-	}
-      break;
-    default:
-      break;
+      tui_free_data_content (detail.data_display_info.regs_content,
+			     detail.data_display_info.regs_content_count);
+      detail.data_display_info.regs_content = NULL;
+      detail.data_display_info.regs_content_count = 0;
+      tui_free_data_content (detail.data_display_info.data_content,
+			     detail.data_display_info.data_content_count);
+      detail.data_display_info.data_content = NULL;
+      detail.data_display_info.data_content_count = 0;
+      detail.data_display_info.regs_column_count = 1;
+      detail.data_display_info.display_regs = FALSE;
+      generic.content = NULL;
+      generic.content_size = 0;
     }
+}  
+
+tui_win_info::~tui_win_info ()
+{
   if (generic.handle != NULL)
     {
       tui_delete_win (generic.handle);
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index d07862f29f8..2a775a42be8 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -294,6 +294,7 @@ public:
 struct tui_source_window : public tui_win_info
 {
   tui_source_window (enum tui_win_type type);
+  ~tui_source_window () override;
   DISABLE_COPY_AND_ASSIGN (tui_source_window);
 
   void clear_detail () override;
@@ -302,6 +303,7 @@ struct tui_source_window : public tui_win_info
 struct tui_data_window : public tui_win_info
 {
   tui_data_window ();
+  ~tui_data_window () override;
   DISABLE_COPY_AND_ASSIGN (tui_data_window);
 
   void clear_detail () override;
-- 
2.17.2

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

* [PATCH 42/66] Introduce tui_gen_win_info::reset method
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (31 preceding siblings ...)
  2019-06-23 23:25 ` [PATCH 41/66] Move make_visible method to tui_gen_win_info Tom Tromey
@ 2019-06-23 23:25 ` Tom Tromey
  2019-06-23 23:25 ` [PATCH 34/66] Change tui_update_source_window for better type safety Tom Tromey
                   ` (17 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces the tui_gen_win_info::reset method and changes various
places to use it.  This led to the realization that the can_highlight
member only needs to be set during construction, so this patch makes
that change as well.  Finally, init_and_make_win is drastically
simplified.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (make_command_window): Don't set
	can_highlight.
	(show_source_disasm_command): Call the reset method.
	(show_data): Don't set can_highlight.  Call the reset method.
	(tui_gen_win_info::reset): Rename from init_gen_win_info
	(init_and_make_win): Simplify.  Return tui_gen_win_info.
	(show_source_or_disasm_and_command): Call the reset method.
	* tui/tui-data.h (struct tui_gen_win_info) <reset>: New method.
	(struct tui_cmd_window): Set can_highlight.
---
 gdb/ChangeLog        |  12 ++
 gdb/tui/tui-data.h   |  10 +-
 gdb/tui/tui-layout.c | 268 ++++++++++++++++++-------------------------
 3 files changed, 134 insertions(+), 156 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index d5e46fed5c0..be34afa70aa 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -60,6 +60,13 @@ struct tui_gen_win_info
     return "";
   }
 
+  /* Reset this window.  WIN_TYPE must match the existing type of this
+     window (it is only passed for self-test purposes).  The other
+     parameters are used to set the window's size and position.  */
+  void reset (enum tui_win_type win_type,
+	      int height, int width,
+	      int origin_x, int origin_y);
+
   /* Window handle.  */
   WINDOW *handle = nullptr;
   /* Type of window.  */
@@ -309,7 +316,7 @@ public:
   void right_scroll (int num_to_scroll);
 
   /* Can this window ever be highlighted?  */
-  bool can_highlight = false;
+  bool can_highlight = true;
 
   /* Is this window highlighted?  */
   bool is_highlighted = false;
@@ -453,6 +460,7 @@ struct tui_cmd_window : public tui_win_info
   tui_cmd_window ()
     : tui_win_info (CMD_WIN)
   {
+    can_highlight = false;
   }
 
   DISABLE_COPY_AND_ASSIGN (tui_cmd_window);
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index d9e1617f19a..f586d703d43 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -43,11 +43,9 @@
 ** Static Local Decls
 ********************************/
 static void show_layout (enum tui_layout_type);
-static void init_gen_win_info (struct tui_gen_win_info *, 
-			       enum tui_win_type, 
-			       int, int, int, int);
-static void *init_and_make_win (void *, enum tui_win_type, 
-				int, int, int, int, int);
+static tui_gen_win_info *init_and_make_win (tui_gen_win_info *,
+					    enum tui_win_type,
+					    int, int, int, int, int);
 static void show_source_or_disasm_and_command (enum tui_layout_type);
 static struct tui_win_info *make_source_or_disasm_window (enum tui_win_type, 
 							  int, int);
@@ -546,7 +544,6 @@ make_command_window (int height, int origin_y)
 						 0,
 						 origin_y,
 						 DONT_BOX_WINDOW);
-  result->can_highlight = false;
   return result;
 }
 
@@ -621,19 +618,16 @@ show_source_disasm_command (void)
 	tui_win_list[SRC_WIN] = make_source_window (src_height, 0);
       else
 	{
-	  init_gen_win_info (TUI_SRC_WIN,
-			     TUI_SRC_WIN->type,
-			     src_height,
-			     TUI_SRC_WIN->width,
-			     TUI_SRC_WIN->execution_info->width,
-			     0);
-	  TUI_SRC_WIN->can_highlight = true;
-	  init_gen_win_info (TUI_SRC_WIN->execution_info,
-			     EXEC_INFO_WIN,
-			     src_height,
-			     3,
-			     0,
-			     0);
+	  TUI_SRC_WIN->reset (TUI_SRC_WIN->type,
+			      src_height,
+			      TUI_SRC_WIN->width,
+			      TUI_SRC_WIN->execution_info->width,
+			      0);
+	  TUI_SRC_WIN->execution_info->reset (EXEC_INFO_WIN,
+					      src_height,
+					      3,
+					      0,
+					      0);
 	  tui_make_visible (TUI_SRC_WIN);
 	  tui_make_visible (TUI_SRC_WIN->execution_info);
 	  TUI_SRC_WIN->m_has_locator = false;
@@ -647,37 +641,32 @@ show_source_disasm_command (void)
 	  tui_win_list[DISASSEM_WIN]
 	    = make_disasm_window (asm_height, src_height - 1);
 	  locator
-	    = ((struct tui_gen_win_info *)
-	       init_and_make_win (locator,
-				  LOCATOR_WIN,
-				  2 /* 1 */ ,
-				  tui_term_width (),
-				  0,
-				  (src_height + asm_height) - 1,
-				  DONT_BOX_WINDOW));
+	    = init_and_make_win (locator,
+				 LOCATOR_WIN,
+				 2 /* 1 */ ,
+				 tui_term_width (),
+				 0,
+				 (src_height + asm_height) - 1,
+				 DONT_BOX_WINDOW);
 	}
       else
 	{
-	  init_gen_win_info (locator,
-			     LOCATOR_WIN,
-			     2 /* 1 */ ,
-			     tui_term_width (),
-			     0,
-			     (src_height + asm_height) - 1);
+	  locator->reset (LOCATOR_WIN,
+			  2 /* 1 */ ,
+			  tui_term_width (),
+			  0,
+			  (src_height + asm_height) - 1);
 	  TUI_DISASM_WIN->m_has_locator = true;
-	  init_gen_win_info (TUI_DISASM_WIN,
-			     TUI_DISASM_WIN->type,
-			     asm_height,
-			     TUI_DISASM_WIN->width,
-			     TUI_DISASM_WIN->execution_info->width,
-			     src_height - 1);
-	  init_gen_win_info (TUI_DISASM_WIN->execution_info,
-			     EXEC_INFO_WIN,
-			     asm_height,
-			     3,
-			     0,
-			     src_height - 1);
-	  TUI_DISASM_WIN->can_highlight = true;
+	  TUI_DISASM_WIN->reset (TUI_DISASM_WIN->type,
+				 asm_height,
+				 TUI_DISASM_WIN->width,
+				 TUI_DISASM_WIN->execution_info->width,
+				 src_height - 1);
+	  TUI_DISASM_WIN->execution_info->reset (EXEC_INFO_WIN,
+						 asm_height,
+						 3,
+						 0,
+						 src_height - 1);
 	  tui_make_visible (TUI_DISASM_WIN);
 	  tui_make_visible (TUI_DISASM_WIN->execution_info);
 	}
@@ -692,13 +681,11 @@ show_source_disasm_command (void)
 	  = make_command_window (cmd_height, tui_term_height () - cmd_height);
       else
 	{
-	  init_gen_win_info (TUI_CMD_WIN,
-			     TUI_CMD_WIN->type,
-			     TUI_CMD_WIN->height,
-			     TUI_CMD_WIN->width,
-			     0,
-			     TUI_CMD_WIN->origin.y);
-	  TUI_CMD_WIN->can_highlight = false;
+	  TUI_CMD_WIN->reset (TUI_CMD_WIN->type,
+			      TUI_CMD_WIN->height,
+			      TUI_CMD_WIN->width,
+			      0,
+			      TUI_CMD_WIN->origin.y);
 	  tui_make_visible (TUI_CMD_WIN);
 	}
       TUI_CMD_WIN->refresh_window ();
@@ -723,7 +710,6 @@ show_data (enum tui_layout_type new_layout)
   tui_make_all_invisible ();
   tui_make_invisible (locator);
   make_data_window (&tui_win_list[DATA_WIN], data_height, 0);
-  TUI_DATA_WIN->can_highlight = true;
   if (new_layout == SRC_DATA_COMMAND)
     win_type = SRC_WIN;
   else
@@ -739,39 +725,35 @@ show_data (enum tui_layout_type new_layout)
 	tui_win_list[win_type]
 	  = make_disasm_window (src_height, data_height - 1);
       locator
-	= ((struct tui_gen_win_info *)
-	   init_and_make_win (locator,
-			      LOCATOR_WIN,
-			      2 /* 1 */ ,
-			      tui_term_width (),
-			      0,
-			      total_height - 1,
-			      DONT_BOX_WINDOW));
+	= init_and_make_win (locator,
+			     LOCATOR_WIN,
+			     2 /* 1 */ ,
+			     tui_term_width (),
+			     0,
+			     total_height - 1,
+			     DONT_BOX_WINDOW);
       base = (tui_source_window_base *) tui_win_list[win_type];
     }
   else
     {
       base = (tui_source_window_base *) tui_win_list[win_type];
-      init_gen_win_info (tui_win_list[win_type],
-			 tui_win_list[win_type]->type,
-			 src_height,
-			 tui_win_list[win_type]->width,
-			 base->execution_info->width,
-			 data_height - 1);
-      init_gen_win_info (base->execution_info,
-			 EXEC_INFO_WIN,
-			 src_height,
-			 3,
-			 0,
-			 data_height - 1);
+      tui_win_list[win_type]->reset (tui_win_list[win_type]->type,
+				     src_height,
+				     tui_win_list[win_type]->width,
+				     base->execution_info->width,
+				     data_height - 1);
+      base->execution_info->reset (EXEC_INFO_WIN,
+				   src_height,
+				   3,
+				   0,
+				   data_height - 1);
       tui_make_visible (tui_win_list[win_type]);
       tui_make_visible (base->execution_info);
-      init_gen_win_info (locator,
-			 LOCATOR_WIN,
-			 2 /* 1 */ ,
-			 tui_term_width (),
-			 0,
-			 total_height - 1);
+      locator->reset (LOCATOR_WIN,
+		      2 /* 1 */ ,
+		      tui_term_width (),
+		      0,
+		      total_height - 1);
     }
   base->m_has_locator = true;
   tui_make_visible (locator);
@@ -781,67 +763,50 @@ show_data (enum tui_layout_type new_layout)
   tui_set_current_layout_to (new_layout);
 }
 
-/* init_gen_win_info().
- */
-static void
-init_gen_win_info (struct tui_gen_win_info *win_info, 
-		   enum tui_win_type type,
-		   int height, int width, 
-		   int origin_x, int origin_y)
+void
+tui_gen_win_info::reset (enum tui_win_type win_type,
+			 int height_, int width_,
+			 int origin_x_, int origin_y_)
 {
-  int h = height;
+  int h = height_;
+
+  gdb_assert (type == win_type);
 
-  win_info->type = type;
-  win_info->width = width;
-  win_info->height = h;
+  width = width_;
+  height = h;
   if (h > 1)
     {
-      win_info->viewport_height = h - 1;
-      if (win_info->type != CMD_WIN)
-	win_info->viewport_height--;
+      viewport_height = h - 1;
+      if (type != CMD_WIN)
+	viewport_height--;
     }
   else
-    win_info->viewport_height = 1;
-  win_info->origin.x = origin_x;
-  win_info->origin.y = origin_y;
-
-  return;
-}				/* init_gen_win_info */
+    viewport_height = 1;
+  origin.x = origin_x_;
+  origin.y = origin_y_;
+}
 
 /* init_and_make_win().
  */
-static void *
-init_and_make_win (void *opaque_win_info, 
+static tui_gen_win_info *
+init_and_make_win (tui_gen_win_info *win_info, 
 		   enum tui_win_type win_type,
 		   int height, int width, 
 		   int origin_x, int origin_y,
 		   int box_it)
 {
-  struct tui_gen_win_info *generic;
-
-  if (opaque_win_info == NULL)
+  if (win_info == NULL)
     {
       if (tui_win_is_auxillary (win_type))
-	opaque_win_info = (void *) new tui_gen_win_info (win_type);
+	win_info = new tui_gen_win_info (win_type);
       else
-	opaque_win_info = (void *) tui_alloc_win_info (win_type);
+	win_info = tui_alloc_win_info (win_type);
     }
-  if (tui_win_is_auxillary (win_type))
-    generic = (struct tui_gen_win_info *) opaque_win_info;
-  else
-    generic = (struct tui_win_info *) opaque_win_info;
 
-  init_gen_win_info (generic, win_type, height, width, origin_x, origin_y);
-  if (!tui_win_is_auxillary (win_type))
-    {
-      if (generic->type == CMD_WIN)
-	((struct tui_win_info *) opaque_win_info)->can_highlight = false;
-      else
-	((struct tui_win_info *) opaque_win_info)->can_highlight = true;
-    }
-  tui_make_window (generic, box_it);
+  win_info->reset (win_type, height, width, origin_x, origin_y);
+  tui_make_window (win_info, box_it);
 
-  return opaque_win_info;
+  return win_info;
 }
 
 
@@ -910,39 +875,34 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 	  else
 	    *win_info_ptr = make_disasm_window (src_height - 1, 0);
 	  locator
-	    = ((struct tui_gen_win_info *)
-	       init_and_make_win (locator,
-				  LOCATOR_WIN,
-				  2 /* 1 */ ,
-				  tui_term_width (),
-				  0,
-				  src_height - 1,
-				  DONT_BOX_WINDOW));
+	    = init_and_make_win (locator,
+				 LOCATOR_WIN,
+				 2 /* 1 */ ,
+				 tui_term_width (),
+				 0,
+				 src_height - 1,
+				 DONT_BOX_WINDOW);
 	  base = (tui_source_window_base *) *win_info_ptr;
 	}
       else
 	{
 	  base = (tui_source_window_base *) *win_info_ptr;
-	  init_gen_win_info (locator,
-			     LOCATOR_WIN,
-			     2 /* 1 */ ,
-			     tui_term_width (),
-			     0,
-			     src_height - 1);
+	  locator->reset (LOCATOR_WIN,
+			  2 /* 1 */ ,
+			  tui_term_width (),
+			  0,
+			  src_height - 1);
 	  base->m_has_locator = true;
-	  init_gen_win_info (*win_info_ptr,
-			     (*win_info_ptr)->type,
-			     src_height - 1,
-			     (*win_info_ptr)->width,
-			     base->execution_info->width,
-			     0);
-	  init_gen_win_info (base->execution_info,
-			     EXEC_INFO_WIN,
-			     src_height - 1,
-			     3,
-			     0,
-			     0);
-	  base->can_highlight = true;
+	  (*win_info_ptr)->reset ((*win_info_ptr)->type,
+				  src_height - 1,
+				  (*win_info_ptr)->width,
+				  base->execution_info->width,
+				  0);
+	  base->execution_info->reset (EXEC_INFO_WIN,
+				       src_height - 1,
+				       3,
+				       0,
+				       0);
 	  tui_make_visible (*win_info_ptr);
 	  tui_make_visible (base->execution_info);
 	}
@@ -960,13 +920,11 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 	}
       else
 	{
-	  init_gen_win_info (TUI_CMD_WIN,
-			     TUI_CMD_WIN->type,
-			     TUI_CMD_WIN->height,
-			     TUI_CMD_WIN->width,
-			     TUI_CMD_WIN->origin.x,
-			     TUI_CMD_WIN->origin.y);
-	  TUI_CMD_WIN->can_highlight = false;
+	  TUI_CMD_WIN->reset (TUI_CMD_WIN->type,
+			      TUI_CMD_WIN->height,
+			      TUI_CMD_WIN->width,
+			      TUI_CMD_WIN->origin.x,
+			      TUI_CMD_WIN->origin.y);
 	  tui_make_visible (TUI_CMD_WIN);
 	}
       tui_set_current_layout_to (layout_type);
-- 
2.17.2

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

* [PATCH 35/66] Introduce tui_gen_win_info::name method
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (33 preceding siblings ...)
  2019-06-23 23:25 ` [PATCH 34/66] Change tui_update_source_window for better type safety Tom Tromey
@ 2019-06-23 23:25 ` Tom Tromey
  2019-06-23 23:26 ` [PATCH 37/66] Remove NULL check from tui_set_exec_info_content Tom Tromey
                   ` (15 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This removes tui_win_name and replaces it with a method on
tui_gen_win_info, removing another spot that switched on window type.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (window_name_completer, tui_set_focus)
	(tui_all_windows_info): Use name method.
	* tui/tui-data.h (struct tui_gen_win_info)
	(struct tui_source_window, struct tui_disasm_window)
	(struct tui_data_window, struct tui_cmd_window) <name>: New
	method.
	(tui_win_name): Don't declare.
	* tui/tui-data.c (tui_partial_win_by_name): Use name method.
	(tui_win_name): Remove.
---
 gdb/ChangeLog      | 12 ++++++++++++
 gdb/tui/tui-data.c | 31 +------------------------------
 gdb/tui/tui-data.h | 27 ++++++++++++++++++++++++++-
 gdb/tui/tui-win.c  |  8 ++++----
 4 files changed, 43 insertions(+), 35 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 63afec57141..5bb79156e70 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -337,7 +337,7 @@ tui_partial_win_by_name (const char *name)
 	{
           if (tui_win_list[i] != 0)
             {
-              const char *cur_name = tui_win_name (tui_win_list[i]);
+              const char *cur_name = tui_win_list[i]->name ();
 
               if (strlen (name) <= strlen (cur_name)
 		  && startswith (cur_name, name))
@@ -351,35 +351,6 @@ tui_partial_win_by_name (const char *name)
 }
 
 
-/* Answer the name of the window.  */
-const char *
-tui_win_name (const struct tui_gen_win_info *win_info)
-{
-  const char *name = NULL;
-
-  switch (win_info->type)
-    {
-    case SRC_WIN:
-      name = SRC_NAME;
-      break;
-    case CMD_WIN:
-      name = CMD_NAME;
-      break;
-    case DISASSEM_WIN:
-      name = DISASSEM_NAME;
-      break;
-    case DATA_WIN:
-      name = DATA_NAME;
-      break;
-    default:
-      name = "";
-      break;
-    }
-
-  return name;
-}
-
-
 void
 tui_initialize_static_data (void)
 {
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 78c17102218..01c0f167cde 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -51,6 +51,12 @@ struct tui_gen_win_info
   /* Call to refresh this window.  */
   virtual void refresh_window ();
 
+  /* Return the name of this type of window.  */
+  virtual const char *name () const
+  {
+    return "";
+  }
+
   /* Window handle.  */
   WINDOW *handle = nullptr;
   /* Type of window.  */
@@ -383,6 +389,11 @@ struct tui_source_window : public tui_source_window_base
 
   DISABLE_COPY_AND_ASSIGN (tui_source_window);
 
+  const char *name () const override
+  {
+    return SRC_NAME;
+  }
+
 protected:
 
   void do_scroll_vertical (enum tui_scroll_direction,
@@ -400,6 +411,11 @@ struct tui_disasm_window : public tui_source_window_base
 
   DISABLE_COPY_AND_ASSIGN (tui_disasm_window);
 
+  const char *name () const override
+  {
+    return DISASSEM_NAME;
+  }
+
 protected:
 
   void do_scroll_vertical (enum tui_scroll_direction,
@@ -423,6 +439,11 @@ struct tui_data_window : public tui_win_info
 
   void refresh_window () override;
 
+  const char *name () const override
+  {
+    return DATA_NAME;
+  }
+
   /* Start of data display content.  */
   tui_win_content data_content = NULL;
   int data_content_count = 0;
@@ -465,6 +486,11 @@ struct tui_cmd_window : public tui_win_info
   {
   }
 
+  const char *name () const override
+  {
+    return CMD_NAME;
+  }
+
   int start_line = 0;
 
 protected:
@@ -502,7 +528,6 @@ extern void tui_free_win_content (struct tui_gen_win_info *);
 extern void tui_free_data_content (tui_win_content, int);
 extern void tui_free_all_source_wins_content (void);
 extern struct tui_win_info *tui_partial_win_by_name (const char *);
-extern const char *tui_win_name (const struct tui_gen_win_info *);
 extern enum tui_layout_type tui_current_layout (void);
 extern void tui_set_current_layout_to (enum tui_layout_type);
 extern int tui_term_height (void);
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index c8fd267f362..33dcb3b2f6c 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -376,7 +376,7 @@ window_name_completer (completion_tracker &tracker,
 	  || !tui_win_list[win_type]->is_visible)
 	continue;
 
-      completion_name = tui_win_name (tui_win_list [win_type]);
+      completion_name = tui_win_list[win_type]->name ();
       gdb_assert (completion_name != NULL);
       completion_name_vec.push_back (completion_name);
     }
@@ -869,7 +869,7 @@ The window name specified must be valid and visible.\n"));
 	TUI_DATA_WIN->refresh_all ();
       xfree (buf_ptr);
       printf_filtered (_("Focus set to %s window.\n"),
-		       tui_win_name (tui_win_with_focus ()));
+		       tui_win_with_focus ()->name ());
     }
   else
     warning (_("Incorrect Number of Arguments.\n%s"), FOCUS_USAGE);
@@ -896,11 +896,11 @@ tui_all_windows_info (const char *arg, int from_tty)
       {
 	if (win_with_focus == tui_win_list[type])
 	  printf_filtered ("        %s\t(%d lines)  <has focus>\n",
-			   tui_win_name (tui_win_list[type]),
+			   tui_win_list[type]->name (),
 			   tui_win_list[type]->height);
 	else
 	  printf_filtered ("        %s\t(%d lines)\n",
-			   tui_win_name (tui_win_list[type]),
+			   tui_win_list[type]->name (),
 			   tui_win_list[type]->height);
       }
 }
-- 
2.17.2

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

* [PATCH 40/66] Remove tui_scroll_direction enum
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (29 preceding siblings ...)
  2019-06-23 23:25 ` [PATCH 45/66] Introduce tui_win_info::update_tab_width Tom Tromey
@ 2019-06-23 23:25 ` Tom Tromey
  2019-06-24 14:13   ` Pedro Alves
  2019-06-23 23:25 ` [PATCH 41/66] Move make_visible method to tui_gen_win_info Tom Tromey
                   ` (19 subsequent siblings)
  50 siblings, 1 reply; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The tui_scroll_direction enum is not really needed, because it's
simple to adapt the various scrolling methods to use the sign of their
argument as the direction in which to scroll.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c
	(tui_source_window_base::do_scroll_horizontal): Remove direction
	parameter.
	* tui/tui-windata.c (tui_data_window::do_scroll_vertical): Remove
	direction parameter.
	* tui/tui-win.c (tui_win_info::forward_scroll)
	(tui_win_info::backward_scroll, tui_win_info::left_scroll)
	(tui_win_info::right_scroll): Update.
	* tui/tui-source.c (tui_source_window::do_scroll_vertical): Remove
	direction parameter.
	* tui/tui-disasm.c (tui_disasm_window::do_scroll_vertical): Remove
	direction parameter.
	* tui/tui-data.h (enum tui_scroll_direction): Remove.
	(struct tui_win_info) <do_scroll_vertical, do_scroll_horizontal>:
	Remove direction parameter.
	(struct tui_source_window_base, struct tui_source_window)
	(struct tui_disasm_window, struct tui_data_window)
	(struct tui_cmd_window): Update.
---
 gdb/ChangeLog           | 21 +++++++++++++++++++++
 gdb/tui/tui-data.h      | 37 +++++++++----------------------------
 gdb/tui/tui-disasm.c    | 13 ++++++-------
 gdb/tui/tui-source.c    | 29 ++++++++++-------------------
 gdb/tui/tui-win.c       |  8 ++++----
 gdb/tui/tui-windata.c   |  8 ++------
 gdb/tui/tui-winsource.c | 16 ++++------------
 7 files changed, 56 insertions(+), 76 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 01c0f167cde..92bfb39fe86 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -122,16 +122,6 @@ struct tui_gen_win_info
 #define MAX_TARGET_WIDTH  10
 #define MAX_PID_WIDTH     19
 
-/* Scroll direction enum.  */
-enum tui_scroll_direction
-{
-  FORWARD_SCROLL,
-  BACKWARD_SCROLL,
-  LEFT_SCROLL,
-  RIGHT_SCROLL
-};
-
-
 /* The kinds of layouts available.  */
 enum tui_layout_type
 {
@@ -264,13 +254,11 @@ protected:
 
   /* Scroll the contents vertically.  This is only called via
      forward_scroll and backward_scroll.  */
-  virtual void do_scroll_vertical (enum tui_scroll_direction,
-				   int num_to_scroll) = 0;
+  virtual void do_scroll_vertical (int num_to_scroll) = 0;
 
   /* Scroll the contents horizontally.  This is only called via
      left_scroll and right_scroll.  */
-  virtual void do_scroll_horizontal (enum tui_scroll_direction,
-				     int num_to_scroll) = 0;
+  virtual void do_scroll_horizontal (int num_to_scroll) = 0;
 
 public:
 
@@ -337,8 +325,7 @@ protected:
   ~tui_source_window_base () override;
   DISABLE_COPY_AND_ASSIGN (tui_source_window_base);
 
-  void do_scroll_horizontal (enum tui_scroll_direction,
-			     int num_to_scroll) override;
+  void do_scroll_horizontal (int num_to_scroll) override;
 
 public:
 
@@ -396,8 +383,7 @@ struct tui_source_window : public tui_source_window_base
 
 protected:
 
-  void do_scroll_vertical (enum tui_scroll_direction,
-			   int num_to_scroll) override;
+  void do_scroll_vertical (int num_to_scroll) override;
 };
 
 /* A TUI disassembly window.  */
@@ -418,8 +404,7 @@ struct tui_disasm_window : public tui_source_window_base
 
 protected:
 
-  void do_scroll_vertical (enum tui_scroll_direction,
-			   int num_to_scroll) override;
+  void do_scroll_vertical (int num_to_scroll) override;
 };
 
 struct tui_data_window : public tui_win_info
@@ -457,10 +442,8 @@ struct tui_data_window : public tui_win_info
 
 protected:
 
-  void do_scroll_vertical (enum tui_scroll_direction,
-			   int num_to_scroll) override;
-  void do_scroll_horizontal (enum tui_scroll_direction,
-			     int num_to_scroll) override
+  void do_scroll_vertical (int num_to_scroll) override;
+  void do_scroll_horizontal (int num_to_scroll) override
   {
   }
 };
@@ -495,13 +478,11 @@ struct tui_cmd_window : public tui_win_info
 
 protected:
 
-  void do_scroll_vertical (enum tui_scroll_direction,
-			   int num_to_scroll) override
+  void do_scroll_vertical (int num_to_scroll) override
   {
   }
 
-  void do_scroll_horizontal (enum tui_scroll_direction,
-			     int num_to_scroll) override
+  void do_scroll_horizontal (int num_to_scroll) override
   {
   }
 };
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 0bc7c642bcd..b3d39ea8031 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -371,22 +371,21 @@ tui_get_low_disassembly_address (struct gdbarch *gdbarch,
 
 /* Scroll the disassembly forward or backward vertically.  */
 void
-tui_disasm_window::do_scroll_vertical
-  (enum tui_scroll_direction scroll_direction, int num_to_scroll)
+tui_disasm_window::do_scroll_vertical (int num_to_scroll)
 {
   if (content != NULL)
     {
       CORE_ADDR pc;
       struct tui_line_or_address val;
-      int dir;
 
       pc = content[0]->which_element.source.line_or_addr.u.addr;
-      num_to_scroll++;
-      dir = (scroll_direction == FORWARD_SCROLL)
-	? num_to_scroll : -num_to_scroll;
+      if (num_to_scroll >= 0)
+	num_to_scroll++;
+      else
+	--num_to_scroll;
 
       val.loa = LOA_ADDRESS;
-      val.u.addr = tui_find_disassembly_address (gdbarch, pc, dir);
+      val.u.addr = tui_find_disassembly_address (gdbarch, pc, num_to_scroll);
       tui_update_source_window_as_is (this, gdbarch,
 				      NULL, val, FALSE);
     }
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 39abe81a870..54e53cf8dbd 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -308,8 +308,7 @@ tui_source_is_displayed (const char *fullname)
 
 /* Scroll the source forward or backward vertically.  */
 void
-tui_source_window::do_scroll_vertical
-  (enum tui_scroll_direction scroll_direction, int num_to_scroll)
+tui_source_window::do_scroll_vertical (int num_to_scroll)
 {
   if (content != NULL)
     {
@@ -323,23 +322,15 @@ tui_source_window::do_scroll_vertical
 	s = cursal.symtab;
 
       l.loa = LOA_LINE;
-      if (scroll_direction == FORWARD_SCROLL)
-	{
-	  l.u.line_no = content[0]->which_element.source.line_or_addr.u.line_no
-	    + num_to_scroll;
-	  if (l.u.line_no > s->nlines)
-	    /* line = s->nlines - win_info->content_size + 1; */
-	    /* elz: fix for dts 23398.  */
-	    l.u.line_no
-	      = content[0]->which_element.source.line_or_addr.u.line_no;
-	}
-      else
-	{
-	  l.u.line_no = content[0]->which_element.source.line_or_addr.u.line_no
-	    - num_to_scroll;
-	  if (l.u.line_no <= 0)
-	    l.u.line_no = 1;
-	}
+      l.u.line_no = content[0]->which_element.source.line_or_addr.u.line_no
+	+ num_to_scroll;
+      if (l.u.line_no > s->nlines)
+	/* line = s->nlines - win_info->content_size + 1; */
+	/* elz: fix for dts 23398.  */
+	l.u.line_no
+	  = content[0]->which_element.source.line_or_addr.u.line_no;
+      if (l.u.line_no <= 0)
+	l.u.line_no = 1;
 
       print_source_lines (s, l.u.line_no, l.u.line_no + 1, 0);
     }
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 33dcb3b2f6c..b92eb505b31 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -475,7 +475,7 @@ tui_win_info::forward_scroll (int num_to_scroll)
   if (num_to_scroll == 0)
     num_to_scroll = height - 3;
 
-  do_scroll_vertical (FORWARD_SCROLL, num_to_scroll);
+  do_scroll_vertical (num_to_scroll);
 }
 
 void
@@ -484,7 +484,7 @@ tui_win_info::backward_scroll (int num_to_scroll)
   if (num_to_scroll == 0)
     num_to_scroll = height - 3;
 
-  do_scroll_vertical (BACKWARD_SCROLL, num_to_scroll);
+  do_scroll_vertical (- num_to_scroll);
 }
 
 
@@ -494,7 +494,7 @@ tui_win_info::left_scroll (int num_to_scroll)
   if (num_to_scroll == 0)
     num_to_scroll = 1;
 
-  do_scroll_horizontal (LEFT_SCROLL, num_to_scroll);
+  do_scroll_horizontal (num_to_scroll);
 }
 
 
@@ -504,7 +504,7 @@ tui_win_info::right_scroll (int num_to_scroll)
   if (num_to_scroll == 0)
     num_to_scroll = 1;
 
-  do_scroll_horizontal (RIGHT_SCROLL, num_to_scroll);
+  do_scroll_horizontal (- num_to_scroll);
 }
 
 
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index 739272a5d03..c5593454580 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -243,8 +243,7 @@ tui_check_data_values (struct frame_info *frame)
 
 /* Scroll the data window vertically forward or backward.  */
 void
-tui_data_window::do_scroll_vertical
-  (enum tui_scroll_direction scroll_direction, int num_to_scroll)
+tui_data_window::do_scroll_vertical (int num_to_scroll)
 {
   int first_element_no;
   int first_line = (-1);
@@ -259,10 +258,7 @@ tui_data_window::do_scroll_vertical
 
   if (first_line >= 0)
     {
-      if (scroll_direction == FORWARD_SCROLL)
-	first_line += num_to_scroll;
-      else
-	first_line -= num_to_scroll;
+      first_line += num_to_scroll;
       tui_erase_data_content (NULL);
       tui_delete_data_content_windows ();
       tui_display_data_from_line (first_line);
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index e55ce40a206..e56fbcb76d6 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -332,21 +332,13 @@ tui_source_window_base::refill ()
 /* Scroll the source forward or backward horizontally.  */
 
 void
-tui_source_window_base::do_scroll_horizontal
-  (enum tui_scroll_direction direction, int num_to_scroll)
+tui_source_window_base::do_scroll_horizontal (int num_to_scroll)
 {
   if (content != NULL)
     {
-      int offset;
-
-      if (direction == LEFT_SCROLL)
-	offset = horizontal_offset + num_to_scroll;
-      else
-	{
-	  offset = horizontal_offset - num_to_scroll;
-	  if (offset < 0)
-	    offset = 0;
-	}
+      int offset = horizontal_offset + num_to_scroll;
+      if (offset < 0)
+	offset = 0;
       horizontal_offset = offset;
       refill ();
     }
-- 
2.17.2

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

* [PATCH 45/66] Introduce tui_win_info::update_tab_width
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (28 preceding siblings ...)
  2019-06-23 22:44 ` [PATCH 18/66] Change tui_data_window::display_regs to bool Tom Tromey
@ 2019-06-23 23:25 ` Tom Tromey
  2019-06-23 23:25 ` [PATCH 40/66] Remove tui_scroll_direction enum Tom Tromey
                   ` (20 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces a new tui_win_info::update_tab_width method, and
changes the TUI to call it.  This fixes another spot that was checking
the window type.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (tui_source_window_base::update_tab_width): New
	method.
	(update_tab_width): Call update_tab_width method.
	* tui/tui-data.h (struct tui_win_info)
	(struct tui_source_window_base) <update_tab_width>: New methods.
---
 gdb/ChangeLog      |  8 ++++++++
 gdb/tui/tui-data.h |  7 +++++++
 gdb/tui/tui-win.c  | 33 +++++++++++++++++----------------
 3 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index caf3bb4f408..298ee452d50 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -306,6 +306,11 @@ public:
   /* Compute the maximum height of this window.  */
   virtual int max_height () const;
 
+  /* Called after the tab width has been changed.  */
+  virtual void update_tab_width ()
+  {
+  }
+
   /* Set whether this window is highglighted.  */
   void set_highlight (bool highlight)
   {
@@ -362,6 +367,8 @@ public:
 
   void set_new_height (int height) override;
 
+  void update_tab_width () override;
+
   /* Does locator belongs to this window?  */
   bool m_has_locator = false;
   /* Execution information window.  */
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index b92eb505b31..8a4e64f3c88 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -923,29 +923,30 @@ unsigned int tui_tab_width = DEFAULT_TAB_LEN;
 
 static unsigned int internal_tab_width = DEFAULT_TAB_LEN;
 
-/* After the tab width is set, call this to update the relevant
-   windows.  */
+/* See tui-data.h.  */
 
-static void
-update_tab_width ()
+void
+tui_source_window_base::update_tab_width ()
 {
   /* We don't really change the height of any windows, but
      calling these 2 functions causes a complete regeneration
      and redisplay of the window's contents, which will take
      the new tab width into account.  */
-  if (tui_win_list[SRC_WIN]
-      && tui_win_list[SRC_WIN]->is_visible)
-    {
-      make_invisible_and_set_new_height (TUI_SRC_WIN,
-					 TUI_SRC_WIN->height);
-      make_visible_with_new_height (TUI_SRC_WIN);
-    }
-  if (tui_win_list[DISASSEM_WIN]
-      && tui_win_list[DISASSEM_WIN]->is_visible)
+  make_invisible_and_set_new_height (this, height);
+  make_visible_with_new_height (this);
+}
+
+/* After the tab width is set, call this to update the relevant
+   windows.  */
+
+static void
+update_tab_width ()
+{
+  for (int win_type = SRC_WIN; win_type < MAX_MAJOR_WINDOWS; win_type++)
     {
-      make_invisible_and_set_new_height (TUI_DISASM_WIN,
-					 TUI_DISASM_WIN->height);
-      make_visible_with_new_height (TUI_DISASM_WIN);
+      if (tui_win_list[win_type] != NULL
+	  && tui_win_list[win_type]->is_visible)
+	tui_win_list[win_type]->update_tab_width ();
     }
 }
 
-- 
2.17.2

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

* [PATCH 41/66] Move make_visible method to tui_gen_win_info
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (30 preceding siblings ...)
  2019-06-23 23:25 ` [PATCH 40/66] Remove tui_scroll_direction enum Tom Tromey
@ 2019-06-23 23:25 ` Tom Tromey
  2019-06-23 23:25 ` [PATCH 42/66] Introduce tui_gen_win_info::reset method Tom Tromey
                   ` (18 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves the make_visible method from tui_win_info to its base
class, tui_gen_win_info.  This allows the removal of another window
type check.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (tui_gen_win_info::make_visible): Rename
	from make_visible.
	(tui_make_visible, tui_make_invisible): Rewrite.
	(tui_win_info::make_visible): Remove.
	(tui_source_window_base::make_visible): Update.
	* tui/tui-data.h (struct tui_gen_win_info) <make_visible>: New
	method.  Moved from...
	(struct tui_win_info) <make_visible>: ...here.
---
 gdb/ChangeLog            | 11 +++++++++++
 gdb/tui/tui-data.h       |  6 +++---
 gdb/tui/tui-wingeneral.c | 41 ++++++++++++++--------------------------
 3 files changed, 28 insertions(+), 30 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 92bfb39fe86..d5e46fed5c0 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -51,6 +51,9 @@ struct tui_gen_win_info
   /* Call to refresh this window.  */
   virtual void refresh_window ();
 
+  /* Make this window visible or invisible.  */
+  virtual void make_visible (bool visible);
+
   /* Return the name of this type of window.  */
   virtual const char *name () const
   {
@@ -273,9 +276,6 @@ public:
     return false;
   }
 
-  /* Make this window visible or invisible.  */
-  virtual void make_visible (bool visible);
-
   /* Refresh this window and any associated windows.  */
   virtual void refresh ();
 
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index f1089a9f38a..acb8a26765b 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -168,51 +168,37 @@ tui_make_window (struct tui_gen_win_info *win_info, int box_it)
 /* We can't really make windows visible, or invisible.  So we have to
    delete the entire window when making it visible, and create it
    again when making it visible.  */
-static void
-make_visible (struct tui_gen_win_info *win_info, bool visible)
+void
+tui_gen_win_info::make_visible (bool visible)
 {
-  /* Don't tear down/recreate command window.  */
-  if (win_info->type == CMD_WIN)
-    return;
-
   if (visible)
     {
-      if (!win_info->is_visible)
+      if (!is_visible)
 	{
-	  tui_make_window (win_info, !tui_win_is_auxillary (win_info->type));
-	  win_info->is_visible = true;
+	  tui_make_window (this, !tui_win_is_auxillary (type));
+	  is_visible = true;
 	}
     }
   else if (!visible
-	   && win_info->is_visible
-	   && win_info->handle != NULL)
+	   && is_visible
+	   && handle != NULL)
     {
-      win_info->is_visible = false;
-      tui_delete_win (win_info->handle);
-      win_info->handle = NULL;
+      is_visible = false;
+      tui_delete_win (handle);
+      handle = NULL;
     }
-
-  return;
 }
 
 void
 tui_make_visible (struct tui_gen_win_info *win_info)
 {
-  make_visible (win_info, true);
+  win_info->make_visible (true);
 }
 
 void
 tui_make_invisible (struct tui_gen_win_info *win_info)
 {
-  make_visible (win_info, false);
-}
-
-/* See tui-data.h.  */
-
-void
-tui_win_info::make_visible (bool visible)
-{
-  ::make_visible (this, visible);
+  win_info->make_visible (false);
 }
 
 /* See tui-data.h.  */
@@ -220,7 +206,8 @@ tui_win_info::make_visible (bool visible)
 void
 tui_source_window_base::make_visible (bool visible)
 {
-  ::make_visible (execution_info, visible);
+  if (execution_info != nullptr)
+    execution_info->make_visible (visible);
   tui_win_info::make_visible (visible);
 }
 
-- 
2.17.2

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

* [PATCH 34/66] Change tui_update_source_window for better type safety
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (32 preceding siblings ...)
  2019-06-23 23:25 ` [PATCH 42/66] Introduce tui_gen_win_info::reset method Tom Tromey
@ 2019-06-23 23:25 ` Tom Tromey
  2019-06-23 23:25 ` [PATCH 35/66] Introduce tui_gen_win_info::name method Tom Tromey
                   ` (16 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_update_source_window can only be called for source and disassembly
windows, so change the argument type to enforce this at compile time.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_update_source_window)
	(tui_update_source_window_as_is): Change parameter type.
	* tui/tui-winsource.c (tui_update_source_window): Change win_info
	to be a tui_source_window_base.
	(tui_update_source_window_as_is): Likewise.
	* tui/tui-win.c (make_visible_with_new_height): Update.
---
 gdb/ChangeLog           | 9 +++++++++
 gdb/tui/tui-win.c       | 4 ++--
 gdb/tui/tui-winsource.c | 7 +++----
 gdb/tui/tui-winsource.h | 4 ++--
 4 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index a40e6c5206b..c8fd267f362 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -1327,7 +1327,7 @@ make_visible_with_new_height (struct tui_win_info *win_info)
 
 	  line_or_addr = base->start_line_or_addr;
 	  tui_free_win_content (win_info);
-	  tui_update_source_window (win_info, gdbarch,
+	  tui_update_source_window (base, gdbarch,
 				    cursal.symtab, line_or_addr, TRUE);
 	}
       else if (deprecated_safe_get_selected_frame () != NULL)
@@ -1349,7 +1349,7 @@ make_visible_with_new_height (struct tui_win_info *win_info)
 	      line.loa = LOA_ADDRESS;
 	      find_line_pc (s, cursal.line, &line.u.addr);
 	    }
-	  tui_update_source_window (win_info, gdbarch, s, line, TRUE);
+	  tui_update_source_window (base, gdbarch, s, line, TRUE);
 	}
       if (win_info->has_locator ())
 	{
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 254c7e00dcb..1ec9cecdc9c 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -69,14 +69,13 @@ tui_display_main ()
 /* Function to display source in the source window.  This function
    initializes the horizontal scroll to 0.  */
 void
-tui_update_source_window (struct tui_win_info *win_info,
+tui_update_source_window (struct tui_source_window_base *win_info,
 			  struct gdbarch *gdbarch,
 			  struct symtab *s,
 			  struct tui_line_or_address line_or_addr,
 			  int noerror)
 {
-  tui_source_window_base *base = (tui_source_window_base *) win_info;
-  base->horizontal_offset = 0;
+  win_info->horizontal_offset = 0;
   tui_update_source_window_as_is (win_info, gdbarch, s, line_or_addr, noerror);
 
   return;
@@ -86,7 +85,7 @@ tui_update_source_window (struct tui_win_info *win_info,
 /* Function to display source in the source/asm window.  This function
    shows the source as specified by the horizontal offset.  */
 void
-tui_update_source_window_as_is (struct tui_win_info *win_info, 
+tui_update_source_window_as_is (struct tui_source_window_base *win_info, 
 				struct gdbarch *gdbarch,
 				struct symtab *s,
 				struct tui_line_or_address line_or_addr, 
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index ada3964ad1a..6f2dc3533f7 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -39,11 +39,11 @@ extern int tui_update_breakpoint_info (struct tui_win_info *win,
 
 /* Function to display the "main" routine.  */
 extern void tui_display_main (void);
-extern void tui_update_source_window (struct tui_win_info *, 
+extern void tui_update_source_window (struct tui_source_window_base *, 
 				      struct gdbarch *, struct symtab *,
 				      struct tui_line_or_address, 
 				      int);
-extern void tui_update_source_window_as_is (struct tui_win_info *,
+extern void tui_update_source_window_as_is (struct tui_source_window_base *,
 					    struct gdbarch *, struct symtab *,
 					    struct tui_line_or_address, 
 					    int);
-- 
2.17.2

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

* [PATCH 36/66] Change tui_alloc_source_buffer return type to void
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (42 preceding siblings ...)
  2019-06-23 23:26 ` [PATCH 31/66] Use new and delete for tui_gen_win_info Tom Tromey
@ 2019-06-23 23:26 ` Tom Tromey
  2019-06-23 23:26 ` [PATCH 32/66] Derive tui_win_info from tui_gen_win_info Tom Tromey
                   ` (6 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_alloc_source_buffer can't actually fail, so change its return type
to void and update the callers.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_alloc_source_buffer): Change return
	type to void.
	* tui/tui-winsource.c (tui_alloc_source_buffer): Change return
	type to void.
	* tui/tui-source.c (tui_set_source_content): Update.
	* tui/tui-disasm.c (tui_set_disassem_content): Update.
---
 gdb/ChangeLog           |   9 +++
 gdb/tui/tui-disasm.c    |   5 +-
 gdb/tui/tui-source.c    | 149 ++++++++++++++++++++--------------------
 gdb/tui/tui-winsource.c |   4 +-
 gdb/tui/tui-winsource.h |   2 +-
 5 files changed, 86 insertions(+), 83 deletions(-)

diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index a9d827f5b78..0bc7c642bcd 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -165,7 +165,6 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from)
 enum tui_status
 tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
-  enum tui_status ret = TUI_FAILURE;
   int i;
   int offset = TUI_DISASM_WIN->horizontal_offset;
   int max_lines, line_width;
@@ -180,9 +179,7 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
   if (pc == 0)
     return TUI_FAILURE;
 
-  ret = tui_alloc_source_buffer (TUI_DISASM_WIN);
-  if (ret != TUI_SUCCESS)
-    return ret;
+  tui_alloc_source_buffer (TUI_DISASM_WIN);
 
   tui_source_window_base *base = TUI_DISASM_WIN;
   base->gdbarch = gdbarch;
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index c6367765d67..39abe81a870 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -133,86 +133,85 @@ tui_set_source_content (struct symtab *s,
     {
       int line_width, nlines;
 
-      if ((ret = tui_alloc_source_buffer (TUI_SRC_WIN)) == TUI_SUCCESS)
+      ret = TUI_SUCCESS;
+      tui_alloc_source_buffer (TUI_SRC_WIN);
+      line_width = TUI_SRC_WIN->width - 1;
+      /* Take hilite (window border) into account, when
+	 calculating the number of lines.  */
+      nlines = (line_no + (TUI_SRC_WIN->height - 2)) - line_no;
+
+      std::string srclines;
+      if (!g_source_cache.get_source_lines (s, line_no, line_no + nlines,
+					    &srclines))
 	{
-	  line_width = TUI_SRC_WIN->width - 1;
-	  /* Take hilite (window border) into account, when
-	     calculating the number of lines.  */
-	  nlines = (line_no + (TUI_SRC_WIN->height - 2)) - line_no;
-
-	  std::string srclines;
-	  if (!g_source_cache.get_source_lines (s, line_no, line_no + nlines,
-						&srclines))
+	  if (!noerror)
 	    {
-	      if (!noerror)
-		{
-		  const char *filename = symtab_to_filename_for_display (s);
-		  char *name = (char *) alloca (strlen (filename) + 100);
-
-		  sprintf (name, "%s:%d", filename, line_no);
-		  print_sys_errmsg (name, errno);
-		}
-	      ret = TUI_FAILURE;
+	      const char *filename = symtab_to_filename_for_display (s);
+	      char *name = (char *) alloca (strlen (filename) + 100);
+
+	      sprintf (name, "%s:%d", filename, line_no);
+	      print_sys_errmsg (name, errno);
 	    }
-	  else
+	  ret = TUI_FAILURE;
+	}
+      else
+	{
+	  int cur_line_no, cur_line;
+	  struct tui_gen_win_info *locator
+	    = tui_locator_win_info_ptr ();
+	  struct tui_source_window_base *src
+	    = (struct tui_source_window_base *) TUI_SRC_WIN;
+	  const char *s_filename = symtab_to_filename_for_display (s);
+
+	  if (TUI_SRC_WIN->title)
+	    xfree (TUI_SRC_WIN->title);
+	  TUI_SRC_WIN->title = xstrdup (s_filename);
+
+	  xfree (src->fullname);
+	  src->fullname = xstrdup (symtab_to_fullname (s));
+
+	  cur_line = 0;
+	  src->gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s));
+	  src->start_line_or_addr.loa = LOA_LINE;
+	  cur_line_no = src->start_line_or_addr.u.line_no = line_no;
+
+	  const char *iter = srclines.c_str ();
+	  while (cur_line < nlines)
 	    {
-	      int cur_line_no, cur_line;
-	      struct tui_gen_win_info *locator
-		= tui_locator_win_info_ptr ();
-	      struct tui_source_window_base *src
-		= (struct tui_source_window_base *) TUI_SRC_WIN;
-	      const char *s_filename = symtab_to_filename_for_display (s);
-
-	      if (TUI_SRC_WIN->title)
-		xfree (TUI_SRC_WIN->title);
-	      TUI_SRC_WIN->title = xstrdup (s_filename);
-
-	      xfree (src->fullname);
-	      src->fullname = xstrdup (symtab_to_fullname (s));
-
-	      cur_line = 0;
-	      src->gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s));
-	      src->start_line_or_addr.loa = LOA_LINE;
-	      cur_line_no = src->start_line_or_addr.u.line_no = line_no;
-
-	      const char *iter = srclines.c_str ();
-	      while (cur_line < nlines)
-		{
-		  struct tui_win_element *element
-		    = TUI_SRC_WIN->content[cur_line];
-
-		  std::string text;
-		  if (*iter != '\0')
-		    text = copy_source_line (&iter, cur_line_no,
-					     src->horizontal_offset,
-					     line_width);
-
-		  /* Set whether element is the execution point
-		     and whether there is a break point on it.  */
-		  element->which_element.source.line_or_addr.loa =
-		    LOA_LINE;
-		  element->which_element.source.line_or_addr.u.line_no =
-		    cur_line_no;
-		  element->which_element.source.is_exec_point =
-		    (filename_cmp (locator->content[0]
-				   ->which_element.locator.full_name,
-				   symtab_to_fullname (s)) == 0
-		     && cur_line_no
-		     == locator->content[0]
-		     ->which_element.locator.line_no);
-
-		  xfree (TUI_SRC_WIN->content[cur_line]
-			 ->which_element.source.line);
-		  TUI_SRC_WIN->content[cur_line]
-		    ->which_element.source.line
-		    = xstrdup (text.c_str ());
-
-		  cur_line++;
-		  cur_line_no++;
-		}
-	      TUI_SRC_WIN->content_size = nlines;
-	      ret = TUI_SUCCESS;
+	      struct tui_win_element *element
+		= TUI_SRC_WIN->content[cur_line];
+
+	      std::string text;
+	      if (*iter != '\0')
+		text = copy_source_line (&iter, cur_line_no,
+					 src->horizontal_offset,
+					 line_width);
+
+	      /* Set whether element is the execution point
+		 and whether there is a break point on it.  */
+	      element->which_element.source.line_or_addr.loa =
+		LOA_LINE;
+	      element->which_element.source.line_or_addr.u.line_no =
+		cur_line_no;
+	      element->which_element.source.is_exec_point =
+		(filename_cmp (locator->content[0]
+			       ->which_element.locator.full_name,
+			       symtab_to_fullname (s)) == 0
+		 && cur_line_no
+		 == locator->content[0]
+		 ->which_element.locator.line_no);
+
+	      xfree (TUI_SRC_WIN->content[cur_line]
+		     ->which_element.source.line);
+	      TUI_SRC_WIN->content[cur_line]
+		->which_element.source.line
+		= xstrdup (text.c_str ());
+
+	      cur_line++;
+	      cur_line_no++;
 	    }
+	  TUI_SRC_WIN->content_size = nlines;
+	  ret = TUI_SUCCESS;
 	}
     }
   return ret;
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 1ec9cecdc9c..209d33d6c99 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -589,7 +589,7 @@ tui_update_exec_info (struct tui_win_info *win_info)
   tui_show_exec_info_content (win_info);
 }
 
-enum tui_status
+void
 tui_alloc_source_buffer (struct tui_win_info *win_info)
 {
   int i, line_width, max_lines;
@@ -608,8 +608,6 @@ tui_alloc_source_buffer (struct tui_win_info *win_info)
 	win_info->content[i]->which_element.source.line
 	  = (char *) xmalloc (line_width);
     }
-
-  return TUI_SUCCESS;
 }
 
 
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 6f2dc3533f7..ccc9ae5f68a 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -59,7 +59,7 @@ extern void tui_erase_exec_info_content (struct tui_win_info *);
 extern void tui_clear_exec_info_content (struct tui_win_info *);
 extern void tui_update_exec_info (struct tui_win_info *);
 
-extern enum tui_status tui_alloc_source_buffer (struct tui_win_info *);
+extern void tui_alloc_source_buffer (struct tui_win_info *);
 extern int tui_line_is_displayed (int, 
 				  struct tui_win_info *, 
 				  int);
-- 
2.17.2

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

* [PATCH 32/66] Derive tui_win_info from tui_gen_win_info
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (43 preceding siblings ...)
  2019-06-23 23:26 ` [PATCH 36/66] Change tui_alloc_source_buffer return type to void Tom Tromey
@ 2019-06-23 23:26 ` Tom Tromey
  2019-06-23 23:26 ` [PATCH 33/66] Introduce refresh_window method Tom Tromey
                   ` (5 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_win_info to derive from tui_gen_win_info, rather than
having a tui_gen_win_info as a member.  This removes a layer of member
access from the entire TUI, which is why this patch is so large.  This
change will enable further removal of switches based on window type.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui.c (tui_rl_other_window, tui_enable)
	(tui_is_window_visible, tui_get_command_dimension): Update.
	* tui/tui-winsource.c (tui_update_source_window_as_is)
	(tui_clear_source_content, tui_erase_source_content)
	(tui_show_source_line, tui_source_window_base::refill)
	(tui_source_window_base::do_scroll_horizontal)
	(tui_source_window_base::set_is_exec_point_at)
	(tui_update_breakpoint_info, tui_set_exec_info_content)
	(tui_alloc_source_buffer, tui_line_is_displayed)
	(tui_addr_is_displayed): Update.
	* tui/tui-wingeneral.c (tui_unhighlight_win, tui_highlight_win)
	(tui_check_and_display_highlight_if_needed)
	(tui_win_info::make_visible, tui_win_info::refresh)
	(tui_refresh_all): Update.
	* tui/tui-windata.c (tui_first_data_item_displayed)
	(tui_delete_data_content_windows, tui_erase_data_content)
	(tui_display_all_data, tui_data_window::refresh_all)
	(tui_check_data_values): Update.
	* tui/tui-win.c (window_name_completer, tui_update_gdb_sizes)
	(tui_set_win_focus_to, tui_win_info::forward_scroll)
	(tui_win_info::backward_scroll, tui_refresh_all_win)
	(tui_resize_all, tui_set_focus, tui_all_windows_info)
	(update_tab_width, tui_set_win_height, tui_adjust_win_heights)
	(tui_source_window_base::set_new_height)
	(tui_data_window::set_new_height)
	(make_invisible_and_set_new_height)
	(make_visible_with_new_height, new_height_ok)
	(parse_scrolling_args): Update.
	* tui/tui-stack.c (tui_show_frame_info): Update.
	* tui/tui-source.c (tui_set_source_content)
	(tui_set_source_content_nil, tui_source_is_displayed)
	(tui_source_window::do_scroll_vertical): Update.
	* tui/tui-regs.c (tui_show_registers, tui_show_register_group)
	(tui_display_registers_from, tui_display_reg_element_at_line)
	(tui_check_register_values, tui_reg_command): Update.
	* tui/tui-layout.c (tui_default_win_height)
	(show_source_disasm_command, show_data, init_and_make_win)
	(show_source_or_disasm_and_command): Update.
	* tui/tui-io.c (update_cmdwin_start_line, tui_putc, tui_puts)
	(tui_redisplay_readline, tui_mld_flush)
	(tui_mld_erase_entire_line, tui_mld_getc, tui_cont_sig)
	(tui_getc): Update.
	* tui/tui-disasm.c (tui_set_disassem_content)
	(tui_disasm_window::do_scroll_vertical): Update.
	* tui/tui-data.h (struct tui_gen_win_info) <~tui_gen_win_info>:
	Now virtual.
	(struct tui_win_info): Derive from tui_gen_win_info.
	<~tui_win_info>: Mark as override.
	<generic>: Remove member.
	* tui/tui-data.c (tui_cmd_window::clear_detail, tui_next_win)
	(tui_prev_win, tui_partial_win_by_name, tui_win_info)
	(~tui_data_window, ~tui_win_info)
	(tui_free_all_source_wins_content): Update.
	* tui/tui-command.c (tui_refresh_cmd_win): Update.
---
 gdb/ChangeLog            |  57 ++++++++++
 gdb/tui/tui-command.c    |   2 +-
 gdb/tui/tui-data.c       |  47 ++++----
 gdb/tui/tui-data.h       |   8 +-
 gdb/tui/tui-disasm.c     |  13 +--
 gdb/tui/tui-io.c         |  24 ++--
 gdb/tui/tui-layout.c     |  76 ++++++-------
 gdb/tui/tui-regs.c       |  28 ++---
 gdb/tui/tui-source.c     |  33 +++---
 gdb/tui/tui-stack.c      |   2 +-
 gdb/tui/tui-win.c        | 238 +++++++++++++++++++--------------------
 gdb/tui/tui-windata.c    |  24 ++--
 gdb/tui/tui-wingeneral.c |  22 ++--
 gdb/tui/tui-winsource.c  |  95 ++++++++--------
 gdb/tui/tui.c            |  14 +--
 15 files changed, 366 insertions(+), 317 deletions(-)

diff --git a/gdb/tui/tui-command.c b/gdb/tui/tui-command.c
index 9603b3cfdca..259620f7ce7 100644
--- a/gdb/tui/tui-command.c
+++ b/gdb/tui/tui-command.c
@@ -94,7 +94,7 @@ tui_dispatch_ctrl_char (unsigned int ch)
 void
 tui_refresh_cmd_win (void)
 {
-  WINDOW *w = TUI_CMD_WIN->generic.handle;
+  WINDOW *w = TUI_CMD_WIN->handle;
 
   wrefresh (w);
 
diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 82af0c9cf77..63afec57141 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -169,7 +169,7 @@ tui_source_window_base::clear_detail ()
 void
 tui_cmd_window::clear_detail ()
 {
-  wmove (generic.handle, 0, 0);
+  wmove (handle, 0, 0);
 }
 
 /* See tui-data.h.  */
@@ -268,17 +268,17 @@ tui_set_current_layout_to (enum tui_layout_type new_layout)
 struct tui_win_info *
 tui_next_win (struct tui_win_info *cur_win)
 {
-  int type = cur_win->generic.type;
+  int type = cur_win->type;
   struct tui_win_info *next_win = NULL;
 
-  if (cur_win->generic.type == CMD_WIN)
+  if (cur_win->type == CMD_WIN)
     type = SRC_WIN;
   else
-    type = cur_win->generic.type + 1;
-  while (type != cur_win->generic.type && (next_win == NULL))
+    type = cur_win->type + 1;
+  while (type != cur_win->type && (next_win == NULL))
     {
       if (tui_win_list[type]
-	  && tui_win_list[type]->generic.is_visible)
+	  && tui_win_list[type]->is_visible)
 	next_win = tui_win_list[type];
       else
 	{
@@ -298,17 +298,17 @@ tui_next_win (struct tui_win_info *cur_win)
 struct tui_win_info *
 tui_prev_win (struct tui_win_info *cur_win)
 {
-  int type = cur_win->generic.type;
+  int type = cur_win->type;
   struct tui_win_info *prev = NULL;
 
-  if (cur_win->generic.type == SRC_WIN)
+  if (cur_win->type == SRC_WIN)
     type = CMD_WIN;
   else
-    type = cur_win->generic.type - 1;
-  while (type != cur_win->generic.type && (prev == NULL))
+    type = cur_win->type - 1;
+  while (type != cur_win->type && (prev == NULL))
     {
       if (tui_win_list[type]
-	  && tui_win_list[type]->generic.is_visible)
+	  && tui_win_list[type]->is_visible)
 	prev = tui_win_list[type];
       else
 	{
@@ -337,8 +337,7 @@ tui_partial_win_by_name (const char *name)
 	{
           if (tui_win_list[i] != 0)
             {
-              const char *cur_name =
-		tui_win_name (&tui_win_list[i]->generic);
+              const char *cur_name = tui_win_name (tui_win_list[i]);
 
               if (strlen (name) <= strlen (cur_name)
 		  && startswith (cur_name, name))
@@ -457,7 +456,7 @@ init_content_element (struct tui_win_element *element,
 }
 
 tui_win_info::tui_win_info (enum tui_win_type type)
-  : generic (type)
+  : tui_gen_win_info (type)
 {
 }
 
@@ -569,7 +568,7 @@ tui_source_window_base::~tui_source_window_base ()
 
 tui_data_window::~tui_data_window ()
 {
-  if (generic.content != NULL)
+  if (content != NULL)
     {
       tui_free_data_content (regs_content, regs_content_count);
       regs_content = NULL;
@@ -579,21 +578,21 @@ tui_data_window::~tui_data_window ()
       data_content_count = 0;
       regs_column_count = 1;
       display_regs = false;
-      generic.content = NULL;
-      generic.content_size = 0;
+      content = NULL;
+      content_size = 0;
     }
 }  
 
 tui_win_info::~tui_win_info ()
 {
-  if (generic.handle != NULL)
+  if (handle != NULL)
     {
-      tui_delete_win (generic.handle);
-      generic.handle = NULL;
-      tui_free_win_content (&generic);
+      tui_delete_win (handle);
+      handle = NULL;
+      tui_free_win_content (this);
     }
-  if (generic.title)
-    xfree (generic.title);
+  if (title)
+    xfree (title);
 }
 
 
@@ -602,7 +601,7 @@ tui_free_all_source_wins_content ()
 {
   for (tui_source_window_base *win_info : tui_source_windows ())
     {
-      tui_free_win_content (&(win_info->generic));
+      tui_free_win_content (win_info);
       tui_free_win_content (win_info->execution_info);
     }
 }
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 1fc9e32c5c5..4d2f447c942 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -44,7 +44,7 @@ struct tui_gen_win_info
   {
   }
 
-  ~tui_gen_win_info ()
+  virtual ~tui_gen_win_info ()
   {
   }
 
@@ -246,7 +246,7 @@ struct tui_win_element
 };
 
 /* This defines information about each logical window.  */
-struct tui_win_info
+struct tui_win_info : public tui_gen_win_info
 {
 protected:
 
@@ -265,7 +265,7 @@ protected:
 
 public:
 
-  virtual ~tui_win_info ();
+  ~tui_win_info () override;
 
   /* Clear the pertinent detail in the window.  */
   virtual void clear_detail () = 0;
@@ -311,8 +311,6 @@ public:
   void left_scroll (int num_to_scroll);
   void right_scroll (int num_to_scroll);
 
-  struct tui_gen_win_info generic;	/* General window information.  */
-
   /* Can this window ever be highlighted?  */
   bool can_highlight = false;
 
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 8dd156d0907..a9d827f5b78 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -191,8 +191,8 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
   cur_pc = locator->content[0]->which_element.locator.addr;
 
   /* Window size, excluding highlight box.  */
-  max_lines = TUI_DISASM_WIN->generic.height - 2;
-  line_width = TUI_DISASM_WIN->generic.width - 2;
+  max_lines = TUI_DISASM_WIN->height - 2;
+  line_width = TUI_DISASM_WIN->width - 2;
 
   /* Get temporary table that will hold all strings (addr & insn).  */
   asm_lines = XALLOCAVEC (struct tui_asm_line, max_lines);
@@ -228,7 +228,7 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
       struct tui_source_element *src;
       int cur_len;
 
-      element = TUI_DISASM_WIN->generic.content[i];
+      element = TUI_DISASM_WIN->content[i];
       src = &element->which_element.source;
       strcpy (line, asm_lines[i].addr_string);
       cur_len = strlen (line);
@@ -257,7 +257,7 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
       xfree (asm_lines[i].addr_string);
       xfree (asm_lines[i].insn);
     }
-  TUI_DISASM_WIN->generic.content_size = i;
+  TUI_DISASM_WIN->content_size = i;
   return TUI_SUCCESS;
 }
 
@@ -377,15 +377,12 @@ void
 tui_disasm_window::do_scroll_vertical
   (enum tui_scroll_direction scroll_direction, int num_to_scroll)
 {
-  if (generic.content != NULL)
+  if (content != NULL)
     {
       CORE_ADDR pc;
-      tui_win_content content;
       struct tui_line_or_address val;
       int dir;
 
-      content = generic.content;
-
       pc = content[0]->which_element.source.line_or_addr.u.addr;
       num_to_scroll++;
       dir = (scroll_direction == FORWARD_SCROLL)
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index cdb14bf5314..56d5974cb35 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -180,7 +180,7 @@ static void
 update_cmdwin_start_line ()
 {
   TUI_CMD_WIN->start_line
-    = getcury (TUI_CMD_WIN->generic.handle);
+    = getcury (TUI_CMD_WIN->handle);
 }
 
 /* Print a character in the curses command window.  The output is
@@ -190,7 +190,7 @@ update_cmdwin_start_line ()
 static void
 tui_putc (char c)
 {
-  WINDOW *w = TUI_CMD_WIN->generic.handle;
+  WINDOW *w = TUI_CMD_WIN->handle;
 
   do_tui_putc (w, c);
   update_cmdwin_start_line ();
@@ -502,7 +502,7 @@ void
 tui_puts (const char *string, WINDOW *w)
 {
   if (w == nullptr)
-    w = TUI_CMD_WIN->generic.handle;
+    w = TUI_CMD_WIN->handle;
   tui_puts_internal (w, string, nullptr);
 }
 
@@ -538,13 +538,13 @@ tui_redisplay_readline (void)
   
   c_pos = -1;
   c_line = -1;
-  w = TUI_CMD_WIN->generic.handle;
+  w = TUI_CMD_WIN->handle;
   start_line = TUI_CMD_WIN->start_line;
   wmove (w, start_line, 0);
   prev_col = 0;
   height = 1;
   if (prompt != nullptr)
-    tui_puts_internal (TUI_CMD_WIN->generic.handle, prompt, &height);
+    tui_puts_internal (TUI_CMD_WIN->handle, prompt, &height);
 
   prev_col = getcurx (w);
   for (in = 0; in <= rl_end; in++)
@@ -663,7 +663,7 @@ tui_mld_puts (const struct match_list_displayer *displayer, const char *s)
 static void
 tui_mld_flush (const struct match_list_displayer *displayer)
 {
-  wrefresh (TUI_CMD_WIN->generic.handle);
+  wrefresh (TUI_CMD_WIN->handle);
 }
 
 /* TUI version of displayer.erase_entire_line.  */
@@ -671,7 +671,7 @@ tui_mld_flush (const struct match_list_displayer *displayer)
 static void
 tui_mld_erase_entire_line (const struct match_list_displayer *displayer)
 {
-  WINDOW *w = TUI_CMD_WIN->generic.handle;
+  WINDOW *w = TUI_CMD_WIN->handle;
   int cur_y = getcury (w);
 
   wmove (w, cur_y, 0);
@@ -709,7 +709,7 @@ gdb_wgetch (WINDOW *win)
 static int
 tui_mld_getc (FILE *fp)
 {
-  WINDOW *w = TUI_CMD_WIN->generic.handle;
+  WINDOW *w = TUI_CMD_WIN->handle;
   int c = gdb_wgetch (w);
 
   return c;
@@ -845,7 +845,7 @@ tui_cont_sig (int sig)
       /* Force a refresh of the screen.  */
       tui_refresh_all_win ();
 
-      wrefresh (TUI_CMD_WIN->generic.handle);
+      wrefresh (TUI_CMD_WIN->handle);
     }
   signal (sig, tui_cont_sig);
 }
@@ -914,7 +914,7 @@ tui_getc (FILE *fp)
   int ch;
   WINDOW *w;
 
-  w = TUI_CMD_WIN->generic.handle;
+  w = TUI_CMD_WIN->handle;
 
 #ifdef TUI_USE_PIPE_FOR_READLINE
   /* Flush readline output.  */
@@ -950,8 +950,8 @@ tui_getc (FILE *fp)
 	  int px, py;
 	  getyx (w, py, px);
 	  px += rl_end - rl_point;
-	  py += px / TUI_CMD_WIN->generic.width;
-	  px %= TUI_CMD_WIN->generic.width;
+	  py += px / TUI_CMD_WIN->width;
+	  px %= TUI_CMD_WIN->width;
 	  wmove (w, py, px);
 	  tui_putc ('\n');
         }
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 556bef833a3..9685d7fc4e5 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -296,7 +296,7 @@ tui_default_win_height (enum tui_win_type type,
   int h;
 
   if (tui_win_list[type] != NULL)
-    h = tui_win_list[type]->generic.height;
+    h = tui_win_list[type]->height;
   else
     {
       switch (layout)
@@ -306,7 +306,7 @@ tui_default_win_height (enum tui_win_type type,
 	  if (TUI_CMD_WIN == NULL)
 	    h = tui_term_height () / 2;
 	  else
-	    h = tui_term_height () - TUI_CMD_WIN->generic.height;
+	    h = tui_term_height () - TUI_CMD_WIN->height;
 	  break;
 	case SRC_DISASSEM_COMMAND:
 	case SRC_DATA_COMMAND:
@@ -314,7 +314,7 @@ tui_default_win_height (enum tui_win_type type,
 	  if (TUI_CMD_WIN == NULL)
 	    h = tui_term_height () / 3;
 	  else
-	    h = (tui_term_height () - TUI_CMD_WIN->generic.height) / 2;
+	    h = (tui_term_height () - TUI_CMD_WIN->height) / 2;
 	  break;
 	default:
 	  h = 0;
@@ -610,7 +610,7 @@ show_source_disasm_command (void)
       int cmd_height, src_height, asm_height;
 
       if (TUI_CMD_WIN != NULL)
-	cmd_height = TUI_CMD_WIN->generic.height;
+	cmd_height = TUI_CMD_WIN->height;
       else
 	cmd_height = tui_term_height () / 3;
 
@@ -621,10 +621,10 @@ show_source_disasm_command (void)
 	tui_win_list[SRC_WIN] = make_source_window (src_height, 0);
       else
 	{
-	  init_gen_win_info (&TUI_SRC_WIN->generic,
-			     TUI_SRC_WIN->generic.type,
+	  init_gen_win_info (TUI_SRC_WIN,
+			     TUI_SRC_WIN->type,
 			     src_height,
-			     TUI_SRC_WIN->generic.width,
+			     TUI_SRC_WIN->width,
 			     TUI_SRC_WIN->execution_info->width,
 			     0);
 	  TUI_SRC_WIN->can_highlight = true;
@@ -634,7 +634,7 @@ show_source_disasm_command (void)
 			     3,
 			     0,
 			     0);
-	  tui_make_visible (&TUI_SRC_WIN->generic);
+	  tui_make_visible (TUI_SRC_WIN);
 	  tui_make_visible (TUI_SRC_WIN->execution_info);
 	  TUI_SRC_WIN->m_has_locator = false;
 	}
@@ -665,10 +665,10 @@ show_source_disasm_command (void)
 			     0,
 			     (src_height + asm_height) - 1);
 	  TUI_DISASM_WIN->m_has_locator = true;
-	  init_gen_win_info (&TUI_DISASM_WIN->generic,
-			     TUI_DISASM_WIN->generic.type,
+	  init_gen_win_info (TUI_DISASM_WIN,
+			     TUI_DISASM_WIN->type,
 			     asm_height,
-			     TUI_DISASM_WIN->generic.width,
+			     TUI_DISASM_WIN->width,
 			     TUI_DISASM_WIN->execution_info->width,
 			     src_height - 1);
 	  init_gen_win_info (TUI_DISASM_WIN->execution_info,
@@ -678,7 +678,7 @@ show_source_disasm_command (void)
 			     0,
 			     src_height - 1);
 	  TUI_DISASM_WIN->can_highlight = true;
-	  tui_make_visible (&TUI_DISASM_WIN->generic);
+	  tui_make_visible (TUI_DISASM_WIN);
 	  tui_make_visible (TUI_DISASM_WIN->execution_info);
 	}
       TUI_SRC_WIN->m_has_locator = false;
@@ -692,16 +692,16 @@ show_source_disasm_command (void)
 	  = make_command_window (cmd_height, tui_term_height () - cmd_height);
       else
 	{
-	  init_gen_win_info (&TUI_CMD_WIN->generic,
-			     TUI_CMD_WIN->generic.type,
-			     TUI_CMD_WIN->generic.height,
-			     TUI_CMD_WIN->generic.width,
+	  init_gen_win_info (TUI_CMD_WIN,
+			     TUI_CMD_WIN->type,
+			     TUI_CMD_WIN->height,
+			     TUI_CMD_WIN->width,
 			     0,
-			     TUI_CMD_WIN->generic.origin.y);
+			     TUI_CMD_WIN->origin.y);
 	  TUI_CMD_WIN->can_highlight = false;
-	  tui_make_visible (&TUI_CMD_WIN->generic);
+	  tui_make_visible (TUI_CMD_WIN);
 	}
-      tui_refresh_win (&TUI_CMD_WIN->generic);
+      tui_refresh_win (TUI_CMD_WIN);
       tui_set_current_layout_to (SRC_DISASSEM_COMMAND);
     }
 }
@@ -712,7 +712,7 @@ show_source_disasm_command (void)
 static void
 show_data (enum tui_layout_type new_layout)
 {
-  int total_height = (tui_term_height () - TUI_CMD_WIN->generic.height);
+  int total_height = (tui_term_height () - TUI_CMD_WIN->height);
   int src_height, data_height;
   enum tui_win_type win_type;
   struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
@@ -752,10 +752,10 @@ show_data (enum tui_layout_type new_layout)
   else
     {
       base = (tui_source_window_base *) tui_win_list[win_type];
-      init_gen_win_info (&tui_win_list[win_type]->generic,
-			 tui_win_list[win_type]->generic.type,
+      init_gen_win_info (tui_win_list[win_type],
+			 tui_win_list[win_type]->type,
 			 src_height,
-			 tui_win_list[win_type]->generic.width,
+			 tui_win_list[win_type]->width,
 			 base->execution_info->width,
 			 data_height - 1);
       init_gen_win_info (base->execution_info,
@@ -764,7 +764,7 @@ show_data (enum tui_layout_type new_layout)
 			 3,
 			 0,
 			 data_height - 1);
-      tui_make_visible (&tui_win_list[win_type]->generic);
+      tui_make_visible (tui_win_list[win_type]);
       tui_make_visible (base->execution_info);
       init_gen_win_info (locator,
 			 LOCATOR_WIN,
@@ -829,7 +829,7 @@ init_and_make_win (void *opaque_win_info,
   if (tui_win_is_auxillary (win_type))
     generic = (struct tui_gen_win_info *) opaque_win_info;
   else
-    generic = &((struct tui_win_info *) opaque_win_info)->generic;
+    generic = (struct tui_win_info *) opaque_win_info;
 
   init_gen_win_info (generic, win_type, height, width, origin_x, origin_y);
   if (!tui_win_is_auxillary (win_type))
@@ -892,7 +892,7 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
       struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
 
       if (TUI_CMD_WIN != NULL)
-	cmd_height = TUI_CMD_WIN->generic.height;
+	cmd_height = TUI_CMD_WIN->height;
       else
 	cmd_height = tui_term_height () / 3;
       src_height = tui_term_height () - cmd_height;
@@ -930,10 +930,10 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 			     0,
 			     src_height - 1);
 	  base->m_has_locator = true;
-	  init_gen_win_info (&(*win_info_ptr)->generic,
-			     (*win_info_ptr)->generic.type,
+	  init_gen_win_info (*win_info_ptr,
+			     (*win_info_ptr)->type,
 			     src_height - 1,
-			     (*win_info_ptr)->generic.width,
+			     (*win_info_ptr)->width,
 			     base->execution_info->width,
 			     0);
 	  init_gen_win_info (base->execution_info,
@@ -943,7 +943,7 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 			     0,
 			     0);
 	  base->can_highlight = true;
-	  tui_make_visible (&(*win_info_ptr)->generic);
+	  tui_make_visible (*win_info_ptr);
 	  tui_make_visible (base->execution_info);
 	}
 
@@ -956,18 +956,18 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 	{
 	  tui_win_list[CMD_WIN] = make_command_window (cmd_height,
 						       src_height);
-	  tui_refresh_win (&TUI_CMD_WIN->generic);
+	  tui_refresh_win (TUI_CMD_WIN);
 	}
       else
 	{
-	  init_gen_win_info (&TUI_CMD_WIN->generic,
-			     TUI_CMD_WIN->generic.type,
-			     TUI_CMD_WIN->generic.height,
-			     TUI_CMD_WIN->generic.width,
-			     TUI_CMD_WIN->generic.origin.x,
-			     TUI_CMD_WIN->generic.origin.y);
+	  init_gen_win_info (TUI_CMD_WIN,
+			     TUI_CMD_WIN->type,
+			     TUI_CMD_WIN->height,
+			     TUI_CMD_WIN->width,
+			     TUI_CMD_WIN->origin.x,
+			     TUI_CMD_WIN->origin.y);
 	  TUI_CMD_WIN->can_highlight = false;
-	  tui_make_visible (&TUI_CMD_WIN->generic);
+	  tui_make_visible (TUI_CMD_WIN);
 	}
       tui_set_current_layout_to (layout_type);
     }
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 7367cf7c0cb..cfb735c81d5 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -135,7 +135,7 @@ tui_show_registers (struct reggroup *group)
 
   /* Make sure the register window is visible.  If not, select an
      appropriate layout.  */
-  if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->generic.is_visible)
+  if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->is_visible)
     tui_set_layout_by_name (DATA_NAME);
 
   if (group == 0)
@@ -195,8 +195,8 @@ tui_show_register_group (struct reggroup *group,
   /* Make a new title showing which group we display.  */
   snprintf (title, sizeof (title) - 1, "Register group: %s",
             reggroup_name (group));
-  xfree (TUI_DATA_WIN->generic.title);
-  TUI_DATA_WIN->generic.title = xstrdup (title);
+  xfree (TUI_DATA_WIN->title);
+  TUI_DATA_WIN->title = xstrdup (title);
 
   /* See how many registers must be displayed.  */
   nr_regs = 0;
@@ -235,10 +235,10 @@ tui_show_register_group (struct reggroup *group,
     {
       if (!refresh_values_only || allocated_here)
 	{
-	  TUI_DATA_WIN->generic.content = NULL;
-	  TUI_DATA_WIN->generic.content_size = 0;
-	  tui_add_content_elements (&TUI_DATA_WIN->generic, nr_regs);
-	  TUI_DATA_WIN->regs_content = TUI_DATA_WIN->generic.content;
+	  TUI_DATA_WIN->content = NULL;
+	  TUI_DATA_WIN->content_size = 0;
+	  tui_add_content_elements (TUI_DATA_WIN, nr_regs);
+	  TUI_DATA_WIN->regs_content = TUI_DATA_WIN->content;
 	  TUI_DATA_WIN->regs_content_count = nr_regs;
 	}
 
@@ -276,7 +276,7 @@ tui_show_register_group (struct reggroup *group,
           pos++;
 	}
 
-      TUI_DATA_WIN->generic.content_size =
+      TUI_DATA_WIN->content_size =
 	TUI_DATA_WIN->regs_content_count + TUI_DATA_WIN->data_content_count;
       ret = TUI_SUCCESS;
     }
@@ -326,17 +326,17 @@ tui_display_registers_from (int start_element_no)
       i = start_element_no;
 
       TUI_DATA_WIN->regs_column_count =
-        (TUI_DATA_WIN->generic.width - 2) / item_win_width;
+        (TUI_DATA_WIN->width - 2) / item_win_width;
       if (TUI_DATA_WIN->regs_column_count == 0)
         TUI_DATA_WIN->regs_column_count = 1;
       item_win_width =
-        (TUI_DATA_WIN->generic.width - 2) / TUI_DATA_WIN->regs_column_count;
+        (TUI_DATA_WIN->width - 2) / TUI_DATA_WIN->regs_column_count;
 
       /* Now create each data "sub" window, and write the display into
 	 it.  */
       cur_y = 1;
       while (i < TUI_DATA_WIN->regs_content_count 
-	     && cur_y <= TUI_DATA_WIN->generic.viewport_height)
+	     && cur_y <= TUI_DATA_WIN->viewport_height)
 	{
 	  for (j = 0;
 	       j < TUI_DATA_WIN->regs_column_count
@@ -401,7 +401,7 @@ tui_display_reg_element_at_line (int start_element_no,
 
 	  last_line_no = tui_last_regs_line_no ();
 	  first_line_on_last_page
-	    = last_line_no - (TUI_DATA_WIN->generic.height - 2);
+	    = last_line_no - (TUI_DATA_WIN->height - 2);
 	  if (first_line_on_last_page < 0)
 	    first_line_on_last_page = 0;
 
@@ -470,7 +470,7 @@ void
 tui_check_register_values (struct frame_info *frame)
 {
   if (TUI_DATA_WIN != NULL
-      && TUI_DATA_WIN->generic.is_visible)
+      && TUI_DATA_WIN->is_visible)
     {
       if (TUI_DATA_WIN->regs_content_count <= 0 
 	  && TUI_DATA_WIN->display_regs)
@@ -596,7 +596,7 @@ tui_reg_command (const char *args, int from_tty)
       /* Make sure the register window is visible.  If not, select an
 	 appropriate layout.  We need to do this before trying to run the
 	 'next' or 'prev' commands.  */
-      if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->generic.is_visible)
+      if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->is_visible)
 	tui_set_layout_by_name (DATA_NAME);
 
       if (strncmp (args, "next", len) == 0)
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index ac3f225e1b1..c6367765d67 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -135,10 +135,10 @@ tui_set_source_content (struct symtab *s,
 
       if ((ret = tui_alloc_source_buffer (TUI_SRC_WIN)) == TUI_SUCCESS)
 	{
-	  line_width = TUI_SRC_WIN->generic.width - 1;
+	  line_width = TUI_SRC_WIN->width - 1;
 	  /* Take hilite (window border) into account, when
 	     calculating the number of lines.  */
-	  nlines = (line_no + (TUI_SRC_WIN->generic.height - 2)) - line_no;
+	  nlines = (line_no + (TUI_SRC_WIN->height - 2)) - line_no;
 
 	  std::string srclines;
 	  if (!g_source_cache.get_source_lines (s, line_no, line_no + nlines,
@@ -163,9 +163,9 @@ tui_set_source_content (struct symtab *s,
 		= (struct tui_source_window_base *) TUI_SRC_WIN;
 	      const char *s_filename = symtab_to_filename_for_display (s);
 
-	      if (TUI_SRC_WIN->generic.title)
-		xfree (TUI_SRC_WIN->generic.title);
-	      TUI_SRC_WIN->generic.title = xstrdup (s_filename);
+	      if (TUI_SRC_WIN->title)
+		xfree (TUI_SRC_WIN->title);
+	      TUI_SRC_WIN->title = xstrdup (s_filename);
 
 	      xfree (src->fullname);
 	      src->fullname = xstrdup (symtab_to_fullname (s));
@@ -179,7 +179,7 @@ tui_set_source_content (struct symtab *s,
 	      while (cur_line < nlines)
 		{
 		  struct tui_win_element *element
-		    = TUI_SRC_WIN->generic.content[cur_line];
+		    = TUI_SRC_WIN->content[cur_line];
 
 		  std::string text;
 		  if (*iter != '\0')
@@ -201,16 +201,16 @@ tui_set_source_content (struct symtab *s,
 		     == locator->content[0]
 		     ->which_element.locator.line_no);
 
-		  xfree (TUI_SRC_WIN->generic.content[cur_line]
+		  xfree (TUI_SRC_WIN->content[cur_line]
 			 ->which_element.source.line);
-		  TUI_SRC_WIN->generic.content[cur_line]
+		  TUI_SRC_WIN->content[cur_line]
 		    ->which_element.source.line
 		    = xstrdup (text.c_str ());
 
 		  cur_line++;
 		  cur_line_no++;
 		}
-	      TUI_SRC_WIN->generic.content_size = nlines;
+	      TUI_SRC_WIN->content_size = nlines;
 	      ret = TUI_SUCCESS;
 	    }
 	}
@@ -233,18 +233,18 @@ tui_set_source_content_nil (struct tui_win_info *win_info,
   int n_lines;
   int curr_line = 0;
 
-  line_width = win_info->generic.width - 1;
-  n_lines = win_info->generic.height - 2;
+  line_width = win_info->width - 1;
+  n_lines = win_info->height - 2;
 
   /* Set to empty each line in the window, except for the one which
      contains the message.  */
-  while (curr_line < win_info->generic.content_size)
+  while (curr_line < win_info->content_size)
     {
       /* Set the information related to each displayed line to null:
          i.e. the line number is 0, there is no bp, it is not where
          the program is stopped.  */
 
-      struct tui_win_element *element = win_info->generic.content[curr_line];
+      struct tui_win_element *element = win_info->content[curr_line];
 
       element->which_element.source.line_or_addr.loa = LOA_LINE;
       element->which_element.source.line_or_addr.u.line_no = 0;
@@ -300,7 +300,7 @@ int
 tui_source_is_displayed (const char *fullname)
 {
   return (TUI_SRC_WIN != NULL
-	  && TUI_SRC_WIN->generic.content_in_use 
+	  && TUI_SRC_WIN->content_in_use 
 	  && (filename_cmp (tui_locator_win_info_ptr ()->content[0]
 			      ->which_element.locator.full_name,
 			    fullname) == 0));
@@ -312,11 +312,10 @@ void
 tui_source_window::do_scroll_vertical
   (enum tui_scroll_direction scroll_direction, int num_to_scroll)
 {
-  if (generic.content != NULL)
+  if (content != NULL)
     {
       struct tui_line_or_address l;
       struct symtab *s;
-      tui_win_content content = generic.content;
       struct symtab_and_line cursal = get_current_source_symtab_and_line ();
 
       if (cursal.symtab == NULL)
@@ -330,7 +329,7 @@ tui_source_window::do_scroll_vertical
 	  l.u.line_no = content[0]->which_element.source.line_or_addr.u.line_no
 	    + num_to_scroll;
 	  if (l.u.line_no > s->nlines)
-	    /* line = s->nlines - win_info->generic.content_size + 1; */
+	    /* line = s->nlines - win_info->content_size + 1; */
 	    /* elz: fix for dts 23398.  */
 	    l.u.line_no
 	      = content[0]->which_element.source.line_or_addr.u.line_no;
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index 125a5b7a8e3..a38971542eb 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -404,7 +404,7 @@ tui_show_frame_info (struct frame_info *fi)
 	  if (win_info == TUI_SRC_WIN)
 	    {
 	      start_line = (item->locator.line_no -
-			   (win_info->generic.viewport_height / 2)) + 1;
+			   (win_info->viewport_height / 2)) + 1;
 	      if (start_line <= 0)
 		start_line = 1;
 	    }
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index e4c1522a62d..a40e6c5206b 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -373,10 +373,10 @@ window_name_completer (completion_tracker &tracker,
 
       /* We can't focus on an invisible window.  */
       if (tui_win_list[win_type] == NULL
-	  || !tui_win_list[win_type]->generic.is_visible)
+	  || !tui_win_list[win_type]->is_visible)
 	continue;
 
-      completion_name = tui_win_name (&tui_win_list [win_type]->generic);
+      completion_name = tui_win_name (tui_win_list [win_type]);
       gdb_assert (completion_name != NULL);
       completion_name_vec.push_back (completion_name);
     }
@@ -438,8 +438,8 @@ tui_update_gdb_sizes (void)
 
   if (tui_active)
     {
-      width = TUI_CMD_WIN->generic.width;
-      height = TUI_CMD_WIN->generic.height;
+      width = TUI_CMD_WIN->width;
+      height = TUI_CMD_WIN->height;
     }
   else
     {
@@ -460,10 +460,10 @@ tui_set_win_focus_to (struct tui_win_info *win_info)
       struct tui_win_info *win_with_focus = tui_win_with_focus ();
 
       if (win_with_focus != NULL
-	  && win_with_focus->generic.type != CMD_WIN)
+	  && win_with_focus->type != CMD_WIN)
 	tui_unhighlight_win (win_with_focus);
       tui_set_win_with_focus (win_info);
-      if (win_info->generic.type != CMD_WIN)
+      if (win_info->type != CMD_WIN)
 	tui_highlight_win (win_info);
     }
 }
@@ -473,7 +473,7 @@ void
 tui_win_info::forward_scroll (int num_to_scroll)
 {
   if (num_to_scroll == 0)
-    num_to_scroll = generic.height - 3;
+    num_to_scroll = height - 3;
 
   do_scroll_vertical (FORWARD_SCROLL, num_to_scroll);
 }
@@ -482,7 +482,7 @@ void
 tui_win_info::backward_scroll (int num_to_scroll)
 {
   if (num_to_scroll == 0)
-    num_to_scroll = generic.height - 3;
+    num_to_scroll = height - 3;
 
   do_scroll_vertical (BACKWARD_SCROLL, num_to_scroll);
 }
@@ -528,7 +528,7 @@ tui_refresh_all_win (void)
   tui_refresh_all (tui_win_list);
   for (type = SRC_WIN; type < MAX_MAJOR_WINDOWS; type++)
     {
-      if (tui_win_list[type] && tui_win_list[type]->generic.is_visible)
+      if (tui_win_list[type] && tui_win_list[type]->is_visible)
 	tui_win_list[type]->refresh_all ();
     }
   tui_show_locator_content ();
@@ -569,7 +569,7 @@ tui_resize_all (void)
 #endif      
       /* Turn keypad off while we resize.  */
       if (win_with_focus != TUI_CMD_WIN)
-	keypad (TUI_CMD_WIN->generic.handle, FALSE);
+	keypad (TUI_CMD_WIN->handle, FALSE);
       tui_update_gdb_sizes ();
       tui_set_term_height_to (screenheight);
       tui_set_term_width_to (screenwidth);
@@ -597,57 +597,57 @@ tui_resize_all (void)
 	case SRC_COMMAND:
 	case DISASSEM_COMMAND:
 	  first_win = tui_source_windows ()[0];
-	  first_win->generic.width += width_diff;
+	  first_win->width += width_diff;
 	  locator->width += width_diff;
 	  /* Check for invalid heights.  */
 	  if (height_diff == 0)
-	    new_height = first_win->generic.height;
-	  else if ((first_win->generic.height + split_diff) >=
+	    new_height = first_win->height;
+	  else if ((first_win->height + split_diff) >=
 		   (screenheight - MIN_CMD_WIN_HEIGHT - 1))
 	    new_height = screenheight - MIN_CMD_WIN_HEIGHT - 1;
-	  else if ((first_win->generic.height + split_diff) <= 0)
+	  else if ((first_win->height + split_diff) <= 0)
 	    new_height = MIN_WIN_HEIGHT;
 	  else
-	    new_height = first_win->generic.height + split_diff;
+	    new_height = first_win->height + split_diff;
 
 	  locator->origin.y = new_height + 1;
 	  make_invisible_and_set_new_height (first_win, new_height);
-	  TUI_CMD_WIN->generic.origin.y = locator->origin.y + 1;
-	  TUI_CMD_WIN->generic.width += width_diff;
-	  new_height = screenheight - TUI_CMD_WIN->generic.origin.y;
+	  TUI_CMD_WIN->origin.y = locator->origin.y + 1;
+	  TUI_CMD_WIN->width += width_diff;
+	  new_height = screenheight - TUI_CMD_WIN->origin.y;
 	  make_invisible_and_set_new_height (TUI_CMD_WIN, new_height);
 	  make_visible_with_new_height (first_win);
 	  make_visible_with_new_height (TUI_CMD_WIN);
-	  if (first_win->generic.content_size <= 0)
+	  if (first_win->content_size <= 0)
 	    tui_erase_source_content (first_win, EMPTY_SOURCE_PROMPT);
 	  break;
 	default:
 	  if (cur_layout == SRC_DISASSEM_COMMAND)
 	    {
 	      first_win = TUI_SRC_WIN;
-	      first_win->generic.width += width_diff;
+	      first_win->width += width_diff;
 	      second_win = TUI_DISASM_WIN;
-	      second_win->generic.width += width_diff;
+	      second_win->width += width_diff;
 	    }
 	  else
 	    {
 	      first_win = TUI_DATA_WIN;
-	      first_win->generic.width += width_diff;
+	      first_win->width += width_diff;
 	      second_win = tui_source_windows ()[0];
-	      second_win->generic.width += width_diff;
+	      second_win->width += width_diff;
 	    }
 	  /* Change the first window's height/width.  */
 	  /* Check for invalid heights.  */
 	  if (height_diff == 0)
-	    new_height = first_win->generic.height;
-	  else if ((first_win->generic.height +
-		    second_win->generic.height + (split_diff * 2)) >=
+	    new_height = first_win->height;
+	  else if ((first_win->height +
+		    second_win->height + (split_diff * 2)) >=
 		   (screenheight - MIN_CMD_WIN_HEIGHT - 1))
 	    new_height = (screenheight - MIN_CMD_WIN_HEIGHT - 1) / 2;
-	  else if ((first_win->generic.height + split_diff) <= 0)
+	  else if ((first_win->height + split_diff) <= 0)
 	    new_height = MIN_WIN_HEIGHT;
 	  else
-	    new_height = first_win->generic.height + split_diff;
+	    new_height = first_win->height + split_diff;
 	  make_invisible_and_set_new_height (first_win, new_height);
 
 	  locator->width += width_diff;
@@ -655,9 +655,9 @@ tui_resize_all (void)
 	  /* Change the second window's height/width.  */
 	  /* Check for invalid heights.  */
 	  if (height_diff == 0)
-	    new_height = second_win->generic.height;
-	  else if ((first_win->generic.height +
-		    second_win->generic.height + (split_diff * 2)) >=
+	    new_height = second_win->height;
+	  else if ((first_win->height +
+		    second_win->height + (split_diff * 2)) >=
 		   (screenheight - MIN_CMD_WIN_HEIGHT - 1))
 	    {
 	      new_height = screenheight - MIN_CMD_WIN_HEIGHT - 1;
@@ -666,24 +666,24 @@ tui_resize_all (void)
 	      else
 		new_height /= 2;
 	    }
-	  else if ((second_win->generic.height + split_diff) <= 0)
+	  else if ((second_win->height + split_diff) <= 0)
 	    new_height = MIN_WIN_HEIGHT;
 	  else
-	    new_height = second_win->generic.height + split_diff;
-	  second_win->generic.origin.y = first_win->generic.height - 1;
+	    new_height = second_win->height + split_diff;
+	  second_win->origin.y = first_win->height - 1;
 	  make_invisible_and_set_new_height (second_win, new_height);
 
 	  /* Change the command window's height/width.  */
-	  TUI_CMD_WIN->generic.origin.y = locator->origin.y + 1;
+	  TUI_CMD_WIN->origin.y = locator->origin.y + 1;
 	  make_invisible_and_set_new_height (TUI_CMD_WIN,
-					     TUI_CMD_WIN->generic.height
+					     TUI_CMD_WIN->height
 					     + cmd_split_diff);
 	  make_visible_with_new_height (first_win);
 	  make_visible_with_new_height (second_win);
 	  make_visible_with_new_height (TUI_CMD_WIN);
-	  if (first_win->generic.content_size <= 0)
+	  if (first_win->content_size <= 0)
 	    tui_erase_source_content (first_win, EMPTY_SOURCE_PROMPT);
-	  if (second_win->generic.content_size <= 0)
+	  if (second_win->content_size <= 0)
 	    tui_erase_source_content (second_win, EMPTY_SOURCE_PROMPT);
 	  break;
 	}
@@ -693,7 +693,7 @@ tui_resize_all (void)
 	{
 	  if (win_type != CMD_WIN 
 	      && (tui_win_list[win_type] != NULL)
-	      && !tui_win_list[win_type]->generic.is_visible)
+	      && !tui_win_list[win_type]->is_visible)
 	    {
 	      delete tui_win_list[win_type];
 	      tui_win_list[win_type] = NULL;
@@ -702,7 +702,7 @@ tui_resize_all (void)
       /* Turn keypad back on, unless focus is in the command
 	 window.  */
       if (win_with_focus != TUI_CMD_WIN)
-	keypad (TUI_CMD_WIN->generic.handle, TRUE);
+	keypad (TUI_CMD_WIN->handle, TRUE);
     }
 }
 
@@ -856,20 +856,20 @@ tui_set_focus (const char *arg, int from_tty)
       else
 	win_info = tui_partial_win_by_name (buf_ptr);
 
-      if (win_info == NULL || !win_info->generic.is_visible)
+      if (win_info == NULL || !win_info->is_visible)
 	warning (_("Invalid window specified. \n\
 The window name specified must be valid and visible.\n"));
       else
 	{
 	  tui_set_win_focus_to (win_info);
-	  keypad (TUI_CMD_WIN->generic.handle, (win_info != TUI_CMD_WIN));
+	  keypad (TUI_CMD_WIN->handle, (win_info != TUI_CMD_WIN));
 	}
 
-      if (TUI_DATA_WIN && TUI_DATA_WIN->generic.is_visible)
+      if (TUI_DATA_WIN && TUI_DATA_WIN->is_visible)
 	TUI_DATA_WIN->refresh_all ();
       xfree (buf_ptr);
       printf_filtered (_("Focus set to %s window.\n"),
-		       tui_win_name (&tui_win_with_focus ()->generic));
+		       tui_win_name (tui_win_with_focus ()));
     }
   else
     warning (_("Incorrect Number of Arguments.\n%s"), FOCUS_USAGE);
@@ -892,16 +892,16 @@ tui_all_windows_info (const char *arg, int from_tty)
 
   for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
     if (tui_win_list[type] 
-	&& tui_win_list[type]->generic.is_visible)
+	&& tui_win_list[type]->is_visible)
       {
 	if (win_with_focus == tui_win_list[type])
 	  printf_filtered ("        %s\t(%d lines)  <has focus>\n",
-			   tui_win_name (&tui_win_list[type]->generic),
-			   tui_win_list[type]->generic.height);
+			   tui_win_name (tui_win_list[type]),
+			   tui_win_list[type]->height);
 	else
 	  printf_filtered ("        %s\t(%d lines)\n",
-			   tui_win_name (&tui_win_list[type]->generic),
-			   tui_win_list[type]->generic.height);
+			   tui_win_name (tui_win_list[type]),
+			   tui_win_list[type]->height);
       }
 }
 
@@ -934,17 +934,17 @@ update_tab_width ()
      and redisplay of the window's contents, which will take
      the new tab width into account.  */
   if (tui_win_list[SRC_WIN]
-      && tui_win_list[SRC_WIN]->generic.is_visible)
+      && tui_win_list[SRC_WIN]->is_visible)
     {
       make_invisible_and_set_new_height (TUI_SRC_WIN,
-					 TUI_SRC_WIN->generic.height);
+					 TUI_SRC_WIN->height);
       make_visible_with_new_height (TUI_SRC_WIN);
     }
   if (tui_win_list[DISASSEM_WIN]
-      && tui_win_list[DISASSEM_WIN]->generic.is_visible)
+      && tui_win_list[DISASSEM_WIN]->is_visible)
     {
       make_invisible_and_set_new_height (TUI_DISASM_WIN,
-					 TUI_DISASM_WIN->generic.height);
+					 TUI_DISASM_WIN->height);
       make_visible_with_new_height (TUI_DISASM_WIN);
     }
 }
@@ -1025,7 +1025,7 @@ tui_set_win_height (const char *arg, int from_tty)
 	    wname[i] = tolower (wname[i]);
 	  win_info = tui_partial_win_by_name (wname);
 
-	  if (win_info == NULL || !win_info->generic.is_visible)
+	  if (win_info == NULL || !win_info->is_visible)
 	    warning (_("Invalid window specified. \n\
 The window name specified must be valid and visible.\n"));
 	  else
@@ -1055,7 +1055,7 @@ The window name specified must be valid and visible.\n"));
 		      if (fixed_size)
 			new_height = input_no;
 		      else
-			new_height = win_info->generic.height + input_no;
+			new_height = win_info->height + input_no;
 
 		      /* Now change the window's height, and adjust
 		         all other windows around it.  */
@@ -1098,21 +1098,21 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
   if (new_height_ok (primary_win_info, new_height))
     {
       status = TUI_SUCCESS;
-      if (new_height != primary_win_info->generic.height)
+      if (new_height != primary_win_info->height)
 	{
 	  int diff;
 	  struct tui_win_info *win_info;
 	  struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
 	  enum tui_layout_type cur_layout = tui_current_layout ();
 
-	  diff = (new_height - primary_win_info->generic.height) * (-1);
+	  diff = (new_height - primary_win_info->height) * (-1);
 	  if (cur_layout == SRC_COMMAND 
 	      || cur_layout == DISASSEM_COMMAND)
 	    {
 	      struct tui_win_info *src_win_info;
 
 	      make_invisible_and_set_new_height (primary_win_info, new_height);
-	      if (primary_win_info->generic.type == CMD_WIN)
+	      if (primary_win_info->type == CMD_WIN)
 		{
 		  win_info = tui_source_windows ()[0];
 		  src_win_info = win_info;
@@ -1123,11 +1123,11 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 		  src_win_info = primary_win_info;
 		}
 	      make_invisible_and_set_new_height (win_info,
-					     win_info->generic.height + diff);
-	      TUI_CMD_WIN->generic.origin.y = locator->origin.y + 1;
+					     win_info->height + diff);
+	      TUI_CMD_WIN->origin.y = locator->origin.y + 1;
 	      make_visible_with_new_height (win_info);
 	      make_visible_with_new_height (primary_win_info);
-	      if (src_win_info->generic.content_size <= 0)
+	      if (src_win_info->content_size <= 0)
 		tui_erase_source_content (src_win_info, EMPTY_SOURCE_PROMPT);
 	    }
 	  else
@@ -1154,8 +1154,8 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 
 		  if (diff % 2)
 		    {
-		      if (first_win->generic.height >
-			  second_win->generic.height)
+		      if (first_win->height >
+			  second_win->height)
 			if (diff < 0)
 			  first_split_diff--;
 			else
@@ -1170,42 +1170,42 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 		    }
 		  /* Make sure that the minimum hieghts are
 		     honored.  */
-		  while ((first_win->generic.height + first_split_diff) < 3)
+		  while ((first_win->height + first_split_diff) < 3)
 		    {
 		      first_split_diff++;
 		      second_split_diff--;
 		    }
-		  while ((second_win->generic.height + second_split_diff) < 3)
+		  while ((second_win->height + second_split_diff) < 3)
 		    {
 		      second_split_diff++;
 		      first_split_diff--;
 		    }
 		  make_invisible_and_set_new_height (
 						  first_win,
-				 first_win->generic.height + first_split_diff);
-		  second_win->generic.origin.y = first_win->generic.height - 1;
+				 first_win->height + first_split_diff);
+		  second_win->origin.y = first_win->height - 1;
 		  make_invisible_and_set_new_height (second_win,
-						     second_win->generic.height
+						     second_win->height
 						     + second_split_diff);
-		  TUI_CMD_WIN->generic.origin.y = locator->origin.y + 1;
+		  TUI_CMD_WIN->origin.y = locator->origin.y + 1;
 		  make_invisible_and_set_new_height (TUI_CMD_WIN, new_height);
 		}
 	      else
 		{
-		  if ((TUI_CMD_WIN->generic.height + diff) < 1)
+		  if ((TUI_CMD_WIN->height + diff) < 1)
 		    { /* If there is no way to increase the command
 			 window take real estate from the 1st or 2nd
 			 window.  */
-		      if ((TUI_CMD_WIN->generic.height + diff) < 1)
+		      if ((TUI_CMD_WIN->height + diff) < 1)
 			{
 			  int i;
 
-			  for (i = TUI_CMD_WIN->generic.height + diff;
+			  for (i = TUI_CMD_WIN->height + diff;
 			       (i < 1); i++)
 			    if (primary_win_info == first_win)
-			      second_win->generic.height--;
+			      second_win->height--;
 			    else
-			      first_win->generic.height--;
+			      first_win->height--;
 			}
 		    }
 		  if (primary_win_info == first_win)
@@ -1213,26 +1213,26 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 		  else
 		    make_invisible_and_set_new_height (
 						    first_win,
-						  first_win->generic.height);
-		  second_win->generic.origin.y = first_win->generic.height - 1;
+						  first_win->height);
+		  second_win->origin.y = first_win->height - 1;
 		  if (primary_win_info == second_win)
 		    make_invisible_and_set_new_height (second_win, new_height);
 		  else
 		    make_invisible_and_set_new_height (
-				      second_win, second_win->generic.height);
-		  TUI_CMD_WIN->generic.origin.y = locator->origin.y + 1;
-		  if ((TUI_CMD_WIN->generic.height + diff) < 1)
+				      second_win, second_win->height);
+		  TUI_CMD_WIN->origin.y = locator->origin.y + 1;
+		  if ((TUI_CMD_WIN->height + diff) < 1)
 		    make_invisible_and_set_new_height (TUI_CMD_WIN, 1);
 		  else
 		    make_invisible_and_set_new_height (TUI_CMD_WIN,
-						       TUI_CMD_WIN->generic.height + diff);
+						       TUI_CMD_WIN->height + diff);
 		}
 	      make_visible_with_new_height (TUI_CMD_WIN);
 	      make_visible_with_new_height (second_win);
 	      make_visible_with_new_height (first_win);
-	      if (first_win->generic.content_size <= 0)
+	      if (first_win->content_size <= 0)
 		tui_erase_source_content (first_win, EMPTY_SOURCE_PROMPT);
-	      if (second_win->generic.content_size <= 0)
+	      if (second_win->content_size <= 0)
 		tui_erase_source_content (second_win, EMPTY_SOURCE_PROMPT);
 	    }
 	}
@@ -1249,7 +1249,7 @@ tui_source_window_base::set_new_height (int height)
 {
   tui_make_invisible (execution_info);
   execution_info->height = height;
-  execution_info->origin.y = generic.origin.y;
+  execution_info->origin.y = origin.y;
   if (height > 1)
     execution_info->viewport_height = height - 1;
   else
@@ -1260,7 +1260,7 @@ tui_source_window_base::set_new_height (int height)
     {
       tui_gen_win_info *gen_win_info = tui_locator_win_info_ptr ();
       tui_make_invisible (gen_win_info);
-      gen_win_info->origin.y = generic.origin.y + height;
+      gen_win_info->origin.y = origin.y + height;
     }
 }
 
@@ -1270,10 +1270,10 @@ void
 tui_data_window::set_new_height (int height)
 {
   /* Delete all data item windows.  */
-  for (int i = 0; i < generic.content_size; i++)
+  for (int i = 0; i < content_size; i++)
     {
       struct tui_gen_win_info *gen_win_info
-	= generic.content[i]->which_element.data_window;
+	= content[i]->which_element.data_window;
       tui_delete_win (gen_win_info->handle);
       gen_win_info->handle = NULL;
     }
@@ -1286,14 +1286,14 @@ static void
 make_invisible_and_set_new_height (struct tui_win_info *win_info, 
 				   int height)
 {
-  tui_make_invisible (&win_info->generic);
-  win_info->generic.height = height;
+  tui_make_invisible (win_info);
+  win_info->height = height;
   if (height > 1)
-    win_info->generic.viewport_height = height - 1;
+    win_info->viewport_height = height - 1;
   else
-    win_info->generic.viewport_height = height;
+    win_info->viewport_height = height;
   if (win_info != TUI_CMD_WIN)
-    win_info->generic.viewport_height--;
+    win_info->viewport_height--;
 
   /* Now deal with the auxillary windows associated with win_info.  */
   win_info->set_new_height (height);
@@ -1308,17 +1308,17 @@ make_visible_with_new_height (struct tui_win_info *win_info)
 {
   struct symtab *s;
 
-  tui_make_visible (&win_info->generic);
+  tui_make_visible (win_info);
   tui_check_and_display_highlight_if_needed (win_info);
   tui_source_window_base *base;
-  switch (win_info->generic.type)
+  switch (win_info->type)
     {
     case SRC_WIN:
     case DISASSEM_WIN:
       base = (tui_source_window_base *) win_info;
       tui_free_win_content (base->execution_info);
       tui_make_visible (base->execution_info);
-      if (win_info->generic.content != NULL)
+      if (win_info->content != NULL)
 	{
 	  struct gdbarch *gdbarch = base->gdbarch;
 	  struct tui_line_or_address line_or_addr;
@@ -1326,7 +1326,7 @@ make_visible_with_new_height (struct tui_win_info *win_info)
 	    = get_current_source_symtab_and_line ();
 
 	  line_or_addr = base->start_line_or_addr;
-	  tui_free_win_content (&win_info->generic);
+	  tui_free_win_content (win_info);
 	  tui_update_source_window (win_info, gdbarch,
 				    cursal.symtab, line_or_addr, TRUE);
 	}
@@ -1339,7 +1339,7 @@ make_visible_with_new_height (struct tui_win_info *win_info)
 	  struct gdbarch *gdbarch = get_frame_arch (frame);
 
 	  s = find_pc_line_symtab (get_frame_pc (frame));
-	  if (win_info->generic.type == SRC_WIN)
+	  if (win_info->type == SRC_WIN)
 	    {
 	      line.loa = LOA_LINE;
 	      line.u.line_no = cursal.line;
@@ -1362,14 +1362,14 @@ make_visible_with_new_height (struct tui_win_info *win_info)
       break;
     case CMD_WIN:
 #ifdef HAVE_WRESIZE
-      wresize (TUI_CMD_WIN->generic.handle,
-	       TUI_CMD_WIN->generic.height,
-	       TUI_CMD_WIN->generic.width);
+      wresize (TUI_CMD_WIN->handle,
+	       TUI_CMD_WIN->height,
+	       TUI_CMD_WIN->width);
 #endif
-      mvwin (TUI_CMD_WIN->generic.handle,
-	     TUI_CMD_WIN->generic.origin.y,
-	     TUI_CMD_WIN->generic.origin.x);
-      wmove (win_info->generic.handle, 0, 0);
+      mvwin (TUI_CMD_WIN->handle,
+	     TUI_CMD_WIN->origin.y,
+	     TUI_CMD_WIN->origin.x);
+      wmove (win_info->handle, 0, 0);
       break;
     default:
       break;
@@ -1404,7 +1404,7 @@ new_height_ok (struct tui_win_info *primary_win_info,
       int diff;
       enum tui_layout_type cur_layout = tui_current_layout ();
 
-      diff = (new_height - primary_win_info->generic.height) * (-1);
+      diff = (new_height - primary_win_info->height) * (-1);
       if (cur_layout == SRC_COMMAND || cur_layout == DISASSEM_COMMAND)
 	{
 	  ok = (new_height <= primary_win_info->max_height ()
@@ -1418,7 +1418,7 @@ new_height_ok (struct tui_win_info *primary_win_info,
 	      else
 		win_info = TUI_CMD_WIN;
 	      ok = ((new_height +
-		     (win_info->generic.height + diff)) <= tui_term_height ());
+		     (win_info->height + diff)) <= tui_term_height ());
 	    }
 	}
       else
@@ -1442,20 +1442,20 @@ new_height_ok (struct tui_win_info *primary_win_info,
 	     the line that the first and second windows share, and add
 	     one for the locator.  */
 	  total_height = cur_total_height =
-	    (first_win->generic.height + second_win->generic.height - 1)
-	    + TUI_CMD_WIN->generic.height + 1;	/* Locator. */
+	    (first_win->height + second_win->height - 1)
+	    + TUI_CMD_WIN->height + 1;	/* Locator. */
 	  if (primary_win_info == TUI_CMD_WIN)
 	    {
 	      /* Locator included since first & second win share a line.  */
-	      ok = ((first_win->generic.height +
-		     second_win->generic.height + diff) >=
+	      ok = ((first_win->height +
+		     second_win->height + diff) >=
 		    (MIN_WIN_HEIGHT * 2) 
 		    && new_height >= MIN_CMD_WIN_HEIGHT);
 	      if (ok)
 		{
 		  total_height = new_height + 
-		    (first_win->generic.height +
-		     second_win->generic.height + diff);
+		    (first_win->height +
+		     second_win->height + diff);
 		  min_height = MIN_CMD_WIN_HEIGHT;
 		}
 	    }
@@ -1466,25 +1466,25 @@ new_height_ok (struct tui_win_info *primary_win_info,
 	      /* First see if we can increase/decrease the command
 	         window.  And make sure that the command window is at
 	         least 1 line.  */
-	      ok = ((TUI_CMD_WIN->generic.height + diff) > 0);
+	      ok = ((TUI_CMD_WIN->height + diff) > 0);
 	      if (!ok)
 		{ /* Looks like we have to increase/decrease one of
 		     the other windows.  */
 		  if (primary_win_info == first_win)
-		    ok = (second_win->generic.height + diff) >= min_height;
+		    ok = (second_win->height + diff) >= min_height;
 		  else
-		    ok = (first_win->generic.height + diff) >= min_height;
+		    ok = (first_win->height + diff) >= min_height;
 		}
 	      if (ok)
 		{
 		  if (primary_win_info == first_win)
 		    total_height = new_height +
-		      second_win->generic.height +
-		      TUI_CMD_WIN->generic.height + diff;
+		      second_win->height +
+		      TUI_CMD_WIN->height + diff;
 		  else
 		    total_height = new_height +
-		      first_win->generic.height +
-		      TUI_CMD_WIN->generic.height + diff;
+		      first_win->height +
+		      TUI_CMD_WIN->height + diff;
 		}
 	    }
 	  /* Now make sure that the proposed total height doesn't
@@ -1557,7 +1557,7 @@ parse_scrolling_args (const char *arg,
 	  *win_to_scroll = tui_partial_win_by_name (wname);
 
 	  if (*win_to_scroll == NULL
-	      || !(*win_to_scroll)->generic.is_visible)
+	      || !(*win_to_scroll)->is_visible)
 	    error (_("Invalid window specified. \n\
 The window name specified must be valid and visible.\n"));
 	  else if (*win_to_scroll == TUI_CMD_WIN)
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index 1647527e240..739272a5d03 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -48,13 +48,13 @@ tui_first_data_item_displayed (void)
   int i;
 
   for (i = 0; 
-       i < TUI_DATA_WIN->generic.content_size && element_no < 0;
+       i < TUI_DATA_WIN->content_size && element_no < 0;
        i++)
     {
       struct tui_gen_win_info *data_item_win;
 
       data_item_win
-	= TUI_DATA_WIN->generic.content[i]->which_element.data_window;
+	= TUI_DATA_WIN->content[i]->which_element.data_window;
       if (data_item_win->handle != NULL
 	  && data_item_win->is_visible)
 	element_no = i;
@@ -72,10 +72,10 @@ tui_delete_data_content_windows (void)
   int i;
   struct tui_gen_win_info *data_item_win_ptr;
 
-  for (i = 0; (i < TUI_DATA_WIN->generic.content_size); i++)
+  for (i = 0; (i < TUI_DATA_WIN->content_size); i++)
     {
       data_item_win_ptr
-	= TUI_DATA_WIN->generic.content[i]->which_element.data_window;
+	= TUI_DATA_WIN->content[i]->which_element.data_window;
       tui_delete_win (data_item_win_ptr->handle);
       data_item_win_ptr->handle = NULL;
       data_item_win_ptr->is_visible = false;
@@ -86,23 +86,23 @@ tui_delete_data_content_windows (void)
 void
 tui_erase_data_content (const char *prompt)
 {
-  werase (TUI_DATA_WIN->generic.handle);
+  werase (TUI_DATA_WIN->handle);
   tui_check_and_display_highlight_if_needed (TUI_DATA_WIN);
   if (prompt != NULL)
     {
-      int half_width = (TUI_DATA_WIN->generic.width - 2) / 2;
+      int half_width = (TUI_DATA_WIN->width - 2) / 2;
       int x_pos;
 
       if (strlen (prompt) >= half_width)
 	x_pos = 1;
       else
 	x_pos = half_width - strlen (prompt);
-      mvwaddstr (TUI_DATA_WIN->generic.handle,
-		 (TUI_DATA_WIN->generic.height / 2),
+      mvwaddstr (TUI_DATA_WIN->handle,
+		 (TUI_DATA_WIN->height / 2),
 		 x_pos,
 		 (char *) prompt);
     }
-  wrefresh (TUI_DATA_WIN->generic.handle);
+  wrefresh (TUI_DATA_WIN->handle);
 }
 
 
@@ -111,7 +111,7 @@ tui_erase_data_content (const char *prompt)
 void
 tui_display_all_data (void)
 {
-  if (TUI_DATA_WIN->generic.content_size <= 0)
+  if (TUI_DATA_WIN->content_size <= 0)
     tui_erase_data_content (NO_DATA_STRING);
   else
     {
@@ -196,7 +196,7 @@ void
 tui_data_window::refresh_all ()
 {
   tui_erase_data_content (NULL);
-  if (generic.content_size > 0)
+  if (content_size > 0)
     {
       int first_element = tui_first_data_item_displayed ();
 
@@ -214,7 +214,7 @@ tui_check_data_values (struct frame_info *frame)
   tui_check_register_values (frame);
 
   /* Now check any other data values that there are.  */
-  if (TUI_DATA_WIN != NULL && TUI_DATA_WIN->generic.is_visible)
+  if (TUI_DATA_WIN != NULL && TUI_DATA_WIN->is_visible)
     {
       int i;
 
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index ccee399057a..06d7ad5a030 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -110,10 +110,10 @@ void
 tui_unhighlight_win (struct tui_win_info *win_info)
 {
   if (win_info != NULL 
-      && win_info->generic.handle != NULL)
+      && win_info->handle != NULL)
     {
-      box_win (&win_info->generic, NO_HILITE);
-      wrefresh (win_info->generic.handle);
+      box_win (win_info, NO_HILITE);
+      wrefresh (win_info->handle);
       win_info->set_highlight (false);
     }
 }
@@ -124,10 +124,10 @@ tui_highlight_win (struct tui_win_info *win_info)
 {
   if (win_info != NULL
       && win_info->can_highlight
-      && win_info->generic.handle != NULL)
+      && win_info->handle != NULL)
     {
-      box_win (&win_info->generic, HILITE);
-      wrefresh (win_info->generic.handle);
+      box_win (win_info, HILITE);
+      wrefresh (win_info->handle);
       win_info->set_highlight (true);
     }
 }
@@ -135,7 +135,7 @@ tui_highlight_win (struct tui_win_info *win_info)
 void
 tui_check_and_display_highlight_if_needed (struct tui_win_info *win_info)
 {
-  if (win_info != NULL && win_info->generic.type != CMD_WIN)
+  if (win_info != NULL && win_info->type != CMD_WIN)
     {
       if (win_info->is_highlighted)
 	tui_highlight_win (win_info);
@@ -214,7 +214,7 @@ tui_make_invisible (struct tui_gen_win_info *win_info)
 void
 tui_win_info::make_visible (bool visible)
 {
-  ::make_visible (&generic, visible);
+  ::make_visible (this, visible);
 }
 
 /* See tui-data.h.  */
@@ -259,8 +259,8 @@ tui_make_all_invisible (void)
 void
 tui_win_info::refresh ()
 {
-  touchwin (generic.handle);
-  tui_refresh_win (&generic);
+  touchwin (handle);
+  tui_refresh_win (this);
 }
 
 /* See tui-data.h.  */
@@ -283,7 +283,7 @@ tui_refresh_all (struct tui_win_info **list)
 
   for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
     {
-      if (list[type] && list[type]->generic.is_visible)
+      if (list[type] && list[type]->is_visible)
 	list[type]->refresh ();
     }
   if (locator->is_visible)
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 5946db75aaf..f63526bb446 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -94,7 +94,7 @@ tui_update_source_window_as_is (struct tui_win_info *win_info,
 {
   enum tui_status ret;
 
-  if (win_info->generic.type == SRC_WIN)
+  if (win_info->type == SRC_WIN)
     ret = tui_set_source_content (s, line_or_addr.u.line_no, noerror);
   else
     ret = tui_set_disassem_content (gdbarch, line_or_addr.u.addr);
@@ -109,12 +109,12 @@ tui_update_source_window_as_is (struct tui_win_info *win_info,
       tui_update_breakpoint_info (win_info, 0);
       tui_show_source_content (win_info);
       tui_update_exec_info (win_info);
-      if (win_info->generic.type == SRC_WIN)
+      if (win_info->type == SRC_WIN)
 	{
 	  symtab_and_line sal;
 
 	  sal.line = line_or_addr.u.line_no +
-	    (win_info->generic.content_size - 2);
+	    (win_info->content_size - 2);
 	  sal.symtab = s;
 	  sal.pspace = SYMTAB_PSPACE (s);
 	  set_current_source_symtab_and_line (sal);
@@ -212,11 +212,11 @@ tui_clear_source_content (struct tui_win_info *win_info,
     {
       int i;
 
-      win_info->generic.content_in_use = FALSE;
+      win_info->content_in_use = FALSE;
       tui_erase_source_content (win_info, display_prompt);
-      for (i = 0; i < win_info->generic.content_size; i++)
+      for (i = 0; i < win_info->content_size; i++)
 	{
-	  struct tui_win_element *element = win_info->generic.content[i];
+	  struct tui_win_element *element = win_info->content[i];
 
 	  element->which_element.source.has_break = FALSE;
 	  element->which_element.source.is_exec_point = FALSE;
@@ -230,17 +230,17 @@ tui_erase_source_content (struct tui_win_info *win_info,
 			  int display_prompt)
 {
   int x_pos;
-  int half_width = (win_info->generic.width - 2) / 2;
+  int half_width = (win_info->width - 2) / 2;
 
-  if (win_info->generic.handle != NULL)
+  if (win_info->handle != NULL)
     {
-      werase (win_info->generic.handle);
+      werase (win_info->handle);
       tui_check_and_display_highlight_if_needed (win_info);
       if (display_prompt == EMPTY_SOURCE_PROMPT)
 	{
 	  const char *no_src_str;
 
-	  if (win_info->generic.type == SRC_WIN)
+	  if (win_info->type == SRC_WIN)
 	    no_src_str = NO_SRC_STRING;
 	  else
 	    no_src_str = NO_DISASSEM_STRING;
@@ -248,8 +248,8 @@ tui_erase_source_content (struct tui_win_info *win_info,
 	    x_pos = 1;
 	  else
 	    x_pos = half_width - strlen (no_src_str);
-	  mvwaddstr (win_info->generic.handle,
-		     (win_info->generic.height / 2),
+	  mvwaddstr (win_info->handle,
+		     (win_info->height / 2),
 		     x_pos,
 		     (char *) no_src_str);
 
@@ -260,7 +260,7 @@ tui_erase_source_content (struct tui_win_info *win_info,
 
 	  tui_set_source_content_nil (win_info, no_src_str);
 	}
-      tui_refresh_win (&win_info->generic);
+      tui_refresh_win (win_info);
     }
 }
 
@@ -272,41 +272,41 @@ tui_show_source_line (struct tui_win_info *win_info, int lineno)
   struct tui_win_element *line;
   int x;
 
-  line = win_info->generic.content[lineno - 1];
+  line = win_info->content[lineno - 1];
   if (line->which_element.source.is_exec_point)
-    tui_set_reverse_mode (win_info->generic.handle, true);
+    tui_set_reverse_mode (win_info->handle, true);
 
-  wmove (win_info->generic.handle, lineno, 1);
+  wmove (win_info->handle, lineno, 1);
   tui_puts (line->which_element.source.line,
-	    win_info->generic.handle);
+	    win_info->handle);
   if (line->which_element.source.is_exec_point)
-    tui_set_reverse_mode (win_info->generic.handle, false);
+    tui_set_reverse_mode (win_info->handle, false);
 
   /* Clear to end of line but stop before the border.  */
-  x = getcurx (win_info->generic.handle);
-  while (x + 1 < win_info->generic.width)
+  x = getcurx (win_info->handle);
+  while (x + 1 < win_info->width)
     {
-      waddch (win_info->generic.handle, ' ');
-      x = getcurx (win_info->generic.handle);
+      waddch (win_info->handle, ' ');
+      x = getcurx (win_info->handle);
     }
 }
 
 void
 tui_show_source_content (struct tui_win_info *win_info)
 {
-  if (win_info->generic.content_size > 0)
+  if (win_info->content_size > 0)
     {
       int lineno;
 
-      for (lineno = 1; lineno <= win_info->generic.content_size; lineno++)
+      for (lineno = 1; lineno <= win_info->content_size; lineno++)
         tui_show_source_line (win_info, lineno);
     }
   else
     tui_erase_source_content (win_info, TRUE);
 
   tui_check_and_display_highlight_if_needed (win_info);
-  tui_refresh_win (&win_info->generic);
-  win_info->generic.content_in_use = TRUE;
+  tui_refresh_win (win_info);
+  win_info->content_in_use = TRUE;
 }
 
 /* See tui-data.h.  */
@@ -316,7 +316,7 @@ tui_source_window_base::refill ()
 {
   symtab *s = nullptr;
 
-  if (generic.type == SRC_WIN)
+  if (type == SRC_WIN)
     {
       symtab_and_line cursal = get_current_source_symtab_and_line ();
       s = (cursal.symtab == NULL
@@ -325,7 +325,7 @@ tui_source_window_base::refill ()
     }
 
   tui_update_source_window_as_is (this, gdbarch, s,
-				  generic.content[0]
+				  content[0]
 				    ->which_element.source.line_or_addr,
 				  FALSE);
 }
@@ -336,7 +336,7 @@ void
 tui_source_window_base::do_scroll_horizontal
   (enum tui_scroll_direction direction, int num_to_scroll)
 {
-  if (generic.content != NULL)
+  if (content != NULL)
     {
       int offset;
 
@@ -362,10 +362,9 @@ tui_source_window_base::set_is_exec_point_at (struct tui_line_or_address l)
 {
   int changed = 0;
   int i;
-  tui_win_content content = generic.content;
 
   i = 0;
-  while (i < generic.content_size)
+  while (i < content_size)
     {
       int new_state;
       struct tui_line_or_address content_loa =
@@ -422,14 +421,14 @@ tui_update_breakpoint_info (struct tui_win_info *win,
   int need_refresh = 0;
   tui_source_window_base *src = (tui_source_window_base *) win;
 
-  for (i = 0; i < win->generic.content_size; i++)
+  for (i = 0; i < win->content_size; i++)
     {
       struct breakpoint *bp;
       extern struct breakpoint *breakpoint_chain;
       int mode;
       struct tui_source_element *line;
 
-      line = &win->generic.content[i]->which_element.source;
+      line = &win->content[i]->which_element.source;
       if (current_only && !line->is_exec_point)
          continue;
 
@@ -496,20 +495,20 @@ tui_set_exec_info_content (struct tui_win_info *win_info)
 
       if (exec_info_ptr->content == NULL)
 	exec_info_ptr->content =
-	  tui_alloc_content (win_info->generic.height, exec_info_ptr->type);
+	  tui_alloc_content (win_info->height, exec_info_ptr->type);
       if (exec_info_ptr->content != NULL)
 	{
 	  int i;
 
           tui_update_breakpoint_info (win_info, 1);
-	  for (i = 0; i < win_info->generic.content_size; i++)
+	  for (i = 0; i < win_info->content_size; i++)
 	    {
 	      struct tui_win_element *element;
 	      struct tui_win_element *src_element;
               int mode;
 
 	      element = exec_info_ptr->content[i];
-	      src_element = win_info->generic.content[i];
+	      src_element = win_info->content[i];
 
               memset(element->which_element.simple_string, ' ',
                      sizeof(element->which_element.simple_string));
@@ -533,7 +532,7 @@ tui_set_exec_info_content (struct tui_win_info *win_info)
               if (src_element->which_element.source.is_exec_point)
                 element->which_element.simple_string[TUI_EXEC_POS] = '>';
 	    }
-	  exec_info_ptr->content_size = win_info->generic.content_size;
+	  exec_info_ptr->content_size = win_info->content_size;
 	}
       else
 	ret = TUI_FAILURE;
@@ -598,16 +597,16 @@ tui_alloc_source_buffer (struct tui_win_info *win_info)
 
   /* The window width/height includes the highlight box.  Determine actual
      content dimensions, including string null-terminators.  */
-  max_lines = win_info->generic.height - 2;
-  line_width = win_info->generic.width - 2 + 1;
+  max_lines = win_info->height - 2;
+  line_width = win_info->width - 2 + 1;
 
   /* Allocate the buffer for the source lines.  */
-  if (win_info->generic.content == NULL)
+  if (win_info->content == NULL)
     {
       /* Allocate the content list.  */
-      win_info->generic.content = tui_alloc_content (max_lines, SRC_WIN);
+      win_info->content = tui_alloc_content (max_lines, SRC_WIN);
       for (i = 0; i < max_lines; i++)
-	win_info->generic.content[i]->which_element.source.line
+	win_info->content[i]->which_element.source.line
 	  = (char *) xmalloc (line_width);
     }
 
@@ -630,13 +629,13 @@ tui_line_is_displayed (int line,
   else
     threshold = 0;
   i = 0;
-  while (i < win_info->generic.content_size - threshold
+  while (i < win_info->content_size - threshold
 	 && !is_displayed)
     {
       is_displayed
-	= win_info->generic.content[i]
+	= win_info->content[i]
 	    ->which_element.source.line_or_addr.loa == LOA_LINE
-	  && win_info->generic.content[i]
+	  && win_info->content[i]
 	       ->which_element.source.line_or_addr.u.line_no == line;
       i++;
     }
@@ -660,13 +659,13 @@ tui_addr_is_displayed (CORE_ADDR addr,
   else
     threshold = 0;
   i = 0;
-  while (i < win_info->generic.content_size - threshold
+  while (i < win_info->content_size - threshold
 	 && !is_displayed)
     {
       is_displayed
-	= win_info->generic.content[i]
+	= win_info->content[i]
 	    ->which_element.source.line_or_addr.loa == LOA_ADDRESS
-	  && win_info->generic.content[i]
+	  && win_info->content[i]
 	       ->which_element.source.line_or_addr.u.addr == addr;
       i++;
     }
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index 55a44e8840e..693c2ff4a03 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -236,9 +236,9 @@ tui_rl_other_window (int count, int key)
   if (win_info)
     {
       tui_set_win_focus_to (win_info);
-      if (TUI_DATA_WIN && TUI_DATA_WIN->generic.is_visible)
+      if (TUI_DATA_WIN && TUI_DATA_WIN->is_visible)
 	TUI_DATA_WIN->refresh_all ();
-      keypad (TUI_CMD_WIN->generic.handle, (win_info != TUI_CMD_WIN));
+      keypad (TUI_CMD_WIN->handle, (win_info != TUI_CMD_WIN));
     }
   return 0;
 }
@@ -476,8 +476,8 @@ tui_enable (void)
       tui_show_frame_info (0);
       tui_set_layout (SRC_COMMAND);
       tui_set_win_focus_to (TUI_SRC_WIN);
-      keypad (TUI_CMD_WIN->generic.handle, TRUE);
-      wrefresh (TUI_CMD_WIN->generic.handle);
+      keypad (TUI_CMD_WIN->handle, TRUE);
+      wrefresh (TUI_CMD_WIN->handle);
       tui_finish_init = 0;
     }
   else
@@ -664,7 +664,7 @@ tui_is_window_visible (enum tui_win_type type)
   if (tui_win_list[type] == 0)
     return false;
   
-  return tui_win_list[type]->generic.is_visible;
+  return tui_win_list[type]->is_visible;
 }
 
 int
@@ -676,8 +676,8 @@ tui_get_command_dimension (unsigned int *width,
       return 0;
     }
   
-  *width = TUI_CMD_WIN->generic.width;
-  *height = TUI_CMD_WIN->generic.height;
+  *width = TUI_CMD_WIN->width;
+  *height = TUI_CMD_WIN->height;
   return 1;
 }
 
-- 
2.17.2

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

* [PATCH 39/66] Change more TUI functions to take a tui_source_window_base
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (37 preceding siblings ...)
  2019-06-23 23:26 ` [PATCH 48/66] Remove tui_alloc_win_info Tom Tromey
@ 2019-06-23 23:26 ` Tom Tromey
  2019-06-23 23:26 ` [PATCH 38/66] Change tui_set_exec_info_content to return void Tom Tromey
                   ` (11 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Several more TUI functions should only be called with a source or
disassembly window.  This patch changes these functions so that this
can be caught at compile time.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_set_exec_info_content)
	(tui_show_exec_info_content, tui_erase_exec_info_content)
	(tui_clear_exec_info_content, tui_update_exec_info): Change
	argument to tui_source_window_base.
	* tui/tui-winsource.c (tui_set_exec_info_content)
	(tui_show_exec_info_content, tui_erase_exec_info_content)
	(tui_clear_exec_info_content, tui_update_exec_info): Change
	argument to tui_source_window_base.
---
 gdb/ChangeLog           | 11 +++++++++++
 gdb/tui/tui-winsource.c | 26 ++++++++++----------------
 gdb/tui/tui-winsource.h | 10 +++++-----
 3 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 2de5c53214e..e55ce40a206 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -483,12 +483,11 @@ tui_update_breakpoint_info (struct tui_win_info *win,
    based upon the input window which is either the source or
    disassembly window.  */
 void
-tui_set_exec_info_content (struct tui_win_info *win_info)
+tui_set_exec_info_content (struct tui_source_window_base *win_info)
 {
-  tui_source_window_base *base = (tui_source_window_base *) win_info;
-  if (base->execution_info != NULL)
+  if (win_info->execution_info != NULL)
     {
-      struct tui_gen_win_info *exec_info_ptr = base->execution_info;
+      struct tui_gen_win_info *exec_info_ptr = win_info->execution_info;
 
       if (exec_info_ptr->content == NULL)
 	exec_info_ptr->content =
@@ -532,10 +531,9 @@ tui_set_exec_info_content (struct tui_win_info *win_info)
 
 
 void
-tui_show_exec_info_content (struct tui_win_info *win_info)
+tui_show_exec_info_content (struct tui_source_window_base *win_info)
 {
-  tui_source_window_base *base = (tui_source_window_base *) win_info;
-  struct tui_gen_win_info *exec_info = base->execution_info;
+  struct tui_gen_win_info *exec_info = win_info->execution_info;
   int cur_line;
 
   werase (exec_info->handle);
@@ -552,28 +550,24 @@ tui_show_exec_info_content (struct tui_win_info *win_info)
 
 
 void
-tui_erase_exec_info_content (struct tui_win_info *win_info)
+tui_erase_exec_info_content (struct tui_source_window_base *win_info)
 {
-  tui_source_window_base *base = (tui_source_window_base *) win_info;
-  struct tui_gen_win_info *exec_info = base->execution_info;
+  struct tui_gen_win_info *exec_info = win_info->execution_info;
 
   werase (exec_info->handle);
   exec_info->refresh_window ();
 }
 
 void
-tui_clear_exec_info_content (struct tui_win_info *win_info)
+tui_clear_exec_info_content (struct tui_source_window_base *win_info)
 {
-  tui_source_window_base *base = (tui_source_window_base *) win_info;
-  base->execution_info->content_in_use = FALSE;
+  win_info->execution_info->content_in_use = FALSE;
   tui_erase_exec_info_content (win_info);
-
-  return;
 }
 
 /* Function to update the execution info window.  */
 void
-tui_update_exec_info (struct tui_win_info *win_info)
+tui_update_exec_info (struct tui_source_window_base *win_info)
 {
   tui_set_exec_info_content (win_info);
   tui_show_exec_info_content (win_info);
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 3ed461a3157..09a9d5abf4a 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -53,11 +53,11 @@ extern void tui_update_source_windows_with_line (struct symtab *,
 extern void tui_clear_source_content (struct tui_win_info *, int);
 extern void tui_erase_source_content (struct tui_win_info *, int);
 extern void tui_show_source_content (struct tui_win_info *);
-extern void tui_set_exec_info_content (struct tui_win_info *);
-extern void tui_show_exec_info_content (struct tui_win_info *);
-extern void tui_erase_exec_info_content (struct tui_win_info *);
-extern void tui_clear_exec_info_content (struct tui_win_info *);
-extern void tui_update_exec_info (struct tui_win_info *);
+extern void tui_set_exec_info_content (struct tui_source_window_base *);
+extern void tui_show_exec_info_content (struct tui_source_window_base *);
+extern void tui_erase_exec_info_content (struct tui_source_window_base *);
+extern void tui_clear_exec_info_content (struct tui_source_window_base *);
+extern void tui_update_exec_info (struct tui_source_window_base *);
 
 extern void tui_alloc_source_buffer (struct tui_win_info *);
 extern int tui_line_is_displayed (int, 
-- 
2.17.2

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

* [PATCH 31/66] Use new and delete for tui_gen_win_info
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (41 preceding siblings ...)
  2019-06-23 23:26 ` [PATCH 30/66] Change tui_which_element::data_window to be a pointer Tom Tromey
@ 2019-06-23 23:26 ` Tom Tromey
  2019-06-23 23:26 ` [PATCH 36/66] Change tui_alloc_source_buffer return type to void Tom Tromey
                   ` (7 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_gen_win_info to be allocated with new and destroyed
with delete.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (init_and_make_win): Use new.
	* tui/tui-data.h (struct tui_gen_win_info): Add constructor,
	destructor, initializers.
	(tui_alloc_generic_win_info): Don't declare.
	* tui/tui-data.c (_locator): Add argument to constructor.
	(source_win, disasm_win): New globals.
	(exec_info): Remove.
	(tui_source_exec_info_win_ptr, tui_disassem_exec_info_win_ptr):
	Update.
	(tui_alloc_generic_win_info): Remove.
	(init_content_element): Use new.
	(tui_win_info::tui_win_info): Update.
	(free_content_elements) <case DATA_WIN>: Use delete.
---
 gdb/ChangeLog        | 16 +++++++++++++++
 gdb/tui/tui-data.c   | 29 ++++++++--------------------
 gdb/tui/tui-data.h   | 46 +++++++++++++++++++++++++++++++-------------
 gdb/tui/tui-layout.c |  2 +-
 4 files changed, 58 insertions(+), 35 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index af571450316..82af0c9cf77 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -36,8 +36,9 @@ struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
 ****************************/
 static enum tui_layout_type current_layout = UNDEFINED_LAYOUT;
 static int term_height, term_width;
-static struct tui_gen_win_info _locator;
-static struct tui_gen_win_info exec_info[2];
+static struct tui_gen_win_info _locator (LOCATOR_WIN);
+static struct tui_gen_win_info source_win (EXEC_INFO_WIN);
+static struct tui_gen_win_info disasm_win (EXEC_INFO_WIN);
 static struct std::vector<tui_source_window_base *> source_windows;
 static struct tui_win_info *win_with_focus = NULL;
 static struct tui_layout_def layout_def = {
@@ -188,7 +189,7 @@ tui_data_window::clear_detail ()
 struct tui_gen_win_info *
 tui_source_exec_info_win_ptr (void)
 {
-  return &exec_info[0];
+  return &source_win;
 }
 
 
@@ -196,7 +197,7 @@ tui_source_exec_info_win_ptr (void)
 struct tui_gen_win_info *
 tui_disassem_exec_info_win_ptr (void)
 {
-  return &exec_info[1];
+  return &disasm_win;
 }
 
 
@@ -389,17 +390,6 @@ tui_initialize_static_data (void)
 }
 
 
-struct tui_gen_win_info *
-tui_alloc_generic_win_info (void)
-{
-  struct tui_gen_win_info *win = XNEW (struct tui_gen_win_info);
-
-  tui_init_generic_part (win);
-
-  return win;
-}
-
-
 void
 tui_init_generic_part (struct tui_gen_win_info *win)
 {
@@ -435,9 +425,7 @@ init_content_element (struct tui_win_element *element,
       element->which_element.source.has_break = FALSE;
       break;
     case DATA_WIN:
-      element->which_element.data_window = XNEW (struct tui_gen_win_info);
-      tui_init_generic_part (element->which_element.data_window);
-      element->which_element.data_window->type = DATA_ITEM_WIN;
+      element->which_element.data_window = new struct tui_gen_win_info (DATA_ITEM_WIN);
       element->which_element.data_window->content =
 	tui_alloc_content (1, DATA_ITEM_WIN);
       element->which_element.data_window->content_size = 1;
@@ -469,9 +457,8 @@ init_content_element (struct tui_win_element *element,
 }
 
 tui_win_info::tui_win_info (enum tui_win_type type)
+  : generic (type)
 {
-  generic.type = type;
-  tui_init_generic_part (&generic);
 }
 
 tui_source_window_base::tui_source_window_base (enum tui_win_type type)
@@ -711,7 +698,7 @@ free_content_elements (tui_win_content content,
 		      xfree (element->which_element.source.line);
 		      break;
 		    case DATA_WIN:
-		      xfree (element->which_element.data_window);
+		      delete element->which_element.data_window;
 		      xfree (element);
 		      break;
 		    case DATA_ITEM_WIN:
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index f915d209782..1fc9e32c5c5 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -39,18 +39,39 @@ typedef struct tui_win_element **tui_win_content;
 /* Generic window information.  */
 struct tui_gen_win_info
 {
-  WINDOW *handle;	    /* Window handle.  */
-  enum tui_win_type type;   /* Type of window.  */
-  int width;		    /* Window width.  */
-  int height;		    /* Window height.  */
-  struct tui_point origin;  /* Origin of window.  */
-  tui_win_content content;  /* Content of window.  */
-  int content_size;	    /* Size of content (# of elements).  */
-  int content_in_use;	    /* Can it be used, or is it already used?  */
-  int viewport_height;	    /* Viewport height.  */
-  int last_visible_line;    /* Index of last visible line.  */
-  bool is_visible;	    /* Whether the window is visible or not.  */
-  char *title;              /* Window title to display.  */
+  explicit tui_gen_win_info (enum tui_win_type t)
+    : type (t)
+  {
+  }
+
+  ~tui_gen_win_info ()
+  {
+  }
+
+  /* Window handle.  */
+  WINDOW *handle = nullptr;
+  /* Type of window.  */
+  enum tui_win_type type;
+  /* Window width.  */
+  int width = 0;
+  /* Window height.  */
+  int height = 0;
+  /* Origin of window.  */
+  struct tui_point origin = {0, 0};
+  /* Content of window.  */
+  tui_win_content content = nullptr;
+  /* Size of content (# of elements).  */
+  int content_size = 0;
+  /* Can it be used, or is it already used?  */
+  int content_in_use = FALSE;
+  /* Viewport height.  */
+  int viewport_height = 0;
+  /* Index of last visible line.  */
+  int last_visible_line = 0;
+  /* Whether the window is visible or not.  */
+  bool is_visible = false;
+  /* Window title to display.  */
+  char *title = nullptr;
 };
 
 /* Constant definitions.  */
@@ -465,7 +486,6 @@ extern struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
 
 /* Data Manipulation Functions.  */
 extern void tui_initialize_static_data (void);
-extern struct tui_gen_win_info *tui_alloc_generic_win_info (void);
 extern struct tui_win_info *tui_alloc_win_info (enum tui_win_type);
 extern void tui_init_generic_part (struct tui_gen_win_info *);
 extern tui_win_content tui_alloc_content (int, enum tui_win_type);
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index d060c5c7807..556bef833a3 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -822,7 +822,7 @@ init_and_make_win (void *opaque_win_info,
   if (opaque_win_info == NULL)
     {
       if (tui_win_is_auxillary (win_type))
-	opaque_win_info = (void *) tui_alloc_generic_win_info ();
+	opaque_win_info = (void *) new tui_gen_win_info (win_type);
       else
 	opaque_win_info = (void *) tui_alloc_win_info (win_type);
     }
-- 
2.17.2

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

* [PATCH 37/66] Remove NULL check from tui_set_exec_info_content
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (34 preceding siblings ...)
  2019-06-23 23:25 ` [PATCH 35/66] Introduce tui_gen_win_info::name method Tom Tromey
@ 2019-06-23 23:26 ` Tom Tromey
  2019-06-23 23:26 ` [PATCH 43/66] Remove some TUI static allocations Tom Tromey
                   ` (14 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_set_exec_info_content ensures that the window's "execution_info"
is allocated, so the NULL check here is redundant and can be removed.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_set_exec_info_content): Remove NULL
	check.
---
 gdb/ChangeLog           |  5 +++
 gdb/tui/tui-winsource.c | 70 +++++++++++++++++++----------------------
 2 files changed, 37 insertions(+), 38 deletions(-)

diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 209d33d6c99..5e60e9e3726 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -495,46 +495,40 @@ tui_set_exec_info_content (struct tui_win_info *win_info)
       if (exec_info_ptr->content == NULL)
 	exec_info_ptr->content =
 	  tui_alloc_content (win_info->height, exec_info_ptr->type);
-      if (exec_info_ptr->content != NULL)
-	{
-	  int i;
 
-          tui_update_breakpoint_info (win_info, 1);
-	  for (i = 0; i < win_info->content_size; i++)
-	    {
-	      struct tui_win_element *element;
-	      struct tui_win_element *src_element;
-              int mode;
-
-	      element = exec_info_ptr->content[i];
-	      src_element = win_info->content[i];
-
-              memset(element->which_element.simple_string, ' ',
-                     sizeof(element->which_element.simple_string));
-              element->which_element.simple_string[TUI_EXECINFO_SIZE - 1] = 0;
-
-	      /* Now update the exec info content based upon the state
-                 of each line as indicated by the source content.  */
-              mode = src_element->which_element.source.has_break;
-              if (mode & TUI_BP_HIT)
-                element->which_element.simple_string[TUI_BP_HIT_POS] =
-                  (mode & TUI_BP_HARDWARE) ? 'H' : 'B';
-              else if (mode & (TUI_BP_ENABLED | TUI_BP_DISABLED))
-                element->which_element.simple_string[TUI_BP_HIT_POS] =
-                  (mode & TUI_BP_HARDWARE) ? 'h' : 'b';
-
-              if (mode & TUI_BP_ENABLED)
-                element->which_element.simple_string[TUI_BP_BREAK_POS] = '+';
-              else if (mode & TUI_BP_DISABLED)
-                element->which_element.simple_string[TUI_BP_BREAK_POS] = '-';
-
-              if (src_element->which_element.source.is_exec_point)
-                element->which_element.simple_string[TUI_EXEC_POS] = '>';
-	    }
-	  exec_info_ptr->content_size = win_info->content_size;
+      tui_update_breakpoint_info (win_info, 1);
+      for (int i = 0; i < win_info->content_size; i++)
+	{
+	  struct tui_win_element *element;
+	  struct tui_win_element *src_element;
+	  int mode;
+
+	  element = exec_info_ptr->content[i];
+	  src_element = win_info->content[i];
+
+	  memset(element->which_element.simple_string, ' ',
+		 sizeof(element->which_element.simple_string));
+	  element->which_element.simple_string[TUI_EXECINFO_SIZE - 1] = 0;
+
+	  /* Now update the exec info content based upon the state
+	     of each line as indicated by the source content.  */
+	  mode = src_element->which_element.source.has_break;
+	  if (mode & TUI_BP_HIT)
+	    element->which_element.simple_string[TUI_BP_HIT_POS] =
+	      (mode & TUI_BP_HARDWARE) ? 'H' : 'B';
+	  else if (mode & (TUI_BP_ENABLED | TUI_BP_DISABLED))
+	    element->which_element.simple_string[TUI_BP_HIT_POS] =
+	      (mode & TUI_BP_HARDWARE) ? 'h' : 'b';
+
+	  if (mode & TUI_BP_ENABLED)
+	    element->which_element.simple_string[TUI_BP_BREAK_POS] = '+';
+	  else if (mode & TUI_BP_DISABLED)
+	    element->which_element.simple_string[TUI_BP_BREAK_POS] = '-';
+
+	  if (src_element->which_element.source.is_exec_point)
+	    element->which_element.simple_string[TUI_EXEC_POS] = '>';
 	}
-      else
-	ret = TUI_FAILURE;
+      exec_info_ptr->content_size = win_info->content_size;
     }
 
   return ret;
-- 
2.17.2

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

* [PATCH 46/66] Introduce tui_win_info::make_visible_with_new_height
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (39 preceding siblings ...)
  2019-06-23 23:26 ` [PATCH 38/66] Change tui_set_exec_info_content to return void Tom Tromey
@ 2019-06-23 23:26 ` Tom Tromey
  2019-06-23 23:26 ` [PATCH 30/66] Change tui_which_element::data_window to be a pointer Tom Tromey
                   ` (9 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes make_visible_with_new_height to be a method on
tui_win_info, letting us remove a spot that checks the window type.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (tui_source_window_base::update_tab_width): Call
	make_visible_with_new_height method.
	(tui_win_info::make_visible_with_new_height): New method.
	(tui_source_window_base::do_make_visible_with_new_height)
	(tui_data_window::do_make_visible_with_new_height)
	(tui_cmd_window::do_make_visible_with_new_height): New methods.
	(make_visible_with_new_height): Remove.
	(tui_resize_all, tui_adjust_win_heights): Use
	make_visible_with_new_height method.
	* tui/tui-data.h (struct tui_win_info)
	<do_make_visible_with_new_height, make_visible_with_new_height>:
	New methods.
	(struct tui_source_window_base, struct tui_data_window)
	(struct tui_cmd_window) <do_make_visible_with_new_height>: New
	methods.
---
 gdb/ChangeLog      |  18 ++++++
 gdb/tui/tui-data.h |  11 ++++
 gdb/tui/tui-win.c  | 154 ++++++++++++++++++++++-----------------------
 3 files changed, 105 insertions(+), 78 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 298ee452d50..d875eb7bbc9 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -273,6 +273,10 @@ protected:
      left_scroll and right_scroll.  */
   virtual void do_scroll_horizontal (int num_to_scroll) = 0;
 
+  /* Called after make_visible_with_new_height sets the new height.
+     Should update the window.  */
+  virtual void do_make_visible_with_new_height () = 0;
+
 public:
 
   ~tui_win_info () override
@@ -311,6 +315,9 @@ public:
   {
   }
 
+  /* Make the window visible after the height has been changed.  */
+  void make_visible_with_new_height ();
+
   /* Set whether this window is highglighted.  */
   void set_highlight (bool highlight)
   {
@@ -343,6 +350,7 @@ protected:
   DISABLE_COPY_AND_ASSIGN (tui_source_window_base);
 
   void do_scroll_horizontal (int num_to_scroll) override;
+  void do_make_visible_with_new_height () override;
 
 public:
 
@@ -465,6 +473,7 @@ protected:
   void do_scroll_horizontal (int num_to_scroll) override
   {
   }
+  void do_make_visible_with_new_height () override;
 };
 
 struct tui_cmd_window : public tui_win_info
@@ -505,6 +514,8 @@ protected:
   void do_scroll_horizontal (int num_to_scroll) override
   {
   }
+
+  void do_make_visible_with_new_height () override;
 };
 
 extern int tui_win_is_auxillary (enum tui_win_type win_type);
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 8a4e64f3c88..2ca3d086c98 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -55,7 +55,6 @@
 /*******************************
 ** Static Local Decls
 ********************************/
-static void make_visible_with_new_height (struct tui_win_info *);
 static void make_invisible_and_set_new_height (struct tui_win_info *, 
 					       int);
 static enum tui_status tui_adjust_win_heights (struct tui_win_info *, 
@@ -616,8 +615,8 @@ tui_resize_all (void)
 	  TUI_CMD_WIN->width += width_diff;
 	  new_height = screenheight - TUI_CMD_WIN->origin.y;
 	  make_invisible_and_set_new_height (TUI_CMD_WIN, new_height);
-	  make_visible_with_new_height (first_win);
-	  make_visible_with_new_height (TUI_CMD_WIN);
+	  first_win->make_visible_with_new_height ();
+	  TUI_CMD_WIN->make_visible_with_new_height ();
 	  if (first_win->content_size <= 0)
 	    tui_erase_source_content (first_win, EMPTY_SOURCE_PROMPT);
 	  break;
@@ -678,9 +677,9 @@ tui_resize_all (void)
 	  make_invisible_and_set_new_height (TUI_CMD_WIN,
 					     TUI_CMD_WIN->height
 					     + cmd_split_diff);
-	  make_visible_with_new_height (first_win);
-	  make_visible_with_new_height (second_win);
-	  make_visible_with_new_height (TUI_CMD_WIN);
+	  first_win->make_visible_with_new_height ();
+	  second_win->make_visible_with_new_height ();
+	  TUI_CMD_WIN->make_visible_with_new_height ();
 	  if (first_win->content_size <= 0)
 	    tui_erase_source_content (first_win, EMPTY_SOURCE_PROMPT);
 	  if (second_win->content_size <= 0)
@@ -933,7 +932,7 @@ tui_source_window_base::update_tab_width ()
      and redisplay of the window's contents, which will take
      the new tab width into account.  */
   make_invisible_and_set_new_height (this, height);
-  make_visible_with_new_height (this);
+  make_visible_with_new_height ();
 }
 
 /* After the tab width is set, call this to update the relevant
@@ -1126,8 +1125,8 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 	      make_invisible_and_set_new_height (win_info,
 					     win_info->height + diff);
 	      TUI_CMD_WIN->origin.y = locator->origin.y + 1;
-	      make_visible_with_new_height (win_info);
-	      make_visible_with_new_height (primary_win_info);
+	      win_info->make_visible_with_new_height ();
+	      primary_win_info->make_visible_with_new_height ();
 	      if (src_win_info->content_size <= 0)
 		tui_erase_source_content (src_win_info, EMPTY_SOURCE_PROMPT);
 	    }
@@ -1228,9 +1227,9 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 		    make_invisible_and_set_new_height (TUI_CMD_WIN,
 						       TUI_CMD_WIN->height + diff);
 		}
-	      make_visible_with_new_height (TUI_CMD_WIN);
-	      make_visible_with_new_height (second_win);
-	      make_visible_with_new_height (first_win);
+	      TUI_CMD_WIN->make_visible_with_new_height ();
+	      second_win->make_visible_with_new_height ();
+	      first_win->make_visible_with_new_height ();
 	      if (first_win->content_size <= 0)
 		tui_erase_source_content (first_win, EMPTY_SOURCE_PROMPT);
 	      if (second_win->content_size <= 0)
@@ -1301,82 +1300,81 @@ make_invisible_and_set_new_height (struct tui_win_info *win_info,
 }
 
 
-/* Function to make the windows with new heights visible.  This means
-   re-creating the windows' content since the window had to be
-   destroyed to be made invisible.  */
-static void
-make_visible_with_new_height (struct tui_win_info *win_info)
+/* See tui-data.h.  */
+
+void
+tui_win_info::make_visible_with_new_height ()
 {
-  struct symtab *s;
+  make_visible (true);
+  tui_check_and_display_highlight_if_needed (this);
+  do_make_visible_with_new_height ();
+}
+
+/* See tui-data.h.  */
 
-  tui_make_visible (win_info);
-  tui_check_and_display_highlight_if_needed (win_info);
-  tui_source_window_base *base;
-  switch (win_info->type)
+void
+tui_source_window_base::do_make_visible_with_new_height ()
+{
+  tui_free_win_content (execution_info);
+  tui_make_visible (execution_info);
+  if (content != NULL)
     {
-    case SRC_WIN:
-    case DISASSEM_WIN:
-      base = (tui_source_window_base *) win_info;
-      tui_free_win_content (base->execution_info);
-      tui_make_visible (base->execution_info);
-      if (win_info->content != NULL)
-	{
-	  struct gdbarch *gdbarch = base->gdbarch;
-	  struct tui_line_or_address line_or_addr;
-	  struct symtab_and_line cursal
-	    = get_current_source_symtab_and_line ();
-
-	  line_or_addr = base->start_line_or_addr;
-	  tui_free_win_content (win_info);
-	  tui_update_source_window (base, gdbarch,
-				    cursal.symtab, line_or_addr, TRUE);
-	}
-      else if (deprecated_safe_get_selected_frame () != NULL)
+      struct tui_line_or_address line_or_addr;
+      struct symtab_and_line cursal
+	= get_current_source_symtab_and_line ();
+
+      line_or_addr = start_line_or_addr;
+      tui_free_win_content (this);
+      tui_update_source_window (this, gdbarch,
+				cursal.symtab, line_or_addr, TRUE);
+    }
+  else if (deprecated_safe_get_selected_frame () != NULL)
+    {
+      struct tui_line_or_address line;
+      struct symtab_and_line cursal
+	= get_current_source_symtab_and_line ();
+      struct frame_info *frame = deprecated_safe_get_selected_frame ();
+      struct gdbarch *gdbarch = get_frame_arch (frame);
+
+      struct symtab *s = find_pc_line_symtab (get_frame_pc (frame));
+      if (type == SRC_WIN)
 	{
-	  struct tui_line_or_address line;
-	  struct symtab_and_line cursal
-	    = get_current_source_symtab_and_line ();
-	  struct frame_info *frame = deprecated_safe_get_selected_frame ();
-	  struct gdbarch *gdbarch = get_frame_arch (frame);
-
-	  s = find_pc_line_symtab (get_frame_pc (frame));
-	  if (win_info->type == SRC_WIN)
-	    {
-	      line.loa = LOA_LINE;
-	      line.u.line_no = cursal.line;
-	    }
-	  else
-	    {
-	      line.loa = LOA_ADDRESS;
-	      find_line_pc (s, cursal.line, &line.u.addr);
-	    }
-	  tui_update_source_window (base, gdbarch, s, line, TRUE);
+	  line.loa = LOA_LINE;
+	  line.u.line_no = cursal.line;
 	}
-      if (win_info->has_locator ())
+      else
 	{
-	  tui_make_visible (tui_locator_win_info_ptr ());
-	  tui_show_locator_content ();
+	  line.loa = LOA_ADDRESS;
+	  find_line_pc (s, cursal.line, &line.u.addr);
 	}
-      break;
-    case DATA_WIN:
-      tui_display_all_data ();
-      break;
-    case CMD_WIN:
-#ifdef HAVE_WRESIZE
-      wresize (TUI_CMD_WIN->handle,
-	       TUI_CMD_WIN->height,
-	       TUI_CMD_WIN->width);
-#endif
-      mvwin (TUI_CMD_WIN->handle,
-	     TUI_CMD_WIN->origin.y,
-	     TUI_CMD_WIN->origin.x);
-      wmove (win_info->handle, 0, 0);
-      break;
-    default:
-      break;
+      tui_update_source_window (this, gdbarch, s, line, TRUE);
+    }
+  if (has_locator ())
+    {
+      tui_make_visible (tui_locator_win_info_ptr ());
+      tui_show_locator_content ();
     }
 }
 
+/* See tui-data.h.  */
+
+void
+tui_data_window::do_make_visible_with_new_height ()
+{
+  tui_display_all_data ();
+}
+
+/* See tui-data.h.  */
+
+void
+tui_cmd_window::do_make_visible_with_new_height ()
+{
+#ifdef HAVE_WRESIZE
+  wresize (handle, height, width);
+#endif
+  mvwin (handle, origin.y, origin.x);
+  wmove (handle, 0, 0);
+}
 
 /* See tui-data.h.  */
 
-- 
2.17.2

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

* [PATCH 44/66] Introduce enum tui_box
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (47 preceding siblings ...)
  2019-06-23 23:26 ` [PATCH 49/66] Separate out execution-info window Tom Tromey
@ 2019-06-23 23:26 ` Tom Tromey
  2019-06-24 14:23 ` [PATCH 00/66] Clean up the TUI Pedro Alves
  2019-06-24 18:49 ` [PATCH 50/66] Separate out locator window Tom Tromey
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds a new enum to the TUI, replacing two #define constants,
providing better type safety.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.h (tui_make_window): Change type of "box_it"
	parameter.
	* tui/tui-wingeneral.c (tui_make_window): Change type of "box_it"
	parameter.
	(tui_gen_win_info::make_visible): Update.
	* tui/tui-layout.c (init_and_make_win): Change type of "box_it"
	parameter.
	* tui/tui-data.h (enum tui_box): New enum.
	(BOX_WINDOW, DONT_BOX_WINDOW): Remove defines.
---
 gdb/ChangeLog            | 12 ++++++++++++
 gdb/tui/tui-data.h       |  9 +++++++--
 gdb/tui/tui-layout.c     |  5 +++--
 gdb/tui/tui-wingeneral.c |  5 +++--
 gdb/tui/tui-wingeneral.h |  2 +-
 5 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index a79331144dd..caf3bb4f408 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -91,6 +91,13 @@ struct tui_gen_win_info
   char *title = nullptr;
 };
 
+/* Whether or not a window should be drawn with a box.  */
+enum tui_box
+{
+  DONT_BOX_WINDOW = 0,
+  BOX_WINDOW
+};
+
 /* Constant definitions.  */
 #define DEFAULT_TAB_LEN         8
 #define NO_SRC_STRING           "[ No Source Available ]"
@@ -104,8 +111,6 @@ struct tui_gen_win_info
 #define DISASSEM_NAME           "asm"
 #define TUI_NULL_STR            ""
 #define DEFAULT_HISTORY_COUNT	25
-#define BOX_WINDOW              TRUE
-#define DONT_BOX_WINDOW         FALSE
 #define HILITE                  TRUE
 #define NO_HILITE               FALSE
 #define WITH_LOCATOR            TRUE
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 695fa3560b2..6507b06dd39 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -45,7 +45,8 @@
 static void show_layout (enum tui_layout_type);
 static tui_gen_win_info *init_and_make_win (tui_gen_win_info *,
 					    enum tui_win_type,
-					    int, int, int, int, int);
+					    int, int, int, int,
+					    enum tui_box);
 static void show_source_or_disasm_and_command (enum tui_layout_type);
 static struct tui_win_info *make_source_or_disasm_window (enum tui_win_type, 
 							  int, int);
@@ -793,7 +794,7 @@ init_and_make_win (tui_gen_win_info *win_info,
 		   enum tui_win_type win_type,
 		   int height, int width, 
 		   int origin_x, int origin_y,
-		   int box_it)
+		   enum tui_box box_it)
 {
   if (win_info == NULL)
     {
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index acb8a26765b..cfa4a08701c 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -146,7 +146,7 @@ tui_check_and_display_highlight_if_needed (struct tui_win_info *win_info)
 
 
 void
-tui_make_window (struct tui_gen_win_info *win_info, int box_it)
+tui_make_window (struct tui_gen_win_info *win_info, enum tui_box box_it)
 {
   WINDOW *handle;
 
@@ -175,7 +175,8 @@ tui_gen_win_info::make_visible (bool visible)
     {
       if (!is_visible)
 	{
-	  tui_make_window (this, !tui_win_is_auxillary (type));
+	  tui_make_window (this, (tui_win_is_auxillary (type)
+				  ? DONT_BOX_WINDOW : BOX_WINDOW));
 	  is_visible = true;
 	}
     }
diff --git a/gdb/tui/tui-wingeneral.h b/gdb/tui/tui-wingeneral.h
index 15e61c94166..e925606229c 100644
--- a/gdb/tui/tui-wingeneral.h
+++ b/gdb/tui/tui-wingeneral.h
@@ -32,7 +32,7 @@ extern void tui_make_visible (struct tui_gen_win_info *);
 extern void tui_make_invisible (struct tui_gen_win_info *);
 extern void tui_make_all_visible (void);
 extern void tui_make_all_invisible (void);
-extern void tui_make_window (struct tui_gen_win_info *, int);
+extern void tui_make_window (struct tui_gen_win_info *, enum tui_box);
 extern struct tui_win_info *tui_copy_win (struct tui_win_info *);
 extern void tui_box_win (struct tui_gen_win_info *, int);
 extern void tui_highlight_win (struct tui_win_info *);
-- 
2.17.2

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

* [PATCH 38/66] Change tui_set_exec_info_content to return void
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (38 preceding siblings ...)
  2019-06-23 23:26 ` [PATCH 39/66] Change more TUI functions to take a tui_source_window_base Tom Tromey
@ 2019-06-23 23:26 ` Tom Tromey
  2019-06-23 23:26 ` [PATCH 46/66] Introduce tui_win_info::make_visible_with_new_height Tom Tromey
                   ` (10 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_set_exec_info_content can't return an error, so change it to
return void instead.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_set_exec_info_content): Return void.
	* tui/tui-winsource.c (tui_set_exec_info_content): Return void.
---
 gdb/ChangeLog           | 5 +++++
 gdb/tui/tui-winsource.c | 6 +-----
 gdb/tui/tui-winsource.h | 2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 5e60e9e3726..2de5c53214e 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -482,11 +482,9 @@ tui_update_breakpoint_info (struct tui_win_info *win,
 /* Function to initialize the content of the execution info window,
    based upon the input window which is either the source or
    disassembly window.  */
-enum tui_status
+void
 tui_set_exec_info_content (struct tui_win_info *win_info)
 {
-  enum tui_status ret = TUI_SUCCESS;
-
   tui_source_window_base *base = (tui_source_window_base *) win_info;
   if (base->execution_info != NULL)
     {
@@ -530,8 +528,6 @@ tui_set_exec_info_content (struct tui_win_info *win_info)
 	}
       exec_info_ptr->content_size = win_info->content_size;
     }
-
-  return ret;
 }
 
 
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index ccc9ae5f68a..3ed461a3157 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -53,7 +53,7 @@ extern void tui_update_source_windows_with_line (struct symtab *,
 extern void tui_clear_source_content (struct tui_win_info *, int);
 extern void tui_erase_source_content (struct tui_win_info *, int);
 extern void tui_show_source_content (struct tui_win_info *);
-extern enum tui_status tui_set_exec_info_content (struct tui_win_info *);
+extern void tui_set_exec_info_content (struct tui_win_info *);
 extern void tui_show_exec_info_content (struct tui_win_info *);
 extern void tui_erase_exec_info_content (struct tui_win_info *);
 extern void tui_clear_exec_info_content (struct tui_win_info *);
-- 
2.17.2

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

* [PATCH 47/66] Don't check window type in tui_set_win_focus_to
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (45 preceding siblings ...)
  2019-06-23 23:26 ` [PATCH 33/66] Introduce refresh_window method Tom Tromey
@ 2019-06-23 23:26 ` Tom Tromey
  2019-06-23 23:26 ` [PATCH 49/66] Separate out execution-info window Tom Tromey
                   ` (3 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_set_win_focus_to so that it no longer checks the
window type.  Instead, now tui_unhighlight_win also checks whether the
window can be highlighted.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (tui_set_win_focus_to): Don't check window type.
	* tui/tui-wingeneral.c (tui_unhighlight_win): Check
	can_highlight.
---
 gdb/ChangeLog            | 6 ++++++
 gdb/tui/tui-win.c        | 7 ++-----
 gdb/tui/tui-wingeneral.c | 1 +
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 2ca3d086c98..61b3a3251f1 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -458,12 +458,9 @@ tui_set_win_focus_to (struct tui_win_info *win_info)
     {
       struct tui_win_info *win_with_focus = tui_win_with_focus ();
 
-      if (win_with_focus != NULL
-	  && win_with_focus->type != CMD_WIN)
-	tui_unhighlight_win (win_with_focus);
+      tui_unhighlight_win (win_with_focus);
       tui_set_win_with_focus (win_info);
-      if (win_info->type != CMD_WIN)
-	tui_highlight_win (win_info);
+      tui_highlight_win (win_info);
     }
 }
 
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index cfa4a08701c..98eb5abde16 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -108,6 +108,7 @@ void
 tui_unhighlight_win (struct tui_win_info *win_info)
 {
   if (win_info != NULL 
+      && win_info->can_highlight
       && win_info->handle != NULL)
     {
       box_win (win_info, NO_HILITE);
-- 
2.17.2

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

* [PATCH 49/66] Separate out execution-info window
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (46 preceding siblings ...)
  2019-06-23 23:26 ` [PATCH 47/66] Don't check window type in tui_set_win_focus_to Tom Tromey
@ 2019-06-23 23:26 ` Tom Tromey
  2019-06-24 14:13   ` Pedro Alves
  2019-06-23 23:26 ` [PATCH 44/66] Introduce enum tui_box Tom Tromey
                   ` (2 subsequent siblings)
  50 siblings, 1 reply; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This pulls the EXEC_INFO_WIN case out into its own subclass of
tui_gen_win_info.  This lets us remove an element from
union tui_which_element.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c
	(tui_exec_info_window::maybe_allocate_content): New method.
	(tui_set_exec_info_content, tui_show_exec_info_content): Update.
	* tui/tui-layout.c (init_and_make_win): Add EXEC_INFO_WIN case.
	(make_source_or_disasm_window): Add cast.
	* tui/tui-data.h (union tui_which_element) <simple_string>:
	Remove.
	(struct tui_source_info): New.
	(struct tui_source_window_base) <execution_info>: Change type.
	* tui/tui-data.c (init_content_element): Remove EXEC_INFO_WIN
	case, and add assert.
	(tui_alloc_content): Add assert.
---
 gdb/ChangeLog           | 15 +++++++++++++
 gdb/tui/tui-data.c      |  8 +++----
 gdb/tui/tui-data.h      | 31 +++++++++++++++++++++++++--
 gdb/tui/tui-layout.c    | 20 +++++++++++-------
 gdb/tui/tui-winsource.c | 47 +++++++++++++++++++++--------------------
 5 files changed, 84 insertions(+), 37 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 9b247b46808..d74c4f7b2a9 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -364,6 +364,8 @@ static void
 init_content_element (struct tui_win_element *element, 
 		      enum tui_win_type type)
 {
+  gdb_assert (type != EXEC_INFO_WIN);
+
   switch (type)
     {
     case SRC_WIN:
@@ -397,10 +399,6 @@ init_content_element (struct tui_win_element *element,
       element->which_element.locator.line_no = 0;
       element->which_element.locator.addr = 0;
       break;
-    case EXEC_INFO_WIN:
-      memset(element->which_element.simple_string, ' ',
-             sizeof(element->which_element.simple_string));
-      break;
     default:
       break;
     }
@@ -427,6 +425,8 @@ tui_alloc_content (int num_elements, enum tui_win_type type)
   struct tui_win_element *element_block_ptr;
   int i;
 
+  gdb_assert (type != EXEC_INFO_WIN);
+
   content = XNEWVEC (struct tui_win_element *, num_elements);
 
   /*
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 7392a4e4133..23dd0fd9080 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -249,7 +249,6 @@ union tui_which_element
   struct tui_data_element data;		/* Elements of data_window.  */
   struct tui_command_element command;	/* Command elements.  */
   struct tui_locator_element locator;	/* Locator elements.  */
-  tui_exec_info_content simple_string;	/* Simple char based elements.  */
 };
 
 struct tui_win_element
@@ -257,6 +256,34 @@ struct tui_win_element
   union tui_which_element which_element;
 };
 
+/* Execution info window class.  */
+
+struct tui_exec_info_window : public tui_gen_win_info
+{
+  tui_exec_info_window ()
+    : tui_gen_win_info (EXEC_INFO_WIN)
+  {
+  }
+
+  ~tui_exec_info_window () override
+  {
+    xfree (m_content);
+  }
+
+  /* Get or allocate contents.  */
+  tui_exec_info_content *maybe_allocate_content (int n_elements);
+
+  /* Allocate contents.  */
+  const tui_exec_info_content *get_content () const
+  {
+    return m_content;
+  }
+
+private:
+
+  tui_exec_info_content *m_content = nullptr;
+};
+
 /* This defines information about each logical window.  */
 struct tui_win_info : public tui_gen_win_info
 {
@@ -380,7 +407,7 @@ public:
   /* Does locator belongs to this window?  */
   bool m_has_locator = false;
   /* Execution information window.  */
-  struct tui_gen_win_info *execution_info = nullptr;
+  struct tui_exec_info_window *execution_info = nullptr;
   /* Used for horizontal scroll.  */
   int horizontal_offset = 0;
   struct tui_line_or_address start_line_or_addr;
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 6d343921d4c..a0745bf5384 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -816,6 +816,10 @@ init_and_make_win (tui_gen_win_info *win_info,
 	  win_info = new tui_cmd_window ();
 	  break;
 
+	case EXEC_INFO_WIN:
+	  win_info = new tui_exec_info_window ();
+	  break;
+
 	default:
 	  gdb_assert (tui_win_is_auxillary (win_type));
 	  win_info = new tui_gen_win_info (win_type);
@@ -834,14 +838,14 @@ static struct tui_win_info *
 make_source_or_disasm_window (enum tui_win_type type,
 			      int height, int origin_y)
 {
-  struct tui_gen_win_info *execution_info
-    = init_and_make_win (nullptr,
-			 EXEC_INFO_WIN,
-			 height,
-			 3,
-			 0,
-			 origin_y,
-			 DONT_BOX_WINDOW);
+  struct tui_exec_info_window *execution_info
+    = (tui_exec_info_window *) init_and_make_win (nullptr,
+						  EXEC_INFO_WIN,
+						  height,
+						  3,
+						  0,
+						  origin_y,
+						  DONT_BOX_WINDOW);
 
   /* Now create the source window.  */
   struct tui_source_window_base *result
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index e56fbcb76d6..204fee13be9 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -470,6 +470,16 @@ tui_update_breakpoint_info (struct tui_win_info *win,
   return need_refresh;
 }
 
+/* See tui-data.h.  */
+
+tui_exec_info_content *
+tui_exec_info_window::maybe_allocate_content (int n_elements)
+{
+  if (m_content == nullptr)
+    m_content = XNEWVEC (tui_exec_info_content, n_elements);
+  return m_content;
+}
+
 
 /* Function to initialize the content of the execution info window,
    based upon the input window which is either the source or
@@ -479,45 +489,37 @@ tui_set_exec_info_content (struct tui_source_window_base *win_info)
 {
   if (win_info->execution_info != NULL)
     {
-      struct tui_gen_win_info *exec_info_ptr = win_info->execution_info;
-
-      if (exec_info_ptr->content == NULL)
-	exec_info_ptr->content =
-	  tui_alloc_content (win_info->height, exec_info_ptr->type);
+      tui_exec_info_content *content
+	= win_info->execution_info->maybe_allocate_content (win_info->height);
 
       tui_update_breakpoint_info (win_info, 1);
       for (int i = 0; i < win_info->content_size; i++)
 	{
-	  struct tui_win_element *element;
+	  tui_exec_info_content &element = content[i];
 	  struct tui_win_element *src_element;
 	  int mode;
 
-	  element = exec_info_ptr->content[i];
 	  src_element = win_info->content[i];
 
-	  memset(element->which_element.simple_string, ' ',
-		 sizeof(element->which_element.simple_string));
-	  element->which_element.simple_string[TUI_EXECINFO_SIZE - 1] = 0;
+	  memset (element, ' ', sizeof (tui_exec_info_content));
+	  element[TUI_EXECINFO_SIZE - 1] = 0;
 
 	  /* Now update the exec info content based upon the state
 	     of each line as indicated by the source content.  */
 	  mode = src_element->which_element.source.has_break;
 	  if (mode & TUI_BP_HIT)
-	    element->which_element.simple_string[TUI_BP_HIT_POS] =
-	      (mode & TUI_BP_HARDWARE) ? 'H' : 'B';
+	    element[TUI_BP_HIT_POS] = (mode & TUI_BP_HARDWARE) ? 'H' : 'B';
 	  else if (mode & (TUI_BP_ENABLED | TUI_BP_DISABLED))
-	    element->which_element.simple_string[TUI_BP_HIT_POS] =
-	      (mode & TUI_BP_HARDWARE) ? 'h' : 'b';
+	    element[TUI_BP_HIT_POS] = (mode & TUI_BP_HARDWARE) ? 'h' : 'b';
 
 	  if (mode & TUI_BP_ENABLED)
-	    element->which_element.simple_string[TUI_BP_BREAK_POS] = '+';
+	    element[TUI_BP_BREAK_POS] = '+';
 	  else if (mode & TUI_BP_DISABLED)
-	    element->which_element.simple_string[TUI_BP_BREAK_POS] = '-';
+	    element[TUI_BP_BREAK_POS] = '-';
 
 	  if (src_element->which_element.source.is_exec_point)
-	    element->which_element.simple_string[TUI_EXEC_POS] = '>';
+	    element[TUI_EXEC_POS] = '>';
 	}
-      exec_info_ptr->content_size = win_info->content_size;
     }
 }
 
@@ -525,17 +527,16 @@ tui_set_exec_info_content (struct tui_source_window_base *win_info)
 void
 tui_show_exec_info_content (struct tui_source_window_base *win_info)
 {
-  struct tui_gen_win_info *exec_info = win_info->execution_info;
-  int cur_line;
+  struct tui_exec_info_window *exec_info = win_info->execution_info;
+  const tui_exec_info_content *content = exec_info->get_content ();
 
   werase (exec_info->handle);
   exec_info->refresh_window ();
-  for (cur_line = 1; (cur_line <= exec_info->content_size); cur_line++)
+  for (int cur_line = 1; (cur_line <= win_info->content_size); cur_line++)
     mvwaddstr (exec_info->handle,
 	       cur_line,
 	       0,
-	       (char *) exec_info->content[cur_line - 1]
-			  ->which_element.simple_string);
+	       content[cur_line - 1]);
   exec_info->refresh_window ();
   exec_info->content_in_use = TRUE;
 }
-- 
2.17.2

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

* [PATCH 43/66] Remove some TUI static allocations
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (35 preceding siblings ...)
  2019-06-23 23:26 ` [PATCH 37/66] Remove NULL check from tui_set_exec_info_content Tom Tromey
@ 2019-06-23 23:26 ` Tom Tromey
  2019-06-23 23:26 ` [PATCH 48/66] Remove tui_alloc_win_info Tom Tromey
                   ` (13 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The TUI statically allocates the "execution_info" for the source and
disassembly windows.  However, there's no deep reason to do this, and
this approach makes it harder to allow multiple such windows.

This patch removes the static data and changes the code to simply
allocate these windows as needed.  This required pushing some code
into the tui_gen_win_info destructor, but that seems like a good idea
anyhow.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (make_source_or_disasm_window): Always use
	init_and_make_win for EXEC_INFO_WIN.
	* tui/tui-data.h (struct tui_gen_win_info) <~tui_gen_win_info>: No
	longer inline.
	(struct tui_win_info) <~tui_win_info>: Inline.
	(tui_source_exec_info_win_ptr, tui_disassem_exec_info_win_ptr):
	Don't declare.
	* tui/tui-data.c (source_win, disasm_win): Remove globals.
	(tui_source_exec_info_win_ptr, tui_disassem_exec_info_win_ptr):
	Remove.
	(tui_initialize_static_data): Update.
	(~tui_gen_win_info): Handle more cleanup here.
	(~tui_source_window_base): Delete "execution_info".
	(~tui_win_info): Move code to ~tui_gen_win_info; remove.
---
 gdb/ChangeLog        | 17 +++++++++++++++
 gdb/tui/tui-data.c   | 52 ++++++++++----------------------------------
 gdb/tui/tui-data.h   | 10 ++++-----
 gdb/tui/tui-layout.c | 24 +++++++-------------
 4 files changed, 41 insertions(+), 62 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 5bb79156e70..7af9c19fa4d 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -37,8 +37,6 @@ struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
 static enum tui_layout_type current_layout = UNDEFINED_LAYOUT;
 static int term_height, term_width;
 static struct tui_gen_win_info _locator (LOCATOR_WIN);
-static struct tui_gen_win_info source_win (EXEC_INFO_WIN);
-static struct tui_gen_win_info disasm_win (EXEC_INFO_WIN);
 static struct std::vector<tui_source_window_base *> source_windows;
 static struct tui_win_info *win_with_focus = NULL;
 static struct tui_layout_def layout_def = {
@@ -185,22 +183,6 @@ tui_data_window::clear_detail ()
   display_regs = false;
 }
 
-/* Accessor for the source execution info ptr.  */
-struct tui_gen_win_info *
-tui_source_exec_info_win_ptr (void)
-{
-  return &source_win;
-}
-
-
-/* Accessor for the disassem execution info ptr.  */
-struct tui_gen_win_info *
-tui_disassem_exec_info_win_ptr (void)
-{
-  return &disasm_win;
-}
-
-
 /* Accessor for the locator win info.  Answers a pointer to the static
    locator win info struct.  */
 struct tui_gen_win_info *
@@ -354,8 +336,6 @@ tui_partial_win_by_name (const char *name)
 void
 tui_initialize_static_data (void)
 {
-  tui_init_generic_part (tui_source_exec_info_win_ptr ());
-  tui_init_generic_part (tui_disassem_exec_info_win_ptr ());
   tui_init_generic_part (tui_locator_win_info_ptr ());
 }
 
@@ -525,16 +505,21 @@ tui_add_content_elements (struct tui_gen_win_info *win_info,
   return index_start;
 }
 
-tui_source_window_base::~tui_source_window_base ()
+tui_gen_win_info::~tui_gen_win_info ()
 {
-  xfree (fullname);
-  struct tui_gen_win_info *generic_win = execution_info;
-  if (generic_win != NULL)
+  if (handle != NULL)
     {
-      tui_delete_win (generic_win->handle);
-      generic_win->handle = NULL;
-      tui_free_win_content (generic_win);
+      tui_delete_win (handle);
+      handle = NULL;
+      tui_free_win_content (this);
     }
+  xfree (title);
+}
+
+tui_source_window_base::~tui_source_window_base ()
+{
+  xfree (fullname);
+  delete execution_info;
 }  
 
 tui_data_window::~tui_data_window ()
@@ -554,19 +539,6 @@ tui_data_window::~tui_data_window ()
     }
 }  
 
-tui_win_info::~tui_win_info ()
-{
-  if (handle != NULL)
-    {
-      tui_delete_win (handle);
-      handle = NULL;
-      tui_free_win_content (this);
-    }
-  if (title)
-    xfree (title);
-}
-
-
 void
 tui_free_all_source_wins_content ()
 {
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index be34afa70aa..a79331144dd 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -44,9 +44,7 @@ struct tui_gen_win_info
   {
   }
 
-  virtual ~tui_gen_win_info ()
-  {
-  }
+  virtual ~tui_gen_win_info ();
 
   /* Call to refresh this window.  */
   virtual void refresh_window ();
@@ -272,7 +270,9 @@ protected:
 
 public:
 
-  ~tui_win_info () override;
+  ~tui_win_info () override
+  {
+  }
 
   /* Clear the pertinent detail in the window.  */
   virtual void clear_detail () = 0;
@@ -524,8 +524,6 @@ extern void tui_set_term_height_to (int);
 extern int tui_term_width (void);
 extern void tui_set_term_width_to (int);
 extern struct tui_gen_win_info *tui_locator_win_info_ptr (void);
-extern struct tui_gen_win_info *tui_source_exec_info_win_ptr (void);
-extern struct tui_gen_win_info *tui_disassem_exec_info_win_ptr (void);
 extern struct std::vector<tui_source_window_base *> &tui_source_windows ();
 extern void tui_clear_source_windows (void);
 extern void tui_clear_source_windows_detail (void);
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index f586d703d43..695fa3560b2 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -814,22 +814,14 @@ static struct tui_win_info *
 make_source_or_disasm_window (enum tui_win_type type,
 			      int height, int origin_y)
 {
-  struct tui_gen_win_info *execution_info = NULL;
-
-  /* Create the exeuction info window.  */
-  if (type == SRC_WIN)
-    execution_info = tui_source_exec_info_win_ptr ();
-  else
-    execution_info = tui_disassem_exec_info_win_ptr ();
-  execution_info
-    = ((struct tui_gen_win_info *)
-       init_and_make_win (execution_info,
-			  EXEC_INFO_WIN,
-			  height,
-			  3,
-			  0,
-			  origin_y,
-			  DONT_BOX_WINDOW));
+  struct tui_gen_win_info *execution_info
+    = init_and_make_win (nullptr,
+			 EXEC_INFO_WIN,
+			 height,
+			 3,
+			 0,
+			 origin_y,
+			 DONT_BOX_WINDOW);
 
   /* Now create the source window.  */
   struct tui_source_window_base *result
-- 
2.17.2

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

* [PATCH 30/66] Change tui_which_element::data_window to be a pointer
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (40 preceding siblings ...)
  2019-06-23 23:26 ` [PATCH 46/66] Introduce tui_win_info::make_visible_with_new_height Tom Tromey
@ 2019-06-23 23:26 ` Tom Tromey
  2019-06-23 23:26 ` [PATCH 31/66] Use new and delete for tui_gen_win_info Tom Tromey
                   ` (8 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

A coming patch will add a constructor to tui_gen_win_info.  However,
because the tui_which_element union contains an object of this type,
first something must be done here in order to avoid having a union
with a member that has a constructor.  This patch changes this element
to be a pointer instead.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (tui_refresh_win): Update.
	* tui/tui-windata.c (tui_first_data_item_displayed)
	(tui_delete_data_content_windows): Update.
	* tui/tui-win.c (tui_data_window::set_new_height): Update.
	* tui/tui-regs.c (tui_show_registers, tui_show_register_group)
	(tui_display_registers_from, tui_check_register_values): Update.
	* tui/tui-data.h (union tui_which_element) <data_window>: Now a
	pointer.
	* tui/tui-data.c (init_content_element): Update.  Allocate the new
	window.
	(tui_free_data_content): Update.
	(free_content_elements) <case DATA_WIN>: Free the window.
---
 gdb/ChangeLog            | 15 +++++++++++++++
 gdb/tui/tui-data.c       | 12 +++++++-----
 gdb/tui/tui-data.h       |  2 +-
 gdb/tui/tui-regs.c       | 10 +++++-----
 gdb/tui/tui-win.c        |  2 +-
 gdb/tui/tui-windata.c    |  4 ++--
 gdb/tui/tui-wingeneral.c |  2 +-
 7 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index bdfc2de73af..af571450316 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -435,11 +435,12 @@ init_content_element (struct tui_win_element *element,
       element->which_element.source.has_break = FALSE;
       break;
     case DATA_WIN:
-      tui_init_generic_part (&element->which_element.data_window);
-      element->which_element.data_window.type = DATA_ITEM_WIN;
-      element->which_element.data_window.content =
+      element->which_element.data_window = XNEW (struct tui_gen_win_info);
+      tui_init_generic_part (element->which_element.data_window);
+      element->which_element.data_window->type = DATA_ITEM_WIN;
+      element->which_element.data_window->content =
 	tui_alloc_content (1, DATA_ITEM_WIN);
-      element->which_element.data_window.content_size = 1;
+      element->which_element.data_window->content_size = 1;
       break;
     case CMD_WIN:
       element->which_element.command.line = NULL;
@@ -646,7 +647,7 @@ tui_free_data_content (tui_win_content content,
   for (i = 0; i < content_size; i++)
     {
       struct tui_gen_win_info *generic_win
-	= &content[i]->which_element.data_window;
+	= content[i]->which_element.data_window;
 
       if (generic_win != NULL)
 	{
@@ -710,6 +711,7 @@ free_content_elements (tui_win_content content,
 		      xfree (element->which_element.source.line);
 		      break;
 		    case DATA_WIN:
+		      xfree (element->which_element.data_window);
 		      xfree (element);
 		      break;
 		    case DATA_ITEM_WIN:
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 98e7a2ca34e..f915d209782 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -212,7 +212,7 @@ typedef char tui_exec_info_content[TUI_EXECINFO_SIZE];
 union tui_which_element
 {
   struct tui_source_element source;	/* The source elements.  */
-  struct tui_gen_win_info data_window;	/* Data display elements.  */
+  struct tui_gen_win_info *data_window;	/* Data display elements.  */
   struct tui_data_element data;		/* Elements of data_window.  */
   struct tui_command_element command;	/* Command elements.  */
   struct tui_locator_element locator;	/* Locator elements.  */
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index d7940af984b..7367cf7c0cb 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -165,7 +165,7 @@ tui_show_registers (struct reggroup *group)
 	  struct tui_gen_win_info *data_item_win;
           struct tui_win_element *win;
 
-	  data_item_win = &TUI_DATA_WIN->regs_content[i]
+	  data_item_win = TUI_DATA_WIN->regs_content[i]
             ->which_element.data_window;
           win = data_item_win->content[0];
           win->which_element.data.highlight = FALSE;
@@ -261,7 +261,7 @@ tui_show_register_group (struct reggroup *group,
 	    continue;
 
 	  data_item_win =
-            &TUI_DATA_WIN->regs_content[pos]->which_element.data_window;
+            TUI_DATA_WIN->regs_content[pos]->which_element.data_window;
           data = &data_item_win->content[0]->which_element.data;
           if (data)
             {
@@ -306,7 +306,7 @@ tui_display_registers_from (int start_element_no)
           int len;
 
           data_item_win
-	    = &TUI_DATA_WIN->regs_content[i]->which_element.data_window;
+	    = TUI_DATA_WIN->regs_content[i]->which_element.data_window;
           data = &data_item_win->content[0]->which_element.data;
           len = 0;
           p = data->content;
@@ -347,7 +347,7 @@ tui_display_registers_from (int start_element_no)
 	      struct tui_data_element *data_element_ptr;
 
 	      /* Create the window if necessary.  */
-	      data_item_win = &TUI_DATA_WIN->regs_content[i]
+	      data_item_win = TUI_DATA_WIN->regs_content[i]
                 ->which_element.data_window;
 	      data_element_ptr = &data_item_win->content[0]->which_element.data;
               if (data_item_win->handle != NULL
@@ -485,7 +485,7 @@ tui_check_register_values (struct frame_info *frame)
 	      struct tui_gen_win_info *data_item_win_ptr;
 	      int was_hilighted;
 
-	      data_item_win_ptr = &TUI_DATA_WIN->regs_content[i]->
+	      data_item_win_ptr = TUI_DATA_WIN->regs_content[i]->
                 which_element.data_window;
 	      data = &data_item_win_ptr->content[0]->which_element.data;
 	      was_hilighted = data->highlight;
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index dc40ab7736d..e4c1522a62d 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -1273,7 +1273,7 @@ tui_data_window::set_new_height (int height)
   for (int i = 0; i < generic.content_size; i++)
     {
       struct tui_gen_win_info *gen_win_info
-	= &generic.content[i]->which_element.data_window;
+	= generic.content[i]->which_element.data_window;
       tui_delete_win (gen_win_info->handle);
       gen_win_info->handle = NULL;
     }
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index 770baf857f6..1647527e240 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -54,7 +54,7 @@ tui_first_data_item_displayed (void)
       struct tui_gen_win_info *data_item_win;
 
       data_item_win
-	= &TUI_DATA_WIN->generic.content[i]->which_element.data_window;
+	= TUI_DATA_WIN->generic.content[i]->which_element.data_window;
       if (data_item_win->handle != NULL
 	  && data_item_win->is_visible)
 	element_no = i;
@@ -75,7 +75,7 @@ tui_delete_data_content_windows (void)
   for (i = 0; (i < TUI_DATA_WIN->generic.content_size); i++)
     {
       data_item_win_ptr
-	= &TUI_DATA_WIN->generic.content[i]->which_element.data_window;
+	= TUI_DATA_WIN->generic.content[i]->which_element.data_window;
       tui_delete_win (data_item_win_ptr->handle);
       data_item_win_ptr->handle = NULL;
       data_item_win_ptr->is_visible = false;
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index c1778289442..ccee399057a 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -43,7 +43,7 @@ tui_refresh_win (struct tui_gen_win_info *win_info)
 	{
 	  struct tui_gen_win_info *data_item_win_ptr;
 
-	  data_item_win_ptr = &win_info->content[i]->which_element.data_window;
+	  data_item_win_ptr = win_info->content[i]->which_element.data_window;
 	  if (data_item_win_ptr != NULL
 	      && data_item_win_ptr->handle != NULL)
 	    wrefresh (data_item_win_ptr->handle);
-- 
2.17.2

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

* [PATCH 48/66] Remove tui_alloc_win_info
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (36 preceding siblings ...)
  2019-06-23 23:26 ` [PATCH 43/66] Remove some TUI static allocations Tom Tromey
@ 2019-06-23 23:26 ` Tom Tromey
  2019-06-23 23:26 ` [PATCH 39/66] Change more TUI functions to take a tui_source_window_base Tom Tromey
                   ` (12 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

There is only a single caller of tui_alloc_win_info, and we're going
to add more "new" cases to that caller, so remove tui_alloc_win_info
and inline it into init_and_make_win.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (tui_alloc_win_info): Don't declare.
	* tui/tui-layout.c (init_and_make_win): Use "new" directly.
	* tui/tui-data.c (tui_alloc_win_info): Remove.
---
 gdb/ChangeLog        |  6 ++++++
 gdb/tui/tui-data.c   | 22 ----------------------
 gdb/tui/tui-data.h   |  1 -
 gdb/tui/tui-layout.c | 27 +++++++++++++++++++++++----
 4 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 7af9c19fa4d..9b247b46808 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -419,28 +419,6 @@ tui_source_window_base::tui_source_window_base (enum tui_win_type type)
   start_line_or_addr.u.addr = 0;
 }
 
-struct tui_win_info *
-tui_alloc_win_info (enum tui_win_type type)
-{
-  switch (type)
-    {
-    case SRC_WIN:
-      return new tui_source_window ();
-
-    case DISASSEM_WIN:
-      return new tui_disasm_window ();
-
-    case DATA_WIN:
-      return new tui_data_window ();
-
-    case CMD_WIN:
-      return new tui_cmd_window ();
-    }
-
-  gdb_assert_not_reached (_("Unhandled window type"));
-}
-
-
 /* Allocates the content and elements in a block.  */
 tui_win_content
 tui_alloc_content (int num_elements, enum tui_win_type type)
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index d875eb7bbc9..7392a4e4133 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -531,7 +531,6 @@ extern struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
 
 /* Data Manipulation Functions.  */
 extern void tui_initialize_static_data (void);
-extern struct tui_win_info *tui_alloc_win_info (enum tui_win_type);
 extern void tui_init_generic_part (struct tui_gen_win_info *);
 extern tui_win_content tui_alloc_content (int, enum tui_win_type);
 extern int tui_add_content_elements (struct tui_gen_win_info *, 
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 6507b06dd39..6d343921d4c 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -798,10 +798,29 @@ init_and_make_win (tui_gen_win_info *win_info,
 {
   if (win_info == NULL)
     {
-      if (tui_win_is_auxillary (win_type))
-	win_info = new tui_gen_win_info (win_type);
-      else
-	win_info = tui_alloc_win_info (win_type);
+      switch (win_type)
+	{
+	case SRC_WIN:
+	  win_info = new tui_source_window ();
+	  break;
+
+	case DISASSEM_WIN:
+	  win_info = new tui_disasm_window ();
+	  break;
+
+	case DATA_WIN:
+	  win_info = new tui_data_window ();
+	  break;
+
+	case CMD_WIN:
+	  win_info = new tui_cmd_window ();
+	  break;
+
+	default:
+	  gdb_assert (tui_win_is_auxillary (win_type));
+	  win_info = new tui_gen_win_info (win_type);
+	  break;
+	}
     }
 
   win_info->reset (win_type, height, width, origin_x, origin_y);
-- 
2.17.2

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

* [PATCH 33/66] Introduce refresh_window method
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (44 preceding siblings ...)
  2019-06-23 23:26 ` [PATCH 32/66] Derive tui_win_info from tui_gen_win_info Tom Tromey
@ 2019-06-23 23:26 ` Tom Tromey
  2019-06-23 23:26 ` [PATCH 47/66] Don't check window type in tui_set_win_focus_to Tom Tromey
                   ` (4 subsequent siblings)
  50 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-23 23:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This replaces tui_refresh_win with a new refresh_window method.  This
removes another spot that was checking the window's type.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_erase_source_content)
	(tui_show_source_content, tui_show_exec_info_content)
	(tui_erase_exec_info_content): Use refresh_window method.
	* tui/tui-wingeneral.h (tui_refresh_win): Don't declare.
	* tui/tui-wingeneral.c (tui_gen_win_info::refresh_window): Rename
	from tui_refresh_win.
	(tui_data_window::refresh_window): New method.
	(tui_win_info::refresh, tui_source_window_base::refresh)
	(tui_refresh_all): Use refresh_window method.
	* tui/tui-stack.c (tui_show_locator_content): Call refresh_window
	method.
	* tui/tui-regs.c (tui_display_register): Call refresh_window
	method.
	* tui/tui-layout.c (show_source_disasm_command)
	(show_source_or_disasm_and_command): Call refresh_window method.
	* tui/tui-data.h (struct tui_gen_win_info)
	(struct tui_data_window, struct tui_cmd_window) <refresh_window>:
	New method.
---
 gdb/ChangeLog            | 21 +++++++++++++++++++++
 gdb/tui/tui-data.h       |  9 +++++++++
 gdb/tui/tui-layout.c     |  4 ++--
 gdb/tui/tui-regs.c       |  2 +-
 gdb/tui/tui-stack.c      |  2 +-
 gdb/tui/tui-wingeneral.c | 40 +++++++++++++++++++---------------------
 gdb/tui/tui-wingeneral.h |  1 -
 gdb/tui/tui-winsource.c  | 10 +++++-----
 8 files changed, 58 insertions(+), 31 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 4d2f447c942..78c17102218 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -48,6 +48,9 @@ struct tui_gen_win_info
   {
   }
 
+  /* Call to refresh this window.  */
+  virtual void refresh_window ();
+
   /* Window handle.  */
   WINDOW *handle = nullptr;
   /* Type of window.  */
@@ -418,6 +421,8 @@ struct tui_data_window : public tui_win_info
 
   void set_new_height (int height) override;
 
+  void refresh_window () override;
+
   /* Start of data display content.  */
   tui_win_content data_content = NULL;
   int data_content_count = 0;
@@ -456,6 +461,10 @@ struct tui_cmd_window : public tui_win_info
 
   int max_height () const override;
 
+  void refresh_window () override
+  {
+  }
+
   int start_line = 0;
 
 protected:
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 9685d7fc4e5..d9e1617f19a 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -701,7 +701,7 @@ show_source_disasm_command (void)
 	  TUI_CMD_WIN->can_highlight = false;
 	  tui_make_visible (TUI_CMD_WIN);
 	}
-      tui_refresh_win (TUI_CMD_WIN);
+      TUI_CMD_WIN->refresh_window ();
       tui_set_current_layout_to (SRC_DISASSEM_COMMAND);
     }
 }
@@ -956,7 +956,7 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 	{
 	  tui_win_list[CMD_WIN] = make_command_window (cmd_height,
 						       src_height);
-	  tui_refresh_win (TUI_CMD_WIN);
+	  TUI_CMD_WIN->refresh_window ();
 	}
       else
 	{
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index cfb735c81d5..c748d513fc3 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -534,7 +534,7 @@ tui_display_register (struct tui_data_element *data,
 	   to code that causes the compiler to generate an unused-value
 	   warning.  */
 	(void) wstandend (win_info->handle);
-      tui_refresh_win (win_info);
+      win_info->refresh_window ();
     }
 }
 
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index a38971542eb..efa24453b65 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -267,7 +267,7 @@ tui_show_locator_content (void)
       waddstr (locator->handle, string);
       wclrtoeol (locator->handle);
       (void) wstandend (locator->handle);
-      tui_refresh_win (locator);
+      locator->refresh_window ();
       wmove (locator->handle, 0, 0);
       xfree (string);
       locator->content_in_use = TRUE;
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 06d7ad5a030..f1089a9f38a 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -31,38 +31,36 @@
 ** PUBLIC FUNCTIONS
 ***********************/
 
-/* Refresh the window.  */
+/* See tui-data.h.  */
+
 void
-tui_refresh_win (struct tui_gen_win_info *win_info)
+tui_gen_win_info::refresh_window ()
 {
-  if (win_info->type == DATA_WIN && win_info->content_size > 0)
-    {
-      int i;
+  if (handle != NULL)
+    wrefresh (handle);
+}
 
-      for (i = 0; (i < win_info->content_size); i++)
+/* See tui-data.h.  */
+
+void
+tui_data_window::refresh_window ()
+{
+  if (content_size > 0)
+    {
+      for (int i = 0; i < content_size; i++)
 	{
 	  struct tui_gen_win_info *data_item_win_ptr;
 
-	  data_item_win_ptr = win_info->content[i]->which_element.data_window;
+	  data_item_win_ptr = content[i]->which_element.data_window;
 	  if (data_item_win_ptr != NULL
 	      && data_item_win_ptr->handle != NULL)
 	    wrefresh (data_item_win_ptr->handle);
 	}
     }
-  else if (win_info->type == CMD_WIN)
-    {
-      /* Do nothing.  */
-    }
   else
-    {
-      if (win_info->handle != NULL)
-	wrefresh (win_info->handle);
-    }
-
-  return;
+    tui_gen_win_info::refresh_window ();
 }
 
-
 /* Function to delete the curses window, checking for NULL.  */
 void
 tui_delete_win (WINDOW *window)
@@ -260,7 +258,7 @@ void
 tui_win_info::refresh ()
 {
   touchwin (handle);
-  tui_refresh_win (this);
+  refresh_window ();
 }
 
 /* See tui-data.h.  */
@@ -269,7 +267,7 @@ void
 tui_source_window_base::refresh ()
 {
   touchwin (execution_info->handle);
-  tui_refresh_win (execution_info);
+  execution_info->refresh_window ();
   tui_win_info::refresh ();
 }
 
@@ -289,7 +287,7 @@ tui_refresh_all (struct tui_win_info **list)
   if (locator->is_visible)
     {
       touchwin (locator->handle);
-      tui_refresh_win (locator);
+      locator->refresh_window ();
     }
 }
 
diff --git a/gdb/tui/tui-wingeneral.h b/gdb/tui/tui-wingeneral.h
index 73b10d21311..15e61c94166 100644
--- a/gdb/tui/tui-wingeneral.h
+++ b/gdb/tui/tui-wingeneral.h
@@ -39,6 +39,5 @@ extern void tui_highlight_win (struct tui_win_info *);
 extern void tui_check_and_display_highlight_if_needed (struct tui_win_info *);
 extern void tui_refresh_all (struct tui_win_info **);
 extern void tui_delete_win (WINDOW *window);
-extern void tui_refresh_win (struct tui_gen_win_info *);
 
 #endif /* TUI_TUI_WINGENERAL_H */
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index f63526bb446..254c7e00dcb 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -260,7 +260,7 @@ tui_erase_source_content (struct tui_win_info *win_info,
 
 	  tui_set_source_content_nil (win_info, no_src_str);
 	}
-      tui_refresh_win (win_info);
+      win_info->refresh_window ();
     }
 }
 
@@ -305,7 +305,7 @@ tui_show_source_content (struct tui_win_info *win_info)
     tui_erase_source_content (win_info, TRUE);
 
   tui_check_and_display_highlight_if_needed (win_info);
-  tui_refresh_win (win_info);
+  win_info->refresh_window ();
   win_info->content_in_use = TRUE;
 }
 
@@ -550,14 +550,14 @@ tui_show_exec_info_content (struct tui_win_info *win_info)
   int cur_line;
 
   werase (exec_info->handle);
-  tui_refresh_win (exec_info);
+  exec_info->refresh_window ();
   for (cur_line = 1; (cur_line <= exec_info->content_size); cur_line++)
     mvwaddstr (exec_info->handle,
 	       cur_line,
 	       0,
 	       (char *) exec_info->content[cur_line - 1]
 			  ->which_element.simple_string);
-  tui_refresh_win (exec_info);
+  exec_info->refresh_window ();
   exec_info->content_in_use = TRUE;
 }
 
@@ -569,7 +569,7 @@ tui_erase_exec_info_content (struct tui_win_info *win_info)
   struct tui_gen_win_info *exec_info = base->execution_info;
 
   werase (exec_info->handle);
-  tui_refresh_win (exec_info);
+  exec_info->refresh_window ();
 }
 
 void
-- 
2.17.2

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

* Re: [PATCH 08/66] Remove tui_list
  2019-06-23 22:43 ` [PATCH 08/66] Remove tui_list Tom Tromey
@ 2019-06-24 14:12   ` Pedro Alves
  2019-06-24 15:12     ` Ruslan Kabatsayev
  2019-06-24 20:47     ` Tom Tromey
  0 siblings, 2 replies; 85+ messages in thread
From: Pedro Alves @ 2019-06-24 14:12 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 6/23/19 11:42 PM, Tom Tromey wrote:
> -static struct tui_list source_windows = {src_win_list, 0};
> +static struct std::vector<tui_win_info *> source_windows;

I usually prefer to drop "struct", but I can live with it.

However, I have to say that "struct std::vector" looks weird.  :-)

(There are other instances in the patch.)

Thanks,
Pedro Alves

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

* Re: [PATCH 40/66] Remove tui_scroll_direction enum
  2019-06-23 23:25 ` [PATCH 40/66] Remove tui_scroll_direction enum Tom Tromey
@ 2019-06-24 14:13   ` Pedro Alves
  2019-06-24 20:51     ` Tom Tromey
  0 siblings, 1 reply; 85+ messages in thread
From: Pedro Alves @ 2019-06-24 14:13 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 6/23/19 11:43 PM, Tom Tromey wrote:
> -  do_scroll_vertical (BACKWARD_SCROLL, num_to_scroll);
> +  do_scroll_vertical (- num_to_scroll);

No space after - (unary minus):

 https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#Whitespaces

>  
> -  do_scroll_horizontal (RIGHT_SCROLL, num_to_scroll);
> +  do_scroll_horizontal (- num_to_scroll);
>  }

Ditto.

Thanks,
Pedro Alves

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

* Re: [PATCH 49/66] Separate out execution-info window
  2019-06-23 23:26 ` [PATCH 49/66] Separate out execution-info window Tom Tromey
@ 2019-06-24 14:13   ` Pedro Alves
  2019-06-24 20:52     ` Tom Tromey
  0 siblings, 1 reply; 85+ messages in thread
From: Pedro Alves @ 2019-06-24 14:13 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 6/23/19 11:43 PM, Tom Tromey wrote:
> +  /* Get or allocate contents.  */
> +  tui_exec_info_content *maybe_allocate_content (int n_elements);
> +
> +  /* Allocate contents.  */

This "Allocate" here reads odd.  Did you mean "Get" instead of "Allocate"?

> +  const tui_exec_info_content *get_content () const
> +  {

Thanks,
Pedro Alves

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

* Re: [PATCH 14/66] Introduce has_locator method
  2019-06-23 22:44 ` [PATCH 14/66] Introduce has_locator method Tom Tromey
@ 2019-06-24 14:13   ` Pedro Alves
  2019-06-24 20:50     ` Tom Tromey
  0 siblings, 1 reply; 85+ messages in thread
From: Pedro Alves @ 2019-06-24 14:13 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 6/23/19 11:42 PM, Tom Tromey wrote:
> -  int has_locator;		/* Does locator belongs to this window?  */
> +  bool has_locator;		/* Does locator belongs to this window?  */

I'd vote to fix the comment's grammar at the same time.

/me reads rest of series.

I see now that the comment is moved around in the following patch,
though it remains incorrect.  Fine with me to leave it as is if
it helps.  It's not a big deal.  I'm only commenting on that
because I wanted to comment on something else, below.

>    /* Execution information window.  */
>    struct tui_gen_win_info *execution_info;
>    int horizontal_offset;	/* Used for horizontal scroll.  */
> @@ -285,6 +285,12 @@ public:
>    /* Clear the pertinent detail in the window.  */
>    virtual void clear_detail () = 0;
>  
> +  /* Return true if this window has a locator.  */

Should this "a locator" be "the locator", or ...

> +  virtual bool has_locator () const
> +  {
> +    return false;
> +  }

>    void clear_detail () override;
> +
> +  /* Return true if this window has the locator.  */
> +  bool has_locator () const override;

... should this here be "a locator"?

Thanks,
Pedro Alves

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

* Re: [PATCH 00/66] Clean up the TUI
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (48 preceding siblings ...)
  2019-06-23 23:26 ` [PATCH 44/66] Introduce enum tui_box Tom Tromey
@ 2019-06-24 14:23 ` Pedro Alves
  2019-06-24 16:47   ` Tom Tromey
  2019-06-24 18:49 ` [PATCH 50/66] Separate out locator window Tom Tromey
  50 siblings, 1 reply; 85+ messages in thread
From: Pedro Alves @ 2019-06-24 14:23 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 6/23/19 11:42 PM, Tom Tromey wrote:

> On the other hand, working on the TUI changed my mind about the TUI
> generally.  I've become a fan.  I think it would be good to improve
> the TUI for users, but to do that I think we first have to improve its
> code.

Ahah, welcome on board.  :-)

> 
> This series is a start at this.  It's already quite long,
> unfortunately, and yet is still incomplete.  Still, I think it is
> progress.  This series:
> 
> * Splits tui_win_info into subclasses, one per window type.
> 
> * Adds virtual methods, particularly in an attempt to remove all the
>   code that switches based on the type of the window.  This is
>   important to make it simpler to add new window types.
> 
> * Changes tui_gen_win_info into a real base class for tui_win_info.
> 
> * Removes the uses of unions from the window class hierarchy.
> 
> * Simplifies and C++-ifies various other minor things along the way.
> 

Hurray!

As I think you know, I attempted something like this over 7 years ago,
but doing it in C wasn't nearly as nice and I just gave up.  Being
a TUI user myself, I was so happy to see this series that I couldn't
resist and started reading it straight away.  Thanks so much for
working on this.

Looks like only patches up to #49 made it to the list (and I haven't
received a copy of the missing ones either).

Anyway, I skimmed patches #1-#49, and I sent a few responses
for some very minor things, but overall all of it seems good to me.
Looking forward to see this merged.

> I tested this by trying the various TUI features by hand.  However,
> I'm not sure I managed to test them all.

If you have this on a branch, I volunteer to test a bit.

Thanks,
Pedro Alves

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

* Re: [PATCH 08/66] Remove tui_list
  2019-06-24 14:12   ` Pedro Alves
@ 2019-06-24 15:12     ` Ruslan Kabatsayev
  2019-06-24 16:05       ` Pedro Alves
  2019-06-24 20:47     ` Tom Tromey
  1 sibling, 1 reply; 85+ messages in thread
From: Ruslan Kabatsayev @ 2019-06-24 15:12 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

Hello,

On Mon, 24 Jun 2019 at 17:12, Pedro Alves <palves@redhat.com> wrote:
>
> On 6/23/19 11:42 PM, Tom Tromey wrote:
> > -static struct tui_list source_windows = {src_win_list, 0};
> > +static struct std::vector<tui_win_info *> source_windows;
>
> I usually prefer to drop "struct", but I can live with it.
>
> However, I have to say that "struct std::vector" looks weird.  :-)

BTW, if you compile a declaration like "struct
std::vector<tui_win_info*> source_windows;" with clang++ (with -Wall
option), you'll get a warning "struct 'vector' was previously declared
as a class [-Wmismatched-tags]", so it's better to either drop the
"struct" or change it to "class".

>
> (There are other instances in the patch.)
>
> Thanks,
> Pedro Alves

Regards,
Ruslan

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

* Re: [PATCH 08/66] Remove tui_list
  2019-06-24 15:12     ` Ruslan Kabatsayev
@ 2019-06-24 16:05       ` Pedro Alves
  0 siblings, 0 replies; 85+ messages in thread
From: Pedro Alves @ 2019-06-24 16:05 UTC (permalink / raw)
  To: Ruslan Kabatsayev; +Cc: Tom Tromey, gdb-patches

On 6/24/19 4:11 PM, Ruslan Kabatsayev wrote:
> BTW, if you compile a declaration like "struct
> std::vector<tui_win_info*> source_windows;" with clang++ (with -Wall
> option), you'll get a warning "struct 'vector' was previously declared
> as a class [-Wmismatched-tags]", so it's better to either drop the
> "struct" or change it to "class".

GDB actually disables that warning explicitly, with -Wno-mismatched-tags
(gdb/warning.m4).

The mismatch is only important for MS's Visual Studio, since although
the C++ standard says struct and class are the same, IIRC Visual Studio
mangles struct vs class differently.  But, AFAIK, no one ever builds
GDB with Visual Studio.  At least, I've not heard of anyone
attempting it, though I guess it might be possible nowadays, with
Visual Studio offering much better standard C++ compliance than it used to.

Thanks,
Pedro Alves

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

* Re: [PATCH 00/66] Clean up the TUI
  2019-06-24 14:23 ` [PATCH 00/66] Clean up the TUI Pedro Alves
@ 2019-06-24 16:47   ` Tom Tromey
  2019-06-24 17:46     ` Pedro Alves
  2019-06-24 18:54     ` Tom Tromey
  0 siblings, 2 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 16:47 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

Pedro> As I think you know, I attempted something like this over 7 years ago,
Pedro> but doing it in C wasn't nearly as nice and I just gave up.

Yeah.  I looked at that branch but it seemed better to just redo it,
since we have C++ now.

Pedro> Looks like only patches up to #49 made it to the list (and I haven't
Pedro> received a copy of the missing ones either).

I don't know why :( I will send the remaining patches separately.

>> I tested this by trying the various TUI features by hand.  However,
>> I'm not sure I managed to test them all.

Pedro> If you have this on a branch, I volunteer to test a bit.

In my github, branch submit/tui-rewrite.

Tom

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

* Re: [PATCH 00/66] Clean up the TUI
  2019-06-24 16:47   ` Tom Tromey
@ 2019-06-24 17:46     ` Pedro Alves
  2019-06-24 18:54     ` Tom Tromey
  1 sibling, 0 replies; 85+ messages in thread
From: Pedro Alves @ 2019-06-24 17:46 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 6/24/19 5:47 PM, Tom Tromey wrote:

> Pedro> If you have this on a branch, I volunteer to test a bit.
> 
> In my github, branch submit/tui-rewrite.

I played a little, and didn't spot any behavior change so far.

Thanks,
Pedro Alves

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

* [PATCH 55/66] Remove tui_init_generic_part
  2019-06-24 18:49 ` [PATCH 50/66] Separate out locator window Tom Tromey
@ 2019-06-24 18:48   ` Tom Tromey
  2019-06-24 18:48   ` [PATCH 53/66] Remove two unused enum constants from tui_win_type Tom Tromey
                     ` (14 subsequent siblings)
  15 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 18:48 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_init_generic_part has a single caller, so simply inline it there.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (tui_init_generic_part): Don't declare.
	* tui/tui-data.c (tui_init_generic_part): Remove, moving
	contents...
	(tui_initialize_static_data): ...here.
---
 gdb/ChangeLog      |  7 +++++++
 gdb/tui/tui-data.c | 10 ++--------
 gdb/tui/tui-data.h |  1 -
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 7b58f9ed52d..e9d0308b86b 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -334,15 +334,9 @@ tui_partial_win_by_name (const char *name)
 
 
 void
-tui_initialize_static_data (void)
-{
-  tui_init_generic_part (tui_locator_win_info_ptr ());
-}
-
-
-void
-tui_init_generic_part (struct tui_gen_win_info *win)
+tui_initialize_static_data ()
 {
+  tui_gen_win_info *win = tui_locator_win_info_ptr ();
   win->width =
     win->height =
     win->origin.x =
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index e5fd7e610ea..2306abe1292 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -562,7 +562,6 @@ extern struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
 
 /* Data Manipulation Functions.  */
 extern void tui_initialize_static_data (void);
-extern void tui_init_generic_part (struct tui_gen_win_info *);
 extern tui_win_content tui_alloc_content (int, enum tui_win_type);
 extern int tui_add_content_elements (struct tui_gen_win_info *, 
 				     int);
-- 
2.17.2

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

* [PATCH 53/66] Remove two unused enum constants from tui_win_type
  2019-06-24 18:49 ` [PATCH 50/66] Separate out locator window Tom Tromey
  2019-06-24 18:48   ` [PATCH 55/66] Remove tui_init_generic_part Tom Tromey
@ 2019-06-24 18:48   ` Tom Tromey
  2019-06-24 18:49   ` [PATCH 58/66] Separate out data window Tom Tromey
                     ` (13 subsequent siblings)
  15 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 18:48 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This removes a couple of unused constants from enum tui_win_type.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui.h (enum tui_win_type) <MAX_WINDOWS, UNDEFINED_WIN>:
	Remove.
---
 gdb/ChangeLog | 5 +++++
 gdb/tui/tui.h | 5 +----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/gdb/tui/tui.h b/gdb/tui/tui.h
index 8f6ef64f496..b3321de9fdc 100644
--- a/gdb/tui/tui.h
+++ b/gdb/tui/tui.h
@@ -45,10 +45,7 @@ enum tui_win_type
   /* Auxillary windows.  */
   LOCATOR_WIN,
   EXEC_INFO_WIN,
-  DATA_ITEM_WIN,
-  /* This must ALWAYS be next to last.  */
-  MAX_WINDOWS,
-  UNDEFINED_WIN		/* LAST */
+  DATA_ITEM_WIN
 };
 
 /* GENERAL TUI FUNCTIONS */
-- 
2.17.2

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

* [PATCH 50/66] Separate out locator window
  2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
                   ` (49 preceding siblings ...)
  2019-06-24 14:23 ` [PATCH 00/66] Clean up the TUI Pedro Alves
@ 2019-06-24 18:49 ` Tom Tromey
  2019-06-24 18:48   ` [PATCH 55/66] Remove tui_init_generic_part Tom Tromey
                     ` (15 more replies)
  50 siblings, 16 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 18:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces a new subclass of tui_gen_win_info for the locator,
letting us remove another element from union tui_which_element.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (tui_refresh_all): Update.
	* tui/tui-win.c (tui_resize_all, tui_adjust_win_heights)
	(tui_source_window_base::set_new_height): Update.
	* tui/tui-stack.c (tui_make_status_line): Change parameter type.
	Update.
	(tui_set_locator_fullname, tui_set_locator_info)
	(tui_show_frame_info): Update.
	* tui/tui-source.c (tui_set_source_content)
	(tui_source_is_displayed): Update.
	* tui/tui-layout.c (show_source_disasm_command, show_data)
	(show_source_or_disasm_and_command): Update.
	* tui/tui-disasm.c (tui_set_disassem_content)
	(tui_get_begin_asm_address): Update.
	* tui/tui-data.h (struct tui_locator_element): Remove.
	(union tui_which_element) <locator>: Remove.
	(struct tui_locator_window): New.
	(tui_locator_win_info_ptr): Change return type.
	* tui/tui-data.c (_locator): Change type.
	(tui_locator_win_info_ptr): Change return type.
	(init_content_element): Remove LOCATOR_WIN case.  Add assert.
	(tui_alloc_content): Add assert.
---
 gdb/ChangeLog            | 24 +++++++++++++
 gdb/tui/tui-data.c       | 12 +++----
 gdb/tui/tui-data.h       | 34 ++++++++++--------
 gdb/tui/tui-disasm.c     | 14 ++++----
 gdb/tui/tui-layout.c     | 42 +++++++++++------------
 gdb/tui/tui-source.c     | 12 +++----
 gdb/tui/tui-stack.c      | 74 +++++++++++++---------------------------
 gdb/tui/tui-win.c        |  6 ++--
 gdb/tui/tui-wingeneral.c |  2 +-
 9 files changed, 107 insertions(+), 113 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index d74c4f7b2a9..4f5f710ba94 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -36,7 +36,7 @@ struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
 ****************************/
 static enum tui_layout_type current_layout = UNDEFINED_LAYOUT;
 static int term_height, term_width;
-static struct tui_gen_win_info _locator (LOCATOR_WIN);
+static struct tui_locator_window _locator;
 static struct std::vector<tui_source_window_base *> source_windows;
 static struct tui_win_info *win_with_focus = NULL;
 static struct tui_layout_def layout_def = {
@@ -185,7 +185,7 @@ tui_data_window::clear_detail ()
 
 /* Accessor for the locator win info.  Answers a pointer to the static
    locator win info struct.  */
-struct tui_gen_win_info *
+struct tui_locator_window *
 tui_locator_win_info_ptr (void)
 {
   return &_locator;
@@ -365,6 +365,7 @@ init_content_element (struct tui_win_element *element,
 		      enum tui_win_type type)
 {
   gdb_assert (type != EXEC_INFO_WIN);
+  gdb_assert (type != LOCATOR_WIN);
 
   switch (type)
     {
@@ -393,12 +394,6 @@ init_content_element (struct tui_win_element *element,
       element->which_element.data.highlight = FALSE;
       element->which_element.data.content = NULL;
       break;
-    case LOCATOR_WIN:
-      element->which_element.locator.full_name[0] =
-	element->which_element.locator.proc_name[0] = (char) 0;
-      element->which_element.locator.line_no = 0;
-      element->which_element.locator.addr = 0;
-      break;
     default:
       break;
     }
@@ -426,6 +421,7 @@ tui_alloc_content (int num_elements, enum tui_win_type type)
   int i;
 
   gdb_assert (type != EXEC_INFO_WIN);
+  gdb_assert (type != LOCATOR_WIN);
 
   content = XNEWVEC (struct tui_win_element *, num_elements);
 
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 23dd0fd9080..cdafc69a379 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -214,18 +214,6 @@ struct tui_command_element
 # define MAX_LOCATOR_ELEMENT_LEN        1024
 #endif
 
-/* Elements in the locator window content.  */
-struct tui_locator_element
-{
-  /* Resolved absolute filename as returned by symtab_to_fullname.  */
-  char full_name[MAX_LOCATOR_ELEMENT_LEN];
-  char proc_name[MAX_LOCATOR_ELEMENT_LEN];
-  int line_no;
-  CORE_ADDR addr;
-  /* Architecture associated with code at this location.  */
-  struct gdbarch *gdbarch;
-};
-
 /* Flags to tell what kind of breakpoint is at current line.  */
 #define TUI_BP_ENABLED      0x01
 #define TUI_BP_DISABLED     0x02
@@ -248,7 +236,6 @@ union tui_which_element
   struct tui_gen_win_info *data_window;	/* Data display elements.  */
   struct tui_data_element data;		/* Elements of data_window.  */
   struct tui_command_element command;	/* Command elements.  */
-  struct tui_locator_element locator;	/* Locator elements.  */
 };
 
 struct tui_win_element
@@ -284,6 +271,25 @@ private:
   tui_exec_info_content *m_content = nullptr;
 };
 
+/* Locator window class.  */
+
+struct tui_locator_window : public tui_gen_win_info
+{
+  tui_locator_window ()
+    : tui_gen_win_info (LOCATOR_WIN)
+  {
+    full_name[0] = 0;
+    proc_name[0] = 0;
+  }
+
+  char full_name[MAX_LOCATOR_ELEMENT_LEN];
+  char proc_name[MAX_LOCATOR_ELEMENT_LEN];
+  int line_no = 0;
+  CORE_ADDR addr = 0;
+  /* Architecture associated with code at this location.  */
+  struct gdbarch *gdbarch = nullptr;
+};
+
 /* This defines information about each logical window.  */
 struct tui_win_info : public tui_gen_win_info
 {
@@ -572,7 +578,7 @@ extern int tui_term_height (void);
 extern void tui_set_term_height_to (int);
 extern int tui_term_width (void);
 extern void tui_set_term_width_to (int);
-extern struct tui_gen_win_info *tui_locator_win_info_ptr (void);
+extern struct tui_locator_window *tui_locator_win_info_ptr (void);
 extern struct std::vector<tui_source_window_base *> &tui_source_windows ();
 extern void tui_clear_source_windows (void);
 extern void tui_clear_source_windows_detail (void);
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index b3d39ea8031..6b88d96a9db 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -169,7 +169,7 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
   int offset = TUI_DISASM_WIN->horizontal_offset;
   int max_lines, line_width;
   CORE_ADDR cur_pc;
-  struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+  struct tui_locator_window *locator = tui_locator_win_info_ptr ();
   int tab_len = tui_tab_width;
   struct tui_asm_line *asm_lines;
   int insn_pos;
@@ -185,7 +185,7 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
   base->gdbarch = gdbarch;
   base->start_line_or_addr.loa = LOA_ADDRESS;
   base->start_line_or_addr.u.addr = pc;
-  cur_pc = locator->content[0]->which_element.locator.addr;
+  cur_pc = locator->addr;
 
   /* Window size, excluding highlight box.  */
   max_lines = TUI_DISASM_WIN->height - 2;
@@ -316,15 +316,13 @@ tui_show_disassem_and_update_source (struct gdbarch *gdbarch,
 void
 tui_get_begin_asm_address (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
 {
-  struct tui_gen_win_info *locator;
-  struct tui_locator_element *element;
+  struct tui_locator_window *locator;
   struct gdbarch *gdbarch = get_current_arch ();
   CORE_ADDR addr;
 
   locator = tui_locator_win_info_ptr ();
-  element = &locator->content[0]->which_element.locator;
 
-  if (element->addr == 0)
+  if (locator->addr == 0)
     {
       struct bound_minimal_symbol main_symbol;
 
@@ -342,8 +340,8 @@ tui_get_begin_asm_address (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
     }
   else				/* The target is executing.  */
     {
-      gdbarch = element->gdbarch;
-      addr = element->addr;
+      gdbarch = locator->gdbarch;
+      addr = locator->addr;
     }
 
   *gdbarch_p = gdbarch;
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index a0745bf5384..cf8f13feeed 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -634,21 +634,21 @@ show_source_disasm_command (void)
 	  TUI_SRC_WIN->m_has_locator = false;
 	}
 
-      struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+      struct tui_locator_window *locator = tui_locator_win_info_ptr ();
+      gdb_assert (locator != nullptr);
 
       tui_show_source_content (TUI_SRC_WIN);
       if (TUI_DISASM_WIN == NULL)
 	{
 	  tui_win_list[DISASSEM_WIN]
 	    = make_disasm_window (asm_height, src_height - 1);
-	  locator
-	    = init_and_make_win (locator,
-				 LOCATOR_WIN,
-				 2 /* 1 */ ,
-				 tui_term_width (),
-				 0,
-				 (src_height + asm_height) - 1,
-				 DONT_BOX_WINDOW);
+	  init_and_make_win (locator,
+			     LOCATOR_WIN,
+			     2 /* 1 */ ,
+			     tui_term_width (),
+			     0,
+			     (src_height + asm_height) - 1,
+			     DONT_BOX_WINDOW);
 	}
       else
 	{
@@ -703,8 +703,9 @@ show_data (enum tui_layout_type new_layout)
   int total_height = (tui_term_height () - TUI_CMD_WIN->height);
   int src_height, data_height;
   enum tui_win_type win_type;
-  struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
 
+  struct tui_locator_window *locator = tui_locator_win_info_ptr ();
+  gdb_assert (locator != nullptr);
 
   data_height = total_height / 2;
   src_height = total_height - data_height;
@@ -725,8 +726,7 @@ show_data (enum tui_layout_type new_layout)
       else
 	tui_win_list[win_type]
 	  = make_disasm_window (src_height, data_height - 1);
-      locator
-	= init_and_make_win (locator,
+      init_and_make_win (locator,
 			     LOCATOR_WIN,
 			     2 /* 1 */ ,
 			     tui_term_width (),
@@ -870,7 +870,8 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
     {
       struct tui_win_info **win_info_ptr;
       int src_height, cmd_height;
-      struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+      struct tui_locator_window *locator = tui_locator_win_info_ptr ();
+      gdb_assert (locator != nullptr);
 
       if (TUI_CMD_WIN != NULL)
 	cmd_height = TUI_CMD_WIN->height;
@@ -890,14 +891,13 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 	    *win_info_ptr = make_source_window (src_height - 1, 0);
 	  else
 	    *win_info_ptr = make_disasm_window (src_height - 1, 0);
-	  locator
-	    = init_and_make_win (locator,
-				 LOCATOR_WIN,
-				 2 /* 1 */ ,
-				 tui_term_width (),
-				 0,
-				 src_height - 1,
-				 DONT_BOX_WINDOW);
+	  init_and_make_win (locator,
+			     LOCATOR_WIN,
+			     2 /* 1 */ ,
+			     tui_term_width (),
+			     0,
+			     src_height - 1,
+			     DONT_BOX_WINDOW);
 	  base = (tui_source_window_base *) *win_info_ptr;
 	}
       else
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 54e53cf8dbd..e1448dbd961 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -157,7 +157,7 @@ tui_set_source_content (struct symtab *s,
       else
 	{
 	  int cur_line_no, cur_line;
-	  struct tui_gen_win_info *locator
+	  struct tui_locator_window *locator
 	    = tui_locator_win_info_ptr ();
 	  struct tui_source_window_base *src
 	    = (struct tui_source_window_base *) TUI_SRC_WIN;
@@ -194,12 +194,9 @@ tui_set_source_content (struct symtab *s,
 	      element->which_element.source.line_or_addr.u.line_no =
 		cur_line_no;
 	      element->which_element.source.is_exec_point =
-		(filename_cmp (locator->content[0]
-			       ->which_element.locator.full_name,
+		(filename_cmp (locator->full_name,
 			       symtab_to_fullname (s)) == 0
-		 && cur_line_no
-		 == locator->content[0]
-		 ->which_element.locator.line_no);
+		 && cur_line_no == locator->line_no);
 
 	      xfree (TUI_SRC_WIN->content[cur_line]
 		     ->which_element.source.line);
@@ -300,8 +297,7 @@ tui_source_is_displayed (const char *fullname)
 {
   return (TUI_SRC_WIN != NULL
 	  && TUI_SRC_WIN->content_in_use 
-	  && (filename_cmp (tui_locator_win_info_ptr ()->content[0]
-			      ->which_element.locator.full_name,
+	  && (filename_cmp (tui_locator_win_info_ptr ()->full_name,
 			    fullname) == 0));
 }
 
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index efa24453b65..f761ac1f701 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -59,8 +59,8 @@ static void tui_update_command (const char *, int);
 /* Create the status line to display as much information as we can on
    this single line: target name, process number, current function,
    current line, current PC, SingleKey mode.  */
-static char*
-tui_make_status_line (struct tui_locator_element *loc)
+static char *
+tui_make_status_line (struct tui_locator_window *loc)
 {
   char *string;
   char line_buf[50], *pname;
@@ -246,17 +246,13 @@ void
 tui_show_locator_content (void)
 {
   char *string;
-  struct tui_gen_win_info *locator;
+  struct tui_locator_window *locator;
 
   locator = tui_locator_win_info_ptr ();
 
   if (locator != NULL && locator->handle != NULL)
     {
-      struct tui_win_element *element;
-
-      element = locator->content[0];
-
-      string = tui_make_status_line (&element->which_element.locator);
+      string = tui_make_status_line (locator);
       wmove (locator->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
@@ -279,18 +275,10 @@ tui_show_locator_content (void)
 static void
 tui_set_locator_fullname (const char *fullname)
 {
-  struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
-  struct tui_locator_element *element;
-
-  if (locator->content[0] == NULL)
-    {
-      tui_set_locator_info (NULL, fullname, NULL, 0, 0);
-      return;
-    }
+  struct tui_locator_window *locator = tui_locator_win_info_ptr ();
 
-  element = &locator->content[0]->which_element.locator;
-  element->full_name[0] = 0;
-  strcat_to_buf (element->full_name, MAX_LOCATOR_ELEMENT_LEN, fullname);
+  locator->full_name[0] = 0;
+  strcat_to_buf (locator->full_name, MAX_LOCATOR_ELEMENT_LEN, fullname);
 }
 
 /* Update the locator, with the provided arguments.
@@ -305,39 +293,28 @@ tui_set_locator_info (struct gdbarch *gdbarch,
 		      int lineno,
                       CORE_ADDR addr)
 {
-  struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
-  struct tui_locator_element *element;
+  struct tui_locator_window *locator = tui_locator_win_info_ptr ();
   int locator_changed_p = 0;
 
-  /* Allocate the locator content if necessary.  */
-  if (locator->content_size <= 0)
-    {
-      locator->content = tui_alloc_content (1, LOCATOR_WIN);
-      locator->content_size = 1;
-      locator_changed_p = 1;
-    }
-
   if (procname == NULL)
     procname = "";
 
   if (fullname == NULL)
     fullname = "";
 
-  element = &locator->content[0]->which_element.locator;
-
-  locator_changed_p |= strncmp (element->proc_name, procname,
+  locator_changed_p |= strncmp (locator->proc_name, procname,
 				MAX_LOCATOR_ELEMENT_LEN) != 0;
-  locator_changed_p |= lineno != element->line_no;
-  locator_changed_p |= addr != element->addr;
-  locator_changed_p |= gdbarch != element->gdbarch;
-  locator_changed_p |= strncmp (element->full_name, fullname,
+  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,
 				MAX_LOCATOR_ELEMENT_LEN) != 0;
 
-  element->proc_name[0] = (char) 0;
-  strcat_to_buf (element->proc_name, MAX_LOCATOR_ELEMENT_LEN, procname);
-  element->line_no = lineno;
-  element->addr = addr;
-  element->gdbarch = gdbarch;
+  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);
 
   return locator_changed_p;
@@ -366,7 +343,7 @@ tui_show_frame_info (struct frame_info *fi)
     {
       int start_line;
       CORE_ADDR low;
-      struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+      struct tui_locator_window *locator = tui_locator_win_info_ptr ();
       int source_already_displayed;
       CORE_ADDR pc;
 
@@ -398,12 +375,9 @@ tui_show_frame_info (struct frame_info *fi)
       start_line = 0;
       for (struct tui_source_window_base *win_info : tui_source_windows ())
 	{
-	  union tui_which_element *item;
-
-	  item = &locator->content[0]->which_element;
 	  if (win_info == TUI_SRC_WIN)
 	    {
-	      start_line = (item->locator.line_no -
+	      start_line = (locator->line_no -
 			   (win_info->viewport_height / 2)) + 1;
 	      if (start_line <= 0)
 		start_line = 1;
@@ -429,13 +403,13 @@ tui_show_frame_info (struct frame_info *fi)
 	      l.loa = LOA_LINE;
 	      l.u.line_no = start_line;
 	      if (!(source_already_displayed
-		    && tui_line_is_displayed (item->locator.line_no,
+		    && tui_line_is_displayed (locator->line_no,
 					      win_info, TRUE)))
 		tui_update_source_window (win_info, get_frame_arch (fi),
 					  sal.symtab, l, TRUE);
 	      else
 		{
-		  l.u.line_no = item->locator.line_no;
+		  l.u.line_no = locator->line_no;
 		  win_info->set_is_exec_point_at (l);
 		}
 	    }
@@ -447,13 +421,13 @@ tui_show_frame_info (struct frame_info *fi)
 
 		  a.loa = LOA_ADDRESS;
 		  a.u.addr = low;
-		  if (!tui_addr_is_displayed (item->locator.addr,
+		  if (!tui_addr_is_displayed (locator->addr,
 					      win_info, TRUE))
 		    tui_update_source_window (win_info, get_frame_arch (fi),
 					      sal.symtab, a, TRUE);
 		  else
 		    {
-		      a.u.addr = item->locator.addr;
+		      a.u.addr = locator->addr;
 		      win_info->set_is_exec_point_at (a);
 		    }
 		}
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 61b3a3251f1..64da13c3bb5 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -556,7 +556,7 @@ tui_resize_all (void)
       struct tui_win_info *win_with_focus = tui_win_with_focus ();
       struct tui_win_info *first_win;
       struct tui_win_info *second_win;
-      struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+      struct tui_locator_window *locator = tui_locator_win_info_ptr ();
       int win_type;
       int new_height, split_diff, cmd_split_diff, num_wins_displayed = 2;
 
@@ -1099,7 +1099,7 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 	{
 	  int diff;
 	  struct tui_win_info *win_info;
-	  struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+	  struct tui_locator_window *locator = tui_locator_win_info_ptr ();
 	  enum tui_layout_type cur_layout = tui_current_layout ();
 
 	  diff = (new_height - primary_win_info->height) * (-1);
@@ -1255,7 +1255,7 @@ tui_source_window_base::set_new_height (int height)
 
   if (has_locator ())
     {
-      tui_gen_win_info *gen_win_info = tui_locator_win_info_ptr ();
+      tui_locator_window *gen_win_info = tui_locator_win_info_ptr ();
       tui_make_invisible (gen_win_info);
       gen_win_info->origin.y = origin.y + height;
     }
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 98eb5abde16..9bc4e2b24ca 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -266,7 +266,7 @@ void
 tui_refresh_all (struct tui_win_info **list)
 {
   int type;
-  struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+  struct tui_locator_window *locator = tui_locator_win_info_ptr ();
 
   for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
     {
-- 
2.17.2

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

* [PATCH 60/66] Use bool for is_exec_point
  2019-06-24 18:49 ` [PATCH 50/66] Separate out locator window Tom Tromey
                     ` (6 preceding siblings ...)
  2019-06-24 18:49   ` [PATCH 63/66] Remove NULL checks before xfree Tom Tromey
@ 2019-06-24 18:49   ` Tom Tromey
  2019-06-24 18:49   ` [PATCH 64/66] Fix latent bug in set_is_exec_point_at Tom Tromey
                     ` (7 subsequent siblings)
  15 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 18:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_source_element::is_exec_point to be a bool.  I looked
at also changing "has_break", but it turns out that this field is used
inconsistently (sometimes as flags and sometimes as a bool), and so
needs more invesstigation before it can be changed.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_clear_source_content)
	(tui_source_window_base::set_is_exec_point_at): Update.
	* tui/tui-source.c (tui_set_source_content_nil): Update.
	* tui/tui-data.h (struct tui_source_element) <is_exec_point>: Now
	a bool.
	* tui/tui-data.c (init_content_element): Update.
---
 gdb/ChangeLog           |  9 +++++++++
 gdb/tui/tui-data.c      |  2 +-
 gdb/tui/tui-data.h      |  2 +-
 gdb/tui/tui-source.c    |  2 +-
 gdb/tui/tui-winsource.c | 12 ++++++------
 5 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 34d9272b413..429ce1c414c 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -368,7 +368,7 @@ init_content_element (struct tui_win_element *element,
       element->which_element.source.line = NULL;
       element->which_element.source.line_or_addr.loa = LOA_LINE;
       element->which_element.source.line_or_addr.u.line_no = 0;
-      element->which_element.source.is_exec_point = FALSE;
+      element->which_element.source.is_exec_point = false;
       element->which_element.source.has_break = FALSE;
       break;
     default:
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 2fe8c72af01..f0454c5d742 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -174,7 +174,7 @@ struct tui_source_element
 {
   char *line;
   struct tui_line_or_address line_or_addr;
-  int is_exec_point;
+  bool is_exec_point;
   int has_break;
 };
 
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index e1448dbd961..54e4e1be903 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -244,7 +244,7 @@ tui_set_source_content_nil (struct tui_win_info *win_info,
 
       element->which_element.source.line_or_addr.loa = LOA_LINE;
       element->which_element.source.line_or_addr.u.line_no = 0;
-      element->which_element.source.is_exec_point = FALSE;
+      element->which_element.source.is_exec_point = false;
       element->which_element.source.has_break = FALSE;
 
       /* Set the contents of the line to blank.  */
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 204fee13be9..f30c3d67632 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -218,7 +218,7 @@ tui_clear_source_content (struct tui_win_info *win_info,
 	  struct tui_win_element *element = win_info->content[i];
 
 	  element->which_element.source.has_break = FALSE;
-	  element->which_element.source.is_exec_point = FALSE;
+	  element->which_element.source.is_exec_point = false;
 	}
     }
 }
@@ -351,13 +351,13 @@ tui_source_window_base::do_scroll_horizontal (int num_to_scroll)
 void
 tui_source_window_base::set_is_exec_point_at (struct tui_line_or_address l)
 {
-  int changed = 0;
+  bool changed = false;
   int i;
 
   i = 0;
   while (i < content_size)
     {
-      int new_state;
+      bool new_state;
       struct tui_line_or_address content_loa =
 	content[i]->which_element.source.line_or_addr;
 
@@ -367,12 +367,12 @@ tui_source_window_base::set_is_exec_point_at (struct tui_line_or_address l)
       if (content_loa.loa == l.loa
 	  && ((l.loa == LOA_LINE && content_loa.u.line_no == l.u.line_no)
               || (content_loa.u.addr == l.u.addr)))
-        new_state = TRUE;
+        new_state = true;
       else
-	new_state = FALSE;
+	new_state = false;
       if (new_state != content[i]->which_element.source.is_exec_point)
         {
-          changed++;
+          changed = true;
           content[i]->which_element.source.is_exec_point = new_state;
           tui_show_source_line (this, i + 1);
         }
-- 
2.17.2

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

* [PATCH 56/66] Turn tui_first_data_item_displayed into a method
  2019-06-24 18:49 ` [PATCH 50/66] Separate out locator window Tom Tromey
                     ` (3 preceding siblings ...)
  2019-06-24 18:49   ` [PATCH 51/66] Remove layout_def::split Tom Tromey
@ 2019-06-24 18:49   ` Tom Tromey
  2019-06-24 18:49   ` [PATCH 52/66] Remove command from tui_which_element Tom Tromey
                     ` (10 subsequent siblings)
  15 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 18:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_first_data_item_displayed is only called from tui_data_window
methods, so turn it into a method as well.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-windata.h (tui_first_data_item_displayed): Don't
	declare.
	* tui/tui-windata.c (tui_data_window::first_data_item_displayed):
	Rename from tui_first_data_item_displayed.  Update.
	(tui_data_window::refresh_all)
	(tui_data_window::do_scroll_vertical): Update.
	* tui/tui-data.h (struct tui_data_window)
	<first_data_item_displayed>: Declare new method.
---
 gdb/ChangeLog         | 11 +++++++++++
 gdb/tui/tui-data.h    |  4 ++++
 gdb/tui/tui-windata.c | 23 ++++++++---------------
 gdb/tui/tui-windata.h |  1 -
 4 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 2306abe1292..3416c413dc2 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -505,6 +505,10 @@ protected:
   {
   }
   void do_make_visible_with_new_height () override;
+
+  /* Return the index of the first element displayed.  If none are
+     displayed, then return -1.  */
+  int first_data_item_displayed ();
 };
 
 struct tui_cmd_window : public tui_win_info
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index c5593454580..82436a31d92 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -42,25 +42,18 @@
 /* Answer the index first element displayed.  If none are displayed,
    then return (-1).  */
 int
-tui_first_data_item_displayed (void)
+tui_data_window::first_data_item_displayed ()
 {
-  int element_no = (-1);
-  int i;
-
-  for (i = 0; 
-       i < TUI_DATA_WIN->content_size && element_no < 0;
-       i++)
+  for (int i = 0; i < content_size; i++)
     {
       struct tui_gen_win_info *data_item_win;
 
-      data_item_win
-	= TUI_DATA_WIN->content[i]->which_element.data_window;
-      if (data_item_win->handle != NULL
-	  && data_item_win->is_visible)
-	element_no = i;
+      data_item_win = content[i]->which_element.data_window;
+      if (data_item_win->handle != NULL && data_item_win->is_visible)
+	return i;
     }
 
-  return element_no;
+  return -1;
 }
 
 
@@ -198,7 +191,7 @@ tui_data_window::refresh_all ()
   tui_erase_data_content (NULL);
   if (content_size > 0)
     {
-      int first_element = tui_first_data_item_displayed ();
+      int first_element = first_data_item_displayed ();
 
       if (first_element >= 0)	/* Re-use existing windows.  */
 	tui_display_data_from (first_element, TRUE);
@@ -248,7 +241,7 @@ tui_data_window::do_scroll_vertical (int num_to_scroll)
   int first_element_no;
   int first_line = (-1);
 
-  first_element_no = tui_first_data_item_displayed ();
+  first_element_no = first_data_item_displayed ();
   if (first_element_no < regs_content_count)
     first_line = tui_line_from_reg_element_no (first_element_no);
   else
diff --git a/gdb/tui/tui-windata.h b/gdb/tui/tui-windata.h
index c070f76c392..4aa8cb0b38c 100644
--- a/gdb/tui/tui-windata.h
+++ b/gdb/tui/tui-windata.h
@@ -28,7 +28,6 @@ extern void tui_erase_data_content (const char *);
 extern void tui_display_all_data (void);
 extern void tui_check_data_values (struct frame_info *);
 extern void tui_display_data_from_line (int);
-extern int tui_first_data_item_displayed (void);
 extern void tui_delete_data_content_windows (void);
 extern void tui_refresh_data_win (void);
 extern void tui_display_data_from (int, int);
-- 
2.17.2

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

* [PATCH 64/66] Fix latent bug in set_is_exec_point_at
  2019-06-24 18:49 ` [PATCH 50/66] Separate out locator window Tom Tromey
                     ` (7 preceding siblings ...)
  2019-06-24 18:49   ` [PATCH 60/66] Use bool for is_exec_point Tom Tromey
@ 2019-06-24 18:49   ` Tom Tromey
  2019-06-24 18:49   ` [PATCH 54/66] Separate out data item window Tom Tromey
                     ` (6 subsequent siblings)
  15 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 18:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

valgrind pointed out that the TUI was using uninitialized memory in
set_is_exec_point_at.  The bug is a missing check against LOA_ADDRESS,
causing gdb to examine the uninitialized bits of the "addr" field.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c
	(tui_source_window_base::set_is_exec_point_at): Add check against
	LOA_ADDRESS.
---
 gdb/ChangeLog           | 6 ++++++
 gdb/tui/tui-winsource.c | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 93c6253fd65..6ec1f1bc0b6 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -365,7 +365,7 @@ tui_source_window_base::set_is_exec_point_at (struct tui_line_or_address l)
 		  || content_loa.loa == LOA_ADDRESS);
       if (content_loa.loa == l.loa
 	  && ((l.loa == LOA_LINE && content_loa.u.line_no == l.u.line_no)
-              || (content_loa.u.addr == l.u.addr)))
+              || (l.loa == LOA_ADDRESS && content_loa.u.addr == l.u.addr)))
         new_state = true;
       else
 	new_state = false;
-- 
2.17.2

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

* [PATCH 63/66] Remove NULL checks before xfree
  2019-06-24 18:49 ` [PATCH 50/66] Separate out locator window Tom Tromey
                     ` (5 preceding siblings ...)
  2019-06-24 18:49   ` [PATCH 52/66] Remove command from tui_which_element Tom Tromey
@ 2019-06-24 18:49   ` Tom Tromey
  2019-06-24 18:49   ` [PATCH 60/66] Use bool for is_exec_point Tom Tromey
                     ` (8 subsequent siblings)
  15 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 18:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

A couple of spots in the TUI did a NULL check before an xfree.  This
isn't necessary, and most other cases were removed from gdb a while
ago.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-source.c (tui_set_source_content): Don't check before
	xfree.
	* tui/tui-disasm.c (tui_disassemble): Don't check before xfree.
---
 gdb/ChangeLog        | 6 ++++++
 gdb/tui/tui-disasm.c | 6 ++----
 gdb/tui/tui-source.c | 3 +--
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index d3d53d7c607..4899b1d03cf 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -59,10 +59,8 @@ tui_disassemble (struct gdbarch *gdbarch, struct tui_asm_line *asm_lines,
   /* Now construct each line.  */
   for (; count > 0; count--, asm_lines++)
     {
-      if (asm_lines->addr_string)
-        xfree (asm_lines->addr_string);
-      if (asm_lines->insn)
-        xfree (asm_lines->insn);
+      xfree (asm_lines->addr_string);
+      xfree (asm_lines->insn);
       
       print_address (gdbarch, pc, &gdb_dis_out);
       asm_lines->addr = pc;
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 4f82cbab2db..889b9509fec 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -163,8 +163,7 @@ tui_set_source_content (struct symtab *s,
 	    = (struct tui_source_window_base *) TUI_SRC_WIN;
 	  const char *s_filename = symtab_to_filename_for_display (s);
 
-	  if (TUI_SRC_WIN->title)
-	    xfree (TUI_SRC_WIN->title);
+	  xfree (TUI_SRC_WIN->title);
 	  TUI_SRC_WIN->title = xstrdup (s_filename);
 
 	  xfree (src->fullname);
-- 
2.17.2

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

* [PATCH 59/66] Fix "auxiliary" typo
  2019-06-24 18:49 ` [PATCH 50/66] Separate out locator window Tom Tromey
                     ` (12 preceding siblings ...)
  2019-06-24 18:49   ` [PATCH 61/66] More type safety for TUI source window functions Tom Tromey
@ 2019-06-24 18:49   ` Tom Tromey
  2019-06-24 18:49   ` [PATCH 62/66] Remove union tui_which_element Tom Tromey
  2019-06-24 18:49   ` [PATCH 65/66] Make tui_gen_win_info constructor protected Tom Tromey
  15 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 18:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The TUI has a function called tui_win_is_auxillary, but the word
should actually be spelled "auxiliary".  This fixes the typo.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (tui_gen_win_info::make_visible): Update.
	* tui/tui-win.c (make_invisible_and_set_new_height): Update.
	* tui/tui-layout.c (init_and_make_win): Update.
	* tui/tui.h (enum tui_win_type): Update.
	* tui/tui-data.h (tui_win_is_auxiliary): Rename from
	tui_win_is_auxillary.
	* tui/tui-data.c (tui_win_is_auxiliary): Rename from
	tui_win_is_auxillary.
---
 gdb/ChangeLog            | 11 +++++++++++
 gdb/tui/tui-data.c       |  2 +-
 gdb/tui/tui-data.h       |  2 +-
 gdb/tui/tui-layout.c     |  2 +-
 gdb/tui/tui-win.c        |  4 ++--
 gdb/tui/tui-wingeneral.c |  2 +-
 gdb/tui/tui.h            |  2 +-
 7 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index b957043a60f..34d9272b413 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -63,7 +63,7 @@ static void free_content_elements (tui_win_content,
 **********************************/
 
 int
-tui_win_is_auxillary (enum tui_win_type win_type)
+tui_win_is_auxiliary (enum tui_win_type win_type)
 {
   return (win_type > MAX_MAJOR_WINDOWS);
 }
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 112fbf4664b..2fe8c72af01 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -538,7 +538,7 @@ protected:
   void do_make_visible_with_new_height () override;
 };
 
-extern int tui_win_is_auxillary (enum tui_win_type win_type);
+extern int tui_win_is_auxiliary (enum tui_win_type win_type);
 
 
 /* Global Data.  */
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 61be48b877f..9fffba779a9 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -816,7 +816,7 @@ init_and_make_win (tui_gen_win_info *win_info,
 	  break;
 
 	default:
-	  gdb_assert (tui_win_is_auxillary (win_type));
+	  gdb_assert (tui_win_is_auxiliary (win_type));
 	  win_info = new tui_gen_win_info (win_type);
 	  break;
 	}
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 468e245351c..3837397d9e7 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -1274,7 +1274,7 @@ tui_data_window::set_new_height (int height)
     }
 }
 
-/* Function make the target window (and auxillary windows associated
+/* Function make the target window (and auxiliary windows associated
    with the targer) invisible, and set the new height and
    location.  */
 static void
@@ -1290,7 +1290,7 @@ make_invisible_and_set_new_height (struct tui_win_info *win_info,
   if (win_info != TUI_CMD_WIN)
     win_info->viewport_height--;
 
-  /* Now deal with the auxillary windows associated with win_info.  */
+  /* Now deal with the auxiliary windows associated with win_info.  */
   win_info->set_new_height (height);
 }
 
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 8f64e73e284..13063ae9356 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -172,7 +172,7 @@ tui_gen_win_info::make_visible (bool visible)
     {
       if (!is_visible)
 	{
-	  tui_make_window (this, (tui_win_is_auxillary (type)
+	  tui_make_window (this, (tui_win_is_auxiliary (type)
 				  ? DONT_BOX_WINDOW : BOX_WINDOW));
 	  is_visible = true;
 	}
diff --git a/gdb/tui/tui.h b/gdb/tui/tui.h
index b3321de9fdc..69ad60c98bf 100644
--- a/gdb/tui/tui.h
+++ b/gdb/tui/tui.h
@@ -42,7 +42,7 @@ enum tui_win_type
   CMD_WIN,
   /* This must ALWAYS be AFTER the major windows last.  */
   MAX_MAJOR_WINDOWS,
-  /* Auxillary windows.  */
+  /* Auxiliary windows.  */
   LOCATOR_WIN,
   EXEC_INFO_WIN,
   DATA_ITEM_WIN
-- 
2.17.2

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

* [PATCH 61/66] More type safety for TUI source window functions
  2019-06-24 18:49 ` [PATCH 50/66] Separate out locator window Tom Tromey
                     ` (11 preceding siblings ...)
  2019-06-24 18:49   ` [PATCH 57/66] Remove "data_content" and "data_content_count" from TUI data window Tom Tromey
@ 2019-06-24 18:49   ` Tom Tromey
  2019-06-24 18:49   ` [PATCH 59/66] Fix "auxiliary" typo Tom Tromey
                     ` (2 subsequent siblings)
  15 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 18:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

A few functions can only operate on a source or disassembly window.
This patch adds a bit more type safety to a few of these functions.
This simplifies a subsequent patch.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_clear_source_content)
	(tui_erase_source_content, tui_show_source_content): Change type
	of win_info.
	* tui/tui-winsource.c (tui_clear_source_content)
	(tui_erase_source_content, tui_show_source_content): Change type
	of win_info.
	* tui/tui-win.c (tui_resize_all, tui_adjust_win_heights): Update.
	* tui/tui-source.h (tui_set_source_content_nil): Change type of
	win_info.
	* tui/tui-source.c (tui_set_source_content_nil): Change type of
	win_info.
	* tui/tui-layout.c (show_source_or_disasm_and_command): Update.
---
 gdb/ChangeLog           | 15 +++++++++++++++
 gdb/tui/tui-layout.c    |  2 +-
 gdb/tui/tui-source.c    |  2 +-
 gdb/tui/tui-source.h    |  2 +-
 gdb/tui/tui-win.c       | 39 ++++++++++++++++++++++++---------------
 gdb/tui/tui-winsource.c |  6 +++---
 gdb/tui/tui-winsource.h |  6 +++---
 7 files changed, 48 insertions(+), 24 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 9fffba779a9..ad99ec9abd9 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -921,7 +921,7 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
       base->m_has_locator = true;
       tui_make_visible (locator);
       tui_show_locator_content ();
-      tui_show_source_content (*win_info_ptr);
+      tui_show_source_content (base);
 
       if (TUI_CMD_WIN == NULL)
 	{
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 54e4e1be903..fd89d98ba16 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -222,7 +222,7 @@ tui_set_source_content (struct symtab *s,
    source files cannot be accessed.  */
 
 void
-tui_set_source_content_nil (struct tui_win_info *win_info, 
+tui_set_source_content_nil (struct tui_source_window_base *win_info,
 			    const char *warning_string)
 {
   int line_width;
diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
index 7757373a2a2..9e1dc1a6e10 100644
--- a/gdb/tui/tui-source.h
+++ b/gdb/tui/tui-source.h
@@ -27,7 +27,7 @@
 struct symtab;
 struct tui_win_info;
 
-extern void tui_set_source_content_nil (struct tui_win_info *, 
+extern void tui_set_source_content_nil (struct tui_source_window_base *,
 					const char *);
 
 extern enum tui_status tui_set_source_content (struct symtab *, 
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 3837397d9e7..f88ec970781 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -556,6 +556,7 @@ tui_resize_all (void)
       struct tui_win_info *win_with_focus = tui_win_with_focus ();
       struct tui_win_info *first_win;
       struct tui_win_info *second_win;
+      tui_source_window_base *src_win;
       struct tui_locator_window *locator = tui_locator_win_info_ptr ();
       int win_type;
       int new_height, split_diff, cmd_split_diff, num_wins_displayed = 2;
@@ -592,7 +593,8 @@ tui_resize_all (void)
        {
 	case SRC_COMMAND:
 	case DISASSEM_COMMAND:
-	  first_win = tui_source_windows ()[0];
+	  src_win = tui_source_windows ()[0];
+	  first_win = src_win;
 	  first_win->width += width_diff;
 	  locator->width += width_diff;
 	  /* Check for invalid heights.  */
@@ -614,13 +616,14 @@ tui_resize_all (void)
 	  make_invisible_and_set_new_height (TUI_CMD_WIN, new_height);
 	  first_win->make_visible_with_new_height ();
 	  TUI_CMD_WIN->make_visible_with_new_height ();
-	  if (first_win->content_size <= 0)
-	    tui_erase_source_content (first_win, EMPTY_SOURCE_PROMPT);
+	  if (src_win->content_size <= 0)
+	    tui_erase_source_content (src_win, EMPTY_SOURCE_PROMPT);
 	  break;
 	default:
 	  if (cur_layout == SRC_DISASSEM_COMMAND)
 	    {
-	      first_win = TUI_SRC_WIN;
+	      src_win = TUI_SRC_WIN;
+	      first_win = src_win;
 	      first_win->width += width_diff;
 	      second_win = TUI_DISASM_WIN;
 	      second_win->width += width_diff;
@@ -629,7 +632,8 @@ tui_resize_all (void)
 	    {
 	      first_win = TUI_DATA_WIN;
 	      first_win->width += width_diff;
-	      second_win = tui_source_windows ()[0];
+	      src_win = tui_source_windows ()[0];
+	      second_win = src_win;
 	      second_win->width += width_diff;
 	    }
 	  /* Change the first window's height/width.  */
@@ -677,10 +681,8 @@ tui_resize_all (void)
 	  first_win->make_visible_with_new_height ();
 	  second_win->make_visible_with_new_height ();
 	  TUI_CMD_WIN->make_visible_with_new_height ();
-	  if (first_win->content_size <= 0)
-	    tui_erase_source_content (first_win, EMPTY_SOURCE_PROMPT);
-	  if (second_win->content_size <= 0)
-	    tui_erase_source_content (second_win, EMPTY_SOURCE_PROMPT);
+	  if (src_win->content_size <= 0)
+	    tui_erase_source_content (src_win, EMPTY_SOURCE_PROMPT);
 	  break;
 	}
       /* Now remove all invisible windows, and their content so that
@@ -1124,21 +1126,28 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 	      TUI_CMD_WIN->origin.y = locator->origin.y + 1;
 	      win_info->make_visible_with_new_height ();
 	      primary_win_info->make_visible_with_new_height ();
-	      if (src_win_info->content_size <= 0)
-		tui_erase_source_content (src_win_info, EMPTY_SOURCE_PROMPT);
+	      if ((src_win_info->type == SRC_WIN
+		   || src_win_info->type == DISASSEM_WIN)
+		  && src_win_info->content_size <= 0)
+		tui_erase_source_content
+		  ((tui_source_window_base *) src_win_info,
+		   EMPTY_SOURCE_PROMPT);
 	    }
 	  else
 	    {
 	      struct tui_win_info *first_win;
-	      struct tui_win_info *second_win;
+	      struct tui_source_window_base *second_win;
+	      tui_source_window_base *src1;
 
 	      if (cur_layout == SRC_DISASSEM_COMMAND)
 		{
-		  first_win = TUI_SRC_WIN;
+		  src1 = TUI_SRC_WIN;
+		  first_win = src1;
 		  second_win = TUI_DISASM_WIN;
 		}
 	      else
 		{
+		  src1 = nullptr;
 		  first_win = TUI_DATA_WIN;
 		  second_win = tui_source_windows ()[0];
 		}
@@ -1227,8 +1236,8 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 	      TUI_CMD_WIN->make_visible_with_new_height ();
 	      second_win->make_visible_with_new_height ();
 	      first_win->make_visible_with_new_height ();
-	      if (first_win->content_size <= 0)
-		tui_erase_source_content (first_win, EMPTY_SOURCE_PROMPT);
+	      if (src1 != nullptr && src1->content_size <= 0)
+		tui_erase_source_content (src1, EMPTY_SOURCE_PROMPT);
 	      if (second_win->content_size <= 0)
 		tui_erase_source_content (second_win, EMPTY_SOURCE_PROMPT);
 	    }
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index f30c3d67632..b11feff2a4d 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -204,7 +204,7 @@ tui_update_source_windows_with_line (struct symtab *s, int line)
 }
 
 void
-tui_clear_source_content (struct tui_win_info *win_info, 
+tui_clear_source_content (struct tui_source_window_base *win_info,
 			  int display_prompt)
 {
   if (win_info != NULL)
@@ -225,7 +225,7 @@ tui_clear_source_content (struct tui_win_info *win_info,
 
 
 void
-tui_erase_source_content (struct tui_win_info *win_info, 
+tui_erase_source_content (struct tui_source_window_base *win_info,
 			  int display_prompt)
 {
   int x_pos;
@@ -291,7 +291,7 @@ tui_show_source_line (struct tui_win_info *win_info, int lineno)
 }
 
 void
-tui_show_source_content (struct tui_win_info *win_info)
+tui_show_source_content (struct tui_source_window_base *win_info)
 {
   if (win_info->content_size > 0)
     {
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 09a9d5abf4a..f914c0aaf14 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -50,9 +50,9 @@ extern void tui_update_source_window_as_is (struct tui_source_window_base *,
 extern void tui_update_source_windows_with_addr (struct gdbarch *, CORE_ADDR);
 extern void tui_update_source_windows_with_line (struct symtab *, 
 						 int);
-extern void tui_clear_source_content (struct tui_win_info *, int);
-extern void tui_erase_source_content (struct tui_win_info *, int);
-extern void tui_show_source_content (struct tui_win_info *);
+extern void tui_clear_source_content (struct tui_source_window_base *, int);
+extern void tui_erase_source_content (struct tui_source_window_base *, int);
+extern void tui_show_source_content (struct tui_source_window_base *);
 extern void tui_set_exec_info_content (struct tui_source_window_base *);
 extern void tui_show_exec_info_content (struct tui_source_window_base *);
 extern void tui_erase_exec_info_content (struct tui_source_window_base *);
-- 
2.17.2

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

* [PATCH 62/66] Remove union tui_which_element
  2019-06-24 18:49 ` [PATCH 50/66] Separate out locator window Tom Tromey
                     ` (13 preceding siblings ...)
  2019-06-24 18:49   ` [PATCH 59/66] Fix "auxiliary" typo Tom Tromey
@ 2019-06-24 18:49   ` Tom Tromey
  2019-06-24 18:49   ` [PATCH 65/66] Make tui_gen_win_info constructor protected Tom Tromey
  15 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 18:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This removes union tui_which_element, instead moving the content
directly into tui_source_window_base.  This allows for the deletion of
a fair amount of code.  Now the TUI window hierarchy is more
type-safe.  In particular, there is never any confusion now about
which members are in use by which subtype.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_update_source_window_as_is)
	(tui_alloc_source_buffer, tui_line_is_displayed)
	(tui_addr_is_displayed): Change type of win_info.
	* tui/tui-winsource.c (tui_update_source_window_as_is)
	(tui_clear_source_content, tui_show_source_line)
	(tui_show_source_content, tui_source_window_base::refill)
	(tui_source_window_base::set_is_exec_point_at)
	(tui_source_window_base::set_is_exec_point_at)
	(tui_update_breakpoint_info, tui_set_exec_info_content): Update.
	(tui_alloc_source_buffer, tui_line_is_displayed)
	(tui_addr_is_displayed): Change type of win_info.  Update.
	* tui/tui-win.c (tui_resize_all, tui_adjust_win_heights)
	(tui_source_window_base::do_make_visible_with_new_height):
	Update.
	* tui/tui-source.c (tui_set_source_content)
	(tui_set_source_content_nil)
	(tui_source_window::do_scroll_vertical): Update.
	* tui/tui-layout.c (show_layout): Update.
	* tui/tui-disasm.c (tui_set_disassem_content)
	(tui_disasm_window::do_scroll_vertical): Update.
	* tui/tui-data.h (tui_win_content): Remove.
	(struct tui_gen_win_info) <content, content_size>: Remove.
	(struct tui_source_element): Add initializers and destructor.
	(union tui_which_element, struct tui_win_element): Remove.
	(struct tui_source_window_base) <content>: New field.
	(struct tui_data_window): Remove destructor.
	(tui_alloc_content, tui_free_win_content)
	(tui_free_all_source_wins_content): Don't declare.
	* tui/tui-data.c (tui_initialize_static_data): Update.
	(init_content_element, tui_alloc_content): Remove.
	(~tui_gen_win_info): Update.
	(~tui_data_window, tui_free_all_source_wins_content)
	(tui_free_win_content, free_content, free_content_elements):
	Remove.
---
 gdb/ChangeLog           |  37 +++++++++
 gdb/tui/tui-data.c      | 166 ----------------------------------------
 gdb/tui/tui-data.h      |  43 ++++-------
 gdb/tui/tui-disasm.c    |  19 ++---
 gdb/tui/tui-layout.c    |   1 -
 gdb/tui/tui-source.c    |  53 ++++++-------
 gdb/tui/tui-win.c       |  25 +++---
 gdb/tui/tui-winsource.c |  89 ++++++++++-----------
 gdb/tui/tui-winsource.h |  12 +--
 9 files changed, 144 insertions(+), 301 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 429ce1c414c..1ecf486e37f 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -46,18 +46,6 @@ static struct tui_layout_def layout_def = {
 static int win_resized = FALSE;
 
 
-/*********************************
-** Static function forward decls
-**********************************/
-static void free_content (tui_win_content, 
-			  int, 
-			  enum tui_win_type);
-static void free_content_elements (tui_win_content, 
-				   int, 
-				   enum tui_win_type);
-
-
-
 /*********************************
 ** PUBLIC FUNCTIONS
 **********************************/
@@ -339,43 +327,14 @@ tui_initialize_static_data ()
     win->origin.x =
     win->origin.y =
     win->viewport_height =
-    win->content_size =
     win->last_visible_line = 0;
   win->handle = NULL;
-  win->content = NULL;
   win->content_in_use = FALSE;
   win->is_visible = false;
   win->title = 0;
 }
 
 
-/* init_content_element().
- */
-static void
-init_content_element (struct tui_win_element *element, 
-		      enum tui_win_type type)
-{
-  gdb_assert (type != EXEC_INFO_WIN);
-  gdb_assert (type != LOCATOR_WIN);
-  gdb_assert (type != CMD_WIN);
-  gdb_assert (type != DATA_ITEM_WIN);
-  gdb_assert (type != DATA_WIN);
-
-  switch (type)
-    {
-    case SRC_WIN:
-    case DISASSEM_WIN:
-      element->which_element.source.line = NULL;
-      element->which_element.source.line_or_addr.loa = LOA_LINE;
-      element->which_element.source.line_or_addr.u.line_no = 0;
-      element->which_element.source.is_exec_point = false;
-      element->which_element.source.has_break = FALSE;
-      break;
-    default:
-      break;
-    }
-}
-
 tui_win_info::tui_win_info (enum tui_win_type type)
   : tui_gen_win_info (type)
 {
@@ -389,47 +348,12 @@ tui_source_window_base::tui_source_window_base (enum tui_win_type type)
   start_line_or_addr.u.addr = 0;
 }
 
-/* Allocates the content and elements in a block.  */
-tui_win_content
-tui_alloc_content (int num_elements, enum tui_win_type type)
-{
-  tui_win_content content;
-  struct tui_win_element *element_block_ptr;
-  int i;
-
-  gdb_assert (type != EXEC_INFO_WIN);
-  gdb_assert (type != LOCATOR_WIN);
-
-  content = XNEWVEC (struct tui_win_element *, num_elements);
-
-  /*
-   * All windows, except the data window, can allocate the
-   * elements in a chunk.  The data window cannot because items
-   * can be added/removed from the data display by the user at any
-   * time.
-   */
-  if (type != DATA_WIN)
-    {
-      element_block_ptr = XNEWVEC (struct tui_win_element, num_elements);
-      for (i = 0; i < num_elements; i++)
-	{
-	  content[i] = element_block_ptr;
-	  init_content_element (content[i], type);
-	  element_block_ptr++;
-	}
-    }
-
-  return content;
-}
-
-
 tui_gen_win_info::~tui_gen_win_info ()
 {
   if (handle != NULL)
     {
       tui_delete_win (handle);
       handle = NULL;
-      tui_free_win_content (this);
     }
   xfree (title);
 }
@@ -440,103 +364,13 @@ tui_source_window_base::~tui_source_window_base ()
   delete execution_info;
 }  
 
-tui_data_window::~tui_data_window ()
-{
-  if (content != NULL)
-    {
-      regs_column_count = 1;
-      display_regs = false;
-      content = NULL;
-      content_size = 0;
-    }
-}  
-
-void
-tui_free_all_source_wins_content ()
-{
-  for (tui_source_window_base *win_info : tui_source_windows ())
-    {
-      tui_free_win_content (win_info);
-      tui_free_win_content (win_info->execution_info);
-    }
-}
-
-
-void
-tui_free_win_content (struct tui_gen_win_info *win_info)
-{
-  if (win_info->content != NULL)
-    {
-      free_content (win_info->content,
-		   win_info->content_size,
-		   win_info->type);
-      win_info->content = NULL;
-    }
-  win_info->content_size = 0;
-}
-
-
 /**********************************
 ** LOCAL STATIC FUNCTIONS        **
 **********************************/
 
 
-static void
-free_content (tui_win_content content, 
-	      int content_size, 
-	      enum tui_win_type win_type)
-{
-  if (content != NULL)
-    {
-      free_content_elements (content, content_size, win_type);
-      xfree (content);
-    }
-}
-
-
 tui_data_item_window::~tui_data_item_window ()
 {
   xfree (value);
   xfree (content);
 }
-
-/* free_content_elements().
- */
-static void
-free_content_elements (tui_win_content content, 
-		       int content_size, 
-		       enum tui_win_type type)
-{
-  if (content != NULL)
-    {
-      int i;
-
-      if (type == DISASSEM_WIN)
-	{
-	  /* Free whole source block.  */
-	  xfree (content[0]->which_element.source.line);
-	}
-      else
-	{
-	  for (i = 0; i < content_size; i++)
-	    {
-	      struct tui_win_element *element;
-
-	      element = content[i];
-	      if (element != NULL)
-		{
-		  switch (type)
-		    {
-		    case SRC_WIN:
-		      xfree (element->which_element.source.line);
-		      break;
-		    default:
-		      break;
-		    }
-		}
-	    }
-	}
-      if (type != DATA_WIN && type != DATA_ITEM_WIN)
-	xfree (content[0]);	/* Free the element block.  */
-    }
-}
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index f0454c5d742..147149389cf 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -31,11 +31,6 @@ struct tui_point
   int x, y;
 };
 
-struct tui_win_element;
-
-/* This describes the content of the window.  */
-typedef struct tui_win_element **tui_win_content;
-
 /* Generic window information.  */
 struct tui_gen_win_info
 {
@@ -75,10 +70,6 @@ struct tui_gen_win_info
   int height = 0;
   /* Origin of window.  */
   struct tui_point origin = {0, 0};
-  /* Content of window.  */
-  tui_win_content content = nullptr;
-  /* Size of content (# of elements).  */
-  int content_size = 0;
   /* Can it be used, or is it already used?  */
   int content_in_use = FALSE;
   /* Viewport height.  */
@@ -172,10 +163,21 @@ struct tui_layout_def
 /* Elements in the Source/Disassembly Window.  */
 struct tui_source_element
 {
-  char *line;
+  tui_source_element ()
+  {
+    line_or_addr.loa = LOA_LINE;
+    line_or_addr.u.line_no = 0;
+  }
+
+  ~tui_source_element ()
+  {
+    xfree (line);
+  }
+
+  char *line = nullptr;
   struct tui_line_or_address line_or_addr;
-  bool is_exec_point;
-  int has_break;
+  bool is_exec_point = false;
+  int has_break = 0;
 };
 
 
@@ -200,17 +202,6 @@ struct tui_source_element
 
 typedef char tui_exec_info_content[TUI_EXECINFO_SIZE];
 
-/* An content element in a window.  */
-union tui_which_element
-{
-  struct tui_source_element source;	/* The source elements.  */
-};
-
-struct tui_win_element
-{
-  union tui_which_element which_element;
-};
-
 /* Execution info window class.  */
 
 struct tui_exec_info_window : public tui_gen_win_info
@@ -410,6 +401,8 @@ public:
 
   /* Architecture associated with code at this location.  */
   struct gdbarch *gdbarch = nullptr;
+
+  std::vector<tui_source_element> content;
 };
 
 /* A TUI source window.  */
@@ -461,7 +454,6 @@ struct tui_data_window : public tui_win_info
   {
   }
 
-  ~tui_data_window () override;
   DISABLE_COPY_AND_ASSIGN (tui_data_window);
 
   void clear_detail () override;
@@ -551,9 +543,6 @@ extern struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
 
 /* Data Manipulation Functions.  */
 extern void tui_initialize_static_data (void);
-extern tui_win_content tui_alloc_content (int, enum tui_win_type);
-extern void tui_free_win_content (struct tui_gen_win_info *);
-extern void tui_free_all_source_wins_content (void);
 extern struct tui_win_info *tui_partial_win_by_name (const char *);
 extern enum tui_layout_type tui_current_layout (void);
 extern void tui_set_current_layout_to (enum tui_layout_type);
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 6b88d96a9db..d3d53d7c607 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -219,27 +219,23 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
   line = (char*) alloca (insn_pos + insn_size + 1);
 
   /* Now construct each line.  */
+  TUI_DISASM_WIN->content.resize (max_lines);
   for (i = 0; i < max_lines; i++)
     {
-      struct tui_win_element *element;
-      struct tui_source_element *src;
       int cur_len;
 
-      element = TUI_DISASM_WIN->content[i];
-      src = &element->which_element.source;
+      tui_source_element *src = &TUI_DISASM_WIN->content[i];
       strcpy (line, asm_lines[i].addr_string);
       cur_len = strlen (line);
       memset (line + cur_len, ' ', insn_pos - cur_len);
       strcpy (line + insn_pos, asm_lines[i].insn);
 
       /* Now copy the line taking the offset into account.  */
+      xfree (src->line);
       if (strlen (line) > offset)
-	{
-	  strncpy (src->line, &line[offset], line_width);
-	  src->line[line_width] = '\0';
-	}
+	src->line = xstrndup (&line[offset], line_width);
       else
-        src->line[0] = '\0';
+	src->line = xstrdup ("");
 
       src->line_or_addr.loa = LOA_ADDRESS;
       src->line_or_addr.u.addr = asm_lines[i].addr;
@@ -254,7 +250,6 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
       xfree (asm_lines[i].addr_string);
       xfree (asm_lines[i].insn);
     }
-  TUI_DISASM_WIN->content_size = i;
   return TUI_SUCCESS;
 }
 
@@ -371,12 +366,12 @@ tui_get_low_disassembly_address (struct gdbarch *gdbarch,
 void
 tui_disasm_window::do_scroll_vertical (int num_to_scroll)
 {
-  if (content != NULL)
+  if (!content.empty ())
     {
       CORE_ADDR pc;
       struct tui_line_or_address val;
 
-      pc = content[0]->which_element.source.line_or_addr.u.addr;
+      pc = content[0].line_or_addr.u.addr;
       if (num_to_scroll >= 0)
 	num_to_scroll++;
       else
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index ad99ec9abd9..9dbb5995998 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -81,7 +81,6 @@ show_layout (enum tui_layout_type layout)
       /* Since the new layout may cause changes in window size, we
          should free the content and reallocate on next display of
          source/asm.  */
-      tui_free_all_source_wins_content ();
       tui_clear_source_windows ();
       if (layout == SRC_DATA_COMMAND 
 	  || layout == DISASSEM_DATA_COMMAND)
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index fd89d98ba16..4f82cbab2db 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -176,10 +176,11 @@ tui_set_source_content (struct symtab *s,
 	  cur_line_no = src->start_line_or_addr.u.line_no = line_no;
 
 	  const char *iter = srclines.c_str ();
+	  TUI_SRC_WIN->content.resize (nlines);
 	  while (cur_line < nlines)
 	    {
-	      struct tui_win_element *element
-		= TUI_SRC_WIN->content[cur_line];
+	      struct tui_source_element *element
+		= &TUI_SRC_WIN->content[cur_line];
 
 	      std::string text;
 	      if (*iter != '\0')
@@ -189,25 +190,20 @@ tui_set_source_content (struct symtab *s,
 
 	      /* Set whether element is the execution point
 		 and whether there is a break point on it.  */
-	      element->which_element.source.line_or_addr.loa =
-		LOA_LINE;
-	      element->which_element.source.line_or_addr.u.line_no =
-		cur_line_no;
-	      element->which_element.source.is_exec_point =
-		(filename_cmp (locator->full_name,
-			       symtab_to_fullname (s)) == 0
-		 && cur_line_no == locator->line_no);
-
-	      xfree (TUI_SRC_WIN->content[cur_line]
-		     ->which_element.source.line);
-	      TUI_SRC_WIN->content[cur_line]
-		->which_element.source.line
+	      element->line_or_addr.loa = LOA_LINE;
+	      element->line_or_addr.u.line_no = cur_line_no;
+	      element->is_exec_point
+		= (filename_cmp (locator->full_name,
+				 symtab_to_fullname (s)) == 0
+		   && cur_line_no == locator->line_no);
+
+	      xfree (TUI_SRC_WIN->content[cur_line].line);
+	      TUI_SRC_WIN->content[cur_line].line
 		= xstrdup (text.c_str ());
 
 	      cur_line++;
 	      cur_line_no++;
 	    }
-	  TUI_SRC_WIN->content_size = nlines;
 	  ret = TUI_SUCCESS;
 	}
     }
@@ -234,21 +230,21 @@ tui_set_source_content_nil (struct tui_source_window_base *win_info,
 
   /* Set to empty each line in the window, except for the one which
      contains the message.  */
-  while (curr_line < win_info->content_size)
+  while (curr_line < win_info->content.size ())
     {
       /* Set the information related to each displayed line to null:
          i.e. the line number is 0, there is no bp, it is not where
          the program is stopped.  */
 
-      struct tui_win_element *element = win_info->content[curr_line];
+      struct tui_source_element *element = &win_info->content[curr_line];
 
-      element->which_element.source.line_or_addr.loa = LOA_LINE;
-      element->which_element.source.line_or_addr.u.line_no = 0;
-      element->which_element.source.is_exec_point = false;
-      element->which_element.source.has_break = FALSE;
+      element->line_or_addr.loa = LOA_LINE;
+      element->line_or_addr.u.line_no = 0;
+      element->is_exec_point = false;
+      element->has_break = FALSE;
 
       /* Set the contents of the line to blank.  */
-      element->which_element.source.line[0] = (char) 0;
+      element->line[0] = (char) 0;
 
       /* If the current line is in the middle of the screen, then we
          want to display the 'no source available' message in it.
@@ -269,8 +265,8 @@ tui_set_source_content_nil (struct tui_source_window_base *win_info,
 	    xpos = (line_width - 1) / 2 - warning_length;
 
 	  src_line = xstrprintf ("%s%s", n_spaces (xpos), warning_string);
-	  xfree (element->which_element.source.line);
-	  element->which_element.source.line = src_line;
+	  xfree (element->line);
+	  element->line = src_line;
 	}
 
       curr_line++;
@@ -306,7 +302,7 @@ tui_source_is_displayed (const char *fullname)
 void
 tui_source_window::do_scroll_vertical (int num_to_scroll)
 {
-  if (content != NULL)
+  if (!content.empty ())
     {
       struct tui_line_or_address l;
       struct symtab *s;
@@ -318,13 +314,12 @@ tui_source_window::do_scroll_vertical (int num_to_scroll)
 	s = cursal.symtab;
 
       l.loa = LOA_LINE;
-      l.u.line_no = content[0]->which_element.source.line_or_addr.u.line_no
+      l.u.line_no = content[0].line_or_addr.u.line_no
 	+ num_to_scroll;
       if (l.u.line_no > s->nlines)
 	/* line = s->nlines - win_info->content_size + 1; */
 	/* elz: fix for dts 23398.  */
-	l.u.line_no
-	  = content[0]->which_element.source.line_or_addr.u.line_no;
+	l.u.line_no = content[0].line_or_addr.u.line_no;
       if (l.u.line_no <= 0)
 	l.u.line_no = 1;
 
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index f88ec970781..4763184b211 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -616,7 +616,7 @@ tui_resize_all (void)
 	  make_invisible_and_set_new_height (TUI_CMD_WIN, new_height);
 	  first_win->make_visible_with_new_height ();
 	  TUI_CMD_WIN->make_visible_with_new_height ();
-	  if (src_win->content_size <= 0)
+	  if (src_win->content.empty ())
 	    tui_erase_source_content (src_win, EMPTY_SOURCE_PROMPT);
 	  break;
 	default:
@@ -681,7 +681,7 @@ tui_resize_all (void)
 	  first_win->make_visible_with_new_height ();
 	  second_win->make_visible_with_new_height ();
 	  TUI_CMD_WIN->make_visible_with_new_height ();
-	  if (src_win->content_size <= 0)
+	  if (src_win->content.empty ())
 	    tui_erase_source_content (src_win, EMPTY_SOURCE_PROMPT);
 	  break;
 	}
@@ -1127,11 +1127,14 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 	      win_info->make_visible_with_new_height ();
 	      primary_win_info->make_visible_with_new_height ();
 	      if ((src_win_info->type == SRC_WIN
-		   || src_win_info->type == DISASSEM_WIN)
-		  && src_win_info->content_size <= 0)
-		tui_erase_source_content
-		  ((tui_source_window_base *) src_win_info,
-		   EMPTY_SOURCE_PROMPT);
+		   || src_win_info->type == DISASSEM_WIN))
+		{
+		  tui_source_window_base *src_base
+		    = (tui_source_window_base *) src_win_info;
+		  if (src_base->content.empty ())
+		    tui_erase_source_content (src_base,
+					      EMPTY_SOURCE_PROMPT);
+		}
 	    }
 	  else
 	    {
@@ -1236,9 +1239,9 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 	      TUI_CMD_WIN->make_visible_with_new_height ();
 	      second_win->make_visible_with_new_height ();
 	      first_win->make_visible_with_new_height ();
-	      if (src1 != nullptr && src1->content_size <= 0)
+	      if (src1 != nullptr && src1->content.empty ())
 		tui_erase_source_content (src1, EMPTY_SOURCE_PROMPT);
-	      if (second_win->content_size <= 0)
+	      if (second_win->content.empty ())
 		tui_erase_source_content (second_win, EMPTY_SOURCE_PROMPT);
 	    }
 	}
@@ -1319,16 +1322,14 @@ tui_win_info::make_visible_with_new_height ()
 void
 tui_source_window_base::do_make_visible_with_new_height ()
 {
-  tui_free_win_content (execution_info);
   tui_make_visible (execution_info);
-  if (content != NULL)
+  if (!content.empty ())
     {
       struct tui_line_or_address line_or_addr;
       struct symtab_and_line cursal
 	= get_current_source_symtab_and_line ();
 
       line_or_addr = start_line_or_addr;
-      tui_free_win_content (this);
       tui_update_source_window (this, gdbarch,
 				cursal.symtab, line_or_addr, TRUE);
     }
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index b11feff2a4d..93c6253fd65 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -113,7 +113,7 @@ tui_update_source_window_as_is (struct tui_source_window_base *win_info,
 	  symtab_and_line sal;
 
 	  sal.line = line_or_addr.u.line_no +
-	    (win_info->content_size - 2);
+	    (win_info->content.size () - 2);
 	  sal.symtab = s;
 	  sal.pspace = SYMTAB_PSPACE (s);
 	  set_current_source_symtab_and_line (sal);
@@ -213,12 +213,12 @@ tui_clear_source_content (struct tui_source_window_base *win_info,
 
       win_info->content_in_use = FALSE;
       tui_erase_source_content (win_info, display_prompt);
-      for (i = 0; i < win_info->content_size; i++)
+      for (i = 0; i < win_info->content.size (); i++)
 	{
-	  struct tui_win_element *element = win_info->content[i];
+	  struct tui_source_element *element = &win_info->content[i];
 
-	  element->which_element.source.has_break = FALSE;
-	  element->which_element.source.is_exec_point = false;
+	  element->has_break = FALSE;
+	  element->is_exec_point = false;
 	}
     }
 }
@@ -266,19 +266,19 @@ tui_erase_source_content (struct tui_source_window_base *win_info,
 
 /* Redraw the complete line of a source or disassembly window.  */
 static void
-tui_show_source_line (struct tui_win_info *win_info, int lineno)
+tui_show_source_line (struct tui_source_window_base *win_info, int lineno)
 {
-  struct tui_win_element *line;
+  struct tui_source_element *line;
   int x;
 
-  line = win_info->content[lineno - 1];
-  if (line->which_element.source.is_exec_point)
+  line = &win_info->content[lineno - 1];
+  if (line->is_exec_point)
     tui_set_reverse_mode (win_info->handle, true);
 
   wmove (win_info->handle, lineno, 1);
-  tui_puts (line->which_element.source.line,
+  tui_puts (line->line,
 	    win_info->handle);
-  if (line->which_element.source.is_exec_point)
+  if (line->is_exec_point)
     tui_set_reverse_mode (win_info->handle, false);
 
   /* Clear to end of line but stop before the border.  */
@@ -293,11 +293,11 @@ tui_show_source_line (struct tui_win_info *win_info, int lineno)
 void
 tui_show_source_content (struct tui_source_window_base *win_info)
 {
-  if (win_info->content_size > 0)
+  if (!win_info->content.empty ())
     {
       int lineno;
 
-      for (lineno = 1; lineno <= win_info->content_size; lineno++)
+      for (lineno = 1; lineno <= win_info->content.size (); lineno++)
         tui_show_source_line (win_info, lineno);
     }
   else
@@ -324,8 +324,7 @@ tui_source_window_base::refill ()
     }
 
   tui_update_source_window_as_is (this, gdbarch, s,
-				  content[0]
-				    ->which_element.source.line_or_addr,
+				  content[0].line_or_addr,
 				  FALSE);
 }
 
@@ -334,7 +333,7 @@ tui_source_window_base::refill ()
 void
 tui_source_window_base::do_scroll_horizontal (int num_to_scroll)
 {
-  if (content != NULL)
+  if (!content.empty ())
     {
       int offset = horizontal_offset + num_to_scroll;
       if (offset < 0)
@@ -355,11 +354,11 @@ tui_source_window_base::set_is_exec_point_at (struct tui_line_or_address l)
   int i;
 
   i = 0;
-  while (i < content_size)
+  while (i < content.size ())
     {
       bool new_state;
       struct tui_line_or_address content_loa =
-	content[i]->which_element.source.line_or_addr;
+	content[i].line_or_addr;
 
       gdb_assert (l.loa == LOA_ADDRESS || l.loa == LOA_LINE);
       gdb_assert (content_loa.loa == LOA_LINE
@@ -370,10 +369,10 @@ tui_source_window_base::set_is_exec_point_at (struct tui_line_or_address l)
         new_state = true;
       else
 	new_state = false;
-      if (new_state != content[i]->which_element.source.is_exec_point)
+      if (new_state != content[i].is_exec_point)
         {
           changed = true;
-          content[i]->which_element.source.is_exec_point = new_state;
+          content[i].is_exec_point = new_state;
           tui_show_source_line (this, i + 1);
         }
       i++;
@@ -405,21 +404,21 @@ tui_update_all_breakpoint_info ()
    refreshed.  */
 
 int
-tui_update_breakpoint_info (struct tui_win_info *win, 
+tui_update_breakpoint_info (struct tui_source_window_base *win, 
 			    int current_only)
 {
   int i;
   int need_refresh = 0;
   tui_source_window_base *src = (tui_source_window_base *) win;
 
-  for (i = 0; i < win->content_size; i++)
+  for (i = 0; i < win->content.size (); i++)
     {
       struct breakpoint *bp;
       extern struct breakpoint *breakpoint_chain;
       int mode;
       struct tui_source_element *line;
 
-      line = &win->content[i]->which_element.source;
+      line = &win->content[i];
       if (current_only && !line->is_exec_point)
          continue;
 
@@ -493,20 +492,20 @@ tui_set_exec_info_content (struct tui_source_window_base *win_info)
 	= win_info->execution_info->maybe_allocate_content (win_info->height);
 
       tui_update_breakpoint_info (win_info, 1);
-      for (int i = 0; i < win_info->content_size; i++)
+      for (int i = 0; i < win_info->content.size (); i++)
 	{
 	  tui_exec_info_content &element = content[i];
-	  struct tui_win_element *src_element;
+	  struct tui_source_element *src_element;
 	  int mode;
 
-	  src_element = win_info->content[i];
+	  src_element = &win_info->content[i];
 
 	  memset (element, ' ', sizeof (tui_exec_info_content));
 	  element[TUI_EXECINFO_SIZE - 1] = 0;
 
 	  /* Now update the exec info content based upon the state
 	     of each line as indicated by the source content.  */
-	  mode = src_element->which_element.source.has_break;
+	  mode = src_element->has_break;
 	  if (mode & TUI_BP_HIT)
 	    element[TUI_BP_HIT_POS] = (mode & TUI_BP_HARDWARE) ? 'H' : 'B';
 	  else if (mode & (TUI_BP_ENABLED | TUI_BP_DISABLED))
@@ -517,7 +516,7 @@ tui_set_exec_info_content (struct tui_source_window_base *win_info)
 	  else if (mode & TUI_BP_DISABLED)
 	    element[TUI_BP_BREAK_POS] = '-';
 
-	  if (src_element->which_element.source.is_exec_point)
+	  if (src_element->is_exec_point)
 	    element[TUI_EXEC_POS] = '>';
 	}
     }
@@ -532,7 +531,7 @@ tui_show_exec_info_content (struct tui_source_window_base *win_info)
 
   werase (exec_info->handle);
   exec_info->refresh_window ();
-  for (int cur_line = 1; (cur_line <= win_info->content_size); cur_line++)
+  for (int cur_line = 1; cur_line <= win_info->content.size (); cur_line++)
     mvwaddstr (exec_info->handle,
 	       cur_line,
 	       0,
@@ -567,7 +566,7 @@ tui_update_exec_info (struct tui_source_window_base *win_info)
 }
 
 void
-tui_alloc_source_buffer (struct tui_win_info *win_info)
+tui_alloc_source_buffer (struct tui_source_window_base *win_info)
 {
   int i, line_width, max_lines;
 
@@ -577,13 +576,11 @@ tui_alloc_source_buffer (struct tui_win_info *win_info)
   line_width = win_info->width - 2 + 1;
 
   /* Allocate the buffer for the source lines.  */
-  if (win_info->content == NULL)
+  win_info->content.resize (max_lines);
+  for (i = 0; i < max_lines; i++)
     {
-      /* Allocate the content list.  */
-      win_info->content = tui_alloc_content (max_lines, SRC_WIN);
-      for (i = 0; i < max_lines; i++)
-	win_info->content[i]->which_element.source.line
-	  = (char *) xmalloc (line_width);
+      if (win_info->content[i].line == nullptr)
+	win_info->content[i].line = (char *) xmalloc (line_width);
     }
 }
 
@@ -592,7 +589,7 @@ tui_alloc_source_buffer (struct tui_win_info *win_info)
    in the current source window.  */
 int
 tui_line_is_displayed (int line, 
-		       struct tui_win_info *win_info,
+		       struct tui_source_window_base *win_info,
 		       int check_threshold)
 {
   int is_displayed = FALSE;
@@ -603,14 +600,12 @@ tui_line_is_displayed (int line,
   else
     threshold = 0;
   i = 0;
-  while (i < win_info->content_size - threshold
+  while (i < win_info->content.size () - threshold
 	 && !is_displayed)
     {
       is_displayed
-	= win_info->content[i]
-	    ->which_element.source.line_or_addr.loa == LOA_LINE
-	  && win_info->content[i]
-	       ->which_element.source.line_or_addr.u.line_no == line;
+	= win_info->content[i].line_or_addr.loa == LOA_LINE
+	  && win_info->content[i].line_or_addr.u.line_no == line;
       i++;
     }
 
@@ -622,7 +617,7 @@ tui_line_is_displayed (int line,
    in the current source window.  */
 int
 tui_addr_is_displayed (CORE_ADDR addr, 
-		       struct tui_win_info *win_info,
+		       struct tui_source_window_base *win_info,
 		       int check_threshold)
 {
   int is_displayed = FALSE;
@@ -633,14 +628,12 @@ tui_addr_is_displayed (CORE_ADDR addr,
   else
     threshold = 0;
   i = 0;
-  while (i < win_info->content_size - threshold
+  while (i < win_info->content.size () - threshold
 	 && !is_displayed)
     {
       is_displayed
-	= win_info->content[i]
-	    ->which_element.source.line_or_addr.loa == LOA_ADDRESS
-	  && win_info->content[i]
-	       ->which_element.source.line_or_addr.u.addr == addr;
+	= win_info->content[i].line_or_addr.loa == LOA_ADDRESS
+	  && win_info->content[i].line_or_addr.u.addr == addr;
       i++;
     }
 
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index f914c0aaf14..adf4af45359 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -34,7 +34,7 @@ extern void tui_update_all_breakpoint_info (void);
 /* Scan the source window and the breakpoints to update the hasBreak
    information for each line.  Returns 1 if something changed and the
    execution window must be refreshed.  */
-extern int tui_update_breakpoint_info (struct tui_win_info *win,
+extern int tui_update_breakpoint_info (struct tui_source_window_base *win,
 				       int current_only);
 
 /* Function to display the "main" routine.  */
@@ -59,12 +59,12 @@ extern void tui_erase_exec_info_content (struct tui_source_window_base *);
 extern void tui_clear_exec_info_content (struct tui_source_window_base *);
 extern void tui_update_exec_info (struct tui_source_window_base *);
 
-extern void tui_alloc_source_buffer (struct tui_win_info *);
-extern int tui_line_is_displayed (int, 
-				  struct tui_win_info *, 
+extern void tui_alloc_source_buffer (struct tui_source_window_base *);
+extern int tui_line_is_displayed (int,
+				  struct tui_source_window_base *,
 				  int);
-extern int tui_addr_is_displayed (CORE_ADDR, 
-				  struct tui_win_info *, 
+extern int tui_addr_is_displayed (CORE_ADDR,
+				  struct tui_source_window_base *,
 				  int);
 
 
-- 
2.17.2

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

* [PATCH 58/66] Separate out data window
  2019-06-24 18:49 ` [PATCH 50/66] Separate out locator window Tom Tromey
  2019-06-24 18:48   ` [PATCH 55/66] Remove tui_init_generic_part Tom Tromey
  2019-06-24 18:48   ` [PATCH 53/66] Remove two unused enum constants from tui_win_type Tom Tromey
@ 2019-06-24 18:49   ` Tom Tromey
  2019-06-24 18:49   ` [PATCH 51/66] Remove layout_def::split Tom Tromey
                     ` (12 subsequent siblings)
  15 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 18:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This removes "data_window" from union tui_which_element and updates
the uses.  It also changes how tui_data_window refers to the register
data, and changes it not to need the "content" field at all (though as
this is in a base class, it can't yet be removed).

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (tui_data_window::refresh_window): Update.
	* tui/tui-windata.c (tui_data_window::first_data_item_displayed)
	(tui_delete_data_content_windows, tui_display_all_data)
	(tui_data_window::do_scroll_vertical, tui_display_data_from):
	Update.
	* tui/tui-win.c (tui_data_window::set_new_height): Simplify.
	* tui/tui-regs.c (tui_last_regs_line_no)
	(tui_line_from_reg_element_no, tui_first_reg_element_no_inline)
	(tui_show_registers): Update.
	(tui_show_register_group): Return void.  Update.
	(tui_display_registers_from, tui_display_reg_element_at_line)
	(tui_display_registers_from_line, tui_check_register_values):
	Update.
	* tui/tui-data.h (union tui_which_element) <data_window>: Remove
	member.
	(struct tui_data_window) <regs_content>: Now a std::vector.
	<regs_content_count>: Remove.
	(tui_add_content_elements, tui_free_data_content): Don't declare.
	* tui/tui-data.c (tui_data_window::clear_detail): Update.
	(init_content_element): Remove DATA_WIN case.  Add assert.
	(tui_add_content_elements): Remove.
	(tui_data_window): Update.
	(tui_free_data_content): Remove.
	(free_content_elements): Remove DATA_WIN case.
---
 gdb/ChangeLog            |  27 +++++++
 gdb/tui/tui-data.c       |  74 +----------------
 gdb/tui/tui-data.h       |   9 +--
 gdb/tui/tui-regs.c       | 166 +++++++++++++++------------------------
 gdb/tui/tui-win.c        |   8 +-
 gdb/tui/tui-windata.c    |  25 +++---
 gdb/tui/tui-wingeneral.c |  12 +--
 7 files changed, 110 insertions(+), 211 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 07bf20e290a..b957043a60f 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -175,8 +175,7 @@ tui_cmd_window::clear_detail ()
 void
 tui_data_window::clear_detail ()
 {
-  regs_content = NULL;
-  regs_content_count = 0;
+  regs_content.clear ();
   regs_column_count = 1;
   display_regs = false;
 }
@@ -360,6 +359,7 @@ init_content_element (struct tui_win_element *element,
   gdb_assert (type != LOCATOR_WIN);
   gdb_assert (type != CMD_WIN);
   gdb_assert (type != DATA_ITEM_WIN);
+  gdb_assert (type != DATA_WIN);
 
   switch (type)
     {
@@ -371,9 +371,6 @@ init_content_element (struct tui_win_element *element,
       element->which_element.source.is_exec_point = FALSE;
       element->which_element.source.has_break = FALSE;
       break;
-    case DATA_WIN:
-      element->which_element.data_window = new tui_data_item_window ();
-      break;
     default:
       break;
     }
@@ -426,39 +423,6 @@ tui_alloc_content (int num_elements, enum tui_win_type type)
 }
 
 
-/* Adds the input number of elements to the windows's content.  If no
-   content has been allocated yet, alloc_content() is called to do
-   this.  The index of the first element added is returned, unless
-   there is a memory allocation error, in which case, (-1) is
-   returned.  */
-int
-tui_add_content_elements (struct tui_gen_win_info *win_info, 
-			  int num_elements)
-{
-  struct tui_win_element *element_ptr;
-  int i, index_start;
-
-  if (win_info->content == NULL)
-    {
-      win_info->content = tui_alloc_content (num_elements, win_info->type);
-      index_start = 0;
-    }
-  else
-    index_start = win_info->content_size;
-  if (win_info->content != NULL)
-    {
-      for (i = index_start; (i < num_elements + index_start); i++)
-	{
-	  element_ptr = XNEW (struct tui_win_element);
-	  win_info->content[i] = element_ptr;
-	  init_content_element (element_ptr, win_info->type);
-	  win_info->content_size++;
-	}
-    }
-
-  return index_start;
-}
-
 tui_gen_win_info::~tui_gen_win_info ()
 {
   if (handle != NULL)
@@ -480,9 +444,6 @@ tui_data_window::~tui_data_window ()
 {
   if (content != NULL)
     {
-      tui_free_data_content (regs_content, regs_content_count);
-      regs_content = NULL;
-      regs_content_count = 0;
       regs_column_count = 1;
       display_regs = false;
       content = NULL;
@@ -515,33 +476,6 @@ tui_free_win_content (struct tui_gen_win_info *win_info)
 }
 
 
-void
-tui_free_data_content (tui_win_content content, 
-		       int content_size)
-{
-  int i;
-
-  /* Remember that data window content elements are of type struct
-     tui_gen_win_info *, each of which whose single element is a data
-     element.  */
-  for (i = 0; i < content_size; i++)
-    {
-      struct tui_gen_win_info *generic_win
-	= content[i]->which_element.data_window;
-
-      if (generic_win != NULL)
-	{
-	  tui_delete_win (generic_win->handle);
-	  generic_win->handle = NULL;
-	  tui_free_win_content (generic_win);
-	}
-    }
-  free_content (content,
-		content_size,
-		DATA_WIN);
-}
-
-
 /**********************************
 ** LOCAL STATIC FUNCTIONS        **
 **********************************/
@@ -596,10 +530,6 @@ free_content_elements (tui_win_content content,
 		    case SRC_WIN:
 		      xfree (element->which_element.source.line);
 		      break;
-		    case DATA_WIN:
-		      delete element->which_element.data_window;
-		      xfree (element);
-		      break;
 		    default:
 		      break;
 		    }
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 083b4a5f48e..112fbf4664b 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -204,7 +204,6 @@ typedef char tui_exec_info_content[TUI_EXECINFO_SIZE];
 union tui_which_element
 {
   struct tui_source_element source;	/* The source elements.  */
-  struct tui_data_item_window *data_window;	/* Data display elements.  */
 };
 
 struct tui_win_element
@@ -477,9 +476,8 @@ struct tui_data_window : public tui_win_info
     return DATA_NAME;
   }
 
-  /* Start of regs display content.  */
-  tui_win_content regs_content = NULL;
-  int regs_content_count = 0;
+  /* Windows that are used to display registers.  */
+  std::vector<std::unique_ptr<tui_data_item_window>> regs_content;
   int regs_column_count = 0;
   /* Should regs be displayed at all?  */
   bool display_regs = false;
@@ -554,10 +552,7 @@ extern struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
 /* Data Manipulation Functions.  */
 extern void tui_initialize_static_data (void);
 extern tui_win_content tui_alloc_content (int, enum tui_win_type);
-extern int tui_add_content_elements (struct tui_gen_win_info *, 
-				     int);
 extern void tui_free_win_content (struct tui_gen_win_info *);
-extern void tui_free_data_content (tui_win_content, int);
 extern void tui_free_all_source_wins_content (void);
 extern struct tui_win_info *tui_partial_win_by_name (const char *);
 extern enum tui_layout_type tui_current_layout (void);
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index c3970caa5a6..32e82b23482 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -49,9 +49,9 @@
 ******************************************/
 static void tui_display_register (struct tui_data_item_window *data);
 
-static enum tui_status tui_show_register_group (struct reggroup *group,
-						struct frame_info *frame,
-						int refresh_values_only);
+static void tui_show_register_group (struct reggroup *group,
+				     struct frame_info *frame,
+				     int refresh_values_only);
 
 static enum tui_status tui_get_register (struct frame_info *frame,
 					 struct tui_data_item_window *data,
@@ -70,11 +70,11 @@ tui_last_regs_line_no (void)
 {
   int num_lines = (-1);
 
-  if (TUI_DATA_WIN->regs_content_count > 0)
+  if (!TUI_DATA_WIN->regs_content.empty ())
     {
-      num_lines = (TUI_DATA_WIN->regs_content_count
+      num_lines = (TUI_DATA_WIN->regs_content.size ()
 		   / TUI_DATA_WIN->regs_column_count);
-      if (TUI_DATA_WIN->regs_content_count % TUI_DATA_WIN->regs_column_count)
+      if (TUI_DATA_WIN->regs_content.size () % TUI_DATA_WIN->regs_column_count)
 	num_lines++;
     }
   return num_lines;
@@ -87,7 +87,7 @@ tui_last_regs_line_no (void)
 int
 tui_line_from_reg_element_no (int element_no)
 {
-  if (element_no < TUI_DATA_WIN->regs_content_count)
+  if (element_no < TUI_DATA_WIN->regs_content.size ())
     {
       int i, line = (-1);
 
@@ -113,7 +113,7 @@ int
 tui_first_reg_element_no_inline (int line_no)
 {
   if ((line_no * TUI_DATA_WIN->regs_column_count)
-      <= TUI_DATA_WIN->regs_content_count)
+      <= TUI_DATA_WIN->regs_content.size ())
     return (((line_no + 1) * TUI_DATA_WIN->regs_column_count) 
 	    - TUI_DATA_WIN->regs_column_count);
   else
@@ -145,8 +145,9 @@ tui_show_registers (struct reggroup *group)
 
   if (target_has_registers && target_has_stack && target_has_memory)
     {
-      ret = tui_show_register_group (group, get_selected_frame (NULL),
-                                     group == TUI_DATA_WIN->current_group);
+      tui_show_register_group (group, get_selected_frame (NULL),
+			       group == TUI_DATA_WIN->current_group);
+      ret = TUI_SUCCESS;
     }
   if (ret == TUI_FAILURE)
     {
@@ -155,16 +156,11 @@ tui_show_registers (struct reggroup *group)
     }
   else
     {
-      int i;
-
       /* Clear all notation of changed values.  */
-      for (i = 0; i < TUI_DATA_WIN->regs_content_count; i++)
+      for (auto &&data_item_win : TUI_DATA_WIN->regs_content)
 	{
-	  struct tui_data_item_window *data_item_win;
-
-	  data_item_win = TUI_DATA_WIN->regs_content[i]
-            ->which_element.data_window;
-	  data_item_win->highlight = false;
+	  if (data_item_win != nullptr)
+	    data_item_win->highlight = false;
 	}
       TUI_DATA_WIN->current_group = group;
       tui_display_all_data ();
@@ -176,15 +172,13 @@ tui_show_registers (struct reggroup *group)
    using the given frame.  Values are refreshed only when
    refresh_values_only is TRUE.  */
 
-static enum tui_status
+static void
 tui_show_register_group (struct reggroup *group,
                          struct frame_info *frame, 
 			 int refresh_values_only)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  enum tui_status ret = TUI_FAILURE;
   int nr_regs;
-  int allocated_here = FALSE;
   int regnum, pos;
   char title[80];
 
@@ -213,68 +207,47 @@ tui_show_register_group (struct reggroup *group,
       nr_regs++;
     }
 
-  if (TUI_DATA_WIN->regs_content_count > 0 && !refresh_values_only)
-    {
-      tui_free_data_content (TUI_DATA_WIN->regs_content,
-                             TUI_DATA_WIN->regs_content_count);
-      TUI_DATA_WIN->regs_content_count = 0;
-    }
+  if (!refresh_values_only)
+    TUI_DATA_WIN->regs_content.clear ();
 
-  if (TUI_DATA_WIN->regs_content_count <= 0)
+  if (nr_regs < TUI_DATA_WIN->regs_content.size ())
+    TUI_DATA_WIN->regs_content.resize (nr_regs);
+  else
     {
-      TUI_DATA_WIN->regs_content = tui_alloc_content (nr_regs, DATA_WIN);
-      allocated_here = TRUE;
-      refresh_values_only = FALSE;
+      for (int i = TUI_DATA_WIN->regs_content.size (); i < nr_regs; ++i)
+	TUI_DATA_WIN->regs_content.emplace_back (new tui_data_item_window ());
     }
 
-  if (TUI_DATA_WIN->regs_content != NULL)
+  /* Now set the register names and values.  */
+  pos = 0;
+  for (regnum = 0; regnum < gdbarch_num_cooked_regs (gdbarch); regnum++)
     {
-      if (!refresh_values_only || allocated_here)
-	{
-	  TUI_DATA_WIN->content = NULL;
-	  TUI_DATA_WIN->content_size = 0;
-	  tui_add_content_elements (TUI_DATA_WIN, nr_regs);
-	  TUI_DATA_WIN->regs_content = TUI_DATA_WIN->content;
-	  TUI_DATA_WIN->regs_content_count = nr_regs;
-	}
+      struct tui_data_item_window *data_item_win;
+      const char *name;
 
-      /* Now set the register names and values.  */
-      pos = 0;
-      for (regnum = 0; regnum < gdbarch_num_cooked_regs (gdbarch); regnum++)
-        {
-	  struct tui_data_item_window *data_item_win;
-          const char *name;
-
-          /* Must be in the group.  */
-          if (!gdbarch_register_reggroup_p (gdbarch, regnum, group))
-            continue;
-
-	  /* If the register name is empty, it is undefined for this
-	     processor, so don't display anything.  */
-	  name = gdbarch_register_name (gdbarch, regnum);
-	  if (name == 0 || *name == '\0')
-	    continue;
-
-	  data_item_win =
-            TUI_DATA_WIN->regs_content[pos]->which_element.data_window;
-          if (data_item_win)
-            {
-              if (!refresh_values_only)
-                {
-                  data_item_win->item_no = regnum;
-                  data_item_win->name = name;
-                  data_item_win->highlight = false;
-                }
-              tui_get_register (frame, data_item_win, regnum, 0);
-            }
-          pos++;
-	}
+      /* Must be in the group.  */
+      if (!gdbarch_register_reggroup_p (gdbarch, regnum, group))
+	continue;
 
-      TUI_DATA_WIN->content_size = TUI_DATA_WIN->regs_content_count;
-      ret = TUI_SUCCESS;
-    }
+      /* If the register name is empty, it is undefined for this
+	 processor, so don't display anything.  */
+      name = gdbarch_register_name (gdbarch, regnum);
+      if (name == 0 || *name == '\0')
+	continue;
 
-  return ret;
+      data_item_win = TUI_DATA_WIN->regs_content[pos].get ();
+      if (data_item_win)
+	{
+	  if (!refresh_values_only)
+	    {
+	      data_item_win->item_no = regnum;
+	      data_item_win->name = name;
+	      data_item_win->highlight = false;
+	    }
+	  tui_get_register (frame, data_item_win, regnum, 0);
+	}
+      pos++;
+    }
 }
 
 /* Function to display the registers in the content from
@@ -284,21 +257,16 @@ tui_show_register_group (struct reggroup *group,
 void
 tui_display_registers_from (int start_element_no)
 {
-  if (TUI_DATA_WIN->regs_content != NULL
-      && TUI_DATA_WIN->regs_content_count > 0)
+  if (!TUI_DATA_WIN->regs_content.empty ())
     {
-      int i = start_element_no;
       int j, item_win_width, cur_y;
 
       int max_len = 0;
-      for (i = 0; i < TUI_DATA_WIN->regs_content_count; i++)
+      for (auto &&data_item_win : TUI_DATA_WIN->regs_content)
         {
-          struct tui_data_item_window *data_item_win;
           char *p;
           int len;
 
-          data_item_win
-	    = TUI_DATA_WIN->regs_content[i]->which_element.data_window;
           len = 0;
           p = data_item_win->content;
           if (p != 0)
@@ -314,7 +282,7 @@ tui_display_registers_from (int start_element_no)
             max_len = len;
         }
       item_win_width = max_len + 1;
-      i = start_element_no;
+      int i = start_element_no;
 
       TUI_DATA_WIN->regs_column_count =
         (TUI_DATA_WIN->width - 2) / item_win_width;
@@ -326,19 +294,18 @@ tui_display_registers_from (int start_element_no)
       /* Now create each data "sub" window, and write the display into
 	 it.  */
       cur_y = 1;
-      while (i < TUI_DATA_WIN->regs_content_count 
+      while (i < TUI_DATA_WIN->regs_content.size ()
 	     && cur_y <= TUI_DATA_WIN->viewport_height)
 	{
 	  for (j = 0;
 	       j < TUI_DATA_WIN->regs_column_count
-		 && i < TUI_DATA_WIN->regs_content_count;
+		 && i < TUI_DATA_WIN->regs_content.size ();
 	       j++)
 	    {
 	      struct tui_data_item_window *data_item_win;
 
 	      /* Create the window if necessary.  */
-	      data_item_win = TUI_DATA_WIN->regs_content[i]
-                ->which_element.data_window;
+	      data_item_win = TUI_DATA_WIN->regs_content[i].get ();
               if (data_item_win->handle != NULL
                   && (data_item_win->height != 1
                       || data_item_win->width != item_win_width
@@ -379,8 +346,7 @@ static void
 tui_display_reg_element_at_line (int start_element_no,
 				 int start_line_no)
 {
-  if (TUI_DATA_WIN->regs_content != NULL
-      && TUI_DATA_WIN->regs_content_count > 0)
+  if (!TUI_DATA_WIN->regs_content.empty ())
     {
       int element_no = start_element_no;
 
@@ -414,7 +380,7 @@ int
 tui_display_registers_from_line (int line_no, 
 				 int force_display)
 {
-  if (TUI_DATA_WIN->regs_content_count > 0)
+  if (!TUI_DATA_WIN->regs_content.empty ())
     {
       int line, element_no;
 
@@ -427,7 +393,7 @@ tui_display_registers_from_line (int line_no,
 	  if (line_no >= tui_last_regs_line_no ())
 	    {
 	      if ((line = tui_line_from_reg_element_no (
-		 TUI_DATA_WIN->regs_content_count - 1)) < 0)
+		 TUI_DATA_WIN->regs_content.size () - 1)) < 0)
 		line = 0;
 	    }
 	  else
@@ -437,8 +403,7 @@ tui_display_registers_from_line (int line_no,
 	line = line_no;
 
       element_no = tui_first_reg_element_no_inline (line);
-      if (element_no
-	  < TUI_DATA_WIN->regs_content_count)
+      if (element_no < TUI_DATA_WIN->regs_content.size ())
 	tui_display_reg_element_at_line (element_no, line);
       else
 	line = (-1);
@@ -459,30 +424,23 @@ tui_check_register_values (struct frame_info *frame)
   if (TUI_DATA_WIN != NULL
       && TUI_DATA_WIN->is_visible)
     {
-      if (TUI_DATA_WIN->regs_content_count <= 0 
+      if (TUI_DATA_WIN->regs_content.empty ()
 	  && TUI_DATA_WIN->display_regs)
 	tui_show_registers (TUI_DATA_WIN->current_group);
       else
 	{
-	  int i;
-
-	  for (i = 0; (i < TUI_DATA_WIN->regs_content_count); i++)
+	  for (auto &&data_item_win_ptr : TUI_DATA_WIN->regs_content)
 	    {
-	      struct tui_data_item_window *data_item_win_ptr;
 	      int was_hilighted;
 
-	      data_item_win_ptr = TUI_DATA_WIN->regs_content[i]->
-                which_element.data_window;
 	      was_hilighted = data_item_win_ptr->highlight;
 
-              tui_get_register (frame, data_item_win_ptr,
+              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);
-		}
+		tui_display_register (data_item_win_ptr.get ());
 	    }
 	}
     }
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 64da13c3bb5..468e245351c 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -1267,12 +1267,10 @@ void
 tui_data_window::set_new_height (int height)
 {
   /* Delete all data item windows.  */
-  for (int i = 0; i < content_size; i++)
+  for (auto &&win : regs_content)
     {
-      struct tui_gen_win_info *gen_win_info
-	= content[i]->which_element.data_window;
-      tui_delete_win (gen_win_info->handle);
-      gen_win_info->handle = NULL;
+      tui_delete_win (win->handle);
+      win->handle = NULL;
     }
 }
 
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index 23510f6da84..7ff50a0c905 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -44,11 +44,11 @@
 int
 tui_data_window::first_data_item_displayed ()
 {
-  for (int i = 0; i < content_size; i++)
+  for (int i = 0; i < regs_content.size (); i++)
     {
       struct tui_gen_win_info *data_item_win;
 
-      data_item_win = content[i]->which_element.data_window;
+      data_item_win = regs_content[i].get ();
       if (data_item_win->handle != NULL && data_item_win->is_visible)
 	return i;
     }
@@ -62,16 +62,11 @@ tui_data_window::first_data_item_displayed ()
 void
 tui_delete_data_content_windows (void)
 {
-  int i;
-  struct tui_gen_win_info *data_item_win_ptr;
-
-  for (i = 0; (i < TUI_DATA_WIN->content_size); i++)
+  for (auto &&win : TUI_DATA_WIN->regs_content)
     {
-      data_item_win_ptr
-	= TUI_DATA_WIN->content[i]->which_element.data_window;
-      tui_delete_win (data_item_win_ptr->handle);
-      data_item_win_ptr->handle = NULL;
-      data_item_win_ptr->is_visible = false;
+      tui_delete_win (win->handle);
+      win->handle = NULL;
+      win->is_visible = false;
     }
 }
 
@@ -104,7 +99,7 @@ tui_erase_data_content (const char *prompt)
 void
 tui_display_all_data (void)
 {
-  if (TUI_DATA_WIN->content_size <= 0)
+  if (TUI_DATA_WIN->regs_content.empty ())
     tui_erase_data_content (NO_DATA_STRING);
   else
     {
@@ -138,7 +133,7 @@ tui_display_data_from (int element_no, int reuse_windows)
 {
   int first_line = (-1);
 
-  if (element_no < TUI_DATA_WIN->regs_content_count)
+  if (element_no < TUI_DATA_WIN->regs_content.size ())
     first_line = tui_line_from_reg_element_no (element_no);
   else
     { /* Calculate the first_line from the element number.  */
@@ -159,7 +154,7 @@ void
 tui_data_window::refresh_all ()
 {
   tui_erase_data_content (NULL);
-  if (content_size > 0)
+  if (!regs_content.empty ())
     {
       int first_element = first_data_item_displayed ();
 
@@ -177,7 +172,7 @@ tui_data_window::do_scroll_vertical (int num_to_scroll)
   int first_line = (-1);
 
   first_element_no = first_data_item_displayed ();
-  if (first_element_no < regs_content_count)
+  if (first_element_no < regs_content.size ())
     first_line = tui_line_from_reg_element_no (first_element_no);
   else
     { /* Calculate the first line from the element number which is in
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 9bc4e2b24ca..8f64e73e284 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -45,16 +45,12 @@ tui_gen_win_info::refresh_window ()
 void
 tui_data_window::refresh_window ()
 {
-  if (content_size > 0)
+  if (!regs_content.empty ())
     {
-      for (int i = 0; i < content_size; i++)
+      for (auto &&win : regs_content)
 	{
-	  struct tui_gen_win_info *data_item_win_ptr;
-
-	  data_item_win_ptr = content[i]->which_element.data_window;
-	  if (data_item_win_ptr != NULL
-	      && data_item_win_ptr->handle != NULL)
-	    wrefresh (data_item_win_ptr->handle);
+	  if (win != NULL && win->handle != NULL)
+	    wrefresh (win->handle);
 	}
     }
   else
-- 
2.17.2

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

* [PATCH 57/66] Remove "data_content" and "data_content_count" from TUI data window
  2019-06-24 18:49 ` [PATCH 50/66] Separate out locator window Tom Tromey
                     ` (10 preceding siblings ...)
  2019-06-24 18:49   ` [PATCH 66/66] Tidy tui_delete_win Tom Tromey
@ 2019-06-24 18:49   ` Tom Tromey
  2019-06-24 18:49   ` [PATCH 61/66] More type safety for TUI source window functions Tom Tromey
                     ` (3 subsequent siblings)
  15 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 18:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The TUI has some stub code for adding data other than registers to the
data window.  However, it doesn't do anything, and apparently never
has.  This removes the dead code.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.c (tui_data_item_window): Update.
	* tui/tui-windata.h (tui_check_data_values): Don't declare.
	* tui/tui-windata.c (tui_display_all_data)
	(tui_display_data_from_line): Update.
	(tui_check_data_values): Remove.
	* tui/tui-regs.c (tui_show_register_group)
	(tui_display_reg_element_at_line): Update.
	* tui/tui-hooks.c (tui_register_changed)
	(tui_refresh_frame_and_register_information): Call
	tui_check_register_values.
	* tui/tui-data.h (struct tui_data_window) <data_content,
	data_content_count, data_type>: Remove.
	(enum tui_data_type): Remove.
---
 gdb/ChangeLog         | 19 ++++++++++++
 gdb/tui/tui-data.c    |  7 -----
 gdb/tui/tui-data.h    | 13 ---------
 gdb/tui/tui-hooks.c   |  4 +--
 gdb/tui/tui-regs.c    |  9 ++----
 gdb/tui/tui-windata.c | 67 +------------------------------------------
 gdb/tui/tui-windata.h |  1 -
 7 files changed, 25 insertions(+), 95 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index e9d0308b86b..07bf20e290a 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -175,8 +175,6 @@ tui_cmd_window::clear_detail ()
 void
 tui_data_window::clear_detail ()
 {
-  data_content = NULL;
-  data_content_count = 0;
   regs_content = NULL;
   regs_content_count = 0;
   regs_column_count = 1;
@@ -485,9 +483,6 @@ tui_data_window::~tui_data_window ()
       tui_free_data_content (regs_content, regs_content_count);
       regs_content = NULL;
       regs_content_count = 0;
-      tui_free_data_content (data_content, data_content_count);
-      data_content = NULL;
-      data_content_count = 0;
       regs_column_count = 1;
       display_regs = false;
       content = NULL;
@@ -567,8 +562,6 @@ free_content (tui_win_content content,
 
 tui_data_item_window::~tui_data_item_window ()
 {
-  if (data_type != TUI_REGISTER)
-    xfree ((void *) name);
   xfree (value);
   xfree (content);
 }
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 3416c413dc2..083b4a5f48e 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -146,15 +146,6 @@ enum tui_layout_type
   UNDEFINED_LAYOUT
 };
 
-/* Basic data types that can be displayed in the data window.  */
-enum tui_data_type
-{
-  TUI_REGISTER,
-  TUI_SCALAR,
-  TUI_COMPLEX,
-  TUI_STRUCT
-};
-
 enum tui_line_or_address_kind
 {
   LOA_LINE,
@@ -282,7 +273,6 @@ struct tui_data_item_window : public tui_gen_win_info
   const char *name = nullptr;
   /* The register number, or data display number.  */
   int item_no = UNDEFINED_ITEM;
-  enum tui_data_type data_type = TUI_REGISTER;
   void *value = nullptr;
   bool highlight = false;
   char *content = nullptr;
@@ -487,9 +477,6 @@ struct tui_data_window : public tui_win_info
     return DATA_NAME;
   }
 
-  /* Start of data display content.  */
-  tui_win_content data_content = NULL;
-  int data_content_count = 0;
   /* Start of regs display content.  */
   tui_win_content regs_content = NULL;
   int regs_content_count = 0;
diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index 7e94a13e901..9bac4a883aa 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -81,7 +81,7 @@ tui_register_changed (struct frame_info *frame, int regno)
   if (tui_refreshing_registers == 0)
     {
       tui_refreshing_registers = 1;
-      tui_check_data_values (fi);
+      tui_check_register_values (fi);
       tui_refreshing_registers = 0;
     }
 }
@@ -153,7 +153,7 @@ tui_refresh_frame_and_register_information (int registers_too_p)
       && (frame_info_changed_p || registers_too_p))
     {
       tui_refreshing_registers = 1;
-      tui_check_data_values (fi);
+      tui_check_register_values (fi);
       tui_refreshing_registers = 0;
     }
 }
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 590a0752280..c3970caa5a6 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -270,8 +270,7 @@ tui_show_register_group (struct reggroup *group,
           pos++;
 	}
 
-      TUI_DATA_WIN->content_size =
-	TUI_DATA_WIN->regs_content_count + TUI_DATA_WIN->data_content_count;
+      TUI_DATA_WIN->content_size = TUI_DATA_WIN->regs_content_count;
       ret = TUI_SUCCESS;
     }
 
@@ -395,12 +394,10 @@ tui_display_reg_element_at_line (int start_element_no,
 	  if (first_line_on_last_page < 0)
 	    first_line_on_last_page = 0;
 
-	  /* If there is no other data displayed except registers, and
-	     the element_no causes us to scroll past the end of the
+	  /* If the element_no causes us to scroll past the end of the
 	     registers, adjust what element to really start the
 	     display at.  */
-	  if (TUI_DATA_WIN->data_content_count <= 0
-	      && start_line_no > first_line_on_last_page)
+	  if (start_line_no > first_line_on_last_page)
 	    element_no
 	      = tui_first_reg_element_no_inline (first_line_on_last_page);
 	}
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index 82436a31d92..23510f6da84 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -112,12 +112,6 @@ tui_display_all_data (void)
       tui_delete_data_content_windows ();
       tui_check_and_display_highlight_if_needed (TUI_DATA_WIN);
       tui_display_registers_from (0);
-
-      /* Then display the other data.  */
-      if (TUI_DATA_WIN->data_content != NULL
-	  && TUI_DATA_WIN->data_content_count > 0)
-	{
-	}
     }
 }
 
@@ -134,31 +128,7 @@ tui_display_data_from_line (int line_no)
 
   tui_check_and_display_highlight_if_needed (TUI_DATA_WIN);
 
-  /* There is no general data, force regs to display (if there are
-     any).  */
-  if (TUI_DATA_WIN->data_content_count <= 0)
-    tui_display_registers_from_line (_line_no, TRUE);
-  else
-    {
-      int regs_last_line = tui_last_regs_line_no ();
-
-
-      /* Display regs if we can.  */
-      if (tui_display_registers_from_line (_line_no, FALSE) < 0)
-	{ /* _line_no is past the regs display, so calc where the
-	     start data element is.  */
-	  if (regs_last_line < _line_no)
-	    { /* Figure out how many lines each element is to obtain
-		 the start element_no.  */
-	    }
-	}
-      else
-	{ /* Calculate the starting element of the data display, given
-	     regs_last_line and how many lines each element is, up to
-	     _line_no.  */
-	}
-      /* Now display the data , starting at element_no.  */
-    }
+  tui_display_registers_from_line (_line_no, TRUE);
 }
 
 
@@ -199,41 +169,6 @@ tui_data_window::refresh_all ()
 }
 
 
-/* Function to check the data values and hilite any that have
-   changed.  */
-void
-tui_check_data_values (struct frame_info *frame)
-{
-  tui_check_register_values (frame);
-
-  /* Now check any other data values that there are.  */
-  if (TUI_DATA_WIN != NULL && TUI_DATA_WIN->is_visible)
-    {
-      int i;
-
-      for (i = 0; TUI_DATA_WIN->data_content_count; i++)
-	{
-#ifdef LATER
-	  tui_data_element_ptr data_element_ptr;
-	  struct tui_gen_win_info *data_item_win_ptr;
-	  Opaque new_value;
-
-	  data_item_ptr = &TUI_DATA_WIN->
-	    data_content[i]->which_element.data_window;
-	  data_element_ptr = &((tui_win_content)
-			       data_item_win_ptr->content)[0]->which_element.data;
-	  if value
-	    has changed (data_element_ptr, frame, &new_value)
-	    {
-	      data_element_ptr->value = new_value;
-	      update the display with the newobj value, hiliting it.
-	    }
-#endif
-	}
-    }
-}
-
-
 /* 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-windata.h b/gdb/tui/tui-windata.h
index 4aa8cb0b38c..1aba67520ec 100644
--- a/gdb/tui/tui-windata.h
+++ b/gdb/tui/tui-windata.h
@@ -26,7 +26,6 @@
 
 extern void tui_erase_data_content (const char *);
 extern void tui_display_all_data (void);
-extern void tui_check_data_values (struct frame_info *);
 extern void tui_display_data_from_line (int);
 extern void tui_delete_data_content_windows (void);
 extern void tui_refresh_data_win (void);
-- 
2.17.2

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

* [PATCH 66/66] Tidy tui_delete_win
  2019-06-24 18:49 ` [PATCH 50/66] Separate out locator window Tom Tromey
                     ` (9 preceding siblings ...)
  2019-06-24 18:49   ` [PATCH 54/66] Separate out data item window Tom Tromey
@ 2019-06-24 18:49   ` Tom Tromey
  2019-06-24 18:49   ` [PATCH 57/66] Remove "data_content" and "data_content_count" from TUI data window Tom Tromey
                     ` (4 subsequent siblings)
  15 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 18:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_delete_win does its own NULL check, so ~tui_gen_win_info does not
need to do it.  Also, tui_delete_win has an extraneous "return".

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (tui_delete_win): Remove "return".
	* tui/tui-data.c (~tui_gen_win_info): Remove "if".
---
 gdb/ChangeLog            | 5 +++++
 gdb/tui/tui-data.c       | 6 +-----
 gdb/tui/tui-wingeneral.c | 2 --
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 1ecf486e37f..4a16c4f03f2 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -350,11 +350,7 @@ tui_source_window_base::tui_source_window_base (enum tui_win_type type)
 
 tui_gen_win_info::~tui_gen_win_info ()
 {
-  if (handle != NULL)
-    {
-      tui_delete_win (handle);
-      handle = NULL;
-    }
+  tui_delete_win (handle);
   xfree (title);
 }
 
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 13063ae9356..cf8d9fc3959 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -63,8 +63,6 @@ tui_delete_win (WINDOW *window)
 {
   if (window != NULL)
     delwin (window);
-
-  return;
 }
 
 
-- 
2.17.2

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

* [PATCH 52/66] Remove command from tui_which_element
  2019-06-24 18:49 ` [PATCH 50/66] Separate out locator window Tom Tromey
                     ` (4 preceding siblings ...)
  2019-06-24 18:49   ` [PATCH 56/66] Turn tui_first_data_item_displayed into a method Tom Tromey
@ 2019-06-24 18:49   ` Tom Tromey
  2019-06-24 18:49   ` [PATCH 63/66] Remove NULL checks before xfree Tom Tromey
                     ` (9 subsequent siblings)
  15 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 18:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

union tui_which_element has a "command" member, but it is never used.
This removes it.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (struct tui_command_element): Remove.
	(union tui_which_element) <command>: Remove.
	* tui/tui-data.c (init_content_element): Remove CMD_WIN case.  Add
	assert.
	(free_content_elements): Remove CMD_WIN case.
---
 gdb/ChangeLog      | 8 ++++++++
 gdb/tui/tui-data.c | 7 +------
 gdb/tui/tui-data.h | 7 -------
 3 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index f6d36e670fb..b6d1b9913d3 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -366,6 +366,7 @@ init_content_element (struct tui_win_element *element,
 {
   gdb_assert (type != EXEC_INFO_WIN);
   gdb_assert (type != LOCATOR_WIN);
+  gdb_assert (type != CMD_WIN);
 
   switch (type)
     {
@@ -383,9 +384,6 @@ init_content_element (struct tui_win_element *element,
 	tui_alloc_content (1, DATA_ITEM_WIN);
       element->which_element.data_window->content_size = 1;
       break;
-    case CMD_WIN:
-      element->which_element.command.line = NULL;
-      break;
     case DATA_ITEM_WIN:
       element->which_element.data.name = NULL;
       element->which_element.data.type = TUI_REGISTER;
@@ -627,9 +625,6 @@ free_content_elements (tui_win_content content,
                       xfree (element->which_element.data.content);
 		      xfree (element);
 		      break;
-		    case CMD_WIN:
-		      xfree (element->which_element.command.line);
-		      break;
 		    default:
 		      break;
 		    }
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 922f1301fa4..5f58b109e96 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -201,12 +201,6 @@ struct tui_data_element
 };
 
 
-/* Elements in the command window content.  */
-struct tui_command_element
-{
-  char *line;
-};
-
 #ifdef PATH_MAX
 # define MAX_LOCATOR_ELEMENT_LEN        PATH_MAX
 #else
@@ -234,7 +228,6 @@ union tui_which_element
   struct tui_source_element source;	/* The source elements.  */
   struct tui_gen_win_info *data_window;	/* Data display elements.  */
   struct tui_data_element data;		/* Elements of data_window.  */
-  struct tui_command_element command;	/* Command elements.  */
 };
 
 struct tui_win_element
-- 
2.17.2

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

* [PATCH 65/66] Make tui_gen_win_info constructor protected
  2019-06-24 18:49 ` [PATCH 50/66] Separate out locator window Tom Tromey
                     ` (14 preceding siblings ...)
  2019-06-24 18:49   ` [PATCH 62/66] Remove union tui_which_element Tom Tromey
@ 2019-06-24 18:49   ` Tom Tromey
  15 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 18:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Now that all the window types have their own concrete classes, the
tui_gen_win_info constructor can be protected.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (init_and_make_win): Assert on unrecognized
	type.
	* tui/tui-data.h (struct tui_gen_win_info): Make constructor
	protected.
---
 gdb/ChangeLog        | 7 +++++++
 gdb/tui/tui-data.h   | 4 ++++
 gdb/tui/tui-layout.c | 4 +---
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 147149389cf..3936aedec95 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -34,11 +34,15 @@ struct tui_point
 /* Generic window information.  */
 struct tui_gen_win_info
 {
+protected:
+
   explicit tui_gen_win_info (enum tui_win_type t)
     : type (t)
   {
   }
 
+public:
+
   virtual ~tui_gen_win_info ();
 
   /* Call to refresh this window.  */
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 9dbb5995998..d9a1f08ac1f 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -815,9 +815,7 @@ init_and_make_win (tui_gen_win_info *win_info,
 	  break;
 
 	default:
-	  gdb_assert (tui_win_is_auxiliary (win_type));
-	  win_info = new tui_gen_win_info (win_type);
-	  break;
+	  gdb_assert_not_reached (_("unhandled window type"));
 	}
     }
 
-- 
2.17.2

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

* [PATCH 51/66] Remove layout_def::split
  2019-06-24 18:49 ` [PATCH 50/66] Separate out locator window Tom Tromey
                     ` (2 preceding siblings ...)
  2019-06-24 18:49   ` [PATCH 58/66] Separate out data window Tom Tromey
@ 2019-06-24 18:49   ` Tom Tromey
  2019-06-24 18:49   ` [PATCH 56/66] Turn tui_first_data_item_displayed into a method Tom Tromey
                     ` (11 subsequent siblings)
  15 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 18:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The "split" field in struct layout_def is never used, so this patch
removes it.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (tui_set_layout): Update.
	* tui/tui-data.h (struct tui_layout_def) <split>: Remove.
	* tui/tui-data.c (layout_def): Update.
---
 gdb/ChangeLog        | 6 ++++++
 gdb/tui/tui-data.c   | 2 +-
 gdb/tui/tui-data.h   | 1 -
 gdb/tui/tui-layout.c | 5 -----
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 4f5f710ba94..f6d36e670fb 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -41,7 +41,7 @@ static struct std::vector<tui_source_window_base *> source_windows;
 static struct tui_win_info *win_with_focus = NULL;
 static struct tui_layout_def layout_def = {
   SRC_WIN,			/* DISPLAY_MODE */
-  FALSE};			/* SPLIT */
+};
 
 static int win_resized = FALSE;
 
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index cdafc69a379..922f1301fa4 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -176,7 +176,6 @@ struct tui_line_or_address
 struct tui_layout_def
 {
   enum tui_win_type display_mode;
-  int split;
 };
 
 /* Elements in the Source/Disassembly Window.  */
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index cf8f13feeed..61be48b877f 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -154,7 +154,6 @@ tui_set_layout (enum tui_layout_type layout_type)
 		case SRC_COMMAND:
 		  tui_set_win_focus_to (TUI_SRC_WIN);
 		  layout_def->display_mode = SRC_WIN;
-		  layout_def->split = FALSE;
 		  break;
 		case DISASSEM_COMMAND:
 		  /* The previous layout was not showing code.
@@ -168,7 +167,6 @@ tui_set_layout (enum tui_layout_type layout_type)
 		  tui_get_begin_asm_address (&gdbarch, &addr);
 		  tui_set_win_focus_to (TUI_DISASM_WIN);
 		  layout_def->display_mode = DISASSEM_WIN;
-		  layout_def->split = FALSE;
 		  break;
 		case SRC_DISASSEM_COMMAND:
 		  /* The previous layout was not showing code.
@@ -184,7 +182,6 @@ tui_set_layout (enum tui_layout_type layout_type)
 		    tui_set_win_focus_to (TUI_SRC_WIN);
 		  else
 		    tui_set_win_focus_to (TUI_DISASM_WIN);
-		  layout_def->split = TRUE;
 		  break;
 		case SRC_DATA_COMMAND:
 		  if (win_with_focus != TUI_DATA_WIN)
@@ -192,7 +189,6 @@ tui_set_layout (enum tui_layout_type layout_type)
 		  else
 		    tui_set_win_focus_to (TUI_DATA_WIN);
 		  layout_def->display_mode = SRC_WIN;
-		  layout_def->split = FALSE;
 		  break;
 		case DISASSEM_DATA_COMMAND:
 		  /* The previous layout was not showing code.
@@ -209,7 +205,6 @@ tui_set_layout (enum tui_layout_type layout_type)
 		  else
 		    tui_set_win_focus_to (TUI_DATA_WIN);
 		  layout_def->display_mode = DISASSEM_WIN;
-		  layout_def->split = FALSE;
 		  break;
 		default:
 		  break;
-- 
2.17.2

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

* [PATCH 54/66] Separate out data item window
  2019-06-24 18:49 ` [PATCH 50/66] Separate out locator window Tom Tromey
                     ` (8 preceding siblings ...)
  2019-06-24 18:49   ` [PATCH 64/66] Fix latent bug in set_is_exec_point_at Tom Tromey
@ 2019-06-24 18:49   ` Tom Tromey
  2019-06-24 18:49   ` [PATCH 66/66] Tidy tui_delete_win Tom Tromey
                     ` (5 subsequent siblings)
  15 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 18:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces a new subclass of tui_gen_win_info for the data item
windows, letting us remove another element from tui_which_element.

gdb/ChangeLog
2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.c (tui_show_registers, tui_show_register_group)
	(tui_display_registers_from, tui_check_register_values): Update.
	(tui_display_register): Remove win_info parameter; update.
	(tui_get_register): Change type of parameters.
	* tui/tui-data.h (struct tui_data_element): Remove.
	(union tui_which_element) <data>: Remove.
	<data_window>: Change type.
	(struct tui_data_item_window): New.
	* tui/tui-data.c (init_content_element): Remove DATA_ITEM_WIN
	case.  Add assert.
	(~tui_data_item_window): New destructor.
	(free_content_elements): Remove DATA_ITEM_WIN case.
---
 gdb/ChangeLog      | 15 +++++++++
 gdb/tui/tui-data.c | 32 ++++++------------
 gdb/tui/tui-data.h | 36 +++++++++++---------
 gdb/tui/tui-regs.c | 84 ++++++++++++++++++++--------------------------
 4 files changed, 82 insertions(+), 85 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index b6d1b9913d3..7b58f9ed52d 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -367,6 +367,7 @@ init_content_element (struct tui_win_element *element,
   gdb_assert (type != EXEC_INFO_WIN);
   gdb_assert (type != LOCATOR_WIN);
   gdb_assert (type != CMD_WIN);
+  gdb_assert (type != DATA_ITEM_WIN);
 
   switch (type)
     {
@@ -379,18 +380,7 @@ init_content_element (struct tui_win_element *element,
       element->which_element.source.has_break = FALSE;
       break;
     case DATA_WIN:
-      element->which_element.data_window = new struct tui_gen_win_info (DATA_ITEM_WIN);
-      element->which_element.data_window->content =
-	tui_alloc_content (1, DATA_ITEM_WIN);
-      element->which_element.data_window->content_size = 1;
-      break;
-    case DATA_ITEM_WIN:
-      element->which_element.data.name = NULL;
-      element->which_element.data.type = TUI_REGISTER;
-      element->which_element.data.item_no = UNDEFINED_ITEM;
-      element->which_element.data.value = NULL;
-      element->which_element.data.highlight = FALSE;
-      element->which_element.data.content = NULL;
+      element->which_element.data_window = new tui_data_item_window ();
       break;
     default:
       break;
@@ -581,6 +571,14 @@ free_content (tui_win_content content,
 }
 
 
+tui_data_item_window::~tui_data_item_window ()
+{
+  if (data_type != TUI_REGISTER)
+    xfree ((void *) name);
+  xfree (value);
+  xfree (content);
+}
+
 /* free_content_elements().
  */
 static void
@@ -615,16 +613,6 @@ free_content_elements (tui_win_content content,
 		      delete element->which_element.data_window;
 		      xfree (element);
 		      break;
-		    case DATA_ITEM_WIN:
-		      /* Note that data elements are not allocated in
-		         a single block, but individually, as
-		         needed.  */
-		      if (element->which_element.data.type != TUI_REGISTER)
-			xfree ((void *)element->which_element.data.name);
-		      xfree (element->which_element.data.value);
-                      xfree (element->which_element.data.content);
-		      xfree (element);
-		      break;
 		    default:
 		      break;
 		    }
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 5f58b109e96..e5fd7e610ea 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -188,19 +188,6 @@ struct tui_source_element
 };
 
 
-/* Elements in the data display window content.  */
-struct tui_data_element
-{
-  const char *name;
-  int item_no;		/* The register number, or data display
-			   number.  */
-  enum tui_data_type type;
-  void *value;
-  int highlight;
-  char *content;
-};
-
-
 #ifdef PATH_MAX
 # define MAX_LOCATOR_ELEMENT_LEN        PATH_MAX
 #else
@@ -226,8 +213,7 @@ typedef char tui_exec_info_content[TUI_EXECINFO_SIZE];
 union tui_which_element
 {
   struct tui_source_element source;	/* The source elements.  */
-  struct tui_gen_win_info *data_window;	/* Data display elements.  */
-  struct tui_data_element data;		/* Elements of data_window.  */
+  struct tui_data_item_window *data_window;	/* Data display elements.  */
 };
 
 struct tui_win_element
@@ -282,6 +268,26 @@ struct tui_locator_window : public tui_gen_win_info
   struct gdbarch *gdbarch = nullptr;
 };
 
+/* A data item window.  */
+
+struct tui_data_item_window : public tui_gen_win_info
+{
+  tui_data_item_window ()
+    : tui_gen_win_info (DATA_ITEM_WIN)
+  {
+  }
+
+  ~tui_data_item_window () override;
+
+  const char *name = nullptr;
+  /* The register number, or data display number.  */
+  int item_no = UNDEFINED_ITEM;
+  enum tui_data_type data_type = TUI_REGISTER;
+  void *value = nullptr;
+  bool highlight = false;
+  char *content = nullptr;
+};
+
 /* This defines information about each logical window.  */
 struct tui_win_info : public tui_gen_win_info
 {
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index c748d513fc3..590a0752280 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -47,17 +47,15 @@
 /*****************************************
 ** STATIC LOCAL FUNCTIONS FORWARD DECLS    **
 ******************************************/
-static void
-tui_display_register (struct tui_data_element *data,
-                      struct tui_gen_win_info *win_info);
+static void tui_display_register (struct tui_data_item_window *data);
 
 static enum tui_status tui_show_register_group (struct reggroup *group,
 						struct frame_info *frame,
 						int refresh_values_only);
 
 static enum tui_status tui_get_register (struct frame_info *frame,
-					 struct tui_data_element *data,
-					 int regnum, int *changedp);
+					 struct tui_data_item_window *data,
+					 int regnum, bool *changedp);
 
 
 
@@ -162,13 +160,11 @@ tui_show_registers (struct reggroup *group)
       /* Clear all notation of changed values.  */
       for (i = 0; i < TUI_DATA_WIN->regs_content_count; i++)
 	{
-	  struct tui_gen_win_info *data_item_win;
-          struct tui_win_element *win;
+	  struct tui_data_item_window *data_item_win;
 
 	  data_item_win = TUI_DATA_WIN->regs_content[i]
             ->which_element.data_window;
-          win = data_item_win->content[0];
-          win->which_element.data.highlight = FALSE;
+	  data_item_win->highlight = false;
 	}
       TUI_DATA_WIN->current_group = group;
       tui_display_all_data ();
@@ -246,8 +242,7 @@ tui_show_register_group (struct reggroup *group,
       pos = 0;
       for (regnum = 0; regnum < gdbarch_num_cooked_regs (gdbarch); regnum++)
         {
-	  struct tui_gen_win_info *data_item_win;
-          struct tui_data_element *data;
+	  struct tui_data_item_window *data_item_win;
           const char *name;
 
           /* Must be in the group.  */
@@ -262,16 +257,15 @@ tui_show_register_group (struct reggroup *group,
 
 	  data_item_win =
             TUI_DATA_WIN->regs_content[pos]->which_element.data_window;
-          data = &data_item_win->content[0]->which_element.data;
-          if (data)
+          if (data_item_win)
             {
               if (!refresh_values_only)
                 {
-                  data->item_no = regnum;
-                  data->name = name;
-                  data->highlight = FALSE;
+                  data_item_win->item_no = regnum;
+                  data_item_win->name = name;
+                  data_item_win->highlight = false;
                 }
-              tui_get_register (frame, data, regnum, 0);
+              tui_get_register (frame, data_item_win, regnum, 0);
             }
           pos++;
 	}
@@ -300,16 +294,14 @@ tui_display_registers_from (int start_element_no)
       int max_len = 0;
       for (i = 0; i < TUI_DATA_WIN->regs_content_count; i++)
         {
-          struct tui_data_element *data;
-          struct tui_gen_win_info *data_item_win;
+          struct tui_data_item_window *data_item_win;
           char *p;
           int len;
 
           data_item_win
 	    = TUI_DATA_WIN->regs_content[i]->which_element.data_window;
-          data = &data_item_win->content[0]->which_element.data;
           len = 0;
-          p = data->content;
+          p = data_item_win->content;
           if (p != 0)
             while (*p)
               {
@@ -343,13 +335,11 @@ tui_display_registers_from (int start_element_no)
 		 && i < TUI_DATA_WIN->regs_content_count;
 	       j++)
 	    {
-	      struct tui_gen_win_info *data_item_win;
-	      struct tui_data_element *data_element_ptr;
+	      struct tui_data_item_window *data_item_win;
 
 	      /* Create the window if necessary.  */
 	      data_item_win = TUI_DATA_WIN->regs_content[i]
                 ->which_element.data_window;
-	      data_element_ptr = &data_item_win->content[0]->which_element.data;
               if (data_item_win->handle != NULL
                   && (data_item_win->height != 1
                       || data_item_win->width != item_win_width
@@ -373,7 +363,7 @@ tui_display_registers_from (int start_element_no)
 
 	      /* Get the printable representation of the register
                  and display it.  */
-              tui_display_register (data_element_ptr, data_item_win);
+              tui_display_register (data_item_win);
 	      i++;		/* Next register.  */
 	    }
 	  cur_y++;		/* Next row.  */
@@ -481,21 +471,20 @@ tui_check_register_values (struct frame_info *frame)
 
 	  for (i = 0; (i < TUI_DATA_WIN->regs_content_count); i++)
 	    {
-	      struct tui_data_element *data;
-	      struct tui_gen_win_info *data_item_win_ptr;
+	      struct tui_data_item_window *data_item_win_ptr;
 	      int was_hilighted;
 
 	      data_item_win_ptr = TUI_DATA_WIN->regs_content[i]->
                 which_element.data_window;
-	      data = &data_item_win_ptr->content[0]->which_element.data;
-	      was_hilighted = data->highlight;
+	      was_hilighted = data_item_win_ptr->highlight;
 
-              tui_get_register (frame, data,
-                                data->item_no, &data->highlight);
+              tui_get_register (frame, data_item_win_ptr,
+                                data_item_win_ptr->item_no,
+				&data_item_win_ptr->highlight);
 
-	      if (data->highlight || was_hilighted)
+	      if (data_item_win_ptr->highlight || was_hilighted)
 		{
-                  tui_display_register (data, data_item_win_ptr);
+                  tui_display_register (data_item_win_ptr);
 		}
 	    }
 	}
@@ -505,10 +494,9 @@ tui_check_register_values (struct frame_info *frame)
 /* 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_element *data,
-                      struct tui_gen_win_info *win_info)
+tui_display_register (struct tui_data_item_window *data)
 {
-  if (win_info->handle != NULL)
+  if (data->handle != NULL)
     {
       int i;
 
@@ -518,14 +506,14 @@ tui_display_register (struct tui_data_element *data,
 	   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 (win_info->handle);
+	(void) wstandout (data->handle);
       
-      wmove (win_info->handle, 0, 0);
-      for (i = 1; i < win_info->width; i++)
-        waddch (win_info->handle, ' ');
-      wmove (win_info->handle, 0, 0);
+      wmove (data->handle, 0, 0);
+      for (i = 1; i < data->width; i++)
+        waddch (data->handle, ' ');
+      wmove (data->handle, 0, 0);
       if (data->content)
-        waddstr (win_info->handle, data->content);
+        waddstr (data->handle, data->content);
 
       if (data->highlight)
 	/* We ignore the return value, casting it to void in order to avoid
@@ -533,8 +521,8 @@ tui_display_register (struct tui_data_element *data,
 	   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 (win_info->handle);
-      win_info->refresh_window ();
+	(void) wstandend (data->handle);
+      data->refresh_window ();
     }
 }
 
@@ -716,13 +704,13 @@ tui_register_format (struct frame_info *frame, int regnum)
    changed with respect to the previous call.  */
 static enum tui_status
 tui_get_register (struct frame_info *frame,
-                  struct tui_data_element *data, 
-		  int regnum, int *changedp)
+                  struct tui_data_item_window *data, 
+		  int regnum, bool *changedp)
 {
   enum tui_status ret = TUI_FAILURE;
 
   if (changedp)
-    *changedp = FALSE;
+    *changedp = false;
   if (target_has_registers)
     {
       char *prev_content = data->content;
@@ -731,7 +719,7 @@ tui_get_register (struct frame_info *frame,
 
       if (changedp != NULL
 	  && strcmp (prev_content, data->content) != 0)
-	*changedp = 1;
+	*changedp = true;
 
       xfree (prev_content);
 
-- 
2.17.2

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

* Re: [PATCH 00/66] Clean up the TUI
  2019-06-24 16:47   ` Tom Tromey
  2019-06-24 17:46     ` Pedro Alves
@ 2019-06-24 18:54     ` Tom Tromey
  2019-06-24 22:23       ` Pedro Alves
  1 sibling, 1 reply; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 18:54 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Pedro Alves, gdb-patches

Tom> I don't know why :( I will send the remaining patches separately.

I managed to do this, though somewhat clumsily as I forgot to use
--no-thread.

Tom

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

* Re: [PATCH 08/66] Remove tui_list
  2019-06-24 14:12   ` Pedro Alves
  2019-06-24 15:12     ` Ruslan Kabatsayev
@ 2019-06-24 20:47     ` Tom Tromey
  1 sibling, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 20:47 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

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

Pedro> On 6/23/19 11:42 PM, Tom Tromey wrote:
>> -static struct tui_list source_windows = {src_win_list, 0};
>> +static struct std::vector<tui_win_info *> source_windows;

Pedro> I usually prefer to drop "struct", but I can live with it.

Pedro> However, I have to say that "struct std::vector" looks weird.  :-)

Pedro> (There are other instances in the patch.)

This was just an oversight when search/replacing.
I've fixed it.

Tom

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

* Re: [PATCH 14/66] Introduce has_locator method
  2019-06-24 14:13   ` Pedro Alves
@ 2019-06-24 20:50     ` Tom Tromey
  0 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 20:50 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

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

>> -  int has_locator;		/* Does locator belongs to this window?  */
>> +  bool has_locator;		/* Does locator belongs to this window?  */

Pedro> I'd vote to fix the comment's grammar at the same time.

I did that.

>> +  /* Return true if this window has a locator.  */

Pedro> Should this "a locator" be "the locator", or ...

It should be "the locator", so I made this change.

Tom

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

* Re: [PATCH 40/66] Remove tui_scroll_direction enum
  2019-06-24 14:13   ` Pedro Alves
@ 2019-06-24 20:51     ` Tom Tromey
  0 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 20:51 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

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

Pedro> On 6/23/19 11:43 PM, Tom Tromey wrote:
>> -  do_scroll_vertical (BACKWARD_SCROLL, num_to_scroll);
>> +  do_scroll_vertical (- num_to_scroll);

Pedro> No space after - (unary minus):

Pedro>  https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#Whitespaces

I've fixed this.

Tom

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

* Re: [PATCH 49/66] Separate out execution-info window
  2019-06-24 14:13   ` Pedro Alves
@ 2019-06-24 20:52     ` Tom Tromey
  0 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-24 20:52 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

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

Pedro> On 6/23/19 11:43 PM, Tom Tromey wrote:
>> +  /* Get or allocate contents.  */
>> +  tui_exec_info_content *maybe_allocate_content (int n_elements);
>> +
>> +  /* Allocate contents.  */

Pedro> This "Allocate" here reads odd.  Did you mean "Get" instead of "Allocate"?

>> +  const tui_exec_info_content *get_content () const
>> +  {

Yes, thanks.  I've fixed this.

Tom

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

* Re: [PATCH 03/66] Create subclasses for different window types
  2019-06-23 22:44 ` [PATCH 03/66] Create subclasses for different window types Tom Tromey
@ 2019-06-24 22:21   ` Pedro Alves
  2019-06-25 13:51     ` Tom Tromey
  0 siblings, 1 reply; 85+ messages in thread
From: Pedro Alves @ 2019-06-24 22:21 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 6/23/19 11:42 PM, Tom Tromey wrote:
> +protected:
>  
> +  tui_win_info (enum tui_win_type type);

I forgot to mention in the earlier pass that I thought that
these ctors should be explicit?

Fine with me to leave it as is, and then fix it all up
in a follow up patch, if that's easier.

Thanks,
Pedro Alves

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

* Re: [PATCH 00/66] Clean up the TUI
  2019-06-24 18:54     ` Tom Tromey
@ 2019-06-24 22:23       ` Pedro Alves
  2019-06-25 13:51         ` Tom Tromey
  0 siblings, 1 reply; 85+ messages in thread
From: Pedro Alves @ 2019-06-24 22:23 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 6/24/19 7:54 PM, Tom Tromey wrote:
> Tom> I don't know why :( I will send the remaining patches separately.
> 
> I managed to do this, though somewhat clumsily as I forgot to use
> --no-thread.
> 

Skimmed the patches out, and nothing stood out to me.  It all
looked fine.

Thanks again for doing all this, and I have to say I'm impressed
by the neat patch splitting.

Thanks,
Pedro Alves

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

* Re: [PATCH 00/66] Clean up the TUI
  2019-06-24 22:23       ` Pedro Alves
@ 2019-06-25 13:51         ` Tom Tromey
  0 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-25 13:51 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

Pedro> Skimmed the patches out, and nothing stood out to me.  It all
Pedro> looked fine.

I'm going to check it in now.

Pedro> Thanks again for doing all this, and I have to say I'm impressed
Pedro> by the neat patch splitting.

Thanks!

Tom

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

* Re: [PATCH 03/66] Create subclasses for different window types
  2019-06-24 22:21   ` Pedro Alves
@ 2019-06-25 13:51     ` Tom Tromey
  0 siblings, 0 replies; 85+ messages in thread
From: Tom Tromey @ 2019-06-25 13:51 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

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

Pedro> On 6/23/19 11:42 PM, Tom Tromey wrote:
>> +protected:
>> 
>> +  tui_win_info (enum tui_win_type type);

Pedro> I forgot to mention in the earlier pass that I thought that
Pedro> these ctors should be explicit?

Yes, thanks.  I went through and added them where it seemed appropriate.

Tom

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

end of thread, other threads:[~2019-06-25 13:51 UTC | newest]

Thread overview: 85+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-23 22:43 [PATCH 00/66] Clean up the TUI Tom Tromey
2019-06-23 22:43 ` [PATCH 12/66] Don't use TUI_DISASM_WIN in tui_disasm_window method Tom Tromey
2019-06-23 22:43 ` [PATCH 13/66] Remove tui_clear_win_detail Tom Tromey
2019-06-23 22:43 ` [PATCH 01/66] Use new and delete for TUI windows Tom Tromey
2019-06-23 22:43 ` [PATCH 05/66] Simplify command window creation Tom Tromey
2019-06-23 22:43 ` [PATCH 10/66] Create tui_disasm_window Tom Tromey
2019-06-23 22:43 ` [PATCH 08/66] Remove tui_list Tom Tromey
2019-06-24 14:12   ` Pedro Alves
2019-06-24 15:12     ` Ruslan Kabatsayev
2019-06-24 16:05       ` Pedro Alves
2019-06-24 20:47     ` Tom Tromey
2019-06-23 22:44 ` [PATCH 26/66] Introduce set_new_height method Tom Tromey
2019-06-23 22:44 ` [PATCH 16/66] Remove struct tui_command_info Tom Tromey
2019-06-23 22:44 ` [PATCH 15/66] Remove struct tui_source_info Tom Tromey
2019-06-23 22:44 ` [PATCH 21/66] Introduce make_visible method Tom Tromey
2019-06-23 22:44 ` [PATCH 20/66] Remove an unneeded NULL check Tom Tromey
2019-06-23 22:44 ` [PATCH 28/66] Remove redundant check from make_visible Tom Tromey
2019-06-23 22:44 ` [PATCH 27/66] Introduce max_height method Tom Tromey
2019-06-23 22:44 ` [PATCH 25/66] Introduce the refresh_all method Tom Tromey
2019-06-23 22:44 ` [PATCH 17/66] Remove struct tui_data_info Tom Tromey
2019-06-23 22:44 ` [PATCH 04/66] Remove an unnecessary NULL check from the TUI Tom Tromey
2019-06-23 22:44 ` [PATCH 02/66] Add destructor to tui_win_info Tom Tromey
2019-06-23 22:44 ` [PATCH 24/66] Introduce two TUI source window methods Tom Tromey
2019-06-23 22:44 ` [PATCH 06/66] Simplify source and disassembly window creation Tom Tromey
2019-06-23 22:44 ` [PATCH 14/66] Introduce has_locator method Tom Tromey
2019-06-24 14:13   ` Pedro Alves
2019-06-24 20:50     ` Tom Tromey
2019-06-23 22:44 ` [PATCH 09/66] Split the tui_win_info destructor Tom Tromey
2019-06-23 22:44 ` [PATCH 11/66] Introduce methods for scrolling Tom Tromey
2019-06-23 22:44 ` [PATCH 07/66] Introduce tui_win_info::clear_detail method Tom Tromey
2019-06-23 22:44 ` [PATCH 23/66] Introduce the refresh method Tom Tromey
2019-06-23 22:44 ` [PATCH 22/66] Use bool for visibility Tom Tromey
2019-06-23 22:44 ` [PATCH 29/66] Introduce set_highlight method Tom Tromey
2019-06-23 22:44 ` [PATCH 03/66] Create subclasses for different window types Tom Tromey
2019-06-24 22:21   ` Pedro Alves
2019-06-25 13:51     ` Tom Tromey
2019-06-23 22:44 ` [PATCH 19/66] Inline constructors and initializers Tom Tromey
2019-06-23 22:44 ` [PATCH 18/66] Change tui_data_window::display_regs to bool Tom Tromey
2019-06-23 23:25 ` [PATCH 45/66] Introduce tui_win_info::update_tab_width Tom Tromey
2019-06-23 23:25 ` [PATCH 40/66] Remove tui_scroll_direction enum Tom Tromey
2019-06-24 14:13   ` Pedro Alves
2019-06-24 20:51     ` Tom Tromey
2019-06-23 23:25 ` [PATCH 41/66] Move make_visible method to tui_gen_win_info Tom Tromey
2019-06-23 23:25 ` [PATCH 42/66] Introduce tui_gen_win_info::reset method Tom Tromey
2019-06-23 23:25 ` [PATCH 34/66] Change tui_update_source_window for better type safety Tom Tromey
2019-06-23 23:25 ` [PATCH 35/66] Introduce tui_gen_win_info::name method Tom Tromey
2019-06-23 23:26 ` [PATCH 37/66] Remove NULL check from tui_set_exec_info_content Tom Tromey
2019-06-23 23:26 ` [PATCH 43/66] Remove some TUI static allocations Tom Tromey
2019-06-23 23:26 ` [PATCH 48/66] Remove tui_alloc_win_info Tom Tromey
2019-06-23 23:26 ` [PATCH 39/66] Change more TUI functions to take a tui_source_window_base Tom Tromey
2019-06-23 23:26 ` [PATCH 38/66] Change tui_set_exec_info_content to return void Tom Tromey
2019-06-23 23:26 ` [PATCH 46/66] Introduce tui_win_info::make_visible_with_new_height Tom Tromey
2019-06-23 23:26 ` [PATCH 30/66] Change tui_which_element::data_window to be a pointer Tom Tromey
2019-06-23 23:26 ` [PATCH 31/66] Use new and delete for tui_gen_win_info Tom Tromey
2019-06-23 23:26 ` [PATCH 36/66] Change tui_alloc_source_buffer return type to void Tom Tromey
2019-06-23 23:26 ` [PATCH 32/66] Derive tui_win_info from tui_gen_win_info Tom Tromey
2019-06-23 23:26 ` [PATCH 33/66] Introduce refresh_window method Tom Tromey
2019-06-23 23:26 ` [PATCH 47/66] Don't check window type in tui_set_win_focus_to Tom Tromey
2019-06-23 23:26 ` [PATCH 49/66] Separate out execution-info window Tom Tromey
2019-06-24 14:13   ` Pedro Alves
2019-06-24 20:52     ` Tom Tromey
2019-06-23 23:26 ` [PATCH 44/66] Introduce enum tui_box Tom Tromey
2019-06-24 14:23 ` [PATCH 00/66] Clean up the TUI Pedro Alves
2019-06-24 16:47   ` Tom Tromey
2019-06-24 17:46     ` Pedro Alves
2019-06-24 18:54     ` Tom Tromey
2019-06-24 22:23       ` Pedro Alves
2019-06-25 13:51         ` Tom Tromey
2019-06-24 18:49 ` [PATCH 50/66] Separate out locator window Tom Tromey
2019-06-24 18:48   ` [PATCH 55/66] Remove tui_init_generic_part Tom Tromey
2019-06-24 18:48   ` [PATCH 53/66] Remove two unused enum constants from tui_win_type Tom Tromey
2019-06-24 18:49   ` [PATCH 58/66] Separate out data window Tom Tromey
2019-06-24 18:49   ` [PATCH 51/66] Remove layout_def::split Tom Tromey
2019-06-24 18:49   ` [PATCH 56/66] Turn tui_first_data_item_displayed into a method Tom Tromey
2019-06-24 18:49   ` [PATCH 52/66] Remove command from tui_which_element Tom Tromey
2019-06-24 18:49   ` [PATCH 63/66] Remove NULL checks before xfree Tom Tromey
2019-06-24 18:49   ` [PATCH 60/66] Use bool for is_exec_point Tom Tromey
2019-06-24 18:49   ` [PATCH 64/66] Fix latent bug in set_is_exec_point_at Tom Tromey
2019-06-24 18:49   ` [PATCH 54/66] Separate out data item window Tom Tromey
2019-06-24 18:49   ` [PATCH 66/66] Tidy tui_delete_win Tom Tromey
2019-06-24 18:49   ` [PATCH 57/66] Remove "data_content" and "data_content_count" from TUI data window Tom Tromey
2019-06-24 18:49   ` [PATCH 61/66] More type safety for TUI source window functions Tom Tromey
2019-06-24 18:49   ` [PATCH 59/66] Fix "auxiliary" typo Tom Tromey
2019-06-24 18:49   ` [PATCH 62/66] Remove union tui_which_element Tom Tromey
2019-06-24 18:49   ` [PATCH 65/66] Make tui_gen_win_info constructor protected 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).