summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
diff options
context:
space:
mode:
authorOleksiy Vyalov <ovyalov@google.com>2016-07-08 17:45:37 +0000
committerOleksiy Vyalov <ovyalov@google.com>2016-07-08 17:45:37 +0000
commitc6ac2e1e80098594620cb7d60c1c6552bbb2d49a (patch)
tree3a18128c0ad3f86a401ef5979dae621a087d553f /lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
parent4d3c21307c87a7b3b61ed432815222393de641c7 (diff)
downloadbcm5719-llvm-c6ac2e1e80098594620cb7d60c1c6552bbb2d49a.tar.gz
bcm5719-llvm-c6ac2e1e80098594620cb7d60c1c6552bbb2d49a.zip
Use shell cat command as a workaround if ADB stat cannot lookup a file.
http://reviews.llvm.org/D22081 llvm-svn: 274895
Diffstat (limited to 'lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp')
-rw-r--r--lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
index da57ae926b3..381795171d3 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -230,7 +230,31 @@ PlatformAndroid::GetFile (const FileSpec& source,
if (error.Fail ())
return error;
- return sync_service->PullFile (source_spec, destination);
+ uint32_t mode = 0, size = 0, mtime = 0;
+ error = sync_service->Stat(source_spec, mode, size, mtime);
+ if (error.Fail())
+ return error;
+
+ if (mode != 0)
+ return sync_service->PullFile(source_spec, destination);
+
+ auto source_file = source_spec.GetCString(false);
+
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log)
+ log->Printf("Got mode == 0 on '%s': try to get file via 'shell cat'", source_file);
+
+ if (strchr(source_file, '\'') != nullptr)
+ return Error("Doesn't support single-quotes in filenames");
+
+ // mode == 0 can signify that adbd cannot access the file
+ // due security constraints - try "cat ..." as a fallback.
+ AdbClient adb(m_device_id);
+
+ char cmd[PATH_MAX];
+ snprintf(cmd, sizeof(cmd), "cat '%s'", source_file);
+
+ return adb.ShellToFile(cmd, 60000 /* ms */, destination);
}
Error
OpenPOWER on IntegriCloud