<div dir="ltr">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.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 17, 2015 at 4:31 PM, Greg Clayton <span dir="ltr"><<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">RunThreadPlan in synchronous so the shared pointer will be back to a single ref count by the time it returns.<br>
<div><div class="h5"><br>
> On Jun 15, 2015, at 3:19 PM, Keno Fischer <<a href="mailto:kfischer@college.harvard.edu">kfischer@college.harvard.edu</a>> wrote:<br>
><br>
> 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.<br>
> 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<br>
><br>
> 1<br>
> 1<br>
> 0xf5f1290<br>
> 1<br>
> 0xf5f1290<br>
> 1<br>
><br>
>         if (!ctx.HasThreadScope())<br>
>         {<br>
>             error_stream.Printf("ClangUserExpression::Execute called with no thread selected.");<br>
>             return lldb::eExpressionSetupError;<br>
>         }<br>
><br>
>         lldb_private::EvaluateExpressionOptions options;<br>
>         llvm::ArrayRef <lldb::addr_t> args;<br>
><br>
>         lldb::ThreadPlanSP call_plan_sp(new lldb_private::ThreadPlanCallFunction(ctx.GetThreadRef(), address, $(ClangASTType(C,rt)), args, options));<br>
>         std::cout << call_plan_sp.use_count() << "\n";<br>
><br>
>         if (!call_plan_sp || !call_plan_sp->ValidatePlan (&error_stream))<br>
>             return lldb::eExpressionSetupError;<br>
><br>
>         std::cout << call_plan_sp.use_count() << "\n";<br>
><br>
>         lldb::ExpressionResults execution_result = ctx.GetProcessRef().RunThreadPlan (ctx,<br>
>                                                                                    call_plan_sp,<br>
>                                                                                    options,<br>
>                                                                                    error_stream);<br>
><br>
>         std::cout << ctx.GetThreadRef().m_completed_plan_stack[1].get() << "\n";<br>
>         std::cout << ctx.GetThreadRef().m_completed_plan_stack[1].use_count() << "\n";<br>
><br>
>         std::cout << call_plan_sp.get() << "\n";<br>
>         std::cout << call_plan_sp.use_count() << "\n";<br>
><br>
>         return lldb::eExpressionCompleted;<br>
</div></div>> _______________________________________________<br>
> lldb-dev mailing list<br>
> <a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
<br>
</blockquote></div><br></div>