summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
diff options
context:
space:
mode:
authorTamas Berghammer <tberghammer@google.com>2015-09-29 11:04:18 +0000
committerTamas Berghammer <tberghammer@google.com>2015-09-29 11:04:18 +0000
commit9d8dde8ce57fd89ad5eb09a1bfbeda162e199141 (patch)
tree006b0f42fe6175eac6e534bd0cd5a5dca54a138f /lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
parent740f9d79ca7ea90b4836424f841462e286a46f43 (diff)
downloadbcm5719-llvm-9d8dde8ce57fd89ad5eb09a1bfbeda162e199141.tar.gz
bcm5719-llvm-9d8dde8ce57fd89ad5eb09a1bfbeda162e199141.zip
Change oat symbolization code for android to work on non-rooted devices
On android when debugging an apk we run lldb-server as application user because the sell user (on non-rooted device) can't attach to an application. The problem is that "adb pull" will run as a shell user what can't access to files created by lldb-server because they will be owned by the application user. This CL changes the oat symbolization code to run "oatdump --symbolize" to generate an output what is owned by the shell user. Differential revision: http://reviews.llvm.org/D13162 llvm-svn: 248788
Diffstat (limited to 'lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp')
-rw-r--r--lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp35
1 files changed, 9 insertions, 26 deletions
diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
index 3d2546a1849..0d33c2b1290 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -325,33 +325,21 @@ PlatformAndroid::DownloadSymbolFile (const lldb::ModuleSP& module_sp,
if (module_sp->GetSectionList()->FindSectionByName(ConstString(".symtab")) != nullptr)
return Error("Symtab already available in the module");
- int status = 0;
- std::string tmpdir;
- StreamString command;
- command.Printf("mktemp --directory --tmpdir %s", GetWorkingDirectory().GetCString());
- Error error = RunShellCommand(command.GetData(),
- GetWorkingDirectory(),
- &status,
- nullptr,
- &tmpdir,
- 5 /* timeout (s) */);
+ AdbClient adb(m_device_id);
- if (error.Fail() || status != 0 || tmpdir.empty())
+ std::string tmpdir;
+ Error error = adb.Shell("mktemp --directory --tmpdir /data/local/tmp", 5000 /* ms */, &tmpdir);
+ if (error.Fail() || tmpdir.empty())
return Error("Failed to generate temporary directory on the device (%s)", error.AsCString());
tmpdir.erase(tmpdir.size() - 1); // Remove trailing new line
// Create file remover for the temporary directory created on the device
std::unique_ptr<std::string, std::function<void(std::string*)>> tmpdir_remover(
&tmpdir,
- [this](std::string* s) {
+ [this, &adb](std::string* s) {
StreamString command;
command.Printf("rm -rf %s", s->c_str());
- Error error = this->RunShellCommand(command.GetData(),
- GetWorkingDirectory(),
- nullptr,
- nullptr,
- nullptr,
- 5 /* timeout (s) */);
+ Error error = adb.Shell(command.GetData(), 5000 /* ms */, nullptr);
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
if (error.Fail())
@@ -363,17 +351,12 @@ PlatformAndroid::DownloadSymbolFile (const lldb::ModuleSP& module_sp,
symfile_platform_filespec.AppendPathComponent("symbolized.oat");
// Execute oatdump on the remote device to generate a file with symtab
- command.Clear();
+ StreamString command;
command.Printf("oatdump --symbolize=%s --output=%s",
module_sp->GetPlatformFileSpec().GetCString(false),
symfile_platform_filespec.GetCString(false));
- error = RunShellCommand(command.GetData(),
- GetWorkingDirectory(),
- &status,
- nullptr,
- nullptr,
- 60 /* timeout (s) */);
- if (error.Fail() || status != 0)
+ error = adb.Shell(command.GetData(), 60000 /* ms */, nullptr);
+ if (error.Fail())
return Error("Oatdump failed: %s", error.AsCString());
// Download the symbolfile from the remote device
OpenPOWER on IntegriCloud