]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Move contents of tui_show_frame_info to new method
authorTom Tromey <tom@tromey.com>
Sat, 6 Jul 2019 21:04:12 +0000 (15:04 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 15 Aug 2019 18:29:28 +0000 (12:29 -0600)
This moves much of the body of tui_show_frame_info to a new method on
tui_source_window_base.  This removes a check for the type of a
window.

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

* tui/tui-winsource.h (struct tui_source_window_base)
<maybe_update>: Declare.
* tui/tui-stack.c (tui_show_frame_info): Call maybe_update
method.
* tui/tui-source.h (struct tui_source_window) <maybe_update>:
Declare.
* tui/tui-source.c (tui_source_window::maybe_update): New method.
* tui/tui-disasm.h (struct tui_disasm_window) <maybe_update>:
Declare.
* tui/tui-disasm.c (tui_disasm_window::maybe_update): New method.

gdb/ChangeLog
gdb/tui/tui-disasm.c
gdb/tui/tui-disasm.h
gdb/tui/tui-source.c
gdb/tui/tui-source.h
gdb/tui/tui-stack.c
gdb/tui/tui-winsource.h

index 58fa44d7446ad19b52ff712b6bc785f3793a3835..b0da5a1a3a848d8e896f84955bd79ae9ff767fe5 100644 (file)
@@ -1,3 +1,16 @@
+2019-08-15  Tom Tromey  <tom@tromey.com>
+
+       * tui/tui-winsource.h (struct tui_source_window_base)
+       <maybe_update>: Declare.
+       * tui/tui-stack.c (tui_show_frame_info): Call maybe_update
+       method.
+       * tui/tui-source.h (struct tui_source_window) <maybe_update>:
+       Declare.
+       * tui/tui-source.c (tui_source_window::maybe_update): New method.
+       * tui/tui-disasm.h (struct tui_disasm_window) <maybe_update>:
+       Declare.
+       * tui/tui-disasm.c (tui_disasm_window::maybe_update): New method.
+
 2019-08-15  Tom Tromey  <tom@tromey.com>
 
        * tui/tui-stack.c (tui_make_status_line): Use string constructor.
index a442a00019e142583ab405ded51e6b88f6310bbe..fcb33bccfd7e66532ce654991bfccb4088fa36fe 100644 (file)
@@ -380,3 +380,34 @@ tui_disasm_window::location_matches_p (struct bp_location *loc, int line_no)
   return (content[line_no].line_or_addr.loa == LOA_ADDRESS
          && content[line_no].line_or_addr.u.addr == loc->address);
 }
+
+void
+tui_disasm_window::maybe_update (struct frame_info *fi, symtab_and_line sal,
+                                int line_no, CORE_ADDR addr)
+{
+  CORE_ADDR low;
+
+  if (find_pc_partial_function (get_frame_pc (fi),
+                               NULL, &low, NULL) == 0)
+    {
+      /* There is no symbol available for current PC.  There is no
+        safe way how to "disassemble backwards".  */
+      low = get_frame_pc (fi);
+    }
+  else
+    low = tui_get_low_disassembly_address (get_frame_arch (fi),
+                                          low, get_frame_pc (fi));
+
+  struct tui_line_or_address a;
+
+  a.loa = LOA_ADDRESS;
+  a.u.addr = low;
+  if (!tui_addr_is_displayed (addr, this, TRUE))
+    tui_update_source_window (this, get_frame_arch (fi),
+                             sal.symtab, a, TRUE);
+  else
+    {
+      a.u.addr = addr;
+      set_is_exec_point_at (a);
+    }
+}
index 19672a74df11ba78b23f5bfc09558e34d1fd5be2..20bc4290ffc1ac22f05828d93320a677e68e5d1c 100644 (file)
@@ -44,6 +44,10 @@ struct tui_disasm_window : public tui_source_window_base
 
   bool location_matches_p (struct bp_location *loc, int line_no) override;
 
+  void maybe_update (struct frame_info *fi, symtab_and_line sal,
+                    int line_no, CORE_ADDR addr)
+    override;
+
 protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
index 619d93745003a8548078850861259f2e6d725737..34b8f54557dd9e6c91ac18c9a4c9f9969e4856ff 100644 (file)
@@ -293,3 +293,29 @@ tui_source_window::location_matches_p (struct bp_location *loc, int line_no)
          && filename_cmp (fullname,
                           symtab_to_fullname (loc->symtab)) == 0);
 }
+
+void
+tui_source_window::maybe_update (struct frame_info *fi, symtab_and_line sal,
+                                int line_no, CORE_ADDR addr)
+{
+  int start_line = (line_no - (viewport_height / 2)) + 1;
+  if (start_line <= 0)
+    start_line = 1;
+
+  bool source_already_displayed = (sal.symtab != 0
+                                  && showing_source_p (fullname));
+
+  struct tui_line_or_address l;
+
+  l.loa = LOA_LINE;
+  l.u.line_no = start_line;
+  if (!(source_already_displayed
+       && tui_line_is_displayed (line_no, this, TRUE)))
+    tui_update_source_window (this, get_frame_arch (fi),
+                             sal.symtab, l, TRUE);
+  else
+    {
+      l.u.line_no = line_no;
+      set_is_exec_point_at (l);
+    }
+}
index 49d79aba6295b56cf4dfeea86da7705a258398c2..dc4470e9e5a86940af311c5e10dcf50bfa5c90d8 100644 (file)
@@ -47,6 +47,10 @@ struct tui_source_window : public tui_source_window_base
 
   bool showing_source_p (const char *filename) const;
 
+  void maybe_update (struct frame_info *fi, symtab_and_line sal,
+                    int line_no, CORE_ADDR addr)
+    override;
+
 protected:
 
   void do_scroll_vertical (int num_to_scroll) override;
index 1d7491dff93464d031f59c795b34e0cd3afe83b9..09ee87f4027cec5b0493030f0458542aed79b7fe 100644 (file)
@@ -364,7 +364,6 @@ tui_show_frame_info (struct frame_info *fi)
   if (fi)
     {
       struct tui_locator_window *locator = tui_locator_win_info_ptr ();
-      int source_already_displayed;
       CORE_ADDR pc;
 
       symtab_and_line sal = find_frame_sal (fi);
@@ -373,10 +372,6 @@ tui_show_frame_info (struct frame_info *fi)
       if (sal.symtab != nullptr)
        fullname = symtab_to_fullname (sal.symtab);
 
-      source_already_displayed = (sal.symtab != 0
-                                 && TUI_SRC_WIN != nullptr
-                                 && TUI_SRC_WIN->showing_source_p (fullname));
-
       if (get_frame_pc_if_available (fi, &pc))
        locator_changed_p
          = tui_set_locator_info (get_frame_arch (fi),
@@ -399,58 +394,7 @@ tui_show_frame_info (struct frame_info *fi)
       tui_show_locator_content ();
       for (struct tui_source_window_base *win_info : tui_source_windows ())
        {
-         if (win_info == TUI_SRC_WIN)
-           {
-             int start_line = (locator->line_no -
-                               (win_info->viewport_height / 2)) + 1;
-             if (start_line <= 0)
-               start_line = 1;
-
-             struct tui_line_or_address l;
-
-             l.loa = LOA_LINE;
-             l.u.line_no = start_line;
-             if (!(source_already_displayed
-                   && tui_line_is_displayed (locator->line_no,
-                                             win_info, TRUE)))
-               tui_update_source_window (win_info, get_frame_arch (fi),
-                                         sal.symtab, l, TRUE);
-             else
-               {
-                 l.u.line_no = locator->line_no;
-                 win_info->set_is_exec_point_at (l);
-               }
-           }
-         else
-           {
-             CORE_ADDR low;
-
-             if (find_pc_partial_function (get_frame_pc (fi),
-                                           NULL, &low, NULL) == 0)
-               {
-                 /* There is no symbol available for current PC.  There is no
-                    safe way how to "disassemble backwards".  */
-                 low = get_frame_pc (fi);
-               }
-             else
-               low = tui_get_low_disassembly_address (get_frame_arch (fi),
-                                                      low, get_frame_pc (fi));
-
-             struct tui_line_or_address a;
-
-             a.loa = LOA_ADDRESS;
-             a.u.addr = low;
-             if (!tui_addr_is_displayed (locator->addr,
-                                         win_info, TRUE))
-               tui_update_source_window (win_info, get_frame_arch (fi),
-                                         sal.symtab, a, TRUE);
-             else
-               {
-                 a.u.addr = locator->addr;
-                 win_info->set_is_exec_point_at (a);
-               }
-           }
-
+         win_info->maybe_update (fi, sal, locator->line_no, locator->addr);
          win_info->update_exec_info ();
        }
 
index abb7ea34816bf6b992f31abba99fa5e9724b355f..f2fd1eb1b0bf0b6df8c5d0ae9fa8c2a9a4411d72 100644 (file)
@@ -23,6 +23,7 @@
 #define TUI_TUI_WINSOURCE_H
 
 #include "tui/tui-data.h"
+#include "symtab.h"
 
 /* Flags to tell what kind of breakpoint is at current line.  */
 enum tui_bp_flag
@@ -116,6 +117,11 @@ public:
 
   void update_exec_info ();
 
+  /* Update the window to display the given location.  Does nothing if
+     the location is already displayed.  */
+  virtual void maybe_update (struct frame_info *fi, symtab_and_line sal,
+                            int line_no, CORE_ADDR addr) = 0;
+
   /* Does the locator belong to this window?  */
   bool m_has_locator = false;
   /* Execution information window.  */