See objc calls in call stack
I am debugging a Objective-C application开发者_Go百科 and would like to see the method calls in the ObjC library (for educational purposes!). What is the best way of doing this?
// print a stacktrace
NSLog(@"%@", [NSThread callStackSymbols]); // requires iOS 4
or
// print stacktrace using C functions
#import <execinfo.h>
#import <unistd.h>
void PrintStackTrace() {
void *stackAdresses[32];
int stackSize = backtrace(stackAdresses, 32);
backtrace_symbols_fd(stackAdresses, stackSize, STDOUT_FILENO);
}
or set a breakpoint in XCode to pause the execution and then type GDB commands in the console or just look at the stack in the debug navigator tab.
精彩评论