在做的项目中,用到了友盟的组件,在没有禁用错误日志上传之前,收集了一些错误日志。
有一些朋友看到了错误日志,却不知道怎么定位到程序的的代码中,实际上,这一步是非常的简单。
友盟没有集成.dSYM文件,只能显示错误的地址,无法显示详细的信息。
准备步骤,
1,友盟错误日志
*** -[__NSArrayM objectAtIndex:]: index 20 beyond bounds [0 .. 19]
(null)
(
"0 CoreFoundation 0x371308bf __exceptionPreprocess + 162",
"1 libobjc.A.dylib 0x317fe1e5 objc_exception_throw + 32",
"2 CoreFoundation 0x37079b6b -[__NSArrayM objectAtIndex:] + 270",
"3 aaaaa 0x0004af6f aaaaa + 302959",
"4 UIKit 0x3277d565 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 944",
"5 UIKit 0x327f5ce7 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 158",
"6 Foundation 0x31ba0943 __NSFireDelayedPerform + 414",
"7 CoreFoundation 0x37104a63 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14",
"8 CoreFoundation 0x371046c9 __CFRunLoopDoTimer + 364",
"9 CoreFoundation 0x3710329f __CFRunLoopRun + 1206",
"10 CoreFoundation 0x370864dd CFRunLoopRunSpecific + 300",
"11 CoreFoundation 0x370863a5 CFRunLoopRunInMode + 104",
"12 GraphicsServices 0x3123cfcd GSEventRunModal + 156",
"13 UIKit 0x326f8743 UIApplicationMain + 1090",
"14 aaaaa 0x00003687 aaaaa + 9863",
"15 aaaaa 0x00003144 aaaaa + 8516"
)
2.找到.dSYM文件,在编译程序时,会自动生成这个文件,
3.把应用 aaaaaa.app和 .dSYM文件放到一个目录中,
执行
atos -arch armv7 -o 'aaaaaa.app/aaaa' -l 0x0004af6f
这样就得到了程序错误的对应的源代码地址。
--------------------------------------
当然,如果你的程序很复杂,友盟的功能肯定不够使用。
友盟无法返回详细的信息,Binary Images, Thread 0 crashed with ARM Thread State.. 更主要的是,很许多的错误代码友盟无法收集,也无法收集更多的信息。
这时,你就需要更专业的日志处理方法。