From 3ea689b313d43355faa0e5ab68b26367ee30de83 Mon Sep 17 00:00:00 2001 From: Chaoren Lin Date: Fri, 1 May 2015 16:49:28 +0000 Subject: Support remote-android with multiple connected devices. Summary: This change introduces a new URL scheme for `platform connect`: ``` adb://device-id:port ``` Reviewers: vharron, tberghammer, clayborg, ovyalov Reviewed By: ovyalov Subscribers: tberghammer, lldb-commits Differential Revision: http://reviews.llvm.org/D9358 llvm-svn: 236321 --- .../Plugins/Platform/Android/PlatformAndroid.cpp | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp') diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp index 7bc3287d035..3bd628b263d 100644 --- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp +++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/Log.h" #include "lldb/Core/PluginManager.h" #include "lldb/Host/HostInfo.h" +#include "Utility/UriParser.h" // Project includes #include "AdbClient.h" @@ -171,9 +172,9 @@ PlatformAndroid::GetPluginName() } Error -PlatformAndroid::ConnectRemote (Args& args) +PlatformAndroid::ConnectRemote(Args& args) { - m_device_id.clear (); + m_device_id.clear(); if (IsHost()) { @@ -183,17 +184,25 @@ PlatformAndroid::ConnectRemote (Args& args) if (!m_remote_platform_sp) m_remote_platform_sp = PlatformSP(new PlatformAndroidRemoteGDBServer()); - auto error = PlatformLinux::ConnectRemote (args); - if (error.Success ()) + int port; + std::string scheme, host, path; + const char *url = args.GetArgumentAtIndex(0); + if (!url) + return Error("URL is null."); + if (!UriParser::Parse(url, scheme, host, port, path)) + return Error("Invalid URL: %s", url); + if (scheme == "adb") + m_device_id = host; + + auto error = PlatformLinux::ConnectRemote(args); + if (error.Success()) { - // Fetch the device list from ADB and if only 1 device found then use that device - // TODO: Handle the case when more device is available AdbClient adb; - error = AdbClient::CreateByDeviceID (nullptr, adb); - if (error.Fail ()) + error = AdbClient::CreateByDeviceID(m_device_id, adb); + if (error.Fail()) return error; - m_device_id = adb.GetDeviceID (); + m_device_id = adb.GetDeviceID(); } return error; } -- cgit v1.2.3