[Lldb-commits] [lldb] r178115 - Fixed a problem where inline assembly errors caused
Sean Callanan
scallanan at apple.com
Tue Mar 26 20:09:56 PDT 2013
Author: spyffe
Date: Tue Mar 26 22:09:55 2013
New Revision: 178115
URL: http://llvm.org/viewvc/llvm-project?rev=178115&view=rev
Log:
Fixed a problem where inline assembly errors caused
LLDB to crash.
<rdar://problem/13497915>
Modified:
lldb/trunk/source/Expression/IRExecutionUnit.cpp
Modified: lldb/trunk/source/Expression/IRExecutionUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRExecutionUnit.cpp?rev=178115&r1=178114&r2=178115&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRExecutionUnit.cpp (original)
+++ lldb/trunk/source/Expression/IRExecutionUnit.cpp Tue Mar 26 22:09:55 2013
@@ -11,7 +11,9 @@
// C++ Includes
// Other libraries and framework includes
#include "llvm/ExecutionEngine/ExecutionEngine.h"
+#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
+#include "llvm/Support/SourceMgr.h"
// Project includes
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
@@ -253,6 +255,17 @@ IRExecutionUnit::DisassembleFunction (St
return ret;
}
+static void ReportInlineAsmError(const llvm::SMDiagnostic &diagnostic, void *Context, unsigned LocCookie)
+{
+ Error *err = static_cast<Error*>(Context);
+
+ if (err && err->Success())
+ {
+ err->SetErrorToGenericError();
+ err->SetErrorStringWithFormat("Inline assembly error: %s", diagnostic.getMessage().str().c_str());
+ }
+}
+
void
IRExecutionUnit::GetRunnableInfo(Error &error,
lldb::addr_t &func_addr,
@@ -325,6 +338,8 @@ IRExecutionUnit::GetRunnableInfo(Error &
codeModel = llvm::CodeModel::Small;
}
+ m_module_ap->getContext().setInlineAsmDiagnosticHandler(ReportInlineAsmError, &error);
+
llvm::EngineBuilder builder(m_module_ap.get());
builder.setEngineKind(llvm::EngineKind::JIT)
@@ -367,7 +382,11 @@ IRExecutionUnit::GetRunnableInfo(Error &
void *fun_ptr = m_execution_engine_ap->getPointerToFunction(function);
- // Errors usually cause failures in the JIT, but if we're lucky we get here.
+ if (!error.Success())
+ {
+ // We got an error through our callback!
+ return;
+ }
if (!function)
{
More information about the lldb-commits
mailing list