Lines Matching +full:needs +full:- +full:reset +full:- +full:on +full:- +full:resume
1 //===-- Thread.cpp --------------------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
53 #include "lldb/lldb-enumerations.h"
88 Thread *thread = exe_ctx->GetThreadPtr();
92 thread->GetValueProperties().get());
94 return instance_properties->ProtectedGetPropertyAtIndex(idx);
104 m_collection_sp->Initialize(g_thread_properties);
168 const EventData *event_data = event_ptr->GetData();
170 event_data->GetFlavor() == ThreadEventData::GetFlavorString())
171 return static_cast<const ThreadEventData *>(event_ptr->GetData());
180 thread_sp = event_data->GetThread();
188 stack_id = event_data->GetStackID();
197 ThreadSP thread_sp = event_data->GetThread();
199 frame_sp = thread_sp->GetStackFrameList()->GetFrameWithStackID(
200 event_data->GetStackID());
247 m_stop_info_sp.reset();
248 m_reg_context_sp.reset();
249 m_unwinder_up.reset();
251 m_curr_frames_sp.reset();
252 m_prev_frames_sp.reset();
253 m_prev_framezero_pc.reset();
267 StackFrameSP frame_sp = stack_frame_list_sp->GetFrameAtIndex(
268 stack_frame_list_sp->GetSelectedFrameIndex(select_most_relevant));
275 uint32_t ret_value = GetStackFrameList()->SetSelectedFrame(frame);
277 BroadcastSelectedFrameChange(frame->GetStackID());
283 StackFrameSP frame_sp(GetStackFrameList()->GetFrameAtIndex(frame_idx));
285 GetStackFrameList()->SetSelectedFrame(frame_sp.get());
287 BroadcastSelectedFrameChange(frame_sp->GetStackID());
303 frame_sp->GetSymbolContext(eSymbolContextLineEntry));
304 const Debugger &debugger = GetProcess()->GetTarget().GetDebugger();
320 return frame_sp->GetStatus(output_stream, show_frame_info, show_source);
331 if (frame->HasDebugInformation() &&
332 (GetProcess()->GetWarningsOptimization() ||
333 GetProcess()->GetWarningsUnsupportedLanguage())) {
335 frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextModule);
336 GetProcess()->PrintWarningOptimization(sc);
337 GetProcess()->PrintWarningUnsupportedLanguage(sc);
347 const uint32_t stop_id = process_sp ? process_sp->GetStopID() : UINT32_MAX;
349 // Here we select the stop info according to priorirty: - m_stop_info_sp (if
350 // not trace) - preset value - completed plan stop info - new value with plan
351 // from completed plan stack - m_stop_info_sp (trace stop reason is OK now) -
355 m_stop_info_sp ->IsValid() &&
357 bool have_valid_completed_plan = completed_plan_sp && completed_plan_sp->PlanSucceeded();
358 bool plan_failed = completed_plan_sp && !completed_plan_sp->PlanSucceeded();
361 && (m_stop_info_sp->GetStopReason() == eStopReasonTrace);
388 const uint32_t process_stop_id = process_sp->GetStopID();
396 if (m_stop_info_sp->IsValid() || IsStillAtLastBreakpointHit() ||
397 GetCurrentPlan()->IsVirtualStep()
401 m_stop_info_sp.reset();
411 // to this function ever getting called, so we can't rely on
415 // Architecture::OverrideStopInfo() for more information on the stop
421 process_sp->GetTarget().GetArchitecturePlugin())
422 arch->OverrideStopInfo(*this);
428 // return no stop reason. This thread would like to resume.
429 if (m_stop_info_sp && m_stop_info_sp->WasContinueInterrupted(*this))
438 return stop_info_sp->GetStopReason();
445 return m_stop_info_stop_id == process_sp->GetStopID();
453 m_stop_info_sp.reset();
460 m_stop_info_sp->MakeStopInfoValid();
463 m_stop_info_sp->OverrideShouldNotify(m_override_should_notify ==
469 m_stop_info_stop_id = process_sp->GetStopID();
475 stop_info_sp ? stop_info_sp->GetDescription() : "<NULL>",
485 m_stop_info_sp->OverrideShouldNotify(m_override_should_notify ==
501 saved_state.register_backup_sp.reset();
507 lldb::RegisterContextSP reg_ctx_sp(frame_sp->GetRegisterContext());
508 if (reg_ctx_sp && reg_ctx_sp->ReadAllRegisterValues(*reg_checkpoint_sp))
518 saved_state.orig_stop_id = process_sp->GetStopID();
531 lldb::RegisterContextSP reg_ctx_sp(frame_sp->GetRegisterContext());
534 reg_ctx_sp->WriteAllRegisterValues(*saved_state.register_backup_sp);
538 reg_ctx_sp->InvalidateIfNeeded(true);
540 m_unwinder_up->Clear();
551 saved_state.stop_info_sp->MakeStopInfoValid();
553 GetStackFrameList()->SetCurrentInlinedDepth(
576 auto recognized_frame_sp = frame_sp->GetRecognizedFrame();
582 recognized_frame_sp->GetStopDescription();
593 if (stop_info_sp && stop_info_sp->IsValid()) {
594 raw_stop_description = stop_info_sp->GetDescription();
596 stop_info_sp->GetStopReason() == eStopReasonNone) &&
611 current_plan->WillStop();
616 // If we're at a breakpoint push the step-over breakpoint plan. Do this
617 // before telling the current plan it will resume, since we might change
622 const addr_t thread_pc = reg_ctx_sp->GetPC();
624 GetProcess()->GetBreakpointSiteList().FindByAddress(thread_pc);
632 if (cur_plan->GetKind() == ThreadPlan::eKindStepOverBreakpoint) {
635 if (bp_plan->GetBreakpointLoadAddress() != thread_pc)
643 step_bp_plan_sp->SetPrivate(true);
645 if (GetCurrentPlan()->RunState() != eStateStepping) {
649 step_bp_plan->SetAutoContinue(true);
670 backing_thread_sp->SetTemporaryResumeState(resume_state);
679 // So assume that if we got to the point where we're about to resume, and we
682 const uint32_t process_stop_id = GetProcess()->GetStopID();
684 (m_stop_info_sp && m_stop_info_sp->IsValid())) {
687 stop_info->WillResume(resume_state);
690 // Tell all the plans that we are about to resume in case they need to clear
691 // any state. We distinguish between the plan on the top of the stack and the
692 // lower plans in case a plan needs to do any special business before it
698 need_to_resume = plan_ptr->WillResume(resume_state, true);
701 plan_ptr->WillResume(resume_state, false);
704 // If the WillResume for the plan says we are faking a resume, then it will
705 // have set an appropriate stop info. In that case, don't reset it here.
708 m_stop_info_sp.reset();
752 // Based on the current thread plan and process stop info, check if this
761 GetRegisterContext() ? GetRegisterContext()->GetPC()
774 GetRegisterContext() ? GetRegisterContext()->GetPC()
779 GetProcess()->DumpThreadPlansForTID(
786 current_plan->DoTraceLog();
789 // "synchronous" stop reasons, for example the breakpoint command on internal
791 // we don't have to do any more work on this stop.
794 !private_stop_info->ShouldStopSynchronous(event_ptr)) {
807 GetStackFrameList()->CalculateCurrentInlinedDepth();
817 if (!current_plan->PlanExplainsStop(event_ptr)) {
818 if (current_plan->TracerExplainsStop()) {
826 if (plan_ptr->PlanExplainsStop(event_ptr)) {
827 LLDB_LOGF(log, "Plan %s explains stop.", plan_ptr->GetName());
829 should_stop = plan_ptr->ShouldStop(event_ptr);
835 if (plan_ptr->MischiefManaged()) {
842 current_plan->WillStop();
849 (plan_ptr->IsControllingPlan() && !plan_ptr->OkayToDiscard());
851 bool should_force_run = plan_ptr->ShouldRunBeforePublicStop();
868 if (current_plan->IsBasePlan()) {
869 should_stop = current_plan->ShouldStop(event_ptr);
876 if (current_plan->IsBasePlan())
879 should_stop = current_plan->ShouldStop(event_ptr);
880 LLDB_LOGF(log, "Plan %s should stop: %d.", current_plan->GetName(),
882 if (current_plan->MischiefManaged()) {
884 current_plan->WillStop();
886 if (current_plan->ShouldAutoContinue(event_ptr)) {
888 LLDB_LOGF(log, "Plan %s auto-continue: true.",
889 current_plan->GetName());
896 if (should_stop && current_plan->IsControllingPlan() &&
897 !current_plan->OkayToDiscard()) {
916 // in before it is complete - for instance by hitting a breakpoint during a
917 // step-over - then do some step/finish/etc operations that wind up past the
919 // original plan on the stack, This code clears stale plans off the stack.
926 while (!plan_ptr->IsBasePlan()) {
927 bool stale = plan_ptr->IsPlanStale();
935 examined_plan->GetName());
939 if (examined_plan->IsPlanComplete()) {
953 GetProcess()->DumpThreadPlansForTID(
1001 return GetPlans().GetCompletedPlan(false)->ShouldReportStop(event_ptr);
1006 if (plan_ptr->PlanExplainsStop(event_ptr)) {
1007 thread_vote = plan_ptr->ShouldReportStop(event_ptr);
1010 if (plan_ptr->IsBasePlan())
1040 GetCompletedPlan()->GetName());
1042 return GetPlans().GetCompletedPlan(false)->ShouldReportRun(event_ptr);
1049 GetCurrentPlan()->GetName());
1051 return GetCurrentPlan()->ShouldReportRun(event_ptr);
1056 return (spec == nullptr) ? true : spec->ThreadPassesBasicTests(*this);
1060 ThreadPlanStack *plans = GetProcess()->FindThreadPlans(GetID());
1066 // That in turn will check for a completed plan on the ThreadPlanStack.
1067 // Instead of special-casing at that point, we return a Stack with a
1081 thread_plan_sp->GetDescription(&s, lldb::eDescriptionLevelFull);
1084 thread_plan_sp->GetThread().GetID());
1095 popped_plan_sp->GetName(), popped_plan_sp->GetThread().GetID());
1104 discarded_plan_sp->GetName(),
1105 discarded_plan_sp->GetThread().GetID());
1118 p->GetDescription(&strm, eDescriptionLevelInitial);
1160 if (!thread_plan_sp->ValidatePlan(&s)) {
1162 thread_plan_sp.reset();
1176 if (!thread_plan_sp->ValidatePlan(&s)) {
1178 thread_plan_sp.reset();
1231 error.SetErrorString("No expressions currently active on this thread");
1336 new_plan->ClearShouldStopHereCallbacks();
1348 if (!thread_plan_sp || !thread_plan_sp->ValidatePlan(nullptr))
1383 thread_plan_sp->SetStopOthers(stop_other_threads);
1394 target_sp = process_sp->CalculateTarget();
1426 m_prev_framezero_pc.reset();
1428 m_prev_framezero_pc = reg_ctx_sp->GetPC();
1434 if (m_curr_frames_sp && m_curr_frames_sp->GetAllFramesFetched())
1436 m_curr_frames_sp.reset();
1438 m_extended_info.reset();
1443 return GetStackFrameList()->GetFrameWithConcreteFrameIndex(unwind_idx);
1471 Thread *thread = frame_sp->GetThread().get();
1472 uint32_t older_frame_idx = frame_sp->GetFrameIndex() + 1;
1473 StackFrameSP older_frame_sp = thread->GetStackFrameAtIndex(older_frame_idx);
1480 lldb::ABISP abi = thread->GetProcess()->GetABI();
1485 SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextFunction);
1489 // Turn that back on when that works.
1491 Type *function_type = sc.function->GetType();
1494 sc.function->GetCompilerType().GetFunctionReturnType();
1498 ValueObjectSP cast_value_sp = return_value_sp->Cast(return_type);
1500 cast_value_sp->SetFormat(eFormatHex);
1507 return_error = abi->SetReturnValueObject(older_frame_sp, return_value_sp);
1513 // ReadAllRegisterValues->WriteAllRegisterValues, since the read & write cook
1516 StackFrameSP youngest_frame_sp = thread->GetStackFrameAtIndex(0);
1518 lldb::RegisterContextSP reg_ctx_sp(youngest_frame_sp->GetRegisterContext());
1520 bool copy_success = reg_ctx_sp->CopyFromRegisterContext(
1521 older_frame_sp->GetRegisterContext());
1523 thread->DiscardThreadPlans(true);
1524 thread->ClearStackFrames();
1530 return_error.SetErrorString("Could not reset register values.");
1558 const SymbolContext &sc = frame->GetSymbolContext(eSymbolContextFunction);
1562 target->GetImages().FindAddressesForLine(target_sp, file, line, sc.function,
1602 if (!reg_ctx->SetPC(dest))
1621 frame_sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
1650 return m_reg_context_sp->GetThreadPointer();
1658 DynamicLoader *loader = GetProcess()->GetDynamicLoader();
1660 return loader->GetThreadLocalData(module, shared_from_this(),
1669 DynamicLoader *loader = GetProcess()->GetDynamicLoader();
1670 if (loader && loader->IsFullyInitialized() == false)
1673 SystemRuntime *runtime = process->GetSystemRuntime();
1675 return runtime->SafeToCallFunctionsOnThisThread(shared_from_this());
1683 return GetStackFrameList()->GetStackFrameSPForStackFramePtr(stack_frame_ptr);
1747 if (process->GetThreadList().GetSelectedThread().get() == this)
1751 if (target && target->GetDebugger().GetUseExternalEditor()) {
1755 frame_sp->GetSymbolContext(eSymbolContextLineEntry));
1758 target->GetDebugger().GetExternalEditor(),
1778 (GetID() != GetProcess()->GetThreadList().GetSelectedThread()->GetID()))
1783 num_frames_shown = GetStackFrameList()->GetStatus(
1803 thread_info->Dump(strm);
1808 StructuredData::ObjectSP stop_info = m_stop_info_sp->GetExtendedInfo();
1810 stop_info->Dump(strm);
1820 thread_info->GetObjectForDotSeparatedPath("activity");
1822 thread_info->GetObjectForDotSeparatedPath("breadcrumb");
1824 thread_info->GetObjectForDotSeparatedPath("trace_messages");
1827 if (activity && activity->GetType() == eStructuredDataTypeDictionary) {
1828 StructuredData::Dictionary *activity_dict = activity->GetAsDictionary();
1829 StructuredData::ObjectSP id = activity_dict->GetValueForKey("id");
1830 StructuredData::ObjectSP name = activity_dict->GetValueForKey("name");
1831 if (name && name->GetType() == eStructuredDataTypeString && id &&
1832 id->GetType() == eStructuredDataTypeInteger) {
1834 name->GetAsString()->GetValue(),
1835 id->GetUnsignedIntegerValue());
1840 if (breadcrumb && breadcrumb->GetType() == eStructuredDataTypeDictionary) {
1844 breadcrumb->GetAsDictionary();
1846 breadcrumb_dict->GetValueForKey("name");
1848 breadcrumb_text->GetType() == eStructuredDataTypeString) {
1850 breadcrumb_text->GetAsString()->GetValue());
1854 if (messages && messages->GetType() == eStructuredDataTypeArray) {
1857 StructuredData::Array *messages_array = messages->GetAsArray();
1858 const size_t msg_count = messages_array->GetSize();
1862 StructuredData::ObjectSP message = messages_array->GetItemAtIndex(i);
1863 if (message && message->GetType() == eStructuredDataTypeDictionary) {
1865 message->GetAsDictionary();
1867 message_dict->GetValueForKey("message");
1869 message_text->GetType() == eStructuredDataTypeString) {
1870 strm.Format(" {0}\n", message_text->GetAsString()->GetValue());
1884 return GetStackFrameList()->GetStatus(
1896 m_reg_context_sp.reset();
1901 // and don't reset it. This allows threads to maintain their breakpoint
1902 // stopinfo, such as when thread-stepping in multithreaded programs.
1904 StopReason stop_reason = m_stop_info_sp->GetStopReason();
1906 uint64_t value = m_stop_info_sp->GetValue();
1909 lldb::addr_t pc = reg_ctx_sp->GetPC();
1911 GetProcess()->GetBreakpointSiteList().FindByAddress(pc);
1912 if (bp_site_sp && static_cast<break_id_t>(value) == bp_site_sp->GetID())
1927 if (StateIsStoppedState(process->GetState(), true)) {
1933 if (source_step && frame_sp && frame_sp->HasDebugInformation()) {
1934 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
1944 new_plan_sp->SetIsControllingPlan(true);
1945 new_plan_sp->SetOkayToDiscard(false);
1948 process->GetThreadList().SetSelectedThreadByID(GetID());
1949 error = process->Resume();
1960 if (StateIsStoppedState(process->GetState(), true)) {
1967 if (source_step && frame_sp && frame_sp->HasDebugInformation()) {
1968 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
1977 new_plan_sp->SetIsControllingPlan(true);
1978 new_plan_sp->SetOkayToDiscard(false);
1981 process->GetThreadList().SetSelectedThreadByID(GetID());
1982 error = process->Resume();
1992 if (StateIsStoppedState(process->GetState(), true)) {
2001 new_plan_sp->SetIsControllingPlan(true);
2002 new_plan_sp->SetOkayToDiscard(false);
2005 process->GetThreadList().SetSelectedThreadByID(GetID());
2006 error = process->Resume();
2015 if (auto recognized_frame = frame_sp->GetRecognizedFrame())
2016 if (auto e = recognized_frame->GetExceptionObject())
2021 for (LanguageRuntime *runtime : GetProcess()->GetLanguageRuntimes()) {
2022 if (auto e = runtime->GetExceptionObjectForThread(shared_from_this()))
2036 for (LanguageRuntime *runtime : GetProcess()->GetLanguageRuntimes()) {
2037 if (auto bt = runtime->GetBacktraceThreadFromException(exception))
2047 Target &target = process_sp->GetTarget();
2052 CompilerType type = platform_sp->GetSiginfoType(arch.GetTriple());
2063 DataExtractor data_extractor{data.get()->getBufferStart(), data.get()->getBufferSize(),
2064 process_sp->GetByteOrder(), arch.GetAddressByteSize()};