core: Support fetching x86 XSAVE layout from architectures.

Add gdbarch_core_read_x86_xsave_layout to fetch the x86 XSAVE layout
structure from a core file.

Current OS's do not export the offsets of XSAVE state components in
core dumps, so provide an i387_guess_xsave_layout helper function to
set offsets based on known combinations of XCR0 masks and total state
sizes.  Eventually when core dumps do contain this information this
function should only be used as a fall back for older core dumps.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
John Baldwin
2023-08-28 14:18:19 -07:00
parent a388ab0b86
commit c689d1fe58
7 changed files with 137 additions and 0 deletions

View File

@@ -47,6 +47,7 @@
#include "build-id.h"
#include "gdbsupport/pathstuff.h"
#include "gdbsupport/scoped_fd.h"
#include "gdbsupport/x86-xstate.h"
#include "debuginfod-support.h"
#include <unordered_map>
#include <unordered_set>
@@ -109,6 +110,8 @@ public:
bool fetch_memtags (CORE_ADDR address, size_t len,
gdb::byte_vector &tags, int type) override;
x86_xsave_layout fetch_x86_xsave_layout () override;
/* A few helpers. */
/* Getter, see variable definition. */
@@ -1387,6 +1390,24 @@ core_target::fetch_memtags (CORE_ADDR address, size_t len,
return false;
}
/* Implementation of the "fetch_x86_xsave_layout" target_ops method. */
x86_xsave_layout
core_target::fetch_x86_xsave_layout ()
{
if (m_core_gdbarch != nullptr &&
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))
return {};
return layout;
}
return {};
}
/* Get a pointer to the current core target. If not connected to a
core target, return NULL. */