-
Notifications
You must be signed in to change notification settings - Fork 53
ObjC环境变量
jiaxw32 edited this page Jan 9, 2021
·
3 revisions
阅读 ObjC 源码时,看到几个实用的环境变量用来控制输出日志。例如 OBJC_PRINT_IMAGES
可以用来打印输出程序运行时加载的镜像名称;OBJC_PRINT_LOAD_METHODS
可以打印类和分类中 +load
方法的调用日志。掌握这些环境变量,有助于了解程序执行的逻辑。
为方便以后查询,摘录如下:
环境变量 | 参数说明 |
---|---|
OBJC_PRINT_IMAGES | log image and library names as they are loaded |
OBJC_PRINT_IMAGE_TIMES | measure duration of image loading steps |
OBJC_PRINT_LOAD_METHODS | log calls to class and category +load methods |
OBJC_PRINT_INITIALIZE_METHODS | log calls to class +initialize methods |
OBJC_PRINT_RESOLVED_METHODS | log methods created by +resolveClassMethod: and +resolveInstanceMethod: |
OBJC_PRINT_CLASS_SETUP | log progress of class and category setup |
OBJC_PRINT_PROTOCOL_SETUP | log progress of protocol setup |
OBJC_PRINT_IVAR_SETUP | log processing of non-fragile ivars |
OBJC_PRINT_VTABLE_SETUP | log processing of class vtables |
OBJC_PRINT_VTABLE_IMAGES | print vtable images showing overridden methods |
OBJC_PRINT_CACHE_SETUP | log processing of method caches |
OBJC_PRINT_FUTURE_CLASSES | log use of future classes for toll-free bridging |
OBJC_PRINT_PREOPTIMIZATION | log preoptimization courtesy of dyld shared cache |
OBJC_PRINT_CXX_CTORS | log calls to C++ ctors and dtors for instance variables |
OBJC_PRINT_EXCEPTIONS | log exception handling |
OBJC_PRINT_EXCEPTION_THROW | log backtrace of every objc_exception_throw() |
OBJC_PRINT_ALT_HANDLERS | log processing of exception alt handlers |
OBJC_PRINT_REPLACED_METHODS | log methods replaced by category implementations |
OBJC_PRINT_DEPRECATION_WARNINGS | warn about calls to deprecated runtime functions |
OBJC_PRINT_POOL_HIGHWATER | log high-water marks for autorelease pools |
OBJC_PRINT_CUSTOM_CORE | log classes with custom core methods |
OBJC_PRINT_CUSTOM_RR | log classes with custom retain/release methods |
OBJC_PRINT_CUSTOM_AWZ | log classes with custom allocWithZone methods |
OBJC_PRINT_RAW_ISA | log classes that require raw pointer isa fields |
OBJC_DEBUG_UNLOAD | warn about poorly-behaving bundles when unloaded |
OBJC_DEBUG_FRAGILE_SUPERCLASSES | warn about subclasses that may have been broken by subsequent changes to superclasses |
OBJC_DEBUG_NIL_SYNC | warn about @synchronized(nil), which does no synchronization |
OBJC_DEBUG_NONFRAGILE_IVARS | capriciously rearrange non-fragile ivars |
OBJC_DEBUG_ALT_HANDLERS | record more info about bad alt handler use |
OBJC_DEBUG_MISSING_POOLS | warn about autorelease with no pool in place, which may be a leak |
OBJC_DEBUG_POOL_ALLOCATION | halt when autorelease pools are popped out of order, and allow heap debuggers to track autorelease pools |
OBJC_DEBUG_DUPLICATE_CLASSES | halt when multiple classes with the same name are present |
OBJC_DEBUG_DONT_CRASH | halt the process by exiting instead of crashing |
OBJC_DISABLE_VTABLES | disable vtable dispatch |
OBJC_DISABLE_PREOPTIMIZATION | disable preoptimization courtesy of dyld shared cache |
OBJC_DISABLE_TAGGED_POINTERS | disable tagged pointer optimization of NSNumber et al. |
OBJC_DISABLE_TAG_OBFUSCATION | disable obfuscation of tagged pointers |
OBJC_DISABLE_NONPOINTER_ISA | disable non-pointer isa fields |
OBJC_DISABLE_INITIALIZE_FORK_SAFETY | disable safety checks for +initialize after fork |
Edit Scheme
-> Run
-> Arguments
