ios开发 如何利用 友盟统计 或者 百度统计 进行 错误分析

来源:互联网 发布:淘宝助手怎么导出订单 编辑:程序博客网 时间:2024/06/06 16:35

当我们的 app 开发完成 并切 上线之后, 会被  很多用户去使用,在他们使用的 过程中 可能会 由于各种原因 导致  程序 崩溃 ,如果我们不关心这个问题, 就不可能 做出 健壮的 app。


我们可以自己 写 code 来 捕获异常 ,在 app 崩溃之前 将  异常内容 固化成文件 ,在 app 下次 启动时   再将 异常 信息 上传到 我们的服务器  供我们 分析  , 也可以使用  统计平台都  错误分析 功能  ,百度或者 友盟 都有  错误 统计 和分析 功能 。


具体怎么使用 统计 sdk , 下载完 sdk 后 文档 说的都很清楚,我就不 解释了 。


下 面说一下 ,获取到 异常 信息后 如何 使用  dwarfdump 工具 在 .dsym文件中 找出  出错的 代码 位置 。

1、首先 你要 有 dsym 文件才行   ,dsym 文件的位置  由于 打包的方式不同 可能  不同 ,如果你是 直接 build 出来的  ,那么 在 你 对应的  .app 文件相同目录下就可以看到 dsym文件,如果你是  菜单栏中  product -> archive  ,archive 完了 打开 Organizer ->Archives  中 打的包 ,那么你的 dsym 文件将在 对应 的 archive 中的 dsyms 文件夹下 。

2、获取 异常日志 

登录友盟统计平台 ,进入制定 app ,点击 左边栏 里的 错误分析 , 这样就可以看到 错误列表 ,

比如:

Application received signal SIGSEGV2.1.5208652014-06-06 15:31:55点击该错误 可以看到 详细信息

Application received signal SIGSEGV(null)(0   CoreFoundation                      0x2f471f23  + 1541   libobjc.A.dylib                     0x39f38ce7 objc_exception_throw + 382   CoreFoundation                      0x2f471e4d  + 03   aaaaaaaa                        0x8aa981 _ZNSt3__113__vector_baseIP10OneRequestNS_9allocatorIS2_EEED2Ev + 11347364   libsystem_platform.dylib            0x3a55071b _sigtramp + 345   aaaaaaaa                        0x7439e9 _ZNSt3__113__vector_baseIP9OnePacketNS_9allocatorIS2_EEED2Ev + 30446   aaaaaaaa                        0x749769 _ZN14BasicHashTable8IteratorD2Ev + 5687   aaaaaaaa                        0x760f93 _ZN12THREAD_MUTEXC2Ev + 128108   libsystem_pthread.dylib             0x3a554959  + 1409   libsystem_pthread.dylib             0x3a5548cb _pthread_start + 10210  libsystem_pthread.dylib             0x3a552ae8 thread_start + 8)dSYM UUID: 8AA8370C-D292-3051-BF23-B46128B941E2CPU Type: armv7Slide Address: 0x00004000Binary Image: FengYunZhiBoBase Address: 0x00025000
3、使用 dwarfdump 导出 异常信息 

进入 终端 输入,$dSYMPath  就是 第一步获取的  dsym 文件的路径 ,然后回车,就可以看到 错误信息了


dwarfdump --arch=armv7 --lookup 0x8aa981 $dSYMPath

0x0172f6da: Compile Unit: length = 0x00005ec0  version = 0x0002  abbr_offset = 0x00000000  addr_size = 0x04  (next CU at 0x0173559e)


0x0172f6e5: TAG_compile_unit [233] *

             AT_producer( "Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)" )

             AT_language( DW_LANG_C99 )

             AT_name( "libavformat/rtpenc.c" )

             AT_low_pc( 0x008a9e14 )

             AT_stmt_list( 0x0027eb6a )

             AT_comp_dir( "/Users/fyzb0/Desktop/ffmpegFastBuild/build/src/ffmpeg-2.1" )

             AT_APPLE_optimized( 0x01 )


0x01734bec:     TAG_subprogram [351] *

                 AT_name( "rtp_write_packet" )

                 AT_decl_file( "libavformat/rtpenc.c" )

                 AT_decl_line( 483 )

                 AT_prototyped( 0x01 )

                 AT_type( {0x01730ca0} ( int ) )

                 AT_APPLE_isa( 0x01 )

                 AT_low_pc( 0x008aa37c )

                 AT_high_pc( 0x008aaba4 )

                 AT_frame_base( r7 )

                 AT_APPLE_omit_frame_ptr( 0x01 )


0x01734c8b:         TAG_lexical_block [51] *

                     AT_ranges( 0x0011e928

                        [0x008aa5b4 - 0x008aab8c)

                        [0x008aab96 - 0x008aaba4)

                         End )

Line table dir : 'libavformat'

Line table file: 'rtpenc.c' line 322, column 0 with start address 0x00000000008aa968


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


0x00036e30: FDE

        length: 0x0000000c

   CIE_pointer: 0x00000000

    start_addr: 0x008aa37c rtp_write_packet

    range_size: 0x00000828 (end_addr = 0x008aaba4)

  Instructions: 0x008aa37c: CFA=4294967295+4294967295









0 0
原创粉丝点击