Index: source/Plugins/Platform/Android/PlatformAndroid.h =================================================================== --- source/Plugins/Platform/Android/PlatformAndroid.h +++ source/Plugins/Platform/Android/PlatformAndroid.h @@ -26,8 +26,8 @@ static void Terminate (); - - PlatformAndroid (); + + PlatformAndroid (bool is_host); virtual ~PlatformAndroid(); @@ -39,10 +39,10 @@ CreateInstance (bool force, const lldb_private::ArchSpec *arch); static lldb_private::ConstString - GetPluginNameStatic (); + GetPluginNameStatic (bool is_host); static const char * - GetPluginDescriptionStatic (); + GetPluginDescriptionStatic (bool is_host); lldb_private::ConstString GetPluginName() override; Index: source/Plugins/Platform/Android/PlatformAndroid.cpp =================================================================== --- source/Plugins/Platform/Android/PlatformAndroid.cpp +++ source/Plugins/Platform/Android/PlatformAndroid.cpp @@ -12,6 +12,7 @@ // Other libraries and framework includes #include "lldb/Core/Log.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/HostInfo.h" // Project includes #include "PlatformAndroid.h" @@ -29,8 +30,13 @@ if (g_initialize_count++ == 0) { - PluginManager::RegisterPlugin (PlatformAndroid::GetPluginNameStatic(), - PlatformAndroid::GetPluginDescriptionStatic(), +#if defined(__ANDROID__) + PlatformSP default_platform_sp (new PlatformAndroid(true)); + default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); + Platform::SetHostPlatform (default_platform_sp); +#endif + PluginManager::RegisterPlugin (PlatformAndroid::GetPluginNameStatic(false), + PlatformAndroid::GetPluginDescriptionStatic(false), PlatformAndroid::CreateInstance); } } @@ -92,9 +98,9 @@ { switch (triple.getOS()) { - case llvm::Triple::Linux: + case llvm::Triple::Android: break; - + #if defined(__ANDROID__) // Only accept "unknown" for the OS if the host is android and // it "unknown" wasn't specified (it was just returned because it @@ -114,7 +120,7 @@ { if (log) log->Printf ("PlatformAndroid::%s() creating remote-android platform", __FUNCTION__); - return PlatformSP(new PlatformAndroid()); + return PlatformSP(new PlatformAndroid(false)); } if (log) @@ -123,8 +129,8 @@ return PlatformSP(); } -PlatformAndroid::PlatformAndroid () : - PlatformLinux(false) // Platform android is always a remote target +PlatformAndroid::PlatformAndroid (bool is_host) : + PlatformLinux(is_host) { } @@ -133,27 +139,43 @@ } lldb_private::ConstString -PlatformAndroid::GetPluginNameStatic () +PlatformAndroid::GetPluginNameStatic (bool is_host) { - static ConstString g_remote_name("remote-android"); - return g_remote_name; + if (is_host) + { + static ConstString g_host_name(Platform::GetHostPlatformName ()); + return g_host_name; + } + else + { + static ConstString g_remote_name("remote-android"); + return g_remote_name; + } } const char * -PlatformAndroid::GetPluginDescriptionStatic () +PlatformAndroid::GetPluginDescriptionStatic (bool is_host) { - return "Remote Android user platform plug-in."; + if (is_host) + return "Local Android user platform plug-in."; + else + return "Remote Android user platform plug-in."; } lldb_private::ConstString PlatformAndroid::GetPluginName() { - return GetPluginNameStatic(); + return GetPluginNameStatic(IsHost()); } Error PlatformAndroid::ConnectRemote (Args& args) { + if (IsHost()) + { + return Error ("can't connect to the host platform '%s', always connected", GetPluginName().GetCString()); + } + if (!m_remote_platform_sp) m_remote_platform_sp = PlatformSP(new PlatformAndroidRemoteGDBServer()); return PlatformLinux::ConnectRemote (args); Index: source/Plugins/Platform/Linux/PlatformLinux.cpp =================================================================== --- source/Plugins/Platform/Linux/PlatformLinux.cpp +++ source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -246,7 +246,7 @@ if (g_initialize_count++ == 0) { -#if defined(__linux__) +#if defined(__linux__) && !defined(__ANDROID__) PlatformSP default_platform_sp (new PlatformLinux(true)); default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); Platform::SetHostPlatform (default_platform_sp); @@ -853,9 +853,6 @@ lldb_private::NativeProcessProtocol::NativeDelegate &native_delegate, NativeProcessProtocolSP &process_sp) { -#if !defined(__linux__) || defined(__ANDROID_NDK__) - return Error("only implemented on Linux hosts"); -#else if (!IsHost ()) return Error("PlatformLinux::%s (): cannot launch a debug process when not the host", __FUNCTION__); @@ -882,7 +879,6 @@ process_sp); return error; -#endif } Error @@ -890,13 +886,9 @@ lldb_private::NativeProcessProtocol::NativeDelegate &native_delegate, NativeProcessProtocolSP &process_sp) { -#if !defined(__linux__) || defined(__ANDROID_NDK__) - return Error("only implemented on Linux hosts"); -#else if (!IsHost ()) return Error("PlatformLinux::%s (): cannot attach to a debug process when not the host", __FUNCTION__); // Launch it for debugging return NativeProcessLinux::AttachToProcess (pid, native_delegate, process_sp); -#endif } Index: source/Plugins/Process/Linux/NativeThreadLinux.cpp =================================================================== --- source/Plugins/Process/Linux/NativeThreadLinux.cpp +++ source/Plugins/Process/Linux/NativeThreadLinux.cpp @@ -198,9 +198,8 @@ break; } #endif -#if 0 + case llvm::Triple::x86: -#endif case llvm::Triple::x86_64: { const uint32_t concrete_frame_idx = 0;