前言
当我们有时候拿到Crash
日志,发现里面都有很多的<redacted>
,日志里面有一个很明显的特征是没有APP内的方法调用
,全部都是系统库的调用,用dSYM
也无法解析,比如这样:
OS Version: iOS 14.8.1 (18H107)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: BUS_NOOP at 0x0000603700000000
Crashed Thread: 30
Application Specific Information:
setState: >
Attempted to dereference garbage pointer 0x603700000000.
Thread 30 Crashed:
0 CoreFoundation 0x307023b40 CFDictionaryGetValue
1 Foundation 0x30968bffc [inlined] <redacted>
2 Foundation 0x30968bffc <redacted>
3 CFNetwork 0x307f7c264 _CFNetworkHTTPConnectionCacheSetLimit
4 Foundation 0x3096b3b2c <redacted>
5 Foundation 0x3095b06d8 <redacted>
6 Foundation 0x3096b5dc8 <redacted>
7 Foundation 0x3095b0394 <redacted>
8 Foundation 0x3096b67c0 <redacted>
9 Foundation 0x3096b628c <redacted>
10 libdispatch.dylib 0x3069e5b34 <redacted>
11 libdispatch.dylib 0x306a03298 <redacted>
12 libdispatch.dylib 0x3069dba70 <redacted>
13 libdispatch.dylib 0x3069db294 <redacted>
14 libdispatch.dylib 0x3069e82c4 <redacted>
15 libdispatch.dylib 0x3069e8a5c <redacted>
16 libsystem_pthread.dylib 0x397c6b580 _pthread_wqthread
对于这种情况,就需要通过一些特殊手段,符号化系统库
来解析日志了
如何符号化
要将系统库的<redacted>
符号解析为完整的方法名调用,就需要有系统库的符号文件
提取对应的符号文件
系统库的符号文件不是通用的,在对应crash日志里面有详细的信息:
OS Version: iOS 14.8.1 (18H107)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: BUS_NOOP at 0x0000603700000000
Crashed Thread: 30
那么这个日志就需要iOS 14.8.1 (18H107)
的文件来解析了
获取系统符号文件的方法
-
苹果并没有提供系统库符号文件的下载,当我们用XCode首次连接手机进行调试的时候,这时候就会看到XCode显示
Processing symbol files
,其实是在拷贝真机上的符号文件到我们的电脑上面/Users/xxx/Library/Developer/Xcode/iOS DeviceSupport
通常这类文件都会比较大,所以我们首次连接手机调试的时候会比较慢。
比如上面的crash发生在iOS 14.8.1
设备上,我们就可以找一个14.8.1的手机连接到XCode提取系统符号 -
寻找热心网友收集到的符号文件。有网友收集到了符号文件,将其放在了Google硬盘上
https://drive.google.com/drive/folders/1EQPNNY9BPxuYmFdPovIx0eyIJcLodOtN
收集符号文件放到指定目录
我们收集到对应版本的符号文件,放到电脑上的~/Library/Developer/Xcode/iOS DeviceSupport
解析
使用Xcode自带的符号化工具symbolicatecrash
进行符号化。这个工具会自动搜索系统库符号文件.
OS Version: iOS 14.8.1 (18H107)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: BUS_NOOP at 0x003f836300000000
Crashed Thread: 27
Application Specific Information:
ithTimeout: > setState: >
Attempted to dereference garbage pointer 0x3f836300000000.
Thread 27 Crashed:
0 CoreFoundation 0x324b2dcb0 CFDictionaryGetValue
1 Foundation 0x3272d4c90 [inlined] _NSSetLongLongValueAndNotify
2 Foundation 0x3272d4c90 _NSSetLongLongValueAndNotify
3 CFNetwork 0x325afe358 _CFNetworkHTTPConnectionCacheSetLimit
4 Foundation 0x3272fef84 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__
5 Foundation 0x3271ec624 -[NSBlockOperation main]
6 Foundation 0x3273013ac __NSOPERATION_IS_INVOKING_MAIN__
7 Foundation 0x3271ec2ac -[NSOperation start]
8 Foundation 0x327301e50 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__
9 Foundation 0x3273018dc __NSOQSchedule_f
10 libdispatch.dylib 0x3244f9480 _dispatch_block_async_invoke2
11 libdispatch.dylib 0x3244ea818 _dispatch_client_callout
12 libdispatch.dylib 0x3244edcf0 _dispatch_continuation_pop
13 libdispatch.dylib 0x3244ed380 _dispatch_async_redirect_invoke
14 libdispatch.dylib 0x3244fbfdc _dispatch_root_queue_drain
15 libdispatch.dylib 0x3244fc7d4 _dispatch_worker_thread2
16 libsystem_pthread.dylib 0x3bc8d1764 _pthread_wqthread
本文首次发布于 孙忠良 Blog, 作者 [@sunzhongliang] , 转载请保留原文链接.