[Lldb-commits] [PATCH] D27161: Fix floating point register reads x86_64 linux on targets with no AVX support
Pavel Labath via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Nov 28 03:52:41 PST 2016
labath created this revision.
labath added reviewers: tberghammer, valentinagiusti.
labath added a subscriber: lldb-commits.
On for 64-bit targets, the correct register set to read the fxsave are is
NT_PRFPREG (only 32-bit targets need NT_PRXFPREG, presumably for historic
reasons). Reference:
https://github.com/torvalds/linux/blob/v4.8/arch/x86/kernel/ptrace.c#L1261.
https://reviews.llvm.org/D27161
Files:
source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
Index: source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
===================================================================
--- source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
+++ source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
@@ -20,6 +20,8 @@
#include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
#include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
+#include <linux/elf.h>
+
using namespace lldb_private;
using namespace lldb_private::process_linux;
@@ -218,6 +220,12 @@
#define NT_PRXFPREG 0x46e62b7f
#endif
+// On x86_64 NT_PRFPREG is used to access the FXSAVE area. On i386, we need to
+// use NT_PRXFPREG.
+static inline unsigned int fxsr_regset(const ArchSpec &arch) {
+ return arch.GetAddressByteSize() == 8 ? NT_PRFPREG : NT_PRXFPREG;
+}
+
// ----------------------------------------------------------------------------
// Required MPX define.
// ----------------------------------------------------------------------------
@@ -235,6 +243,8 @@
#define mask_XSTATE_BNDCFG (1ULL << 4)
#define mask_XSTATE_MPX (mask_XSTATE_BNDREGS | mask_XSTATE_BNDCFG)
+
+
NativeRegisterContextLinux *
NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(
const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
@@ -852,8 +862,9 @@
Error NativeRegisterContextLinux_x86_64::WriteFPR() {
switch (m_xstate_type) {
case XStateType::FXSAVE:
- return WriteRegisterSet(&m_iovec, sizeof(m_fpr.xstate.xsave),
- NT_PRXFPREG);
+ return WriteRegisterSet(
+ &m_iovec, sizeof(m_fpr.xstate.xsave),
+ fxsr_regset(GetRegisterInfoInterface().GetTargetArchitecture()));
case XStateType::XSAVE:
return WriteRegisterSet(&m_iovec, sizeof(m_fpr.xstate.xsave),
NT_X86_XSTATE);
@@ -957,7 +968,9 @@
return error;
}
}
- error = ReadRegisterSet(&m_iovec, sizeof(m_fpr.xstate.xsave), NT_PRXFPREG);
+ error = ReadRegisterSet(
+ &m_iovec, sizeof(m_fpr.xstate.xsave),
+ fxsr_regset(GetRegisterInfoInterface().GetTargetArchitecture()));
if (!error.Fail()) {
m_xstate_type = XStateType::FXSAVE;
return error;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27161.79388.patch
Type: text/x-patch
Size: 2228 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20161128/4c3eff5b/attachment.bin>
More information about the lldb-commits
mailing list