[PATCH 0/9] Even more TUI refactorings

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

[PATCH 0/9] Even more TUI refactorings

Tom Tromey-2
Here's another round of TUI refactorings.

This series is a bit shorter than the others because I'm trying to
send refactorings separately from behavior-changing patches, and the
next patch after these does change the TUI in a user-visible way.

Each patch was built and tested using the gdb.tui tests.

Tom


Reply | Threaded
Open this post in threaded view
|

[PATCH 1/9] Remove m_has_locator

Tom Tromey-2
The previous patch removed the only use of m_has_locator, so this
member can now be removed.

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

        * tui/tui-winsource.h (struct tui_source_window_base)
        <m_has_locator>: Remove.
        * tui/tui-layout.c (show_source_disasm_command, show_data)
        (show_source_or_disasm_and_command): Update.
---
 gdb/ChangeLog           | 7 +++++++
 gdb/tui/tui-layout.c    | 7 -------
 gdb/tui/tui-winsource.h | 2 --
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index d81b8f9aa40..b7c5ed63c64 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -504,7 +504,6 @@ show_source_disasm_command (void)
        tui_term_width (),
        0,
        0);
-  TUI_SRC_WIN->m_has_locator = false;
 
   struct tui_locator_window *locator = tui_locator_win_info_ptr ();
   gdb_assert (locator != nullptr);
@@ -520,8 +519,6 @@ show_source_disasm_command (void)
    tui_term_width (),
    0,
    (src_height + asm_height) - 1);
-  TUI_SRC_WIN->m_has_locator = false;
-  TUI_DISASM_WIN->m_has_locator = true;
   TUI_DISASM_WIN->show_source_content ();
 
   if (TUI_CMD_WIN == NULL)
@@ -565,8 +562,6 @@ show_data (enum tui_layout_type new_layout)
  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]->resize (src_height,
   tui_term_width (),
   0,
@@ -578,7 +573,6 @@ show_data (enum tui_layout_type new_layout)
   TUI_CMD_WIN->resize (TUI_CMD_WIN->height, tui_term_width (),
        0, total_height);
 
-  base->m_has_locator = true;
   current_layout = new_layout;
 }
 
@@ -650,7 +644,6 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
     0,
     0);
 
-  win_info->m_has_locator = true;
   win_info->show_source_content ();
 
   if (TUI_CMD_WIN == NULL)
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 7304e726a76..a4167f50d7a 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -138,8 +138,6 @@ public:
   /* Erase the source content.  */
   virtual void erase_source_content () = 0;
 
-  /* 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.  */
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 2/9] Remove separate visibility flag

Tom Tromey-2
In reply to this post by Tom Tromey-2
TUI windows keep track of their visibility in a boolean field.
However, this is not needed, because a window is visible if and only
if it has an underlying curses handle.  So, we can remove this
separate field.

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

        * tui/tui.c (tui_is_window_visible): Update.
        * tui/tui-wingeneral.c (tui_make_window)
        (tui_gen_win_info::make_visible, tui_refresh_all): Update.
        * tui/tui-win.c (window_name_completer, tui_refresh_all_win)
        (tui_set_focus_command, tui_all_windows_info, update_tab_width)
        (tui_set_win_height_command, parse_scrolling_args): Update.
        * tui/tui-source.c (tui_source_window::style_changed): Update.
        * tui/tui-regs.c (tui_show_registers)
        (tui_data_window::first_data_item_displayed)
        (tui_data_window::delete_data_content_windows)
        (tui_check_register_values, tui_reg_command): Update.
        * tui/tui-disasm.c (tui_show_disassem): Update.
        * tui/tui-data.h (struct tui_gen_win_info) <is_visible>: New
        method.
        <is_visible>: Remove field.
        * tui/tui-data.c (tui_next_win, tui_prev_win)
        (tui_delete_invisible_windows): Update.
---
 gdb/ChangeLog            | 20 ++++++++++++++++++++
 gdb/tui/tui-data.c       |  6 +++---
 gdb/tui/tui-data.h       |  8 ++++++--
 gdb/tui/tui-disasm.c     |  2 +-
 gdb/tui/tui-regs.c       |  9 ++++-----
 gdb/tui/tui-source.c     |  2 +-
 gdb/tui/tui-win.c        | 14 +++++++-------
 gdb/tui/tui-wingeneral.c |  8 +++-----
 gdb/tui/tui.c            |  2 +-
 9 files changed, 46 insertions(+), 25 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index dc2c810b0c1..9b80aca028e 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -148,7 +148,7 @@ tui_next_win (struct tui_win_info *cur_win)
   while (type != cur_win->type && (next_win == NULL))
     {
       if (tui_win_list[type]
-  && tui_win_list[type]->is_visible)
+  && tui_win_list[type]->is_visible ())
  next_win = tui_win_list[type];
       else
  {
@@ -178,7 +178,7 @@ tui_prev_win (struct tui_win_info *cur_win)
   while (type != cur_win->type && (prev == NULL))
     {
       if (tui_win_list[type]
-  && tui_win_list[type]->is_visible)
+  && tui_win_list[type]->is_visible ())
  prev = tui_win_list[type];
       else
  {
@@ -220,7 +220,7 @@ 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)
+  && !tui_win_list[win_type]->is_visible ())
  {
   /* This should always be made visible before a call to this
      function.  */
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 6c7ab056b48..7993c639376 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -79,6 +79,12 @@ public:
     return false;
   }
 
+  /* Return true if this window is visible.  */
+  bool is_visible () const
+  {
+    return handle != nullptr;
+  }
+
   /* Window handle.  */
   WINDOW *handle = nullptr;
   /* Type of window.  */
@@ -91,8 +97,6 @@ public:
   struct tui_point origin = {0, 0};
   /* Viewport height.  */
   int viewport_height = 0;
-  /* Whether the window is visible or not.  */
-  bool is_visible = false;
   /* Window title to display.  */
   char *title = nullptr;
 };
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 23943947085..3ebe303f751 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -253,7 +253,7 @@ 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);
+  gdb_assert (TUI_DISASM_WIN != nullptr && TUI_DISASM_WIN->is_visible ());
 
   val.loa = LOA_ADDRESS;
   val.u.addr = start_addr;
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 89faefa8f60..36973ff51ae 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -138,7 +138,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)
+  if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->is_visible ())
     tui_reg_layout ();
 
   if (group == 0)
@@ -411,7 +411,7 @@ tui_data_window::first_data_item_displayed ()
       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)
+      if (data_item_win->is_visible ())
  return i;
     }
 
@@ -427,7 +427,6 @@ tui_data_window::delete_data_content_windows ()
     {
       tui_delete_win (win->handle);
       win->handle = NULL;
-      win->is_visible = false;
     }
 }
 
@@ -552,7 +551,7 @@ void
 tui_check_register_values (struct frame_info *frame)
 {
   if (TUI_DATA_WIN != NULL
-      && TUI_DATA_WIN->is_visible)
+      && TUI_DATA_WIN->is_visible ())
     {
       if (TUI_DATA_WIN->regs_content.empty ()
   && TUI_DATA_WIN->display_regs)
@@ -667,7 +666,7 @@ tui_reg_command (const char *args, int from_tty)
       /* Make sure the register window is visible.  If not, select an
  appropriate layout.  We need to do this before trying to run the
  'next' or 'prev' commands.  */
-      if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->is_visible)
+      if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->is_visible ())
  tui_reg_layout ();
 
       struct reggroup *current_group = NULL;
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 3d88f66d549..c86af84423e 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -279,7 +279,7 @@ tui_source_window::~tui_source_window ()
 void
 tui_source_window::style_changed ()
 {
-  if (tui_active && is_visible)
+  if (tui_active && is_visible ())
     refill ();
 }
 
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 872e002b6cb..64e38880a2c 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -367,7 +367,7 @@ window_name_completer (completion_tracker &tracker,
       const char *completion_name = NULL;
 
       /* We can't focus on an invisible window.  */
-      if (!win_info->is_visible)
+      if (!win_info->is_visible ())
  continue;
 
       completion_name = win_info->name ();
@@ -506,7 +506,7 @@ tui_refresh_all_win (void)
   tui_refresh_all ();
   for (tui_win_info *win_info : all_tui_windows ())
     {
-      if (win_info->is_visible)
+      if (win_info->is_visible ())
  win_info->refresh_all ();
     }
   tui_show_locator_content ();
@@ -813,7 +813,7 @@ tui_set_focus_command (const char *arg, int from_tty)
       else
  win_info = tui_partial_win_by_name (buf_ptr);
 
-      if (win_info == NULL || !win_info->is_visible)
+      if (win_info == NULL || !win_info->is_visible ())
  warning (_("Invalid window specified. \n\
 The window name specified must be valid and visible.\n"));
       else
@@ -836,7 +836,7 @@ tui_all_windows_info (const char *arg, int from_tty)
   struct tui_win_info *win_with_focus = tui_win_with_focus ();
 
   for (tui_win_info *win_info : all_tui_windows ())
-    if (win_info->is_visible)
+    if (win_info->is_visible ())
       {
  if (win_with_focus == win_info)
   printf_filtered ("        %s\t(%d lines)  <has focus>\n",
@@ -875,7 +875,7 @@ update_tab_width ()
 {
   for (tui_win_info *win_info : all_tui_windows ())
     {
-      if (win_info->is_visible)
+      if (win_info->is_visible ())
  win_info->update_tab_width ();
     }
 }
@@ -956,7 +956,7 @@ tui_set_win_height_command (const char *arg, int from_tty)
     wname[i] = tolower (wname[i]);
   win_info = tui_partial_win_by_name (wname);
 
-  if (win_info == NULL || !win_info->is_visible)
+  if (win_info == NULL || !win_info->is_visible ())
     warning (_("Invalid window specified. \n\
 The window name specified must be valid and visible.\n"));
   else
@@ -1347,7 +1347,7 @@ parse_scrolling_args (const char *arg,
 
   if (*win_to_scroll == NULL)
     error (_("Unrecognized window `%s'"), wname);
-  if (!(*win_to_scroll)->is_visible)
+  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 ().begin ());
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 52583cfb8ac..4e565bdc653 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -139,7 +139,6 @@ tui_make_window (struct tui_gen_win_info *win_info)
     {
       if (win_info->can_box ())
  box_win (win_info, NO_HILITE);
-      win_info->is_visible = true;
       scrollok (handle, TRUE);
     }
 }
@@ -151,9 +150,8 @@ tui_make_window (struct tui_gen_win_info *win_info)
 void
 tui_gen_win_info::make_visible (bool visible)
 {
-  if (is_visible == visible)
+  if (is_visible () == visible)
     return;
-  is_visible = visible;
 
   if (visible)
     tui_make_window (this);
@@ -182,10 +180,10 @@ tui_refresh_all ()
 
   for (tui_win_info *win_info : all_tui_windows ())
     {
-      if (win_info->is_visible)
+      if (win_info->is_visible ())
  win_info->refresh_window ();
     }
-  if (locator->is_visible)
+  if (locator->is_visible ())
     locator->refresh_window ();
 }
 
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index e0eb12fb833..db34e0c0441 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -661,7 +661,7 @@ tui_is_window_visible (enum tui_win_type type)
   if (tui_win_list[type] == 0)
     return false;
   
-  return tui_win_list[type]->is_visible;
+  return tui_win_list[type]->is_visible ();
 }
 
 int
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 3/9] Remove "noerror" parameter from some TUI functions

Tom Tromey-2
In reply to this post by Tom Tromey-2
A few TUI functions take a "noerror" parameter.  This is only checked
in one spot: in tui_set_source_content, if noerror is false, and if an
error occurs, then the function will call print_sys_errmsg.

This seems misguided to me, so this patch removes that code and this
parameter.

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

        * tui/tui-winsource.h (tui_update_source_window)
        (tui_update_source_window_as_is): Remove "noerror" parameter.
        * tui/tui-winsource.c (tui_update_source_window)
        (tui_update_source_window_as_is): Remove "noerror" parameter.
        (tui_update_source_windows_with_addr)
        (tui_update_source_windows_with_line)
        (tui_source_window_base::rerender)
        (tui_source_window_base::refill): Update.
        * tui/tui-source.h (tui_set_source_content)
        (tui_show_symtab_source): Remove "noerror" parameter.
        * tui/tui-source.c (tui_set_source_content): Remove "noerror"
        parameter.
        (tui_show_symtab_source): Likewise.
        (tui_source_window::maybe_update): Update.
        * tui/tui-disasm.c (tui_show_disassem)
        (tui_show_disassem_and_update_source)
        (tui_disasm_window::do_scroll_vertical)
        (tui_disasm_window::maybe_update): Update.
---
 gdb/ChangeLog           | 21 +++++++++++++++++++++
 gdb/tui/tui-disasm.c    |  8 ++++----
 gdb/tui/tui-source.c    | 22 +++++-----------------
 gdb/tui/tui-source.h    |  5 ++---
 gdb/tui/tui-winsource.c | 22 +++++++++-------------
 gdb/tui/tui-winsource.h |  6 ++----
 6 files changed, 43 insertions(+), 41 deletions(-)

diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 3ebe303f751..621832ff92a 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -257,7 +257,7 @@ tui_show_disassem (struct gdbarch *gdbarch, CORE_ADDR start_addr)
 
   val.loa = LOA_ADDRESS;
   val.u.addr = start_addr;
-  tui_update_source_window (TUI_DISASM_WIN, gdbarch, s, val, FALSE);
+  tui_update_source_window (TUI_DISASM_WIN, gdbarch, s, val);
 
   /* If the focus was in the src win, put it in the asm win, if the
      source view isn't split.  */
@@ -285,7 +285,7 @@ tui_show_disassem_and_update_source (struct gdbarch *gdbarch,
       sal = find_pc_line (start_addr, 0);
       val.loa = LOA_LINE;
       val.u.line_no = sal.line;
-      tui_update_source_window (TUI_SRC_WIN, gdbarch, sal.symtab, val, TRUE);
+      tui_update_source_window (TUI_SRC_WIN, gdbarch, sal.symtab, val);
       if (sal.symtab)
  {
   set_current_source_symtab_and_line (sal);
@@ -368,7 +368,7 @@ tui_disasm_window::do_scroll_vertical (int num_to_scroll)
       val.loa = LOA_ADDRESS;
       val.u.addr = tui_find_disassembly_address (gdbarch, pc, num_to_scroll);
       tui_update_source_window_as_is (this, gdbarch,
-      NULL, val, FALSE);
+      NULL, val);
     }
 }
 
@@ -420,7 +420,7 @@ tui_disasm_window::maybe_update (struct frame_info *fi, symtab_and_line sal,
   a.u.addr = low;
   if (!addr_is_displayed (addr))
     tui_update_source_window (this, get_frame_arch (fi),
-      sal.symtab, a, TRUE);
+      sal.symtab, a);
   else
     {
       a.u.addr = addr;
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index c86af84423e..db83fb01138 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -125,8 +125,7 @@ copy_source_line (const char **ptr, int line_no, int first_col,
 enum tui_status
 tui_set_source_content (tui_source_window_base *win_info,
  struct symtab *s,
- int line_no,
- int noerror)
+ int line_no)
 {
   enum tui_status ret = TUI_FAILURE;
 
@@ -143,17 +142,7 @@ tui_set_source_content (tui_source_window_base *win_info,
       std::string srclines;
       if (!g_source_cache.get_source_lines (s, line_no, line_no + nlines,
     &srclines))
- {
-  if (!noerror)
-    {
-      const char *filename = symtab_to_filename_for_display (s);
-      char *name = (char *) alloca (strlen (filename) + 100);
-
-      sprintf (name, "%s:%d", filename, line_no);
-      print_sys_errmsg (name, errno);
-    }
-  ret = TUI_FAILURE;
- }
+ ret = TUI_FAILURE;
       else
  {
   int cur_line_no, cur_line;
@@ -213,11 +202,10 @@ tui_set_source_content (tui_source_window_base *win_info,
 void
 tui_show_symtab_source (tui_source_window_base *win_info,
  struct gdbarch *gdbarch, struct symtab *s,
- struct tui_line_or_address line,
- int noerror)
+ struct tui_line_or_address line)
 {
   win_info->horizontal_offset = 0;
-  tui_update_source_window_as_is (win_info, gdbarch, s, line, noerror);
+  tui_update_source_window_as_is (win_info, gdbarch, s, line);
 }
 
 
@@ -330,7 +318,7 @@ tui_source_window::maybe_update (struct frame_info *fi, symtab_and_line sal,
   if (!(source_already_displayed
  && line_is_displayed (line_no)))
     tui_update_source_window (this, get_frame_arch (fi),
-      sal.symtab, l, TRUE);
+      sal.symtab, l);
   else
     {
       l.u.line_no = line_no;
diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
index 2926777ab3f..1d7af2aad83 100644
--- a/gdb/tui/tui-source.h
+++ b/gdb/tui/tui-source.h
@@ -74,10 +74,9 @@ private:
 
 extern enum tui_status tui_set_source_content (tui_source_window_base *,
        struct symtab *,
-       int, int);
+       int);
 extern void tui_show_symtab_source (tui_source_window_base *,
     struct gdbarch *, struct symtab *,
-    struct tui_line_or_address,
-    int);
+    struct tui_line_or_address);
 
 #endif /* TUI_TUI_SOURCE_H */
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index b6ce652d09d..94ab8c09f67 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -73,11 +73,10 @@ void
 tui_update_source_window (struct tui_source_window_base *win_info,
   struct gdbarch *gdbarch,
   struct symtab *s,
-  struct tui_line_or_address line_or_addr,
-  int noerror)
+  struct tui_line_or_address line_or_addr)
 {
   win_info->horizontal_offset = 0;
-  tui_update_source_window_as_is (win_info, gdbarch, s, line_or_addr, noerror);
+  tui_update_source_window_as_is (win_info, gdbarch, s, line_or_addr);
 }
 
 
@@ -87,14 +86,12 @@ void
 tui_update_source_window_as_is (struct tui_source_window_base *win_info,
  struct gdbarch *gdbarch,
  struct symtab *s,
- struct tui_line_or_address line_or_addr,
- int noerror)
+ struct tui_line_or_address line_or_addr)
 {
   enum tui_status ret;
 
   if (win_info->type == SRC_WIN)
-    ret = tui_set_source_content (win_info, s, line_or_addr.u.line_no,
-  noerror);
+    ret = tui_set_source_content (win_info, s, line_or_addr.u.line_no);
   else
     ret = tui_set_disassem_content (win_info, gdbarch, line_or_addr.u.addr);
 
@@ -147,7 +144,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 (TUI_SRC_WIN, gdbarch, sal.symtab, l, FALSE);
+  tui_show_symtab_source (TUI_SRC_WIN, gdbarch, sal.symtab, l);
   break;
  }
     }
@@ -182,7 +179,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 (TUI_SRC_WIN, gdbarch, s, l, FALSE);
+      tui_show_symtab_source (TUI_SRC_WIN, gdbarch, s, l);
       if (tui_current_layout () == SRC_DISASSEM_COMMAND)
  {
   find_line_pc (s, line, &pc);
@@ -330,7 +327,7 @@ tui_source_window_base::rerender ()
 
       line_or_addr = start_line_or_addr;
       tui_update_source_window (this, gdbarch,
- cursal.symtab, line_or_addr, TRUE);
+ cursal.symtab, line_or_addr);
     }
   else if (deprecated_safe_get_selected_frame () != NULL)
     {
@@ -351,7 +348,7 @@ tui_source_window_base::rerender ()
   line.loa = LOA_ADDRESS;
   find_line_pc (s, cursal.line, &line.u.addr);
  }
-      tui_update_source_window (this, gdbarch, s, line, TRUE);
+      tui_update_source_window (this, gdbarch, s, line);
     }
   else
     erase_source_content ();
@@ -391,8 +388,7 @@ tui_source_window_base::refill ()
     }
 
   tui_update_source_window_as_is (this, gdbarch, s,
-  content[0].line_or_addr,
-  FALSE);
+  content[0].line_or_addr);
 }
 
 /* Scroll the source forward or backward horizontally.  */
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index a4167f50d7a..dfd4a0002a8 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -245,12 +245,10 @@ extern bool tui_update_breakpoint_info (struct tui_source_window_base *win,
 extern void tui_display_main (void);
 extern void tui_update_source_window (struct tui_source_window_base *,
       struct gdbarch *, struct symtab *,
-      struct tui_line_or_address,
-      int);
+      struct tui_line_or_address);
 extern void tui_update_source_window_as_is (struct tui_source_window_base *,
     struct gdbarch *, struct symtab *,
-    struct tui_line_or_address,
-    int);
+    struct tui_line_or_address);
 extern void tui_update_source_windows_with_addr (struct gdbarch *, CORE_ADDR);
 extern void tui_update_source_windows_with_line (struct symtab *,
  int);
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 4/9] Change tui_update_source_window_as_is to be a method

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

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

        * tui/tui-winsource.h (struct tui_source_window_base)
        <update_source_window_as_is>: Declare.
        (tui_update_source_window_as_is): Don't declare.
        * tui/tui-winsource.c (tui_update_source_window): Update
        (tui_source_window_base::update_source_window_as_is): Rename from
        tui_update_source_window_as_is.
        (tui_source_window_base::refill): Update.
        * tui/tui-source.c (tui_show_symtab_source): Update.
        * tui/tui-disasm.c (tui_disasm_window::do_scroll_vertical):
        Update.
---
 gdb/ChangeLog           | 13 +++++++++++++
 gdb/tui/tui-disasm.c    |  3 +--
 gdb/tui/tui-source.c    |  2 +-
 gdb/tui/tui-winsource.c | 34 ++++++++++++++++------------------
 gdb/tui/tui-winsource.h |  7 ++++---
 5 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 621832ff92a..d47639c4c77 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -367,8 +367,7 @@ tui_disasm_window::do_scroll_vertical (int num_to_scroll)
 
       val.loa = LOA_ADDRESS;
       val.u.addr = tui_find_disassembly_address (gdbarch, pc, num_to_scroll);
-      tui_update_source_window_as_is (this, gdbarch,
-      NULL, val);
+      update_source_window_as_is (gdbarch, NULL, val);
     }
 }
 
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index db83fb01138..e62d999fe3e 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -205,7 +205,7 @@ tui_show_symtab_source (tui_source_window_base *win_info,
  struct tui_line_or_address line)
 {
   win_info->horizontal_offset = 0;
-  tui_update_source_window_as_is (win_info, gdbarch, s, line);
+  win_info->update_source_window_as_is (gdbarch, s, line);
 }
 
 
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 94ab8c09f67..2c747eb42a9 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -76,38 +76,37 @@ tui_update_source_window (struct tui_source_window_base *win_info,
   struct tui_line_or_address line_or_addr)
 {
   win_info->horizontal_offset = 0;
-  tui_update_source_window_as_is (win_info, gdbarch, s, line_or_addr);
+  win_info->update_source_window_as_is (gdbarch, s, line_or_addr);
 }
 
 
 /* Function to display source in the source/asm window.  This function
    shows the source as specified by the horizontal offset.  */
 void
-tui_update_source_window_as_is (struct tui_source_window_base *win_info,
- struct gdbarch *gdbarch,
- struct symtab *s,
- struct tui_line_or_address line_or_addr)
+tui_source_window_base::update_source_window_as_is
+  (struct gdbarch *gdbarch,
+   struct symtab *s,
+   struct tui_line_or_address line_or_addr)
 {
   enum tui_status ret;
 
-  if (win_info->type == SRC_WIN)
-    ret = tui_set_source_content (win_info, s, line_or_addr.u.line_no);
+  if (type == SRC_WIN)
+    ret = tui_set_source_content (this, s, line_or_addr.u.line_no);
   else
-    ret = tui_set_disassem_content (win_info, gdbarch, line_or_addr.u.addr);
+    ret = tui_set_disassem_content (this, gdbarch, line_or_addr.u.addr);
 
   if (ret == TUI_FAILURE)
-    win_info->erase_source_content ();
+    erase_source_content ();
   else
     {
-      tui_update_breakpoint_info (win_info, nullptr, false);
-      win_info->show_source_content ();
-      win_info->update_exec_info ();
-      if (win_info->type == SRC_WIN)
+      tui_update_breakpoint_info (this, nullptr, false);
+      show_source_content ();
+      update_exec_info ();
+      if (type == SRC_WIN)
  {
   symtab_and_line sal;
 
-  sal.line = line_or_addr.u.line_no +
-    (win_info->content.size () - 2);
+  sal.line = line_or_addr.u.line_no + (content.size () - 2);
   sal.symtab = s;
   sal.pspace = SYMTAB_PSPACE (s);
   set_current_source_symtab_and_line (sal);
@@ -115,7 +114,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 (win_info);
+    tui_set_win_focus_to (this);
  }
     }
 }
@@ -387,8 +386,7 @@ tui_source_window_base::refill ()
    : cursal.symtab);
     }
 
-  tui_update_source_window_as_is (this, gdbarch, s,
-  content[0].line_or_addr);
+  update_source_window_as_is (gdbarch, s, content[0].line_or_addr);
 }
 
 /* Scroll the source forward or backward horizontally.  */
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index dfd4a0002a8..ebc50e71e03 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -135,6 +135,10 @@ public:
   virtual void maybe_update (struct frame_info *fi, symtab_and_line sal,
      int line_no, CORE_ADDR addr) = 0;
 
+  void update_source_window_as_is  (struct gdbarch *gdbarch,
+    struct symtab *s,
+    struct tui_line_or_address line_or_addr);
+
   /* Erase the source content.  */
   virtual void erase_source_content () = 0;
 
@@ -246,9 +250,6 @@ extern void tui_display_main (void);
 extern void tui_update_source_window (struct tui_source_window_base *,
       struct gdbarch *, struct symtab *,
       struct tui_line_or_address);
-extern void tui_update_source_window_as_is (struct tui_source_window_base *,
-    struct gdbarch *, struct symtab *,
-    struct tui_line_or_address);
 extern void tui_update_source_windows_with_addr (struct gdbarch *, CORE_ADDR);
 extern void tui_update_source_windows_with_line (struct symtab *,
  int);
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 5/9] Change tui_update_source_window to be a method

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

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

        * tui/tui-winsource.h (struct tui_source_window_base)
        <update_source_window>: Declare.
        (tui_update_source_window): Don't declare.
        * tui/tui-winsource.c
        (tui_source_window_base::update_source_window): Rename from
        tui_update_source_window.
        (tui_source_window_base::rerender): Update.
        * tui/tui-source.c (tui_source_window::maybe_update): Update.
        * tui/tui-disasm.c (tui_show_disassem)
        (tui_show_disassem_and_update_source)
        (tui_disasm_window::maybe_update): Update.
---
 gdb/ChangeLog           | 14 ++++++++++++++
 gdb/tui/tui-disasm.c    |  7 +++----
 gdb/tui/tui-source.c    |  3 +--
 gdb/tui/tui-winsource.c | 17 ++++++++---------
 gdb/tui/tui-winsource.h |  6 +++---
 5 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index d47639c4c77..221e48e661a 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -257,7 +257,7 @@ tui_show_disassem (struct gdbarch *gdbarch, CORE_ADDR start_addr)
 
   val.loa = LOA_ADDRESS;
   val.u.addr = start_addr;
-  tui_update_source_window (TUI_DISASM_WIN, gdbarch, s, val);
+  TUI_DISASM_WIN->update_source_window (gdbarch, s, val);
 
   /* If the focus was in the src win, put it in the asm win, if the
      source view isn't split.  */
@@ -285,7 +285,7 @@ tui_show_disassem_and_update_source (struct gdbarch *gdbarch,
       sal = find_pc_line (start_addr, 0);
       val.loa = LOA_LINE;
       val.u.line_no = sal.line;
-      tui_update_source_window (TUI_SRC_WIN, gdbarch, sal.symtab, val);
+      TUI_SRC_WIN->update_source_window (gdbarch, sal.symtab, val);
       if (sal.symtab)
  {
   set_current_source_symtab_and_line (sal);
@@ -418,8 +418,7 @@ tui_disasm_window::maybe_update (struct frame_info *fi, symtab_and_line sal,
   a.loa = LOA_ADDRESS;
   a.u.addr = low;
   if (!addr_is_displayed (addr))
-    tui_update_source_window (this, get_frame_arch (fi),
-      sal.symtab, a);
+    update_source_window (get_frame_arch (fi), sal.symtab, a);
   else
     {
       a.u.addr = addr;
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index e62d999fe3e..f08bd88aeff 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -317,8 +317,7 @@ tui_source_window::maybe_update (struct frame_info *fi, symtab_and_line sal,
   l.u.line_no = start_line;
   if (!(source_already_displayed
  && line_is_displayed (line_no)))
-    tui_update_source_window (this, get_frame_arch (fi),
-      sal.symtab, l);
+    update_source_window (get_frame_arch (fi), sal.symtab, l);
   else
     {
       l.u.line_no = line_no;
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 2c747eb42a9..3d1d6c4a97e 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -70,13 +70,13 @@ tui_display_main ()
 /* Function to display source in the source window.  This function
    initializes the horizontal scroll to 0.  */
 void
-tui_update_source_window (struct tui_source_window_base *win_info,
-  struct gdbarch *gdbarch,
-  struct symtab *s,
-  struct tui_line_or_address line_or_addr)
+tui_source_window_base::update_source_window
+  (struct gdbarch *gdbarch,
+   struct symtab *s,
+   struct tui_line_or_address line_or_addr)
 {
-  win_info->horizontal_offset = 0;
-  win_info->update_source_window_as_is (gdbarch, s, line_or_addr);
+  horizontal_offset = 0;
+  update_source_window_as_is (gdbarch, s, line_or_addr);
 }
 
 
@@ -325,8 +325,7 @@ tui_source_window_base::rerender ()
  = get_current_source_symtab_and_line ();
 
       line_or_addr = start_line_or_addr;
-      tui_update_source_window (this, gdbarch,
- cursal.symtab, line_or_addr);
+      update_source_window (gdbarch, cursal.symtab, line_or_addr);
     }
   else if (deprecated_safe_get_selected_frame () != NULL)
     {
@@ -347,7 +346,7 @@ tui_source_window_base::rerender ()
   line.loa = LOA_ADDRESS;
   find_line_pc (s, cursal.line, &line.u.addr);
  }
-      tui_update_source_window (this, gdbarch, s, line);
+      update_source_window (gdbarch, s, line);
     }
   else
     erase_source_content ();
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index ebc50e71e03..80608b5d733 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -138,6 +138,9 @@ public:
   void update_source_window_as_is  (struct gdbarch *gdbarch,
     struct symtab *s,
     struct tui_line_or_address line_or_addr);
+  void update_source_window (struct gdbarch *gdbarch,
+     struct symtab *s,
+     struct tui_line_or_address line_or_addr);
 
   /* Erase the source content.  */
   virtual void erase_source_content () = 0;
@@ -247,9 +250,6 @@ extern bool tui_update_breakpoint_info (struct tui_source_window_base *win,
 
 /* Function to display the "main" routine.  */
 extern void tui_display_main (void);
-extern void tui_update_source_window (struct tui_source_window_base *,
-      struct gdbarch *, struct symtab *,
-      struct tui_line_or_address);
 extern void tui_update_source_windows_with_addr (struct gdbarch *, CORE_ADDR);
 extern void tui_update_source_windows_with_line (struct symtab *,
  int);
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 6/9] Change tui_update_breakpoint_info to be a method

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

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

        * tui/tui-winsource.h (struct tui_source_window_base)
        <update_breakpoint_info>: Declare.
        (tui_update_breakpoint_info): Don't declare.
        * tui/tui-winsource.c (tui_source_window_base::update_source_window_as_is)
        (tui_update_all_breakpoint_info): Update.
        (tui_source_window_base::update_breakpoint_info): Rename from
        tui_update_breakpoint_info.
        (tui_source_window_base::update_exec_info): Update.
---
 gdb/ChangeLog           | 11 +++++++++++
 gdb/tui/tui-winsource.c | 21 +++++++++------------
 gdb/tui/tui-winsource.h | 17 ++++++++---------
 3 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 3d1d6c4a97e..d0e18791e4a 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -99,7 +99,7 @@ tui_source_window_base::update_source_window_as_is
     erase_source_content ();
   else
     {
-      tui_update_breakpoint_info (this, nullptr, false);
+      update_breakpoint_info (nullptr, false);
       show_source_content ();
       update_exec_info ();
       if (type == SRC_WIN)
@@ -448,10 +448,8 @@ tui_update_all_breakpoint_info (struct breakpoint *being_deleted)
 {
   for (tui_source_window_base *win : tui_source_windows ())
     {
-      if (tui_update_breakpoint_info (win, being_deleted, false))
-        {
-          win->update_exec_info ();
-        }
+      if (win->update_breakpoint_info (being_deleted, false))
+ win->update_exec_info ();
     }
 }
 
@@ -463,20 +461,19 @@ tui_update_all_breakpoint_info (struct breakpoint *being_deleted)
    refreshed.  */
 
 bool
-tui_update_breakpoint_info (struct tui_source_window_base *win,
-    struct breakpoint *being_deleted,
-    bool current_only)
+tui_source_window_base::update_breakpoint_info
+  (struct breakpoint *being_deleted, bool current_only)
 {
   int i;
   bool need_refresh = false;
 
-  for (i = 0; i < win->content.size (); i++)
+  for (i = 0; i < content.size (); i++)
     {
       struct breakpoint *bp;
       extern struct breakpoint *breakpoint_chain;
       struct tui_source_element *line;
 
-      line = &win->content[i];
+      line = &content[i];
       if (current_only && !line->is_exec_point)
          continue;
 
@@ -498,7 +495,7 @@ tui_update_breakpoint_info (struct tui_source_window_base *win,
 
   for (loc = bp->loc; loc != NULL; loc = loc->next)
     {
-      if (win->location_matches_p (loc, i))
+      if (location_matches_p (loc, i))
  {
   if (bp->enable_state == bp_disabled)
     mode |= TUI_BP_DISABLED;
@@ -529,7 +526,7 @@ void
 tui_source_window_base::update_exec_info ()
 {
   werase (execution_info->handle);
-  tui_update_breakpoint_info (this, nullptr, true);
+  update_breakpoint_info (nullptr, true);
   for (int i = 0; i < content.size (); i++)
     {
       struct tui_source_element *src_element = &content[i];
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 80608b5d733..30b29ca8fdc 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -142,6 +142,14 @@ public:
      struct symtab *s,
      struct tui_line_or_address line_or_addr);
 
+  /* Scan the source window and the breakpoints to update the
+     break_mode 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.  */
+  bool update_breakpoint_info (struct breakpoint *being_deleted,
+       bool current_only);
+
   /* Erase the source content.  */
   virtual void erase_source_content () = 0;
 
@@ -239,15 +247,6 @@ struct tui_source_windows
    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 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);
 extern void tui_update_source_windows_with_addr (struct gdbarch *, CORE_ADDR);
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 7/9] Introduce tui_source_window_base::set_contents method

Tom Tromey-2
In reply to this post by Tom Tromey-2
This introduces the tui_source_window_base::set_contents method and
implements it in the subclasses.  This removes a check of the window
type.

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

        * tui/tui-winsource.h (struct tui_source_window_base)
        <set_contents>: Declare.
        * tui/tui-winsource.c
        (tui_source_window_base::update_source_window_as_is): Update.
        * tui/tui-source.h (struct tui_source_window) <set_contents>:
        Declare.
        (tui_set_source_content): Don't declare.
        * tui/tui-source.c (tui_source_window::set_contents): Rename from
        tui_set_source_content.
        * tui/tui-disasm.h (struct tui_disasm_window) <set_contents>:
        Declare.
        (tui_set_disassem_content): Don't declare.
        * tui/tui-disasm.c (tui_disasm_window::set_contents): Rename from
        tui_set_disassem_content.
---
 gdb/ChangeLog           | 17 +++++++++++++++++
 gdb/tui/tui-disasm.c    | 23 +++++++++++++----------
 gdb/tui/tui-disasm.h    |  7 +++++--
 gdb/tui/tui-source.c    | 38 ++++++++++++++++++++------------------
 gdb/tui/tui-source.h    |  8 +++++---
 gdb/tui/tui-winsource.c |  8 ++------
 gdb/tui/tui-winsource.h |  5 +++++
 7 files changed, 67 insertions(+), 39 deletions(-)

diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 221e48e661a..2a291831e27 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -162,11 +162,12 @@ 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 (tui_source_window_base *win_info,
-  struct gdbarch *gdbarch, CORE_ADDR pc)
+tui_disasm_window::set_contents (struct gdbarch *arch,
+ struct symtab *s,
+ struct tui_line_or_address line_or_addr)
 {
   int i;
-  int offset = win_info->horizontal_offset;
+  int offset = horizontal_offset;
   int max_lines, line_width;
   CORE_ADDR cur_pc;
   struct tui_locator_window *locator = tui_locator_win_info_ptr ();
@@ -176,17 +177,19 @@ tui_set_disassem_content (tui_source_window_base *win_info,
   int addr_size, insn_size;
   char *line;
   
+  gdb_assert (line_or_addr.loa == LOA_ADDRESS);
+  CORE_ADDR pc = line_or_addr.u.addr;
   if (pc == 0)
     return TUI_FAILURE;
 
-  win_info->gdbarch = gdbarch;
-  win_info->start_line_or_addr.loa = LOA_ADDRESS;
-  win_info->start_line_or_addr.u.addr = pc;
+  gdbarch = arch;
+  start_line_or_addr.loa = LOA_ADDRESS;
+  start_line_or_addr.u.addr = pc;
   cur_pc = locator->addr;
 
   /* Window size, excluding highlight box.  */
-  max_lines = win_info->height - 2;
-  line_width = win_info->width - 2;
+  max_lines = height - 2;
+  line_width = width - 2;
 
   /* Get temporary table that will hold all strings (addr & insn).  */
   asm_lines = XALLOCAVEC (struct tui_asm_line, max_lines);
@@ -216,12 +219,12 @@ tui_set_disassem_content (tui_source_window_base *win_info,
   line = (char*) alloca (insn_pos + insn_size + 1);
 
   /* Now construct each line.  */
-  win_info->content.resize (max_lines);
+  content.resize (max_lines);
   for (i = 0; i < max_lines; i++)
     {
       int cur_len;
 
-      tui_source_element *src = &win_info->content[i];
+      tui_source_element *src = &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 0ebe42acb0a..d9895322487 100644
--- a/gdb/tui/tui-disasm.h
+++ b/gdb/tui/tui-disasm.h
@@ -57,14 +57,17 @@ protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
 
+  enum tui_status set_contents
+    (struct gdbarch *gdbarch,
+     struct symtab *s,
+     struct tui_line_or_address line_or_addr) override;
+
 private:
   /* Answer whether a particular line number or address is displayed
      in the current source window.  */
   bool addr_is_displayed (CORE_ADDR addr) const;
 };
 
-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-source.c b/gdb/tui/tui-source.c
index f08bd88aeff..9eb7c48472e 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -123,10 +123,13 @@ 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 (tui_source_window_base *win_info,
- struct symtab *s,
- int line_no)
+tui_source_window::set_contents (struct gdbarch *arch,
+ struct symtab *s,
+ struct tui_line_or_address line_or_addr)
 {
+  gdb_assert (line_or_addr.loa == LOA_LINE);
+  int line_no = line_or_addr.u.line_no;
+
   enum tui_status ret = TUI_FAILURE;
 
   if (s != NULL)
@@ -134,10 +137,10 @@ tui_set_source_content (tui_source_window_base *win_info,
       int line_width, nlines;
 
       ret = TUI_SUCCESS;
-      line_width = win_info->width - 1;
+      line_width = width - 1;
       /* Take hilite (window border) into account, when
  calculating the number of lines.  */
-      nlines = (line_no + (win_info->height - 2)) - line_no;
+      nlines = (line_no + (height - 2)) - line_no;
 
       std::string srclines;
       if (!g_source_cache.get_source_lines (s, line_no, line_no + nlines,
@@ -150,28 +153,27 @@ tui_set_source_content (tui_source_window_base *win_info,
     = tui_locator_win_info_ptr ();
   const char *s_filename = symtab_to_filename_for_display (s);
 
-  xfree (win_info->title);
-  win_info->title = xstrdup (s_filename);
+  xfree (title);
+  title = xstrdup (s_filename);
 
-  xfree (win_info->fullname);
-  win_info->fullname = xstrdup (symtab_to_fullname (s));
+  xfree (fullname);
+  fullname = xstrdup (symtab_to_fullname (s));
 
   cur_line = 0;
-  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;
+  gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s));
+  start_line_or_addr.loa = LOA_LINE;
+  cur_line_no = start_line_or_addr.u.line_no = line_no;
 
   const char *iter = srclines.c_str ();
-  win_info->content.resize (nlines);
+  content.resize (nlines);
   while (cur_line < nlines)
     {
       struct tui_source_element *element
- = &win_info->content[cur_line];
+ = &content[cur_line];
 
       std::string text;
       if (*iter != '\0')
- text = copy_source_line (&iter, cur_line_no,
- win_info->horizontal_offset,
+ text = copy_source_line (&iter, cur_line_no, horizontal_offset,
  line_width);
 
       /* Set whether element is the execution point
@@ -183,8 +185,8 @@ tui_set_source_content (tui_source_window_base *win_info,
  symtab_to_fullname (s)) == 0
    && cur_line_no == locator->line_no);
 
-      xfree (win_info->content[cur_line].line);
-      win_info->content[cur_line].line
+      xfree (content[cur_line].line);
+      content[cur_line].line
  = xstrdup (text.c_str ());
 
       cur_line++;
diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
index 1d7af2aad83..c623f5e2941 100644
--- a/gdb/tui/tui-source.h
+++ b/gdb/tui/tui-source.h
@@ -60,6 +60,11 @@ protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
 
+  enum tui_status set_contents
+    (struct gdbarch *gdbarch,
+     struct symtab *s,
+     struct tui_line_or_address line_or_addr) override;
+
 private:
 
   void style_changed ();
@@ -72,9 +77,6 @@ private:
   gdb::observers::token m_observable;
 };
 
-extern enum tui_status tui_set_source_content (tui_source_window_base *,
-       struct symtab *,
-       int);
 extern void tui_show_symtab_source (tui_source_window_base *,
     struct gdbarch *, struct symtab *,
     struct tui_line_or_address);
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index d0e18791e4a..3a678f2b531 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -88,12 +88,8 @@ tui_source_window_base::update_source_window_as_is
    struct symtab *s,
    struct tui_line_or_address line_or_addr)
 {
-  enum tui_status ret;
-
-  if (type == SRC_WIN)
-    ret = tui_set_source_content (this, s, line_or_addr.u.line_no);
-  else
-    ret = tui_set_disassem_content (this, gdbarch, line_or_addr.u.addr);
+  enum tui_status ret
+    = set_contents (gdbarch, s, line_or_addr);
 
   if (ret == TUI_FAILURE)
     erase_source_content ();
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 30b29ca8fdc..85e83021be1 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -104,6 +104,11 @@ protected:
 
   void rerender () override;
 
+  virtual enum tui_status set_contents
+    (struct gdbarch *gdbarch,
+     struct symtab *s,
+     struct tui_line_or_address line_or_addr) = 0;
+
 public:
 
   void clear_detail ();
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 8/9] Change tui_show_symtab_source to be a method

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

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

        * tui/tui-winsource.c (tui_update_source_windows_with_addr)
        (tui_update_source_windows_with_line): Update.
        * tui/tui-source.h (struct tui_source_window)
        <show_symtab_source>: Declare.
        (tui_show_symtab_source): Don't declare.
        * tui/tui-source.c (tui_show_symtab_source): Rename from
        tui_show_symtab_source.
---
 gdb/ChangeLog           | 10 ++++++++++
 gdb/tui/tui-source.c    | 10 +++++-----
 gdb/tui/tui-source.h    |  7 +++----
 gdb/tui/tui-winsource.c |  4 ++--
 4 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 9eb7c48472e..57d27aee4af 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -202,12 +202,12 @@ tui_source_window::set_contents (struct gdbarch *arch,
 /* Function to display source in the source window.  This function
    initializes the horizontal scroll to 0.  */
 void
-tui_show_symtab_source (tui_source_window_base *win_info,
- struct gdbarch *gdbarch, struct symtab *s,
- struct tui_line_or_address line)
+tui_source_window::show_symtab_source (struct gdbarch *gdbarch,
+       struct symtab *s,
+       struct tui_line_or_address line)
 {
-  win_info->horizontal_offset = 0;
-  win_info->update_source_window_as_is (gdbarch, s, line);
+  horizontal_offset = 0;
+  update_source_window_as_is (gdbarch, s, line);
 }
 
 
diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
index c623f5e2941..9c3013637b7 100644
--- a/gdb/tui/tui-source.h
+++ b/gdb/tui/tui-source.h
@@ -56,6 +56,9 @@ struct tui_source_window : public tui_source_window_base
     do_erase_source_content (NO_SRC_STRING);
   }
 
+  void show_symtab_source (struct gdbarch *, struct symtab *,
+   struct tui_line_or_address);
+
 protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
@@ -77,8 +80,4 @@ private:
   gdb::observers::token m_observable;
 };
 
-extern void tui_show_symtab_source (tui_source_window_base *,
-    struct gdbarch *, struct symtab *,
-    struct tui_line_or_address);
-
 #endif /* TUI_TUI_SOURCE_H */
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 3a678f2b531..43e8a28df5a 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -139,7 +139,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 (TUI_SRC_WIN, gdbarch, sal.symtab, l);
+  TUI_SRC_WIN->show_symtab_source (gdbarch, sal.symtab, l);
   break;
  }
     }
@@ -174,7 +174,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 (TUI_SRC_WIN, gdbarch, s, l);
+      TUI_SRC_WIN->show_symtab_source (gdbarch, s, l);
       if (tui_current_layout () == SRC_DISASSEM_COMMAND)
  {
   find_line_pc (s, line, &pc);
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 9/9] Remove useless assignment from tui_remove_hooks

Tom Tromey-2
In reply to this post by Tom Tromey-2
tui_remove_hooks clears deprecated_query_hook, but nothing in the TUI
ever sets it; so remove the assignment.

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

        * tui/tui-hooks.c (tui_remove_hooks): Don't set
        deprecated_query_hook.
---
 gdb/ChangeLog       | 5 +++++
 gdb/tui/tui-hooks.c | 1 -
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index a2d06f8a152..5cc90dd3b6c 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -260,7 +260,6 @@ void
 tui_remove_hooks (void)
 {
   deprecated_print_frame_info_listing_hook = 0;
-  deprecated_query_hook = 0;
 
   /* Remove our observers.  */
   tui_attach_detach_observers (false);
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/9] Even more TUI refactorings

Pedro Alves-7
In reply to this post by Tom Tromey-2
On 8/16/19 5:15 PM, Tom Tromey wrote:
> Here's another round of TUI refactorings.
>
> This series is a bit shorter than the others because I'm trying to
> send refactorings separately from behavior-changing patches, and the
> next patch after these does change the TUI in a user-visible way.
>
> Each patch was built and tested using the gdb.tui tests.

Looks good.

Thanks,
Pedro Alves