LLGS Android target support - for Andy Chien : http://reviews.llvm.org/D6166
llvm-svn: 221570
diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp
index 50513af..c3c7783 100644
--- a/lldb/source/Host/common/File.cpp
+++ b/lldb/source/Host/common/File.cpp
@@ -896,7 +896,7 @@
{
m_is_interactive = eLazyBoolNo;
m_is_real_terminal = eLazyBoolNo;
-#ifdef _WIN32
+#if (defined(_WIN32) || defined(__ANDROID_NDK__))
if (_isatty(fd))
{
m_is_interactive = eLazyBoolYes;
diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp
index 33729ab..c6a1b6e 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -30,7 +30,7 @@
#endif
#if defined (__linux__) || defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__) || defined(__NetBSD__)
-#ifndef __ANDROID__
+#if !defined(__ANDROID__) && !defined(__ANDROID_NDK__)
#include <spawn.h>
#endif
#include <sys/wait.h>
@@ -111,7 +111,7 @@
return ThreadLauncher::LaunchThread(thread_name, MonitorChildProcessThreadFunction, info_ptr, NULL);
}
-#ifndef __ANDROID__
+#if !defined(__ANDROID__) && !defined(__ANDROID_NDK__)
//------------------------------------------------------------------
// Scoped class that will disable thread canceling when it is
// constructed, and exception safely restore the previous value it
@@ -126,7 +126,6 @@
int err = ::pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &m_old_state);
if (err != 0)
m_old_state = -1;
-
}
~ScopedPThreadCancelDisabler()
@@ -139,7 +138,7 @@
private:
int m_old_state; // Save the old cancelability state.
};
-#endif
+#endif // __ANDROID_NDK__
static thread_result_t
MonitorChildProcessThreadFunction (void *arg)
@@ -173,15 +172,14 @@
log->Printf("%s ::wait_pid (pid = %" PRIi32 ", &status, options = %i)...", function, pid, options);
// Wait for all child processes
-#ifndef __ANDROID__
+#if !defined(__ANDROID__) && !defined(__ANDROID_NDK__)
::pthread_testcancel ();
#endif
// Get signals from all children with same process group of pid
const ::pid_t wait_pid = ::waitpid (pid, &status, options);
-#ifndef __ANDROID__
+#if !defined(__ANDROID__) && !defined(__ANDROID_NDK__)
::pthread_testcancel ();
#endif
-
if (wait_pid == -1)
{
if (errno == EINTR)
@@ -226,7 +224,7 @@
// Scope for pthread_cancel_disabler
{
-#ifndef __ANDROID__
+#if !defined(__ANDROID__) && !defined(__ANDROID_NDK__)
ScopedPThreadCancelDisabler pthread_cancel_disabler;
#endif
@@ -316,6 +314,8 @@
return thread_self;
#elif defined(__FreeBSD__)
return lldb::tid_t(pthread_getthreadid_np());
+#elif defined(__ANDROID_NDK__)
+ return lldb::tid_t(gettid());
#elif defined(__linux__)
return lldb::tid_t(syscall(SYS_gettid));
#else
@@ -456,7 +456,7 @@
Host::GetModuleFileSpecForHostAddress (const void *host_addr)
{
FileSpec module_filespec;
-#ifndef __ANDROID__
+#if !defined(__ANDROID__) && !defined(__ANDROID_NDK__)
Dl_info info;
if (::dladdr (host_addr, &info))
{
@@ -694,14 +694,13 @@
// systems
#if defined (__APPLE__) || defined (__linux__) || defined (__FreeBSD__) || defined (__GLIBC__) || defined(__NetBSD__)
-
// this method needs to be visible to macosx/Host.cpp and
// common/Host.cpp.
short
Host::GetPosixspawnFlags(const ProcessLaunchInfo &launch_info)
{
-#ifndef __ANDROID__
+#if !defined(__ANDROID__) && !defined(__ANDROID_NDK__)
short flags = POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK;
#if defined (__APPLE__)
@@ -745,7 +744,7 @@
#endif // #if defined (__APPLE__)
return flags;
#else
- assert(false *&& "Host::GetPosixspawnFlags() not supported on Android");
+ assert(false && "Host::GetPosixspawnFlags() not supported on Android");
return 0;
#endif
}
@@ -754,7 +753,7 @@
Host::LaunchProcessPosixSpawn(const char *exe_path, const ProcessLaunchInfo &launch_info, lldb::pid_t &pid)
{
Error error;
-#ifndef __ANDROID__
+#if !defined(__ANDROID__) && !defined(__ANDROID_NDK__)
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_HOST | LIBLLDB_LOG_PROCESS));
posix_spawnattr_t attr;
@@ -954,7 +953,7 @@
bool
Host::AddPosixSpawnFileAction(void *_file_actions, const FileAction *info, Log *log, Error &error)
{
-#ifndef __ANDROID__
+#if !defined(__ANDROID__) && !defined(__ANDROID_NDK__)
if (info == NULL)
return false;
@@ -1022,7 +1021,6 @@
return false;
#endif
}
-
#endif // LaunchProcedssPosixSpawn: Apple, Linux, FreeBSD and other GLIBC systems
#if defined(__linux__) || defined(__FreeBSD__) || defined(__GLIBC__) || defined(__NetBSD__) || defined(_WIN32)
@@ -1049,11 +1047,9 @@
return error;
}
-
#endif // defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
#ifndef _WIN32
-
void
Host::Kill(lldb::pid_t pid, int signo)
{
diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp
index e0c3694..ba99bdf 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -18,6 +18,14 @@
#include "lldb/Host/TimeValue.h"
#include "lldb/Interpreter/Args.h"
+#ifdef __ANDROID_NDK__
+#include <linux/tcp.h>
+#include <bits/error_constants.h>
+#include <asm-generic/errno-base.h>
+#include <errno.h>
+#include <arpa/inet.h>
+#endif
+
#ifndef LLDB_DISABLE_POSIX
#include <arpa/inet.h>
#include <netdb.h>