diff options
Diffstat (limited to 'lldb/source')
-rw-r--r-- | lldb/source/Core/Debugger.cpp | 14 | ||||
-rw-r--r-- | lldb/source/Expression/ClangUserExpression.cpp | 20 | ||||
-rw-r--r-- | lldb/source/Target/StopInfo.cpp | 30 | ||||
-rw-r--r-- | lldb/source/Target/Thread.cpp | 18 | ||||
-rw-r--r-- | lldb/source/Target/ThreadPlanCallUserExpression.cpp | 49 |
5 files changed, 118 insertions, 13 deletions
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 0def3680a62..5ce2eae0735 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -111,6 +111,7 @@ g_language_enumerators[] = "{, ${thread.info.trace_messages} messages}" \ "{, stop reason = ${thread.stop-reason}}"\ "{\\nReturn value: ${thread.return-value}}"\ + "{\\nCompleted expression: ${thread.completed-expression}}"\ "\\n" #define DEFAULT_FRAME_FORMAT "frame #${frame.index}: ${frame.pc}"\ @@ -2075,6 +2076,19 @@ FormatPromptRecurse } } } + else if (IsToken (var_name_begin, "completed-expression}")) + { + StopInfoSP stop_info_sp = thread->GetStopInfo (); + if (stop_info_sp && stop_info_sp->IsValid()) + { + ClangExpressionVariableSP expression_var_sp = StopInfo::GetExpressionVariable (stop_info_sp); + if (expression_var_sp && expression_var_sp->GetValueObject()) + { + expression_var_sp->GetValueObject()->Dump(s); + var_success = true; + } + } + } else if (IsToken (var_name_begin, "script:")) { var_name_begin += ::strlen("script:"); diff --git a/lldb/source/Expression/ClangUserExpression.cpp b/lldb/source/Expression/ClangUserExpression.cpp index 8f580024821..62f2869dd4b 100644 --- a/lldb/source/Expression/ClangUserExpression.cpp +++ b/lldb/source/Expression/ClangUserExpression.cpp @@ -884,17 +884,19 @@ ClangUserExpression::Execute (Stream &error_stream, } args.push_back(struct_address); - - lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression (exe_ctx.GetThreadRef(), - wrapper_address, - args, - options, - shared_ptr_to_me)); + + ThreadPlanCallUserExpression *user_expression_plan = + new ThreadPlanCallUserExpression (exe_ctx.GetThreadRef(), + wrapper_address, + args, + options, + shared_ptr_to_me); + lldb::ThreadPlanSP call_plan_sp(user_expression_plan); if (!call_plan_sp || !call_plan_sp->ValidatePlan (&error_stream)) return lldb::eExpressionSetupError; - lldb::addr_t function_stack_pointer = static_cast<ThreadPlanCallFunction *>(call_plan_sp.get())->GetFunctionStackPointer(); + lldb::addr_t function_stack_pointer = user_expression_plan->GetFunctionStackPointer(); function_stack_bottom = function_stack_pointer - Host::GetPageSize(); function_stack_top = function_stack_pointer; @@ -935,8 +937,12 @@ ClangUserExpression::Execute (Stream &error_stream, || (execution_result == lldb::eExpressionHitBreakpoint && options.DoesIgnoreBreakpoints())) error_stream.PutCString ("\nThe process has been returned to the state before expression evaluation."); else + { + if (execution_result == lldb::eExpressionHitBreakpoint) + user_expression_plan->TransferExpressionOwnership(); error_stream.PutCString ("\nThe process has been left at the point where it was interrupted, " "use \"thread return -x\" to return to the state before expression evaluation."); + } return execution_result; } diff --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp index 7241f6b3c75..931cc0ae8f2 100644 --- a/lldb/source/Target/StopInfo.cpp +++ b/lldb/source/Target/StopInfo.cpp @@ -997,10 +997,11 @@ class StopInfoThreadPlan : public StopInfo { public: - StopInfoThreadPlan (ThreadPlanSP &plan_sp, ValueObjectSP &return_valobj_sp) : + StopInfoThreadPlan (ThreadPlanSP &plan_sp, ValueObjectSP &return_valobj_sp, ClangExpressionVariableSP &expression_variable_sp) : StopInfo (plan_sp->GetThread(), LLDB_INVALID_UID), m_plan_sp (plan_sp), - m_return_valobj_sp (return_valobj_sp) + m_return_valobj_sp (return_valobj_sp), + m_expression_variable_sp (expression_variable_sp) { } @@ -1032,6 +1033,12 @@ public: return m_return_valobj_sp; } + ClangExpressionVariableSP + GetExpressionVariable() + { + return m_expression_variable_sp; + } + protected: virtual bool ShouldStop (Event *event_ptr) @@ -1045,6 +1052,7 @@ protected: private: ThreadPlanSP m_plan_sp; ValueObjectSP m_return_valobj_sp; + ClangExpressionVariableSP m_expression_variable_sp; }; class StopInfoExec : public StopInfo @@ -1123,9 +1131,11 @@ StopInfo::CreateStopReasonToTrace (Thread &thread) } StopInfoSP -StopInfo::CreateStopReasonWithPlan (ThreadPlanSP &plan_sp, ValueObjectSP return_valobj_sp) +StopInfo::CreateStopReasonWithPlan (ThreadPlanSP &plan_sp, + ValueObjectSP return_valobj_sp, + ClangExpressionVariableSP expression_variable_sp) { - return StopInfoSP (new StopInfoThreadPlan (plan_sp, return_valobj_sp)); + return StopInfoSP (new StopInfoThreadPlan (plan_sp, return_valobj_sp, expression_variable_sp)); } StopInfoSP @@ -1151,3 +1161,15 @@ StopInfo::GetReturnValueObject(StopInfoSP &stop_info_sp) else return ValueObjectSP(); } + +ClangExpressionVariableSP +StopInfo::GetExpressionVariable(StopInfoSP &stop_info_sp) +{ + if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonPlanComplete) + { + StopInfoThreadPlan *plan_stop_info = static_cast<StopInfoThreadPlan *>(stop_info_sp.get()); + return plan_stop_info->GetExpressionVariable(); + } + else + return ClangExpressionVariableSP(); +} diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index 89d4359ca6f..3aa7fbcaad9 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -420,7 +420,7 @@ Thread::GetStopInfo () const uint32_t stop_id = process_sp ? process_sp->GetStopID() : UINT32_MAX; if (plan_sp && plan_sp->PlanSucceeded()) { - return StopInfo::CreateStopReasonWithPlan (plan_sp, GetReturnValueObject()); + return StopInfo::CreateStopReasonWithPlan (plan_sp, GetReturnValueObject(), GetExpressionVariable()); } else { @@ -1184,6 +1184,22 @@ Thread::GetReturnValueObject () return ValueObjectSP(); } +ClangExpressionVariableSP +Thread::GetExpressionVariable () +{ + if (!m_completed_plan_stack.empty()) + { + for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--) + { + ClangExpressionVariableSP expression_variable_sp; + expression_variable_sp = m_completed_plan_stack[i]->GetExpressionVariable(); + if (expression_variable_sp) + return expression_variable_sp; + } + } + return ClangExpressionVariableSP(); +} + bool Thread::IsThreadPlanDone (ThreadPlan *plan) { diff --git a/lldb/source/Target/ThreadPlanCallUserExpression.cpp b/lldb/source/Target/ThreadPlanCallUserExpression.cpp index 55aa26f4dd9..a7d627f2579 100644 --- a/lldb/source/Target/ThreadPlanCallUserExpression.cpp +++ b/lldb/source/Target/ThreadPlanCallUserExpression.cpp @@ -56,7 +56,54 @@ ThreadPlanCallUserExpression::~ThreadPlanCallUserExpression () void ThreadPlanCallUserExpression::GetDescription (Stream *s, lldb::DescriptionLevel level) { - ThreadPlanCallFunction::GetDescription (s, level); + if (level == eDescriptionLevelBrief) + s->Printf("User Expression thread plan"); + else + ThreadPlanCallFunction::GetDescription (s, level); +} + +void +ThreadPlanCallUserExpression::WillPop () +{ + ThreadPlanCallFunction::WillPop(); + if (m_user_expression_sp) + m_user_expression_sp.reset(); +} + +bool +ThreadPlanCallUserExpression::MischiefManaged () +{ + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); + + if (IsPlanComplete()) + { + if (log) + log->Printf("ThreadPlanCallFunction(%p): Completed call function plan.", + static_cast<void*>(this)); + + if (m_manage_materialization && PlanSucceeded() && m_user_expression_sp) + { + lldb::addr_t function_stack_top; + lldb::addr_t function_stack_bottom; + lldb::addr_t function_stack_pointer = GetFunctionStackPointer(); + + function_stack_bottom = function_stack_pointer - Host::GetPageSize(); + function_stack_top = function_stack_pointer; + + StreamString error_stream; + + ExecutionContext exe_ctx(GetThread()); + + m_user_expression_sp->FinalizeJITExecution(error_stream, exe_ctx, m_result_var_sp, function_stack_bottom, function_stack_top); + } + + ThreadPlan::MischiefManaged (); + return true; + } + else + { + return false; + } } StopInfoSP |