42 std::lock_guard<std::recursive_mutex> guard(
GetMutex(), std::adopt_lock);
43 std::lock_guard<std::recursive_mutex> rhs_guard(rhs.
GetMutex(),
65 return expr_thread_sp;
84 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
92 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
104 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
112 for (idx = 0; idx < num_threads; ++idx) {
122 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
130 for (idx = 0; idx < num_threads; ++idx) {
131 if (
m_threads[idx]->GetProtocolID() == tid) {
140 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
148 for (idx = 0; idx < num_threads; ++idx) {
160 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
168 for (idx = 0; idx < num_threads; ++idx) {
169 if (
m_threads[idx]->GetProtocolID() == tid) {
181 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
185 for (idx = 0; idx < num_threads; ++idx) {
186 if (
m_threads[idx].get() == thread_ptr) {
196 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
200 for (
uint32_t idx = 0; idx < num_threads; ++idx) {
210 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
217 for (
uint32_t idx = 0; idx < num_threads; ++idx) {
218 if (
m_threads[idx]->GetIndexID() == index_id) {
242 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
245 for (lldb::ThreadSP thread_sp :
m_threads) {
255 thread_sp->IsStillAtLastBreakpointHit())
256 threads_copy.push_back(thread_sp);
263 if (threads_copy.size() == 0)
267 collection::iterator pos, end = threads_copy.end();
272 "ThreadList::%s: %" PRIu64
" threads, %" PRIu64
273 " unsuspended threads",
274 __FUNCTION__, (uint64_t)
m_threads.size(),
275 (uint64_t)threads_copy.size());
278 bool did_anybody_stop_for_a_reason =
false;
282 bool should_stop =
false;
285 log,
"ThreadList::%s handling interrupt event, should stop set to true",
298 for (pos = threads_copy.begin(); pos != end; ++pos) {
299 ThreadSP thread_sp(*pos);
300 thread_sp->GetStopInfo();
303 for (pos = threads_copy.begin(); pos != end; ++pos) {
304 ThreadSP thread_sp(*pos);
326 if (thread_sp->GetProcess()->GetStopID() > 1)
327 did_anybody_stop_for_a_reason =
true;
329 did_anybody_stop_for_a_reason |= thread_sp->ThreadStoppedForAReason();
331 const bool thread_should_stop = thread_sp->ShouldStop(event_ptr);
332 if (thread_should_stop)
336 if (!should_stop && !did_anybody_stop_for_a_reason) {
339 "ThreadList::%s we stopped but no threads had a stop reason, "
340 "overriding should_stop and stopping.",
344 LLDB_LOGF(log,
"ThreadList::%s overall should_stop = %i", __FUNCTION__,
348 for (pos = threads_copy.begin(); pos != end; ++pos) {
349 ThreadSP thread_sp(*pos);
350 thread_sp->WillStop();
358 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
362 collection::iterator pos, end =
m_threads.end();
366 LLDB_LOGF(log,
"ThreadList::%s %" PRIu64
" threads", __FUNCTION__,
372 for (pos =
m_threads.begin(); pos != end; ++pos) {
373 ThreadSP thread_sp(*pos);
374 const Vote vote = thread_sp->ShouldReportStop(event_ptr);
388 "Thread {0:x} voted {1}, but lost out because result was {2}",
389 thread_sp->GetID(), vote, result);
394 LLDB_LOG(log,
"Returning {0}", result);
399 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
402 collection::iterator pos, end =
m_threads.end();
403 for (pos =
m_threads.begin(); pos != end; ++pos) {
404 ThreadSP thread_sp(*pos);
405 thread_sp->SetShouldReportStop(vote);
411 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
415 collection::iterator pos, end =
m_threads.end();
422 for (pos =
m_threads.begin(); pos != end; ++pos) {
424 switch ((*pos)->ShouldReportRun(event_ptr)) {
433 "ThreadList::ShouldReportRun() thread %d (0x%4.4" PRIx64
434 ") says don't report.",
435 (*pos)->GetIndexID(), (*pos)->GetID());
445 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
452 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
454 for (
uint32_t idx = 0; idx < num_threads; ++idx) {
460 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
467 "Turning off notification of new threads while single stepping "
470 collection::iterator pos, end =
m_threads.end();
471 for (pos =
m_threads.begin(); pos != end; ++pos)
472 (*pos)->RefreshStateAfterStop();
478 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
480 collection::iterator pos, end =
m_threads.end();
481 for (pos =
m_threads.begin(); pos != end; ++pos)
482 (*pos)->DiscardThreadPlans(
true);
490 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
493 collection::iterator pos, end =
m_threads.end();
502 bool wants_solo_run =
false;
504 for (pos =
m_threads.begin(); pos != end; ++pos) {
506 "thread should not have null thread plan");
508 (*pos)->GetCurrentPlan()->StopOthers()) {
509 if ((*pos)->IsOperatingSystemPluginThread() &&
510 !(*pos)->GetBackingThread())
512 wants_solo_run =
true;
517 if (wants_solo_run) {
520 LLDB_LOGF(log,
"Turning on notification of new threads while single "
521 "stepping a thread.");
526 LLDB_LOGF(log,
"Turning off notification of new threads while single "
527 "stepping a thread.");
536 for (pos =
m_threads.begin(); pos != end; ++pos) {
538 (!wants_solo_run || (*pos)->GetCurrentPlan()->StopOthers())) {
539 if ((*pos)->IsOperatingSystemPluginThread() &&
540 !(*pos)->GetBackingThread())
542 (*pos)->SetupForResume();
553 bool run_only_current_thread =
false;
555 for (pos =
m_threads.begin(); pos != end; ++pos) {
556 ThreadSP thread_sp(*pos);
558 thread_sp->GetCurrentPlan()->StopOthers()) {
559 if ((*pos)->IsOperatingSystemPluginThread() &&
560 !(*pos)->GetBackingThread())
569 run_only_current_thread =
true;
570 run_me_only_list.
Clear();
579 bool need_to_resume =
true;
581 if (run_me_only_list.
GetSize(
false) == 0) {
583 for (pos =
m_threads.begin(); pos != end; ++pos) {
584 ThreadSP thread_sp(*pos);
587 run_state = thread_sp->GetCurrentPlan()->RunState();
590 if (!thread_sp->ShouldResume(run_state))
591 need_to_resume =
false;
594 ThreadSP thread_to_run;
596 if (run_only_current_thread) {
598 }
else if (run_me_only_list.
GetSize(
false) == 1) {
602 (int)((run_me_only_list.
GetSize(
false) * (
double)rand()) /
607 for (pos =
m_threads.begin(); pos != end; ++pos) {
608 ThreadSP thread_sp(*pos);
609 if (thread_sp == thread_to_run) {
610 if (!thread_sp->ShouldResume(thread_sp->GetCurrentPlan()->RunState()))
611 need_to_resume =
false;
617 return need_to_resume;
621 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
622 collection::iterator pos, end =
m_threads.end();
623 for (pos =
m_threads.begin(); pos != end; ++pos) {
626 ThreadSP thread_sp(*pos);
628 thread_sp->DidResume();
633 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
634 collection::iterator pos, end =
m_threads.end();
635 for (pos =
m_threads.begin(); pos != end; ++pos) {
643 ThreadSP thread_sp(*pos);
645 thread_sp->DidStop();
650 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
652 if (!thread_sp.get()) {
662 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
664 if (selected_thread_sp) {
666 selected_thread_sp->SetDefaultFileAndLineToSelectedFrame();
677 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
679 if (selected_thread_sp.get()) {
681 selected_thread_sp->SetDefaultFileAndLineToSelectedFrame();
693 if (selected_thread_sp->EventTypeHasListeners(
695 selected_thread_sp->BroadcastEvent(
704 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
717 collection::iterator rhs_pos, rhs_end = rhs.
m_threads.end();
718 for (rhs_pos = rhs.
m_threads.begin(); rhs_pos != rhs_end; ++rhs_pos) {
721 if (!(*rhs_pos)->IsValid())
725 bool thread_is_alive =
false;
727 for (
uint32_t idx = 0; idx < num_threads; ++idx) {
728 ThreadSP backing_thread =
m_threads[idx]->GetBackingThread();
730 (backing_thread && backing_thread->GetID() == tid)) {
731 thread_is_alive =
true;
735 if (!thread_is_alive) {
736 (*rhs_pos)->DestroyThread();
743 std::lock_guard<std::recursive_mutex> guard(
GetMutex());
744 collection::iterator pos, end =
m_threads.end();
745 for (pos =
m_threads.begin(); pos != end; ++pos)
754 lldb::ThreadSP thread_sp)
757 m_tid = thread_sp->GetID();