]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: pass core file to gdbarch_core_read_x86_xsave_layout
authorAndrew Burgess <aburgess@redhat.com>
Wed, 27 Aug 2025 19:24:02 +0000 (20:24 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Fri, 5 Sep 2025 09:37:45 +0000 (10:37 +0100)
Continuing the removal of 'current_program_space->core_bfd ()' from
GDB, this commit updates the gdbarch method
'gdbarch_core_read_x86_xsave_layout' to take the core file BFD as a
reference parameter.  For now this just moves the
'current_program_space->core_bfd ()' calls up the program stack into
core_target::fetch_x86_xsave_layout.  In the future I plan to move the
core file BFD object out of the program_space and into the
core_target, at which point these new global accesses can also be
removed.

There should be no user visible changes after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/corelow.c
gdb/gdbarch-gen.c
gdb/gdbarch-gen.h
gdb/gdbarch_components.py
gdb/i386-fbsd-tdep.c
gdb/i386-fbsd-tdep.h
gdb/i386-linux-tdep.c
gdb/i386-linux-tdep.h

index b877a31edc6647c5b2ae0a5ca5037dc6c0f08474..29eafe8bdfd2bfd8b1c8e6456fd21b8c4d2b96a0 100644 (file)
@@ -1912,7 +1912,9 @@ core_target::fetch_x86_xsave_layout ()
       gdbarch_core_read_x86_xsave_layout_p (m_core_gdbarch))
     {
       x86_xsave_layout layout;
-      if (!gdbarch_core_read_x86_xsave_layout (m_core_gdbarch, layout))
+      bfd *cbfd = current_program_space->core_bfd ();
+      gdb_assert (cbfd != nullptr);
+      if (!gdbarch_core_read_x86_xsave_layout (m_core_gdbarch, *cbfd, layout))
        return {};
 
       return layout;
index 64a63037789e056748bce2471359f51451cfb840..7887b1386c6944141f142aa9e14b67d1cdf16c8d 100644 (file)
@@ -4090,13 +4090,13 @@ gdbarch_core_read_x86_xsave_layout_p (struct gdbarch *gdbarch)
 }
 
 bool
-gdbarch_core_read_x86_xsave_layout (struct gdbarch *gdbarch, x86_xsave_layout &xsave_layout)
+gdbarch_core_read_x86_xsave_layout (struct gdbarch *gdbarch, struct bfd &cbfd, x86_xsave_layout &xsave_layout)
 {
   gdb_assert (gdbarch != NULL);
   gdb_assert (gdbarch->core_read_x86_xsave_layout != NULL);
   if (gdbarch_debug >= 2)
     gdb_printf (gdb_stdlog, "gdbarch_core_read_x86_xsave_layout called\n");
-  return gdbarch->core_read_x86_xsave_layout (gdbarch, xsave_layout);
+  return gdbarch->core_read_x86_xsave_layout (gdbarch, cbfd, xsave_layout);
 }
 
 void
index c666802b85c3f6ba3b448dfd8ca8a5d09b772fb2..24fa8bab2dbbb7d803c8bc493e766cc8d31e2494 100644 (file)
@@ -1069,13 +1069,13 @@ typedef LONGEST (gdbarch_core_xfer_siginfo_ftype) (struct gdbarch *gdbarch, stru
 extern LONGEST gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch, struct bfd &cbfd, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
 extern void set_gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch, gdbarch_core_xfer_siginfo_ftype *core_xfer_siginfo);
 
-/* Read x86 XSAVE layout information from core file into XSAVE_LAYOUT.
+/* Read x86 XSAVE layout information from core file CBFD into XSAVE_LAYOUT.
    Returns true if the layout was read successfully. */
 
 extern bool gdbarch_core_read_x86_xsave_layout_p (struct gdbarch *gdbarch);
 
-typedef bool (gdbarch_core_read_x86_xsave_layout_ftype) (struct gdbarch *gdbarch, x86_xsave_layout &xsave_layout);
-extern bool gdbarch_core_read_x86_xsave_layout (struct gdbarch *gdbarch, x86_xsave_layout &xsave_layout);
+typedef bool (gdbarch_core_read_x86_xsave_layout_ftype) (struct gdbarch *gdbarch, struct bfd &cbfd, x86_xsave_layout &xsave_layout);
+extern bool gdbarch_core_read_x86_xsave_layout (struct gdbarch *gdbarch, struct bfd &cbfd, x86_xsave_layout &xsave_layout);
 extern void set_gdbarch_core_read_x86_xsave_layout (struct gdbarch *gdbarch, gdbarch_core_read_x86_xsave_layout_ftype *core_read_x86_xsave_layout);
 
 /* BFD target to use when generating a core file. */
index 1f32087d03b1023afd59d8515c82ad61c4af2245..3820ae3c94c2ebfa16a420b87479968b84829042 100644 (file)
@@ -1803,12 +1803,12 @@ of bytes read (zero indicates EOF, a negative value indicates failure).
 
 Method(
     comment="""
-Read x86 XSAVE layout information from core file into XSAVE_LAYOUT.
+Read x86 XSAVE layout information from core file CBFD into XSAVE_LAYOUT.
 Returns true if the layout was read successfully.
 """,
     type="bool",
     name="core_read_x86_xsave_layout",
-    params=[("x86_xsave_layout &", "xsave_layout")],
+    params=[("struct bfd &", "cbfd"), ("x86_xsave_layout &", "xsave_layout")],
     predicate=True,
 )
 
index 827d53ce5d0cea24f0340401012cb7a9e5f4990d..a32880e0be34bc684281f077728a0595e8dc1607 100644 (file)
@@ -274,11 +274,10 @@ i386_fbsd_core_read_xsave_info (bfd *abfd, x86_xsave_layout &layout)
 /* See i386-fbsd-tdep.h.  */
 
 bool
-i386_fbsd_core_read_x86_xsave_layout (struct gdbarch *gdbarch,
+i386_fbsd_core_read_x86_xsave_layout (struct gdbarch *gdbarch, bfd &cbfd,
                                      x86_xsave_layout &layout)
 {
-  return i386_fbsd_core_read_xsave_info (current_program_space->core_bfd (),
-                                        layout) != 0;
+  return i386_fbsd_core_read_xsave_info (&cbfd, layout) != 0;
 }
 
 /* Implement the core_read_description gdbarch method.  */
index 70ad32fecdd8623cc6d76ece4784500162137454..acc5776582771d4ee2f56275768e4293ace83851 100644 (file)
@@ -32,8 +32,9 @@
 uint64_t i386_fbsd_core_read_xsave_info (bfd *abfd, x86_xsave_layout &layout);
 
 /* Implement the core_read_x86_xsave_layout gdbarch method.  */
-bool i386_fbsd_core_read_x86_xsave_layout (struct gdbarch *gdbarch,
-                                          x86_xsave_layout &layout);
+extern bool i386_fbsd_core_read_x86_xsave_layout (struct gdbarch *gdbarch,
+                                                 bfd &cbfd,
+                                                 x86_xsave_layout &layout);
 
 /* The format of the XSAVE extended area is determined by hardware.
    Cores store the XSAVE extended area in a NT_X86_XSTATE note that
index efbde6a3ccfec496602541f992191729a62be1b7..3360e96f86c392a92ae44a91118162b24a0258d2 100644 (file)
@@ -1105,11 +1105,10 @@ i386_linux_core_read_xsave_info (bfd *abfd, x86_xsave_layout &layout)
 /* See i386-linux-tdep.h.  */
 
 bool
-i386_linux_core_read_x86_xsave_layout (struct gdbarch *gdbarch,
+i386_linux_core_read_x86_xsave_layout (struct gdbarch *gdbarch, bfd &cbfd,
                                       x86_xsave_layout &layout)
 {
-  return i386_linux_core_read_xsave_info (current_program_space->core_bfd (),
-                                         layout) != 0;
+  return i386_linux_core_read_xsave_info (&cbfd, layout) != 0;
 }
 
 /* See arch/x86-linux-tdesc.h.  */
index de98256462a25020b705728ed8daeb8c55cf4148..3a0e056413f5af4f878f8b83c60fde77d7572e53 100644 (file)
@@ -47,6 +47,7 @@ extern uint64_t i386_linux_core_read_xsave_info (bfd *abfd,
 
 /* Implement the core_read_x86_xsave_layout gdbarch method.  */
 extern bool i386_linux_core_read_x86_xsave_layout (struct gdbarch *gdbarch,
+                                                  bfd &cbfd,
                                                   x86_xsave_layout &layout);
 
 extern int i386_linux_gregset_reg_offset[];