<div dir="ltr">Hi Oleksiy,<div><br></div><div>This change caused some regression on android because in some case GetFile is called with a remote path relative to the current working directory selected through lldb and it isn't handled by adb. Please create a fix for it or revert this CL.</div><div><br></div><div>Thanks,</div><div>Tamas</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 28, 2015 at 6:42 PM, Oleksiy Vyalov <span dir="ltr"><<a href="mailto:ovyalov@google.com" target="_blank">ovyalov@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ovyalov<br>
Date: Thu May 28 12:42:48 2015<br>
New Revision: 238442<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D238442-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=MEqT8U_n7oNfuDW5NRbY3ZV384ZquXIYFPWmprwUdKM&m=O7PKfL1hOseO4LgrDtOWOlviAwZyXqVP1Apg60WzThY&s=hmnon72V1aHqW3lY4l8L9LLzUGyD9UAWxz6f-2j5AjM&e=" target="_blank">http://llvm.org/viewvc/llvm-project?rev=238442&view=rev</a><br>
Log:<br>
Refactor AdbClient and make PlatformAndroid::GetFile to use "adb pull".<br>
<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D10082&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=MEqT8U_n7oNfuDW5NRbY3ZV384ZquXIYFPWmprwUdKM&m=O7PKfL1hOseO4LgrDtOWOlviAwZyXqVP1Apg60WzThY&s=MuXRd5KNlLeb5ccx-qqCYARnJEVyKq29Cc_qlShm1k4&e=" target="_blank">http://reviews.llvm.org/D10082</a><br>
<br>
<br>
Modified:<br>
lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp<br>
lldb/trunk/source/Plugins/Platform/Android/AdbClient.h<br>
lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp<br>
lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h<br>
<br>
Modified: lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lldb_trunk_source_Plugins_Platform_Android_AdbClient.cpp-3Frev-3D238442-26r1-3D238441-26r2-3D238442-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=MEqT8U_n7oNfuDW5NRbY3ZV384ZquXIYFPWmprwUdKM&m=O7PKfL1hOseO4LgrDtOWOlviAwZyXqVP1Apg60WzThY&s=2sueW5zFgb4bo8GIh8o5i2MDfK2oeSlkJm_8P1RUz-s&e=" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp?rev=238442&r1=238441&r2=238442&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp (original)<br>
+++ lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp Thu May 28 12:42:48 2015<br>
@@ -250,23 +250,21 @@ AdbClient::SwitchDeviceTransport ()<br>
}<br>
<br>
Error<br>
-AdbClient::PullFile (const char *remote_file, const char *local_file)<br>
+AdbClient::PullFile (const FileSpec &remote_file, const FileSpec &local_file)<br>
{<br>
- auto error = SwitchDeviceTransport ();<br>
+ auto error = StartSync ();<br>
if (error.Fail ())<br>
- return Error ("Failed to switch to device transport: %s", error.AsCString ());<br>
-<br>
- error = Sync ();<br>
- if (error.Fail ())<br>
- return Error ("Sync failed: %s", error.AsCString ());<br>
+ return error;<br>
<br>
- llvm::FileRemover local_file_remover (local_file);<br>
+ const auto local_file_path = local_file.GetPath ();<br>
+ llvm::FileRemover local_file_remover (local_file_path.c_str ());<br>
<br>
- std::ofstream dst (local_file, std::ios::out | std::ios::binary);<br>
+ std::ofstream dst (local_file_path, std::ios::out | std::ios::binary);<br>
if (!dst.is_open ())<br>
- return Error ("Unable to open local file %s", local_file);<br>
+ return Error ("Unable to open local file %s", local_file_path.c_str());<br>
<br>
- error = SendSyncRequest ("RECV", strlen(remote_file), remote_file);<br>
+ const auto remote_file_path = remote_file.GetPath (false);<br>
+ error = SendSyncRequest ("RECV", remote_file_path.length (), remote_file_path.c_str ());<br>
if (error.Fail ())<br>
return error;<br>
<br>
@@ -286,22 +284,19 @@ AdbClient::PullFile (const char *remote_<br>
}<br>
<br>
Error<br>
-AdbClient::PushFile (const lldb_private::FileSpec& source, const lldb_private::FileSpec& destination)<br>
+AdbClient::PushFile (const FileSpec &local_file, const FileSpec &remote_file)<br>
{<br>
- auto error = SwitchDeviceTransport ();<br>
+ auto error = StartSync ();<br>
if (error.Fail ())<br>
- return Error ("Failed to switch to device transport: %s", error.AsCString ());<br>
-<br>
- error = Sync ();<br>
- if (error.Fail ())<br>
- return Error ("Sync failed: %s", error.AsCString ());<br>
+ return error;<br>
<br>
- std::ifstream src (source.GetPath().c_str(), std::ios::in | std::ios::binary);<br>
+ const auto local_file_path (local_file.GetPath ());<br>
+ std::ifstream src (local_file_path.c_str(), std::ios::in | std::ios::binary);<br>
if (!src.is_open ())<br>
- return Error ("Unable to open local file %s", source.GetPath().c_str());<br>
+ return Error ("Unable to open local file %s", local_file_path.c_str());<br>
<br>
std::stringstream file_description;<br>
- file_description << destination.GetPath(false).c_str() << "," << kDefaultMode;<br>
+ file_description << remote_file.GetPath(false).c_str() << "," << kDefaultMode;<br>
std::string file_description_str = file_description.str();<br>
error = SendSyncRequest ("SEND", file_description_str.length(), file_description_str.c_str());<br>
if (error.Fail ())<br>
@@ -315,14 +310,28 @@ AdbClient::PushFile (const lldb_private:<br>
if (error.Fail ())<br>
return Error ("Failed to send file chunk: %s", error.AsCString ());<br>
}<br>
- error = SendSyncRequest("DONE", source.GetModificationTime().seconds(), nullptr);<br>
+ error = SendSyncRequest("DONE", local_file.GetModificationTime().seconds(), nullptr);<br>
if (error.Fail ())<br>
return error;<br>
error = ReadResponseStatus();<br>
// If there was an error reading the source file, finish the adb file<br>
// transfer first so that adb isn't expecting any more data.<br>
if (src.bad())<br>
- return Error ("Failed read on %s", source.GetPath().c_str());<br>
+ return Error ("Failed read on %s", local_file_path.c_str());<br>
+ return error;<br>
+}<br>
+<br>
+Error<br>
+AdbClient::StartSync ()<br>
+{<br>
+ auto error = SwitchDeviceTransport ();<br>
+ if (error.Fail ())<br>
+ return Error ("Failed to switch to device transport: %s", error.AsCString ());<br>
+<br>
+ error = Sync ();<br>
+ if (error.Fail ())<br>
+ return Error ("Sync failed: %s", error.AsCString ());<br>
+<br>
return error;<br>
}<br>
<br>
<br>
Modified: lldb/trunk/source/Plugins/Platform/Android/AdbClient.h<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lldb_trunk_source_Plugins_Platform_Android_AdbClient.h-3Frev-3D238442-26r1-3D238441-26r2-3D238442-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=MEqT8U_n7oNfuDW5NRbY3ZV384ZquXIYFPWmprwUdKM&m=O7PKfL1hOseO4LgrDtOWOlviAwZyXqVP1Apg60WzThY&s=BJ3-oQaxB5REgJfGyIW1fEenewdrruax0hJd3Ob1zi0&e=" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/AdbClient.h?rev=238442&r1=238441&r2=238442&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Platform/Android/AdbClient.h (original)<br>
+++ lldb/trunk/source/Plugins/Platform/Android/AdbClient.h Thu May 28 12:42:48 2015<br>
@@ -25,6 +25,9 @@<br>
#include "lldb/Host/ConnectionFileDescriptor.h"<br>
<br>
namespace lldb_private {<br>
+<br>
+class FileSpec;<br>
+<br>
namespace platform_android {<br>
<br>
class AdbClient<br>
@@ -51,10 +54,10 @@ public:<br>
DeletePortForwarding (const uint16_t port);<br>
<br>
Error<br>
- PullFile (const char *remote_file, const char *local_file);<br>
+ PullFile (const FileSpec &remote_file, const FileSpec &local_file);<br>
<br>
Error<br>
- PushFile (const lldb_private::FileSpec& source, const lldb_private::FileSpec& destination);<br>
+ PushFile (const FileSpec &local_file, const FileSpec &remote_file);<br>
<br>
private:<br>
Error<br>
@@ -91,6 +94,9 @@ private:<br>
Sync ();<br>
<br>
Error<br>
+ StartSync ();<br>
+<br>
+ Error<br>
PullFileChunk (std::vector<char> &buffer, bool &eof);<br>
<br>
Error<br>
<br>
Modified: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lldb_trunk_source_Plugins_Platform_Android_PlatformAndroid.cpp-3Frev-3D238442-26r1-3D238441-26r2-3D238442-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=MEqT8U_n7oNfuDW5NRbY3ZV384ZquXIYFPWmprwUdKM&m=O7PKfL1hOseO4LgrDtOWOlviAwZyXqVP1Apg60WzThY&s=p1uzZs09iH9rpUR4m6O5jFFpnkid5Ta5AL-Q3nb3fbk&e=" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp?rev=238442&r1=238441&r2=238442&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp (original)<br>
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp Thu May 28 12:42:48 2015<br>
@@ -207,9 +207,21 @@ PlatformAndroid::ConnectRemote(Args& arg<br>
return error;<br>
}<br>
<br>
-lldb_private::Error<br>
-PlatformAndroid::PutFile (const lldb_private::FileSpec& source,<br>
- const lldb_private::FileSpec& destination,<br>
+Error<br>
+PlatformAndroid::GetFile (const FileSpec& source,<br>
+ const FileSpec& destination)<br>
+{<br>
+ if (!IsHost() && m_remote_platform_sp)<br>
+ {<br>
+ AdbClient adb (m_device_id);<br>
+ return adb.PullFile(source, destination);<br>
+ }<br>
+ return PlatformLinux::GetFile(source, destination);<br>
+}<br>
+<br>
+Error<br>
+PlatformAndroid::PutFile (const FileSpec& source,<br>
+ const FileSpec& destination,<br>
uint32_t uid,<br>
uint32_t gid)<br>
{<br>
@@ -237,6 +249,5 @@ PlatformAndroid::DownloadModuleSlice (co<br>
if (src_offset != 0)<br>
return Error ("Invalid offset - %" PRIu64, src_offset);<br>
<br>
- AdbClient adb (m_device_id);<br>
- return adb.PullFile (src_file_spec.GetPath (false).c_str (), dst_file_spec.GetPath ().c_str ());<br>
+ return GetFile (src_file_spec, dst_file_spec);<br>
}<br>
<br>
Modified: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lldb_trunk_source_Plugins_Platform_Android_PlatformAndroid.h-3Frev-3D238442-26r1-3D238441-26r2-3D238442-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=MEqT8U_n7oNfuDW5NRbY3ZV384ZquXIYFPWmprwUdKM&m=O7PKfL1hOseO4LgrDtOWOlviAwZyXqVP1Apg60WzThY&s=-2AzUBOWkTSXmLFtuELnkVCCsMCaS6rO8ZlC6kHHWVQ&e=" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h?rev=238442&r1=238441&r2=238442&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h (original)<br>
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h Thu May 28 12:42:48 2015<br>
@@ -64,9 +64,13 @@ namespace platform_android {<br>
Error<br>
ConnectRemote (Args& args) override;<br>
<br>
- lldb_private::Error<br>
- PutFile (const lldb_private::FileSpec& source,<br>
- const lldb_private::FileSpec& destination,<br>
+ Error<br>
+ GetFile (const FileSpec& source,<br>
+ const FileSpec& destination) override;<br>
+<br>
+ Error<br>
+ PutFile (const FileSpec& source,<br>
+ const FileSpec& destination,<br>
uint32_t uid = UINT32_MAX,<br>
uint32_t gid = UINT32_MAX) override;<br>
<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@cs.uiuc.edu">lldb-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits</a><br>
</blockquote></div><br></div>