Lines Matching +full:needs +full:- +full:reset +full:- +full:on +full:- +full:resume
1 //===-- Process.cpp -------------------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
83 // setting target.process.disable-memory-cache
104 Process *process = exe_ctx->GetProcessPtr();
108 process->GetValueProperties().get());
110 return instance_properties->ProtectedGetPropertyAtIndex(idx);
185 m_collection_sp->Initialize(g_process_experimental_properties);
195 m_collection_sp->Initialize(g_process_properties);
196 m_collection_sp->AppendProperty(
202 m_collection_sp->SetValueChangedCallback(
204 [this] { m_process->LoadOperatingSystemPlugin(true); });
209 m_collection_sp->AppendProperty(
211 "Experimental settings - setting these won't produce "
213 true, m_experimental_properties_up->GetValueProperties());
233 m_collection_sp->GetPropertyAtIndexAsArgs(idx, args);
239 m_collection_sp->SetPropertyAtIndexFromArgs(idx, args);
316 m_process->Flush();
371 m_collection_sp->GetPropertyAtIndex(ePropertyExperimental);
373 exp_property->GetValue()->GetAsProperties();
378 ->GetPropertyAtIndexAs<bool>(ePropertyOSPluginReportsAllThreads)
384 m_collection_sp->GetPropertyAtIndex(ePropertyExperimental);
386 exp_property->GetValue()->GetAsProperties();
388 exp_values->SetPropertyAtIndex(ePropertyOSPluginReportsAllThreads,
415 if (process_sp->CanDebug(target_sp, true)) {
416 process_sp->m_process_unique_id = ++g_process_unique_id;
418 process_sp.reset();
429 if (process_sp->CanDebug(target_sp, false)) {
430 process_sp->m_process_unique_id = ++g_process_unique_id;
433 process_sp.reset();
454 Broadcaster((target_sp->GetDebugger().GetBroadcasterManager()),
465 m_thread_id_to_index_id_map(), m_exit_status(-1),
489 SetEventName(eBroadcastBitStateChanged, "state-changed");
491 SetEventName(eBroadcastBitSTDOUT, "stdout-available");
492 SetEventName(eBroadcastBitSTDERR, "stderr-available");
493 SetEventName(eBroadcastBitProfileData, "profile-data-available");
494 SetEventName(eBroadcastBitStructuredData, "structured-data-available");
497 eBroadcastInternalStateControlStop, "control-stop");
499 eBroadcastInternalStateControlPause, "control-pause");
501 eBroadcastInternalStateControlResume, "control-resume");
507 m_private_state_listener_sp->StartListeningForEvents(
511 m_private_state_listener_sp->StartListeningForEvents(
520 m_collection_sp->GetPropertyAtIndex(ePropertyMemCacheLineSize)
521 ->GetValue();
523 target_sp->GetPlatform()->GetDefaultMemoryCacheLineSize();
524 if (!value_sp->OptionWasSet() && platform_cache_line_size != 0)
525 value_sp->SetValueAs(platform_cache_line_size);
572 m_dynamic_checkers_up.reset();
573 m_abi_sp.reset();
574 m_os_up.reset();
575 m_system_runtime_up.reset();
576 m_dyld_up.reset();
577 m_jit_loaders_up.reset();
595 m_next_event_action_up.reset();
602 m_private_state_listener_sp->Clear();
619 if (pos->baton == callbacks.baton &&
620 pos->initialize == callbacks.initialize &&
621 pos->process_state_changed == callbacks.process_state_changed) {
634 if (notification_pos->process_state_changed)
635 notification_pos->process_state_changed(notification_pos->baton, this,
640 // FIXME: We need to do some work on events before the general Listener sees
644 // that when the event is delivered by the broadcaster - since that is done on
653 if (GetPrimaryListener()->GetEventForBroadcaster(this, event_sp,
688 // the case of a stopped event check the restarted flag on the event.
690 event_sp_ptr->reset();
776 stream->Printf("Process %" PRIu64 " %s\n", process_sp->GetID(),
789 process_sp->GetStatus(*stream);
796 // Make sure the program hasn't been auto-restarted:
808 stream->Printf("Process %" PRIu64 " stopped and restarted: %s\n",
809 process_sp->GetID(),
812 stream->Printf("Process %" PRIu64
814 process_sp->GetID());
820 stream->Printf("\t%s\n", reason ? reason : "<UNKNOWN REASON>");
827 // Lock the thread list so it doesn't change on us, this is the scope for
830 ThreadList &thread_list = process_sp->GetThreadList();
837 if (curr_thread && curr_thread->IsValid()) {
838 curr_thread_stop_reason = curr_thread->GetStopReason();
847 // stopped for the no-stop signal.
848 uint64_t signo = curr_thread->GetStopInfo()->GetValue();
849 if (process_sp->GetUnixSignals()->GetShouldStop(signo))
856 curr_thread_stop_info_sp = curr_thread->GetStopInfo();
869 StopReason thread_stop_reason = thread->GetStopReason();
879 uint64_t signo = thread->GetStopInfo()->GetValue();
880 if (process_sp->GetUnixSignals()->GetShouldStop(signo)) {
907 thread_list.SetSelectedThreadByID(plan_thread->GetID());
909 thread_list.SetSelectedThreadByID(other_thread->GetID());
911 if (curr_thread && curr_thread->IsValid())
917 thread_list.SetSelectedThreadByID(thread->GetID());
926 Debugger &debugger = process_sp->GetTarget().GetDebugger();
928 &process_sp->GetTarget()) {
929 ThreadSP thread_sp = process_sp->GetThreadList().GetSelectedThread();
931 if (!thread_sp || !thread_sp->IsValid())
936 thread_sp->GetSelectedFrameIndex(select_most_relevant);
941 process_sp->GetStatus(*stream);
942 process_sp->GetThreadStatus(*stream, only_threads_with_stop_reason,
954 stream->PutCString("Likely cause: ");
955 valobj_sp->GetExpressionPath(*stream, format);
956 stream->Printf(" accessed 0x%" PRIx64 "\n", crashing_address);
961 process_sp->GetTarget().shared_from_this());
963 stream->Printf("Target %d: (", target_idx);
965 stream->Printf("Target <unknown index>: (");
966 process_sp->GetTarget().Dump(stream, eDescriptionLevelBrief);
967 stream->Printf(") stopped.\n");
978 process_sp->PopProcessIOHandler();
1004 if (listener_sp->GetEventForBroadcasterWithType(
1007 if (event_sp && event_sp->GetType() == eBroadcastBitStateChanged)
1023 event_ptr = GetPrimaryListener()->PeekAtNextEventForBroadcasterWithType(
1043 if (m_private_state_listener_sp->GetEventForBroadcasterWithType(
1047 if (event_sp && event_sp->GetType() == eBroadcastBitStateChanged)
1062 return m_private_state_listener_sp->GetEventForBroadcaster(
1065 return m_private_state_listener_sp->GetEvent(event_sp, timeout);
1077 return -1;
1140 // This static callback can be used to watch for local child processes on the
1158 ProcessSP process_sp(target_sp->GetProcessSP());
1161 process_sp->GetUnixSignals()->GetSignalAsStringRef(signo);
1162 process_sp->SetExitStatus(exit_status, signal_str);
1188 // os->UpdateThreadList(...) so it doesn't change on us
1205 old_thread_list.GetThreadAtIndex(i, false)->ClearBackingThread();
1212 // Objective-C can run an expression to determine if a SBValue is a
1214 // plug-ins can't run expressions that require running code...
1222 // Now let the OperatingSystem plug-in update the thread list
1224 os->UpdateThreadList(
1225 old_thread_list, // Old list full of threads created by OS plug-in
1235 // No OS plug-in, the new thread list is the same as the real thread
1295 m_system_runtime_up->PopulateQueueList(m_queue_list);
1305 return os->CreateThread(tid, context);
1326 result = iterator->second;
1357 // On the transition from Run to Stopped, we unlock the writer end of the run
1358 // lock. The lock gets locked in Resume, which is the public API to tell the
1363 "(plugin = %s, state = %s) -- unlocking run lock for detach",
1370 LLDB_LOGF(log, "(plugin = %s, state = %s) -- unlocking run lock",
1379 Status Process::Resume() {
1381 LLDB_LOGF(log, "(plugin = %s) -- locking run lock", GetPluginName().data());
1383 Status error("Resume request failed - process still running.");
1384 LLDB_LOGF(log, "(plugin = %s) -- TrySetRunning failed, not resuming.",
1398 LLDB_LOGF(log, "Process::ResumeSynchronous -- locking run lock");
1400 Status error("Resume request failed - process still running.");
1401 LLDB_LOGF(log, "Process::Resume: -- TrySetRunning failed, not resuming.");
1418 "process not in stopped state after synchronous resume: %s",
1455 // not be true for an in-the-middle-of-being-destructed Process, since the
1456 // event system relies on Process::shared_from_this, which may have already
1518 void Process::SetRunningUserExpression(bool on) {
1519 m_mod_id.SetRunningUserExpression(on);
1522 void Process::SetRunningUtilityFunction(bool on) {
1523 m_mod_id.SetRunningUtilityFunction(on);
1563 if (pos == m_language_runtimes.end() || !pos->second) {
1570 runtime = pos->second.get();
1577 assert(runtime->GetLanguageType() == Language::GetPrimaryLanguage(language));
1592 return runtime ? runtime->CouldHaveDynamicValue(in_value) : false;
1596 if (runtime->CouldHaveDynamicValue(in_value))
1604 m_dynamic_checkers_up.reset(dynamic_checkers);
1617 m_breakpoint_site_list.ForEach([this](BreakpointSite *bp_site) -> void {
1618 // bp_site->SetEnabled(true);
1636 if (bp_site_sp->IsEnabled())
1650 if (!bp_site_sp->IsEnabled())
1685 // Reset the IsIndirect flag here, in case the location changes from pointing
1687 constituent->SetIsIndirect(false);
1689 if (constituent->ShouldResolveIndirectFunctions()) {
1690 Symbol *symbol = constituent->GetAddress().CalculateSymbolContextSymbol();
1691 if (symbol && symbol->IsIndirect()) {
1693 Address symbol_address = symbol->GetAddress();
1699 symbol->GetLoadAddress(&GetTarget()),
1700 constituent->GetBreakpoint().GetID(), constituent->GetID(),
1706 constituent->SetIsIndirect(true);
1708 load_addr = constituent->GetAddress().GetOpcodeLoadAddress(&GetTarget());
1710 load_addr = constituent->GetAddress().GetOpcodeLoadAddress(&GetTarget());
1721 bp_site_sp->AddConstituent(constituent);
1722 constituent->SetBreakpointSite(bp_site_sp);
1723 return bp_site_sp->GetID();
1725 bp_site_sp.reset(
1730 constituent->SetBreakpointSite(bp_site_sp);
1738 load_addr, constituent->GetBreakpoint().GetID(),
1739 constituent->GetID(),
1754 bp_site_sp->RemoveConstituent(constituent_id, constituent_loc_id);
1759 m_breakpoint_site_list.RemoveByAddress(bp_site_sp->GetLoadAddress());
1771 buf](BreakpointSite *bp_site) -> void {
1772 if (bp_site->GetType() == BreakpointSite::eSoftware) {
1776 if (bp_site->IntersectsRange(bp_addr, size, &intersect_addr,
1781 assert(opcode_offset + intersect_size <= bp_site->GetByteSize());
1782 size_t buf_offset = intersect_addr - bp_addr;
1784 bp_site->GetSavedOpcodeBytes() + opcode_offset,
1796 return platform_sp->GetSoftwareBreakpointTrapOpcode(GetTarget(), bp_site);
1804 const addr_t bp_addr = bp_site->GetLoadAddress();
1807 bp_site->GetID(), (uint64_t)bp_addr);
1808 if (bp_site->IsEnabled()) {
1812 " -- already enabled",
1813 bp_site->GetID(), (uint64_t)bp_addr);
1831 const uint8_t *const bp_opcode_bytes = bp_site->GetTrapOpcodeBytes();
1840 if (DoReadMemory(bp_addr, bp_site->GetSavedOpcodeBytes(), bp_opcode_size,
1850 bp_site->SetEnabled(true);
1851 bp_site->SetType(BreakpointSite::eSoftware);
1854 "addr = 0x%" PRIx64 " -- SUCCESS",
1855 bp_site->GetID(), (uint64_t)bp_addr);
1871 " -- FAILED: %s",
1872 bp_site->GetID(), (uint64_t)bp_addr, error.AsCString());
1880 addr_t bp_addr = bp_site->GetLoadAddress();
1881 lldb::user_id_t breakID = bp_site->GetID();
1887 if (bp_site->IsHardware()) {
1889 } else if (bp_site->IsEnabled()) {
1890 const size_t break_op_size = bp_site->GetByteSize();
1891 const uint8_t *const break_op = bp_site->GetTrapOpcodeBytes();
1907 if (DoWriteMemory(bp_addr, bp_site->GetSavedOpcodeBytes(),
1928 if (::memcmp(bp_site->GetSavedOpcodeBytes(), verify_opcode,
1931 bp_site->SetEnabled(false);
1934 "addr = 0x%" PRIx64 " -- SUCCESS",
1935 bp_site->GetID(), (uint64_t)bp_addr);
1953 " -- already disabled",
1954 bp_site->GetID(), (uint64_t)bp_addr);
1961 " -- FAILED: %s",
1962 bp_site->GetID(), (uint64_t)bp_addr, error.AsCString());
1972 addr = abi_sp->FixAnyAddress(addr);
2147 // If we got "length - 1" bytes, we didn't get the whole C string, we need
2149 if (length == sizeof(buf) - 1)
2170 size_t bytes_left = dst_max_len - 1;
2175 cache_line_size - (curr_addr % cache_line_size);
2194 bytes_left -= bytes_read;
2210 addr = abi_sp->FixAnyAddress(addr);
2219 const size_t curr_size = size - bytes_read;
2282 const size_t curr_size = size - bytes_written;
2295 addr = abi_sp->FixAnyAddress(addr);
2322 &error](BreakpointSite *bp) -> void {
2326 if (bp->GetType() != BreakpointSite::eSoftware)
2332 const bool intersects = bp->IntersectsRange(
2339 assert(opcode_offset + intersect_size <= bp->GetByteSize());
2346 size_t curr_size = intersect_addr - curr_addr;
2360 ::memcpy(bp->GetSavedOpcodeBytes() + opcode_offset, ubuf + bytes_written,
2369 size - bytes_written, error);
2398 } else if (byte_size & (byte_size - 1)) {
2562 ObjectFile *objfile = module_sp->GetMemoryObjectFile(
2604 event_sp.reset();
2624 m_os_up.reset(OperatingSystem::FindPlugin(this, nullptr));
2644 // prevent a stop message with a bunch of spurious output on thread
2664 m_abi_sp.reset();
2665 m_dyld_up.reset();
2666 m_jit_loaders_up.reset();
2667 m_system_runtime_up.reset();
2668 m_os_up.reset();
2672 m_process_input_reader.reset();
2679 // executable module only exists on the remote. However, there needs to
2692 exe_spec_to_use = exe_module->GetFileSpec();
2694 if (exe_module && FileSystem::Instance().Exists(exe_module->GetFileSpec())) {
2735 SetExitStatus(-1, error_string);
2772 dyld->DidLaunch();
2778 system_runtime->DidLaunch();
2810 dyld->DidAttach();
2816 system_runtime->DidAttach();
2845 m_dyld_up.reset(DynamicLoader::FindPlugin(this, ""));
2869 m_system_runtime_up.reset(SystemRuntime::FindPlugin(this));
2904 assert(m_process->GetID() != LLDB_INVALID_PROCESS_ID);
2907 m_process->GetThreadList().SetShouldReportStop(eVoteNo);
2910 --m_exec_count;
2914 "remaining exec count to %" PRIu32 ", requesting resume",
2925 m_process->CompleteAttach();
2970 m_abi_sp.reset();
2973 m_process_input_reader.reset();
2975 m_dyld_up.reset();
2976 m_jit_loaders_up.reset();
2977 m_system_runtime_up.reset();
2978 m_os_up.reset();
3009 SetExitStatus(-1, error.AsCString());
3026 platform_sp->FindProcesses(match_info, process_infos);
3039 s, platform_sp->GetUserIDResolver(), true, false);
3086 SetExitStatus(-1, error_string);
3098 // before we go looking for a dynamic loader plug-in.
3118 if (target_arch.IsValid() && !platform_sp->IsCompatibleArchitecture(
3128 "switching platform to {0} and architecture to {1} based on "
3130 platform_sp->GetName(), platform_arch.GetTriple().getTriple());
3142 "Process::%s switching architecture to %s based on info "
3157 // plug-in
3160 dyld->DidAttach();
3166 exe_module_sp ? exe_module_sp->GetFileSpec() : FileSpec(),
3167 dyld->GetPluginName());
3175 system_runtime->DidAttach();
3181 exe_module_sp ? exe_module_sp->GetFileSpec() : FileSpec(),
3182 system_runtime->GetPluginName());
3199 if (module_sp && module_sp->IsExecutable()) {
3214 exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str()
3221 m_abi_sp.reset();
3224 m_process_input_reader.reset();
3237 // If we attached and actually have a process on the other end, then
3268 // Tell the process it is about to resume before the thread list
3270 // Now let the thread list know we are about to resume so it can let all of
3274 // (suspended/running/stepping). Threads should also check their resume
3316 // case it was already set and some thread plan logic calls halt on its own.
3358 const size_t region_size = high - low;
3366 for (size_t idx = 0; idx < size - 1; idx++) {
3368 bad_char_heuristic[bcu_idx] = size - idx - 1;
3370 for (size_t s = 0; s <= (region_size - size);) {
3371 int64_t j = size - 1;
3373 j--;
3377 s += bad_char_heuristic[iterator[s + size - 1]];
3416 exit_event_sp.reset(); // It is ok to consume any non-exit stop events
3423 // really are stopped, then continue on.
3543 m_process_input_reader->SetIsDone(true);
3544 m_process_input_reader->Cancel();
3545 m_process_input_reader.reset();
3628 // differently. running -> running: Automatically suppress extra running
3629 // events stopped -> running: Report except when there is one or more no
3646 // and hit the breakpoints on multiple threads, then somehow during the
3727 // Forcing the next event delivery is a one shot deal. So reset it here.
3732 // broadcast. So we use m_last_broadcast_state to track that. NB - you
3735 // queue, and there may be several events stacked up on the queue unserviced.
3744 "broadcast state: %s - %s",
3767 // On platforms with abbreviated thread name lengths, choose thread names
3770 snprintf(thread_name, sizeof(thread_name), "intern-state-OV");
3772 snprintf(thread_name, sizeof(thread_name), "intern-state");
3776 "<lldb.process.internal-state-override(pid=%" PRIu64 ")>",
3780 "<lldb.process.internal-state(pid=%" PRIu64 ")>", GetID());
3796 assert(private_state_thread->IsJoinable());
3835 // on a control event instead of simply being on its way out (this should
3849 event_receipt_sp->WaitForEventReceived(GetUtilityExpressionTimeout());
3862 m_private_state_thread.Reset();
3889 m_next_event_action_up->PerformAction(event_sp);
3906 SetExitStatus(0, m_next_event_action_up->GetExitString());
3953 // "process_sp->PopProcessIOHandler()" to see where I am talking about.
3962 // they call "process->WaitForProcessToStop()". An example of something
3967 // This will cause the internal process state thread to resume and halt
4016 if (event_sp->BroadcasterIs(&m_private_state_control_broadcaster)) {
4021 event_sp->GetType());
4023 switch (event_sp->GetType()) {
4038 } else if (event_sp->GetType() == eBroadcastBitInterrupt) {
4042 ") woke up with an interrupt while attaching - "
4049 // cases where relying on that side-effect causes the shutdown to be
4056 ") woke up with an interrupt - Halting.",
4068 // HaltPrivate failed, so that we can interrupt on the next natural
4103 "Process::%s interrupt_requested, but a non-stopped "
4130 // it was doing yet, so don't try to change it on the way out.
4165 ThreadList &curr_thread_list = process_sp->GetThreadList();
4184 of stop and no need to perform any actions on them.
4186 if (thread_sp->GetResumeState() != eStateSuspended)
4187 not_suspended_threads.emplace_back(thread_sp, thread_sp->GetIndexID());
4197 // Sometimes - for instance if we have a bug in the stub we are talking to,
4213 if (thread_sp->GetIndexID() != thread_index) {
4217 thread_sp.get(), thread_index, thread_sp->GetIndexID());
4221 StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
4222 if (stop_info_sp && stop_info_sp->IsValid()) {
4225 if (stop_info_sp->GetOverrideShouldStop()) {
4227 stop_info_sp->GetOverriddenShouldStopValue();
4229 stop_info_sp->PerformAction(event_ptr);
4237 if (stop_info_sp->HasTargetRunSinceMe()) {
4242 this_thread_wants_to_stop = stop_info_sp->ShouldStop(event_ptr);
4256 if (event_ptr->GetType() != Process::eBroadcastBitStateChanged)
4260 // this on the private state thread. We should wait for the public event.
4266 if (event_ptr->GetType() != Process::eBroadcastBitStateChanged)
4285 process_sp->SetPublicState(
4292 process_sp->WillPublicStop();
4317 // Use the private resume method here, since we aren't changing the run
4319 process_sp->PrivateResume();
4321 bool hijacked = process_sp->IsHijackedForEvent(eBroadcastBitStateChanged) &&
4322 !process_sp->StateChangedIsHijackedForSynchronousResume();
4330 if (process_sp->GetTarget().RunStopHooks())
4340 s->Printf(" process = %p (pid = %" PRIu64 "), ",
4341 static_cast<void *>(process_sp.get()), process_sp->GetID());
4343 s->PutCString(" process = NULL, ");
4345 s->Printf("state = %s", StateAsCString(GetState()));
4351 const EventData *event_data = event_ptr->GetData();
4353 event_data->GetFlavor() == ProcessEventData::GetFlavorString())
4354 return static_cast<const ProcessEventData *>(event_ptr->GetData());
4364 process_sp = data->GetProcessSP();
4373 return data->GetState();
4381 return data->GetRestarted();
4389 data->SetRestarted(new_value);
4397 return data->GetNumRestartedReasons();
4408 return data->GetRestartedReasonAtIndex(idx);
4418 data->AddRestartedReason(reason);
4427 return data->GetInterrupted();
4435 data->SetInterrupted(new_value);
4442 data->SetUpdateStateOnRemoval();
4514 return find_it->second;
4585 process->AppendSTDOUT(static_cast<const char *>(src), src_len);
4591 : IOHandler(process->GetTarget().GetDebugger(),
4623 // FD_ZERO, FD_SET are not supported on windows
4661 if (StateIsRunningState(m_process->GetState()))
4662 m_process->SendAsyncInterrupt();
4696 // m_process->SendAsyncInterrupt() from a much safer location in code.
4703 // This IOHandler might be pushed on the stack, but not being run
4707 // interpreter is running and gets a "expression ...". It will be on the
4712 if (StateIsRunningState(m_process->GetState())) {
4713 m_process->SendAsyncInterrupt();
4766 io_handler_sp->SetIsDone(false);
4768 // IOHandler. Our IOHandler is non-interactive and shouldn't disturb the
4787 // The process needs to know about installed plug-ins
4795 // to discard" fields of the plan we are running, and reset it on Clean or on
4796 // destruction. It will only reset the state once, so you can call Clean and
4797 // then monkey with the state and it won't get reset on you again.
4804 m_private = m_thread_plan_sp->GetPrivate();
4805 m_is_controlling = m_thread_plan_sp->IsControllingPlan();
4806 m_okay_to_discard = m_thread_plan_sp->OkayToDiscard();
4815 m_thread_plan_sp->SetPrivate(m_private);
4816 m_thread_plan_sp->SetIsControllingPlan(m_is_controlling);
4817 m_thread_plan_sp->SetOkayToDiscard(m_okay_to_discard);
4864 return *options.GetTimeout() - GetOneThreadExpressionTimeout(options);
4875 ThreadSP thread_sp = thread_plan_sp->GetTarget()
4877 ->GetThreadList()
4881 "The thread on which we were running the "
4888 ThreadPlanSP plan = thread_sp->GetCompletedPlan();
4889 if (plan == thread_plan_sp && plan->PlanSucceeded()) {
4898 StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
4899 if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonBreakpoint &&
4900 stop_info_sp->ShouldNotify(event_sp.get())) {
4901 LLDB_LOG(log, "stopped for breakpoint: {0}.", stop_info_sp->GetDescription());
4906 // on.
4908 thread_plan_sp->SetPrivate(false);
4939 if (!thread_plan_sp->ValidatePlan(nullptr)) {
4948 "RunThreadPlan called on wrong process.");
4961 lldb::tid_t expr_thread_id = thread->GetID();
4968 // We rely on the thread plan we are running returning "PlanCompleted" if
4970 // private - since private plans suppress themselves in the GetCompletedPlan
4973 thread_plan_sp->SetPrivate(false);
4979 thread_plan_sp->SetIsControllingPlan(true);
4980 thread_plan_sp->SetOkayToDiscard(false);
4995 const uint32_t thread_idx_id = thread->GetIndexID();
4997 thread->GetSelectedFrame(DoNoSelectMostRelevantFrame);
4999 thread->SetSelectedFrame(nullptr);
5000 selected_frame_sp = thread->GetSelectedFrame(DoNoSelectMostRelevantFrame);
5004 "RunThreadPlan called without a selected frame on thread %d",
5010 // Make sure the timeout values make sense. The one thread timeout needs to
5020 StackID ctx_frame_id = selected_frame_sp->GetStackID();
5023 // We don't want to do that either, so we should arrange to reset them as
5031 selected_tid = selected_thread_sp->GetIndexID();
5033 selected_thread_sp->GetSelectedFrame(DoNoSelectMostRelevantFrame)
5034 ->GetStackID();
5045 // Yikes, we are running on the private state thread! So we can't wait for
5046 // public events on this thread, since we are the thread that is generating
5050 LLDB_LOGF(log, "Running thread plan on private state thread, spinning up "
5057 // normal course of things, the plan above us on the stack would be given a
5059 // So we insert a "stopper" base plan on the stack before the plan we want
5062 stopper_base_plan_sp.reset(new ThreadPlanBase(*thread));
5063 thread->QueueThreadPlan(stopper_base_plan_sp, false);
5073 thread->QueueThreadPlan(
5084 thread->Flush();
5089 Listener::MakeListener("lldb.process.listener.run-thread-plan"));
5095 // makes sure that the process events get restored on exit to the function.
5097 // If the event needs to propagate beyond the hijacker (e.g., the process
5105 thread_plan_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
5107 "Process::RunThreadPlan(): Resuming thread %u - 0x%4.4" PRIx64
5134 // This isn't going to work if there are unfetched events on the queue. Are
5139 Event *other_events = listener_sp->PeekAtNextEvent();
5143 "RunThreadPlan called with pending events on the queue.");
5158 // thread timeout expires, I go to halt, but the process already stopped on
5159 // the function call stop breakpoint. Turning on this define will make us
5167 // We usually want to resume the process if we get to the top of the
5177 // Do the initial resume and wait for the running event before going
5186 "couldn't resume inferior the %d time: \"%s\".", num_resumes,
5194 listener_sp->GetEvent(event_sp, GetUtilityExpressionTimeout());
5198 "resume %" PRIu32 ", exiting.",
5202 "didn't get any event after resume %" PRIu32
5221 "resume %d, got %s instead (restarted: %i, do_resume: %i, "
5238 "didn't get running event after initial resume, got %s instead.",
5245 log->PutCString("Process::RunThreadPlan(): resuming succeeded.");
5249 // point. We set the timeout AFTER the resume, since the resume takes
5253 log->PutCString("Process::RunThreadPlan(): waiting for next event.");
5260 event_sp.reset();
5268 "Process::RunThreadPlan(): about to wait - now is %s - "
5285 got_event = listener_sp->GetEvent(event_sp, timeout);
5290 if (event_sp->GetType() == eBroadcastBitInterrupt) {
5361 log->PutCString("Process::RunThreadPlan(): got_event was true, but "
5368 // interrupt the process here. Depending on what we were asked to do
5410 log->PutCString("Process::RunThreadPlan(): Halt succeeded.");
5413 listener_sp->GetEvent(event_sp, GetUtilityExpressionTimeout());
5425 log->PutCString(" Event was the Halt interruption event.");
5432 log->PutCString("Process::RunThreadPlan(): Went to halt "
5434 "an un-restarted stopped event so try "
5457 log->PutCString("Process::RunThreadPlan(): try_all_threads "
5469 thread_plan_sp->SetStopOthers(false);
5471 log->PutCString(
5472 "Process::RunThreadPlan(): about to resume.");
5479 log->PutCString("Process::RunThreadPlan(): running all "
5488 log->PutCString("Process::RunThreadPlan(): halt said it "
5515 thread->DiscardThreadPlansUpToPlan(stopper_base_plan_sp);
5521 // If our thread went away on us, we need to get out of here without
5532 thread->GetStackFrameStatus(s, 0, UINT32_MAX, true, UINT32_MAX);
5533 log->PutString(s.GetString());
5545 thread_plan_sp->RestoreThreadState();
5548 // Now do some processing on the results of the run:
5554 event_sp->Dump(&s);
5556 log->PutCString("Process::RunThreadPlan(): Stop event that "
5568 } else if (event_sp->GetType() == eBroadcastBitInterrupt) {
5581 Process *process = event_data->GetProcessSP().get();
5588 ThreadList &thread_list = process->GetThreadList();
5603 ts.Printf("<0x%4.4" PRIx64 " ", thread->GetID());
5605 thread->GetRegisterContext().get();
5608 ts.Printf("[ip 0x%" PRIx64 "] ", register_context->GetPC());
5614 lldb::StopInfoSP stop_info_sp = thread->GetPrivateStopInfo();
5616 const char *stop_desc = stop_info_sp->GetDescription();
5638 "Process::RunThreadPlan: ExecutionInterrupted - "
5641 thread->DiscardThreadPlansUpToPlan(thread_plan_sp);
5644 "Process::RunThreadPlan: ExecutionInterrupted - for "
5650 log->PutCString("Process::RunThreadPlan(): execution set up error.");
5653 thread->DiscardThreadPlansUpToPlan(thread_plan_sp);
5656 if (thread->IsThreadPlanDone(thread_plan_sp.get())) {
5658 log->PutCString("Process::RunThreadPlan(): thread plan is done");
5660 } else if (thread->WasThreadPlanDiscarded(thread_plan_sp.get())) {
5662 log->PutCString(
5667 log->PutCString(
5671 log->PutCString("Process::RunThreadPlan(): discarding thread plan "
5673 thread->DiscardThreadPlansUpToPlan(thread_plan_sp);
5683 exe_ctx.SetFrameSP(thread->GetFrameWithStackID(ctx_frame_id));
5695 GetThreadList().GetSelectedThread()->GetFrameWithStackID(
5698 GetThreadList().GetSelectedThread()->SetSelectedFrame(
5708 log->PutCString("Process::RunThreadPlan(): rebroadcasting event.");
5794 thread_id_array[idx] = curr_thread_list.GetThreadAtIndex(idx)->GetID();
5801 StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
5802 if (!stop_info_sp || !stop_info_sp->IsValid())
5805 thread_sp->GetStatus(strm, start_frame, num_frames,
5811 LLDB_LOGF(log, "Process::GetThreadStatus - thread 0x" PRIu64
5937 addr = abi_sp->FixCodeAddress(addr);
5943 addr = abi_sp->FixDataAddress(addr);
5949 addr = abi_sp->FixAnyAddress(addr);
5960 m_dynamic_checkers_up.reset();
5961 m_abi_sp.reset();
5962 m_system_runtime_up.reset();
5963 m_os_up.reset();
5964 m_dyld_up.reset();
5965 m_jit_loaders_up.reset();
5985 // let the target know so it can do any cleanup it needs to.
5997 addr_t addr = address->GetLoadAddress(&GetTarget());
6004 Symbol *symbol = address->CalculateSymbolContextSymbol();
6007 symbol ? symbol->GetName().AsCString() : "<UNKNOWN>");
6011 function_addr = abi_sp->FixCodeAddress(function_addr);
6023 sys_runtime->ModulesDidLoad(module_list);
6032 runtime.second->ModulesDidLoad(module_list);
6038 runtime->ModulesDidLoad(module_list);
6041 // If we don't have an operating system plug-in, try to load one since
6046 // Inform the structured-data plugins of the modified modules.
6049 pair.second->ModulesDidLoad(*this, module_list);
6056 if (!sc.module_sp || !sc.function || !sc.function->GetIsOptimized())
6058 sc.module_sp->ReportWarningOptimization(GetTarget().GetDebugger().GetID());
6075 sc.module_sp->ReportWarningUnsupportedLanguage(
6086 return platform_sp->GetProcessInfo(GetID(), info);
6100 memory_history->GetHistoryThreads(addr));
6123 return m_image_tokens.size() - 1;
6156 insn_list = &disassembler_sp->GetInstructionList();
6163 insn_list->GetIndexOfInstructionAtAddress(default_stop_addr);
6168 uint32_t branch_index = insn_list->GetIndexOfNextBranchInstruction(
6176 insn_list->GetInstructionAtIndex(branch_index)->GetAddress();
6189 load_addr = abi->FixAnyAddress(load_addr);
6210 // the start will not have non-address bits until the first unmappable
6212 // region, the last mappable region, will have non-address bits in its end
6219 // For a process with no non-address bits, all address bits
6222 // If we have non-address bits and some are set then the end
6224 !(abi && (abi->FixAnyAddress(range_end) != range_end)));
6232 // If you get this, the Process-derived class needs to implement a method to
6233 // enable an already-reported asynchronous structured data feature. See
6234 // ProcessGDBRemote for an example implementation over gdb-remote.
6261 const llvm::StringRef type_name = object->GetStringValue();
6266 LLDB_LOG(log, "- {0}", type_name);
6285 // This plugin doesn't think it can work with the process. Move on to the
6293 if (plugin_sp->SupportsStructuredDataType(type_name)) {
6298 plugin_sp->GetPluginName(), type_name);
6315 // key via the top-level 'type' string value within the dictionary.
6316 StructuredData::Dictionary *dictionary = object_sp->GetAsDictionary();
6322 if (!dictionary->GetValueForKeyAsString("type", type_name))
6333 find_it->second->HandleArrivalOfStructuredData(*this, type_name, object_sp);
6356 "Can't trace a non-live process.");
6386 ts->GetBasicTypeFromAST(eBasicTypeVoid).GetPointerType();
6392 StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
6395 frame->CalculateExecutionContext(exe_ctx);
6400 call_plan_sp->GetReturnValueObject()->GetValueAsUnsigned(
6421 arch ? arch->GetMemoryTagManager() : nullptr;
6445 DoReadMemoryTags(addr, len, tag_manager->GetAllocationTagType());
6449 return tag_manager->UnpackTagsData(*tag_data,
6450 len / tag_manager->GetGranuleSize());
6462 tag_manager->PackTags(tags);
6467 return DoWriteMemoryTags(addr, len, tag_manager->GetAllocationTagType(),
6541 // the unused portion of the stack below the stack pointer. Saving space on
6546 StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(0);
6549 RegisterContextSP reg_ctx_sp = frame_sp->GetRegisterContext();
6552 const addr_t sp = reg_ctx_sp->GetSP();
6553 const size_t red_zone = process.GetABI()->GetRedZoneSize();
6556 const size_t stack_head = (sp - red_zone);
6557 const size_t stack_size = sp_region.GetRange().GetRangeEnd() - stack_head;
6598 // plug-in so fall back to any region with write access permissions.
6608 // when a memory region is stack related. We check on this information, but we