diff options
Diffstat (limited to 'lldb/source/Target/Process.cpp')
| -rw-r--r-- | lldb/source/Target/Process.cpp | 65 |
1 files changed, 42 insertions, 23 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index ff6a2f59eba3..c009d17d3ba5 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -446,8 +446,7 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp, m_memory_cache(*this), m_allocated_memory_cache(*this), m_should_detach(false), m_next_event_action_up(), m_public_run_lock(), m_private_run_lock(), m_currently_handling_do_on_removals(false), - m_resume_requested(false), m_last_run_direction(eRunForward), - m_interrupt_tid(LLDB_INVALID_THREAD_ID), + m_resume_requested(false), m_interrupt_tid(LLDB_INVALID_THREAD_ID), m_finalizing(false), m_destructing(false), m_clear_thread_plans_on_stop(false), m_force_next_event_delivery(false), m_last_broadcast_state(eStateInvalid), m_destroy_in_process(false), @@ -846,7 +845,6 @@ bool Process::HandleProcessStateChangedEvent( switch (thread_stop_reason) { case eStopReasonInvalid: case eStopReasonNone: - case eStopReasonHistoryBoundary: break; case eStopReasonSignal: { @@ -1354,7 +1352,7 @@ void Process::SetPublicState(StateType new_state, bool restarted) { } } -Status Process::Resume(RunDirection direction) { +Status Process::Resume() { Log *log(GetLog(LLDBLog::State | LLDBLog::Process)); LLDB_LOGF(log, "(plugin = %s) -- locking run lock", GetPluginName().data()); if (!m_public_run_lock.TrySetRunning()) { @@ -1363,7 +1361,7 @@ Status Process::Resume(RunDirection direction) { return Status::FromErrorString( "Resume request failed - process still running."); } - Status error = PrivateResume(direction); + Status error = PrivateResume(); if (!error.Success()) { // Undo running state change m_public_run_lock.SetStopped(); @@ -1371,7 +1369,7 @@ Status Process::Resume(RunDirection direction) { return error; } -Status Process::ResumeSynchronous(Stream *stream, RunDirection direction) { +Status Process::ResumeSynchronous(Stream *stream) { Log *log(GetLog(LLDBLog::State | LLDBLog::Process)); LLDB_LOGF(log, "Process::ResumeSynchronous -- locking run lock"); if (!m_public_run_lock.TrySetRunning()) { @@ -1384,7 +1382,7 @@ Status Process::ResumeSynchronous(Stream *stream, RunDirection direction) { Listener::MakeListener(ResumeSynchronousHijackListenerName.data())); HijackProcessEvents(listener_sp); - Status error = PrivateResume(direction); + Status error = PrivateResume(); if (error.Success()) { StateType state = WaitForProcessToStop(std::nullopt, nullptr, true, listener_sp, stream, @@ -3241,7 +3239,7 @@ Status Process::ConnectRemote(llvm::StringRef remote_url) { return error; } -Status Process::PrivateResume(RunDirection direction) { +Status Process::PrivateResume() { Log *log(GetLog(LLDBLog::Process | LLDBLog::Step)); LLDB_LOGF(log, "Process::PrivateResume() m_stop_id = %u, public state: %s " @@ -3257,15 +3255,6 @@ Status Process::PrivateResume(RunDirection direction) { if (!GetModID().IsLastResumeForUserExpression()) ResetExtendedCrashInfoDict(); - if (m_last_run_direction != direction) { - // In the future we might want to support mixed-direction plans, - // e.g. a forward step-over stops at a breakpoint, the user does - // a reverse-step, then disables the breakpoint and continues forward. - // This code will need to be changed to support that. - m_thread_list.DiscardThreadPlans(); - m_last_run_direction = direction; - } - Status error(WillResume()); // Tell the process it is about to resume before the thread list if (error.Success()) { @@ -3283,7 +3272,7 @@ Status Process::PrivateResume(RunDirection direction) { "Process::PrivateResume PreResumeActions failed, not resuming."); } else { m_mod_id.BumpResumeID(); - error = DoResume(direction); + error = DoResume(); if (error.Success()) { DidResume(); m_thread_list.DidResume(); @@ -3746,7 +3735,7 @@ bool Process::ShouldBroadcastEvent(Event *event_ptr) { "from state: %s", static_cast<void *>(event_ptr), StateAsCString(state)); ProcessEventData::SetRestartedInEvent(event_ptr, true); - PrivateResume(m_last_run_direction); + PrivateResume(); } } else { return_value = true; @@ -4357,7 +4346,7 @@ void Process::ProcessEventData::DoOnRemoval(Event *event_ptr) { SetRestarted(true); // Use the private resume method here, since we aren't changing the run // lock state. - process_sp->PrivateResume(process_sp->m_last_run_direction); + process_sp->PrivateResume(); } else { bool hijacked = process_sp->IsHijackedForEvent(eBroadcastBitStateChanged) && !process_sp->StateChangedIsHijackedForSynchronousResume(); @@ -6539,6 +6528,29 @@ static void AddRegion(const MemoryRegionInfo ®ion, bool try_dirty_pages, CreateCoreFileMemoryRange(region)); } +static void SaveDynamicLoaderSections(Process &process, + const SaveCoreOptions &options, + CoreFileMemoryRanges &ranges, + std::set<addr_t> &stack_ends) { + DynamicLoader *dyld = process.GetDynamicLoader(); + if (!dyld) + return; + + std::vector<MemoryRegionInfo> dynamic_loader_mem_regions; + std::function<bool(const lldb_private::Thread &)> save_thread_predicate = + [&](const lldb_private::Thread &t) -> bool { + return options.ShouldThreadBeSaved(t.GetID()); + }; + dyld->CalculateDynamicSaveCoreRanges(process, dynamic_loader_mem_regions, + save_thread_predicate); + for (const auto ®ion : dynamic_loader_mem_regions) { + // The Dynamic Loader can give us regions that could include a truncated + // stack + if (stack_ends.count(region.GetRange().GetRangeEnd()) == 0) + AddRegion(region, true, ranges); + } +} + static void SaveOffRegionsWithStackPointers(Process &process, const SaveCoreOptions &core_options, const MemoryRegionInfos ®ions, @@ -6570,11 +6582,13 @@ static void SaveOffRegionsWithStackPointers(Process &process, // off in other calls sp_region.GetRange().SetRangeBase(stack_head); sp_region.GetRange().SetByteSize(stack_size); - stack_ends.insert(sp_region.GetRange().GetRangeEnd()); + const addr_t range_end = sp_region.GetRange().GetRangeEnd(); + stack_ends.insert(range_end); // This will return true if the threadlist the user specified is empty, // or contains the thread id from thread_sp. - if (core_options.ShouldThreadBeSaved(thread_sp->GetID())) + if (core_options.ShouldThreadBeSaved(thread_sp->GetID())) { AddRegion(sp_region, try_dirty_pages, ranges); + } } } } @@ -6683,9 +6697,14 @@ Status Process::CalculateCoreFileSaveRanges(const SaveCoreOptions &options, std::set<addr_t> stack_ends; // For fully custom set ups, we don't want to even look at threads if there // are no threads specified. - if (core_style != lldb::eSaveCoreCustomOnly || options.HasSpecifiedThreads()) + if (core_style != lldb::eSaveCoreCustomOnly || + options.HasSpecifiedThreads()) { SaveOffRegionsWithStackPointers(*this, options, regions, ranges, stack_ends); + // Save off the dynamic loader sections, so if we are on an architecture + // that supports Thread Locals, that we include those as well. + SaveDynamicLoaderSections(*this, options, ranges, stack_ends); + } switch (core_style) { case eSaveCoreUnspecified: |
