REPOSITORY
  rL LLVM

http://reviews.llvm.org/D7613

Files:
  lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
  lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h
  lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
  lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
Index: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
===================================================================
--- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ lldb/trunk/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,21 +879,16 @@
         process_sp);
 
     return error;
-#endif
 }
 
 Error
 PlatformLinux::AttachNativeProcess (lldb::pid_t pid,
                                     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: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
===================================================================
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ lldb/trunk/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,46 +120,62 @@
     {
         if (log)
             log->Printf ("PlatformAndroid::%s() creating remote-android platform", __FUNCTION__);
-        return PlatformSP(new PlatformAndroid());
+        return PlatformSP(new PlatformAndroid(false));
     }
 
     if (log)
         log->Printf ("PlatformAndroid::%s() aborting creation of remote-android platform", __FUNCTION__);
 
     return PlatformSP();
 }
 
-PlatformAndroid::PlatformAndroid () :
-    PlatformLinux(false)  // Platform android is always a remote target
+PlatformAndroid::PlatformAndroid (bool is_host) :
+    PlatformLinux(is_host)
 {
 }
 
 PlatformAndroid::~PlatformAndroid()
 {
 }
 
 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: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h
===================================================================
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h
+++ lldb/trunk/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: lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp
===================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp
+++ lldb/trunk/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;
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to