一個字符串,在iOS上每一個可執行文件或庫文件都包含至少一個UUID,目的是爲了惟一識別這個文件。html
蘋果提供的命令行工具,其中一些功能就是查看可執行文件或庫文件的UUID。示例:c++
dwarfdump --uuid 應用名稱.app/應用名稱
dwarfdump --uuid 應用名稱.dSYM
蘋果提供的命令行工具,能夠將crash日誌符號化爲可讀的堆棧信息。XCode6/XCode7版本中,其路徑爲/Applications/Xcode.app/Contents/SharedFrameworks/DTDeviceKitBase.framework/Versions/A/Resources/symbolicatecrashapi
蘋果提供的命令行工具,能夠將crash的base_address和load_address轉化爲可讀的堆棧信息。symbolicatecrash就是使用這個命令來作符號化的。cookie
模擬器/Mac應用崩潰後能夠在「~/Library/Logs/DiagnosticReports/」下找到crash日誌。app
手機和mac鏈接後,打開Xcode選擇window進入 Devices標籤欄。 以下圖所示: ide
選擇「View Device Logs」按鈕,就能夠看到崩潰日誌: 函數
日誌存放的路徑 ~/Library/Logs/CrashReporter/MobileDevice/DEVICE_NAME,DEVICE_NAME是你想要查看的設備。 工具
app在真機設備上Crash後,咱們可讓iOS設備和mac鏈接,而後打開Xcode選擇window進入 Devices標籤欄. 在左側的導航面板上,選中設備,單擊「View Device Logs」按鈕,就能夠看到已經符號化完畢的日誌。如圖所示:oop
symbolicatecrash是蘋果隨Xcode一塊兒提供的專門用來作崩潰日誌符號化的腳本工具(perl)。ui
symbolicatecrash存放路徑是
「/Applications/Xcode.app/Contents/SharedFrameworks/DTDeviceKitBase.framework/Versions/A/Resources/symbolicatecrash"
由於symbolicatecrash能夠獨立使用,所以咱們能夠把它複製到指定的目錄下,如放到根目錄的bin文件夾下面,而後將相應的crash和dsym文件拷貝到該目錄下,以下圖所示:
使用方法是:
./symbolicatecrash ./*.crash ./*.app.dSYM > symbol.crash
【注意】:終端有可能會出現:Error: "DEVELOPER_DIR" is not defined at ./symbolicatecrash line 60,遇到該錯誤的時候,在終端輸入以下命令:
export DEVELOPER_DIR="/Applications/XCode.app/Contents/Developer"
以下圖所示:
生成的symbol.crash以下圖所示:
### 1.進程信息 ### Incident Identifier: 2F6FE1EF-0653-4CF1-A83B-27DF7D57D152 CrashReporter Key: 06a7a1ed53669f0375772f0765603cbd2d2cb414 Hardware Model: iPhone6,2 Process: newPatient [9506] Path: /private/var/mobile/Containers/Bundle/Application/00B0A0AD-628A-4795-9654-B9E440BA6F14/newPatient.app/newPatient Identifier: com.haodf.newPatient Version: 10840 (3.4.1) Code Type: ARM-64 (Native) Parent Process: launchd [1] ### 2.基本信息 ### Date/Time: 2016-03-16 16:59:41.41 +0800 Launch Time: 2016-03-16 16:59:39.39 +0800 OS Version: iOS 9.2.1 (13D15) Report Version: 105 ### 3.異常信息 ### Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Triggered by Thread: 0 Filtered syslog: None found ### 4.線程回溯 ### Last Exception Backtrace: 0 CoreFoundation 0x180e99900 __exceptionPreprocess + 124 1 libobjc.A.dylib 0x180507f80 objc_exception_throw + 56 2 CoreFoundation 0x180d7fac4 -[__NSArrayI objectAtIndex:] + 196 3 newPatient 0x100a7970c 0x100098000 + 10360588 4 newPatient 0x101083114 0x100098000 + 16691476 5 UIKit 0x185cc1f38 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1316 6 UIKit 0x185d80018 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 376 7 UIKit 0x185e3cb70 _runAfterCACommitDeferredBlocks + 292 8 UIKit 0x185e4a030 _cleanUpAfterCAFlushAndRunDeferredBlocks + 92 9 UIKit 0x185b7dc24 _afterCACommitHandler + 96 10 CoreFoundation 0x180e50588 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32 11 CoreFoundation 0x180e4e32c __CFRunLoopDoObservers + 372 12 CoreFoundation 0x180e4e75c __CFRunLoopRun + 928 13 CoreFoundation 0x180d7d680 CFRunLoopRunSpecific + 384 14 GraphicsServices 0x18228c088 GSEventRunModal + 180 15 UIKit 0x185bf4d90 UIApplicationMain + 204 16 newPatient 0x1008da544 0x100098000 + 8660292 17 libdyld.dylib 0x18091e8b8 start + 4 Global Trace Buffer (reverse chronological seconds): 1.076547 CFNetwork 0x0000000181513104 TCP Conn 0x1557dcd60 complete. fd: 14, err: 0 1.077687 CFNetwork 0x0000000181514630 TCP Conn 0x1557dcd60 event 1. err: 0 1.127049 CFNetwork 0x0000000181514708 TCP Conn 0x1557dcd60 started 1.198354 CFNetwork 0x0000000181513104 TCP Conn 0x15686f720 complete. fd: 14, err: 0 1.202190 CFNetwork 0x0000000181514630 TCP Conn 0x15686f720 event 1. err: 0 1.269881 CFNetwork 0x0000000181514708 TCP Conn 0x15686f720 started 1.329771 CFNetwork 0x0000000181513104 TCP Conn 0x1557abdc0 complete. fd: 14, err: 0 1.331608 CFNetwork 0x0000000181514630 TCP Conn 0x1557abdc0 event 1. err: 0 1.390077 CFNetwork 0x0000000181514708 TCP Conn 0x1557abdc0 started 1.390513 CFNetwork 0x0000000181513104 TCP Conn 0x1557b78e0 complete. fd: 15, err: 0 1.391615 CFNetwork 0x0000000181514630 TCP Conn 0x1557b78e0 event 1. err: 0 1.404025 CFNetwork 0x000000018147184c TCP Conn 0x15680f4b0 SSL Handshake DONE 1.438749 CFNetwork 0x000000018147175c TCP Conn 0x15680f4b0 starting SSL negotiation 1.439767 CFNetwork 0x0000000181513104 TCP Conn 0x15680f4b0 complete. fd: 17, err: 0 1.440554 CFNetwork 0x0000000181514708 TCP Conn 0x1557b78e0 started 1.440838 CFNetwork 0x0000000181514630 TCP Conn 0x15680f4b0 event 1. err: 0 1.444573 CFNetwork 0x0000000181513104 TCP Conn 0x156812200 complete. fd: 19, err: 0 1.446372 CFNetwork 0x0000000181514630 TCP Conn 0x156812200 event 1. err: 0 1.457398 CFNetwork 0x0000000181514708 TCP Conn 0x15680f4b0 started 1.458434 CFNetwork 0x0000000181514708 TCP Conn 0x156812200 started 1.483722 CFNetwork 0x000000018147184c TCP Conn 0x15680bbe0 SSL Handshake DONE 1.527764 CFNetwork 0x000000018147175c TCP Conn 0x15680bbe0 starting SSL negotiation 1.530029 CFNetwork 0x0000000181513104 TCP Conn 0x15680bbe0 complete. fd: 4, err: 0 1.532408 CFNetwork 0x0000000181514630 TCP Conn 0x15680bbe0 event 1. err: 0 1.574343 CFNetwork 0x0000000181514708 TCP Conn 0x15680bbe0 started 1.577344 CFNetwork 0x00000001815698bc Creating default cookie storage with default identifier 1.577438 CFNetwork 0x0000000181569888 Faulting in CFHTTPCookieStorage singleton 1.577438 CFNetwork 0x00000001815bb558 Faulting in NSHTTPCookieStorage singleton Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libsystem_kernel.dylib 0x0000000180a3c140 __pthread_kill + 8 1 libsystem_pthread.dylib 0x0000000180b04ef8 pthread_kill + 112 2 libsystem_c.dylib 0x00000001809addac abort + 140 3 libc++abi.dylib 0x00000001804e13f4 __cxa_bad_cast + 0 4 libc++abi.dylib 0x00000001804fde98 default_unexpected_handler() + 0 5 libobjc.A.dylib 0x0000000180508248 _objc_terminate() + 124 6 libc++abi.dylib 0x00000001804faf44 std::__terminate(void (*)()) + 16 7 libc++abi.dylib 0x00000001804fab10 __cxa_rethrow + 144 8 libobjc.A.dylib 0x0000000180508120 objc_exception_rethrow + 44 9 CoreFoundation 0x0000000180d7d728 CFRunLoopRunSpecific + 552 10 GraphicsServices 0x000000018228c088 GSEventRunModal + 180 11 UIKit 0x0000000185bf4d90 UIApplicationMain + 204 12 newPatient 0x00000001008da544 0x100098000 + 8660292 13 libdyld.dylib 0x000000018091e8b8 start + 4 Thread 1: 0 libsystem_kernel.dylib 0x0000000180a3cb6c __workq_kernreturn + 8 1 libsystem_pthread.dylib 0x0000000180b01530 _pthread_wqthread + 1284 2 libsystem_pthread.dylib 0x0000000180b01020 start_wqthread + 4 Thread 2 name: Dispatch queue: com.apple.libdispatch-manager Thread 2: 0 libsystem_kernel.dylib 0x0000000180a3d4fc kevent_qos + 8 1 libdispatch.dylib 0x000000018090094c _dispatch_mgr_invoke + 232 2 libdispatch.dylib 0x00000001808ef7bc _dispatch_source_invoke + 0 //省略了部分線程日誌 ### 5.線程狀態 ### Thread 0 crashed with ARM Thread State (64-bit): x0: 0x0000000000000000 x1: 0x0000000000000000 x2: 0x0000000000000000 x3: 0x000000015578ece7 x4: 0x00000001804fee02 x5: 0x000000016fd674d0 x6: 0x000000000000006e x7: 0x0000000000000fa0 x8: 0x0000000008000000 x9: 0x0000000004000000 x10: 0x0000000000000002 x11: 0x0000000000000010 x12: 0x0000000000000000 x13: 0x0000000000000002 x14: 0x0000000000000000 x15: 0x0000030000000300 x16: 0x0000000000000148 x17: 0x0000000000000000 x18: 0x0000000000000000 x19: 0x0000000000000006 x20: 0x000000019e4bc000 x21: 0x000000016fd674d0 x22: 0x0000000155516bf0 x23: 0x000000019e4c7b68 x24: 0x0000000000000001 x25: 0x87001a44017766b4 x26: 0x0000000155504e80 x27: 0x0000000000000000 x28: 0x0000000000000001 fp: 0x000000016fd67430 lr: 0x0000000180b04ef8 sp: 0x000000016fd67410 pc: 0x0000000180a3c140 cpsr: 0x00000000 ### 6.動態庫信息 ### Binary Images: 0x100098000 - 0x1015cbfff newPatient arm64 <9d28622234923355a849412ab7062230> /var/mobile/Containers/Bundle/Application/00B0A0AD-628A-4795-9654-B9E440BA6F14/newPatient.app/newPatient 0x1200cc000 - 0x1200fbfff dyld arm64 <9e98992ceed735e2ac4784cb28efe7c1> /usr/lib/dyld 0x180488000 - 0x180489fff libSystem.B.dylib arm64 <c4cd04b37e5f34698856a9384aefff40> /usr/lib/libSystem.B.dylib 0x18048c000 - 0x1804dffff libc++.1.dylib arm64 <d430d0ad16893b76bbc52468f65d5906> /usr/lib/libc++.1.dylib 0x1804e0000 - 0x1804fffff libc++abi.dylib arm64 <1c0a8ef87e8c37b2a577dc1a44e2b16e> /usr/lib/libc++abi.dylib 0x180500000 - 0x18086cfff libobjc.A.dylib arm64 <da8e482b3e7d3c40a798a0c86a3d6890> /usr/lib/libobjc.A.dylib 0x180870000 - 0x180874fff libcache.dylib arm64 <242f50f854a1301fa6f76b4531101238> /usr/lib/system/libcache.dylib 0x180878000 - 0x180883fff libcommonCrypto.dylib arm64 <962b6da2f76d3b22afb83adeb2b030ef> /usr/lib/system/libcommonCrypto.dylib 0x180884000 - 0x180887fff libcompiler_rt.dylib arm64 <516b8400a98f3a4fb8f82780faca4b31> /usr/lib/system/libcompiler_rt.dylib 0x180888000 - 0x18088ffff libcopyfile.dylib arm64 <c027b29d770e3a5e83aa48463916d3ed> /usr/lib/system/libcopyfile.dylib 0x180890000 - 0x1808ebfff libcorecrypto.dylib arm64 <f3daba6e74753ddc9d7a3df953621d46> /usr/lib/system/libcorecrypto.dylib //省略了部分日誌
這部分是閃退進程的相關信息。
這部分給出了一些基本信息,包括閃退發生的日期和時間,設備的iOS版本。若是有不少崩潰日誌都來自iOS 6.0,說明問題只發生在iOS 6.0上。
在這部分,你能夠看到閃退發生時拋出的異常類型。還能看到異常編碼和拋出異常的線程。根據崩潰報告類型的不一樣,在這部分你還能看到一些另外的信息。
這部分提供應用中全部線程的回溯日誌。 回溯是閃退發生時全部活動幀清單。它包含閃退發生時調用函數的清單。看下面這行日誌:
2 CoreFoundation 0x34648e88 0x83000 + 224
這條調用棧包括下面四部分:
這部分是閃退時寄存器中的值。通常不須要這部分的信息,由於回溯部分的信息已經足夠讓你找出問題所在。
這些信息包括動態庫名稱、UUID、模塊起始地址、模塊結束地址、指令集種類、安裝路徑等信息。
這些信息都是在符號化堆棧用到的。
*** -[__NSArrayI objectAtIndex:]: index 3 beyond bounds [0 .. 2] (null) ( 0 CoreFoundation 0x00000001853142f4 <redacted> + 160 1 libobjc.A.dylib 0x0000000196f900e4 objc_exception_throw + 60 2 CoreFoundation 0x00000001851f7b34 CFRunLoopRemoveTimer + 0 3 ????????? 0x000000010005e9c4 ????????? + 338372 4 UIKit 0x0000000189dff124 <redacted> + 404 5 UIKit 0x000000018a0167e8 <redacted> + 2376 6 UIKit 0x000000018a01919c <redacted> + 1504 7 UIKit 0x000000018a01770c <redacted> + 184 8 FrontBoardServices 0x000000018db513c8 <redacted> + 32 9 CoreFoundation 0x00000001852cc27c <redacted> + 20 10 CoreFoundation 0x00000001852cb384 <redacted> + 312 11 CoreFoundation 0x00000001852c99a8 <redacted> + 1756 12 CoreFoundation 0x00000001851f52d4 CFRunLoopRunSpecific + 396 13 UIKit 0x0000000189df83d0 <redacted> + 552 14 UIKit 0x0000000189df2f40 UIApplicationMain + 1488 15 ????????? 0x00000001000cbb14 ????????? + 785172 16 libdyld.dylib 0x000000019763aa08 <redacted> + 4 ) dSYM UUID: 5FFF54D6-71B5-37F5-AB11-4D7111E27BE2 CPU Type: arm64 Slide Address: 0x0000000100000000 Binary Image: ??? Base Address: 0x000000010000c000
方法一:從友盟下載錯誤分析工具,按以下步驟操做:
./umcrashtool //Users/GofLee/crash/zhaibuzhu.csv
方法二:使用dSYM協助分析(我通常用這個),操做很簡單,截圖以下:
略
略