summaryrefslogtreecommitdiffstats
path: root/lldb
diff options
context:
space:
mode:
Diffstat (limited to 'lldb')
-rw-r--r--lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp3
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp7
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h6
-rw-r--r--lldb/source/Target/Process.cpp17
-rw-r--r--lldb/source/Target/Target.cpp14
5 files changed, 39 insertions, 8 deletions
diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index 9dedfece654..f12f98c30b4 100644
--- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -372,6 +372,9 @@ ConnectionFileDescriptor::Disconnect(Error *error_ptr)
if (error_ptr)
*error_ptr = error.Fail() ? error : error2;
+ // Close any pipes we were using for async interrupts
+ m_pipe.Close();
+
m_uri.clear();
m_shutting_down = false;
return status;
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index e1f5f2fbd53..a03c43b005f 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1401,12 +1401,11 @@ ProcessGDBRemote::DoAttachToProcessWithName (const char *process_name, const Pro
return error;
}
-
-bool
-ProcessGDBRemote::SetExitStatus (int exit_status, const char *cstr)
+void
+ProcessGDBRemote::DidExit ()
{
+ // When we exit, disconnect from the GDB server communications
m_gdb_comm.Disconnect();
- return Process::SetExitStatus (exit_status, cstr);
}
void
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index a6c2d107dc1..59906808322 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -225,10 +225,10 @@ public:
SendEventData(const char *data) override;
//----------------------------------------------------------------------
- // Override SetExitStatus so we can disconnect from the remote GDB server
+ // Override DidExit so we can disconnect from the remote GDB server
//----------------------------------------------------------------------
- bool
- SetExitStatus (int exit_status, const char *cstr) override;
+ void
+ DidExit () override;
void
SetUserSpecifiedMaxMemoryTransferSize (uint64_t user_specified_max);
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
{
OpenPOWER on IntegriCloud