diff options
Diffstat (limited to 'source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp')
| -rw-r--r-- | source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp | 119 |
1 files changed, 61 insertions, 58 deletions
diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp index 2dd23ad75a03..22b7d10869fe 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp @@ -13,8 +13,8 @@ #include "lldb/Core/RegisterValue.h" #include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "Plugins/Process/Linux/Procfs.h" #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" @@ -157,9 +157,10 @@ NativeRegisterContextLinux_arm::GetRegisterSet(uint32_t set_index) const { return nullptr; } -Error NativeRegisterContextLinux_arm::ReadRegister(const RegisterInfo *reg_info, - RegisterValue ®_value) { - Error error; +Status +NativeRegisterContextLinux_arm::ReadRegister(const RegisterInfo *reg_info, + RegisterValue ®_value) { + Status error; if (!reg_info) { error.SetErrorString("reg_info NULL"); @@ -226,16 +227,17 @@ Error NativeRegisterContextLinux_arm::ReadRegister(const RegisterInfo *reg_info, return error; } -Error NativeRegisterContextLinux_arm::WriteRegister( - const RegisterInfo *reg_info, const RegisterValue ®_value) { +Status +NativeRegisterContextLinux_arm::WriteRegister(const RegisterInfo *reg_info, + const RegisterValue ®_value) { if (!reg_info) - return Error("reg_info NULL"); + return Status("reg_info 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); @@ -257,29 +259,29 @@ Error NativeRegisterContextLinux_arm::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; - 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_arm::ReadAllRegisterValues( +Status NativeRegisterContextLinux_arm::ReadAllRegisterValues( lldb::DataBufferSP &data_sp) { - Error error; + Status error; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); if (!data_sp) - return Error("failed to allocate DataBufferHeap instance of size %" PRIu64, - (uint64_t)REG_CONTEXT_SIZE); + return Status("failed to allocate DataBufferHeap instance of size %" PRIu64, + (uint64_t)REG_CONTEXT_SIZE); error = ReadGPR(); if (error.Fail()) @@ -304,9 +306,9 @@ Error NativeRegisterContextLinux_arm::ReadAllRegisterValues( return error; } -Error NativeRegisterContextLinux_arm::WriteAllRegisterValues( +Status NativeRegisterContextLinux_arm::WriteAllRegisterValues( const lldb::DataBufferSP &data_sp) { - Error error; + Status error; if (!data_sp) { error.SetErrorStringWithFormat( @@ -361,7 +363,7 @@ uint32_t NativeRegisterContextLinux_arm::NumSupportedHardwareBreakpoints() { if (log) log->Printf("NativeRegisterContextLinux_arm::%s()", __FUNCTION__); - Error error; + Status error; // Read hardware breakpoint and watchpoint information. error = ReadHardwareDebugInfo(); @@ -380,7 +382,7 @@ NativeRegisterContextLinux_arm::SetHardwareBreakpoint(lldb::addr_t addr, LLDB_LOG(log, "addr: {0:x}, size: {1:x}", addr, size); // Read hardware breakpoint and watchpoint information. - Error error = ReadHardwareDebugInfo(); + Status error = ReadHardwareDebugInfo(); if (error.Fail()) return LLDB_INVALID_INDEX32; @@ -438,7 +440,7 @@ bool NativeRegisterContextLinux_arm::ClearHardwareBreakpoint(uint32_t hw_idx) { LLDB_LOG(log, "hw_idx: {0}", hw_idx); // Read hardware breakpoint and watchpoint information. - Error error = ReadHardwareDebugInfo(); + Status error = ReadHardwareDebugInfo(); if (error.Fail()) return false; @@ -466,7 +468,7 @@ bool NativeRegisterContextLinux_arm::ClearHardwareBreakpoint(uint32_t hw_idx) { return true; } -Error NativeRegisterContextLinux_arm::GetHardwareBreakHitIndex( +Status NativeRegisterContextLinux_arm::GetHardwareBreakHitIndex( uint32_t &bp_index, lldb::addr_t trap_addr) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS)); @@ -480,21 +482,21 @@ Error NativeRegisterContextLinux_arm::GetHardwareBreakHitIndex( if ((m_hbr_regs[bp_index].control & 0x1) && (trap_addr == break_addr)) { m_hbr_regs[bp_index].hit_addr = trap_addr; - return Error(); + return Status(); } } bp_index = LLDB_INVALID_INDEX32; - return Error(); + return Status(); } -Error NativeRegisterContextLinux_arm::ClearAllHardwareBreakpoints() { +Status NativeRegisterContextLinux_arm::ClearAllHardwareBreakpoints() { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS)); if (log) log->Printf("NativeRegisterContextLinux_arm::%s()", __FUNCTION__); - Error error; + Status error; // Read hardware breakpoint and watchpoint information. error = ReadHardwareDebugInfo(); @@ -527,14 +529,14 @@ Error NativeRegisterContextLinux_arm::ClearAllHardwareBreakpoints() { } } - return Error(); + return Status(); } uint32_t NativeRegisterContextLinux_arm::NumSupportedHardwareWatchpoints() { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS)); // Read hardware breakpoint and watchpoint information. - Error error = ReadHardwareDebugInfo(); + Status error = ReadHardwareDebugInfo(); if (error.Fail()) return 0; @@ -550,7 +552,7 @@ uint32_t NativeRegisterContextLinux_arm::SetHardwareWatchpoint( watch_flags); // Read hardware breakpoint and watchpoint information. - Error error = ReadHardwareDebugInfo(); + Status error = ReadHardwareDebugInfo(); if (error.Fail()) return LLDB_INVALID_INDEX32; @@ -654,7 +656,7 @@ bool NativeRegisterContextLinux_arm::ClearHardwareWatchpoint( LLDB_LOG(log, "wp_index: {0}", wp_index); // Read hardware breakpoint and watchpoint information. - Error error = ReadHardwareDebugInfo(); + Status error = ReadHardwareDebugInfo(); if (error.Fail()) return false; @@ -683,9 +685,9 @@ bool NativeRegisterContextLinux_arm::ClearHardwareWatchpoint( return true; } -Error NativeRegisterContextLinux_arm::ClearAllHardwareWatchpoints() { +Status NativeRegisterContextLinux_arm::ClearAllHardwareWatchpoints() { // Read hardware breakpoint and watchpoint information. - Error error = ReadHardwareDebugInfo(); + Status error = ReadHardwareDebugInfo(); if (error.Fail()) return error; @@ -715,7 +717,7 @@ Error NativeRegisterContextLinux_arm::ClearAllHardwareWatchpoints() { } } - return Error(); + return Status(); } uint32_t NativeRegisterContextLinux_arm::GetWatchpointSize(uint32_t wp_index) { @@ -745,8 +747,9 @@ bool NativeRegisterContextLinux_arm::WatchpointIsEnabled(uint32_t wp_index) { return false; } -Error NativeRegisterContextLinux_arm::GetWatchpointHitIndex( - uint32_t &wp_index, lldb::addr_t trap_addr) { +Status +NativeRegisterContextLinux_arm::GetWatchpointHitIndex(uint32_t &wp_index, + lldb::addr_t trap_addr) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS)); LLDB_LOG(log, "wp_index: {0}, trap_addr: {1:x}", wp_index, trap_addr); @@ -760,12 +763,12 @@ Error NativeRegisterContextLinux_arm::GetWatchpointHitIndex( if (WatchpointIsEnabled(wp_index) && trap_addr >= watch_addr && trap_addr < watch_addr + watch_size) { m_hwp_regs[wp_index].hit_addr = trap_addr; - return Error(); + return Status(); } } wp_index = LLDB_INVALID_INDEX32; - return Error(); + return Status(); } lldb::addr_t @@ -796,11 +799,11 @@ NativeRegisterContextLinux_arm::GetWatchpointHitAddress(uint32_t wp_index) { return LLDB_INVALID_ADDRESS; } -Error NativeRegisterContextLinux_arm::ReadHardwareDebugInfo() { - Error error; +Status NativeRegisterContextLinux_arm::ReadHardwareDebugInfo() { + Status error; if (!m_refresh_hwdebug_info) { - return Error(); + return Status(); } unsigned int cap_val; @@ -819,9 +822,9 @@ Error NativeRegisterContextLinux_arm::ReadHardwareDebugInfo() { return error; } -Error NativeRegisterContextLinux_arm::WriteHardwareDebugRegs(int hwbType, - int hwb_index) { - Error error; +Status NativeRegisterContextLinux_arm::WriteHardwareDebugRegs(int hwbType, + int hwb_index) { + Status error; lldb::addr_t *addr_buf; uint32_t *ctrl_buf; @@ -869,7 +872,7 @@ uint32_t NativeRegisterContextLinux_arm::CalculateFprOffset( GetRegisterInfoAtIndex(m_reg_info.first_fpr)->byte_offset; } -Error NativeRegisterContextLinux_arm::DoReadRegisterValue( +Status NativeRegisterContextLinux_arm::DoReadRegisterValue( uint32_t offset, const char *reg_name, uint32_t size, RegisterValue &value) { // PTRACE_PEEKUSER don't work in the aarch64 linux kernel used on android @@ -881,17 +884,17 @@ Error NativeRegisterContextLinux_arm::DoReadRegisterValue( // comparision to processing time in lldb-server. assert(offset % 4 == 0 && "Try to write a register with unaligned offset"); if (offset + sizeof(uint32_t) > sizeof(m_gpr_arm)) - return Error("Register isn't fit into the size of the GPR area"); + return Status("Register isn't fit into the size of the GPR area"); - Error error = DoReadGPR(m_gpr_arm, sizeof(m_gpr_arm)); + Status error = DoReadGPR(m_gpr_arm, sizeof(m_gpr_arm)); if (error.Fail()) return error; value.SetUInt32(m_gpr_arm[offset / sizeof(uint32_t)]); - return Error(); + return Status(); } -Error NativeRegisterContextLinux_arm::DoWriteRegisterValue( +Status NativeRegisterContextLinux_arm::DoWriteRegisterValue( uint32_t offset, const char *reg_name, const RegisterValue &value) { // PTRACE_POKEUSER don't work in the aarch64 linux kernel used on android // devices (always return @@ -903,9 +906,9 @@ Error NativeRegisterContextLinux_arm::DoWriteRegisterValue( // lldb-server. assert(offset % 4 == 0 && "Try to write a register with unaligned offset"); if (offset + sizeof(uint32_t) > sizeof(m_gpr_arm)) - return Error("Register isn't fit into the size of the GPR area"); + return Status("Register isn't fit into the size of the GPR area"); - Error error = DoReadGPR(m_gpr_arm, sizeof(m_gpr_arm)); + Status error = DoReadGPR(m_gpr_arm, sizeof(m_gpr_arm)); if (error.Fail()) return error; @@ -927,7 +930,7 @@ Error NativeRegisterContextLinux_arm::DoWriteRegisterValue( return DoWriteGPR(m_gpr_arm, sizeof(m_gpr_arm)); } -Error NativeRegisterContextLinux_arm::DoReadGPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux_arm::DoReadGPR(void *buf, size_t buf_size) { #ifdef __arm__ return NativeRegisterContextLinux::DoReadGPR(buf, buf_size); #else // __aarch64__ @@ -939,7 +942,7 @@ Error NativeRegisterContextLinux_arm::DoReadGPR(void *buf, size_t buf_size) { #endif // __arm__ } -Error NativeRegisterContextLinux_arm::DoWriteGPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux_arm::DoWriteGPR(void *buf, size_t buf_size) { #ifdef __arm__ return NativeRegisterContextLinux::DoWriteGPR(buf, buf_size); #else // __aarch64__ @@ -951,7 +954,7 @@ Error NativeRegisterContextLinux_arm::DoWriteGPR(void *buf, size_t buf_size) { #endif // __arm__ } -Error NativeRegisterContextLinux_arm::DoReadFPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux_arm::DoReadFPR(void *buf, size_t buf_size) { #ifdef __arm__ return NativeProcessLinux::PtraceWrapper(PTRACE_GETVFPREGS, m_thread.GetID(), nullptr, buf, buf_size); @@ -964,7 +967,7 @@ Error NativeRegisterContextLinux_arm::DoReadFPR(void *buf, size_t buf_size) { #endif // __arm__ } -Error NativeRegisterContextLinux_arm::DoWriteFPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux_arm::DoWriteFPR(void *buf, size_t buf_size) { #ifdef __arm__ return NativeProcessLinux::PtraceWrapper(PTRACE_SETVFPREGS, m_thread.GetID(), nullptr, buf, buf_size); |
