Linux fix patch from Dmitry Vyukov.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@151072 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Process/Linux/ProcessLinux.cpp b/source/Plugins/Process/Linux/ProcessLinux.cpp
index a8c33bc..69d54cc 100644
--- a/source/Plugins/Process/Linux/ProcessLinux.cpp
+++ b/source/Plugins/Process/Linux/ProcessLinux.cpp
@@ -31,10 +31,10 @@
 //------------------------------------------------------------------------------
 // Static functions.
 
-Process*
-ProcessLinux::CreateInstance(Target& target, Listener &listener)
+ProcessSP
+ProcessLinux::CreateInstance(Target &target, Listener &listener, const FileSpec *)
 {
-    return new ProcessLinux(target, listener);
+    return ProcessSP(new ProcessLinux(target, listener));
 }
 
 void
@@ -105,8 +105,10 @@
     // FIXME: We should be using tid, not pid.
     assert(m_monitor);
     ThreadSP thread_sp (old_thread_list.FindThreadByID (GetID(), false));
-    if (!thread_sp)
-        thread_sp.reset(new POSIXThread(*this, GetID()));
+    if (!thread_sp) {
+        ProcessSP me = this->shared_from_this();
+        thread_sp.reset(new POSIXThread(me, GetID()));
+    }
 
     if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
         log->Printf ("ProcessLinux::%s() updated pid = %i", __FUNCTION__, GetID());
diff --git a/source/Plugins/Process/Linux/ProcessLinux.h b/source/Plugins/Process/Linux/ProcessLinux.h
index cef8a66..49fdb45 100644
--- a/source/Plugins/Process/Linux/ProcessLinux.h
+++ b/source/Plugins/Process/Linux/ProcessLinux.h
@@ -30,9 +30,10 @@
     //------------------------------------------------------------------
     // Static functions.
     //------------------------------------------------------------------
-    static Process*
+    static lldb::ProcessSP
     CreateInstance(lldb_private::Target& target,
-                   lldb_private::Listener &listener);
+                   lldb_private::Listener &listener,
+                   const lldb_private::FileSpec *);
 
     static void
     Initialize();
diff --git a/source/Plugins/Process/Linux/ProcessMonitor.cpp b/source/Plugins/Process/Linux/ProcessMonitor.cpp
index ed69b97..6c35b7e 100644
--- a/source/Plugins/Process/Linux/ProcessMonitor.cpp
+++ b/source/Plugins/Process/Linux/ProcessMonitor.cpp
@@ -966,6 +966,7 @@
 {
     ProcessMonitor *monitor = args->m_monitor;
     ProcessLinux &process = monitor->GetProcess();
+    lldb::ProcessSP processSP = process.shared_from_this();
     const char **argv = args->m_argv;
     const char **envp = args->m_envp;
     const char *stdin_path = args->m_stdin_path;
@@ -1104,7 +1105,7 @@
     // Update the process thread list with this new thread.
     // FIXME: should we be letting UpdateThreadList handle this?
     // FIXME: by using pids instead of tids, we can only support one thread.
-    inferior.reset(new POSIXThread(process, pid));
+    inferior.reset(new POSIXThread(processSP, pid));
     if (log)
         log->Printf ("ProcessMonitor::%s() adding pid = %i", __FUNCTION__, pid);
     process.GetThreadList().AddThread(inferior);
@@ -1166,6 +1167,7 @@
 
     ProcessMonitor *monitor = args->m_monitor;
     ProcessLinux &process = monitor->GetProcess();
+    lldb::ProcessSP processSP = process.shared_from_this();
     lldb::ThreadSP inferior;
     LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
 
@@ -1191,7 +1193,7 @@
     }
 
     // Update the process thread list with the attached thread.
-    inferior.reset(new POSIXThread(process, pid));
+    inferior.reset(new POSIXThread(processSP, pid));
     if (log)
         log->Printf ("ProcessMonitor::%s() adding tid = %i", __FUNCTION__, pid);
     process.GetThreadList().AddThread(inferior);