diff options
author | Chaoren Lin <chaorenl@google.com> | 2015-05-01 16:49:28 +0000 |
---|---|---|
committer | Chaoren Lin <chaorenl@google.com> | 2015-05-01 16:49:28 +0000 |
commit | 3ea689b313d43355faa0e5ab68b26367ee30de83 (patch) | |
tree | 66b135a8d1e48bd7155a47c2f725ead721816df9 /lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp | |
parent | ec53482aeff13b47672f2a19e499e43daf272f77 (diff) | |
download | bcm5719-llvm-3ea689b313d43355faa0e5ab68b26367ee30de83.tar.gz bcm5719-llvm-3ea689b313d43355faa0e5ab68b26367ee30de83.zip |
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
Diffstat (limited to 'lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp')
-rw-r--r-- | lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
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; } |