diff options
| author | Nitesh Jain <nitesh.jain@imgtec.com> | 2016-08-01 13:45:51 +0000 |
|---|---|---|
| committer | Nitesh Jain <nitesh.jain@imgtec.com> | 2016-08-01 13:45:51 +0000 |
| commit | 52b6cc5d5facf1500699864587cd42397096c76a (patch) | |
| tree | a55fe12ef80ca55a85748f2cb2d625926db6bebc /lldb/source/Target/RegisterContext.cpp | |
| parent | 78bac52e149ec017c292a724b07cb592ebcb8368 (diff) | |
| download | bcm5719-llvm-52b6cc5d5facf1500699864587cd42397096c76a.tar.gz bcm5719-llvm-52b6cc5d5facf1500699864587cd42397096c76a.zip | |
[LLVM][MIPS] Fix FPU Size Based on Dynamic FR.
Reviewers: jingham, clayborg
Subscribers: jaydeep, bhushan, mohit.bhakkad, slthakur, lldb-commits, emaste, nemanjai, labath, sdardis
Differential Revision: https://reviews.llvm.org/D20357
llvm-svn: 277343
Diffstat (limited to 'lldb/source/Target/RegisterContext.cpp')
| -rw-r--r-- | lldb/source/Target/RegisterContext.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lldb/source/Target/RegisterContext.cpp b/lldb/source/Target/RegisterContext.cpp index 483c932719d..ae3c43def27 100644 --- a/lldb/source/Target/RegisterContext.cpp +++ b/lldb/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) { |

