aboutsummaryrefslogtreecommitdiff
path: root/gdb/corelow.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2023-08-28 14:18:19 -0700
committerJohn Baldwin <jhb@FreeBSD.org>2023-08-28 14:18:19 -0700
commitc689d1fe58b2c0faf51e4f574d50271f1d0648e3 (patch)
treea9d6bb2b8f2485874a9d4ec24b079a21dd11fde8 /gdb/corelow.c
parenta388ab0b863a07ddb37d1e98ae8e7443ab85746c (diff)
downloadgdb-c689d1fe58b2c0faf51e4f574d50271f1d0648e3.zip
gdb-c689d1fe58b2c0faf51e4f574d50271f1d0648e3.tar.gz
gdb-c689d1fe58b2c0faf51e4f574d50271f1d0648e3.tar.bz2
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>
Diffstat (limited to 'gdb/corelow.c')
-rw-r--r--gdb/corelow.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 4d692dc..439270f 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -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. */