有些崩溃难以复现只能依赖第三方统计出来的崩溃日志,比如友盟,bugly
下面是友盟的崩溃日志
有些日志直接指出了导致崩溃的方法名,上图这种是没有方法名的,SIGSEGV这种一般是空指针,访问了已释放或不存在的内存/方法导致的
找到带有项目名的行
6 appname 0x100265cc0 appname + 2514112
打开终端
cd /Users/username/Library/Developer/Xcode/Archives/2018-07-18/app 2018-7-18 下午8.04.xcarchive/dSYMs
dwarfdump --uuid appname.app.dSYM
打印出的uuid:
UUID: 00078AA1-1A5C-3E4D-81D4-BB3311CA091C (armv7) appname.app.dSYM/Contents/Resources/DWARF/appname
UUID: AB729AFB-727A-3AB1-8331-22698D7D5AA4 (arm64) appname.app.dSYM/Contents/Resources/DWARF/appname
终端输入:
dwarfdump --arch=arm64 --lookup 0x100b9de78 /Users/username/Library/Developer/Xcode/Archives/2018-07-18/appname\ 2018-7-18\ 下午10.07.xcarchive/dSYMs/appname.app.dSYM/Contents/Resources/DWARF/appname
打印:
----------------------------------------------------------------------
File: /Users/username/Library/Developer/Xcode/Archives/2018-07-18/appname 2018-7-18 下午10.07.xcarchive/dSYMs/appname.app.dSYM/Contents/Resources/DWARF/appname (arm64)
----------------------------------------------------------------------
Looking up address: 0x0000000100106214 in .debug_info... found!
0x000fb3b4: Compile Unit: length = 0x000050b3 version = 0x0002 abbr_offset = 0x00000000 addr_size = 0x08 (next CU at 0x0010046b)
0x000fb3bf: TAG_compile_unit [125] *
AT_producer( "Apple LLVM version 9.1.0 (clang-902.0.39.2)" )
AT_language( DW_LANG_ObjC )
AT_name( "/Users/username/Desktop/yourproject/appname/Main/Expand/Socket/SocketRocket/SRWebSocket.m" )
AT_stmt_list( 0x000967c7 )
AT_comp_dir( "/Users/username/Desktop/yourproject" )
AT_APPLE_optimized( 0x01 )
AT_APPLE_major_runtime_vers( 0x02 )
AT_low_pc( 0x00000001000ff5d4 )
AT_high_pc( 0x00000001001062c0 )
0x000ff200: TAG_subprogram [173] *
AT_low_pc( 0x0000000100106118 )
AT_high_pc( 0x0000000100106244 )
AT_frame_base( reg29 )
AT_object_pointer( {0x000ff221} )
AT_name( "-[_SRRunLoopThread main]" )
AT_decl_file( "/Users/username/Desktop/yourproject/appname/Main/Expand/Socket/SocketRocket/SRWebSocket.m" )
AT_decl_line( 1837 )
AT_prototyped( 0x01 )
AT_APPLE_optimized( 0x01 )
0x000ff23f: TAG_lexical_block [134] *
AT_low_pc( 0x000000010010613c )
AT_high_pc( 0x0000000100106244 )
Line table dir : '/Users/username/Desktop/yourproject/appname/Main/Expand/Socket/SocketRocket'
Line table file: 'SRWebSocket.m' line 1860, column 16 with start address 0x0000000100106200
这行打印定位到了崩溃的文件和行数:
Line table file: 'SRWebSocket.m' line 1860, column 16 with start address 0x0000000100106200