the changes in r233255/r233258. Normally if lldb attaches to
a running process, when we call Process::Destroy, we want to detach
from the process. If lldb launched the process itself, ::Destroy
should kill it.
However, if we attach to a process and the driver calls SBProcess::Kill()
(which calls Destroy), we need to kill it even if we didn't launch it
originally.
The force_kill param allows for the SBProcess::Kill method to force the
behavior of Destroy.
<rdar://problem/
20424439>
llvm-svn: 235158
/// 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.
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");
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");
}
else
{
- Error destroy_error (process->Destroy());
+ Error destroy_error (process->Destroy(false));
if (destroy_error.Success())
{
result.SetStatus (eReturnStatusSuccessFinishResult);
if (command.GetArgumentCount() == 0)
{
- Error error (process->Destroy());
+ Error error (process->Destroy(false));
if (error.Success())
{
result.SetStatus (eReturnStatusSuccessFinishResult);
{
Process *process = exe_ctx.GetProcessPtr();
if (process && process->IsAlive())
- process->Destroy();
+ process->Destroy(false);
}
}
return MenuActionResult::Handled;
{
ExecutionContext exe_ctx = m_debugger.GetCommandInterpreter().GetExecutionContext();
if (exe_ctx.HasProcessScope())
- exe_ctx.GetProcessRef().Destroy();
+ exe_ctx.GetProcessRef().Destroy(false);
}
return eKeyHandled;
}
}
Resume ();
- return Destroy();
+ return Destroy(false);
}
}
}
case eStateStepping:
case eStateCrashed:
case eStateSuspended:
- Destroy();
+ Destroy(false);
break;
case eStateInvalid:
// 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)
{
RestorePrivateProcessEvents();
restored_process_events = true;
SetExitStatus(SIGKILL, "Cancelled async attach.");
- Destroy ();
+ Destroy (false);
}
else
{
}
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())
{
{
m_section_load_history.Clear();
if (m_process_sp->IsAlive())
- m_process_sp->Destroy();
+ m_process_sp->Destroy(false);
m_process_sp->Finalize();
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;