Added the equivalent of gdb's "unwind-on-signal" to the expression command, and a parameter to control it in ClangUserExpression, and on down to ClangFunction.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@118290 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangFunction.cpp b/source/Expression/ClangFunction.cpp
index 0ded190..52cfab0 100644
--- a/source/Expression/ClangFunction.cpp
+++ b/source/Expression/ClangFunction.cpp
@@ -365,7 +365,13 @@
}
ThreadPlan *
-ClangFunction::GetThreadPlanToCallFunction (ExecutionContext &exe_ctx, lldb::addr_t func_addr, lldb::addr_t &args_addr, Stream &errors, bool stop_others, bool discard_on_error, lldb::addr_t *this_arg)
+ClangFunction::GetThreadPlanToCallFunction (ExecutionContext &exe_ctx,
+ lldb::addr_t func_addr,
+ lldb::addr_t &args_addr,
+ Stream &errors,
+ bool stop_others,
+ bool discard_on_error,
+ lldb::addr_t *this_arg)
{
// FIXME: Use the errors Stream for better error reporting.
@@ -441,7 +447,9 @@
ClangFunction::ExecutionResults
ClangFunction::ExecuteFunction(ExecutionContext &exe_ctx, Stream &errors, bool stop_others, Value &results)
{
- return ExecuteFunction (exe_ctx, NULL, errors, stop_others, NULL, false, results);
+ const bool try_all_threads = false;
+ const bool discard_on_error = true;
+ return ExecuteFunction (exe_ctx, NULL, errors, stop_others, NULL, try_all_threads, discard_on_error, results);
}
ClangFunction::ExecutionResults
@@ -452,7 +460,10 @@
bool try_all_threads,
Value &results)
{
- return ExecuteFunction (exe_ctx, NULL, errors, true, single_thread_timeout_usec, try_all_threads, results);
+ const bool stop_others = true;
+ const bool discard_on_error = true;
+ return ExecuteFunction (exe_ctx, NULL, errors, stop_others, single_thread_timeout_usec,
+ try_all_threads, discard_on_error, results);
}
// This is the static function
@@ -463,6 +474,7 @@
lldb::addr_t &void_arg,
bool stop_others,
bool try_all_threads,
+ bool discard_on_error,
uint32_t single_thread_timeout_usec,
Stream &errors,
lldb::addr_t *this_arg)
@@ -488,8 +500,9 @@
}
ClangFunction::ExecutionResults return_value = eExecutionSetupError;
-
- lldb::ThreadPlanSP call_plan_sp(ClangFunction::GetThreadPlanToCallFunction(exe_ctx, function_address, void_arg, errors, stop_others, false, this_arg));
+ lldb::ThreadPlanSP call_plan_sp(ClangFunction::GetThreadPlanToCallFunction(exe_ctx, function_address, void_arg,
+ errors, stop_others, discard_on_error,
+ this_arg));
ThreadPlanCallFunction *call_plan_ptr = static_cast<ThreadPlanCallFunction *> (call_plan_sp.get());
@@ -682,6 +695,10 @@
log->Printf("Execution interrupted: %s %s", s.GetData(), event_explanation);
}
+ if (discard_on_error && call_plan_sp)
+ {
+ exe_ctx.thread->DiscardThreadPlansUpToPlan (call_plan_sp);
+ }
return_value = eExecutionInterrupted;
break;
}
@@ -718,7 +735,8 @@
Stream &errors,
bool stop_others,
uint32_t single_thread_timeout_usec,
- bool try_all_threads,
+ bool try_all_threads,
+ bool discard_on_error,
Value &results)
{
using namespace clang;
@@ -741,7 +759,7 @@
}
return_value = ClangFunction::ExecuteFunction(exe_ctx, m_wrapper_function_addr, args_addr, stop_others,
- try_all_threads, single_thread_timeout_usec, errors);
+ try_all_threads, discard_on_error, single_thread_timeout_usec, errors);
if (args_addr_ptr != NULL)
*args_addr_ptr = args_addr;
diff --git a/source/Expression/ClangUserExpression.cpp b/source/Expression/ClangUserExpression.cpp
index e75c323..87bf733 100644
--- a/source/Expression/ClangUserExpression.cpp
+++ b/source/Expression/ClangUserExpression.cpp
@@ -357,6 +357,7 @@
bool
ClangUserExpression::Execute (Stream &error_stream,
ExecutionContext &exe_ctx,
+ bool discard_on_error,
ClangExpressionVariable *&result)
{
if (m_dwarf_opcodes.get())
@@ -375,12 +376,15 @@
PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr);
+ const bool stop_others = true;
+ const bool try_all_threads = true;
ClangFunction::ExecutionResults execution_result =
ClangFunction::ExecuteFunction (exe_ctx,
m_jit_addr,
struct_address,
- true,
- true,
+ stop_others,
+ try_all_threads,
+ discard_on_error,
10000000,
error_stream,
(m_needs_object_ptr ? &object_ptr : NULL));
@@ -430,9 +434,9 @@
return *m_dwarf_opcodes.get();
}
-
lldb::ValueObjectSP
ClangUserExpression::Evaluate (ExecutionContext &exe_ctx,
+ bool discard_on_error,
const char *expr_cstr,
const char *expr_prefix)
{
@@ -479,7 +483,7 @@
error_stream.GetString().clear();
- if (!user_expression.Execute (error_stream, exe_ctx, expr_result))
+ if (!user_expression.Execute (error_stream, exe_ctx, discard_on_error, expr_result))
{
if (error_stream.GetString().empty())
error.SetErrorString ("expression failed to execute, unknown error");