public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 08/61] Introduce tui_data_window::first_reg_element_no_inline
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (7 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 18/61] Simplify tui_show_registers Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 36/61] Always create an execution info window for a source window Tom Tromey
                   ` (52 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_first_reg_element_no_inline to be a method on
tui_data_window.  This again moves uses of the TUI_DATA_WIN global
from this function into other functions that are already using the
global.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.h (tui_first_reg_element_no_inline): Don't
	declare.
	* tui/tui-regs.c (tui_data_window::first_reg_element_no_inline):
	Rename from tui_first_reg_element_no_inline.
	(tui_display_reg_element_at_line)
	(tui_display_registers_from_line): Update.
	* tui/tui-data.h (struct tui_data_window)
	<first_reg_element_no_inline>: New method.
---
 gdb/ChangeLog      | 11 +++++++++++
 gdb/tui/tui-data.h |  4 ++++
 gdb/tui/tui-regs.c | 16 +++++++---------
 gdb/tui/tui-regs.h |  1 -
 4 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 081d0dfa449..676345c528a 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -499,6 +499,10 @@ struct tui_data_window : public tui_win_info
      elements there are, -1 is returned.  */
   int line_from_reg_element_no (int element_no) const;
 
+  /* Answer the index of the first element in line_no.  If line_no is
+     past the register area (-1) is returned.  */
+  int first_reg_element_no_inline (int line_no) const;
+
 protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 03e91496b0f..d005fe36c23 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -103,16 +103,13 @@ tui_data_window::line_from_reg_element_no (int element_no) const
     return (-1);
 }
 
+/* See tui-data.h.  */
 
-/* Answer the index of the first element in line_no.  If line_no is
-   past the register area (-1) is returned.  */
 int
-tui_first_reg_element_no_inline (int line_no)
+tui_data_window::first_reg_element_no_inline (int line_no) const
 {
-  if ((line_no * TUI_DATA_WIN->regs_column_count)
-      <= TUI_DATA_WIN->regs_content.size ())
-    return (((line_no + 1) * TUI_DATA_WIN->regs_column_count) 
-	    - TUI_DATA_WIN->regs_column_count);
+  if (line_no * regs_column_count <= regs_content.size ())
+    return ((line_no + 1) * regs_column_count) - regs_column_count;
   else
     return (-1);
 }
@@ -362,7 +359,8 @@ tui_display_reg_element_at_line (int start_element_no,
 	     display at.  */
 	  if (start_line_no > first_line_on_last_page)
 	    element_no
-	      = tui_first_reg_element_no_inline (first_line_on_last_page);
+	      = (TUI_DATA_WIN->first_reg_element_no_inline
+		 (first_line_on_last_page));
 	}
       tui_display_registers_from (element_no);
     }
@@ -399,7 +397,7 @@ tui_display_registers_from_line (int line_no,
       else
 	line = line_no;
 
-      element_no = tui_first_reg_element_no_inline (line);
+      element_no = TUI_DATA_WIN->first_reg_element_no_inline (line);
       if (element_no < TUI_DATA_WIN->regs_content.size ())
 	tui_display_reg_element_at_line (element_no, line);
       else
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index f6ed8628f2a..866af458e10 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -29,6 +29,5 @@ extern void tui_show_registers (struct reggroup *group);
 extern void tui_display_registers_from (int);
 extern int tui_display_registers_from_line (int, int);
 extern int tui_first_reg_element_inline (int);
-extern int tui_first_reg_element_no_inline (int lineno);
 
 #endif /* TUI_TUI_REGS_H */
-- 
2.17.2

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

* [PATCH 27/61] Remove unused parameter from two TUI functions
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (29 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 06/61] Introduce tui_data_window::last_regs_line_no method Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 22/61] Make source windows be self-updating Tom Tromey
                   ` (30 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The "display_prompt" parameter of tui_erase_source_content and
tui_clear_source_content was never passed the NO_EMPTY_SOURCE_PROMPT
value, so remove the parameter.  Once this is done, the
EMPTY_SOURCE_PROMPT and NO_EMPTY_SOURCE_PROMPT defines are unused, so
remove those as well.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_erase_source_content)
	(tui_clear_source_content): Remove "display_prompt" parameter.
	* tui/tui-winsource.c (tui_update_source_window_as_is)
	(tui_update_source_windows_with_addr): Update.
	(tui_clear_source_content): Remove "display_prompt" parameter.
	(tui_erase_source_content): Likewise.  Simplify.
	(tui_show_source_content): Update.
	* tui/tui-win.c (tui_resize_all, tui_adjust_win_heights): Update.
	* tui/tui-stack.c (tui_show_frame_info): Update.
	* tui/tui-data.h (EMPTY_SOURCE_PROMPT, NO_EMPTY_SOURCE_PROMPT):
	Remove defines.
---
 gdb/ChangeLog           | 14 ++++++++++
 gdb/tui/tui-data.h      |  2 --
 gdb/tui/tui-stack.c     |  2 +-
 gdb/tui/tui-win.c       | 11 ++++----
 gdb/tui/tui-winsource.c | 61 ++++++++++++++++++++---------------------
 gdb/tui/tui-winsource.h |  4 +--
 6 files changed, 51 insertions(+), 43 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 0f62fb69900..96f44479b5e 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -109,8 +109,6 @@ enum tui_box
 #define NO_HILITE               FALSE
 #define WITH_LOCATOR            TRUE
 #define NO_LOCATOR              FALSE
-#define EMPTY_SOURCE_PROMPT     TRUE
-#define NO_EMPTY_SOURCE_PROMPT  FALSE
 #define UNDEFINED_ITEM          -1
 #define MIN_WIN_HEIGHT          3
 #define MIN_CMD_WIN_HEIGHT      3
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index b466b5fe7f8..6acc2277c04 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -444,7 +444,7 @@ tui_show_frame_info (struct frame_info *fi)
       tui_show_locator_content ();
       for (struct tui_source_window_base *win_info : tui_source_windows ())
 	{
-	  tui_clear_source_content (win_info, EMPTY_SOURCE_PROMPT);
+	  tui_clear_source_content (win_info);
 	  tui_update_exec_info (win_info);
 	}
 
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 7abb8d1e98f..52f0c51f320 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -610,7 +610,7 @@ tui_resize_all (void)
 	  first_win->make_visible_with_new_height ();
 	  TUI_CMD_WIN->make_visible_with_new_height ();
 	  if (src_win->content.empty ())
-	    tui_erase_source_content (src_win, EMPTY_SOURCE_PROMPT);
+	    tui_erase_source_content (src_win);
 	  break;
 	default:
 	  if (cur_layout == SRC_DISASSEM_COMMAND)
@@ -675,7 +675,7 @@ tui_resize_all (void)
 	  second_win->make_visible_with_new_height ();
 	  TUI_CMD_WIN->make_visible_with_new_height ();
 	  if (src_win->content.empty ())
-	    tui_erase_source_content (src_win, EMPTY_SOURCE_PROMPT);
+	    tui_erase_source_content (src_win);
 	  break;
 	}
       /* Now remove all invisible windows, and their content so that
@@ -1113,8 +1113,7 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 		  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);
+		    tui_erase_source_content (src_base);
 		}
 	    }
 	  else
@@ -1221,9 +1220,9 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 	      second_win->make_visible_with_new_height ();
 	      first_win->make_visible_with_new_height ();
 	      if (src1 != nullptr && src1->content.empty ())
-		tui_erase_source_content (src1, EMPTY_SOURCE_PROMPT);
+		tui_erase_source_content (src1);
 	      if (second_win->content.empty ())
-		tui_erase_source_content (second_win, EMPTY_SOURCE_PROMPT);
+		tui_erase_source_content (second_win);
 	    }
 	}
     }
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index a72ba360185..65aa5164122 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -101,7 +101,7 @@ tui_update_source_window_as_is (struct tui_source_window_base *win_info,
 
   if (ret == TUI_FAILURE)
     {
-      tui_clear_source_content (win_info, EMPTY_SOURCE_PROMPT);
+      tui_clear_source_content (win_info);
       tui_clear_exec_info_content (win_info);
     }
   else
@@ -162,7 +162,7 @@ tui_update_source_windows_with_addr (struct gdbarch *gdbarch, CORE_ADDR addr)
     {
       for (struct tui_source_window_base *win_info : tui_source_windows ())
 	{
-	  tui_clear_source_content (win_info, EMPTY_SOURCE_PROMPT);
+	  tui_clear_source_content (win_info);
 	  tui_clear_exec_info_content (win_info);
 	}
     }
@@ -205,15 +205,14 @@ tui_update_source_windows_with_line (struct symtab *s, int line)
 }
 
 void
-tui_clear_source_content (struct tui_source_window_base *win_info,
-			  int display_prompt)
+tui_clear_source_content (struct tui_source_window_base *win_info)
 {
   if (win_info != NULL)
     {
       int i;
 
       win_info->content_in_use = false;
-      tui_erase_source_content (win_info, display_prompt);
+      tui_erase_source_content (win_info);
       for (i = 0; i < win_info->content.size (); i++)
 	{
 	  struct tui_source_element *element = &win_info->content[i];
@@ -226,8 +225,7 @@ tui_clear_source_content (struct tui_source_window_base *win_info,
 
 
 void
-tui_erase_source_content (struct tui_source_window_base *win_info,
-			  int display_prompt)
+tui_erase_source_content (struct tui_source_window_base *win_info)
 {
   int x_pos;
   int half_width = (win_info->width - 2) / 2;
@@ -236,30 +234,29 @@ tui_erase_source_content (struct tui_source_window_base *win_info,
     {
       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->type == SRC_WIN)
-	    no_src_str = NO_SRC_STRING;
-	  else
-	    no_src_str = NO_DISASSEM_STRING;
-	  if (strlen (no_src_str) >= half_width)
-	    x_pos = 1;
-	  else
-	    x_pos = half_width - strlen (no_src_str);
-	  mvwaddstr (win_info->handle,
-		     (win_info->height / 2),
-		     x_pos,
-		     (char *) no_src_str);
-
-	  /* elz: Added this function call to set the real contents of
-	     the window to what is on the screen, so that later calls
-	     to refresh, do display the correct stuff, and not the old
-	     image.  */
-
-	  tui_set_source_content_nil (win_info, no_src_str);
-	}
+
+      const char *no_src_str;
+
+      if (win_info->type == SRC_WIN)
+	no_src_str = NO_SRC_STRING;
+      else
+	no_src_str = NO_DISASSEM_STRING;
+      if (strlen (no_src_str) >= half_width)
+	x_pos = 1;
+      else
+	x_pos = half_width - strlen (no_src_str);
+      mvwaddstr (win_info->handle,
+		 (win_info->height / 2),
+		 x_pos,
+		 (char *) no_src_str);
+
+      /* elz: Added this function call to set the real contents of
+	 the window to what is on the screen, so that later calls
+	 to refresh, do display the correct stuff, and not the old
+	 image.  */
+
+      tui_set_source_content_nil (win_info, no_src_str);
+
       win_info->refresh_window ();
     }
 }
@@ -302,7 +299,7 @@ tui_show_source_content (struct tui_source_window_base *win_info)
         tui_show_source_line (win_info, lineno);
     }
   else
-    tui_erase_source_content (win_info, TRUE);
+    tui_erase_source_content (win_info);
 
   tui_check_and_display_highlight_if_needed (win_info);
   win_info->refresh_window ();
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index c1087f4490a..a4907e6cc4e 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -57,8 +57,8 @@ 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_source_window_base *, int);
-extern void tui_erase_source_content (struct tui_source_window_base *, int);
+extern void tui_clear_source_content (struct tui_source_window_base *);
+extern void tui_erase_source_content (struct tui_source_window_base *);
 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 *);
-- 
2.17.2

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

* [PATCH 40/61] Change tui_set_layout to return void
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (24 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 31/61] Remove tui_source_window::content_in_use Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 03/61] Remove some uses of TUI_WIN_SRC Tom Tromey
                   ` (35 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_set_layout can't meaningfully be called with UNDEFINED_LAYOUT; and
instead of trying to handle this case, simply assert and have the
function return void.  No caller was checking the return value anyway.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.h (tui/tui-layout): Return void.
	* tui/tui-layout.c (tui_set_layout): Return void.  Add assert.
---
 gdb/ChangeLog        |   5 ++
 gdb/tui/tui-layout.c | 167 +++++++++++++++++++++----------------------
 gdb/tui/tui-layout.h |   2 +-
 3 files changed, 86 insertions(+), 88 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index d15df2a37c8..7feadd71ece 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -113,104 +113,97 @@ show_layout (enum tui_layout_type layout)
 
 /* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
    SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.  */
-enum tui_status
+void
 tui_set_layout (enum tui_layout_type layout_type)
 {
-  enum tui_status status = TUI_SUCCESS;
+  gdb_assert (layout_type != UNDEFINED_LAYOUT);
 
-  if (layout_type != UNDEFINED_LAYOUT)
-    {
-      enum tui_layout_type cur_layout = tui_current_layout ();
-      struct gdbarch *gdbarch;
-      CORE_ADDR addr;
-      struct tui_win_info *win_with_focus = tui_win_with_focus ();
-      struct tui_layout_def *layout_def = tui_layout_def ();
+  enum tui_layout_type cur_layout = tui_current_layout ();
+  struct gdbarch *gdbarch;
+  CORE_ADDR addr;
+  struct tui_win_info *win_with_focus = tui_win_with_focus ();
+  struct tui_layout_def *layout_def = tui_layout_def ();
 
-      extract_display_start_addr (&gdbarch, &addr);
+  extract_display_start_addr (&gdbarch, &addr);
 
-      enum tui_layout_type new_layout = layout_type;
+  enum tui_layout_type new_layout = layout_type;
 
-      if (new_layout != cur_layout)
-	{
-	  show_layout (new_layout);
+  if (new_layout != cur_layout)
+    {
+      show_layout (new_layout);
 
-	  /* Now determine where focus should be.  */
-	  if (win_with_focus != TUI_CMD_WIN)
+      /* Now determine where focus should be.  */
+      if (win_with_focus != TUI_CMD_WIN)
+	{
+	  switch (new_layout)
 	    {
-	      switch (new_layout)
-		{
-		case SRC_COMMAND:
-		  tui_set_win_focus_to (TUI_SRC_WIN);
-		  layout_def->display_mode = SRC_WIN;
-		  break;
-		case DISASSEM_COMMAND:
-		  /* The previous layout was not showing code.
-		     This can happen if there is no source
-		     available:
-
-		     1. if the source file is in another dir OR
-		     2. if target was compiled without -g
-		     We still want to show the assembly though!  */
-
-		  tui_get_begin_asm_address (&gdbarch, &addr);
-		  tui_set_win_focus_to (TUI_DISASM_WIN);
-		  layout_def->display_mode = DISASSEM_WIN;
-		  break;
-		case SRC_DISASSEM_COMMAND:
-		  /* The previous layout was not showing code.
-		     This can happen if there is no source
-		     available:
-
-		     1. if the source file is in another dir OR
-		     2. if target was compiled without -g
-		     We still want to show the assembly though!  */
-
-		  tui_get_begin_asm_address (&gdbarch, &addr);
-		  if (win_with_focus == TUI_SRC_WIN)
-		    tui_set_win_focus_to (TUI_SRC_WIN);
-		  else
-		    tui_set_win_focus_to (TUI_DISASM_WIN);
-		  break;
-		case SRC_DATA_COMMAND:
-		  if (win_with_focus != TUI_DATA_WIN)
-		    tui_set_win_focus_to (TUI_SRC_WIN);
-		  else
-		    tui_set_win_focus_to (TUI_DATA_WIN);
-		  layout_def->display_mode = SRC_WIN;
-		  break;
-		case DISASSEM_DATA_COMMAND:
-		  /* The previous layout was not showing code.
-		     This can happen if there is no source
-		     available:
-
-		     1. if the source file is in another dir OR
-		     2. if target was compiled without -g
-		     We still want to show the assembly though!  */
-
-		  tui_get_begin_asm_address (&gdbarch, &addr);
-		  if (win_with_focus != TUI_DATA_WIN)
-		    tui_set_win_focus_to (TUI_DISASM_WIN);
-		  else
-		    tui_set_win_focus_to (TUI_DATA_WIN);
-		  layout_def->display_mode = DISASSEM_WIN;
-		  break;
-		default:
-		  break;
-		}
+	    case SRC_COMMAND:
+	      tui_set_win_focus_to (TUI_SRC_WIN);
+	      layout_def->display_mode = SRC_WIN;
+	      break;
+	    case DISASSEM_COMMAND:
+	      /* The previous layout was not showing code.
+		 This can happen if there is no source
+		 available:
+
+		 1. if the source file is in another dir OR
+		 2. if target was compiled without -g
+		 We still want to show the assembly though!  */
+
+	      tui_get_begin_asm_address (&gdbarch, &addr);
+	      tui_set_win_focus_to (TUI_DISASM_WIN);
+	      layout_def->display_mode = DISASSEM_WIN;
+	      break;
+	    case SRC_DISASSEM_COMMAND:
+	      /* The previous layout was not showing code.
+		 This can happen if there is no source
+		 available:
+
+		 1. if the source file is in another dir OR
+		 2. if target was compiled without -g
+		 We still want to show the assembly though!  */
+
+	      tui_get_begin_asm_address (&gdbarch, &addr);
+	      if (win_with_focus == TUI_SRC_WIN)
+		tui_set_win_focus_to (TUI_SRC_WIN);
+	      else
+		tui_set_win_focus_to (TUI_DISASM_WIN);
+	      break;
+	    case SRC_DATA_COMMAND:
+	      if (win_with_focus != TUI_DATA_WIN)
+		tui_set_win_focus_to (TUI_SRC_WIN);
+	      else
+		tui_set_win_focus_to (TUI_DATA_WIN);
+	      layout_def->display_mode = SRC_WIN;
+	      break;
+	    case DISASSEM_DATA_COMMAND:
+	      /* The previous layout was not showing code.
+		 This can happen if there is no source
+		 available:
+
+		 1. if the source file is in another dir OR
+		 2. if target was compiled without -g
+		 We still want to show the assembly though!  */
+
+	      tui_get_begin_asm_address (&gdbarch, &addr);
+	      if (win_with_focus != TUI_DATA_WIN)
+		tui_set_win_focus_to (TUI_DISASM_WIN);
+	      else
+		tui_set_win_focus_to (TUI_DATA_WIN);
+	      layout_def->display_mode = DISASSEM_WIN;
+	      break;
+	    default:
+	      break;
 	    }
-	  /*
-	   * Now update the window content.
-	   */
-	  tui_update_source_windows_with_addr (gdbarch, addr);
-	  if (new_layout == SRC_DATA_COMMAND
-	      || new_layout == DISASSEM_DATA_COMMAND)
-	    tui_show_registers (TUI_DATA_WIN->current_group);
 	}
+      /*
+       * Now update the window content.
+       */
+      tui_update_source_windows_with_addr (gdbarch, addr);
+      if (new_layout == SRC_DATA_COMMAND
+	  || new_layout == DISASSEM_DATA_COMMAND)
+	tui_show_registers (TUI_DATA_WIN->current_group);
     }
-  else
-    status = TUI_FAILURE;
-
-  return status;
 }
 
 /* Add the specified window to the layout in a logical way.  This
diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h
index bc21d2999e4..5f1993387be 100644
--- a/gdb/tui/tui-layout.h
+++ b/gdb/tui/tui-layout.h
@@ -30,6 +30,6 @@ extern int tui_default_win_height (enum tui_win_type,
 				   enum tui_layout_type);
 extern int tui_default_win_viewport_height (enum tui_win_type,
 					    enum tui_layout_type);
-extern enum tui_status tui_set_layout (enum tui_layout_type);
+extern void tui_set_layout (enum tui_layout_type);
 
 #endif /* TUI_TUI_LAYOUT_H */
-- 
2.17.2

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

* [PATCH 24/61] Introduce tui_source_window_base::location_matches_p method
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (16 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 02/61] Check can_highlight in tui_check_and_display_highlight_if_needed Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-17 12:37   ` Pedro Alves
  2019-07-04 17:03 ` [PATCH 12/61] Don't declare unimplemented functions Tom Tromey
                   ` (43 subsequent siblings)
  61 siblings, 1 reply; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces the location_matches_p method, removing a spot that
explicitly examines a window's type.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_update_breakpoint_info): Use
	location_matches_p.
	* tui/tui-source.c (tui_source_window::location_matches_p): New
	method.
	* tui/tui-disasm.c (tui_disasm_window::location_matches_p): New
	method.
	* tui/tui-data.h (struct tui_source_window_base)
	<location_matches_p>: New method.
	(struct tui_source_window, struct tui_disasm_window)
	<location_matches_p>: Likewise.
---
 gdb/ChangeLog           | 13 +++++++++++++
 gdb/tui/tui-data.h      |  6 ++++++
 gdb/tui/tui-disasm.c    |  7 +++++++
 gdb/tui/tui-source.c    | 10 ++++++++++
 gdb/tui/tui-winsource.c | 11 +----------
 5 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index c456bd7db84..c0f1801ffc1 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -404,6 +404,8 @@ public:
 
   void update_tab_width () override;
 
+  virtual bool location_matches_p (struct bp_location *loc, int line_no) = 0;
+
   /* Does the locator belong to this window?  */
   bool m_has_locator = false;
   /* Execution information window.  */
@@ -435,6 +437,8 @@ struct tui_source_window : public tui_source_window_base
     return SRC_NAME;
   }
 
+  bool location_matches_p (struct bp_location *loc, int line_no) override;
+
 protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
@@ -463,6 +467,8 @@ struct tui_disasm_window : public tui_source_window_base
     return DISASSEM_NAME;
   }
 
+  bool location_matches_p (struct bp_location *loc, int line_no) override;
+
 protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index b22368eccf7..af1a7406be8 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -375,3 +375,10 @@ tui_disasm_window::do_scroll_vertical (int num_to_scroll)
 				      NULL, val, FALSE);
     }
 }
+
+bool
+tui_disasm_window::location_matches_p (struct bp_location *loc, int line_no)
+{
+  return (content[line_no].line_or_addr.loa == LOA_ADDRESS
+	  && content[line_no].line_or_addr.u.addr == loc->address);
+}
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 34cb38b31af..2ca21dcc845 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -345,3 +345,13 @@ tui_source_window::style_changed ()
   if (tui_active && is_visible)
     refill ();
 }
+
+bool
+tui_source_window::location_matches_p (struct bp_location *loc, int line_no)
+{
+  return (content[line_no].line_or_addr.loa == LOA_LINE
+	  && content[line_no].line_or_addr.u.line_no == loc->line_number
+	  && loc->symtab != NULL
+	  && filename_cmp (fullname,
+			   symtab_to_fullname (loc->symtab)) == 0);
+}
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 22cd54ee9b8..03dd1b4af81 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -410,7 +410,6 @@ tui_update_breakpoint_info (struct tui_source_window_base *win,
 {
   int i;
   bool need_refresh = false;
-  tui_source_window_base *src = (tui_source_window_base *) win;
 
   for (i = 0; i < win->content.size (); i++)
     {
@@ -440,15 +439,7 @@ tui_update_breakpoint_info (struct tui_source_window_base *win,
 
 	  for (loc = bp->loc; loc != NULL; loc = loc->next)
 	    {
-	      if ((win == TUI_SRC_WIN
-		   && loc->symtab != NULL
-		   && filename_cmp (src->fullname,
-				    symtab_to_fullname (loc->symtab)) == 0
-		   && line->line_or_addr.loa == LOA_LINE
-		   && loc->line_number == line->line_or_addr.u.line_no)
-		  || (win == TUI_DISASM_WIN
-		      && line->line_or_addr.loa == LOA_ADDRESS
-		      && loc->address == line->line_or_addr.u.addr))
+	      if (win->location_matches_p (loc, i))
 		{
 		  if (bp->enable_state == bp_disabled)
 		    mode |= TUI_BP_DISABLED;
-- 
2.17.2

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

* [PATCH 33/61] Remove tui_set_focus
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (4 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 07/61] Introduce tui_data_window::line_from_reg_element_no method Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 16/61] Introduce tui_data_window::display_reg_element_at_line method Tom Tromey
                   ` (55 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_set_focus_command is a simple wrapper for tui_set_focus, so rename
the latter and remove the wrapper function.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (tui_set_focus_command): Rename from
	tui_set_focus.  Call tui_enable.
	(tui_set_focus_command): Remove.
---
 gdb/ChangeLog     |  6 ++++++
 gdb/tui/tui-win.c | 14 +++-----------
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 52f0c51f320..083f046cafa 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -63,7 +63,6 @@ static int new_height_ok (struct tui_win_info *, int);
 static void tui_set_tab_width_command (const char *, int);
 static void tui_refresh_all_command (const char *, int);
 static void tui_all_windows_info (const char *, int);
-static void tui_set_focus_command (const char *, int);
 static void tui_scroll_forward_command (const char *, int);
 static void tui_scroll_backward_command (const char *, int);
 static void tui_scroll_left_command (const char *, int);
@@ -829,8 +828,10 @@ tui_scroll_right_command (const char *arg, int from_tty)
 
 /* Set focus to the window named by 'arg'.  */
 static void
-tui_set_focus (const char *arg, int from_tty)
+tui_set_focus_command (const char *arg, int from_tty)
 {
+  tui_enable ();
+
   if (arg != NULL)
     {
       char *buf_ptr = xstrdup (arg);
@@ -866,15 +867,6 @@ The window name specified must be valid and visible.\n"));
     warning (_("Incorrect Number of Arguments.\n%s"), FOCUS_USAGE);
 }
 
-static void
-tui_set_focus_command (const char *arg, int from_tty)
-{
-  /* Make sure the curses mode is enabled.  */
-  tui_enable ();
-  tui_set_focus (arg, from_tty);
-}
-
-
 static void
 tui_all_windows_info (const char *arg, int from_tty)
 {
-- 
2.17.2

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

* [PATCH 01/61] Introduce can_scroll method
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (20 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 04/61] Consolidate "if"s in tui_show_frame_info Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 20/61] Introduce TUI window iterator Tom Tromey
                   ` (39 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces a "can_scroll" method, removing a spot that explicitly
checks a window's type.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (struct tui_win_info) <can_scroll>: New method.
	(struct tui_cmd_window) <can_scroll>: New method.
	* tui/tui-command.c (tui_dispatch_ctrl_char): Use can_scroll
	method.
---
 gdb/ChangeLog         |  7 +++++++
 gdb/tui/tui-command.c |  7 +++----
 gdb/tui/tui-data.h    | 11 +++++++++++
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/gdb/tui/tui-command.c b/gdb/tui/tui-command.c
index 259620f7ce7..bd16f801d26 100644
--- a/gdb/tui/tui-command.c
+++ b/gdb/tui/tui-command.c
@@ -48,10 +48,9 @@ tui_dispatch_ctrl_char (unsigned int ch)
   if (ch == '\f')
     tui_refresh_all_win ();
 
-  /* If the command window has the logical focus, or no-one does
-     assume it is the command window; in this case, pass the character
-     on through and do nothing here.  */
-  if (win_info == NULL || win_info == TUI_CMD_WIN)
+  /* If no window has the focus, or if the focus window can't scroll,
+     just pass the character through.  */
+  if (win_info == NULL || !win_info->can_scroll ())
     return ch;
 
   switch (ch)
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 412be1ce756..6a243c3d2f9 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -352,6 +352,12 @@ public:
   void left_scroll (int num_to_scroll);
   void right_scroll (int num_to_scroll);
 
+  /* Return true if this window can be scrolled, false otherwise.  */
+  virtual bool can_scroll () const
+  {
+    return true;
+  }
+
   /* Can this window ever be highlighted?  */
   bool can_highlight = true;
 
@@ -524,6 +530,11 @@ struct tui_cmd_window : public tui_win_info
     return CMD_NAME;
   }
 
+  bool can_scroll () const override
+  {
+    return false;
+  }
+
   int start_line = 0;
 
 protected:
-- 
2.17.2

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

* [PATCH 16/61] Introduce tui_data_window::display_reg_element_at_line method
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (5 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 33/61] Remove tui_set_focus Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 18/61] Simplify tui_show_registers Tom Tromey
                   ` (54 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_display_reg_element_at_line to be a method on
tui_data_window, allowing for the removal of some uses of the
TUI_DATA_WIN global.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.c (tui_data_window::display_reg_element_at_line):
	Rename from tui_display_reg_element_at_line.
	(tui_data_window::display_registers_from_line): Update.
	* tui/tui-data.h (struct tui_data_window)
	<display_reg_element_at_line>: New method.
---
 gdb/ChangeLog      |  8 ++++++++
 gdb/tui/tui-data.h |  7 +++++++
 gdb/tui/tui-regs.c | 21 +++++++++------------
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index e5b4b0f6aa0..b3592e39133 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -535,6 +535,13 @@ protected:
   /* Return the index of the first element displayed.  If none are
      displayed, then return -1.  */
   int first_data_item_displayed ();
+
+  /* Function to display the registers in the content from
+     'start_element_no' on 'start_line_no' until the end of the
+     register content or the end of the display height.  This function
+     checks that we won't display off the end of the register
+     display.  */
+  void display_reg_element_at_line (int start_element_no, int start_line_no);
 };
 
 struct tui_cmd_window : public tui_win_info
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 042563f0495..eea8cf45acf 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -333,11 +333,11 @@ tui_data_window::display_registers_from (int start_element_no)
    'start_element_no' on 'start_line_no' until the end of the register
    content or the end of the display height.  This function checks
    that we won't display off the end of the register display.  */
-static void
-tui_display_reg_element_at_line (int start_element_no,
-				 int start_line_no)
+void
+tui_data_window::display_reg_element_at_line (int start_element_no,
+					      int start_line_no)
 {
-  if (!TUI_DATA_WIN->regs_content.empty ())
+  if (!regs_content.empty ())
     {
       int element_no = start_element_no;
 
@@ -345,9 +345,8 @@ tui_display_reg_element_at_line (int start_element_no,
 	{
 	  int last_line_no, first_line_on_last_page;
 
-	  last_line_no = TUI_DATA_WIN->last_regs_line_no ();
-	  first_line_on_last_page
-	    = last_line_no - (TUI_DATA_WIN->height - 2);
+	  last_line_no = last_regs_line_no ();
+	  first_line_on_last_page = last_line_no - (height - 2);
 	  if (first_line_on_last_page < 0)
 	    first_line_on_last_page = 0;
 
@@ -355,11 +354,9 @@ tui_display_reg_element_at_line (int start_element_no,
 	     registers, adjust what element to really start the
 	     display at.  */
 	  if (start_line_no > first_line_on_last_page)
-	    element_no
-	      = (TUI_DATA_WIN->first_reg_element_no_inline
-		 (first_line_on_last_page));
+	    element_no = first_reg_element_no_inline (first_line_on_last_page);
 	}
-      TUI_DATA_WIN->display_registers_from (element_no);
+      display_registers_from (element_no);
     }
 }
 
@@ -392,7 +389,7 @@ tui_data_window::display_registers_from_line (int line_no)
 
       element_no = first_reg_element_no_inline (line_no);
       if (element_no < regs_content.size ())
-	tui_display_reg_element_at_line (element_no, line_no);
+	display_reg_element_at_line (element_no, line_no);
       else
 	line_no = (-1);
 
-- 
2.17.2

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

* [PATCH 20/61] Introduce TUI window iterator
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (21 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 01/61] Introduce can_scroll method Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 09/61] Remove tui_display_data_from_line Tom Tromey
                   ` (38 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces an iterator class and a range adapter to make it
simpler to iterate over TUI windows.

One explicit iteration remains, in tui-win.c, because that spot is
deleting windows as well.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.h (tui_refresh_all): Update.
	* tui/tui-wingeneral.c (make_all_visible): Use foreach.
	(tui_refresh_all): Remove "list" parameter.  Use foreach.
	* tui/tui-win.c (window_name_completer): Use foreach.
	(tui_refresh_all_win, tui_rehighlight_all, tui_all_windows_info)
	(update_tab_width): Likewise.
	* tui/tui-layout.c (show_layout): Update.
	* tui/tui-data.h (class tui_window_iterator): New.
	(struct all_tui_windows): New.
	* tui/tui-data.c (tui_partial_win_by_name): Use foreach.
---
 gdb/ChangeLog            | 13 ++++++++
 gdb/tui/tui-data.c       | 22 ++++---------
 gdb/tui/tui-data.h       | 69 ++++++++++++++++++++++++++++++++++++++++
 gdb/tui/tui-layout.c     |  2 +-
 gdb/tui/tui-win.c        | 47 +++++++++++----------------
 gdb/tui/tui-wingeneral.c | 20 ++++--------
 gdb/tui/tui-wingeneral.h |  2 +-
 7 files changed, 116 insertions(+), 59 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index a62dbf4d670..eacf174bbe7 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -294,27 +294,19 @@ tui_prev_win (struct tui_win_info *cur_win)
 struct tui_win_info *
 tui_partial_win_by_name (const char *name)
 {
-  struct tui_win_info *win_info = NULL;
-
   if (name != NULL)
     {
-      int i = 0;
-
-      while (i < MAX_MAJOR_WINDOWS && win_info == NULL)
+      for (tui_win_info *item : all_tui_windows ())
 	{
-          if (tui_win_list[i] != 0)
-            {
-              const char *cur_name = tui_win_list[i]->name ();
-
-              if (strlen (name) <= strlen (cur_name)
-		  && startswith (cur_name, name))
-                win_info = tui_win_list[i];
-            }
-	  i++;
+	  const char *cur_name = item->name ();
+
+	  if (strlen (name) <= strlen (cur_name)
+	      && startswith (cur_name, name))
+	    return item;
 	}
     }
 
-  return win_info;
+  return NULL;
 }
 
 
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index b3592e39133..76f6bc6102c 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -602,6 +602,75 @@ extern struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
 #define TUI_DATA_WIN    ((tui_data_window *) tui_win_list[DATA_WIN])
 #define TUI_CMD_WIN     ((tui_cmd_window *) tui_win_list[CMD_WIN])
 
+/* An iterator that iterates over all windows.  */
+
+class tui_window_iterator
+{
+public:
+
+  typedef tui_window_iterator self_type;
+  typedef struct tui_win_info *value_type;
+  typedef struct tui_win_info *&reference;
+  typedef struct tui_win_info **pointer;
+  typedef std::forward_iterator_tag iterator_category;
+  typedef int difference_type;
+
+  explicit tui_window_iterator (enum tui_win_type type)
+    : m_type (type)
+  {
+    advance ();
+  }
+
+  tui_window_iterator ()
+    : m_type (MAX_MAJOR_WINDOWS)
+  {
+  }
+
+  bool operator!= (const self_type &other) const
+  {
+    return m_type != other.m_type;
+  }
+
+  value_type operator* () const
+  {
+    gdb_assert (m_type < MAX_MAJOR_WINDOWS);
+    return tui_win_list[m_type];
+  }
+
+  self_type &operator++ ()
+  {
+    ++m_type;
+    advance ();
+    return *this;
+  }
+
+private:
+
+  void advance ()
+  {
+    while (m_type < MAX_MAJOR_WINDOWS && tui_win_list[m_type] == nullptr)
+      ++m_type;
+  }
+
+  int m_type;
+};
+
+/* A range adapter for iterating over TUI windows.  */
+
+struct all_tui_windows
+{
+  tui_window_iterator begin () const
+  {
+    return tui_window_iterator (SRC_WIN);
+  }
+
+  tui_window_iterator end () const
+  {
+    return tui_window_iterator ();
+  }
+};
+
+
 /* Data Manipulation Functions.  */
 extern void tui_initialize_static_data (void);
 extern struct tui_win_info *tui_partial_win_by_name (const char *);
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 9e683cfa919..a3ded203736 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -86,7 +86,7 @@ show_layout (enum tui_layout_type layout)
 	  || layout == DISASSEM_DATA_COMMAND)
 	{
 	  show_data (layout);
-	  tui_refresh_all (tui_win_list);
+	  tui_refresh_all ();
 	}
       else
 	{
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index ee03cf38e14..f83281f7902 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -364,18 +364,16 @@ window_name_completer (completion_tracker &tracker,
 		       const char *text, const char *word)
 {
   std::vector<const char *> completion_name_vec;
-  int win_type;
 
-  for (win_type = SRC_WIN; win_type < MAX_MAJOR_WINDOWS; win_type++)
+  for (tui_win_info *win_info : all_tui_windows ())
     {
       const char *completion_name = NULL;
 
       /* We can't focus on an invisible window.  */
-      if (tui_win_list[win_type] == NULL
-	  || !tui_win_list[win_type]->is_visible)
+      if (!win_info->is_visible)
 	continue;
 
-      completion_name = tui_win_list[win_type]->name ();
+      completion_name = win_info->name ();
       gdb_assert (completion_name != NULL);
       completion_name_vec.push_back (completion_name);
     }
@@ -518,14 +516,12 @@ tui_source_window_base::refresh_all ()
 void
 tui_refresh_all_win (void)
 {
-  int type;
-
   clearok (curscr, TRUE);
-  tui_refresh_all (tui_win_list);
-  for (type = SRC_WIN; type < MAX_MAJOR_WINDOWS; type++)
+  tui_refresh_all ();
+  for (tui_win_info *win_info : all_tui_windows ())
     {
-      if (tui_win_list[type] && tui_win_list[type]->is_visible)
-	tui_win_list[type]->refresh_all ();
+      if (win_info->is_visible)
+	win_info->refresh_all ();
     }
   tui_show_locator_content ();
 }
@@ -533,10 +529,8 @@ tui_refresh_all_win (void)
 void
 tui_rehighlight_all (void)
 {
-  int type;
-
-  for (type = SRC_WIN; type < MAX_MAJOR_WINDOWS; type++)
-    tui_check_and_display_highlight_if_needed (tui_win_list[type]);
+  for (tui_win_info *win_info : all_tui_windows ())
+    tui_check_and_display_highlight_if_needed (win_info);
 }
 
 /* Resize all the windows based on the terminal size.  This function
@@ -885,21 +879,19 @@ tui_set_focus_command (const char *arg, int from_tty)
 static void
 tui_all_windows_info (const char *arg, int from_tty)
 {
-  int type;
   struct tui_win_info *win_with_focus = tui_win_with_focus ();
 
-  for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
-    if (tui_win_list[type] 
-	&& tui_win_list[type]->is_visible)
+  for (tui_win_info *win_info : all_tui_windows ())
+    if (win_info->is_visible)
       {
-	if (win_with_focus == tui_win_list[type])
+	if (win_with_focus == win_info)
 	  printf_filtered ("        %s\t(%d lines)  <has focus>\n",
-			   tui_win_list[type]->name (),
-			   tui_win_list[type]->height);
+			   win_info->name (),
+			   win_info->height);
 	else
 	  printf_filtered ("        %s\t(%d lines)\n",
-			   tui_win_list[type]->name (),
-			   tui_win_list[type]->height);
+			   win_info->name (),
+			   win_info->height);
       }
 }
 
@@ -940,11 +932,10 @@ tui_source_window_base::update_tab_width ()
 static void
 update_tab_width ()
 {
-  for (int win_type = SRC_WIN; win_type < MAX_MAJOR_WINDOWS; win_type++)
+  for (tui_win_info *win_info : all_tui_windows ())
     {
-      if (tui_win_list[win_type] != NULL
-	  && tui_win_list[win_type]->is_visible)
-	tui_win_list[win_type]->update_tab_width ();
+      if (win_info->is_visible)
+	win_info->update_tab_width ();
     }
 }
 
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index c15739c594b..22f841eb88c 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -212,15 +212,8 @@ tui_source_window_base::make_visible (bool visible)
 static void
 make_all_visible (bool visible)
 {
-  int i;
-
-  for (i = 0; i < MAX_MAJOR_WINDOWS; i++)
-    {
-      if (tui_win_list[i] != NULL)
-	tui_win_list[i]->make_visible (visible);
-    }
-
-  return;
+  for (tui_win_info *win_info : all_tui_windows ())
+    win_info->make_visible (visible);
 }
 
 void
@@ -257,15 +250,14 @@ tui_source_window_base::refresh ()
 /* Function to refresh all the windows currently displayed.  */
 
 void
-tui_refresh_all (struct tui_win_info **list)
+tui_refresh_all ()
 {
-  int type;
   struct tui_locator_window *locator = tui_locator_win_info_ptr ();
 
-  for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
+  for (tui_win_info *win_info : all_tui_windows ())
     {
-      if (list[type] && list[type]->is_visible)
-	list[type]->refresh ();
+      if (win_info->is_visible)
+	win_info->refresh ();
     }
   if (locator->is_visible)
     {
diff --git a/gdb/tui/tui-wingeneral.h b/gdb/tui/tui-wingeneral.h
index e925606229c..20b7f21c7c0 100644
--- a/gdb/tui/tui-wingeneral.h
+++ b/gdb/tui/tui-wingeneral.h
@@ -37,7 +37,7 @@ 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 *);
 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_refresh_all ();
 extern void tui_delete_win (WINDOW *window);
 
 #endif /* TUI_TUI_WINGENERAL_H */
-- 
2.17.2

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

* [PATCH 37/61] Introduce reset_locator function in tui-layout.c
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (27 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 23/61] Remove tui_set_win_height Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 06/61] Introduce tui_data_window::last_regs_line_no method Tom Tromey
                   ` (32 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

init_and_make_win in tui-layout.c is now only called for the locator
-- earlier changes have made most of the cases here obsolete.  This
patch removes init_and_make_win and introduces a reset_locator
function.  Window creation is now much simpler to follow, because it
is no longer quite so dynamic.  (Though it will become even simpler in
coming patches.)

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (show_source_disasm_command): Use
	reset_locator.
	(reset_locator): New function.
	(init_and_make_win): Remove.
	(show_source_or_disasm_and_command): Use reset_locator.
---
 gdb/ChangeLog        |  8 ++++
 gdb/tui/tui-layout.c | 89 ++++++++++++--------------------------------
 2 files changed, 31 insertions(+), 66 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 23537b7f496..ab849a9813d 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -43,10 +43,8 @@
 ** Static Local Decls
 ********************************/
 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,
-					    enum tui_box);
+static void reset_locator (tui_gen_win_info *,
+			   int, int, int, int);
 static void show_source_or_disasm_and_command (enum tui_layout_type);
 static struct tui_win_info *make_command_window (int, int);
 static struct tui_win_info *make_source_window (int, int);
@@ -614,13 +612,11 @@ show_source_disasm_command (void)
 	{
 	  tui_win_list[DISASSEM_WIN]
 	    = make_disasm_window (asm_height, src_height - 1);
-	  init_and_make_win (locator,
-			     LOCATOR_WIN,
-			     2 /* 1 */ ,
-			     tui_term_width (),
-			     0,
-			     (src_height + asm_height) - 1,
-			     DONT_BOX_WINDOW);
+	  reset_locator (locator,
+			 2 /* 1 */ ,
+			 tui_term_width (),
+			 0,
+			 (src_height + asm_height) - 1);
 	}
       else
 	{
@@ -696,13 +692,11 @@ show_data (enum tui_layout_type new_layout)
       else
 	tui_win_list[win_type]
 	  = make_disasm_window (src_height, data_height - 1);
-      init_and_make_win (locator,
-			     LOCATOR_WIN,
-			     2 /* 1 */ ,
-			     tui_term_width (),
-			     0,
-			     total_height - 1,
-			     DONT_BOX_WINDOW);
+      reset_locator (locator,
+		     2 /* 1 */ ,
+		     tui_term_width (),
+		     0,
+		     total_height - 1);
       base = (tui_source_window_base *) tui_win_list[win_type];
     }
   else
@@ -751,48 +745,13 @@ tui_gen_win_info::reset (enum tui_win_type win_type,
   origin.y = origin_y_;
 }
 
-/* init_and_make_win().
- */
-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,
-		   enum tui_box box_it)
+static void
+reset_locator (tui_gen_win_info *win_info, 
+	       int height, int width, 
+	       int origin_x, int origin_y)
 {
-  if (win_info == NULL)
-    {
-      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;
-
-	case EXEC_INFO_WIN:
-	  win_info = new tui_exec_info_window ();
-	  break;
-
-	default:
-	  gdb_assert_not_reached (_("unhandled window type"));
-	}
-    }
-
-  win_info->reset (win_type, height, width, origin_x, origin_y);
-  tui_make_window (win_info, box_it);
-
-  return win_info;
+  win_info->reset (LOCATOR_WIN, height, width, origin_x, origin_y);
+  tui_make_window (win_info, DONT_BOX_WINDOW);
 }
 
 
@@ -825,13 +784,11 @@ 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);
-	  init_and_make_win (locator,
-			     LOCATOR_WIN,
-			     2 /* 1 */ ,
-			     tui_term_width (),
-			     0,
-			     src_height - 1,
-			     DONT_BOX_WINDOW);
+	  reset_locator (locator,
+			 2 /* 1 */ ,
+			 tui_term_width (),
+			 0,
+			 src_height - 1);
 	  base = (tui_source_window_base *) *win_info_ptr;
 	}
       else
-- 
2.17.2

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

* [PATCH 21/61] Fix comment typos
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (14 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 29/61] Remove UNDEFINED_ITEM define from TUI Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 02/61] Check can_highlight in tui_check_and_display_highlight_if_needed Tom Tromey
                   ` (45 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This fixes a couple of comment typos that I noticed.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.c (tui_clear_source_windows_detail): Fix typo.
	* tui/tui-win.c (tui_resize_all): Fix typo.
---
 gdb/ChangeLog      | 5 +++++
 gdb/tui/tui-data.c | 2 +-
 gdb/tui/tui-win.c  | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index eacf174bbe7..70c14ef67ba 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -120,7 +120,7 @@ tui_clear_source_windows ()
 }
 
 
-/* Clear the pertinant detail in the source windows.  */
+/* Clear the pertinent detail in the source windows.  */
 void
 tui_clear_source_windows_detail ()
 {
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index f83281f7902..a7f87e1de13 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -534,7 +534,7 @@ tui_rehighlight_all (void)
 }
 
 /* Resize all the windows based on the terminal size.  This function
-   gets called from within the readline sinwinch handler.  */
+   gets called from within the readline SIGWINCH handler.  */
 void
 tui_resize_all (void)
 {
-- 
2.17.2

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

* [PATCH 36/61] Always create an execution info window for a source window
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (8 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 08/61] Introduce tui_data_window::first_reg_element_no_inline Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 11/61] Introduce tui_data_window::display_all_data method Tom Tromey
                   ` (51 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

A source or disassembly window will always have an "execution info"
window (the window along the side that displays breakpoint info), but
this isn't immediately clear from the source.  As a result, some code
has checks to see whether the execution_info is NULL.

This changes the source window base class to always instantiate an
execution_info window, then updates the rest of the code.  It also
simplifies window creation in tui-layout.c.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_set_exec_info_content): Remove
	condition.
	* tui/tui-wingeneral.c (tui_source_window_base::make_visible):
	Remove condition.
	* tui/tui-source.c (tui_source_window_base::reset): New method.
	* tui/tui-layout.c (make_command_window): Don't call
	init_and_make_win.
	(make_source_window, make_disasm_window): Don't call
	make_source_or_disasm_window.
	(make_data_window): Don't call init_and_make_win.  Change calling
	convention.
	(show_source_disasm_command, show_data): Simplify.
	(make_source_or_disasm_window): Remove.
	(show_source_or_disasm_and_command): Simplify.
	* tui/tui-data.h (struct tui_gen_win_info) <reset>: Now virtual.
	(struct tui_source_window_base) <reset>: Likewise.
	<execution_info>: Remove initializer.
	* tui/tui-data.c (tui_source_window_base): Initialize
	execution_info.
---
 gdb/ChangeLog            |  22 +++++++
 gdb/tui/tui-data.c       |   3 +-
 gdb/tui/tui-data.h       |  12 ++--
 gdb/tui/tui-layout.c     | 120 +++++++++++----------------------------
 gdb/tui/tui-source.c     |  10 ++++
 gdb/tui/tui-wingeneral.c |   3 +-
 gdb/tui/tui-winsource.c  |  61 ++++++++++----------
 7 files changed, 105 insertions(+), 126 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 396635b779c..ee5b3aa3a7a 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -332,7 +332,8 @@ tui_win_info::tui_win_info (enum tui_win_type type)
 }
 
 tui_source_window_base::tui_source_window_base (enum tui_win_type type)
-  : tui_win_info (type)
+  : tui_win_info (type),
+    execution_info (new tui_exec_info_window ())
 {
   gdb_assert (type == SRC_WIN || type == DISASSEM_WIN);
   start_line_or_addr.loa = LOA_ADDRESS;
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 9d1d0dd5753..39c7f0c9d2f 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -61,9 +61,9 @@ public:
   /* 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);
+  virtual void reset (enum tui_win_type win_type,
+		      int height, int width,
+		      int origin_x, int origin_y);
 
   /* Window handle.  */
   WINDOW *handle = nullptr;
@@ -393,10 +393,14 @@ public:
 
   virtual bool location_matches_p (struct bp_location *loc, int line_no) = 0;
 
+  void reset (enum tui_win_type win_type,
+	      int height, int width,
+	      int origin_x, int origin_y) override;
+
   /* Does the locator belong to this window?  */
   bool m_has_locator = false;
   /* Execution information window.  */
-  struct tui_exec_info_window *execution_info = nullptr;
+  struct tui_exec_info_window *execution_info;
   /* 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 ac0d01c990a..23537b7f496 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -48,12 +48,9 @@ static tui_gen_win_info *init_and_make_win (tui_gen_win_info *,
 					    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);
 static struct tui_win_info *make_command_window (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);
 static void show_source_disasm_command (void);
@@ -522,14 +519,9 @@ prev_layout (void)
 static struct tui_win_info *
 make_command_window (int height, int origin_y)
 {
-  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);
+  struct tui_win_info *result = new tui_cmd_window ();
+  result->reset (CMD_WIN, height, tui_term_width (), 0, origin_y);
+  tui_make_window (result, DONT_BOX_WINDOW);
   return result;
 }
 
@@ -539,8 +531,11 @@ make_command_window (int height, int origin_y)
 static struct tui_win_info *
 make_source_window (int height, int origin_y)
 {
-  return make_source_or_disasm_window (SRC_WIN, height, origin_y);
-}				/* make_source_window */
+  tui_win_info *result = new tui_source_window ();
+  result->reset (SRC_WIN, height, tui_term_width (), 0, origin_y);
+  result->make_visible (true);
+  return result;
+}
 
 
 /* make_disasm_window().
@@ -548,22 +543,20 @@ make_source_window (int height, int origin_y)
 static struct tui_win_info *
 make_disasm_window (int height, int origin_y)
 {
-  return make_source_or_disasm_window (DISASSEM_WIN, height, origin_y);
-}				/* make_disasm_window */
+  tui_win_info *result = new tui_disasm_window ();
+  result->reset (SRC_WIN, height, tui_term_width (), 0, origin_y);
+  result->make_visible (true);
+  return result;
+}
 
 
-static void
-make_data_window (struct tui_win_info **win_info_ptr, 
-		  int height, int origin_y)
+static tui_win_info *
+make_data_window (int height, int origin_y)
 {
-  *win_info_ptr
-    = (struct tui_win_info *) init_and_make_win (*win_info_ptr,
-						 DATA_WIN,
-						 height,
-						 tui_term_width (),
-						 0,
-						 origin_y,
-						 BOX_WINDOW);
+  tui_win_info *result = new tui_data_window ();
+  result->reset (DATA_WIN, height, tui_term_width (), 0, origin_y);
+  result->make_visible (true);
+  return result;
 }
 
 
@@ -606,16 +599,10 @@ show_source_disasm_command (void)
 	{
 	  TUI_SRC_WIN->reset (TUI_SRC_WIN->type,
 			      src_height,
-			      TUI_SRC_WIN->width,
-			      TUI_SRC_WIN->execution_info->width,
+			      tui_term_width (),
+			      0,
 			      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;
 	}
 
@@ -645,16 +632,10 @@ show_source_disasm_command (void)
 	  TUI_DISASM_WIN->m_has_locator = true;
 	  TUI_DISASM_WIN->reset (TUI_DISASM_WIN->type,
 				 asm_height,
-				 TUI_DISASM_WIN->width,
-				 TUI_DISASM_WIN->execution_info->width,
+				 tui_term_width (),
+				 0,
 				 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);
 	}
       TUI_SRC_WIN->m_has_locator = false;
       TUI_DISASM_WIN->m_has_locator = true;
@@ -695,7 +676,12 @@ 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_win_list[DATA_WIN], data_height, 0);
+  if (tui_win_list[DATA_WIN] == nullptr)
+    tui_win_list[DATA_WIN] = make_data_window (data_height, 0);
+  else
+    tui_win_list[DATA_WIN]->reset (data_height, tui_term_width (), 0, 0);
+  tui_win_list[DATA_WIN]->make_visible (true);
+
   if (new_layout == SRC_DATA_COMMAND)
     win_type = SRC_WIN;
   else
@@ -724,16 +710,10 @@ show_data (enum tui_layout_type new_layout)
       base = (tui_source_window_base *) tui_win_list[win_type];
       tui_win_list[win_type]->reset (tui_win_list[win_type]->type,
 				     src_height,
-				     tui_win_list[win_type]->width,
-				     base->execution_info->width,
+				     tui_term_width (),
+				     0,
 				     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);
       locator->reset (LOCATOR_WIN,
 		      2 /* 1 */ ,
 		      tui_term_width (),
@@ -816,34 +796,6 @@ init_and_make_win (tui_gen_win_info *win_info,
 }
 
 
-static struct tui_win_info *
-make_source_or_disasm_window (enum tui_win_type type,
-			      int height, int origin_y)
-{
-  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
-    = ((struct tui_source_window_base *)
-       init_and_make_win (NULL,
-			  type,
-			  height,
-			  tui_term_width () - execution_info->width,
-			  execution_info->width,
-			  origin_y,
-			  BOX_WINDOW));
-  result->execution_info = execution_info;
-  return result;
-}
-
-
 /* Show the Source/Command or the Disassem layout.  */
 static void
 show_source_or_disasm_and_command (enum tui_layout_type layout_type)
@@ -893,16 +845,10 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 	  base->m_has_locator = true;
 	  (*win_info_ptr)->reset ((*win_info_ptr)->type,
 				  src_height - 1,
-				  (*win_info_ptr)->width,
-				  base->execution_info->width,
+				  tui_term_width (),
+				  0,
 				  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);
 	}
 
       base->m_has_locator = true;
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index f0bac24bfea..873612fecce 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -291,3 +291,13 @@ tui_source_window::location_matches_p (struct bp_location *loc, int line_no)
 	  && filename_cmp (fullname,
 			   symtab_to_fullname (loc->symtab)) == 0);
 }
+
+void
+tui_source_window_base::reset (enum tui_win_type win_type,
+			       int height, int width,
+			       int origin_x, int origin_y)
+{
+  tui_gen_win_info::reset (win_type, height, width - 3,
+			   origin_x + 3, origin_y);
+  execution_info->reset (EXEC_INFO_WIN, height, 3, origin_x, origin_y);
+}
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index dc008cd7198..3dca621b887 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -201,8 +201,7 @@ tui_make_invisible (struct tui_gen_win_info *win_info)
 void
 tui_source_window_base::make_visible (bool visible)
 {
-  if (execution_info != nullptr)
-    execution_info->make_visible (visible);
+  execution_info->make_visible (visible);
   tui_win_info::make_visible (visible);
 }
 
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 38d5532912d..d9f64251090 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -469,39 +469,36 @@ tui_exec_info_window::maybe_allocate_content (int n_elements)
 void
 tui_set_exec_info_content (struct tui_source_window_base *win_info)
 {
-  if (win_info->execution_info != NULL)
-    {
-      tui_exec_info_content *content
-	= win_info->execution_info->maybe_allocate_content (win_info->height);
+  tui_exec_info_content *content
+    = win_info->execution_info->maybe_allocate_content (win_info->height);
 
-      tui_update_breakpoint_info (win_info, nullptr, true);
-      for (int i = 0; i < win_info->content.size (); i++)
-	{
-	  tui_exec_info_content &element = content[i];
-	  struct tui_source_element *src_element;
-	  tui_bp_flags mode;
-
-	  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->break_mode;
-	  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))
-	    element[TUI_BP_HIT_POS] = (mode & TUI_BP_HARDWARE) ? 'h' : 'b';
-
-	  if (mode & TUI_BP_ENABLED)
-	    element[TUI_BP_BREAK_POS] = '+';
-	  else if (mode & TUI_BP_DISABLED)
-	    element[TUI_BP_BREAK_POS] = '-';
-
-	  if (src_element->is_exec_point)
-	    element[TUI_EXEC_POS] = '>';
-	}
+  tui_update_breakpoint_info (win_info, nullptr, true);
+  for (int i = 0; i < win_info->content.size (); i++)
+    {
+      tui_exec_info_content &element = content[i];
+      struct tui_source_element *src_element;
+      tui_bp_flags mode;
+
+      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->break_mode;
+      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))
+	element[TUI_BP_HIT_POS] = (mode & TUI_BP_HARDWARE) ? 'h' : 'b';
+
+      if (mode & TUI_BP_ENABLED)
+	element[TUI_BP_BREAK_POS] = '+';
+      else if (mode & TUI_BP_DISABLED)
+	element[TUI_BP_BREAK_POS] = '-';
+
+      if (src_element->is_exec_point)
+	element[TUI_EXEC_POS] = '>';
     }
 }
 
-- 
2.17.2

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

* [PATCH 22/61] Make source windows be self-updating
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (30 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 27/61] Remove unused parameter from two TUI functions Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 56/61] Move tui_disasm_window to tui-disasm.h Tom Tromey
                   ` (29 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes the TUI source window to register itself on the
source_styling_changed observable, and removes a bit of code from
tui-hooks.c.  This reduces the number of uses of the TUI_SRC_WIN
global.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-source.c (tui_source_window): New constructor.  Add
	observer.
	(~tui_source_window): New destructor.
	(tui_source_window::style_changed): New method.
	* tui/tui-hooks.c (tui_redisplay_source): Remove.
	(tui_attach_detach_observers): Update.
	* tui/tui-data.h (struct tui_source_window): Make constructor not
	inline.  Add destructor.
	(struct tui_source_window) <style_changed>: New method.
	<m_observable>: New member.
---
 gdb/ChangeLog        | 13 +++++++++++++
 gdb/tui/tui-data.h   | 14 ++++++++++----
 gdb/tui/tui-hooks.c  | 14 --------------
 gdb/tui/tui-source.c | 20 ++++++++++++++++++++
 4 files changed, 43 insertions(+), 18 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 76f6bc6102c..c456bd7db84 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -24,6 +24,7 @@
 
 #include "tui/tui.h"	/* For enum tui_win_type.  */
 #include "gdb_curses.h"	/* For WINDOW.  */
+#include "observable.h"
 
 /* This is a point definition.  */
 struct tui_point
@@ -424,10 +425,8 @@ public:
 
 struct tui_source_window : public tui_source_window_base
 {
-  tui_source_window ()
-    : tui_source_window_base (SRC_WIN)
-  {
-  }
+  tui_source_window ();
+  ~tui_source_window ();
 
   DISABLE_COPY_AND_ASSIGN (tui_source_window);
 
@@ -439,6 +438,13 @@ struct tui_source_window : public tui_source_window_base
 protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
+
+private:
+
+  void style_changed ();
+
+  /* A token used to register and unregister an observer.  */
+  gdb::observers::token m_observable;
 };
 
 /* A TUI disassembly window.  */
diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index 71010530749..84acd3ac2e6 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -204,18 +204,6 @@ tui_normal_stop (struct bpstats *bs, int print_frame)
   tui_refresh_frame_and_register_information (/*registers_too_p=*/1);
 }
 
-/* Observer for source_cache_cleared.  */
-
-static void
-tui_redisplay_source ()
-{
-  if (tui_is_window_visible (SRC_WIN))
-    {
-      /* Force redisplay.  */
-      TUI_SRC_WIN->refill ();
-    }
-}
-
 /* Token associated with observers registered while TUI hooks are
    installed.  */
 static const gdb::observers::token tui_observers_token {};
@@ -251,8 +239,6 @@ tui_attach_detach_observers (bool attach)
 		    tui_normal_stop, attach);
   attach_or_detach (gdb::observers::register_changed,
 		    tui_register_changed, attach);
-  attach_or_detach (gdb::observers::source_styling_changed,
-		    tui_redisplay_source, attach);
 }
 
 /* Install the TUI specific hooks.  */
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index e62ee4ea5f9..34cb38b31af 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -325,3 +325,23 @@ tui_source_window::do_scroll_vertical (int num_to_scroll)
       print_source_lines (s, l.u.line_no, l.u.line_no + 1, 0);
     }
 }
+
+tui_source_window::tui_source_window ()
+  : tui_source_window_base (SRC_WIN)
+{
+  gdb::observers::source_styling_changed.attach
+    (std::bind (&tui_source_window::style_changed, this),
+     m_observable);
+}
+
+tui_source_window::~tui_source_window ()
+{
+  gdb::observers::source_styling_changed.detach (m_observable);
+}
+
+void
+tui_source_window::style_changed ()
+{
+  if (tui_active && is_visible)
+    refill ();
+}
-- 
2.17.2

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

* [PATCH 03/61] Remove some uses of TUI_WIN_SRC
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (25 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 40/61] Change tui_set_layout to return void Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 23/61] Remove tui_set_win_height Tom Tromey
                   ` (34 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds a 'win_info' parameter to a couple of functions.  This
reduces the number of references to the TUI_WIN_SRC global.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_update_source_window_as_is)
	(tui_update_source_windows_with_addr): Update.
	* tui/tui-source.h (tui_set_source_content)
	(tui_show_symtab_source): Add "win_info" parameter.
	* tui/tui-source.c (tui_set_source_content): Add "win_info"
	parameter.
	(tui_show_symtab_source): Likewise.
---
 gdb/ChangeLog           | 10 ++++++++++
 gdb/tui/tui-source.c    | 42 ++++++++++++++++++++---------------------
 gdb/tui/tui-source.h    |  6 ++++--
 gdb/tui/tui-winsource.c |  9 +++++----
 4 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 81ede061570..e62ee4ea5f9 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -123,7 +123,8 @@ copy_source_line (const char **ptr, int line_no, int first_col,
 
 /* Function to display source in the source window.  */
 enum tui_status
-tui_set_source_content (struct symtab *s, 
+tui_set_source_content (tui_source_window_base *win_info,
+			struct symtab *s, 
 			int line_no,
 			int noerror)
 {
@@ -134,11 +135,11 @@ tui_set_source_content (struct symtab *s,
       int line_width, nlines;
 
       ret = TUI_SUCCESS;
-      tui_alloc_source_buffer (TUI_SRC_WIN);
-      line_width = TUI_SRC_WIN->width - 1;
+      tui_alloc_source_buffer (win_info);
+      line_width = win_info->width - 1;
       /* Take hilite (window border) into account, when
 	 calculating the number of lines.  */
-      nlines = (line_no + (TUI_SRC_WIN->height - 2)) - line_no;
+      nlines = (line_no + (win_info->height - 2)) - line_no;
 
       std::string srclines;
       if (!g_source_cache.get_source_lines (s, line_no, line_no + nlines,
@@ -159,32 +160,30 @@ tui_set_source_content (struct symtab *s,
 	  int cur_line_no, cur_line;
 	  struct tui_locator_window *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);
 
-	  xfree (TUI_SRC_WIN->title);
-	  TUI_SRC_WIN->title = xstrdup (s_filename);
+	  xfree (win_info->title);
+	  win_info->title = xstrdup (s_filename);
 
-	  xfree (src->fullname);
-	  src->fullname = xstrdup (symtab_to_fullname (s));
+	  xfree (win_info->fullname);
+	  win_info->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;
+	  win_info->gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s));
+	  win_info->start_line_or_addr.loa = LOA_LINE;
+	  cur_line_no = win_info->start_line_or_addr.u.line_no = line_no;
 
 	  const char *iter = srclines.c_str ();
-	  TUI_SRC_WIN->content.resize (nlines);
+	  win_info->content.resize (nlines);
 	  while (cur_line < nlines)
 	    {
 	      struct tui_source_element *element
-		= &TUI_SRC_WIN->content[cur_line];
+		= &win_info->content[cur_line];
 
 	      std::string text;
 	      if (*iter != '\0')
 		text = copy_source_line (&iter, cur_line_no,
-					 src->horizontal_offset,
+					 win_info->horizontal_offset,
 					 line_width);
 
 	      /* Set whether element is the execution point
@@ -196,8 +195,8 @@ tui_set_source_content (struct symtab *s,
 				 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
+	      xfree (win_info->content[cur_line].line);
+	      win_info->content[cur_line].line
 		= xstrdup (text.c_str ());
 
 	      cur_line++;
@@ -276,12 +275,13 @@ tui_set_source_content_nil (struct tui_source_window_base *win_info,
 /* Function to display source in the source window.  This function
    initializes the horizontal scroll to 0.  */
 void
-tui_show_symtab_source (struct gdbarch *gdbarch, struct symtab *s,
+tui_show_symtab_source (tui_source_window_base *win_info,
+			struct gdbarch *gdbarch, struct symtab *s,
 			struct tui_line_or_address line, 
 			int noerror)
 {
-  TUI_SRC_WIN->horizontal_offset = 0;
-  tui_update_source_window_as_is (TUI_SRC_WIN, gdbarch, s, line, noerror);
+  win_info->horizontal_offset = 0;
+  tui_update_source_window_as_is (win_info, gdbarch, s, line, noerror);
 }
 
 
diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
index 9e1dc1a6e10..8ceb194e392 100644
--- a/gdb/tui/tui-source.h
+++ b/gdb/tui/tui-source.h
@@ -30,9 +30,11 @@ 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 *, 
+extern enum tui_status tui_set_source_content (tui_source_window_base *,
+					       struct symtab *, 
 					       int, int);
-extern void tui_show_symtab_source (struct gdbarch *, struct symtab *,
+extern void tui_show_symtab_source (tui_source_window_base *,
+				    struct gdbarch *, struct symtab *,
 				    struct tui_line_or_address,
 				    int);
 extern int tui_source_is_displayed (const char *);
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index dbede410278..c7c04dfe816 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -94,7 +94,8 @@ tui_update_source_window_as_is (struct tui_source_window_base *win_info,
   enum tui_status ret;
 
   if (win_info->type == SRC_WIN)
-    ret = tui_set_source_content (s, line_or_addr.u.line_no, noerror);
+    ret = tui_set_source_content (win_info, s, line_or_addr.u.line_no,
+				  noerror);
   else
     ret = tui_set_disassem_content (gdbarch, line_or_addr.u.addr);
 
@@ -121,7 +122,7 @@ tui_update_source_window_as_is (struct tui_source_window_base *win_info,
 	     we don't have a split layout.  */
 	  if (tui_win_with_focus () == TUI_DISASM_WIN
 	      && tui_current_layout () != SRC_DISASSEM_COMMAND)
-	    tui_set_win_focus_to (TUI_SRC_WIN);
+	    tui_set_win_focus_to (win_info);
 	}
     }
 
@@ -153,7 +154,7 @@ tui_update_source_windows_with_addr (struct gdbarch *gdbarch, CORE_ADDR addr)
 	  sal = find_pc_line (addr, 0);
 	  l.loa = LOA_LINE;
 	  l.u.line_no = sal.line;
-	  tui_show_symtab_source (gdbarch, sal.symtab, l, FALSE);
+	  tui_show_symtab_source (TUI_SRC_WIN, gdbarch, sal.symtab, l, FALSE);
 	  break;
 	}
     }
@@ -191,7 +192,7 @@ tui_update_source_windows_with_line (struct symtab *s, int line)
     default:
       l.loa = LOA_LINE;
       l.u.line_no = line;
-      tui_show_symtab_source (gdbarch, s, l, FALSE);
+      tui_show_symtab_source (TUI_SRC_WIN, gdbarch, s, l, FALSE);
       if (tui_current_layout () == SRC_DISASSEM_COMMAND)
 	{
 	  find_line_pc (s, line, &pc);
-- 
2.17.2

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

* [PATCH 31/61] Remove tui_source_window::content_in_use
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (23 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 09/61] Remove tui_display_data_from_line Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 40/61] Change tui_set_layout to return void Tom Tromey
                   ` (36 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Now that source window clearing has been simplified, we don't need a
special flag to say whether the source window is in use -- we can
simply check whether the contents are set.  This patch implements this
idea, removing the content_in_use field.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_clear_source_content)
	(tui_show_source_content): Update.
	* tui/tui-source.c (tui_source_window::showing_source_p): Check
	whether content is empty.
	* tui/tui-data.h (struct tui_source_window_base) <content_in_use>:
	Remove.
---
 gdb/ChangeLog           | 9 +++++++++
 gdb/tui/tui-data.h      | 2 --
 gdb/tui/tui-source.c    | 2 +-
 gdb/tui/tui-winsource.c | 2 --
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 42ac859e542..59c6f72e381 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -396,8 +396,6 @@ public:
 
   virtual bool location_matches_p (struct bp_location *loc, int line_no) = 0;
 
-  /* Can it be used, or is it already used?  */
-  bool content_in_use = false;
   /* Does the locator belong to this window?  */
   bool m_has_locator = false;
   /* Execution information window.  */
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index d3cce1c3003..f0bac24bfea 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -227,7 +227,7 @@ tui_show_symtab_source (tui_source_window_base *win_info,
 bool
 tui_source_window::showing_source_p (const char *fullname) const
 {
-  return (content_in_use 
+  return (!content.empty ()
 	  && (filename_cmp (tui_locator_win_info_ptr ()->full_name,
 			    fullname) == 0));
 }
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 2be20492f47..39591db2cc9 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -211,7 +211,6 @@ tui_clear_source_content (struct tui_source_window_base *win_info)
     {
       int i;
 
-      win_info->content_in_use = false;
       tui_erase_source_content (win_info);
       for (i = 0; i < win_info->content.size (); i++)
 	{
@@ -297,7 +296,6 @@ tui_show_source_content (struct tui_source_window_base *win_info)
 
   tui_check_and_display_highlight_if_needed (win_info);
   win_info->refresh_window ();
-  win_info->content_in_use = true;
 }
 
 /* See tui-data.h.  */
-- 
2.17.2

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

* [PATCH 02/61] Check can_highlight in tui_check_and_display_highlight_if_needed
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (15 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 21/61] Fix comment typos Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 24/61] Introduce tui_source_window_base::location_matches_p method Tom Tromey
                   ` (44 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_check_and_display_highlight_if_needed currently checks the
window's type; but this can be replaced with a check of
"can_highlight", making it more polymorphically-correct.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c
	(tui_check_and_display_highlight_if_needed): Check can_highlight.
---
 gdb/ChangeLog            | 5 +++++
 gdb/tui/tui-wingeneral.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index cf8d9fc3959..c15739c594b 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -128,7 +128,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->type != CMD_WIN)
+  if (win_info != NULL && win_info->can_highlight)
     {
       if (win_info->is_highlighted)
 	tui_highlight_win (win_info);
-- 
2.17.2

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

* [PATCH 32/61] Merge refresh and refresh_window methods
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (11 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 17/61] Parameterize tui_show_register_group with window Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 34/61] Remove TUI data window special case Tom Tromey
                   ` (48 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Earlier refactorings introduced the refresh and refresh_window
methods, following the previous TUI code.  However, these methods are
essentially the same, so this patch merges them.  It also removes some
redundant refresh_window calls, because he execution window is updated
automatically by the corresponding source (or disassembly) window.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_show_exec_info_content): Don't call
	refresh_window.
	* tui/tui-wingeneral.c (tui_gen_win_info::refresh_window): Call
	touchwin.
	(tui_data_window::refresh_window): Call refresh_window on data
	items.  Always call superclass refresh_window.
	(tui_win_info::refresh): Remove.
	(tui_source_window_base::refresh_window): Update.
	(tui_refresh_all): Update.
	* tui/tui-layout.c (show_source_disasm_command): Remove call to
	refresh_window.
	(show_source_or_disasm_and_command): Likewise.
	* tui/tui-data.h (struct tui_win_info) <refresh>: Remove.
	(struct tui_source_window_base) <refresh>: Likewise.
---
 gdb/ChangeLog            | 17 +++++++++++++++++
 gdb/tui/tui-data.h       |  5 +----
 gdb/tui/tui-layout.c     |  2 --
 gdb/tui/tui-wingeneral.c | 33 +++++++++++----------------------
 gdb/tui/tui-winsource.c  |  1 -
 5 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 59c6f72e381..9d1d0dd5753 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -303,9 +303,6 @@ public:
     return false;
   }
 
-  /* 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 ()
@@ -380,7 +377,7 @@ public:
   }
 
   void make_visible (bool visible) override;
-  void refresh () override;
+  void refresh_window () override;
   void refresh_all () override;
 
   /* Refill the source window's source cache and update it.  If this
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index a3ded203736..a02c157b87e 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -683,7 +683,6 @@ show_source_disasm_command (void)
 			      TUI_CMD_WIN->origin.y);
 	  tui_make_visible (TUI_CMD_WIN);
 	}
-      TUI_CMD_WIN->refresh_window ();
       tui_set_current_layout_to (SRC_DISASSEM_COMMAND);
     }
 }
@@ -924,7 +923,6 @@ 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_CMD_WIN->refresh_window ();
 	}
       else
 	{
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 22f841eb88c..2902b8006b7 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -37,7 +37,10 @@ void
 tui_gen_win_info::refresh_window ()
 {
   if (handle != NULL)
-    wrefresh (handle);
+    {
+      touchwin (handle);
+      wrefresh (handle);
+    }
 }
 
 /* See tui-data.h.  */
@@ -49,12 +52,11 @@ tui_data_window::refresh_window ()
     {
       for (auto &&win : regs_content)
 	{
-	  if (win != NULL && win->handle != NULL)
-	    wrefresh (win->handle);
+	  if (win != NULL)
+	    win->refresh_window ();
 	}
     }
-  else
-    tui_gen_win_info::refresh_window ();
+  tui_gen_win_info::refresh_window ();
 }
 
 /* Function to delete the curses window, checking for NULL.  */
@@ -231,20 +233,10 @@ tui_make_all_invisible (void)
 /* See tui-data.h.  */
 
 void
-tui_win_info::refresh ()
-{
-  touchwin (handle);
-  refresh_window ();
-}
-
-/* See tui-data.h.  */
-
-void
-tui_source_window_base::refresh ()
+tui_source_window_base::refresh_window ()
 {
-  touchwin (execution_info->handle);
   execution_info->refresh_window ();
-  tui_win_info::refresh ();
+  tui_win_info::refresh_window ();
 }
 
 /* Function to refresh all the windows currently displayed.  */
@@ -257,13 +249,10 @@ tui_refresh_all ()
   for (tui_win_info *win_info : all_tui_windows ())
     {
       if (win_info->is_visible)
-	win_info->refresh ();
+	win_info->refresh_window ();
     }
   if (locator->is_visible)
-    {
-      touchwin (locator->handle);
-      locator->refresh_window ();
-    }
+    locator->refresh_window ();
 }
 
 
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 39591db2cc9..38d5532912d 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -513,7 +513,6 @@ tui_show_exec_info_content (struct tui_source_window_base *win_info)
   const tui_exec_info_content *content = exec_info->get_content ();
 
   werase (exec_info->handle);
-  exec_info->refresh_window ();
   for (int cur_line = 1; cur_line <= win_info->content.size (); cur_line++)
     mvwaddstr (exec_info->handle,
 	       cur_line,
-- 
2.17.2

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

* [PATCH 14/61] Introduce tui_data_window::erase_data_content method
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
  2019-07-04 17:03 ` [PATCH 13/61] Introduce tui_data_window::delete_data_content_windows method Tom Tromey
  2019-07-04 17:03 ` [PATCH 25/61] Move content_in_use to tui_source_window class Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 28/61] Remove unused TUI defines Tom Tromey
                   ` (58 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_erase_data_content to be a method on tui_data_window,
allowing for the removal of some uses of the TUI_DATA_WIN global.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-windata.h (tui_erase_data_content): Don't declare.
	* tui/tui-windata.c (tui_data_window::erase_data_content): Rename
	from tui_erase_data_content.
	(tui_data_window::display_all_data)
	(tui_data_window::refresh_all)
	(tui_data_window::do_scroll_vertical): Update.
	* tui/tui-regs.c (tui_show_registers): Update.
	* tui/tui-data.h (struct tui_data_window) <erase_data_content>:
	New method.
---
 gdb/ChangeLog         | 12 ++++++++++++
 gdb/tui/tui-data.h    |  2 ++
 gdb/tui/tui-regs.c    |  2 +-
 gdb/tui/tui-windata.c | 25 +++++++++++--------------
 gdb/tui/tui-windata.h |  2 --
 5 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 9a908115231..e1c85df31bf 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -511,6 +511,8 @@ struct tui_data_window : public tui_win_info
      is usually done when the data window is scrolled.  */
   void delete_data_content_windows ();
 
+  void erase_data_content (const char *prompt);
+
 protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 59933639f6f..9b396e429e2 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -146,7 +146,7 @@ tui_show_registers (struct reggroup *group)
   if (ret == TUI_FAILURE)
     {
       TUI_DATA_WIN->current_group = 0;
-      tui_erase_data_content (NO_REGS_STRING);
+      TUI_DATA_WIN->erase_data_content (NO_REGS_STRING);
     }
   else
     {
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index 02cd6d0b727..abbed3f16a1 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -72,25 +72,22 @@ tui_data_window::delete_data_content_windows ()
 
 
 void
-tui_erase_data_content (const char *prompt)
+tui_data_window::erase_data_content (const char *prompt)
 {
-  werase (TUI_DATA_WIN->handle);
-  tui_check_and_display_highlight_if_needed (TUI_DATA_WIN);
+  werase (handle);
+  tui_check_and_display_highlight_if_needed (this);
   if (prompt != NULL)
     {
-      int half_width = (TUI_DATA_WIN->width - 2) / 2;
+      int half_width = (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->handle,
-		 (TUI_DATA_WIN->height / 2),
-		 x_pos,
-		 (char *) prompt);
+      mvwaddstr (handle, (height / 2), x_pos, (char *) prompt);
     }
-  wrefresh (TUI_DATA_WIN->handle);
+  wrefresh (handle);
 }
 
 
@@ -100,10 +97,10 @@ void
 tui_data_window::display_all_data ()
 {
   if (regs_content.empty ())
-    tui_erase_data_content (NO_DATA_STRING);
+    erase_data_content (NO_DATA_STRING);
   else
     {
-      tui_erase_data_content (NULL);
+      erase_data_content (NULL);
       delete_data_content_windows ();
       tui_check_and_display_highlight_if_needed (this);
       tui_display_registers_from (0);
@@ -115,7 +112,7 @@ tui_data_window::display_all_data ()
 void
 tui_data_window::refresh_all ()
 {
-  tui_erase_data_content (NULL);
+  erase_data_content (NULL);
   if (!regs_content.empty ())
     {
       int first_element = first_data_item_displayed ();
@@ -129,7 +126,7 @@ tui_data_window::refresh_all ()
 
 	  if (first_line >= 0)
 	    {
-	      tui_erase_data_content (NULL);
+	      erase_data_content (NULL);
 	      tui_display_registers_from_line (first_line);
 	    }
 	}
@@ -155,7 +152,7 @@ tui_data_window::do_scroll_vertical (int num_to_scroll)
   if (first_line >= 0)
     {
       first_line += num_to_scroll;
-      tui_erase_data_content (NULL);
+      erase_data_content (NULL);
       delete_data_content_windows ();
       tui_display_registers_from_line (first_line);
     }
diff --git a/gdb/tui/tui-windata.h b/gdb/tui/tui-windata.h
index 419b22f3658..3b89eefabc0 100644
--- a/gdb/tui/tui-windata.h
+++ b/gdb/tui/tui-windata.h
@@ -24,6 +24,4 @@
 
 #include "tui/tui-data.h"
 
-extern void tui_erase_data_content (const char *);
-
 #endif /* TUI_TUI_WINDATA_H */
-- 
2.17.2

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

* [PATCH 17/61] Parameterize tui_show_register_group with window
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (10 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 11/61] Introduce tui_data_window::display_all_data method Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 32/61] Merge refresh and refresh_window methods Tom Tromey
                   ` (49 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_show_register_group not to reference the TUI_DATA_WIN
global, instead leaving that to its caller.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.c (tui_show_registers): Update.
	(tui_show_register_group): Add win_info parameter.
---
 gdb/ChangeLog      |  5 +++++
 gdb/tui/tui-regs.c | 24 +++++++++++++-----------
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index eea8cf45acf..f99e7c12f7f 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -49,7 +49,8 @@
 ******************************************/
 static void tui_display_register (struct tui_data_item_window *data);
 
-static void tui_show_register_group (struct reggroup *group,
+static void tui_show_register_group (tui_data_window *win_info,
+				     struct reggroup *group,
 				     struct frame_info *frame,
 				     int refresh_values_only);
 
@@ -139,7 +140,7 @@ tui_show_registers (struct reggroup *group)
 
   if (target_has_registers && target_has_stack && target_has_memory)
     {
-      tui_show_register_group (group, get_selected_frame (NULL),
+      tui_show_register_group (TUI_DATA_WIN, group, get_selected_frame (NULL),
 			       group == TUI_DATA_WIN->current_group);
       ret = TUI_SUCCESS;
     }
@@ -167,7 +168,8 @@ tui_show_registers (struct reggroup *group)
    refresh_values_only is TRUE.  */
 
 static void
-tui_show_register_group (struct reggroup *group,
+tui_show_register_group (tui_data_window *win_info,
+			 struct reggroup *group,
                          struct frame_info *frame, 
 			 int refresh_values_only)
 {
@@ -179,8 +181,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->title);
-  TUI_DATA_WIN->title = xstrdup (title);
+  xfree (win_info->title);
+  win_info->title = xstrdup (title);
 
   /* See how many registers must be displayed.  */
   nr_regs = 0;
@@ -202,14 +204,14 @@ tui_show_register_group (struct reggroup *group,
     }
 
   if (!refresh_values_only)
-    TUI_DATA_WIN->regs_content.clear ();
+    win_info->regs_content.clear ();
 
-  if (nr_regs < TUI_DATA_WIN->regs_content.size ())
-    TUI_DATA_WIN->regs_content.resize (nr_regs);
+  if (nr_regs < win_info->regs_content.size ())
+    win_info->regs_content.resize (nr_regs);
   else
     {
-      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 ());
+      for (int i = win_info->regs_content.size (); i < nr_regs; ++i)
+	win_info->regs_content.emplace_back (new tui_data_item_window ());
     }
 
   /* Now set the register names and values.  */
@@ -229,7 +231,7 @@ tui_show_register_group (struct reggroup *group,
       if (name == 0 || *name == '\0')
 	continue;
 
-      data_item_win = TUI_DATA_WIN->regs_content[pos].get ();
+      data_item_win = win_info->regs_content[pos].get ();
       if (data_item_win)
 	{
 	  if (!refresh_values_only)
-- 
2.17.2

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

* [PATCH 28/61] Remove unused TUI defines
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (2 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 14/61] Introduce tui_data_window::erase_data_content method Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 07/61] Introduce tui_data_window::line_from_reg_element_no method Tom Tromey
                   ` (57 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This removes some #defines that were unused in the TUI.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (MAX_CONTENT_COUNT, TUI_NULL_STR)
	(DEFAULT_HISTORY_COUNT, WITH_LOCATOR, NO_LOCATOR): Remove
	defines.
---
 gdb/ChangeLog      | 6 ++++++
 gdb/tui/tui-data.h | 5 -----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 96f44479b5e..310029d5af1 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -98,17 +98,12 @@ enum tui_box
 #define NO_DISASSEM_STRING      "[ No Assembly Available ]"
 #define NO_REGS_STRING          "[ Register Values Unavailable ]"
 #define NO_DATA_STRING          "[ No Data Values Displayed ]"
-#define MAX_CONTENT_COUNT       100
 #define SRC_NAME                "src"
 #define CMD_NAME                "cmd"
 #define DATA_NAME               "regs"
 #define DISASSEM_NAME           "asm"
-#define TUI_NULL_STR            ""
-#define DEFAULT_HISTORY_COUNT	25
 #define HILITE                  TRUE
 #define NO_HILITE               FALSE
-#define WITH_LOCATOR            TRUE
-#define NO_LOCATOR              FALSE
 #define UNDEFINED_ITEM          -1
 #define MIN_WIN_HEIGHT          3
 #define MIN_CMD_WIN_HEIGHT      3
-- 
2.17.2

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

* [PATCH 09/61] Remove tui_display_data_from_line
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (22 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 20/61] Introduce TUI window iterator Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 31/61] Remove tui_source_window::content_in_use Tom Tromey
                   ` (37 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_display_data_from_line is just a wrapper for
tui_display_registers_from_line, so remove it.  Also, nothing passed 0
as the "force_display" parameter to tui_display_registers_from_line,
so remove that parameter as well.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-windata.h (tui_display_data_from_line): Don't declare.
	* tui/tui-windata.c (tui_display_data_from_line): Remove.
	(tui_display_data_from, tui_data_window::do_scroll_vertical): Call
	tui_display_registers_from_line.
	* tui/tui-regs.h (tui_display_registers_from_line): Update.
	* tui/tui-regs.c (tui_display_registers_from_line): Remove
	"force_display" parameter.
---
 gdb/ChangeLog         | 10 ++++++++++
 gdb/tui/tui-regs.c    | 30 +++++++++++++-----------------
 gdb/tui/tui-regs.h    |  2 +-
 gdb/tui/tui-windata.c | 20 ++------------------
 gdb/tui/tui-windata.h |  1 -
 5 files changed, 26 insertions(+), 37 deletions(-)

diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index d005fe36c23..ae38d343822 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -372,38 +372,34 @@ tui_display_reg_element_at_line (int start_element_no,
    data window.  Answers the line number that the display actually
    started from.  If nothing is displayed (-1) is returned.  */
 int
-tui_display_registers_from_line (int line_no, 
-				 int force_display)
+tui_display_registers_from_line (int line_no)
 {
+  tui_check_and_display_highlight_if_needed (TUI_DATA_WIN);
   if (!TUI_DATA_WIN->regs_content.empty ())
     {
-      int line, element_no;
+      int element_no;
 
       if (line_no < 0)
-	line = 0;
-      else if (force_display)
-	{ /* If we must display regs (force_display is true), then
-	     make sure that we don't display off the end of the
+	line_no = 0;
+      else
+	{
+	  /* Make sure that we don't display off the end of the
 	     registers.  */
 	  if (line_no >= TUI_DATA_WIN->last_regs_line_no ())
 	    {
-	      if ((line = TUI_DATA_WIN->line_from_reg_element_no (
+	      if ((line_no = TUI_DATA_WIN->line_from_reg_element_no (
 		 TUI_DATA_WIN->regs_content.size () - 1)) < 0)
-		line = 0;
+		line_no = 0;
 	    }
-	  else
-	    line = line_no;
 	}
-      else
-	line = line_no;
 
-      element_no = TUI_DATA_WIN->first_reg_element_no_inline (line);
+      element_no = TUI_DATA_WIN->first_reg_element_no_inline (line_no);
       if (element_no < TUI_DATA_WIN->regs_content.size ())
-	tui_display_reg_element_at_line (element_no, line);
+	tui_display_reg_element_at_line (element_no, line_no);
       else
-	line = (-1);
+	line_no = (-1);
 
-      return line;
+      return line_no;
     }
 
   return (-1);			/* Nothing was displayed.  */
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index 866af458e10..c1054696493 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -27,7 +27,7 @@
 extern void tui_check_register_values (struct frame_info *);
 extern void tui_show_registers (struct reggroup *group);
 extern void tui_display_registers_from (int);
-extern int tui_display_registers_from_line (int, int);
+extern int tui_display_registers_from_line (int);
 extern int tui_first_reg_element_inline (int);
 
 #endif /* TUI_TUI_REGS_H */
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index ac3e6d6e097..4f18d73aec2 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -111,22 +111,6 @@ tui_display_all_data (void)
 }
 
 
-/* Function to display the data starting at line, line_no, in the data
-   window.  */
-void
-tui_display_data_from_line (int line_no)
-{
-  int _line_no = line_no;
-
-  if (line_no < 0)
-    _line_no = 0;
-
-  tui_check_and_display_highlight_if_needed (TUI_DATA_WIN);
-
-  tui_display_registers_from_line (_line_no, TRUE);
-}
-
-
 /* Display data starting at element element_no.  */
 void
 tui_display_data_from (int element_no, int reuse_windows)
@@ -144,7 +128,7 @@ tui_display_data_from (int element_no, int reuse_windows)
       tui_erase_data_content (NULL);
       if (!reuse_windows)
 	tui_delete_data_content_windows ();
-      tui_display_data_from_line (first_line);
+      tui_display_registers_from_line (first_line);
     }
 }
 
@@ -184,7 +168,7 @@ tui_data_window::do_scroll_vertical (int 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);
+      tui_display_registers_from_line (first_line);
     }
 }
 
diff --git a/gdb/tui/tui-windata.h b/gdb/tui/tui-windata.h
index 1aba67520ec..fd8e6257da7 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_display_data_from_line (int);
 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] 70+ messages in thread

* [PATCH 06/61] Introduce tui_data_window::last_regs_line_no method
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (28 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 37/61] Introduce reset_locator function in tui-layout.c Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 27/61] Remove unused parameter from two TUI functions Tom Tromey
                   ` (31 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_last_regs_line_no into a method on tui_data_window,
allowing the removal of uses of the TUI_DATA_WIN global.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.h (tui_last_regs_line_no): Don't declare.
	* tui/tui-regs.c (tui_data_window::last_regs_line_no): Rename from
	tui_last_regs_line_no.
	(tui_display_reg_element_at_line)
	(tui_display_registers_from_line): Update.
	* tui/tui-data.h (struct tui_data_window) <last_regs_line_no>: New
	method.
---
 gdb/ChangeLog      | 10 ++++++++++
 gdb/tui/tui-data.h |  4 ++++
 gdb/tui/tui-regs.c | 17 ++++++++---------
 gdb/tui/tui-regs.h |  1 -
 4 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 6a243c3d2f9..9b1e892aefe 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -490,6 +490,10 @@ struct tui_data_window : public tui_win_info
   bool display_regs = false;
   struct reggroup *current_group = nullptr;
 
+  /* Answer the number of the last line in the regs display.  If there
+     are no registers (-1) is returned.  */
+  int last_regs_line_no () const;
+
 protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 32e82b23482..e9fbf4b0752 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -63,18 +63,17 @@ static enum tui_status tui_get_register (struct frame_info *frame,
 ** PUBLIC FUNCTIONS                     **
 ******************************************/
 
-/* Answer the number of the last line in the regs display.  If there
-   are no registers (-1) is returned.  */
+/* See tui-data.h.  */
+
 int
-tui_last_regs_line_no (void)
+tui_data_window::last_regs_line_no () const
 {
   int num_lines = (-1);
 
-  if (!TUI_DATA_WIN->regs_content.empty ())
+  if (!regs_content.empty ())
     {
-      num_lines = (TUI_DATA_WIN->regs_content.size ()
-		   / TUI_DATA_WIN->regs_column_count);
-      if (TUI_DATA_WIN->regs_content.size () % TUI_DATA_WIN->regs_column_count)
+      num_lines = regs_content.size () / regs_column_count;
+      if (regs_content.size () % regs_column_count)
 	num_lines++;
     }
   return num_lines;
@@ -354,7 +353,7 @@ tui_display_reg_element_at_line (int start_element_no,
 	{
 	  int last_line_no, first_line_on_last_page;
 
-	  last_line_no = tui_last_regs_line_no ();
+	  last_line_no = TUI_DATA_WIN->last_regs_line_no ();
 	  first_line_on_last_page
 	    = last_line_no - (TUI_DATA_WIN->height - 2);
 	  if (first_line_on_last_page < 0)
@@ -390,7 +389,7 @@ tui_display_registers_from_line (int line_no,
 	{ /* If we must display regs (force_display is true), then
 	     make sure that we don't display off the end of the
 	     registers.  */
-	  if (line_no >= tui_last_regs_line_no ())
+	  if (line_no >= TUI_DATA_WIN->last_regs_line_no ())
 	    {
 	      if ((line = tui_line_from_reg_element_no (
 		 TUI_DATA_WIN->regs_content.size () - 1)) < 0)
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index 54b1b0870f7..fcb440dcf11 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -28,7 +28,6 @@ extern void tui_check_register_values (struct frame_info *);
 extern void tui_show_registers (struct reggroup *group);
 extern void tui_display_registers_from (int);
 extern int tui_display_registers_from_line (int, int);
-extern int tui_last_regs_line_no (void);
 extern int tui_first_reg_element_inline (int);
 extern int tui_line_from_reg_element_no (int);
 extern int tui_first_reg_element_no_inline (int lineno);
-- 
2.17.2

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

* [PATCH 15/61] Introduce two more tui_data_window methods
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (18 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 12/61] Don't declare unimplemented functions Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 04/61] Consolidate "if"s in tui_show_frame_info Tom Tromey
                   ` (41 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_display_registers_from and
tui_display_registers_from_line to be methods on tui_data_window,
allowing for the removal of more uses of the TUI_DATA_WIN global.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.h (tui_display_registers_from)
	(tui_display_registers_from_line): Don't declare.
	* tui/tui-windata.c (tui_data_window::display_all_data)
	(tui_data_window::refresh_all)
	(tui_data_window::do_scroll_vertical): Update.
	* tui/tui-regs.c (tui_data_window::display_registers_from): Rename
	from tui_display_registers_from.
	(tui_display_reg_element_at_line): Update.
	(tui_data_window::display_registers_from_line): Rename from
	tui_display_registers_from_line.
	* tui/tui-data.h (struct tui_data_window) <display_registers_from,
	display_registers_from_line>: New methods.
---
 gdb/ChangeLog         | 15 +++++++++++++++
 gdb/tui/tui-data.h    | 11 +++++++++++
 gdb/tui/tui-regs.c    | 43 ++++++++++++++++++++-----------------------
 gdb/tui/tui-regs.h    |  2 --
 gdb/tui/tui-windata.c |  6 +++---
 5 files changed, 49 insertions(+), 28 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index e1c85df31bf..e5b4b0f6aa0 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -513,6 +513,17 @@ struct tui_data_window : public tui_win_info
 
   void erase_data_content (const char *prompt);
 
+  /* Function to display the registers in the content from
+     'start_element_no' until the end of the register content or the
+     end of the display height.  No checking for displaying past the
+     end of the registers is done here.  */
+  void display_registers_from (int start_element_no);
+
+  /* Function to display the registers starting at line line_no in the
+     data window.  Answers the line number that the display actually
+     started from.  If nothing is displayed (-1) is returned.  */
+  int display_registers_from_line (int line_no);
+
 protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 9b396e429e2..042563f0495 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -249,14 +249,14 @@ tui_show_register_group (struct reggroup *group,
    of the display height.  No checking for displaying past the end of
    the registers is done here.  */
 void
-tui_display_registers_from (int start_element_no)
+tui_data_window::display_registers_from (int start_element_no)
 {
-  if (!TUI_DATA_WIN->regs_content.empty ())
+  if (!regs_content.empty ())
     {
       int j, item_win_width, cur_y;
 
       int max_len = 0;
-      for (auto &&data_item_win : TUI_DATA_WIN->regs_content)
+      for (auto &&data_item_win : regs_content)
         {
           char *p;
           int len;
@@ -278,28 +278,25 @@ tui_display_registers_from (int start_element_no)
       item_win_width = max_len + 1;
       int i = start_element_no;
 
-      TUI_DATA_WIN->regs_column_count =
-        (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->width - 2) / TUI_DATA_WIN->regs_column_count;
+      regs_column_count = (width - 2) / item_win_width;
+      if (regs_column_count == 0)
+        regs_column_count = 1;
+      item_win_width = (width - 2) / regs_column_count;
 
       /* Now create each data "sub" window, and write the display into
 	 it.  */
       cur_y = 1;
-      while (i < TUI_DATA_WIN->regs_content.size ()
-	     && cur_y <= TUI_DATA_WIN->viewport_height)
+      while (i < regs_content.size ()
+	     && cur_y <= viewport_height)
 	{
 	  for (j = 0;
-	       j < TUI_DATA_WIN->regs_column_count
-		 && i < TUI_DATA_WIN->regs_content.size ();
+	       j < regs_column_count && i < regs_content.size ();
 	       j++)
 	    {
 	      struct tui_data_item_window *data_item_win;
 
 	      /* Create the window if necessary.  */
-	      data_item_win = TUI_DATA_WIN->regs_content[i].get ();
+	      data_item_win = regs_content[i].get ();
               if (data_item_win->handle != NULL
                   && (data_item_win->height != 1
                       || data_item_win->width != item_win_width
@@ -362,7 +359,7 @@ tui_display_reg_element_at_line (int start_element_no,
 	      = (TUI_DATA_WIN->first_reg_element_no_inline
 		 (first_line_on_last_page));
 	}
-      tui_display_registers_from (element_no);
+      TUI_DATA_WIN->display_registers_from (element_no);
     }
 }
 
@@ -372,10 +369,10 @@ tui_display_reg_element_at_line (int start_element_no,
    data window.  Answers the line number that the display actually
    started from.  If nothing is displayed (-1) is returned.  */
 int
-tui_display_registers_from_line (int line_no)
+tui_data_window::display_registers_from_line (int line_no)
 {
-  tui_check_and_display_highlight_if_needed (TUI_DATA_WIN);
-  if (!TUI_DATA_WIN->regs_content.empty ())
+  tui_check_and_display_highlight_if_needed (this);
+  if (!regs_content.empty ())
     {
       int element_no;
 
@@ -385,16 +382,16 @@ tui_display_registers_from_line (int line_no)
 	{
 	  /* Make sure that we don't display off the end of the
 	     registers.  */
-	  if (line_no >= TUI_DATA_WIN->last_regs_line_no ())
+	  if (line_no >= last_regs_line_no ())
 	    {
-	      if ((line_no = TUI_DATA_WIN->line_from_reg_element_no (
-		 TUI_DATA_WIN->regs_content.size () - 1)) < 0)
+	      line_no = line_from_reg_element_no (regs_content.size () - 1);
+	      if (line_no < 0)
 		line_no = 0;
 	    }
 	}
 
-      element_no = TUI_DATA_WIN->first_reg_element_no_inline (line_no);
-      if (element_no < TUI_DATA_WIN->regs_content.size ())
+      element_no = first_reg_element_no_inline (line_no);
+      if (element_no < regs_content.size ())
 	tui_display_reg_element_at_line (element_no, line_no);
       else
 	line_no = (-1);
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index c99910b2c7e..354605c96f2 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -26,7 +26,5 @@
 
 extern void tui_check_register_values (struct frame_info *);
 extern void tui_show_registers (struct reggroup *group);
-extern void tui_display_registers_from (int);
-extern int tui_display_registers_from_line (int);
 
 #endif /* TUI_TUI_REGS_H */
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index abbed3f16a1..9256e0e26b6 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -103,7 +103,7 @@ tui_data_window::display_all_data ()
       erase_data_content (NULL);
       delete_data_content_windows ();
       tui_check_and_display_highlight_if_needed (this);
-      tui_display_registers_from (0);
+      display_registers_from (0);
     }
 }
 
@@ -127,7 +127,7 @@ tui_data_window::refresh_all ()
 	  if (first_line >= 0)
 	    {
 	      erase_data_content (NULL);
-	      tui_display_registers_from_line (first_line);
+	      display_registers_from_line (first_line);
 	    }
 	}
     }
@@ -154,7 +154,7 @@ tui_data_window::do_scroll_vertical (int num_to_scroll)
       first_line += num_to_scroll;
       erase_data_content (NULL);
       delete_data_content_windows ();
-      tui_display_registers_from_line (first_line);
+      display_registers_from_line (first_line);
     }
 }
 
-- 
2.17.2

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

* [PATCH 13/61] Introduce tui_data_window::delete_data_content_windows method
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-17 12:36   ` Pedro Alves
  2019-07-04 17:03 ` [PATCH 25/61] Move content_in_use to tui_source_window class Tom Tromey
                   ` (60 subsequent siblings)
  61 siblings, 1 reply; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_delete_data_content_windows to be a method on
tui_data_window, removing some uses of the TUI_DATA_WIN global.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-windata.h (tui_delete_data_content_windows): Don't
	declare.
	* tui/tui-windata.c
	(tui_data_window::delete_data_content_windows): Rename from
	tui_delete_data_content_windows.
	(tui_data_window::display_all_data)
	(tui_data_window::do_scroll_vertical): Update.
	* tui/tui-data.h (struct tui_data_window)
	<delete_data_content_windows>: New method.
---
 gdb/ChangeLog         | 12 ++++++++++++
 gdb/tui/tui-data.h    |  4 ++++
 gdb/tui/tui-windata.c |  8 ++++----
 gdb/tui/tui-windata.h |  1 -
 4 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 5cdd7561e62..9a908115231 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -507,6 +507,10 @@ struct tui_data_window : public tui_win_info
      content.  It does not set the content.  */
   void display_all_data ();
 
+  /* Function to delete all the item windows in the data window.  This
+     is usually done when the data window is scrolled.  */
+  void delete_data_content_windows ();
+
 protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index dd2daf19332..02cd6d0b727 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -60,9 +60,9 @@ tui_data_window::first_data_item_displayed ()
 /* Function to delete all the item windows in the data window.  This
    is usually done when the data window is scrolled.  */
 void
-tui_delete_data_content_windows (void)
+tui_data_window::delete_data_content_windows ()
 {
-  for (auto &&win : TUI_DATA_WIN->regs_content)
+  for (auto &&win : regs_content)
     {
       tui_delete_win (win->handle);
       win->handle = NULL;
@@ -104,7 +104,7 @@ tui_data_window::display_all_data ()
   else
     {
       tui_erase_data_content (NULL);
-      tui_delete_data_content_windows ();
+      delete_data_content_windows ();
       tui_check_and_display_highlight_if_needed (this);
       tui_display_registers_from (0);
     }
@@ -156,7 +156,7 @@ tui_data_window::do_scroll_vertical (int num_to_scroll)
     {
       first_line += num_to_scroll;
       tui_erase_data_content (NULL);
-      tui_delete_data_content_windows ();
+      delete_data_content_windows ();
       tui_display_registers_from_line (first_line);
     }
 }
diff --git a/gdb/tui/tui-windata.h b/gdb/tui/tui-windata.h
index fce4e6defc9..419b22f3658 100644
--- a/gdb/tui/tui-windata.h
+++ b/gdb/tui/tui-windata.h
@@ -25,6 +25,5 @@
 #include "tui/tui-data.h"
 
 extern void tui_erase_data_content (const char *);
-extern void tui_delete_data_content_windows (void);
 
 #endif /* TUI_TUI_WINDATA_H */
-- 
2.17.2

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

* [PATCH 07/61] Introduce tui_data_window::line_from_reg_element_no method
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (3 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 28/61] Remove unused TUI defines Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 33/61] Remove tui_set_focus Tom Tromey
                   ` (56 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_line_from_reg_element_no to be a method on
tui_data_window, allowing for the removal of some uses of the
TUI_DATA_WIN global.  (Actually, in this particular patch, the number
of uses is not decreased, but rather the uses are moved to spots that
are already using the global, i.e., increasing the clustering.)

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-windata.c (tui_display_data_from)
	(tui_data_window::do_scroll_vertical): Update.
	* tui/tui-regs.h (tui_line_from_reg_element_no): Don't declare.
	* tui/tui-regs.c (tui_data_window::line_from_reg_element_no):
	Rename from tui_line_from_reg_element_no.
	(tui_display_registers_from_line): Update.
	* tui/tui-data.h (struct tui_data_window)
	<line_from_reg_element_no>: New method.
---
 gdb/ChangeLog         | 11 +++++++++++
 gdb/tui/tui-data.h    |  5 +++++
 gdb/tui/tui-regs.c    | 12 +++++-------
 gdb/tui/tui-regs.h    |  1 -
 gdb/tui/tui-windata.c |  4 ++--
 5 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 9b1e892aefe..081d0dfa449 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -494,6 +494,11 @@ struct tui_data_window : public tui_win_info
      are no registers (-1) is returned.  */
   int last_regs_line_no () const;
 
+  /* Answer the line number that the register element at element_no is
+     on.  If element_no is greater than the number of register
+     elements there are, -1 is returned.  */
+  int line_from_reg_element_no (int element_no) const;
+
 protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index e9fbf4b0752..03e91496b0f 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -79,21 +79,19 @@ tui_data_window::last_regs_line_no () const
   return num_lines;
 }
 
+/* See tui-data.h.  */
 
-/* Answer the line number that the register element at element_no is
-   on.  If element_no is greater than the number of register elements
-   there are, -1 is returned.  */
 int
-tui_line_from_reg_element_no (int element_no)
+tui_data_window::line_from_reg_element_no (int element_no) const
 {
-  if (element_no < TUI_DATA_WIN->regs_content.size ())
+  if (element_no < regs_content.size ())
     {
       int i, line = (-1);
 
       i = 1;
       while (line == (-1))
 	{
-	  if (element_no < TUI_DATA_WIN->regs_column_count * i)
+	  if (element_no < regs_column_count * i)
 	    line = i - 1;
 	  else
 	    i++;
@@ -391,7 +389,7 @@ tui_display_registers_from_line (int line_no,
 	     registers.  */
 	  if (line_no >= TUI_DATA_WIN->last_regs_line_no ())
 	    {
-	      if ((line = tui_line_from_reg_element_no (
+	      if ((line = TUI_DATA_WIN->line_from_reg_element_no (
 		 TUI_DATA_WIN->regs_content.size () - 1)) < 0)
 		line = 0;
 	    }
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index fcb440dcf11..f6ed8628f2a 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -29,7 +29,6 @@ extern void tui_show_registers (struct reggroup *group);
 extern void tui_display_registers_from (int);
 extern int tui_display_registers_from_line (int, int);
 extern int tui_first_reg_element_inline (int);
-extern int tui_line_from_reg_element_no (int);
 extern int tui_first_reg_element_no_inline (int lineno);
 
 #endif /* TUI_TUI_REGS_H */
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index 7ff50a0c905..ac3e6d6e097 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -134,7 +134,7 @@ tui_display_data_from (int element_no, int reuse_windows)
   int first_line = (-1);
 
   if (element_no < TUI_DATA_WIN->regs_content.size ())
-    first_line = tui_line_from_reg_element_no (element_no);
+    first_line = TUI_DATA_WIN->line_from_reg_element_no (element_no);
   else
     { /* Calculate the first_line from the element number.  */
     }
@@ -173,7 +173,7 @@ tui_data_window::do_scroll_vertical (int num_to_scroll)
 
   first_element_no = first_data_item_displayed ();
   if (first_element_no < regs_content.size ())
-    first_line = tui_line_from_reg_element_no (first_element_no);
+    first_line = line_from_reg_element_no (first_element_no);
   else
     { /* Calculate the first line from the element number which is in
         the general data content.  */
-- 
2.17.2

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

* [PATCH 29/61] Remove UNDEFINED_ITEM define from TUI
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (13 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 34/61] Remove TUI data window special case Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 21/61] Fix comment typos Tom Tromey
                   ` (46 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The TUI defined UNDEFINED_ITEM, but only used it in a single spot.  I
think this isn't very useful, so this removes the define.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (UNDEFINED_ITEM): Remove define.
	(struct tui_data_item_window): Update.
---
 gdb/ChangeLog      | 5 +++++
 gdb/tui/tui-data.h | 3 +--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 310029d5af1..42ac859e542 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -104,7 +104,6 @@ enum tui_box
 #define DISASSEM_NAME           "asm"
 #define HILITE                  TRUE
 #define NO_HILITE               FALSE
-#define UNDEFINED_ITEM          -1
 #define MIN_WIN_HEIGHT          3
 #define MIN_CMD_WIN_HEIGHT      3
 
@@ -263,7 +262,7 @@ 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;
+  int item_no = -1;
   void *value = nullptr;
   bool highlight = false;
   char *content = nullptr;
-- 
2.17.2

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

* [PATCH 04/61] Consolidate "if"s in tui_show_frame_info
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (19 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 15/61] Introduce two more tui_data_window methods Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 01/61] Introduce can_scroll method Tom Tromey
                   ` (40 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_show_frame_info has two parallel "if"s with the same condition and
no intervening code.  The second "if" perhaps wasn't obviously
identical, but earlier refactorings made it clearer, by pointing out
that only source and disassembly windows can be handled here.  This
merges the two statements.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-stack.c (tui_show_frame_info): Consolidate "if"s.
---
 gdb/ChangeLog       |  4 +++
 gdb/tui/tui-stack.c | 62 ++++++++++++++++++++-------------------------
 2 files changed, 31 insertions(+), 35 deletions(-)

diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index f761ac1f701..e1b996d7e6c 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -341,8 +341,6 @@ tui_show_frame_info (struct frame_info *fi)
 
   if (fi)
     {
-      int start_line;
-      CORE_ADDR low;
       struct tui_locator_window *locator = tui_locator_win_info_ptr ();
       int source_already_displayed;
       CORE_ADDR pc;
@@ -372,32 +370,15 @@ tui_show_frame_info (struct frame_info *fi)
 	return 0;
 
       tui_show_locator_content ();
-      start_line = 0;
       for (struct tui_source_window_base *win_info : tui_source_windows ())
 	{
 	  if (win_info == TUI_SRC_WIN)
 	    {
-	      start_line = (locator->line_no -
-			   (win_info->viewport_height / 2)) + 1;
+	      int start_line = (locator->line_no -
+				(win_info->viewport_height / 2)) + 1;
 	      if (start_line <= 0)
 		start_line = 1;
-	    }
-	  else
-	    {
-	      if (find_pc_partial_function (get_frame_pc (fi),
-					    NULL, &low, NULL) == 0)
-		{
-		  /* There is no symbol available for current PC.  There is no
-		     safe way how to "disassemble backwards".  */
-		  low = get_frame_pc (fi);
-		}
-	      else
-		low = tui_get_low_disassembly_address (get_frame_arch (fi),
-						       low, get_frame_pc (fi));
-	    }
 
-	  if (win_info == TUI_SRC_WIN)
-	    {
 	      struct tui_line_or_address l;
 
 	      l.loa = LOA_LINE;
@@ -415,23 +396,34 @@ tui_show_frame_info (struct frame_info *fi)
 	    }
 	  else
 	    {
-	      if (win_info == TUI_DISASM_WIN)
+	      CORE_ADDR low;
+
+	      if (find_pc_partial_function (get_frame_pc (fi),
+					    NULL, &low, NULL) == 0)
+		{
+		  /* There is no symbol available for current PC.  There is no
+		     safe way how to "disassemble backwards".  */
+		  low = get_frame_pc (fi);
+		}
+	      else
+		low = tui_get_low_disassembly_address (get_frame_arch (fi),
+						       low, get_frame_pc (fi));
+
+	      struct tui_line_or_address a;
+
+	      a.loa = LOA_ADDRESS;
+	      a.u.addr = low;
+	      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
 		{
-		  struct tui_line_or_address a;
-
-		  a.loa = LOA_ADDRESS;
-		  a.u.addr = low;
-		  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 = locator->addr;
-		      win_info->set_is_exec_point_at (a);
-		    }
+		  a.u.addr = locator->addr;
+		  win_info->set_is_exec_point_at (a);
 		}
 	    }
+
 	  tui_update_exec_info (win_info);
 	}
 
-- 
2.17.2

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

* [PATCH 23/61] Remove tui_set_win_height
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (26 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 03/61] Remove some uses of TUI_WIN_SRC Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 37/61] Introduce reset_locator function in tui-layout.c Tom Tromey
                   ` (33 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_set_win_height_command is just a simple wrapper for
tui_set_win_height, so rename the latter and remove the wrapper.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (tui_set_win_height_command): Rename from
	tui_set_win_height.
	(tui_set_win_height_command): Remove.
---
 gdb/ChangeLog     |  6 ++++++
 gdb/tui/tui-win.c | 12 +-----------
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index a7f87e1de13..7abb8d1e98f 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -62,7 +62,6 @@ static enum tui_status tui_adjust_win_heights (struct tui_win_info *,
 static int new_height_ok (struct tui_win_info *, int);
 static void tui_set_tab_width_command (const char *, int);
 static void tui_refresh_all_command (const char *, int);
-static void tui_set_win_height_command (const char *, int);
 static void tui_all_windows_info (const char *, int);
 static void tui_set_focus_command (const char *, int);
 static void tui_scroll_forward_command (const char *, int);
@@ -991,7 +990,7 @@ tui_set_tab_width_command (const char *arg, int from_tty)
 
 /* Set the height of the specified window.  */
 static void
-tui_set_win_height (const char *arg, int from_tty)
+tui_set_win_height_command (const char *arg, int from_tty)
 {
   /* Make sure the curses mode is enabled.  */
   tui_enable ();
@@ -1069,15 +1068,6 @@ The window name specified must be valid and visible.\n"));
     printf_filtered (WIN_HEIGHT_USAGE);
 }
 
-/* Set the height of the specified window, with va_list.  */
-static void
-tui_set_win_height_command (const char *arg, int from_tty)
-{
-  /* Make sure the curses mode is enabled.  */
-  tui_enable ();
-  tui_set_win_height (arg, from_tty);
-}
-
 /* Function to adjust all window heights around the primary.   */
 static enum tui_status
 tui_adjust_win_heights (struct tui_win_info *primary_win_info,
-- 
2.17.2

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

* [PATCH 34/61] Remove TUI data window special case
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (12 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 32/61] Merge refresh and refresh_window methods Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 29/61] Remove UNDEFINED_ITEM define from TUI Tom Tromey
                   ` (47 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The TUI has a couple of special cases for updating the data window:
one in tui_rl_other_windowand one in tui_set_focus_command.  As part
of the project to remove references to globals, I wanted to remove
these calls; but when I did, some simple operations (like "C-x o")
would cause the register window to blank.

This fixes the underlying problem by arranging for the data window's
refresh_window method to call the superclass method first, and then to
refresh the child windows.  Then the special cases can be removed.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui.c (tui_rl_other_window): Update.
	* tui/tui-wingeneral.c (tui_data_window::refresh_window): Call
	superclass method first.  Always iterate over regs_content.
	(tui_unhighlight_win, tui_highlight_win): Use refresh_window
	method.
	* tui/tui-win.c (tui_set_focus_command): Update.
---
 gdb/ChangeLog            |  9 +++++++++
 gdb/tui/tui-win.c        |  2 --
 gdb/tui/tui-wingeneral.c | 15 ++++++---------
 gdb/tui/tui.c            |  2 --
 4 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 083f046cafa..9d9d9a5f577 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -857,8 +857,6 @@ The window name specified must be valid and visible.\n"));
 	  keypad (TUI_CMD_WIN->handle, (win_info != TUI_CMD_WIN));
 	}
 
-      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_with_focus ()->name ());
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 2902b8006b7..dc008cd7198 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -48,15 +48,12 @@ tui_gen_win_info::refresh_window ()
 void
 tui_data_window::refresh_window ()
 {
-  if (!regs_content.empty ())
+  tui_gen_win_info::refresh_window ();
+  for (auto &&win : regs_content)
     {
-      for (auto &&win : regs_content)
-	{
-	  if (win != NULL)
-	    win->refresh_window ();
-	}
+      if (win != NULL)
+	win->refresh_window ();
     }
-  tui_gen_win_info::refresh_window ();
 }
 
 /* Function to delete the curses window, checking for NULL.  */
@@ -108,7 +105,7 @@ tui_unhighlight_win (struct tui_win_info *win_info)
       && win_info->handle != NULL)
     {
       box_win (win_info, NO_HILITE);
-      wrefresh (win_info->handle);
+      win_info->refresh_window ();
       win_info->set_highlight (false);
     }
 }
@@ -122,7 +119,7 @@ tui_highlight_win (struct tui_win_info *win_info)
       && win_info->handle != NULL)
     {
       box_win (win_info, HILITE);
-      wrefresh (win_info->handle);
+      win_info->refresh_window ();
       win_info->set_highlight (true);
     }
 }
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index 693c2ff4a03..ee2c35587df 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -236,8 +236,6 @@ 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->is_visible)
-	TUI_DATA_WIN->refresh_all ();
       keypad (TUI_CMD_WIN->handle, (win_info != TUI_CMD_WIN));
     }
   return 0;
-- 
2.17.2

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

* [PATCH 18/61] Simplify tui_show_registers
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (6 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 16/61] Introduce tui_data_window::display_reg_element_at_line method Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 08/61] Introduce tui_data_window::first_reg_element_no_inline Tom Tromey
                   ` (53 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_show_registers keeps a local status variable, but it is not
actually needed.  This rearranges the function to remove the variable.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.c (tui_show_registers): Simplify.
---
 gdb/ChangeLog      |  4 ++++
 gdb/tui/tui-regs.c | 17 ++++++-----------
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index f99e7c12f7f..931787ae4b5 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -121,8 +121,6 @@ tui_data_window::first_reg_element_no_inline (int line_no) const
 void
 tui_show_registers (struct reggroup *group)
 {
-  enum tui_status ret = TUI_FAILURE;
-
   /* Make sure the curses mode is enabled.  */
   tui_enable ();
 
@@ -142,15 +140,7 @@ tui_show_registers (struct reggroup *group)
     {
       tui_show_register_group (TUI_DATA_WIN, group, get_selected_frame (NULL),
 			       group == TUI_DATA_WIN->current_group);
-      ret = TUI_SUCCESS;
-    }
-  if (ret == TUI_FAILURE)
-    {
-      TUI_DATA_WIN->current_group = 0;
-      TUI_DATA_WIN->erase_data_content (NO_REGS_STRING);
-    }
-  else
-    {
+
       /* Clear all notation of changed values.  */
       for (auto &&data_item_win : TUI_DATA_WIN->regs_content)
 	{
@@ -160,6 +150,11 @@ tui_show_registers (struct reggroup *group)
       TUI_DATA_WIN->current_group = group;
       TUI_DATA_WIN->display_all_data ();
     }
+  else
+    {
+      TUI_DATA_WIN->current_group = 0;
+      TUI_DATA_WIN->erase_data_content (NO_REGS_STRING);
+    }
 }
 
 
-- 
2.17.2

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

* [PATCH 25/61] Move content_in_use to tui_source_window class
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
  2019-07-04 17:03 ` [PATCH 13/61] Introduce tui_data_window::delete_data_content_windows method Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 14/61] Introduce tui_data_window::erase_data_content method Tom Tromey
                   ` (59 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

From scanning the source now, it's clear that the content_in_use field
is only used for the source window.  This patch moves the field there,
and changes it to be a bool at the same time.  (A future patch will
clean this up further, removing the field entirely.)

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_clear_source_content)
	(tui_show_source_content, tui_show_exec_info_content)
	(tui_clear_exec_info_content): Update.
	* tui/tui-stack.c (tui_show_locator_content): Update.
	(tui_show_frame_info): Update.
	* tui/tui-source.h (tui_source_window): Don't declare.
	* tui/tui-source.c (tui_source_window::showing_source_p): Rename
	from tui_source_is_displayed.
	* tui/tui-data.h (struct tui_gen_win_info) <content_in_use>:
	Remove field.
	(struct tui_source_window_base) <content_in_use>: New field.  Now
	bool.
	(struct tui_source_window) <showing_source_p>: New method.
	(TUI_SRC_WIN): Change cast.
---
 gdb/ChangeLog           | 19 +++++++++++++++++++
 gdb/tui/tui-data.c      |  1 -
 gdb/tui/tui-data.h      |  8 +++++---
 gdb/tui/tui-source.c    |  7 +++----
 gdb/tui/tui-source.h    |  1 -
 gdb/tui/tui-stack.c     | 12 ++++++++----
 gdb/tui/tui-winsource.c |  6 ++----
 7 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 70c14ef67ba..396635b779c 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -321,7 +321,6 @@ tui_initialize_static_data ()
     win->viewport_height =
     win->last_visible_line = 0;
   win->handle = NULL;
-  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 c0f1801ffc1..0f62fb69900 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -75,8 +75,6 @@ public:
   int height = 0;
   /* Origin of window.  */
   struct tui_point origin = {0, 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.  */
@@ -406,6 +404,8 @@ public:
 
   virtual bool location_matches_p (struct bp_location *loc, int line_no) = 0;
 
+  /* Can it be used, or is it already used?  */
+  bool content_in_use = false;
   /* Does the locator belong to this window?  */
   bool m_has_locator = false;
   /* Execution information window.  */
@@ -439,6 +439,8 @@ struct tui_source_window : public tui_source_window_base
 
   bool location_matches_p (struct bp_location *loc, int line_no) override;
 
+  bool showing_source_p (const char *filename) const;
+
 protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
@@ -609,7 +611,7 @@ extern int tui_win_is_auxiliary (enum tui_win_type win_type);
 /* Global Data.  */
 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_SRC_WIN     ((tui_source_window *) tui_win_list[SRC_WIN])
 #define TUI_DISASM_WIN	((tui_source_window_base *) tui_win_list[DISASSEM_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])
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 2ca21dcc845..2fcb42d9299 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -287,11 +287,10 @@ tui_show_symtab_source (tui_source_window_base *win_info,
 
 /* Answer whether the source is currently displayed in the source
    window.  */
-int
-tui_source_is_displayed (const char *fullname)
+bool
+tui_source_window::showing_source_p (const char *fullname) const
 {
-  return (TUI_SRC_WIN != NULL
-	  && TUI_SRC_WIN->content_in_use 
+  return (content_in_use 
 	  && (filename_cmp (tui_locator_win_info_ptr ()->full_name,
 			    fullname) == 0));
 }
diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
index 8ceb194e392..e4b23133af9 100644
--- a/gdb/tui/tui-source.h
+++ b/gdb/tui/tui-source.h
@@ -37,6 +37,5 @@ extern void tui_show_symtab_source (tui_source_window_base *,
 				    struct gdbarch *, struct symtab *,
 				    struct tui_line_or_address,
 				    int);
-extern int tui_source_is_displayed (const char *);
 
 #endif /* TUI_TUI_SOURCE_H */
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index e1b996d7e6c..b466b5fe7f8 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -266,7 +266,6 @@ tui_show_locator_content (void)
       locator->refresh_window ();
       wmove (locator->handle, 0, 0);
       xfree (string);
-      locator->content_in_use = TRUE;
     }
 }
 
@@ -347,14 +346,19 @@ tui_show_frame_info (struct frame_info *fi)
 
       symtab_and_line sal = find_frame_sal (fi);
 
-      source_already_displayed = sal.symtab != 0
-        && tui_source_is_displayed (symtab_to_fullname (sal.symtab));
+      const char *fullname = nullptr;
+      if (sal.symtab != nullptr)
+	fullname = symtab_to_fullname (sal.symtab);
+
+      source_already_displayed = (sal.symtab != 0
+				  && TUI_SRC_WIN != nullptr
+				  && TUI_SRC_WIN->showing_source_p (fullname));
 
       if (get_frame_pc_if_available (fi, &pc))
 	locator_changed_p
 	  = tui_set_locator_info (get_frame_arch (fi),
 				  (sal.symtab == 0
-				   ? "??" : symtab_to_fullname (sal.symtab)),
+				   ? "??" : fullname),
 				  tui_get_function_from_frame (fi),
 				  sal.line,
 				  pc);
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 03dd1b4af81..27edc4ed29c 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -212,7 +212,7 @@ tui_clear_source_content (struct tui_source_window_base *win_info,
     {
       int i;
 
-      win_info->content_in_use = FALSE;
+      win_info->content_in_use = false;
       tui_erase_source_content (win_info, display_prompt);
       for (i = 0; i < win_info->content.size (); i++)
 	{
@@ -306,7 +306,7 @@ tui_show_source_content (struct tui_source_window_base *win_info)
 
   tui_check_and_display_highlight_if_needed (win_info);
   win_info->refresh_window ();
-  win_info->content_in_use = TRUE;
+  win_info->content_in_use = true;
 }
 
 /* See tui-data.h.  */
@@ -531,7 +531,6 @@ tui_show_exec_info_content (struct tui_source_window_base *win_info)
 	       0,
 	       content[cur_line - 1]);
   exec_info->refresh_window ();
-  exec_info->content_in_use = TRUE;
 }
 
 
@@ -547,7 +546,6 @@ tui_erase_exec_info_content (struct tui_source_window_base *win_info)
 void
 tui_clear_exec_info_content (struct tui_source_window_base *win_info)
 {
-  win_info->execution_info->content_in_use = FALSE;
   tui_erase_exec_info_content (win_info);
 }
 
-- 
2.17.2

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

* [PATCH 11/61] Introduce tui_data_window::display_all_data method
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (9 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 36/61] Always create an execution info window for a source window Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 17/61] Parameterize tui_show_register_group with window Tom Tromey
                   ` (50 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_display_all_data to be a method on tui_data_window.
This helps cluster uses of the TUI_DATA_WIN global.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-windata.h (tui_display_all_data): Don't declare.
	* tui/tui-windata.c (tui_data_window::display_all_data): Rename
	from tui_display_all_data.
	* tui/tui-win.c
	(tui_data_window::do_make_visible_with_new_height): Update.
	* tui/tui-regs.c (tui_show_registers): Update.
	* tui/tui-layout.c (tui_set_layout): Update.
	* tui/tui-data.h (struct tui_data_window) <display_all_data>: New
	method.
---
 gdb/ChangeLog         | 12 ++++++++++++
 gdb/tui/tui-data.h    |  4 ++++
 gdb/tui/tui-layout.c  |  2 +-
 gdb/tui/tui-regs.c    |  2 +-
 gdb/tui/tui-win.c     |  2 +-
 gdb/tui/tui-windata.c |  6 +++---
 gdb/tui/tui-windata.h |  1 -
 7 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 676345c528a..5cdd7561e62 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -503,6 +503,10 @@ struct tui_data_window : public tui_win_info
      past the register area (-1) is returned.  */
   int first_reg_element_no_inline (int line_no) const;
 
+  /* This function displays the data that is in the data window's
+     content.  It does not set the content.  */
+  void display_all_data ();
+
 protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index d9a1f08ac1f..9e683cfa919 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -215,7 +215,7 @@ tui_set_layout (enum tui_layout_type layout_type)
 	  if (!regs_populate
 	      && (new_layout == SRC_DATA_COMMAND
 		  || new_layout == DISASSEM_DATA_COMMAND))
-	    tui_display_all_data ();
+	    TUI_DATA_WIN->display_all_data ();
 
 	  tui_update_source_windows_with_addr (gdbarch, addr);
 
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index ae38d343822..59933639f6f 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -157,7 +157,7 @@ tui_show_registers (struct reggroup *group)
 	    data_item_win->highlight = false;
 	}
       TUI_DATA_WIN->current_group = group;
-      tui_display_all_data ();
+      TUI_DATA_WIN->display_all_data ();
     }
 }
 
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 557f8b5d2d6..ee03cf38e14 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -1366,7 +1366,7 @@ tui_source_window_base::do_make_visible_with_new_height ()
 void
 tui_data_window::do_make_visible_with_new_height ()
 {
-  tui_display_all_data ();
+  display_all_data ();
 }
 
 /* See tui-data.h.  */
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index 722d0a5e26e..dd2daf19332 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -97,15 +97,15 @@ tui_erase_data_content (const char *prompt)
 /* This function displays the data that is in the data window's
    content.  It does not set the content.  */
 void
-tui_display_all_data (void)
+tui_data_window::display_all_data ()
 {
-  if (TUI_DATA_WIN->regs_content.empty ())
+  if (regs_content.empty ())
     tui_erase_data_content (NO_DATA_STRING);
   else
     {
       tui_erase_data_content (NULL);
       tui_delete_data_content_windows ();
-      tui_check_and_display_highlight_if_needed (TUI_DATA_WIN);
+      tui_check_and_display_highlight_if_needed (this);
       tui_display_registers_from (0);
     }
 }
diff --git a/gdb/tui/tui-windata.h b/gdb/tui/tui-windata.h
index 9970cfae547..adffcafacb4 100644
--- a/gdb/tui/tui-windata.h
+++ b/gdb/tui/tui-windata.h
@@ -25,7 +25,6 @@
 #include "tui/tui-data.h"
 
 extern void tui_erase_data_content (const char *);
-extern void tui_display_all_data (void);
 extern void tui_delete_data_content_windows (void);
 extern void tui_refresh_data_win (void);
 
-- 
2.17.2

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

* [PATCH 00/61] More TUI refactorings
@ 2019-07-04 17:03 Tom Tromey
  2019-07-04 17:03 ` [PATCH 13/61] Introduce tui_data_window::delete_data_content_windows method Tom Tromey
                   ` (61 more replies)
  0 siblings, 62 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches

Here is another series of TUI cleanups.  It covers several things.

I made an attempt to remove most of the uses of the TUI_*_WIN globals,
and to remove explicit checks of window types.  I think this is
important if we want to be able to easily add new types of windows:
the core code should be able to manipulate windows without regard to
their exact contents.

This transformation isn't complete, but this series takes it pretty
far, with many of the remaining uses being in the layout code (mainly
tui-layout.c, but also other files) -- which, if we're going to add
new windows types, is going to need to be rewritten anyhow.  (Also,
even once this is all done, I suspect the command window will always
be a singleton with special code here and there in the TUI anyhow.)

This series also simplifies window creation and management.  By the
end of the series, init_and_make_win is completely gone, replaced with
ordinary uses of "new" at the appropriate spots.  These transforms
make this code much simpler to understand, IMO.

The TUI source code is also rearranged somewhat.  In particular, by
the end of the series, the declaration for a window class is in the
appropriate .h file (that is, most are moved out of tui-data.h), and
all the methods for a given class are grouped into a single .c file.

A couple of small bugs have been fixed in this series.  See the patch
"Fix flushing bug in tui_puts_internal" and also "Remove deleted
breakpoint from TUI display".

Finally, the series contains a fair amount of trivia, just random
little things I noticed while working on the code.

In some cases this series introduces functions, only to remove them
some patches later.  This is a side effect of how I wrote the patches,
but TBH I think it makes each individual patch more clear -- bundling
the two patches together would make the result less obviously correct.

I've tested this as well as I could.  You may want to give it a try,
though.  It is on the "t/tui-rewrite" branch in my github.

Tom


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

* [PATCH 12/61] Don't declare unimplemented functions
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (17 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 24/61] Introduce tui_source_window_base::location_matches_p method Tom Tromey
@ 2019-07-04 17:03 ` Tom Tromey
  2019-07-04 17:03 ` [PATCH 15/61] Introduce two more tui_data_window methods Tom Tromey
                   ` (42 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

A couple of functions were declared but never defined.  This removes
the declarations.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-windata.h (tui_refresh_data_win): Don't declare.
	* tui/tui-regs.h (tui_first_reg_element_inline): Don't declare.
---
 gdb/ChangeLog         | 5 +++++
 gdb/tui/tui-regs.h    | 1 -
 gdb/tui/tui-windata.h | 1 -
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index c1054696493..c99910b2c7e 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -28,6 +28,5 @@ extern void tui_check_register_values (struct frame_info *);
 extern void tui_show_registers (struct reggroup *group);
 extern void tui_display_registers_from (int);
 extern int tui_display_registers_from_line (int);
-extern int tui_first_reg_element_inline (int);
 
 #endif /* TUI_TUI_REGS_H */
diff --git a/gdb/tui/tui-windata.h b/gdb/tui/tui-windata.h
index adffcafacb4..fce4e6defc9 100644
--- a/gdb/tui/tui-windata.h
+++ b/gdb/tui/tui-windata.h
@@ -26,6 +26,5 @@
 
 extern void tui_erase_data_content (const char *);
 extern void tui_delete_data_content_windows (void);
-extern void tui_refresh_data_win (void);
 
 #endif /* TUI_TUI_WINDATA_H */
-- 
2.17.2

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

* [PATCH 45/61] Simplify show_source_or_disasm_and_command
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (55 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 39/61] Remove reset_locator Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 61/61] Remove unnecessary "return"s Tom Tromey
                   ` (4 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes show_source_or_disasm_and_command to unify the creation
and re-initialization cases.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (show_source_or_disasm_and_command): Unify
	creation and re-initialization cases.
---
 gdb/ChangeLog        |  5 +++++
 gdb/tui/tui-layout.c | 49 ++++++++++++++++++--------------------------
 2 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 4e914b79ea0..83eb0dfeb46 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -693,7 +693,7 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 {
   if (tui_current_layout () != layout_type)
     {
-      struct tui_win_info **win_info_ptr;
+      struct tui_source_window_base *win_info;
       int src_height, cmd_height;
       struct tui_locator_window *locator = tui_locator_win_info_ptr ();
       gdb_assert (locator != nullptr);
@@ -705,42 +705,33 @@ 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_win_list[SRC_WIN];
-      else
-	win_info_ptr = &tui_win_list[DISASSEM_WIN];
-
-      tui_source_window_base *base;
-      if ((*win_info_ptr) == NULL)
 	{
-	  if (layout_type == SRC_COMMAND)
-	    *win_info_ptr = make_source_window (src_height - 1, 0);
-	  else
-	    *win_info_ptr = make_disasm_window (src_height - 1, 0);
-	  locator->reset (2 /* 1 */ ,
-			  tui_term_width (),
-			  0,
-			  src_height - 1);
-	  base = (tui_source_window_base *) *win_info_ptr;
+	  if (tui_win_list[SRC_WIN] == nullptr)
+	    tui_win_list[SRC_WIN] = new tui_source_window ();
+	  win_info = TUI_SRC_WIN;
 	}
       else
 	{
-	  base = (tui_source_window_base *) *win_info_ptr;
-	  locator->reset (2 /* 1 */ ,
-			  tui_term_width (),
-			  0,
-			  src_height - 1);
-	  base->m_has_locator = true;
-	  (*win_info_ptr)->reset (src_height - 1,
-				  tui_term_width (),
-				  0,
-				  0);
-	  tui_make_visible (*win_info_ptr);
+	  if (tui_win_list[DISASSEM_WIN] == nullptr)
+	    tui_win_list[DISASSEM_WIN] = new tui_disasm_window ();
+	  win_info = TUI_DISASM_WIN;
 	}
 
-      base->m_has_locator = true;
+      locator->reset (2 /* 1 */ ,
+		      tui_term_width (),
+		      0,
+		      src_height - 1);
+      win_info->reset (src_height - 1,
+		       tui_term_width (),
+		       0,
+		       0);
+      tui_make_visible (win_info);
+
+
+      win_info->m_has_locator = true;
       tui_make_visible (locator);
       tui_show_locator_content ();
-      tui_show_source_content (base);
+      tui_show_source_content (win_info);
 
       if (TUI_CMD_WIN == NULL)
 	{
-- 
2.17.2

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

* [PATCH 10/61] Remove tui_display_data_from
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (45 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 60/61] Fix an error in parse_scrolling_args Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 59/61] Move source window common to code to tui-winsource.[ch] Tom Tromey
                   ` (14 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_display_data_from is only called from a single place.  Inlining it
there lets us remove some uses of the TUI_DATA_WIN global.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-windata.h (tui_display_data_from): Don't declare.
	* tui/tui-windata.c (tui_display_data_from): Remove.
	(tui_data_window::refresh_all): Update.
---
 gdb/ChangeLog         |  6 ++++++
 gdb/tui/tui-windata.c | 35 ++++++++++++-----------------------
 gdb/tui/tui-windata.h |  1 -
 3 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index 4f18d73aec2..722d0a5e26e 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -111,28 +111,6 @@ tui_display_all_data (void)
 }
 
 
-/* Display data starting at element element_no.  */
-void
-tui_display_data_from (int element_no, int reuse_windows)
-{
-  int first_line = (-1);
-
-  if (element_no < TUI_DATA_WIN->regs_content.size ())
-    first_line = TUI_DATA_WIN->line_from_reg_element_no (element_no);
-  else
-    { /* Calculate the first_line from the element number.  */
-    }
-
-  if (first_line >= 0)
-    {
-      tui_erase_data_content (NULL);
-      if (!reuse_windows)
-	tui_delete_data_content_windows ();
-      tui_display_registers_from_line (first_line);
-    }
-}
-
-
 /* Function to redisplay the contents of the data window.  */
 void
 tui_data_window::refresh_all ()
@@ -143,7 +121,18 @@ tui_data_window::refresh_all ()
       int first_element = first_data_item_displayed ();
 
       if (first_element >= 0)	/* Re-use existing windows.  */
-	tui_display_data_from (first_element, TRUE);
+	{
+	  int first_line = (-1);
+
+	  if (first_element < regs_content.size ())
+	    first_line = line_from_reg_element_no (first_element);
+
+	  if (first_line >= 0)
+	    {
+	      tui_erase_data_content (NULL);
+	      tui_display_registers_from_line (first_line);
+	    }
+	}
     }
 }
 
diff --git a/gdb/tui/tui-windata.h b/gdb/tui/tui-windata.h
index fd8e6257da7..9970cfae547 100644
--- a/gdb/tui/tui-windata.h
+++ b/gdb/tui/tui-windata.h
@@ -28,6 +28,5 @@ extern void tui_erase_data_content (const char *);
 extern void tui_display_all_data (void);
 extern void tui_delete_data_content_windows (void);
 extern void tui_refresh_data_win (void);
-extern void tui_display_data_from (int, int);
 
 #endif /* TUI_TUI_WINDATA_H */
-- 
2.17.2

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

* [PATCH 54/61] Move TUI command window code
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (38 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 38/61] Remove the win_type parameter from tui_gen_win_info::reset Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 57/61] Move tui_source_window to tui-source.h Tom Tromey
                   ` (21 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Like the earlier change to the data window, this moves the TUI command
window code to tui-command.[ch], and removes the old "structuring"
comments from tui-command.c.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui.c: Update.
	* tui/tui-win.c (tui_cmd_window::do_make_visible_with_new_height)
	(tui_cmd_window::max_height): Move to tui-command.c.
	* tui/tui-layout.c: Update.
	* tui/tui-data.h (struct tui_cmd_window): Move to tui-command.h.
	* tui/tui-data.c (tui_cmd_window::clear_detail): Move to
	tui-command.c.
	* tui/tui-command.h (struct tui_cmd_window): Move from
	tui-data.h.
	* tui/tui-command.c: Remove "structuring" comments.
	(tui_cmd_window::clear_detail)
	(tui_cmd_window::do_make_visible_with_new_height)
	(tui_cmd_window::max_height): Move from elsewhere.
---
 gdb/ChangeLog         | 16 ++++++++++++++
 gdb/tui/tui-command.c | 31 +++++++++++++++++++++------
 gdb/tui/tui-command.h | 50 +++++++++++++++++++++++++++++++++++++++++++
 gdb/tui/tui-data.c    |  8 -------
 gdb/tui/tui-data.h    | 49 ++----------------------------------------
 gdb/tui/tui-layout.c  |  1 +
 gdb/tui/tui-win.c     | 21 +-----------------
 gdb/tui/tui.c         |  1 +
 8 files changed, 96 insertions(+), 81 deletions(-)

diff --git a/gdb/tui/tui-command.c b/gdb/tui/tui-command.c
index 1a269e7fb51..5af3484b9ec 100644
--- a/gdb/tui/tui-command.c
+++ b/gdb/tui/tui-command.c
@@ -27,15 +27,34 @@
 #include "tui/tui-command.h"
 
 #include "gdb_curses.h"
-/*****************************************
-** STATIC LOCAL FUNCTIONS FORWARD DECLS    **
-******************************************/
 
+/* See tui-command.h.  */
+
+void
+tui_cmd_window::clear_detail ()
+{
+  wmove (handle, 0, 0);
+}
+
+/* See tui-command.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);
+}
 
-/*****************************************
-** PUBLIC FUNCTIONS                        **
-******************************************/
+/* See tui-command.h.  */
+
+int
+tui_cmd_window::max_height () const
+{
+  return tui_term_height () - 4;
+}
 
 /* See tui-command.h.  */
 
diff --git a/gdb/tui/tui-command.h b/gdb/tui/tui-command.h
index 3f84ee22fa8..d2a8ab1903a 100644
--- a/gdb/tui/tui-command.h
+++ b/gdb/tui/tui-command.h
@@ -22,6 +22,56 @@
 #ifndef TUI_TUI_COMMAND_H
 #define TUI_TUI_COMMAND_H
 
+#include "tui/tui-data.h"
+
+/* The TUI command window.  */
+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);
+
+  void clear_detail () override;
+
+  void make_visible (bool visible) override
+  {
+  }
+
+  int max_height () const override;
+
+  void refresh_window () override
+  {
+  }
+
+  const char *name () const override
+  {
+    return CMD_NAME;
+  }
+
+  bool can_scroll () const override
+  {
+    return false;
+  }
+
+  int start_line = 0;
+
+protected:
+
+  void do_scroll_vertical (int num_to_scroll) override
+  {
+  }
+
+  void do_scroll_horizontal (int num_to_scroll) override
+  {
+  }
+
+  void do_make_visible_with_new_height () override;
+};
+
 /* Refresh the command window.  */
 extern void tui_refresh_cmd_win (void);
 
diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index e861eb222dd..5e755168827 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -150,14 +150,6 @@ tui_source_window_base::clear_detail ()
   horizontal_offset = 0;
 }
 
-/* See tui-data.h.  */
-
-void
-tui_cmd_window::clear_detail ()
-{
-  wmove (handle, 0, 0);
-}
-
 /* Accessor for the locator win info.  Answers a pointer to the static
    locator win info struct.  */
 struct tui_locator_window *
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 489bae99b22..ed5d291f354 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -26,6 +26,8 @@
 #include "gdb_curses.h"	/* For WINDOW.  */
 #include "observable.h"
 
+struct tui_cmd_window;
+
 /* This is a point definition.  */
 struct tui_point
 {
@@ -452,53 +454,6 @@ protected:
   void do_scroll_vertical (int num_to_scroll) override;
 };
 
-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);
-
-  void clear_detail () override;
-
-  void make_visible (bool visible) override
-  {
-  }
-
-  int max_height () const override;
-
-  void refresh_window () override
-  {
-  }
-
-  const char *name () const override
-  {
-    return CMD_NAME;
-  }
-
-  bool can_scroll () const override
-  {
-    return false;
-  }
-
-  int start_line = 0;
-
-protected:
-
-  void do_scroll_vertical (int num_to_scroll) override
-  {
-  }
-
-  void do_scroll_horizontal (int num_to_scroll) override
-  {
-  }
-
-  void do_make_visible_with_new_height () override;
-};
-
 extern int tui_win_is_auxiliary (enum tui_win_type win_type);
 
 
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index abc3fd60182..2e67ed15238 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -28,6 +28,7 @@
 #include <ctype.h>
 
 #include "tui/tui.h"
+#include "tui/tui-command.h"
 #include "tui/tui-data.h"
 #include "tui/tui-wingeneral.h"
 #include "tui/tui-stack.h"
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 0c7042e9385..124fdb11c7e 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -36,6 +36,7 @@
 
 #include "tui/tui.h"
 #include "tui/tui-io.h"
+#include "tui/tui-command.h"
 #include "tui/tui-data.h"
 #include "tui/tui-wingeneral.h"
 #include "tui/tui-stack.h"
@@ -1319,32 +1320,12 @@ tui_source_window_base::do_make_visible_with_new_height ()
 
 /* 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.  */
-
 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)
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index 996dbaf6cf7..22de9a70b82 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -23,6 +23,7 @@
 #include "gdbcmd.h"
 #include "tui/tui.h"
 #include "tui/tui-hooks.h"
+#include "tui/tui-command.h"
 #include "tui/tui-data.h"
 #include "tui/tui-layout.h"
 #include "tui/tui-io.h"
-- 
2.17.2

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

* [PATCH 48/61] Remove make_data_window
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (47 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 59/61] Move source window common to code to tui-winsource.[ch] Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 43/61] Simplify tui_gen_win_info::make_visible Tom Tromey
                   ` (12 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

As with the previous patches, unifying the creation and
re-initialization cases for the data window lets us remove
make_data_window in favor of simply using "new".

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (make_data_window): Remove.
	(show_data): Unify creation and re-initialization cases.
---
 gdb/ChangeLog        |  5 +++++
 gdb/tui/tui-layout.c | 17 ++---------------
 2 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index b1f784609d5..7478c2c966a 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -476,18 +476,6 @@ prev_layout (void)
   return (enum tui_layout_type) new_layout;
 }
 
-
-static tui_win_info *
-make_data_window (int height, int origin_y)
-{
-  tui_win_info *result = new tui_data_window ();
-  result->reset (height, tui_term_width (), 0, origin_y);
-  result->make_visible (true);
-  return result;
-}
-
-
-
 /* Show the Source/Command layout.  */
 static void
 show_source_command (void)
@@ -581,9 +569,8 @@ show_data (enum tui_layout_type new_layout)
   tui_make_all_invisible ();
   tui_make_invisible (locator);
   if (tui_win_list[DATA_WIN] == nullptr)
-    tui_win_list[DATA_WIN] = make_data_window (data_height, 0);
-  else
-    tui_win_list[DATA_WIN]->reset (data_height, tui_term_width (), 0, 0);
+    tui_win_list[DATA_WIN] = new tui_data_window ();
+  tui_win_list[DATA_WIN]->reset (data_height, tui_term_width (), 0, 0);
   tui_win_list[DATA_WIN]->make_visible (true);
 
   if (new_layout == SRC_DATA_COMMAND)
-- 
2.17.2

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

* [PATCH 30/61] Simplify source window clearing
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (53 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 35/61] Remove some dead code from tui_set_layout Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 39/61] Remove reset_locator Tom Tromey
                   ` (6 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

When a TUI source window is empty, it displays a "No Source Available"
message.  The function tui_set_source_content_nil also made sure to
put this message into the window's "content" field.

However, I believe this isn't really necessary.  Instead, it's simpler
to just empty the contents and let curses handle the refreshing.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_erase_source_content): Clear the
	window's contents.
	* tui/tui-source.h (tui_set_source_content_nil): Don't declare.
	* tui/tui-source.c (tui_set_source_content_nil): Remove.
---
 gdb/ChangeLog           |  7 +++++
 gdb/tui/tui-source.c    | 63 -----------------------------------------
 gdb/tui/tui-source.h    |  3 --
 gdb/tui/tui-winsource.c |  8 +-----
 4 files changed, 8 insertions(+), 73 deletions(-)

diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 2fcb42d9299..d3cce1c3003 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -209,69 +209,6 @@ tui_set_source_content (tui_source_window_base *win_info,
 }
 
 
-/* elz: This function sets the contents of the source window to empty
-   except for a line in the middle with a warning message about the
-   source not being available.  This function is called by
-   tui_erase_source_contents(), which in turn is invoked when the
-   source files cannot be accessed.  */
-
-void
-tui_set_source_content_nil (struct tui_source_window_base *win_info,
-			    const char *warning_string)
-{
-  int line_width;
-  int n_lines;
-  int curr_line = 0;
-
-  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->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_source_element *element = &win_info->content[curr_line];
-
-      element->line_or_addr.loa = LOA_LINE;
-      element->line_or_addr.u.line_no = 0;
-      element->is_exec_point = false;
-      element->break_mode = 0;
-
-      /* Set the contents of the line to blank.  */
-      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.
-         Note: the 'weird' arithmetic with the line width and height
-         comes from the function tui_erase_source_content().  We need
-         to keep the screen and the window's actual contents in
-         synch.  */
-
-      if (curr_line == (n_lines / 2 + 1))
-	{
-	  int xpos;
-	  int warning_length = strlen (warning_string);
-	  char *src_line;
-
-	  if (warning_length >= ((line_width - 1) / 2))
-	    xpos = 1;
-	  else
-	    xpos = (line_width - 1) / 2 - warning_length;
-
-	  src_line = xstrprintf ("%s%s", n_spaces (xpos), warning_string);
-	  xfree (element->line);
-	  element->line = src_line;
-	}
-
-      curr_line++;
-    }
-}
-
-
 /* Function to display source in the source window.  This function
    initializes the horizontal scroll to 0.  */
 void
diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
index e4b23133af9..fc129ab8f26 100644
--- a/gdb/tui/tui-source.h
+++ b/gdb/tui/tui-source.h
@@ -27,9 +27,6 @@
 struct symtab;
 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 (tui_source_window_base *,
 					       struct symtab *, 
 					       int, int);
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 65aa5164122..2be20492f47 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -250,13 +250,7 @@ tui_erase_source_content (struct tui_source_window_base *win_info)
 		 x_pos,
 		 (char *) no_src_str);
 
-      /* elz: Added this function call to set the real contents of
-	 the window to what is on the screen, so that later calls
-	 to refresh, do display the correct stuff, and not the old
-	 image.  */
-
-      tui_set_source_content_nil (win_info, no_src_str);
-
+      win_info->content.clear ();
       win_info->refresh_window ();
     }
 }
-- 
2.17.2

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

* [PATCH 05/61] Remove deleted breakpoint from TUI display
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (32 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 56/61] Move tui_disasm_window to tui-disasm.h Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 49/61] Remove tui_make_visible and tui_make_invisible Tom Tromey
                   ` (27 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

PR tui/24722 points out that deleting a breakpoint does not cause the
"b" to be removed from the breakpoint display.  The issue here was
that the breakpoint still exists at the moment the breakpoint-deleted
observer is notified.  This fixes the problem by specially handling
the case where a breakpoint is being removed.

2019-07-04  Tom Tromey  <tom@tromey.com>

	PR tui/24722:
	* tui/tui-winsource.h (tui_update_all_breakpoint_info)
	(tui_update_breakpoint_info): Add "being_deleted" parameter.
	* tui/tui-winsource.c (tui_update_source_window_as_is): Update.
	(tui_update_all_breakpoint_info): Add "being_deleted" parameter.
	(tui_update_breakpoint_info): Likewise.
	* tui/tui-hooks.c (tui_event_create_breakpoint)
	(tui_event_delete_breakpoint, tui_event_modify_breakpoint):
	Update.
---
 gdb/ChangeLog           | 12 ++++++++++++
 gdb/tui/tui-hooks.c     |  6 +++---
 gdb/tui/tui-winsource.c | 29 ++++++++++++++++-------------
 gdb/tui/tui-winsource.h | 19 +++++++++++++------
 4 files changed, 44 insertions(+), 22 deletions(-)

diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index 9bac4a883aa..71010530749 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -91,7 +91,7 @@ tui_register_changed (struct frame_info *frame, int regno)
 static void
 tui_event_create_breakpoint (struct breakpoint *b)
 {
-  tui_update_all_breakpoint_info ();
+  tui_update_all_breakpoint_info (nullptr);
 }
 
 /* Breakpoint deletion hook.
@@ -99,13 +99,13 @@ tui_event_create_breakpoint (struct breakpoint *b)
 static void
 tui_event_delete_breakpoint (struct breakpoint *b)
 {
-  tui_update_all_breakpoint_info ();
+  tui_update_all_breakpoint_info (b);
 }
 
 static void
 tui_event_modify_breakpoint (struct breakpoint *b)
 {
-  tui_update_all_breakpoint_info ();
+  tui_update_all_breakpoint_info (nullptr);
 }
 
 /* Refresh TUI's frame and register information.  This is a hook intended to be
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index c7c04dfe816..22cd54ee9b8 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -106,7 +106,7 @@ tui_update_source_window_as_is (struct tui_source_window_base *win_info,
     }
   else
     {
-      tui_update_breakpoint_info (win_info, 0);
+      tui_update_breakpoint_info (win_info, nullptr, false);
       tui_show_source_content (win_info);
       tui_update_exec_info (win_info);
       if (win_info->type == SRC_WIN)
@@ -382,15 +382,14 @@ tui_source_window_base::set_is_exec_point_at (struct tui_line_or_address l)
     refill ();
 }
 
-/* Update the execution windows to show the active breakpoints.
-   This is called whenever a breakpoint is inserted, removed or
-   has its state changed.  */
+/* See tui-winsource.h.  */
+
 void
-tui_update_all_breakpoint_info ()
+tui_update_all_breakpoint_info (struct breakpoint *being_deleted)
 {
   for (tui_source_window_base *win : tui_source_windows ())
     {
-      if (tui_update_breakpoint_info (win, FALSE))
+      if (tui_update_breakpoint_info (win, being_deleted, false))
         {
           tui_update_exec_info (win);
         }
@@ -398,18 +397,19 @@ tui_update_all_breakpoint_info ()
 }
 
 
-/* Scan the source window and the breakpoints to update the has_break
+/* Scan the source window and the breakpoints to update the break_mode
    information for each line.
 
-   Returns 1 if something changed and the execution window must be
+   Returns true if something changed and the execution window must be
    refreshed.  */
 
-int
-tui_update_breakpoint_info (struct tui_source_window_base *win, 
-			    int current_only)
+bool
+tui_update_breakpoint_info (struct tui_source_window_base *win,
+			    struct breakpoint *being_deleted,
+			    bool current_only)
 {
   int i;
-  int need_refresh = 0;
+  bool need_refresh = false;
   tui_source_window_base *src = (tui_source_window_base *) win;
 
   for (i = 0; i < win->content.size (); i++)
@@ -435,6 +435,9 @@ tui_update_breakpoint_info (struct tui_source_window_base *win,
 	  gdb_assert (line->line_or_addr.loa == LOA_LINE
 		      || line->line_or_addr.loa == LOA_ADDRESS);
 
+	  if (bp == being_deleted)
+	    continue;
+
 	  for (loc = bp->loc; loc != NULL; loc = loc->next)
 	    {
 	      if ((win == TUI_SRC_WIN
@@ -491,7 +494,7 @@ tui_set_exec_info_content (struct tui_source_window_base *win_info)
       tui_exec_info_content *content
 	= win_info->execution_info->maybe_allocate_content (win_info->height);
 
-      tui_update_breakpoint_info (win_info, 1);
+      tui_update_breakpoint_info (win_info, nullptr, true);
       for (int i = 0; i < win_info->content.size (); i++)
 	{
 	  tui_exec_info_content &element = content[i];
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 2a85a008812..c1087f4490a 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -28,14 +28,21 @@ struct tui_win_info;
 
 /* Update the execution windows to show the active breakpoints.  This
    is called whenever a breakpoint is inserted, removed or has its
-   state changed.  */
-extern void tui_update_all_breakpoint_info (void);
+   state changed.  Normally BEING_DELETED is nullptr; if not nullptr,
+   it indicates a breakpoint that is in the process of being deleted,
+   and which should therefore be ignored by the update.  This is done
+   because the relevant observer is notified before the breakpoint is
+   removed from the list of breakpoints.  */
+extern void tui_update_all_breakpoint_info (struct breakpoint *being_deleted);
 
 /* Scan the source window and the breakpoints to update the break_mode
-   information for each line.  Returns 1 if something changed and the
-   execution window must be refreshed.  */
-extern int tui_update_breakpoint_info (struct tui_source_window_base *win,
-				       int current_only);
+   information for each line.  Returns true if something changed and
+   the execution window must be refreshed.  See
+   tui_update_all_breakpoint_info for a description of
+   BEING_DELETED.  */
+extern bool tui_update_breakpoint_info (struct tui_source_window_base *win,
+					struct breakpoint *being_deleted,
+					bool current_only);
 
 /* Function to display the "main" routine.  */
 extern void tui_display_main (void);
-- 
2.17.2

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

* [PATCH 55/61] Move TUI data item window to tui-regs.h
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (43 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 26/61] Add win_info parameter to tui_set_disassem_content Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 60/61] Fix an error in parse_scrolling_args Tom Tromey
                   ` (16 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The TUI data item window is only used by the TUI register window.  So,
this patch moves the relevant code to tui-regs.[ch].

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.h (struct tui_data_item_window): Move from
	tui-data.h.
	* tui/tui-regs.c (tui_data_item_window): Move from tui-data.c.
	* tui/tui-data.h (struct tui_data_item_window): Move to
	tui-regs.h.
	* tui/tui-data.c (~tui_data_item_window): Move to tui-regs.c.
---
 gdb/ChangeLog      |  9 +++++++++
 gdb/tui/tui-data.c | 11 -----------
 gdb/tui/tui-data.h | 19 -------------------
 gdb/tui/tui-regs.c |  9 +++++++++
 gdb/tui/tui-regs.h | 19 +++++++++++++++++++
 5 files changed, 37 insertions(+), 30 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 5e755168827..8977e8fd592 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -333,14 +333,3 @@ tui_source_window_base::~tui_source_window_base ()
   xfree (fullname);
   delete execution_info;
 }  
-
-/**********************************
-** LOCAL STATIC FUNCTIONS        **
-**********************************/
-
-
-tui_data_item_window::~tui_data_item_window ()
-{
-  xfree (value);
-  xfree (content);
-}
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index ed5d291f354..2f2f2a0ab91 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -249,25 +249,6 @@ 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 = -1;
-  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 264f916aaa1..26f9a0c4a01 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -53,6 +53,15 @@ static void tui_get_register (struct frame_info *frame,
 			      struct tui_data_item_window *data,
 			      int regnum, bool *changedp);
 
+
+/* See tui-regs.h.  */
+
+tui_data_item_window::~tui_data_item_window ()
+{
+  xfree (value);
+  xfree (content);
+}
+
 /* See tui-regs.h.  */
 
 int
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index ad8d01e445f..208c215d0ed 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -24,6 +24,25 @@
 
 #include "tui/tui-data.h"
 
+/* 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 = -1;
+  void *value = nullptr;
+  bool highlight = false;
+  char *content = nullptr;
+};
+
 /* The TUI registers window.  */
 struct tui_data_window : public tui_win_info
 {
-- 
2.17.2

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

* [PATCH 51/61] Fix flushing bug in tui_puts_internal
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (51 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 19/61] Minor tui_reg_next / tui_reg_prev cleanup Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-17 12:37   ` Pedro Alves
  2019-07-04 17:04 ` [PATCH 35/61] Remove some dead code from tui_set_layout Tom Tromey
                   ` (8 subsequent siblings)
  61 siblings, 1 reply; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

A while back I changed gdb not to flush in some places.  It turned out
that this broke the TUI a little.  An easy way to see it is to run
"gdb -tui -nx", then "file gdb" at the gdb prompt.  gdb will print the
usual "Reading symbols..." message -- but it won't appear on-screen
until the reading is complete.

This patch changes the TUI to do the equivalent of line buffering in
tui_puts_internal.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-io.c (tui_puts_internal): Call wrefresh is newline is
	seen.
---
 gdb/ChangeLog    | 5 +++++
 gdb/tui/tui-io.c | 6 ++++++
 2 files changed, 11 insertions(+)

diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 56d5974cb35..51f69185da3 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -461,9 +461,13 @@ tui_puts_internal (WINDOW *w, const char *string, int *height)
 {
   char c;
   int prev_col = 0;
+  bool saw_nl = false;
 
   while ((c = *string++) != 0)
     {
+      if (c == '\n')
+	saw_nl = true;
+
       if (c == '\1' || c == '\2')
 	{
 	  /* Ignore these, they are readline escape-marking
@@ -492,6 +496,8 @@ tui_puts_internal (WINDOW *w, const char *string, int *height)
 	}
     }
   update_cmdwin_start_line ();
+  if (saw_nl)
+    wrefresh (w);
 }
 
 /* Print a string in the curses command window.  The output is
-- 
2.17.2

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

* [PATCH 39/61] Remove reset_locator
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (54 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 30/61] Simplify source window clearing Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 45/61] Simplify show_source_or_disasm_and_command Tom Tromey
                   ` (5 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

reset_locator was introduced just a few patches ago, but it's already
time to remove it.  It consists of a call to the locator's "reset"
method, plus a call to tui_make_window; but the latter is redundant at
all the places that call reset_locator.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (show_source_disasm_command, show_data):
	Update.
	(reset_locator): Remove.
	(show_source_or_disasm_and_command): Update.
---
 gdb/ChangeLog        |  7 +++++++
 gdb/tui/tui-layout.c | 39 ++++++++++++---------------------------
 2 files changed, 19 insertions(+), 27 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 79c7996d19b..d15df2a37c8 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -43,8 +43,6 @@
 ** Static Local Decls
 ********************************/
 static void show_layout (enum tui_layout_type);
-static void reset_locator (tui_gen_win_info *,
-			   int, int, int, int);
 static void show_source_or_disasm_and_command (enum tui_layout_type);
 static struct tui_win_info *make_command_window (int, int);
 static struct tui_win_info *make_source_window (int, int);
@@ -611,11 +609,10 @@ show_source_disasm_command (void)
 	{
 	  tui_win_list[DISASSEM_WIN]
 	    = make_disasm_window (asm_height, src_height - 1);
-	  reset_locator (locator,
-			 2 /* 1 */ ,
-			 tui_term_width (),
-			 0,
-			 (src_height + asm_height) - 1);
+	  locator->reset (2 /* 1 */ ,
+			  tui_term_width (),
+			  0,
+			  (src_height + asm_height) - 1);
 	}
       else
 	{
@@ -688,11 +685,10 @@ show_data (enum tui_layout_type new_layout)
       else
 	tui_win_list[win_type]
 	  = make_disasm_window (src_height, data_height - 1);
-      reset_locator (locator,
-		     2 /* 1 */ ,
-		     tui_term_width (),
-		     0,
-		     total_height - 1);
+      locator->reset (2 /* 1 */ ,
+		      tui_term_width (),
+		      0,
+		      total_height - 1);
       base = (tui_source_window_base *) tui_win_list[win_type];
     }
   else
@@ -736,16 +732,6 @@ tui_gen_win_info::reset (int height_, int width_,
   origin.y = origin_y_;
 }
 
-static void
-reset_locator (tui_gen_win_info *win_info, 
-	       int height, int width, 
-	       int origin_x, int origin_y)
-{
-  win_info->reset (height, width, origin_x, origin_y);
-  tui_make_window (win_info, DONT_BOX_WINDOW);
-}
-
-
 /* Show the Source/Command or the Disassem layout.  */
 static void
 show_source_or_disasm_and_command (enum tui_layout_type layout_type)
@@ -775,11 +761,10 @@ 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);
-	  reset_locator (locator,
-			 2 /* 1 */ ,
-			 tui_term_width (),
-			 0,
-			 src_height - 1);
+	  locator->reset (2 /* 1 */ ,
+			  tui_term_width (),
+			  0,
+			  src_height - 1);
 	  base = (tui_source_window_base *) *win_info_ptr;
 	}
       else
-- 
2.17.2

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

* [PATCH 60/61] Fix an error in parse_scrolling_args
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (44 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 55/61] Move TUI data item window to tui-regs.h Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 10/61] Remove tui_display_data_from Tom Tromey
                   ` (15 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

parse_scrolling_args combines two errors into one message, which also
happens to end with a newline.  This separates the errors and fixes
the message.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (parse_scrolling_args): Throw separate errors.
---
 gdb/ChangeLog     | 4 ++++
 gdb/tui/tui-win.c | 8 ++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 1e02c42dbd1..db4dc1088a6 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -1391,10 +1391,10 @@ parse_scrolling_args (const char *arg,
 	  
 	  *win_to_scroll = tui_partial_win_by_name (wname);
 
-	  if (*win_to_scroll == NULL
-	      || !(*win_to_scroll)->is_visible)
-	    error (_("Invalid window specified. \n\
-The window name specified must be valid and visible.\n"));
+	  if (*win_to_scroll == NULL)
+	    error (_("Unrecognized window `%s'"), wname);
+	  if (!(*win_to_scroll)->is_visible)
+	    error (_("Window is not visible"));
 	  else if (*win_to_scroll == TUI_CMD_WIN)
 	    *win_to_scroll = tui_source_windows ()[0];
 	}
-- 
2.17.2

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

* [PATCH 43/61] Simplify tui_gen_win_info::make_visible
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (48 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 48/61] Remove make_data_window Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 44/61] Change tui_get_register to return void Tom Tromey
                   ` (11 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I noticed that tui_gen_win_info::make_visible was much wordier than it
needed to be.  This simplifies it.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (tui_gen_win_info::make_visible):
	Simplify.
---
 gdb/ChangeLog            |  5 +++++
 gdb/tui/tui-wingeneral.c | 19 +++++++------------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 3dca621b887..4e6637e8687 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -165,20 +165,15 @@ tui_make_window (struct tui_gen_win_info *win_info, enum tui_box box_it)
 void
 tui_gen_win_info::make_visible (bool visible)
 {
+  if (is_visible == visible)
+    return;
+  is_visible = visible;
+
   if (visible)
+    tui_make_window (this, (tui_win_is_auxiliary (type)
+			    ? DONT_BOX_WINDOW : BOX_WINDOW));
+  else
     {
-      if (!is_visible)
-	{
-	  tui_make_window (this, (tui_win_is_auxiliary (type)
-				  ? DONT_BOX_WINDOW : BOX_WINDOW));
-	  is_visible = true;
-	}
-    }
-  else if (!visible
-	   && is_visible
-	   && handle != NULL)
-    {
-      is_visible = false;
       tui_delete_win (handle);
       handle = NULL;
     }
-- 
2.17.2

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

* [PATCH 26/61] Add win_info parameter to tui_set_disassem_content
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (42 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 42/61] Simplify show_source_disasm_command Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 55/61] Move TUI data item window to tui-regs.h Tom Tromey
                   ` (17 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds a win_info parameter to tui_set_disassem_content, removing
uses of the TUI_DISASM_WIN global.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_update_source_window_as_is): Update.
	* tui/tui-disasm.h (tui_set_disassem_content): Add win_info
	parameter.
	* tui/tui-disasm.c (tui_set_disassem_content): Add win_info
	parameter.
---
 gdb/ChangeLog           |  8 ++++++++
 gdb/tui/tui-disasm.c    | 22 +++++++++++-----------
 gdb/tui/tui-disasm.h    |  3 ++-
 gdb/tui/tui-winsource.c |  2 +-
 4 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index af1a7406be8..a644c287cab 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -161,10 +161,11 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from)
 
 /* Function to set the disassembly window's content.  */
 enum tui_status
-tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
+tui_set_disassem_content (tui_source_window_base *win_info,
+			  struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   int i;
-  int offset = TUI_DISASM_WIN->horizontal_offset;
+  int offset = win_info->horizontal_offset;
   int max_lines, line_width;
   CORE_ADDR cur_pc;
   struct tui_locator_window *locator = tui_locator_win_info_ptr ();
@@ -177,17 +178,16 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
   if (pc == 0)
     return TUI_FAILURE;
 
-  tui_alloc_source_buffer (TUI_DISASM_WIN);
+  tui_alloc_source_buffer (win_info);
 
-  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;
+  win_info->gdbarch = gdbarch;
+  win_info->start_line_or_addr.loa = LOA_ADDRESS;
+  win_info->start_line_or_addr.u.addr = pc;
   cur_pc = locator->addr;
 
   /* Window size, excluding highlight box.  */
-  max_lines = TUI_DISASM_WIN->height - 2;
-  line_width = TUI_DISASM_WIN->width - 2;
+  max_lines = win_info->height - 2;
+  line_width = win_info->width - 2;
 
   /* Get temporary table that will hold all strings (addr & insn).  */
   asm_lines = XALLOCAVEC (struct tui_asm_line, max_lines);
@@ -217,12 +217,12 @@ 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);
+  win_info->content.resize (max_lines);
   for (i = 0; i < max_lines; i++)
     {
       int cur_len;
 
-      tui_source_element *src = &TUI_DISASM_WIN->content[i];
+      tui_source_element *src = &win_info->content[i];
       strcpy (line, asm_lines[i].addr_string);
       cur_len = strlen (line);
       memset (line + cur_len, ' ', insn_pos - cur_len);
diff --git a/gdb/tui/tui-disasm.h b/gdb/tui/tui-disasm.h
index 925c7495947..59822c70c5c 100644
--- a/gdb/tui/tui-disasm.h
+++ b/gdb/tui/tui-disasm.h
@@ -25,7 +25,8 @@
 #include "tui/tui.h"		/* For enum tui_status.  */
 #include "tui/tui-data.h"	/* For enum tui_scroll_direction.  */
 
-extern enum tui_status tui_set_disassem_content (struct gdbarch *, CORE_ADDR);
+extern enum tui_status tui_set_disassem_content (tui_source_window_base *,
+						 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_get_begin_asm_address (struct gdbarch **, CORE_ADDR *);
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 27edc4ed29c..a72ba360185 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -97,7 +97,7 @@ tui_update_source_window_as_is (struct tui_source_window_base *win_info,
     ret = tui_set_source_content (win_info, s, line_or_addr.u.line_no,
 				  noerror);
   else
-    ret = tui_set_disassem_content (gdbarch, line_or_addr.u.addr);
+    ret = tui_set_disassem_content (win_info, gdbarch, line_or_addr.u.addr);
 
   if (ret == TUI_FAILURE)
     {
-- 
2.17.2

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

* [PATCH 52/61] Rearrange TUI data window code
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (35 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 58/61] Change make_invisible_and_set_new_height to be a method Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 53/61] Move tui_dispatch_ctrl_char to tui-io.c Tom Tromey
                   ` (24 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

An earlier patch caused tui-windata.h to be essentially empty.  And,
other earlier patches implemented TUI data window methods in any spot
that happened to be convenient at the time.

This patch rearranges all the data window code to be somewhat more
organized.  It moves tui_data_window to tui-regs.h, and moves the
implementation of all methods to tui-regs.c.  It then removes
tui-windata.h and tui-windata.c.

It also removes the "structuring" comments from tui-regs.c; these are
not the usual gdb style, and were out of date anyhow.  Finally, it
moves _initialize_tui_regs to the end of the file, per the usual gdb
convention.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui.c: Update.
	* tui/tui-wingeneral.c (tui_data_window::refresh_window): Move to
	tui-regs.c.
	* tui/tui-windata.h: Remove file.
	* tui/tui-windata.c: Remove file.
	* tui/tui-win.c (tui_data_window::set_new_height)
	(tui_data_window::do_make_visible_with_new_height): Move to
	tui-regs.c.
	* tui/tui-regs.h (struct tui_data_window): Move from tui-data.h.
	* tui/tui-regs.c: Remove "structuring" comments.
	(tui_data_window::first_data_item_displayed)
	(tui_data_window::delete_data_content_windows)
	(tui_data_window::erase_data_content)
	(tui_data_window::display_all_data)
	(tui_data_window::refresh_all)
	(tui_data_window::do_scroll_vertical)
	(tui_data_window::clear_detail, tui_data_window::set_new_height)
	(tui_data_window::do_make_visible_with_new_height)
	(tui_data_window::refresh_window): Move from elsewhere.
	(_initialize_tui_regs): Move to end of file.
	* tui/tui-layout.c: Update.
	* tui/tui-hooks.c: Update.
	* tui/tui-data.h (struct tui_data_window): Move to tui-regs.h.
	* tui/tui-data.c (tui_data_window::clear_detail): Move to
	tui-regs.c.
	* Makefile.in (SUBDIR_TUI_SRCS): Remove tui-windata.c.
---
 gdb/ChangeLog            |  29 ++++++
 gdb/Makefile.in          |   1 -
 gdb/tui/tui-data.c       |  10 --
 gdb/tui/tui-data.h       |  82 ---------------
 gdb/tui/tui-hooks.c      |   1 -
 gdb/tui/tui-layout.c     |   1 -
 gdb/tui/tui-regs.c       | 209 +++++++++++++++++++++++++++++++++------
 gdb/tui/tui-regs.h       |  85 +++++++++++++++-
 gdb/tui/tui-win.c        |  22 -----
 gdb/tui/tui-windata.c    | 164 ------------------------------
 gdb/tui/tui-windata.h    |  27 -----
 gdb/tui/tui-wingeneral.c |  13 ---
 gdb/tui/tui.c            |   1 -
 13 files changed, 291 insertions(+), 354 deletions(-)
 delete mode 100644 gdb/tui/tui-windata.c
 delete mode 100644 gdb/tui/tui-windata.h

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 7308ea57674..abaaabe0ce7 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -291,7 +291,6 @@ SUBDIR_TUI_SRCS = \
 	tui/tui-source.c \
 	tui/tui-stack.c \
 	tui/tui-win.c \
-	tui/tui-windata.c \
 	tui/tui-wingeneral.c \
 	tui/tui-winsource.c
 
diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index ee5b3aa3a7a..e861eb222dd 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -158,16 +158,6 @@ tui_cmd_window::clear_detail ()
   wmove (handle, 0, 0);
 }
 
-/* See tui-data.h.  */
-
-void
-tui_data_window::clear_detail ()
-{
-  regs_content.clear ();
-  regs_column_count = 1;
-  display_regs = false;
-}
-
 /* Accessor for the locator win info.  Answers a pointer to the static
    locator win info struct.  */
 struct tui_locator_window *
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index a95f4272e57..489bae99b22 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -452,88 +452,6 @@ protected:
   void do_scroll_vertical (int num_to_scroll) override;
 };
 
-struct tui_data_window : public tui_win_info
-{
-  tui_data_window ()
-    : tui_win_info (DATA_WIN)
-  {
-  }
-
-  DISABLE_COPY_AND_ASSIGN (tui_data_window);
-
-  void clear_detail () override;
-  void refresh_all () override;
-
-  void set_new_height (int height) override;
-
-  void refresh_window () override;
-
-  const char *name () const override
-  {
-    return DATA_NAME;
-  }
-
-  /* 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;
-  struct reggroup *current_group = nullptr;
-
-  /* Answer the number of the last line in the regs display.  If there
-     are no registers (-1) is returned.  */
-  int last_regs_line_no () const;
-
-  /* Answer the line number that the register element at element_no is
-     on.  If element_no is greater than the number of register
-     elements there are, -1 is returned.  */
-  int line_from_reg_element_no (int element_no) const;
-
-  /* Answer the index of the first element in line_no.  If line_no is
-     past the register area (-1) is returned.  */
-  int first_reg_element_no_inline (int line_no) const;
-
-  /* This function displays the data that is in the data window's
-     content.  It does not set the content.  */
-  void display_all_data ();
-
-  /* Function to delete all the item windows in the data window.  This
-     is usually done when the data window is scrolled.  */
-  void delete_data_content_windows ();
-
-  void erase_data_content (const char *prompt);
-
-  /* Function to display the registers in the content from
-     'start_element_no' until the end of the register content or the
-     end of the display height.  No checking for displaying past the
-     end of the registers is done here.  */
-  void display_registers_from (int start_element_no);
-
-  /* Function to display the registers starting at line line_no in the
-     data window.  Answers the line number that the display actually
-     started from.  If nothing is displayed (-1) is returned.  */
-  int display_registers_from_line (int line_no);
-
-protected:
-
-  void do_scroll_vertical (int num_to_scroll) override;
-  void do_scroll_horizontal (int num_to_scroll) override
-  {
-  }
-  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 ();
-
-  /* Function to display the registers in the content from
-     'start_element_no' on 'start_line_no' until the end of the
-     register content or the end of the display height.  This function
-     checks that we won't display off the end of the register
-     display.  */
-  void display_reg_element_at_line (int start_element_no, int start_line_no);
-};
-
 struct tui_cmd_window : public tui_win_info
 {
   tui_cmd_window ()
diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index 84acd3ac2e6..a2d06f8a152 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -45,7 +45,6 @@
 #include "tui/tui-regs.h"
 #include "tui/tui-win.h"
 #include "tui/tui-stack.h"
-#include "tui/tui-windata.h"
 #include "tui/tui-winsource.h"
 
 #include "gdb_curses.h"
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 4869cd9a11a..abc3fd60182 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -29,7 +29,6 @@
 
 #include "tui/tui.h"
 #include "tui/tui-data.h"
-#include "tui/tui-windata.h"
 #include "tui/tui-wingeneral.h"
 #include "tui/tui-stack.h"
 #include "tui/tui-regs.h"
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index c6ed19d4295..264f916aaa1 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -32,7 +32,6 @@
 #include "target.h"
 #include "tui/tui-layout.h"
 #include "tui/tui-win.h"
-#include "tui/tui-windata.h"
 #include "tui/tui-wingeneral.h"
 #include "tui/tui-file.h"
 #include "tui/tui-regs.h"
@@ -43,10 +42,6 @@
 
 #include "gdb_curses.h"
 
-
-/*****************************************
-** STATIC LOCAL FUNCTIONS FORWARD DECLS    **
-******************************************/
 static void tui_display_register (struct tui_data_item_window *data);
 
 static void tui_show_register_group (tui_data_window *win_info,
@@ -58,13 +53,7 @@ static void tui_get_register (struct frame_info *frame,
 			      struct tui_data_item_window *data,
 			      int regnum, bool *changedp);
 
-
-
-/*****************************************
-** PUBLIC FUNCTIONS                     **
-******************************************/
-
-/* See tui-data.h.  */
+/* See tui-regs.h.  */
 
 int
 tui_data_window::last_regs_line_no () const
@@ -80,7 +69,7 @@ tui_data_window::last_regs_line_no () const
   return num_lines;
 }
 
-/* See tui-data.h.  */
+/* See tui-regs.h.  */
 
 int
 tui_data_window::line_from_reg_element_no (int element_no) const
@@ -104,7 +93,7 @@ tui_data_window::line_from_reg_element_no (int element_no) const
     return (-1);
 }
 
-/* See tui-data.h.  */
+/* See tui-regs.h.  */
 
 int
 tui_data_window::first_reg_element_no_inline (int line_no) const
@@ -411,6 +400,169 @@ tui_data_window::display_registers_from_line (int line_no)
 }
 
 
+/* Answer the index first element displayed.  If none are displayed,
+   then return (-1).  */
+int
+tui_data_window::first_data_item_displayed ()
+{
+  for (int i = 0; i < regs_content.size (); i++)
+    {
+      struct tui_gen_win_info *data_item_win;
+
+      data_item_win = regs_content[i].get ();
+      if (data_item_win->handle != NULL && data_item_win->is_visible)
+	return i;
+    }
+
+  return -1;
+}
+
+
+/* Function to delete all the item windows in the data window.  This
+   is usually done when the data window is scrolled.  */
+void
+tui_data_window::delete_data_content_windows ()
+{
+  for (auto &&win : regs_content)
+    {
+      tui_delete_win (win->handle);
+      win->handle = NULL;
+      win->is_visible = false;
+    }
+}
+
+
+void
+tui_data_window::erase_data_content (const char *prompt)
+{
+  werase (handle);
+  tui_check_and_display_highlight_if_needed (this);
+  if (prompt != NULL)
+    {
+      int half_width = (width - 2) / 2;
+      int x_pos;
+
+      if (strlen (prompt) >= half_width)
+	x_pos = 1;
+      else
+	x_pos = half_width - strlen (prompt);
+      mvwaddstr (handle, (height / 2), x_pos, (char *) prompt);
+    }
+  wrefresh (handle);
+}
+
+
+/* This function displays the data that is in the data window's
+   content.  It does not set the content.  */
+void
+tui_data_window::display_all_data ()
+{
+  if (regs_content.empty ())
+    erase_data_content (NO_DATA_STRING);
+  else
+    {
+      erase_data_content (NULL);
+      delete_data_content_windows ();
+      tui_check_and_display_highlight_if_needed (this);
+      display_registers_from (0);
+    }
+}
+
+
+/* Function to redisplay the contents of the data window.  */
+void
+tui_data_window::refresh_all ()
+{
+  erase_data_content (NULL);
+  if (!regs_content.empty ())
+    {
+      int first_element = first_data_item_displayed ();
+
+      if (first_element >= 0)	/* Re-use existing windows.  */
+	{
+	  int first_line = (-1);
+
+	  if (first_element < regs_content.size ())
+	    first_line = line_from_reg_element_no (first_element);
+
+	  if (first_line >= 0)
+	    {
+	      erase_data_content (NULL);
+	      display_registers_from_line (first_line);
+	    }
+	}
+    }
+}
+
+
+/* Scroll the data window vertically forward or backward.  */
+void
+tui_data_window::do_scroll_vertical (int num_to_scroll)
+{
+  int first_element_no;
+  int first_line = (-1);
+
+  first_element_no = first_data_item_displayed ();
+  if (first_element_no < regs_content.size ())
+    first_line = line_from_reg_element_no (first_element_no);
+  else
+    { /* Calculate the first line from the element number which is in
+        the general data content.  */
+    }
+
+  if (first_line >= 0)
+    {
+      first_line += num_to_scroll;
+      erase_data_content (NULL);
+      delete_data_content_windows ();
+      display_registers_from_line (first_line);
+    }
+}
+
+/* See tui-regs.h.  */
+
+void
+tui_data_window::clear_detail ()
+{
+  regs_content.clear ();
+  regs_column_count = 1;
+  display_regs = false;
+}
+
+/* See tui-regs.h.  */
+
+void
+tui_data_window::set_new_height (int height)
+{
+  /* Delete all data item windows.  */
+  for (auto &&win : regs_content)
+    {
+      tui_delete_win (win->handle);
+      win->handle = NULL;
+    }
+}
+
+/* See tui-regs.h.  */
+
+void
+tui_data_window::do_make_visible_with_new_height ()
+{
+  display_all_data ();
+}
+
+/* See tui-regs.h.  */
+
+void
+tui_data_window::refresh_window ()
+{
+  tui_gen_win_info::refresh_window ();
+  for (auto &&win : regs_content)
+    {
+      if (win != NULL)
+	win->refresh_window ();
+    }
+}
+
 /* This function check all displayed registers for changes in values,
    given a particular frame.  If the values have changed, they are
    updated with the new value and highlighted.  */
@@ -608,23 +760,6 @@ tui_reggroup_completer (struct cmd_list_element *ignore,
     }
 }
 
-void
-_initialize_tui_regs (void)
-{
-  struct cmd_list_element **tuicmd, *cmd;
-
-  tuicmd = tui_get_cmd_list ();
-
-  cmd = add_cmd ("reg", class_tui, tui_reg_command, _("\
-TUI command to control the register window."), tuicmd);
-  set_cmd_completer (cmd, tui_reggroup_completer);
-}
-
-
-/*****************************************
-** STATIC LOCAL FUNCTIONS                 **
-******************************************/
-
 /* Get the register from the frame and return a printable
    representation of it.  */
 
@@ -674,3 +809,15 @@ tui_get_register (struct frame_info *frame,
       xfree (prev_content);
     }
 }
+
+void
+_initialize_tui_regs (void)
+{
+  struct cmd_list_element **tuicmd, *cmd;
+
+  tuicmd = tui_get_cmd_list ();
+
+  cmd = add_cmd ("reg", class_tui, tui_reg_command, _("\
+TUI command to control the register window."), tuicmd);
+  set_cmd_completer (cmd, tui_reggroup_completer);
+}
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index 354605c96f2..ad8d01e445f 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -22,7 +22,90 @@
 #ifndef TUI_TUI_REGS_H
 #define TUI_TUI_REGS_H
 
-#include "tui/tui-data.h"  /* For struct tui_register_display_type.  */
+#include "tui/tui-data.h"
+
+/* The TUI registers window.  */
+struct tui_data_window : public tui_win_info
+{
+  tui_data_window ()
+    : tui_win_info (DATA_WIN)
+  {
+  }
+
+  DISABLE_COPY_AND_ASSIGN (tui_data_window);
+
+  void clear_detail () override;
+  void refresh_all () override;
+
+  void set_new_height (int height) override;
+
+  void refresh_window () override;
+
+  const char *name () const override
+  {
+    return DATA_NAME;
+  }
+
+  /* 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;
+  struct reggroup *current_group = nullptr;
+
+  /* Answer the number of the last line in the regs display.  If there
+     are no registers (-1) is returned.  */
+  int last_regs_line_no () const;
+
+  /* Answer the line number that the register element at element_no is
+     on.  If element_no is greater than the number of register
+     elements there are, -1 is returned.  */
+  int line_from_reg_element_no (int element_no) const;
+
+  /* Answer the index of the first element in line_no.  If line_no is
+     past the register area (-1) is returned.  */
+  int first_reg_element_no_inline (int line_no) const;
+
+  /* This function displays the data that is in the data window's
+     content.  It does not set the content.  */
+  void display_all_data ();
+
+  /* Function to delete all the item windows in the data window.  This
+     is usually done when the data window is scrolled.  */
+  void delete_data_content_windows ();
+
+  void erase_data_content (const char *prompt);
+
+  /* Function to display the registers in the content from
+     'start_element_no' until the end of the register content or the
+     end of the display height.  No checking for displaying past the
+     end of the registers is done here.  */
+  void display_registers_from (int start_element_no);
+
+  /* Function to display the registers starting at line line_no in the
+     data window.  Answers the line number that the display actually
+     started from.  If nothing is displayed (-1) is returned.  */
+  int display_registers_from_line (int line_no);
+
+protected:
+
+  void do_scroll_vertical (int num_to_scroll) override;
+  void do_scroll_horizontal (int num_to_scroll) override
+  {
+  }
+  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 ();
+
+  /* Function to display the registers in the content from
+     'start_element_no' on 'start_line_no' until the end of the
+     register content or the end of the display height.  This function
+     checks that we won't display off the end of the register
+     display.  */
+  void display_reg_element_at_line (int start_element_no, int start_line_no);
+};
 
 extern void tui_check_register_values (struct frame_info *);
 extern void tui_show_registers (struct reggroup *group);
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 2fb757a6a4d..0c7042e9385 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -43,7 +43,6 @@
 #include "tui/tui-disasm.h"
 #include "tui/tui-source.h"
 #include "tui/tui-winsource.h"
-#include "tui/tui-windata.h"
 #include "tui/tui-win.h"
 
 #include "gdb_curses.h"
@@ -1243,19 +1242,6 @@ tui_source_window_base::set_new_height (int height)
     }
 }
 
-/* See tui-data.h.  */
-
-void
-tui_data_window::set_new_height (int height)
-{
-  /* Delete all data item windows.  */
-  for (auto &&win : regs_content)
-    {
-      tui_delete_win (win->handle);
-      win->handle = NULL;
-    }
-}
-
 /* Function make the target window (and auxiliary windows associated
    with the targer) invisible, and set the new height and
    location.  */
@@ -1333,14 +1319,6 @@ tui_source_window_base::do_make_visible_with_new_height ()
 
 /* See tui-data.h.  */
 
-void
-tui_data_window::do_make_visible_with_new_height ()
-{
-  display_all_data ();
-}
-
-/* See tui-data.h.  */
-
 void
 tui_cmd_window::do_make_visible_with_new_height ()
 {
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
deleted file mode 100644
index 9256e0e26b6..00000000000
--- a/gdb/tui/tui-windata.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/* Data/register window display.
-
-   Copyright (C) 1998-2019 Free Software Foundation, Inc.
-
-   Contributed by Hewlett-Packard Company.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include "defs.h"
-#include "tui/tui.h"
-#include "tui/tui-data.h"
-#include "tui/tui-wingeneral.h"
-#include "tui/tui-regs.h"
-#include "tui/tui-windata.h"
-#include "gdb_curses.h"
-
-
-/*****************************************
-** STATIC LOCAL FUNCTIONS FORWARD DECLS    **
-******************************************/
-
-
-
-/*****************************************
-** PUBLIC FUNCTIONS                        **
-******************************************/
-
-
-/* Answer the index first element displayed.  If none are displayed,
-   then return (-1).  */
-int
-tui_data_window::first_data_item_displayed ()
-{
-  for (int i = 0; i < regs_content.size (); i++)
-    {
-      struct tui_gen_win_info *data_item_win;
-
-      data_item_win = regs_content[i].get ();
-      if (data_item_win->handle != NULL && data_item_win->is_visible)
-	return i;
-    }
-
-  return -1;
-}
-
-
-/* Function to delete all the item windows in the data window.  This
-   is usually done when the data window is scrolled.  */
-void
-tui_data_window::delete_data_content_windows ()
-{
-  for (auto &&win : regs_content)
-    {
-      tui_delete_win (win->handle);
-      win->handle = NULL;
-      win->is_visible = false;
-    }
-}
-
-
-void
-tui_data_window::erase_data_content (const char *prompt)
-{
-  werase (handle);
-  tui_check_and_display_highlight_if_needed (this);
-  if (prompt != NULL)
-    {
-      int half_width = (width - 2) / 2;
-      int x_pos;
-
-      if (strlen (prompt) >= half_width)
-	x_pos = 1;
-      else
-	x_pos = half_width - strlen (prompt);
-      mvwaddstr (handle, (height / 2), x_pos, (char *) prompt);
-    }
-  wrefresh (handle);
-}
-
-
-/* This function displays the data that is in the data window's
-   content.  It does not set the content.  */
-void
-tui_data_window::display_all_data ()
-{
-  if (regs_content.empty ())
-    erase_data_content (NO_DATA_STRING);
-  else
-    {
-      erase_data_content (NULL);
-      delete_data_content_windows ();
-      tui_check_and_display_highlight_if_needed (this);
-      display_registers_from (0);
-    }
-}
-
-
-/* Function to redisplay the contents of the data window.  */
-void
-tui_data_window::refresh_all ()
-{
-  erase_data_content (NULL);
-  if (!regs_content.empty ())
-    {
-      int first_element = first_data_item_displayed ();
-
-      if (first_element >= 0)	/* Re-use existing windows.  */
-	{
-	  int first_line = (-1);
-
-	  if (first_element < regs_content.size ())
-	    first_line = line_from_reg_element_no (first_element);
-
-	  if (first_line >= 0)
-	    {
-	      erase_data_content (NULL);
-	      display_registers_from_line (first_line);
-	    }
-	}
-    }
-}
-
-
-/* Scroll the data window vertically forward or backward.  */
-void
-tui_data_window::do_scroll_vertical (int num_to_scroll)
-{
-  int first_element_no;
-  int first_line = (-1);
-
-  first_element_no = first_data_item_displayed ();
-  if (first_element_no < regs_content.size ())
-    first_line = line_from_reg_element_no (first_element_no);
-  else
-    { /* Calculate the first line from the element number which is in
-        the general data content.  */
-    }
-
-  if (first_line >= 0)
-    {
-      first_line += num_to_scroll;
-      erase_data_content (NULL);
-      delete_data_content_windows ();
-      display_registers_from_line (first_line);
-    }
-}
-
-
-/*****************************************
-** STATIC LOCAL FUNCTIONS               **
-******************************************/
diff --git a/gdb/tui/tui-windata.h b/gdb/tui/tui-windata.h
deleted file mode 100644
index 3b89eefabc0..00000000000
--- a/gdb/tui/tui-windata.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Data/register window display.
-
-   Copyright (C) 1998-2019 Free Software Foundation, Inc.
-
-   Contributed by Hewlett-Packard Company.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#ifndef TUI_TUI_WINDATA_H
-#define TUI_TUI_WINDATA_H
-
-#include "tui/tui-data.h"
-
-#endif /* TUI_TUI_WINDATA_H */
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 2fb8d6c684f..5d632b6f97e 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -43,19 +43,6 @@ tui_gen_win_info::refresh_window ()
     }
 }
 
-/* See tui-data.h.  */
-
-void
-tui_data_window::refresh_window ()
-{
-  tui_gen_win_info::refresh_window ();
-  for (auto &&win : regs_content)
-    {
-      if (win != NULL)
-	win->refresh_window ();
-    }
-}
-
 /* Function to delete the curses window, checking for NULL.  */
 void
 tui_delete_win (WINDOW *window)
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index ee2c35587df..996dbaf6cf7 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -30,7 +30,6 @@
 #include "tui/tui-stack.h"
 #include "tui/tui-win.h"
 #include "tui/tui-winsource.h"
-#include "tui/tui-windata.h"
 #include "target.h"
 #include "frame.h"
 #include "breakpoint.h"
-- 
2.17.2

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

* [PATCH 58/61] Change make_invisible_and_set_new_height to be a method
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (34 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 49/61] Remove tui_make_visible and tui_make_invisible Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-22 11:57   ` clang build-regression [Re: [PATCH 58/61] Change make_invisible_and_set_new_height to be a method] Jan Kratochvil
  2019-07-04 17:04 ` [PATCH 52/61] Rearrange TUI data window code Tom Tromey
                   ` (25 subsequent siblings)
  61 siblings, 1 reply; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes make_invisible_and_set_new_height to be a method on
tui_win_info.  I felt that this was cleaner.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (tui_resize_all)
	(tui_source_window_base::update_tab_width)
	(tui_adjust_win_heights): Update.
	(tui_win_info::make_invisible_and_set_new_height): Rename from
	make_invisible_and_set_new_height.
	* tui/tui-data.h (struct tui_win_info)
	<make_invisible_and_set_new_height>: New method.
---
 gdb/ChangeLog      | 10 ++++++
 gdb/tui/tui-data.h |  5 +++
 gdb/tui/tui-win.c  | 78 +++++++++++++++++++++-------------------------
 3 files changed, 50 insertions(+), 43 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 0d984ad3b4c..84a8117c754 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -299,6 +299,11 @@ public:
   {
   }
 
+  /* Function make the target window (and auxiliary windows associated
+     with the target) invisible, and set the new height and
+     location.  */
+  void make_invisible_and_set_new_height (int height);
+
   /* Make the window visible after the height has been changed.  */
   void make_visible_with_new_height ();
 
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 124fdb11c7e..227ab94bdc7 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -55,8 +55,6 @@
 /*******************************
 ** Static Local Decls
 ********************************/
-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 *, 
 					       int);
 static int new_height_ok (struct tui_win_info *, int);
@@ -601,11 +599,11 @@ tui_resize_all (void)
 	    new_height = first_win->height + split_diff;
 
 	  locator->origin.y = new_height + 1;
-	  make_invisible_and_set_new_height (first_win, new_height);
+	  first_win->make_invisible_and_set_new_height (new_height);
 	  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);
+	  TUI_CMD_WIN->make_invisible_and_set_new_height (new_height);
 	  first_win->make_visible_with_new_height ();
 	  TUI_CMD_WIN->make_visible_with_new_height ();
 	  if (src_win->content.empty ())
@@ -640,7 +638,7 @@ tui_resize_all (void)
 	    new_height = MIN_WIN_HEIGHT;
 	  else
 	    new_height = first_win->height + split_diff;
-	  make_invisible_and_set_new_height (first_win, new_height);
+	  first_win->make_invisible_and_set_new_height (new_height);
 
 	  locator->width += width_diff;
 
@@ -663,13 +661,12 @@ tui_resize_all (void)
 	  else
 	    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);
+	  second_win->make_invisible_and_set_new_height (new_height);
 
 	  /* Change the command window's height/width.  */
 	  TUI_CMD_WIN->origin.y = locator->origin.y + 1;
-	  make_invisible_and_set_new_height (TUI_CMD_WIN,
-					     TUI_CMD_WIN->height
-					     + cmd_split_diff);
+	  TUI_CMD_WIN->make_invisible_and_set_new_height (TUI_CMD_WIN->height
+							  + cmd_split_diff);
 	  first_win->make_visible_with_new_height ();
 	  second_win->make_visible_with_new_height ();
 	  TUI_CMD_WIN->make_visible_with_new_height ();
@@ -911,7 +908,7 @@ tui_source_window_base::update_tab_width ()
      calling these 2 functions causes a complete regeneration
      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_invisible_and_set_new_height (height);
   make_visible_with_new_height ();
 }
 
@@ -1081,7 +1078,7 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 	    {
 	      struct tui_win_info *src_win_info;
 
-	      make_invisible_and_set_new_height (primary_win_info, new_height);
+	      primary_win_info->make_invisible_and_set_new_height (new_height);
 	      if (primary_win_info->type == CMD_WIN)
 		{
 		  win_info = tui_source_windows ()[0];
@@ -1092,8 +1089,8 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 		  win_info = tui_win_list[CMD_WIN];
 		  src_win_info = primary_win_info;
 		}
-	      make_invisible_and_set_new_height (win_info,
-					     win_info->height + diff);
+	      win_info->make_invisible_and_set_new_height
+		(win_info->height + diff);
 	      TUI_CMD_WIN->origin.y = locator->origin.y + 1;
 	      win_info->make_visible_with_new_height ();
 	      primary_win_info->make_visible_with_new_height ();
@@ -1159,15 +1156,13 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 		      second_split_diff++;
 		      first_split_diff--;
 		    }
-		  make_invisible_and_set_new_height (
-						  first_win,
-				 first_win->height + first_split_diff);
+		  first_win->make_invisible_and_set_new_height
+		    (first_win->height + first_split_diff);
 		  second_win->origin.y = first_win->height - 1;
-		  make_invisible_and_set_new_height (second_win,
-						     second_win->height
-						     + second_split_diff);
+		  second_win->make_invisible_and_set_new_height
+		    (second_win->height + second_split_diff);
 		  TUI_CMD_WIN->origin.y = locator->origin.y + 1;
-		  make_invisible_and_set_new_height (TUI_CMD_WIN, new_height);
+		  TUI_CMD_WIN->make_invisible_and_set_new_height (new_height);
 		}
 	      else
 		{
@@ -1188,23 +1183,22 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 			}
 		    }
 		  if (primary_win_info == first_win)
-		    make_invisible_and_set_new_height (first_win, new_height);
+		    first_win->make_invisible_and_set_new_height (new_height);
 		  else
-		    make_invisible_and_set_new_height (
-						    first_win,
-						  first_win->height);
+		    first_win->make_invisible_and_set_new_height
+		      (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);
+		    second_win->make_invisible_and_set_new_height (new_height);
 		  else
-		    make_invisible_and_set_new_height (
-				      second_win, second_win->height);
+		    second_win->make_invisible_and_set_new_height
+		      (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);
+		    TUI_CMD_WIN->make_invisible_and_set_new_height (1);
 		  else
-		    make_invisible_and_set_new_height (TUI_CMD_WIN,
-						       TUI_CMD_WIN->height + diff);
+		    TUI_CMD_WIN->make_invisible_and_set_new_height
+		      (TUI_CMD_WIN->height + diff);
 		}
 	      TUI_CMD_WIN->make_visible_with_new_height ();
 	      second_win->make_visible_with_new_height ();
@@ -1243,24 +1237,22 @@ tui_source_window_base::set_new_height (int height)
     }
 }
 
-/* Function make the target window (and auxiliary windows associated
-   with the targer) invisible, and set the new height and
-   location.  */
-static void
-make_invisible_and_set_new_height (struct tui_win_info *win_info, 
-				   int height)
+/* See tui-data.h.  */
+
+void
+tui_win_info::make_invisible_and_set_new_height (int height)
 {
-  win_info->make_visible (false);
-  win_info->height = height;
+  make_visible (false);
+  height = height;
   if (height > 1)
-    win_info->viewport_height = height - 1;
+    viewport_height = height - 1;
   else
-    win_info->viewport_height = height;
-  if (win_info != TUI_CMD_WIN)
-    win_info->viewport_height--;
+    viewport_height = height;
+  if (this != TUI_CMD_WIN)
+    viewport_height--;
 
   /* Now deal with the auxiliary windows associated with win_info.  */
-  win_info->set_new_height (height);
+  set_new_height (height);
 }
 
 
-- 
2.17.2

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

* [PATCH 53/61] Move tui_dispatch_ctrl_char to tui-io.c
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (36 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 52/61] Rearrange TUI data window code Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 38/61] Remove the win_type parameter from tui_gen_win_info::reset Tom Tromey
                   ` (23 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_dispatch_ctrl_char is only called from a single spot in tui-io.c,
so move the function to that file and make it static.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-io.c (tui_dispatch_ctrl_char): Move from tui-command.c.
	Now static.
	* tui/tui-command.h (tui_dispatch_ctrl_char): Don't declare.
	* tui/tui-command.c (tui_dispatch_ctrl_char): Move to tui-io.c.
---
 gdb/ChangeLog         |  7 ++++++
 gdb/tui/tui-command.c | 51 -------------------------------------------
 gdb/tui/tui-command.h |  2 --
 gdb/tui/tui-io.c      | 51 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 58 insertions(+), 53 deletions(-)

diff --git a/gdb/tui/tui-command.c b/gdb/tui/tui-command.c
index bd16f801d26..1a269e7fb51 100644
--- a/gdb/tui/tui-command.c
+++ b/gdb/tui/tui-command.c
@@ -37,57 +37,6 @@
 ** PUBLIC FUNCTIONS                        **
 ******************************************/
 
-/* Dispatch the correct tui function based upon the control
-   character.  */
-unsigned int
-tui_dispatch_ctrl_char (unsigned int ch)
-{
-  struct tui_win_info *win_info = tui_win_with_focus ();
-
-  /* Handle the CTRL-L refresh for each window.  */
-  if (ch == '\f')
-    tui_refresh_all_win ();
-
-  /* If no window has the focus, or if the focus window can't scroll,
-     just pass the character through.  */
-  if (win_info == NULL || !win_info->can_scroll ())
-    return ch;
-
-  switch (ch)
-    {
-    case KEY_NPAGE:
-      win_info->forward_scroll (0);
-      break;
-    case KEY_PPAGE:
-      win_info->backward_scroll (0);
-      break;
-    case KEY_DOWN:
-    case KEY_SF:
-      win_info->forward_scroll (1);
-      break;
-    case KEY_UP:
-    case KEY_SR:
-      win_info->backward_scroll (1);
-      break;
-    case KEY_RIGHT:
-      win_info->left_scroll (1);
-      break;
-    case KEY_LEFT:
-      win_info->right_scroll (1);
-      break;
-    case '\f':
-      break;
-    default:
-      /* We didn't recognize the character as a control character, so pass it
-         through.  */
-      return ch;
-    }
-
-  /* We intercepted the control character, so return 0 (which readline
-     will interpret as a no-op).  */
-  return 0;
-}
-
 /* See tui-command.h.  */
 
 void
diff --git a/gdb/tui/tui-command.h b/gdb/tui/tui-command.h
index 80f69caf61b..3f84ee22fa8 100644
--- a/gdb/tui/tui-command.h
+++ b/gdb/tui/tui-command.h
@@ -22,8 +22,6 @@
 #ifndef TUI_TUI_COMMAND_H
 #define TUI_TUI_COMMAND_H
 
-extern unsigned int tui_dispatch_ctrl_char (unsigned int);
-
 /* Refresh the command window.  */
 extern void tui_refresh_cmd_win (void);
 
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 51f69185da3..70e5310dd13 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -912,6 +912,57 @@ tui_initialize_io (void)
 #endif
 }
 
+/* Dispatch the correct tui function based upon the control
+   character.  */
+static unsigned int
+tui_dispatch_ctrl_char (unsigned int ch)
+{
+  struct tui_win_info *win_info = tui_win_with_focus ();
+
+  /* Handle the CTRL-L refresh for each window.  */
+  if (ch == '\f')
+    tui_refresh_all_win ();
+
+  /* If no window has the focus, or if the focus window can't scroll,
+     just pass the character through.  */
+  if (win_info == NULL || !win_info->can_scroll ())
+    return ch;
+
+  switch (ch)
+    {
+    case KEY_NPAGE:
+      win_info->forward_scroll (0);
+      break;
+    case KEY_PPAGE:
+      win_info->backward_scroll (0);
+      break;
+    case KEY_DOWN:
+    case KEY_SF:
+      win_info->forward_scroll (1);
+      break;
+    case KEY_UP:
+    case KEY_SR:
+      win_info->backward_scroll (1);
+      break;
+    case KEY_RIGHT:
+      win_info->left_scroll (1);
+      break;
+    case KEY_LEFT:
+      win_info->right_scroll (1);
+      break;
+    case '\f':
+      break;
+    default:
+      /* We didn't recognize the character as a control character, so pass it
+         through.  */
+      return ch;
+    }
+
+  /* We intercepted the control character, so return 0 (which readline
+     will interpret as a no-op).  */
+  return 0;
+}
+
 /* Get a character from the command window.  This is called from the
    readline package.  */
 static int
-- 
2.17.2

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

* [PATCH 56/61] Move tui_disasm_window to tui-disasm.h
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (31 preceding siblings ...)
  2019-07-04 17:03 ` [PATCH 22/61] Make source windows be self-updating Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 05/61] Remove deleted breakpoint from TUI display Tom Tromey
                   ` (28 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves tui_disasm_window to tui-disasm.h.  In this case there were
no method definitions to be moved.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-disasm.h (struct tui_disasm_window): Move from
	tui-data.h.
	* tui/tui-data.h (struct tui_disasm_window): Move to
	tui-disasm.h.
---
 gdb/ChangeLog        |  7 +++++++
 gdb/tui/tui-data.h   | 23 -----------------------
 gdb/tui/tui-disasm.h | 27 +++++++++++++++++++++++++--
 3 files changed, 32 insertions(+), 25 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 2f2f2a0ab91..3446d51b8dc 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -412,29 +412,6 @@ private:
   gdb::observers::token m_observable;
 };
 
-/* 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);
-
-  const char *name () const override
-  {
-    return DISASSEM_NAME;
-  }
-
-  bool location_matches_p (struct bp_location *loc, int line_no) override;
-
-protected:
-
-  void do_scroll_vertical (int num_to_scroll) override;
-};
-
 extern int tui_win_is_auxiliary (enum tui_win_type win_type);
 
 
diff --git a/gdb/tui/tui-disasm.h b/gdb/tui/tui-disasm.h
index 59822c70c5c..cc00d0018fa 100644
--- a/gdb/tui/tui-disasm.h
+++ b/gdb/tui/tui-disasm.h
@@ -22,8 +22,31 @@
 #ifndef TUI_TUI_DISASM_H
 #define TUI_TUI_DISASM_H
 
-#include "tui/tui.h"		/* For enum tui_status.  */
-#include "tui/tui-data.h"	/* For enum tui_scroll_direction.  */
+#include "tui/tui.h"
+#include "tui/tui-data.h"
+
+/* 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);
+
+  const char *name () const override
+  {
+    return DISASSEM_NAME;
+  }
+
+  bool location_matches_p (struct bp_location *loc, int line_no) override;
+
+protected:
+
+  void do_scroll_vertical (int num_to_scroll) override;
+};
 
 extern enum tui_status tui_set_disassem_content (tui_source_window_base *,
 						 struct gdbarch *, CORE_ADDR);
-- 
2.17.2

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

* [PATCH 59/61] Move source window common to code to tui-winsource.[ch]
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (46 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 10/61] Remove tui_display_data_from Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 48/61] Remove make_data_window Tom Tromey
                   ` (13 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Like the previous rearranging patches, this moves the source and
disassembly window base class code to tui-winsource.[ch].  The
execution info window is also moved, because it is associated with
this base class.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (struct tui_exec_info_window)
	(struct tui_source_window_base): Move from tui-data.h.
	* tui/tui-winsource.c: Move many method definitions from
	elsewhere.  Remove "structuring" comments.
	* tui/tui-wingeneral.c (tui_source_window_base::make_visible)
	(tui_source_window_base::refresh_window): Move to
	tui-winsource.c.
	* tui/tui-win.c (tui_source_window_base::refresh_all)
	(tui_source_window_base::update_tab_width)
	(tui_source_window_base::set_new_height)
	(tui_source_window_base::do_make_visible_with_new_height): Move to
	tui-winsource.c.
	* tui/tui-source.h: Update.
	* tui/tui-source.c (tui_source_window_base::reset): Move to
	tui-winsource.c.
	* tui/tui-disasm.h: Update.
	* tui/tui-data.h (struct tui_exec_info_window): Move to
	tui-winsource.h.
	(struct tui_source_window_base): Likewise.
	* tui/tui-data.c (tui_source_window_base::clear_detail)
	(tui_source_window_base, ~tui_source_window_base): Move to
	tui-winsource.c.
---
 gdb/ChangeLog            |  25 +++++++
 gdb/tui/tui-data.c       |  27 +------
 gdb/tui/tui-data.h       |  83 +---------------------
 gdb/tui/tui-disasm.h     |   1 +
 gdb/tui/tui-source.c     |   9 ---
 gdb/tui/tui-source.h     |   1 +
 gdb/tui/tui-win.c        |  90 -----------------------
 gdb/tui/tui-wingeneral.c |  18 -----
 gdb/tui/tui-winsource.c  | 149 +++++++++++++++++++++++++++++++++++++--
 gdb/tui/tui-winsource.h  |  82 ++++++++++++++++++++-
 10 files changed, 254 insertions(+), 231 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 8977e8fd592..2748230700c 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -24,6 +24,7 @@
 #include "tui/tui.h"
 #include "tui/tui-data.h"
 #include "tui/tui-wingeneral.h"
+#include "tui/tui-winsource.h"
 #include "gdb_curses.h"
 
 /****************************
@@ -139,17 +140,6 @@ tui_add_to_source_windows (struct tui_source_window_base *win_info)
     source_windows.push_back (win_info);
 }
 
-/* See tui-data.h.  */
-
-void
-tui_source_window_base::clear_detail ()
-{
-  gdbarch = NULL;
-  start_line_or_addr.loa = LOA_ADDRESS;
-  start_line_or_addr.u.addr = 0;
-  horizontal_offset = 0;
-}
-
 /* Accessor for the locator win info.  Answers a pointer to the static
    locator win info struct.  */
 struct tui_locator_window *
@@ -313,23 +303,8 @@ tui_win_info::tui_win_info (enum tui_win_type type)
 {
 }
 
-tui_source_window_base::tui_source_window_base (enum tui_win_type type)
-  : tui_win_info (type),
-    execution_info (new tui_exec_info_window ())
-{
-  gdb_assert (type == SRC_WIN || type == DISASSEM_WIN);
-  start_line_or_addr.loa = LOA_ADDRESS;
-  start_line_or_addr.u.addr = 0;
-}
-
 tui_gen_win_info::~tui_gen_win_info ()
 {
   tui_delete_win (handle);
   xfree (title);
 }
-
-tui_source_window_base::~tui_source_window_base ()
-{
-  xfree (fullname);
-  delete execution_info;
-}  
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 84a8117c754..214f728befe 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -27,6 +27,7 @@
 #include "observable.h"
 
 struct tui_cmd_window;
+struct tui_source_window_base;
 struct tui_source_window;
 
 /* This is a point definition.  */
@@ -203,34 +204,6 @@ struct tui_source_element
 
 typedef char tui_exec_info_content[TUI_EXECINFO_SIZE];
 
-/* 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);
-
-  /* Return the contents.  */
-  const tui_exec_info_content *get_content () const
-  {
-    return m_content;
-  }
-
-private:
-
-  tui_exec_info_content *m_content = nullptr;
-};
-
 /* Locator window class.  */
 
 struct tui_locator_window : public tui_gen_win_info
@@ -334,60 +307,6 @@ public:
   bool is_highlighted = false;
 };
 
-/* The base class for all source-like windows, namely the source and
-   disassembly windows.  */
-
-struct tui_source_window_base : public tui_win_info
-{
-protected:
-  explicit tui_source_window_base (enum tui_win_type type);
-  ~tui_source_window_base () override;
-  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:
-
-  void clear_detail () override;
-
-  void make_visible (bool visible) override;
-  void refresh_window () 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.  */
-  void refill ();
-
-  /* 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;
-
-  void update_tab_width () override;
-
-  virtual bool location_matches_p (struct bp_location *loc, int line_no) = 0;
-
-  void reset (int height, int width,
-	      int origin_x, int origin_y) override;
-
-  /* Does the locator belong to this window?  */
-  bool m_has_locator = false;
-  /* Execution information window.  */
-  struct tui_exec_info_window *execution_info;
-  /* 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;
-
-  std::vector<tui_source_element> content;
-};
-
 extern int tui_win_is_auxiliary (enum tui_win_type win_type);
 
 
diff --git a/gdb/tui/tui-disasm.h b/gdb/tui/tui-disasm.h
index cc00d0018fa..19672a74df1 100644
--- a/gdb/tui/tui-disasm.h
+++ b/gdb/tui/tui-disasm.h
@@ -24,6 +24,7 @@
 
 #include "tui/tui.h"
 #include "tui/tui-data.h"
+#include "tui-winsource.h"
 
 /* A TUI disassembly window.  */
 
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index e171101e7fb..f0bac24bfea 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -291,12 +291,3 @@ tui_source_window::location_matches_p (struct bp_location *loc, int line_no)
 	  && filename_cmp (fullname,
 			   symtab_to_fullname (loc->symtab)) == 0);
 }
-
-void
-tui_source_window_base::reset (int height, int width,
-			       int origin_x, int origin_y)
-{
-  tui_gen_win_info::reset (height, width - 3,
-			   origin_x + 3, origin_y);
-  execution_info->reset (height, 3, origin_x, origin_y);
-}
diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
index 6faaa2e9e0f..063f3e6860e 100644
--- a/gdb/tui/tui-source.h
+++ b/gdb/tui/tui-source.h
@@ -23,6 +23,7 @@
 #define TUI_TUI_SOURCE_H
 
 #include "tui/tui-data.h"
+#include "tui-winsource.h"
 
 struct symtab;
 
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 227ab94bdc7..1e02c42dbd1 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -498,17 +498,6 @@ 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)
 {
@@ -899,19 +888,6 @@ unsigned int tui_tab_width = DEFAULT_TAB_LEN;
 
 static unsigned int internal_tab_width = DEFAULT_TAB_LEN;
 
-/* See tui-data.h.  */
-
-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.  */
-  make_invisible_and_set_new_height (height);
-  make_visible_with_new_height ();
-}
-
 /* After the tab width is set, call this to update the relevant
    windows.  */
 
@@ -1215,28 +1191,6 @@ 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)
-{
-  execution_info->make_visible (false);
-  execution_info->height = height;
-  execution_info->origin.y = origin.y;
-  if (height > 1)
-    execution_info->viewport_height = height - 1;
-  else
-    execution_info->viewport_height = height;
-  execution_info->viewport_height--;
-
-  if (m_has_locator)
-    {
-      tui_locator_window *gen_win_info = tui_locator_win_info_ptr ();
-      gen_win_info->make_visible (false);
-      gen_win_info->origin.y = origin.y + height;
-    }
-}
-
 /* See tui-data.h.  */
 
 void
@@ -1268,50 +1222,6 @@ tui_win_info::make_visible_with_new_height ()
 
 /* See tui-data.h.  */
 
-void
-tui_source_window_base::do_make_visible_with_new_height ()
-{
-  execution_info->make_visible (true);
-  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_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)
-	{
-	  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 (this, gdbarch, s, line, TRUE);
-    }
-  if (m_has_locator)
-    {
-      tui_locator_win_info_ptr ()->make_visible (true);
-      tui_show_locator_content ();
-    }
-}
-
-/* See tui-data.h.  */
-
 int
 tui_win_info::max_height () const
 {
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 5d632b6f97e..a2e48865761 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -166,15 +166,6 @@ tui_gen_win_info::make_visible (bool visible)
     }
 }
 
-/* See tui-data.h.  */
-
-void
-tui_source_window_base::make_visible (bool visible)
-{
-  execution_info->make_visible (visible);
-  tui_win_info::make_visible (visible);
-}
-
 /* Makes all windows invisible (except the command and locator
    windows).  */
 static void
@@ -196,15 +187,6 @@ tui_make_all_invisible (void)
   make_all_visible (false);
 }
 
-/* See tui-data.h.  */
-
-void
-tui_source_window_base::refresh_window ()
-{
-  execution_info->refresh_window ();
-  tui_win_info::refresh_window ();
-}
-
 /* Function to refresh all the windows currently displayed.  */
 
 void
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index d9f64251090..71147da2f91 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -300,6 +300,150 @@ tui_show_source_content (struct tui_source_window_base *win_info)
 
 /* See tui-data.h.  */
 
+void
+tui_source_window_base::clear_detail ()
+{
+  gdbarch = NULL;
+  start_line_or_addr.loa = LOA_ADDRESS;
+  start_line_or_addr.u.addr = 0;
+  horizontal_offset = 0;
+}
+
+tui_source_window_base::tui_source_window_base (enum tui_win_type type)
+  : tui_win_info (type),
+    execution_info (new tui_exec_info_window ())
+{
+  gdb_assert (type == SRC_WIN || type == DISASSEM_WIN);
+  start_line_or_addr.loa = LOA_ADDRESS;
+  start_line_or_addr.u.addr = 0;
+}
+
+
+tui_source_window_base::~tui_source_window_base ()
+{
+  xfree (fullname);
+  delete execution_info;
+}  
+
+void
+tui_source_window_base::reset (int height, int width,
+			       int origin_x, int origin_y)
+{
+  tui_gen_win_info::reset (height, width - 3,
+			   origin_x + 3, origin_y);
+  execution_info->reset (height, 3, origin_x, origin_y);
+}
+
+/* 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);
+}
+
+/* See tui-data.h.  */
+
+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.  */
+  make_invisible_and_set_new_height (height);
+  make_visible_with_new_height ();
+}
+
+/* See tui-data.h.  */
+
+void
+tui_source_window_base::set_new_height (int height)
+{
+  execution_info->make_visible (false);
+  execution_info->height = height;
+  execution_info->origin.y = origin.y;
+  if (height > 1)
+    execution_info->viewport_height = height - 1;
+  else
+    execution_info->viewport_height = height;
+  execution_info->viewport_height--;
+
+  if (m_has_locator)
+    {
+      tui_locator_window *gen_win_info = tui_locator_win_info_ptr ();
+      gen_win_info->make_visible (false);
+      gen_win_info->origin.y = origin.y + height;
+    }
+}
+
+/* See tui-data.h.  */
+
+void
+tui_source_window_base::do_make_visible_with_new_height ()
+{
+  execution_info->make_visible (true);
+  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_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)
+	{
+	  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 (this, gdbarch, s, line, TRUE);
+    }
+  if (m_has_locator)
+    {
+      tui_locator_win_info_ptr ()->make_visible (true);
+      tui_show_locator_content ();
+    }
+}
+
+/* See tui-data.h.  */
+
+void
+tui_source_window_base::make_visible (bool visible)
+{
+  execution_info->make_visible (visible);
+  tui_win_info::make_visible (visible);
+}
+
+/* See tui-data.h.  */
+
+void
+tui_source_window_base::refresh_window ()
+{
+  execution_info->refresh_window ();
+  tui_win_info::refresh_window ();
+}
+
+/* See tui-data.h.  */
+
 void
 tui_source_window_base::refill ()
 {
@@ -616,8 +760,3 @@ tui_addr_is_displayed (CORE_ADDR addr,
 
   return is_displayed;
 }
-
-
-/*****************************************
-** STATIC LOCAL FUNCTIONS               **
-******************************************/
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index a4907e6cc4e..ec44d1d2c02 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -24,7 +24,87 @@
 
 #include "tui/tui-data.h"
 
-struct tui_win_info;
+/* 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);
+
+  /* Return the contents.  */
+  const tui_exec_info_content *get_content () const
+  {
+    return m_content;
+  }
+
+private:
+
+  tui_exec_info_content *m_content = nullptr;
+};
+
+/* The base class for all source-like windows, namely the source and
+   disassembly windows.  */
+
+struct tui_source_window_base : public tui_win_info
+{
+protected:
+  explicit tui_source_window_base (enum tui_win_type type);
+  ~tui_source_window_base () override;
+  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:
+
+  void clear_detail () override;
+
+  void make_visible (bool visible) override;
+  void refresh_window () 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.  */
+  void refill ();
+
+  /* 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;
+
+  void update_tab_width () override;
+
+  virtual bool location_matches_p (struct bp_location *loc, int line_no) = 0;
+
+  void reset (int height, int width,
+	      int origin_x, int origin_y) override;
+
+  /* Does the locator belong to this window?  */
+  bool m_has_locator = false;
+  /* Execution information window.  */
+  struct tui_exec_info_window *execution_info;
+  /* 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;
+
+  std::vector<tui_source_element> content;
+};
 
 /* Update the execution windows to show the active breakpoints.  This
    is called whenever a breakpoint is inserted, removed or has its
-- 
2.17.2

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

* [PATCH 41/61] Clean up tui_layout_command
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (40 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 57/61] Move tui_source_window to tui-source.h Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 42/61] Simplify show_source_disasm_command Tom Tromey
                   ` (19 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_layout_command is a simple wrapper for tui_set_layout_by_name.
This removes the extra layer and cleans up the resulting function a
bit -- changing it to call error rather than return a result.  This
necessitated a small change to tui-regs.c, to avoid calling the
function that is being removed.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui.h (tui_set_layout_by_name): Don't declare.
	* tui/tui-regs.c (tui_reg_layout): New function.
	(tui_show_registers, tui_reg_command): Use it.
	* tui/tui-layout.c (LAYOUT_USAGE): Remove.
	(tui_layout_command): Rename from tui_set_layout_by_name.  Change
	parameters.
	(tui_layout_command): Remove.
---
 gdb/ChangeLog        | 10 +++++
 gdb/tui/tui-layout.c | 94 +++++++++++++++++---------------------------
 gdb/tui/tui-regs.c   | 18 ++++++++-
 gdb/tui/tui.h        |  3 --
 4 files changed, 61 insertions(+), 64 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 7feadd71ece..0ed7b29ce4b 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -61,8 +61,6 @@ static void extract_display_start_addr (struct gdbarch **, CORE_ADDR *);
 ** DEFINITIONS
 ***************************************/
 
-#define LAYOUT_USAGE     "Usage: layout prev | next | <layout_name> \n"
-
 /* Show the screen layout defined.  */
 static void
 show_layout (enum tui_layout_type layout)
@@ -361,63 +359,49 @@ Layout names are:\n\
 
 /* Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA, or
    REGS. */
-enum tui_status
-tui_set_layout_by_name (const char *layout_name)
+static void
+tui_layout_command (const char *layout_name, int from_tty)
 {
-  enum tui_status status = TUI_SUCCESS;
+  int i;
+  enum tui_layout_type new_layout = UNDEFINED_LAYOUT;
+  enum tui_layout_type cur_layout = tui_current_layout ();
 
-  if (layout_name != NULL)
-    {
-      int i;
-      enum tui_layout_type new_layout = UNDEFINED_LAYOUT;
-      enum tui_layout_type cur_layout = tui_current_layout ();
+  if (layout_name == NULL)
+    error (_("Usage: layout prev | next | LAYOUT-NAME"));
 
-      std::string copy = layout_name;
-      for (i = 0; i < copy.size (); i++)
-	copy[i] = toupper (copy[i]);
-      const char *buf_ptr = copy.c_str ();
+  std::string copy = layout_name;
+  for (i = 0; i < copy.size (); i++)
+    copy[i] = toupper (copy[i]);
+  const char *buf_ptr = copy.c_str ();
 
-      /* First check for ambiguous input.  */
-      if (strlen (buf_ptr) <= 1 && *buf_ptr == 'S')
-	{
-	  warning (_("Ambiguous command input."));
-	  status = TUI_FAILURE;
-	}
-      else
-	{
-	  if (subset_compare (buf_ptr, "SRC"))
-	    new_layout = SRC_COMMAND;
-	  else if (subset_compare (buf_ptr, "ASM"))
-	    new_layout = DISASSEM_COMMAND;
-	  else if (subset_compare (buf_ptr, "SPLIT"))
-	    new_layout = SRC_DISASSEM_COMMAND;
-	  else if (subset_compare (buf_ptr, "REGS"))
-	    {
-	      if (cur_layout == SRC_COMMAND
-		  || cur_layout == SRC_DATA_COMMAND)
-		new_layout = SRC_DATA_COMMAND;
-	      else
-		new_layout = DISASSEM_DATA_COMMAND;
-	    }
-	  else if (subset_compare (buf_ptr, "NEXT"))
-	    new_layout = next_layout ();
-	  else if (subset_compare (buf_ptr, "PREV"))
-	    new_layout = prev_layout ();
-	  else
-	    status = TUI_FAILURE;
+  /* First check for ambiguous input.  */
+  if (strlen (buf_ptr) <= 1 && *buf_ptr == 'S')
+    error (_("Ambiguous command input."));
 
-	  if (status == TUI_SUCCESS)
-	    {
-	      /* Make sure the curses mode is enabled.  */
-	      tui_enable ();
-	      tui_set_layout (new_layout);
-	    }
-	}
+  if (subset_compare (buf_ptr, "SRC"))
+    new_layout = SRC_COMMAND;
+  else if (subset_compare (buf_ptr, "ASM"))
+    new_layout = DISASSEM_COMMAND;
+  else if (subset_compare (buf_ptr, "SPLIT"))
+    new_layout = SRC_DISASSEM_COMMAND;
+  else if (subset_compare (buf_ptr, "REGS"))
+    {
+      if (cur_layout == SRC_COMMAND
+	  || cur_layout == SRC_DATA_COMMAND)
+	new_layout = SRC_DATA_COMMAND;
+      else
+	new_layout = DISASSEM_DATA_COMMAND;
     }
+  else if (subset_compare (buf_ptr, "NEXT"))
+    new_layout = next_layout ();
+  else if (subset_compare (buf_ptr, "PREV"))
+    new_layout = prev_layout ();
   else
-    status = TUI_FAILURE;
+    error (_("Unrecognized layout: %s"), layout_name);
 
-  return status;
+  /* Make sure the curses mode is enabled.  */
+  tui_enable ();
+  tui_set_layout (new_layout);
 }
 
 
@@ -456,14 +440,6 @@ extract_display_start_addr (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
 }
 
 
-static void
-tui_layout_command (const char *arg, int from_tty)
-{
-  /* Switch to the selected layout.  */
-  if (tui_set_layout_by_name (arg) != TUI_SUCCESS)
-    warning (_("Invalid layout specified.\n%s"), LAYOUT_USAGE);
-}
-
 /* Answer the previous layout to cycle to.  */
 static enum tui_layout_type
 next_layout (void)
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 31b252e2aa8..8ba517a6ac0 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -115,6 +115,20 @@ tui_data_window::first_reg_element_no_inline (int line_no) const
     return (-1);
 }
 
+/* A helper function to display the register window in the appropriate
+   way.  */
+
+static void
+tui_reg_layout ()
+{
+  enum tui_layout_type cur_layout = tui_current_layout ();
+  enum tui_layout_type new_layout;
+  if (cur_layout == SRC_COMMAND || cur_layout == SRC_DATA_COMMAND)
+    new_layout = SRC_DATA_COMMAND;
+  else
+    new_layout = DISASSEM_DATA_COMMAND;
+  tui_set_layout (new_layout);
+}
 
 /* Show the registers of the given group in the data window
    and refresh the window.  */
@@ -127,7 +141,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->is_visible)
-    tui_set_layout_by_name (DATA_NAME);
+    tui_reg_layout ();
 
   if (group == 0)
     group = general_reggroup;
@@ -520,7 +534,7 @@ tui_reg_command (const char *args, int from_tty)
 	 appropriate layout.  We need to do this before trying to run the
 	 'next' or 'prev' commands.  */
       if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->is_visible)
-	tui_set_layout_by_name (DATA_NAME);
+	tui_reg_layout ();
 
       struct reggroup *current_group = NULL;
       if (TUI_DATA_WIN != NULL)
diff --git a/gdb/tui/tui.h b/gdb/tui/tui.h
index 69ad60c98bf..76ab01443b7 100644
--- a/gdb/tui/tui.h
+++ b/gdb/tui/tui.h
@@ -90,7 +90,4 @@ extern int tui_active;
 
 extern void tui_show_source (const char *fullname, int line);
 
-/* tui-layout.c */
-extern enum tui_status tui_set_layout_by_name (const char *);
-
 #endif /* TUI_TUI_H */
-- 
2.17.2

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

* [PATCH 38/61] Remove the win_type parameter from tui_gen_win_info::reset
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (37 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 53/61] Move tui_dispatch_ctrl_char to tui-io.c Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 54/61] Move TUI command window code Tom Tromey
                   ` (22 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_gen_win_info::reset has a window type parameter that is only used
for an assertion.  This made sense as a defensive measure when window
creation was more dynamic -- it ensured that one did not make
mistakes.  However, there's no need for it any more, so this removes
it.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-source.c (tui_source_window_base::reset): Remove
	win_type parameter.
	* tui/tui-layout.c (make_command_window, make_source_window)
	(make_disasm_window, make_data_window)
	(show_source_disasm_command, show_data, tui_gen_win_info::reset)
	(reset_locator, show_source_or_disasm_and_command): Update.
	* tui/tui-data.h (struct tui_gen_win_info) <reset>: Remove
	win_type parameter.
	(struct tui_source_window_base) <reset>: Likewise.
---
 gdb/ChangeLog        | 12 ++++++++++++
 gdb/tui/tui-data.h   | 11 ++++-------
 gdb/tui/tui-layout.c | 42 +++++++++++++++---------------------------
 gdb/tui/tui-source.c |  7 +++----
 4 files changed, 34 insertions(+), 38 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 39c7f0c9d2f..3c34bd31961 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -58,11 +58,9 @@ public:
     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.  */
-  virtual void reset (enum tui_win_type win_type,
-		      int height, int width,
+  /* Reset this window.  The parameters are used to set the window's
+     size and position.  */
+  virtual void reset (int height, int width,
 		      int origin_x, int origin_y);
 
   /* Window handle.  */
@@ -393,8 +391,7 @@ public:
 
   virtual bool location_matches_p (struct bp_location *loc, int line_no) = 0;
 
-  void reset (enum tui_win_type win_type,
-	      int height, int width,
+  void reset (int height, int width,
 	      int origin_x, int origin_y) override;
 
   /* Does the locator belong to this window?  */
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index ab849a9813d..79c7996d19b 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -518,7 +518,7 @@ static struct tui_win_info *
 make_command_window (int height, int origin_y)
 {
   struct tui_win_info *result = new tui_cmd_window ();
-  result->reset (CMD_WIN, height, tui_term_width (), 0, origin_y);
+  result->reset (height, tui_term_width (), 0, origin_y);
   tui_make_window (result, DONT_BOX_WINDOW);
   return result;
 }
@@ -530,7 +530,7 @@ static struct tui_win_info *
 make_source_window (int height, int origin_y)
 {
   tui_win_info *result = new tui_source_window ();
-  result->reset (SRC_WIN, height, tui_term_width (), 0, origin_y);
+  result->reset (height, tui_term_width (), 0, origin_y);
   result->make_visible (true);
   return result;
 }
@@ -542,7 +542,7 @@ static struct tui_win_info *
 make_disasm_window (int height, int origin_y)
 {
   tui_win_info *result = new tui_disasm_window ();
-  result->reset (SRC_WIN, height, tui_term_width (), 0, origin_y);
+  result->reset (height, tui_term_width (), 0, origin_y);
   result->make_visible (true);
   return result;
 }
@@ -552,7 +552,7 @@ static tui_win_info *
 make_data_window (int height, int origin_y)
 {
   tui_win_info *result = new tui_data_window ();
-  result->reset (DATA_WIN, height, tui_term_width (), 0, origin_y);
+  result->reset (height, tui_term_width (), 0, origin_y);
   result->make_visible (true);
   return result;
 }
@@ -595,8 +595,7 @@ show_source_disasm_command (void)
 	tui_win_list[SRC_WIN] = make_source_window (src_height, 0);
       else
 	{
-	  TUI_SRC_WIN->reset (TUI_SRC_WIN->type,
-			      src_height,
+	  TUI_SRC_WIN->reset (src_height,
 			      tui_term_width (),
 			      0,
 			      0);
@@ -620,14 +619,12 @@ show_source_disasm_command (void)
 	}
       else
 	{
-	  locator->reset (LOCATOR_WIN,
-			  2 /* 1 */ ,
+	  locator->reset (2 /* 1 */ ,
 			  tui_term_width (),
 			  0,
 			  (src_height + asm_height) - 1);
 	  TUI_DISASM_WIN->m_has_locator = true;
-	  TUI_DISASM_WIN->reset (TUI_DISASM_WIN->type,
-				 asm_height,
+	  TUI_DISASM_WIN->reset (asm_height,
 				 tui_term_width (),
 				 0,
 				 src_height - 1);
@@ -644,8 +641,7 @@ show_source_disasm_command (void)
 	  = make_command_window (cmd_height, tui_term_height () - cmd_height);
       else
 	{
-	  TUI_CMD_WIN->reset (TUI_CMD_WIN->type,
-			      TUI_CMD_WIN->height,
+	  TUI_CMD_WIN->reset (TUI_CMD_WIN->height,
 			      TUI_CMD_WIN->width,
 			      0,
 			      TUI_CMD_WIN->origin.y);
@@ -702,14 +698,12 @@ show_data (enum tui_layout_type new_layout)
   else
     {
       base = (tui_source_window_base *) tui_win_list[win_type];
-      tui_win_list[win_type]->reset (tui_win_list[win_type]->type,
-				     src_height,
+      tui_win_list[win_type]->reset (src_height,
 				     tui_term_width (),
 				     0,
 				     data_height - 1);
       tui_make_visible (tui_win_list[win_type]);
-      locator->reset (LOCATOR_WIN,
-		      2 /* 1 */ ,
+      locator->reset (2 /* 1 */ ,
 		      tui_term_width (),
 		      0,
 		      total_height - 1);
@@ -723,14 +717,11 @@ show_data (enum tui_layout_type new_layout)
 }
 
 void
-tui_gen_win_info::reset (enum tui_win_type win_type,
-			 int height_, int width_,
+tui_gen_win_info::reset (int height_, int width_,
 			 int origin_x_, int origin_y_)
 {
   int h = height_;
 
-  gdb_assert (type == win_type);
-
   width = width_;
   height = h;
   if (h > 1)
@@ -750,7 +741,7 @@ reset_locator (tui_gen_win_info *win_info,
 	       int height, int width, 
 	       int origin_x, int origin_y)
 {
-  win_info->reset (LOCATOR_WIN, height, width, origin_x, origin_y);
+  win_info->reset (height, width, origin_x, origin_y);
   tui_make_window (win_info, DONT_BOX_WINDOW);
 }
 
@@ -794,14 +785,12 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
       else
 	{
 	  base = (tui_source_window_base *) *win_info_ptr;
-	  locator->reset (LOCATOR_WIN,
-			  2 /* 1 */ ,
+	  locator->reset (2 /* 1 */ ,
 			  tui_term_width (),
 			  0,
 			  src_height - 1);
 	  base->m_has_locator = true;
-	  (*win_info_ptr)->reset ((*win_info_ptr)->type,
-				  src_height - 1,
+	  (*win_info_ptr)->reset (src_height - 1,
 				  tui_term_width (),
 				  0,
 				  0);
@@ -820,8 +809,7 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 	}
       else
 	{
-	  TUI_CMD_WIN->reset (TUI_CMD_WIN->type,
-			      TUI_CMD_WIN->height,
+	  TUI_CMD_WIN->reset (TUI_CMD_WIN->height,
 			      TUI_CMD_WIN->width,
 			      TUI_CMD_WIN->origin.x,
 			      TUI_CMD_WIN->origin.y);
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 873612fecce..e171101e7fb 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -293,11 +293,10 @@ tui_source_window::location_matches_p (struct bp_location *loc, int line_no)
 }
 
 void
-tui_source_window_base::reset (enum tui_win_type win_type,
-			       int height, int width,
+tui_source_window_base::reset (int height, int width,
 			       int origin_x, int origin_y)
 {
-  tui_gen_win_info::reset (win_type, height, width - 3,
+  tui_gen_win_info::reset (height, width - 3,
 			   origin_x + 3, origin_y);
-  execution_info->reset (EXEC_INFO_WIN, height, 3, origin_x, origin_y);
+  execution_info->reset (height, 3, origin_x, origin_y);
 }
-- 
2.17.2

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

* [PATCH 42/61] Simplify show_source_disasm_command
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (41 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 41/61] Clean up tui_layout_command Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 26/61] Add win_info parameter to tui_set_disassem_content Tom Tromey
                   ` (18 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This is the first of a few patches to further simplify window
(re-)initialization in tui-layout.c.  When changing the layout, a
window may be created or, if it already exists, simply resized.  These
two cases normally are identical, but this was obscured by the way the
code was written.  This patch changes show_source_disasm_command to
unify the creation and re-initialization cases.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (show_source_disasm_command): Simplify window
	resetting.
---
 gdb/ChangeLog        |  5 +++++
 gdb/tui/tui-layout.c | 48 ++++++++++++++++----------------------------
 2 files changed, 22 insertions(+), 31 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 0ed7b29ce4b..4e914b79ea0 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -559,43 +559,29 @@ show_source_disasm_command (void)
       asm_height = tui_term_height () - (src_height + cmd_height);
 
       if (TUI_SRC_WIN == NULL)
-	tui_win_list[SRC_WIN] = make_source_window (src_height, 0);
-      else
-	{
-	  TUI_SRC_WIN->reset (src_height,
-			      tui_term_width (),
-			      0,
-			      0);
-	  tui_make_visible (TUI_SRC_WIN);
-	  TUI_SRC_WIN->m_has_locator = false;
-	}
+	tui_win_list[SRC_WIN] = new tui_source_window ();
+      TUI_SRC_WIN->reset (src_height,
+			  tui_term_width (),
+			  0,
+			  0);
+      tui_make_visible (TUI_SRC_WIN);
+      TUI_SRC_WIN->m_has_locator = false;
 
       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->reset (2 /* 1 */ ,
-			  tui_term_width (),
-			  0,
-			  (src_height + asm_height) - 1);
-	}
-      else
-	{
-	  locator->reset (2 /* 1 */ ,
-			  tui_term_width (),
-			  0,
-			  (src_height + asm_height) - 1);
-	  TUI_DISASM_WIN->m_has_locator = true;
-	  TUI_DISASM_WIN->reset (asm_height,
-				 tui_term_width (),
-				 0,
-				 src_height - 1);
-	  tui_make_visible (TUI_DISASM_WIN);
-	}
+	tui_win_list[DISASSEM_WIN] = new tui_disasm_window ();
+      TUI_DISASM_WIN->reset (asm_height,
+			     tui_term_width (),
+			     0,
+			     src_height - 1);
+      tui_make_visible (TUI_DISASM_WIN);
+      locator->reset (2 /* 1 */ ,
+		      tui_term_width (),
+		      0,
+		      (src_height + asm_height) - 1);
       TUI_SRC_WIN->m_has_locator = false;
       TUI_DISASM_WIN->m_has_locator = true;
       tui_make_visible (locator);
-- 
2.17.2

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

* [PATCH 19/61] Minor tui_reg_next / tui_reg_prev cleanup
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (50 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 44/61] Change tui_get_register to return void Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 51/61] Fix flushing bug in tui_puts_internal Tom Tromey
                   ` (9 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes tui_reg_next and tui_reg_prev so that they don't need to
reference the TUI_DATA_WIN globals.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.c (tui_reg_next, tui_reg_prev): Add "current_group"
	parameter.  Don't reference globals.
	(tui_reg_command): Update.
---
 gdb/ChangeLog      |  6 ++++++
 gdb/tui/tui-regs.c | 21 +++++++++++----------
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 931787ae4b5..31b252e2aa8 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -468,14 +468,13 @@ tui_display_register (struct tui_data_item_window *data)
    register window is not currently being displayed.  */
 
 static struct reggroup *
-tui_reg_next (struct gdbarch *gdbarch)
+tui_reg_next (struct reggroup *current_group, struct gdbarch *gdbarch)
 {
   struct reggroup *group = NULL;
 
-  if (TUI_DATA_WIN != NULL)
+  if (current_group != NULL)
     {
-      group = TUI_DATA_WIN->current_group;
-      group = reggroup_next (gdbarch, group);
+      group = reggroup_next (gdbarch, current_group);
       if (group == NULL)
         group = reggroup_next (gdbarch, NULL);
     }
@@ -487,14 +486,13 @@ tui_reg_next (struct gdbarch *gdbarch)
    register window is not currently being displayed.  */
 
 static struct reggroup *
-tui_reg_prev (struct gdbarch *gdbarch)
+tui_reg_prev (struct reggroup *current_group, struct gdbarch *gdbarch)
 {
   struct reggroup *group = NULL;
 
-  if (TUI_DATA_WIN != NULL)
+  if (current_group != NULL)
     {
-      group = TUI_DATA_WIN->current_group;
-      group = reggroup_prev (gdbarch, group);
+      group = reggroup_prev (gdbarch, current_group);
       if (group == NULL)
 	group = reggroup_prev (gdbarch, NULL);
     }
@@ -524,10 +522,13 @@ tui_reg_command (const char *args, int from_tty)
       if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->is_visible)
 	tui_set_layout_by_name (DATA_NAME);
 
+      struct reggroup *current_group = NULL;
+      if (TUI_DATA_WIN != NULL)
+	current_group = TUI_DATA_WIN->current_group;
       if (strncmp (args, "next", len) == 0)
-	match = tui_reg_next (gdbarch);
+	match = tui_reg_next (current_group, gdbarch);
       else if (strncmp (args, "prev", len) == 0)
-	match = tui_reg_prev (gdbarch);
+	match = tui_reg_prev (current_group, gdbarch);
 
       /* This loop matches on the initial part of a register group
 	 name.  If this initial part in ARGS matches only one register
-- 
2.17.2

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

* [PATCH 57/61] Move tui_source_window to tui-source.h
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (39 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 54/61] Move TUI command window code Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 41/61] Clean up tui_layout_command Tom Tromey
                   ` (20 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves tui_source_window to tui-source.h.  In this case there were
no method definitions to be moved.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui.c: Update.
	* tui/tui-source.h (struct tui_source_window): Move from
	tui-data.h.
	* tui/tui-layout.c: Update.
	* tui/tui-disasm.c: Update.
	* tui/tui-data.h (struct tui_source_window): Move to
	tui-source.h.
---
 gdb/ChangeLog        | 10 ++++++++++
 gdb/tui/tui-data.h   | 31 +------------------------------
 gdb/tui/tui-disasm.c |  1 +
 gdb/tui/tui-layout.c |  1 +
 gdb/tui/tui-source.h | 31 ++++++++++++++++++++++++++++++-
 gdb/tui/tui.c        |  1 +
 6 files changed, 44 insertions(+), 31 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 3446d51b8dc..0d984ad3b4c 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -27,6 +27,7 @@
 #include "observable.h"
 
 struct tui_cmd_window;
+struct tui_source_window;
 
 /* This is a point definition.  */
 struct tui_point
@@ -382,36 +383,6 @@ public:
   std::vector<tui_source_element> content;
 };
 
-/* A TUI source window.  */
-
-struct tui_source_window : public tui_source_window_base
-{
-  tui_source_window ();
-  ~tui_source_window ();
-
-  DISABLE_COPY_AND_ASSIGN (tui_source_window);
-
-  const char *name () const override
-  {
-    return SRC_NAME;
-  }
-
-  bool location_matches_p (struct bp_location *loc, int line_no) override;
-
-  bool showing_source_p (const char *filename) const;
-
-protected:
-
-  void do_scroll_vertical (int num_to_scroll) override;
-
-private:
-
-  void style_changed ();
-
-  /* A token used to register and unregister an observer.  */
-  gdb::observers::token m_observable;
-};
-
 extern int tui_win_is_auxiliary (enum tui_win_type win_type);
 
 
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index a644c287cab..effe8e74528 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -35,6 +35,7 @@
 #include "tui/tui-stack.h"
 #include "tui/tui-file.h"
 #include "tui/tui-disasm.h"
+#include "tui/tui-source.h"
 #include "progspace.h"
 #include "objfiles.h"
 
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 2e67ed15238..a5709c595f3 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -37,6 +37,7 @@
 #include "tui/tui-winsource.h"
 #include "tui/tui-disasm.h"
 #include "tui/tui-layout.h"
+#include "tui/tui-source.h"
 #include "gdb_curses.h"
 
 /*******************************
diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
index fc129ab8f26..6faaa2e9e0f 100644
--- a/gdb/tui/tui-source.h
+++ b/gdb/tui/tui-source.h
@@ -25,7 +25,36 @@
 #include "tui/tui-data.h"
 
 struct symtab;
-struct tui_win_info;
+
+/* A TUI source window.  */
+
+struct tui_source_window : public tui_source_window_base
+{
+  tui_source_window ();
+  ~tui_source_window ();
+
+  DISABLE_COPY_AND_ASSIGN (tui_source_window);
+
+  const char *name () const override
+  {
+    return SRC_NAME;
+  }
+
+  bool location_matches_p (struct bp_location *loc, int line_no) override;
+
+  bool showing_source_p (const char *filename) const;
+
+protected:
+
+  void do_scroll_vertical (int num_to_scroll) override;
+
+private:
+
+  void style_changed ();
+
+  /* A token used to register and unregister an observer.  */
+  gdb::observers::token m_observable;
+};
 
 extern enum tui_status tui_set_source_content (tui_source_window_base *,
 					       struct symtab *, 
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index 22de9a70b82..b15eb32af5e 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -31,6 +31,7 @@
 #include "tui/tui-stack.h"
 #include "tui/tui-win.h"
 #include "tui/tui-winsource.h"
+#include "tui/tui-source.h"
 #include "target.h"
 #include "frame.h"
 #include "breakpoint.h"
-- 
2.17.2

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

* [PATCH 44/61] Change tui_get_register to return void
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (49 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 43/61] Simplify tui_gen_win_info::make_visible Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 19/61] Minor tui_reg_next / tui_reg_prev cleanup Tom Tromey
                   ` (10 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_get_register returns a tui_status, but nothing checks this, so it
can return void instead.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.c (tui_get_register): Return void.
---
 gdb/ChangeLog      |  4 ++++
 gdb/tui/tui-regs.c | 13 ++++---------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 8ba517a6ac0..c6ed19d4295 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -54,9 +54,9 @@ static void tui_show_register_group (tui_data_window *win_info,
 				     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,
-					 int regnum, bool *changedp);
+static void tui_get_register (struct frame_info *frame,
+			      struct tui_data_item_window *data,
+			      int regnum, bool *changedp);
 
 
 
@@ -654,13 +654,11 @@ tui_register_format (struct frame_info *frame, int regnum)
 /* Get the register value from the given frame and format it for the
    display.  When changep is set, check if the new register value has
    changed with respect to the previous call.  */
-static enum tui_status
+static void
 tui_get_register (struct frame_info *frame,
                   struct tui_data_item_window *data, 
 		  int regnum, bool *changedp)
 {
-  enum tui_status ret = TUI_FAILURE;
-
   if (changedp)
     *changedp = false;
   if (target_has_registers)
@@ -674,8 +672,5 @@ tui_get_register (struct frame_info *frame,
 	*changedp = true;
 
       xfree (prev_content);
-
-      ret = TUI_SUCCESS;
     }
-  return ret;
 }
-- 
2.17.2

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

* [PATCH 61/61] Remove unnecessary "return"s
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (56 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 45/61] Simplify show_source_or_disasm_and_command Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-17 12:37   ` Pedro Alves
  2019-07-04 17:04 ` [PATCH 46/61] Remove make_command_window Tom Tromey
                   ` (3 subsequent siblings)
  61 siblings, 1 reply; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The TUI has some "return;" statements at the end of void-returning
functions.  There's no need for these, so this patch removes them.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_update_source_window)
	(tui_update_source_window_as_is)
	(tui_update_source_windows_with_line): Remove return.
	* tui/tui-disasm.c (tui_show_disassem)
	(tui_show_disassem_and_update_source): Remove return.
	* tui/tui.c (tui_reset): Remove return.
	* tui/tui-wingeneral.c
	(tui_check_and_display_highlight_if_needed): Remove return.
---
 gdb/ChangeLog            | 11 +++++++++++
 gdb/tui/tui-disasm.c     |  5 +----
 gdb/tui/tui-wingeneral.c |  1 -
 gdb/tui/tui-winsource.c  |  7 -------
 gdb/tui/tui.c            |  2 --
 5 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index effe8e74528..17587809bcb 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -265,8 +265,6 @@ tui_show_disassem (struct gdbarch *gdbarch, CORE_ADDR start_addr)
   if (tui_current_layout () != SRC_DISASSEM_COMMAND 
       && win_with_focus == TUI_SRC_WIN)
     tui_set_win_focus_to (TUI_DISASM_WIN);
-
-  return;
 }
 
 
@@ -293,12 +291,11 @@ tui_show_disassem_and_update_source (struct gdbarch *gdbarch,
 	{
 	  set_current_source_symtab_and_line (sal);
 	  tui_update_locator_fullname (symtab_to_fullname (sal.symtab));
+
 	}
       else
 	tui_update_locator_fullname ("?");
     }
-
-  return;
 }
 
 void
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index a2e48865761..dc556317297 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -122,7 +122,6 @@ tui_check_and_display_highlight_if_needed (struct tui_win_info *win_info)
 	tui_unhighlight_win (win_info);
 
     }
-  return;
 }
 
 
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 71147da2f91..3de2692deea 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -77,8 +77,6 @@ tui_update_source_window (struct tui_source_window_base *win_info,
 {
   win_info->horizontal_offset = 0;
   tui_update_source_window_as_is (win_info, gdbarch, s, line_or_addr, noerror);
-
-  return;
 }
 
 
@@ -125,9 +123,6 @@ tui_update_source_window_as_is (struct tui_source_window_base *win_info,
 	    tui_set_win_focus_to (win_info);
 	}
     }
-
-
-  return;
 }
 
 
@@ -200,8 +195,6 @@ tui_update_source_windows_with_line (struct symtab *s, int line)
 	}
       break;
     }
-
-  return;
 }
 
 void
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index b15eb32af5e..e0eb12fb833 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -630,8 +630,6 @@ tui_reset (void)
 #endif /* CBREAK */
 		     | VTDELAY | ALLDELAY);
   mode.sg_flags |= XTABS | ECHO | CRMOD | ANYP;
-
-  return;
 }
 #endif
 
-- 
2.17.2

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

* [PATCH 35/61] Remove some dead code from tui_set_layout
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (52 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 51/61] Fix flushing bug in tui_puts_internal Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 30/61] Simplify source window clearing Tom Tromey
                   ` (7 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_set_layout sets regs_populate using:

      regs_populate = (new_layout == SRC_DATA_COMMAND
		       || new_layout == DISASSEM_DATA_COMMAND);

Then later it checks this variable:

	  if (!regs_populate
	      && (new_layout == SRC_DATA_COMMAND
		  || new_layout == DISASSEM_DATA_COMMAND))

However, this is equivalent to "!regs_populate && regs_populate",
which can never be true.  So, remove the dead code and the variable.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (tui_set_layout): Remove regs_populate
	variable.
---
 gdb/ChangeLog        |  5 +++++
 gdb/tui/tui-layout.c | 17 ++++-------------
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index a02c157b87e..ac0d01c990a 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -127,9 +127,7 @@ tui_set_layout (enum tui_layout_type layout_type)
 
   if (layout_type != UNDEFINED_LAYOUT)
     {
-      enum tui_layout_type cur_layout = tui_current_layout (),
-	new_layout = UNDEFINED_LAYOUT;
-      int regs_populate = FALSE;
+      enum tui_layout_type cur_layout = tui_current_layout ();
       struct gdbarch *gdbarch;
       CORE_ADDR addr;
       struct tui_win_info *win_with_focus = tui_win_with_focus ();
@@ -137,10 +135,8 @@ tui_set_layout (enum tui_layout_type layout_type)
 
       extract_display_start_addr (&gdbarch, &addr);
 
-      new_layout = layout_type;
+      enum tui_layout_type new_layout = layout_type;
 
-      regs_populate = (new_layout == SRC_DATA_COMMAND
-		       || new_layout == DISASSEM_DATA_COMMAND);
       if (new_layout != cur_layout)
 	{
 	  show_layout (new_layout);
@@ -212,14 +208,9 @@ tui_set_layout (enum tui_layout_type layout_type)
 	  /*
 	   * Now update the window content.
 	   */
-	  if (!regs_populate
-	      && (new_layout == SRC_DATA_COMMAND
-		  || new_layout == DISASSEM_DATA_COMMAND))
-	    TUI_DATA_WIN->display_all_data ();
-
 	  tui_update_source_windows_with_addr (gdbarch, addr);
-
-	  if (regs_populate)
+	  if (new_layout == SRC_DATA_COMMAND
+	      || new_layout == DISASSEM_DATA_COMMAND)
 	    tui_show_registers (TUI_DATA_WIN->current_group);
 	}
     }
-- 
2.17.2

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

* [PATCH 49/61] Remove tui_make_visible and tui_make_invisible
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (33 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 05/61] Remove deleted breakpoint from TUI display Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:04 ` [PATCH 58/61] Change make_invisible_and_set_new_height to be a method Tom Tromey
                   ` (26 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tui_make_visible and tui_make_invisible are just wrappers for a method
call, so remove them and have the callers simply make the method call
themselves.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.h (tui_make_visible, tui_make_invisible):
	Don't declare.
	* tui/tui-wingeneral.c (tui_make_visible, tui_make_invisible):
	Remove.
	* tui/tui-win.c (tui_source_window_base::set_new_height)
	(tui_source_window_base::set_new_height)
	(make_invisible_and_set_new_height)
	(tui_source_window_base::do_make_visible_with_new_height)
	(tui_source_window_base::do_make_visible_with_new_height):
	Update.
	* tui/tui-layout.c (show_source_disasm_command, show_data)
	(show_source_or_disasm_and_command): Update.
	* tui/tui-layout.c (show_layout): Update.
---
 gdb/ChangeLog            | 16 ++++++++++++++++
 gdb/tui/tui-layout.c     | 16 ++++++++--------
 gdb/tui/tui-win.c        | 10 +++++-----
 gdb/tui/tui-wingeneral.c | 12 ------------
 gdb/tui/tui-wingeneral.h |  2 --
 5 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 7478c2c966a..4869cd9a11a 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -80,7 +80,7 @@ show_layout (enum tui_layout_type layout)
 	{
 	  /* First make the current layout be invisible.  */
 	  tui_make_all_invisible ();
-	  tui_make_invisible (tui_locator_win_info_ptr ());
+	  tui_locator_win_info_ptr ()->make_visible (false);
 
 	  switch (layout)
 	    {
@@ -514,7 +514,7 @@ show_source_disasm_command (void)
 			  tui_term_width (),
 			  0,
 			  0);
-      tui_make_visible (TUI_SRC_WIN);
+      TUI_SRC_WIN->make_visible (true);
       TUI_SRC_WIN->m_has_locator = false;
 
       struct tui_locator_window *locator = tui_locator_win_info_ptr ();
@@ -527,14 +527,14 @@ show_source_disasm_command (void)
 			     tui_term_width (),
 			     0,
 			     src_height - 1);
-      tui_make_visible (TUI_DISASM_WIN);
+      TUI_DISASM_WIN->make_visible (true);
       locator->reset (2 /* 1 */ ,
 		      tui_term_width (),
 		      0,
 		      (src_height + asm_height) - 1);
       TUI_SRC_WIN->m_has_locator = false;
       TUI_DISASM_WIN->m_has_locator = true;
-      tui_make_visible (locator);
+      locator->make_visible (true);
       tui_show_locator_content ();
       tui_show_source_content (TUI_DISASM_WIN);
 
@@ -567,7 +567,7 @@ show_data (enum tui_layout_type new_layout)
   data_height = total_height / 2;
   src_height = total_height - data_height;
   tui_make_all_invisible ();
-  tui_make_invisible (locator);
+  locator->make_visible (false);
   if (tui_win_list[DATA_WIN] == nullptr)
     tui_win_list[DATA_WIN] = new tui_data_window ();
   tui_win_list[DATA_WIN]->reset (data_height, tui_term_width (), 0, 0);
@@ -598,7 +598,7 @@ show_data (enum tui_layout_type new_layout)
 		  total_height - 1);
   base->make_visible (true);
   base->m_has_locator = true;
-  tui_make_visible (locator);
+  locator->make_visible (true);
   tui_show_locator_content ();
   tui_add_to_source_windows (base);
   tui_set_current_layout_to (new_layout);
@@ -662,11 +662,11 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 		       tui_term_width (),
 		       0,
 		       0);
-      tui_make_visible (win_info);
+      win_info->make_visible (true);
 
 
       win_info->m_has_locator = true;
-      tui_make_visible (locator);
+      locator->make_visible (true);
       tui_show_locator_content ();
       tui_show_source_content (win_info);
 
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 9d9d9a5f577..c92a706efc6 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -1226,7 +1226,7 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
 void
 tui_source_window_base::set_new_height (int height)
 {
-  tui_make_invisible (execution_info);
+  execution_info->make_visible (false);
   execution_info->height = height;
   execution_info->origin.y = origin.y;
   if (height > 1)
@@ -1238,7 +1238,7 @@ tui_source_window_base::set_new_height (int height)
   if (has_locator ())
     {
       tui_locator_window *gen_win_info = tui_locator_win_info_ptr ();
-      tui_make_invisible (gen_win_info);
+      gen_win_info->make_visible (false);
       gen_win_info->origin.y = origin.y + height;
     }
 }
@@ -1263,7 +1263,7 @@ static void
 make_invisible_and_set_new_height (struct tui_win_info *win_info, 
 				   int height)
 {
-  tui_make_invisible (win_info);
+  win_info->make_visible (false);
   win_info->height = height;
   if (height > 1)
     win_info->viewport_height = height - 1;
@@ -1292,7 +1292,7 @@ tui_win_info::make_visible_with_new_height ()
 void
 tui_source_window_base::do_make_visible_with_new_height ()
 {
-  tui_make_visible (execution_info);
+  execution_info->make_visible (true);
   if (!content.empty ())
     {
       struct tui_line_or_address line_or_addr;
@@ -1326,7 +1326,7 @@ tui_source_window_base::do_make_visible_with_new_height ()
     }
   if (has_locator ())
     {
-      tui_make_visible (tui_locator_win_info_ptr ());
+      tui_locator_win_info_ptr ()->make_visible (true);
       tui_show_locator_content ();
     }
 }
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 4e6637e8687..2fb8d6c684f 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -179,18 +179,6 @@ tui_gen_win_info::make_visible (bool visible)
     }
 }
 
-void
-tui_make_visible (struct tui_gen_win_info *win_info)
-{
-  win_info->make_visible (true);
-}
-
-void
-tui_make_invisible (struct tui_gen_win_info *win_info)
-{
-  win_info->make_visible (false);
-}
-
 /* See tui-data.h.  */
 
 void
diff --git a/gdb/tui/tui-wingeneral.h b/gdb/tui/tui-wingeneral.h
index 20b7f21c7c0..5e6198d4366 100644
--- a/gdb/tui/tui-wingeneral.h
+++ b/gdb/tui/tui-wingeneral.h
@@ -28,8 +28,6 @@ struct tui_win_info;
 struct tui_gen_win_info;
 
 extern void tui_unhighlight_win (struct tui_win_info *);
-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 *, enum tui_box);
-- 
2.17.2

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

* [PATCH 46/61] Remove make_command_window
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (57 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 61/61] Remove unnecessary "return"s Tom Tromey
@ 2019-07-04 17:04 ` Tom Tromey
  2019-07-04 17:26 ` [PATCH 47/61] Remove make_source_window and make_disasm_window Tom Tromey
                   ` (2 subsequent siblings)
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This unifies the creation and re-initialization cases for the command
window.  When this is done, it becomes clear that make_command_window
isn't needed -- it can be replaced with a simple "new", so this is
removed as well.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (make_command_window): Remove.
	(show_source_disasm_command, show_source_or_disasm_and_command):
	Unify creation and re-initialization cases.
---
 gdb/ChangeLog        |  6 ++++++
 gdb/tui/tui-layout.c | 50 ++++++++++++++------------------------------
 2 files changed, 22 insertions(+), 34 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 83eb0dfeb46..3c263604e82 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -44,7 +44,6 @@
 ********************************/
 static void show_layout (enum tui_layout_type);
 static void show_source_or_disasm_and_command (enum tui_layout_type);
-static struct tui_win_info *make_command_window (int, int);
 static struct tui_win_info *make_source_window (int, int);
 static struct tui_win_info *make_disasm_window (int, int);
 static void show_source_command (void);
@@ -480,17 +479,6 @@ prev_layout (void)
 }
 
 
-
-static struct tui_win_info *
-make_command_window (int height, int origin_y)
-{
-  struct tui_win_info *result = new tui_cmd_window ();
-  result->reset (height, tui_term_width (), 0, origin_y);
-  tui_make_window (result, DONT_BOX_WINDOW);
-  return result;
-}
-
-
 /* make_source_window().
  */
 static struct tui_win_info *
@@ -589,16 +577,14 @@ show_source_disasm_command (void)
       tui_show_source_content (TUI_DISASM_WIN);
 
       if (TUI_CMD_WIN == NULL)
-	tui_win_list[CMD_WIN]
-	  = make_command_window (cmd_height, tui_term_height () - cmd_height);
-      else
-	{
-	  TUI_CMD_WIN->reset (TUI_CMD_WIN->height,
-			      TUI_CMD_WIN->width,
-			      0,
-			      TUI_CMD_WIN->origin.y);
-	  tui_make_visible (TUI_CMD_WIN);
-	}
+	tui_win_list[CMD_WIN] = new tui_cmd_window ();
+      TUI_CMD_WIN->reset (cmd_height,
+			  tui_term_width (),
+			  0,
+			  tui_term_height () - cmd_height);
+      /* FIXME tui_cmd_window won't recreate the handle on
+	 make_visible, so we need this instead.  */
+      tui_make_window (TUI_CMD_WIN, DONT_BOX_WINDOW);
       tui_set_current_layout_to (SRC_DISASSEM_COMMAND);
     }
 }
@@ -734,18 +720,14 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
       tui_show_source_content (win_info);
 
       if (TUI_CMD_WIN == NULL)
-	{
-	  tui_win_list[CMD_WIN] = make_command_window (cmd_height,
-						       src_height);
-	}
-      else
-	{
-	  TUI_CMD_WIN->reset (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_win_list[CMD_WIN] = new tui_cmd_window ();
+      TUI_CMD_WIN->reset (cmd_height,
+			  tui_term_width (),
+			  0,
+			  src_height);
+      /* FIXME tui_cmd_window won't recreate the handle on
+	 make_visible, so we need this instead.  */
+      tui_make_window (TUI_CMD_WIN, DONT_BOX_WINDOW);
       tui_set_current_layout_to (layout_type);
     }
 }
-- 
2.17.2

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

* [PATCH 47/61] Remove make_source_window and make_disasm_window
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (58 preceding siblings ...)
  2019-07-04 17:04 ` [PATCH 46/61] Remove make_command_window Tom Tromey
@ 2019-07-04 17:26 ` Tom Tromey
  2019-07-04 17:26 ` [PATCH 50/61] Remove has_locator method Tom Tromey
  2019-07-17 12:41 ` [PATCH 00/61] More TUI refactorings Pedro Alves
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This unifies the remaining creation and re-initialization cases for
the source and disassembly windows.  Once this is done, it's clear
that make_source_window and make_disasm_window aren't needed any more,
so remove them.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (make_source_window, make_disasm_window):
	Remove.
	(show_data): Unify creation and re-initialization cases.
---
 gdb/ChangeLog        |  6 ++++
 gdb/tui/tui-layout.c | 66 ++++++++++----------------------------------
 2 files changed, 21 insertions(+), 51 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 3c263604e82..b1f784609d5 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -44,8 +44,6 @@
 ********************************/
 static void show_layout (enum tui_layout_type);
 static void show_source_or_disasm_and_command (enum tui_layout_type);
-static struct tui_win_info *make_source_window (int, int);
-static struct tui_win_info *make_disasm_window (int, int);
 static void show_source_command (void);
 static void show_disasm_command (void);
 static void show_source_disasm_command (void);
@@ -479,30 +477,6 @@ prev_layout (void)
 }
 
 
-/* make_source_window().
- */
-static struct tui_win_info *
-make_source_window (int height, int origin_y)
-{
-  tui_win_info *result = new tui_source_window ();
-  result->reset (height, tui_term_width (), 0, origin_y);
-  result->make_visible (true);
-  return result;
-}
-
-
-/* make_disasm_window().
- */
-static struct tui_win_info *
-make_disasm_window (int height, int origin_y)
-{
-  tui_win_info *result = new tui_disasm_window ();
-  result->reset (height, tui_term_width (), 0, origin_y);
-  result->make_visible (true);
-  return result;
-}
-
-
 static tui_win_info *
 make_data_window (int height, int origin_y)
 {
@@ -617,39 +591,29 @@ show_data (enum tui_layout_type new_layout)
   else
     win_type = DISASSEM_WIN;
 
-  tui_source_window_base *base;
   if (tui_win_list[win_type] == NULL)
     {
       if (win_type == SRC_WIN)
-	tui_win_list[win_type]
-	  = make_source_window (src_height, data_height - 1);
+	tui_win_list[win_type] = new tui_source_window ();
       else
-	tui_win_list[win_type]
-	  = make_disasm_window (src_height, data_height - 1);
-      locator->reset (2 /* 1 */ ,
-		      tui_term_width (),
-		      0,
-		      total_height - 1);
-      base = (tui_source_window_base *) tui_win_list[win_type];
-    }
-  else
-    {
-      base = (tui_source_window_base *) tui_win_list[win_type];
-      tui_win_list[win_type]->reset (src_height,
-				     tui_term_width (),
-				     0,
-				     data_height - 1);
-      tui_make_visible (tui_win_list[win_type]);
-      locator->reset (2 /* 1 */ ,
-		      tui_term_width (),
-		      0,
-		      total_height - 1);
+	tui_win_list[win_type] = new tui_disasm_window ();
     }
+
+  tui_source_window_base *base
+    = (tui_source_window_base *) tui_win_list[win_type];
+  tui_win_list[win_type]->reset (src_height,
+				 tui_term_width (),
+				 0,
+				 data_height - 1);
+  locator->reset (2 /* 1 */ ,
+		  tui_term_width (),
+		  0,
+		  total_height - 1);
+  base->make_visible (true);
   base->m_has_locator = true;
   tui_make_visible (locator);
   tui_show_locator_content ();
-  tui_add_to_source_windows
-    ((tui_source_window_base *) tui_win_list[win_type]);
+  tui_add_to_source_windows (base);
   tui_set_current_layout_to (new_layout);
 }
 
-- 
2.17.2

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

* [PATCH 50/61] Remove has_locator method
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (59 preceding siblings ...)
  2019-07-04 17:26 ` [PATCH 47/61] Remove make_source_window and make_disasm_window Tom Tromey
@ 2019-07-04 17:26 ` Tom Tromey
  2019-07-17 12:41 ` [PATCH 00/61] More TUI refactorings Pedro Alves
  61 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-04 17:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Earlier changes made it obvious that the has_locator method can only
be called for source/disassembly windows.  Because the only reference
to this now occurs in methods on this object, we can remove the
has_locator method entirely, in favor of using the member directly.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (tui_source_window_base::set_new_height)
	(tui_source_window_base::do_make_visible_with_new_height): Use
	m_has_locator field directly.
	* tui/tui-data.h (struct tui_win_info) <has_locator>: Remove
	method.
	(struct tui_source_window_base) <has_locator>: Likewise.
---
 gdb/ChangeLog      |  9 +++++++++
 gdb/tui/tui-data.h | 12 ------------
 gdb/tui/tui-win.c  |  4 ++--
 3 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 3c34bd31961..a95f4272e57 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -295,12 +295,6 @@ public:
   /* Clear the pertinent detail in the window.  */
   virtual void clear_detail () = 0;
 
-  /* Return true if this window has the locator.  */
-  virtual bool has_locator () const
-  {
-    return false;
-  }
-
   /* Called after all the TUI windows are refreshed, to let this
      window have a chance to update itself further.  */
   virtual void refresh_all ()
@@ -368,12 +362,6 @@ public:
 
   void clear_detail () override;
 
-  /* Return true if this window has the locator.  */
-  bool has_locator () const override
-  {
-    return m_has_locator;
-  }
-
   void make_visible (bool visible) override;
   void refresh_window () override;
   void refresh_all () override;
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index c92a706efc6..2fb757a6a4d 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -1235,7 +1235,7 @@ tui_source_window_base::set_new_height (int height)
     execution_info->viewport_height = height;
   execution_info->viewport_height--;
 
-  if (has_locator ())
+  if (m_has_locator)
     {
       tui_locator_window *gen_win_info = tui_locator_win_info_ptr ();
       gen_win_info->make_visible (false);
@@ -1324,7 +1324,7 @@ tui_source_window_base::do_make_visible_with_new_height ()
 	}
       tui_update_source_window (this, gdbarch, s, line, TRUE);
     }
-  if (has_locator ())
+  if (m_has_locator)
     {
       tui_locator_win_info_ptr ()->make_visible (true);
       tui_show_locator_content ();
-- 
2.17.2

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

* Re: [PATCH 13/61] Introduce tui_data_window::delete_data_content_windows method
  2019-07-04 17:03 ` [PATCH 13/61] Introduce tui_data_window::delete_data_content_windows method Tom Tromey
@ 2019-07-17 12:36   ` Pedro Alves
  2019-07-17 18:26     ` Tom Tromey
  0 siblings, 1 reply; 70+ messages in thread
From: Pedro Alves @ 2019-07-17 12:36 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 7/4/19 6:02 PM, Tom Tromey wrote:
> @@ -60,9 +60,9 @@ tui_data_window::first_data_item_displayed ()
>  /* Function to delete all the item windows in the data window.  This
>     is usually done when the data window is scrolled.  */
>  void
> -tui_delete_data_content_windows (void)
> +tui_data_window::delete_data_content_windows ()

I noticed that the comment was copied to tui-data.h, and the original
left behind, duplicated.  There are other cases in the patch, but 
I saw this in other patches as well, but I did not think to point
at all of them when I first read through the whole series (and then
came back here).

I'd drop "Function to" in the method's intro comments too, FWIW.

Given the moving-code-around parts later in the series, it might
be simpler to leave things as they are in these intermediate
patches, not sure.

Thanks,
Pedro Alves

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

* Re: [PATCH 61/61] Remove unnecessary "return"s
  2019-07-04 17:04 ` [PATCH 61/61] Remove unnecessary "return"s Tom Tromey
@ 2019-07-17 12:37   ` Pedro Alves
  0 siblings, 0 replies; 70+ messages in thread
From: Pedro Alves @ 2019-07-17 12:37 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 7/4/19 6:03 PM, Tom Tromey wrote:
> @@ -293,12 +291,11 @@ tui_show_disassem_and_update_source (struct gdbarch *gdbarch,
>  	{
>  	  set_current_source_symtab_and_line (sal);
>  	  tui_update_locator_fullname (symtab_to_fullname (sal.symtab));
> +

Odd empty line.

>  	}
>        else
>  	tui_update_locator_fullname ("?");
>      }
> -
> -  return;
>  }
>  

Thanks,
Pedro Alves

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

* Re: [PATCH 51/61] Fix flushing bug in tui_puts_internal
  2019-07-04 17:04 ` [PATCH 51/61] Fix flushing bug in tui_puts_internal Tom Tromey
@ 2019-07-17 12:37   ` Pedro Alves
  0 siblings, 0 replies; 70+ messages in thread
From: Pedro Alves @ 2019-07-17 12:37 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 7/4/19 6:03 PM, Tom Tromey wrote:
> A while back I changed gdb not to flush in some places.  It turned out
> that this broke the TUI a little.  An easy way to see it is to run
> "gdb -tui -nx", then "file gdb" at the gdb prompt.  gdb will print the
> usual "Reading symbols..." message -- but it won't appear on-screen
> until the reading is complete.
> 
> This patch changes the TUI to do the equivalent of line buffering in
> tui_puts_internal.
> 
> 2019-07-04  Tom Tromey  <tom@tromey.com>
> 
> 	* tui/tui-io.c (tui_puts_internal): Call wrefresh is newline is

"if newline"

> 	seen.
Thanks,
Pedro Alves

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

* Re: [PATCH 24/61] Introduce tui_source_window_base::location_matches_p method
  2019-07-04 17:03 ` [PATCH 24/61] Introduce tui_source_window_base::location_matches_p method Tom Tromey
@ 2019-07-17 12:37   ` Pedro Alves
  0 siblings, 0 replies; 70+ messages in thread
From: Pedro Alves @ 2019-07-17 12:37 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 7/4/19 6:02 PM, Tom Tromey wrote:
> --- a/gdb/tui/tui-data.h
> +++ b/gdb/tui/tui-data.h
> @@ -404,6 +404,8 @@ public:
>  
>    void update_tab_width () override;
>  
> +  virtual bool location_matches_p (struct bp_location *loc, int line_no) = 0;

Maybe add an intro comment?

Thanks,
Pedro Alves

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

* Re: [PATCH 00/61] More TUI refactorings
  2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
                   ` (60 preceding siblings ...)
  2019-07-04 17:26 ` [PATCH 50/61] Remove has_locator method Tom Tromey
@ 2019-07-17 12:41 ` Pedro Alves
  2019-07-17 18:35   ` Tom Tromey
  61 siblings, 1 reply; 70+ messages in thread
From: Pedro Alves @ 2019-07-17 12:41 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 7/4/19 6:02 PM, Tom Tromey wrote:
> Here is another series of TUI cleanups.  It covers several things.
> 
> I made an attempt to remove most of the uses of the TUI_*_WIN globals,
> and to remove explicit checks of window types.  I think this is
> important if we want to be able to easily add new types of windows:
> the core code should be able to manipulate windows without regard to
> their exact contents.
> 
> This transformation isn't complete, but this series takes it pretty
> far, with many of the remaining uses being in the layout code (mainly
> tui-layout.c, but also other files) -- which, if we're going to add
> new windows types, is going to need to be rewritten anyhow.  (Also,
> even once this is all done, I suspect the command window will always
> be a singleton with special code here and there in the TUI anyhow.)
> 
> This series also simplifies window creation and management.  By the
> end of the series, init_and_make_win is completely gone, replaced with
> ordinary uses of "new" at the appropriate spots.  These transforms
> make this code much simpler to understand, IMO.
> 
> The TUI source code is also rearranged somewhat.  In particular, by
> the end of the series, the declaration for a window class is in the
> appropriate .h file (that is, most are moved out of tui-data.h), and
> all the methods for a given class are grouped into a single .c file.
> 
> A couple of small bugs have been fixed in this series.  See the patch
> "Fix flushing bug in tui_puts_internal" and also "Remove deleted
> breakpoint from TUI display".
> 
> Finally, the series contains a fair amount of trivia, just random
> little things I noticed while working on the code.
> 
> In some cases this series introduces functions, only to remove them
> some patches later.  This is a side effect of how I wrote the patches,
> but TBH I think it makes each individual patch more clear -- bundling
> the two patches together would make the result less obviously correct.
> 
> I've tested this as well as I could.  You may want to give it a try,
> though.  It is on the "t/tui-rewrite" branch in my github.

I've tested it a bit, and didn't spot anything different.

I read through the series, and it all looked great to me.

I sent a few comments to individual patches pointing out 
some tiny things.

Thanks for doing all of this.  Impressive.

Pedro Alves

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

* Re: [PATCH 13/61] Introduce tui_data_window::delete_data_content_windows method
  2019-07-17 12:36   ` Pedro Alves
@ 2019-07-17 18:26     ` Tom Tromey
  0 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-17 18:26 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

Pedro> I noticed that the comment was copied to tui-data.h, and the original
Pedro> left behind, duplicated.  There are other cases in the patch, but 
Pedro> I saw this in other patches as well, but I did not think to point
Pedro> at all of them when I first read through the whole series (and then
Pedro> came back here).

Pedro> I'd drop "Function to" in the method's intro comments too, FWIW.

Pedro> Given the moving-code-around parts later in the series, it might
Pedro> be simpler to leave things as they are in these intermediate
Pedro> patches, not sure.

I went through the patches and updated them according to the above.

Tom

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

* Re: [PATCH 00/61] More TUI refactorings
  2019-07-17 12:41 ` [PATCH 00/61] More TUI refactorings Pedro Alves
@ 2019-07-17 18:35   ` Tom Tromey
  0 siblings, 0 replies; 70+ messages in thread
From: Tom Tromey @ 2019-07-17 18:35 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

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

Pedro> I've tested it a bit, and didn't spot anything different.

Pedro> I read through the series, and it all looked great to me.

Thanks for looking at it.

I've addressed all the comments you made, and since the changes were
generally small, I am going to check it in.

I've got another cleanup series like this nearly ready.  After that one
I will probably stop doing TUI cleanups and try to fix a few bugs or add
features.

Tom

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

* clang build-regression  [Re: [PATCH 58/61] Change make_invisible_and_set_new_height to be a method]
  2019-07-04 17:04 ` [PATCH 58/61] Change make_invisible_and_set_new_height to be a method Tom Tromey
@ 2019-07-22 11:57   ` Jan Kratochvil
  0 siblings, 0 replies; 70+ messages in thread
From: Jan Kratochvil @ 2019-07-22 11:57 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Thu, 04 Jul 2019 19:03:08 +0200, Tom Tromey wrote:
> @@ -1243,24 +1237,22 @@ tui_source_window_base::set_new_height (int height)
>      }
>  }
>  
> -/* Function make the target window (and auxiliary windows associated
> -   with the targer) invisible, and set the new height and
> -   location.  */
> -static void
> -make_invisible_and_set_new_height (struct tui_win_info *win_info, 
> -				   int height)
> +/* See tui-data.h.  */
> +
> +void
> +tui_win_info::make_invisible_and_set_new_height (int height)
>  {
> -  win_info->make_visible (false);
> -  win_info->height = height;
> +  make_visible (false);
> +  height = height;

clang-8.0.0-1.fc30.x86_64
../../gdb-master/gdb/tui/tui-win.c:1200:10: error: explicitly assigning value of variable of type 'int' to itself [-Werror,-Wself-assign]
  height = height;
  ~~~~~~ ^ ~~~~~~


>    if (height > 1)
> -    win_info->viewport_height = height - 1;
> +    viewport_height = height - 1;
>    else
> -    win_info->viewport_height = height;
> -  if (win_info != TUI_CMD_WIN)
> -    win_info->viewport_height--;
> +    viewport_height = height;
> +  if (this != TUI_CMD_WIN)
> +    viewport_height--;
>  
>    /* Now deal with the auxiliary windows associated with win_info.  */
> -  win_info->set_new_height (height);
> +  set_new_height (height);
>  }


Jan

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

end of thread, other threads:[~2019-07-22 11:57 UTC | newest]

Thread overview: 70+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-04 17:03 [PATCH 00/61] More TUI refactorings Tom Tromey
2019-07-04 17:03 ` [PATCH 13/61] Introduce tui_data_window::delete_data_content_windows method Tom Tromey
2019-07-17 12:36   ` Pedro Alves
2019-07-17 18:26     ` Tom Tromey
2019-07-04 17:03 ` [PATCH 25/61] Move content_in_use to tui_source_window class Tom Tromey
2019-07-04 17:03 ` [PATCH 14/61] Introduce tui_data_window::erase_data_content method Tom Tromey
2019-07-04 17:03 ` [PATCH 28/61] Remove unused TUI defines Tom Tromey
2019-07-04 17:03 ` [PATCH 07/61] Introduce tui_data_window::line_from_reg_element_no method Tom Tromey
2019-07-04 17:03 ` [PATCH 33/61] Remove tui_set_focus Tom Tromey
2019-07-04 17:03 ` [PATCH 16/61] Introduce tui_data_window::display_reg_element_at_line method Tom Tromey
2019-07-04 17:03 ` [PATCH 18/61] Simplify tui_show_registers Tom Tromey
2019-07-04 17:03 ` [PATCH 08/61] Introduce tui_data_window::first_reg_element_no_inline Tom Tromey
2019-07-04 17:03 ` [PATCH 36/61] Always create an execution info window for a source window Tom Tromey
2019-07-04 17:03 ` [PATCH 11/61] Introduce tui_data_window::display_all_data method Tom Tromey
2019-07-04 17:03 ` [PATCH 17/61] Parameterize tui_show_register_group with window Tom Tromey
2019-07-04 17:03 ` [PATCH 32/61] Merge refresh and refresh_window methods Tom Tromey
2019-07-04 17:03 ` [PATCH 34/61] Remove TUI data window special case Tom Tromey
2019-07-04 17:03 ` [PATCH 29/61] Remove UNDEFINED_ITEM define from TUI Tom Tromey
2019-07-04 17:03 ` [PATCH 21/61] Fix comment typos Tom Tromey
2019-07-04 17:03 ` [PATCH 02/61] Check can_highlight in tui_check_and_display_highlight_if_needed Tom Tromey
2019-07-04 17:03 ` [PATCH 24/61] Introduce tui_source_window_base::location_matches_p method Tom Tromey
2019-07-17 12:37   ` Pedro Alves
2019-07-04 17:03 ` [PATCH 12/61] Don't declare unimplemented functions Tom Tromey
2019-07-04 17:03 ` [PATCH 15/61] Introduce two more tui_data_window methods Tom Tromey
2019-07-04 17:03 ` [PATCH 04/61] Consolidate "if"s in tui_show_frame_info Tom Tromey
2019-07-04 17:03 ` [PATCH 01/61] Introduce can_scroll method Tom Tromey
2019-07-04 17:03 ` [PATCH 20/61] Introduce TUI window iterator Tom Tromey
2019-07-04 17:03 ` [PATCH 09/61] Remove tui_display_data_from_line Tom Tromey
2019-07-04 17:03 ` [PATCH 31/61] Remove tui_source_window::content_in_use Tom Tromey
2019-07-04 17:03 ` [PATCH 40/61] Change tui_set_layout to return void Tom Tromey
2019-07-04 17:03 ` [PATCH 03/61] Remove some uses of TUI_WIN_SRC Tom Tromey
2019-07-04 17:03 ` [PATCH 23/61] Remove tui_set_win_height Tom Tromey
2019-07-04 17:03 ` [PATCH 37/61] Introduce reset_locator function in tui-layout.c Tom Tromey
2019-07-04 17:03 ` [PATCH 06/61] Introduce tui_data_window::last_regs_line_no method Tom Tromey
2019-07-04 17:03 ` [PATCH 27/61] Remove unused parameter from two TUI functions Tom Tromey
2019-07-04 17:03 ` [PATCH 22/61] Make source windows be self-updating Tom Tromey
2019-07-04 17:04 ` [PATCH 56/61] Move tui_disasm_window to tui-disasm.h Tom Tromey
2019-07-04 17:04 ` [PATCH 05/61] Remove deleted breakpoint from TUI display Tom Tromey
2019-07-04 17:04 ` [PATCH 49/61] Remove tui_make_visible and tui_make_invisible Tom Tromey
2019-07-04 17:04 ` [PATCH 58/61] Change make_invisible_and_set_new_height to be a method Tom Tromey
2019-07-22 11:57   ` clang build-regression [Re: [PATCH 58/61] Change make_invisible_and_set_new_height to be a method] Jan Kratochvil
2019-07-04 17:04 ` [PATCH 52/61] Rearrange TUI data window code Tom Tromey
2019-07-04 17:04 ` [PATCH 53/61] Move tui_dispatch_ctrl_char to tui-io.c Tom Tromey
2019-07-04 17:04 ` [PATCH 38/61] Remove the win_type parameter from tui_gen_win_info::reset Tom Tromey
2019-07-04 17:04 ` [PATCH 54/61] Move TUI command window code Tom Tromey
2019-07-04 17:04 ` [PATCH 57/61] Move tui_source_window to tui-source.h Tom Tromey
2019-07-04 17:04 ` [PATCH 41/61] Clean up tui_layout_command Tom Tromey
2019-07-04 17:04 ` [PATCH 42/61] Simplify show_source_disasm_command Tom Tromey
2019-07-04 17:04 ` [PATCH 26/61] Add win_info parameter to tui_set_disassem_content Tom Tromey
2019-07-04 17:04 ` [PATCH 55/61] Move TUI data item window to tui-regs.h Tom Tromey
2019-07-04 17:04 ` [PATCH 60/61] Fix an error in parse_scrolling_args Tom Tromey
2019-07-04 17:04 ` [PATCH 10/61] Remove tui_display_data_from Tom Tromey
2019-07-04 17:04 ` [PATCH 59/61] Move source window common to code to tui-winsource.[ch] Tom Tromey
2019-07-04 17:04 ` [PATCH 48/61] Remove make_data_window Tom Tromey
2019-07-04 17:04 ` [PATCH 43/61] Simplify tui_gen_win_info::make_visible Tom Tromey
2019-07-04 17:04 ` [PATCH 44/61] Change tui_get_register to return void Tom Tromey
2019-07-04 17:04 ` [PATCH 19/61] Minor tui_reg_next / tui_reg_prev cleanup Tom Tromey
2019-07-04 17:04 ` [PATCH 51/61] Fix flushing bug in tui_puts_internal Tom Tromey
2019-07-17 12:37   ` Pedro Alves
2019-07-04 17:04 ` [PATCH 35/61] Remove some dead code from tui_set_layout Tom Tromey
2019-07-04 17:04 ` [PATCH 30/61] Simplify source window clearing Tom Tromey
2019-07-04 17:04 ` [PATCH 39/61] Remove reset_locator Tom Tromey
2019-07-04 17:04 ` [PATCH 45/61] Simplify show_source_or_disasm_and_command Tom Tromey
2019-07-04 17:04 ` [PATCH 61/61] Remove unnecessary "return"s Tom Tromey
2019-07-17 12:37   ` Pedro Alves
2019-07-04 17:04 ` [PATCH 46/61] Remove make_command_window Tom Tromey
2019-07-04 17:26 ` [PATCH 47/61] Remove make_source_window and make_disasm_window Tom Tromey
2019-07-04 17:26 ` [PATCH 50/61] Remove has_locator method Tom Tromey
2019-07-17 12:41 ` [PATCH 00/61] More TUI refactorings Pedro Alves
2019-07-17 18:35   ` 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).