moved std::to_string into Android.h file

removed timegm and posix_openpt (they may have been required when I was working 
with Arm NDK previously but this commit only focus on x86_64 so if it is needed 
in the future they will be inside an Android.cpp file)

removed EditLineAndroid and define LLDB_DISABLE_LIBEDIT for Android

removed the ifndef __ANDROID_NDK__ in HostThreadPosix file - the define in 
HostThreadPosix was done before all the refactoring that's been going on. 
Android actually just use HostThreadLinux with a few details stubbed out and 
need to be filled in later.

http://reviews.llvm.org/D6166

Files:
  CMakeLists.txt
  cmake/LLDBDependencies.cmake
  cmake/platforms/Android.cmake
  include/lldb/Core/RegularExpression.h
  include/lldb/Host/Config.h
  include/lldb/Host/Editline.h
  include/lldb/Host/android/Android.h
  include/lldb/Host/android/Config.h
  include/lldb/lldb-private.h
  scripts/Python/modules/CMakeLists.txt
  source/CMakeLists.txt
  source/Core/ConnectionSharedMemory.cpp
  source/DataFormatters/CXXFormatterFunctions.cpp
  source/Host/CMakeLists.txt
  source/Host/common/File.cpp
  source/Host/common/Host.cpp
  source/Host/common/Socket.cpp
  source/Host/linux/Host.cpp
  source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
  source/Plugins/Platform/Linux/PlatformLinux.cpp
  source/Plugins/Process/Linux/NativeProcessLinux.cpp
  source/Plugins/Process/Linux/ProcessMonitor.cpp
  source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp
  source/Utility/PseudoTerminal.cpp
  tools/CMakeLists.txt
  tools/driver/Driver.cpp
  tools/driver/Platform.h
  tools/lldb-gdbserver/CMakeLists.txt
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -7,9 +7,15 @@
     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 @@
 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)
Index: cmake/LLDBDependencies.cmake
===================================================================
--- /dev/null
+++ cmake/LLDBDependencies.cmake
@@ -0,0 +1,175 @@
+set( LLDB_USED_LIBS
+  lldbBreakpoint
+  lldbCommands
+  lldbDataFormatters
+  lldbHost
+  lldbCore
+  lldbExpression
+  lldbInterpreter
+  lldbSymbol
+  lldbTarget
+  lldbUtility
+
+  # 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" AND NOT __ANDROID_NDK__)
+  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()
Index: cmake/platforms/Android.cmake
===================================================================
--- /dev/null
+++ cmake/platforms/Android.cmake
@@ -0,0 +1,104 @@
+# Toolchain config for Android standalone NDK.
+#
+# Usage:
+# build host llvm and clang first
+# cmake -DCMAKE_TOOLCHAIN_FILE=../lldb/cmake/platforms/Android.cmake \
+#       -DANDROID_TOOLCHAIN_DIR=<toolchain_dir> \
+#       -DANDROID_ABI=<target_abi> \
+#       -DCMAKE_CXX_COMPILER_VERSION=<gcc_version> \
+#       -DLLVM_TARGET_ARCH=<llvm_target_arch> \
+#       -DLLVM_TARGETS_TO_BUILD=<llvm_targets_to_build> \
+#       -DLLVM_TABLEGEN=<path_to_llvm-tblgen> \
+#       -DCLANG_TABLEGEN=<path_to_clang-tblgen>
+#
+# Current Support:
+#   ANDROID_ABI = x86, x86_64
+#   CMAKE_CXX_COMPILER_VERSION = 4.9
+#   LLVM_TARGET_ARCH = X86
+#   LLVM_TARGETS_TO_BUILD = X86
+#   LLVM_TABLEGEN = path to host llvm-tblgen
+#   CLANG_TABLEGEN = path to host clang-tblgen
+
+if( DEFINED CMAKE_CROSSCOMPILING )
+ return()
+endif()
+
+get_property( IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
+if( IS_IN_TRY_COMPILE )
+ # this seems necessary and works fine but I'm unsure if it breaks anything
+ return()
+endif()
+
+set( CMAKE_SYSTEM_NAME Linux )
+include( CMakeForceCompiler )
+
+# flags and definitions
+remove_definitions( -DANDROID -D__ANDROID__ )
+add_definitions( -DANDROID -D__ANDROID_NDK__ -DLLDB_DISABLE_LIBEDIT )
+set( ANDROID True )
+set( __ANDROID_NDK__ True )
+
+set( ANDROID_ABI "${ANDROID_ABI}" CACHE INTERNAL "Android Abi" FORCE )
+if( ANDROID_ABI STREQUAL "x86" )
+ set( CMAKE_SYSTEM_PROCESSOR "i686" )
+ set( ANDROID_TOOLCHAIN_NAME "x86-linux-android" )
+elseif( ANDROID_ABI STREQUAL "x86_64" )
+ set( CMAKE_SYSTEM_PROCESSOR "x86_64" )
+ set( ANDROID_TOOLCHAIN_NAME "x86_64-linux-android" )
+else()
+ message( SEND_ERROR "Unknown ANDROID_ABI = \"${ANDROID_ABI}\"." )
+endif()
+
+set( ANDROID_TOOLCHAIN_DIR "${ANDROID_TOOLCHAIN_DIR}" CACHE INTERNAL "Android standalone toolchain directory" FORCE )
+set( ANDROID_SYSROOT "${ANDROID_TOOLCHAIN_DIR}/sysroot" CACHE INTERNAL "Android Sysroot" FORCE )
+
+# force python exe to be the one in Android toolchian
+set( PYTHON_EXECUTABLE "${ANDROID_TOOLCHAIN_DIR}/bin/python" CACHE INTERNAL "Python exec path" FORCE )
+
+if( NOT CMAKE_C_COMPILER )
+ set( CMAKE_C_COMPILER   "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-gcc"     CACHE PATH "C compiler" )
+ set( CMAKE_CXX_COMPILER "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-g++"     CACHE PATH "C++ compiler" )
+ set( CMAKE_ASM_COMPILER "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-gcc"     CACHE PATH "assembler" )
+ set( CMAKE_STRIP        "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-strip"   CACHE PATH "strip" )
+ set( CMAKE_AR           "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-ar"      CACHE PATH "archive" )
+ set( CMAKE_LINKER       "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-ld"      CACHE PATH "linker" )
+ set( CMAKE_NM           "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-nm"      CACHE PATH "nm" )
+ set( CMAKE_OBJCOPY      "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-objcopy" CACHE PATH "objcopy" )
+ set( CMAKE_OBJDUMP      "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-objdump" CACHE PATH "objdump" )
+ set( CMAKE_RANLIB       "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-ranlib"  CACHE PATH "ranlib" )
+endif()
+
+set( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT} -pie -fPIE -funwind-tables -fsigned-char -no-canonical-prefixes" )
+# TODO: different ARM abi have different flags such as neon, vfpv etc
+if( X86 )
+ set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funswitch-loops -finline-limit=300" )
+endif()
+
+# linker flags
+set( ANDROID_CXX_FLAGS    "${ANDROID_CXX_FLAGS} -fdata-sections -ffunction-sections" )
+set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--gc-sections" )
+
+# cache flags
+set( CMAKE_CXX_FLAGS           ""                        CACHE STRING "c++ flags" )
+set( CMAKE_C_FLAGS             ""                        CACHE STRING "c flags" )
+set( CMAKE_EXE_LINKER_FLAGS    "-Wl,-z,nocopyreloc"      CACHE STRING "executable linker flags" )
+set( ANDROID_CXX_FLAGS         "${ANDROID_CXX_FLAGS}"    CACHE INTERNAL "Android c/c++ flags" )
+set( ANDROID_LINKER_FLAGS      "${ANDROID_LINKER_FLAGS}" CACHE INTERNAL "Android c/c++ linker flags" )
+
+# final flags
+set( CMAKE_CXX_FLAGS           "${ANDROID_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" )
+set( CMAKE_C_FLAGS             "${ANDROID_CXX_FLAGS} ${CMAKE_C_FLAGS}" )
+set( CMAKE_EXE_LINKER_FLAGS    "${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )
+
+# global includes and link directories
+set( ANDROID_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_DIR}/include/c++/${ANDROID_COMPILER_VERSION}" )
+list( APPEND ANDROID_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_DIR}/include/python2.7" )
+include_directories( SYSTEM "${ANDROID_SYSROOT}/usr/include" ${ANDROID_INCLUDE_DIRS} )
+
+# target environment
+set( CMAKE_FIND_ROOT_PATH "${ANDROID_TOOLCHAIN_DIR}/bin" "${ANDROID_TOOLCHAIN_DIR}/${ANDROID_TOOLCHAIN_NAME}" "${ANDROID_SYSROOT}" )
+
+# only search for libraries and includes in the ndk toolchain
+set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
+set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
+set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
\ No newline at end of file
Index: include/lldb/Core/RegularExpression.h
===================================================================
--- include/lldb/Core/RegularExpression.h
+++ include/lldb/Core/RegularExpression.h
@@ -39,6 +39,9 @@
 }
 
 #else
+#if __ANDROID_NDK__
+#include <regex>
+#endif
 #include <regex.h>
 #endif
 #include <stdint.h>
Index: include/lldb/Host/Config.h
===================================================================
--- include/lldb/Host/Config.h
+++ 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"
Index: include/lldb/Host/Editline.h
===================================================================
--- include/lldb/Host/Editline.h
+++ include/lldb/Host/Editline.h
@@ -14,11 +14,13 @@
 #include "lldb/lldb-private.h"
 
 #include <stdio.h>
-#ifdef _WIN32
+#if defined(_WIN32)
 #include "lldb/Host/windows/editlinewin.h"
 #else
+#if !defined(__ANDROID_NDK__)
 #include <histedit.h>
 #endif
+#endif
 
 #include <string>
 #include <vector>
Index: include/lldb/Host/android/Android.h
===================================================================
--- /dev/null
+++ include/lldb/Host/android/Android.h
@@ -0,0 +1,34 @@
+//===-- lldb-android.h --------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_lldb_android_h_
+#define LLDB_lldb_android_h_
+
+#include <sstream>
+#include <string>
+#include <errno.h>
+
+#define _isatty			isatty
+#define SYS_tgkill		__NR_tgkill
+#define PT_DETACH		PTRACE_DETACH
+
+typedef int				__ptrace_request;
+
+namespace std
+{
+	template <typename T>
+	std::string to_string(T value)
+	{
+		std::ostringstream os ;
+		os << value ;
+		return os.str() ;
+	}
+}
+
+#endif  // LLDB_lldb_android_h_
Index: include/lldb/Host/android/Config.h
===================================================================
--- /dev/null
+++ include/lldb/Host/android/Config.h
@@ -0,0 +1,28 @@
+//===-- Config.h -----------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+//----------------------------------------------------------------------
+// LLDB currently doesn't have a dynamic configuration mechanism, so we
+// are going to hardcode things for now. Eventually these files will
+// be auto generated by some configuration script that can detect
+// platform functionality availability.
+//----------------------------------------------------------------------
+
+#ifndef liblldb_Platform_Config_h_
+#define liblldb_Platform_Config_h_
+
+#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
+
+#define LLDB_DISABLE_POSIX
+
+//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
+
+//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
+
+#endif // #ifndef liblldb_Platform_Config_h_
Index: include/lldb/lldb-private.h
===================================================================
--- include/lldb/lldb-private.h
+++ 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"
Index: scripts/Python/modules/CMakeLists.txt
===================================================================
--- scripts/Python/modules/CMakeLists.txt
+++ 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()
Index: source/CMakeLists.txt
===================================================================
--- source/CMakeLists.txt
+++ source/CMakeLists.txt
@@ -31,182 +31,8 @@
 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" )
Index: source/Core/ConnectionSharedMemory.cpp
===================================================================
--- source/Core/ConnectionSharedMemory.cpp
+++ 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 @@
     return eConnectionStatusError;
 }
 
+#endif // __ANDROID_NDK__
Index: source/DataFormatters/CXXFormatterFunctions.cpp
===================================================================
--- source/DataFormatters/CXXFormatterFunctions.cpp
+++ source/DataFormatters/CXXFormatterFunctions.cpp
@@ -27,6 +27,9 @@
 #include "lldb/Utility/ProcessStructReader.h"
 
 #include <algorithm>
+#if __ANDROID_NDK__
+#include <sys/types.h>
+#endif
 
 using namespace lldb;
 using namespace lldb_private;
Index: source/Host/CMakeLists.txt
===================================================================
--- source/Host/CMakeLists.txt
+++ source/Host/CMakeLists.txt
@@ -5,7 +5,6 @@
 
 add_host_subdirectory(common
   common/Condition.cpp
-  common/Editline.cpp
   common/File.cpp
   common/FileCache.cpp
   common/FileSpec.cpp
@@ -33,6 +32,12 @@
   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 @@
       )
 
   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
Index: source/Host/common/File.cpp
===================================================================
--- source/Host/common/File.cpp
+++ 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;
Index: source/Host/common/Host.cpp
===================================================================
--- source/Host/common/Host.cpp
+++ 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)
 {
Index: source/Host/common/Socket.cpp
===================================================================
--- source/Host/common/Socket.cpp
+++ 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>
Index: source/Host/linux/Host.cpp
===================================================================
--- source/Host/linux/Host.cpp
+++ 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"
 
Index: source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
===================================================================
--- source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
+++ 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   "!<arch>\n"
 #define SARMAG  8
Index: source/Plugins/Platform/Linux/PlatformLinux.cpp
===================================================================
--- source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -820,7 +820,7 @@
     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 @@
                                     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 ())
Index: source/Plugins/Process/Linux/NativeProcessLinux.cpp
===================================================================
--- source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -18,7 +18,13 @@
 #include <stdint.h>
 #include <unistd.h>
 #include <linux/unistd.h>
+#if defined(__ANDROID_NDK__) && defined (__arm__)
+#include <linux/personality.h>
+#include <linux/user.h>
+#else
 #include <sys/personality.h>
+#include <sys/user.h>
+#endif
 #ifndef __ANDROID__
 #include <sys/procfs.h>
 #endif
@@ -27,7 +33,6 @@
 #include <sys/socket.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
-#include <sys/user.h>
 #include <sys/wait.h>
 
 #if defined (__arm64__) || defined (__aarch64__)
Index: source/Plugins/Process/Linux/ProcessMonitor.cpp
===================================================================
--- source/Plugins/Process/Linux/ProcessMonitor.cpp
+++ source/Plugins/Process/Linux/ProcessMonitor.cpp
@@ -16,7 +16,13 @@
 #include <stdint.h>
 #include <unistd.h>
 #include <elf.h>
+#if defined(__ANDROID_NDK__) && defined (__arm__)
+#include <linux/personality.h>
+#include <linux/user.h>
+#else
 #include <sys/personality.h>
+#include <sys/user.h>
+#endif
 #ifndef __ANDROID__
 #include <sys/procfs.h>
 #endif
@@ -25,7 +31,6 @@
 #include <sys/socket.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
-#include <sys/user.h>
 #include <sys/wait.h>
 
 // C++ Includes
Index: source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp
===================================================================
--- source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp
+++ source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp
@@ -150,7 +150,7 @@
             // 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))
             {
Index: source/Utility/PseudoTerminal.cpp
===================================================================
--- source/Utility/PseudoTerminal.cpp
+++ source/Utility/PseudoTerminal.cpp
@@ -31,6 +31,8 @@
 
 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;
Index: tools/CMakeLists.txt
===================================================================
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -2,7 +2,9 @@
   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()
Index: tools/driver/Driver.cpp
===================================================================
--- tools/driver/Driver.cpp
+++ tools/driver/Driver.cpp
@@ -19,6 +19,8 @@
 #if defined(_WIN32)
 #include <io.h>
 #include <fcntl.h>
+#elif defined(__ANDROID_NDK__)
+#include <errno.h>
 #else
 #include <unistd.h>
 #endif
Index: tools/driver/Platform.h
===================================================================
--- tools/driver/Platform.h
+++ tools/driver/Platform.h
@@ -101,15 +101,17 @@
     #include <termios.h>
     #include <unistd.h>
 
-    #include <histedit.h>
     #include <pthread.h>
     #include <sys/time.h>
 
-    #if defined(__FreeBSD__) || defined(__NetBSD__)
-        #include <readline/readline.h>
-    #else
-        #include <editline/readline.h>
-    #endif
+#if !defined(__ANDROID_NDK__)
+	#include <histedit.h>
+	#if defined(__FreeBSD__) || defined(__NetBSD__)
+		#include <readline/readline.h>
+	#else
+		#include <editline/readline.h>
+	#endif
+#endif
 
 #endif
 
Index: tools/lldb-gdbserver/CMakeLists.txt
===================================================================
--- tools/lldb-gdbserver/CMakeLists.txt
+++ 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})
 
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to