PlatformMacOSX.cpp revision f96c883fde04b2ef8733812c16b0a07ad0cc7439
1//===-- PlatformMacOSX.cpp --------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#include "PlatformMacOSX.h" 11 12// C Includes 13#include <sys/sysctl.h> 14 15// C++ Includes 16// Other libraries and framework includes 17// Project includes 18#include "lldb/Core/Error.h" 19#include "lldb/Breakpoint/BreakpointLocation.h" 20#include "lldb/Core/Module.h" 21#include "lldb/Core/ModuleList.h" 22#include "lldb/Core/PluginManager.h" 23#include "lldb/Core/StreamString.h" 24#include "lldb/Host/FileSpec.h" 25#include "lldb/Host/Host.h" 26#include "lldb/Target/Process.h" 27#include "lldb/Target/Target.h" 28 29using namespace lldb; 30using namespace lldb_private; 31 32static uint32_t g_initialize_count = 0; 33 34void 35PlatformMacOSX::Initialize () 36{ 37 if (g_initialize_count++ == 0) 38 { 39#if defined (__APPLE__) 40 PlatformSP default_platform_sp (new PlatformMacOSX(true)); 41 default_platform_sp->SetSystemArchitecture (Host::GetArchitecture()); 42 Platform::SetDefaultPlatform (default_platform_sp); 43#endif 44 PluginManager::RegisterPlugin (PlatformMacOSX::GetShortPluginNameStatic(false), 45 PlatformMacOSX::GetDescriptionStatic(false), 46 PlatformMacOSX::CreateInstance); 47 } 48 49} 50 51void 52PlatformMacOSX::Terminate () 53{ 54 if (g_initialize_count > 0) 55 { 56 if (--g_initialize_count == 0) 57 { 58 PluginManager::UnregisterPlugin (PlatformMacOSX::CreateInstance); 59 } 60 } 61} 62 63Platform* 64PlatformMacOSX::CreateInstance () 65{ 66 // The only time we create an instance is when we are creating a remote 67 // macosx platform 68 const bool is_host = false; 69 return new PlatformMacOSX (is_host); 70} 71 72 73const char * 74PlatformMacOSX::GetPluginNameStatic () 75{ 76 return "PlatformMacOSX"; 77} 78 79const char * 80PlatformMacOSX::GetShortPluginNameStatic (bool is_host) 81{ 82 if (is_host) 83 return Platform::GetHostPlatformName (); 84 else 85 return "remote-macosx"; 86} 87 88const char * 89PlatformMacOSX::GetDescriptionStatic (bool is_host) 90{ 91 if (is_host) 92 return "Local Mac OS X user platform plug-in."; 93 else 94 return "Remote Mac OS X user platform plug-in."; 95} 96 97//------------------------------------------------------------------ 98/// Default Constructor 99//------------------------------------------------------------------ 100PlatformMacOSX::PlatformMacOSX (bool is_host) : 101 PlatformDarwin (is_host) 102{ 103} 104 105//------------------------------------------------------------------ 106/// Destructor. 107/// 108/// The destructor is virtual since this class is designed to be 109/// inherited from by the plug-in instance. 110//------------------------------------------------------------------ 111PlatformMacOSX::~PlatformMacOSX() 112{ 113} 114 115Error 116PlatformMacOSX::GetFile (const FileSpec &platform_file, 117 const UUID *uuid_ptr, 118 FileSpec &local_file) 119{ 120 if (IsRemote()) 121 { 122 if (m_remote_platform_sp) 123 return m_remote_platform_sp->GetFile (platform_file, uuid_ptr, local_file); 124 } 125 126 // Default to the local case 127 local_file = platform_file; 128 return Error(); 129} 130 131bool 132PlatformMacOSX::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch) 133{ 134#if defined (__arm__) 135 return ARMGetSupportedArchitectureAtIndex (idx, arch); 136#else 137 return x86GetSupportedArchitectureAtIndex (idx, arch); 138#endif 139} 140 141