使用工具分析iOS奔溃日志

写在前言

基本上我们每个app发布之后都要拿到线上的崩溃日志来收集起来,线下来根据崩溃日志来进行修改代码,或者直接热更新修复。

最近我们公司在实施这个的时候,碰到了一个问题,那就是我们抓取的崩溃日志有些具体定位不到哪个文件,哪行。然后经过在网上的一番搜索,找出了方法,来分享给大家。

一个普通的崩溃日志:

-[UITableViewCellScrollView selectedBtn]: unrecognized selector sent to instance 0x178d51f0*2016-09-23 11:46:19---[ 
0 CoreFoundation 0x2fdb9f9b (redacted) 154, 
1 libobjc.A.dylib 0x3a56accf objc_exception_throw 38, 
2 CoreFoundation 0x2fdbd917 (redacted) 202, 
3 CoreFoundation 0x2fdbc203 (redacted) 706, 
4 CoreFoundation 0x2fd0b768 _CF_forwarding_prep_0 24, 
5 GyyxGuangYuTong 0x000aa839 -[AccountClosureController selectedBtnClick:] 790, 
6 UIKit 0x3260c037 (redacted) 90, 
7 UIKit 0x3260bfd7 (redacted) 30, 
8 UIKit 0x3260bfb1 (redacted) 44, 
9 UIKit 0x325f7717 (redacted) 374, 
10 UIKit 0x3260ba2f (redacted) 590, 
11 UIKit 0x325cef13 (redacted) 5522, 
12 UIKit 0x32606d49 (redacted) 772, 
13 UIKit 0x3260666f (redacted) 666, 
14 UIKit 0x325db8cd (redacted) 196, 
15 UIKit 0x325d9f77 (redacted) 7102, 
16 CoreFoundation 0x2fd8520b (redacted) 14, 
17 CoreFoundation 0x2fd846db (redacted) 206, 
18 CoreFoundation 0x2fd82ecf (redacted) 622, 
19 CoreFoundation 0x2fcedebf CFRunLoopRunSpecific 522, 
20 CoreFoundation 0x2fcedca3 CFRunLoopRunInMode 106, 
21 GraphicsServices 0x34bf3663 GSEventRunModal 138, 
22 UIKit 0x3263a14d UIApplicationMain 1136, 
23 GyyxGuangYuTong 0x000bf41f main 106, 
24 libdyld.dylib 0x3aa77ab7 (redacted) 2 ]

在这个崩溃日志中,我们可以很轻易地看到[AccountClosureController selectedBtnClick:]是这里崩溃了。知道崩溃的位置,我们就可以做修改了,

一个错误的崩溃日志(看不到具体位置):

*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds for empty array
*2016-10-19 21:48:02---[ 
0 CoreFoundation 0x0000000186d325b8 (redacted) 160, 
1 libobjc.A.dylib 0x00000001974400e4 objc_exception_throw 60, 
2 CoreFoundation 0x0000000186c1762c (redacted) 0, 
3 GyyxGuangYuTong 0x00000001000e79e0 GyyxGuangYuTong 440800, 
4 UIKit 0x000000018b60cca4 (redacted) 1280, 
5 UIKit 0x000000018b6ca5f0 (redacted) 276, 
6 UIKit 0x000000018b566e80 (redacted) 356, 
7 UIKit 0x000000018b4d8794 (redacted) 532, 
8 CoreFoundation 0x0000000186ceaa50 (redacted) 32, 
9 CoreFoundation 0x0000000186ce79dc (redacted) 360, 
10 CoreFoundation 0x0000000186ce7dbc (redacted) 836, 
11 CoreFoundation 0x0000000186c150a4 CFRunLoopRunSpecific 396, 
12 GraphicsServices 0x000000018fdbf5a4 GSEventRunModal 168, 
13 UIKit 0x000000018b54a3c0 UIApplicationMain 1488, 
14 GyyxGuangYuTong 0x0000000100098854 GyyxGuangYuTong 116820, 
15 libdyld.dylib 0x0000000197aaea08 (redacted) 4 ]

大家要注意这一行

3 GyyxGuangYuTong 0x00000001000e79e0 GyyxGuangYuTong 440800,
14 GyyxGuangYuTong 0x0000000100098854 GyyxGuangYuTong 116820,

我们要找具体的崩溃地方就要从这里来找。

GyyxGuangYuTong 这个是app名 也就是你的app的名字

0x00000001000e79e0

这个是崩溃的内存地址

440800

我理解这个应该是一个偏移量

下面我们就来找具体的崩溃的地方:
借助工具:
dSYM 文件分析工具
新地址: http://pan.baidu.com/s/1mg01Q
ha系统10.11.X 以上可用
源码地址:
https://github.com/answer-huang/dSYMTools
这就是工具:


QQ20161021-0.png

dsym文件要从这里要找:
1.


QQ20161021-1.png


2.


tmp58e94416.png


3.


tmp3b5dd07c.png


4.


tmp32986eed.png


5.


tmp2f14de51.png


6.


tmp0fb15665.png


7.


tmp74327638.png

这就是dysm文件了,线上什么版本就需要对应版本的dysm文件,要不然抓取不到。平常我们开发的时候崩溃也可以安装这种方法来定位。

下面就开始定位log:


1.png

随便选择一个版本。

错误内存地址就填写上面的0x00000001000e79e0
slide Address呢?
slide Address 需要计算:
计算公式
slide Address十进制= 0x00000001000e79e0 转换十进制 - 后面的偏移量
然后将slide Address十进制 转换为十六进制
注意计算的时候把0X去掉 这是16进制的标志~~~,那就是00000001000e79e0
转换后的十进制为4295916000 然后- 偏移量440800
得到十进制address:4 295 475 200
转换为16进制:0x10007c000

然后点击分析


2.png

这就是我们想要的结果。

有些崩溃是这样的

*** -[__NSArrayM objectAtIndex:]: index 4294967295 beyond bounds for empty array
(null)
(
0   CoreFoundation                      0x330dc3ff  + 186
1   libobjc.A.dylib                     0x3add7963 objc_exception_throw + 30
2   CoreFoundation                      0x33027ef9  + 164
3   appname                            0xcbcaf appname + 830639
4   appname                            0x40bc1 appname + 261057
5   appname                            0x3d297 appname + 246423
6   UIKit                               0x34f36569  + 408
7   UIKit                               0x34f1b391  + 1316
8   UIKit                               0x34f32827  + 206
9   UIKit                               0x34eee8c7  + 258
10  QuartzCore                          0x34c9a513  + 214
11  QuartzCore                          0x34c9a0b5  + 460
12  QuartzCore                          0x34c9afd9  + 16
13  QuartzCore                          0x34c9a9c3  + 238
14  QuartzCore                          0x34c9a7d5  + 316
15  QuartzCore                          0x34c9a639  + 60
16  CoreFoundation                      0x330b1941  + 20
17  CoreFoundation                      0x330afc39  + 276
18  CoreFoundation                      0x330aff93  + 746
19  CoreFoundation                      0x3302323d CFRunLoopRunSpecific + 356
20  CoreFoundation                      0x330230c9 CFRunLoopRunInMode + 104
21  GraphicsServices                    0x36c0233b GSEventRunModal + 74
22  UIKit                               0x34f3f2b9 UIApplicationMain + 1120
23  appname                            0xf3df appname + 58335
24  appname                            0x3578 appname + 9592
)

dSYM UUID: 365EF56E-D598-3B94-AD36-BFA13772A4E3
CPU Type: armv7s
Slide Address: 0x00001000
Binary Image: appname
Base Address: 0x000c3000

这样的都不用算,地址已经给出来了。。。
所以你应该会了。

有什么不懂得可以给我留言,相互交流。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值