[PATCH 00/19] More TUI refactoring

classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[PATCH 00/19] More TUI refactoring

Tom Tromey-2
This is the first part of a much longer series to further refactor the
TUI.  The full series causes some test suite regressions that are
proving slow to debug, so I thought I would send the series piecemeal.
This approach is both easier to debug and easier to review.

I built and tested (using the gdb.tui test cases) each patch here on
x86-64 Fedora 28.

Tom


Reply | Threaded
Open this post in threaded view
|

[PATCH 01/19] clear_detail can only be called on TUI source windows

Tom Tromey-2
The clear_detail method can only be called on source windows, so
remove definitions from the base of the class hierarchy, leaving only
a single non-virtual method.

gdb/ChangeLog
2019-08-03  Tom Tromey  <[hidden email]>

        * tui/tui-winsource.h (struct tui_source_window_base)
        <clear_detail>: No longer "override".
        * tui/tui-regs.h (struct tui_data_window) <clear_detail>: Remove.
        * tui/tui-regs.c (tui_data_window::clear_detail): Remove.
        * tui/tui-data.h (struct tui_win_info) <clear_detail>: Remove.
        * tui/tui-command.h (struct tui_cmd_window) <clear_detail>:
        Remove.
        * tui/tui-command.c (tui_cmd_window::clear_detail): Remove.
---
 gdb/ChangeLog           | 11 +++++++++++
 gdb/tui/tui-command.c   |  8 --------
 gdb/tui/tui-command.h   |  2 --
 gdb/tui/tui-data.h      |  3 ---
 gdb/tui/tui-regs.c      | 10 ----------
 gdb/tui/tui-regs.h      |  1 -
 gdb/tui/tui-winsource.h |  2 +-
 7 files changed, 12 insertions(+), 25 deletions(-)

diff --git a/gdb/tui/tui-command.c b/gdb/tui/tui-command.c
index 5af3484b9ec..034abd57982 100644
--- a/gdb/tui/tui-command.c
+++ b/gdb/tui/tui-command.c
@@ -30,14 +30,6 @@
 
 /* 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 ()
 {
diff --git a/gdb/tui/tui-command.h b/gdb/tui/tui-command.h
index d2a8ab1903a..af80b1449fa 100644
--- a/gdb/tui/tui-command.h
+++ b/gdb/tui/tui-command.h
@@ -35,8 +35,6 @@ struct tui_cmd_window : public tui_win_info
 
   DISABLE_COPY_AND_ASSIGN (tui_cmd_window);
 
-  void clear_detail () override;
-
   void make_visible (bool visible) override
   {
   }
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 214f728befe..5a7c487def4 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -249,9 +249,6 @@ public:
   {
   }
 
-  /* Clear the pertinent detail in the window.  */
-  virtual void clear_detail () = 0;
-
   /* Called after all the TUI windows are refreshed, to let this
      window have a chance to update itself further.  */
   virtual void refresh_all ()
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index c13a5b15871..27654629181 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -520,16 +520,6 @@ tui_data_window::do_scroll_vertical (int num_to_scroll)
 
 /* 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)
 {
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index 06467299176..b2abfc2078d 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -53,7 +53,6 @@ struct tui_data_window : public tui_win_info
 
   DISABLE_COPY_AND_ASSIGN (tui_data_window);
 
-  void clear_detail () override;
   void refresh_all () override;
 
   void set_new_height (int height) override;
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index ec44d1d2c02..9d7f0a7d774 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -67,7 +67,7 @@ protected:
 
 public:
 
-  void clear_detail () override;
+  void clear_detail ();
 
   void make_visible (bool visible) override;
   void refresh_window () override;
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 02/19] Remove struct tui_layout_def

Tom Tromey-2
In reply to this post by Tom Tromey-2
"layout_def" isn't actually used in the TUI, so remove it.

gdb/ChangeLog
2019-08-03  Tom Tromey  <[hidden email]>

        * tui/tui-layout.c (tui_set_layout): Update.
        * tui/tui-data.h (struct tui_layout_def): Remove.
        (tui_layout_def): Don't declare.
        * tui/tui-data.c (layout_def): Remove.
        (tui_layout_def): Remove.
---
 gdb/ChangeLog        |  8 ++++++++
 gdb/tui/tui-data.c   | 11 -----------
 gdb/tui/tui-data.h   |  7 -------
 gdb/tui/tui-layout.c |  5 -----
 4 files changed, 8 insertions(+), 23 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 2748230700c..af5e509ff0b 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -40,9 +40,6 @@ static int term_height, term_width;
 static struct tui_locator_window _locator;
 static std::vector<tui_source_window_base *> source_windows;
 static struct tui_win_info *win_with_focus = NULL;
-static struct tui_layout_def layout_def = {
-  SRC_WIN, /* DISPLAY_MODE */
-};
 
 static int win_resized = FALSE;
 
@@ -77,14 +74,6 @@ tui_set_win_resized_to (int resized)
 }
 
 
-/* Answer a pointer to the current layout definition.  */
-struct tui_layout_def *
-tui_layout_def (void)
-{
-  return &layout_def;
-}
-
-
 /* Answer the window with the logical focus.  */
 struct tui_win_info *
 tui_win_with_focus (void)
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 5a7c487def4..745181043aa 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -151,12 +151,6 @@ struct tui_line_or_address
     } u;
 };
 
-/* Current Layout definition.  */
-struct tui_layout_def
-{
-  enum tui_win_type display_mode;
-};
-
 /* Flags to tell what kind of breakpoint is at current line.  */
 enum tui_bp_flag
 {
@@ -400,7 +394,6 @@ extern void tui_clear_source_windows_detail (void);
 extern void tui_add_to_source_windows (struct tui_source_window_base *);
 extern struct tui_win_info *tui_win_with_focus (void);
 extern void tui_set_win_with_focus (struct tui_win_info *);
-extern struct tui_layout_def *tui_layout_def (void);
 extern int tui_win_resized (void);
 extern void tui_set_win_resized_to (int);
 
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index a5709c595f3..93687f3bd99 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -118,7 +118,6 @@ tui_set_layout (enum tui_layout_type layout_type)
   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);
 
@@ -135,7 +134,6 @@ tui_set_layout (enum tui_layout_type layout_type)
     {
     case SRC_COMMAND:
       tui_set_win_focus_to (TUI_SRC_WIN);
-      layout_def->display_mode = SRC_WIN;
       break;
     case DISASSEM_COMMAND:
       /* The previous layout was not showing code.
@@ -148,7 +146,6 @@ tui_set_layout (enum tui_layout_type layout_type)
 
       tui_get_begin_asm_address (&gdbarch, &addr);
       tui_set_win_focus_to (TUI_DISASM_WIN);
-      layout_def->display_mode = DISASSEM_WIN;
       break;
     case SRC_DISASSEM_COMMAND:
       /* The previous layout was not showing code.
@@ -170,7 +167,6 @@ tui_set_layout (enum tui_layout_type layout_type)
  tui_set_win_focus_to (TUI_SRC_WIN);
       else
  tui_set_win_focus_to (TUI_DATA_WIN);
-      layout_def->display_mode = SRC_WIN;
       break;
     case DISASSEM_DATA_COMMAND:
       /* The previous layout was not showing code.
@@ -186,7 +182,6 @@ tui_set_layout (enum tui_layout_type layout_type)
  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;
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 03/19] Move current_layout to tui-layout.c

Tom Tromey-2
In reply to this post by Tom Tromey-2
This moves the current_layout global to tui-layout.c.  This allows for
the removal of an accessor function; but also it just seems clearer to
have it here.

gdb/ChangeLog
2019-08-03  Tom Tromey  <[hidden email]>

        * tui/tui-layout.c (current_layout, tui_current_layout): Move from
        tui-data.c.
        (show_source_disasm_command, show_data)
        (show_source_or_disasm_and_command): Don't use
        tui_set_current_layout_to.
        * tui/tui-data.h (tui_set_current_layout_to): Don't declare.
        * tui/tui-data.c (current_layout, tui_current_layout): Move to
        tui-layout.c.
        (tui_set_current_layout_to): Remove.
---
 gdb/ChangeLog        | 12 ++++++++++++
 gdb/tui/tui-data.c   | 17 -----------------
 gdb/tui/tui-data.h   |  1 -
 gdb/tui/tui-layout.c | 15 ++++++++++++---
 4 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index af5e509ff0b..fd7649bdeab 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -35,7 +35,6 @@ struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
 /***************************
 ** Private data
 ****************************/
-static enum tui_layout_type current_layout = UNDEFINED_LAYOUT;
 static int term_height, term_width;
 static struct tui_locator_window _locator;
 static std::vector<tui_source_window_base *> source_windows;
@@ -170,22 +169,6 @@ tui_set_term_width_to (int w)
 }
 
 
-/* Accessor for the current layout.  */
-enum tui_layout_type
-tui_current_layout (void)
-{
-  return current_layout;
-}
-
-
-/* Mutator for the current layout.  */
-void
-tui_set_current_layout_to (enum tui_layout_type new_layout)
-{
-  current_layout = new_layout;
-}
-
-
 /*****************************
 ** OTHER PUBLIC FUNCTIONS
 *****************************/
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 745181043aa..dbae2fb3b00 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -382,7 +382,6 @@ struct all_tui_windows
 extern void tui_initialize_static_data (void);
 extern struct tui_win_info *tui_partial_win_by_name (const char *);
 extern enum tui_layout_type tui_current_layout (void);
-extern void tui_set_current_layout_to (enum tui_layout_type);
 extern int tui_term_height (void);
 extern void tui_set_term_height_to (int);
 extern int tui_term_width (void);
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 93687f3bd99..2b25e7a57fd 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -55,6 +55,15 @@ static void tui_layout_command (const char *, int);
 static void extract_display_start_addr (struct gdbarch **, CORE_ADDR *);
 
 
+static enum tui_layout_type current_layout = UNDEFINED_LAYOUT;
+
+/* Accessor for the current layout.  */
+enum tui_layout_type
+tui_current_layout (void)
+{
+  return current_layout;
+}
+
 /***************************************
 ** DEFINITIONS
 ***************************************/
@@ -543,7 +552,7 @@ show_source_disasm_command (void)
       /* 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);
+      current_layout = SRC_DISASSEM_COMMAND;
     }
 }
 
@@ -597,7 +606,7 @@ show_data (enum tui_layout_type new_layout)
   locator->make_visible (true);
   tui_show_locator_content ();
   tui_add_to_source_windows (base);
-  tui_set_current_layout_to (new_layout);
+  current_layout = new_layout;
 }
 
 void
@@ -675,6 +684,6 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
       /* 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);
+      current_layout = layout_type;
     }
 }
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 04/19] Remove tui_make_all_visible

Tom Tromey-2
In reply to this post by Tom Tromey-2
The function tui_make_all_visible is not used, so remove it.

gdb/ChangeLog
2019-08-03  Tom Tromey  <[hidden email]>

        * tui/tui-wingeneral.h (tui_make_all_visible): Don't declare.
        * tui/tui-wingeneral.c (tui_make_all_visible): Remove.
---
 gdb/ChangeLog            | 5 +++++
 gdb/tui/tui-wingeneral.c | 6 ------
 gdb/tui/tui-wingeneral.h | 1 -
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index dc556317297..92a678cc1e2 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -174,12 +174,6 @@ make_all_visible (bool visible)
     win_info->make_visible (visible);
 }
 
-void
-tui_make_all_visible (void)
-{
-  make_all_visible (true);
-}
-
 void
 tui_make_all_invisible (void)
 {
diff --git a/gdb/tui/tui-wingeneral.h b/gdb/tui/tui-wingeneral.h
index d0a8ef99417..3c035aa48b1 100644
--- a/gdb/tui/tui-wingeneral.h
+++ b/gdb/tui/tui-wingeneral.h
@@ -28,7 +28,6 @@ struct tui_win_info;
 struct tui_gen_win_info;
 
 extern void tui_unhighlight_win (struct tui_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);
 extern void tui_highlight_win (struct tui_win_info *);
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 05/19] Simplify tui_make_all_invisible

Tom Tromey-2
In reply to this post by Tom Tromey-2
This simplifies the implementation of tui_make_all_invisible.  Also,
because show_data is only called by show_layout, this hoists the call
to tui_make_all_invisible and removes the call from show_data.

gdb/ChangeLog
2019-08-03  Tom Tromey  <[hidden email]>

        * tui/tui-wingeneral.c (make_all_visible): Remove.
        (tui_make_all_invisible): Simplify.
        * tui/tui-layout.c (tui_make_all_invisible): Move from
        tui-wingeneral.c; simplify.
        (show_layout): Hoist call to tui_make_all_invisible.
        (show_data): Don't call tui_make_all_invisible.
---
 gdb/ChangeLog            |  9 +++++++++
 gdb/tui/tui-layout.c     |  9 +++------
 gdb/tui/tui-wingeneral.c | 12 +++---------
 gdb/tui/tui-wingeneral.h |  4 +++-
 4 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 2b25e7a57fd..3ee3354b2ff 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -80,6 +80,9 @@ show_layout (enum tui_layout_type layout)
          should free the content and reallocate on next display of
          source/asm.  */
       tui_clear_source_windows ();
+      /* First make the current layout be invisible.  */
+      tui_make_all_invisible ();
+      tui_locator_win_info_ptr ()->make_visible (false);
       if (layout == SRC_DATA_COMMAND
   || layout == DISASSEM_DATA_COMMAND)
  {
@@ -88,10 +91,6 @@ show_layout (enum tui_layout_type layout)
  }
       else
  {
-  /* First make the current layout be invisible.  */
-  tui_make_all_invisible ();
-  tui_locator_win_info_ptr ()->make_visible (false);
-
   switch (layout)
     {
       /* Now show the new layout.  */
@@ -571,8 +570,6 @@ show_data (enum tui_layout_type new_layout)
 
   data_height = total_height / 2;
   src_height = total_height - data_height;
-  tui_make_all_invisible ();
-  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);
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 92a678cc1e2..79f93ceaf9f 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -165,19 +165,13 @@ tui_gen_win_info::make_visible (bool visible)
     }
 }
 
-/* Makes all windows invisible (except the command and locator
-   windows).  */
-static void
-make_all_visible (bool visible)
-{
-  for (tui_win_info *win_info : all_tui_windows ())
-    win_info->make_visible (visible);
-}
+/* See tui-wingeneral.h.  */
 
 void
 tui_make_all_invisible (void)
 {
-  make_all_visible (false);
+  for (tui_win_info *win_info : all_tui_windows ())
+    win_info->make_visible (false);
 }
 
 /* Function to refresh all the windows currently displayed.  */
diff --git a/gdb/tui/tui-wingeneral.h b/gdb/tui/tui-wingeneral.h
index 3c035aa48b1..051be6da690 100644
--- a/gdb/tui/tui-wingeneral.h
+++ b/gdb/tui/tui-wingeneral.h
@@ -27,8 +27,10 @@
 struct tui_win_info;
 struct tui_gen_win_info;
 
-extern void tui_unhighlight_win (struct tui_win_info *);
+/* Makes all windows invisible.  */
 extern void tui_make_all_invisible (void);
+
+extern void tui_unhighlight_win (struct tui_win_info *);
 extern void tui_make_window (struct tui_gen_win_info *, enum tui_box);
 extern void tui_highlight_win (struct tui_win_info *);
 extern void tui_check_and_display_highlight_if_needed (struct tui_win_info *);
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 06/19] Two simplifications in tui-layout.c

Tom Tromey-2
In reply to this post by Tom Tromey-2
This patch simplifies some code in tui-layout.c.

In show_layout, all the layout settings can be handled by a single
switch statement.  In show_source_disasm_command and
show_source_or_disasm_and_command, there is no need to check the
current layout, as the caller has already done so.

gdb/ChangeLog
2019-08-03  Tom Tromey  <[hidden email]>

        * tui/tui-layout.c (show_layout): Unify all layout cases into a
        single switch.
        (show_source_disasm_command, show_source_or_disasm_and_command):
        Don't check current layout.
---
 gdb/ChangeLog        |   7 ++
 gdb/tui/tui-layout.c | 228 +++++++++++++++++++++----------------------
 2 files changed, 116 insertions(+), 119 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 3ee3354b2ff..91db38404b3 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -83,33 +83,29 @@ show_layout (enum tui_layout_type layout)
       /* First make the current layout be invisible.  */
       tui_make_all_invisible ();
       tui_locator_win_info_ptr ()->make_visible (false);
-      if (layout == SRC_DATA_COMMAND
-  || layout == DISASSEM_DATA_COMMAND)
+      switch (layout)
  {
+ case SRC_DATA_COMMAND:
+ case DISASSEM_DATA_COMMAND:
   show_data (layout);
   tui_refresh_all ();
- }
-      else
- {
-  switch (layout)
-    {
-      /* Now show the new layout.  */
-    case SRC_COMMAND:
-      show_source_command ();
-      tui_add_to_source_windows (TUI_SRC_WIN);
-      break;
-    case DISASSEM_COMMAND:
-      show_disasm_command ();
-      tui_add_to_source_windows (TUI_DISASM_WIN);
-      break;
-    case SRC_DISASSEM_COMMAND:
-      show_source_disasm_command ();
-      tui_add_to_source_windows (TUI_SRC_WIN);
-      tui_add_to_source_windows (TUI_DISASM_WIN);
-      break;
-    default:
-      break;
-    }
+  break;
+  /* Now show the new layout.  */
+ case SRC_COMMAND:
+  show_source_command ();
+  tui_add_to_source_windows (TUI_SRC_WIN);
+  break;
+ case DISASSEM_COMMAND:
+  show_disasm_command ();
+  tui_add_to_source_windows (TUI_DISASM_WIN);
+  break;
+ case SRC_DISASSEM_COMMAND:
+  show_source_disasm_command ();
+  tui_add_to_source_windows (TUI_SRC_WIN);
+  tui_add_to_source_windows (TUI_DISASM_WIN);
+  break;
+ default:
+  break;
  }
     }
 }
@@ -500,59 +496,56 @@ show_disasm_command (void)
 static void
 show_source_disasm_command (void)
 {
-  if (tui_current_layout () != SRC_DISASSEM_COMMAND)
-    {
-      int cmd_height, src_height, asm_height;
+  int cmd_height, src_height, asm_height;
 
-      if (TUI_CMD_WIN != NULL)
- cmd_height = TUI_CMD_WIN->height;
-      else
- cmd_height = tui_term_height () / 3;
+  if (TUI_CMD_WIN != NULL)
+    cmd_height = TUI_CMD_WIN->height;
+  else
+    cmd_height = tui_term_height () / 3;
 
-      src_height = (tui_term_height () - cmd_height) / 2;
-      asm_height = tui_term_height () - (src_height + cmd_height);
+  src_height = (tui_term_height () - cmd_height) / 2;
+  asm_height = tui_term_height () - (src_height + cmd_height);
 
-      if (TUI_SRC_WIN == NULL)
- tui_win_list[SRC_WIN] = new tui_source_window ();
-      TUI_SRC_WIN->reset (src_height,
-  tui_term_width (),
-  0,
-  0);
-      TUI_SRC_WIN->make_visible (true);
-      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] = new tui_disasm_window ();
-      TUI_DISASM_WIN->reset (asm_height,
-     tui_term_width (),
-     0,
-     src_height - 1);
-      TUI_DISASM_WIN->make_visible (true);
-      locator->reset (2 /* 1 */ ,
+  if (TUI_SRC_WIN == NULL)
+    tui_win_list[SRC_WIN] = new tui_source_window ();
+  TUI_SRC_WIN->reset (src_height,
       tui_term_width (),
       0,
-      (src_height + asm_height) - 1);
-      TUI_SRC_WIN->m_has_locator = false;
-      TUI_DISASM_WIN->m_has_locator = true;
-      locator->make_visible (true);
-      tui_show_locator_content ();
-      tui_show_source_content (TUI_DISASM_WIN);
-
-      if (TUI_CMD_WIN == NULL)
- 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);
-      current_layout = SRC_DISASSEM_COMMAND;
-    }
+      0);
+  TUI_SRC_WIN->make_visible (true);
+  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] = new tui_disasm_window ();
+  TUI_DISASM_WIN->reset (asm_height,
+ tui_term_width (),
+ 0,
+ src_height - 1);
+  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;
+  locator->make_visible (true);
+  tui_show_locator_content ();
+  tui_show_source_content (TUI_DISASM_WIN);
+
+  if (TUI_CMD_WIN == NULL)
+    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);
+  current_layout = SRC_DISASSEM_COMMAND;
 }
 
 
@@ -630,57 +623,54 @@ tui_gen_win_info::reset (int height_, int width_,
 static void
 show_source_or_disasm_and_command (enum tui_layout_type layout_type)
 {
-  if (tui_current_layout () != layout_type)
+  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);
+
+  if (TUI_CMD_WIN != NULL)
+    cmd_height = TUI_CMD_WIN->height;
+  else
+    cmd_height = tui_term_height () / 3;
+  src_height = tui_term_height () - cmd_height;
+
+  if (layout_type == SRC_COMMAND)
     {
-      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);
+      if (tui_win_list[SRC_WIN] == nullptr)
+ tui_win_list[SRC_WIN] = new tui_source_window ();
+      win_info = TUI_SRC_WIN;
+    }
+  else
+    {
+      if (tui_win_list[DISASSEM_WIN] == nullptr)
+ tui_win_list[DISASSEM_WIN] = new tui_disasm_window ();
+      win_info = TUI_DISASM_WIN;
+    }
 
-      if (TUI_CMD_WIN != NULL)
- cmd_height = TUI_CMD_WIN->height;
-      else
- cmd_height = tui_term_height () / 3;
-      src_height = tui_term_height () - cmd_height;
+  locator->reset (2 /* 1 */ ,
+  tui_term_width (),
+  0,
+  src_height - 1);
+  win_info->reset (src_height - 1,
+   tui_term_width (),
+   0,
+   0);
+  win_info->make_visible (true);
 
-      if (layout_type == SRC_COMMAND)
- {
-  if (tui_win_list[SRC_WIN] == nullptr)
-    tui_win_list[SRC_WIN] = new tui_source_window ();
-  win_info = TUI_SRC_WIN;
- }
-      else
- {
-  if (tui_win_list[DISASSEM_WIN] == nullptr)
-    tui_win_list[DISASSEM_WIN] = new tui_disasm_window ();
-  win_info = TUI_DISASM_WIN;
- }
 
-      locator->reset (2 /* 1 */ ,
+  win_info->m_has_locator = true;
+  locator->make_visible (true);
+  tui_show_locator_content ();
+  tui_show_source_content (win_info);
+
+  if (TUI_CMD_WIN == NULL)
+    tui_win_list[CMD_WIN] = new tui_cmd_window ();
+  TUI_CMD_WIN->reset (cmd_height,
       tui_term_width (),
       0,
-      src_height - 1);
-      win_info->reset (src_height - 1,
-       tui_term_width (),
-       0,
-       0);
-      win_info->make_visible (true);
-
-
-      win_info->m_has_locator = true;
-      locator->make_visible (true);
-      tui_show_locator_content ();
-      tui_show_source_content (win_info);
-
-      if (TUI_CMD_WIN == NULL)
- 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);
-      current_layout = layout_type;
-    }
+      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);
+  current_layout = layout_type;
 }
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 07/19] Make tui_default_win_height static

Tom Tromey-2
In reply to this post by Tom Tromey-2
tui_default_win_height is only used in tui-layout.c, so make it static.

gdb/ChangeLog
2019-08-03  Tom Tromey  <[hidden email]>

        * tui/tui-layout.h (tui_default_win_height): Don't declare.
        * tui/tui-layout.c (tui_default_win_height): Now static.
---
 gdb/ChangeLog        | 5 +++++
 gdb/tui/tui-layout.c | 2 +-
 gdb/tui/tui-layout.h | 2 --
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 91db38404b3..f4f834dc83e 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -254,7 +254,7 @@ tui_add_win_to_layout (enum tui_win_type type)
 /* Answer the height of a window.  If it hasn't been created yet,
    answer what the height of a window would be based upon its type and
    the layout.  */
-int
+static int
 tui_default_win_height (enum tui_win_type type,
  enum tui_layout_type layout)
 {
diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h
index 5f1993387be..a7e1e908983 100644
--- a/gdb/tui/tui-layout.h
+++ b/gdb/tui/tui-layout.h
@@ -26,8 +26,6 @@
 #include "tui/tui-data.h"
 
 extern void tui_add_win_to_layout (enum tui_win_type);
-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 void tui_set_layout (enum tui_layout_type);
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 08/19] Simplify tui_show_disassem

Tom Tromey-2
In reply to this post by Tom Tromey-2
tui_show_disassem does not need to call tui_add_win_to_layout, because
the callers that could change the layout have already ensured that it
exists.

gdb/ChangeLog
2019-08-03  Tom Tromey  <[hidden email]>

        * tui/tui-disasm.c (tui_show_disassem): Add assertion.  Don't call
        tui_add_win_to_layout.
---
 gdb/ChangeLog        | 5 +++++
 gdb/tui/tui-disasm.c | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 80f8d47f0ac..a442a00019e 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -255,9 +255,10 @@ tui_show_disassem (struct gdbarch *gdbarch, CORE_ADDR start_addr)
   struct tui_win_info *win_with_focus = tui_win_with_focus ();
   struct tui_line_or_address val;
 
+  gdb_assert (TUI_DISASM_WIN != nullptr && TUI_DISASM_WIN->is_visible);
+
   val.loa = LOA_ADDRESS;
   val.u.addr = start_addr;
-  tui_add_win_to_layout (DISASSEM_WIN);
   tui_update_source_window (TUI_DISASM_WIN, gdbarch, s, val, FALSE);
 
   /* If the focus was in the src win, put it in the asm win, if the
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 09/19] Delete invisible TUI windows

Tom Tromey-2
In reply to this post by Tom Tromey-2
This changes the TUI so that when the layout changes, any windows that
are invisible are now deleted.  This makes it simpler to understand
window lifetimes.

gdb/ChangeLog
2019-08-03  Tom Tromey  <[hidden email]>

        * tui/tui-win.c (tui_resize_all): Call
        tui_delete_invisible_windows.
        * tui/tui-layout.c (show_layout): Call
        tui_delete_invisible_windows.
        * tui/tui-data.h (tui_delete_invisible_windows): Declare.
        * tui/tui-data.c (tui_delete_invisible_windows): New function.
---
 gdb/ChangeLog        |  9 +++++++++
 gdb/tui/tui-data.c   | 22 ++++++++++++++++++++++
 gdb/tui/tui-data.h   |  5 +++++
 gdb/tui/tui-layout.c |  3 +++
 gdb/tui/tui-win.c    | 15 ++-------------
 5 files changed, 41 insertions(+), 13 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index fd7649bdeab..bb725c199cc 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -269,6 +269,28 @@ tui_initialize_static_data ()
   win->title = 0;
 }
 
+/* See tui-data.h.  */
+
+void
+tui_delete_invisible_windows ()
+{
+  for (int win_type = SRC_WIN; (win_type < MAX_MAJOR_WINDOWS); win_type++)
+    {
+      if (tui_win_list[win_type] != NULL
+  && !tui_win_list[win_type]->is_visible)
+ {
+  /* This should always be made visible before a call to this
+     function.  */
+  gdb_assert (win_type != CMD_WIN);
+
+  if (win_with_focus == tui_win_list[win_type])
+    win_with_focus = nullptr;
+
+  delete tui_win_list[win_type];
+  tui_win_list[win_type] = NULL;
+ }
+    }
+}
 
 tui_win_info::tui_win_info (enum tui_win_type type)
   : tui_gen_win_info (type)
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index dbae2fb3b00..d3fa03657c5 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -399,6 +399,11 @@ extern void tui_set_win_resized_to (int);
 extern struct tui_win_info *tui_next_win (struct tui_win_info *);
 extern struct tui_win_info *tui_prev_win (struct tui_win_info *);
 
+/* Delete all the invisible windows.  Note that it is an error to call
+   this when the command window is invisible -- we don't allow the
+   command window to be removed from the layout.  */
+extern void tui_delete_invisible_windows ();
+
 extern unsigned int tui_tab_width;
 
 #endif /* TUI_TUI_DATA_H */
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index f4f834dc83e..2715d322dc7 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -107,6 +107,8 @@ show_layout (enum tui_layout_type layout)
  default:
   break;
  }
+
+      tui_delete_invisible_windows ();
     }
 }
 
@@ -596,6 +598,7 @@ show_data (enum tui_layout_type new_layout)
   locator->make_visible (true);
   tui_show_locator_content ();
   tui_add_to_source_windows (base);
+  TUI_CMD_WIN->make_visible (true);
   current_layout = new_layout;
 }
 
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 785c623b7e2..0e64db3e7a1 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -537,7 +537,6 @@ tui_resize_all (void)
       struct tui_win_info *second_win;
       tui_source_window_base *src_win;
       struct tui_locator_window *locator = tui_locator_win_info_ptr ();
-      int win_type;
       int new_height, split_diff, cmd_split_diff, num_wins_displayed = 2;
 
 #ifdef HAVE_RESIZE_TERM
@@ -663,18 +662,8 @@ tui_resize_all (void)
     tui_erase_source_content (src_win);
   break;
  }
-      /* Now remove all invisible windows, and their content so that
-         they get created again when called for with the new size.  */
-      for (win_type = SRC_WIN; (win_type < MAX_MAJOR_WINDOWS); win_type++)
- {
-  if (win_type != CMD_WIN
-      && (tui_win_list[win_type] != NULL)
-      && !tui_win_list[win_type]->is_visible)
-    {
-      delete tui_win_list[win_type];
-      tui_win_list[win_type] = NULL;
-    }
- }
+
+      tui_delete_invisible_windows ();
       /* Turn keypad back on, unless focus is in the command
  window.  */
       if (win_with_focus != TUI_CMD_WIN)
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 10/19] Change tui_check_and_display_highlight_if_needed to be a method

Tom Tromey-2
In reply to this post by Tom Tromey-2
This changes tui_check_and_display_highlight_if_needed to be a method
on tui_win_info.  This makes it clear that the NULL check in that
function is not needed, so it is removed here.

gdb/ChangeLog
2019-08-03  Tom Tromey  <[hidden email]>

        * tui/tui-winsource.c (tui_erase_source_content)
        (tui_show_source_content, tui_source_window_base::refresh_all):
        Update.
        * tui/tui-wingeneral.h
        (tui_check_and_display_highlight_if_needed): Don't declare.
        * tui/tui-wingeneral.c
        (tui_win_info::check_and_display_highlight_if_needed): Rename from
        check_and_display_highlight_if_needed.
        * tui/tui-win.c (tui_rehighlight_all)
        (tui_win_info::make_visible_with_new_height): Update.
        * tui/tui-regs.c (tui_data_window::display_registers_from_line)
        (tui_data_window::erase_data_content)
        (tui_data_window::display_all_data): Update.
        * tui/tui-data.h (struct tui_win_info)
        <check_and_display_highlight_if_needed>: Declare.
---
 gdb/ChangeLog            | 18 ++++++++++++++++++
 gdb/tui/tui-data.h       |  2 ++
 gdb/tui/tui-regs.c       |  6 +++---
 gdb/tui/tui-win.c        |  4 ++--
 gdb/tui/tui-wingeneral.c | 11 +++++------
 gdb/tui/tui-wingeneral.h |  1 -
 gdb/tui/tui-winsource.c  |  6 +++---
 7 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index d3fa03657c5..6683848bc18 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -291,6 +291,8 @@ public:
     return true;
   }
 
+  void check_and_display_highlight_if_needed ();
+
   /* Can this window ever be highlighted?  */
   bool can_highlight = true;
 
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 27654629181..aaba94da467 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -369,7 +369,7 @@ tui_data_window::display_reg_element_at_line (int start_element_no,
 int
 tui_data_window::display_registers_from_line (int line_no)
 {
-  tui_check_and_display_highlight_if_needed (this);
+  check_and_display_highlight_if_needed ();
   if (!regs_content.empty ())
     {
       int element_no;
@@ -436,7 +436,7 @@ void
 tui_data_window::erase_data_content (const char *prompt)
 {
   werase (handle);
-  tui_check_and_display_highlight_if_needed (this);
+  check_and_display_highlight_if_needed ();
   if (prompt != NULL)
     {
       int half_width = (width - 2) / 2;
@@ -462,7 +462,7 @@ tui_data_window::display_all_data ()
     {
       erase_data_content (NULL);
       delete_data_content_windows ();
-      tui_check_and_display_highlight_if_needed (this);
+      check_and_display_highlight_if_needed ();
       display_registers_from (0);
     }
 }
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 0e64db3e7a1..f8238c7303e 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -515,7 +515,7 @@ void
 tui_rehighlight_all (void)
 {
   for (tui_win_info *win_info : all_tui_windows ())
-    tui_check_and_display_highlight_if_needed (win_info);
+    win_info->check_and_display_highlight_if_needed ();
 }
 
 /* Resize all the windows based on the terminal size.  This function
@@ -1205,7 +1205,7 @@ void
 tui_win_info::make_visible_with_new_height ()
 {
   make_visible (true);
-  tui_check_and_display_highlight_if_needed (this);
+  check_and_display_highlight_if_needed ();
   do_make_visible_with_new_height ();
 }
 
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 79f93ceaf9f..8ff5aa5fce8 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -112,15 +112,14 @@ tui_highlight_win (struct tui_win_info *win_info)
 }
 
 void
-tui_check_and_display_highlight_if_needed (struct tui_win_info *win_info)
+tui_win_info::check_and_display_highlight_if_needed ()
 {
-  if (win_info != NULL && win_info->can_highlight)
+  if (can_highlight)
     {
-      if (win_info->is_highlighted)
- tui_highlight_win (win_info);
+      if (is_highlighted)
+ tui_highlight_win (this);
       else
- tui_unhighlight_win (win_info);
-
+ tui_unhighlight_win (this);
     }
 }
 
diff --git a/gdb/tui/tui-wingeneral.h b/gdb/tui/tui-wingeneral.h
index 051be6da690..54d6eb684f7 100644
--- a/gdb/tui/tui-wingeneral.h
+++ b/gdb/tui/tui-wingeneral.h
@@ -33,7 +33,6 @@ extern void tui_make_all_invisible (void);
 extern void tui_unhighlight_win (struct tui_win_info *);
 extern void tui_make_window (struct tui_gen_win_info *, enum tui_box);
 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 ();
 extern void tui_delete_win (WINDOW *window);
 
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 3de2692deea..6a72c6fe74b 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -225,7 +225,7 @@ tui_erase_source_content (struct tui_source_window_base *win_info)
   if (win_info->handle != NULL)
     {
       werase (win_info->handle);
-      tui_check_and_display_highlight_if_needed (win_info);
+      win_info->check_and_display_highlight_if_needed ();
 
       const char *no_src_str;
 
@@ -287,7 +287,7 @@ tui_show_source_content (struct tui_source_window_base *win_info)
   else
     tui_erase_source_content (win_info);
 
-  tui_check_and_display_highlight_if_needed (win_info);
+  win_info->check_and_display_highlight_if_needed ();
   win_info->refresh_window ();
 }
 
@@ -333,7 +333,7 @@ void
 tui_source_window_base::refresh_all ()
 {
   tui_show_source_content (this);
-  tui_check_and_display_highlight_if_needed (this);
+  check_and_display_highlight_if_needed ();
   tui_erase_exec_info_content (this);
   tui_update_exec_info (this);
 }
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 11/19] Change tui_show_source_content to be a method

Tom Tromey-2
In reply to this post by Tom Tromey-2
This changes tui_show_source_content to be a method on
tui_source_window_base.

gdb/ChangeLog
2019-08-03  Tom Tromey  <[hidden email]>

        * tui/tui-winsource.h (struct tui_source_window_base)
        <show_source_content>: Declare.
        (tui_show_source_content): Don't declare.
        * tui/tui-winsource.c (tui_update_source_window_as_is): Update.
        (tui_source_window_base::show_source_content): Rename from
        tui_show_source_content.
        (tui_source_window_base::refresh_all): Update.
        * tui/tui-layout.c (show_source_disasm_command)
        (show_source_or_disasm_and_command): Update.
---
 gdb/ChangeLog           | 12 ++++++++++++
 gdb/tui/tui-layout.c    |  6 +++---
 gdb/tui/tui-winsource.c | 18 +++++++++---------
 gdb/tui/tui-winsource.h |  3 ++-
 4 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 2715d322dc7..3683835954d 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -520,7 +520,7 @@ show_source_disasm_command (void)
   struct tui_locator_window *locator = tui_locator_win_info_ptr ();
   gdb_assert (locator != nullptr);
 
-  tui_show_source_content (TUI_SRC_WIN);
+  TUI_SRC_WIN->show_source_content ();
   if (TUI_DISASM_WIN == NULL)
     tui_win_list[DISASSEM_WIN] = new tui_disasm_window ();
   TUI_DISASM_WIN->reset (asm_height,
@@ -536,7 +536,7 @@ show_source_disasm_command (void)
   TUI_DISASM_WIN->m_has_locator = true;
   locator->make_visible (true);
   tui_show_locator_content ();
-  tui_show_source_content (TUI_DISASM_WIN);
+  TUI_DISASM_WIN->show_source_content ();
 
   if (TUI_CMD_WIN == NULL)
     tui_win_list[CMD_WIN] = new tui_cmd_window ();
@@ -664,7 +664,7 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
   win_info->m_has_locator = true;
   locator->make_visible (true);
   tui_show_locator_content ();
-  tui_show_source_content (win_info);
+  win_info->show_source_content ();
 
   if (TUI_CMD_WIN == NULL)
     tui_win_list[CMD_WIN] = new tui_cmd_window ();
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 6a72c6fe74b..bccc345fed9 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -105,7 +105,7 @@ tui_update_source_window_as_is (struct tui_source_window_base *win_info,
   else
     {
       tui_update_breakpoint_info (win_info, nullptr, false);
-      tui_show_source_content (win_info);
+      win_info->show_source_content ();
       tui_update_exec_info (win_info);
       if (win_info->type == SRC_WIN)
  {
@@ -275,20 +275,20 @@ tui_show_source_line (struct tui_source_window_base *win_info, int lineno)
 }
 
 void
-tui_show_source_content (struct tui_source_window_base *win_info)
+tui_source_window_base::show_source_content ()
 {
-  if (!win_info->content.empty ())
+  if (!content.empty ())
     {
       int lineno;
 
-      for (lineno = 1; lineno <= win_info->content.size (); lineno++)
-        tui_show_source_line (win_info, lineno);
+      for (lineno = 1; lineno <= content.size (); lineno++)
+        tui_show_source_line (this, lineno);
     }
   else
-    tui_erase_source_content (win_info);
+    tui_erase_source_content (this);
 
-  win_info->check_and_display_highlight_if_needed ();
-  win_info->refresh_window ();
+  check_and_display_highlight_if_needed ();
+  refresh_window ();
 }
 
 /* See tui-data.h.  */
@@ -332,7 +332,7 @@ tui_source_window_base::reset (int height, int width,
 void
 tui_source_window_base::refresh_all ()
 {
-  tui_show_source_content (this);
+  show_source_content ();
   check_and_display_highlight_if_needed ();
   tui_erase_exec_info_content (this);
   tui_update_exec_info (this);
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 9d7f0a7d774..8c76322d069 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -89,6 +89,8 @@ public:
   void reset (int height, int width,
       int origin_x, int origin_y) override;
 
+  void show_source_content ();
+
   /* Does the locator belong to this window?  */
   bool m_has_locator = false;
   /* Execution information window.  */
@@ -139,7 +141,6 @@ extern void tui_update_source_windows_with_line (struct symtab *,
  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 *);
 extern void tui_erase_exec_info_content (struct tui_source_window_base *);
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 12/19] Change tui_set_exec_info_content to be a method

Tom Tromey-2
In reply to this post by Tom Tromey-2
This changes tui_set_exec_info_content to bea method on
tui_source_window_base.

gdb/ChangeLog
2019-08-03  Tom Tromey  <[hidden email]>

        * tui/tui-winsource.h (struct tui_source_window_base)
        <set_exec_info_content>: Declare.
        (tui_set_exec_info_content): Don't declare.
        * tui/tui-winsource.c
        (tui_source_window_base::set_exec_info_content): Rename from
        tui_set_exec_info_content.
        (tui_update_exec_info): Update.
---
 gdb/ChangeLog           | 10 ++++++++++
 gdb/tui/tui-winsource.c | 16 ++++++++--------
 gdb/tui/tui-winsource.h |  3 ++-
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index bccc345fed9..c47da04e2a3 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -604,19 +604,19 @@ tui_exec_info_window::maybe_allocate_content (int n_elements)
    based upon the input window which is either the source or
    disassembly window.  */
 void
-tui_set_exec_info_content (struct tui_source_window_base *win_info)
+tui_source_window_base::set_exec_info_content ()
 {
-  tui_exec_info_content *content
-    = win_info->execution_info->maybe_allocate_content (win_info->height);
+  tui_exec_info_content *exec_content
+    = execution_info->maybe_allocate_content (height);
 
-  tui_update_breakpoint_info (win_info, nullptr, true);
-  for (int i = 0; i < win_info->content.size (); i++)
+  tui_update_breakpoint_info (this, nullptr, true);
+  for (int i = 0; i < content.size (); i++)
     {
-      tui_exec_info_content &element = content[i];
+      tui_exec_info_content &element = exec_content[i];
       struct tui_source_element *src_element;
       tui_bp_flags mode;
 
-      src_element = &win_info->content[i];
+      src_element = &content[i];
 
       memset (element, ' ', sizeof (tui_exec_info_content));
       element[TUI_EXECINFO_SIZE - 1] = 0;
@@ -675,7 +675,7 @@ tui_clear_exec_info_content (struct tui_source_window_base *win_info)
 void
 tui_update_exec_info (struct tui_source_window_base *win_info)
 {
-  tui_set_exec_info_content (win_info);
+  win_info->set_exec_info_content ();
   tui_show_exec_info_content (win_info);
 }
 
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 8c76322d069..645cd6717d6 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -91,6 +91,8 @@ public:
 
   void show_source_content ();
 
+  void set_exec_info_content ();
+
   /* Does the locator belong to this window?  */
   bool m_has_locator = false;
   /* Execution information window.  */
@@ -141,7 +143,6 @@ extern void tui_update_source_windows_with_line (struct symtab *,
  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_set_exec_info_content (struct tui_source_window_base *);
 extern void tui_show_exec_info_content (struct tui_source_window_base *);
 extern void tui_erase_exec_info_content (struct tui_source_window_base *);
 extern void tui_clear_exec_info_content (struct tui_source_window_base *);
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 13/19] Change tui_update_exec_info to be a method

Tom Tromey-2
In reply to this post by Tom Tromey-2
This changes tui_update_exec_info to be a method on
tui_source_window_base.

gdb/ChangeLog
2019-08-03  Tom Tromey  <[hidden email]>

        * tui/tui-winsource.h (struct tui_source_window_base)
        <update_exec_info>: Declare.
        (tui_update_exec_info): Don't declare.
        * tui/tui-winsource.c (tui_update_source_window_as_is)
        (tui_source_window_base::refresh_all)
        (tui_update_all_breakpoint_info): Update.
        (tui_source_window_base::update_exec_info): Rename from
        tui_update_exec_info.
        * tui/tui-stack.c (tui_show_frame_info): Update.
---
 gdb/ChangeLog           | 12 ++++++++++++
 gdb/tui/tui-stack.c     |  4 ++--
 gdb/tui/tui-winsource.c | 12 ++++++------
 gdb/tui/tui-winsource.h |  2 +-
 4 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index 6acc2277c04..0a712231fa5 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -428,7 +428,7 @@ tui_show_frame_info (struct frame_info *fi)
  }
     }
 
-  tui_update_exec_info (win_info);
+  win_info->update_exec_info ();
  }
 
       return 1;
@@ -445,7 +445,7 @@ tui_show_frame_info (struct frame_info *fi)
       for (struct tui_source_window_base *win_info : tui_source_windows ())
  {
   tui_clear_source_content (win_info);
-  tui_update_exec_info (win_info);
+  win_info->update_exec_info ();
  }
 
       return 1;
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index c47da04e2a3..53113bd785c 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,
     {
       tui_update_breakpoint_info (win_info, nullptr, false);
       win_info->show_source_content ();
-      tui_update_exec_info (win_info);
+      win_info->update_exec_info ();
       if (win_info->type == SRC_WIN)
  {
   symtab_and_line sal;
@@ -335,7 +335,7 @@ tui_source_window_base::refresh_all ()
   show_source_content ();
   check_and_display_highlight_if_needed ();
   tui_erase_exec_info_content (this);
-  tui_update_exec_info (this);
+  update_exec_info ();
 }
 
 /* See tui-data.h.  */
@@ -517,7 +517,7 @@ tui_update_all_breakpoint_info (struct breakpoint *being_deleted)
     {
       if (tui_update_breakpoint_info (win, being_deleted, false))
         {
-          tui_update_exec_info (win);
+          win->update_exec_info ();
         }
     }
 }
@@ -673,10 +673,10 @@ tui_clear_exec_info_content (struct tui_source_window_base *win_info)
 
 /* Function to update the execution info window.  */
 void
-tui_update_exec_info (struct tui_source_window_base *win_info)
+tui_source_window_base::update_exec_info ()
 {
-  win_info->set_exec_info_content ();
-  tui_show_exec_info_content (win_info);
+  set_exec_info_content ();
+  tui_show_exec_info_content (this);
 }
 
 void
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 645cd6717d6..bce889d5abe 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -92,6 +92,7 @@ public:
   void show_source_content ();
 
   void set_exec_info_content ();
+  void update_exec_info ();
 
   /* Does the locator belong to this window?  */
   bool m_has_locator = false;
@@ -146,7 +147,6 @@ extern void tui_erase_source_content (struct tui_source_window_base *);
 extern void tui_show_exec_info_content (struct tui_source_window_base *);
 extern void tui_erase_exec_info_content (struct tui_source_window_base *);
 extern void tui_clear_exec_info_content (struct tui_source_window_base *);
-extern void tui_update_exec_info (struct tui_source_window_base *);
 
 extern void tui_alloc_source_buffer (struct tui_source_window_base *);
 extern int tui_line_is_displayed (int,
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 14/19] Move code to tui-winsource.h

Tom Tromey-2
In reply to this post by Tom Tromey-2
This moves code related to the execution info window from tui-data.h
to tui-winsource.h.  It fits better here because the execution info is
conceptually part of the source and disassembly windows, and
tui-winsource.h is where this common class lives.

gdb/ChangeLog
2019-08-03  Tom Tromey  <[hidden email]>

        * tui/tui-data.h (enum tui_bp_flag, tui_bp_flags, struct tui_source_element)
        (TUI_BP_HIT_POS, TUI_BP_BREAK_POS, TUI_EXEC_POS)
        (TUI_EXECINFO_SIZE, tui_exec_info_content): Move ...
        * tui/tui-winsource.h (enum tui_bp_flag, tui_bp_flags, struct
        tui_source_element, TUI_BP_HIT_POS, TUI_BP_BREAK_POS)
        (TUI_EXEC_POS, TUI_EXECINFO_SIZE, tui_exec_info_content):
        ... here.
---
 gdb/ChangeLog           | 10 ++++++++++
 gdb/tui/tui-data.h      | 41 -----------------------------------------
 gdb/tui/tui-winsource.h | 41 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+), 41 deletions(-)

diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 6683848bc18..08178e49ea8 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -151,53 +151,12 @@ struct tui_line_or_address
     } u;
 };
 
-/* Flags to tell what kind of breakpoint is at current line.  */
-enum tui_bp_flag
-{
-  TUI_BP_ENABLED = 0x01,
-  TUI_BP_DISABLED = 0x02,
-  TUI_BP_HIT = 0x04,
-  TUI_BP_CONDITIONAL = 0x08,
-  TUI_BP_HARDWARE = 0x10
-};
-
-DEF_ENUM_FLAGS_TYPE (enum tui_bp_flag, tui_bp_flags);
-
-/* Elements in the Source/Disassembly Window.  */
-struct tui_source_element
-{
-  tui_source_element ()
-  {
-    line_or_addr.loa = LOA_LINE;
-    line_or_addr.u.line_no = 0;
-  }
-
-  ~tui_source_element ()
-  {
-    xfree (line);
-  }
-
-  char *line = nullptr;
-  struct tui_line_or_address line_or_addr;
-  bool is_exec_point = false;
-  tui_bp_flags break_mode = 0;
-};
-
-
 #ifdef PATH_MAX
 # define MAX_LOCATOR_ELEMENT_LEN        PATH_MAX
 #else
 # define MAX_LOCATOR_ELEMENT_LEN        1024
 #endif
 
-/* Position of breakpoint markers in the exec info string.  */
-#define TUI_BP_HIT_POS      0
-#define TUI_BP_BREAK_POS    1
-#define TUI_EXEC_POS        2
-#define TUI_EXECINFO_SIZE   4
-
-typedef char tui_exec_info_content[TUI_EXECINFO_SIZE];
-
 /* Locator window class.  */
 
 struct tui_locator_window : public tui_gen_win_info
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index bce889d5abe..71201e51d89 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -24,6 +24,26 @@
 
 #include "tui/tui-data.h"
 
+/* Flags to tell what kind of breakpoint is at current line.  */
+enum tui_bp_flag
+{
+  TUI_BP_ENABLED = 0x01,
+  TUI_BP_DISABLED = 0x02,
+  TUI_BP_HIT = 0x04,
+  TUI_BP_CONDITIONAL = 0x08,
+  TUI_BP_HARDWARE = 0x10
+};
+
+DEF_ENUM_FLAGS_TYPE (enum tui_bp_flag, tui_bp_flags);
+
+/* Position of breakpoint markers in the exec info string.  */
+#define TUI_BP_HIT_POS      0
+#define TUI_BP_BREAK_POS    1
+#define TUI_EXEC_POS        2
+#define TUI_EXECINFO_SIZE   4
+
+typedef char tui_exec_info_content[TUI_EXECINFO_SIZE];
+
 /* Execution info window class.  */
 
 struct tui_exec_info_window : public tui_gen_win_info
@@ -52,6 +72,27 @@ private:
   tui_exec_info_content *m_content = nullptr;
 };
 
+/* Elements in the Source/Disassembly Window.  */
+struct tui_source_element
+{
+  tui_source_element ()
+  {
+    line_or_addr.loa = LOA_LINE;
+    line_or_addr.u.line_no = 0;
+  }
+
+  ~tui_source_element ()
+  {
+    xfree (line);
+  }
+
+  char *line = nullptr;
+  struct tui_line_or_address line_or_addr;
+  bool is_exec_point = false;
+  tui_bp_flags break_mode = 0;
+};
+
+
 /* The base class for all source-like windows, namely the source and
    disassembly windows.  */
 
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 15/19] Turn tui_show_exec_info_content into a method

Tom Tromey-2
In reply to this post by Tom Tromey-2
This changes tui_show_exec_info_content to be a method on
tui_source_window_base.  As it is only called by other methods on this
class, it can be private.

gdb/ChangeLog
2019-08-03  Tom Tromey  <[hidden email]>

        * tui/tui-winsource.h (struct tui_source_window_base)
        <show_exec_info_content>: Declare.
        (tui_show_exec_info_content): Don't declare.
        * tui/tui-winsource.c
        (tui_source_window_base::show_exec_info_content): Rename from
        tui_show_exec_info_content.
        (tui_source_window_base::update_exec_info): Update.
---
 gdb/ChangeLog           | 10 ++++++++++
 gdb/tui/tui-winsource.c | 12 ++++++------
 gdb/tui/tui-winsource.h |  4 +++-
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 53113bd785c..c99e207b011 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -641,17 +641,17 @@ tui_source_window_base::set_exec_info_content ()
 
 
 void
-tui_show_exec_info_content (struct tui_source_window_base *win_info)
+tui_source_window_base::show_exec_info_content ()
 {
-  struct tui_exec_info_window *exec_info = win_info->execution_info;
-  const tui_exec_info_content *content = exec_info->get_content ();
+  struct tui_exec_info_window *exec_info = execution_info;
+  const tui_exec_info_content *exec_content = exec_info->get_content ();
 
   werase (exec_info->handle);
-  for (int cur_line = 1; cur_line <= win_info->content.size (); cur_line++)
+  for (int cur_line = 1; cur_line <= content.size (); cur_line++)
     mvwaddstr (exec_info->handle,
        cur_line,
        0,
-       content[cur_line - 1]);
+       exec_content[cur_line - 1]);
   exec_info->refresh_window ();
 }
 
@@ -676,7 +676,7 @@ void
 tui_source_window_base::update_exec_info ()
 {
   set_exec_info_content ();
-  tui_show_exec_info_content (this);
+  show_exec_info_content ();
 }
 
 void
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 71201e51d89..c902ee0f17e 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -150,6 +150,9 @@ public:
   struct gdbarch *gdbarch = nullptr;
 
   std::vector<tui_source_element> content;
+
+private:
+  void show_exec_info_content ();
 };
 
 /* Update the execution windows to show the active breakpoints.  This
@@ -185,7 +188,6 @@ extern void tui_update_source_windows_with_line (struct symtab *,
  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_exec_info_content (struct tui_source_window_base *);
 extern void tui_erase_exec_info_content (struct tui_source_window_base *);
 extern void tui_clear_exec_info_content (struct tui_source_window_base *);
 
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 16/19] Remove tui_erase_exec_info_content

Tom Tromey-2
In reply to this post by Tom Tromey-2
One call to tui_erase_exec_info_content can be removed.  This call is
not needed because the function in question then immediately sets the
execution info window contents.

Once this is done, tui_clear_exec_info_content is just a wrapper for
the only call to tui_erase_exec_info_content, so
tui_erase_exec_info_content can be renamed and the wrapper function
removed.

gdb/ChangeLog
2019-08-03  Tom Tromey  <[hidden email]>

        * tui/tui-winsource.h (tui_erase_exec_info_content): Don't
        declare.
        * tui/tui-winsource.c (tui_source_window_base::refresh_all): Don't
        call tui_erase_exec_info_content.
        (tui_clear_exec_info_content): Rename from
        tui_erase_exec_info_content.
        (tui_clear_exec_info_content): Delete.
---
 gdb/ChangeLog           | 10 ++++++++++
 gdb/tui/tui-winsource.c |  9 +--------
 gdb/tui/tui-winsource.h |  1 -
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index c99e207b011..ed2af064c47 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -334,7 +334,6 @@ tui_source_window_base::refresh_all ()
 {
   show_source_content ();
   check_and_display_highlight_if_needed ();
-  tui_erase_exec_info_content (this);
   update_exec_info ();
 }
 
@@ -657,7 +656,7 @@ tui_source_window_base::show_exec_info_content ()
 
 
 void
-tui_erase_exec_info_content (struct tui_source_window_base *win_info)
+tui_clear_exec_info_content (struct tui_source_window_base *win_info)
 {
   struct tui_gen_win_info *exec_info = win_info->execution_info;
 
@@ -665,12 +664,6 @@ tui_erase_exec_info_content (struct tui_source_window_base *win_info)
   exec_info->refresh_window ();
 }
 
-void
-tui_clear_exec_info_content (struct tui_source_window_base *win_info)
-{
-  tui_erase_exec_info_content (win_info);
-}
-
 /* Function to update the execution info window.  */
 void
 tui_source_window_base::update_exec_info ()
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index c902ee0f17e..d8a84b01846 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -188,7 +188,6 @@ extern void tui_update_source_windows_with_line (struct symtab *,
  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_erase_exec_info_content (struct tui_source_window_base *);
 extern void tui_clear_exec_info_content (struct tui_source_window_base *);
 
 extern void tui_alloc_source_buffer (struct tui_source_window_base *);
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 17/19] Remove tui_clear_exec_info_content

Tom Tromey-2
In reply to this post by Tom Tromey-2
After the previous patch, all calls to tui_clear_exec_info_content
come just after a call to tui_clear_source_content.  Because these two
windows are linked, I think it makes sense to have
tui_clear_source_content simply do the work.  So, this patch removes
tui_clear_exec_info_content.

gdb/ChangeLog
2019-08-03  Tom Tromey  <[hidden email]>

        * tui/tui-winsource.h (tui_clear_exec_info_content): Don't
        declare.
        * tui/tui-winsource.c (tui_update_source_window_as_is)
        (tui_update_source_windows_with_addr, tui_erase_source_content):
        Update.
        (tui_clear_exec_info_content): Remove.
---
 gdb/ChangeLog           |  9 +++++++++
 gdb/tui/tui-winsource.c | 24 +++++++-----------------
 gdb/tui/tui-winsource.h |  1 -
 3 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index ed2af064c47..2f02c6a0120 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -98,10 +98,7 @@ tui_update_source_window_as_is (struct tui_source_window_base *win_info,
     ret = tui_set_disassem_content (win_info, gdbarch, line_or_addr.u.addr);
 
   if (ret == TUI_FAILURE)
-    {
-      tui_clear_source_content (win_info);
-      tui_clear_exec_info_content (win_info);
-    }
+    tui_clear_source_content (win_info);
   else
     {
       tui_update_breakpoint_info (win_info, nullptr, false);
@@ -156,10 +153,7 @@ tui_update_source_windows_with_addr (struct gdbarch *gdbarch, CORE_ADDR addr)
   else
     {
       for (struct tui_source_window_base *win_info : tui_source_windows ())
- {
-  tui_clear_source_content (win_info);
-  tui_clear_exec_info_content (win_info);
- }
+ tui_clear_source_content (win_info);
     }
 }
 
@@ -244,6 +238,11 @@ tui_erase_source_content (struct tui_source_window_base *win_info)
 
       win_info->content.clear ();
       win_info->refresh_window ();
+
+      struct tui_gen_win_info *exec_info = win_info->execution_info;
+
+      werase (exec_info->handle);
+      exec_info->refresh_window ();
     }
 }
 
@@ -655,15 +654,6 @@ tui_source_window_base::show_exec_info_content ()
 }
 
 
-void
-tui_clear_exec_info_content (struct tui_source_window_base *win_info)
-{
-  struct tui_gen_win_info *exec_info = win_info->execution_info;
-
-  werase (exec_info->handle);
-  exec_info->refresh_window ();
-}
-
 /* Function to update the execution info window.  */
 void
 tui_source_window_base::update_exec_info ()
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index d8a84b01846..e0a96c14dcc 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -188,7 +188,6 @@ extern void tui_update_source_windows_with_line (struct symtab *,
  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_clear_exec_info_content (struct tui_source_window_base *);
 
 extern void tui_alloc_source_buffer (struct tui_source_window_base *);
 extern int tui_line_is_displayed (int,
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 18/19] Don't track the contents of the execution info window

Tom Tromey-2
In reply to this post by Tom Tromey-2
The curses library keeps track of the contents of each window, and can
redraw the screen as needed.  This means that in most cases is no need
for the TUI windows to also keep track of their contents.  This patch
removes content tracking from the execution window, leaving that to
curses.

gdb/ChangeLog
2019-08-03  Tom Tromey  <[hidden email]>

        * tui/tui-winsource.h (struct tui_exec_info_window)
        <~tui_exec_info_window, maybe_allocate_content, get_content,
        m_content>: Remove.
        (struct tui_source_window_base) <set_exec_info_content,
        show_exec_info_content>: Don't declare.
        * tui/tui-winsource.c
        (tui_exec_info_window::maybe_allocate_content): Remove.
        (tui_source_window_base::update_exec_info): Rename from
        set_exec_info_content.
        (tui_source_window_base::show_exec_info_content)
        (tui_source_window_base::update_exec_info): Remove.
---
 gdb/ChangeLog           | 14 +++++++++++
 gdb/tui/tui-winsource.c | 56 ++++++-----------------------------------
 gdb/tui/tui-winsource.h | 22 ----------------
 3 files changed, 22 insertions(+), 70 deletions(-)

diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 2f02c6a0120..1b2b4393fd9 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -587,41 +587,22 @@ tui_update_breakpoint_info (struct tui_source_window_base *win,
   return need_refresh;
 }
 
-/* See tui-data.h.  */
-
-tui_exec_info_content *
-tui_exec_info_window::maybe_allocate_content (int n_elements)
-{
-  if (m_content == nullptr)
-    m_content = XNEWVEC (tui_exec_info_content, n_elements);
-  return m_content;
-}
-
-
 /* Function to initialize the content of the execution info window,
    based upon the input window which is either the source or
    disassembly window.  */
 void
-tui_source_window_base::set_exec_info_content ()
+tui_source_window_base::update_exec_info ()
 {
-  tui_exec_info_content *exec_content
-    = execution_info->maybe_allocate_content (height);
-
+  werase (execution_info->handle);
   tui_update_breakpoint_info (this, nullptr, true);
   for (int i = 0; i < content.size (); i++)
     {
-      tui_exec_info_content &element = exec_content[i];
-      struct tui_source_element *src_element;
-      tui_bp_flags mode;
-
-      src_element = &content[i];
-
-      memset (element, ' ', sizeof (tui_exec_info_content));
-      element[TUI_EXECINFO_SIZE - 1] = 0;
+      struct tui_source_element *src_element = &content[i];
+      char element[TUI_EXECINFO_SIZE] = "   ";
 
       /* Now update the exec info content based upon the state
  of each line as indicated by the source content.  */
-      mode = src_element->break_mode;
+      tui_bp_flags 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))
@@ -634,34 +615,13 @@ tui_source_window_base::set_exec_info_content ()
 
       if (src_element->is_exec_point)
  element[TUI_EXEC_POS] = '>';
-    }
-}
-
 
-void
-tui_source_window_base::show_exec_info_content ()
-{
-  struct tui_exec_info_window *exec_info = execution_info;
-  const tui_exec_info_content *exec_content = exec_info->get_content ();
-
-  werase (exec_info->handle);
-  for (int cur_line = 1; cur_line <= content.size (); cur_line++)
-    mvwaddstr (exec_info->handle,
-       cur_line,
-       0,
-       exec_content[cur_line - 1]);
-  exec_info->refresh_window ();
+      mvwaddstr (execution_info->handle, i + 1, 0, element);
+    }
+  execution_info->refresh_window ();
 }
 
 
-/* Function to update the execution info window.  */
-void
-tui_source_window_base::update_exec_info ()
-{
-  set_exec_info_content ();
-  show_exec_info_content ();
-}
-
 void
 tui_alloc_source_buffer (struct tui_source_window_base *win_info)
 {
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index e0a96c14dcc..abb7ea34816 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -52,24 +52,6 @@ struct tui_exec_info_window : public tui_gen_win_info
     : 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;
 };
 
 /* Elements in the Source/Disassembly Window.  */
@@ -132,7 +114,6 @@ public:
 
   void show_source_content ();
 
-  void set_exec_info_content ();
   void update_exec_info ();
 
   /* Does the locator belong to this window?  */
@@ -150,9 +131,6 @@ public:
   struct gdbarch *gdbarch = nullptr;
 
   std::vector<tui_source_element> content;
-
-private:
-  void show_exec_info_content ();
 };
 
 /* Update the execution windows to show the active breakpoints.  This
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 19/19] Remove tui_gen_win_info::last_visible_line

Tom Tromey-2
In reply to this post by Tom Tromey-2
The last_visible_line field of tui_gen_win_info is not used, so remove
it.

gdb/ChangeLog
2019-08-03  Tom Tromey  <[hidden email]>

        * tui/tui-data.h (struct tui_gen_win_info) <last_visible_line>:
        Remove.
        * tui/tui-data.c (tui_initialize_static_data): Update.
---
 gdb/ChangeLog      | 6 ++++++
 gdb/tui/tui-data.c | 3 +--
 gdb/tui/tui-data.h | 2 --
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index bb725c199cc..add1f33926f 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -262,8 +262,7 @@ tui_initialize_static_data ()
     win->height =
     win->origin.x =
     win->origin.y =
-    win->viewport_height =
-    win->last_visible_line = 0;
+    win->viewport_height = 0;
   win->handle = NULL;
   win->is_visible = false;
   win->title = 0;
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 08178e49ea8..3493b5ed68b 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -79,8 +79,6 @@ public:
   struct tui_point origin = {0, 0};
   /* Viewport height.  */
   int viewport_height = 0;
-  /* Index of last visible line.  */
-  int last_visible_line = 0;
   /* Whether the window is visible or not.  */
   bool is_visible = false;
   /* Window title to display.  */
--
2.17.2

12