如何在其他线程中打印主线程的回溯?
在其他线程中,我想打印主线程的回溯。有适合我的完整代码吗?
做类似的事情:
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"Trace = %@", [NSThread callStackSymbols]);
});
查看此代码(GPLv3):BSBacktraceLogger
+ (NSString *)bs_backtraceOfCurrentThread {
return [self bs_backtraceOfNSThread:[NSThread currentThread]];
}
+ (NSString *)bs_backtraceOfMainThread {
return [self bs_backtraceOfNSThread:[NSThread mainThread]];
}