diff options
author | Tamas Berghammer <tberghammer@google.com> | 2015-02-12 18:13:44 +0000 |
---|---|---|
committer | Tamas Berghammer <tberghammer@google.com> | 2015-02-12 18:13:44 +0000 |
commit | 00e305d281502a9b4d90dc02aa4c7dad819a9083 (patch) | |
tree | 39a3796bf30454182b8947b30e29e42f6eb3db0d /lldb/source/Host/android | |
parent | 97eac4089aa5e249143fbc7aa24984242eeea54b (diff) | |
download | bcm5719-llvm-00e305d281502a9b4d90dc02aa4c7dad819a9083.tar.gz bcm5719-llvm-00e305d281502a9b4d90dc02aa4c7dad819a9083.zip |
Create new platform: remote-android
* Create new platform plugin for lldb
* Create HostInfo class for android
* Create ProcessLauncher for android
Differential Revision: http://reviews.llvm.org/D7584
llvm-svn: 228943
Diffstat (limited to 'lldb/source/Host/android')
-rw-r--r-- | lldb/source/Host/android/HostInfoAndroid.cpp | 28 | ||||
-rw-r--r-- | lldb/source/Host/android/ProcessLauncherAndroid.cpp | 59 |
2 files changed, 87 insertions, 0 deletions
diff --git a/lldb/source/Host/android/HostInfoAndroid.cpp b/lldb/source/Host/android/HostInfoAndroid.cpp new file mode 100644 index 00000000000..bc546e537b8 --- /dev/null +++ b/lldb/source/Host/android/HostInfoAndroid.cpp @@ -0,0 +1,28 @@ +//===-- HostInfoAndroid.cpp -------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Host/android/HostInfoAndroid.h" +#include "lldb/Host/linux/HostInfoLinux.h" + +using namespace lldb_private; + +void +HostInfoAndroid::ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64) +{ + HostInfoLinux::ComputeHostArchitectureSupport(arch_32, arch_64); + + if (arch_32.IsValid()) + { + arch_32.GetTriple().setEnvironment(llvm::Triple::Android); + } + if (arch_64.IsValid()) + { + arch_64.GetTriple().setEnvironment(llvm::Triple::Android); + } +} diff --git a/lldb/source/Host/android/ProcessLauncherAndroid.cpp b/lldb/source/Host/android/ProcessLauncherAndroid.cpp new file mode 100644 index 00000000000..f90ba2fe41d --- /dev/null +++ b/lldb/source/Host/android/ProcessLauncherAndroid.cpp @@ -0,0 +1,59 @@ +//===-- ProcessLauncherAndroid.cpp ------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Host/Host.h" +#include "lldb/Host/HostProcess.h" +#include "lldb/Host/android/ProcessLauncherAndroid.h" + +#include "lldb/Target/ProcessLaunchInfo.h" + +#include <limits.h> + +using namespace lldb; +using namespace lldb_private; + +HostProcess +ProcessLauncherAndroid::LaunchProcess(const ProcessLaunchInfo &launch_info, Error &error) +{ + // TODO: Handle other launch parameters specified in launc_info + + char exe_path[PATH_MAX]; + launch_info.GetExecutableFile().GetPath(exe_path, sizeof(exe_path)); + + const size_t err_len = 1024; + char err_str[err_len]; + + lldb::pid_t pid = ::fork (); + if (pid < 0) + { + // Fork failed + error.SetErrorStringWithFormat("Fork failed with error message: %s", strerror(errno)); + return HostProcess(LLDB_INVALID_PROCESS_ID); + } + else if (pid == 0) + { + // Child process + const char **argv = launch_info.GetArguments().GetConstArgumentVector(); + const char **envp = launch_info.GetEnvironmentEntries().GetConstArgumentVector(); + const char *working_dir = launch_info.GetWorkingDirectory(); + + if (working_dir != nullptr && working_dir[0]) + { + if (::chdir(working_dir) != 0) + exit(-1); + } + + execve(argv[0], + const_cast<char *const *>(argv), + const_cast<char *const *>(envp)); + exit(-1); + } + + return HostProcess(pid); +} |