[lldb-dev] What's the right way to use ThreadPlanCallFunction
Greg Clayton
gclayton at apple.com
Wed Jun 17 13:31:33 PDT 2015
RunThreadPlan in synchronous so the shared pointer will be back to a single ref count by the time it returns.
> On Jun 15, 2015, at 3:19 PM, Keno Fischer <kfischer at college.harvard.edu> wrote:
>
> Hey everyone, I'm having some trouble using ThreadPlanCallFunction, I tried the following, but for some reason the reference that the thread stores in m_completed_plan_stack does not increment the use count of the shared ptr.
> I have tried debugging this, but gotten nowhere, so I figured I must be missing something. Does this code look ok? (Ignore the debug print statements, though for completeness, the output is
>
> 1
> 1
> 0xf5f1290
> 1
> 0xf5f1290
> 1
>
> if (!ctx.HasThreadScope())
> {
> error_stream.Printf("ClangUserExpression::Execute called with no thread selected.");
> return lldb::eExpressionSetupError;
> }
>
> lldb_private::EvaluateExpressionOptions options;
> llvm::ArrayRef <lldb::addr_t> args;
>
> lldb::ThreadPlanSP call_plan_sp(new lldb_private::ThreadPlanCallFunction(ctx.GetThreadRef(), address, $(ClangASTType(C,rt)), args, options));
> std::cout << call_plan_sp.use_count() << "\n";
>
> if (!call_plan_sp || !call_plan_sp->ValidatePlan (&error_stream))
> return lldb::eExpressionSetupError;
>
> std::cout << call_plan_sp.use_count() << "\n";
>
> lldb::ExpressionResults execution_result = ctx.GetProcessRef().RunThreadPlan (ctx,
> call_plan_sp,
> options,
> error_stream);
>
> std::cout << ctx.GetThreadRef().m_completed_plan_stack[1].get() << "\n";
> std::cout << ctx.GetThreadRef().m_completed_plan_stack[1].use_count() << "\n";
>
> std::cout << call_plan_sp.get() << "\n";
> std::cout << call_plan_sp.use_count() << "\n";
>
> return lldb::eExpressionCompleted;
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
More information about the lldb-dev
mailing list