美文网首页iOS开发专题
iOS崩溃信息分析实例

iOS崩溃信息分析实例

作者: wg689 | 来源:发表于2016-12-17 19:18 被阅读292次

    数组越界在现实中使用异常断点就可以很快定位,本文提供定位的新思路

    1. 数组越界
      只需要分析,下面红色框的就可以,coreFoundation,
    CoreFoundation                      0x00000001096d8e65 __exceptionPreprocess + 165
        1   libobjc.A.dylib                     0x000000010914fdeb objc_exception_throw + 48
        2   CoreFoundation                      0x00000001095c7534 -[__NSArrayI objectAtIndex:] + 164
    //----此处才是重点
        3   CrashDemo                           0x0000000108c4e6b5 -[ViewController test0] + 133
        4   CrashDemo                           0x0000000108c4e629 -[ViewController viewDidLoad] + 73
    // ---***上面才是重点,dylib, CoreFoundation, UIKit 都是系统的,非自己写的代码***
        5   UIKit                               0x000000010a026f98 -[UIViewController loadViewIfRequired] + 1198
        6   UIKit                               0x000000010a0272e7 -[UIViewController view] + 27
        7   UIKit                               0x0000000109efdab0 -[UIWindow addRootViewControllerViewIfPossible] + 61
        8   UIKit                               0x0000000109efe199 -[UIWindow _setHidden:forced:] + 282
        9   UIKit                               0x0000000109f0fc2e -[UIWindow makeKeyAndVisible] + 42
        10  UIKit                               0x0000000109e88663 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4131
        11  UIKit                               0x0000000109e8ecc6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1760
        12  UIKit                               0x0000000109e8be7b -[UIApplication workspaceDidEndTransaction:] + 188
        13  FrontBoardServices                  0x000000010dc88754 -[FBSSerialQueue _performNext] + 192
        14  FrontBoardServices                  0x000000010dc88ac2 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
        15  CoreFoundation                      0x0000000109604a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
        16  CoreFoundation                      0x00000001095fa95c __CFRunLoopDoSources0 + 556
        17  CoreFoundation                      0x00000001095f9e13 __CFRunLoopRun + 867
        18  CoreFoundation                      0x00000001095f9828 CFRunLoopRunSpecific + 488
        19  UIKit                               0x0000000109e8b7cd -[UIApplication _run] + 402
        20  UIKit                               0x0000000109e90610 UIApplicationMain + 171
        21  CrashDemo                           0x0000000108c4eb9f main + 111
        22  libdyld.dylib                       0x000000010c23692d start + 1
        23  ???                                 0x0000000000000001 0x0 + 1
    
    Snip20161217_3.png

    使用 Image lookup 命令定位到崩溃的地址行

    libc++abi.dylib: terminating with uncaught exception of type NSException
    (lldb) image lookup --0x00000001095c7534
    error: unknown or ambiguous option
    (lldb) image lookup --address 0x00000001095c7534
          Address: CoreFoundation[0x0000000000036534] (CoreFoundation.__TEXT.__text + 214148)
          Summary: CoreFoundation`-[__NSArrayI objectAtIndex:] + 164
    (lldb) image lookup --address 0x0000000108c4e629 
          Address: CrashDemo[0x0000000100001629] (CrashDemo.__TEXT.__text + 73)
          Summary: CrashDemo`-[ViewController viewDidLoad] + 73 at ViewController.m:25
    (lldb) image lookup --address 0x0000000108c4e629 
          Address: CrashDemo[0x0000000100001629] (CrashDemo.__TEXT.__text + 73)
          Summary: CrashDemo`-[ViewController viewDidLoad] + 73 at ViewController.m:25
    (lldb) image lookup --address 0x000000010a026f98 
          Address: UIKit[0x00000000001bbf98] (UIKit.__TEXT.__text + 1810648)
          Summary: UIKit`-[UIViewController loadViewIfRequired] + 1198
    (lldb) 
    

    详细的对比图如下

    Snip20161217_5.png

    基本上对比很多崩溃分析,只需要分析和工程名对应的行号的崩溃信息就可以,比如本例中只需要分析上图中的3,4,21 后面的崩溃信息,就可以找到原因

    --

    上图中的0-23是回溯,是闪退发生时所有活动帧清单。它包含闪退发生时调用函数的清单。帧的调用顺序是倒序的先23 再0 的,参考iOS应用崩溃日志分析


    相关文章

      网友评论

        本文标题:iOS崩溃信息分析实例

        本文链接:https://www.haomeiwen.com/subject/effamttx.html