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;