aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2016-07-07 15:46:00 +0000
committerPavel Labath <labath@google.com>2016-07-07 15:46:00 +0000
commitca92aed5dc6301ff1bf642fdc44d8b344106e98a (patch)
treede1bec9e15c46b6015fcec1fb014a667285116b0 /lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
parent613cce835f1f8ed58a3f116ae979ee196ca826b8 (diff)
downloadllvm-ca92aed5dc6301ff1bf642fdc44d8b344106e98a.zip
llvm-ca92aed5dc6301ff1bf642fdc44d8b344106e98a.tar.gz
llvm-ca92aed5dc6301ff1bf642fdc44d8b344106e98a.tar.bz2
[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. llvm-svn: 274763
Diffstat (limited to 'lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp')
-rw-r--r--lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index bbd24ea..eb7b07b 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -561,6 +561,18 @@ NativeProcessLinux::ChildFunc(const LaunchArgs &args)
// 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);
}