Index: lldb/include/lldb/Target/RegisterContext.h =================================================================== --- lldb/include/lldb/Target/RegisterContext.h +++ lldb/include/lldb/Target/RegisterContext.h @@ -39,6 +39,8 @@ virtual const RegisterSet *GetRegisterSet(size_t reg_set) = 0; + virtual lldb::ByteOrder GetByteOrder(); + virtual bool ReadRegister(const RegisterInfo *reg_info, RegisterValue ®_value) = 0; @@ -105,7 +107,7 @@ /// The equivalent register number in the eRegisterKindLLDB /// numbering scheme, if possible, else LLDB_INVALID_REGNUM. virtual uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, - uint32_t num) = 0; + uint32_t num); // Subclasses can override these functions if desired virtual uint32_t NumSupportedHardwareBreakpoints(); Index: lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h +++ lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h @@ -44,9 +44,6 @@ const char *GetRegisterName(unsigned reg); - uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, - uint32_t num) override; - protected: struct RegInfo { uint32_t num_registers; @@ -95,8 +92,6 @@ bool IsFPR(unsigned reg); - lldb::ByteOrder GetByteOrder(); - virtual bool ReadGPR() = 0; virtual bool ReadFPR() = 0; virtual bool WriteGPR() = 0; Index: lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp +++ lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp @@ -178,35 +178,6 @@ return GetRegisterInfo()[reg].name; } -lldb::ByteOrder RegisterContextPOSIX_arm::GetByteOrder() { - // Get the target process whose privileged thread was used for the register - // read. - lldb::ByteOrder byte_order = lldb::eByteOrderInvalid; - lldb_private::Process *process = CalculateProcess().get(); - - if (process) - byte_order = process->GetByteOrder(); - return byte_order; -} - bool RegisterContextPOSIX_arm::IsRegisterSetAvailable(size_t set_index) { return set_index < k_num_register_sets; } - -// Used when parsing DWARF and EH frame information and any other object file -// sections that contain register numbers in them. -uint32_t RegisterContextPOSIX_arm::ConvertRegisterKindToRegisterNumber( - lldb::RegisterKind kind, uint32_t num) { - const uint32_t num_regs = GetRegisterCount(); - - assert(kind < lldb::kNumRegisterKinds); - for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) { - const lldb_private::RegisterInfo *reg_info = - GetRegisterInfoAtIndex(reg_idx); - - if (reg_info->kinds[kind] == num) - return reg_idx; - } - - return LLDB_INVALID_REGNUM; -} Index: lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h +++ lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h @@ -44,9 +44,6 @@ const char *GetRegisterName(unsigned reg); - uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, - uint32_t num) override; - protected: struct RegInfo { uint32_t num_registers; @@ -95,8 +92,6 @@ bool IsFPR(unsigned reg); - lldb::ByteOrder GetByteOrder(); - virtual bool ReadGPR() = 0; virtual bool ReadFPR() = 0; virtual bool WriteGPR() = 0; Index: lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp +++ lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp @@ -180,6 +180,10 @@ return sets; } +bool RegisterContextPOSIX_arm64::IsRegisterSetAvailable(size_t set_index) { + return set_index < k_num_register_sets; +} + const lldb_private::RegisterSet * RegisterContextPOSIX_arm64::GetRegisterSet(size_t set) { if (IsRegisterSetAvailable(set)) { @@ -199,36 +203,3 @@ assert(reg < m_reg_info.num_registers && "Invalid register offset."); return GetRegisterInfo()[reg].name; } - -lldb::ByteOrder RegisterContextPOSIX_arm64::GetByteOrder() { - // Get the target process whose privileged thread was used for the register - // read. - lldb::ByteOrder byte_order = lldb::eByteOrderInvalid; - lldb_private::Process *process = CalculateProcess().get(); - - if (process) - byte_order = process->GetByteOrder(); - return byte_order; -} - -bool RegisterContextPOSIX_arm64::IsRegisterSetAvailable(size_t set_index) { - return set_index < k_num_register_sets; -} - -// Used when parsing DWARF and EH frame information and any other object file -// sections that contain register numbers in them. -uint32_t RegisterContextPOSIX_arm64::ConvertRegisterKindToRegisterNumber( - lldb::RegisterKind kind, uint32_t num) { - const uint32_t num_regs = GetRegisterCount(); - - assert(kind < lldb::kNumRegisterKinds); - for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) { - const lldb_private::RegisterInfo *reg_info = - GetRegisterInfoAtIndex(reg_idx); - - if (reg_info->kinds[kind] == num) - return reg_idx; - } - - return LLDB_INVALID_REGNUM; -} Index: lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h +++ lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h @@ -73,8 +73,6 @@ bool IsFPR(unsigned reg); - lldb::ByteOrder GetByteOrder(); - virtual bool ReadGPR() = 0; virtual bool ReadFPR() = 0; virtual bool WriteGPR() = 0; Index: lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp +++ lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp @@ -149,17 +149,6 @@ return GetRegisterInfo()[reg].name; } -lldb::ByteOrder RegisterContextPOSIX_mips64::GetByteOrder() { - // Get the target process whose privileged thread was used for the register - // read. - lldb::ByteOrder byte_order = eByteOrderInvalid; - Process *process = CalculateProcess().get(); - - if (process) - byte_order = process->GetByteOrder(); - return byte_order; -} - bool RegisterContextPOSIX_mips64::IsRegisterSetAvailable(size_t set_index) { size_t num_sets = GetRegisterSetCount(); Index: lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h +++ lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h @@ -165,9 +165,6 @@ const char *GetRegisterName(unsigned reg); - uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, - uint32_t num) override; - protected: uint64_t m_gpr_powerpc[k_num_gpr_registers_powerpc]; // general purpose registers. @@ -189,8 +186,6 @@ bool IsVMX(unsigned reg); - lldb::ByteOrder GetByteOrder(); - virtual bool ReadGPR() = 0; virtual bool ReadFPR() = 0; virtual bool ReadVMX() = 0; Index: lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp +++ lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp @@ -157,36 +157,8 @@ return GetRegisterInfo()[reg].name; } -lldb::ByteOrder RegisterContextPOSIX_powerpc::GetByteOrder() { - // Get the target process whose privileged thread was used for the register - // read. - lldb::ByteOrder byte_order = eByteOrderInvalid; - Process *process = CalculateProcess().get(); - - if (process) - byte_order = process->GetByteOrder(); - return byte_order; -} - bool RegisterContextPOSIX_powerpc::IsRegisterSetAvailable(size_t set_index) { size_t num_sets = k_num_register_sets; return (set_index < num_sets); } - -// Used when parsing DWARF and EH frame information and any other object file -// sections that contain register numbers in them. -uint32_t RegisterContextPOSIX_powerpc::ConvertRegisterKindToRegisterNumber( - lldb::RegisterKind kind, uint32_t num) { - const uint32_t num_regs = GetRegisterCount(); - - assert(kind < kNumRegisterKinds); - for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) { - const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg_idx); - - if (reg_info->kinds[kind] == num) - return reg_idx; - } - - return LLDB_INVALID_REGNUM; -} Index: lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h +++ lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h @@ -39,9 +39,6 @@ const char *GetRegisterName(unsigned reg); - uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, - uint32_t num) override; - protected: // 64-bit general purpose registers. uint64_t m_gpr_ppc64le[k_num_gpr_registers_ppc64le]; @@ -71,7 +68,6 @@ bool IsVSX(unsigned reg); - lldb::ByteOrder GetByteOrder(); }; #endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_PPC64LE_H Index: lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp +++ lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp @@ -176,36 +176,8 @@ return GetRegisterInfo()[reg].name; } -lldb::ByteOrder RegisterContextPOSIX_ppc64le::GetByteOrder() { - // Get the target process whose privileged thread was used for the register - // read. - lldb::ByteOrder byte_order = eByteOrderInvalid; - Process *process = CalculateProcess().get(); - - if (process) - byte_order = process->GetByteOrder(); - return byte_order; -} - bool RegisterContextPOSIX_ppc64le::IsRegisterSetAvailable(size_t set_index) { size_t num_sets = k_num_register_sets; return (set_index < num_sets); } - -// Used when parsing DWARF and EH frame information and any other object file -// sections that contain register numbers in them. -uint32_t RegisterContextPOSIX_ppc64le::ConvertRegisterKindToRegisterNumber( - lldb::RegisterKind kind, uint32_t num) { - const uint32_t num_regs = GetRegisterCount(); - - assert(kind < kNumRegisterKinds); - for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) { - const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg_idx); - - if (reg_info->kinds[kind] == num) - return reg_idx; - } - - return LLDB_INVALID_REGNUM; -} Index: lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h +++ lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h @@ -43,9 +43,6 @@ const char *GetRegisterName(unsigned reg); - uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, - uint32_t num) override; - protected: struct RegInfo { uint32_t num_registers; @@ -68,8 +65,6 @@ bool IsFPR(unsigned reg); - lldb::ByteOrder GetByteOrder(); - virtual bool ReadGPR() = 0; virtual bool ReadFPR() = 0; virtual bool WriteGPR() = 0; Index: lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp +++ lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp @@ -161,31 +161,3 @@ } return nullptr; } - -lldb::ByteOrder RegisterContextPOSIX_s390x::GetByteOrder() { - // Get the target process whose privileged thread was used for the register - // read. - lldb::ByteOrder byte_order = eByteOrderInvalid; - Process *process = CalculateProcess().get(); - - if (process) - byte_order = process->GetByteOrder(); - return byte_order; -} - -// Used when parsing DWARF and EH frame information and any other object file -// sections that contain register numbers in them. -uint32_t RegisterContextPOSIX_s390x::ConvertRegisterKindToRegisterNumber( - lldb::RegisterKind kind, uint32_t num) { - const uint32_t num_regs = GetRegisterCount(); - - assert(kind < kNumRegisterKinds); - for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) { - const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg_idx); - - if (reg_info->kinds[kind] == num) - return reg_idx; - } - - return LLDB_INVALID_REGNUM; -} Index: lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h +++ lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h @@ -47,9 +47,6 @@ const char *GetRegisterName(unsigned reg); - uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, - uint32_t num) override; - // Note: prefer kernel definitions over user-land enum FPRType { eNotValid = 0, @@ -160,8 +157,6 @@ bool IsAVX(unsigned reg); - lldb::ByteOrder GetByteOrder(); - bool CopyXSTATEtoYMM(uint32_t reg, lldb::ByteOrder byte_order); bool CopyYMMtoXSTATE(uint32_t reg, lldb::ByteOrder byte_order); bool IsFPR(unsigned reg, FPRType fpr_type); Index: lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp +++ lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp @@ -456,17 +456,6 @@ return GetRegisterInfo()[reg].name; } -lldb::ByteOrder RegisterContextPOSIX_x86::GetByteOrder() { - // Get the target process whose privileged thread was used for the register - // read. - lldb::ByteOrder byte_order = eByteOrderInvalid; - Process *process = CalculateProcess().get(); - - if (process) - byte_order = process->GetByteOrder(); - return byte_order; -} - // Parse ymm registers and into xmm.bytes and ymmh.bytes. bool RegisterContextPOSIX_x86::CopyYMMtoXSTATE(uint32_t reg, lldb::ByteOrder byte_order) { @@ -509,20 +498,3 @@ ++num_sets; return (set_index < num_sets); } - -// Used when parsing DWARF and EH frame information and any other object file -// sections that contain register numbers in them. -uint32_t RegisterContextPOSIX_x86::ConvertRegisterKindToRegisterNumber( - lldb::RegisterKind kind, uint32_t num) { - const uint32_t num_regs = GetRegisterCount(); - - assert(kind < kNumRegisterKinds); - for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) { - const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg_idx); - - if (reg_info->kinds[kind] == num) - return reg_idx; - } - - return LLDB_INVALID_REGNUM; -} Index: lldb/source/Target/RegisterContext.cpp =================================================================== --- lldb/source/Target/RegisterContext.cpp +++ lldb/source/Target/RegisterContext.cpp @@ -274,6 +274,24 @@ return LLDB_INVALID_INDEX32; } +// Used when parsing DWARF and EH frame information and any other object file +// sections that contain register numbers in them. +uint32_t +RegisterContext::ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, + uint32_t num) { + const uint32_t num_regs = GetRegisterCount(); + + assert(kind < kNumRegisterKinds); + for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) { + const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg_idx); + + if (reg_info->kinds[kind] == num) + return reg_idx; + } + + return LLDB_INVALID_REGNUM; +} + bool RegisterContext::ClearHardwareBreakpoint(uint32_t hw_idx) { return false; } uint32_t RegisterContext::NumSupportedHardwareWatchpoints() { return 0; } @@ -397,6 +415,17 @@ return error; } +lldb::ByteOrder RegisterContext::GetByteOrder() { + // Get the target process whose privileged thread was used for the register + // read. + lldb::ByteOrder byte_order = lldb::eByteOrderInvalid; + lldb_private::Process *process = CalculateProcess().get(); + + if (process) + byte_order = process->GetByteOrder(); + return byte_order; +} + bool RegisterContext::ReadAllRegisterValues( lldb_private::RegisterCheckpoint ®_checkpoint) { return ReadAllRegisterValues(reg_checkpoint.GetData());