关于crash report和dSYM的使用

 所�^的 Crash Report 是在���w�C器上,�绦谐淌�r�l生 crash �r,此�r iOS ���兔�⒊淌匠鲥e的相�P�Y�存起�恚��@�r候用 Xcode 的 Organizer - Devices �r,可以去�c�x�O�洌��K且可以查看有哪些 report 在上�^,�@�r候就可以稍作�^看,但是上�^��的�Y�是有稍微�似做�^保�o的,只��看到�似(�@是�W路上收集的�Y�,但我�L�做出的 log 好像已��D好了?):

Thread 0 Crashed:
0   libSystem.B.dylib             	0x35de3ad0 0x######## + ##
1   libSystem.B.dylib             	0x35de3abe 0x######## + ##
2   libSystem.B.dylib             	0x35de3ab2 0x######## + ##
3   libSystem.B.dylib             	0x35dfad5e 0x######## + ##
4   libSystem.B.dylib             	0x35de967e 0x######## + ##
5   libSystem.B.dylib             	0x35de974c 0x######## + ##
6   libSystem.B.dylib             	0x35d5c8e0 0x######## + ##
7   libSystem.B.dylib             	0x35d5c798 0x######## + ##
8   CoreFoundation                	0x3750022c 0x######## + ##
9   CoreFoundation                	0x374fc206 0x######## + ##
10  CoreFoundation                	0x37504564 0x######## + ##
11  CoreFoundation                	0x37504406 0x######## + ##
12  Foundation                    	0x351530f0 0x######## + ##
13  CrashTesting                  	0x00002712 0x######## + ##
14  UIKit                         	0x35924fd0 0x######## + ##
15  UIKit                         	0x3591ea70 0x######## + ##
16  UIKit                         	0x358d82dc 0x######## + ##
17  UIKit                         	0x358d7b14 0x######## + ##
18  UIKit                         	0x358d73ac 0x######## + ##
19  GraphicsServices              	0x33e77c80 0x######## + ##
20  CoreFoundation                	0x3752f5c4 0x######## + ##
21  CoreFoundation                	0x3752f582 0x######## + ##
22  CoreFoundation                	0x3752182e 0x######## + ##
23  CoreFoundation                	0x37521504 0x######## + ##
24  CoreFoundation                	0x37521412 0x######## + ##
25  UIKit                         	0x3591d54c 0x######## + ##
26  UIKit                         	0x3591a550 0x######## + ##
27  CrashTesting                  	0x0000266e 0x######## + ##
28  CrashTesting                  	0x00002620 0x######## + ##

�@�r候需要使用原先��g app �r,在同一目�中���a生���的 dSYM �n案,搭配 dwarfdump 使用才可以查�到真正的片段程式(例如想看 line 13 的意思):

$ dwarfdump --lookup 0x00002712 -arch armv6 CrashTesting.app.dSYM/
----------------------------------------------------------------------
 File: CrashTesting.app.dSYM/Contents/Resources/DWARF/CrashTesting (armv6)
----------------------------------------------------------------------
Looking up address: 0x0000000000002712 in .debug_info... found!

0x00000132: Compile Unit: length = 0x000049b0  version = 0x0002  abbr_offset = 0x00000000  addr_size = 0x04  (next CU at 0x00004ae6)

0x0000013d: TAG_compile_unit [1] *
             AT_producer( "4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2373.6)" )
             AT_language( DW_LANG_ObjC )
             AT_name( "CrashTestingAppDelegate.m" )
             AT_entry_pc( 0x000026b4 )
             AT_stmt_list( 0x0000006b )
             AT_comp_dir( "/Volumes/Data/iPhoneDev/trunk/CrashTesting/CrashTesting" )
             AT_APPLE_major_runtime_vers( 0x02 )

0x00000166:     TAG_subprogram [16] *
                 AT_sibling( {0x000001d2} )
                 AT_name( "-[CrashTestingAppDelegate application:didFinishLaunchingWithOptions:]" )
                 AT_decl_file( "/Volumes/Data/iPhoneDev/trunk/CrashTesting/CrashTesting/CrashTestingAppDelegate.m" )
                 AT_decl_line( 17 )
                 AT_prototyped( 0x01 )
                 AT_type( {0x0000015b} ( BOOL ) )
                 AT_APPLE_isa( 0x01 )
                 AT_low_pc( 0x000026b4 )
                 AT_high_pc( 0x00002780 )
                 AT_frame_base( r7 )

0x000001b9:         TAG_lexical_block [5] *
                     AT_low_pc( 0x000026c4 )
                     AT_high_pc( 0x00002780 )
Line table file: 'CrashTestingAppDelegate.m' line 20, column 0 with start address 0x000000000000270e

Looking up address: 0x0000000000002712 in .debug_frame... found!

0x00000020: FDE
        length: 0x0000000c
   CIE_pointer: 0x00000000
    start_addr: 0x000026b4 -[CrashTestingAppDelegate application:didFinishLaunchingWithOptions:]
    range_size: 0x000000cc (end_addr = 0x00002780)
  Instructions: 0x000026b4: CFA=4294967295+4294967295

因此就可以查看到 line 13 是指 CrashTestingAppDelegate.m' line 20,所以就可以去那�追查看看。

以上的例子�H需建立一�� Project (此例名�� CrashTesting),然後在 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions �e�^��一段�� crash 的程式�a(此例�� double free):

    NSString *justCrash = [[NSString alloc] initWithFormat:@"CrashTesting"];
    [justCrash release];
    [justCrash release];

如此一�恚�在���C�绦型�K���C後,可以接上 Xcode 去 Organizer - Devices 查看:

xcode-crash-log

而 dSYM �n案,�t是在 Xcode ��g的地方:

xcode-dSYM

�c�x後,就可以看到�K且可以�}�u到��T的工作目���

xcode-app-dSYM

�⒖假Y料:

How to deal with an iPhone crash report

 

你可能感兴趣的:(ios)