iOS异常捕获-堆栈信息的解析

0 CoreFoundation 0x00000001d3bbc530 + 252
1 libobjc.A.dylib 0x00000001d2d979f8 objc_exception_throw + 56
2 CoreFoundation 0x00000001d3ad9278 + 0
3 UIKitCore 0x000000020015eef8 + 280
4 CoreFoundation 0x00000001d3bc1d60 + 1408
5 CoreFoundation 0x00000001d3bc39fc _CF_forwarding_prep_0 + 92
6 Test 0x000000010479766c Test + 570988
7 Test 0x0000000104793764 Test + 554852
8 Test 0x00000001049c1a94 Test + 2841236
9 UIKitCore 0x0000000200555c88 + 72
10 UIKitCore 0x0000000200540e2c + 760
11 UIKitCore 0x000000020033b2a0 + 292
12 Foundation 0x00000001d4609840 + 604
13 Foundation 0x00000001d455bccc + 68
14 Foundation 0x00000001d46056ec + 284
15 UIKitCore 0x000000020031c04c + 4576
16 UIKitCore 0x0000000200338a60 + 140
17 UIKitCore 0x00000002005bbe54 + 1292
18 QuartzCore 0x00000001d804a1f0 + 184
19 QuartzCore 0x00000001d804f198 + 332
20 QuartzCore 0x00000001d7fb20a8 + 348
21 QuartzCore 0x00000001d7fe0108 + 640
22 QuartzCore 0x00000001d7fe0cf8 + 92
23 CoreFoundation 0x00000001d3b4d89c + 32
24 CoreFoundation 0x00000001d3b485c4 + 412
25 CoreFoundation 0x00000001d3b48b40 + 1228
26 CoreFoundation 0x00000001d3b48354 CFRunLoopRunSpecific + 436
27 GraphicsServices 0x00000001d5d4879c GSEventRunModal + 104
28 UIKitCore 0x0000000200133b68 UIApplicationMain + 212
29 BetaWM.BAW 0x00000001047145e4 BetaWM.BAW + 34276
30 libdyld.dylib 0x00000001d360e8e0 + 4

这是什么鬼???不要慌!!!
这是crash日志。

下面我们来看看怎么解读上面的一堆日志。

异常信息

异常信息有三种类型:

1.已标记错误位置的:
test 0x000000010bfddd8c -[ViewController viewDidLoad] + 8588

这种信息已经很明确了,不用解析

2.有模块地址的情况:
test 0x00000001018157dc 0x100064000 + 24844252

以上面为例子,从左到右依次是:
二进制库名(test),调用方法的地址(0x00000001018157dc),模块地址(0x100064000)+偏移地址(24844252)

3.无模块地址的情况:
test 0x00000001018157dc test + 24844252

dSYM符号表获取

xcode->window->organizer->右键你的应用 show finder->右键.xcarchive 显示包内容->dSYMs->test.app.dYSM

atos命令

atos命令来符号化某个特定模块加载地址

atos [-arch 架构名] [-o 符号表] [-l 模块地址] [方法地址]

解析

使用终端,进到test.app.dYSM所在目录

一.如果是有模块地址的情况,运行:
atos -arch arm64 -o test.app.dSYM/Contents/Resources/DWARF/test -l 0x100064000 0x0000000101815
二.如果是无模块地址的情况

1.先将偏移地址转为16进制:

24844252 = 0x17B17DC

2.然后用'方法的地址-偏移地址',得到的就是'模块地址'

0x00000001018157dc - 0x17B17DC = 0x100064000

3.最后运行:

atos -arch arm64 -o test.app.dSYM/Contents/Resources/DWARF/test -l 0x100064000 0x0000000101815
/**
*有的同学会出现"atos cannot load symbols for the file"的错误提示,这是因为你没有进到test.app.dYSM所在目录,或者去除"test.app.dSYM/"再试试。
**/

进制转换:http://tool.oschina.net/hexconvert/
十六进制计算:http://www.ab126.com/system/2858.html
参考链接:https://blog.csdn.net/SeanHuang1661/article/details/56488719#0-tsina-1-51684-397232819ff9a47a7b7e80a40613cfe1

你可能感兴趣的:(iOS异常捕获-堆栈信息的解析)