From c6ac2e1e80098594620cb7d60c1c6552bbb2d49a Mon Sep 17 00:00:00 2001 From: Oleksiy Vyalov Date: Fri, 8 Jul 2016 17:45:37 +0000 Subject: Use shell cat command as a workaround if ADB stat cannot lookup a file. http://reviews.llvm.org/D22081 llvm-svn: 274895 --- .../Plugins/Platform/Android/PlatformAndroid.cpp | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (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 da57ae926b35..381795171d36 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 -- cgit v1.2.3