[Lldb-commits] [PATCH] D80112: Check if thread was suspended during previous stop added.

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 4 18:46:34 PDT 2020

jingham added a comment.

In D80112#2075097 <https://reviews.llvm.org/D80112#2075097>, @jingham wrote:

> Adding a ShouldStop to that if test doesn't seem right.  You should still run the stop actions even if the thread doesn't want to stop.
> If I understand the problem you are describing, it is that you suspended a thread as a user-level suspend, so it's stop reason got stuck.  That seems okay, its probably useful to keep the stop reason of the thread at what it was when you suspended it.  But that means  when gets asked to do its action again, the action is stale and does the wrong thing.  If that's what's going wrong, then it would make more sense short-circuit suspended threads earlier on in the iteration, like:
>   lldb::ThreadSP thread_sp = curr_thread_list.GetThreadAtIndex(idx);
>   // This thread was suspended by the user during this run, so it's actions are stale:
>   if (thread_sp->GetResumeState() == eStateSuspended)
>       continue;
> That mirrors what the ThreadList::ShouldStop does.  You actually probably don't want to do it quite this way, because it is possible that one thread's breakpoint action could resume another thread.  So you should probably first run through the thread list and get all the suspended threads, then run through again doing the actions and skipping the suspended threads you found in the first iteration.

Actually, you can more easily do that.  The thread iteration where we call PerformAction etc. works on a copy of the thread list (since one thread's action could cause the thread list to change).  So if you just change the copy operation to only copy over threads which aren't user-suspended, then you should be set.

> It would be good to write a end-to-end test that mirrors this behavior.  It would be pretty straightforward to write an API test that runs a process, sets a breakpoint, hits it on one thread, suspends that thread, then hits it on another thread and make sure the action didn't run twice on the second stop.

  rG LLVM Github Monorepo



More information about the lldb-commits mailing list