Track whether a process was Launched or Attached to. If Attached, the detach when the debugger is destroyed, rather than killing the process. Also added a Debugger::Clear, which gets called in Debugger::Destroy to deal with all the targets in the Debugger. Also made the Driver's main loop call Destroy on the debugger, rather than just Destroying the currently selected Target's process.

llvm-svn: 139853
This commit is contained in:
Jim Ingham 2011-09-15 21:36:42 +00:00
parent 12e9a2012f
commit 8314c5259d
2 changed files with 17 additions and 3 deletions

View File

@ -157,6 +157,8 @@ Debugger::Destroy (lldb::DebuggerSP &debugger_sp)
if (debugger_sp.get() == NULL)
return;
debugger_sp->Clear();
Mutex::Locker locker (GetDebuggerListMutex ());
DebuggerList &debugger_list = GetDebuggerList ();
DebuggerList::iterator pos, end = debugger_list.end();
@ -168,7 +170,6 @@ Debugger::Destroy (lldb::DebuggerSP &debugger_sp)
return;
}
}
}
lldb::DebuggerSP
@ -251,6 +252,12 @@ Debugger::Debugger () :
}
Debugger::~Debugger ()
{
Clear();
}
void
Debugger::Clear()
{
CleanUpInputReaders();
int num_targets = m_target_list.GetNumTargets();
@ -258,11 +265,16 @@ Debugger::~Debugger ()
{
ProcessSP process_sp (m_target_list.GetTargetAtIndex (i)->GetProcessSP());
if (process_sp)
process_sp->Destroy();
{
if (process_sp->AttachedToProcess())
process_sp->Detach();
else
process_sp->Destroy();
}
}
DisconnectInput();
}
}
bool
Debugger::GetCloseInputOnEOF () const

View File

@ -600,6 +600,7 @@ Process::Process(Target &target, Listener &listener) :
m_stdout_data (),
m_memory_cache (*this),
m_allocated_memory_cache (*this),
m_attached_to_process (false),
m_next_event_action_ap()
{
UpdateInstanceName();
@ -2305,6 +2306,7 @@ Process::CompleteAttach ()
{
// Let the process subclass figure out at much as it can about the process
// before we go looking for a dynamic loader plug-in.
m_attached_to_process = true;
DidAttach();
// We just attached. If we have a platform, ask it for the process architecture, and if it isn't