diff options
author | Greg Clayton <gclayton@apple.com> | 2012-02-25 06:56:35 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2012-02-25 06:56:35 +0000 |
commit | 722cec2957b44766879b936c0b2dfb9d2f1a5e4f (patch) | |
tree | 1b5cfb8ee61f03a39a0a6d451f0e3ac1ee9edd32 /lldb/source | |
parent | a4d6bc9ff85fc4eb979765f3ea8bd53fa4f3496a (diff) | |
download | bcm5719-llvm-722cec2957b44766879b936c0b2dfb9d2f1a5e4f.tar.gz bcm5719-llvm-722cec2957b44766879b936c0b2dfb9d2f1a5e4f.zip |
<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.
llvm-svn: 151436
Diffstat (limited to 'lldb/source')
-rw-r--r-- | lldb/source/Host/macosx/Host.mm | 1 | ||||
-rw-r--r-- | lldb/source/Host/macosx/launcherXPCService/LauncherXPCService.mm | 1 | ||||
-rw-r--r-- | lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp | 102 | ||||
-rw-r--r-- | lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h | 10 | ||||
-rw-r--r-- | lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp | 22 | ||||
-rw-r--r-- | lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp | 65 | ||||
-rw-r--r-- | lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h | 4 | ||||
-rw-r--r-- | lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp | 387 | ||||
-rw-r--r-- | lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h | 132 | ||||
-rw-r--r-- | lldb/source/lldb.cpp | 3 |
10 files changed, 637 insertions, 90 deletions
diff --git a/lldb/source/Host/macosx/Host.mm b/lldb/source/Host/macosx/Host.mm index 944f05a4d56..8d845b47fbc 100644 --- a/lldb/source/Host/macosx/Host.mm +++ b/lldb/source/Host/macosx/Host.mm @@ -16,6 +16,7 @@ #endif #if !BUILDING_ON_SNOW_LEOPARD +#define __XPC_PRIVATE_H__ #include <xpc/xpc.h> #include "LauncherXPCService.h" #endif diff --git a/lldb/source/Host/macosx/launcherXPCService/LauncherXPCService.mm b/lldb/source/Host/macosx/launcherXPCService/LauncherXPCService.mm index 9ffae6d3f58..a5c0c6a2093 100644 --- a/lldb/source/Host/macosx/launcherXPCService/LauncherXPCService.mm +++ b/lldb/source/Host/macosx/launcherXPCService/LauncherXPCService.mm @@ -11,6 +11,7 @@ #endif #if !BUILDING_ON_SNOW_LEOPARD +#define __XPC_PRIVATE_H__ #include <xpc/xpc.h> #include <spawn.h> #include <signal.h> diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index 5bfae0be4ce..c07b134a0be 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -28,7 +28,8 @@ using namespace lldb_private; //------------------------------------------------------------------ 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 @@ PlatformDarwin::ModuleIsExcludedForNonModuleSpecificSearches (lldb_private::Targ } +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 @@ PlatformDarwin::ARMGetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch 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; +} + diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h index abb8326d1e7..a36422f684b 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h @@ -100,10 +100,18 @@ public: 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); diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp index 3ca4dd604cf..6262c59c133 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp @@ -133,26 +133,8 @@ PlatformMacOSX::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch) { #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; } diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp index 4a32e718e72..5210682667e 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp @@ -90,7 +90,6 @@ PlatformRemoteiOS::GetDescriptionStatic() //------------------------------------------------------------------ PlatformRemoteiOS::PlatformRemoteiOS () : PlatformDarwin (false), // This is a remote platform - m_device_support_directory (), m_device_support_directory_for_os_version () { } @@ -209,68 +208,6 @@ PlatformRemoteiOS::ResolveExecutable (const FileSpec &exe_file, } 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 @@ PlatformRemoteiOS::GetDeviceSupportDirectoryForOSVersion() 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) { diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h index 13fd11e5a9b..2815a95ca89 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h @@ -117,15 +117,11 @@ public: 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: diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp new file mode 100644 index 00000000000..623c0a793e7 --- /dev/null +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp @@ -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; +} diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h new file mode 100644 index 00000000000..9842bf673d9 --- /dev/null +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h @@ -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_ diff --git a/lldb/source/lldb.cpp b/lldb/source/lldb.cpp index d71a46bca0e..d4eb7820a00 100644 --- a/lldb/source/lldb.cpp +++ b/lldb/source/lldb.cpp @@ -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 @@ lldb_private::Initialize () SymbolVendorMacOSX::Initialize(); PlatformMacOSX::Initialize(); PlatformRemoteiOS::Initialize(); + PlatformiOSSimulator::Initialize(); #endif #if defined (__linux__) //---------------------------------------------------------------------- @@ -202,6 +204,7 @@ lldb_private::Terminate () SymbolVendorMacOSX::Terminate(); PlatformMacOSX::Terminate(); PlatformRemoteiOS::Terminate(); + PlatformiOSSimulator::Terminate(); #endif Debugger::SettingsTerminate (); |