diff options
author | Greg Clayton <gclayton@apple.com> | 2015-05-23 03:54:53 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2015-05-23 03:54:53 +0000 |
commit | 5df78fa35b75e51014884ec5eae7fc0ff83f7dd8 (patch) | |
tree | 21f8562ce446d54b008ec2b6334c359bdbd4b333 /lldb/source/Target | |
parent | ac60f4594fb8e7d249db05f5b3a89533e11a92be (diff) | |
download | bcm5719-llvm-5df78fa35b75e51014884ec5eae7fc0ff83f7dd8.tar.gz bcm5719-llvm-5df78fa35b75e51014884ec5eae7fc0ff83f7dd8.zip |
Did some cleanup to stop us from leaking Pipe file descriptors.
The main issue was the Communication::Disconnect() was calling its Connection::Disconnect() but this wouldn't release the pipes that the ConnectionFileDescriptor was using. We also have someone that is holding a strong reference to the Process so that when you re-run, target replaces its m_process_sp, but it doesn't get destructed because someone has a strong reference to it. I need to track that down. But, even if we have a strong reference to the a process that is outstanding, we need to call Process::Finalize() to have it release as much of its resources as possible to avoid memory bloat.
Removed the ProcessGDBRemote::SetExitStatus() override and replaced it with ProcessGDBRemote::DidExit().
Now we aren't leaking file descriptors and the stand alone test suite should run much better.
llvm-svn: 238089
Diffstat (limited to 'lldb/source/Target')
-rw-r--r-- | lldb/source/Target/Process.cpp | 17 | ||||
-rw-r--r-- | lldb/source/Target/Target.cpp | 14 |
2 files changed, 30 insertions, 1 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index a78979cc701..896fb3fedda 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -1466,9 +1466,24 @@ Process::SetExitStatus (int status, const char *cstr) m_exit_string.clear(); } - DidExit (); + // When we exit, we no longer need to the communication channel + m_stdio_communication.StopReadThread(); + m_stdio_communication.Disconnect(); + m_stdin_forward = false; + + // And we don't need the input reader anymore as well + if (m_process_input_reader) + { + m_process_input_reader->SetIsDone(true); + m_process_input_reader->Cancel(); + m_process_input_reader.reset(); + } SetPrivateState (eStateExited); + + // Allow subclasses to do some cleanup + DidExit (); + return true; } diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 6018308d66b..3233e9d3acf 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -2580,10 +2580,24 @@ Target::Launch (ProcessLaunchInfo &launch_info, Stream *stream) if (log) log->Printf ("Target::%s asking the platform to debug the process", __FUNCTION__); + // Get a weak pointer to the previous process if we have one + ProcessWP process_wp; + if (m_process_sp) + process_wp = m_process_sp; m_process_sp = GetPlatform()->DebugProcess (launch_info, debugger, this, error); + + // Cleanup the old process since someone might still have a strong + // reference to this process and we would like to allow it to cleanup + // as much as it can without the object being destroyed. We try to + // lock the shared pointer and if that works, then someone else still + // has a strong reference to the process. + + ProcessSP old_process_sp(process_wp.lock()); + if (old_process_sp) + old_process_sp->Finalize(); } else { |