Of course there is. If you can use the Cocoa framework:
NSLog(@"%@", [NSThread callStackSymbols]);
(Documentation.)
If you can't use it:
#include <execinfo.h>
int size = 256;
void *stack[size];
size = backtrace(stack, size);
char **syms = backtrace_symbols(stack, size);
for (int i = 0; i < size; i++) {
printf("Frame #%d: %s\n", i, syms[i]);
}
free(syms);
(Documentation.)
参考http://stackoverflow.com/questions/13319551/how-to-nslog-a-call-stack-when-a-program-is-running