Modified the OptionGroupOptions to be able to specify only some of the options that should be appended by using the usage_mask in the group defintions and also provided a way to remap them to a new usage mask after the copy. This allows options to be re-used and also targetted for specific option groups. Modfied the CommandArgumentType to have a new eArgTypePlatform enumeration. Taught the option parser to be able to automatically use the appropriate auto completion for a given options if nothing is explicitly specified in the option definition. So you don't have to specify it in the option definition tables. Renamed the default host platform name to "host", and the default platform hostname to be "localhost". Modified the "file" and "platform select" commands to make sure all options and args are good prior to creating a new platform. Also defer the computation of the architecture in the file command until all options are parsed and the platform has either not been specified or reset to a new value to avoid computing the arch more than once. Switch the PluginManager code over to using llvm::StringRef for string comparisons and got rid of all the AccessorXXX functions in lieu of the newer mutex + collection singleton accessors. llvm-svn: 129483
203 lines
6.0 KiB
C++
203 lines
6.0 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::GetShortPluginNameStatic(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 ()
|
|
{
|
|
// The only time we create an instance is when we are creating a remote
|
|
// macosx platform
|
|
const bool is_host = false;
|
|
return new PlatformMacOSX (is_host);
|
|
}
|
|
|
|
|
|
const char *
|
|
PlatformMacOSX::GetPluginNameStatic ()
|
|
{
|
|
return "PlatformMacOSX";
|
|
}
|
|
|
|
const char *
|
|
PlatformMacOSX::GetShortPluginNameStatic (bool is_host)
|
|
{
|
|
if (is_host)
|
|
return Platform::GetHostPlatformName ();
|
|
else
|
|
return "remote-macosx";
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
Error
|
|
PlatformMacOSX::GetSharedModule (const FileSpec &platform_file,
|
|
const ArchSpec &arch,
|
|
const UUID *uuid_ptr,
|
|
const ConstString *object_name_ptr,
|
|
off_t object_offset,
|
|
ModuleSP &module_sp,
|
|
ModuleSP *old_module_sp_ptr,
|
|
bool *did_create_ptr)
|
|
{
|
|
Error error;
|
|
module_sp.reset();
|
|
|
|
if (IsRemote())
|
|
{
|
|
// If we have a remote platform always, let it try and locate
|
|
// the shared module first.
|
|
if (m_remote_platform_sp)
|
|
{
|
|
error = m_remote_platform_sp->GetSharedModule (platform_file,
|
|
arch,
|
|
uuid_ptr,
|
|
object_name_ptr,
|
|
object_offset,
|
|
module_sp,
|
|
old_module_sp_ptr,
|
|
did_create_ptr);
|
|
}
|
|
}
|
|
|
|
if (!module_sp)
|
|
{
|
|
// Fall back to the local platform and find the file locally
|
|
error = Platform::GetSharedModule(platform_file,
|
|
arch,
|
|
uuid_ptr,
|
|
object_name_ptr,
|
|
object_offset,
|
|
module_sp,
|
|
old_module_sp_ptr,
|
|
did_create_ptr);
|
|
}
|
|
if (module_sp)
|
|
module_sp->SetPlatformFileSpec(platform_file);
|
|
return error;
|
|
}
|
|
|
|
bool
|
|
PlatformMacOSX::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
|
|
{
|
|
if (idx == 0)
|
|
{
|
|
arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture);
|
|
return arch.IsValid();
|
|
}
|
|
else if (idx == 1)
|
|
{
|
|
ArchSpec platform_arch (Host::GetArchitecture (Host::eSystemDefaultArchitecture));
|
|
ArchSpec platform_arch64 (Host::GetArchitecture (Host::eSystemDefaultArchitecture64));
|
|
if (platform_arch == platform_arch64)
|
|
{
|
|
// This macosx platform supports both 32 and 64 bit. Since we already
|
|
// returned the 64 bit arch for idx == 0, return the 32 bit arch
|
|
// for idx == 1
|
|
arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture32);
|
|
return arch.IsValid();
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|