gdb: pass core file to gdbarch_core_read_x86_xsave_layout

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>
This commit is contained in:
Andrew Burgess
2025-08-27 20:24:02 +01:00
parent a6b9480111
commit a6138daaf5
8 changed files with 18 additions and 16 deletions

View 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;

View 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

View 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. */

View 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,
)

View 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. */

View 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

View 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. */

View 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[];