summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
diff options
context:
space:
mode:
authorTamas Berghammer <tberghammer@google.com>2015-02-12 18:13:44 +0000
committerTamas Berghammer <tberghammer@google.com>2015-02-12 18:13:44 +0000
commit00e305d281502a9b4d90dc02aa4c7dad819a9083 (patch)
tree39a3796bf30454182b8947b30e29e42f6eb3db0d /lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
parent97eac4089aa5e249143fbc7aa24984242eeea54b (diff)
downloadbcm5719-llvm-00e305d281502a9b4d90dc02aa4c7dad819a9083.tar.gz
bcm5719-llvm-00e305d281502a9b4d90dc02aa4c7dad819a9083.zip
Create new platform: remote-android
* Create new platform plugin for lldb * Create HostInfo class for android * Create ProcessLauncher for android Differential Revision: http://reviews.llvm.org/D7584 llvm-svn: 228943
Diffstat (limited to 'lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp')
-rw-r--r--lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp156
1 files changed, 156 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
new file mode 100644
index 00000000000..e89254d89f0
--- /dev/null
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -0,0 +1,156 @@
+//===-- PlatformAndroid.cpp -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+#include "lldb/Core/Log.h"
+#include "lldb/Core/PluginManager.h"
+
+// Project includes
+#include "PlatformAndroid.h"
+#include "PlatformAndroidRemoteGDBServer.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+static uint32_t g_initialize_count = 0;
+
+void
+PlatformAndroid::Initialize ()
+{
+ if (g_initialize_count++ == 0)
+ {
+ PluginManager::RegisterPlugin (PlatformAndroid::GetPluginNameStatic(),
+ PlatformAndroid::GetPluginDescriptionStatic(),
+ PlatformAndroid::CreateInstance);
+ }
+}
+
+void
+PlatformAndroid::Terminate ()
+{
+ if (g_initialize_count > 0)
+ {
+ if (--g_initialize_count == 0)
+ {
+ PluginManager::UnregisterPlugin (PlatformAndroid::CreateInstance);
+ }
+ }
+}
+
+PlatformSP
+PlatformAndroid::CreateInstance (bool force, const ArchSpec *arch)
+{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
+ if (log)
+ {
+ const char *arch_name;
+ if (arch && arch->GetArchitectureName ())
+ arch_name = arch->GetArchitectureName ();
+ else
+ arch_name = "<null>";
+
+ const char *triple_cstr = arch ? arch->GetTriple ().getTriple ().c_str() : "<null>";
+
+ log->Printf ("PlatformAndroid::%s(force=%s, arch={%s,%s})", __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
+ }
+
+ bool create = force;
+ if (create == false && arch && arch->IsValid())
+ {
+ const llvm::Triple &triple = arch->GetTriple();
+ switch (triple.getVendor())
+ {
+ case llvm::Triple::PC:
+ create = true;
+ break;
+
+#if defined(__ANDROID__)
+ // Only accept "unknown" for the vendor if the host is android and
+ // it "unknown" wasn't specified (it was just returned because it
+ // was NOT specified_
+ case llvm::Triple::VendorType::UnknownVendor:
+ create = !arch->TripleVendorWasSpecified();
+ break;
+#endif
+ default:
+ break;
+ }
+
+ if (create)
+ {
+ switch (triple.getOS())
+ {
+ case llvm::Triple::Linux:
+ 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
+ // was NOT specified)
+ case llvm::Triple::OSType::UnknownOS:
+ create = !arch->TripleOSWasSpecified();
+ break;
+#endif
+ default:
+ create = false;
+ break;
+ }
+ }
+ }
+
+ if (create)
+ {
+ if (log)
+ log->Printf ("PlatformAndroid::%s() creating remote-android platform", __FUNCTION__);
+ return PlatformSP(new PlatformAndroid());
+ }
+
+ 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()
+{
+}
+
+lldb_private::ConstString
+PlatformAndroid::GetPluginNameStatic ()
+{
+ static ConstString g_remote_name("remote-android");
+ return g_remote_name;
+}
+
+const char *
+PlatformAndroid::GetPluginDescriptionStatic ()
+{
+ return "Remote Android user platform plug-in.";
+}
+
+lldb_private::ConstString
+PlatformAndroid::GetPluginName()
+{
+ return GetPluginNameStatic();
+}
+
+Error
+PlatformAndroid::ConnectRemote (Args& args)
+{
+ if (!m_remote_platform_sp)
+ m_remote_platform_sp = PlatformSP(new PlatformAndroidRemoteGDBServer());
+ return PlatformLinux::ConnectRemote (args);
+}
OpenPOWER on IntegriCloud