Skip to content

Instantly share code, notes, and snippets.

@cppforlife
Created October 7, 2011 05:09
Show Gist options
  • Save cppforlife/1269501 to your computer and use it in GitHub Desktop.
Save cppforlife/1269501 to your computer and use it in GitHub Desktop.
objective-c debugging env variables
[schwa@ungoliant] ~$ export OBJC_HELP=1
[schwa@ungoliant] ~$ /Applications/Safari.app/Contents/MacOS/Safari
objc[10559]: Objective-C runtime debugging. Set variable=YES to enable.
objc[10559]: OBJC_HELP: describe available environment variables
objc[10559]: OBJC_PRINT_OPTIONS: list which options are set
objc[10559]: OBJC_PRINT_IMAGES: log image and library names as they are loaded
objc[10559]: OBJC_PRINT_LOAD_METHODS: log calls to class and category +load methods
objc[10559]: OBJC_PRINT_INITIALIZE_METHODS: log calls to class +initialize methods
objc[10559]: OBJC_PRINT_RESOLVED_METHODS: log methods created by +resolveClassMethod: and +resolveInstanceMethod:
objc[10559]: OBJC_PRINT_CLASS_SETUP: log progress of class and category setup
objc[10559]: OBJC_PRINT_PROTOCOL_SETUP: log progress of protocol setup
objc[10559]: OBJC_PRINT_IVAR_SETUP: log processing of non-fragile ivars
objc[10559]: OBJC_PRINT_VTABLE_SETUP: log processing of class vtables
objc[10559]: OBJC_PRINT_VTABLE_IMAGES: print vtable images showing overridden methods
objc[10559]: OBJC_PRINT_CACHE_SETUP: log processing of method caches
objc[10559]: OBJC_PRINT_FUTURE_CLASSES: log use of future classes for toll-free bridging
objc[10559]: OBJC_PRINT_RTP: log initialization of the Objective-C runtime pages
objc[10559]: OBJC_PRINT_GC: log some GC operations
objc[10559]: OBJC_PRINT_PREOPTIMIZATION: log preoptimization courtesy of dyld shared cache
objc[10559]: OBJC_PRINT_CXX_CTORS: log calls to C++ ctors and dtors for instance variables
objc[10559]: OBJC_PRINT_EXCEPTIONS: log exception handling
objc[10559]: OBJC_PRINT_EXCEPTION_THROW: log backtrace of every objc_exception_throw()
objc[10559]: OBJC_PRINT_ALT_HANDLERS: log processing of exception alt handlers
objc[10559]: OBJC_PRINT_REPLACED_METHODS: log methods replaced by category implementations
objc[10559]: OBJC_PRINT_DEPRECATION_WARNINGS: warn about calls to deprecated runtime functions
objc[10559]: OBJC_PRINT_POOL_HIGHWATER: print high-water marks for autorelease pools
objc[10559]: OBJC_DEBUG_UNLOAD: warn about poorly-behaving bundles when unloaded
objc[10559]: OBJC_DEBUG_FRAGILE_SUPERCLASSES: warn about subclasses that may have been broken by subsequent changes to superclasses
objc[10559]: OBJC_DEBUG_FINALIZERS: warn about classes that implement -dealloc but not -finalize
objc[10559]: OBJC_DEBUG_NIL_SYNC: warn about @synchronized(nil), which does no synchronization
objc[10559]: OBJC_DEBUG_NONFRAGILE_IVARS: capriciously rearrange non-fragile ivars
objc[10559]: OBJC_DEBUG_ALT_HANDLERS: record more info about bad alt handler use
objc[10559]: OBJC_USE_INTERNAL_ZONE: allocate runtime data in a dedicated malloc zone
objc[10559]: OBJC_DISABLE_GC: force GC OFF, even if the executable wants it on
objc[10559]: OBJC_DISABLE_VTABLES: disable vtable dispatch
objc[10559]: OBJC_DISABLE_PREOPTIMIZATION: disable preoptimization courtesy of dyld shared cache
######################################################################################
IMO The following flags should be turned on for ALL (debug) builds to help you catch otherwise hard to find bugs.
OBJC_PRINT_REPLACED_METHODS
OBJC_PRINT_DEPRECATION_WARNINGS
OBJC_DEBUG_NIL_SYNC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment