如何在其他线程中打印主线程的回溯?

问题描述 投票:0回答:2

如何在其他线程中打印主线程的回溯?

在其他线程中,我想打印主线程的回溯。有适合我的完整代码吗?

ios objective-c backtrace
2个回答
0
投票

做类似的事情:

dispatch_async(dispatch_get_main_queue(), ^{
   NSLog(@"Trace = %@", [NSThread callStackSymbols]);
});

0
投票

查看此代码(GPLv3):BSBacktraceLogger

+ (NSString *)bs_backtraceOfCurrentThread {
    return [self bs_backtraceOfNSThread:[NSThread currentThread]];
}

+ (NSString *)bs_backtraceOfMainThread {
    return [self bs_backtraceOfNSThread:[NSThread mainThread]];
}
© www.soinside.com 2019 - 2024. All rights reserved.