[Lldb-commits] [lldb] r151436 - in /lldb/trunk: lldb.xcodeproj/ source/ source/Host/macosx/ source/Host/macosx/launcherXPCService/ source/Plugins/Platform/MacOSX/
Greg Clayton
gclayton at apple.com
Fri Feb 24 22:56:35 PST 2012
Author: gclayton
Date: Sat Feb 25 00:56:35 2012
New Revision: 151436
URL: http://llvm.org/viewvc/llvm-project?rev=151436&view=rev
Log:
<rdar://problem/9886712>
Added a dedicated platform for the iOS simulator. This helps us to find the
correct files for a simulator binary before running and helps us select the
right arch (i386 only) for files when we load them.
Added:
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h
Modified:
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/Host/macosx/Host.mm
lldb/trunk/source/Host/macosx/launcherXPCService/LauncherXPCService.mm
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
lldb/trunk/source/lldb.cpp
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=151436&r1=151435&r2=151436&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sat Feb 25 00:56:35 2012
@@ -344,6 +344,8 @@
26B1FCBC13381071002886E2 /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C37410F3F61B009D5894 /* libobjc.dylib */; };
26B1FCC21338115F002886E2 /* Host.mm in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EE810F1B88F00F91463 /* Host.mm */; };
26B42C4D1187ABA50079C8C8 /* LLDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B42C4C1187ABA50079C8C8 /* LLDB.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 26B7564E14F89356008D9CB3 /* PlatformiOSSimulator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26B7564C14F89356008D9CB3 /* PlatformiOSSimulator.cpp */; };
+ 26B7564F14F89356008D9CB3 /* PlatformiOSSimulator.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B7564D14F89356008D9CB3 /* PlatformiOSSimulator.h */; };
26B8283D142D01E9002DBC64 /* SBSection.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B8283C142D01E9002DBC64 /* SBSection.h */; settings = {ATTRIBUTES = (Public, ); }; };
26B82840142D020F002DBC64 /* SBSection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26B8283F142D020F002DBC64 /* SBSection.cpp */; };
26BCFC521368AE38006DC050 /* OptionGroupFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BCFC511368AE38006DC050 /* OptionGroupFormat.cpp */; };
@@ -825,6 +827,8 @@
26B167A41123BF5500DC7B4F /* ThreadSafeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadSafeValue.h; path = include/lldb/Core/ThreadSafeValue.h; sourceTree = "<group>"; };
26B42C4C1187ABA50079C8C8 /* LLDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LLDB.h; path = include/lldb/API/LLDB.h; sourceTree = "<group>"; };
26B4E26E112F35F700AB3F64 /* TimeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TimeValue.h; path = include/lldb/Host/TimeValue.h; sourceTree = "<group>"; };
+ 26B7564C14F89356008D9CB3 /* PlatformiOSSimulator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformiOSSimulator.cpp; sourceTree = "<group>"; };
+ 26B7564D14F89356008D9CB3 /* PlatformiOSSimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformiOSSimulator.h; sourceTree = "<group>"; };
26B8283C142D01E9002DBC64 /* SBSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBSection.h; path = include/lldb/API/SBSection.h; sourceTree = "<group>"; };
26B8283F142D020F002DBC64 /* SBSection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBSection.cpp; path = source/API/SBSection.cpp; sourceTree = "<group>"; };
26B8B42212EEC52A00A831B2 /* UniqueDWARFASTType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UniqueDWARFASTType.h; sourceTree = "<group>"; };
@@ -2723,6 +2727,8 @@
children = (
2697A54B133A6305004E4240 /* PlatformDarwin.cpp */,
2697A54C133A6305004E4240 /* PlatformDarwin.h */,
+ 26B7564C14F89356008D9CB3 /* PlatformiOSSimulator.cpp */,
+ 26B7564D14F89356008D9CB3 /* PlatformiOSSimulator.h */,
26C5577B132575AD008FD8FE /* PlatformMacOSX.cpp */,
26C5577C132575AD008FD8FE /* PlatformMacOSX.h */,
2675F6FE1332BE690067997B /* PlatformRemoteiOS.cpp */,
@@ -3020,6 +3026,7 @@
26A527C214E24F5F00F3A14A /* ProcessMachCore.h in Headers */,
26A527C414E24F5F00F3A14A /* ThreadMachCore.h in Headers */,
4C6649A014EEE7F100B0316F /* StreamCallback.h in Headers */,
+ 26B7564F14F89356008D9CB3 /* PlatformiOSSimulator.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -3741,6 +3748,7 @@
26A527C314E24F5F00F3A14A /* ThreadMachCore.cpp in Sources */,
4C6649A314EEE81000B0316F /* StreamCallback.cpp in Sources */,
B299580B14F2FA1400050A04 /* DisassemblerLLVMC.cpp in Sources */,
+ 26B7564E14F89356008D9CB3 /* PlatformiOSSimulator.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: lldb/trunk/source/Host/macosx/Host.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=151436&r1=151435&r2=151436&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Host.mm (original)
+++ lldb/trunk/source/Host/macosx/Host.mm Sat Feb 25 00:56:35 2012
@@ -16,6 +16,7 @@
#endif
#if !BUILDING_ON_SNOW_LEOPARD
+#define __XPC_PRIVATE_H__
#include <xpc/xpc.h>
#include "LauncherXPCService.h"
#endif
Modified: lldb/trunk/source/Host/macosx/launcherXPCService/LauncherXPCService.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/launcherXPCService/LauncherXPCService.mm?rev=151436&r1=151435&r2=151436&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/launcherXPCService/LauncherXPCService.mm (original)
+++ lldb/trunk/source/Host/macosx/launcherXPCService/LauncherXPCService.mm Sat Feb 25 00:56:35 2012
@@ -11,6 +11,7 @@
#endif
#if !BUILDING_ON_SNOW_LEOPARD
+#define __XPC_PRIVATE_H__
#include <xpc/xpc.h>
#include <spawn.h>
#include <signal.h>
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=151436&r1=151435&r2=151436&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Sat Feb 25 00:56:35 2012
@@ -28,7 +28,8 @@
//------------------------------------------------------------------
PlatformDarwin::PlatformDarwin (bool is_host) :
Platform(is_host), // This is the local host platform
- m_remote_platform_sp ()
+ m_remote_platform_sp (),
+ m_developer_directory ()
{
}
@@ -601,6 +602,30 @@
}
+bool
+PlatformDarwin::x86GetSupportedArchitectureAtIndex (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;
+}
+
// The architecture selection rules for arm processors
// These cpu subtypes have distinct names (e.g. armv7f) but armv7 binaries run fine on an armv7f processor.
@@ -710,3 +735,78 @@
arch.Clear();
return false;
}
+
+
+const char *
+PlatformDarwin::GetDeveloperDirectory()
+{
+ if (m_developer_directory.empty())
+ {
+ bool developer_dir_path_valid = false;
+ char developer_dir_path[PATH_MAX];
+ FileSpec temp_file_spec;
+ if (Host::GetLLDBPath (ePathTypeLLDBShlibDir, temp_file_spec))
+ {
+ if (temp_file_spec.GetPath (developer_dir_path, sizeof(developer_dir_path)))
+ {
+ char *shared_frameworks = strstr (developer_dir_path, "/SharedFrameworks/LLDB.framework");
+ if (shared_frameworks)
+ {
+ ::snprintf (shared_frameworks,
+ sizeof(developer_dir_path) - (shared_frameworks - developer_dir_path),
+ "/Developer");
+ developer_dir_path_valid = true;
+ }
+ else
+ {
+ char *lib_priv_frameworks = strstr (developer_dir_path, "/Library/PrivateFrameworks/LLDB.framework");
+ if (lib_priv_frameworks)
+ {
+ *lib_priv_frameworks = '\0';
+ developer_dir_path_valid = true;
+ }
+ }
+ }
+ }
+
+ if (!developer_dir_path_valid)
+ {
+ std::string xcode_dir_path;
+ const char *xcode_select_prefix_dir = getenv ("XCODE_SELECT_PREFIX_DIR");
+ if (xcode_select_prefix_dir)
+ xcode_dir_path.append (xcode_select_prefix_dir);
+ xcode_dir_path.append ("/usr/share/xcode-select/xcode_dir_path");
+ temp_file_spec.SetFile(xcode_dir_path.c_str(), false);
+ size_t bytes_read = temp_file_spec.ReadFileContents(0, developer_dir_path, sizeof(developer_dir_path), NULL);
+ if (bytes_read > 0)
+ {
+ developer_dir_path[bytes_read] = '\0';
+ while (developer_dir_path[bytes_read-1] == '\r' ||
+ developer_dir_path[bytes_read-1] == '\n')
+ developer_dir_path[--bytes_read] = '\0';
+ developer_dir_path_valid = true;
+ }
+ }
+
+ if (developer_dir_path_valid)
+ {
+ temp_file_spec.SetFile (developer_dir_path, false);
+ if (temp_file_spec.Exists())
+ {
+ m_developer_directory.assign (developer_dir_path);
+ return m_developer_directory.c_str();
+ }
+ }
+ // Assign a single NULL character so we know we tried to find the device
+ // support directory and we don't keep trying to find it over and over.
+ m_developer_directory.assign (1, '\0');
+ }
+
+ // We should have put a single NULL character into m_developer_directory
+ // or it should have a valid path if the code gets here
+ assert (m_developer_directory.empty() == false);
+ if (m_developer_directory[0])
+ return m_developer_directory.c_str();
+ return NULL;
+}
+
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h?rev=151436&r1=151435&r2=151436&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h Sat Feb 25 00:56:35 2012
@@ -100,10 +100,18 @@
virtual bool
ModuleIsExcludedForNonModuleSpecificSearches (lldb_private::Target &target, const lldb::ModuleSP &module_sp);
- bool ARMGetSupportedArchitectureAtIndex (uint32_t idx, lldb_private::ArchSpec &arch);
+ bool
+ ARMGetSupportedArchitectureAtIndex (uint32_t idx, lldb_private::ArchSpec &arch);
+
+ bool
+ x86GetSupportedArchitectureAtIndex (uint32_t idx, lldb_private::ArchSpec &arch);
protected:
lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a remote darwin OS
+ std::string m_developer_directory;
+
+ const char *
+ GetDeveloperDirectory();
private:
DISALLOW_COPY_AND_ASSIGN (PlatformDarwin);
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp?rev=151436&r1=151435&r2=151436&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp Sat Feb 25 00:56:35 2012
@@ -133,26 +133,8 @@
{
#if defined (__arm__)
return ARMGetSupportedArchitectureAtIndex (idx, arch);
+#else
+ return x86GetSupportedArchitectureAtIndex (idx, arch);
#endif
-
- 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;
}
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp?rev=151436&r1=151435&r2=151436&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp Sat Feb 25 00:56:35 2012
@@ -90,7 +90,6 @@
//------------------------------------------------------------------
PlatformRemoteiOS::PlatformRemoteiOS () :
PlatformDarwin (false), // This is a remote platform
- m_device_support_directory (),
m_device_support_directory_for_os_version ()
{
}
@@ -209,68 +208,6 @@
}
const char *
-PlatformRemoteiOS::GetDeviceSupportDirectory()
-{
- if (m_device_support_directory.empty())
- {
- bool developer_dir_path_valid = false;
- char developer_dir_path[PATH_MAX];
- FileSpec temp_file_spec;
- if (Host::GetLLDBPath (ePathTypeLLDBShlibDir, temp_file_spec))
- {
- if (temp_file_spec.GetPath (developer_dir_path, sizeof(developer_dir_path)))
- {
- char *lib_priv_frameworks = strstr (developer_dir_path, "/Library/PrivateFrameworks/LLDB.framework");
- if (lib_priv_frameworks)
- {
- *lib_priv_frameworks = '\0';
- developer_dir_path_valid = true;
- }
- }
- }
-
- if (!developer_dir_path_valid)
- {
- std::string xcode_dir_path;
- const char *xcode_select_prefix_dir = getenv ("XCODE_SELECT_PREFIX_DIR");
- if (xcode_select_prefix_dir)
- xcode_dir_path.append (xcode_select_prefix_dir);
- xcode_dir_path.append ("/usr/share/xcode-select/xcode_dir_path");
- temp_file_spec.SetFile(xcode_dir_path.c_str(), false);
- size_t bytes_read = temp_file_spec.ReadFileContents(0, developer_dir_path, sizeof(developer_dir_path), NULL);
- if (bytes_read > 0)
- {
- developer_dir_path[bytes_read] = '\0';
- while (developer_dir_path[bytes_read-1] == '\r' ||
- developer_dir_path[bytes_read-1] == '\n')
- developer_dir_path[--bytes_read] = '\0';
- developer_dir_path_valid = true;
- }
- }
-
- if (developer_dir_path_valid)
- {
- temp_file_spec.SetFile (developer_dir_path, false);
- if (temp_file_spec.Exists())
- {
- m_device_support_directory.assign (developer_dir_path);
- return m_device_support_directory.c_str();
- }
- }
- // Assign a single NULL character so we know we tried to find the device
- // support directory and we don't keep trying to find it over and over.
- m_device_support_directory.assign (1, '\0');
- }
-
- // We should have put a single NULL character into m_device_support_directory
- // or it should have a valid path if the code gets here
- assert (m_device_support_directory.empty() == false);
- if (m_device_support_directory[0])
- return m_device_support_directory.c_str();
- return NULL;
-}
-
-const char *
PlatformRemoteiOS::GetDeviceSupportDirectoryForOSVersion()
{
if (m_sdk_sysroot)
@@ -278,7 +215,7 @@
if (m_device_support_directory_for_os_version.empty())
{
- const char *device_support_dir = GetDeviceSupportDirectory();
+ const char *device_support_dir = GetDeveloperDirectory();
const bool resolve_path = true;
if (device_support_dir)
{
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h?rev=151436&r1=151435&r2=151436&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h Sat Feb 25 00:56:35 2012
@@ -117,15 +117,11 @@
lldb_private::ArchSpec &arch);
protected:
- std::string m_device_support_directory;
std::string m_device_support_directory_for_os_version;
std::string m_build_update;
//std::vector<FileSpec> m_device_support_os_dirs;
const char *
- GetDeviceSupportDirectory();
-
- const char *
GetDeviceSupportDirectoryForOSVersion();
private:
Added: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp?rev=151436&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp (added)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp Sat Feb 25 00:56:35 2012
@@ -0,0 +1,387 @@
+//===-- PlatformiOSSimulator.cpp -----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "PlatformiOSSimulator.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Breakpoint/BreakpointLocation.h"
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Core/Error.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 Variables
+//------------------------------------------------------------------
+static uint32_t g_initialize_count = 0;
+
+//------------------------------------------------------------------
+// Static Functions
+//------------------------------------------------------------------
+void
+PlatformiOSSimulator::Initialize ()
+{
+ if (g_initialize_count++ == 0)
+ {
+ PluginManager::RegisterPlugin (PlatformiOSSimulator::GetShortPluginNameStatic(),
+ PlatformiOSSimulator::GetDescriptionStatic(),
+ PlatformiOSSimulator::CreateInstance);
+ }
+}
+
+void
+PlatformiOSSimulator::Terminate ()
+{
+ if (g_initialize_count > 0)
+ {
+ if (--g_initialize_count == 0)
+ {
+ PluginManager::UnregisterPlugin (PlatformiOSSimulator::CreateInstance);
+ }
+ }
+}
+
+Platform*
+PlatformiOSSimulator::CreateInstance ()
+{
+ return new PlatformiOSSimulator ();
+}
+
+
+const char *
+PlatformiOSSimulator::GetPluginNameStatic ()
+{
+ return "PlatformiOSSimulator";
+}
+
+const char *
+PlatformiOSSimulator::GetShortPluginNameStatic()
+{
+ return "ios-simulator";
+}
+
+const char *
+PlatformiOSSimulator::GetDescriptionStatic()
+{
+ return "iOS simulator platform plug-in.";
+}
+
+
+//------------------------------------------------------------------
+/// Default Constructor
+//------------------------------------------------------------------
+PlatformiOSSimulator::PlatformiOSSimulator () :
+ PlatformDarwin (false),
+ m_sdk_directory ()
+{
+}
+
+//------------------------------------------------------------------
+/// Destructor.
+///
+/// The destructor is virtual since this class is designed to be
+/// inherited from by the plug-in instance.
+//------------------------------------------------------------------
+PlatformiOSSimulator::~PlatformiOSSimulator()
+{
+}
+
+
+void
+PlatformiOSSimulator::GetStatus (Stream &strm)
+{
+ Platform::GetStatus (strm);
+ const char *sdk_directory = GetSDKDirectory();
+ if (sdk_directory)
+ strm.Printf (" SDK Path: \"%s\"\n", sdk_directory);
+ else
+ strm.PutCString (" SDK Path: error: unable to locate SDK\n");
+}
+
+
+Error
+PlatformiOSSimulator::ResolveExecutable (const FileSpec &exe_file,
+ const ArchSpec &exe_arch,
+ lldb::ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr)
+{
+ Error error;
+ // Nothing special to do here, just use the actual file and architecture
+
+ FileSpec resolved_exe_file (exe_file);
+
+ // If we have "ls" as the exe_file, resolve the executable loation based on
+ // the current path variables
+ // TODO: resolve bare executables in the Platform SDK
+// if (!resolved_exe_file.Exists())
+// resolved_exe_file.ResolveExecutableLocation ();
+
+ // Resolve any executable within a bundle on MacOSX
+ // TODO: verify that this handles shallow bundles, if not then implement one ourselves
+ Host::ResolveExecutableInBundle (resolved_exe_file);
+
+ if (resolved_exe_file.Exists())
+ {
+ if (exe_arch.IsValid())
+ {
+ error = ModuleList::GetSharedModule (resolved_exe_file,
+ exe_arch,
+ NULL,
+ NULL,
+ 0,
+ exe_module_sp,
+ NULL,
+ NULL,
+ NULL);
+
+ if (exe_module_sp->GetObjectFile())
+ return error;
+ exe_module_sp.reset();
+ }
+ // No valid architecture was specified or the exact ARM slice wasn't
+ // found so ask the platform for the architectures that we should be
+ // using (in the correct order) and see if we can find a match that way
+ StreamString arch_names;
+ ArchSpec platform_arch;
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, platform_arch); ++idx)
+ {
+ error = ModuleList::GetSharedModule (resolved_exe_file,
+ platform_arch,
+ NULL,
+ NULL,
+ 0,
+ exe_module_sp,
+ NULL,
+ NULL,
+ NULL);
+ // Did we find an executable using one of the
+ if (error.Success())
+ {
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ break;
+ else
+ error.SetErrorToGenericError();
+ }
+
+ if (idx > 0)
+ arch_names.PutCString (", ");
+ arch_names.PutCString (platform_arch.GetArchitectureName());
+ }
+
+ if (error.Fail() || !exe_module_sp)
+ {
+ error.SetErrorStringWithFormat ("'%s%s%s' doesn't contain any '%s' platform architectures: %s",
+ exe_file.GetDirectory().AsCString(""),
+ exe_file.GetDirectory() ? "/" : "",
+ exe_file.GetFilename().AsCString(""),
+ GetShortPluginName(),
+ arch_names.GetString().c_str());
+ }
+ }
+ else
+ {
+ error.SetErrorStringWithFormat ("'%s%s%s' does not exist",
+ exe_file.GetDirectory().AsCString(""),
+ exe_file.GetDirectory() ? "/" : "",
+ exe_file.GetFilename().AsCString(""));
+ }
+
+ return error;
+}
+
+static FileSpec::EnumerateDirectoryResult
+EnumerateDirectoryCallback (void *baton, FileSpec::FileType file_type, const FileSpec &file_spec)
+{
+ if (file_type == FileSpec::eFileTypeDirectory)
+ {
+ const char *filename = file_spec.GetFilename().GetCString();
+ if (filename && strncmp(filename, "iPhoneSimulator", strlen ("iPhoneSimulator")) == 0)
+ {
+ ::snprintf ((char *)baton, PATH_MAX, "%s", filename);
+ return FileSpec::eEnumerateDirectoryResultQuit;
+ }
+ }
+ return FileSpec::eEnumerateDirectoryResultNext;
+}
+
+
+
+const char *
+PlatformiOSSimulator::GetSDKDirectory()
+{
+ if (m_sdk_directory.empty())
+ {
+ const char *developer_dir = GetDeveloperDirectory();
+ if (developer_dir)
+ {
+ char sdks_directory[PATH_MAX];
+ char sdk_dirname[PATH_MAX];
+ sdk_dirname[0] = '\0';
+ snprintf (sdks_directory,
+ sizeof(sdks_directory),
+ "%s/Platforms/iPhoneSimulator.platform/Developer/SDKs",
+ developer_dir);
+ FileSpec simulator_sdk_spec;
+ bool find_directories = true;
+ bool find_files = false;
+ bool find_other = false;
+ FileSpec::EnumerateDirectory (sdks_directory,
+ find_directories,
+ find_files,
+ find_other,
+ EnumerateDirectoryCallback,
+ sdk_dirname);
+
+ if (sdk_dirname[0])
+ {
+ m_sdk_directory = sdks_directory;
+ m_sdk_directory.append (1, '/');
+ m_sdk_directory.append (sdk_dirname);
+ return m_sdk_directory.c_str();
+ }
+ }
+ // Assign a single NULL character so we know we tried to find the device
+ // support directory and we don't keep trying to find it over and over.
+ m_sdk_directory.assign (1, '\0');
+ }
+
+ // We should have put a single NULL character into m_sdk_directory
+ // or it should have a valid path if the code gets here
+ assert (m_sdk_directory.empty() == false);
+ if (m_sdk_directory[0])
+ return m_sdk_directory.c_str();
+ return NULL;
+}
+
+Error
+PlatformiOSSimulator::GetFile (const FileSpec &platform_file,
+ const UUID *uuid_ptr,
+ FileSpec &local_file)
+{
+ Error error;
+ char platform_file_path[PATH_MAX];
+ if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path)))
+ {
+ char resolved_path[PATH_MAX];
+
+ const char * sdk_dir = GetSDKDirectory();
+ if (sdk_dir)
+ {
+ ::snprintf (resolved_path,
+ sizeof(resolved_path),
+ "%s/%s",
+ sdk_dir,
+ platform_file_path);
+
+ // First try in the SDK and see if the file is in there
+ local_file.SetFile(resolved_path, true);
+ if (local_file.Exists())
+ return error;
+
+ // Else fall back to the actual path itself
+ local_file.SetFile(platform_file_path, true);
+ if (local_file.Exists())
+ return error;
+
+ }
+ error.SetErrorStringWithFormat ("unable to locate a platform file for '%s' in platform '%s'",
+ platform_file_path,
+ GetPluginName());
+ }
+ else
+ {
+ error.SetErrorString ("invalid platform file argument");
+ }
+ return error;
+}
+
+Error
+PlatformiOSSimulator::GetSharedModule (const FileSpec &platform_file,
+ const ArchSpec &arch,
+ const UUID *uuid_ptr,
+ const ConstString *object_name_ptr,
+ off_t object_offset,
+ ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr,
+ ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr)
+{
+ // For iOS, the SDK files are all cached locally on the host
+ // system. So first we ask for the file in the cached SDK,
+ // then we attempt to get a shared module for the right architecture
+ // with the right UUID.
+ Error error;
+ FileSpec local_file;
+ error = GetFile (platform_file, uuid_ptr, local_file);
+ if (error.Success())
+ {
+ error = ResolveExecutable (local_file, arch, module_sp, module_search_paths_ptr);
+ }
+ else
+ {
+ const bool always_create = false;
+ error = ModuleList::GetSharedModule (platform_file,
+ arch,
+ uuid_ptr,
+ object_name_ptr,
+ object_offset,
+ module_sp,
+ module_search_paths_ptr,
+ old_module_sp_ptr,
+ did_create_ptr,
+ always_create);
+
+ }
+ if (module_sp)
+ module_sp->SetPlatformFileSpec(platform_file);
+
+ return error;
+}
+
+
+uint32_t
+PlatformiOSSimulator::FindProcesses (const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos)
+{
+ // TODO: if connected, send a packet to get the remote process infos by name
+ process_infos.Clear();
+ return 0;
+}
+
+bool
+PlatformiOSSimulator::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
+{
+ // TODO: if connected, send a packet to get the remote process info
+ process_info.Clear();
+ return false;
+}
+
+bool
+PlatformiOSSimulator::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
+{
+ if (idx == 0)
+ {
+ // All iOS simulator binaries are currently i386
+ arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture32);
+ return arch.IsValid();
+ }
+ return false;
+}
Added: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h?rev=151436&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h (added)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h Sat Feb 25 00:56:35 2012
@@ -0,0 +1,132 @@
+//===-- PlatformiOSSimulator.h ----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_PlatformiOSSimulator_h_
+#define liblldb_PlatformiOSSimulator_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "PlatformDarwin.h"
+
+class PlatformiOSSimulator : public PlatformDarwin
+{
+public:
+
+ //------------------------------------------------------------
+ // Class Functions
+ //------------------------------------------------------------
+ static lldb_private::Platform*
+ CreateInstance ();
+
+ static void
+ Initialize ();
+
+ static void
+ Terminate ();
+
+ static const char *
+ GetPluginNameStatic ();
+
+ static const char *
+ GetShortPluginNameStatic();
+
+ static const char *
+ GetDescriptionStatic();
+
+ //------------------------------------------------------------
+ // Class Methods
+ //------------------------------------------------------------
+ PlatformiOSSimulator ();
+
+ virtual
+ ~PlatformiOSSimulator();
+
+ //------------------------------------------------------------
+ // lldb_private::PluginInterface functions
+ //------------------------------------------------------------
+ virtual const char *
+ GetPluginName()
+ {
+ return GetPluginNameStatic();
+ }
+
+ virtual const char *
+ GetShortPluginName()
+ {
+ return GetShortPluginNameStatic();
+ }
+
+ virtual uint32_t
+ GetPluginVersion()
+ {
+ return 1;
+ }
+
+ //------------------------------------------------------------
+ // lldb_private::Platform functions
+ //------------------------------------------------------------
+ virtual lldb_private::Error
+ ResolveExecutable (const lldb_private::FileSpec &exe_file,
+ const lldb_private::ArchSpec &arch,
+ lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr);
+
+ virtual const char *
+ GetDescription ()
+ {
+ return GetDescriptionStatic();
+ }
+
+ virtual void
+ GetStatus (lldb_private::Stream &strm);
+
+ virtual lldb_private::Error
+ GetFile (const lldb_private::FileSpec &platform_file,
+ const lldb_private::UUID *uuid_ptr,
+ lldb_private::FileSpec &local_file);
+
+ virtual lldb_private::Error
+ GetSharedModule (const lldb_private::FileSpec &platform_file,
+ const lldb_private::ArchSpec &arch,
+ const lldb_private::UUID *uuid_ptr,
+ const lldb_private::ConstString *object_name_ptr,
+ off_t object_offset,
+ lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr,
+ lldb::ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr);
+
+ virtual uint32_t
+ FindProcesses (const lldb_private::ProcessInstanceInfoMatch &match_info,
+ lldb_private::ProcessInstanceInfoList &process_infos);
+
+ virtual bool
+ GetProcessInfo (lldb::pid_t pid,
+ lldb_private::ProcessInstanceInfo &proc_info);
+
+ virtual bool
+ GetSupportedArchitectureAtIndex (uint32_t idx,
+ lldb_private::ArchSpec &arch);
+
+protected:
+ std::string m_sdk_directory;
+ std::string m_build_update;
+ //std::vector<FileSpec> m_device_support_os_dirs;
+
+ const char *
+ GetSDKDirectory();
+
+private:
+ DISALLOW_COPY_AND_ASSIGN (PlatformiOSSimulator);
+
+};
+
+#endif // liblldb_PlatformiOSSimulator_h_
Modified: lldb/trunk/source/lldb.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=151436&r1=151435&r2=151436&view=diff
==============================================================================
--- lldb/trunk/source/lldb.cpp (original)
+++ lldb/trunk/source/lldb.cpp Sat Feb 25 00:56:35 2012
@@ -50,6 +50,7 @@
#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
+#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
#endif
#include "Plugins/Process/mach-core/ProcessMachCore.h"
@@ -125,6 +126,7 @@
SymbolVendorMacOSX::Initialize();
PlatformMacOSX::Initialize();
PlatformRemoteiOS::Initialize();
+ PlatformiOSSimulator::Initialize();
#endif
#if defined (__linux__)
//----------------------------------------------------------------------
@@ -202,6 +204,7 @@
SymbolVendorMacOSX::Terminate();
PlatformMacOSX::Terminate();
PlatformRemoteiOS::Terminate();
+ PlatformiOSSimulator::Terminate();
#endif
Debugger::SettingsTerminate ();
More information about the lldb-commits
mailing list