解析IOS崩溃日志(crash Log)

转自

http://lieyunye.github.io/blog/2013/09/10/how-to-analyse-ios-crash-log/

http://blog.csdn.net/smking/article/details/9342899


  1. 最近在解析umeng错误分析日志上有了重大突破!  
  2.   
  3.   很显然,我们的应用免不了crash,各种各样的crash,不过大部分在提交至appstore前经过严格的“消毒”后,所剩无几了。but(这个词..)漏网之鱼总是有的嘛(貌似很多..囧)。好吧,看下文:  
  4.   
  5.   首先看一些这些线上app crash 信息:  
  6.   
  7. * Application received signal SIGSEGV  
  8. * Application received signal SIGBUS  
  9. * -[__NSArrayM objectAtIndex:]: index 4294967295 beyond bounds for empty array  
  10. * -[JKArray objectAtIndex:]: index (0) beyond bounds (0)  
  11. SIGSEGV和SIGBUS一般是因为访问已被释放的内存或者调用不存在的方法导致的,余下两个就是数组越界的问题了 这些你都知道的,然后来看看具体的log信息:  
  12.   
  13. Application received signal SIGSEGV  
  14.   
  15. Application received signal SIGSEGV  
  16. (null)  
  17. (  
  18. 0   CoreFoundation                      0x32f1c3ff  + 186  
  19. 1   libobjc.A.dylib                     0x3ac17963 objc_exception_throw + 30  
  20. 2   CoreFoundation                      0x32f1c307  + 106  
  21. 3   appname                            0x14e1e1 appname + 1364449  
  22. 4   libsystem_c.dylib                   0x3b08bd33 _sigtramp + 34  
  23. 5   appname                            0x97525 appname + 615717  
  24. 6   CoreFoundation                      0x32e6d349 _CFXNotificationPost + 1420  
  25. 7   Foundation                          0x337879cd  + 168  
  26. 8   Foundation                          0x337876c1  + 136  
  27. 9   appname                            0x96f2f appname + 614191  
  28. 10  Foundation                          0x33858915  + 16  
  29. 11  Foundation                          0x33798769  + 200  
  30. 12  Foundation                          0x33798685  + 60  
  31. 13  CFNetwork                           0x32bf964f  + 26  
  32. 14  CFNetwork                           0x32bf8d33  + 54  
  33. 15  CFNetwork                           0x32c21013  + 18  
  34. 16  CoreFoundation                      0x32e62acd CFArrayApplyFunction + 176  
  35. 17  CFNetwork                           0x32c21473  + 74  
  36. 18  CFNetwork                           0x32b85461  + 188  
  37. 19  CoreFoundation                      0x32ef18f7  + 14  
  38. 20  CoreFoundation                      0x32ef115d  + 212  
  39. 21  CoreFoundation                      0x32eeff2f  + 646  
  40. 22  CoreFoundation                      0x32e6323d CFRunLoopRunSpecific + 356  
  41. 23  CoreFoundation                      0x32e630c9 CFRunLoopRunInMode + 104  
  42. 24  GraphicsServices                    0x36a4233b GSEventRunModal + 74  
  43. 25  UIKit                               0x34d7f2b9 UIApplicationMain + 1120  
  44. 26  appname                            0xf3df appname + 58335  
  45. 27  appname                            0x3578 appname + 9592  
  46. )  
  47.   
  48. dSYM UUID365EF56E-D598-3B94-AD36-BFA13772A4E3  
  49. CPU Type: armv7s  
  50. Slide Address0x00001000  
  51. Binary Image: appname  
  52. Base Address0x000f7000  
  53. –[__NSArrayM objectAtIndex:]: index 4294967295 beyond bounds for empty array  
  54.   
  55. *** -[__NSArrayM objectAtIndex:]: index 4294967295 beyond bounds for empty array  
  56. (null)  
  57. (  
  58. 0   CoreFoundation                      0x330dc3ff  + 186  
  59. 1   libobjc.A.dylib                     0x3add7963 objc_exception_throw + 30  
  60. 2   CoreFoundation                      0x33027ef9  + 164  
  61. 3   appname                            0xcbcaf appname + 830639  
  62. 4   appname                            0x40bc1 appname + 261057  
  63. 5   appname                            0x3d297 appname + 246423  
  64. 6   UIKit                               0x34f36569  + 408  
  65. 7   UIKit                               0x34f1b391  + 1316  
  66. 8   UIKit                               0x34f32827  + 206  
  67. 9   UIKit                               0x34eee8c7  + 258  
  68. 10  QuartzCore                          0x34c9a513  + 214  
  69. 11  QuartzCore                          0x34c9a0b5  + 460  
  70. 12  QuartzCore                          0x34c9afd9  + 16  
  71. 13  QuartzCore                          0x34c9a9c3  + 238  
  72. 14  QuartzCore                          0x34c9a7d5  + 316  
  73. 15  QuartzCore                          0x34c9a639  + 60  
  74. 16  CoreFoundation                      0x330b1941  + 20  
  75. 17  CoreFoundation                      0x330afc39  + 276  
  76. 18  CoreFoundation                      0x330aff93  + 746  
  77. 19  CoreFoundation                      0x3302323d CFRunLoopRunSpecific + 356  
  78. 20  CoreFoundation                      0x330230c9 CFRunLoopRunInMode + 104  
  79. 21  GraphicsServices                    0x36c0233b GSEventRunModal + 74  
  80. 22  UIKit                               0x34f3f2b9 UIApplicationMain + 1120  
  81. 23  appname                            0xf3df appname + 58335  
  82. 24  appname                            0x3578 appname + 9592  
  83. )  
  84.   
  85. dSYM UUID365EF56E-D598-3B94-AD36-BFA13772A4E3  
  86. CPU Type: armv7s  
  87. Slide Address0x00001000  
  88. Binary Image: appname  
  89. Base Address0x000c3000  
  90. 好了,相信你也看出来了,这些具体的crash log 什么都看不出来,都是一些内存地址,帧调用栈等,所以需要进一步的解析,看下文:  
  91.   
  92. 看一下上面的crash log,找到一句  
  93.   
  94. 5   appname                            0x97525 appname + 615717  
  95. 它指出了应用名称,崩溃时的调用方法的地址,文件的地址以及方法所在的行的位置(具体请看这篇文章),接下来就要符号化(Symbolication)这句,用dwarfdump来检测crash log中dSYM UUID和本地的dSYM文件是否匹配  
  96.   
  97. 打开终端:  
  98.   
  99. cd /Users/username/Library/Developer/Xcode/Archives/2013-08-30/app 8-30-13 6.19 PM.xcarchive/dSYMs  
  100. dwarfdump --uuid appname.app.dSYM  
  101. UUID: 9F0AEFA6-4349-30AF-8420-BCEE739DA0B4 (armv7) appname.app.dSYM/Contents/Resources/DWARF/appname  
  102. UUID: 365EF56E-D598-3B94-AD36-BFA13772A4E3 (armv7s) appname.app.dSYM/Contents/Resources/DWARF/appname  
  103. OK,crash log中的dSYM UUID与本地的dYSM文件是相匹配的。好接下来就查一下0x97525这个地址是什么,  
  104.   
  105. dwarfdump --arch=armv7 --lookup 0x97525  /Users/username/Library/Developer/Xcode/Archives/2013-08-30/appname\ 8-30-136.19\ PM.xcarchive/dSYMs/appname.app.dSYM/Contents/Resources/DWARF/appname  
  106. 得到的结果:  
  107.   
  108. ----------------------------------------------------------------------  
  109. File: /Users/username/Library/Developer/Xcode/  Archives/2013-08-30/appname 8-30-13 6.19    PM.xcarchive/dSYMs/appname.app.dSYM/Contents/   Resources/DWARF/appname (armv7)  
  110. ----------------------------------------------------------------------  
  111. Looking up address0x0000000000097525 in .debug_info... found!  
  112.   
  113. 0x00359c67: Compile Unit: length = 0x000066f1  version = 0x0002  abbr_offset = 0x00000000  addr_size = 0x04  (next CU at 0x0036035c)  
  114.   
  115. 0x00359c72: TAG_compile_unit [1] *  
  116.          AT_producer( "Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)" )  
  117.          AT_language( DW_LANG_ObjC )  
  118.          AT_name( "xxx/EGOImageView.m" )  
  119.          AT_low_pc( 0x0009710c )  
  120.          AT_stmt_list( 0x000655c1 )  
  121.          AT_comp_dir( "xxx" )  
  122.          AT_APPLE_optimized( 0x01 )  
  123.          AT_APPLE_major_runtime_vers( 0x02 )  
  124.   
  125. 0x00359e57:     TAG_subprogram [10] *  
  126.              AT_name( "-[EGOImageView imageLoaderDidFailToLoad:]" )  
  127.              AT_decl_file( "xxx/EGOImageView.m" )  
  128.              AT_decl_line( 96 )  
  129.              AT_prototyped( 0x01 )  
  130.              AT_APPLE_isa( 0x01 )  
  131.              AT_low_pc( 0x00097490 )  
  132.              AT_high_pc( 0x00097572 )  
  133.              AT_frame_base( r7 )  
  134.              AT_object_pointer( {0x00359e6e} )  
  135. Line table dir : 'xxx'  
  136. Line table file'EGOImageView.m' line 99, column 2 with start address 0x00000000000974fe  
  137.   
  138. Looking up address0x0000000000097525 in .debug_frame... found!  
  139.   
  140. 0x0000c620: FDE  
  141.     length0x0000000c  
  142.     CIE_pointer0x00000000  
  143.     start_addr0x00097490 -[EGOImageView imageLoaderDidFailToLoad:]  
  144. range_size: 0x000000e2 (end_addr = 0x00097572)  
  145. Instructions: 0x00097490: CFA=4294967295+4294967295  
  146. 看一下结果:发现有AT_name、Line table dir :、Line table file:,aha!找到了出错的地方(出错的这个文件是网上别人写的,有bug,现已不再使用)。  
  147.   
  148. 注意:如果发现warning: unsupported file type:错误,这个问题是因为有文件或者目录的名称中包含空格,比如:2013-08-30/appname 8-30-13 6.19 ,所以,需要转义一下:2013-08-30/appname\ 8-30-136.19\ PM.xcarchive 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值