<div dir="ltr">Whoops.  The inclusion of <dlfcn.h> breaks non-POSIX platforms like Windows.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 4, 2015 at 4:46 PM, Enrico Granata via lldb-commits <span dir="ltr"><<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: enrico<br>
Date: Wed Nov  4 18:46:25 2015<br>
New Revision: 252112<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=252112&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=252112&view=rev</a><br>
Log:<br>
Teach LLDB how to directly launch processes on the iOS simulator<br>
<br>
This allows for command-line debugging of iOS simulator binaries (as long as UI is not required, or a full UI simulator has previously been otherwise launched), as well as execution of the LLDB test suite on the iOS simulator<br>
<br>
This is known to compile on OSX 10.11 GM - feedback from people on other platforms and/or older versions of OSX as to the buildability of this code is greatly appreciated<br>
<br>
<br>
Added:<br>
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp<br>
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h<br>
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.h<br>
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm<br>
Modified:<br>
    lldb/trunk/lldb.xcodeproj/project.pbxproj<br>
    lldb/trunk/packages/Python/lldbsuite/test/dotest.py<br>
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py<br>
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py<br>
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/TestRegisters.py<br>
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py<br>
    lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py<br>
    lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules<br>
    lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py<br>
    lldb/trunk/source/Plugins/Platform/MacOSX/CMakeLists.txt<br>
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp<br>
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h<br>
<br>
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=252112&r1=252111&r2=252112&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=252112&r1=252111&r2=252112&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)<br>
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Nov  4 18:46:25 2015<br>
@@ -772,6 +772,8 @@<br>
                945261C51B9A11FC00BF138D /* LibCxxVector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261BB1B9A11E800BF138D /* LibCxxVector.cpp */; };<br>
                945261C61B9A11FC00BF138D /* LibStdcpp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261BC1B9A11E800BF138D /* LibStdcpp.cpp */; };<br>
                945261C81B9A14D300BF138D /* CXXFunctionPointer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261C71B9A14D300BF138D /* CXXFunctionPointer.cpp */; };<br>
+               9455630F1BEAD0600073F75F /* PlatformAppleSimulator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9455630A1BEAD0570073F75F /* PlatformAppleSimulator.cpp */; };<br>
+               945563101BEAD0650073F75F /* PlatformiOSSimulatorCoreSimulatorSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9455630D1BEAD0570073F75F /* PlatformiOSSimulatorCoreSimulatorSupport.mm */; };<br>
                945759671534941F005A9070 /* PlatformPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945759651534941F005A9070 /* PlatformPOSIX.cpp */; };<br>
                945E8D80152F6AB40019BCCD /* StreamGDBRemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945E8D7F152F6AB40019BCCD /* StreamGDBRemote.cpp */; };<br>
                9461569A14E358A6003A195C /* SBTypeFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568A14E35621003A195C /* SBTypeFilter.cpp */; };<br>
@@ -2523,6 +2525,10 @@<br>
                945261BD1B9A11E800BF138D /* LibStdcpp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = LibStdcpp.h; path = Language/CPlusPlus/LibStdcpp.h; sourceTree = "<group>"; };<br>
                945261C71B9A14D300BF138D /* CXXFunctionPointer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CXXFunctionPointer.cpp; path = source/DataFormatters/CXXFunctionPointer.cpp; sourceTree = "<group>"; };<br>
                945261C91B9A14E000BF138D /* CXXFunctionPointer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CXXFunctionPointer.h; path = include/lldb/DataFormatters/CXXFunctionPointer.h; sourceTree = "<group>"; };<br>
+               9455630A1BEAD0570073F75F /* PlatformAppleSimulator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformAppleSimulator.cpp; sourceTree = "<group>"; };<br>
+               9455630B1BEAD0570073F75F /* PlatformAppleSimulator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlatformAppleSimulator.h; sourceTree = "<group>"; };<br>
+               9455630C1BEAD0570073F75F /* PlatformiOSSimulatorCoreSimulatorSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlatformiOSSimulatorCoreSimulatorSupport.h; sourceTree = "<group>"; };<br>
+               9455630D1BEAD0570073F75F /* PlatformiOSSimulatorCoreSimulatorSupport.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformiOSSimulatorCoreSimulatorSupport.mm; sourceTree = "<group>"; };<br>
                945759651534941F005A9070 /* PlatformPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PlatformPOSIX.cpp; path = POSIX/PlatformPOSIX.cpp; sourceTree = "<group>"; };<br>
                945759661534941F005A9070 /* PlatformPOSIX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformPOSIX.h; path = POSIX/PlatformPOSIX.h; sourceTree = "<group>"; };<br>
                945E8D7D152F6AA80019BCCD /* StreamGDBRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StreamGDBRemote.h; path = include/lldb/Core/StreamGDBRemote.h; sourceTree = "<group>"; };<br>
@@ -4929,12 +4935,16 @@<br>
                26C5577F132575C8008FD8FE /* MacOSX */ = {<br>
                        isa = PBXGroup;<br>
                        children = (<br>
+                               9455630A1BEAD0570073F75F /* PlatformAppleSimulator.cpp */,<br>
+                               9455630B1BEAD0570073F75F /* PlatformAppleSimulator.h */,<br>
                                AF254E2F170CCC33007AE5C9 /* PlatformDarwinKernel.cpp */,<br>
                                AF254E30170CCC33007AE5C9 /* PlatformDarwinKernel.h */,<br>
                                2697A54B133A6305004E4240 /* PlatformDarwin.cpp */,<br>
                                2697A54C133A6305004E4240 /* PlatformDarwin.h */,<br>
                                26B7564C14F89356008D9CB3 /* PlatformiOSSimulator.cpp */,<br>
                                26B7564D14F89356008D9CB3 /* PlatformiOSSimulator.h */,<br>
+                               9455630C1BEAD0570073F75F /* PlatformiOSSimulatorCoreSimulatorSupport.h */,<br>
+                               9455630D1BEAD0570073F75F /* PlatformiOSSimulatorCoreSimulatorSupport.mm */,<br>
                                26C5577B132575AD008FD8FE /* PlatformMacOSX.cpp */,<br>
                                26C5577C132575AD008FD8FE /* PlatformMacOSX.h */,<br>
                                2675F6FE1332BE690067997B /* PlatformRemoteiOS.cpp */,<br>
@@ -6622,6 +6632,7 @@<br>
                                25EF23781AC09B3700908DF0 /* AdbClient.cpp in Sources */,<br>
                                94380B8219940B0A00BFE4A8 /* StringLexer.cpp in Sources */,<br>
                                268900C413353E5F00698AC0 /* DWARFDefines.cpp in Sources */,<br>
+                               945563101BEAD0650073F75F /* PlatformiOSSimulatorCoreSimulatorSupport.mm in Sources */,<br>
                                268900C513353E5F00698AC0 /* DWARFDIECollection.cpp in Sources */,<br>
                                268900C613353E5F00698AC0 /* DWARFFormValue.cpp in Sources */,<br>
                                3FDFE53119A292F0009756A7 /* HostInfoPosix.cpp in Sources */,<br>
@@ -6877,6 +6888,7 @@<br>
                                260CC64A15D0440D002BF2E0 /* OptionValueBoolean.cpp in Sources */,<br>
                                260CC64B15D0440D002BF2E0 /* OptionValueProperties.cpp in Sources */,<br>
                                3FDFED0C19B7C8E7009756A7 /* ThisThread.cpp in Sources */,<br>
+                               9455630F1BEAD0600073F75F /* PlatformAppleSimulator.cpp in Sources */,<br>
                                6D86CEA01B440F8500A7FBFA /* CommandObjectBugreport.cpp in Sources */,<br>
                                260CC64C15D0440D002BF2E0 /* OptionValueDictionary.cpp in Sources */,<br>
                                49DCF6FE170E6B4A0092F75E /* IRMemoryMap.cpp in Sources */,<br>
<br>
Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=252112&r1=252111&r2=252112&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=252112&r1=252111&r2=252112&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/packages/Python/lldbsuite/test/dotest.py (original)<br>
+++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py Wed Nov  4 18:46:25 2015<br>
@@ -1381,6 +1381,28 @@ def isMultiprocessTestRunner():<br>
     # test runner<br>
     return not (is_inferior_test_runner or no_multiprocess_test_runner)<br>
<br>
+def getVersionForSDK(sdk):<br>
+    sdk = str.lower(sdk)<br>
+    full_path = seven.get_command_output('xcrun -sdk %s --show-sdk-path' % sdk)<br>
+    basename = os.path.basename(full_path)<br>
+    basename = os.path.splitext(basename)[0]<br>
+    basename = str.lower(basename)<br>
+    ver = basename.replace(sdk, '')<br>
+    return ver<br>
+<br>
+def getPathForSDK(sdk):<br>
+    sdk = str.lower(sdk)<br>
+    full_path = seven.get_command_output('xcrun -sdk %s --show-sdk-path' % sdk)<br>
+    if os.path.exists(full_path): return full_path<br>
+    return None<br>
+<br>
+def setDefaultTripleForPlatform():<br>
+    if lldb_platform_name == 'ios-simulator':<br>
+        triple_str = 'x86_64-apple-ios%s' % (getVersionForSDK('iphonesimulator'))<br>
+        os.environ['TRIPLE'] = triple_str<br>
+        return {'TRIPLE':triple_str}<br>
+    return {}<br>
+<br>
 def run_suite():<br>
     global just_do_benchmarks_test<br>
     global dont_do_dsym_test<br>
@@ -1478,6 +1500,7 @@ def run_suite():<br>
     if lldb_platform_name:<br>
         print("Setting up remote platform '%s'" % (lldb_platform_name))<br>
         lldb.remote_platform = lldb.SBPlatform(lldb_platform_name)<br>
+        lldb.remote_platform_name = lldb_platform_name<br>
         if not lldb.remote_platform.IsValid():<br>
             print("error: unable to create the LLDB platform named '%s'." % (lldb_platform_name))<br>
             exitTestSuite(1)<br>
@@ -1495,10 +1518,17 @@ def run_suite():<br>
         else:<br>
             lldb.platform_url = None<br>
<br>
-        if lldb_platform_working_dir:<br>
-            print("Setting remote platform working directory to '%s'..." % (lldb_platform_working_dir))<br>
-            lldb.remote_platform.SetWorkingDirectory(lldb_platform_working_dir)<br>
-<br>
+    platform_changes = setDefaultTripleForPlatform()<br>
+    first = True<br>
+    for key in platform_changes:<br>
+        if first:<br>
+            print("Environment variables setup for platform support:")<br>
+            first = False<br>
+        print("%s = %s" % (key,platform_changes[key]))<br>
+<br>
+    if lldb_platform_working_dir:<br>
+        print("Setting remote platform working directory to '%s'..." % (lldb_platform_working_dir))<br>
+        lldb.remote_platform.SetWorkingDirectory(lldb_platform_working_dir)<br>
         lldb.remote_platform_working_dir = lldb_platform_working_dir<br>
         lldb.DBG.SetSelectedPlatform(lldb.remote_platform)<br>
     else:<br>
<br>
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py?rev=252112&r1=252111&r2=252112&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py?rev=252112&r1=252111&r2=252112&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py (original)<br>
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py Wed Nov  4 18:46:25 2015<br>
@@ -17,6 +17,7 @@ class ProcessAttachTestCase(TestBase):<br>
<br>
     mydir = TestBase.compute_mydir(__file__)<br>
<br>
+    @skipIfiOSSimulator<br>
     def test_attach_to_process_by_id(self):<br>
         """Test attach by process id"""<br>
         self.build()<br>
<br>
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py?rev=252112&r1=252111&r2=252112&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py?rev=252112&r1=252111&r2=252112&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py (original)<br>
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py Wed Nov  4 18:46:25 2015<br>
@@ -24,6 +24,7 @@ class AttachDeniedTestCase(TestBase):<br>
         return (err, shell_command.GetStatus(), shell_command.GetOutput())<br>
<br>
     @skipIfWindows<br>
+    @skipIfiOSSimulator<br>
     def test_attach_to_process_by_id_denied(self):<br>
         """Test attach by process id denied"""<br>
         self.build()<br>
<br>
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/TestRegisters.py<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/TestRegisters.py?rev=252112&r1=252111&r2=252112&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/TestRegisters.py?rev=252112&r1=252111&r2=252112&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/TestRegisters.py (original)<br>
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/TestRegisters.py Wed Nov  4 18:46:25 2015<br>
@@ -24,6 +24,7 @@ class RegisterCommandsTestCase(TestBase)<br>
         self.dbg.GetSelectedTarget().GetProcess().Destroy()<br>
         TestBase.tearDown(self)<br>
<br>
+    @skipIfiOSSimulator<br>
     def test_register_commands(self):<br>
         """Test commands related to registers, in particular vector registers."""<br>
         if not self.getArchitecture() in ['amd64', 'i386', 'x86_64']:<br>
@@ -31,6 +32,7 @@ class RegisterCommandsTestCase(TestBase)<br>
         self.build()<br>
         self.register_commands()<br>
<br>
+    @skipIfiOSSimulator<br>
     @skipIfTargetAndroid(archs=["i386"]) # Writing of mxcsr register fails, presumably due to a kernel/hardware problem<br>
     def test_fp_register_write(self):<br>
         """Test commands that write to registers, in particular floating-point registers."""<br>
@@ -39,6 +41,7 @@ class RegisterCommandsTestCase(TestBase)<br>
         self.build()<br>
         self.fp_register_write()<br>
<br>
+    @skipIfiOSSimulator<br>
     @expectedFailureAndroid(archs=["i386"]) # "register read fstat" always return 0xffff<br>
     @skipIfFreeBSD    #<a href="http://llvm.org/pr25057" rel="noreferrer" target="_blank">llvm.org/pr25057</a><br>
     def test_fp_special_purpose_register_read(self):<br>
@@ -48,6 +51,7 @@ class RegisterCommandsTestCase(TestBase)<br>
         self.build()<br>
         self.fp_special_purpose_register_read()<br>
<br>
+    @skipIfiOSSimulator<br>
     def test_register_expressions(self):<br>
         """Test expression evaluation with commands related to registers."""<br>
         if not self.getArchitecture() in ['amd64', 'i386', 'x86_64']:<br>
@@ -55,6 +59,7 @@ class RegisterCommandsTestCase(TestBase)<br>
         self.build()<br>
         self.register_expressions()<br>
<br>
+    @skipIfiOSSimulator<br>
     def test_convenience_registers(self):<br>
         """Test convenience registers."""<br>
         if not self.getArchitecture() in ['amd64', 'x86_64']:<br>
@@ -62,6 +67,7 @@ class RegisterCommandsTestCase(TestBase)<br>
         self.build()<br>
         self.convenience_registers()<br>
<br>
+    @skipIfiOSSimulator<br>
     def test_convenience_registers_with_process_attach(self):<br>
         """Test convenience registers after a 'process attach'."""<br>
         if not self.getArchitecture() in ['amd64', 'x86_64']:<br>
@@ -69,6 +75,7 @@ class RegisterCommandsTestCase(TestBase)<br>
         self.build()<br>
         self.convenience_registers_with_process_attach(test_16bit_regs=False)<br>
<br>
+    @skipIfiOSSimulator<br>
     def test_convenience_registers_16bit_with_process_attach(self):<br>
         """Test convenience registers after a 'process attach'."""<br>
         if not self.getArchitecture() in ['amd64', 'x86_64']:<br>
<br>
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py?rev=252112&r1=252111&r2=252112&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py?rev=252112&r1=252111&r2=252112&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py (original)<br>
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py Wed Nov  4 18:46:25 2015<br>
@@ -19,6 +19,7 @@ class CreateAfterAttachTestCase(TestBase<br>
                    # not yet investigated.  Revisit once required functionality<br>
                    # is implemented for FreeBSD.<br>
     @skipIfWindows # Occasionally hangs on Windows, may be same as other issues.<br>
+    @skipIfiOSSimulator<br>
     def test_create_after_attach_with_popen(self):<br>
         """Test thread creation after process attach."""<br>
         self.build(dictionary=self.getBuildFlags(use_cpp11=False))<br>
@@ -29,6 +30,7 @@ class CreateAfterAttachTestCase(TestBase<br>
     @skipIfRemote<br>
     @skipIfWindows # Windows doesn't have fork.<br>
     @expectedFlakeyLinux("<a href="http://llvm.org/pr16229" rel="noreferrer" target="_blank">llvm.org/pr16229</a>") # 1/100 dosep, build 3546, clang-3.5 x84_64<br>
+    @skipIfiOSSimulator<br>
     def test_create_after_attach_with_fork(self):<br>
         """Test thread creation after process attach."""<br>
         self.build(dictionary=self.getBuildFlags(use_cpp11=False))<br>
<br>
Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=252112&r1=252111&r2=252112&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=252112&r1=252111&r2=252112&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original)<br>
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Wed Nov  4 18:46:25 2015<br>
@@ -868,6 +868,10 @@ def skipIfNoSBHeaders(func):<br>
             func(*args, **kwargs)<br>
     return wrapper<br>
<br>
+def skipIfiOSSimulator(func):<br>
+    """Decorate the item to skip tests that should be skipped on the iOS Simulator."""<br>
+    return unittest2.skipIf(hasattr(lldb, 'remote_platform_name') and lldb.remote_platform_name == 'ios-simulator', 'skip on the iOS Simulator')(func)<br>
+<br>
 def skipIfFreeBSD(func):<br>
     """Decorate the item to skip tests that should be skipped on FreeBSD."""<br>
     return skipIfPlatform(["freebsd"])(func)<br>
<br>
Modified: lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules?rev=252112&r1=252111&r2=252112&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules?rev=252112&r1=252111&r2=252112&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules (original)<br>
+++ lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules Wed Nov  4 18:46:25 2015<br>
@@ -40,7 +40,7 @@ ifneq "$(TRIPLE)" ""<br>
        triple_space = $(subst -, ,$(TRIPLE))<br>
        ARCH =$(word 1, $(triple_space))<br>
        TRIPLE_VENDOR =$(word 2, $(triple_space))<br>
-       triple_os_and_version =$(shell echo $(word 3, $(triple_space)) | sed -e 's/\(.*\)\([0-9]\.[0-9]\).*/\1 \2/')<br>
+       triple_os_and_version =$(shell echo $(word 3, $(triple_space)) | sed 's/\([a-z]*\)\(.*\)/\1 \2/')<br>
        TRIPLE_OS =$(word 1, $(triple_os_and_version))<br>
        TRIPLE_VERSION =$(word 2, $(triple_os_and_version))<br>
        ifeq "$(TRIPLE_VENDOR)" "apple"<br>
@@ -181,6 +181,7 @@ ifeq "$(OS)" "Darwin"<br>
 else<br>
        CFLAGS += $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) -I$(LLDB_BASE_DIR)include<br>
 endif<br>
+<br>
 CFLAGS += -include $(THIS_FILE_DIR)test_common.h $(TRIPLE_CFLAGS)<br>
<br>
 # Use this one if you want to build one part of the result without debug information:<br>
<br>
Modified: lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py?rev=252112&r1=252111&r2=252112&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py?rev=252112&r1=252111&r2=252112&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py (original)<br>
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py Wed Nov  4 18:46:25 2015<br>
@@ -30,6 +30,7 @@ class HelloWorldTestCase(TestBase):<br>
         TestBase.tearDown(self)<br>
<br>
     @add_test_categories(['pyapi'])<br>
+    @skipIfiOSSimulator<br>
     def test_with_process_launch_api(self):<br>
         """Create target, breakpoint, launch a process, and then kill it."""<br>
         self.build(dictionary=self.d)<br>
@@ -75,6 +76,7 @@ class HelloWorldTestCase(TestBase):<br>
     @add_test_categories(['pyapi'])<br>
     @expectedFailureWindows("<a href="http://llvm.org/pr24600" rel="noreferrer" target="_blank">llvm.org/pr24600</a>")<br>
     @expectedFailurei386("<a href="http://llvm.org/pr25338" rel="noreferrer" target="_blank">llvm.org/pr25338</a>")<br>
+    @skipIfiOSSimulator<br>
     def test_with_attach_to_process_with_id_api(self):<br>
         """Create target, spawn a process, and attach to it with process id."""<br>
         self.build(dictionary=self.d)<br>
@@ -104,6 +106,7 @@ class HelloWorldTestCase(TestBase):<br>
     @add_test_categories(['pyapi'])<br>
     @expectedFailureWindows("<a href="http://llvm.org/pr24600" rel="noreferrer" target="_blank">llvm.org/pr24600</a>")<br>
     @expectedFailurei386("<a href="http://llvm.org/pr25338" rel="noreferrer" target="_blank">llvm.org/pr25338</a>")<br>
+    @skipIfiOSSimulator<br>
     def test_with_attach_to_process_with_name_api(self):<br>
         """Create target, spawn a process, and attach to it with process name."""<br>
         self.build(dictionary=self.d)<br>
<br>
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/CMakeLists.txt?rev=252112&r1=252111&r2=252112&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/CMakeLists.txt?rev=252112&r1=252111&r2=252112&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Platform/MacOSX/CMakeLists.txt (original)<br>
+++ lldb/trunk/source/Plugins/Platform/MacOSX/CMakeLists.txt Wed Nov  4 18:46:25 2015<br>
@@ -1,7 +1,9 @@<br>
 add_lldb_library(lldbPluginPlatformMacOSX<br>
+  PlatformAppleSimulator.cpp<br>
   PlatformDarwin.cpp<br>
   PlatformDarwinKernel.cpp<br>
   PlatformiOSSimulator.cpp<br>
+  PlatformiOSSimulatorCoreSimulatorSupport.mm<br>
   PlatformMacOSX.cpp<br>
   PlatformRemoteiOS.cpp<br>
   )<br>
<br>
Added: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp?rev=252112&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp?rev=252112&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp (added)<br>
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp Wed Nov  4 18:46:25 2015<br>
@@ -0,0 +1,300 @@<br>
+//===-- PlatformAppleSimulator.cpp ------------------------------*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "PlatformAppleSimulator.h"<br>
+<br>
+// C Includes<br>
+#include <dlfcn.h><br>
+// C++ Includes<br>
+#include <mutex><br>
+#include <thread><br>
+// Other libraries and framework includes<br>
+// Project includes<br>
+#include "lldb/Core/Error.h"<br>
+#include "lldb/Core/StreamString.h"<br>
+#include "lldb/Target/Process.h"<br>
+#include "lldb/Utility/LLDBAssert.h"<br>
+#include "lldb/Utility/PseudoTerminal.h"<br>
+<br>
+using namespace lldb;<br>
+using namespace lldb_private;<br>
+<br>
+#if !defined(__APPLE__)<br>
+#define UNSUPPORTED_ERROR ("Apple simulators aren't supported on this platform")<br>
+#endif<br>
+<br>
+//------------------------------------------------------------------<br>
+// Static Functions<br>
+//------------------------------------------------------------------<br>
+void<br>
+PlatformAppleSimulator::Initialize ()<br>
+{<br>
+    PlatformDarwin::Initialize ();<br>
+}<br>
+<br>
+void<br>
+PlatformAppleSimulator::Terminate ()<br>
+{<br>
+    PlatformDarwin::Terminate ();<br>
+}<br>
+<br>
+//------------------------------------------------------------------<br>
+/// Default Constructor<br>
+//------------------------------------------------------------------<br>
+PlatformAppleSimulator::PlatformAppleSimulator () :<br>
+    PlatformDarwin (true),<br>
+    m_core_simulator_framework_path()<br>
+{<br>
+}<br>
+<br>
+//------------------------------------------------------------------<br>
+/// Destructor.<br>
+///<br>
+/// The destructor is virtual since this class is designed to be<br>
+/// inherited from by the plug-in instance.<br>
+//------------------------------------------------------------------<br>
+PlatformAppleSimulator::~PlatformAppleSimulator()<br>
+{<br>
+}<br>
+<br>
+lldb_private::Error<br>
+PlatformAppleSimulator::LaunchProcess (lldb_private::ProcessLaunchInfo &launch_info)<br>
+{<br>
+#if defined(__APPLE__)<br>
+    LoadCoreSimulator();<br>
+    CoreSimulatorSupport::Device device(GetSimulatorDevice());<br>
+<br>
+    if (device.GetState() != CoreSimulatorSupport::Device::State::Booted)<br>
+    {<br>
+        Error boot_err;<br>
+        device.Boot(boot_err);<br>
+        if (boot_err.Fail())<br>
+            return boot_err;<br>
+    }<br>
+<br>
+    auto spawned = device.Spawn(launch_info);<br>
+<br>
+    if (spawned)<br>
+    {<br>
+        launch_info.SetProcessID(spawned.GetPID());<br>
+        return Error();<br>
+    }<br>
+    else<br>
+        return spawned.GetError();<br>
+#else<br>
+    Error err;<br>
+    err.SetErrorString(UNSUPPORTED_ERROR);<br>
+    return err;<br>
+#endif<br>
+}<br>
+<br>
+void<br>
+PlatformAppleSimulator::GetStatus (Stream &strm)<br>
+{<br>
+#if defined(__APPLE__)<br>
+    // This will get called by subclasses, so just output status on the<br>
+    // current simulator<br>
+    PlatformAppleSimulator::LoadCoreSimulator();<br>
+<br>
+    CoreSimulatorSupport::DeviceSet devices = CoreSimulatorSupport::DeviceSet::GetAvailableDevices();<br>
+    const size_t num_devices = devices.GetNumDevices();<br>
+    if (num_devices)<br>
+    {<br>
+        strm.Printf("Available devices:\n");<br>
+        for (size_t i=0; i<num_devices; ++i)<br>
+        {<br>
+            CoreSimulatorSupport::Device device = devices.GetDeviceAtIndex(i);<br>
+            strm.Printf("   %s: %s\n", device.GetUDID().c_str(), device.GetName().c_str());<br>
+        }<br>
+<br>
+        if (m_device.hasValue() && m_device->operator bool())<br>
+        {<br>
+            strm.Printf("Current device: %s: %s", m_device->GetUDID().c_str(), m_device->GetName().c_str());<br>
+            if (m_device->GetState() == CoreSimulatorSupport::Device::State::Booted)<br>
+            {<br>
+                strm.Printf(" state = booted");<br>
+            }<br>
+            strm.Printf("\nType \"platform connect <ARG>\" where <ARG> is a device UDID or a device name to disconnect and connect to a different device.\n");<br>
+<br>
+        }<br>
+        else<br>
+        {<br>
+            strm.Printf("No current device is selected, \"platform connect <ARG>\" where <ARG> is a device UDID or a device name to connect to a specific device.\n");<br>
+        }<br>
+<br>
+    }<br>
+    else<br>
+    {<br>
+        strm.Printf("No devices are available.\n");<br>
+    }<br>
+#else<br>
+    strm.Printf(UNSUPPORTED_ERROR);<br>
+#endif<br>
+}<br>
+<br>
+Error<br>
+PlatformAppleSimulator::ConnectRemote (Args& args)<br>
+{<br>
+#if defined(__APPLE__)<br>
+    Error error;<br>
+    if (args.GetArgumentCount() == 1)<br>
+    {<br>
+        if (m_device)<br>
+            DisconnectRemote ();<br>
+        PlatformAppleSimulator::LoadCoreSimulator();<br>
+        const char *arg_cstr = args.GetArgumentAtIndex(0);<br>
+        if (arg_cstr)<br>
+        {<br>
+            std::string arg_str(arg_cstr);<br>
+            CoreSimulatorSupport::DeviceSet devices = CoreSimulatorSupport::DeviceSet::GetAvailableDevices();<br>
+            devices.ForEach([this, &arg_str](const CoreSimulatorSupport::Device &device) -> bool {<br>
+                if (arg_str == device.GetUDID() || arg_str == device.GetName())<br>
+                {<br>
+                    m_device = device;<br>
+                    return false; // Stop iterating<br>
+                }<br>
+                else<br>
+                {<br>
+                    return true; // Keep iterating<br>
+                }<br>
+            });<br>
+            if (!m_device)<br>
+                error.SetErrorStringWithFormat("no device with UDID or name '%s' was found", arg_cstr);<br>
+        }<br>
+    }<br>
+    else<br>
+    {<br>
+        error.SetErrorString("this command take a single UDID argument of the device you want to connect to.");<br>
+    }<br>
+    return error;<br>
+#else<br>
+    Error err;<br>
+    err.SetErrorString(UNSUPPORTED_ERROR);<br>
+    return err;<br>
+#endif<br>
+}<br>
+<br>
+Error<br>
+PlatformAppleSimulator::DisconnectRemote ()<br>
+{<br>
+#if defined(__APPLE__)<br>
+    m_device.reset();<br>
+    return Error();<br>
+#else<br>
+    Error err;<br>
+    err.SetErrorString(UNSUPPORTED_ERROR);<br>
+    return err;<br>
+#endif<br>
+}<br>
+<br>
+<br>
+lldb::ProcessSP<br>
+PlatformAppleSimulator::DebugProcess (ProcessLaunchInfo &launch_info,<br>
+                                      Debugger &debugger,<br>
+                                      Target *target,       // Can be NULL, if NULL create a new target, else use existing one<br>
+                                      Error &error)<br>
+{<br>
+#if defined(__APPLE__)<br>
+    ProcessSP process_sp;<br>
+    // Make sure we stop at the entry point<br>
+    launch_info.GetFlags ().Set (eLaunchFlagDebug);<br>
+    // We always launch the process we are going to debug in a separate process<br>
+    // group, since then we can handle ^C interrupts ourselves w/o having to worry<br>
+    // about the target getting them as well.<br>
+    launch_info.SetLaunchInSeparateProcessGroup(true);<br>
+<br>
+    error = LaunchProcess (launch_info);<br>
+    if (error.Success())<br>
+    {<br>
+        if (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID)<br>
+        {<br>
+            ProcessAttachInfo attach_info (launch_info);<br>
+            process_sp = Attach (attach_info, debugger, target, error);<br>
+            if (process_sp)<br>
+            {<br>
+                launch_info.SetHijackListener(attach_info.GetHijackListener());<br>
+<br>
+                // Since we attached to the process, it will think it needs to detach<br>
+                // if the process object just goes away without an explicit call to<br>
+                // Process::Kill() or Process::Detach(), so let it know to kill the<br>
+                // process if this happens.<br>
+                process_sp->SetShouldDetach (false);<br>
+<br>
+                // If we didn't have any file actions, the pseudo terminal might<br>
+                // have been used where the slave side was given as the file to<br>
+                // open for stdin/out/err after we have already opened the master<br>
+                // so we can read/write stdin/out/err.<br>
+                int pty_fd = launch_info.GetPTY().ReleaseMasterFileDescriptor();<br>
+                if (pty_fd != lldb_utility::PseudoTerminal::invalid_fd)<br>
+                {<br>
+                    process_sp->SetSTDIOFileDescriptor(pty_fd);<br>
+                }<br>
+            }<br>
+        }<br>
+    }<br>
+<br>
+    return process_sp;<br>
+#else<br>
+    return ProcessSP();<br>
+#endif<br>
+}<br>
+<br>
+FileSpec<br>
+PlatformAppleSimulator::GetCoreSimulatorPath()<br>
+{<br>
+#if defined(__APPLE__)<br>
+    Mutex::Locker locker (m_mutex);<br>
+    if (!m_core_simulator_framework_path.hasValue())<br>
+    {<br>
+        const char *developer_dir = GetDeveloperDirectory();<br>
+        if (developer_dir)<br>
+        {<br>
+            StreamString cs_path;<br>
+            cs_path.Printf("%s/Library/PrivateFrameworks/CoreSimulator.framework/CoreSimulator", developer_dir);<br>
+            const bool resolve_path = true;<br>
+            m_core_simulator_framework_path = FileSpec(cs_path.GetData(), resolve_path);<br>
+        }<br>
+    }<br>
+<br>
+    return m_core_simulator_framework_path.getValue();<br>
+#else<br>
+    return FileSpec();<br>
+#endif<br>
+}<br>
+<br>
+void<br>
+PlatformAppleSimulator::LoadCoreSimulator ()<br>
+{<br>
+#if defined(__APPLE__)<br>
+    static std::once_flag g_load_core_sim_flag;<br>
+    std::call_once(g_load_core_sim_flag, [this] {<br>
+        const std::string core_sim_path(GetCoreSimulatorPath().GetPath());<br>
+        if (core_sim_path.size())<br>
+            dlopen(core_sim_path.c_str(), RTLD_LAZY);<br>
+    });<br>
+#endif<br>
+}<br>
+<br>
+#if defined(__APPLE__)<br>
+CoreSimulatorSupport::Device<br>
+PlatformAppleSimulator::GetSimulatorDevice ()<br>
+{<br>
+    if (!m_device.hasValue())<br>
+    {<br>
+        const CoreSimulatorSupport::DeviceType::ProductFamilyID dev_id = CoreSimulatorSupport::DeviceType::ProductFamilyID::iPhone;<br>
+        m_device = CoreSimulatorSupport::DeviceSet::GetAvailableDevices().GetFanciest(dev_id);<br>
+    }<br>
+<br>
+    if (m_device.hasValue())<br>
+        return m_device.getValue();<br>
+    else<br>
+        return CoreSimulatorSupport::Device();<br>
+}<br>
+#endif<br>
+<br>
<br>
Added: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h?rev=252112&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h?rev=252112&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h (added)<br>
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h Wed Nov  4 18:46:25 2015<br>
@@ -0,0 +1,81 @@<br>
+//===-- PlatformAppleSimulator.h --------------------------------*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#ifndef liblldb_PlatformAppleSimulator_h_<br>
+#define liblldb_PlatformAppleSimulator_h_<br>
+<br>
+// C Includes<br>
+// C++ Includes<br>
+// Other libraries and framework includes<br>
+// Project includes<br>
+#include "lldb/Host/FileSpec.h"<br>
+#include "PlatformDarwin.h"<br>
+#include "PlatformiOSSimulatorCoreSimulatorSupport.h"<br>
+<br>
+#include "llvm/ADT/Optional.h"<br>
+<br>
+class PlatformAppleSimulator : public PlatformDarwin<br>
+{<br>
+public:<br>
+    //------------------------------------------------------------<br>
+    // Class Functions<br>
+    //------------------------------------------------------------<br>
+    static void<br>
+    Initialize ();<br>
+<br>
+    static void<br>
+    Terminate ();<br>
+<br>
+    //------------------------------------------------------------<br>
+    // Class Methods<br>
+    //------------------------------------------------------------<br>
+    PlatformAppleSimulator ();<br>
+<br>
+    virtual<br>
+    ~PlatformAppleSimulator();<br>
+<br>
+    lldb_private::Error<br>
+    LaunchProcess (lldb_private::ProcessLaunchInfo &launch_info) override;<br>
+<br>
+    void<br>
+    GetStatus (lldb_private::Stream &strm) override;<br>
+<br>
+    lldb_private::Error<br>
+    ConnectRemote (lldb_private::Args& args) override;<br>
+<br>
+    lldb_private::Error<br>
+    DisconnectRemote () override;<br>
+<br>
+    lldb::ProcessSP<br>
+    DebugProcess (lldb_private::ProcessLaunchInfo &launch_info,<br>
+                  lldb_private::Debugger &debugger,<br>
+                  lldb_private::Target *target,<br>
+                  lldb_private::Error &error) override;<br>
+<br>
+protected:<br>
+    llvm::Optional<lldb_private::FileSpec> m_core_simulator_framework_path;<br>
+    llvm::Optional<CoreSimulatorSupport::Device> m_device;<br>
+<br>
+    lldb_private::FileSpec<br>
+    GetCoreSimulatorPath();<br>
+<br>
+    void<br>
+    LoadCoreSimulator ();<br>
+<br>
+#if defined(__APPLE__)<br>
+    CoreSimulatorSupport::Device<br>
+    GetSimulatorDevice ();<br>
+#endif<br>
+<br>
+private:<br>
+    DISALLOW_COPY_AND_ASSIGN (PlatformAppleSimulator);<br>
+<br>
+};<br>
+<br>
+#endif  // liblldb_PlatformAppleSimulator_h_<br>
<br>
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp?rev=252112&r1=252111&r2=252112&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp?rev=252112&r1=252111&r2=252112&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp (original)<br>
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp Wed Nov  4 18:46:25 2015<br>
@@ -41,8 +41,8 @@ static uint32_t g_initialize_count = 0;<br>
 void<br>
 PlatformiOSSimulator::Initialize ()<br>
 {<br>
-    PlatformDarwin::Initialize ();<br>
-<br>
+    PlatformAppleSimulator::Initialize ();<br>
+<br>
     if (g_initialize_count++ == 0)<br>
     {<br>
         PluginManager::RegisterPlugin (PlatformiOSSimulator::GetPluginNameStatic(),<br>
@@ -61,8 +61,8 @@ PlatformiOSSimulator::Terminate ()<br>
             PluginManager::UnregisterPlugin (PlatformiOSSimulator::CreateInstance);<br>
         }<br>
     }<br>
-<br>
-    PlatformDarwin::Terminate ();<br>
+<br>
+    PlatformAppleSimulator::Terminate ();<br>
 }<br>
<br>
 PlatformSP<br>
@@ -73,8 +73,8 @@ PlatformiOSSimulator::CreateInstance (bo<br>
     {<br>
         switch (arch->GetMachine())<br>
         {<br>
-        case llvm::Triple::x86_64:<br>
-        case llvm::Triple::x86:<br>
+            case llvm::Triple::x86_64:<br>
+            case llvm::Triple::x86:<br>
             {<br>
                 const llvm::Triple &triple = arch->GetTriple();<br>
                 switch (triple.getVendor())<br>
@@ -84,9 +84,9 @@ PlatformiOSSimulator::CreateInstance (bo<br>
                         break;<br>
<br>
 #if defined(__APPLE__)<br>
-                    // Only accept "unknown" for the vendor if the host is Apple and<br>
-                    // it "unknown" wasn't specified (it was just returned because it<br>
-                    // was NOT specified)<br>
+                        // Only accept "unknown" for the vendor if the host is Apple and<br>
+                        // it "unknown" wasn't specified (it was just returned because it<br>
+                        // was NOT specified)<br>
                     case llvm::Triple::UnknownArch:<br>
                         create = !arch->TripleVendorWasSpecified();<br>
                         break;<br>
@@ -105,9 +105,9 @@ PlatformiOSSimulator::CreateInstance (bo<br>
                             break;<br>
<br>
 #if defined(__APPLE__)<br>
-                        // Only accept "unknown" for the OS if the host is Apple and<br>
-                        // it "unknown" wasn't specified (it was just returned because it<br>
-                        // was NOT specified)<br>
+                            // Only accept "unknown" for the OS if the host is Apple and<br>
+                            // it "unknown" wasn't specified (it was just returned because it<br>
+                            // was NOT specified)<br>
                         case llvm::Triple::UnknownOS:<br>
                             create = !arch->TripleOSWasSpecified();<br>
                             break;<br>
@@ -118,9 +118,9 @@ PlatformiOSSimulator::CreateInstance (bo<br>
                     }<br>
                 }<br>
             }<br>
-            break;<br>
-        default:<br>
-            break;<br>
+                break;<br>
+            default:<br>
+                break;<br>
         }<br>
     }<br>
     if (create)<br>
@@ -147,8 +147,8 @@ PlatformiOSSimulator::GetDescriptionStat<br>
 /// Default Constructor<br>
 //------------------------------------------------------------------<br>
 PlatformiOSSimulator::PlatformiOSSimulator () :<br>
-    PlatformDarwin (true),<br>
-    m_sdk_directory ()<br>
+PlatformAppleSimulator (),<br>
+m_sdk_directory ()<br>
 {<br>
 }<br>
<br>
@@ -167,11 +167,12 @@ void<br>
 PlatformiOSSimulator::GetStatus (Stream &strm)<br>
 {<br>
     Platform::GetStatus (strm);<br>
-    const char *sdk_directory = GetSDKsDirectory();<br>
+    const char *sdk_directory = GetSDKDirectoryAsCString();<br>
     if (sdk_directory)<br>
         strm.Printf ("  SDK Path: \"%s\"\n", sdk_directory);<br>
     else<br>
         strm.PutCString ("  SDK Path: error: unable to locate SDK\n");<br>
+    PlatformAppleSimulator::GetStatus(strm);<br>
 }<br>
<br>
<br>
@@ -182,29 +183,29 @@ PlatformiOSSimulator::ResolveExecutable<br>
 {<br>
     Error error;<br>
     // Nothing special to do here, just use the actual file and architecture<br>
-<br>
+<br>
     ModuleSpec resolved_module_spec(module_spec);<br>
-<br>
+<br>
     // If we have "ls" as the exe_file, resolve the executable loation based on<br>
     // the current path variables<br>
     // TODO: resolve bare executables in the Platform SDK<br>
-//    if (!resolved_exe_file.Exists())<br>
-//        resolved_exe_file.ResolveExecutableLocation ();<br>
-<br>
+    //    if (!resolved_exe_file.Exists())<br>
+    //        resolved_exe_file.ResolveExecutableLocation ();<br>
+<br>
     // Resolve any executable within a bundle on MacOSX<br>
     // TODO: verify that this handles shallow bundles, if not then implement one ourselves<br>
     Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());<br>
-<br>
+<br>
     if (resolved_module_spec.GetFileSpec().Exists())<br>
     {<br>
         if (resolved_module_spec.GetArchitecture().IsValid())<br>
         {<br>
             error = ModuleList::GetSharedModule (resolved_module_spec,<br>
-                                                 exe_module_sp,<br>
+                                                 exe_module_sp,<br>
+                                                 NULL,<br>
                                                  NULL,<br>
-                                                 NULL,<br>
                                                  NULL);<br>
-<br>
+<br>
             if (exe_module_sp && exe_module_sp->GetObjectFile())<br>
                 return error;<br>
             exe_module_sp.reset();<br>
@@ -220,11 +221,11 @@ PlatformiOSSimulator::ResolveExecutable<br>
             if (!module_spec.GetArchitecture().IsValid() || module_spec.GetArchitecture().GetCore() == resolved_module_spec.GetArchitecture().GetCore())<br>
             {<br>
                 error = ModuleList::GetSharedModule (resolved_module_spec,<br>
-                                                     exe_module_sp,<br>
+                                                     exe_module_sp,<br>
+                                                     NULL,<br>
                                                      NULL,<br>
-                                                     NULL,<br>
                                                      NULL);<br>
-                // Did we find an executable using one of the<br>
+                // Did we find an executable using one of the<br>
                 if (error.Success())<br>
                 {<br>
                     if (exe_module_sp && exe_module_sp->GetObjectFile())<br>
@@ -259,11 +260,11 @@ PlatformiOSSimulator::ResolveExecutable<br>
         error.SetErrorStringWithFormat ("'%s' does not exist",<br>
                                         module_spec.GetFileSpec().GetPath().c_str());<br>
     }<br>
-<br>
+<br>
     return error;<br>
 }<br>
<br>
-static FileSpec::EnumerateDirectoryResult<br>
+static FileSpec::EnumerateDirectoryResult<br>
 EnumerateDirectoryCallback (void *baton, FileSpec::FileType file_type, const FileSpec &file_spec)<br>
 {<br>
     if (file_type == FileSpec::eFileTypeDirectory)<br>
@@ -281,8 +282,9 @@ EnumerateDirectoryCallback (void *baton,<br>
<br>
<br>
 const char *<br>
-PlatformiOSSimulator::GetSDKsDirectory()<br>
+PlatformiOSSimulator::GetSDKDirectoryAsCString()<br>
 {<br>
+    Mutex::Locker locker (m_mutex);<br>
     if (m_sdk_directory.empty())<br>
     {<br>
         const char *developer_dir = GetDeveloperDirectory();<br>
@@ -291,8 +293,8 @@ PlatformiOSSimulator::GetSDKsDirectory()<br>
             char sdks_directory[PATH_MAX];<br>
             char sdk_dirname[PATH_MAX];<br>
             sdk_dirname[0] = '\0';<br>
-            snprintf (sdks_directory,<br>
-                      sizeof(sdks_directory),<br>
+            snprintf (sdks_directory,<br>
+                      sizeof(sdks_directory),<br>
                       "%s/Platforms/iPhoneSimulator.platform/Developer/SDKs",<br>
                       developer_dir);<br>
             FileSpec simulator_sdk_spec;<br>
@@ -318,7 +320,7 @@ PlatformiOSSimulator::GetSDKsDirectory()<br>
         // support directory and we don't keep trying to find it over and over.<br>
         m_sdk_directory.assign (1, '\0');<br>
     }<br>
-<br>
+<br>
     // We should have put a single NULL character into m_sdk_directory<br>
     // or it should have a valid path if the code gets here<br>
     assert (m_sdk_directory.empty() == false);<br>
@@ -328,7 +330,7 @@ PlatformiOSSimulator::GetSDKsDirectory()<br>
 }<br>
<br>
 Error<br>
-PlatformiOSSimulator::GetSymbolFile (const FileSpec &platform_file,<br>
+PlatformiOSSimulator::GetSymbolFile (const FileSpec &platform_file,<br>
                                      const UUID *uuid_ptr,<br>
                                      FileSpec &local_file)<br>
 {<br>
@@ -337,28 +339,28 @@ PlatformiOSSimulator::GetSymbolFile (con<br>
     if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path)))<br>
     {<br>
         char resolved_path[PATH_MAX];<br>
-<br>
-        const char * sdk_dir = GetSDKsDirectory();<br>
+<br>
+        const char * sdk_dir = GetSDKDirectoryAsCString();<br>
         if (sdk_dir)<br>
         {<br>
-            ::snprintf (resolved_path,<br>
-                        sizeof(resolved_path),<br>
-                        "%s/%s",<br>
-                        sdk_dir,<br>
+            ::snprintf (resolved_path,<br>
+                        sizeof(resolved_path),<br>
+                        "%s/%s",<br>
+                        sdk_dir,<br>
                         platform_file_path);<br>
<br>
             // First try in the SDK and see if the file is in there<br>
             local_file.SetFile(resolved_path, true);<br>
             if (local_file.Exists())<br>
                 return error;<br>
-<br>
+<br>
             // Else fall back to the actual path itself<br>
             local_file.SetFile(platform_file_path, true);<br>
             if (local_file.Exists())<br>
                 return error;<br>
-<br>
+<br>
         }<br>
-        error.SetErrorStringWithFormat ("unable to locate a platform file for '%s' in platform '%s'",<br>
+        error.SetErrorStringWithFormat ("unable to locate a platform file for '%s' in platform '%s'",<br>
                                         platform_file_path,<br>
                                         GetPluginName().GetCString());<br>
     }<br>
@@ -392,17 +394,17 @@ PlatformiOSSimulator::GetSharedModule (c<br>
     else<br>
     {<br>
         const bool always_create = false;<br>
-        error = ModuleList::GetSharedModule (module_spec,<br>
+        error = ModuleList::GetSharedModule (module_spec,<br>
                                              module_sp,<br>
                                              module_search_paths_ptr,<br>
                                              old_module_sp_ptr,<br>
                                              did_create_ptr,<br>
                                              always_create);<br>
-<br>
+<br>
     }<br>
     if (module_sp)<br>
         module_sp->SetPlatformFileSpec(platform_file);<br>
-<br>
+<br>
     return error;<br>
 }<br>
<br>
@@ -414,7 +416,7 @@ PlatformiOSSimulator::FindProcesses (con<br>
     ProcessInstanceInfoList all_osx_process_infos;<br>
     // First we get all OSX processes<br>
     const uint32_t n = Host::FindProcesses (match_info, all_osx_process_infos);<br>
-<br>
+<br>
     // Now we filter them down to only the iOS triples<br>
     for (uint32_t i=0; i<n; ++i)<br>
     {<br>
@@ -431,7 +433,7 @@ PlatformiOSSimulator::GetSupportedArchit<br>
 {<br>
     static const ArchSpec platform_arch(HostInfo::GetArchitecture(HostInfo::eArchKindDefault));<br>
     static const ArchSpec platform_arch64(HostInfo::GetArchitecture(HostInfo::eArchKind64));<br>
-<br>
+<br>
     if (idx == 0)<br>
     {<br>
         arch = platform_arch;<br>
<br>
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h?rev=252112&r1=252111&r2=252112&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h?rev=252112&r1=252111&r2=252112&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h (original)<br>
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h Wed Nov  4 18:46:25 2015<br>
@@ -16,30 +16,30 @@<br>
<br>
 // Other libraries and framework includes<br>
 // Project includes<br>
-#include "PlatformDarwin.h"<br>
+#include "PlatformAppleSimulator.h"<br>
<br>
-class PlatformiOSSimulator : public PlatformDarwin<br>
+class PlatformiOSSimulator : public PlatformAppleSimulator<br>
 {<br>
 public:<br>
     PlatformiOSSimulator ();<br>
-<br>
+<br>
     ~PlatformiOSSimulator() override;<br>
-<br>
+<br>
     //------------------------------------------------------------<br>
     // Class Functions<br>
     //------------------------------------------------------------<br>
     static lldb::PlatformSP<br>
     CreateInstance (bool force, const lldb_private::ArchSpec *arch);<br>
-<br>
+<br>
     static void<br>
     Initialize ();<br>
-<br>
+<br>
     static void<br>
     Terminate ();<br>
<br>
     static lldb_private::ConstString<br>
     GetPluginNameStatic ();<br>
-<br>
+<br>
     static const char *<br>
     GetDescriptionStatic();<br>
<br>
@@ -57,7 +57,7 @@ public:<br>
     {<br>
         return 1;<br>
     }<br>
-<br>
+<br>
     //------------------------------------------------------------<br>
     // lldb_private::Platform functions<br>
     //------------------------------------------------------------<br>
@@ -65,21 +65,21 @@ public:<br>
     ResolveExecutable (const lldb_private::ModuleSpec &module_spec,<br>
                        lldb::ModuleSP &module_sp,<br>
                        const lldb_private::FileSpecList *module_search_paths_ptr) override;<br>
-<br>
+<br>
     const char *<br>
     GetDescription () override<br>
     {<br>
         return GetDescriptionStatic();<br>
     }<br>
-<br>
+<br>
     void<br>
     GetStatus (lldb_private::Stream &strm) override;<br>
-<br>
+<br>
     virtual lldb_private::Error<br>
-    GetSymbolFile (const lldb_private::FileSpec &platform_file,<br>
+    GetSymbolFile (const lldb_private::FileSpec &platform_file,<br>
                    const lldb_private::UUID *uuid_ptr,<br>
                    lldb_private::FileSpec &local_file);<br>
-<br>
+<br>
     lldb_private::Error<br>
     GetSharedModule (const lldb_private::ModuleSpec &module_spec,<br>
                      lldb_private::Process* process,<br>
@@ -87,13 +87,13 @@ public:<br>
                      const lldb_private::FileSpecList *module_search_paths_ptr,<br>
                      lldb::ModuleSP *old_module_sp_ptr,<br>
                      bool *did_create_ptr) override;<br>
-<br>
+<br>
     uint32_t<br>
     FindProcesses (const lldb_private::ProcessInstanceInfoMatch &match_info,<br>
                    lldb_private::ProcessInstanceInfoList &process_infos) override;<br>
-<br>
+<br>
     bool<br>
-    GetSupportedArchitectureAtIndex (uint32_t idx,<br>
+    GetSupportedArchitectureAtIndex (uint32_t idx,<br>
                                      lldb_private::ArchSpec &arch) override;<br>
<br>
     void<br>
@@ -101,15 +101,14 @@ public:<br>
     {<br>
         return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(target, options, PlatformDarwin::SDKType::iPhoneSimulator);<br>
     }<br>
-<br>
+<br>
 protected:<br>
     std::string m_sdk_directory;<br>
     std::string m_build_update;<br>
-    //std::vector<FileSpec> m_device_support_os_dirs;<br>
<br>
     const char *<br>
-    GetSDKsDirectory();<br>
-<br>
+    GetSDKDirectoryAsCString();<br>
+<br>
 private:<br>
     DISALLOW_COPY_AND_ASSIGN (PlatformiOSSimulator);<br>
 };<br>
<br>
Added: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.h?rev=252112&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.h?rev=252112&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.h (added)<br>
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.h Wed Nov  4 18:46:25 2015<br>
@@ -0,0 +1,315 @@<br>
+//===-- PlatformiOSSimulatorCoreSimulatorSupport.h ----------------*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#ifndef liblldb_PlatformiOSSimulatorCoreSimulatorSupport_h_<br>
+#define liblldb_PlatformiOSSimulatorCoreSimulatorSupport_h_<br>
+<br>
+// C Includes<br>
+// C++ Includes<br>
+#include <functional><br>
+#include <string><br>
+#include <ostream><br>
+#include <vector><br>
+// Other libraries and framework includes<br>
+#ifdef __APPLE__<br>
+#include <objc/objc.h><br>
+#else<br>
+typedef void *id;<br>
+#endif<br>
+// Project includes<br>
+#include "lldb/Core/ConstString.h"<br>
+#include "lldb/Core/Error.h"<br>
+#include "lldb/Interpreter/Args.h"<br>
+#include "lldb/Target/ProcessLaunchInfo.h"<br>
+<br>
+#include "llvm/ADT/Optional.h"<br>
+<br>
+// And now the actual magic<br>
+namespace CoreSimulatorSupport<br>
+{<br>
+    class Process<br>
+    {<br>
+    public:<br>
+        pid_t<br>
+        GetPID ()<br>
+        {<br>
+            return m_pid;<br>
+        }<br>
+<br>
+        explicit operator bool ()<br>
+        {<br>
+            return m_pid != LLDB_INVALID_PROCESS_ID;<br>
+        }<br>
+<br>
+        lldb_private::Error<br>
+        GetError ()<br>
+        {<br>
+            return m_error;<br>
+        }<br>
+<br>
+    private:<br>
+        Process (pid_t p);<br>
+<br>
+        Process(lldb_private::Error error);<br>
+<br>
+        Process (pid_t p, lldb_private::Error error);<br>
+<br>
+        pid_t m_pid;<br>
+        lldb_private::Error m_error;<br>
+<br>
+        friend class Device;<br>
+    };<br>
+<br>
+    class ModelIdentifier {<br>
+    public:<br>
+        ModelIdentifier (const std::string& mi);<br>
+        ModelIdentifier ();<br>
+<br>
+        explicit operator bool () const<br>
+        {<br>
+            return !m_versions.empty();<br>
+        }<br>
+<br>
+        size_t<br>
+        GetNumVersions () const<br>
+        {<br>
+            return m_versions.size();<br>
+        }<br>
+<br>
+        unsigned int<br>
+        GetVersionAtIndex (size_t idx) const<br>
+        {<br>
+            return m_versions[idx];<br>
+        }<br>
+<br>
+        std::string<br>
+        GetFamily () const<br>
+        {<br>
+            return m_family.c_str();<br>
+        }<br>
+<br>
+    private:<br>
+        std::string m_family;<br>
+        std::vector<unsigned int> m_versions;<br>
+    };<br>
+<br>
+    class DeviceType<br>
+    {<br>
+    public:<br>
+        enum class ProductFamilyID : int32_t<br>
+        {<br>
+            iPhone = 1,<br>
+            iPad = 2,<br>
+            appleTV = 3,<br>
+            appleWatch = 4<br>
+        };<br>
+<br>
+        DeviceType ();<br>
+<br>
+        DeviceType (id d);<br>
+<br>
+        explicit operator bool ();<br>
+<br>
+        std::string<br>
+        GetName ();<br>
+<br>
+        lldb_private::ConstString<br>
+        GetIdentifier ();<br>
+<br>
+        ModelIdentifier<br>
+        GetModelIdentifier ();<br>
+<br>
+        lldb_private::ConstString<br>
+        GetProductFamily ();<br>
+<br>
+        ProductFamilyID<br>
+        GetProductFamilyID ();<br>
+<br>
+    private:<br>
+        id m_dev;<br>
+        llvm::Optional<ModelIdentifier> m_model_identifier;<br>
+    };<br>
+<br>
+    class OSVersion {<br>
+    public:<br>
+        OSVersion (const std::string& ver,<br>
+                   const std::string& build);<br>
+<br>
+        OSVersion ();<br>
+<br>
+        explicit operator bool () const<br>
+        {<br>
+            return !m_versions.empty();<br>
+        }<br>
+<br>
+        size_t<br>
+        GetNumVersions () const<br>
+        {<br>
+            return m_versions.size();<br>
+        }<br>
+<br>
+        unsigned int<br>
+        GetVersionAtIndex (size_t idx) const<br>
+        {<br>
+            return m_versions[idx];<br>
+        }<br>
+<br>
+        const char*<br>
+        GetBuild () const<br>
+        {<br>
+            return m_build.c_str();<br>
+        }<br>
+<br>
+    private:<br>
+        std::vector<unsigned int> m_versions;<br>
+        std::string m_build;<br>
+    };<br>
+<br>
+    class DeviceRuntime<br>
+    {<br>
+    public:<br>
+        DeviceRuntime ();<br>
+<br>
+        DeviceRuntime (id d);<br>
+<br>
+        explicit operator bool ();<br>
+<br>
+        OSVersion<br>
+        GetVersion ();<br>
+<br>
+        bool<br>
+        IsAvailable ();<br>
+<br>
+    private:<br>
+        id m_dev;<br>
+        llvm::Optional<OSVersion> m_os_version;<br>
+    };<br>
+<br>
+    class Device<br>
+    {<br>
+    private:<br>
+        typedef unsigned long int NSUInteger;<br>
+<br>
+    public:<br>
+        enum class State : NSUInteger<br>
+        {<br>
+            Creating,<br>
+            Shutdown,<br>
+            Booting,<br>
+            Booted,<br>
+            ShuttingDown<br>
+        };<br>
+<br>
+        Device ();<br>
+<br>
+        Device (id d);<br>
+<br>
+        explicit operator bool ();<br>
+<br>
+        std::string<br>
+        GetName () const;<br>
+<br>
+        DeviceType<br>
+        GetDeviceType ();<br>
+<br>
+        DeviceRuntime<br>
+        GetDeviceRuntime ();<br>
+<br>
+        State<br>
+        GetState ();<br>
+<br>
+        bool<br>
+        Boot (lldb_private::Error &err);<br>
+<br>
+        bool<br>
+        Shutdown (lldb_private::Error &err);<br>
+<br>
+        std::string<br>
+        GetUDID () const;<br>
+<br>
+        Process<br>
+        Spawn (lldb_private::ProcessLaunchInfo& launch_info);<br>
+<br>
+    private:<br>
+        id m_dev;<br>
+        llvm::Optional<DeviceType> m_dev_type;<br>
+        llvm::Optional<DeviceRuntime> m_dev_runtime;<br>
+<br>
+        friend class DeviceSet;<br>
+    };<br>
+<br>
+    bool<br>
+    operator > (const OSVersion& lhs,<br>
+                const OSVersion& rhs);<br>
+<br>
+    bool<br>
+    operator > (const ModelIdentifier& lhs,<br>
+                const ModelIdentifier& rhs);<br>
+<br>
+    bool<br>
+    operator < (const OSVersion& lhs,<br>
+                const OSVersion& rhs);<br>
+<br>
+    bool<br>
+    operator < (const ModelIdentifier& lhs,<br>
+                const ModelIdentifier& rhs);<br>
+<br>
+    bool<br>
+    operator == (const OSVersion& lhs,<br>
+                 const OSVersion& rhs);<br>
+<br>
+    bool<br>
+    operator == (const ModelIdentifier& lhs,<br>
+                 const ModelIdentifier& rhs);<br>
+<br>
+    bool<br>
+    operator != (const OSVersion& lhs,<br>
+                 const OSVersion& rhs);<br>
+<br>
+    bool<br>
+    operator != (const ModelIdentifier& lhs,<br>
+                 const ModelIdentifier& rhs);<br>
+<br>
+    class DeviceSet<br>
+    {<br>
+    public:<br>
+        static DeviceSet<br>
+        GetAllDevices ();<br>
+<br>
+        static DeviceSet<br>
+        GetAvailableDevices ();<br>
+<br>
+        size_t<br>
+        GetNumDevices ();<br>
+<br>
+        Device<br>
+        GetDeviceAtIndex (size_t idx);<br>
+<br>
+        void<br>
+        ForEach (std::function<bool(const Device &)> f);<br>
+<br>
+        DeviceSet<br>
+        GetDevicesIf (std::function<bool(Device)> f);<br>
+<br>
+        DeviceSet<br>
+        GetDevices (DeviceType::ProductFamilyID dev_id);<br>
+<br>
+        Device<br>
+        GetFanciest (DeviceType::ProductFamilyID dev_id);<br>
+<br>
+    private:<br>
+        DeviceSet (id arr) : m_dev(arr)<br>
+        {<br>
+        }<br>
+<br>
+        id m_dev;<br>
+    };<br>
+}<br>
+<br>
+#endif  // liblldb_PlatformiOSSimulatorCoreSimulatorSupport_h_<br>
<br>
Added: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm?rev=252112&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm?rev=252112&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm (added)<br>
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm Wed Nov  4 18:46:25 2015<br>
@@ -0,0 +1,773 @@<br>
+//===-- PlatformiOSSimulatorCoreSimulatorSupport.cpp ---------------*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "PlatformiOSSimulatorCoreSimulatorSupport.h"<br>
+<br>
+// C Includes<br>
+// C++ Includes<br>
+// Other libraries and framework includes<br>
+#include <CoreFoundation/CoreFoundation.h><br>
+#include <Foundation/Foundation.h><br>
+// Project includes<br>
+#include "lldb/Target/FileAction.h"<br>
+#include "lldb/Utility/PseudoTerminal.h"<br>
+<br>
+#include "llvm/ADT/StringRef.h"<br>
+<br>
+using namespace lldb_private;<br>
+using namespace lldb_utility;<br>
+// CoreSimulator lives as part of Xcode, which means we can't really link against it, so we dlopen()<br>
+// it at runtime, and error out nicely if that fails<br>
+@interface SimDeviceSet<br>
+{}<br>
++ (id) defaultSet;<br>
+@end<br>
+// However, the drawback is that the compiler will not know about the selectors we're trying to use<br>
+// until runtime; to appease clang in this regard, define a fake protocol on NSObject that exposes<br>
+// the needed interface names for us<br>
+@protocol LLDBCoreSimulatorSupport <NSObject><br>
+- (NSArray *) devices;<br>
+- (id) deviceType;<br>
+- (NSString *) name;<br>
+- (NSString *) identifier;<br>
+- (NSString *) modelIdentifier;<br>
+- (NSString *) productFamily;<br>
+- (int32_t) productFamilyID;<br>
+- (id) runtime;<br>
+- (BOOL) available;<br>
+- (NSString *) versionString;<br>
+- (NSString *) buildVersionString;<br>
+- (BOOL) bootWithOptions:(NSDictionary *)options error:(NSError**)error;<br>
+- (NSUInteger) state;<br>
+- (BOOL) shutdownWithError:(NSError **)error;<br>
+- (NSUUID *) UDID;<br>
+- (pid_t) spawnWithPath:(NSString *)path options:(NSDictionary *)options terminationHandler:(void (^)(int status)) terminationHandler error:(NSError **)error;<br>
+@end<br>
+<br>
+CoreSimulatorSupport::Process::Process (pid_t p) :<br>
+    m_pid (p),<br>
+    m_error ()<br>
+{<br>
+}<br>
+<br>
+CoreSimulatorSupport::Process::Process(Error error) :<br>
+    m_pid (LLDB_INVALID_PROCESS_ID),<br>
+    m_error (error)<br>
+{<br>
+}<br>
+<br>
+CoreSimulatorSupport::Process::Process (pid_t p, Error error) :<br>
+    m_pid (p),<br>
+    m_error (error)<br>
+{<br>
+}<br>
+<br>
+<br>
+CoreSimulatorSupport::DeviceType::DeviceType () :<br>
+    m_dev (nil),<br>
+    m_model_identifier ()<br>
+{<br>
+}<br>
+<br>
+CoreSimulatorSupport::DeviceType::DeviceType (id d) :<br>
+    m_dev (d),<br>
+    m_model_identifier ()<br>
+{<br>
+}<br>
+<br>
+CoreSimulatorSupport::DeviceType::operator bool ()<br>
+{<br>
+    return m_dev != nil;<br>
+}<br>
+<br>
+ConstString<br>
+CoreSimulatorSupport::DeviceType::GetIdentifier ()<br>
+{<br>
+    return ConstString( [[m_dev identifier] UTF8String] );<br>
+}<br>
+<br>
+ConstString<br>
+CoreSimulatorSupport::DeviceType::GetProductFamily ()<br>
+{<br>
+    return ConstString( [[m_dev productFamily] UTF8String] );<br>
+}<br>
+<br>
+CoreSimulatorSupport::DeviceType::ProductFamilyID<br>
+CoreSimulatorSupport::DeviceType::GetProductFamilyID ()<br>
+{<br>
+    return ProductFamilyID([m_dev productFamilyID]);<br>
+}<br>
+<br>
+CoreSimulatorSupport::DeviceRuntime::DeviceRuntime () :<br>
+    m_dev (nil),<br>
+    m_os_version ()<br>
+{<br>
+}<br>
+<br>
+CoreSimulatorSupport::DeviceRuntime::DeviceRuntime (id d) :<br>
+    m_dev (d),<br>
+    m_os_version ()<br>
+{<br>
+}<br>
+<br>
+CoreSimulatorSupport::DeviceRuntime::operator bool ()<br>
+{<br>
+    return m_dev != nil;<br>
+}<br>
+<br>
+bool<br>
+CoreSimulatorSupport::DeviceRuntime::IsAvailable ()<br>
+{<br>
+    return [m_dev available];<br>
+}<br>
+<br>
+CoreSimulatorSupport::Device::Device () :<br>
+    m_dev (nil),<br>
+    m_dev_type (),<br>
+    m_dev_runtime ()<br>
+{<br>
+}<br>
+<br>
+CoreSimulatorSupport::Device::Device (id d) :<br>
+    m_dev (d),<br>
+    m_dev_type (),<br>
+    m_dev_runtime ()<br>
+{<br>
+}<br>
+<br>
+CoreSimulatorSupport::Device::operator bool ()<br>
+{<br>
+    return m_dev != nil;<br>
+}<br>
+<br>
+CoreSimulatorSupport::Device::State<br>
+CoreSimulatorSupport::Device::GetState ()<br>
+{<br>
+    return (State)([m_dev state]);<br>
+}<br>
+<br>
+CoreSimulatorSupport::ModelIdentifier::ModelIdentifier (const std::string& mi) :<br>
+    m_family (),<br>
+    m_versions ()<br>
+{<br>
+    bool any = false;<br>
+    bool first_digit = false;<br>
+    unsigned int val = 0;<br>
+<br>
+    for (char c : mi)<br>
+    {<br>
+        any = true;<br>
+        if (::isdigit(c))<br>
+        {<br>
+            if (!first_digit)<br>
+                first_digit = true;<br>
+            val = 10*val + (c - '0');<br>
+        }<br>
+        else if (c == ',')<br>
+        {<br>
+            if (first_digit)<br>
+            {<br>
+                m_versions.push_back(val);<br>
+                val = 0;<br>
+            }<br>
+            else<br>
+                m_family.push_back(c);<br>
+        }<br>
+        else<br>
+        {<br>
+            if (first_digit)<br>
+            {<br>
+                m_family.clear();<br>
+                m_versions.clear();<br>
+                return;<br>
+            }<br>
+            else<br>
+            {<br>
+                m_family.push_back(c);<br>
+            }<br>
+        }<br>
+    }<br>
+<br>
+    if (first_digit)<br>
+        m_versions.push_back(val);<br>
+}<br>
+<br>
+CoreSimulatorSupport::ModelIdentifier::ModelIdentifier () :<br>
+ModelIdentifier("")<br>
+{<br>
+}<br>
+<br>
+CoreSimulatorSupport::OSVersion::OSVersion (const std::string& ver,<br>
+                                            const std::string& build) :<br>
+    m_versions (),<br>
+    m_build (build)<br>
+{<br>
+    bool any = false;<br>
+    unsigned int val = 0;<br>
+    for (char c : ver)<br>
+    {<br>
+        if (c == '.')<br>
+        {<br>
+            m_versions.push_back(val);<br>
+            val = 0;<br>
+        }<br>
+        else if (::isdigit(c))<br>
+        {<br>
+            val = 10*val + (c - '0');<br>
+            any = true;<br>
+        }<br>
+        else<br>
+        {<br>
+            m_versions.clear();<br>
+            return;<br>
+        }<br>
+    }<br>
+    if (any)<br>
+        m_versions.push_back(val);<br>
+}<br>
+<br>
+CoreSimulatorSupport::OSVersion::OSVersion () :<br>
+    OSVersion("","")<br>
+{<br>
+}<br>
+<br>
+CoreSimulatorSupport::ModelIdentifier<br>
+CoreSimulatorSupport::DeviceType::GetModelIdentifier ()<br>
+{<br>
+    if (!m_model_identifier.hasValue())<br>
+    {<br>
+        auto utf8_model_id = [[m_dev modelIdentifier] UTF8String];<br>
+        if (utf8_model_id && *utf8_model_id)<br>
+            m_model_identifier = ModelIdentifier (utf8_model_id);<br>
+    }<br>
+<br>
+    if (m_model_identifier.hasValue())<br>
+        return m_model_identifier.getValue();<br>
+    else<br>
+        return ModelIdentifier();<br>
+}<br>
+<br>
+CoreSimulatorSupport::OSVersion<br>
+CoreSimulatorSupport::DeviceRuntime::GetVersion ()<br>
+{<br>
+    if (!m_os_version.hasValue())<br>
+    {<br>
+        auto utf8_ver_string = [[m_dev versionString] UTF8String];<br>
+        auto utf8_build_ver = [[m_dev buildVersionString] UTF8String];<br>
+        if (utf8_ver_string && *utf8_ver_string &&<br>
+            utf8_build_ver && *utf8_build_ver)<br>
+        {<br>
+            m_os_version = OSVersion(utf8_ver_string, utf8_build_ver);<br>
+        }<br>
+    }<br>
+<br>
+    if (m_os_version.hasValue())<br>
+        return m_os_version.getValue();<br>
+    return OSVersion();<br>
+}<br>
+<br>
+std::string<br>
+CoreSimulatorSupport::DeviceType::GetName ()<br>
+{<br>
+    auto utf8_name = [[m_dev name] UTF8String];<br>
+    if (utf8_name)<br>
+        return std::string(utf8_name);<br>
+    return "";<br>
+}<br>
+<br>
+std::string<br>
+CoreSimulatorSupport::Device::GetName () const<br>
+{<br>
+    auto utf8_name = [[m_dev name] UTF8String];<br>
+    if (utf8_name)<br>
+        return std::string(utf8_name);<br>
+    return "";<br>
+}<br>
+<br>
+std::string<br>
+CoreSimulatorSupport::Device::GetUDID () const<br>
+{<br>
+    auto utf8_udid = [ [[m_dev UDID] UUIDString] UTF8String];<br>
+    if (utf8_udid)<br>
+        return std::string(utf8_udid);<br>
+    else<br>
+        return std::string();<br>
+}<br>
+<br>
+CoreSimulatorSupport::DeviceType<br>
+CoreSimulatorSupport::Device::GetDeviceType ()<br>
+{<br>
+    if (!m_dev_type.hasValue())<br>
+        m_dev_type = DeviceType([m_dev deviceType]);<br>
+<br>
+    return m_dev_type.getValue();<br>
+}<br>
+<br>
+CoreSimulatorSupport::DeviceRuntime<br>
+CoreSimulatorSupport::Device::GetDeviceRuntime ()<br>
+{<br>
+    if (!m_dev_runtime.hasValue())<br>
+        m_dev_runtime = DeviceRuntime([m_dev runtime]);<br>
+<br>
+    return m_dev_runtime.getValue();<br>
+}<br>
+<br>
+bool<br>
+CoreSimulatorSupport::operator > (const CoreSimulatorSupport::OSVersion& lhs,<br>
+                                  const CoreSimulatorSupport::OSVersion& rhs)<br>
+{<br>
+    for (size_t i = 0;<br>
+         i < rhs.GetNumVersions();<br>
+         i++)<br>
+    {<br>
+        unsigned int l = lhs.GetVersionAtIndex(i);<br>
+        unsigned int r = rhs.GetVersionAtIndex(i);<br>
+        if (l > r)<br>
+            return true;<br>
+    }<br>
+    return false;<br>
+}<br>
+<br>
+bool<br>
+CoreSimulatorSupport::operator > (const CoreSimulatorSupport::ModelIdentifier& lhs,<br>
+                                  const CoreSimulatorSupport::ModelIdentifier& rhs)<br>
+{<br>
+    if (lhs.GetFamily() != rhs.GetFamily())<br>
+        return false;<br>
+    for (size_t i = 0;<br>
+         i < rhs.GetNumVersions();<br>
+         i++)<br>
+    {<br>
+        unsigned int l = lhs.GetVersionAtIndex(i);<br>
+        unsigned int r = rhs.GetVersionAtIndex(i);<br>
+        if (l > r)<br>
+            return true;<br>
+    }<br>
+    return false;<br>
+}<br>
+<br>
+bool<br>
+CoreSimulatorSupport::operator < (const CoreSimulatorSupport::OSVersion& lhs,<br>
+                                  const CoreSimulatorSupport::OSVersion& rhs)<br>
+{<br>
+    for (size_t i = 0;<br>
+         i < rhs.GetNumVersions();<br>
+         i++)<br>
+    {<br>
+        unsigned int l = lhs.GetVersionAtIndex(i);<br>
+        unsigned int r = rhs.GetVersionAtIndex(i);<br>
+        if (l < r)<br>
+            return true;<br>
+    }<br>
+    return false;<br>
+}<br>
+<br>
+bool<br>
+CoreSimulatorSupport::operator < (const CoreSimulatorSupport::ModelIdentifier& lhs,<br>
+                                  const CoreSimulatorSupport::ModelIdentifier& rhs)<br>
+{<br>
+    if (lhs.GetFamily() != rhs.GetFamily())<br>
+        return false;<br>
+<br>
+    for (size_t i = 0;<br>
+         i < rhs.GetNumVersions();<br>
+         i++)<br>
+    {<br>
+        unsigned int l = lhs.GetVersionAtIndex(i);<br>
+        unsigned int r = rhs.GetVersionAtIndex(i);<br>
+        if (l < r)<br>
+            return true;<br>
+    }<br>
+    return false;<br>
+}<br>
+<br>
+bool<br>
+CoreSimulatorSupport::operator == (const CoreSimulatorSupport::OSVersion& lhs,<br>
+                                   const CoreSimulatorSupport::OSVersion& rhs)<br>
+{<br>
+    for (size_t i = 0;<br>
+         i < rhs.GetNumVersions();<br>
+         i++)<br>
+    {<br>
+        unsigned int l = lhs.GetVersionAtIndex(i);<br>
+        unsigned int r = rhs.GetVersionAtIndex(i);<br>
+        if (l != r)<br>
+            return false;<br>
+    }<br>
+    return true;<br>
+}<br>
+<br>
+bool<br>
+CoreSimulatorSupport::operator == (const CoreSimulatorSupport::ModelIdentifier& lhs,<br>
+                                   const CoreSimulatorSupport::ModelIdentifier& rhs)<br>
+{<br>
+    if (lhs.GetFamily() != rhs.GetFamily())<br>
+        return false;<br>
+<br>
+    for (size_t i = 0;<br>
+         i < rhs.GetNumVersions();<br>
+         i++)<br>
+    {<br>
+        unsigned int l = lhs.GetVersionAtIndex(i);<br>
+        unsigned int r = rhs.GetVersionAtIndex(i);<br>
+        if (l != r)<br>
+            return false;<br>
+    }<br>
+    return true;<br>
+}<br>
+<br>
+bool<br>
+CoreSimulatorSupport::operator != (const CoreSimulatorSupport::OSVersion& lhs,<br>
+                                   const CoreSimulatorSupport::OSVersion& rhs)<br>
+{<br>
+    for (size_t i = 0;<br>
+         i < rhs.GetNumVersions();<br>
+         i++)<br>
+    {<br>
+        unsigned int l = lhs.GetVersionAtIndex(i);<br>
+        unsigned int r = rhs.GetVersionAtIndex(i);<br>
+        if (l != r)<br>
+            return true;<br>
+    }<br>
+    return false;<br>
+}<br>
+<br>
+bool<br>
+CoreSimulatorSupport::operator != (const CoreSimulatorSupport::ModelIdentifier& lhs,<br>
+                                   const CoreSimulatorSupport::ModelIdentifier& rhs)<br>
+{<br>
+    if (lhs.GetFamily() != rhs.GetFamily())<br>
+        return false;<br>
+<br>
+    for (size_t i = 0;<br>
+         i < rhs.GetNumVersions();<br>
+         i++)<br>
+    {<br>
+        unsigned int l = lhs.GetVersionAtIndex(i);<br>
+        unsigned int r = rhs.GetVersionAtIndex(i);<br>
+        if (l != r)<br>
+            return true;<br>
+    }<br>
+    return false;<br>
+}<br>
+<br>
+bool<br>
+CoreSimulatorSupport::Device::Boot (Error &err)<br>
+{<br>
+    if (m_dev == nil)<br>
+    {<br>
+        err.SetErrorString("no valid simulator instance");<br>
+        return false;<br>
+    }<br>
+<br>
+#define kSimDeviceBootEnv            @"env"           /* An NSDictionary of "extra" environment key/values */<br>
+#define kSimDeviceBootPersist        @"persist"       /* An NSNumber (boolean) indicating whether or not the session should outlive the calling process (default false) */<br>
+#define kSimDeviceBootDisabledJobs   @"disabled_jobs" /* An NSDictionary of NSStrings -> NSNumbers, each string is the name of a job, and the value is the corresponding state (true if disabled) */<br>
+<br>
+    NSDictionary *options = @{<br>
+                              kSimDeviceBootPersist : @NO,<br>
+                              kSimDeviceBootDisabledJobs : @{@"com.apple.backboardd" : @YES}<br>
+                              };<br>
+<br>
+#undef kSimDeviceBootEnv<br>
+#undef kSimDeviceBootPersist<br>
+#undef kSimDeviceBootDisabledJobs<br>
+<br>
+    NSError* nserror;<br>
+    if ([m_dev bootWithOptions:options error:&nserror])<br>
+    {<br>
+        err.Clear();<br>
+        return true;<br>
+    }<br>
+    else<br>
+    {<br>
+        err.SetErrorString([[nserror description] UTF8String]);<br>
+        return false;<br>
+    }<br>
+}<br>
+<br>
+bool<br>
+CoreSimulatorSupport::Device::Shutdown (Error &err)<br>
+{<br>
+    NSError* nserror;<br>
+    if ([m_dev shutdownWithError:&nserror])<br>
+    {<br>
+        err.Clear();<br>
+        return true;<br>
+    }<br>
+    else<br>
+    {<br>
+        err.SetErrorString([[nserror description] UTF8String]);<br>
+        return false;<br>
+    }<br>
+}<br>
+<br>
+<br>
+static Error<br>
+HandleFileAction(ProcessLaunchInfo& launch_info,<br>
+                 NSMutableDictionary *options,<br>
+                 NSString *key,<br>
+                 const int fd,<br>
+                 File &file)<br>
+{<br>
+    Error error;<br>
+    const FileAction *file_action = launch_info.GetFileActionForFD (fd);<br>
+    if (file_action)<br>
+    {<br>
+        switch (file_action->GetAction())<br>
+        {<br>
+            case FileAction::eFileActionNone:<br>
+                break;<br>
+<br>
+            case FileAction::eFileActionClose:<br>
+                error.SetErrorStringWithFormat ("close file action for %i not supported", fd);<br>
+                break;<br>
+<br>
+            case FileAction::eFileActionDuplicate:<br>
+                error.SetErrorStringWithFormat ("duplication file action for %i not supported", fd);<br>
+                break;<br>
+<br>
+            case FileAction::eFileActionOpen:<br>
+                {<br>
+                    FileSpec file_spec = file_action->GetFileSpec();<br>
+                    if (file_spec)<br>
+                    {<br>
+                        const int master_fd = launch_info.GetPTY().GetMasterFileDescriptor();<br>
+                        if (master_fd != PseudoTerminal::invalid_fd)<br>
+                        {<br>
+                            // Check in case our file action open wants to open the slave<br>
+                            const char *slave_path = launch_info.GetPTY().GetSlaveName(NULL, 0);<br>
+                            if (slave_path)<br>
+                            {<br>
+                                FileSpec slave_spec(slave_path, false);<br>
+                                if (file_spec == slave_spec)<br>
+                                {<br>
+                                    int slave_fd = launch_info.GetPTY().GetSlaveFileDescriptor();<br>
+                                    if (slave_fd == PseudoTerminal::invalid_fd)<br>
+                                        slave_fd = launch_info.GetPTY().OpenSlave(O_RDWR, nullptr, 0);<br>
+                                    if (slave_fd == PseudoTerminal::invalid_fd)<br>
+                                    {<br>
+                                        error.SetErrorStringWithFormat("unable to open slave pty '%s'", slave_path);<br>
+                                        return error; // Failure<br>
+                                    }<br>
+                                    [options setValue:[NSNumber numberWithInteger:slave_fd] forKey:key];<br>
+                                    return error; // Success<br>
+                                }<br>
+                            }<br>
+                        }<br>
+                        Error posix_error;<br>
+                        int created_fd = open(file_spec.GetPath().c_str(), file_action->GetActionArgument(), S_IRUSR | S_IWUSR);<br>
+                        if (created_fd >= 0)<br>
+                        {<br>
+                            file.SetDescriptor(created_fd, true);<br>
+                            [options setValue:[NSNumber numberWithInteger:created_fd] forKey:key];<br>
+                            return error; // Success<br>
+                        }<br>
+                        else<br>
+                        {<br>
+                            posix_error.SetErrorToErrno();<br>
+                            error.SetErrorStringWithFormat("unable to open file '%s': %s", file_spec.GetPath().c_str(), posix_error.AsCString());<br>
+                        }<br>
+                    }<br>
+                }<br>
+                break;<br>
+        }<br>
+    }<br>
+    return error; // Success, no file action, nothing to do<br>
+}<br>
+<br>
+CoreSimulatorSupport::Process<br>
+CoreSimulatorSupport::Device::Spawn (ProcessLaunchInfo& launch_info)<br>
+{<br>
+#define kSimDeviceSpawnEnvironment     @"environment"        /* An NSDictionary (NSStrings -> NSStrings) of environment key/values */<br>
+#define kSimDeviceSpawnStdin           @"stdin"              /* An NSNumber corresponding to a fd */<br>
+#define kSimDeviceSpawnStdout          @"stdout"             /* An NSNumber corresponding to a fd */<br>
+#define kSimDeviceSpawnStderr          @"stderr"             /* An NSNumber corresponding to a fd */<br>
+#define kSimDeviceSpawnArguments       @"arguments"          /* An NSArray of strings to use as the argv array.  If not provided, path will be argv[0] */<br>
+#define kSimDeviceSpawnWaitForDebugger @"wait_for_debugger"  /* An NSNumber (bool) */<br>
+<br>
+    NSMutableDictionary *options = [[NSMutableDictionary alloc] init];<br>
+<br>
+    if (launch_info.GetFlags().Test(lldb::eLaunchFlagDebug))<br>
+        [options setObject:@YES forKey:kSimDeviceSpawnWaitForDebugger];<br>
+<br>
+    if (launch_info.GetArguments().GetArgumentCount())<br>
+    {<br>
+        const Args& args(launch_info.GetArguments());<br>
+        NSMutableArray *args_array = [[NSMutableArray alloc] init];<br>
+        for (size_t idx = 0;<br>
+             idx < args.GetArgumentCount();<br>
+             idx++)<br>
+            [args_array addObject:[NSString stringWithUTF8String:args.GetArgumentAtIndex(idx)]];<br>
+<br>
+        [options setObject:args_array forKey:kSimDeviceSpawnArguments];<br>
+    }<br>
+<br>
+    if (launch_info.GetEnvironmentEntries().GetArgumentCount())<br>
+    {<br>
+        const Args& envs(launch_info.GetEnvironmentEntries());<br>
+        NSMutableDictionary *env_dict = [[NSMutableDictionary alloc] init];<br>
+        for (size_t idx = 0;<br>
+             idx < envs.GetArgumentCount();<br>
+             idx++)<br>
+        {<br>
+            llvm::StringRef arg_sr(envs.GetArgumentAtIndex(idx));<br>
+            auto first_eq = arg_sr.find('=');<br>
+            if (first_eq == llvm::StringRef::npos)<br>
+                continue;<br>
+            llvm::StringRef key = arg_sr.substr(0, first_eq);<br>
+            llvm::StringRef value = arg_sr.substr(first_eq+1);<br>
+<br>
+            NSString *key_ns = [NSString stringWithUTF8String:key.str().c_str()];<br>
+            NSString *value_ns = [NSString stringWithUTF8String:value.str().c_str()];<br>
+<br>
+            [env_dict setValue:value_ns forKey:key_ns];<br>
+        }<br>
+<br>
+        [options setObject:env_dict forKey:kSimDeviceSpawnEnvironment];<br>
+    }<br>
+<br>
+    Error error;<br>
+    File stdin_file;<br>
+    File stdout_file;<br>
+    File stderr_file;<br>
+    error = HandleFileAction(launch_info, options, kSimDeviceSpawnStdin, STDIN_FILENO, stdin_file);<br>
+<br>
+    if (error.Fail())<br>
+        return CoreSimulatorSupport::Process(error);<br>
+<br>
+    error = HandleFileAction(launch_info, options, kSimDeviceSpawnStdout, STDOUT_FILENO, stdout_file);<br>
+<br>
+    if (error.Fail())<br>
+        return CoreSimulatorSupport::Process(error);<br>
+<br>
+    error = HandleFileAction(launch_info, options, kSimDeviceSpawnStderr, STDERR_FILENO, stderr_file);<br>
+<br>
+    if (error.Fail())<br>
+        return CoreSimulatorSupport::Process(error);<br>
+<br>
+#undef kSimDeviceSpawnEnvironment<br>
+#undef kSimDeviceSpawnStdin<br>
+#undef kSimDeviceSpawnStdout<br>
+#undef kSimDeviceSpawnStderr<br>
+#undef kSimDeviceSpawnWaitForDebugger<br>
+#undef kSimDeviceSpawnArguments<br>
+<br>
+    NSError* nserror;<br>
+<br>
+    pid_t pid = [m_dev spawnWithPath: [NSString stringWithUTF8String: launch_info.GetExecutableFile().GetPath().c_str()]<br>
+                             options: options<br>
+                  terminationHandler: nil<br>
+                               error: &nserror];<br>
+<br>
+<br>
+    if (pid < 0)<br>
+    {<br>
+        const char* nserror_string = [[nserror description] UTF8String];<br>
+        error.SetErrorString(nserror_string ? nserror_string : "unable to launch");<br>
+    }<br>
+<br>
+    return CoreSimulatorSupport::Process (pid, error);<br>
+}<br>
+<br>
+CoreSimulatorSupport::DeviceSet<br>
+CoreSimulatorSupport::DeviceSet::GetAllDevices ()<br>
+{<br>
+    return DeviceSet([[NSClassFromString(@"SimDeviceSet") defaultSet] devices]);<br>
+}<br>
+<br>
+CoreSimulatorSupport::DeviceSet<br>
+CoreSimulatorSupport::DeviceSet::GetAvailableDevices ()<br>
+{<br>
+    return GetAllDevices().GetDevicesIf( [] (Device d) -> bool {<br>
+        return (d && d.GetDeviceType() && d.GetDeviceRuntime() && d.GetDeviceRuntime().IsAvailable());<br>
+    });<br>
+}<br>
+<br>
+size_t<br>
+CoreSimulatorSupport::DeviceSet::GetNumDevices ()<br>
+{<br>
+    return [m_dev count];<br>
+}<br>
+<br>
+CoreSimulatorSupport::Device<br>
+CoreSimulatorSupport::DeviceSet::GetDeviceAtIndex (size_t idx)<br>
+{<br>
+    if (idx < GetNumDevices())<br>
+        return Device([m_dev objectAtIndex:idx]);<br>
+    return Device();<br>
+}<br>
+<br>
+CoreSimulatorSupport::DeviceSet<br>
+CoreSimulatorSupport::DeviceSet::GetDevicesIf (std::function<bool(CoreSimulatorSupport::Device)> f)<br>
+{<br>
+    NSMutableArray *array = [[NSMutableArray alloc] init];<br>
+    for (NSUInteger i = 0;<br>
+         i < GetNumDevices();<br>
+         i++)<br>
+    {<br>
+        Device d(GetDeviceAtIndex(i));<br>
+        if (f(d))<br>
+            [array addObject:(id)d.m_dev];<br>
+    }<br>
+<br>
+    return DeviceSet(array);<br>
+}<br>
+<br>
+void<br>
+CoreSimulatorSupport::DeviceSet::ForEach (std::function<bool(const Device &)> f)<br>
+{<br>
+    const size_t n = GetNumDevices();<br>
+    for (NSUInteger i = 0; i < n; ++i)<br>
+    {<br>
+        if (f(GetDeviceAtIndex(i)) == false)<br>
+            break;<br>
+    }<br>
+}<br>
+<br>
+CoreSimulatorSupport::DeviceSet<br>
+CoreSimulatorSupport::DeviceSet::GetDevices (CoreSimulatorSupport::DeviceType::ProductFamilyID dev_id)<br>
+{<br>
+    NSMutableArray *array = [[NSMutableArray alloc] init];<br>
+    const size_t n = GetNumDevices();<br>
+    for (NSUInteger i = 0; i < n; ++i)<br>
+    {<br>
+        Device d(GetDeviceAtIndex(i));<br>
+        if (d && d.GetDeviceType() && d.GetDeviceType().GetProductFamilyID() == dev_id)<br>
+            [array addObject:(id)d.m_dev];<br>
+    }<br>
+<br>
+    return DeviceSet(array);<br>
+}<br>
+<br>
+CoreSimulatorSupport::Device<br>
+CoreSimulatorSupport::DeviceSet::GetFanciest (CoreSimulatorSupport::DeviceType::ProductFamilyID dev_id)<br>
+{<br>
+    Device dev;<br>
+<br>
+    for (NSUInteger i = 0;<br>
+         i < GetNumDevices();<br>
+         i++)<br>
+    {<br>
+        Device d(GetDeviceAtIndex(i));<br>
+        if (d && d.GetDeviceType() && d.GetDeviceType().GetProductFamilyID() == dev_id)<br>
+        {<br>
+            if (!dev)<br>
+                dev = d;<br>
+            else<br>
+            {<br>
+                if ((d.GetDeviceType().GetModelIdentifier() > dev.GetDeviceType().GetModelIdentifier()) ||<br>
+                    d.GetDeviceRuntime().GetVersion() > dev.GetDeviceRuntime().GetVersion())<br>
+                    dev = d;<br>
+            }<br>
+        }<br>
+    }<br>
+<br>
+    return dev;<br>
+}<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org">lldb-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
</blockquote></div><br></div>