手动解析崩溃日志
xcrun atos 系统的符号化工具也是使用该命令实现的,我们可以基于这个实现一些我们特性化的功能。 dwarfdump -u <DSYM_FILE> 可以得到该文件的uuid,用以查看是否和crash应用加载的库是否一致 一致可以开始下一步
eg: aTrust APP 奔溃日志
Thread 27 name: com.facebook.react.JavaScript
Thread 27 Crashed:
0 libsystem_kernel.dylib 0x1b7512964 __pthread_kill + 8
1 libsystem_pthread.dylib 0x1f10fc378 pthread_kill + 268
2 libsystem_c.dylib 0x18b3aaf50 abort + 164
3 libc++abi.dylib 0x198ce9bc4 abort_message + 132
4 libc++abi.dylib 0x198cdafc0 demangling_terminate_handler() + 308
5 libobjc.A.dylib 0x198be8074 _objc_terminate() + 160
6 libc++abi.dylib 0x198ce8f58 std::__terminate(void (*)()) + 20
7 libc++abi.dylib 0x198cebc5c __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 36
8 libc++abi.dylib 0x198cebc08 __cxa_throw + 140
9 libc++.1.dylib 0x198c886bc std::__1::__throw_system_error(int, char const*) + 100
10 libc++.1.dylib 0x198c89214 std::__1::random_device::random_device(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) + 144
11 hermes 0x10505738c 0x104fa8000 + 717708
12 hermes 0x104fc9d14 0x104fa8000 + 138516
13 hermes 0x104fe1c04 0x104fa8000 + 236548
14 hermes 0x104fe35c0 0x104fa8000 + 243136
15 hermes 0x104fe2cb4 0x104fa8000 + 240820
16 hermes 0x104fc9f28 0x104fa8000 + 139048
17 hermes 0x104fc9884 0x104fa8000 + 137348
18 hermes 0x104fe1c10 0x104fa8000 + 236560
19 hermes 0x104fe35c0 0x104fa8000 + 243136
20 hermes 0x104fe2cb4 0x104fa8000 + 240820
21 hermes 0x104fc9f28 0x104fa8000 + 139048
22 hermes 0x104fc8d3c 0x104fa8000 + 134460
23 hermes 0x105068780 0x104fa8000 + 788352
24 hermes 0x104fc9d14 0x104fa8000 + 138516
25 hermes 0x104fe1c04 0x104fa8000 + 236548
26 hermes 0x104fe35c0 0x104fa8000 + 243136
27 hermes 0x104fe2cb4 0x104fa8000 + 240820
28 hermes 0x104fc9f28 0x104fa8000 + 139048
29 hermes 0x104fc9884 0x104fa8000 + 137348
30 hermes 0x104fb434c 0x104fa8000 + 49996
31 aTrust 0x104a3b104 0x104850000 + 2011396
32 aTrust 0x104a6d1f8 0x104850000 + 2216440
33 aTrust 0x104a6d05c 0x104850000 + 2216028
34 aTrust 0x104901d70 0x104850000 + 728432
35 aTrust 0x104a6a538 0x104850000 + 2204984
36 aTrust 0x104a13c7c 0x104850000 + 1850492
37 aTrust 0x10495e2b4 0x104850000 + 1106612
38 aTrust 0x10496a5d4 0x104850000 + 1156564
39 aTrust 0x10496a388 0x104850000 + 1155976
40 CoreFoundation 0x180546924 CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 28
41 CoreFoundation 0x180547820 __CFRunLoopDoBlocks + 412
42 CoreFoundation 0x1804dfb80 __CFRunLoopRun + 1728
43 CoreFoundation 0x1804f33b8 CFRunLoopRunSpecific + 600
44 aTrust 0x1049532f8 0x104850000 + 1061624
45 Foundation 0x181d5e36c NSThread__start + 808
46 libsystem_pthread.dylib 0x1f10f69a4 _pthread_start + 148
47 libsystem_pthread.dylib 0x1f10f5ea0 thread_start + 8
loadAddress 表示函数的动态加载地址,对应崩溃地址堆栈中 + 号前面的地址,即0x104850000 address 表示运行时地址、对应崩溃地址堆栈中第一个地址,即0x10496a388
实际上,崩溃地址堆栈中+号前后的地址相加即是运行时地址,即0x104850000 + 1155976 = 0x10496a388
xcrun atos -o <SymbolFile> -arch <architecture> -l <loadAddress> <addr1> <addr2> ...
之后进入交互阶段, 输入地址即可知道符号位置
SymbolFile 符号文件位置
architecture 架构 i386,armv7s,arm64, x86_64
loadAddress 库加载位置
addrs 要解析的地址 或者不输入则进入交互状态
终端执行:
xcrun atos -o /Users/fly/Desktop/crash/aTrust.app.dSYM/Contents/Resources/DWARF/aTrust -arch arm64 -l 0x104850000 0x10496a388