summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process
diff options
context:
space:
mode:
authorGuilherme Andrade <guiandrade@google.com>2019-10-31 10:46:58 +0100
committerPavel Labath <pavel@labath.sk>2019-10-31 10:58:17 +0100
commite46c6644db8432584e82ef7ddfc9d0f36543f205 (patch)
tree806bfb6bceabcac722222a426a83059406e2d1e1 /lldb/source/Plugins/Process
parent92aa0c2dbcb723d102c508f6e7559330b637f912 (diff)
downloadbcm5719-llvm-e46c6644db8432584e82ef7ddfc9d0f36543f205.tar.gz
bcm5719-llvm-e46c6644db8432584e82ef7ddfc9d0f36543f205.zip
[lldb] Fix offset intersection bug between MPX and AVX registers
Summary: This change increases the offset of MPX registers (by 128) so they do not overlap with the offset associated with AVX registers. That was causing MPX data in GDBRemoteRegisterContext::m_reg_data to get overwritten. Reviewers: labath Reviewed By: labath Subscribers: JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68874
Diffstat (limited to 'lldb/source/Plugins/Process')
-rw-r--r--lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp5
-rw-r--r--lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h4
-rw-r--r--lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp7
-rw-r--r--lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h7
5 files changed, 21 insertions, 4 deletions
diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
index 3ae215e7573..3186b6cf39a 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
@@ -34,7 +34,7 @@ Status NativeRegisterContextLinux::ReadRegisterRaw(uint32_t reg_index,
if (!reg_info)
return Status("register %" PRIu32 " not found", reg_index);
- return DoReadRegisterValue(reg_info->byte_offset, reg_info->name,
+ return DoReadRegisterValue(GetPtraceOffset(reg_index), reg_info->name,
reg_info->byte_size, reg_value);
}
@@ -91,7 +91,8 @@ NativeRegisterContextLinux::WriteRegisterRaw(uint32_t reg_index,
"for write register index %" PRIu32,
__FUNCTION__, reg_to_write);
- return DoWriteRegisterValue(reg_info->byte_offset, reg_info->name, reg_value);
+ return DoWriteRegisterValue(GetPtraceOffset(reg_index), reg_info->name,
+ reg_value);
}
Status NativeRegisterContextLinux::ReadGPR() {
diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
index 82894852c13..3b98310c196 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
@@ -60,6 +60,10 @@ protected:
virtual size_t GetFPRSize() = 0;
+ virtual uint32_t GetPtraceOffset(uint32_t reg_index) {
+ return GetRegisterInfoAtIndex(reg_index)->byte_offset;
+ }
+
// The Do*** functions are executed on the privileged thread and can perform
// ptrace
// operations directly.
diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
index 49f1d44b39d..0818630db62 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
@@ -1213,4 +1213,11 @@ uint32_t NativeRegisterContextLinux_x86_64::NumSupportedHardwareWatchpoints() {
return 4;
}
+uint32_t
+NativeRegisterContextLinux_x86_64::GetPtraceOffset(uint32_t reg_index) {
+ // If register is MPX, remove extra factor from gdb offset
+ return GetRegisterInfoAtIndex(reg_index)->byte_offset -
+ (IsMPX(reg_index) ? 128 : 0);
+}
+
#endif // defined(__i386__) || defined(__x86_64__)
diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
index 6031ddb0a7a..58b749025c5 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
@@ -75,6 +75,8 @@ protected:
Status WriteFPR() override;
+ uint32_t GetPtraceOffset(uint32_t reg_index) override;
+
private:
// Private member types.
enum class XStateType { Invalid, FXSAVE, XSAVE };
diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h b/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h
index 4a3b3c73fd6..af3027afa73 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h
@@ -25,15 +25,18 @@
LLVM_EXTENSION offsetof(FPR, xsave) + \
LLVM_EXTENSION offsetof(XSAVE, ymmh[0]) + (32 * reg_index))
+// Guarantees BNDR/BNDC offsets do not overlap with YMM offsets.
+#define GDB_REMOTE_OFFSET 128
+
#define BNDR_OFFSET(reg_index) \
(LLVM_EXTENSION offsetof(UserArea, fpr) + \
LLVM_EXTENSION offsetof(FPR, xsave) + \
- LLVM_EXTENSION offsetof(XSAVE, mpxr[reg_index]))
+ LLVM_EXTENSION offsetof(XSAVE, mpxr[reg_index]) + GDB_REMOTE_OFFSET)
#define BNDC_OFFSET(reg_index) \
(LLVM_EXTENSION offsetof(UserArea, fpr) + \
LLVM_EXTENSION offsetof(FPR, xsave) + \
- LLVM_EXTENSION offsetof(XSAVE, mpxc[reg_index]))
+ LLVM_EXTENSION offsetof(XSAVE, mpxc[reg_index]) + GDB_REMOTE_OFFSET)
#ifdef DECLARE_REGISTER_INFOS_X86_64_STRUCT
OpenPOWER on IntegriCloud