Platform holds a smart pointer to each platform object created in a static variable what cause the platform destructors called only on program exit when other static variables are not availables. With this change the destructors are called on lldb_private::Terminate() + Fix DebuggerRefCount handling in ScriptInterpreterPython Differential Revision: http://reviews.llvm.org/D7590 llvm-svn: 228944
161 lines
4.2 KiB
C++
161 lines
4.2 KiB
C++
//===-- 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 ()
|
|
{
|
|
PlatformLinux::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);
|
|
}
|
|
}
|
|
|
|
PlatformLinux::Terminate ();
|
|
}
|
|
|
|
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);
|
|
}
|