2011-08-24 74 views
9

我使用下面的代碼從我的iOS應用程序中獲得的崩潰報告:在iOS崩潰報告中獲取線程特定信息?

void *frames[128]; 
int i,len = backtrace(frames, 128); 
char **symbols = backtrace_symbols(frames,len); 

NSMutableString *buffer = [[NSMutableString alloc] initWithCapacity:4096]; 

NSBundle *bundle = [NSBundle mainBundle]; 
[buffer appendFormat:@"PComp version %@ build %@\n\n", 
    [bundle objectForInfoDictionaryKey:@"CFBundleVersion"], 
    [bundle objectForInfoDictionaryKey:@"CIMBuildNumber"]]; 
[buffer appendString:@"Uncaught C++ Exception\n"]; 
[buffer appendString:@"Stack trace:\n\n"]; 
for (i = 0; i < len; ++i) { 
    [buffer appendFormat:@"%4d - %s\n",i,symbols[i]]; 
} 

這隻會提供有關當前線程的信息?我怎麼能得到這個所有線程的堆棧跟蹤?

回答