diff options
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Expression/IRInterpreter.cpp')
-rw-r--r-- | contrib/llvm/tools/lldb/source/Expression/IRInterpreter.cpp | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/contrib/llvm/tools/lldb/source/Expression/IRInterpreter.cpp b/contrib/llvm/tools/lldb/source/Expression/IRInterpreter.cpp index dcbf584..71ef8d6 100644 --- a/contrib/llvm/tools/lldb/source/Expression/IRInterpreter.cpp +++ b/contrib/llvm/tools/lldb/source/Expression/IRInterpreter.cpp @@ -14,6 +14,7 @@ #include "lldb/Core/StreamString.h" #include "lldb/Expression/IRMemoryMap.h" #include "lldb/Expression/IRInterpreter.h" +#include "lldb/Host/Endian.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" @@ -321,13 +322,19 @@ public: if (!ResolveConstantValue(resolved_value, constant)) return false; - const uint64_t *raw_data = resolved_value.getRawData(); - + lldb_private::StreamString buffer (lldb_private::Stream::eBinary, + m_memory_map.GetAddressByteSize(), + m_memory_map.GetByteOrder()); + size_t constant_size = m_target_data.getTypeStoreSize(constant->getType()); + const uint64_t *raw_data = resolved_value.getRawData(); + + buffer.PutRawBytes(raw_data, constant_size, lldb::endian::InlHostByteOrder()); + lldb_private::Error write_error; - m_memory_map.WriteMemory(process_address, (uint8_t*)raw_data, constant_size, write_error); + m_memory_map.WriteMemory(process_address, (const uint8_t*)buffer.GetData(), constant_size, write_error); return write_error.Success(); } @@ -517,6 +524,7 @@ IRInterpreter::CanInterpret (llvm::Module &module, case Instruction::SRem: case Instruction::Store: case Instruction::Sub: + case Instruction::Trunc: case Instruction::UDiv: case Instruction::URem: case Instruction::Xor: @@ -1162,6 +1170,42 @@ IRInterpreter::Interpret (llvm::Module &module, } } break; + case Instruction::Trunc: + { + const TruncInst *trunc_inst = dyn_cast<TruncInst>(inst); + + if (!trunc_inst) + { + if (log) + log->Printf("getOpcode() returns Trunc, but instruction is not a TruncInst"); + error.SetErrorToGenericError(); + error.SetErrorString(interpreter_internal_error); + return false; + } + + Value *src_operand = trunc_inst->getOperand(0); + + lldb_private::Scalar I; + + if (!frame.EvaluateValue(I, src_operand, module)) + { + if (log) + log->Printf("Couldn't evaluate %s", PrintValue(src_operand).c_str()); + error.SetErrorToGenericError(); + error.SetErrorString(bad_value_error); + return false; + } + + frame.AssignValue(inst, I, module); + + if (log) + { + log->Printf("Interpreted a Trunc"); + log->Printf(" Src : %s", frame.SummarizeValue(src_operand).c_str()); + log->Printf(" = : %s", frame.SummarizeValue(inst).c_str()); + } + } + break; case Instruction::Load: { const LoadInst *load_inst = dyn_cast<LoadInst>(inst); |