diff options
| author | Jim Ingham <jingham@apple.com> | 2013-11-07 00:11:47 +0000 |
|---|---|---|
| committer | Jim Ingham <jingham@apple.com> | 2013-11-07 00:11:47 +0000 |
| commit | 6fbc48bc427f4d8368bcb37116843045981e9b76 (patch) | |
| tree | 7c1e9f97d44d3c381aa732274ecda09ded4a5287 /lldb/source/Expression/ClangFunction.cpp | |
| parent | bed356a9eae0d45b878410b5c42d6ff278bb0c83 (diff) | |
| download | bcm5719-llvm-6fbc48bc427f4d8368bcb37116843045981e9b76.tar.gz bcm5719-llvm-6fbc48bc427f4d8368bcb37116843045981e9b76.zip | |
This patch does a couple of things.
It completes the job of using EvaluateExpressionOptions consistently throughout
the inferior function calling mechanism in lldb begun in Greg's patch r194009.
It removes a handful of alternate calls into the ClangUserExpression/ClangFunction/ThreadPlanCallFunction which
were there for convenience. Using the EvaluateExpressionOptions removes the need for them.
Using that it gets the --debug option from Greg's patch to work cleanly.
It also adds another EvaluateExpressionOption to not trap exceptions when running expressions. You shouldn't
use this option unless you KNOW your expression can't throw beyond itself. This is:
<rdar://problem/15374885>
At present this is only available through the SB API's or python.
It fixes a bug where function calls would unset the ObjC & C++ exception breakpoints without checking whether
they were set by somebody else already.
llvm-svn: 194182
Diffstat (limited to 'lldb/source/Expression/ClangFunction.cpp')
| -rw-r--r-- | lldb/source/Expression/ClangFunction.cpp | 155 |
1 files changed, 43 insertions, 112 deletions
diff --git a/lldb/source/Expression/ClangFunction.cpp b/lldb/source/Expression/ClangFunction.cpp index b37044df9ec..92a07971dbc 100644 --- a/lldb/source/Expression/ClangFunction.cpp +++ b/lldb/source/Expression/ClangFunction.cpp @@ -394,14 +394,9 @@ ClangFunction::InsertFunction (ExecutionContext &exe_ctx, lldb::addr_t &args_add ThreadPlan * ClangFunction::GetThreadPlanToCallFunction (ExecutionContext &exe_ctx, - lldb::addr_t func_addr, - lldb::addr_t &args_addr, - Stream &errors, - bool stop_others, - bool unwind_on_error, - bool ignore_breakpoints, - lldb::addr_t *this_arg, - lldb::addr_t *cmd_arg) + lldb::addr_t &args_addr, + const EvaluateExpressionOptions &options, + Stream &errors) { Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP)); @@ -418,16 +413,14 @@ ClangFunction::GetThreadPlanToCallFunction (ExecutionContext &exe_ctx, // Okay, now run the function: - Address wrapper_address (func_addr); + Address wrapper_address (m_jit_start_addr); ThreadPlan *new_plan = new ThreadPlanCallFunction (*thread, wrapper_address, ClangASTType(), args_addr, - stop_others, - unwind_on_error, - ignore_breakpoints, - this_arg, - cmd_arg); + options, + 0, + 0); new_plan->SetIsMasterPlan(true); new_plan->SetOkayToDiscard (false); return new_plan; @@ -479,63 +472,48 @@ ClangFunction::DeallocateFunctionResults (ExecutionContext &exe_ctx, lldb::addr_ } ExecutionResults -ClangFunction::ExecuteFunction(ExecutionContext &exe_ctx, Stream &errors, Value &results) -{ - return ExecuteFunction (exe_ctx, errors, 1000, true, results); -} - -ExecutionResults -ClangFunction::ExecuteFunction(ExecutionContext &exe_ctx, Stream &errors, bool stop_others, Value &results) -{ - const bool try_all_threads = false; - const bool unwind_on_error = true; - const bool ignore_breakpoints = true; - return ExecuteFunction (exe_ctx, NULL, errors, stop_others, 0UL, try_all_threads, - unwind_on_error, ignore_breakpoints, results); -} - -ExecutionResults ClangFunction::ExecuteFunction( ExecutionContext &exe_ctx, + lldb::addr_t *args_addr_ptr, + const EvaluateExpressionOptions &options, Stream &errors, - uint32_t timeout_usec, - bool try_all_threads, Value &results) { - const bool stop_others = true; - const bool unwind_on_error = true; - const bool ignore_breakpoints = true; - return ExecuteFunction (exe_ctx, NULL, errors, stop_others, timeout_usec, - try_all_threads, unwind_on_error, ignore_breakpoints, results); -} + using namespace clang; + ExecutionResults return_value = eExecutionSetupError; + + // ClangFunction::ExecuteFunction execution is always just to get the result. Do make sure we ignore + // breakpoints, unwind on error, and don't try to debug it. + EvaluateExpressionOptions real_options = options; + real_options.SetDebug(false); + real_options.SetUnwindOnError(true); + real_options.SetIgnoreBreakpoints(true); + + lldb::addr_t args_addr; + + if (args_addr_ptr != NULL) + args_addr = *args_addr_ptr; + else + args_addr = LLDB_INVALID_ADDRESS; + + if (CompileFunction(errors) != 0) + return eExecutionSetupError; + + if (args_addr == LLDB_INVALID_ADDRESS) + { + if (!InsertFunction(exe_ctx, args_addr, errors)) + return eExecutionSetupError; + } -// This is the static function -ExecutionResults -ClangFunction::ExecuteFunction ( - ExecutionContext &exe_ctx, - lldb::addr_t function_address, - lldb::addr_t &void_arg, - bool stop_others, - bool try_all_threads, - bool unwind_on_error, - bool ignore_breakpoints, - uint32_t timeout_usec, - Stream &errors, - lldb::addr_t *this_arg) -{ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP)); if (log) log->Printf("== [ClangFunction::ExecuteFunction] Executing function =="); - lldb::ThreadPlanSP call_plan_sp (ClangFunction::GetThreadPlanToCallFunction (exe_ctx, - function_address, - void_arg, - errors, - stop_others, - unwind_on_error, - ignore_breakpoints, - this_arg)); + lldb::ThreadPlanSP call_plan_sp (GetThreadPlanToCallFunction (exe_ctx, + args_addr, + real_options, + errors)); if (!call_plan_sp) return eExecutionSetupError; @@ -544,17 +522,14 @@ ClangFunction::ExecuteFunction ( if (exe_ctx.GetProcessPtr()) exe_ctx.GetProcessPtr()->SetRunningUserExpression(true); - ExecutionResults results = exe_ctx.GetProcessRef().RunThreadPlan (exe_ctx, call_plan_sp, - stop_others, - try_all_threads, - unwind_on_error, - ignore_breakpoints, - timeout_usec, - errors); + return_value = exe_ctx.GetProcessRef().RunThreadPlan (exe_ctx, + call_plan_sp, + real_options, + errors); if (log) { - if (results != eExecutionCompleted) + if (return_value != eExecutionCompleted) { log->Printf("== [ClangFunction::ExecuteFunction] Execution completed abnormally =="); } @@ -567,50 +542,6 @@ ClangFunction::ExecuteFunction ( if (exe_ctx.GetProcessPtr()) exe_ctx.GetProcessPtr()->SetRunningUserExpression(false); - return results; -} - -ExecutionResults -ClangFunction::ExecuteFunction( - ExecutionContext &exe_ctx, - lldb::addr_t *args_addr_ptr, - Stream &errors, - bool stop_others, - uint32_t timeout_usec, - bool try_all_threads, - bool unwind_on_error, - bool ignore_breakpoints, - Value &results) -{ - using namespace clang; - ExecutionResults return_value = eExecutionSetupError; - - lldb::addr_t args_addr; - - if (args_addr_ptr != NULL) - args_addr = *args_addr_ptr; - else - args_addr = LLDB_INVALID_ADDRESS; - - if (CompileFunction(errors) != 0) - return eExecutionSetupError; - - if (args_addr == LLDB_INVALID_ADDRESS) - { - if (!InsertFunction(exe_ctx, args_addr, errors)) - return eExecutionSetupError; - } - - return_value = ClangFunction::ExecuteFunction (exe_ctx, - m_jit_start_addr, - args_addr, - stop_others, - try_all_threads, - unwind_on_error, - ignore_breakpoints, - timeout_usec, - errors); - if (args_addr_ptr != NULL) *args_addr_ptr = args_addr; |

