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