[Lldb-commits] [PATCH] D22052: Respect `ANDROID_SERIAL` environment variable used by ADB
Luke Drummond via lldb-commits
lldb-commits at lists.llvm.org
Wed Jul 6 09:51:20 PDT 2016
ldrumm created this revision.
ldrumm added reviewers: tberghammer, ovyalov.
ldrumm added a subscriber: lldb-commits.
ldrumm set the repository for this revision to rL LLVM.
Herald added subscribers: srhines, danalbert, tberghammer.
Respect `ANDROID_SERIAL` environment variable used by ADB
When multiple Android devices are attached, the default behaviour of ADB
is to resolve a device number based on the presence of ANDROID_SERIAL if
the serial number is not explicitly passed by the `-s` parameter. This patch
emulates that behaviour in lldb's ADB platform connector
Repository:
rL LLVM
http://reviews.llvm.org/D22052
Files:
source/Plugins/Platform/Android/AdbClient.cpp
Index: source/Plugins/Platform/Android/AdbClient.cpp
===================================================================
--- source/Plugins/Platform/Android/AdbClient.cpp
+++ source/Plugins/Platform/Android/AdbClient.cpp
@@ -24,6 +24,7 @@
#include <limits.h>
+#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <sstream>
@@ -66,10 +67,15 @@
if (device_id.empty())
{
if (connect_devices.size() != 1)
- return Error("Expected a single connected device, got instead %" PRIu64,
- static_cast<uint64_t>(connect_devices.size()));
-
- adb.SetDeviceID(connect_devices.front());
+ {
+ if (const char *android_serial = std::getenv("ANDROID_SERIAL"))
+ adb.SetDeviceID(android_serial);
+ else
+ return Error("Expected a single connected device, got instead %" PRIu64,
+ static_cast<uint64_t>(connect_devices.size()));
+ }
+ else
+ adb.SetDeviceID(connect_devices.front());
}
else
{
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22052.62896.patch
Type: text/x-patch
Size: 1079 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160706/1c482942/attachment.bin>
More information about the lldb-commits
mailing list