diff options
author | Greg Clayton <gclayton@apple.com> | 2015-05-29 03:20:37 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2015-05-29 03:20:37 +0000 |
commit | aeb3b8b1c03c3cc92de65bf0267dae52d05e51d9 (patch) | |
tree | ac0f98a502c7a6c10442cf62431dda4b081e7595 /lldb/source/Target/Process.cpp | |
parent | 27a6cfd8230a65dd9b512024e602d34549dffc3d (diff) | |
download | bcm5719-llvm-aeb3b8b1c03c3cc92de65bf0267dae52d05e51d9.tar.gz bcm5719-llvm-aeb3b8b1c03c3cc92de65bf0267dae52d05e51d9.zip |
Change ProcessEventData over to use a std::weak_ptr to a process intead of a std::shared_ptr. Anyone consuming events for a process should have the process around long enough to grab the event and anyone that holds onto an event for too long won't keep the process around.
llvm-svn: 238541
Diffstat (limited to 'lldb/source/Target/Process.cpp')
-rw-r--r-- | lldb/source/Target/Process.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 8f1582b5f4f..78e21413ec4 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -4646,7 +4646,7 @@ Process::RunPrivateStateThread () Process::ProcessEventData::ProcessEventData () : EventData (), - m_process_sp (), + m_process_wp (), m_state (eStateInvalid), m_restarted (false), m_update_state (0), @@ -4656,12 +4656,14 @@ Process::ProcessEventData::ProcessEventData () : Process::ProcessEventData::ProcessEventData (const ProcessSP &process_sp, StateType state) : EventData (), - m_process_sp (process_sp), + m_process_wp (), m_state (state), m_restarted (false), m_update_state (0), m_interrupted (false) { + if (process_sp) + m_process_wp = process_sp; } Process::ProcessEventData::~ProcessEventData() @@ -4684,6 +4686,11 @@ Process::ProcessEventData::GetFlavor () const void Process::ProcessEventData::DoOnRemoval (Event *event_ptr) { + ProcessSP process_sp(m_process_wp.lock()); + + if (!process_sp) + return; + // This function gets called twice for each event, once when the event gets pulled // off of the private process event queue, and then any number of times, first when it gets pulled off of // the public event queue, then other times when we're pretending that this is where we stopped at the @@ -4693,7 +4700,7 @@ Process::ProcessEventData::DoOnRemoval (Event *event_ptr) if (m_update_state != 1) return; - m_process_sp->SetPublicState (m_state, Process::ProcessEventData::GetRestartedFromEvent(event_ptr)); + process_sp->SetPublicState (m_state, Process::ProcessEventData::GetRestartedFromEvent(event_ptr)); // If this is a halt event, even if the halt stopped with some reason other than a plain interrupt (e.g. we had // already stopped for a breakpoint when the halt request came through) don't do the StopInfo actions, as they may @@ -4704,7 +4711,7 @@ Process::ProcessEventData::DoOnRemoval (Event *event_ptr) // If we're stopped and haven't restarted, then do the StopInfo actions here: if (m_state == eStateStopped && ! m_restarted) { - ThreadList &curr_thread_list = m_process_sp->GetThreadList(); + ThreadList &curr_thread_list = process_sp->GetThreadList(); uint32_t num_threads = curr_thread_list.GetSize(); uint32_t idx; @@ -4734,7 +4741,7 @@ Process::ProcessEventData::DoOnRemoval (Event *event_ptr) for (idx = 0; idx < num_threads; ++idx) { - curr_thread_list = m_process_sp->GetThreadList(); + curr_thread_list = process_sp->GetThreadList(); if (curr_thread_list.GetSize() != num_threads) { Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STEP | LIBLLDB_LOG_PROCESS)); @@ -4797,14 +4804,14 @@ Process::ProcessEventData::DoOnRemoval (Event *event_ptr) SetRestarted(true); // Use the public resume method here, since this is just // extending a public resume. - m_process_sp->PrivateResume(); + process_sp->PrivateResume(); } else { // If we didn't restart, run the Stop Hooks here: // They might also restart the target, so watch for that. - m_process_sp->GetTarget().RunStopHooks(); - if (m_process_sp->GetPrivateState() == eStateRunning) + process_sp->GetTarget().RunStopHooks(); + if (process_sp->GetPrivateState() == eStateRunning) SetRestarted(true); } } @@ -4814,9 +4821,13 @@ Process::ProcessEventData::DoOnRemoval (Event *event_ptr) void Process::ProcessEventData::Dump (Stream *s) const { - if (m_process_sp) + ProcessSP process_sp(m_process_wp.lock()); + + if (process_sp) s->Printf(" process = %p (pid = %" PRIu64 "), ", - static_cast<void*>(m_process_sp.get()), m_process_sp->GetID()); + static_cast<void*>(process_sp.get()), process_sp->GetID()); + else + s->PutCString(" process = NULL, "); s->Printf("state = %s", StateAsCString(GetState())); } |