diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp index 9bce8a80a22f..ad8b2756ced2 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp @@ -592,6 +592,63 @@ NativeRegisterContextLinux_mips64::WriteAllRegisterValues (const lldb::DataBuffe return error; } +Error +NativeRegisterContextLinux_mips64::ReadFPR() +{ + void* buf = GetFPRBuffer(); + if (!buf) + return Error("FPR buffer is NULL"); + + Error error = NativeRegisterContextLinux::ReadFPR(); + + if (IsFR0()) + { + for (int i = 0; i < 16; i++) + { + // copy odd single from top of neighbouring even double + uint8_t * src = (uint8_t *)buf + 4 + (i * 16); + uint8_t * dst = (uint8_t *)buf + 8 + (i * 16); + *(uint32_t *) dst = *(uint32_t *) src; + } + } + + return error; +} + +Error +NativeRegisterContextLinux_mips64::WriteFPR() +{ + void* buf = GetFPRBuffer(); + if (!buf) + return Error("FPR buffer is NULL"); + + if (IsFR0()) + { + for (int i = 0; i < 16; i++) + { + // copy odd single to top of neighbouring even double + uint8_t * src = (uint8_t *)buf + 8 + (i * 16); + uint8_t * dst = (uint8_t *)buf + 4 + (i * 16); + *(uint32_t *) dst = *(uint32_t *) src; + } + } + + return NativeRegisterContextLinux::WriteFPR(); +} + +bool +NativeRegisterContextLinux_mips64::IsFR0() +{ + const RegisterInfo *const reg_info_p = GetRegisterInfoAtIndex (36); // Status Register is at index 36 of the register array + + RegisterValue reg_value; + ReadRegister (reg_info_p, reg_value); + + uint64_t value = reg_value.GetAsUInt64(); + + return (!(value & 0x4000000)); +} + bool NativeRegisterContextLinux_mips64::IsFPR(uint32_t reg_index) const { diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.h b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.h index 15ff877dfb4a..1c24c91c3867 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.h +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.h @@ -46,6 +46,12 @@ namespace process_linux { Error WriteAllRegisterValues (const lldb::DataBufferSP &data_sp) override; + Error + ReadFPR() override; + + Error + WriteFPR() override; + Error IsWatchpointHit (uint32_t wp_index, bool &is_hit) override; @@ -84,6 +90,9 @@ namespace process_linux { const char* reg_name, const RegisterValue &value) override; + bool + IsFR0(); + bool IsFPR(uint32_t reg_index) const; diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp index 3cbb823c6236..a762930e8eb4 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp @@ -74,6 +74,13 @@ typedef struct _GPR #include "RegisterInfos_mips64.h" #undef DECLARE_REGISTER_INFOS_MIPS64_STRUCT +//--------------------------------------------------------------------------- +// Include RegisterInfos_mips to declare our g_register_infos_mips structure. +//--------------------------------------------------------------------------- +#define DECLARE_REGISTER_INFOS_MIPS_STRUCT +#include "RegisterInfos_mips.h" +#undef DECLARE_REGISTER_INFOS_MIPS_STRUCT + static const RegisterInfo * GetRegisterInfoPtr (const ArchSpec &target_arch) { @@ -81,9 +88,10 @@ GetRegisterInfoPtr (const ArchSpec &target_arch) { case llvm::Triple::mips64: case llvm::Triple::mips64el: + return g_register_infos_mips64; case llvm::Triple::mips: case llvm::Triple::mipsel: - return g_register_infos_mips64; + return g_register_infos_mips; default: assert(false && "Unhandled target architecture."); return nullptr; @@ -97,9 +105,10 @@ GetRegisterInfoCount (const ArchSpec &target_arch) { case llvm::Triple::mips64: case llvm::Triple::mips64el: + return static_cast (sizeof (g_register_infos_mips64) / sizeof (g_register_infos_mips64 [0])); case llvm::Triple::mips: case llvm::Triple::mipsel: - return static_cast (sizeof (g_register_infos_mips64) / sizeof (g_register_infos_mips64 [0])); + return static_cast (sizeof (g_register_infos_mips) / sizeof (g_register_infos_mips [0])); default: assert(false && "Unhandled target architecture."); return 0; diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfos_mips.h b/lldb/source/Plugins/Process/Utility/RegisterInfos_mips.h index ddfb98ab8aa1..0956b2ca9eca 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterInfos_mips.h +++ b/lldb/source/Plugins/Process/Utility/RegisterInfos_mips.h @@ -26,6 +26,10 @@ eFormatHex, { kind1, kind2, kind3, kind4, gpr_##reg##_mips }, NULL, NULL } #define DEFINE_FPR(member, reg, alt, kind1, kind2, kind3, kind4) \ + { #reg, alt, sizeof(((FPR_mips*)NULL)->member) / 2, FPR_OFFSET(member), eEncodingUint, \ + eFormatHex, { kind1, kind2, kind3, kind4, fpr_##reg##_mips }, NULL, NULL } + +#define DEFINE_FPR_INFO(member, reg, alt, kind1, kind2, kind3, kind4) \ { #reg, alt, sizeof(((FPR_mips*)NULL)->member), FPR_OFFSET(member), eEncodingUint, \ eFormatHex, { kind1, kind2, kind3, kind4, fpr_##reg##_mips }, NULL, NULL } @@ -104,8 +108,8 @@ g_register_infos_mips[] = DEFINE_FPR (fp_reg[29], f29, NULL, gcc_dwarf_f29_mips, gcc_dwarf_f29_mips, LLDB_INVALID_REGNUM, gdb_f29_mips), DEFINE_FPR (fp_reg[30], f30, NULL, gcc_dwarf_f30_mips, gcc_dwarf_f30_mips, LLDB_INVALID_REGNUM, gdb_f30_mips), DEFINE_FPR (fp_reg[31], f31, NULL, gcc_dwarf_f31_mips, gcc_dwarf_f31_mips, LLDB_INVALID_REGNUM, gdb_f31_mips), - DEFINE_FPR (fcsr, fcsr, NULL, gcc_dwarf_fcsr_mips, gcc_dwarf_fcsr_mips, LLDB_INVALID_REGNUM, gdb_fcsr_mips), - DEFINE_FPR (fir, fir, NULL, gcc_dwarf_fir_mips, gcc_dwarf_fir_mips, LLDB_INVALID_REGNUM, gdb_fir_mips) + DEFINE_FPR_INFO (fcsr, fcsr, NULL, gcc_dwarf_fcsr_mips, gcc_dwarf_fcsr_mips, LLDB_INVALID_REGNUM, gdb_fcsr_mips), + DEFINE_FPR_INFO (fir, fir, NULL, gcc_dwarf_fir_mips, gcc_dwarf_fir_mips, LLDB_INVALID_REGNUM, gdb_fir_mips) }; static_assert((sizeof(g_register_infos_mips) / sizeof(g_register_infos_mips[0])) == k_num_registers_mips, "g_register_infos_mips has wrong number of register infos");