根据fir获取的BugHD崩溃栈和文件描述符解析原始崩溃栈
fir获取的BugHD崩溃栈
错误堆栈 KSCrash libobjc.A.dylib 183341b90 objc_msgSend 105360 KSCrash CoreFoundation 183ba5b44 _CFArrayReplaceValues 23364 KSCrash CoreFoundation 183ba5994 CFArrayAppendValue 22932 KSCrash CoreFoundation 183c7eb04 912132 KSCrash CoreFoundation 183ba8c50 CFRunLoopRunSpecific 35920 KSCrash GraphicsServices 185490088 GSEventRunModal 49288 KSCrash UIKit 188e92088 UIApplicationMain 516232 KSCrash caocao 1001adc44 _mh_execute_header 990276 KSCrash libdyld.dylib 1837468b8 10424
xcode->windows->organizer 选中对应版本打的包击右键->show in finder->选中对应版本打的包击右键显示包内容->选中dSYMs->选中对应版本打的包击右键显示包内容,打开方式选终端->cd ..回到dSYM目录
Last login: Tue Jul 12 10:13:24 on ttys003 laojia:caocao.app.dSYM jiaguoshang$ pwd /Users/jiaguoshang/Library/Developer/Xcode/Archives/2016-07-07/caocao 2 16-7-7 上午10.37.xcarchive/dSYMs/caocao.app.dSYM laojia:caocao.app.dSYM jiaguoshang$ cd .. laojia:dSYMs jiaguoshang$ pwd /Users/jiaguoshang/Library/Developer/Xcode/Archives/2016-07-07/caocao 2 16-7-7 上午10.37.xcarchive/dSYMs
laojia:dSYMs jiaguoshang$ dwarfdump --lookup 183341b90 -arch armv7 caocao.app.dSYM ---------------------------------------------------------------------- File: caocao.app.dSYM/Contents/Resources/DWARF/caocao (armv7) ---------------------------------------------------------------------- Looking up address: 0x000000000002cc2d in .debug_info... found! 0x0007077b: Compile Unit: length = 0x000026e9 version = 0x0002 abbr_offset = 0x00000000 addr_size = 0x04 (next CU at 0x00072e68) 0x00070786: TAG_compile_unit [133] * AT_producer( "Apple LLVM version 7.3.0 (clang-703.0.29)" ) AT_language( DW_LANG_ObjC ) AT_name( "/Users/jiaguoshang/Desktop/司机1.3.28/CaocaoDriver/caocao/viewcontroller/main/BookingListViewController.m" ) AT_stmt_list( 0x00014051 ) AT_comp_dir( "/Users/jiaguoshang/Desktop/司机1.3.28/CaocaoDriver" ) AT_APPLE_optimized( 0x01 ) AT_APPLE_major_runtime_vers( 0x02 ) AT_low_pc( 0x00022518 ) AT_high_pc( 0x0003318c ) 0x00072042: TAG_subprogram [187] * AT_low_pc( 0x0002bda4 ) AT_high_pc( 0x0002e312 ) AT_frame_base( r7 ) AT_name( "__53-[BookingListViewController ConfirmReceiveBookOrder:]_block_invoke" ) AT_decl_file( "/Users/jiaguoshang/Desktop/司机1.3.28/CaocaoDriver/caocao/viewcontroller/main/BookingListViewController.m" ) AT_decl_line( 1947 ) AT_prototyped( 0x01 ) AT_APPLE_optimized( 0x01 ) AT_APPLE_isa( 0x01 ) 0x0007207b: TAG_lexical_block [168] * AT_ranges( 0x00001468 [0x0002bdd6 - 0x0002be24) [0x0002c00e - 0x0002c21a) [0x0002c532 - 0x0002c596) [0x0002c726 - 0x0002cc44) [0x0002cd5e - 0x0002cf5a) [0x0002d09e - 0x0002d1c4) [0x0002d208 - 0x0002e2cc) End ) 0x0007213e: TAG_lexical_block [168] * AT_ranges( 0x000014f0 [0x0002c9aa - 0x0002ca24) [0x0002ca2e - 0x0002cad4) [0x0002cc22 - 0x0002cc44) [0x0002cd5e - 0x0002cf5a) [0x0002d09e - 0x0002d0e0) [0x0002d0ea - 0x0002d1c4) [0x0002d208 - 0x0002d22e) [0x0002d238 - 0x0002d2b0) [0x0002d32e - 0x0002d46e) End ) Line table dir : '/Users/jiaguoshang/Desktop/司机1.3.28/CaocaoDriver/caocao/viewcontroller/main' Line table file: 'BookingListViewController.m' line 2062, column 29 with start address 0x000000000002cc2c Looking up address: 0x000000000002cc2d in .debug_frame... found! 0x00002020: FDE length: 0x0000000c CIE_pointer: 0x00000000 start_addr: 0x0002bda4 __53-[BookingListViewController ConfirmReceiveBookOrder:]_block_invoke range_size: 0x0000256e (end_addr = 0x0002e312) Instructions: 0x0002bda4: CFA=sp
可以看到是在刷新表格时数据源数组元素增加引起的。这个问题很让人头大啊!
注意:
编译宏中的代码出现闪退,是解析不出崩溃信息的。当然系统自己释放内存等崩溃也是解析不出崩溃栈有用信息的。
编译宏是为了统一修改,减少重复代码而设计的,他要求编译宏中的代码使用者负者。编译器不替你检查。所以编译宏有优店也有缺点,复杂的代码还是用全局静态函数代替编译宏为号。
如下列编译宏:
#define dispatch_main_sync_safe(block)\ if ([NSThread isMainThread]) {\ block();\ } else {\ dispatch_sync(dispatch_get_main_queue(), block);\ }
这样使用:
dispatch_main_sync_safe(^{ if(self.hitOnLineTime > 0) { if(self.onLineFailedBlock != nil) { self.onLineFailedBlock(YES); } self.hitOnLineTime = 0; self.socketConnectStat = SOCKECT_CONNECT_INIT; } });
若里面出现崩溃的问题,就解析不出崩溃栈,也不能单步跟踪到编译宏包含住的代码部分。