What's the right way to use ThreadPlanCallFunction

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;

RunThreadPlan in synchronous so the shared pointer will be back to a single ref count by the time it returns.

FWIW, I found the problem - the bug was in my compiler which decided it didn’t have compare and swap instructions when building my code - but did decide it had them when building liblldb.so so the layout of the shared_ptr class was subtly different. UGH! Sorry for the noise everyone.