diff options
-rw-r--r-- | lldb/include/lldb/Target/Process.h | 6 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectProcess.cpp | 9 | ||||
-rw-r--r-- | lldb/source/Target/Process.cpp | 14 |
3 files changed, 21 insertions, 8 deletions
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 97a39959428..92ae7541e69 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1936,12 +1936,15 @@ public: /// process event with GetInterrupted will be broadcast. If false, we will /// halt the process with no events generated by the halt. /// + /// @param[in] clear_thread_plans + /// If true, when the process stops, clear all thread plans. + /// /// @return /// Returns an error object. If the error is empty, the process is halted. /// otherwise the halt has failed. //------------------------------------------------------------------ Error - Halt (); + Halt (bool clear_thread_plans = false); //------------------------------------------------------------------ /// Detaches from a running or stopped process. @@ -3668,6 +3671,7 @@ protected: bool m_currently_handling_do_on_removals; bool m_resume_requested; // If m_currently_handling_event or m_currently_handling_do_on_removals are true, Resume will only request a resume, using this flag to check. bool m_finalize_called; + bool m_clear_thread_plans_on_stop; lldb::StateType m_last_broadcast_state; /// This helps with the Public event coalescing in ShouldBroadcastEvent. bool m_destroy_in_process; diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 7ad5f7be935..4c406a4f2aa 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -1470,7 +1470,7 @@ public: protected: bool DoExecute (Args& command, - CommandReturnObject &result) + CommandReturnObject &result) { Process *process = m_exe_ctx.GetProcessPtr(); if (process == NULL) @@ -1482,14 +1482,11 @@ protected: if (command.GetArgumentCount() == 0) { - Error error(process->Halt ()); + bool clear_thread_plans = true; + Error error(process->Halt (clear_thread_plans)); if (error.Success()) { result.SetStatus (eReturnStatusSuccessFinishResult); - - // Maybe we should add a "SuspendThreadPlans so we - // can halt, and keep in place all the current thread plans. - process->GetThreadList().DiscardThreadPlans(); } else { diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index f4733c38d76..652505252f1 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -1035,6 +1035,7 @@ Process::Process(Target &target, Listener &listener) : m_private_run_lock (), m_currently_handling_event(false), m_finalize_called(false), + m_clear_thread_plans_on_stop (false), m_last_broadcast_state (eStateInvalid), m_destroy_in_process (false), m_can_jit(eCanJITDontKnow) @@ -3332,8 +3333,13 @@ Process::PrivateResume () } Error -Process::Halt () +Process::Halt (bool clear_thread_plans) { + // Don't clear the m_clear_thread_plans_on_stop, only set it to true if + // in case it was already set and some thread plan logic calls halt on its + // own. + m_clear_thread_plans_on_stop |= clear_thread_plans; + // First make sure we aren't in the middle of handling an event, or we might restart. This is pretty weak, since // we could just straightaway get another event. It just narrows the window... m_currently_handling_event.WaitForValueEqualTo(false); @@ -4035,6 +4041,12 @@ Process::RunPrivateStateThread () if (internal_state != eStateInvalid) { + if (m_clear_thread_plans_on_stop && + StateIsStoppedState(internal_state, true)) + { + m_clear_thread_plans_on_stop = false; + m_thread_list.DiscardThreadPlans(); + } HandlePrivateEvent (event_sp); } |