From 8da0bf3b7cf3670095d7ce9eac885dfc5976720e Mon Sep 17 00:00:00 2001 From: Shawn Best Date: Sat, 8 Nov 2014 01:41:49 +0000 Subject: [PATCH] LLGS Android target support - for Andy Chien : http://reviews.llvm.org/D6166 llvm-svn: 221570 --- lldb/CMakeLists.txt | 22 ++- lldb/include/lldb/Core/RegularExpression.h | 3 + lldb/include/lldb/Host/Config.h | 4 + lldb/include/lldb/Host/Editline.h | 4 +- lldb/include/lldb/lldb-private.h | 4 + lldb/scripts/Python/modules/CMakeLists.txt | 2 +- lldb/source/CMakeLists.txt | 176 +-------------------- lldb/source/Core/ConnectionSharedMemory.cpp | 2 + .../DataFormatters/CXXFormatterFunctions.cpp | 3 + lldb/source/Host/CMakeLists.txt | 28 +++- lldb/source/Host/common/File.cpp | 2 +- lldb/source/Host/common/Host.cpp | 30 ++-- lldb/source/Host/common/Socket.cpp | 8 + lldb/source/Host/linux/Host.cpp | 3 + .../BSD-Archive/ObjectContainerBSDArchive.cpp | 2 +- .../Plugins/Platform/Linux/PlatformLinux.cpp | 4 +- .../Plugins/Process/Linux/NativeProcessLinux.cpp | 7 +- .../Plugins/Process/Linux/ProcessMonitor.cpp | 7 +- .../RegisterContextMacOSXFrameBackchain.cpp | 2 +- lldb/source/Utility/PseudoTerminal.cpp | 2 + lldb/tools/CMakeLists.txt | 2 + lldb/tools/driver/Driver.cpp | 2 + lldb/tools/driver/Platform.h | 14 +- lldb/tools/lldb-gdbserver/CMakeLists.txt | 30 +++- 24 files changed, 143 insertions(+), 220 deletions(-) diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt index 2decf16..4a0f996 100644 --- a/lldb/CMakeLists.txt +++ b/lldb/CMakeLists.txt @@ -7,9 +7,15 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) set(LLDB_DEFAULT_ENABLE_PYTHON_SCRIPTS_SWIG_API_GENERATION 1) endif() else() - set(LLDB_DEFAULT_DISABLE_PYTHON 0) - set(LLDB_DEFAULT_DISABLE_CURSES 0) - set(LLDB_DEFAULT_ENABLE_PYTHON_SCRIPTS_SWIG_API_GENERATION 0) + if ( __ANDROID_NDK__ ) + set(LLDB_DEFAULT_DISABLE_PYTHON 1) + set(LLDB_DEFAULT_DISABLE_CURSES 1) + set(LLDB_DEFAULT_ENABLE_PYTHON_SCRIPTS_SWIG_API_GENERATION 0) + else() + set(LLDB_DEFAULT_DISABLE_PYTHON 0) + set(LLDB_DEFAULT_DISABLE_CURSES 0) + set(LLDB_DEFAULT_ENABLE_PYTHON_SCRIPTS_SWIG_API_GENERATION 0) + endif() endif() set(LLDB_DISABLE_PYTHON ${LLDB_DEFAULT_DISABLE_PYTHON} CACHE BOOL "Disables the Python scripting integration.") @@ -115,8 +121,14 @@ macro(add_lldb_definitions) endmacro(add_lldb_definitions) if (NOT LLDB_DISABLE_PYTHON) - find_package(PythonLibs REQUIRED) - include_directories(${PYTHON_INCLUDE_DIRS}) + if(UNIX) + # This is necessary for crosscompile on Ubuntu 14.04 64bit. Need a proper fix. + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") + endif() + endif() + find_package(PythonLibs REQUIRED) + include_directories(${PYTHON_INCLUDE_DIRS}) endif() include_directories(../clang/include) diff --git a/lldb/include/lldb/Core/RegularExpression.h b/lldb/include/lldb/Core/RegularExpression.h index 8e36811..00d8310 100644 --- a/lldb/include/lldb/Core/RegularExpression.h +++ b/lldb/include/lldb/Core/RegularExpression.h @@ -39,6 +39,9 @@ inline void regfree(llvm_regex_t * a) } #else +#if __ANDROID_NDK__ +#include +#endif #include #endif #include diff --git a/lldb/include/lldb/Host/Config.h b/lldb/include/lldb/Host/Config.h index af6b98a..7872eb9 100644 --- a/lldb/include/lldb/Host/Config.h +++ b/lldb/include/lldb/Host/Config.h @@ -14,6 +14,10 @@ #include "lldb/Host/macosx/Config.h" +#elif defined(__ANDROID_NDK__) + +#include "lldb/Host/android/Config.h" + #elif defined(__linux__) || defined(__GNU__) #include "lldb/Host/linux/Config.h" diff --git a/lldb/include/lldb/Host/Editline.h b/lldb/include/lldb/Host/Editline.h index 58c091a..5f50ab6 100644 --- a/lldb/include/lldb/Host/Editline.h +++ b/lldb/include/lldb/Host/Editline.h @@ -14,11 +14,13 @@ #include "lldb/lldb-private.h" #include -#ifdef _WIN32 +#if defined(_WIN32) #include "lldb/Host/windows/editlinewin.h" #else +#if !defined(__ANDROID_NDK__) #include #endif +#endif #include #include diff --git a/lldb/include/lldb/lldb-private.h b/lldb/include/lldb/lldb-private.h index 05b2c4f..bbd9743 100644 --- a/lldb/include/lldb/lldb-private.h +++ b/lldb/include/lldb/lldb-private.h @@ -16,6 +16,10 @@ #include "lldb/Host/windows/win32.h" #endif +#ifdef __ANDROID_NDK__ +#include "lldb/Host/android/Android.h" +#endif + #include "lldb/lldb-public.h" #include "lldb/lldb-private-enumerations.h" #include "lldb/lldb-private-interfaces.h" diff --git a/lldb/scripts/Python/modules/CMakeLists.txt b/lldb/scripts/Python/modules/CMakeLists.txt index 13e65ee..282320d3 100644 --- a/lldb/scripts/Python/modules/CMakeLists.txt +++ b/lldb/scripts/Python/modules/CMakeLists.txt @@ -1,4 +1,4 @@ # build the Python readline suppression module only on Linux -if (CMAKE_SYSTEM_NAME MATCHES "Linux") +if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT __ANDROID_NDK__) add_subdirectory(readline) endif() diff --git a/lldb/source/CMakeLists.txt b/lldb/source/CMakeLists.txt index 9996257..5e2ac8b 100644 --- a/lldb/source/CMakeLists.txt +++ b/lldb/source/CMakeLists.txt @@ -31,182 +31,8 @@ add_subdirectory(Symbol) add_subdirectory(Target) add_subdirectory(Utility) -set( LLDB_USED_LIBS - lldbBreakpoint - lldbCommands - lldbDataFormatters - lldbHost - lldbCore - lldbExpression - lldbInterpreter - lldbSymbol - lldbTarget - lldbUtility +include(../cmake/LLDBDependencies.cmake) - # Plugins - lldbPluginDisassemblerLLVM - lldbPluginSymbolFileDWARF - lldbPluginSymbolFileSymtab - lldbPluginDynamicLoaderStatic - lldbPluginDynamicLoaderPosixDYLD - lldbPluginDynamicLoaderHexagonDYLD - - lldbPluginObjectFileMachO - lldbPluginObjectFileELF - lldbPluginObjectFileJIT - lldbPluginSymbolVendorELF - lldbPluginObjectContainerBSDArchive - lldbPluginObjectContainerMachOArchive - lldbPluginProcessGDBRemote - lldbPluginProcessMachCore - lldbPluginProcessUtility - lldbPluginPlatformGDB - lldbPluginPlatformFreeBSD - lldbPluginPlatformKalimba - lldbPluginPlatformLinux - lldbPluginPlatformPOSIX - lldbPluginPlatformWindows - lldbPluginObjectFileMachO - lldbPluginObjectContainerMachOArchive - lldbPluginObjectContainerBSDArchive - lldbPluginPlatformMacOSX - lldbPluginDynamicLoaderMacOSXDYLD - lldbPluginUnwindAssemblyInstEmulation - lldbPluginUnwindAssemblyX86 - lldbPluginAppleObjCRuntime - lldbPluginCXXItaniumABI - lldbPluginABIMacOSX_arm - lldbPluginABIMacOSX_arm64 - lldbPluginABIMacOSX_i386 - lldbPluginABISysV_x86_64 - lldbPluginABISysV_hexagon - lldbPluginABISysV_ppc - lldbPluginABISysV_ppc64 - lldbPluginInstructionARM - lldbPluginInstructionARM64 - lldbPluginObjectFilePECOFF - lldbPluginOSPython - lldbPluginMemoryHistoryASan - lldbPluginInstrumentationRuntimeAddressSanitizer - ) - -# Need to export the API in the liblldb.dll for Windows -# The lldbAPI source files are added directly in liblldb -if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows" ) - list(APPEND LLDB_USED_LIBS - lldbAPI - ) -endif () - -# Windows-only libraries -if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) - list(APPEND LLDB_USED_LIBS - lldbPluginProcessWindows - lldbPluginProcessElfCore - lldbPluginJITLoaderGDB - Ws2_32 - ) -endif () - -# Linux-only libraries -if ( CMAKE_SYSTEM_NAME MATCHES "Linux" ) - list(APPEND LLDB_USED_LIBS - lldbPluginProcessLinux - lldbPluginProcessPOSIX - lldbPluginProcessElfCore - lldbPluginJITLoaderGDB - ) -endif () - -# FreeBSD-only libraries -if ( CMAKE_SYSTEM_NAME MATCHES "FreeBSD" ) - list(APPEND LLDB_USED_LIBS - lldbPluginProcessFreeBSD - lldbPluginProcessPOSIX - lldbPluginProcessElfCore - lldbPluginJITLoaderGDB - ) -endif () - -# Darwin-only libraries -if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" ) - set(LLDB_VERS_GENERATED_FILE ${LLDB_BINARY_DIR}/source/LLDB_vers.c) - add_custom_command(OUTPUT ${LLDB_VERS_GENERATED_FILE} - COMMAND ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl - ${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj liblldb_core - > ${LLDB_VERS_GENERATED_FILE}) - - set_source_files_properties(${LLDB_VERS_GENERATED_FILE} PROPERTIES GENERATED 1) - list(APPEND LLDB_USED_LIBS - lldbPluginDynamicLoaderDarwinKernel - lldbPluginProcessMacOSXKernel - lldbPluginSymbolVendorMacOSX - lldbPluginSystemRuntimeMacOSX - lldbPluginProcessElfCore - lldbPluginJITLoaderGDB - ) -endif() - -set( CLANG_USED_LIBS - clangAnalysis - clangAST - clangBasic - clangCodeGen - clangDriver - clangEdit - clangFrontend - clangLex - clangParse - clangRewrite - clangRewriteFrontend - clangSema - clangSerialization - ) - -set(LLDB_SYSTEM_LIBS) -if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows") - list(APPEND LLDB_SYSTEM_LIBS edit panel ncurses) -endif() -# On FreeBSD backtrace() is provided by libexecinfo, not libc. -if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") - list(APPEND LLDB_SYSTEM_LIBS execinfo) -endif() - -if (NOT LLDB_DISABLE_PYTHON) - list(APPEND LLDB_SYSTEM_LIBS ${PYTHON_LIBRARIES}) -endif() - -list(APPEND LLDB_SYSTEM_LIBS ${system_libs}) - -set( LLVM_LINK_COMPONENTS - ${LLVM_TARGETS_TO_BUILD} - interpreter - asmparser - bitreader - bitwriter - codegen - ipo - selectiondag - bitreader - mc - mcjit - core - mcdisassembler - executionengine - option - ) - - -if ( NOT LLDB_DISABLE_PYTHON ) - set(LLDB_WRAP_PYTHON ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp) - - set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1) - if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND - NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") - set_property(SOURCE ${LLDB_WRAP_PYTHON} - APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-sequence-point") - endif () -endif() set(SHARED_LIBRARY 1) if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) diff --git a/lldb/source/Core/ConnectionSharedMemory.cpp b/lldb/source/Core/ConnectionSharedMemory.cpp index 5db3d68..1cbee20 100644 --- a/lldb/source/Core/ConnectionSharedMemory.cpp +++ b/lldb/source/Core/ConnectionSharedMemory.cpp @@ -6,6 +6,7 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +#ifndef __ANDROID_NDK__ #include "lldb/Core/ConnectionSharedMemory.h" @@ -156,3 +157,4 @@ ConnectionSharedMemory::Open (bool create, const char *name, size_t size, Error return eConnectionStatusError; } +#endif // __ANDROID_NDK__ diff --git a/lldb/source/DataFormatters/CXXFormatterFunctions.cpp b/lldb/source/DataFormatters/CXXFormatterFunctions.cpp index ad040bb..2a8ca2d 100644 --- a/lldb/source/DataFormatters/CXXFormatterFunctions.cpp +++ b/lldb/source/DataFormatters/CXXFormatterFunctions.cpp @@ -27,6 +27,9 @@ #include "lldb/Utility/ProcessStructReader.h" #include +#if __ANDROID_NDK__ +#include +#endif using namespace lldb; using namespace lldb_private; diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt index 85211f9..e77b535 100644 --- a/lldb/source/Host/CMakeLists.txt +++ b/lldb/source/Host/CMakeLists.txt @@ -5,7 +5,6 @@ endmacro() add_host_subdirectory(common common/Condition.cpp - common/Editline.cpp common/File.cpp common/FileCache.cpp common/FileSpec.cpp @@ -33,6 +32,12 @@ add_host_subdirectory(common common/TimeValue.cpp ) +if (NOT __ANDROID_NDK__) +add_host_subdirectory(common + common/Editline.cpp + ) +endif() + add_host_subdirectory(posix posix/ConnectionFileDescriptorPosix.cpp ) @@ -81,12 +86,21 @@ else() ) elseif (CMAKE_SYSTEM_NAME MATCHES "Linux") - add_host_subdirectory(linux - linux/Host.cpp - linux/HostInfoLinux.cpp - linux/HostThreadLinux.cpp - linux/ThisThread.cpp - ) + if (__ANDROID_NDK__) + add_host_subdirectory(android + linux/Host.cpp + linux/HostInfoLinux.cpp + linux/HostThreadLinux.cpp + linux/ThisThread.cpp + ) + else() + add_host_subdirectory(linux + linux/Host.cpp + linux/HostInfoLinux.cpp + linux/HostThreadLinux.cpp + linux/ThisThread.cpp + ) + endif() elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") add_host_subdirectory(freebsd freebsd/Host.cpp 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 @@ File::CalculateInteractiveAndTerminal () { 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 #endif #include @@ -111,7 +111,7 @@ Host::StartMonitoringChildProcess(Host::MonitorChildProcessCallback callback, vo 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 @@ public: int err = ::pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &m_old_state); if (err != 0) m_old_state = -1; - } ~ScopedPThreadCancelDisabler() @@ -139,7 +138,7 @@ public: 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 @@ MonitorChildProcessThreadFunction (void *arg) 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 @@ MonitorChildProcessThreadFunction (void *arg) // Scope for pthread_cancel_disabler { -#ifndef __ANDROID__ +#if !defined(__ANDROID__) && !defined(__ANDROID_NDK__) ScopedPThreadCancelDisabler pthread_cancel_disabler; #endif @@ -316,6 +314,8 @@ Host::GetCurrentThreadID() 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 @@ FileSpec 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 @@ Host::RunShellCommand (const char *command, // 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 @@ Host::GetPosixspawnFlags(const ProcessLaunchInfo &launch_info) #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 @@ Error 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 @@ Host::LaunchProcessPosixSpawn(const char *exe_path, const ProcessLaunchInfo &lau 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 @@ Host::AddPosixSpawnFileAction(void *_file_actions, const FileAction *info, Log * 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 @@ Host::LaunchProcess (ProcessLaunchInfo &launch_info) 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 +#include +#include +#include +#include +#endif + #ifndef LLDB_DISABLE_POSIX #include #include diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp index 175624d..cd2d481 100644 --- a/lldb/source/Host/linux/Host.cpp +++ b/lldb/source/Host/linux/Host.cpp @@ -26,6 +26,9 @@ #include "lldb/Target/Process.h" #include "lldb/Host/Host.h" +#ifdef __ANDROID_NDK__ +#include "lldb/Host/android/Android.h" +#endif #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" diff --git a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp index 0263c23..1e2a0c7 100644 --- a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp +++ b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp @@ -9,7 +9,7 @@ #include "ObjectContainerBSDArchive.h" -#ifdef _WIN32 +#if defined(_WIN32) || defined(__ANDROID_NDK__) // Defines from ar, missing on Windows #define ARMAG "!\n" #define SARMAG 8 diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp index 7dc0a20..1519c5b 100644 --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -820,7 +820,7 @@ PlatformLinux::LaunchNativeProcess ( lldb_private::NativeProcessProtocol::NativeDelegate &native_delegate, NativeProcessProtocolSP &process_sp) { -#if !defined(__linux__) +#if !defined(__linux__) || defined(__ANDROID_NDK__) return Error("only implemented on Linux hosts"); #else if (!IsHost ()) @@ -857,7 +857,7 @@ PlatformLinux::AttachNativeProcess (lldb::pid_t pid, lldb_private::NativeProcessProtocol::NativeDelegate &native_delegate, NativeProcessProtocolSP &process_sp) { -#if !defined(__linux__) +#if !defined(__linux__) || defined(__ANDROID_NDK__) return Error("only implemented on Linux hosts"); #else if (!IsHost ()) diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp index 2810b70..abda9ba 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -18,7 +18,13 @@ #include #include #include +#if defined(__ANDROID_NDK__) && defined (__arm__) +#include +#include +#else #include +#include +#endif #ifndef __ANDROID__ #include #endif @@ -27,7 +33,6 @@ #include #include #include -#include #include #if defined (__arm64__) || defined (__aarch64__) diff --git a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp index 5bc8c51..3efeb5d 100644 --- a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp +++ b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp @@ -16,7 +16,13 @@ #include #include #include +#if defined(__ANDROID_NDK__) && defined (__arm__) +#include +#include +#else #include +#include +#endif #ifndef __ANDROID__ #include #endif @@ -25,7 +31,6 @@ #include #include #include -#include #include // C++ Includes diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp index 5579b0b..a2ab674 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp @@ -150,7 +150,7 @@ RegisterContextMacOSXFrameBackchain::ReadRegister (const RegisterInfo *reg_info, // TOOD: need a better way to detect when "long double" types are // the same bytes size as "double" #if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__) && !defined(_MSC_VER) && \ - !defined(__mips__) && !defined(__powerpc__) + !defined(__mips__) && !defined(__powerpc__) && !defined(__ANDROID_NDK__) case sizeof (long double): if (sizeof (long double) == sizeof(uint32_t)) { diff --git a/lldb/source/Utility/PseudoTerminal.cpp b/lldb/source/Utility/PseudoTerminal.cpp index f60c00a..e90955d 100644 --- a/lldb/source/Utility/PseudoTerminal.cpp +++ b/lldb/source/Utility/PseudoTerminal.cpp @@ -31,6 +31,8 @@ char *ptsname(int fd) { return 0; } pid_t fork(void) { return 0; } pid_t setsid(void) { return 0; } +#elif defined(__ANDROID_NDK__) +#include "lldb/Host/android/Android.h" #endif using namespace lldb_utility; diff --git a/lldb/tools/CMakeLists.txt b/lldb/tools/CMakeLists.txt index 92181b5..8008b07 100644 --- a/lldb/tools/CMakeLists.txt +++ b/lldb/tools/CMakeLists.txt @@ -2,7 +2,9 @@ if (CMAKE_SYSTEM_NAME MATCHES "Darwin") add_subdirectory(debugserver) endif() add_subdirectory(driver) +if (NOT __ANDROID_NDK__) add_subdirectory(lldb-mi) +endif() if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "Linux") add_subdirectory(lldb-gdbserver) endif() diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index cec56b4..477b7d6 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -19,6 +19,8 @@ #if defined(_WIN32) #include #include +#elif defined(__ANDROID_NDK__) +#include #else #include #endif diff --git a/lldb/tools/driver/Platform.h b/lldb/tools/driver/Platform.h index e266107..8995512 100644 --- a/lldb/tools/driver/Platform.h +++ b/lldb/tools/driver/Platform.h @@ -101,15 +101,17 @@ #include #include - #include #include #include - #if defined(__FreeBSD__) || defined(__NetBSD__) - #include - #else - #include - #endif +#if !defined(__ANDROID_NDK__) + #include + #if defined(__FreeBSD__) || defined(__NetBSD__) + #include + #else + #include + #endif +#endif #endif diff --git a/lldb/tools/lldb-gdbserver/CMakeLists.txt b/lldb/tools/lldb-gdbserver/CMakeLists.txt index 9c1599a..1dc2e1c 100644 --- a/lldb/tools/lldb-gdbserver/CMakeLists.txt +++ b/lldb/tools/lldb-gdbserver/CMakeLists.txt @@ -1,12 +1,40 @@ set(LLVM_NO_RTTI 1) +if ( CMAKE_SYSTEM_NAME MATCHES "Linux" ) +include_directories( + ../../source/Plugins/Process/Linux + ../../source/Plugins/Process/POSIX + ) +endif () + +if ( CMAKE_SYSTEM_NAME MATCHES "FreeBSD" ) +include_directories( + ../../source/Plugins/Process/FreeBSD + ../../source/Plugins/Process/POSIX + ) +endif () include_directories(../../source) +include(../../cmake/LLDBDependencies.cmake) + +# have to include lldb and lldb-log files since those are not libraries and llgs depends on them add_lldb_executable(lldb-gdbserver lldb-gdbserver.cpp + ../../source/lldb-log.cpp + ../../source/lldb.cpp ) -target_link_libraries(lldb-gdbserver liblldb) +# The Darwin linker doesn't understand --start-group/--end-group. +if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") + target_link_libraries(lldb-gdbserver + -Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group) +else() + target_link_libraries(lldb-gdbserver ${LLDB_USED_LIBS}) +endif() +target_link_libraries(lldb-gdbserver ${CLANG_USED_LIBS}) +llvm_config(lldb-gdbserver ${LLVM_LINK_COMPONENTS}) + +target_link_libraries(lldb-gdbserver ${LLDB_SYSTEM_LIBS}) set_target_properties(lldb-gdbserver PROPERTIES VERSION ${LLDB_VERSION}) -- 2.7.4