在做的項目中,用到了友盟的組件,在沒有禁用錯誤日志上傳之前,收集了一些錯誤日志。
有一些朋友看到了錯誤日志,卻不知道怎么定位到程序的的代碼中,實際上,這一步是非常的簡單。
友盟沒有集成.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.. 更主要的是,很許多的錯誤代碼友盟無法收集,也無法收集更多的信息。
這時,你就需要更專業的日志處理方法。
