Files
clang-p2996/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
Greg Clayton 57abc5d6a6 <rdar://problem/13854277>
<rdar://problem/13594769>

Main changes in this patch include:
- cleanup plug-in interface and use ConstStrings for plug-in names
- Modfiied the BSD Archive plug-in to be able to pick out the correct .o file when .a files contain multiple .o files with the same name by using the timestamp
- Modified SymbolFileDWARFDebugMap to properly verify the timestamp on .o files it loads to ensure we don't load updated .o files and cause problems when debugging

The plug-in interface changes:

Modified the lldb_private::PluginInterface class that all plug-ins inherit from:

Changed:

virtual const char * GetPluginName() = 0;

To: 

virtual ConstString GetPluginName() = 0;

Removed:

virtual const char * GetShortPluginName() = 0;

- Fixed up all plug-in to adhere to the new interface and to return lldb_private::ConstString values for the plug-in names. 
- Fixed all plug-ins to return simple names with no prefixes. Some plug-ins had prefixes and most ones didn't, so now they all don't have prefixed names, just simple names like "linux", "gdb-remote", etc.

llvm-svn: 181631
2013-05-10 21:47:16 +00:00

186 lines
5.1 KiB
C++

//===-- PlatformMacOSX.cpp --------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "PlatformMacOSX.h"
// C Includes
#include <sys/sysctl.h>
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Error.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
static uint32_t g_initialize_count = 0;
void
PlatformMacOSX::Initialize ()
{
if (g_initialize_count++ == 0)
{
#if defined (__APPLE__)
PlatformSP default_platform_sp (new PlatformMacOSX(true));
default_platform_sp->SetSystemArchitecture (Host::GetArchitecture());
Platform::SetDefaultPlatform (default_platform_sp);
#endif
PluginManager::RegisterPlugin (PlatformMacOSX::GetPluginNameStatic(false),
PlatformMacOSX::GetDescriptionStatic(false),
PlatformMacOSX::CreateInstance);
}
}
void
PlatformMacOSX::Terminate ()
{
if (g_initialize_count > 0)
{
if (--g_initialize_count == 0)
{
PluginManager::UnregisterPlugin (PlatformMacOSX::CreateInstance);
}
}
}
Platform*
PlatformMacOSX::CreateInstance (bool force, const ArchSpec *arch)
{
// The only time we create an instance is when we are creating a remote
// macosx platform
const bool is_host = false;
bool create = force;
if (create == false && arch && arch->IsValid())
{
const llvm::Triple &triple = arch->GetTriple();
switch (triple.getVendor())
{
case llvm::Triple::Apple:
create = true;
break;
#if defined(__APPLE__)
// Only accept "unknown" for vendor if the host is Apple and
// it "unknown" wasn't specified (it was just returned becasue it
// was NOT specified)
case llvm::Triple::UnknownArch:
create = !arch->TripleVendorWasSpecified();
break;
#endif
default:
break;
}
if (create)
{
switch (triple.getOS())
{
case llvm::Triple::Darwin: // Deprecated, but still support Darwin for historical reasons
case llvm::Triple::MacOSX:
break;
#if defined(__APPLE__)
// Only accept "vendor" for vendor if the host is Apple and
// it "unknown" wasn't specified (it was just returned becasue it
// was NOT specified)
case llvm::Triple::UnknownOS:
create = !arch->TripleOSWasSpecified();
break;
#endif
default:
create = false;
break;
}
}
}
if (create)
return new PlatformMacOSX (is_host);
return NULL;
}
lldb_private::ConstString
PlatformMacOSX::GetPluginNameStatic (bool is_host)
{
if (is_host)
{
static ConstString g_host_name(Platform::GetHostPlatformName ());
return g_host_name;
}
else
{
static ConstString g_remote_name("remote-macosx");
return g_remote_name;
}
}
const char *
PlatformMacOSX::GetDescriptionStatic (bool is_host)
{
if (is_host)
return "Local Mac OS X user platform plug-in.";
else
return "Remote Mac OS X user platform plug-in.";
}
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
PlatformMacOSX::PlatformMacOSX (bool is_host) :
PlatformDarwin (is_host)
{
}
//------------------------------------------------------------------
/// Destructor.
///
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
//------------------------------------------------------------------
PlatformMacOSX::~PlatformMacOSX()
{
}
Error
PlatformMacOSX::GetFile (const FileSpec &platform_file,
const UUID *uuid_ptr,
FileSpec &local_file)
{
if (IsRemote())
{
if (m_remote_platform_sp)
return m_remote_platform_sp->GetFile (platform_file, uuid_ptr, local_file);
}
// Default to the local case
local_file = platform_file;
return Error();
}
bool
PlatformMacOSX::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
{
#if defined (__arm__)
return ARMGetSupportedArchitectureAtIndex (idx, arch);
#else
return x86GetSupportedArchitectureAtIndex (idx, arch);
#endif
}