Remove use of multiple reg index enums by RegisterContextPOSIX_arm64

Summary:
This patch removes dependence of RegisterContextPOSIX_arm64 on register number enums defined in lldb-arm64-register-enums.h.
RegisterContextPOSIX_arm64 makes use of helper functions to access register numbers defined in RegisterInfos_arm64.h via RegisterInfosPOSIX_arm64.

Reviewers: labath

Reviewed By: labath

Subscribers: emaste, kristof.beyls, arphaman, danielkiss, lldb-commits

Differential Revision: https://reviews.llvm.org/D83753
This commit is contained in:
Muhammad Omair Javaid 2020-07-20 14:36:40 +05:00
parent 9b7c43d341
commit 4923dca9bd
4 changed files with 12 additions and 15 deletions

View File

@ -24,7 +24,10 @@ RegisterContextPOSIXProcessMonitor_arm64::
RegisterContextPOSIXProcessMonitor_arm64(
lldb_private::Thread &thread,
std::unique_ptr<RegisterInfoPOSIX_arm64> register_info)
: RegisterContextPOSIX_arm64(thread, std::move(register_info)) {}
: RegisterContextPOSIX_arm64(thread, std::move(register_info)) {
::memset(&m_fpr, 0, sizeof m_gpr_arm64);
::memset(&m_fpr, 0, sizeof m_fpr);
}
ProcessMonitor &RegisterContextPOSIXProcessMonitor_arm64::GetMonitor() {
lldb::ProcessSP base = CalculateProcess();
@ -226,11 +229,11 @@ bool RegisterContextPOSIXProcessMonitor_arm64::UpdateAfterBreakpoint() {
unsigned RegisterContextPOSIXProcessMonitor_arm64::GetRegisterIndexFromOffset(
unsigned offset) {
unsigned reg;
for (reg = 0; reg < k_num_registers_arm64; reg++) {
for (reg = 0; reg < GetRegisterCount(); reg++) {
if (GetRegisterInfo()[reg].byte_offset == offset)
break;
}
assert(reg < k_num_registers_arm64 && "Invalid register offset.");
assert(reg < GetRegisterCount() && "Invalid register offset.");
return reg;
}

View File

@ -71,6 +71,11 @@ protected:
uint32_t NumSupportedHardwareWatchpoints();
private:
RegisterInfoPOSIX_arm64::GPR m_gpr_arm64; // 64-bit general purpose registers.
RegisterInfoPOSIX_arm64::FPU
m_fpr; // floating-point registers including extended register sets.
ProcessMonitor &GetMonitor();
};

View File

@ -43,10 +43,7 @@ RegisterContextPOSIX_arm64::RegisterContextPOSIX_arm64(
lldb_private::Thread &thread,
std::unique_ptr<RegisterInfoPOSIX_arm64> register_info)
: lldb_private::RegisterContext(thread, 0),
m_register_info_up(std::move(register_info)) {
::memset(&m_fpr, 0, sizeof m_fpr);
}
m_register_info_up(std::move(register_info)) {}
RegisterContextPOSIX_arm64::~RegisterContextPOSIX_arm64() {}

View File

@ -11,7 +11,6 @@
#include "RegisterInfoInterface.h"
#include "RegisterInfoPOSIX_arm64.h"
#include "lldb-arm64-register-enums.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Utility/Log.h"
@ -46,13 +45,6 @@ public:
const char *GetRegisterName(unsigned reg);
protected:
uint64_t m_gpr_arm64[lldb_private::k_num_gpr_registers_arm64]; // 64-bit
// general
// purpose
// registers.
struct RegisterInfoPOSIX_arm64::FPU
m_fpr; // floating-point registers including extended register sets.
std::unique_ptr<RegisterInfoPOSIX_arm64> m_register_info_up;
virtual const lldb_private::RegisterInfo *GetRegisterInfo();