<div dir="ltr"><span style="font-size:16px">>The way this works is that when we go to resume the process, all the thread's get asked whether they need to stop other threads to implement whatever strategy they are currently pursuing. That query ends up calling the currently active thread plan's "StopOthers" method.</span><br><div><span style="font-size:16px"><br></span></div><div><span style="font-size:16px">Right, and since the ThreadPlanStepOverBreakpoint responds true to StopOthers, all the other threads get suspended. Once the breakpoint is restored and stepped over and the ThreadPlanStepOverBreakpoint is popped, the rest of the threads are still suspended.</span></div><div><span style="font-size:16px"><br></span></div><div><span style="font-size:16px">> </span><span style="font-size:16px">But ThreadPlanBase::ShouldStop returns false, so if all your threads are running just the ThreadPlanBase, then they should all resume.</span></div><div><span style="font-size:16px"><br></span></div><div><span style="font-size:16px">Except that ShouldStop is not called for threads that are already suspended (Thread::ShouldStop has an early out if the resume state is eStateSuspended). So I still don't see how those threads can ever get out of the suspended state.</span></div><div><span style="font-size:16px"><br></span></div><div><span style="font-size:16px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 1, 2015 at 11:51 AM, Jim Ingham <span dir="ltr"><<a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The way this works is that when we go to resume the process, all the thread's get asked whether they need to stop other threads to implement whatever strategy they are currently pursuing. That query ends up calling the currently active thread plan's "StopOthers" method. If one thread returns true to StopOthers, then that thread will get to run solo. If more than one thread returns true I do a little round robin to pick which one gets to go. But ThreadPlanBase::ShouldStop returns false, so if all your threads are running just the ThreadPlanBase, then they should all resume.<br>
<br>
This all happens in ThreadList::WillResume.<br>
<br>
Note I started to add some commands to manipulate the thread plans - of which "thread plan list" is the relevant one. The work isn't done yet (for instance I should actually DO something with the --internal and --verbose options, but for now I only print user visible plans, not implementation only plans. Anyway, if you are poking around in this area that might be of some use.<br>
<span class="HOEnZb"><font color="#888888"><br>
Jim<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
> On Jun 1, 2015, at 8:04 AM, Adrian McCarthy <<a href="mailto:amccarth@google.com">amccarth@google.com</a>> wrote:<br>
><br>
> Thanks for the info.<br>
><br>
> This is not theoretical. I'm trying to get TestBreakAfterJoin to pass on Windows. Step 1 was to convert it use <thread> instead of <pthreads.h>. Step 2 was to fix some minor issues in TargetThreadWindows.<br>
><br>
> But now the inferior deadlocks because the one thread that's not suspended is waiting on the ones that are. Once the ThreadPlanStepOverBreakpoint plan is popped, the current plan is ThreadPlanBase, which, as far as I can tell, does nothing to resume suspended threads.<br>
><br>
> I'll compare this to what happens on another platform to see if there should be some other thread plan in use.<br>
><br>
> Adrian.<br>
><br>
> On Fri, May 29, 2015 at 4:50 PM, Jim Ingham <<a href="mailto:jingham@apple.com">jingham@apple.com</a>> wrote:<br>
> When stepping over a breakpoint, the ThreadPlanStepOverBreakpoint gets pushed, handles the single instruction step - during which it does suspend the other threads - then it gets popped. When you next resume, whatever plan was handling the stepping before the breakpoint was hit will resume with whatever policy for running other threads it was using.<br>
><br>
> So it's up to the plan that was on the stack before the "StepOverBreakpoint" was pushed to decide this. Most of the more complex plans (like step-over/step-into) try to keep the other threads from running if possible (unless the user instructed otherwise) but they also will let all the threads run if there's something going on that might deadlock. For instance, if you are doing "next" and we step through straight-line instructions in a function, we will only run the one thread you are stepping in (by default, you can control this with options to the "thread step-over" command. But if we step into a function, we set a breakpoint on the return address and then run with all threads resumed because stepping out of a function could run arbitrary code.<br>
><br>
> Anyway, was this a theoretical question, or do you have some instance where you are actually seeing a deadlock?<br>
><br>
> Jim<br>
><br>
><br>
> > On May 29, 2015, at 1:59 PM, Adrian McCarthy <<a href="mailto:amccarth@google.com">amccarth@google.com</a>> wrote:<br>
> ><br>
> > [I'm trying to make TestBreakAfterJoin work on Windows.]<br>
> ><br>
> > I'm unclear how continuing from a breakpoint in a multi-threaded inferior is supposed to work.<br>
> ><br>
> > A breakpoint is set, and the inferior runs until one of its threads hits the breakpoint. The user then selects continue.<br>
> ><br>
> > The thread that had hit the breakpoint has a thread plan type of ThreadPlanStepOverBreakpoint, which causes all of the other threads to be set to state eStateSuspended. The thread that had hit the breakpoint then steps beyond the breakpoint, and the breakpoint is restored. The thread is then resumed again.<br>
> ><br>
> > But the other threads are all still suspended, causing the inferior to deadlock.<br>
> ><br>
> > The question is: Where should the other threads have their resume states set back to a running state?<br>
> ><br>
> > Adrian<br>
> > _______________________________________________<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" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
><br>
><br>
<br>
</div></div></blockquote></div><br></div>