2012-11-10 15 views

risposta

46

Ovviamente c'è. Se è possibile utilizzare il framework Cocoa:

NSLog(@"%@", [NSThread callStackSymbols]); 

(Documentation.)

Se non è possibile utilizzarlo:

#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.)

+0

Questo è molto utile, grazie. – mskw

4

Vedi NSThread callStackSymbols.

+0

Grazie per la rapida risposta! – mskw

Problemi correlati