diff options
| -rw-r--r-- | lldb/include/lldb/Target/Process.h | 10 | ||||
| -rw-r--r-- | lldb/source/API/SBProcess.cpp | 4 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectProcess.cpp | 4 | ||||
| -rw-r--r-- | lldb/source/Core/IOHandler.cpp | 4 | ||||
| -rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Target/Process.cpp | 11 | ||||
| -rw-r--r-- | lldb/source/Target/Target.cpp | 4 |
7 files changed, 25 insertions, 14 deletions
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index e8cf91068c7..5e474096bcc 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1343,11 +1343,19 @@ public: /// This function is not meant to be overridden by Process /// subclasses. /// + /// @param[in] force_kill + /// Whether lldb should force a kill (instead of a detach) from + /// the inferior process. Normally if lldb launched a binary and + /// Destory is called, lldb kills it. If lldb attached to a + /// running process and Destory is called, lldb detaches. If + /// this behavior needs to be over-ridden, this is the bool that + /// can be used. + /// /// @return /// Returns an error object. //------------------------------------------------------------------ Error - Destroy(); + Destroy(bool force_kill); //------------------------------------------------------------------ /// Sends a process a UNIX signal \a signal. diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index d979db77eba..aad3f85ae63 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -768,7 +768,7 @@ SBProcess::Destroy () if (process_sp) { Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); - sb_error.SetError(process_sp->Destroy()); + sb_error.SetError(process_sp->Destroy(false)); } else sb_error.SetErrorString ("SBProcess is invalid"); @@ -821,7 +821,7 @@ SBProcess::Kill () if (process_sp) { Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); - sb_error.SetError (process_sp->Destroy()); + sb_error.SetError (process_sp->Destroy(true)); } else sb_error.SetErrorString ("SBProcess is invalid"); diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 487a97915a8..c9d92103553 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -93,7 +93,7 @@ protected: } else { - Error destroy_error (process->Destroy()); + Error destroy_error (process->Destroy(false)); if (destroy_error.Success()) { result.SetStatus (eReturnStatusSuccessFinishResult); @@ -1466,7 +1466,7 @@ protected: if (command.GetArgumentCount() == 0) { - Error error (process->Destroy()); + Error error (process->Destroy(false)); if (error.Success()) { result.SetStatus (eReturnStatusSuccessFinishResult); diff --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp index 0f9d8a8c8f3..81afae545ea 100644 --- a/lldb/source/Core/IOHandler.cpp +++ b/lldb/source/Core/IOHandler.cpp @@ -4433,7 +4433,7 @@ public: { Process *process = exe_ctx.GetProcessPtr(); if (process && process->IsAlive()) - process->Destroy(); + process->Destroy(false); } } return MenuActionResult::Handled; @@ -5392,7 +5392,7 @@ public: { ExecutionContext exe_ctx = m_debugger.GetCommandInterpreter().GetExecutionContext(); if (exe_ctx.HasProcessScope()) - exe_ctx.GetProcessRef().Destroy(); + exe_ctx.GetProcessRef().Destroy(false); } return eKeyHandled; diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index dc61ec839da..da3a650e789 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -2166,7 +2166,7 @@ ProcessGDBRemote::DoDestroy () } } Resume (); - return Destroy(); + return Destroy(false); } } } diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 606c2c0b2ff..caa6756afcd 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -836,7 +836,7 @@ Process::Finalize() case eStateStepping: case eStateCrashed: case eStateSuspended: - Destroy(); + Destroy(false); break; case eStateInvalid: @@ -3160,7 +3160,7 @@ Process::Launch (ProcessLaunchInfo &launch_info) // catch the initial stop. error.SetErrorString ("failed to catch stop after launch"); SetExitStatus (0, "failed to catch stop after launch"); - Destroy(); + Destroy(false); } else if (state == eStateStopped || state == eStateCrashed) { @@ -3787,7 +3787,7 @@ Process::Halt (bool clear_thread_plans) RestorePrivateProcessEvents(); restored_process_events = true; SetExitStatus(SIGKILL, "Cancelled async attach."); - Destroy (); + Destroy (false); } else { @@ -3961,12 +3961,15 @@ Process::Detach (bool keep_stopped) } Error -Process::Destroy () +Process::Destroy (bool force_kill) { // Tell ourselves we are in the process of destroying the process, so that we don't do any unnecessary work // that might hinder the destruction. Remember to set this back to false when we are done. That way if the attempt // failed and the process stays around for some reason it won't be in a confused state. + + if (force_kill) + m_should_detach = false; if (GetShouldDetach()) { diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 193d62d4fd0..400cf47bf05 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -189,7 +189,7 @@ Target::DeleteCurrentProcess () { m_section_load_history.Clear(); if (m_process_sp->IsAlive()) - m_process_sp->Destroy(); + m_process_sp->Destroy(false); m_process_sp->Finalize(); @@ -2753,7 +2753,7 @@ Target::Attach (ProcessAttachInfo &attach_info, Stream *stream) error.SetErrorStringWithFormat ("attach failed: %s", exit_desc); else error.SetErrorString ("attach failed: process did not stop (no such process or permission problem?)"); - process_sp->Destroy (); + process_sp->Destroy (false); } } return error; |

