summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/lldb/source/Expression/IRInterpreter.cpp
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2014-03-19 13:11:35 +0000
committeremaste <emaste@FreeBSD.org>2014-03-19 13:11:35 +0000
commit958843c32b7a29741f2e45996b5b3e89f9e108b0 (patch)
tree95ae4ffabc848a86b94be3ad3cd42471cdb66b06 /contrib/llvm/tools/lldb/source/Expression/IRInterpreter.cpp
parent2a9993c246f3a2463ccd6b8786781e5b97a35065 (diff)
downloadFreeBSD-src-958843c32b7a29741f2e45996b5b3e89f9e108b0.zip
FreeBSD-src-958843c32b7a29741f2e45996b5b3e89f9e108b0.tar.gz
MFC r258054: Update LLDB to upstream r194122 snapshot
Inludes minor changes relative to upstream, for compatibility with FreeBSD's in-tree LLVM 3.3: - Reverted LLDB r191806, restoring use of previous API. - Reverted part of LLDB r189317, restoring previous enum names. - Work around missing LLVM r192504, using previous registerEHFrames API (limited functionality). - Removed PlatformWindows header include and init/terminate calls. Sponsored by: DARPA, AFRL
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Expression/IRInterpreter.cpp')
-rw-r--r--contrib/llvm/tools/lldb/source/Expression/IRInterpreter.cpp50
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);
OpenPOWER on IntegriCloud