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 {
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 {
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits