diff options
Diffstat (limited to 'source/Target/RegisterContext.cpp')
-rw-r--r-- | source/Target/RegisterContext.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/source/Target/RegisterContext.cpp b/source/Target/RegisterContext.cpp index 483c932719d6..ae3c43def275 100644 --- a/source/Target/RegisterContext.cpp +++ b/source/Target/RegisterContext.cpp @@ -21,6 +21,9 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" #include "lldb/Target/Target.h" +#include "lldb/Core/Module.h" +#include "lldb/Expression/DWARFExpression.h" +#include "lldb/Core/Value.h" using namespace lldb; using namespace lldb_private; @@ -76,6 +79,46 @@ RegisterContext::GetRegisterInfoByName (const char *reg_name, uint32_t start_idx return nullptr; } +uint32_t +RegisterContext::UpdateDynamicRegisterSize (const lldb_private::ArchSpec &arch, + RegisterInfo* reg_info) +{ + ExecutionContext exe_ctx (CalculateThread()); + + // In MIPS, the floating point registers size is depends on FR bit of SR register. + // if SR.FR == 1 then all floating point registers are 64 bits. + // else they are all 32 bits. + + int expr_result; + uint32_t addr_size = arch.GetAddressByteSize (); + const uint8_t* dwarf_opcode_ptr = reg_info->dynamic_size_dwarf_expr_bytes; + const size_t dwarf_opcode_len = reg_info->dynamic_size_dwarf_len; + + DataExtractor dwarf_data (dwarf_opcode_ptr, dwarf_opcode_len, + arch.GetByteOrder (), addr_size); + ModuleSP opcode_ctx; + DWARFExpression dwarf_expr (opcode_ctx, dwarf_data, nullptr, 0, dwarf_opcode_len); + Value result; + Error error; + const lldb::offset_t offset = 0; + if (dwarf_expr.Evaluate (&exe_ctx, nullptr, nullptr, this, opcode_ctx, dwarf_data, nullptr, + offset, dwarf_opcode_len, eRegisterKindDWARF, nullptr, nullptr, result, &error)) + { + expr_result = result.GetScalar ().SInt (-1); + switch (expr_result) + { + case 0: return 4; + case 1: return 8; + default: return reg_info->byte_size; + } + } + else + { + printf ("Error executing DwarfExpression::Evaluate %s\n", error.AsCString()); + return reg_info->byte_size; + } +} + const RegisterInfo * RegisterContext::GetRegisterInfo (lldb::RegisterKind kind, uint32_t num) { |