Author: labath
Date: Thu Jul  7 10:46:00 2016
New Revision: 274763

URL: http://llvm.org/viewvc/llvm-project?rev=274763&view=rev
Log:
[LLGS] Work around an adb bug on Android <=M

On android M it can happen that we get a ETXTBSY, when we try to launch the 
inferior. Sleeping
and retrying should help us get more stable results.

Modified:
    lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=274763&r1=274762&r2=274763&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Thu Jul  7 
10:46:00 2016
@@ -561,6 +561,18 @@ NativeProcessLinux::ChildFunc(const Laun
     // Execute.  We should never return...
     execve(args.m_argv[0], const_cast<char *const *>(args.m_argv), 
const_cast<char *const *>(envp));
 
+    if (errno == ETXTBSY)
+    {
+        // On android M and earlier we can get this error because the adb 
deamon can hold a write
+        // handle on the executable even after it has finished uploading it. 
This state lasts
+        // only a short time and happens only when there are many concurrent 
adb commands being
+        // issued, such as when running the test suite. (The file remains open 
when someone does
+        // an "adb shell" command in the fork() child before it has had a 
chance to exec.) Since
+        // this state should clear up quickly, wait a while and then give it 
one more go.
+        usleep(10000);
+        execve(args.m_argv[0], const_cast<char *const *>(args.m_argv), 
const_cast<char *const *>(envp));
+    }
+
     // ...unless exec fails.  In which case we definitely need to end the 
child here.
     ExitChildAbnormally(eExecFailed);
 }


_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to