[lldb-dev] What's the right way to use ThreadPlanCallFunction

Keno Fischer kfischer at college.harvard.edu
Wed Jun 17 13:54:18 PDT 2015


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.

On Wed, Jun 17, 2015 at 4:31 PM, Greg Clayton <gclayton at apple.com> wrote:

> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20150617/1bb8b907/attachment.html>


More information about the lldb-dev mailing list