Print callstack at runtime (XCode)
问题 Is it possible? I have found solution for Visual Studio Print n levels of callstack? 回答1: To print a backtrace at runtime programmatically, you can use this function: #import <execinfo.h> void PrintBacktrace ( void ) { void *callstack[128]; int frameCount = backtrace(callstack, 128); char **frameStrings = backtrace_symbols(callstack, frameCount); if ( frameStrings != NULL ) { // Start with frame 1 because frame 0 is PrintBacktrace() for ( int i = 1; i < frameCount; i++ ) { printf("%s\n",