[Lldb-commits] [lldb] r189666 - Move detach to FreeBSD- and Linux-specific classes.

Ed Maste emaste at freebsd.org
Fri Aug 30 06:11:30 PDT 2013


Author: emaste
Date: Fri Aug 30 08:11:30 2013
New Revision: 189666

URL: http://llvm.org/viewvc/llvm-project?rev=189666&view=rev
Log:
Move detach to FreeBSD- and Linux-specific classes.

On Linux there is no separate notion of a process (vs. a thread) for
ptrace(); each thread needs to be individually detached.  On FreeBSD
we have a separate process context, and we detach just it.

Review: http://llvm-reviews.chandlerc.com/D1418

Modified:
    lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
    lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
    lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp
    lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h
    lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
    lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.h

Modified: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp?rev=189666&r1=189665&r2=189666&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp (original)
+++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp Fri Aug 30 08:11:30 2013
@@ -122,6 +122,24 @@ ProcessFreeBSD::Terminate()
 {
 }
 
+Error
+ProcessFreeBSD::DoDetach(bool keep_stopped)
+{
+    Error error;
+    if (keep_stopped)
+    {
+        error.SetErrorString("Detaching with keep_stopped true is not currently supported on FreeBSD.");
+        return error;
+    }
+
+    error = m_monitor->Detach(GetID());
+
+    if (error.Success())
+        SetPrivateState(eStateDetached);
+
+    return error;
+}
+
 bool
 ProcessFreeBSD::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)
 {

Modified: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h?rev=189666&r1=189665&r2=189666&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h (original)
+++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h Fri Aug 30 08:11:30 2013
@@ -54,6 +54,9 @@ public:
     ProcessFreeBSD(lldb_private::Target& target,
                    lldb_private::Listener &listener);
 
+    virtual lldb_private::Error
+    DoDetach(bool keep_stopped);
+
     virtual bool
     UpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list);
 

Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp?rev=189666&r1=189665&r2=189666&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp Fri Aug 30 08:11:30 2013
@@ -136,6 +136,35 @@ ProcessLinux::EnablePluginLogging(Stream
     return NULL;
 }
 
+Error
+ProcessLinux::DoDetach(bool keep_stopped)
+{
+    Error error;
+    if (keep_stopped)
+    {
+        // FIXME: If you want to implement keep_stopped,
+        // this would be the place to do it.
+        error.SetErrorString("Detaching with keep_stopped true is not currently supported on Linux.");
+        return error;
+    }
+
+    Mutex::Locker lock(m_thread_list.GetMutex());
+
+    uint32_t thread_count = m_thread_list.GetSize(false);
+    for (uint32_t i = 0; i < thread_count; ++i)
+    {
+        POSIXThread *thread = static_cast<POSIXThread*>(
+            m_thread_list.GetThreadAtIndex(i, false).get());
+        error = m_monitor->Detach(thread->GetID());
+    }
+
+    if (error.Success())
+        SetPrivateState(eStateDetached);
+
+    return error;
+}
+
+
 // ProcessPOSIX override
 void
 ProcessLinux::StopAllThreads(lldb::tid_t stop_tid)

Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h?rev=189666&r1=189665&r2=189666&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h Fri Aug 30 08:11:30 2013
@@ -54,6 +54,9 @@ public:
                  lldb_private::Listener &listener,
                  lldb_private::FileSpec *core_file);
 
+    virtual lldb_private::Error
+    DoDetach(bool keep_stopped);
+
     virtual bool
     UpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list);
 

Modified: lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp?rev=189666&r1=189665&r2=189666&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp Fri Aug 30 08:11:30 2013
@@ -319,34 +319,6 @@ ProcessPOSIX::DoHalt(bool &caused_stop)
 }
 
 Error
-ProcessPOSIX::DoDetach(bool keep_stopped)
-{
-    Error error;
-    if (keep_stopped)
-    {
-        // FIXME: If you want to implement keep_stopped,
-        // this would be the place to do it.
-        error.SetErrorString("Detaching with keep_stopped true is not currently supported on this platform.");
-        return error;
-    }
-
-    Mutex::Locker lock(m_thread_list.GetMutex());
-
-    uint32_t thread_count = m_thread_list.GetSize(false);
-    for (uint32_t i = 0; i < thread_count; ++i)
-    {
-        POSIXThread *thread = static_cast<POSIXThread*>(
-            m_thread_list.GetThreadAtIndex(i, false).get());
-        error = m_monitor->Detach(thread->GetID());
-    }
-
-    if (error.Success())
-        SetPrivateState(eStateDetached);
-
-    return error;
-}
-
-Error
 ProcessPOSIX::DoSignal(int signal)
 {
     Error error;

Modified: lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.h?rev=189666&r1=189665&r2=189666&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.h (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.h Fri Aug 30 08:11:30 2013
@@ -70,7 +70,7 @@ public:
     DoHalt(bool &caused_stop);
 
     virtual lldb_private::Error
-    DoDetach(bool keep_stopped);
+    DoDetach(bool keep_stopped) = 0;
 
     virtual lldb_private::Error
     DoSignal(int signal);





More information about the lldb-commits mailing list