├── .gitignore ├── Hash Map ├── RuntimeSample.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcuserdata │ │ │ └── kyson.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── kyson.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── RuntimeSample │ ├── KSNXHashTable.c │ ├── KSNXHashTable.h │ ├── KSNXMapTable.c │ ├── KSNXMapTable.h │ └── main.m ├── HookModInitiOSDemo ├── .DS_Store ├── HookModInitiOSDemo.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcuserdata │ │ │ └── kyson.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── kyson.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── HookModInitiOSDemo │ ├── .DS_Store │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ ├── AccentColor.colorset │ │ │ └── Contents.json │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── SceneDelegate.h │ ├── SceneDelegate.m │ ├── Test │ │ ├── TestAttribute.h │ │ ├── TestAttribute.m │ │ ├── TestCBlock.h │ │ ├── TestCBlock.mm │ │ ├── TestClass.h │ │ ├── TestClass.mm │ │ ├── TestDict.h │ │ ├── TestDict.m │ │ ├── TestFunction.h │ │ ├── TestFunction.mm │ │ ├── TestMacro.h │ │ ├── TestMacro.mm │ │ ├── TestRectZero.h │ │ ├── TestRectZero.mm │ │ ├── TestStaticClassMemberMutex.cpp │ │ ├── TestStaticClassMemberMutex.hpp │ │ ├── TestVarVar.h │ │ ├── TestVarVar.mm │ │ └── TextVarVarC.c │ ├── ViewController.h │ ├── ViewController.m │ └── main.m └── hook_cpp_init.mm ├── LogLog ├── .DS_Store ├── LogDemo │ └── main.mm ├── LogLog.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcuserdata │ │ │ └── kyson.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── kyson.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── dependency │ └── _simple.h ├── libLogLog.dylib ├── objc-env.h ├── objc-errors.mm ├── objc-os.h ├── objc-os.mm ├── objc-private.h ├── objc-runtime.h ├── objc-runtime.mm └── objc.h ├── MyDIYClass ├── MyDIYClass │ ├── MyDIYClass.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ ├── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ └── xcuserdata │ │ │ │ └── kyson.xcuserdatad │ │ │ │ └── UserInterfaceState.xcuserstate │ │ └── xcuserdata │ │ │ └── kyson.xcuserdatad │ │ │ └── xcschemes │ │ │ └── xcschememanagement.plist │ └── MyDIYClass │ │ ├── TestObject.h │ │ ├── TestObject.m │ │ └── main.mm ├── MyDIYClass2 │ ├── MyDIYClass │ │ ├── A.cpp │ │ ├── A.hpp │ │ ├── TestObject.h │ │ ├── TestObject.mm │ │ └── main.mm │ └── MyDIYClass2.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcuserdata │ │ │ └── kyson.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ │ ├── xcshareddata │ │ └── xcschemes │ │ │ └── MyDIYClass.xcscheme │ │ └── xcuserdata │ │ └── kyson.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ └── xcschememanagement.plist └── MyDIYClass3 │ ├── MyDIYClass │ ├── TestObject.h │ ├── TestObject.m │ └── main.mm │ └── MyDIYClass2.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── kyson.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ ├── xcshareddata │ └── xcschemes │ │ └── MyDIYClass.xcscheme │ └── xcuserdata │ └── kyson.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── xcschememanagement.plist ├── README.md ├── Section ├── .DS_Store ├── Person.h ├── Person.mm ├── Section.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcuserdata │ │ │ └── kyson.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── kyson.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── SectionDemo │ └── main.mm ├── libSection.dylib ├── objc-file.h ├── objc-file.mm ├── objc-private.h ├── section.h └── section.mm ├── SetSectionCustomInfoDemo ├── SetSectionCustomInfoDemo.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcuserdata │ │ │ └── kyson.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── kyson.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── SetSectionCustomInfoDemo │ └── main.m ├── debugableruntime ├── objc4-706-master │ ├── .gitignore │ ├── APPLE_LICENSE │ ├── README.md │ ├── ReleaseNotes.rtf │ ├── debug-objc │ │ └── main.m │ ├── include │ │ ├── Block_private.h │ │ ├── CrashReporterClient.h │ │ ├── System │ │ │ ├── machine │ │ │ │ └── cpu_capabilities.h │ │ │ └── pthread_machdep.h │ │ ├── _simple.h │ │ ├── mach-o │ │ │ └── dyld_priv.h │ │ ├── objc-shared-cache.h │ │ ├── os │ │ │ └── tsd.h │ │ ├── pthread │ │ │ ├── qos_private.h │ │ │ ├── spinlock_private.h │ │ │ ├── tsd_private.h │ │ │ └── workqueue_private.h │ │ └── sys │ │ │ ├── qos_private.h │ │ │ └── reason.h │ ├── libobjc.order │ ├── markgc.cpp │ ├── objc.sln │ ├── objc.suo │ ├── objc.vcproj │ ├── objc.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ ├── objcrt │ │ └── objcrt.vcproj │ ├── prebuild.bat │ ├── runtime │ │ ├── Messengers.subproj │ │ │ ├── objc-msg-arm.s │ │ │ ├── objc-msg-arm64.s │ │ │ ├── objc-msg-i386.s │ │ │ ├── objc-msg-simulator-i386.s │ │ │ ├── objc-msg-simulator-x86_64.s │ │ │ ├── objc-msg-win32.m │ │ │ └── objc-msg-x86_64.s │ │ ├── NSObjCRuntime.h │ │ ├── NSObject.h │ │ ├── NSObject.mm │ │ ├── Object.h │ │ ├── Object.mm │ │ ├── OldClasses.subproj │ │ │ ├── List.h │ │ │ └── List.m │ │ ├── Protocol.h │ │ ├── Protocol.mm │ │ ├── a1a2-blocktramps-arm.s │ │ ├── a1a2-blocktramps-arm64.s │ │ ├── a1a2-blocktramps-i386.s │ │ ├── a1a2-blocktramps-x86_64.s │ │ ├── a2a3-blocktramps-arm.s │ │ ├── a2a3-blocktramps-i386.s │ │ ├── a2a3-blocktramps-x86_64.s │ │ ├── hashtable.h │ │ ├── hashtable2.h │ │ ├── hashtable2.mm │ │ ├── llvm-AlignOf.h │ │ ├── llvm-DenseMap.h │ │ ├── llvm-DenseMapInfo.h │ │ ├── llvm-MathExtras.h │ │ ├── llvm-type_traits.h │ │ ├── maptable.h │ │ ├── maptable.mm │ │ ├── message.h │ │ ├── objc-abi.h │ │ ├── objc-accessors.mm │ │ ├── objc-api.h │ │ ├── objc-auto.h │ │ ├── objc-auto.mm │ │ ├── objc-block-trampolines.mm │ │ ├── objc-cache-old.h │ │ ├── objc-cache-old.mm │ │ ├── objc-cache.h │ │ ├── objc-cache.mm │ │ ├── objc-class-old.mm │ │ ├── objc-class.h │ │ ├── objc-class.mm │ │ ├── objc-config.h │ │ ├── objc-env.h │ │ ├── objc-errors.mm │ │ ├── objc-exception.h │ │ ├── objc-exception.mm │ │ ├── objc-file-old.h │ │ ├── objc-file-old.mm │ │ ├── objc-file.h │ │ ├── objc-file.mm │ │ ├── objc-gdb.h │ │ ├── objc-initialize.h │ │ ├── objc-initialize.mm │ │ ├── objc-internal.h │ │ ├── objc-layout.mm │ │ ├── objc-load.h │ │ ├── objc-load.mm │ │ ├── objc-loadmethod.h │ │ ├── objc-loadmethod.mm │ │ ├── objc-lockdebug.h │ │ ├── objc-lockdebug.mm │ │ ├── objc-object.h │ │ ├── objc-opt.mm │ │ ├── objc-os.h │ │ ├── objc-os.mm │ │ ├── objc-private.h │ │ ├── objc-probes.d │ │ ├── objc-references.h │ │ ├── objc-references.mm │ │ ├── objc-runtime-new.h │ │ ├── objc-runtime-new.mm │ │ ├── objc-runtime-old.h │ │ ├── objc-runtime-old.mm │ │ ├── objc-runtime.h │ │ ├── objc-runtime.mm │ │ ├── objc-sel-old.mm │ │ ├── objc-sel-set.h │ │ ├── objc-sel-set.mm │ │ ├── objc-sel-table.s │ │ ├── objc-sel.mm │ │ ├── objc-sync.h │ │ ├── objc-sync.mm │ │ ├── objc-typeencoding.mm │ │ ├── objc-weak.h │ │ ├── objc-weak.mm │ │ ├── objc.h │ │ ├── objcrt.c │ │ ├── objcrt.h │ │ └── runtime.h │ ├── unexported_symbols │ ├── version.bat │ └── version.rc ├── objc4-818.2 │ ├── APPLE_LICENSE │ ├── ReleaseNotes.rtf │ ├── debugobjc │ │ ├── main.cpp │ │ └── main.mm │ ├── dependency │ │ ├── .DS_Store │ │ ├── Block_private.h │ │ ├── CrashReporterClient.h │ │ ├── System │ │ │ ├── .DS_Store │ │ │ ├── machine │ │ │ │ └── cpu_capabilities.h │ │ │ └── pthread_machdep.h │ │ ├── _simple.h │ │ ├── kern │ │ │ └── restartable.h │ │ ├── mach-o │ │ │ └── dyld_priv.h │ │ ├── objc-shared-cache.h │ │ ├── os │ │ │ ├── base_private.h │ │ │ ├── lock_private.h │ │ │ └── tsd.h │ │ ├── pthread │ │ │ ├── spinlock_private.h │ │ │ └── tsd_private.h │ │ └── sys │ │ │ └── reason.h │ ├── interposable.txt │ ├── libobjc.order │ ├── markgc.cpp │ ├── objc.sln │ ├── objc.vcproj │ ├── objc.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ ├── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ └── xcuserdata │ │ │ │ └── kyson.xcuserdatad │ │ │ │ └── UserInterfaceState.xcuserstate │ │ ├── xcshareddata │ │ │ └── xcschemes │ │ │ │ ├── debugobjc.xcscheme │ │ │ │ └── objc.xcscheme │ │ └── xcuserdata │ │ │ └── kyson.xcuserdatad │ │ │ ├── xcdebugger │ │ │ └── Breakpoints_v2.xcbkptlist │ │ │ └── xcschemes │ │ │ └── xcschememanagement.plist │ ├── objc4.plist │ ├── objcdt │ │ ├── json.h │ │ ├── json.mm │ │ ├── objcdt-entitlements.plist │ │ ├── objcdt.1 │ │ └── objcdt.mm │ ├── objcrt │ │ └── objcrt.vcproj │ ├── prebuild.bat │ ├── runtime │ │ ├── .DS_Store │ │ ├── DenseMapExtras.h │ │ ├── Messengers.subproj │ │ │ ├── objc-msg-arm.s │ │ │ ├── objc-msg-arm64.s │ │ │ ├── objc-msg-i386.s │ │ │ ├── objc-msg-simulator-i386.s │ │ │ ├── objc-msg-simulator-x86_64.s │ │ │ ├── objc-msg-win32.m │ │ │ └── objc-msg-x86_64.s │ │ ├── Module │ │ │ ├── ObjectiveC.apinotes │ │ │ └── module.modulemap │ │ ├── NSObjCRuntime.h │ │ ├── NSObject-internal.h │ │ ├── NSObject.h │ │ ├── NSObject.mm │ │ ├── Object.h │ │ ├── Object.mm │ │ ├── OldClasses.subproj │ │ │ ├── List.h │ │ │ └── List.m │ │ ├── PointerUnion.h │ │ ├── Protocol.h │ │ ├── Protocol.mm │ │ ├── arm64-asm.h │ │ ├── dummy-library-mac-i386.c │ │ ├── hashtable.h │ │ ├── hashtable2.h │ │ ├── hashtable2.mm │ │ ├── isa.h │ │ ├── llvm-AlignOf.h │ │ ├── llvm-DenseMap.h │ │ ├── llvm-DenseMapInfo.h │ │ ├── llvm-DenseSet.h │ │ ├── llvm-MathExtras.h │ │ ├── llvm-type_traits.h │ │ ├── maptable.h │ │ ├── maptable.mm │ │ ├── message.h │ │ ├── objc-abi.h │ │ ├── objc-accessors.mm │ │ ├── objc-api.h │ │ ├── objc-auto.h │ │ ├── objc-auto.mm │ │ ├── objc-block-trampolines.h │ │ ├── objc-block-trampolines.mm │ │ ├── objc-blocktramps-arm.s │ │ ├── objc-blocktramps-arm64.s │ │ ├── objc-blocktramps-i386.s │ │ ├── objc-blocktramps-x86_64.s │ │ ├── objc-cache-old.h │ │ ├── objc-cache-old.mm │ │ ├── objc-cache.mm │ │ ├── objc-class-old.mm │ │ ├── objc-class.h │ │ ├── objc-class.mm │ │ ├── objc-config.h │ │ ├── objc-env.h │ │ ├── objc-errors.mm │ │ ├── objc-exception.h │ │ ├── objc-exception.mm │ │ ├── objc-file-old.h │ │ ├── objc-file-old.mm │ │ ├── objc-file.h │ │ ├── objc-file.mm │ │ ├── objc-gdb.h │ │ ├── objc-initialize.h │ │ ├── objc-initialize.mm │ │ ├── objc-internal.h │ │ ├── objc-layout.mm │ │ ├── objc-load.h │ │ ├── objc-load.mm │ │ ├── objc-loadmethod.h │ │ ├── objc-loadmethod.mm │ │ ├── objc-lockdebug.h │ │ ├── objc-lockdebug.mm │ │ ├── objc-locks-new.h │ │ ├── objc-locks-old.h │ │ ├── objc-locks.h │ │ ├── objc-object.h │ │ ├── objc-opt.mm │ │ ├── objc-os.h │ │ ├── objc-os.mm │ │ ├── objc-private.h │ │ ├── objc-probes.d │ │ ├── objc-ptrauth.h │ │ ├── objc-references.h │ │ ├── objc-references.mm │ │ ├── objc-runtime-new.h │ │ ├── objc-runtime-new.mm │ │ ├── objc-runtime-old.h │ │ ├── objc-runtime-old.mm │ │ ├── objc-runtime.h │ │ ├── objc-runtime.mm │ │ ├── objc-sel-old.mm │ │ ├── objc-sel-set.h │ │ ├── objc-sel-set.mm │ │ ├── objc-sel-table.s │ │ ├── objc-sel.mm │ │ ├── objc-sync.h │ │ ├── objc-sync.mm │ │ ├── objc-typeencoding.mm │ │ ├── objc-weak.h │ │ ├── objc-weak.mm │ │ ├── objc-zalloc.h │ │ ├── objc-zalloc.mm │ │ ├── objc.h │ │ ├── objcrt.c │ │ ├── objcrt.h │ │ └── runtime.h │ ├── test │ │ ├── ARCBase.h │ │ ├── ARCBase.m │ │ ├── ARCLayouts.m │ │ ├── ARCLayoutsWithoutWeak.m │ │ ├── ARCMRC.h │ │ ├── ARCMRC.m │ │ ├── MRCARC.h │ │ ├── MRCARC.m │ │ ├── MRCBase.h │ │ ├── MRCBase.m │ │ ├── accessors.m │ │ ├── accessors2.m │ │ ├── addMethod.m │ │ ├── addMethods.m │ │ ├── addProtocol.m │ │ ├── applescriptobjc.m │ │ ├── arr-cast.m │ │ ├── arr-weak.m │ │ ├── asm-placeholder.s │ │ ├── association-cf.m │ │ ├── association.m │ │ ├── associationForbidden.h │ │ ├── associationForbidden.m │ │ ├── associationForbidden2.m │ │ ├── associationForbidden3.m │ │ ├── associationForbidden4.m │ │ ├── atomicProperty.mm │ │ ├── badAltHandler.m │ │ ├── badCache.m │ │ ├── badPool.m │ │ ├── badPoolCompat-ios.m │ │ ├── badPoolCompat-macos.m │ │ ├── badPoolCompat-tvos.m │ │ ├── badPoolCompat-watchos.m │ │ ├── badSuperclass.m │ │ ├── badSuperclass2.m │ │ ├── badTagClass.m │ │ ├── badTagIndex.m │ │ ├── bigrc.m │ │ ├── blocksAsImps.m │ │ ├── bool.c │ │ ├── cacheflush-constant.m │ │ ├── cacheflush.h │ │ ├── cacheflush.m │ │ ├── cacheflush0.m │ │ ├── cacheflush2.m │ │ ├── cacheflush3.m │ │ ├── category.m │ │ ├── cdtors.mm │ │ ├── classgetclass.m │ │ ├── classname.m │ │ ├── classpair.mm │ │ ├── classversion.m │ │ ├── concurrentcat.m │ │ ├── concurrentcat_category.m │ │ ├── consolidatePoolPointers.m │ │ ├── copyFixupHandler.mm │ │ ├── copyIvarList.m │ │ ├── copyMethodList.m │ │ ├── copyPropertyList.m │ │ ├── copyProtocolList.m │ │ ├── createInstance.m │ │ ├── customrr-cat1.m │ │ ├── customrr-cat2.m │ │ ├── customrr-nsobject-awz.m │ │ ├── customrr-nsobject-core.m │ │ ├── customrr-nsobject-none.m │ │ ├── customrr-nsobject-rr.m │ │ ├── customrr-nsobject-rrawz.m │ │ ├── customrr-nsobject.m │ │ ├── customrr.m │ │ ├── customrr2.m │ │ ├── definitions.c │ │ ├── designatedinit.m │ │ ├── duplicateClass.m │ │ ├── duplicateProtocols.m │ │ ├── duplicatedClasses.m │ │ ├── evil-class-def.m │ │ ├── exc.m │ │ ├── exchangeImp.m │ │ ├── fakeRealizedClass.m │ │ ├── fakeRealizedClass2.m │ │ ├── foreach.m │ │ ├── fork.m │ │ ├── forkInitialize.m │ │ ├── forkInitializeDisabled.m │ │ ├── forkInitializeSingleThreaded.m │ │ ├── forward.m │ │ ├── forwardDefault.m │ │ ├── forwardDefaultStret.m │ │ ├── future.h │ │ ├── future.m │ │ ├── future0.m │ │ ├── future2.m │ │ ├── gdb.m │ │ ├── getClassHook.m │ │ ├── getImageNameHook.m │ │ ├── getMethod.m │ │ ├── get_task_allow_entitlement.plist │ │ ├── headers.c │ │ ├── headers.sh │ │ ├── imageorder.h │ │ ├── imageorder.m │ │ ├── imageorder1.m │ │ ├── imageorder2.m │ │ ├── imageorder3.m │ │ ├── imports.c │ │ ├── include-warnings.c │ │ ├── includes-objc2.c │ │ ├── includes.c │ │ ├── initialize.m │ │ ├── initializeVersusWeak.m │ │ ├── instanceSize.m │ │ ├── isaValidation.m │ │ ├── ismeta.m │ │ ├── ivar.m │ │ ├── ivarSlide.h │ │ ├── ivarSlide.m │ │ ├── ivarSlide1.m │ │ ├── lazyClassName.m │ │ ├── libraryPath.c │ │ ├── literals.m │ │ ├── load-image-notification-dylib.m │ │ ├── load-image-notification.m │ │ ├── load-noobjc.m │ │ ├── load-noobjc2.m │ │ ├── load-noobjc3.m │ │ ├── load-order.m │ │ ├── load-order1.m │ │ ├── load-order2.m │ │ ├── load-order3.m │ │ ├── load-parallel.m │ │ ├── load-parallel0.m │ │ ├── load-parallel00.m │ │ ├── load-reentrant.m │ │ ├── load-reentrant2.m │ │ ├── load.m │ │ ├── methodArgs.m │ │ ├── methodCacheLeaks.m │ │ ├── methodListSize.m │ │ ├── methodListSmall.h │ │ ├── methodListSmall.mm │ │ ├── msgSend-performance.m │ │ ├── msgSend.m │ │ ├── nilAPIArgs.m │ │ ├── nonpointerisa.m │ │ ├── nopool.m │ │ ├── nscdtors.mm │ │ ├── nsexc.m │ │ ├── nsobject.m │ │ ├── nsprotocol.m │ │ ├── objectCopy.m │ │ ├── preopt-caches.entitlements │ │ ├── preopt-caches.mm │ │ ├── property.m │ │ ├── propertyDesc.m │ │ ├── protocol.m │ │ ├── protocolSmall.m │ │ ├── protocol_copyMethodList.m │ │ ├── protocol_copyPropertyList.m │ │ ├── rawisa.m │ │ ├── readClassPair.m │ │ ├── realizedClassGenerationCount.m │ │ ├── release-workaround.m │ │ ├── resolve.m │ │ ├── restartableRangesSynchronizeStress.m │ │ ├── rr-autorelease-fast.m │ │ ├── rr-autorelease-fastarc.m │ │ ├── rr-autorelease-stacklogging.m │ │ ├── rr-autorelease.m │ │ ├── rr-autorelease2.m │ │ ├── rr-nsautorelease.m │ │ ├── rr-sidetable.m │ │ ├── runtime.m │ │ ├── sel.m │ │ ├── setAssociatedObjectHook.m │ │ ├── setSuper.m │ │ ├── subscripting.m │ │ ├── super.m │ │ ├── supported-inline-refcnt.m │ │ ├── swift-class-def.m │ │ ├── swiftMetadataInitializer.m │ │ ├── swiftMetadataInitializerRealloc-dylib1.m │ │ ├── swiftMetadataInitializerRealloc-dylib2.m │ │ ├── swiftMetadataInitializerRealloc.m │ │ ├── synchronized-counter.m │ │ ├── synchronized-grid.m │ │ ├── synchronized.m │ │ ├── taggedNSPointers.m │ │ ├── taggedPointers.m │ │ ├── taggedPointersAllClasses.m │ │ ├── taggedPointersDisabled.m │ │ ├── taggedPointersTagObfuscationDisabled.m │ │ ├── tbi.c │ │ ├── test-defines.h │ │ ├── test.h │ │ ├── test.pl │ │ ├── testroot.i │ │ ├── timeout.pl │ │ ├── unload.h │ │ ├── unload.m │ │ ├── unload2.m │ │ ├── unload3.c │ │ ├── unload4.m │ │ ├── unwind.m │ │ ├── weak.h │ │ ├── weak.m │ │ ├── weak2.m │ │ ├── weakReferenceHook.m │ │ ├── weakcopy.m │ │ ├── weakframework-missing.m │ │ ├── weakframework-not-missing.m │ │ ├── weakimport-missing.m │ │ ├── weakimport-not-missing.m │ │ ├── weakrace.m │ │ ├── willInitializeClassFunc.m │ │ └── zone.m │ ├── unexported_symbols │ ├── version.bat │ └── version.rc └── objc4-838.1-main │ ├── .gitignore │ ├── APPLE_LICENSE │ ├── PrivateHeaders │ ├── Block_private.h │ ├── CrashReporterClient.h │ ├── System │ │ ├── machine │ │ │ └── cpu_capabilities.h │ │ └── pthread_machdep.h │ ├── _simple.h │ ├── kern │ │ └── restartable.h │ ├── mach-o │ │ └── dyld_priv.h │ ├── objc-shared-cache.h │ ├── os │ │ ├── base_private.h │ │ ├── linker_set.h │ │ ├── lock_private.h │ │ ├── reason_private.h │ │ ├── tsd.h │ │ └── variant_private.h │ ├── pthread │ │ ├── spinlock_private.h │ │ └── tsd_private.h │ └── sys │ │ └── reason.h │ ├── README.md │ ├── ReleaseNotes.rtf │ ├── interposable.txt │ ├── markgc.cpp │ ├── objc.sln │ ├── objc.vcproj │ ├── objc.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ ├── objc4.plist │ ├── objc_test │ └── main.m │ ├── objcdt │ ├── json.h │ ├── json.mm │ ├── objcdt-entitlements.plist │ ├── objcdt.1 │ └── objcdt.mm │ ├── objcrt │ └── objcrt.vcproj │ ├── prebuild.bat │ ├── runtime │ ├── DenseMapExtras.h │ ├── Messengers.subproj │ │ ├── objc-msg-arm.s │ │ ├── objc-msg-arm64.s │ │ ├── objc-msg-i386.s │ │ ├── objc-msg-simulator-i386.s │ │ ├── objc-msg-simulator-x86_64.s │ │ ├── objc-msg-win32.m │ │ └── objc-msg-x86_64.s │ ├── Module │ │ ├── ObjectiveC.apinotes │ │ └── module.modulemap │ ├── ModulePrivate │ │ └── module.modulemap │ ├── NSObjCRuntime.h │ ├── NSObject-internal.h │ ├── NSObject-private.h │ ├── NSObject.h │ ├── NSObject.mm │ ├── Object.h │ ├── Object.mm │ ├── OldClasses.subproj │ │ ├── List.h │ │ └── List.m │ ├── PointerUnion.h │ ├── Protocol.h │ ├── Protocol.mm │ ├── arm64-asm.h │ ├── dummy-library-mac-i386.c │ ├── hashtable.h │ ├── hashtable2.h │ ├── hashtable2.mm │ ├── isa.h │ ├── llvm-AlignOf.h │ ├── llvm-DenseMap.h │ ├── llvm-DenseMapInfo.h │ ├── llvm-DenseSet.h │ ├── llvm-MathExtras.h │ ├── llvm-type_traits.h │ ├── maptable.h │ ├── maptable.mm │ ├── message.h │ ├── objc-abi.h │ ├── objc-accessors.mm │ ├── objc-api.h │ ├── objc-auto.h │ ├── objc-auto.mm │ ├── objc-block-trampolines.h │ ├── objc-block-trampolines.mm │ ├── objc-blocktramps-arm.s │ ├── objc-blocktramps-arm64.s │ ├── objc-blocktramps-i386.s │ ├── objc-blocktramps-x86_64.s │ ├── objc-cache-old.h │ ├── objc-cache-old.mm │ ├── objc-cache.mm │ ├── objc-class-old.mm │ ├── objc-class.h │ ├── objc-class.mm │ ├── objc-config.h │ ├── objc-env.h │ ├── objc-errors.mm │ ├── objc-exception.h │ ├── objc-exception.mm │ ├── objc-file-old.h │ ├── objc-file-old.mm │ ├── objc-file.h │ ├── objc-file.mm │ ├── objc-gdb.h │ ├── objc-initialize.h │ ├── objc-initialize.mm │ ├── objc-internal.h │ ├── objc-layout.mm │ ├── objc-load.h │ ├── objc-load.mm │ ├── objc-loadmethod.h │ ├── objc-loadmethod.mm │ ├── objc-lockdebug.h │ ├── objc-lockdebug.mm │ ├── objc-locks-new.h │ ├── objc-locks-old.h │ ├── objc-locks.h │ ├── objc-object.h │ ├── objc-opt.mm │ ├── objc-os.h │ ├── objc-os.mm │ ├── objc-private.h │ ├── objc-probes.d │ ├── objc-ptrauth.h │ ├── objc-references.h │ ├── objc-references.mm │ ├── objc-runtime-new.h │ ├── objc-runtime-new.mm │ ├── objc-runtime-old.h │ ├── objc-runtime-old.mm │ ├── objc-runtime.h │ ├── objc-runtime.mm │ ├── objc-sel-old.mm │ ├── objc-sel-set.h │ ├── objc-sel-set.mm │ ├── objc-sel-table.s │ ├── objc-sel.mm │ ├── objc-sync.h │ ├── objc-sync.mm │ ├── objc-typeencoding.mm │ ├── objc-weak.h │ ├── objc-weak.mm │ ├── objc-zalloc.h │ ├── objc-zalloc.mm │ ├── objc.h │ ├── objcrt.c │ ├── objcrt.h │ └── runtime.h │ ├── test │ ├── ARCBase.h │ ├── ARCBase.m │ ├── ARCLayouts.m │ ├── ARCLayoutsWithoutWeak.m │ ├── ARCMRC.h │ ├── ARCMRC.m │ ├── MRCARC.h │ ├── MRCARC.m │ ├── MRCBase.h │ ├── MRCBase.m │ ├── accessors.m │ ├── accessors2.m │ ├── addMethod.m │ ├── addMethods.m │ ├── addProtocol.m │ ├── applescriptobjc.m │ ├── arr-cast.m │ ├── arr-weak.m │ ├── asm-placeholder.s │ ├── association-cf.m │ ├── association.m │ ├── associationForbidden.h │ ├── associationForbidden.m │ ├── associationForbidden2.m │ ├── associationForbidden3.m │ ├── associationForbidden4.m │ ├── atomicProperty.mm │ ├── badAltHandler.m │ ├── badCache.m │ ├── badPool.m │ ├── badPoolCompat-ios.m │ ├── badPoolCompat-macos.m │ ├── badPoolCompat-tvos.m │ ├── badPoolCompat-watchos.m │ ├── badSuperclass.m │ ├── badSuperclass2.m │ ├── badTagClass.m │ ├── badTagIndex.m │ ├── bigrc.m │ ├── blocksAsImps.m │ ├── bool.c │ ├── cacheflush-constant.m │ ├── cacheflush.h │ ├── cacheflush.m │ ├── cacheflush0.m │ ├── cacheflush2.m │ ├── cacheflush3.m │ ├── category.m │ ├── cdtors.mm │ ├── classgetclass.m │ ├── classname.m │ ├── classpair.mm │ ├── classversion.m │ ├── concurrentcat.m │ ├── concurrentcat_category.m │ ├── consolidatePoolPointers.m │ ├── copyFixupHandler.mm │ ├── copyIvarList.m │ ├── copyMethodList.m │ ├── copyPropertyList.m │ ├── copyProtocolList.m │ ├── createInstance.m │ ├── customrr-cat1.m │ ├── customrr-cat2.m │ ├── customrr-nsobject-awz.m │ ├── customrr-nsobject-core.m │ ├── customrr-nsobject-none.m │ ├── customrr-nsobject-rr.m │ ├── customrr-nsobject-rrawz.m │ ├── customrr-nsobject.m │ ├── customrr.m │ ├── customrr2.m │ ├── debugScanWeakTables.m │ ├── defines.c │ ├── defines.expected │ ├── defines.sh │ ├── definitions.c │ ├── designatedinit.m │ ├── duplicateClass.m │ ├── duplicateProtocols.m │ ├── duplicatedClasses.m │ ├── evil-class-def.m │ ├── exc.m │ ├── exchangeImp.m │ ├── fakeRealizedClass.m │ ├── fakeRealizedClass2.m │ ├── foreach.m │ ├── fork.m │ ├── forkInitialize.m │ ├── forkInitializeDisabled.m │ ├── forkInitializeSingleThreaded.m │ ├── forward.m │ ├── forwardDefault.m │ ├── forwardDefaultStret.m │ ├── future.h │ ├── future.m │ ├── future0.m │ ├── future2.m │ ├── gdb.m │ ├── getClassHook.m │ ├── getImageNameHook.m │ ├── getMethod.m │ ├── get_task_allow_entitlement.plist │ ├── headers.c │ ├── headers.sh │ ├── imageAPIs.m │ ├── imageorder.h │ ├── imageorder.m │ ├── imageorder1.m │ ├── imageorder2.m │ ├── imageorder3.m │ ├── imports.c │ ├── include-warnings.c │ ├── includes-objc2.c │ ├── includes.c │ ├── initialize.m │ ├── initializeVersusWeak.m │ ├── instanceSize.m │ ├── isaValidation.m │ ├── ismeta.m │ ├── ivar.m │ ├── ivarSlide.h │ ├── ivarSlide.m │ ├── ivarSlide1.m │ ├── lazyClassName.m │ ├── libraryPath.c │ ├── literals.m │ ├── load-image-notification-dylib.m │ ├── load-image-notification.m │ ├── load-order.m │ ├── load-order1.m │ ├── load-order2.m │ ├── load-order3.m │ ├── load-parallel.m │ ├── load-parallel0.m │ ├── load-parallel00.m │ ├── load-reentrant.m │ ├── load-reentrant2.m │ ├── load.m │ ├── methodArgs.m │ ├── methodCacheLeaks.m │ ├── methodListSize.m │ ├── methodListSmall.h │ ├── methodListSmall.mm │ ├── msgSend-performance.m │ ├── msgSend.m │ ├── nilAPIArgs.m │ ├── nonpointerisa.m │ ├── nopool.m │ ├── nscdtors.mm │ ├── nsexc.m │ ├── nsobject.m │ ├── nsprotocol.m │ ├── objectCopy.m │ ├── preopt-caches.entitlements │ ├── preopt-caches.mm │ ├── property.m │ ├── propertyDesc.m │ ├── protocol.m │ ├── protocolSmall.m │ ├── protocol_copyMethodList.m │ ├── protocol_copyPropertyList.m │ ├── rawisa.m │ ├── readClassPair.m │ ├── realizedClassGenerationCount.m │ ├── release-workaround.m │ ├── resolve.m │ ├── restartableRangesSynchronizeStress.m │ ├── restartableRangesSynchronizeStress2.m │ ├── rr-autorelease-fast.m │ ├── rr-autorelease-fastarc.m │ ├── rr-autorelease-stacklogging.m │ ├── rr-autorelease.m │ ├── rr-autorelease2.m │ ├── rr-nsautorelease.m │ ├── rr-sidetable.m │ ├── runtime.m │ ├── sel.m │ ├── setAssociatedObjectHook.m │ ├── setSuper.m │ ├── subscripting.m │ ├── super.m │ ├── supported-inline-refcnt.m │ ├── swift-class-def.m │ ├── swiftMetadataInitializer.m │ ├── swiftMetadataInitializerRealloc-dylib1.m │ ├── swiftMetadataInitializerRealloc-dylib2.m │ ├── swiftMetadataInitializerRealloc.m │ ├── swiftStubClassList.m │ ├── synchronized-counter.m │ ├── synchronized-grid.m │ ├── synchronized.m │ ├── taggedNSPointers.m │ ├── taggedPointers.m │ ├── taggedPointersAllClasses.m │ ├── taggedPointersDisabled.m │ ├── taggedPointersTagObfuscationDisabled.m │ ├── tbi.c │ ├── test-defines.h │ ├── test.h │ ├── test.pl │ ├── testroot.i │ ├── timeout.pl │ ├── unload.h │ ├── unload.m │ ├── unload2.m │ ├── unload3.c │ ├── unload4.m │ ├── unwind.m │ ├── weak.h │ ├── weak.m │ ├── weak2.m │ ├── weakReferenceHook.m │ ├── weakcopy.m │ ├── weakframework-missing.m │ ├── weakframework-not-missing.m │ ├── weakimport-missing.m │ ├── weakimport-not-missing.m │ ├── weakrace.m │ ├── willInitializeClassFunc.m │ └── zone.m │ ├── unexported_symbols │ ├── version.bat │ └── version.rc ├── gdb_objc_realized_classes └── gdb_objc_realized_classes ├── non-lazy-classes └── non-lazy-classes.txt └── protocollist └── protocollist.txt /Hash Map/RuntimeSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Hash Map/RuntimeSample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Hash Map/RuntimeSample.xcodeproj/project.xcworkspace/xcuserdata/kyson.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjh171/RuntimeSample/2f3ef0867129fefa9b37d0c5499253f514b52dee/Hash Map/RuntimeSample.xcodeproj/project.xcworkspace/xcuserdata/kyson.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Hash Map/RuntimeSample.xcodeproj/xcuserdata/kyson.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | RuntimeSample.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Hash Map/RuntimeSample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // RuntimeSample 4 | // 5 | // Created by kyson on 2019/3/26. 6 | // Copyright © 2019 cn.kyson. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KSNXMapTable.h" 11 | #import "KSNXHashTable.h" 12 | 13 | int main(int argc, const char * argv[]) { 14 | @autoreleasepool { 15 | // insert code here... 16 | KSNXMapTable *maptable = NXCreateMapTable(NXPtrValueMapPrototype, 16); 17 | int a = 1000; 18 | int* p = &a ; 19 | int* a1 = (int *)NXMapGet(maptable, "kyson"); 20 | printf("%p\n",a1); 21 | 22 | NXMapInsert(maptable, "kyson", p); 23 | 24 | int * b = (int *)NXMapGet(maptable, "kyson"); 25 | int b1 = *b; 26 | printf("%i\n",b1); 27 | 28 | NXMapRemove(maptable,"kyson"); 29 | int *c = (int *)NXMapGet(maptable, "kyson"); 30 | printf("%p\n",c); 31 | 32 | } 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjh171/RuntimeSample/2f3ef0867129fefa9b37d0c5499253f514b52dee/HookModInitiOSDemo/.DS_Store -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo.xcodeproj/project.xcworkspace/xcuserdata/kyson.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjh171/RuntimeSample/2f3ef0867129fefa9b37d0c5499253f514b52dee/HookModInitiOSDemo/HookModInitiOSDemo.xcodeproj/project.xcworkspace/xcuserdata/kyson.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo.xcodeproj/xcuserdata/kyson.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | HookModInitiOSDemo.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjh171/RuntimeSample/2f3ef0867129fefa9b37d0c5499253f514b52dee/HookModInitiOSDemo/HookModInitiOSDemo/.DS_Store -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // HookModInitiOSDemo 4 | // 5 | // Created by kyson on 2021/4/10. 6 | // 7 | 8 | #import 9 | 10 | @interface AppDelegate : UIResponder 11 | 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/SceneDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.h 3 | // HookModInitiOSDemo 4 | // 5 | // Created by kyson on 2021/4/10. 6 | // 7 | 8 | #import 9 | 10 | @interface SceneDelegate : UIResponder 11 | 12 | @property (strong, nonatomic) UIWindow * window; 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Test/TestAttribute.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestAttribute.h 3 | // ModFuncInitApp 4 | // 5 | // Created by everettjf on 2016/12/6. 6 | // Copyright © 2016年 everettjf. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Test/TestAttribute.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestAttribute.m 3 | // ModFuncInitApp 4 | // 5 | // Created by everettjf on 2016/12/6. 6 | // Copyright © 2016年 everettjf. All rights reserved. 7 | // 8 | 9 | #import "TestAttribute.h" 10 | 11 | 12 | __attribute__((constructor)) void myentry(){ 13 | NSLog(@"constructor"); 14 | } 15 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Test/TestCBlock.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestCBlock.h 3 | // ModFuncInitApp 4 | // 5 | // Created by everettjf on 2017/1/4. 6 | // Copyright © 2017年 everettjf. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Test/TestCBlock.mm: -------------------------------------------------------------------------------- 1 | // 2 | // TestCBlock.m 3 | // ModFuncInitApp 4 | // 5 | // Created by everettjf on 2017/1/4. 6 | // Copyright © 2017年 everettjf. All rights reserved. 7 | // 8 | 9 | #import "TestCBlock.h" 10 | 11 | typedef struct { 12 | NSString *const blank; 13 | NSString *const CDPServer; 14 | NSString *const countdown; 15 | NSString *const infoBox; 16 | NSString *const shop; 17 | NSString *const more; 18 | NSString *const CDPSdk; 19 | NSString *const notice; 20 | NSString *const recommend; 21 | }O2OPGoodsDetailBlockId; 22 | 23 | const O2OPGoodsDetailBlockId kBlockId = { 24 | .blank = @"detail_blank", 25 | .CDPServer = @"goods_detail_cdp", 26 | .countdown = @"goods_detail_countdown", 27 | .infoBox = @"goods_detail_infobox", 28 | .shop = @"goods_detail_shop", 29 | .more = @"goods_detail_more", 30 | .CDPSdk = @"detail_cdp_sdk", 31 | .notice = @"goods_detail_notice", 32 | .recommend = @"goods_detail_recommend", 33 | }; 34 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Test/TestClass.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestClass.h 3 | // ModFuncInitApp 4 | // 5 | // Created by everettjf on 2016/12/6. 6 | // Copyright © 2016年 everettjf. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Test/TestClass.mm: -------------------------------------------------------------------------------- 1 | // 2 | // TestClass.m 3 | // ModFuncInitApp 4 | // 5 | // Created by everettjf on 2016/12/6. 6 | // Copyright © 2016年 everettjf. All rights reserved. 7 | // 8 | 9 | #import "TestClass.h" 10 | 11 | class FooObject{ 12 | public: 13 | FooObject(){ 14 | // do somthing 15 | NSLog(@"in fooobject"); 16 | } 17 | 18 | }; 19 | 20 | static FooObject globalObj = FooObject(); 21 | FooObject globalObj2 = FooObject(); 22 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Test/TestDict.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestDict.h 3 | // ModFuncInitApp 4 | // 5 | // Created by everettjf on 2016/12/5. 6 | // Copyright © 2016年 everettjf. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface TestDict : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Test/TestDict.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestDict.m 3 | // ModFuncInitApp 4 | // 5 | // Created by everettjf on 2016/12/5. 6 | // Copyright © 2016年 everettjf. All rights reserved. 7 | // 8 | 9 | #import "TestDict.h" 10 | #import 11 | 12 | //static NSDictionary * dictObject = @{@"one":@"1"}; 13 | //NSDictionary * dictObject2 = @{@"one":@"1", @"two":@"2"}; 14 | 15 | 16 | NSString * const kkkkk = @"hkjkjk"; 17 | 18 | @implementation TestDict 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Test/TestFunction.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestFunction.h 3 | // ModFuncInitApp 4 | // 5 | // Created by everettjf on 2016/12/6. 6 | // Copyright © 2016年 everettjf. All rights reserved. 7 | // 8 | 9 | #import 10 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Test/TestFunction.mm: -------------------------------------------------------------------------------- 1 | // 2 | // TestFunction.m 3 | // ModFuncInitApp 4 | // 5 | // Created by everettjf on 2016/12/6. 6 | // Copyright © 2016年 everettjf. All rights reserved. 7 | // 8 | 9 | #import "TestFunction.h" 10 | 11 | bool initBar(){ 12 | int i = 0; 13 | ++i; 14 | return i == 1; 15 | } 16 | 17 | 18 | //bool globalBar2 = initBar(); 19 | 20 | void hello(){ 21 | 22 | static bool globalBar = initBar(); 23 | 24 | NSLog(@"%@",@(globalBar)); 25 | } 26 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Test/TestMacro.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestMacro.h 3 | // ModFuncInitApp 4 | // 5 | // Created by everettjf on 2016/12/6. 6 | // Copyright © 2016年 everettjf. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Test/TestMacro.mm: -------------------------------------------------------------------------------- 1 | // 2 | // TestMacro.m 3 | // ModFuncInitApp 4 | // 5 | // Created by everettjf on 2016/12/6. 6 | // Copyright © 2016年 everettjf. All rights reserved. 7 | // 8 | 9 | #import "TestMacro.h" 10 | 11 | NSString *description(const char *str){ 12 | return [NSString stringWithFormat:@"hello %s",str]; 13 | } 14 | 15 | #define E(str) description(str) 16 | 17 | 18 | NSString* globalArray[] = { 19 | E("hello"), 20 | E("hello"), 21 | E("hello"), 22 | E("hello"), 23 | E("hello"), 24 | E("hello"), 25 | }; 26 | 27 | NSString *globalString = E("world"); 28 | 29 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Test/TestRectZero.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestRectZero.h 3 | // ModFuncInitApp 4 | // 5 | // Created by everettjf on 2016/12/6. 6 | // Copyright © 2016年 everettjf. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Test/TestRectZero.mm: -------------------------------------------------------------------------------- 1 | // 2 | // TestRectZero.m 3 | // ModFuncInitApp 4 | // 5 | // Created by everettjf on 2016/12/6. 6 | // Copyright © 2016年 everettjf. All rights reserved. 7 | // 8 | 9 | #import "TestRectZero.h" 10 | #import 11 | 12 | 13 | CGRect globalRect = CGRectZero; 14 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Test/TestStaticClassMemberMutex.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // TestStaticClassMemberMutex.cpp 3 | // ModFuncInitApp 4 | // 5 | // Created by everettjf on 2017/3/20. 6 | // Copyright © 2017年 everettjf. All rights reserved. 7 | // 8 | 9 | #include "TestStaticClassMemberMutex.hpp" 10 | 11 | 12 | std::mutex TestStaticClassMemberMutex::s_mutex; 13 | 14 | 15 | void TestStaticClassMemberMutex::hello(){ 16 | s_mutex.lock(); 17 | 18 | s_mutex.unlock(); 19 | } 20 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Test/TestStaticClassMemberMutex.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // TestStaticClassMemberMutex.hpp 3 | // ModFuncInitApp 4 | // 5 | // Created by everettjf on 2017/3/20. 6 | // Copyright © 2017年 everettjf. All rights reserved. 7 | // 8 | 9 | #ifndef TestStaticClassMemberMutex_hpp 10 | #define TestStaticClassMemberMutex_hpp 11 | 12 | #include 13 | 14 | class TestStaticClassMemberMutex{ 15 | public: 16 | 17 | void hello(); 18 | 19 | private: 20 | static std::mutex s_mutex; 21 | }; 22 | 23 | #endif /* TestStaticClassMemberMutex_hpp */ 24 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Test/TestVarVar.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestVarVar.h 3 | // ModFuncInitApp 4 | // 5 | // Created by everettjf on 2017/1/4. 6 | // Copyright © 2017年 everettjf. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | extern const float FlexAuto; 13 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Test/TestVarVar.mm: -------------------------------------------------------------------------------- 1 | // 2 | // TestVarVar.m 3 | // ModFuncInitApp 4 | // 5 | // Created by everettjf on 2017/1/4. 6 | // Copyright © 2017年 everettjf. All rights reserved. 7 | // 8 | 9 | #import "TestVarVar.h" 10 | 11 | 12 | const float Auto = FlexAuto; 13 | 14 | 15 | void testfuncvarvar(){ 16 | printf("%f",Auto); 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/Test/TextVarVarC.c: -------------------------------------------------------------------------------- 1 | // 2 | // TextVarVarC.c 3 | // ModFuncInitApp 4 | // 5 | // Created by everettjf on 2017/1/4. 6 | // Copyright © 2017年 everettjf. All rights reserved. 7 | // 8 | 9 | const float FlexAuto = 999998; 10 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // HookModInitiOSDemo 4 | // 5 | // Created by kyson on 2021/4/10. 6 | // 7 | 8 | #import 9 | 10 | @interface ViewController : UIViewController 11 | 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // HookModInitiOSDemo 4 | // 5 | // Created by kyson on 2021/4/10. 6 | // 7 | 8 | #import "ViewController.h" 9 | 10 | @interface ViewController () 11 | 12 | @end 13 | 14 | @implementation ViewController 15 | 16 | 17 | const char* getallinitinfo(); 18 | 19 | 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | // Do any additional setup after loading the view. 24 | 25 | //dispatch_time_t参数 26 | dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (ino64_t)(4 * NSEC_PER_SEC)); 27 | 28 | //dispatch_queue_t参数 29 | dispatch_queue_t queue = dispatch_get_main_queue();//主队列 30 | 31 | //dispatch_after函数 32 | dispatch_after(time, queue, ^{ 33 | //Code 34 | NSLog(@"allinitinfo = %s",getallinitinfo()); 35 | 36 | }); 37 | 38 | } 39 | 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /HookModInitiOSDemo/HookModInitiOSDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // HookModInitiOSDemo 4 | // 5 | // Created by kyson on 2021/4/10. 6 | // 7 | 8 | #import 9 | #import "AppDelegate.h" 10 | 11 | int main(int argc, char * argv[]) { 12 | NSString * appDelegateClassName; 13 | @autoreleasepool { 14 | // Setup code that might create autoreleased objects goes here. 15 | appDelegateClassName = NSStringFromClass([AppDelegate class]); 16 | } 17 | return UIApplicationMain(argc, argv, nil, appDelegateClassName); 18 | } 19 | -------------------------------------------------------------------------------- /LogLog/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjh171/RuntimeSample/2f3ef0867129fefa9b37d0c5499253f514b52dee/LogLog/.DS_Store -------------------------------------------------------------------------------- /LogLog/LogDemo/main.mm: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // LogDemo 4 | // 5 | // Created by kyson on 2021/4/3. 6 | // 7 | 8 | #import 9 | #import "objc-private.h" 10 | 11 | int main(int argc, const char * argv[]) { 12 | @autoreleasepool { 13 | // insert code here... 14 | NSLog(@"Hello, World!"); 15 | environ_init(); 16 | 17 | _objc_inform("123456555555555"); 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /LogLog/LogLog.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LogLog/LogLog.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /LogLog/LogLog.xcodeproj/project.xcworkspace/xcuserdata/kyson.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjh171/RuntimeSample/2f3ef0867129fefa9b37d0c5499253f514b52dee/LogLog/LogLog.xcodeproj/project.xcworkspace/xcuserdata/kyson.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /LogLog/LogLog.xcodeproj/xcuserdata/kyson.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /LogLog/LogLog.xcodeproj/xcuserdata/kyson.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | LogDemo.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | LogLog.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 1 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /LogLog/libLogLog.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjh171/RuntimeSample/2f3ef0867129fefa9b37d0c5499253f514b52dee/LogLog/libLogLog.dylib -------------------------------------------------------------------------------- /LogLog/objc-os.h: -------------------------------------------------------------------------------- 1 | // 2 | // objc-os.h 3 | // ObjcLogSystem 4 | // 5 | // Created by kyson on 2021/3/29. 6 | // 7 | 8 | 9 | #ifndef _OBJC_OS_H 10 | #define _OBJC_OS_H 11 | 12 | 13 | #include "objc-private.h" 14 | 15 | 16 | //#if TARGET_OS_MAC 17 | 18 | 19 | # include 20 | # include 21 | # include 22 | # include 23 | # include 24 | # include 25 | 26 | 27 | //#endif 28 | 29 | #endif /* objc_os_h */ 30 | -------------------------------------------------------------------------------- /LogLog/objc-os.mm: -------------------------------------------------------------------------------- 1 | // 2 | // objc-os.m 3 | // ObjcLogSystem 4 | // 5 | // Created by kyson on 2021/3/29. 6 | // 7 | 8 | #include "objc-private.h" 9 | 10 | 11 | void _objc_init(void) 12 | { 13 | environ_init(); 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /LogLog/objc-private.h: -------------------------------------------------------------------------------- 1 | // 2 | // objc-private.h 3 | // ObjcLogSystem 4 | // 5 | // Created by kyson on 2021/3/27. 6 | // 7 | 8 | #ifndef _OBJC_PRIVATE_H_ 9 | #define _OBJC_PRIVATE_H_ 10 | 11 | #ifdef _OBJC_OBJC_H_ 12 | //#error include objc-private.h before other headers 13 | #endif 14 | 15 | #include 16 | 17 | // Public headers 18 | #include "objc.h" 19 | #include "objc-os.h" 20 | 21 | 22 | #define OPTION(var, env, help) extern bool var; 23 | #include "objc-env.h" 24 | #undef OPTION 25 | 26 | 27 | 28 | 29 | /** 30 | errors 31 | 32 | */ 33 | 34 | extern void _objc_inform(const char *fmt, ...) __attribute__((cold, format(printf, 1, 2))); 35 | 36 | 37 | extern void environ_init(void); 38 | 39 | #endif /* objc_private_h */ 40 | -------------------------------------------------------------------------------- /LogLog/objc-runtime.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | -------------------------------------------------------------------------------- /LogLog/objc.h: -------------------------------------------------------------------------------- 1 | // 2 | // objc.h 3 | // ObjcLogSystem 4 | // 5 | // Created by kyson on 2021/3/29. 6 | // 7 | 8 | #ifndef _OBJC_OBJC_H_ 9 | #define _OBJC_OBJC_H_ 10 | 11 | 12 | #include 13 | 14 | 15 | #if OBJC_BOOL_IS_BOOL 16 | typedef bool BOOL; 17 | #else 18 | # define OBJC_BOOL_IS_CHAR 1 19 | typedef signed char BOOL; 20 | // BOOL is explicitly signed so @encode(BOOL) == "c" rather than "C" 21 | // even if -funsigned-char is used. 22 | #endif 23 | 24 | #ifndef nil 25 | # if __has_feature(cxx_nullptr) 26 | # define nil nullptr 27 | # else 28 | # define nil __DARWIN_NULL 29 | # endif 30 | #endif 31 | 32 | 33 | 34 | #endif /* _OBJC_OBJC_H_ */ 35 | -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass/MyDIYClass.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass/MyDIYClass.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass/MyDIYClass.xcodeproj/project.xcworkspace/xcuserdata/kyson.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjh171/RuntimeSample/2f3ef0867129fefa9b37d0c5499253f514b52dee/MyDIYClass/MyDIYClass/MyDIYClass.xcodeproj/project.xcworkspace/xcuserdata/kyson.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass/MyDIYClass.xcodeproj/xcuserdata/kyson.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | MyDIYClass.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | MyDIYClass.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 0 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass/MyDIYClass/TestObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestObject.h 3 | // debug-objc 4 | // 5 | // Created by kyson on 2019/1/30. 6 | // 7 | 8 | #import 9 | 10 | extern int abcdefg; 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface TestObject : NSObject 15 | 16 | @end 17 | 18 | NS_ASSUME_NONNULL_END 19 | -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass/MyDIYClass/TestObject.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestObject.m 3 | // debug-objc 4 | // 5 | // Created by kyson on 2019/1/30. 6 | // 7 | 8 | #import "TestObject.h" 9 | 10 | @implementation TestObject 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass2/MyDIYClass/A.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // A.cpp 3 | // MyDIYClass2 4 | // 5 | // Created by kyson on 2019/6/27. 6 | // Copyright © 2019 cn.kyson. All rights reserved. 7 | // 8 | 9 | #include "A.hpp" 10 | -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass2/MyDIYClass/A.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // A.hpp 3 | // MyDIYClass2 4 | // 5 | // Created by kyson on 2019/6/27. 6 | // Copyright © 2019 cn.kyson. All rights reserved. 7 | // 8 | 9 | #ifndef A_hpp 10 | #define A_hpp 11 | 12 | #include 13 | class A 14 | { 15 | public: 16 | //默认构造函数 17 | A() 18 | { 19 | num=1001; 20 | age=18; 21 | } 22 | //初始化构造函数 23 | A(int n,int a):num(n),age(a){} 24 | private: 25 | int num; 26 | int age; 27 | }; 28 | 29 | 30 | 31 | #endif /* A_hpp */ 32 | -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass2/MyDIYClass/TestObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestObject.h 3 | // debug-objc 4 | // 5 | // Created by kyson on 2019/1/30. 6 | // 7 | 8 | #import 9 | #include 10 | 11 | extern int abcdefg; 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | 16 | 17 | class A 18 | { 19 | public: 20 | //默认构造函数 21 | A() 22 | { 23 | num=1001; 24 | age=18; 25 | } 26 | //初始化构造函数 27 | A(int n,int a):num(n),age(a){} 28 | private: 29 | int num; 30 | int age; 31 | }; 32 | 33 | 34 | 35 | 36 | @interface TestObject : NSObject { 37 | // __weak NSObject *propertyA; 38 | // A a; 39 | } 40 | 41 | @end 42 | 43 | NS_ASSUME_NONNULL_END 44 | -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass2/MyDIYClass/TestObject.mm: -------------------------------------------------------------------------------- 1 | // 2 | // TestObject.m 3 | // debug-objc 4 | // 5 | // Created by kyson on 2019/1/30. 6 | // 7 | 8 | #import "TestObject.h" 9 | 10 | 11 | 12 | @implementation TestObject 13 | 14 | //+(void) load { 15 | // NSLog(@"hello"); 16 | // A(); 17 | //} 18 | 19 | +(instancetype)allocWithZone:(struct _NSZone *)zone { 20 | TestObject *obj = [[TestObject alloc] init]; 21 | return obj; 22 | } 23 | 24 | 25 | 26 | @end 27 | 28 | -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass2/MyDIYClass2.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass2/MyDIYClass2.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass2/MyDIYClass2.xcodeproj/project.xcworkspace/xcuserdata/kyson.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjh171/RuntimeSample/2f3ef0867129fefa9b37d0c5499253f514b52dee/MyDIYClass/MyDIYClass2/MyDIYClass2.xcodeproj/project.xcworkspace/xcuserdata/kyson.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass2/MyDIYClass2.xcodeproj/xcuserdata/kyson.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass2/MyDIYClass2.xcodeproj/xcuserdata/kyson.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | MyDIYClass.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | MyDIYClass.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 0 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 96F2D8E7229AA4E1004B020A 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass3/MyDIYClass/TestObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestObject.h 3 | // debug-objc 4 | // 5 | // Created by kyson on 2019/1/30. 6 | // 7 | 8 | #import 9 | 10 | extern int abcdefg; 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface TestObject : NSObject 15 | 16 | @end 17 | 18 | NS_ASSUME_NONNULL_END 19 | -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass3/MyDIYClass/TestObject.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestObject.m 3 | // debug-objc 4 | // 5 | // Created by kyson on 2019/1/30. 6 | // 7 | 8 | #import "TestObject.h" 9 | 10 | @implementation TestObject 11 | 12 | +(void) load { 13 | NSLog(@"hello"); 14 | } 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass3/MyDIYClass2.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass3/MyDIYClass2.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass3/MyDIYClass2.xcodeproj/project.xcworkspace/xcuserdata/kyson.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjh171/RuntimeSample/2f3ef0867129fefa9b37d0c5499253f514b52dee/MyDIYClass/MyDIYClass3/MyDIYClass2.xcodeproj/project.xcworkspace/xcuserdata/kyson.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass3/MyDIYClass2.xcodeproj/xcuserdata/kyson.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /MyDIYClass/MyDIYClass3/MyDIYClass2.xcodeproj/xcuserdata/kyson.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | MyDIYClass.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | MyDIYClass.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 0 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 96F2D8E7229AA4E1004B020A 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RuntimeSample 2 | 3 | 4 | ## 文件列表以及描述 5 | 6 | ### debugableruntime 7 | 8 | 可编译的 runtime 版本,版本对应的系统在文章 https://xiaozhuanlan.com/topic/9178403562 中有提及。 9 | 10 | ### Hash Map 11 | 12 | 剥离出 runtime 中的 hash map。 13 | 14 | KSNXHashTable.c KSNXHashTable.h KSNXMapTable.c KSNXMapTable.h 这四个文件是从 runtime 中剥离出来的 maptable 和 hashtable,之所以加上前缀 “KS” ,是为了防止和 runtime 中的冲突。 15 | 16 | ### LogLog 17 | 18 | 剥离出 runtime 中的日志系统。使用方式很简单,直接跑 demo 工程即可。 19 | 20 | 21 | | 基本类型 | 包装器类型 | 22 | | -------- | ----- | 23 | |boolean| Boolean| 24 | |char |Character| 25 | |int| Integer| 26 | |byte| Byte| 27 | |short| Short| 28 | |long| Long| 29 | |float| Float| 30 | |double| Double| 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /Section/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjh171/RuntimeSample/2f3ef0867129fefa9b37d0c5499253f514b52dee/Section/.DS_Store -------------------------------------------------------------------------------- /Section/Person.h: -------------------------------------------------------------------------------- 1 | // 2 | // Person.hpp 3 | // SectionDemo 4 | // 5 | // Created by kyson on 2021/4/4. 6 | // 7 | 8 | #ifndef Person_hpp 9 | #define Person_hpp 10 | 11 | #include 12 | 13 | class Person{ 14 | public: 15 | Person(){ 16 | printf("Person::Person()\n"); 17 | } 18 | 19 | ~Person(){ 20 | printf("Person::~Person()\n"); 21 | } 22 | }; 23 | 24 | 25 | class iOSer : Person{ 26 | public: 27 | iOSer(){ 28 | printf("iOSer::iOSer()\n"); 29 | } 30 | 31 | ~iOSer(){ 32 | printf("iOSer::~iOSer()\n"); 33 | } 34 | }; 35 | 36 | #endif /* Person_hpp */ 37 | -------------------------------------------------------------------------------- /Section/Person.mm: -------------------------------------------------------------------------------- 1 | // 2 | // Person.cpp 3 | // SectionDemo 4 | // 5 | // Created by kyson on 2021/4/4. 6 | // 7 | 8 | #include "Person.h" 9 | 10 | 11 | // Look for a __DATA or __DATA_CONST or __DATA_DIRTY section 12 | // with the given name that stores an array of T. 13 | -------------------------------------------------------------------------------- /Section/Section.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Section/Section.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Section/Section.xcodeproj/project.xcworkspace/xcuserdata/kyson.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjh171/RuntimeSample/2f3ef0867129fefa9b37d0c5499253f514b52dee/Section/Section.xcodeproj/project.xcworkspace/xcuserdata/kyson.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Section/Section.xcodeproj/xcuserdata/kyson.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /Section/Section.xcodeproj/xcuserdata/kyson.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Section.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 1 11 | 12 | SectionDemo.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 0 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Section/SectionDemo/main.mm: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SectionDemo 4 | // 5 | // Created by kyson on 2021/4/4. 6 | // 7 | 8 | #import 9 | #include "section.h" 10 | 11 | int main(int argc, const char * argv[]) { 12 | @autoreleasepool { 13 | // insert code here... 14 | callGlobalObjInitialMethod(); 15 | 16 | NSLog(@"Hello, World!"); 17 | } 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /Section/libSection.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjh171/RuntimeSample/2f3ef0867129fefa9b37d0c5499253f514b52dee/Section/libSection.dylib -------------------------------------------------------------------------------- /Section/objc-file.h: -------------------------------------------------------------------------------- 1 | // 2 | // objc-file.hpp 3 | // SectionDemo 4 | // 5 | // Created by kyson on 2021/4/4. 6 | // 7 | 8 | #ifndef objc_file_hpp 9 | #define objc_file_hpp 10 | 11 | #include "objc-private.h" 12 | 13 | #ifndef nil 14 | # if __has_feature(cxx_nullptr) 15 | # define nil nullptr 16 | # else 17 | # define nil __DARWIN_NULL 18 | # endif 19 | #endif 20 | 21 | 22 | #include 23 | 24 | 25 | #define ptrauth_sign_unauthenticated(__value, __key, __data) __value 26 | 27 | // FIXME: rdar://29241917&33734254 clang doesn't sign static initializers. 28 | struct UnsignedInitializer { 29 | private: 30 | uintptr_t storage; 31 | public: 32 | UnsignedInitializer(uint32_t offset) { 33 | storage = (uintptr_t)&_mh_dylib_header + offset; 34 | } 35 | 36 | void operator () () const { 37 | using Initializer = void(*)(); 38 | Initializer init = 39 | ptrauth_sign_unauthenticated((Initializer)storage, 40 | ptrauth_key_function_pointer, 0); 41 | init(); 42 | } 43 | }; 44 | 45 | 46 | extern UnsignedInitializer* getLibsectionInitializers(const headerType *mhdr, size_t *count); 47 | 48 | 49 | #endif /* objc_file_hpp */ 50 | -------------------------------------------------------------------------------- /Section/objc-file.mm: -------------------------------------------------------------------------------- 1 | // 2 | // objc-file.cpp 3 | // SectionDemo 4 | // 5 | // Created by kyson on 2021/4/4. 6 | // 7 | 8 | #include "objc-file.h" 9 | #include "objc-private.h" 10 | 11 | 12 | template 13 | T* getDataSection(const headerType *mhdr, const char *sectname, 14 | size_t *outBytes, size_t *outCount) 15 | { 16 | unsigned long byteCount = 0; 17 | T* data = (T*)getsectiondata(mhdr, "__DATA", sectname, &byteCount); 18 | if (!data) { 19 | data = (T*)getsectiondata(mhdr, "__DATA_CONST", sectname, &byteCount); 20 | } 21 | if (!data) { 22 | data = (T*)getsectiondata(mhdr, "__DATA_DIRTY", sectname, &byteCount); 23 | } 24 | if (outBytes) *outBytes = byteCount; 25 | if (outCount) *outCount = byteCount / sizeof(T); 26 | return data; 27 | } 28 | 29 | 30 | UnsignedInitializer *getLibsectionInitializers(const headerType *mhdr, size_t *outCount) { 31 | return getDataSection(mhdr, "__mod_init_func", nil, outCount); 32 | } 33 | 34 | //UnsignedInitializer *getLibsectionInitializers(const header_info *hi, size_t *outCount) { 35 | // return getDataSection(hi->mhdr(), "__mod_init_func", nil, outCount); 36 | //} 37 | -------------------------------------------------------------------------------- /Section/section.h: -------------------------------------------------------------------------------- 1 | // 2 | // section.hpp 3 | // Section 4 | // 5 | // Created by kyson on 2021/4/4. 6 | // 7 | 8 | #ifndef section_hpp 9 | #define section_hpp 10 | 11 | #include 12 | 13 | 14 | void callGlobalObjInitialMethod(); 15 | 16 | #endif /* section_hpp */ 17 | -------------------------------------------------------------------------------- /Section/section.mm: -------------------------------------------------------------------------------- 1 | // 2 | // section.cpp 3 | // Section 4 | // 5 | // Created by kyson on 2021/4/4. 6 | // 7 | 8 | #include "section.h" 9 | #include "objc-private.h" 10 | 11 | #include 12 | #include 13 | #include "Person.h" 14 | #include "objc-file.h" 15 | 16 | Person kyson; 17 | //iOSer kimi; 18 | 19 | void callGlobalObjInitialMethod(){ 20 | size_t count; 21 | 22 | auto inits = getLibsectionInitializers(&_mh_dylib_header, &count); 23 | for (size_t i = 0; i < count; i++) { 24 | UnsignedInitializer init = inits[i]; 25 | init(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /SetSectionCustomInfoDemo/SetSectionCustomInfoDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SetSectionCustomInfoDemo/SetSectionCustomInfoDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SetSectionCustomInfoDemo/SetSectionCustomInfoDemo.xcodeproj/project.xcworkspace/xcuserdata/kyson.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjh171/RuntimeSample/2f3ef0867129fefa9b37d0c5499253f514b52dee/SetSectionCustomInfoDemo/SetSectionCustomInfoDemo.xcodeproj/project.xcworkspace/xcuserdata/kyson.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /SetSectionCustomInfoDemo/SetSectionCustomInfoDemo.xcodeproj/xcuserdata/kyson.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SetSectionCustomInfoDemo.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /debugableruntime/objc4-706-master/.gitignore: -------------------------------------------------------------------------------- 1 | debug-objc/Foo.cpp 2 | 3 | 4 | #################### Mac OS X & Xcode #################### 5 | 6 | .DS_Store 7 | *.swp 8 | *.lock 9 | profile 10 | 11 | 12 | *~.nib 13 | 14 | 15 | DerivedData/ 16 | 17 | 18 | build/ 19 | 20 | 21 | *.pbxuser 22 | *.mode1v3 23 | *.mode2v3 24 | *.perspectivev3 25 | # NB: also, whitelist the default ones, some projects need to use these 26 | !default.pbxuser 27 | !default.mode1v3 28 | !default.mode2v3 29 | !default.perspectivev3 30 | 31 | 32 | xcuserdata 33 | UserInterfaceState.xcuserstate 34 | 35 | 36 | *.moved-aside 37 | 38 | Pods/ 39 | Podfile.lock 40 | -------------------------------------------------------------------------------- /debugableruntime/objc4-706-master/README.md: -------------------------------------------------------------------------------- 1 | 2 | [How to build libobjc (objc4-680)](http://blog.csdn.net/wotors/article/details/52489464) (Chinese Version) 3 | 4 | [How to build libobjc (objc4-706)](http://blog.csdn.net/wotors/article/details/54426316) (Chinese Version) 5 | 6 | -------------------------------------------------------------------------------- /debugableruntime/objc4-706-master/debug-objc/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // debug-objc 4 | // 5 | // Created by suchavision on 1/24/17. 6 | // 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, const char * argv[]) { 12 | @autoreleasepool { 13 | // insert code here... 14 | NSLog(@"Hello, World!"); 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /debugableruntime/objc4-706-master/objc.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjh171/RuntimeSample/2f3ef0867129fefa9b37d0c5499253f514b52dee/debugableruntime/objc4-706-master/objc.suo -------------------------------------------------------------------------------- /debugableruntime/objc4-706-master/objc.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /debugableruntime/objc4-706-master/prebuild.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | echo prebuild: installing headers 4 | xcopy /Y "%ProjectDir%runtime\objc.h" "%DSTROOT%\AppleInternal\include\objc\" 5 | xcopy /Y "%ProjectDir%runtime\objc-api.h" "%DSTROOT%\AppleInternal\include\objc\" 6 | xcopy /Y "%ProjectDir%runtime\objc-auto.h" "%DSTROOT%\AppleInternal\include\objc\" 7 | xcopy /Y "%ProjectDir%runtime\objc-exception.h" "%DSTROOT%\AppleInternal\include\objc\" 8 | xcopy /Y "%ProjectDir%runtime\message.h" "%DSTROOT%\AppleInternal\include\objc\" 9 | xcopy /Y "%ProjectDir%runtime\runtime.h" "%DSTROOT%\AppleInternal\include\objc\" 10 | xcopy /Y "%ProjectDir%runtime\hashtable.h" "%DSTROOT%\AppleInternal\include\objc\" 11 | xcopy /Y "%ProjectDir%runtime\hashtable2.h" "%DSTROOT%\AppleInternal\include\objc\" 12 | xcopy /Y "%ProjectDir%runtime\maptable.h" "%DSTROOT%\AppleInternal\include\objc\" 13 | 14 | echo prebuild: setting version 15 | version 16 | -------------------------------------------------------------------------------- /debugableruntime/objc4-706-master/runtime/NSObjCRuntime.h: -------------------------------------------------------------------------------- 1 | /* NSObjCRuntime.h 2 | Copyright (c) 1994-2012, Apple Inc. All rights reserved. 3 | */ 4 | 5 | #ifndef _OBJC_NSOBJCRUNTIME_H_ 6 | #define _OBJC_NSOBJCRUNTIME_H_ 7 | 8 | #include 9 | #include 10 | 11 | #if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64 12 | typedef long NSInteger; 13 | typedef unsigned long NSUInteger; 14 | #else 15 | typedef int NSInteger; 16 | typedef unsigned int NSUInteger; 17 | #endif 18 | 19 | #define NSIntegerMax LONG_MAX 20 | #define NSIntegerMin LONG_MIN 21 | #define NSUIntegerMax ULONG_MAX 22 | 23 | #define NSINTEGER_DEFINED 1 24 | 25 | #ifndef NS_DESIGNATED_INITIALIZER 26 | #if __has_attribute(objc_designated_initializer) 27 | #define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) 28 | #else 29 | #define NS_DESIGNATED_INITIALIZER 30 | #endif 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /debugableruntime/objc4-706-master/runtime/hashtable.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | -------------------------------------------------------------------------------- /debugableruntime/objc4-706-master/runtime/objc-cache.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _OBJC_CACHE_H 3 | #define _OBJC_CACHE_H 4 | 5 | #include "objc-private.h" 6 | 7 | __BEGIN_DECLS 8 | 9 | extern IMP cache_getImp(Class cls, SEL sel); 10 | 11 | extern void cache_fill(Class cls, SEL sel, IMP imp, id receiver); 12 | 13 | extern void cache_erase_nolock(Class cls); 14 | 15 | extern void cache_delete(Class cls); 16 | 17 | extern void cache_collect(bool collectALot); 18 | 19 | __END_DECLS 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /debugableruntime/objc4-706-master/runtime/objc-class.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | -------------------------------------------------------------------------------- /debugableruntime/objc4-706-master/runtime/objc-probes.d: -------------------------------------------------------------------------------- 1 | provider objc_runtime 2 | { 3 | probe objc_exception_throw(void *id); 4 | probe objc_exception_rethrow(); 5 | }; 6 | -------------------------------------------------------------------------------- /debugableruntime/objc4-706-master/runtime/objc-runtime.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | -------------------------------------------------------------------------------- /debugableruntime/objc4-706-master/runtime/objcrt.h: -------------------------------------------------------------------------------- 1 | #ifndef _OBJC_RT_H_ 2 | #define _OBJC_RT_H_ 3 | 4 | #include 5 | 6 | 7 | typedef struct { 8 | int count; // number of pointer pairs that follow 9 | void *modStart; 10 | void *modEnd; 11 | void *protoStart; 12 | void *protoEnd; 13 | void *iiStart; 14 | void *iiEnd; 15 | void *selrefsStart; 16 | void *selrefsEnd; 17 | void *clsrefsStart; 18 | void *clsrefsEnd; 19 | } objc_sections; 20 | 21 | OBJC_EXPORT void *_objc_init_image(HMODULE image, const objc_sections *sects); 22 | OBJC_EXPORT void _objc_load_image(HMODULE image, void *hinfo); 23 | OBJC_EXPORT void _objc_unload_image(HMODULE image, void *hinfo); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /debugableruntime/objc4-706-master/unexported_symbols: -------------------------------------------------------------------------------- 1 | .objc_class_name___IncompleteProtocol 2 | __Znam 3 | __ZnamRKSt9nothrow_t 4 | __Znwm 5 | __ZnwmRKSt9nothrow_t 6 | __ZdaPv 7 | __ZdaPvRKSt9nothrow_t 8 | __ZdlPv 9 | __ZdlPvRKSt9nothrow_t 10 | __ZTISt9bad_alloc 11 | __ZTISt9exception 12 | __ZTISt11logic_error 13 | __ZTISt12length_error 14 | __ZTSSt9bad_alloc 15 | __ZTSSt9exception 16 | __ZTSSt11logic_error 17 | __ZTSSt12length_error 18 | -------------------------------------------------------------------------------- /debugableruntime/objc4-706-master/version.bat: -------------------------------------------------------------------------------- 1 | :: version.bat 2 | :: Writes version numbers from B&I into version.h for use by version.rc. 3 | 4 | @ECHO OFF 5 | 6 | :: Set default values for environment variables if not set by B&I 7 | IF "%OBJROOT%"=="" SET OBJROOT=. 8 | IF "%RC_PROJECTSOURCEVERSION%"=="" SET RC_PROJECTSOURCEVERSION=0.0 9 | IF "%RC_PROJECTBUILDVERSION%"=="" SET RC_PROJECTBUILDVERSION=0 10 | 11 | :: Get version numbers from environment variables 12 | SET major=1 13 | SET patch=0 14 | FOR /F "tokens=1* eol= delims=." %%i IN ("%RC_PROJECTSOURCEVERSION%") DO ( 15 | SET minor=%%i 16 | IF NOT "%%j"=="" SET patch=%%j 17 | ) 18 | SET build=%RC_PROJECTBUILDVERSION% 19 | 20 | ECHO version %major% . %minor% . %patch% . %build% 21 | 22 | :: Write version.h 23 | ECHO // This file is automatically generated by version.bat. > "%OBJROOT%\version.h" 24 | ECHO // DO NOT EDIT >> "%OBJROOT%\version.h" 25 | ECHO #define major %major% >> "%OBJROOT%\version.h" 26 | ECHO #define minor %minor% >> "%OBJROOT%\version.h" 27 | ECHO #define patch %patch% >> "%OBJROOT%\version.h" 28 | ECHO #define build %build% >> "%OBJROOT%\version.h" 29 | ECHO #define string "%major%,%minor%,%patch%,%build%" >> "%OBJROOT%\version.h" 30 | -------------------------------------------------------------------------------- /debugableruntime/objc4-706-master/version.rc: -------------------------------------------------------------------------------- 1 | #include "Winver.h" 2 | 3 | // built by version.bat; sets variables major, minor, patch, build, string 4 | #include "version.h" 5 | 6 | VS_VERSION_INFO VERSIONINFO 7 | FILEVERSION major,minor,patch,build 8 | PRODUCTVERSION major,minor,patch,build 9 | FILEFLAGSMASK 0x17L 10 | #ifdef _DEBUG 11 | FILEFLAGS VS_FF_DEBUG 12 | #else 13 | FILEFLAGS 0x0L 14 | #endif 15 | FILEOS VOS_NT_WINDOWS32 16 | FILETYPE VFT_DLL 17 | FILESUBTYPE VFT2_UNKNOWN 18 | BEGIN 19 | BLOCK "StringFileInfo" 20 | BEGIN 21 | BLOCK "040904b0" 22 | BEGIN 23 | VALUE "CompanyName", "Apple Inc." 24 | VALUE "FileDescription", "Objective-C Runtime Library" 25 | VALUE "FileVersion", string 26 | VALUE "ProductVersion", string 27 | VALUE "ProductName", "objc4" 28 | VALUE "InternalName", "objc4" 29 | VALUE "LegalCopyright", "Copyright (C) 2007-2009, Apple Inc." 30 | VALUE "OriginalFilename", "objc.dll" 31 | END 32 | END 33 | BLOCK "VarFileInfo" 34 | BEGIN 35 | VALUE "Translation", 0x409, 1200 36 | END 37 | END 38 | 39 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/debugobjc/main.mm: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // debugobjc 4 | // 5 | // Created by cooci on 2021/1/5. 6 | 7 | 8 | #import 9 | 10 | 11 | @interface DemoClass : NSObject 12 | 13 | @end 14 | 15 | @implementation DemoClass 16 | 17 | 18 | 19 | @end 20 | 21 | int main(int argc, const char * argv[]) { 22 | @autoreleasepool { 23 | // insert code here... 24 | DemoClass *objc = [[DemoClass alloc] init]; 25 | [objc isKindOfClass:NSObject.class]; 26 | } 27 | return 0; 28 | } 29 | 30 | //class Person{ 31 | //public: 32 | // Person(){ 33 | // printf("Person::Person()\n"); 34 | // } 35 | // 36 | // ~Person(){ 37 | // printf("Person::~Person()\n"); 38 | // } 39 | //}; 40 | // 41 | //Person kyson; 42 | // 43 | //int main() { 44 | // return 0; 45 | //} 46 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/dependency/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjh171/RuntimeSample/2f3ef0867129fefa9b37d0c5499253f514b52dee/debugableruntime/objc4-818.2/dependency/.DS_Store -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/dependency/System/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjh171/RuntimeSample/2f3ef0867129fefa9b37d0c5499253f514b52dee/debugableruntime/objc4-818.2/dependency/System/.DS_Store -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/interposable.txt: -------------------------------------------------------------------------------- 1 | _objc_release 2 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/objc.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/objc.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/objc.xcodeproj/project.xcworkspace/xcuserdata/kyson.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjh171/RuntimeSample/2f3ef0867129fefa9b37d0c5499253f514b52dee/debugableruntime/objc4-818.2/objc.xcodeproj/project.xcworkspace/xcuserdata/kyson.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/objc4.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | preoptimizedCaches 6 | 7 | Enabled 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/objcdt/objcdt-entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | task_for_pid-allow 6 | 7 | com.apple.system-task-ports 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/objcdt/objcdt.1: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 2019, Apple Computer, Inc. All rights reserved. 2 | .\" 3 | .Dd September 9, 2019 \" DATE 4 | .Dt objcdt 1 \" Program name and manual section number 5 | .Os "OS X" 6 | .Sh NAME 7 | .Nm objcdt 8 | .Nd Tool to debug objective-C usage in live processes 9 | .Sh SYNOPSIS 10 | .Nm objcdt 11 | .Sh DESCRIPTION 12 | The 13 | .Nm 14 | utility is a small CLI with embedded help that can dump some information about 15 | the Objective-C runtime state in live processes. 16 | .Pp 17 | Help can be obtained using 18 | .Nm 19 | .Ar help 20 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/prebuild.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | echo prebuild: installing headers 4 | xcopy /Y "%ProjectDir%runtime\objc.h" "%DSTROOT%\AppleInternal\include\objc\" 5 | xcopy /Y "%ProjectDir%runtime\objc-api.h" "%DSTROOT%\AppleInternal\include\objc\" 6 | xcopy /Y "%ProjectDir%runtime\objc-auto.h" "%DSTROOT%\AppleInternal\include\objc\" 7 | xcopy /Y "%ProjectDir%runtime\objc-exception.h" "%DSTROOT%\AppleInternal\include\objc\" 8 | xcopy /Y "%ProjectDir%runtime\message.h" "%DSTROOT%\AppleInternal\include\objc\" 9 | xcopy /Y "%ProjectDir%runtime\runtime.h" "%DSTROOT%\AppleInternal\include\objc\" 10 | xcopy /Y "%ProjectDir%runtime\hashtable.h" "%DSTROOT%\AppleInternal\include\objc\" 11 | xcopy /Y "%ProjectDir%runtime\hashtable2.h" "%DSTROOT%\AppleInternal\include\objc\" 12 | xcopy /Y "%ProjectDir%runtime\maptable.h" "%DSTROOT%\AppleInternal\include\objc\" 13 | 14 | echo prebuild: setting version 15 | version 16 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/runtime/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zjh171/RuntimeSample/2f3ef0867129fefa9b37d0c5499253f514b52dee/debugableruntime/objc4-818.2/runtime/.DS_Store -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/runtime/Module/module.modulemap: -------------------------------------------------------------------------------- 1 | module ObjectiveC [system] [extern_c] { 2 | umbrella "." 3 | export * 4 | module * { 5 | export * 6 | } 7 | 8 | module NSObject { 9 | requires objc 10 | header "NSObject.h" 11 | export * 12 | } 13 | 14 | #if defined(BUILD_FOR_OSX) 15 | module List { 16 | // Uses @defs, which does not work in ObjC++ or non-ARC. 17 | requires objc, !objc_arc, !cplusplus 18 | header "List.h" 19 | export * 20 | } 21 | 22 | module Object { 23 | requires objc 24 | header "Object.h" 25 | export * 26 | } 27 | 28 | module Protocol { 29 | requires objc 30 | header "Protocol.h" 31 | export * 32 | } 33 | #endif 34 | 35 | #if !defined(BUILD_FOR_OSX) 36 | // These file are not available outside macOS. 37 | exclude header "hashtable.h" 38 | exclude header "hashtable2.h" 39 | #endif 40 | } 41 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/runtime/NSObjCRuntime.h: -------------------------------------------------------------------------------- 1 | /* NSObjCRuntime.h 2 | Copyright (c) 1994-2012, Apple Inc. All rights reserved. 3 | */ 4 | 5 | #ifndef _OBJC_NSOBJCRUNTIME_H_ 6 | #define _OBJC_NSOBJCRUNTIME_H_ 7 | 8 | #include 9 | #include 10 | 11 | #if __LP64__ || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64 12 | typedef long NSInteger; 13 | typedef unsigned long NSUInteger; 14 | #else 15 | typedef int NSInteger; 16 | typedef unsigned int NSUInteger; 17 | #endif 18 | 19 | #define NSIntegerMax LONG_MAX 20 | #define NSIntegerMin LONG_MIN 21 | #define NSUIntegerMax ULONG_MAX 22 | 23 | #define NSINTEGER_DEFINED 1 24 | 25 | #ifndef NS_DESIGNATED_INITIALIZER 26 | #if __has_attribute(objc_designated_initializer) 27 | #define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) 28 | #else 29 | #define NS_DESIGNATED_INITIALIZER 30 | #endif 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/runtime/hashtable.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/runtime/objc-class.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/runtime/objc-probes.d: -------------------------------------------------------------------------------- 1 | provider objc_runtime 2 | { 3 | probe objc_exception_throw(void *id); 4 | probe objc_exception_rethrow(); 5 | }; 6 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/runtime/objc-runtime.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/runtime/objc-sel-table.s: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #if __LP64__ 5 | #if __arm64e__ 6 | // 0x6AE1 7 | # define PTR(x) .quad x@AUTH(da, 27361, addr) 8 | #else 9 | # define PTR(x) .quad x 10 | #endif 11 | #else 12 | # define PTR(x) .long x 13 | #endif 14 | 15 | // These offsets are populated by the dyld shared cache builder. 16 | // They point to memory allocatd elsewhere in the shared cache. 17 | 18 | .section __TEXT,__objc_opt_ro 19 | .align 3 20 | .private_extern __objc_opt_data 21 | __objc_opt_data: 22 | .long 15 /* table.version */ 23 | .long 0 /* table.flags */ 24 | .long 0 /* table.selopt_offset */ 25 | .long 0 /* table.headeropt_ro_offset */ 26 | .long 0 /* table.clsopt_offset */ 27 | .long 0 /* table.protocolopt_offset */ 28 | .long 0 /* table.headeropt_rw_offset */ 29 | .space PAGE_MAX_SIZE-28 30 | 31 | 32 | /* section of pointers that the shared cache optimizer wants to know about */ 33 | .section __DATA,__objc_opt_ptrs 34 | .align 3 35 | 36 | #if TARGET_OS_OSX && __i386__ 37 | // old ABI 38 | .globl .objc_class_name_Protocol 39 | PTR(.objc_class_name_Protocol) 40 | #else 41 | // new ABI 42 | .globl _OBJC_CLASS_$_Protocol 43 | PTR(_OBJC_CLASS_$_Protocol) 44 | #endif 45 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/runtime/objcrt.h: -------------------------------------------------------------------------------- 1 | #ifndef _OBJC_RT_H_ 2 | #define _OBJC_RT_H_ 3 | 4 | #include 5 | 6 | 7 | typedef struct { 8 | int count; // number of pointer pairs that follow 9 | void *modStart; 10 | void *modEnd; 11 | void *protoStart; 12 | void *protoEnd; 13 | void *iiStart; 14 | void *iiEnd; 15 | void *selrefsStart; 16 | void *selrefsEnd; 17 | void *clsrefsStart; 18 | void *clsrefsEnd; 19 | } objc_sections; 20 | 21 | OBJC_EXPORT void *_objc_init_image(HMODULE image, const objc_sections *sects); 22 | OBJC_EXPORT void _objc_load_image(HMODULE image, void *hinfo); 23 | OBJC_EXPORT void _objc_unload_image(HMODULE image, void *hinfo); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/ARCBase.h: -------------------------------------------------------------------------------- 1 | // 2 | // ARCBase.h 3 | // TestARCLayouts 4 | // 5 | // Created by Patrick Beard on 3/8/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ARCMisalign : NSObject { 12 | char misalign1; 13 | } 14 | @end 15 | 16 | @interface ARCBase : ARCMisalign 17 | @property long number; 18 | @property(retain) id object; 19 | @property void *pointer; 20 | @property(weak) __weak id delegate; 21 | @end 22 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/ARCBase.m: -------------------------------------------------------------------------------- 1 | // 2 | // ARCBase.m 3 | // TestARCLayouts 4 | // 5 | // Created by Patrick Beard on 3/8/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "ARCBase.h" 10 | 11 | // ARCMisalign->misalign1 and ARCBase->misalign2 together cause 12 | // ARCBase's instanceStart to be misaligned, which exercises handling 13 | // of storage that is not represented in the class's ivar layout bitmaps. 14 | 15 | @implementation ARCMisalign 16 | @end 17 | 18 | @interface ARCBase () { 19 | @private 20 | char misalign2; 21 | long number; 22 | id object; 23 | void *pointer; 24 | __weak id delegate; 25 | } 26 | @end 27 | 28 | @implementation ARCBase 29 | @synthesize number, object, pointer, delegate; 30 | @end 31 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/ARCLayoutsWithoutWeak.m: -------------------------------------------------------------------------------- 1 | // Same as test ARCLayouts but with MRC __weak support disabled. 2 | /* 3 | TEST_CONFIG MEM=arc 4 | TEST_BUILD 5 | mkdir -p $T{OBJDIR} 6 | $C{COMPILE_NOLINK_NOMEM} -c $DIR/MRCBase.m -o $T{OBJDIR}/MRCBase.o -fno-objc-weak 7 | $C{COMPILE_NOLINK_NOMEM} -c $DIR/MRCARC.m -o $T{OBJDIR}/MRCARC.o -fno-objc-weak 8 | $C{COMPILE_NOLINK} -c $DIR/ARCBase.m -o $T{OBJDIR}/ARCBase.o 9 | $C{COMPILE_NOLINK} -c $DIR/ARCMRC.m -o $T{OBJDIR}/ARCMRC.o 10 | $C{COMPILE} '-DNAME=\"ARCLayoutsWithoutWeak.m\"' -fobjc-arc $DIR/ARCLayouts.m -x none $T{OBJDIR}/MRCBase.o $T{OBJDIR}/MRCARC.o $T{OBJDIR}/ARCBase.o $T{OBJDIR}/ARCMRC.o -framework Foundation -o ARCLayoutsWithoutWeak.exe 11 | END 12 | */ 13 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/ARCMRC.h: -------------------------------------------------------------------------------- 1 | // 2 | // ARCMRC.h 3 | // TestARCLayouts 4 | // 5 | // Created by Patrick Beard on 3/8/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "MRCBase.h" 10 | 11 | @interface ARCMRC : MRCBase 12 | @property(retain) id dataSource; 13 | @end 14 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/ARCMRC.m: -------------------------------------------------------------------------------- 1 | // 2 | // ARCMRC.m 3 | // 4 | 5 | #import "ARCMRC.h" 6 | 7 | @implementation ARCMRC 8 | 9 | @synthesize dataSource; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/MRCARC.h: -------------------------------------------------------------------------------- 1 | // 2 | // MRCARC.h 3 | // TestARCLayouts 4 | // 5 | // Created by Patrick Beard on 3/8/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "ARCBase.h" 10 | 11 | @interface MRCARC : ARCBase 12 | @property(retain) id dataSource; 13 | @end 14 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/MRCARC.m: -------------------------------------------------------------------------------- 1 | // 2 | // MRCARC.m 3 | // 4 | 5 | #import "MRCARC.h" 6 | 7 | @implementation MRCARC 8 | 9 | @synthesize dataSource; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/MRCBase.h: -------------------------------------------------------------------------------- 1 | // 2 | // MRCBase.h 3 | // TestARCLayouts 4 | // 5 | // Created by Patrick Beard on 3/8/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // YES if MRC compiler supports ARC-style weak 12 | extern bool supportsMRCWeak; 13 | 14 | #if __LP64__ 15 | #define DOUBLEWORD_ALIGNED __attribute__((aligned(16))) 16 | #else 17 | #define DOUBLEWORD_ALIGNED __attribute__((aligned(8))) 18 | #endif 19 | 20 | @interface MRCBase : NSObject 21 | @property double number; 22 | @property(retain) id object; 23 | @property void *pointer; 24 | @property(weak) __weak id delegate; 25 | @end 26 | 27 | // Call object_copy from MRC. 28 | extern id __attribute__((ns_returns_retained)) docopy(id obj); 29 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/MRCBase.m: -------------------------------------------------------------------------------- 1 | // 2 | // MRCBase.m 3 | // TestARCLayouts 4 | // 5 | // Created by Patrick Beard on 3/8/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #include "MRCBase.h" 10 | #include "test.h" 11 | 12 | // MRCBase->alignment ensures that there is a gap between the end of 13 | // NSObject's ivars and the start of MRCBase's ivars, which exercises 14 | // handling of storage that is not represented in any class's ivar 15 | // layout bitmaps. 16 | 17 | #if __has_feature(objc_arc_weak) 18 | bool supportsMRCWeak = true; 19 | #else 20 | bool supportsMRCWeak = false; 21 | #endif 22 | 23 | @interface MRCBase () { 24 | @private 25 | double DOUBLEWORD_ALIGNED alignment; 26 | uintptr_t pad[3]; // historically this made OBJC2 layout bitmaps match OBJC1 27 | double number; 28 | id object; 29 | void *pointer; 30 | #if __has_feature(objc_arc_weak) 31 | __weak 32 | #endif 33 | id delegate; 34 | } 35 | @end 36 | 37 | @implementation MRCBase 38 | @synthesize number, object, pointer, delegate; 39 | @end 40 | 41 | // Call object_copy from MRC. 42 | extern id __attribute__((ns_returns_retained)) 43 | docopy(id obj) 44 | { 45 | return object_copy(obj, 0); 46 | } 47 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/applescriptobjc.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG OS=macosx 2 | // TEST_CFLAGS -framework AppleScriptObjC -framework Foundation 3 | 4 | // Verify that trivial AppleScriptObjC apps run with GC off. 5 | 6 | #include 7 | #include "test.h" 8 | 9 | int main() 10 | { 11 | [NSBundle class]; 12 | succeed(__FILE__); 13 | } 14 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/arr-cast.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | 5 | // objc.h redefines these calls into bridge casts. 6 | // This test verifies that the function implementations are exported. 7 | __BEGIN_DECLS 8 | extern void *retainedObject(void *arg) __asm__("_objc_retainedObject"); 9 | extern void *unretainedObject(void *arg) __asm__("_objc_unretainedObject"); 10 | extern void *unretainedPointer(void *arg) __asm__("_objc_unretainedPointer"); 11 | __END_DECLS 12 | 13 | int main() 14 | { 15 | void *p = (void*)&main; 16 | testassert(p == retainedObject(p)); 17 | testassert(p == unretainedObject(p)); 18 | testassert(p == unretainedPointer(p)); 19 | succeed(__FILE__); 20 | } 21 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/asm-placeholder.s: -------------------------------------------------------------------------------- 1 | .macro NOP16 2 | nop 3 | nop 4 | nop 5 | nop 6 | nop 7 | nop 8 | nop 9 | nop 10 | nop 11 | nop 12 | nop 13 | nop 14 | nop 15 | nop 16 | nop 17 | nop 18 | .endmacro 19 | 20 | .macro NOP256 21 | NOP16 22 | NOP16 23 | NOP16 24 | NOP16 25 | NOP16 26 | NOP16 27 | NOP16 28 | NOP16 29 | NOP16 30 | NOP16 31 | NOP16 32 | NOP16 33 | NOP16 34 | NOP16 35 | NOP16 36 | NOP16 37 | .endmacro 38 | 39 | .text 40 | .globl _main 41 | .align 14 42 | _main: 43 | // at least 1024 instruction bytes on all architectures 44 | NOP256 45 | NOP256 46 | NOP256 47 | NOP256 48 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/association-cf.m: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -framework CoreFoundation 2 | // TEST_CONFIG MEM=mrc 3 | // not for ARC because ARC memory management doesn't 4 | // work on CF types whose ObjC side is not yet loaded 5 | 6 | #include 7 | #include 8 | 9 | #include "test.h" 10 | 11 | #if __has_feature(objc_arc) 12 | 13 | int main() 14 | { 15 | testwarn("rdar://11368528 confused by Foundation"); 16 | succeed(__FILE__); 17 | } 18 | 19 | #else 20 | 21 | int main() 22 | { 23 | // rdar://6164781 setAssociatedObject on unresolved future class crashes 24 | 25 | id mp = (id)CFMachPortCreate(0, 0, 0, 0); 26 | testassert(mp); 27 | 28 | testassert(! objc_getClass("NSMachPort")); 29 | 30 | objc_setAssociatedObject(mp, (void*)1, mp, OBJC_ASSOCIATION_ASSIGN); 31 | 32 | id obj = objc_getAssociatedObject(mp, (void*)1); 33 | testassert(obj == mp); 34 | 35 | CFRelease((CFTypeRef)mp); 36 | 37 | succeed(__FILE__); 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/associationForbidden.m: -------------------------------------------------------------------------------- 1 | // TEST_CRASHES 2 | /* 3 | TEST_RUN_OUTPUT 4 | Associated object is 0x[0-9a-fA-F]+ 5 | objc\[\d+\]: objc_setAssociatedObject called on instance \(0x[0-9a-fA-F]+\) of class Forbidden which does not allow associated objects 6 | objc\[\d+\]: HALTED 7 | END 8 | */ 9 | 10 | #include "associationForbidden.h" 11 | 12 | void test(void) 13 | { 14 | ShouldSucceed([Normal alloc]); 15 | ShouldFail([Forbidden alloc]); 16 | } 17 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/associationForbidden2.m: -------------------------------------------------------------------------------- 1 | // TEST_CRASHES 2 | /* 3 | TEST_RUN_OUTPUT 4 | Associated object is 0x[0-9a-fA-F]+ 5 | objc\[\d+\]: objc_setAssociatedObject called on instance \(0x[0-9a-fA-F]+\) of class ForbiddenSubclass which does not allow associated objects 6 | objc\[\d+\]: HALTED 7 | END 8 | */ 9 | 10 | #include "associationForbidden.h" 11 | 12 | void test(void) 13 | { 14 | ShouldSucceed([Normal alloc]); 15 | Class ForbiddenSubclass = objc_allocateClassPair([Forbidden class], 16 | "ForbiddenSubclass", 0); 17 | objc_registerClassPair(ForbiddenSubclass); 18 | ShouldFail([ForbiddenSubclass alloc]); 19 | } 20 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/associationForbidden3.m: -------------------------------------------------------------------------------- 1 | // TEST_CRASHES 2 | /* 3 | TEST_RUN_OUTPUT 4 | Associated object is 0x[0-9a-fA-F]+ 5 | objc\[\d+\]: objc_setAssociatedObject called on instance \(0x[0-9a-fA-F]+\) of class ForbiddenSubclass which does not allow associated objects 6 | objc\[\d+\]: HALTED 7 | END 8 | */ 9 | 10 | #include "associationForbidden.h" 11 | 12 | @interface ForbiddenSubclass : Forbidden 13 | @end 14 | @implementation ForbiddenSubclass 15 | @end 16 | 17 | void test(void) 18 | { 19 | ShouldSucceed([Normal alloc]); 20 | ShouldSucceed([ForbiddenSubclass alloc]); 21 | } 22 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/associationForbidden4.m: -------------------------------------------------------------------------------- 1 | // TEST_CRASHES 2 | /* 3 | TEST_RUN_OUTPUT 4 | Associated object is 0x[0-9a-fA-F]+ 5 | objc\[\d+\]: objc_setAssociatedObject called on instance \(0x[0-9a-fA-F]+\) of class ForbiddenDuplicate which does not allow associated objects 6 | objc\[\d+\]: HALTED 7 | END 8 | */ 9 | 10 | #include "associationForbidden.h" 11 | 12 | void test(void) 13 | { 14 | ShouldSucceed([Normal alloc]); 15 | Class ForbiddenDuplicate = objc_duplicateClass([Forbidden class], 16 | "ForbiddenDuplicate", 0); 17 | ShouldFail([ForbiddenDuplicate alloc]); 18 | } 19 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/atomicProperty.mm: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include 5 | #include 6 | #import 7 | 8 | class SerialNumber { 9 | size_t _number; 10 | public: 11 | SerialNumber() : _number(42) {} 12 | SerialNumber(const SerialNumber &number) : _number(number._number + 1) {} 13 | SerialNumber &operator=(const SerialNumber &number) { _number = number._number + 1; return *this; } 14 | 15 | int operator==(const SerialNumber &number) { return _number == number._number; } 16 | int operator!=(const SerialNumber &number) { return _number != number._number; } 17 | }; 18 | 19 | @interface TestAtomicProperty : NSObject { 20 | SerialNumber number; 21 | } 22 | @property(atomic) SerialNumber number; 23 | @end 24 | 25 | @implementation TestAtomicProperty 26 | 27 | @synthesize number; 28 | 29 | @end 30 | 31 | int main() 32 | { 33 | PUSH_POOL { 34 | SerialNumber number; 35 | TestAtomicProperty *test = [TestAtomicProperty new]; 36 | test.number = number; 37 | testassert(test.number != number); 38 | } POP_POOL; 39 | 40 | succeed(__FILE__); 41 | } 42 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/badPool.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG MEM=mrc 2 | // TEST_CRASHES 3 | 4 | // Test badPoolCompat also uses this file. 5 | 6 | /* 7 | TEST_RUN_OUTPUT 8 | objc\[\d+\]: [Ii]nvalid or prematurely-freed autorelease pool 0x[0-9a-fA-F]+\.? 9 | objc\[\d+\]: HALTED 10 | END 11 | */ 12 | 13 | #include "test.h" 14 | 15 | int main() 16 | { 17 | void *outer = objc_autoreleasePoolPush(); 18 | void *inner = objc_autoreleasePoolPush(); 19 | objc_autoreleasePoolPop(outer); 20 | objc_autoreleasePoolPop(inner); 21 | 22 | #if !OLD 23 | fail("should have crashed already with new SDK"); 24 | #else 25 | // should only warn once 26 | outer = objc_autoreleasePoolPush(); 27 | inner = objc_autoreleasePoolPush(); 28 | objc_autoreleasePoolPop(outer); 29 | objc_autoreleasePoolPop(inner); 30 | 31 | succeed(__FILE__); 32 | #endif 33 | } 34 | 35 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/badPoolCompat-ios.m: -------------------------------------------------------------------------------- 1 | // Run test badPool as if it were built with an old SDK. 2 | 3 | // TEST_CONFIG MEM=mrc OS=iphoneos,iphonesimulator ARCH=x86_64,arm64 4 | // TEST_CRASHES 5 | // TEST_CFLAGS -DOLD=1 -Xlinker -platform_version -Xlinker ios -Xlinker 9.0 -Xlinker 9.0 -miphoneos-version-min=9.0 6 | 7 | /* 8 | TEST_BUILD_OUTPUT 9 | ld: warning: passed two min versions.*for platform.* 10 | END 11 | 12 | TEST_RUN_OUTPUT 13 | objc\[\d+\]: Invalid or prematurely-freed autorelease pool 0x[0-9a-fA-f]+\. Set a breakpoint .* Proceeding anyway .* 14 | OK: badPool.m 15 | END 16 | */ 17 | 18 | #include "badPool.m" 19 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/badPoolCompat-macos.m: -------------------------------------------------------------------------------- 1 | // Run test badPool as if it were built with an old SDK. 2 | 3 | // TEST_CONFIG MEM=mrc OS=macosx ARCH=x86_64 4 | // TEST_CRASHES 5 | // TEST_CFLAGS -DOLD=1 -Xlinker -platform_version -Xlinker macos -Xlinker 10.11 -Xlinker 10.11 -mmacosx-version-min=10.11 6 | 7 | /* 8 | TEST_BUILD_OUTPUT 9 | ld: warning: passed two min versions.*for platform.* 10 | END 11 | 12 | TEST_RUN_OUTPUT 13 | objc\[\d+\]: Invalid or prematurely-freed autorelease pool 0x[0-9a-fA-f]+\. Set a breakpoint .* Proceeding anyway .* 14 | OK: badPool.m 15 | END 16 | */ 17 | 18 | #include "badPool.m" 19 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/badPoolCompat-tvos.m: -------------------------------------------------------------------------------- 1 | // Run test badPool as if it were built with an old SDK. 2 | 3 | // TEST_CONFIG MEM=mrc OS=appletvos,appletvsimulator ARCH=x86_64,arm64 4 | // TEST_CRASHES 5 | // TEST_CFLAGS -DOLD=1 -Xlinker -platform_version -Xlinker tvos -Xlinker 9.0 -Xlinker 9.0 -mtvos-version-min=9.0 6 | 7 | /* 8 | TEST_BUILD_OUTPUT 9 | ld: warning: passed two min versions.*for platform.* 10 | END 11 | 12 | TEST_RUN_OUTPUT 13 | objc\[\d+\]: Invalid or prematurely-freed autorelease pool 0x[0-9a-fA-f]+\. Set a breakpoint .* Proceeding anyway .* 14 | OK: badPool.m 15 | END 16 | */ 17 | 18 | #include "badPool.m" 19 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/badPoolCompat-watchos.m: -------------------------------------------------------------------------------- 1 | // Run test badPool as if it were built with an old SDK. 2 | 3 | // TEST_CONFIG MEM=mrc OS=watchos,watchsimulator 4 | // TEST_CRASHES 5 | // TEST_CFLAGS -DOLD=1 -Xlinker -platform_version -Xlinker watchos -Xlinker 2.0 -Xlinker 2.0 -mwatchos-version-min=2.0 6 | 7 | /* 8 | TEST_BUILD_OUTPUT 9 | ld: warning: passed two min versions.*for platform.* 10 | END 11 | 12 | TEST_RUN_OUTPUT 13 | objc\[\d+\]: Invalid or prematurely-freed autorelease pool 0x[0-9a-fA-f]+\. Set a breakpoint .* Proceeding anyway .* 14 | OK: badPool.m 15 | END 16 | */ 17 | 18 | #include "badPool.m" 19 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/badSuperclass.m: -------------------------------------------------------------------------------- 1 | // TEST_CRASHES 2 | /* 3 | TEST_RUN_OUTPUT 4 | objc\[\d+\]: Memory corruption in class list\. 5 | objc\[\d+\]: HALTED 6 | END 7 | */ 8 | 9 | #include "test.h" 10 | #include "testroot.i" 11 | 12 | @interface Super : TestRoot @end 13 | @implementation Super @end 14 | 15 | @interface Sub : Super @end 16 | @implementation Sub @end 17 | 18 | int main() 19 | { 20 | alarm(10); 21 | 22 | Class supercls = [Super class]; 23 | Class subcls = [Sub class]; 24 | id subobj __unused = [Sub alloc]; 25 | 26 | // Create a cycle in a superclass chain (Sub->supercls == Sub) 27 | // then attempt to walk that chain. Runtime should halt eventually. 28 | _objc_flush_caches(supercls); 29 | ((Class __ptrauth_objc_super_pointer *)(__bridge void *)subcls)[1] = subcls; 30 | #ifdef CACHE_FLUSH 31 | _objc_flush_caches(supercls); 32 | #else 33 | [subobj class]; 34 | #endif 35 | 36 | fail("should have crashed"); 37 | } 38 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/badSuperclass2.m: -------------------------------------------------------------------------------- 1 | // TEST_CRASHES 2 | /* 3 | TEST_RUN_OUTPUT 4 | objc\[\d+\]: Memory corruption in class list\. 5 | objc\[\d+\]: HALTED 6 | OR 7 | old abi 8 | OK: badSuperclass\.m 9 | END 10 | */ 11 | 12 | #define CACHE_FLUSH 13 | #include "badSuperclass.m" 14 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/badTagIndex.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_CRASHES 3 | TEST_RUN_OUTPUT 4 | objc\[\d+\]: tag index 264 is invalid 5 | objc\[\d+\]: HALTED 6 | OR 7 | no tagged pointers 8 | OK: badTagIndex.m 9 | END 10 | */ 11 | 12 | #include "test.h" 13 | 14 | #include 15 | #include 16 | 17 | #if OBJC_HAVE_TAGGED_POINTERS 18 | 19 | int main() 20 | { 21 | _objc_registerTaggedPointerClass((objc_tag_index_t)(OBJC_TAG_Last52BitPayload+1), [NSObject class]); 22 | fail(__FILE__); 23 | } 24 | 25 | #else 26 | 27 | int main() 28 | { 29 | fprintf(stderr, "no tagged pointers\n"); 30 | succeed(__FILE__); 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/bool.c: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -funsigned-char 2 | // (verify -funsigned-char doesn't change the definition of BOOL) 3 | 4 | #include "test.h" 5 | #include 6 | 7 | #if TARGET_OS_OSX 8 | # if __x86_64__ 9 | # define RealBool 0 10 | # else 11 | # define RealBool 1 12 | # endif 13 | #elif TARGET_OS_IOS || TARGET_OS_BRIDGE 14 | # if (__arm__ && !__armv7k__) || __i386__ 15 | # define RealBool 0 16 | # else 17 | # define RealBool 1 18 | # endif 19 | #else 20 | # define RealBool 1 21 | #endif 22 | 23 | #if __OBJC__ && !defined(__OBJC_BOOL_IS_BOOL) 24 | # error no __OBJC_BOOL_IS_BOOL 25 | #endif 26 | 27 | #if RealBool != OBJC_BOOL_IS_BOOL 28 | # error wrong OBJC_BOOL_IS_BOOL 29 | #endif 30 | 31 | #if RealBool == OBJC_BOOL_IS_CHAR 32 | # error wrong OBJC_BOOL_IS_CHAR 33 | #endif 34 | 35 | int main() 36 | { 37 | const char *expected __unused = 38 | #if RealBool 39 | "B" 40 | #else 41 | "c" 42 | #endif 43 | ; 44 | #if __OBJC__ 45 | const char *enc = @encode(BOOL); 46 | testassert(0 == strcmp(enc, expected)); 47 | #endif 48 | succeed(__FILE__); 49 | } 50 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/cacheflush-constant.m: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -framework Foundation 2 | /* 3 | TEST_RUN_OUTPUT 4 | foo 5 | bar 6 | bar 7 | foo 8 | END 9 | */ 10 | 11 | // NOTE: This test won't catch problems when running against a root, so it's of 12 | // limited utility, but it would at least catch things when testing against the 13 | // shared cache. 14 | 15 | #include 16 | #include 17 | 18 | @interface NSBlock: NSObject @end 19 | 20 | // NSBlock is a conveniently accessible superclass that (currently) has a constant cache. 21 | @interface MyBlock: NSBlock 22 | +(void)foo; 23 | +(void)bar; 24 | @end 25 | @implementation MyBlock 26 | +(void)foo { 27 | printf("foo\n"); 28 | } 29 | +(void)bar { 30 | printf("bar\n"); 31 | } 32 | @end 33 | 34 | int main() { 35 | [MyBlock foo]; 36 | [MyBlock bar]; 37 | 38 | Method m1 = class_getClassMethod([MyBlock class], @selector(foo)); 39 | Method m2 = class_getClassMethod([MyBlock class], @selector(bar)); 40 | method_exchangeImplementations(m1, m2); 41 | 42 | [MyBlock foo]; 43 | [MyBlock bar]; 44 | } 45 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/cacheflush.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "test.h" 3 | 4 | @interface TestRoot(cat) 5 | +(int)classMethod; 6 | -(int)instanceMethod; 7 | @end 8 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/cacheflush0.m: -------------------------------------------------------------------------------- 1 | #include "cacheflush.h" 2 | #include "testroot.i" 3 | 4 | @implementation TestRoot(cat) 5 | +(int)classMethod { return 1; } 6 | -(int)instanceMethod { return 1; } 7 | @end 8 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/cacheflush2.m: -------------------------------------------------------------------------------- 1 | #include "cacheflush.h" 2 | 3 | @implementation TestRoot (Category2) 4 | +(int)classMethod { return 2; } 5 | -(int)instanceMethod { return 2; } 6 | @end 7 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/cacheflush3.m: -------------------------------------------------------------------------------- 1 | #include "cacheflush.h" 2 | 3 | @implementation TestRoot (Category3) 4 | +(int)classMethod { return 3; } 5 | -(int)instanceMethod { return 3; } 6 | @end 7 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/classgetclass.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include 5 | #include 6 | #import 7 | 8 | @interface Foo:NSObject 9 | @end 10 | @implementation Foo 11 | @end 12 | 13 | int main() 14 | { 15 | testassert(gdb_class_getClass([Foo class]) == [Foo class]); 16 | succeed(__FILE__); 17 | } 18 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/classversion.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | #include 6 | 7 | int main() 8 | { 9 | Class cls = [TestRoot class]; 10 | testassert(class_getVersion(cls) == 0); 11 | testassert(class_getVersion(object_getClass(cls)) > 5); 12 | class_setVersion(cls, 100); 13 | testassert(class_getVersion(cls) == 100); 14 | 15 | testassert(class_getVersion(Nil) == 0); 16 | class_setVersion(Nil, 100); 17 | 18 | succeed(__FILE__); 19 | } 20 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/customrr-cat1.m: -------------------------------------------------------------------------------- 1 | @interface InheritingSubCat @end 2 | 3 | @interface InheritingSubCat (NonClobberingCategory) @end 4 | 5 | @implementation InheritingSubCat (NonClobberingCategory) 6 | -(id) unrelatedMethod { return self; } 7 | @end 8 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/customrr-cat2.m: -------------------------------------------------------------------------------- 1 | @interface InheritingSubCat @end 2 | 3 | @interface InheritingSubCat (ClobberingCategory) @end 4 | 5 | @implementation InheritingSubCat (ClobberingCategory) 6 | -(int) retainCount { return 1; } 7 | @end 8 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/customrr-nsobject-awz.m: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TEST_CONFIG MEM=mrc 4 | TEST_ENV OBJC_PRINT_CUSTOM_RR=YES OBJC_PRINT_CUSTOM_AWZ=YES OBJC_PRINT_CUSTOM_CORE=YES 5 | 6 | TEST_BUILD 7 | $C{COMPILE} $DIR/customrr-nsobject.m -o customrr-nsobject-awz.exe -DSWIZZLE_AWZ=1 -fno-objc-convert-messages-to-runtime-calls 8 | END 9 | 10 | TEST_RUN_OUTPUT 11 | objc\[\d+\]: CUSTOM AWZ: NSObject \(meta\) 12 | OK: customrr-nsobject-awz.exe 13 | END 14 | 15 | */ 16 | 17 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/customrr-nsobject-core.m: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TEST_CONFIG MEM=mrc 4 | TEST_ENV OBJC_PRINT_CUSTOM_RR=YES OBJC_PRINT_CUSTOM_AWZ=YES OBJC_PRINT_CUSTOM_CORE=YES 5 | 6 | TEST_BUILD 7 | $C{COMPILE} $DIR/customrr-nsobject.m -o customrr-nsobject-core.exe -DSWIZZLE_CORE=1 -fno-objc-convert-messages-to-runtime-calls 8 | END 9 | 10 | TEST_RUN_OUTPUT 11 | objc\[\d+\]: CUSTOM Core: NSObject 12 | objc\[\d+\]: CUSTOM Core: NSObject \(meta\) 13 | OK: customrr-nsobject-core.exe 14 | END 15 | 16 | */ 17 | 18 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/customrr-nsobject-none.m: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TEST_CONFIG MEM=mrc 4 | TEST_ENV OBJC_PRINT_CUSTOM_RR=YES OBJC_PRINT_CUSTOM_AWZ=YES OBJC_PRINT_CUSTOM_CORE=YES 5 | 6 | TEST_BUILD 7 | $C{COMPILE} $DIR/customrr-nsobject.m -o customrr-nsobject-none.exe -fno-objc-convert-messages-to-runtime-calls 8 | END 9 | 10 | TEST_RUN_OUTPUT 11 | OK: customrr-nsobject-none.exe 12 | END 13 | 14 | */ 15 | 16 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/customrr-nsobject-rr.m: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TEST_CONFIG MEM=mrc 4 | TEST_ENV OBJC_PRINT_CUSTOM_RR=YES OBJC_PRINT_CUSTOM_AWZ=YES OBJC_PRINT_CUSTOM_CORE=YES 5 | 6 | TEST_BUILD 7 | $C{COMPILE} $DIR/customrr-nsobject.m -o customrr-nsobject-rr.exe -DSWIZZLE_RELEASE=1 -fno-objc-convert-messages-to-runtime-calls 8 | END 9 | 10 | TEST_RUN_OUTPUT 11 | objc\[\d+\]: CUSTOM RR: NSObject 12 | OK: customrr-nsobject-rr.exe 13 | END 14 | 15 | */ 16 | 17 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/customrr-nsobject-rrawz.m: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TEST_CONFIG MEM=mrc 4 | TEST_ENV OBJC_PRINT_CUSTOM_RR=YES OBJC_PRINT_CUSTOM_AWZ=YES OBJC_PRINT_CUSTOM_CORE=YES 5 | 6 | TEST_BUILD 7 | $C{COMPILE} $DIR/customrr-nsobject.m -o customrr-nsobject-rrawz.exe -DSWIZZLE_RELEASE=1 -DSWIZZLE_AWZ=1 -fno-objc-convert-messages-to-runtime-calls 8 | END 9 | 10 | TEST_RUN_OUTPUT 11 | objc\[\d+\]: CUSTOM AWZ: NSObject \(meta\) 12 | objc\[\d+\]: CUSTOM RR: NSObject 13 | OK: customrr-nsobject-rrawz.exe 14 | END 15 | 16 | */ 17 | 18 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/customrr2.m: -------------------------------------------------------------------------------- 1 | // These options must match customrr.m 2 | // TEST_CONFIG MEM=mrc 3 | /* 4 | TEST_BUILD 5 | $C{COMPILE} $DIR/customrr.m -fvisibility=default -o customrr2.exe -DTEST_EXCHANGEIMPLEMENTATIONS=1 -fno-objc-convert-messages-to-runtime-calls 6 | $C{COMPILE} -bundle -bundle_loader customrr2.exe $DIR/customrr-cat1.m -o customrr-cat1.bundle 7 | $C{COMPILE} -bundle -bundle_loader customrr2.exe $DIR/customrr-cat2.m -o customrr-cat2.bundle 8 | END 9 | */ 10 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/designatedinit.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | /* TEST_BUILD_OUTPUT 3 | .*designatedinit.m:\d+:\d+: warning: designated initializer should only invoke a designated initializer on 'super'.* 4 | .*designatedinit.m:\d+:\d+: note: .* 5 | .*designatedinit.m:\d+:\d+: warning: method override for the designated initializer of the superclass '-init' not found.* 6 | .*NSObject.h:\d+:\d+: note: .* 7 | END */ 8 | 9 | #define NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER 1 10 | #include "test.h" 11 | #include 12 | 13 | @interface C : NSObject 14 | -(id) initWithInt:(int)i NS_DESIGNATED_INITIALIZER; 15 | @end 16 | 17 | @implementation C 18 | -(id) initWithInt:(int)__unused i { 19 | return [self init]; 20 | } 21 | @end 22 | 23 | int main() 24 | { 25 | succeed(__FILE__); 26 | } 27 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/duplicatedClasses.m: -------------------------------------------------------------------------------- 1 | // fixme rdar://24624435 duplicate class warning fails with the shared cache 2 | // OBJC_DISABLE_PREOPTIMIZATION=YES works around that problem. 3 | 4 | // TEST_ENV OBJC_DEBUG_DUPLICATE_CLASSES=YES OBJC_DISABLE_PREOPTIMIZATION=YES 5 | // TEST_CRASHES 6 | /* 7 | TEST_RUN_OUTPUT 8 | objc\[\d+\]: Class [^\s]+ is implemented in both .+ \(0x[0-9a-f]+\) and .+ \(0x[0-9a-f]+\)\. One of the two will be used\. Which one is undefined\. 9 | objc\[\d+\]: HALTED 10 | OR 11 | OK: duplicatedClasses.m 12 | END 13 | */ 14 | 15 | #include "test.h" 16 | #include "testroot.i" 17 | 18 | @interface WKWebView : TestRoot @end 19 | @implementation WKWebView @end 20 | 21 | int main() 22 | { 23 | void *dl = dlopen("/System/Library/Frameworks/WebKit.framework/WebKit", RTLD_LAZY); 24 | if (!dl) fail("couldn't open WebKit"); 25 | fail("should have crashed already"); 26 | } 27 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/forkInitializeDisabled.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_CONFIG OS=macosx MEM=mrc ARCH=x86_64 3 | (confused by ARC which loads Foundation which provokes more +initialize logs) 4 | (also confused by i386 OS_object +load workaround) 5 | 6 | TEST_ENV OBJC_PRINT_INITIALIZE_METHODS=YES 7 | 8 | TEST_RUN_OUTPUT 9 | objc\[\d+\]: INITIALIZE: disabling \+initialize fork safety enforcement because the app has a __DATA,__objc_fork_ok section 10 | OK: forkInitializeDisabled\.m 11 | END 12 | */ 13 | 14 | #include "test.h" 15 | 16 | asm(".section __DATA, __objc_fork_ok\n.long 0\n"); 17 | 18 | int main() 19 | { 20 | succeed(__FILE__); 21 | } 22 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/forkInitializeSingleThreaded.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_RUN_OUTPUT 3 | OK: forkInitialize\.m 4 | OK: forkInitialize\.m 5 | END 6 | */ 7 | #define SINGLETHREADED 1 8 | #include "forkInitialize.m" 9 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/forwardDefault.m: -------------------------------------------------------------------------------- 1 | /* 2 | no arc, rdar://11368528 confused by Foundation 3 | TEST_CONFIG MEM=mrc 4 | TEST_CRASHES 5 | TEST_RUN_OUTPUT 6 | objc\[\d+\]: \+\[NSObject fakeorama\]: unrecognized selector sent to instance 0x[0-9a-fA-F]+ \(no message forward handler is installed\) 7 | objc\[\d+\]: HALTED 8 | END 9 | */ 10 | 11 | #include "test.h" 12 | 13 | #include 14 | 15 | @interface NSObject (Fake) 16 | -(void)fakeorama; 17 | @end 18 | 19 | int main() 20 | { 21 | [NSObject fakeorama]; 22 | fail("should have crashed"); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/forwardDefaultStret.m: -------------------------------------------------------------------------------- 1 | /* 2 | no arc, rdar://11368528 confused by Foundation 3 | TEST_CONFIG MEM=mrc 4 | TEST_CRASHES 5 | TEST_RUN_OUTPUT 6 | objc\[\d+\]: \+\[NSObject fakeorama\]: unrecognized selector sent to instance 0x[0-9a-fA-F]+ \(no message forward handler is installed\) 7 | objc\[\d+\]: HALTED 8 | END 9 | */ 10 | 11 | #include "test.h" 12 | 13 | #include 14 | 15 | @interface NSObject (Fake) 16 | -(struct stret)fakeorama; 17 | @end 18 | 19 | int main() 20 | { 21 | [NSObject fakeorama]; 22 | fail("should have crashed"); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/future.h: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | @interface Sub1 : TestRoot 4 | +(int)method; 5 | +(Class)classref; 6 | @end 7 | 8 | @interface Sub2 : TestRoot 9 | +(int)method; 10 | +(Class)classref; 11 | @end 12 | 13 | @interface SubSub1 : Sub1 @end 14 | 15 | @interface SubSub2 : Sub2 @end 16 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/future0.m: -------------------------------------------------------------------------------- 1 | #include "future.h" 2 | #include "testroot.i" 3 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/future2.m: -------------------------------------------------------------------------------- 1 | #include "future.h" 2 | 3 | 4 | @implementation Sub1 5 | +(Class)classref { 6 | return [Sub1 class]; 7 | } 8 | +(int)method { 9 | return 1; 10 | } 11 | @end 12 | 13 | @implementation SubSub1 14 | +(int)method { 15 | return 1 + [super method]; 16 | } 17 | @end 18 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/get_task_allow_entitlement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | get-task-allow 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/headers.c: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $DIR/headers.sh '$C{TESTINCLUDEDIR}' '$C{TESTLOCALINCLUDEDIR}' '$C{COMPILE_C}' '$C{COMPILE_CXX}' '$C{COMPILE_M}' '$C{COMPILE_MM}' '$VERBOSE' 4 | $C{COMPILE_C} $DIR/headers.c -o headers.exe 5 | END 6 | 7 | allow `sh -x` output from headers.sh 8 | TEST_BUILD_OUTPUT 9 | (\+ .*\n)*(\+ .*)?done 10 | END 11 | */ 12 | 13 | 14 | #include "test.h" 15 | 16 | int main() 17 | { 18 | succeed(__FILE__); 19 | } 20 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/headers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Compile every exported ObjC header as if it were a file in every language. 4 | # This script is executed by test headers.c's TEST_BUILD command. 5 | 6 | TESTINCLUDEDIR=$1; shift 7 | TESTLOCALINCLUDEDIR=$1; shift 8 | COMPILE_C=$1; shift 9 | COMPILE_CXX=$1; shift 10 | COMPILE_M=$1; shift 11 | COMPILE_MM=$1; shift 12 | VERBOSE=$1; shift 13 | 14 | # stop after any command error 15 | set -e 16 | 17 | # echo commands when verbose 18 | if [ "$VERBOSE" != "0" ]; then 19 | set -x 20 | fi 21 | 22 | FILES="$TESTINCLUDEDIR/objc/*.h $TESTLOCALINCLUDEDIR/objc/*.h" 23 | CFLAGS='-fsyntax-only -Wno-unused-function -D_OBJC_PRIVATE_H_' 24 | 25 | $COMPILE_C $CFLAGS $FILES 26 | $COMPILE_CXX $CFLAGS $FILES 27 | $COMPILE_M $CFLAGS $FILES 28 | $COMPILE_MM $CFLAGS $FILES 29 | for STDC in '99' '11' ; do 30 | $COMPILE_C $CFLAGS $FILES -std=c$STDC 31 | $COMPILE_M $CFLAGS $FILES -std=c$STDC 32 | done 33 | for STDCXX in '98' '03' '11' '14' '17' ; do 34 | $COMPILE_CXX $CFLAGS $FILES -std=c++$STDCXX 35 | $COMPILE_MM $CFLAGS $FILES -std=c++$STDCXX 36 | done 37 | 38 | echo done 39 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/imageorder.h: -------------------------------------------------------------------------------- 1 | extern int state; 2 | extern int cstate; 3 | 4 | OBJC_ROOT_CLASS 5 | @interface Super { id isa; } 6 | +(void) method; 7 | +(void) method0; 8 | @end 9 | 10 | @interface Super (cat1) 11 | +(void) method1; 12 | @end 13 | 14 | @interface Super (cat2) 15 | +(void) method2; 16 | @end 17 | 18 | @interface Super (cat3) 19 | +(void) method3; 20 | @end 21 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/imageorder1.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | #include "imageorder.h" 3 | 4 | int state = -1; 5 | int cstate = 0; 6 | 7 | static void c1(void) __attribute__((constructor)); 8 | static void c1(void) 9 | { 10 | testassert(state == 1); // +load before C/C++ 11 | testassert(cstate == 0); 12 | cstate = 1; 13 | } 14 | 15 | 16 | #if __clang__ 17 | #pragma clang diagnostic push 18 | #pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation" 19 | #endif 20 | 21 | @implementation Super (cat1) 22 | +(void) method { 23 | fail("+[Super(cat1) method] not replaced!"); 24 | } 25 | +(void) method1 { 26 | state = 1; 27 | } 28 | +(void) load { 29 | testassert(state == 0); 30 | state = 1; 31 | } 32 | @end 33 | 34 | #if __clang__ 35 | #pragma clang diagnostic pop 36 | #endif 37 | 38 | 39 | @implementation Super 40 | +(void) initialize { } 41 | +(void) method { 42 | fail("+[Super method] not replaced!"); 43 | } 44 | +(void) method0 { 45 | state = 0; 46 | } 47 | +(void) load { 48 | testassert(state == -1); 49 | state = 0; 50 | } 51 | @end 52 | 53 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/imageorder2.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | #include "imageorder.h" 3 | 4 | static void c2(void) __attribute__((constructor)); 5 | static void c2(void) 6 | { 7 | testassert(state == 2); // +load before C/C++ 8 | testassert(cstate == 1); 9 | cstate = 2; 10 | } 11 | 12 | 13 | #if __clang__ 14 | #pragma clang diagnostic push 15 | #pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation" 16 | #endif 17 | 18 | @implementation Super (cat2) 19 | +(void) method { 20 | fail("+[Super(cat2) method] not replaced!"); 21 | } 22 | +(void) method2 { 23 | state = 2; 24 | } 25 | +(void) load { 26 | testassert(state == 1); 27 | state = 2; 28 | } 29 | @end 30 | 31 | #if __clang__ 32 | #pragma clang diagnostic pop 33 | #endif 34 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/imageorder3.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | #include "imageorder.h" 3 | 4 | static void c3(void) __attribute__((constructor)); 5 | static void c3(void) 6 | { 7 | testassert(state == 3); // +load before C/C++ 8 | testassert(cstate == 2); 9 | cstate = 3; 10 | } 11 | 12 | 13 | #if __clang__ 14 | #pragma clang diagnostic push 15 | #pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation" 16 | #endif 17 | 18 | @implementation Super (cat3) 19 | +(void) method { 20 | state = 3; 21 | } 22 | +(void) method3 { 23 | state = 3; 24 | } 25 | +(void) load { 26 | testassert(state == 2); 27 | state = 3; 28 | } 29 | @end 30 | 31 | #if __clang__ 32 | #pragma clang diagnostic pop 33 | #endif 34 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/include-warnings.c: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/include-warnings.c -o include-warnings.exe -Wsystem-headers -Weverything -Wno-undef -Wno-old-style-cast -Wno-nullability-extension -Wno-c++98-compat 2>&1 | grep -v 'In file' | grep objc || true 4 | END 5 | 6 | TEST_RUN_OUTPUT 7 | OK: includes.c 8 | END 9 | */ 10 | 11 | // Detect warnings inside any header. 12 | // The build command above filters out warnings inside non-objc headers 13 | // (which are noisy with -Weverything). 14 | // -Wno-undef suppresses warnings about `#if __cplusplus` and the like. 15 | // -Wno-old-style-cast is tough to avoid in mixed C/C++ code. 16 | // -Wno-nullability-extension disables a warning about non-portable 17 | // _Nullable etc which we already handle correctly in objc-abi.h. 18 | // -Wno-c++98-compat disables warnings about things that already 19 | // have guards against C++98. 20 | 21 | #include "includes.c" 22 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/includes-objc2.c: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -D__OBJC2__ 2 | 3 | // Verify that all headers can be included in any language, even if 4 | // the client is C code that defined __OBJC2__. 5 | 6 | // This is the definition that Instruments uses in its build. 7 | #if defined(__OBJC2__) 8 | #undef __OBJC2__ 9 | #endif 10 | #define __OBJC2__ 1 11 | 12 | #define NAME "includes-objc2.c" 13 | #include "includes.c" 14 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/ismeta.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | #include 6 | 7 | int main() 8 | { 9 | testassert(!class_isMetaClass([TestRoot class])); 10 | testassert(class_isMetaClass(object_getClass([TestRoot class]))); 11 | testassert(!class_isMetaClass(nil)); 12 | succeed(__FILE__); 13 | } 14 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/ivarSlide1.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | #include 3 | #include 4 | 5 | #define OLD 0 6 | #include "ivarSlide.h" 7 | 8 | #include "testroot.i" 9 | 10 | @implementation Super @end 11 | 12 | @implementation ShrinkingSuper @end 13 | 14 | @implementation MoreStrongSuper @end 15 | @implementation LessStrongSuper @end 16 | @implementation MoreWeakSuper @end 17 | @implementation MoreWeak2Super @end 18 | @implementation LessWeakSuper @end 19 | @implementation LessWeak2Super @end 20 | @implementation NoGCChangeSuper @end 21 | @implementation RunsOf15 @end 22 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/load-image-notification-dylib.m: -------------------------------------------------------------------------------- 1 | #import "test.h" 2 | 3 | #import 4 | 5 | @interface CLASSNAME: NSObject @end 6 | @implementation CLASSNAME @end 7 | 8 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/load-noobjc2.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | extern semaphore_t go; 4 | 5 | OBJC_ROOT_CLASS 6 | @interface noobjc @end 7 | @implementation noobjc 8 | +(void)load 9 | { 10 | semaphore_signal(go); 11 | while (1) sleep(1); 12 | } 13 | @end 14 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/load-noobjc3.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | extern int state; 4 | 5 | __attribute__((constructor)) 6 | static void ctor(void) 7 | { 8 | state = 1; 9 | } 10 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/load-order.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/load-order3.m -o load-order3.dylib -dynamiclib 4 | $C{COMPILE} $DIR/load-order2.m -o load-order2.dylib -x none load-order3.dylib -dynamiclib 5 | $C{COMPILE} $DIR/load-order1.m -o load-order1.dylib -x none load-order3.dylib load-order2.dylib -dynamiclib 6 | $C{COMPILE} $DIR/load-order.m -o load-order.exe -x none load-order3.dylib load-order2.dylib load-order1.dylib 7 | END 8 | */ 9 | 10 | #include "test.h" 11 | 12 | extern int state1, state2, state3; 13 | 14 | int main() 15 | { 16 | testassert(state1 == 1 && state2 == 2 && state3 == 3); 17 | succeed(__FILE__); 18 | } 19 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/load-order1.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | extern int state2, state3; 4 | 5 | int state1 = 0; 6 | 7 | OBJC_ROOT_CLASS 8 | @interface One @end 9 | @implementation One 10 | +(void)load 11 | { 12 | testassert(state2 == 2 && state3 == 3); 13 | state1 = 1; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/load-order2.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | extern int state3; 4 | 5 | int state2 = 0; 6 | 7 | OBJC_ROOT_CLASS 8 | @interface Two @end 9 | @implementation Two 10 | +(void)load 11 | { 12 | testassert(state3 == 3); 13 | state2 = 2; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/load-order3.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | int state3 = 0; 4 | 5 | OBJC_ROOT_CLASS 6 | @interface Three @end 7 | @implementation Three 8 | +(void)load 9 | { 10 | state3 = 3; 11 | } 12 | @end 13 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/load-parallel0.m: -------------------------------------------------------------------------------- 1 | #ifndef N 2 | #error -DN=n missing 3 | #endif 4 | 5 | #import 6 | #include 7 | #include 8 | #include 9 | #include "test.h" 10 | extern atomic_int state; 11 | 12 | #define CLASS0(n,nn) \ 13 | OBJC_ROOT_CLASS \ 14 | @interface C_##n##_##nn @end \ 15 | @implementation C_##n##_##nn \ 16 | +(void)load { \ 17 | atomic_fetch_add_explicit(&state, 1, memory_order_relaxed); \ 18 | usleep(10); } \ 19 | @end 20 | 21 | #define CLASS(n,nn) CLASS0(n,nn) 22 | 23 | CLASS(a,N) 24 | CLASS(b,N) 25 | CLASS(c,N) 26 | CLASS(d,N) 27 | CLASS(e,N) 28 | CLASS(f,N) 29 | CLASS(g,N) 30 | CLASS(h,N) 31 | CLASS(i,N) 32 | CLASS(j,N) 33 | CLASS(k,N) 34 | CLASS(l,N) 35 | CLASS(m,N) 36 | CLASS(n,N) 37 | CLASS(o,N) 38 | CLASS(p,N) 39 | CLASS(q,N) 40 | CLASS(r,N) 41 | CLASS(s,N) 42 | CLASS(t,N) 43 | CLASS(u,N) 44 | CLASS(v,N) 45 | CLASS(w,N) 46 | CLASS(x,N) 47 | CLASS(y,N) 48 | CLASS(z,N) 49 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/load-parallel00.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | atomic_int state; 3 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/load-reentrant.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/load-reentrant.m -o load-reentrant.exe 4 | $C{COMPILE} $DIR/load-reentrant2.m -o libload-reentrant2.dylib -bundle -bundle_loader load-reentrant.exe 5 | END 6 | */ 7 | 8 | #include "test.h" 9 | #include 10 | 11 | int state1 = 0; 12 | int *state2_p; 13 | 14 | OBJC_ROOT_CLASS 15 | @interface One @end 16 | @implementation One 17 | +(void)load 18 | { 19 | state1 = 111; 20 | 21 | // Re-entrant +load doesn't get to complete until we do 22 | void *dlh = dlopen("libload-reentrant2.dylib", RTLD_LAZY); 23 | testassert(dlh); 24 | state2_p = (int *)dlsym(dlh, "state2"); 25 | testassert(state2_p); 26 | testassert(*state2_p == 0); 27 | 28 | state1 = 1; 29 | } 30 | @end 31 | 32 | int main() 33 | { 34 | testassert(state1 == 1 && state2_p && *state2_p == 2); 35 | succeed(__FILE__); 36 | } 37 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/load-reentrant2.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | int state2 = 0; 4 | extern int state1; 5 | 6 | static void ctor(void) __attribute__((constructor)); 7 | static void ctor(void) 8 | { 9 | // should be called during One's dlopen(), before Two's +load 10 | testassert(state1 == 111); 11 | testassert(state2 == 0); 12 | } 13 | 14 | OBJC_ROOT_CLASS 15 | @interface Two @end 16 | @implementation Two 17 | +(void) load 18 | { 19 | // Does not run until One's +load completes 20 | testassert(state1 == 1); 21 | state2 = 2; 22 | } 23 | @end 24 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/nilAPIArgs.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD_OUTPUT 3 | .*nilAPIArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\] 4 | .*nilAPIArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\] 5 | END 6 | */ 7 | 8 | #include "test.h" 9 | 10 | #import 11 | 12 | int main() { 13 | // ensure various bits of API don't crash when tossed nil parameters 14 | class_conformsToProtocol(nil, nil); 15 | method_setImplementation(nil, NULL); 16 | 17 | succeed(__FILE__); 18 | } 19 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/nscdtors.mm: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | // test cdtors, with NSObject instead of TestRoot as the root class 3 | 4 | #define USE_FOUNDATION 1 5 | #include "cdtors.mm" 6 | 7 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/nsexc.m: -------------------------------------------------------------------------------- 1 | /* 2 | need exception-safe ARC for exception deallocation tests 3 | TEST_CFLAGS -fobjc-arc-exceptions -framework Foundation 4 | */ 5 | 6 | #define USE_FOUNDATION 1 7 | #include "exc.m" 8 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/nsprotocol.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include 5 | 6 | int main() 7 | { 8 | // Class Protocol is always a subclass of NSObject 9 | 10 | testassert(objc_getClass("NSObject")); 11 | 12 | Class cls = objc_getClass("Protocol"); 13 | testassert(class_getInstanceMethod(cls, sel_registerName("isProxy"))); 14 | testassert(class_getSuperclass(cls) == objc_getClass("NSObject")); 15 | 16 | succeed(__FILE__); 17 | } 18 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/objectCopy.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG MEM=mrc 2 | 3 | #include "test.h" 4 | #include 5 | 6 | @interface Test : NSObject { 7 | @public 8 | char bytes[32-sizeof(void*)]; 9 | } 10 | @end 11 | @implementation Test 12 | @end 13 | 14 | 15 | int main() 16 | { 17 | Test *o0 = [Test new]; 18 | [o0 retain]; 19 | Test *o1 = class_createInstance([Test class], 32); 20 | [o1 retain]; 21 | id o2 = object_copy(o0, 0); 22 | id o3 = object_copy(o1, 0); 23 | id o4 = object_copy(o1, 32); 24 | 25 | testassert(malloc_size(o0) == 32); 26 | testassert(malloc_size(o1) == 64); 27 | testassert(malloc_size(o2) == 32); 28 | testassert(malloc_size(o3) == 32); 29 | testassert(malloc_size(o4) == 64); 30 | 31 | testassert([o0 retainCount] == 2); 32 | testassert([o1 retainCount] == 2); 33 | testassert([o2 retainCount] == 1); 34 | testassert([o3 retainCount] == 1); 35 | testassert([o4 retainCount] == 1); 36 | 37 | succeed(__FILE__); 38 | } 39 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/preopt-caches.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.springboard-ui.client 6 | 7 | com.apple.security.system-groups 8 | 9 | systemgroup.com.apple.powerlog 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/rawisa.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_CFLAGS -Xlinker -sectcreate -Xlinker __DATA -Xlinker __objc_rawisa -Xlinker /dev/null 3 | TEST_ENV OBJC_PRINT_RAW_ISA=YES 4 | 5 | TEST_RUN_OUTPUT 6 | objc\[\d+\]: RAW ISA: disabling non-pointer isa because the app has a __DATA,__objc_rawisa section 7 | (.* RAW ISA: .*\n)* 8 | OK: rawisa.m(\n.* RAW ISA: .*)* 9 | OR 10 | (.* RAW ISA: .*\n)* 11 | no __DATA,__rawisa support 12 | OK: rawisa.m(\n.* RAW ISA: .*)* 13 | END 14 | 15 | "RAW ISA" is allowed after "OK" because of static destructors 16 | that provoke class realization. 17 | */ 18 | 19 | #include "test.h" 20 | 21 | int main() 22 | { 23 | fprintf(stderr, "\n"); 24 | #if ! (SUPPORT_NONPOINTER_ISA && TARGET_OS_OSX) 25 | // only 64-bit Mac supports this 26 | fprintf(stderr, "no __DATA,__rawisa support\n"); 27 | #endif 28 | succeed(__FILE__); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/realizedClassGenerationCount.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | 6 | #include 7 | 8 | extern uintptr_t objc_debug_realized_class_generation_count; 9 | 10 | int main() 11 | { 12 | testassert(objc_debug_realized_class_generation_count > 0); 13 | uintptr_t prev = objc_debug_realized_class_generation_count; 14 | 15 | void *handle = dlopen("/System/Library/Frameworks/Foundation.framework/Foundation", RTLD_LAZY); 16 | testassert(handle); 17 | Class c = objc_getClass("NSFileManager"); 18 | testassert(c); 19 | testassert(objc_debug_realized_class_generation_count > prev); 20 | 21 | prev = objc_debug_realized_class_generation_count; 22 | c = objc_allocateClassPair([TestRoot class], "Dynamic", 0); 23 | testassert(objc_debug_realized_class_generation_count > prev); 24 | prev = objc_debug_realized_class_generation_count; 25 | objc_registerClassPair(c); 26 | testassert(objc_debug_realized_class_generation_count == prev); 27 | 28 | succeed(__FILE__); 29 | } -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/release-workaround.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG ARCH=x86_64 MEM=mrc 2 | // TEST_CFLAGS -framework Foundation 3 | 4 | // rdar://20206767 5 | 6 | #include 7 | #include "test.h" 8 | 9 | 10 | @interface Test : NSObject @end 11 | @implementation Test 12 | @end 13 | 14 | 15 | int main() 16 | { 17 | id buf[1]; 18 | buf[0] = [Test class]; 19 | id obj = (id)buf; 20 | [obj retain]; 21 | [obj retain]; 22 | 23 | uintptr_t rax; 24 | 25 | [obj release]; 26 | asm("mov %%rax, %0" : "=r" (rax)); 27 | testassert(rax == 0); 28 | 29 | objc_release(obj); 30 | asm("mov %%rax, %0" : "=r" (rax)); 31 | testassert(rax == 0); 32 | 33 | succeed(__FILE__); 34 | } 35 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/rr-autorelease-stacklogging.m: -------------------------------------------------------------------------------- 1 | // Test OBJC_DEBUG_POOL_ALLOCATION (which is also enabled by MallocStackLogging) 2 | 3 | // TEST_ENV OBJC_DEBUG_POOL_ALLOCATION=YES 4 | // TEST_CFLAGS -framework Foundation 5 | // TEST_CONFIG MEM=mrc 6 | 7 | #include "test.h" 8 | 9 | #define FOUNDATION 0 10 | #define NAME "rr-autorelease-stacklogging" 11 | #define DEBUG_POOL_ALLOCATION 1 12 | 13 | #include "rr-autorelease2.m" 14 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/rr-autorelease.m: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -framework Foundation 2 | // TEST_CONFIG MEM=mrc 3 | 4 | #include "test.h" 5 | 6 | #define FOUNDATION 0 7 | #define NAME "rr-autorelease" 8 | 9 | #include "rr-autorelease2.m" 10 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/rr-nsautorelease.m: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -framework Foundation 2 | // TEST_CONFIG MEM=mrc 3 | 4 | #define FOUNDATION 1 5 | #define NAME "rr-nsautorelease" 6 | 7 | #include "rr-autorelease2.m" 8 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/sel.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD_OUTPUT 3 | .*sel.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'testassert')? 4 | END 5 | */ 6 | 7 | #include "test.h" 8 | #include 9 | #include 10 | #include 11 | 12 | int main() 13 | { 14 | // Make sure @selector values are correctly fixed up 15 | testassert(@selector(foo) == sel_registerName("foo")); 16 | 17 | // sel_getName recognizes the zero SEL 18 | testassert(0 == strcmp("", sel_getName(0))); 19 | 20 | succeed(__FILE__); 21 | } 22 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/setAssociatedObjectHook.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_CONFIG MEM=mrc 3 | TEST_ENV OBJC_DISABLE_NONPOINTER_ISA=YES 4 | */ 5 | 6 | #include "test.h" 7 | #include "testroot.i" 8 | 9 | bool hasAssociations = false; 10 | 11 | @interface TestRoot (AssocHooks) 12 | @end 13 | 14 | @implementation TestRoot (AssocHooks) 15 | 16 | - (void)_noteAssociatedObjects { 17 | hasAssociations = true; 18 | } 19 | 20 | // -_noteAssociatedObjects is currently limited to raw-isa custom-rr to avoid overhead 21 | - (void) release { 22 | } 23 | 24 | @end 25 | 26 | int main() { 27 | id obj = [TestRoot new]; 28 | id value = [TestRoot new]; 29 | const void *key = "key"; 30 | objc_setAssociatedObject(obj, key, value, OBJC_ASSOCIATION_RETAIN); 31 | testassert(hasAssociations == true); 32 | 33 | id out = objc_getAssociatedObject(obj, key); 34 | testassert(out == value); 35 | 36 | hasAssociations = false; 37 | key = "key2"; 38 | objc_setAssociatedObject(obj, key, value, OBJC_ASSOCIATION_RETAIN); 39 | testassert(hasAssociations == false); //only called once 40 | 41 | 42 | out = objc_getAssociatedObject(obj, key); 43 | testassert(out == value); 44 | 45 | succeed(__FILE__); 46 | } 47 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/setSuper.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | #include 6 | 7 | @interface Super1 : TestRoot @end 8 | @implementation Super1 9 | +(int)classMethod { return 1; } 10 | -(int)instanceMethod { return 10000; } 11 | @end 12 | 13 | @interface Super2 : TestRoot @end 14 | @implementation Super2 15 | +(int)classMethod { return 2; } 16 | -(int)instanceMethod { return 20000; } 17 | @end 18 | 19 | @interface Sub : Super1 @end 20 | @implementation Sub 21 | +(int)classMethod { return [super classMethod] + 100; } 22 | -(int)instanceMethod { 23 | return [super instanceMethod] + 1000000; 24 | } 25 | @end 26 | 27 | int main() 28 | { 29 | Class cls; 30 | Sub *obj = [Sub new]; 31 | 32 | testassert(101 == [[Sub class] classMethod]); 33 | testassert(1010000 == [obj instanceMethod]); 34 | 35 | cls = class_setSuperclass([Sub class], [Super2 class]); 36 | 37 | testassert(cls == [Super1 class]); 38 | testassert(object_getClass(cls) == object_getClass([Super1 class])); 39 | 40 | testassert(102 == [[Sub class] classMethod]); 41 | testassert(1020000 == [obj instanceMethod]); 42 | 43 | succeed(__FILE__); 44 | } 45 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/super.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | #include 6 | 7 | @interface Sub : TestRoot @end 8 | @implementation Sub @end 9 | 10 | int main() 11 | { 12 | // [super ...] messages are tested in msgSend.m 13 | 14 | testassert(class_getSuperclass([Sub class]) == [TestRoot class]); 15 | testassert(class_getSuperclass(object_getClass([Sub class])) == object_getClass([TestRoot class])); 16 | testassert(class_getSuperclass([TestRoot class]) == Nil); 17 | testassert(class_getSuperclass(object_getClass([TestRoot class])) == [TestRoot class]); 18 | testassert(class_getSuperclass(Nil) == Nil); 19 | 20 | succeed(__FILE__); 21 | } 22 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/taggedPointersDisabled.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_ENV OBJC_DISABLE_TAGGED_POINTERS=YES 3 | TEST_CRASHES 4 | 5 | TEST_BUILD_OUTPUT 6 | .*taggedPointersDisabled.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\] 7 | END 8 | 9 | TEST_RUN_OUTPUT 10 | objc\[\d+\]: tagged pointers are disabled 11 | objc\[\d+\]: HALTED 12 | OR 13 | OK: taggedPointersDisabled.m 14 | END 15 | */ 16 | 17 | #include "test.h" 18 | #include 19 | 20 | #if !OBJC_HAVE_TAGGED_POINTERS 21 | 22 | int main() 23 | { 24 | // provoke the same nullability warning as the real test 25 | objc_getClass(nil); 26 | 27 | succeed(__FILE__); 28 | } 29 | 30 | #else 31 | 32 | int main() 33 | { 34 | testassert(!_objc_taggedPointersEnabled()); 35 | _objc_registerTaggedPointerClass((objc_tag_index_t)0, nil); 36 | fail("should have crashed in _objc_registerTaggedPointerClass()"); 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/taggedPointersTagObfuscationDisabled.m: -------------------------------------------------------------------------------- 1 | // TEST_ENV OBJC_DISABLE_TAG_OBFUSCATION=YES 2 | 3 | #include "test.h" 4 | #include 5 | 6 | #if !OBJC_HAVE_TAGGED_POINTERS 7 | 8 | int main() 9 | { 10 | succeed(__FILE__); 11 | } 12 | 13 | #else 14 | 15 | int main() 16 | { 17 | #if OBJC_SPLIT_TAGGED_POINTERS 18 | void *obj = (void *)0; 19 | #else 20 | void *obj = (void *)1; 21 | #endif 22 | 23 | testassert(_objc_getTaggedPointerTag(obj) == 0); 24 | succeed(__FILE__); 25 | } 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/tbi.c: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG OS=iphoneos ARCH=arm64 2 | 3 | #include "test.h" 4 | 5 | #ifndef __arm64__ 6 | #error wrong architecture for TBI hardware feature 7 | #endif 8 | 9 | volatile int x = 123456; 10 | 11 | int main(void) { 12 | testassert(*(int *)((unsigned long)&x | 0xFF00000000000000ul) == 123456); 13 | succeed(__FILE__); 14 | } 15 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/test-defines.h: -------------------------------------------------------------------------------- 1 | #define TEST_OVERRIDES_NEW 1 2 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/timeout.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | use strict; 4 | 5 | my $usage = "timeout \n"; 6 | my $timeout = shift || die $usage; 7 | alarm($timeout); 8 | exec @ARGV; 9 | die "exec failed: @ARGV"; 10 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/unload.h: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | @interface SmallClass : TestRoot @end 4 | 5 | @interface BigClass : TestRoot @end 6 | 7 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/unload3.c: -------------------------------------------------------------------------------- 1 | // unload3: contains imageinfo but no other objc metadata 2 | // libobjc must not keep it open 3 | 4 | #include 5 | 6 | int fake[2] __attribute__((section("__DATA,__objc_imageinfo"))) 7 | = { 0, TARGET_OS_SIMULATOR ? (1<<5) : 0 }; 8 | 9 | // silence "no debug symbols in executable" warning 10 | void fn(void) { } 11 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/unload4.m: -------------------------------------------------------------------------------- 1 | // unload4: contains some objc metadata other than imageinfo 2 | // libobjc must keep it open 3 | 4 | int fake2 __attribute__((section("__DATA,__objc_foo"))) = 0; 5 | 6 | // getsectiondata() falls over if __TEXT has no contents 7 | const char *unload4 = "unload4"; 8 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/weakReferenceHook.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_CONFIG MEM=mrc 3 | TEST_ENV OBJC_DISABLE_NONPOINTER_ISA=YES 4 | */ 5 | 6 | #include "test.h" 7 | #include "testroot.i" 8 | 9 | bool hasWeakRefs = false; 10 | 11 | @interface TestRoot (WeakHooks) 12 | @end 13 | 14 | @implementation TestRoot (WeakHooks) 15 | 16 | - (void)_setWeaklyReferenced { 17 | hasWeakRefs = true; 18 | } 19 | 20 | // -_setWeaklyReferenced is currently limited to raw-isa custom-rr to avoid overhead 21 | - (void) release { 22 | } 23 | 24 | @end 25 | 26 | int main() { 27 | id obj = [TestRoot new]; 28 | id wobj = nil; 29 | objc_storeWeak(&wobj, obj); 30 | testassert(hasWeakRefs == true); 31 | 32 | id out = objc_loadWeak(&wobj); 33 | testassert(out == obj); 34 | 35 | objc_storeWeak(&wobj, nil); 36 | out = objc_loadWeak(&wobj); 37 | testassert(out == nil); 38 | 39 | hasWeakRefs = false; 40 | objc_storeWeak(&wobj, obj); 41 | testassert(hasWeakRefs == true); 42 | 43 | 44 | out = objc_loadWeak(&wobj); 45 | testassert(out == obj); 46 | objc_storeWeak(&wobj, nil); 47 | 48 | succeed(__FILE__); 49 | } 50 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/weakframework-missing.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/weak2.m -DWEAK_FRAMEWORK=1 -DWEAK_IMPORT= -UEMPTY -dynamiclib -o libweakframework.dylib 4 | 5 | $C{COMPILE} $DIR/weakframework-missing.m -L. -weak-lweakframework -o weakframework-missing.exe 6 | 7 | $C{COMPILE} $DIR/weak2.m -DWEAK_FRAMEWORK=1 -DWEAK_IMPORT= -DEMPTY= -dynamiclib -o libweakframework.dylib 8 | 9 | END 10 | */ 11 | 12 | #define WEAK_FRAMEWORK 1 13 | #define WEAK_IMPORT 14 | #include "weak.m" 15 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/weakframework-not-missing.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/weak2.m -DWEAK_FRAMEWORK=1 -DWEAK_IMPORT= -UEMPTY -dynamiclib -o libweakframework.dylib 4 | 5 | $C{COMPILE} $DIR/weakframework-not-missing.m -L. -weak-lweakframework -o weakframework-not-missing.exe 6 | END 7 | */ 8 | 9 | #define WEAK_FRAMEWORK 1 10 | #define WEAK_IMPORT 11 | #include "weak.m" 12 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/weakimport-missing.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/weak2.m -UWEAK_FRAMEWORK -DWEAK_IMPORT=__attribute__\\(\\(weak_import\\)\\) -UEMPTY -dynamiclib -o libweakimport.dylib 4 | 5 | $C{COMPILE} $DIR/weakimport-missing.m -L. -weak-lweakimport -o weakimport-missing.exe 6 | 7 | $C{COMPILE} $DIR/weak2.m -UWEAK_FRAMEWORK -DWEAK_IMPORT=__attribute__\\(\\(weak_import\\)\\) -DEMPTY= -dynamiclib -o libweakimport.dylib 8 | END 9 | */ 10 | 11 | // #define WEAK_FRAMEWORK 12 | #define WEAK_IMPORT __attribute__((weak_import)) 13 | #include "weak.m" 14 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/test/weakimport-not-missing.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/weak2.m -UWEAK_FRAMEWORK -DWEAK_IMPORT=__attribute__\\(\\(weak_import\\)\\) -UEMPTY -dynamiclib -o libweakimport.dylib 4 | 5 | $C{COMPILE} $DIR/weakimport-not-missing.m -L. -weak-lweakimport -o weakimport-not-missing.exe 6 | END 7 | */ 8 | 9 | // #define WEAK_FRAMEWORK 10 | #define WEAK_IMPORT __attribute__((weak_import)) 11 | #include "weak.m" 12 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/unexported_symbols: -------------------------------------------------------------------------------- 1 | .objc_class_name___IncompleteProtocol 2 | __Znam 3 | __ZnamRKSt9nothrow_t 4 | __Znwm 5 | __ZnwmRKSt9nothrow_t 6 | __ZdaPv 7 | __ZdaPvRKSt9nothrow_t 8 | __ZdlPv 9 | __ZdlPvRKSt9nothrow_t 10 | __ZTISt9bad_alloc 11 | __ZTISt9exception 12 | __ZTISt11logic_error 13 | __ZTISt12length_error 14 | __ZTSSt9bad_alloc 15 | __ZTSSt9exception 16 | __ZTSSt11logic_error 17 | __ZTSSt12length_error 18 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/version.bat: -------------------------------------------------------------------------------- 1 | :: version.bat 2 | :: Writes version numbers from B&I into version.h for use by version.rc. 3 | 4 | @ECHO OFF 5 | 6 | :: Set default values for environment variables if not set by B&I 7 | IF "%OBJROOT%"=="" SET OBJROOT=. 8 | IF "%RC_PROJECTSOURCEVERSION%"=="" SET RC_PROJECTSOURCEVERSION=0.0 9 | IF "%RC_PROJECTBUILDVERSION%"=="" SET RC_PROJECTBUILDVERSION=0 10 | 11 | :: Get version numbers from environment variables 12 | SET major=1 13 | SET patch=0 14 | FOR /F "tokens=1* eol= delims=." %%i IN ("%RC_PROJECTSOURCEVERSION%") DO ( 15 | SET minor=%%i 16 | IF NOT "%%j"=="" SET patch=%%j 17 | ) 18 | SET build=%RC_PROJECTBUILDVERSION% 19 | 20 | ECHO version %major% . %minor% . %patch% . %build% 21 | 22 | :: Write version.h 23 | ECHO // This file is automatically generated by version.bat. > "%OBJROOT%\version.h" 24 | ECHO // DO NOT EDIT >> "%OBJROOT%\version.h" 25 | ECHO #define major %major% >> "%OBJROOT%\version.h" 26 | ECHO #define minor %minor% >> "%OBJROOT%\version.h" 27 | ECHO #define patch %patch% >> "%OBJROOT%\version.h" 28 | ECHO #define build %build% >> "%OBJROOT%\version.h" 29 | ECHO #define string "%major%,%minor%,%patch%,%build%" >> "%OBJROOT%\version.h" 30 | -------------------------------------------------------------------------------- /debugableruntime/objc4-818.2/version.rc: -------------------------------------------------------------------------------- 1 | #include "Winver.h" 2 | 3 | // built by version.bat; sets variables major, minor, patch, build, string 4 | #include "version.h" 5 | 6 | VS_VERSION_INFO VERSIONINFO 7 | FILEVERSION major,minor,patch,build 8 | PRODUCTVERSION major,minor,patch,build 9 | FILEFLAGSMASK 0x17L 10 | #ifdef _DEBUG 11 | FILEFLAGS VS_FF_DEBUG 12 | #else 13 | FILEFLAGS 0x0L 14 | #endif 15 | FILEOS VOS_NT_WINDOWS32 16 | FILETYPE VFT_DLL 17 | FILESUBTYPE VFT2_UNKNOWN 18 | BEGIN 19 | BLOCK "StringFileInfo" 20 | BEGIN 21 | BLOCK "040904b0" 22 | BEGIN 23 | VALUE "CompanyName", "Apple Inc." 24 | VALUE "FileDescription", "Objective-C Runtime Library" 25 | VALUE "FileVersion", string 26 | VALUE "ProductVersion", string 27 | VALUE "ProductName", "objc4" 28 | VALUE "InternalName", "objc4" 29 | VALUE "LegalCopyright", "Copyright (C) 2007-2009, Apple Inc." 30 | VALUE "OriginalFilename", "objc.dll" 31 | END 32 | END 33 | BLOCK "VarFileInfo" 34 | BEGIN 35 | VALUE "Translation", 0x409, 1200 36 | END 37 | END 38 | 39 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/interposable.txt: -------------------------------------------------------------------------------- 1 | _objc_release 2 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/objc.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/objc.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/objc4.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | preoptimizedCaches 6 | 7 | Enabled 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/objc_test/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // objc_test 4 | // 5 | // Created by Yi Wang on 2022/4/29. 6 | // 7 | 8 | #import 9 | 10 | int main(int argc, const char * argv[]) { 11 | @autoreleasepool { 12 | // insert code here... 13 | NSObject *obj = [[NSObject alloc] init]; 14 | } 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/objcdt/objcdt-entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | task_for_pid-allow 6 | 7 | com.apple.system-task-ports 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/objcdt/objcdt.1: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 2019, Apple Computer, Inc. All rights reserved. 2 | .\" 3 | .Dd September 9, 2019 \" DATE 4 | .Dt objcdt 1 \" Program name and manual section number 5 | .Os "OS X" 6 | .Sh NAME 7 | .Nm objcdt 8 | .Nd Tool to debug objective-C usage in live processes 9 | .Sh SYNOPSIS 10 | .Nm objcdt 11 | .Sh DESCRIPTION 12 | The 13 | .Nm 14 | utility is a small CLI with embedded help that can dump some information about 15 | the Objective-C runtime state in live processes. 16 | .Pp 17 | Help can be obtained using 18 | .Nm 19 | .Ar help 20 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/prebuild.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | echo prebuild: installing headers 4 | xcopy /Y "%ProjectDir%runtime\objc.h" "%DSTROOT%\AppleInternal\include\objc\" 5 | xcopy /Y "%ProjectDir%runtime\objc-api.h" "%DSTROOT%\AppleInternal\include\objc\" 6 | xcopy /Y "%ProjectDir%runtime\objc-auto.h" "%DSTROOT%\AppleInternal\include\objc\" 7 | xcopy /Y "%ProjectDir%runtime\objc-exception.h" "%DSTROOT%\AppleInternal\include\objc\" 8 | xcopy /Y "%ProjectDir%runtime\message.h" "%DSTROOT%\AppleInternal\include\objc\" 9 | xcopy /Y "%ProjectDir%runtime\runtime.h" "%DSTROOT%\AppleInternal\include\objc\" 10 | xcopy /Y "%ProjectDir%runtime\hashtable.h" "%DSTROOT%\AppleInternal\include\objc\" 11 | xcopy /Y "%ProjectDir%runtime\hashtable2.h" "%DSTROOT%\AppleInternal\include\objc\" 12 | xcopy /Y "%ProjectDir%runtime\maptable.h" "%DSTROOT%\AppleInternal\include\objc\" 13 | 14 | echo prebuild: setting version 15 | version 16 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/runtime/Module/module.modulemap: -------------------------------------------------------------------------------- 1 | module ObjectiveC [system] [extern_c] { 2 | umbrella "." 3 | export * 4 | module * { 5 | export * 6 | } 7 | 8 | module NSObject { 9 | requires objc 10 | header "NSObject.h" 11 | export * 12 | } 13 | 14 | #if defined(BUILD_FOR_OSX) 15 | module List { 16 | // Uses @defs, which does not work in ObjC++ or non-ARC. 17 | requires objc, !objc_arc, !cplusplus 18 | header "List.h" 19 | export * 20 | } 21 | 22 | module Object { 23 | requires objc 24 | header "Object.h" 25 | export * 26 | } 27 | 28 | module Protocol { 29 | requires objc 30 | header "Protocol.h" 31 | export * 32 | } 33 | #endif 34 | 35 | #if !defined(BUILD_FOR_OSX) 36 | // These file are not available outside macOS. 37 | exclude header "hashtable.h" 38 | exclude header "hashtable2.h" 39 | #endif 40 | } 41 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/runtime/ModulePrivate/module.modulemap: -------------------------------------------------------------------------------- 1 | module ObjectiveC_Private [system] { 2 | umbrella "." 3 | explicit module * { export * } 4 | } 5 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/runtime/NSObjCRuntime.h: -------------------------------------------------------------------------------- 1 | /* NSObjCRuntime.h 2 | Copyright (c) 1994-2012, Apple Inc. All rights reserved. 3 | */ 4 | 5 | #ifndef _OBJC_NSOBJCRUNTIME_H_ 6 | #define _OBJC_NSOBJCRUNTIME_H_ 7 | 8 | #include 9 | #include 10 | 11 | #if __LP64__ || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64 12 | typedef long NSInteger; 13 | typedef unsigned long NSUInteger; 14 | #else 15 | typedef int NSInteger; 16 | typedef unsigned int NSUInteger; 17 | #endif 18 | 19 | #define NSIntegerMax LONG_MAX 20 | #define NSIntegerMin LONG_MIN 21 | #define NSUIntegerMax ULONG_MAX 22 | 23 | #define NSINTEGER_DEFINED 1 24 | 25 | #ifndef NS_DESIGNATED_INITIALIZER 26 | #if __has_attribute(objc_designated_initializer) 27 | #define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) 28 | #else 29 | #define NS_DESIGNATED_INITIALIZER 30 | #endif 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/runtime/hashtable.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/runtime/objc-class.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/runtime/objc-probes.d: -------------------------------------------------------------------------------- 1 | provider objc_runtime 2 | { 3 | probe objc_exception_throw(void *id); 4 | probe objc_exception_rethrow(); 5 | }; 6 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/runtime/objc-runtime.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/runtime/objcrt.h: -------------------------------------------------------------------------------- 1 | #ifndef _OBJC_RT_H_ 2 | #define _OBJC_RT_H_ 3 | 4 | #include 5 | 6 | 7 | typedef struct { 8 | int count; // number of pointer pairs that follow 9 | void *modStart; 10 | void *modEnd; 11 | void *protoStart; 12 | void *protoEnd; 13 | void *iiStart; 14 | void *iiEnd; 15 | void *selrefsStart; 16 | void *selrefsEnd; 17 | void *clsrefsStart; 18 | void *clsrefsEnd; 19 | } objc_sections; 20 | 21 | OBJC_EXPORT void *_objc_init_image(HMODULE image, const objc_sections *sects); 22 | OBJC_EXPORT void _objc_load_image(HMODULE image, void *hinfo); 23 | OBJC_EXPORT void _objc_unload_image(HMODULE image, void *hinfo); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/ARCBase.h: -------------------------------------------------------------------------------- 1 | // 2 | // ARCBase.h 3 | // TestARCLayouts 4 | // 5 | // Created by Patrick Beard on 3/8/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ARCMisalign : NSObject { 12 | char misalign1; 13 | } 14 | @end 15 | 16 | @interface ARCBase : ARCMisalign 17 | @property long number; 18 | @property(retain) id object; 19 | @property void *pointer; 20 | @property(weak) __weak id delegate; 21 | @end 22 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/ARCBase.m: -------------------------------------------------------------------------------- 1 | // 2 | // ARCBase.m 3 | // TestARCLayouts 4 | // 5 | // Created by Patrick Beard on 3/8/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "ARCBase.h" 10 | 11 | // ARCMisalign->misalign1 and ARCBase->misalign2 together cause 12 | // ARCBase's instanceStart to be misaligned, which exercises handling 13 | // of storage that is not represented in the class's ivar layout bitmaps. 14 | 15 | @implementation ARCMisalign 16 | @end 17 | 18 | @interface ARCBase () { 19 | @private 20 | char misalign2; 21 | long number; 22 | id object; 23 | void *pointer; 24 | __weak id delegate; 25 | } 26 | @end 27 | 28 | @implementation ARCBase 29 | @synthesize number, object, pointer, delegate; 30 | @end 31 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/ARCLayoutsWithoutWeak.m: -------------------------------------------------------------------------------- 1 | // Same as test ARCLayouts but with MRC __weak support disabled. 2 | /* 3 | TEST_CONFIG MEM=arc 4 | TEST_BUILD 5 | mkdir -p $T{OBJDIR} 6 | $C{COMPILE_NOLINK_NOMEM} -c $DIR/MRCBase.m -o $T{OBJDIR}/MRCBase.o -fno-objc-weak 7 | $C{COMPILE_NOLINK_NOMEM} -c $DIR/MRCARC.m -o $T{OBJDIR}/MRCARC.o -fno-objc-weak 8 | $C{COMPILE_NOLINK} -c $DIR/ARCBase.m -o $T{OBJDIR}/ARCBase.o 9 | $C{COMPILE_NOLINK} -c $DIR/ARCMRC.m -o $T{OBJDIR}/ARCMRC.o 10 | $C{COMPILE} '-DNAME=\"ARCLayoutsWithoutWeak.m\"' -fobjc-arc $DIR/ARCLayouts.m -x none $T{OBJDIR}/MRCBase.o $T{OBJDIR}/MRCARC.o $T{OBJDIR}/ARCBase.o $T{OBJDIR}/ARCMRC.o -framework Foundation -o ARCLayoutsWithoutWeak.exe 11 | END 12 | */ 13 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/ARCMRC.h: -------------------------------------------------------------------------------- 1 | // 2 | // ARCMRC.h 3 | // TestARCLayouts 4 | // 5 | // Created by Patrick Beard on 3/8/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "MRCBase.h" 10 | 11 | @interface ARCMRC : MRCBase 12 | @property(retain) id dataSource; 13 | @end 14 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/ARCMRC.m: -------------------------------------------------------------------------------- 1 | // 2 | // ARCMRC.m 3 | // 4 | 5 | #import "ARCMRC.h" 6 | 7 | @implementation ARCMRC 8 | 9 | @synthesize dataSource; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/MRCARC.h: -------------------------------------------------------------------------------- 1 | // 2 | // MRCARC.h 3 | // TestARCLayouts 4 | // 5 | // Created by Patrick Beard on 3/8/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "ARCBase.h" 10 | 11 | @interface MRCARC : ARCBase 12 | @property(retain) id dataSource; 13 | @end 14 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/MRCARC.m: -------------------------------------------------------------------------------- 1 | // 2 | // MRCARC.m 3 | // 4 | 5 | #import "MRCARC.h" 6 | 7 | @implementation MRCARC 8 | 9 | @synthesize dataSource; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/MRCBase.h: -------------------------------------------------------------------------------- 1 | // 2 | // MRCBase.h 3 | // TestARCLayouts 4 | // 5 | // Created by Patrick Beard on 3/8/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // YES if MRC compiler supports ARC-style weak 12 | extern bool supportsMRCWeak; 13 | 14 | #if __LP64__ 15 | #define DOUBLEWORD_ALIGNED __attribute__((aligned(16))) 16 | #else 17 | #define DOUBLEWORD_ALIGNED __attribute__((aligned(8))) 18 | #endif 19 | 20 | @interface MRCBase : NSObject 21 | @property double number; 22 | @property(retain) id object; 23 | @property void *pointer; 24 | @property(weak) __weak id delegate; 25 | @end 26 | 27 | // Call object_copy from MRC. 28 | extern id __attribute__((ns_returns_retained)) docopy(id obj); 29 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/MRCBase.m: -------------------------------------------------------------------------------- 1 | // 2 | // MRCBase.m 3 | // TestARCLayouts 4 | // 5 | // Created by Patrick Beard on 3/8/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #include "MRCBase.h" 10 | #include "test.h" 11 | 12 | // MRCBase->alignment ensures that there is a gap between the end of 13 | // NSObject's ivars and the start of MRCBase's ivars, which exercises 14 | // handling of storage that is not represented in any class's ivar 15 | // layout bitmaps. 16 | 17 | #if __has_feature(objc_arc_weak) 18 | bool supportsMRCWeak = true; 19 | #else 20 | bool supportsMRCWeak = false; 21 | #endif 22 | 23 | @interface MRCBase () { 24 | @private 25 | double DOUBLEWORD_ALIGNED alignment; 26 | uintptr_t pad[3]; // historically this made OBJC2 layout bitmaps match OBJC1 27 | double number; 28 | id object; 29 | void *pointer; 30 | #if __has_feature(objc_arc_weak) 31 | __weak 32 | #endif 33 | id delegate; 34 | } 35 | @end 36 | 37 | @implementation MRCBase 38 | @synthesize number, object, pointer, delegate; 39 | @end 40 | 41 | // Call object_copy from MRC. 42 | extern id __attribute__((ns_returns_retained)) 43 | docopy(id obj) 44 | { 45 | return object_copy(obj, 0); 46 | } 47 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/applescriptobjc.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG OS=macosx 2 | // TEST_CFLAGS -framework AppleScriptObjC -framework Foundation 3 | 4 | // Verify that trivial AppleScriptObjC apps run with GC off. 5 | 6 | #include 7 | #include "test.h" 8 | 9 | int main() 10 | { 11 | [NSBundle class]; 12 | succeed(__FILE__); 13 | } 14 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/arr-cast.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | 5 | // objc.h redefines these calls into bridge casts. 6 | // This test verifies that the function implementations are exported. 7 | __BEGIN_DECLS 8 | extern void *retainedObject(void *arg) __asm__("_objc_retainedObject"); 9 | extern void *unretainedObject(void *arg) __asm__("_objc_unretainedObject"); 10 | extern void *unretainedPointer(void *arg) __asm__("_objc_unretainedPointer"); 11 | __END_DECLS 12 | 13 | int main() 14 | { 15 | void *p = (void*)&main; 16 | testassert(p == retainedObject(p)); 17 | testassert(p == unretainedObject(p)); 18 | testassert(p == unretainedPointer(p)); 19 | succeed(__FILE__); 20 | } 21 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/asm-placeholder.s: -------------------------------------------------------------------------------- 1 | .macro NOP16 2 | nop 3 | nop 4 | nop 5 | nop 6 | nop 7 | nop 8 | nop 9 | nop 10 | nop 11 | nop 12 | nop 13 | nop 14 | nop 15 | nop 16 | nop 17 | nop 18 | .endmacro 19 | 20 | .macro NOP256 21 | NOP16 22 | NOP16 23 | NOP16 24 | NOP16 25 | NOP16 26 | NOP16 27 | NOP16 28 | NOP16 29 | NOP16 30 | NOP16 31 | NOP16 32 | NOP16 33 | NOP16 34 | NOP16 35 | NOP16 36 | NOP16 37 | .endmacro 38 | 39 | .text 40 | .globl _main 41 | .align 14 42 | _main: 43 | // at least 1024 instruction bytes on all architectures 44 | NOP256 45 | NOP256 46 | NOP256 47 | NOP256 48 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/association-cf.m: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -framework CoreFoundation 2 | // TEST_CONFIG MEM=mrc 3 | // not for ARC because ARC memory management doesn't 4 | // work on CF types whose ObjC side is not yet loaded 5 | 6 | #include 7 | #include 8 | 9 | #include "test.h" 10 | 11 | #if __has_feature(objc_arc) 12 | 13 | int main() 14 | { 15 | testwarn("rdar://11368528 confused by Foundation"); 16 | succeed(__FILE__); 17 | } 18 | 19 | #else 20 | 21 | int main() 22 | { 23 | // rdar://6164781 setAssociatedObject on unresolved future class crashes 24 | 25 | id mp = (id)CFMachPortCreate(0, 0, 0, 0); 26 | testassert(mp); 27 | 28 | testassert(! objc_getClass("NSMachPort")); 29 | 30 | objc_setAssociatedObject(mp, (void*)1, mp, OBJC_ASSOCIATION_ASSIGN); 31 | 32 | id obj = objc_getAssociatedObject(mp, (void*)1); 33 | testassert(obj == mp); 34 | 35 | CFRelease((CFTypeRef)mp); 36 | 37 | succeed(__FILE__); 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/associationForbidden.m: -------------------------------------------------------------------------------- 1 | // TEST_CRASHES 2 | /* 3 | TEST_RUN_OUTPUT 4 | Associated object is 0x[0-9a-fA-F]+ 5 | objc\[\d+\]: objc_setAssociatedObject called on instance \(0x[0-9a-fA-F]+\) of class Forbidden which does not allow associated objects 6 | objc\[\d+\]: HALTED 7 | END 8 | */ 9 | 10 | #include "associationForbidden.h" 11 | 12 | void test(void) 13 | { 14 | ShouldSucceed([Normal alloc]); 15 | ShouldFail([Forbidden alloc]); 16 | } 17 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/associationForbidden2.m: -------------------------------------------------------------------------------- 1 | // TEST_CRASHES 2 | /* 3 | TEST_RUN_OUTPUT 4 | Associated object is 0x[0-9a-fA-F]+ 5 | objc\[\d+\]: objc_setAssociatedObject called on instance \(0x[0-9a-fA-F]+\) of class ForbiddenSubclass which does not allow associated objects 6 | objc\[\d+\]: HALTED 7 | END 8 | */ 9 | 10 | #include "associationForbidden.h" 11 | 12 | void test(void) 13 | { 14 | ShouldSucceed([Normal alloc]); 15 | Class ForbiddenSubclass = objc_allocateClassPair([Forbidden class], 16 | "ForbiddenSubclass", 0); 17 | objc_registerClassPair(ForbiddenSubclass); 18 | ShouldFail([ForbiddenSubclass alloc]); 19 | } 20 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/associationForbidden3.m: -------------------------------------------------------------------------------- 1 | // TEST_CRASHES 2 | /* 3 | TEST_RUN_OUTPUT 4 | Associated object is 0x[0-9a-fA-F]+ 5 | objc\[\d+\]: objc_setAssociatedObject called on instance \(0x[0-9a-fA-F]+\) of class ForbiddenSubclass which does not allow associated objects 6 | objc\[\d+\]: HALTED 7 | END 8 | */ 9 | 10 | #include "associationForbidden.h" 11 | 12 | @interface ForbiddenSubclass : Forbidden 13 | @end 14 | @implementation ForbiddenSubclass 15 | @end 16 | 17 | void test(void) 18 | { 19 | ShouldSucceed([Normal alloc]); 20 | ShouldSucceed([ForbiddenSubclass alloc]); 21 | } 22 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/associationForbidden4.m: -------------------------------------------------------------------------------- 1 | // TEST_CRASHES 2 | /* 3 | TEST_RUN_OUTPUT 4 | Associated object is 0x[0-9a-fA-F]+ 5 | objc\[\d+\]: objc_setAssociatedObject called on instance \(0x[0-9a-fA-F]+\) of class ForbiddenDuplicate which does not allow associated objects 6 | objc\[\d+\]: HALTED 7 | END 8 | */ 9 | 10 | #include "associationForbidden.h" 11 | 12 | void test(void) 13 | { 14 | ShouldSucceed([Normal alloc]); 15 | Class ForbiddenDuplicate = objc_duplicateClass([Forbidden class], 16 | "ForbiddenDuplicate", 0); 17 | ShouldFail([ForbiddenDuplicate alloc]); 18 | } 19 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/atomicProperty.mm: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include 5 | #include 6 | #import 7 | 8 | class SerialNumber { 9 | size_t _number; 10 | public: 11 | SerialNumber() : _number(42) {} 12 | SerialNumber(const SerialNumber &number) : _number(number._number + 1) {} 13 | SerialNumber &operator=(const SerialNumber &number) { _number = number._number + 1; return *this; } 14 | 15 | int operator==(const SerialNumber &number) { return _number == number._number; } 16 | int operator!=(const SerialNumber &number) { return _number != number._number; } 17 | }; 18 | 19 | @interface TestAtomicProperty : NSObject { 20 | SerialNumber number; 21 | } 22 | @property(atomic) SerialNumber number; 23 | @end 24 | 25 | @implementation TestAtomicProperty 26 | 27 | @synthesize number; 28 | 29 | @end 30 | 31 | int main() 32 | { 33 | PUSH_POOL { 34 | SerialNumber number; 35 | TestAtomicProperty *test = [TestAtomicProperty new]; 36 | test.number = number; 37 | testassert(test.number != number); 38 | } POP_POOL; 39 | 40 | succeed(__FILE__); 41 | } 42 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/badPool.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG MEM=mrc 2 | // TEST_CRASHES 3 | 4 | // Test badPoolCompat also uses this file. 5 | 6 | /* 7 | TEST_RUN_OUTPUT 8 | objc\[\d+\]: [Ii]nvalid or prematurely-freed autorelease pool 0x[0-9a-fA-F]+\.? 9 | objc\[\d+\]: HALTED 10 | END 11 | */ 12 | 13 | #include "test.h" 14 | 15 | int main() 16 | { 17 | void *outer = objc_autoreleasePoolPush(); 18 | void *inner = objc_autoreleasePoolPush(); 19 | objc_autoreleasePoolPop(outer); 20 | objc_autoreleasePoolPop(inner); 21 | 22 | #if !OLD 23 | fail("should have crashed already with new SDK"); 24 | #else 25 | // should only warn once 26 | outer = objc_autoreleasePoolPush(); 27 | inner = objc_autoreleasePoolPush(); 28 | objc_autoreleasePoolPop(outer); 29 | objc_autoreleasePoolPop(inner); 30 | 31 | succeed(__FILE__); 32 | #endif 33 | } 34 | 35 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/badPoolCompat-ios.m: -------------------------------------------------------------------------------- 1 | // Run test badPool as if it were built with an old SDK. 2 | 3 | // TEST_CONFIG MEM=mrc OS=iphoneos,iphonesimulator ARCH=x86_64,arm64 4 | // TEST_CRASHES 5 | // TEST_CFLAGS -DOLD=1 -Xlinker -platform_version -Xlinker ios -Xlinker 9.0 -Xlinker 9.0 -miphoneos-version-min=9.0 6 | 7 | /* 8 | TEST_BUILD_OUTPUT 9 | ld: warning: passed two min versions.*for platform.* 10 | END 11 | 12 | TEST_RUN_OUTPUT 13 | objc\[\d+\]: Invalid or prematurely-freed autorelease pool 0x[0-9a-fA-f]+\. Set a breakpoint .* Proceeding anyway .* 14 | OK: badPool.m 15 | END 16 | */ 17 | 18 | #include "badPool.m" 19 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/badPoolCompat-macos.m: -------------------------------------------------------------------------------- 1 | // Run test badPool as if it were built with an old SDK. 2 | 3 | // TEST_CONFIG MEM=mrc OS=macosx ARCH=x86_64 4 | // TEST_CRASHES 5 | // TEST_CFLAGS -DOLD=1 -Xlinker -platform_version -Xlinker macos -Xlinker 10.11 -Xlinker 10.11 -mmacosx-version-min=10.11 6 | 7 | /* 8 | TEST_BUILD_OUTPUT 9 | ld: warning: passed two min versions.*for platform.* 10 | END 11 | 12 | TEST_RUN_OUTPUT 13 | objc\[\d+\]: Invalid or prematurely-freed autorelease pool 0x[0-9a-fA-f]+\. Set a breakpoint .* Proceeding anyway .* 14 | OK: badPool.m 15 | END 16 | */ 17 | 18 | #include "badPool.m" 19 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/badPoolCompat-tvos.m: -------------------------------------------------------------------------------- 1 | // Run test badPool as if it were built with an old SDK. 2 | 3 | // TEST_CONFIG MEM=mrc OS=appletvos,appletvsimulator ARCH=x86_64,arm64 4 | // TEST_CRASHES 5 | // TEST_CFLAGS -DOLD=1 -Xlinker -platform_version -Xlinker tvos -Xlinker 9.0 -Xlinker 9.0 -mtvos-version-min=9.0 6 | 7 | /* 8 | TEST_BUILD_OUTPUT 9 | ld: warning: passed two min versions.*for platform.* 10 | END 11 | 12 | TEST_RUN_OUTPUT 13 | objc\[\d+\]: Invalid or prematurely-freed autorelease pool 0x[0-9a-fA-f]+\. Set a breakpoint .* Proceeding anyway .* 14 | OK: badPool.m 15 | END 16 | */ 17 | 18 | #include "badPool.m" 19 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/badPoolCompat-watchos.m: -------------------------------------------------------------------------------- 1 | // Run test badPool as if it were built with an old SDK. 2 | 3 | // TEST_CONFIG MEM=mrc OS=watchos,watchsimulator 4 | // TEST_CRASHES 5 | // TEST_CFLAGS -DOLD=1 -Xlinker -platform_version -Xlinker watchos -Xlinker 2.0 -Xlinker 2.0 -mwatchos-version-min=2.0 6 | 7 | /* 8 | TEST_BUILD_OUTPUT 9 | ld: warning: passed two min versions.*for platform.* 10 | END 11 | 12 | TEST_RUN_OUTPUT 13 | objc\[\d+\]: Invalid or prematurely-freed autorelease pool 0x[0-9a-fA-f]+\. Set a breakpoint .* Proceeding anyway .* 14 | OK: badPool.m 15 | END 16 | */ 17 | 18 | #include "badPool.m" 19 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/badSuperclass.m: -------------------------------------------------------------------------------- 1 | // TEST_CRASHES 2 | /* 3 | TEST_RUN_OUTPUT 4 | objc\[\d+\]: Memory corruption in class list\. 5 | objc\[\d+\]: HALTED 6 | END 7 | */ 8 | 9 | #include "test.h" 10 | #include "testroot.i" 11 | 12 | @interface Super : TestRoot @end 13 | @implementation Super @end 14 | 15 | @interface Sub : Super @end 16 | @implementation Sub @end 17 | 18 | int main() 19 | { 20 | alarm(10); 21 | 22 | Class supercls = [Super class]; 23 | Class subcls = [Sub class]; 24 | id subobj __unused = [Sub alloc]; 25 | 26 | // Create a cycle in a superclass chain (Sub->supercls == Sub) 27 | // then attempt to walk that chain. Runtime should halt eventually. 28 | _objc_flush_caches(supercls); 29 | ((Class __ptrauth_objc_super_pointer *)(__bridge void *)subcls)[1] = subcls; 30 | #ifdef CACHE_FLUSH 31 | _objc_flush_caches(supercls); 32 | #else 33 | [subobj class]; 34 | #endif 35 | 36 | fail("should have crashed"); 37 | } 38 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/badSuperclass2.m: -------------------------------------------------------------------------------- 1 | // TEST_CRASHES 2 | /* 3 | TEST_RUN_OUTPUT 4 | objc\[\d+\]: Memory corruption in class list\. 5 | objc\[\d+\]: HALTED 6 | OR 7 | old abi 8 | OK: badSuperclass\.m 9 | END 10 | */ 11 | 12 | #define CACHE_FLUSH 13 | #include "badSuperclass.m" 14 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/badTagIndex.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_CRASHES 3 | TEST_RUN_OUTPUT 4 | objc\[\d+\]: tag index 264 is invalid 5 | objc\[\d+\]: HALTED 6 | OR 7 | no tagged pointers 8 | OK: badTagIndex.m 9 | END 10 | */ 11 | 12 | #include "test.h" 13 | 14 | #include 15 | #include 16 | 17 | #if OBJC_HAVE_TAGGED_POINTERS 18 | 19 | int main() 20 | { 21 | _objc_registerTaggedPointerClass((objc_tag_index_t)(OBJC_TAG_Last52BitPayload+1), [NSObject class]); 22 | fail(__FILE__); 23 | } 24 | 25 | #else 26 | 27 | int main() 28 | { 29 | fprintf(stderr, "no tagged pointers\n"); 30 | succeed(__FILE__); 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/bool.c: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -funsigned-char 2 | // (verify -funsigned-char doesn't change the definition of BOOL) 3 | 4 | #include "test.h" 5 | #include 6 | 7 | #if TARGET_OS_OSX 8 | # if __x86_64__ 9 | # define RealBool 0 10 | # else 11 | # define RealBool 1 12 | # endif 13 | #elif TARGET_OS_IOS || TARGET_OS_BRIDGE 14 | # if (__arm__ && !__armv7k__) || __i386__ 15 | # define RealBool 0 16 | # else 17 | # define RealBool 1 18 | # endif 19 | #else 20 | # define RealBool 1 21 | #endif 22 | 23 | #if __OBJC__ && !defined(__OBJC_BOOL_IS_BOOL) 24 | # error no __OBJC_BOOL_IS_BOOL 25 | #endif 26 | 27 | #if RealBool != OBJC_BOOL_IS_BOOL 28 | # error wrong OBJC_BOOL_IS_BOOL 29 | #endif 30 | 31 | #if RealBool == OBJC_BOOL_IS_CHAR 32 | # error wrong OBJC_BOOL_IS_CHAR 33 | #endif 34 | 35 | int main() 36 | { 37 | const char *expected __unused = 38 | #if RealBool 39 | "B" 40 | #else 41 | "c" 42 | #endif 43 | ; 44 | #if __OBJC__ 45 | const char *enc = @encode(BOOL); 46 | testassert(0 == strcmp(enc, expected)); 47 | #endif 48 | succeed(__FILE__); 49 | } 50 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/cacheflush-constant.m: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -framework Foundation 2 | /* 3 | TEST_RUN_OUTPUT 4 | foo 5 | bar 6 | bar 7 | foo 8 | END 9 | */ 10 | 11 | // NOTE: This test won't catch problems when running against a root, so it's of 12 | // limited utility, but it would at least catch things when testing against the 13 | // shared cache. 14 | 15 | #include 16 | #include 17 | 18 | @interface NSBlock: NSObject @end 19 | 20 | // NSBlock is a conveniently accessible superclass that (currently) has a constant cache. 21 | @interface MyBlock: NSBlock 22 | +(void)foo; 23 | +(void)bar; 24 | @end 25 | @implementation MyBlock 26 | +(void)foo { 27 | printf("foo\n"); 28 | } 29 | +(void)bar { 30 | printf("bar\n"); 31 | } 32 | @end 33 | 34 | int main() { 35 | [MyBlock foo]; 36 | [MyBlock bar]; 37 | 38 | Method m1 = class_getClassMethod([MyBlock class], @selector(foo)); 39 | Method m2 = class_getClassMethod([MyBlock class], @selector(bar)); 40 | method_exchangeImplementations(m1, m2); 41 | 42 | [MyBlock foo]; 43 | [MyBlock bar]; 44 | } 45 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/cacheflush.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "test.h" 3 | 4 | @interface TestRoot(cat) 5 | +(int)classMethod; 6 | -(int)instanceMethod; 7 | @end 8 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/cacheflush0.m: -------------------------------------------------------------------------------- 1 | #include "cacheflush.h" 2 | #include "testroot.i" 3 | 4 | @implementation TestRoot(cat) 5 | +(int)classMethod { return 1; } 6 | -(int)instanceMethod { return 1; } 7 | @end 8 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/cacheflush2.m: -------------------------------------------------------------------------------- 1 | #include "cacheflush.h" 2 | 3 | @implementation TestRoot (Category2) 4 | +(int)classMethod { return 2; } 5 | -(int)instanceMethod { return 2; } 6 | @end 7 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/cacheflush3.m: -------------------------------------------------------------------------------- 1 | #include "cacheflush.h" 2 | 3 | @implementation TestRoot (Category3) 4 | +(int)classMethod { return 3; } 5 | -(int)instanceMethod { return 3; } 6 | @end 7 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/classgetclass.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include 5 | #include 6 | #import 7 | 8 | @interface Foo:NSObject 9 | @end 10 | @implementation Foo 11 | @end 12 | 13 | int main() 14 | { 15 | testassert(gdb_class_getClass([Foo class]) == [Foo class]); 16 | succeed(__FILE__); 17 | } 18 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/classversion.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | #include 6 | 7 | int main() 8 | { 9 | Class cls = [TestRoot class]; 10 | testassert(class_getVersion(cls) == 0); 11 | testassert(class_getVersion(object_getClass(cls)) > 5); 12 | class_setVersion(cls, 100); 13 | testassert(class_getVersion(cls) == 100); 14 | 15 | testassert(class_getVersion(Nil) == 0); 16 | class_setVersion(Nil, 100); 17 | 18 | succeed(__FILE__); 19 | } 20 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/customrr-cat1.m: -------------------------------------------------------------------------------- 1 | @interface InheritingSubCat @end 2 | 3 | @interface InheritingSubCat (NonClobberingCategory) @end 4 | 5 | @implementation InheritingSubCat (NonClobberingCategory) 6 | -(id) unrelatedMethod { return self; } 7 | @end 8 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/customrr-cat2.m: -------------------------------------------------------------------------------- 1 | @interface InheritingSubCat @end 2 | 3 | @interface InheritingSubCat (ClobberingCategory) @end 4 | 5 | @implementation InheritingSubCat (ClobberingCategory) 6 | -(int) retainCount { return 1; } 7 | @end 8 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/customrr-nsobject-awz.m: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TEST_CONFIG MEM=mrc 4 | TEST_ENV OBJC_PRINT_CUSTOM_RR=YES OBJC_PRINT_CUSTOM_AWZ=YES OBJC_PRINT_CUSTOM_CORE=YES 5 | 6 | TEST_BUILD 7 | $C{COMPILE} $DIR/customrr-nsobject.m -o customrr-nsobject-awz.exe -DSWIZZLE_AWZ=1 -fno-objc-convert-messages-to-runtime-calls 8 | END 9 | 10 | TEST_RUN_OUTPUT 11 | objc\[\d+\]: CUSTOM AWZ: NSObject \(meta\) 12 | OK: customrr-nsobject-awz.exe 13 | END 14 | 15 | */ 16 | 17 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/customrr-nsobject-core.m: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TEST_CONFIG MEM=mrc 4 | TEST_ENV OBJC_PRINT_CUSTOM_RR=YES OBJC_PRINT_CUSTOM_AWZ=YES OBJC_PRINT_CUSTOM_CORE=YES 5 | 6 | TEST_BUILD 7 | $C{COMPILE} $DIR/customrr-nsobject.m -o customrr-nsobject-core.exe -DSWIZZLE_CORE=1 -fno-objc-convert-messages-to-runtime-calls 8 | END 9 | 10 | TEST_RUN_OUTPUT 11 | objc\[\d+\]: CUSTOM Core: NSObject 12 | objc\[\d+\]: CUSTOM Core: NSObject \(meta\) 13 | OK: customrr-nsobject-core.exe 14 | END 15 | 16 | */ 17 | 18 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/customrr-nsobject-none.m: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TEST_CONFIG MEM=mrc 4 | TEST_ENV OBJC_PRINT_CUSTOM_RR=YES OBJC_PRINT_CUSTOM_AWZ=YES OBJC_PRINT_CUSTOM_CORE=YES 5 | 6 | TEST_BUILD 7 | $C{COMPILE} $DIR/customrr-nsobject.m -o customrr-nsobject-none.exe -fno-objc-convert-messages-to-runtime-calls 8 | END 9 | 10 | TEST_RUN_OUTPUT 11 | OK: customrr-nsobject-none.exe 12 | END 13 | 14 | */ 15 | 16 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/customrr-nsobject-rr.m: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TEST_CONFIG MEM=mrc 4 | TEST_ENV OBJC_PRINT_CUSTOM_RR=YES OBJC_PRINT_CUSTOM_AWZ=YES OBJC_PRINT_CUSTOM_CORE=YES 5 | 6 | TEST_BUILD 7 | $C{COMPILE} $DIR/customrr-nsobject.m -o customrr-nsobject-rr.exe -DSWIZZLE_RELEASE=1 -fno-objc-convert-messages-to-runtime-calls 8 | END 9 | 10 | TEST_RUN_OUTPUT 11 | objc\[\d+\]: CUSTOM RR: NSObject 12 | OK: customrr-nsobject-rr.exe 13 | END 14 | 15 | */ 16 | 17 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/customrr-nsobject-rrawz.m: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TEST_CONFIG MEM=mrc 4 | TEST_ENV OBJC_PRINT_CUSTOM_RR=YES OBJC_PRINT_CUSTOM_AWZ=YES OBJC_PRINT_CUSTOM_CORE=YES 5 | 6 | TEST_BUILD 7 | $C{COMPILE} $DIR/customrr-nsobject.m -o customrr-nsobject-rrawz.exe -DSWIZZLE_RELEASE=1 -DSWIZZLE_AWZ=1 -fno-objc-convert-messages-to-runtime-calls 8 | END 9 | 10 | TEST_RUN_OUTPUT 11 | objc\[\d+\]: CUSTOM AWZ: NSObject \(meta\) 12 | objc\[\d+\]: CUSTOM RR: NSObject 13 | OK: customrr-nsobject-rrawz.exe 14 | END 15 | 16 | */ 17 | 18 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/customrr2.m: -------------------------------------------------------------------------------- 1 | // These options must match customrr.m 2 | // TEST_CONFIG MEM=mrc 3 | /* 4 | TEST_BUILD 5 | $C{COMPILE} $DIR/customrr.m -fvisibility=default -o customrr2.exe -DTEST_EXCHANGEIMPLEMENTATIONS=1 -fno-objc-convert-messages-to-runtime-calls 6 | $C{COMPILE} -bundle -bundle_loader customrr2.exe $DIR/customrr-cat1.m -o customrr-cat1.bundle 7 | $C{COMPILE} -bundle -bundle_loader customrr2.exe $DIR/customrr-cat2.m -o customrr-cat2.bundle 8 | END 9 | */ 10 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/debugScanWeakTables.m: -------------------------------------------------------------------------------- 1 | // TEST_ENV OBJC_DEBUG_SCAN_WEAK_TABLES=YES OBJC_DEBUG_SCAN_WEAK_TABLES_INTERVAL_NANOSECONDS=1000 2 | // TEST_CRASHES 3 | // TEST_CONFIG MEM=mrc 4 | /* 5 | TEST_RUN_OUTPUT 6 | objc\[\d+\]: Starting background scan of weak references. 7 | objc\[\d+\]: Weak reference at 0x[0-9a-fA-F]+ contains 0x[0-9a-fA-F]+, should contain 0x[0-9a-fA-F]+ 8 | objc\[\d+\]: HALTED 9 | END 10 | */ 11 | 12 | #include "test.h" 13 | #include "testroot.i" 14 | 15 | #include 16 | 17 | int main() { 18 | id obj = [TestRoot new]; 19 | id weakLoc = nil; 20 | 21 | objc_storeWeak(&weakLoc, obj); 22 | memset_s(&weakLoc, sizeof(weakLoc), 0x35, sizeof(weakLoc)); 23 | 24 | uint64_t startTime = clock_gettime_nsec_np(CLOCK_UPTIME_RAW_APPROX); 25 | while (clock_gettime_nsec_np(CLOCK_UPTIME_RAW_APPROX) - startTime < 5000000000) { 26 | sleep(1); 27 | printf(".\n"); 28 | } 29 | 30 | fail("Should have crashed scanning weakLoc"); 31 | } -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/defines.c: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_CONFIG MEM=mrc LANGUAGE=c 3 | 4 | TEST_BUILD 5 | $DIR/defines.sh '$C{TESTINCLUDEDIR}' '$C{TESTLOCALINCLUDEDIR}' '$C{COMPILE_C}' '$C{COMPILE_CXX}' '$C{COMPILE_M}' '$C{COMPILE_MM}' '$VERBOSE' 6 | $C{COMPILE_C} $DIR/defines.c -o defines.exe 7 | END 8 | 9 | TEST_BUILD_OUTPUT 10 | (.|\n)*No unexpected #defines found\. 11 | END 12 | */ 13 | 14 | 15 | #include "test.h" 16 | 17 | int main() 18 | { 19 | succeed(__FILE__); 20 | } 21 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/designatedinit.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | /* TEST_BUILD_OUTPUT 3 | .*designatedinit.m:\d+:\d+: warning: designated initializer should only invoke a designated initializer on 'super'.* 4 | .*designatedinit.m:\d+:\d+: note: .* 5 | .*designatedinit.m:\d+:\d+: warning: method override for the designated initializer of the superclass '-init' not found.* 6 | .*NSObject.h:\d+:\d+: note: .* 7 | END */ 8 | 9 | #define NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER 1 10 | #include "test.h" 11 | #include 12 | 13 | @interface C : NSObject 14 | -(id) initWithInt:(int)i NS_DESIGNATED_INITIALIZER; 15 | @end 16 | 17 | @implementation C 18 | -(id) initWithInt:(int)__unused i { 19 | return [self init]; 20 | } 21 | @end 22 | 23 | int main() 24 | { 25 | succeed(__FILE__); 26 | } 27 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/duplicatedClasses.m: -------------------------------------------------------------------------------- 1 | // fixme rdar://24624435 duplicate class warning fails with the shared cache 2 | // OBJC_DISABLE_PREOPTIMIZATION=YES works around that problem. 3 | 4 | // TEST_ENV OBJC_DEBUG_DUPLICATE_CLASSES=YES OBJC_DISABLE_PREOPTIMIZATION=YES 5 | // TEST_CRASHES 6 | /* 7 | TEST_RUN_OUTPUT 8 | objc\[\d+\]: Class [^\s]+ is implemented in both .+ \(0x[0-9a-f]+\) and .+ \(0x[0-9a-f]+\)\. One of the two will be used\. Which one is undefined\. 9 | objc\[\d+\]: HALTED 10 | OR 11 | OK: duplicatedClasses.m 12 | END 13 | */ 14 | 15 | #include "test.h" 16 | #include "testroot.i" 17 | 18 | @interface WKWebView : TestRoot @end 19 | @implementation WKWebView @end 20 | 21 | int main() 22 | { 23 | void *dl = dlopen("/System/Library/Frameworks/WebKit.framework/WebKit", RTLD_LAZY); 24 | if (!dl) fail("couldn't open WebKit"); 25 | fail("should have crashed already"); 26 | } 27 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/forkInitializeDisabled.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_CONFIG OS=macosx MEM=mrc ARCH=x86_64 3 | (confused by ARC which loads Foundation which provokes more +initialize logs) 4 | (also confused by i386 OS_object +load workaround) 5 | 6 | TEST_ENV OBJC_PRINT_INITIALIZE_METHODS=YES 7 | 8 | TEST_RUN_OUTPUT 9 | objc\[\d+\]: INITIALIZE: disabling \+initialize fork safety enforcement because the app has a __DATA,__objc_fork_ok section 10 | OK: forkInitializeDisabled\.m 11 | END 12 | */ 13 | 14 | #include "test.h" 15 | 16 | asm(".section __DATA, __objc_fork_ok\n.long 0\n"); 17 | 18 | int main() 19 | { 20 | succeed(__FILE__); 21 | } 22 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/forkInitializeSingleThreaded.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_RUN_OUTPUT 3 | OK: forkInitialize\.m 4 | OK: forkInitialize\.m 5 | END 6 | */ 7 | #define SINGLETHREADED 1 8 | #include "forkInitialize.m" 9 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/forwardDefault.m: -------------------------------------------------------------------------------- 1 | /* 2 | no arc, rdar://11368528 confused by Foundation 3 | TEST_CONFIG MEM=mrc 4 | TEST_CRASHES 5 | TEST_RUN_OUTPUT 6 | objc\[\d+\]: \+\[NSObject fakeorama\]: unrecognized selector sent to instance 0x[0-9a-fA-F]+ \(no message forward handler is installed\) 7 | objc\[\d+\]: HALTED 8 | END 9 | */ 10 | 11 | #include "test.h" 12 | 13 | #include 14 | 15 | @interface NSObject (Fake) 16 | -(void)fakeorama; 17 | @end 18 | 19 | int main() 20 | { 21 | [NSObject fakeorama]; 22 | fail("should have crashed"); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/forwardDefaultStret.m: -------------------------------------------------------------------------------- 1 | /* 2 | no arc, rdar://11368528 confused by Foundation 3 | TEST_CONFIG MEM=mrc 4 | TEST_CRASHES 5 | TEST_RUN_OUTPUT 6 | objc\[\d+\]: \+\[NSObject fakeorama\]: unrecognized selector sent to instance 0x[0-9a-fA-F]+ \(no message forward handler is installed\) 7 | objc\[\d+\]: HALTED 8 | END 9 | */ 10 | 11 | #include "test.h" 12 | 13 | #include 14 | 15 | @interface NSObject (Fake) 16 | -(struct stret)fakeorama; 17 | @end 18 | 19 | int main() 20 | { 21 | [NSObject fakeorama]; 22 | fail("should have crashed"); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/future.h: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | @interface Sub1 : TestRoot 4 | +(int)method; 5 | +(Class)classref; 6 | @end 7 | 8 | @interface Sub2 : TestRoot 9 | +(int)method; 10 | +(Class)classref; 11 | @end 12 | 13 | @interface SubSub1 : Sub1 @end 14 | 15 | @interface SubSub2 : Sub2 @end 16 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/future0.m: -------------------------------------------------------------------------------- 1 | #include "future.h" 2 | #include "testroot.i" 3 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/future2.m: -------------------------------------------------------------------------------- 1 | #include "future.h" 2 | 3 | 4 | @implementation Sub1 5 | +(Class)classref { 6 | return [Sub1 class]; 7 | } 8 | +(int)method { 9 | return 1; 10 | } 11 | @end 12 | 13 | @implementation SubSub1 14 | +(int)method { 15 | return 1 + [super method]; 16 | } 17 | @end 18 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/get_task_allow_entitlement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | get-task-allow 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/headers.c: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $DIR/headers.sh '$C{TESTINCLUDEDIR}' '$C{TESTLOCALINCLUDEDIR}' '$C{COMPILE_C}' '$C{COMPILE_CXX}' '$C{COMPILE_M}' '$C{COMPILE_MM}' '$VERBOSE' 4 | $C{COMPILE_C} $DIR/headers.c -o headers.exe 5 | END 6 | 7 | allow `sh -x` output from headers.sh 8 | TEST_BUILD_OUTPUT 9 | (\+ .*\n)*(\+ .*)?done 10 | END 11 | */ 12 | 13 | 14 | #include "test.h" 15 | 16 | int main() 17 | { 18 | succeed(__FILE__); 19 | } 20 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/headers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Compile every exported ObjC header as if it were a file in every language. 4 | # This script is executed by test headers.c's TEST_BUILD command. 5 | 6 | TESTINCLUDEDIR=$1; shift 7 | TESTLOCALINCLUDEDIR=$1; shift 8 | COMPILE_C=$1; shift 9 | COMPILE_CXX=$1; shift 10 | COMPILE_M=$1; shift 11 | COMPILE_MM=$1; shift 12 | VERBOSE=$1; shift 13 | 14 | # stop after any command error 15 | set -e 16 | 17 | # echo commands when verbose 18 | if [ "$VERBOSE" != "0" ]; then 19 | set -x 20 | fi 21 | 22 | FILES="$TESTINCLUDEDIR/objc/*.h $TESTLOCALINCLUDEDIR/objc/*.h" 23 | CFLAGS='-fsyntax-only -Wno-unused-function -D_OBJC_PRIVATE_H_' 24 | 25 | $COMPILE_C $CFLAGS $FILES 26 | $COMPILE_CXX $CFLAGS $FILES 27 | $COMPILE_M $CFLAGS $FILES 28 | $COMPILE_MM $CFLAGS $FILES 29 | for STDC in '99' '11' ; do 30 | $COMPILE_C $CFLAGS $FILES -std=c$STDC 31 | $COMPILE_M $CFLAGS $FILES -std=c$STDC 32 | done 33 | for STDCXX in '98' '03' '11' '14' '17' ; do 34 | $COMPILE_CXX $CFLAGS $FILES -std=c++$STDCXX 35 | $COMPILE_MM $CFLAGS $FILES -std=c++$STDCXX 36 | done 37 | 38 | echo done 39 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/imageorder.h: -------------------------------------------------------------------------------- 1 | extern int state; 2 | extern int cstate; 3 | 4 | OBJC_ROOT_CLASS 5 | @interface Super { id isa; } 6 | +(void) method; 7 | +(void) method0; 8 | @end 9 | 10 | @interface Super (cat1) 11 | +(void) method1; 12 | @end 13 | 14 | @interface Super (cat2) 15 | +(void) method2; 16 | @end 17 | 18 | @interface Super (cat3) 19 | +(void) method3; 20 | @end 21 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/imageorder1.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | #include "imageorder.h" 3 | 4 | int state = -1; 5 | int cstate = 0; 6 | 7 | static void c1(void) __attribute__((constructor)); 8 | static void c1(void) 9 | { 10 | testassert(state == 1); // +load before C/C++ 11 | testassert(cstate == 0); 12 | cstate = 1; 13 | } 14 | 15 | 16 | #if __clang__ 17 | #pragma clang diagnostic push 18 | #pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation" 19 | #endif 20 | 21 | @implementation Super (cat1) 22 | +(void) method { 23 | fail("+[Super(cat1) method] not replaced!"); 24 | } 25 | +(void) method1 { 26 | state = 1; 27 | } 28 | +(void) load { 29 | testassert(state == 0); 30 | state = 1; 31 | } 32 | @end 33 | 34 | #if __clang__ 35 | #pragma clang diagnostic pop 36 | #endif 37 | 38 | 39 | @implementation Super 40 | +(void) initialize { } 41 | +(void) method { 42 | fail("+[Super method] not replaced!"); 43 | } 44 | +(void) method0 { 45 | state = 0; 46 | } 47 | +(void) load { 48 | testassert(state == -1); 49 | state = 0; 50 | } 51 | @end 52 | 53 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/imageorder2.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | #include "imageorder.h" 3 | 4 | static void c2(void) __attribute__((constructor)); 5 | static void c2(void) 6 | { 7 | testassert(state == 2); // +load before C/C++ 8 | testassert(cstate == 1); 9 | cstate = 2; 10 | } 11 | 12 | 13 | #if __clang__ 14 | #pragma clang diagnostic push 15 | #pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation" 16 | #endif 17 | 18 | @implementation Super (cat2) 19 | +(void) method { 20 | fail("+[Super(cat2) method] not replaced!"); 21 | } 22 | +(void) method2 { 23 | state = 2; 24 | } 25 | +(void) load { 26 | testassert(state == 1); 27 | state = 2; 28 | } 29 | @end 30 | 31 | #if __clang__ 32 | #pragma clang diagnostic pop 33 | #endif 34 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/imageorder3.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | #include "imageorder.h" 3 | 4 | static void c3(void) __attribute__((constructor)); 5 | static void c3(void) 6 | { 7 | testassert(state == 3); // +load before C/C++ 8 | testassert(cstate == 2); 9 | cstate = 3; 10 | } 11 | 12 | 13 | #if __clang__ 14 | #pragma clang diagnostic push 15 | #pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation" 16 | #endif 17 | 18 | @implementation Super (cat3) 19 | +(void) method { 20 | state = 3; 21 | } 22 | +(void) method3 { 23 | state = 3; 24 | } 25 | +(void) load { 26 | testassert(state == 2); 27 | state = 3; 28 | } 29 | @end 30 | 31 | #if __clang__ 32 | #pragma clang diagnostic pop 33 | #endif 34 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/include-warnings.c: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/include-warnings.c -o include-warnings.exe -Wsystem-headers -Weverything -Wno-undef -Wno-old-style-cast -Wno-nullability-extension -Wno-c++98-compat 2>&1 | grep -v 'In file' | grep objc || true 4 | END 5 | 6 | TEST_RUN_OUTPUT 7 | OK: includes.c 8 | END 9 | */ 10 | 11 | // Detect warnings inside any header. 12 | // The build command above filters out warnings inside non-objc headers 13 | // (which are noisy with -Weverything). 14 | // -Wno-undef suppresses warnings about `#if __cplusplus` and the like. 15 | // -Wno-old-style-cast is tough to avoid in mixed C/C++ code. 16 | // -Wno-nullability-extension disables a warning about non-portable 17 | // _Nullable etc which we already handle correctly in objc-abi.h. 18 | // -Wno-c++98-compat disables warnings about things that already 19 | // have guards against C++98. 20 | 21 | #include "includes.c" 22 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/includes-objc2.c: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -D__OBJC2__ 2 | 3 | // Verify that all headers can be included in any language, even if 4 | // the client is C code that defined __OBJC2__. 5 | 6 | // This is the definition that Instruments uses in its build. 7 | #if defined(__OBJC2__) 8 | #undef __OBJC2__ 9 | #endif 10 | #define __OBJC2__ 1 11 | 12 | #define NAME "includes-objc2.c" 13 | #include "includes.c" 14 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/ismeta.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | #include 6 | 7 | int main() 8 | { 9 | testassert(!class_isMetaClass([TestRoot class])); 10 | testassert(class_isMetaClass(object_getClass([TestRoot class]))); 11 | testassert(!class_isMetaClass(nil)); 12 | succeed(__FILE__); 13 | } 14 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/ivarSlide1.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | #include 3 | #include 4 | 5 | #define OLD 0 6 | #include "ivarSlide.h" 7 | 8 | #include "testroot.i" 9 | 10 | @implementation Super @end 11 | 12 | @implementation ShrinkingSuper @end 13 | 14 | @implementation MoreStrongSuper @end 15 | @implementation LessStrongSuper @end 16 | @implementation MoreWeakSuper @end 17 | @implementation MoreWeak2Super @end 18 | @implementation LessWeakSuper @end 19 | @implementation LessWeak2Super @end 20 | @implementation NoGCChangeSuper @end 21 | @implementation RunsOf15 @end 22 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/load-image-notification-dylib.m: -------------------------------------------------------------------------------- 1 | #import "test.h" 2 | 3 | #import 4 | 5 | @interface CLASSNAME: NSObject @end 6 | @implementation CLASSNAME @end 7 | 8 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/load-order.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/load-order3.m -o load-order3.dylib -dynamiclib 4 | $C{COMPILE} $DIR/load-order2.m -o load-order2.dylib -x none load-order3.dylib -dynamiclib 5 | $C{COMPILE} $DIR/load-order1.m -o load-order1.dylib -x none load-order3.dylib load-order2.dylib -dynamiclib 6 | $C{COMPILE} $DIR/load-order.m -o load-order.exe -x none load-order3.dylib load-order2.dylib load-order1.dylib 7 | END 8 | */ 9 | 10 | #include "test.h" 11 | 12 | extern int state1, state2, state3; 13 | 14 | int main() 15 | { 16 | testassert(state1 == 1 && state2 == 2 && state3 == 3); 17 | succeed(__FILE__); 18 | } 19 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/load-order1.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | extern int state2, state3; 4 | 5 | int state1 = 0; 6 | 7 | OBJC_ROOT_CLASS 8 | @interface One @end 9 | @implementation One 10 | +(void)load 11 | { 12 | testassert(state2 == 2 && state3 == 3); 13 | state1 = 1; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/load-order2.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | extern int state3; 4 | 5 | int state2 = 0; 6 | 7 | OBJC_ROOT_CLASS 8 | @interface Two @end 9 | @implementation Two 10 | +(void)load 11 | { 12 | testassert(state3 == 3); 13 | state2 = 2; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/load-order3.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | int state3 = 0; 4 | 5 | OBJC_ROOT_CLASS 6 | @interface Three @end 7 | @implementation Three 8 | +(void)load 9 | { 10 | state3 = 3; 11 | } 12 | @end 13 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/load-parallel00.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | atomic_int state; 3 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/load-reentrant.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/load-reentrant.m -o load-reentrant.exe 4 | $C{COMPILE} $DIR/load-reentrant2.m -o libload-reentrant2.dylib -bundle -bundle_loader load-reentrant.exe 5 | END 6 | */ 7 | 8 | #include "test.h" 9 | #include 10 | 11 | int state1 = 0; 12 | int *state2_p; 13 | 14 | OBJC_ROOT_CLASS 15 | @interface One @end 16 | @implementation One 17 | +(void)load 18 | { 19 | state1 = 111; 20 | 21 | // Re-entrant +load doesn't get to complete until we do 22 | void *dlh = dlopen("libload-reentrant2.dylib", RTLD_LAZY); 23 | testassert(dlh); 24 | state2_p = (int *)dlsym(dlh, "state2"); 25 | testassert(state2_p); 26 | testassert(*state2_p == 0); 27 | 28 | state1 = 1; 29 | } 30 | @end 31 | 32 | int main() 33 | { 34 | testassert(state1 == 1 && state2_p && *state2_p == 2); 35 | succeed(__FILE__); 36 | } 37 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/load-reentrant2.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | int state2 = 0; 4 | extern int state1; 5 | 6 | static void ctor(void) __attribute__((constructor)); 7 | static void ctor(void) 8 | { 9 | // should be called during One's dlopen(), before Two's +load 10 | testassert(state1 == 111); 11 | testassert(state2 == 0); 12 | } 13 | 14 | OBJC_ROOT_CLASS 15 | @interface Two @end 16 | @implementation Two 17 | +(void) load 18 | { 19 | // Does not run until One's +load completes 20 | testassert(state1 == 1); 21 | state2 = 2; 22 | } 23 | @end 24 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/nilAPIArgs.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD_OUTPUT 3 | .*nilAPIArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\] 4 | .*nilAPIArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\] 5 | END 6 | */ 7 | 8 | #include "test.h" 9 | 10 | #import 11 | 12 | int main() { 13 | // ensure various bits of API don't crash when tossed nil parameters 14 | class_conformsToProtocol(nil, nil); 15 | method_setImplementation(nil, NULL); 16 | 17 | succeed(__FILE__); 18 | } 19 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/nscdtors.mm: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | // test cdtors, with NSObject instead of TestRoot as the root class 3 | 4 | #define USE_FOUNDATION 1 5 | #include "cdtors.mm" 6 | 7 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/nsexc.m: -------------------------------------------------------------------------------- 1 | /* 2 | need exception-safe ARC for exception deallocation tests 3 | TEST_CFLAGS -fobjc-arc-exceptions -framework Foundation 4 | */ 5 | 6 | #define USE_FOUNDATION 1 7 | #include "exc.m" 8 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/nsprotocol.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include 5 | 6 | int main() 7 | { 8 | // Class Protocol is always a subclass of NSObject 9 | 10 | testassert(objc_getClass("NSObject")); 11 | 12 | Class cls = objc_getClass("Protocol"); 13 | testassert(class_getInstanceMethod(cls, sel_registerName("isProxy"))); 14 | testassert(class_getSuperclass(cls) == objc_getClass("NSObject")); 15 | 16 | succeed(__FILE__); 17 | } 18 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/objectCopy.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG MEM=mrc 2 | 3 | #include "test.h" 4 | #include 5 | 6 | @interface Test : NSObject { 7 | @public 8 | char bytes[32-sizeof(void*)]; 9 | } 10 | @end 11 | @implementation Test 12 | @end 13 | 14 | 15 | int main() 16 | { 17 | Test *o0 = [Test new]; 18 | [o0 retain]; 19 | Test *o1 = class_createInstance([Test class], 32); 20 | [o1 retain]; 21 | id o2 = object_copy(o0, 0); 22 | id o3 = object_copy(o1, 0); 23 | id o4 = object_copy(o1, 32); 24 | 25 | testassert(malloc_size(o0) == 32); 26 | testassert(malloc_size(o1) == 64); 27 | testassert(malloc_size(o2) == 32); 28 | testassert(malloc_size(o3) == 32); 29 | testassert(malloc_size(o4) == 64); 30 | 31 | testassert([o0 retainCount] == 2); 32 | testassert([o1 retainCount] == 2); 33 | testassert([o2 retainCount] == 1); 34 | testassert([o3 retainCount] == 1); 35 | testassert([o4 retainCount] == 1); 36 | 37 | succeed(__FILE__); 38 | } 39 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/preopt-caches.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.springboard-ui.client 6 | 7 | com.apple.security.system-groups 8 | 9 | systemgroup.com.apple.powerlog 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/rawisa.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_CFLAGS -Xlinker -sectcreate -Xlinker __DATA -Xlinker __objc_rawisa -Xlinker /dev/null 3 | TEST_ENV OBJC_PRINT_RAW_ISA=YES 4 | 5 | TEST_RUN_OUTPUT 6 | objc\[\d+\]: RAW ISA: disabling non-pointer isa because the app has a __DATA,__objc_rawisa section 7 | (.* RAW ISA: .*\n)* 8 | OK: rawisa.m(\n.* RAW ISA: .*)* 9 | OR 10 | (.* RAW ISA: .*\n)* 11 | no __DATA,__rawisa support 12 | OK: rawisa.m(\n.* RAW ISA: .*)* 13 | END 14 | 15 | "RAW ISA" is allowed after "OK" because of static destructors 16 | that provoke class realization. 17 | */ 18 | 19 | #include "test.h" 20 | 21 | int main() 22 | { 23 | fprintf(stderr, "\n"); 24 | #if ! (SUPPORT_NONPOINTER_ISA && TARGET_OS_OSX) 25 | // only 64-bit Mac supports this 26 | fprintf(stderr, "no __DATA,__rawisa support\n"); 27 | #endif 28 | succeed(__FILE__); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/realizedClassGenerationCount.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | 6 | #include 7 | 8 | extern uintptr_t objc_debug_realized_class_generation_count; 9 | 10 | int main() 11 | { 12 | testassert(objc_debug_realized_class_generation_count > 0); 13 | uintptr_t prev = objc_debug_realized_class_generation_count; 14 | 15 | void *handle = dlopen("/System/Library/Frameworks/Foundation.framework/Foundation", RTLD_LAZY); 16 | testassert(handle); 17 | Class c = objc_getClass("NSFileManager"); 18 | testassert(c); 19 | testassert(objc_debug_realized_class_generation_count > prev); 20 | 21 | prev = objc_debug_realized_class_generation_count; 22 | c = objc_allocateClassPair([TestRoot class], "Dynamic", 0); 23 | testassert(objc_debug_realized_class_generation_count > prev); 24 | prev = objc_debug_realized_class_generation_count; 25 | objc_registerClassPair(c); 26 | testassert(objc_debug_realized_class_generation_count == prev); 27 | 28 | succeed(__FILE__); 29 | } -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/release-workaround.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG ARCH=x86_64 MEM=mrc 2 | // TEST_CFLAGS -framework Foundation 3 | 4 | // rdar://20206767 5 | 6 | #include 7 | #include "test.h" 8 | 9 | 10 | @interface Test : NSObject @end 11 | @implementation Test 12 | @end 13 | 14 | 15 | int main() 16 | { 17 | id buf[1]; 18 | buf[0] = [Test class]; 19 | id obj = (id)buf; 20 | [obj retain]; 21 | [obj retain]; 22 | 23 | uintptr_t rax; 24 | 25 | [obj release]; 26 | asm("mov %%rax, %0" : "=r" (rax)); 27 | testassert(rax == 0); 28 | 29 | objc_release(obj); 30 | asm("mov %%rax, %0" : "=r" (rax)); 31 | testassert(rax == 0); 32 | 33 | succeed(__FILE__); 34 | } 35 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/rr-autorelease-stacklogging.m: -------------------------------------------------------------------------------- 1 | // Test OBJC_DEBUG_POOL_ALLOCATION (which is also enabled by MallocStackLogging) 2 | 3 | // TEST_ENV OBJC_DEBUG_POOL_ALLOCATION=YES 4 | // TEST_CFLAGS -framework Foundation 5 | // TEST_CONFIG MEM=mrc 6 | 7 | #include "test.h" 8 | 9 | #define FOUNDATION 0 10 | #define NAME "rr-autorelease-stacklogging" 11 | #define DEBUG_POOL_ALLOCATION 1 12 | 13 | #include "rr-autorelease2.m" 14 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/rr-autorelease.m: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -framework Foundation 2 | // TEST_CONFIG MEM=mrc 3 | 4 | #include "test.h" 5 | 6 | #define FOUNDATION 0 7 | #define NAME "rr-autorelease" 8 | 9 | #include "rr-autorelease2.m" 10 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/rr-nsautorelease.m: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -framework Foundation 2 | // TEST_CONFIG MEM=mrc 3 | 4 | #define FOUNDATION 1 5 | #define NAME "rr-nsautorelease" 6 | 7 | #include "rr-autorelease2.m" 8 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/setAssociatedObjectHook.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_CONFIG MEM=mrc 3 | TEST_ENV OBJC_DISABLE_NONPOINTER_ISA=YES 4 | */ 5 | 6 | #include "test.h" 7 | #include "testroot.i" 8 | 9 | bool hasAssociations = false; 10 | 11 | @interface TestRoot (AssocHooks) 12 | @end 13 | 14 | @implementation TestRoot (AssocHooks) 15 | 16 | - (void)_noteAssociatedObjects { 17 | hasAssociations = true; 18 | } 19 | 20 | // -_noteAssociatedObjects is currently limited to raw-isa custom-rr to avoid overhead 21 | - (void) release { 22 | } 23 | 24 | @end 25 | 26 | int main() { 27 | id obj = [TestRoot new]; 28 | id value = [TestRoot new]; 29 | const void *key = "key"; 30 | objc_setAssociatedObject(obj, key, value, OBJC_ASSOCIATION_RETAIN); 31 | testassert(hasAssociations == true); 32 | 33 | id out = objc_getAssociatedObject(obj, key); 34 | testassert(out == value); 35 | 36 | hasAssociations = false; 37 | key = "key2"; 38 | objc_setAssociatedObject(obj, key, value, OBJC_ASSOCIATION_RETAIN); 39 | testassert(hasAssociations == false); //only called once 40 | 41 | 42 | out = objc_getAssociatedObject(obj, key); 43 | testassert(out == value); 44 | 45 | succeed(__FILE__); 46 | } 47 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/setSuper.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | #include 6 | 7 | @interface Super1 : TestRoot @end 8 | @implementation Super1 9 | +(int)classMethod { return 1; } 10 | -(int)instanceMethod { return 10000; } 11 | @end 12 | 13 | @interface Super2 : TestRoot @end 14 | @implementation Super2 15 | +(int)classMethod { return 2; } 16 | -(int)instanceMethod { return 20000; } 17 | @end 18 | 19 | @interface Sub : Super1 @end 20 | @implementation Sub 21 | +(int)classMethod { return [super classMethod] + 100; } 22 | -(int)instanceMethod { 23 | return [super instanceMethod] + 1000000; 24 | } 25 | @end 26 | 27 | int main() 28 | { 29 | Class cls; 30 | Sub *obj = [Sub new]; 31 | 32 | testassert(101 == [[Sub class] classMethod]); 33 | testassert(1010000 == [obj instanceMethod]); 34 | 35 | cls = class_setSuperclass([Sub class], [Super2 class]); 36 | 37 | testassert(cls == [Super1 class]); 38 | testassert(object_getClass(cls) == object_getClass([Super1 class])); 39 | 40 | testassert(102 == [[Sub class] classMethod]); 41 | testassert(1020000 == [obj instanceMethod]); 42 | 43 | succeed(__FILE__); 44 | } 45 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/super.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | #include 6 | 7 | @interface Sub : TestRoot @end 8 | @implementation Sub @end 9 | 10 | int main() 11 | { 12 | // [super ...] messages are tested in msgSend.m 13 | 14 | testassert(class_getSuperclass([Sub class]) == [TestRoot class]); 15 | testassert(class_getSuperclass(object_getClass([Sub class])) == object_getClass([TestRoot class])); 16 | testassert(class_getSuperclass([TestRoot class]) == Nil); 17 | testassert(class_getSuperclass(object_getClass([TestRoot class])) == [TestRoot class]); 18 | testassert(class_getSuperclass(Nil) == Nil); 19 | 20 | succeed(__FILE__); 21 | } 22 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/taggedPointersDisabled.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_ENV OBJC_DISABLE_TAGGED_POINTERS=YES 3 | TEST_CRASHES 4 | 5 | TEST_BUILD_OUTPUT 6 | .*taggedPointersDisabled.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\] 7 | END 8 | 9 | TEST_RUN_OUTPUT 10 | objc\[\d+\]: tagged pointers are disabled 11 | objc\[\d+\]: HALTED 12 | OR 13 | OK: taggedPointersDisabled.m 14 | END 15 | */ 16 | 17 | #include "test.h" 18 | #include 19 | 20 | #if !OBJC_HAVE_TAGGED_POINTERS 21 | 22 | int main() 23 | { 24 | // provoke the same nullability warning as the real test 25 | objc_getClass(nil); 26 | 27 | succeed(__FILE__); 28 | } 29 | 30 | #else 31 | 32 | int main() 33 | { 34 | testassert(!_objc_taggedPointersEnabled()); 35 | _objc_registerTaggedPointerClass((objc_tag_index_t)0, nil); 36 | fail("should have crashed in _objc_registerTaggedPointerClass()"); 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/taggedPointersTagObfuscationDisabled.m: -------------------------------------------------------------------------------- 1 | // TEST_ENV OBJC_DISABLE_TAG_OBFUSCATION=YES 2 | 3 | #include "test.h" 4 | #include 5 | 6 | #if !OBJC_HAVE_TAGGED_POINTERS 7 | 8 | int main() 9 | { 10 | succeed(__FILE__); 11 | } 12 | 13 | #else 14 | 15 | int main() 16 | { 17 | #if OBJC_SPLIT_TAGGED_POINTERS 18 | void *obj = (void *)0; 19 | #else 20 | void *obj = (void *)1; 21 | #endif 22 | 23 | testassert(_objc_getTaggedPointerTag(obj) == 0); 24 | succeed(__FILE__); 25 | } 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/tbi.c: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG OS=iphoneos ARCH=arm64 2 | 3 | #include "test.h" 4 | 5 | #ifndef __arm64__ 6 | #error wrong architecture for TBI hardware feature 7 | #endif 8 | 9 | volatile int x = 123456; 10 | 11 | int main(void) { 12 | testassert(*(int *)((unsigned long)&x | 0xFF00000000000000ul) == 123456); 13 | succeed(__FILE__); 14 | } 15 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/test-defines.h: -------------------------------------------------------------------------------- 1 | #define TEST_OVERRIDES_NEW 1 2 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/timeout.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | use strict; 4 | 5 | my $usage = "timeout \n"; 6 | my $timeout = shift || die $usage; 7 | alarm($timeout); 8 | exec @ARGV; 9 | die "exec failed: @ARGV"; 10 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/unload.h: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | @interface SmallClass : TestRoot @end 4 | 5 | @interface BigClass : TestRoot @end 6 | 7 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/unload3.c: -------------------------------------------------------------------------------- 1 | // unload3: contains imageinfo but no other objc metadata 2 | // libobjc must not keep it open 3 | 4 | #include 5 | 6 | int fake[2] __attribute__((section("__DATA,__objc_imageinfo"))) 7 | = { 0, TARGET_OS_SIMULATOR ? (1<<5) : 0 }; 8 | 9 | // silence "no debug symbols in executable" warning 10 | void fn(void) { } 11 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/unload4.m: -------------------------------------------------------------------------------- 1 | // unload4: contains some objc metadata other than imageinfo 2 | // libobjc must keep it open 3 | 4 | int fake2 __attribute__((section("__DATA,__objc_foo"))) = 0; 5 | 6 | // getsectiondata() falls over if __TEXT has no contents 7 | const char *unload4 = "unload4"; 8 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/weakReferenceHook.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_CONFIG MEM=mrc 3 | TEST_ENV OBJC_DISABLE_NONPOINTER_ISA=YES 4 | */ 5 | 6 | #include "test.h" 7 | #include "testroot.i" 8 | 9 | bool hasWeakRefs = false; 10 | 11 | @interface TestRoot (WeakHooks) 12 | @end 13 | 14 | @implementation TestRoot (WeakHooks) 15 | 16 | - (void)_setWeaklyReferenced { 17 | hasWeakRefs = true; 18 | } 19 | 20 | // -_setWeaklyReferenced is currently limited to raw-isa custom-rr to avoid overhead 21 | - (void) release { 22 | } 23 | 24 | @end 25 | 26 | int main() { 27 | id obj = [TestRoot new]; 28 | id wobj = nil; 29 | objc_storeWeak(&wobj, obj); 30 | testassert(hasWeakRefs == true); 31 | 32 | id out = objc_loadWeak(&wobj); 33 | testassert(out == obj); 34 | 35 | objc_storeWeak(&wobj, nil); 36 | out = objc_loadWeak(&wobj); 37 | testassert(out == nil); 38 | 39 | hasWeakRefs = false; 40 | objc_storeWeak(&wobj, obj); 41 | testassert(hasWeakRefs == true); 42 | 43 | 44 | out = objc_loadWeak(&wobj); 45 | testassert(out == obj); 46 | objc_storeWeak(&wobj, nil); 47 | 48 | succeed(__FILE__); 49 | } 50 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/weakframework-missing.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/weak2.m -DWEAK_FRAMEWORK=1 -DWEAK_IMPORT= -UEMPTY -dynamiclib -o libweakframework.dylib 4 | 5 | $C{COMPILE} $DIR/weakframework-missing.m -L. -weak-lweakframework -o weakframework-missing.exe 6 | 7 | $C{COMPILE} $DIR/weak2.m -DWEAK_FRAMEWORK=1 -DWEAK_IMPORT= -DEMPTY= -dynamiclib -o libweakframework.dylib 8 | 9 | END 10 | */ 11 | 12 | #define WEAK_FRAMEWORK 1 13 | #define WEAK_IMPORT 14 | #include "weak.m" 15 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/weakframework-not-missing.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/weak2.m -DWEAK_FRAMEWORK=1 -DWEAK_IMPORT= -UEMPTY -dynamiclib -o libweakframework.dylib 4 | 5 | $C{COMPILE} $DIR/weakframework-not-missing.m -L. -weak-lweakframework -o weakframework-not-missing.exe 6 | END 7 | */ 8 | 9 | #define WEAK_FRAMEWORK 1 10 | #define WEAK_IMPORT 11 | #include "weak.m" 12 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/weakimport-missing.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/weak2.m -UWEAK_FRAMEWORK -DWEAK_IMPORT=__attribute__\\(\\(weak_import\\)\\) -UEMPTY -dynamiclib -o libweakimport.dylib 4 | 5 | $C{COMPILE} $DIR/weakimport-missing.m -L. -weak-lweakimport -o weakimport-missing.exe 6 | 7 | $C{COMPILE} $DIR/weak2.m -UWEAK_FRAMEWORK -DWEAK_IMPORT=__attribute__\\(\\(weak_import\\)\\) -DEMPTY= -dynamiclib -o libweakimport.dylib 8 | END 9 | */ 10 | 11 | // #define WEAK_FRAMEWORK 12 | #define WEAK_IMPORT __attribute__((weak_import)) 13 | #include "weak.m" 14 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/test/weakimport-not-missing.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/weak2.m -UWEAK_FRAMEWORK -DWEAK_IMPORT=__attribute__\\(\\(weak_import\\)\\) -UEMPTY -dynamiclib -o libweakimport.dylib 4 | 5 | $C{COMPILE} $DIR/weakimport-not-missing.m -L. -weak-lweakimport -o weakimport-not-missing.exe 6 | END 7 | */ 8 | 9 | // #define WEAK_FRAMEWORK 10 | #define WEAK_IMPORT __attribute__((weak_import)) 11 | #include "weak.m" 12 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/unexported_symbols: -------------------------------------------------------------------------------- 1 | .objc_class_name___IncompleteProtocol 2 | __Znam 3 | __ZnamRKSt9nothrow_t 4 | __Znwm 5 | __ZnwmRKSt9nothrow_t 6 | __ZdaPv 7 | __ZdaPvRKSt9nothrow_t 8 | __ZdlPv 9 | __ZdlPvRKSt9nothrow_t 10 | __ZTISt9bad_alloc 11 | __ZTISt9exception 12 | __ZTISt11logic_error 13 | __ZTISt12length_error 14 | __ZTSSt9bad_alloc 15 | __ZTSSt9exception 16 | __ZTSSt11logic_error 17 | __ZTSSt12length_error 18 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/version.bat: -------------------------------------------------------------------------------- 1 | :: version.bat 2 | :: Writes version numbers from B&I into version.h for use by version.rc. 3 | 4 | @ECHO OFF 5 | 6 | :: Set default values for environment variables if not set by B&I 7 | IF "%OBJROOT%"=="" SET OBJROOT=. 8 | IF "%RC_PROJECTSOURCEVERSION%"=="" SET RC_PROJECTSOURCEVERSION=0.0 9 | IF "%RC_PROJECTBUILDVERSION%"=="" SET RC_PROJECTBUILDVERSION=0 10 | 11 | :: Get version numbers from environment variables 12 | SET major=1 13 | SET patch=0 14 | FOR /F "tokens=1* eol= delims=." %%i IN ("%RC_PROJECTSOURCEVERSION%") DO ( 15 | SET minor=%%i 16 | IF NOT "%%j"=="" SET patch=%%j 17 | ) 18 | SET build=%RC_PROJECTBUILDVERSION% 19 | 20 | ECHO version %major% . %minor% . %patch% . %build% 21 | 22 | :: Write version.h 23 | ECHO // This file is automatically generated by version.bat. > "%OBJROOT%\version.h" 24 | ECHO // DO NOT EDIT >> "%OBJROOT%\version.h" 25 | ECHO #define major %major% >> "%OBJROOT%\version.h" 26 | ECHO #define minor %minor% >> "%OBJROOT%\version.h" 27 | ECHO #define patch %patch% >> "%OBJROOT%\version.h" 28 | ECHO #define build %build% >> "%OBJROOT%\version.h" 29 | ECHO #define string "%major%,%minor%,%patch%,%build%" >> "%OBJROOT%\version.h" 30 | -------------------------------------------------------------------------------- /debugableruntime/objc4-838.1-main/version.rc: -------------------------------------------------------------------------------- 1 | #include "Winver.h" 2 | 3 | // built by version.bat; sets variables major, minor, patch, build, string 4 | #include "version.h" 5 | 6 | VS_VERSION_INFO VERSIONINFO 7 | FILEVERSION major,minor,patch,build 8 | PRODUCTVERSION major,minor,patch,build 9 | FILEFLAGSMASK 0x17L 10 | #ifdef _DEBUG 11 | FILEFLAGS VS_FF_DEBUG 12 | #else 13 | FILEFLAGS 0x0L 14 | #endif 15 | FILEOS VOS_NT_WINDOWS32 16 | FILETYPE VFT_DLL 17 | FILESUBTYPE VFT2_UNKNOWN 18 | BEGIN 19 | BLOCK "StringFileInfo" 20 | BEGIN 21 | BLOCK "040904b0" 22 | BEGIN 23 | VALUE "CompanyName", "Apple Inc." 24 | VALUE "FileDescription", "Objective-C Runtime Library" 25 | VALUE "FileVersion", string 26 | VALUE "ProductVersion", string 27 | VALUE "ProductName", "objc4" 28 | VALUE "InternalName", "objc4" 29 | VALUE "LegalCopyright", "Copyright (C) 2007-2009, Apple Inc." 30 | VALUE "OriginalFilename", "objc.dll" 31 | END 32 | END 33 | BLOCK "VarFileInfo" 34 | BEGIN 35 | VALUE "Translation", 0x409, 1200 36 | END 37 | END 38 | 39 | --------------------------------------------------------------------------------