[Lldb-commits] [lldb] r163399 - in /lldb/trunk/source: API/SBTarget.cpp Plugins/Process/POSIX/ProcessPOSIX.cpp Plugins/Process/POSIX/ProcessPOSIX.h

Greg Clayton gclayton at apple.com
Fri Sep 7 10:51:47 PDT 2012


Author: gclayton
Date: Fri Sep  7 12:51:47 2012
New Revision: 163399

URL: http://llvm.org/viewvc/llvm-project?rev=163399&view=rev
Log:
Patch from Andrew Kaylor for linux:

The attached patch fixes a problem with performing an attach from the SBTarget API on Linux (and other systems that use ProcessPOSIX).
 
When Process::Attach was called from SBTarget, it resulted in a call to a form of the DoAttachWithID function that wasn't implemented in ProcessPOSIX, and so it fell back to the default implementation (which just returns an error).  It didn't seem necessary to use the attach_info parameter for this case, so I just implemented it as a call to the simpler version of the function.
 
In debugging this problem, I also found that SBTarget wasn't checking the return value from the Attach call, causing it to hang when the attach fails.


Modified:
    lldb/trunk/source/API/SBTarget.cpp
    lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
    lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.h

Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=163399&r1=163398&r2=163399&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Fri Sep  7 12:51:47 2012
@@ -957,10 +957,13 @@
                 attach_info.SetUserID(instance_info.GetEffectiveUserID());
             }
             error.SetError (process_sp->Attach (attach_info));            
-            // If we are doing synchronous mode, then wait for the
-            // process to stop!
-            if (target_sp->GetDebugger().GetAsyncExecution () == false)
+            if (error.Success())
+            {
+                // If we are doing synchronous mode, then wait for the
+                // process to stop!
+                if (target_sp->GetDebugger().GetAsyncExecution () == false)
                 process_sp->WaitForProcessToStop (NULL);
+            }
         }
         else
         {

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=163399&r1=163398&r2=163399&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp Fri Sep  7 12:51:47 2012
@@ -118,6 +118,12 @@
 }
 
 Error
+ProcessPOSIX::DoAttachToProcessWithID (lldb::pid_t pid,  const ProcessAttachInfo &attach_info)
+{
+    return DoAttachToProcessWithID(pid);
+}
+
+Error
 ProcessPOSIX::WillLaunch(Module* module)
 {
     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=163399&r1=163398&r2=163399&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.h (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.h Fri Sep  7 12:51:47 2012
@@ -49,6 +49,9 @@
     DoAttachToProcessWithID(lldb::pid_t pid);
 
     virtual lldb_private::Error
+    DoAttachToProcessWithID (lldb::pid_t pid, const lldb_private::ProcessAttachInfo &attach_info);
+
+    virtual lldb_private::Error
     DoLaunch (lldb_private::Module *exe_module, 
               const lldb_private::ProcessLaunchInfo &launch_info);
 





More information about the lldb-commits mailing list