aboutsummaryrefslogtreecommitdiff
path: root/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp')
-rwxr-xr-xsource/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp99
1 files changed, 50 insertions, 49 deletions
diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
index dd35705a8ae8..59dc9e9f7d45 100755
--- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
+++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
@@ -14,8 +14,8 @@
#include "lldb/Core/RegisterValue.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Utility/DataBufferHeap.h"
-#include "lldb/Utility/Error.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Status.h"
#include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
#include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
@@ -385,9 +385,10 @@ NativeRegisterContextLinux_x86_64::GetRegisterSet(uint32_t set_index) const {
return nullptr;
}
-Error NativeRegisterContextLinux_x86_64::ReadRegister(
- const RegisterInfo *reg_info, RegisterValue &reg_value) {
- Error error;
+Status
+NativeRegisterContextLinux_x86_64::ReadRegister(const RegisterInfo *reg_info,
+ RegisterValue &reg_value) {
+ Status error;
if (!reg_info) {
error.SetErrorString("reg_info NULL");
@@ -529,15 +530,15 @@ Error NativeRegisterContextLinux_x86_64::ReadRegister(
return error;
}
-Error NativeRegisterContextLinux_x86_64::WriteRegister(
+Status NativeRegisterContextLinux_x86_64::WriteRegister(
const RegisterInfo *reg_info, const RegisterValue &reg_value) {
assert(reg_info && "reg_info is null");
const uint32_t reg_index = reg_info->kinds[lldb::eRegisterKindLLDB];
if (reg_index == LLDB_INVALID_REGNUM)
- return Error("no lldb regnum for %s", reg_info && reg_info->name
- ? reg_info->name
- : "<unknown register>");
+ return Status("no lldb regnum for %s", reg_info && reg_info->name
+ ? reg_info->name
+ : "<unknown register>");
if (IsGPR(reg_index))
return WriteRegisterRaw(reg_index, reg_value);
@@ -566,7 +567,7 @@ Error NativeRegisterContextLinux_x86_64::WriteRegister(
::memcpy(m_ymm_set.ymm[reg_index - m_reg_info.first_ymm].bytes,
reg_value.GetBytes(), reg_value.GetByteSize());
if (!CopyYMMtoXSTATE(reg_index, GetByteOrder()))
- return Error("CopyYMMtoXSTATE() failed");
+ return Status("CopyYMMtoXSTATE() failed");
}
if (reg_index >= m_reg_info.first_mpxr &&
@@ -574,7 +575,7 @@ Error NativeRegisterContextLinux_x86_64::WriteRegister(
::memcpy(m_mpx_set.mpxr[reg_index - m_reg_info.first_mpxr].bytes,
reg_value.GetBytes(), reg_value.GetByteSize());
if (!CopyMPXtoXSTATE(reg_index))
- return Error("CopyMPXtoXSTATE() failed");
+ return Status("CopyMPXtoXSTATE() failed");
}
if (reg_index >= m_reg_info.first_mpxc &&
@@ -582,7 +583,7 @@ Error NativeRegisterContextLinux_x86_64::WriteRegister(
::memcpy(m_mpx_set.mpxc[reg_index - m_reg_info.first_mpxc].bytes,
reg_value.GetBytes(), reg_value.GetByteSize());
if (!CopyMPXtoXSTATE(reg_index))
- return Error("CopyMPXtoXSTATE() failed");
+ return Status("CopyMPXtoXSTATE() failed");
}
} else {
// Get pointer to m_fpr.xstate.fxsave variable and set the data to it.
@@ -616,33 +617,33 @@ Error NativeRegisterContextLinux_x86_64::WriteRegister(
break;
default:
assert(false && "Unhandled data size.");
- return Error("unhandled register data size %" PRIu32,
- reg_info->byte_size);
+ return Status("unhandled register data size %" PRIu32,
+ reg_info->byte_size);
}
}
- Error error = WriteFPR();
+ Status error = WriteFPR();
if (error.Fail())
return error;
if (IsAVX(reg_index)) {
if (!CopyYMMtoXSTATE(reg_index, GetByteOrder()))
- return Error("CopyYMMtoXSTATE() failed");
+ return Status("CopyYMMtoXSTATE() failed");
}
if (IsMPX(reg_index)) {
if (!CopyMPXtoXSTATE(reg_index))
- return Error("CopyMPXtoXSTATE() failed");
+ return Status("CopyMPXtoXSTATE() failed");
}
- return Error();
+ return Status();
}
- return Error("failed - register wasn't recognized to be a GPR or an FPR, "
- "write strategy unknown");
+ return Status("failed - register wasn't recognized to be a GPR or an FPR, "
+ "write strategy unknown");
}
-Error NativeRegisterContextLinux_x86_64::ReadAllRegisterValues(
+Status NativeRegisterContextLinux_x86_64::ReadAllRegisterValues(
lldb::DataBufferSP &data_sp) {
- Error error;
+ Status error;
data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
if (!data_sp) {
@@ -728,9 +729,9 @@ Error NativeRegisterContextLinux_x86_64::ReadAllRegisterValues(
return error;
}
-Error NativeRegisterContextLinux_x86_64::WriteAllRegisterValues(
+Status NativeRegisterContextLinux_x86_64::WriteAllRegisterValues(
const lldb::DataBufferSP &data_sp) {
- Error error;
+ Status error;
if (!data_sp) {
error.SetErrorStringWithFormat(
@@ -857,7 +858,7 @@ bool NativeRegisterContextLinux_x86_64::IsFPR(uint32_t reg_index) const {
reg_index <= m_reg_info.last_fpr);
}
-Error NativeRegisterContextLinux_x86_64::WriteFPR() {
+Status NativeRegisterContextLinux_x86_64::WriteFPR() {
switch (m_xstate_type) {
case XStateType::FXSAVE:
return WriteRegisterSet(
@@ -867,7 +868,7 @@ Error NativeRegisterContextLinux_x86_64::WriteFPR() {
return WriteRegisterSet(&m_iovec, sizeof(m_fpr.xstate.xsave),
NT_X86_XSTATE);
default:
- return Error("Unrecognized FPR type.");
+ return Status("Unrecognized FPR type.");
}
}
@@ -954,8 +955,8 @@ size_t NativeRegisterContextLinux_x86_64::GetFPRSize() {
}
}
-Error NativeRegisterContextLinux_x86_64::ReadFPR() {
- Error error;
+Status NativeRegisterContextLinux_x86_64::ReadFPR() {
+ Status error;
// Probe XSAVE and if it is not supported fall back to FXSAVE.
if (m_xstate_type != XStateType::FXSAVE) {
@@ -973,7 +974,7 @@ Error NativeRegisterContextLinux_x86_64::ReadFPR() {
m_xstate_type = XStateType::FXSAVE;
return error;
}
- return Error("Unrecognized FPR type.");
+ return Status("Unrecognized FPR type.");
}
bool NativeRegisterContextLinux_x86_64::IsMPX(uint32_t reg_index) const {
@@ -1013,13 +1014,13 @@ bool NativeRegisterContextLinux_x86_64::CopyMPXtoXSTATE(uint32_t reg) {
return true;
}
-Error NativeRegisterContextLinux_x86_64::IsWatchpointHit(uint32_t wp_index,
- bool &is_hit) {
+Status NativeRegisterContextLinux_x86_64::IsWatchpointHit(uint32_t wp_index,
+ bool &is_hit) {
if (wp_index >= NumSupportedHardwareWatchpoints())
- return Error("Watchpoint index out of range");
+ return Status("Watchpoint index out of range");
RegisterValue reg_value;
- Error error = ReadRegisterRaw(m_reg_info.first_dr + 6, reg_value);
+ Status error = ReadRegisterRaw(m_reg_info.first_dr + 6, reg_value);
if (error.Fail()) {
is_hit = false;
return error;
@@ -1032,12 +1033,12 @@ Error NativeRegisterContextLinux_x86_64::IsWatchpointHit(uint32_t wp_index,
return error;
}
-Error NativeRegisterContextLinux_x86_64::GetWatchpointHitIndex(
+Status NativeRegisterContextLinux_x86_64::GetWatchpointHitIndex(
uint32_t &wp_index, lldb::addr_t trap_addr) {
uint32_t num_hw_wps = NumSupportedHardwareWatchpoints();
for (wp_index = 0; wp_index < num_hw_wps; ++wp_index) {
bool is_hit;
- Error error = IsWatchpointHit(wp_index, is_hit);
+ Status error = IsWatchpointHit(wp_index, is_hit);
if (error.Fail()) {
wp_index = LLDB_INVALID_INDEX32;
return error;
@@ -1046,16 +1047,16 @@ Error NativeRegisterContextLinux_x86_64::GetWatchpointHitIndex(
}
}
wp_index = LLDB_INVALID_INDEX32;
- return Error();
+ return Status();
}
-Error NativeRegisterContextLinux_x86_64::IsWatchpointVacant(uint32_t wp_index,
- bool &is_vacant) {
+Status NativeRegisterContextLinux_x86_64::IsWatchpointVacant(uint32_t wp_index,
+ bool &is_vacant) {
if (wp_index >= NumSupportedHardwareWatchpoints())
- return Error("Watchpoint index out of range");
+ return Status("Watchpoint index out of range");
RegisterValue reg_value;
- Error error = ReadRegisterRaw(m_reg_info.first_dr + 7, reg_value);
+ Status error = ReadRegisterRaw(m_reg_info.first_dr + 7, reg_value);
if (error.Fail()) {
is_vacant = false;
return error;
@@ -1068,11 +1069,11 @@ Error NativeRegisterContextLinux_x86_64::IsWatchpointVacant(uint32_t wp_index,
return error;
}
-Error NativeRegisterContextLinux_x86_64::SetHardwareWatchpointWithIndex(
+Status NativeRegisterContextLinux_x86_64::SetHardwareWatchpointWithIndex(
lldb::addr_t addr, size_t size, uint32_t watch_flags, uint32_t wp_index) {
if (wp_index >= NumSupportedHardwareWatchpoints())
- return Error("Watchpoint index out of range");
+ return Status("Watchpoint index out of range");
// Read only watchpoints aren't supported on x86_64. Fall back to read/write
// waitchpoints instead.
@@ -1082,17 +1083,17 @@ Error NativeRegisterContextLinux_x86_64::SetHardwareWatchpointWithIndex(
watch_flags = 0x3;
if (watch_flags != 0x1 && watch_flags != 0x3)
- return Error("Invalid read/write bits for watchpoint");
+ return Status("Invalid read/write bits for watchpoint");
if (size != 1 && size != 2 && size != 4 && size != 8)
- return Error("Invalid size for watchpoint");
+ return Status("Invalid size for watchpoint");
bool is_vacant;
- Error error = IsWatchpointVacant(wp_index, is_vacant);
+ Status error = IsWatchpointVacant(wp_index, is_vacant);
if (error.Fail())
return error;
if (!is_vacant)
- return Error("Watchpoint index not vacant");
+ return Status("Watchpoint index not vacant");
RegisterValue reg_value;
error = ReadRegisterRaw(m_reg_info.first_dr + 7, reg_value);
@@ -1140,7 +1141,7 @@ bool NativeRegisterContextLinux_x86_64::ClearHardwareWatchpoint(
// for watchpoints 0, 1, 2, or 3, respectively,
// clear bits 0, 1, 2, or 3 of the debug status register (DR6)
- Error error = ReadRegisterRaw(m_reg_info.first_dr + 6, reg_value);
+ Status error = ReadRegisterRaw(m_reg_info.first_dr + 6, reg_value);
if (error.Fail())
return false;
uint64_t bit_mask = 1 << wp_index;
@@ -1161,11 +1162,11 @@ bool NativeRegisterContextLinux_x86_64::ClearHardwareWatchpoint(
.Success();
}
-Error NativeRegisterContextLinux_x86_64::ClearAllHardwareWatchpoints() {
+Status NativeRegisterContextLinux_x86_64::ClearAllHardwareWatchpoints() {
RegisterValue reg_value;
// clear bits {0-4} of the debug status register (DR6)
- Error error = ReadRegisterRaw(m_reg_info.first_dr + 6, reg_value);
+ Status error = ReadRegisterRaw(m_reg_info.first_dr + 6, reg_value);
if (error.Fail())
return error;
uint64_t bit_mask = 0xF;
@@ -1189,7 +1190,7 @@ uint32_t NativeRegisterContextLinux_x86_64::SetHardwareWatchpoint(
const uint32_t num_hw_watchpoints = NumSupportedHardwareWatchpoints();
for (uint32_t wp_index = 0; wp_index < num_hw_watchpoints; ++wp_index) {
bool is_vacant;
- Error error = IsWatchpointVacant(wp_index, is_vacant);
+ Status error = IsWatchpointVacant(wp_index, is_vacant);
if (is_vacant) {
error = SetHardwareWatchpointWithIndex(addr, size, watch_flags, wp_index);
if (error.Success())