]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/tui: update maybe_update to take gdbarch
authorAndrew Burgess <aburgess@redhat.com>
Thu, 6 Feb 2025 12:16:48 +0000 (12:16 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Fri, 14 Feb 2025 21:06:30 +0000 (21:06 +0000)
This is a refactor to setup for the next commit.

The maybe_update function currently takes a frame_info_ptr&, however,
it only uses this to get the frame's gdbarch.

In the next commit I want to call maybe_update when I have a gdbarch,
but no frame_info_ptr& (the inferior hasn't even started).

So, update maybe_update to take the gdbarch, and update the callers to
pass that through.  Most callers already have the gdbarch to hand, but
in one place I do need to extract this from the frame_info_ptr&.

There should be no user visible changes after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/tui/tui-disasm.c
gdb/tui/tui-disasm.h
gdb/tui/tui-source.c
gdb/tui/tui-source.h
gdb/tui/tui-status.c
gdb/tui/tui-winsource.h

index cd828537a5a4824050157c6c1a765a1539874575..f45c30c109bd0135327e981c5657b85c853cfa8a 100644 (file)
@@ -485,12 +485,10 @@ tui_disasm_window::addr_is_displayed (CORE_ADDR addr) const
 }
 
 void
-tui_disasm_window::maybe_update (const frame_info_ptr &fi, symtab_and_line sal)
+tui_disasm_window::maybe_update (struct gdbarch *gdbarch, symtab_and_line sal)
 {
   CORE_ADDR low;
 
-  struct gdbarch *frame_arch = get_frame_arch (fi);
-
   if (find_pc_partial_function (sal.pc, NULL, &low, NULL) == 0)
     {
       /* There is no symbol available for current PC.  There is no
@@ -498,7 +496,7 @@ tui_disasm_window::maybe_update (const frame_info_ptr &fi, symtab_and_line sal)
       low = sal.pc;
     }
   else
-    low = tui_get_low_disassembly_address (frame_arch, low, sal.pc);
+    low = tui_get_low_disassembly_address (gdbarch, low, sal.pc);
 
   struct tui_line_or_address a;
 
@@ -507,7 +505,7 @@ tui_disasm_window::maybe_update (const frame_info_ptr &fi, symtab_and_line sal)
   if (!addr_is_displayed (sal.pc))
     {
       sal.pc = low;
-      update_source_window (frame_arch, sal);
+      update_source_window (gdbarch, sal);
     }
   else
     {
index a49719a0dca2d2534bd227c216b5b14c66890df2..4279bb03406dee7dad858c439ed79ab50f68f302 100644 (file)
@@ -42,7 +42,7 @@ struct tui_disasm_window : public tui_source_window_base
 
   bool location_matches_p (struct bp_location *loc, int line_no) override;
 
-  void maybe_update (const frame_info_ptr &fi, symtab_and_line sal) override;
+  void maybe_update (struct gdbarch *gdbarch, symtab_and_line sal) override;
 
   void erase_source_content () override
   {
index 9a0a04142b23700f95f366e9f0485a42d6946a0f..2ef0308bb3cf130be8837e4dc7efd37b1269f85e 100644 (file)
@@ -207,7 +207,7 @@ tui_source_window::line_is_displayed (int line) const
 }
 
 void
-tui_source_window::maybe_update (const frame_info_ptr &fi, symtab_and_line sal)
+tui_source_window::maybe_update (struct gdbarch *gdbarch, symtab_and_line sal)
 {
   int start_line = (sal.line - ((height - box_size ()) / 2)) + 1;
   if (start_line <= 0)
@@ -219,7 +219,7 @@ tui_source_window::maybe_update (const frame_info_ptr &fi, symtab_and_line sal)
   if (!(source_already_displayed && line_is_displayed (sal.line)))
     {
       sal.line = start_line;
-      update_source_window (get_frame_arch (fi), sal);
+      update_source_window (gdbarch, sal);
     }
   else
     {
index 9cad4ff91b4d57e60301bee02871c93967f4b8f3..10702b22f65b1316e519004207645b1d5a56cec6 100644 (file)
@@ -46,7 +46,7 @@ struct tui_source_window : public tui_source_window_base
 
   bool showing_source_p (const char *filename) const;
 
-  void maybe_update (const frame_info_ptr &fi, symtab_and_line sal) override;
+  void maybe_update (struct gdbarch *gdbarch, symtab_and_line sal) override;
 
   void erase_source_content () override
   {
index d76c2db78e89007a86baf59745af69482d7a1d6b..fa2d07c9b3590432746ff0bf06952002226a6776 100644 (file)
@@ -278,8 +278,9 @@ tui_show_frame_info (const frame_info_ptr &fi)
       else
        func_name = _("<unavailable>");
 
+      struct gdbarch *gdbarch = get_frame_arch (fi);
       status_changed_p
-       = tui_location.set_location (get_frame_arch (fi), sal, func_name);
+       = tui_location.set_location (gdbarch, sal, func_name);
 
       /* If the status information has not changed, then frame information has
         not changed.  If frame information has not changed, then the windows'
@@ -289,7 +290,7 @@ tui_show_frame_info (const frame_info_ptr &fi)
 
       for (struct tui_source_window_base *win_info : tui_source_windows ())
        {
-         win_info->maybe_update (fi, sal);
+         win_info->maybe_update (gdbarch, sal);
          win_info->update_exec_info ();
        }
     }
index 2883ec9cf9f122543a8b746bfe21b5f78a2e3b36..deae786aea2ef2bbe330beb8d0056a551de26fed 100644 (file)
@@ -160,7 +160,7 @@ public:
 
   /* Update the window to display the given location.  Does nothing if
      the location is already displayed.  */
-  virtual void maybe_update (const frame_info_ptr &fi, symtab_and_line sal) = 0;
+  virtual void maybe_update (struct gdbarch *gdbarch, symtab_and_line sal) = 0;
 
   void update_source_window_as_is  (struct gdbarch *gdbarch,
                                    const struct symtab_and_line &sal);