Fixed IRForTarget so that it errors out when function
pointers are used. Previously, they caused a crash
in the JIT because we didn't resolve them correctly.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@120728 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/IRForTarget.cpp b/source/Expression/IRForTarget.cpp
index cfe4007..fe67417 100644
--- a/source/Expression/IRForTarget.cpp
+++ b/source/Expression/IRForTarget.cpp
@@ -844,6 +844,9 @@
IRForTarget::MaybeHandleVariable (Module &llvm_module, Value *llvm_value_ptr)
{
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+
+ if (log)
+ log->Printf("MaybeHandleVariable (%s)\n", PrintValue(llvm_value_ptr).c_str());
if (ConstantExpr *constant_expr = dyn_cast<ConstantExpr>(llvm_value_ptr))
{
@@ -854,7 +857,8 @@
case Instruction::GetElementPtr:
case Instruction::BitCast:
Value *s = constant_expr->getOperand(0);
- MaybeHandleVariable(llvm_module, s);
+ if (!MaybeHandleVariable(llvm_module, s))
+ return false;
}
}
if (GlobalVariable *global_variable = dyn_cast<GlobalVariable>(llvm_value_ptr))
@@ -909,6 +913,13 @@
value_alignment))
return false;
}
+ else if (llvm::Function *function = dyn_cast<llvm::Function>(llvm_value_ptr))
+ {
+ if (log)
+ log->Printf("Function pointers aren't handled right now");
+
+ return false;
+ }
return true;
}
@@ -916,7 +927,10 @@
bool
IRForTarget::MaybeHandleCallArguments (Module &llvm_module, CallInst *Old)
{
- // lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+
+ if (log)
+ log->Printf("MaybeHandleCallArguments(%s)", PrintValue(Old).c_str());
for (unsigned op_index = 0, num_ops = Old->getNumArgOperands();
op_index < num_ops;
@@ -945,11 +959,11 @@
fun = dyn_cast<Function>(const_expr->getOperand(0));
if (!fun)
- return true;
+ return false;
}
else
{
- return true;
+ return false;
}
}
@@ -1065,6 +1079,9 @@
if (call && !MaybeHandleCall(llvm_module, call))
return false;
+
+ if (call && !MaybeHandleCallArguments(llvm_module, call))
+ return false;
}
return true;