xcode怎么xcode查看崩溃日志crash日志

Xcode崩溃日志分析工具symbolicatecrash用法 - 简书
下载简书移动应用
写了2991字,被25人关注,获得了33个喜欢
Xcode崩溃日志分析工具symbolicatecrash用法
什么是symbolicatecrash
symbolicatecrash是Xcode自带的一个分析工具,可以通过机器上的崩溃日志和应用的.dSYM文件定位发生崩溃的位置,把crash日志中的一堆地址替换成代码相应位置。
为什么要用symbolicatecrash
开发者调试错误只需要有真机,并且连接到xcode上,就可以跟踪发现错了。但是如果你的APP不是安装在你自己的真机上,比如你的APP发布到App Store(客户下载后你如何跟踪你的APP在他们的机器上?)这时候就要用到symbolicatecrash。当一款APP软件在IOS设备上崩溃的时候,一份“crash report”将会自动创建并且存储在设备上。crash report描述了APP崩溃的日志。在大多数情况下,包括对每个线程执行一个完整的堆栈跟踪,查看该日志对于APP崩溃调试非常有用。
如何查看iphone上的崩溃日志
// ios8之前设置通用关于本机诊断与用量诊断与用量数据
// iOS 8设置隐私诊断与用量诊断与用量数据
如何同步设备日志到我们的mac上
如果是其他用户并且是APP Store下的APP需要用户在'如何查看iphone上的崩溃日志'中,将《自动发送》开启,打开《与应用开发者共享》,这样用户的APP崩溃后,会提示发送崩溃日志到开发者,开发者就可以在iTunes Connect中下载这些崩溃日志。如果是手中的真机直接将IPHONE连接到iTunes,打开xcode-&window-&devices,导出你需要的崩溃日志即可
如何使用symbolicatecrash分析崩溃日志
Step 1:在你的MAC桌面创建一个新文件夹,并且命名为"CrashReport"
Step 2:打开前往应用程序,找到 Xcode 应用程序, 右击它选中 "显示包内容" ,之后根据下面提供的路径
Xcode6.0之前:"Contents-&Developer-&Platforms-&iPhoneOS.platform-&Developer-&Library-&PrivateFrameworks-&DTDeviceKit.framework-&Versions-&A-&Resources"
"Contents-&Developer-&Platforms-&iPhoneOS.platform-&Developer-&Library-&PrivateFrameworks-&DTDeviceKitBase.framework-&Versions-&A-&Resources"
Xcode6.0之后改成 "Contents/SharedFrameworks"
实在找不到可以打开终端输入 find /Applications/Xcode.app -name symbolicatecrash -type f ,然后终端会返回这个文件的路径
只要找到"symbolicatecrash" 文件, 复制然后粘贴到刚才创建的 "CrashReport" 文件夹里面.
Step 3: 从Xcode Archive的二进制文件中找到.dSYM文件和.app文件拷贝到刚才创建的 "CrashReport" 文件夹里面.
Step 4:打开终端进入CrashReport文件夹,依次输入以下命令行:cd /Users/username/Desktop/CrashReport
export DEVELOPER_DIR=/Applications/XCode.app/Contents/Developer
./symbolicatecrash ./*.crash ./*.app.dSYM & symbol.crash这时候终端将会进行处理......处理结果是生成一个新的文件symbol.crash。然后打开这个文件。你就会看到日志跟我们调试APP的控制台输出的内容一样了!
你应该看到的是这样的
--EOF--若无特别说明,本站文章均为原创,转载请保留链接,谢谢
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
被以下专题收入,发现更多相似内容:
搜集些和码农有关系的东西
· 365人关注
小技巧,新技能
· 188人关注
· 37人关注
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
选择支付方式:主题 : xcode6 如何查看.crash文件
级别: 侠客
可可豆: 415 CB
威望: 417 点
在线时间: 192(时)
发自: Web Page
来源于&&分类
xcode6 如何查看.crash文件&&&
游戏被拒,说会崩溃,苹果发来几个.crash文件。但是看不到具体的内容。按照这个帖子。但是xcode6没有Device Logs有谁知道如何查看?
级别: 新手上路
可可豆: 73 CB
威望: 13 点
在线时间: 253(时)
发自: Web Page
&Window“ / &Devices&  / &View Device Logs&
图片:未命名 2.png
图片:未命名 3.png
级别: 侠客
可可豆: 415 CB
威望: 417 点
在线时间: 192(时)
发自: Web Page
回 1楼(wan2171) 的帖子
级别: 侠客
可可豆: 530 CB
威望: 545 点
在线时间: 181(时)
发自: Web Page
回 1楼(wan2171) 的帖子
但是是 别人的 .crash&& 我怎么看呢? 这个只能看 这台机器的&&。。。
级别: 新手上路
可可豆: 73 CB
威望: 13 点
在线时间: 253(时)
发自: Web Page
回 3楼(getlee) 的帖子
让他把crash导出给你啊 Mac上可以双击直接在控制台查看的1、xcode获取
2、iTunes同步获取大部分用户可能都会使用iTunes软件来管理iPhone或者iPad设备,这时候同步的Crash日志就会同步到电脑上,我们只需要在特定的路径里面寻找即可。Mac OS X:~/Library/Logs/CrashReporter/MobileDeviceWindows XP:C:\Documents and Settings\Application Data\Apple computer\Logs\CrashReporterWindows 7/Vista: C:\Users\计算机登录名\AppData\Roaming\Apple Computer\Logs\CrashReporter\MobileDevice3、使用第三方软件:itools等如果你平时不用iTunes,而是使用itools(windows版) 这类第三方的软件对iPhone设备进行管理,也是没问题的。打开itools,在你的设备下,找到“高级功能”,点击“崩溃日志”,然后将需要的日志导出到电脑里面就可以了!
级别: 侠客
可可豆: 530 CB
威望: 545 点
在线时间: 181(时)
发自: Web Page
回 4楼(wan2171) 的帖子
&& 嗯多谢, 后来自己找到了哈
关注本帖(如果有新回复会站内信通知您)
4*5+2 正确答案:22
发帖、回帖都会得到可观的积分奖励。
按"Ctrl+Enter"直接提交
关注CocoaChina
关注微信 每日推荐
扫一扫 浏览移动版iPhone真机调试日志读取 iPhone Crash Logs
1.同步应用程序以后,找到你要查看的日志文件,日志文件对应mac的位置,xp\vista的位置.
2.发现日志文件都是看不懂的16进制,如何进行转换成我们看得懂的内容.
3.使用命令行工具 &symbolicatecrash&来进行转换,可以把 工具复制到任何地方都可以调用的路径:sudo cp/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKit.framework/Versions/A/Resources/symbolicatecrash /usr/local/bin/
4.讲了 &symbolicatecrash& 工具怎么用.一般只要:symbolicatecrash report.crashMobileLines.app.dSYM & report-with-symbols.crash,就可以了
5.注意说明的是,你在用Xcode debug打包的时候,会生成两个东西,一个是XXX.app,另一个是XXX.app.dSYM,这两个是相对应的,与我写的第4点里的 MobileLines.app.dSYM是对应起来的.这里的日志文件必须是你打包的那个版本,不然就没有解析出你的日志文件了.通俗的说,你安装到手机上的app和这个dSYM,是配对的,如果你想要看这个手机上的日志文件,那你必须保存对应的dSYM文件去解析日志文件.每一次重新打包都会重新生成dSYM文件.
6.好了,你可以根据你的 report-with-symbols.crash,日志文件来看看你的程序哪里出问题了
Sometimes programs crash. This annoys users and developers alike. Users are frustrated because they cannot use crashing software, developers are frustrated because they have to hunt bugs instead of doing something creative and rewarding. How do we communicate if an iPhone application crashes?
I&ll start with a disclaimer. I&m not sure whether the information provided in this post is covered by iPhone Developer Program NDA or not. If it is, the post will be removed. Secondly, this post is a result of googling, so I haven&t invented anything new here.
Working with crash logs typically involves certain interaction between developers and users, unless they are automagically sent to the developer. First of all, the user should get the crash log and send it to the developer, who should examine it, find the bug and fix it.
iPhone OS and Mac OS X are remarkably similar architectures. Both store crash logs to help identify crashing bugs. The difference between the two is how users retrieve them. On Mac OS X every user has unrestricted access to crash logs related to the applications she runs. The iPhone does not even have a file browser. What to do? iTunes comes to the rescue.
Whenever you synchronize your iPhone or iPod Touch, all the crash logs are transferred to your computer. Here are their locations:
&&Mac OS X:~/Library/Logs/CrashReporter/MobileDevice/&DEVICE_NAME&
&&Windows XP:C:\Documents and Settings\&USERNAME&\Application Data\Apple computer\Logs\CrashReporter/&DEVICE_NAME&
&&Windows Vista:C:\Users\&USERNAME&\AppData\Roaming\Apple computer\Logs\CrashReporter/MobileDevice/&DEVICE_NAME&
The log file names start with application name and have the extension &crash&. They are just plain text files and can be sent by e-mail in original or zipped form, or even copy-pasted into your e-mail program.
The second part is trickier. Both Apple and common sense suggest that all AppStore binaries are shipped with stripped symbols. If you ever saw a crash log like this, read on:
Thread 0 Crashed:0&& libobjc.A.dylib&&&&&&&&&& 0x300c87ec 0x300bb000 + 552761&& MobileLines&&&&&&&&&&&&&& 0xx1000 + 215562&& MobileLines&&&&&&&&&&&&&& 0x 0x1000 + 216983&& UIKit&&&&&&&&&&&&&&&&&&&& 0x30a740ac 0x30a54000 + 1312444&& UIKit&&&&&&&&&&&&&&&&&&&& 0x30aa54000 + 740005&& UIKit&&&&&&&&&&&&&&&&&&&& 0x30aa54000 + 712606&& GraphicsServices&&&&&&&&& 0x 0x + 206607&& GraphicsServices&&&&&&&&& 0xx + 307448&& IOMobileFramebuffer&&&&&& 0x31f3e8f8 0x31f3d000 + 63929&& com.apple.framework.IOKit 0x30f342b8 0x30f30000 + 1708010& CoreFoundation&&&&&&&&&&& 0x3025ced4 0x + & CoreFoundation&&&&&&&&&&& 0x3025bed6 0x + & CoreFoundation&&&&&&&&&&& 0xx + & GraphicsServices&&&&&&&&& 0x 0x + 1456414& UIKit&&&&&&&&&&&&&&&&&&&& 0x30a5e308 0x30a54000 + 4173615& UIKit&&&&&&&&&&&&&&&&&&&& 0x30a671dc 0x30a54000 + 7830016& MobileLines&&&&&&&&&&&&&& 0xx1000 + 424017& MobileLines&&&&&&&&&&&&&& 0xx1000 + 4140
In a nutshell, it contains function addresses and offsets instead of function names and line numbers. The structure is obvious, but, to be honest, I don&t know what&MobileLines 0&&1000 + 21556&P is, even though I have all the source code. Thanks to Apple Developer Tools and to Craig Hockenberry whowrote about it, we have a perfect solution called symbolicatecrash.
I copied it to/usr/local/bin/so that I can run it whenever I want without trying to remember its original location (you may prefer a symbolic link):
$ sudo cp /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins/iPhoneRemoteDevice.xcodeplugin/Contents/Resources/symbolicatecrash /usr/local/bin/
Running this script with the-h option provides the minimal help:
$ symbolicatecrash -h
&&& symbolicatecrash [-Ah] LOGFILE [SYMBOL_PATH ...]
&&& Symbolicates a crashdump LOGFILE which may be &-& to refer
& to stdin. By default, all heuristics will be employed
& in an attempt to symbolicate all addresses. Additional
& symbol files can be found under specified directories.
&&& -A& Only symbolicate the application, not libraries
&&& -h& Display this message
&&& -v& Verbose
To add symbols to the crash log you need the dSYM file generated by the linker when you compiled your application for AppStore. In other words, when you build for AppStore you should keep the dSYM package in a safe place backed up by Time Machine. This is very important.You should keep a copy of the dSYM for each version of your application ever shipped. If you have the package, translating code offsets to function names with line numbers has never been easier:
$ symbolicatecrash report.crash MobileLines.app.dSYM & report-with-symbols.crash
Here is the result:
Thread 0 Crashed:0&& libobjc.A.dylib&&&&&&&&&& 0x300c87ec objc_msgSend + 201&& MobileLines&&&&&&&&&&&&&& 0x -[BoardView setSelectedPiece:] (BoardView.m:321)2&& MobileLines&&&&&&&&&&&&&& 0x -[BoardView touchesBegan:withEvent:] (BoardView.m:349)3&& UIKit&&&&&&&&&&&&&&&&&&&& 0x30a740ac -[UIWindow sendEvent:] + 2644&& UIKit&&&&&&&&&&&&&&&&&&&& 0x30a66110 -[UIApplication sendEvent:] + 2485&& UIKit&&&&&&&&&&&&&&&&&&&& 0x30a6565c _UIApplicationHandleEvent + 40886&& GraphicsServices&&&&&&&&& 0x PurpleEventCallback + 4287&& GraphicsServices&&&&&&&&& 0x HeartbeatVBLCallback + 1528&& IOMobileFramebuffer&&&&&& 0x31f3e8f8 IOMobileFramebufferNotifyFunc + 1249&& com.apple.framework.IOKit 0x30f342b8 IODispatchCalloutFromCFMessage + 30410& CoreFoundation&&&&&&&&&&& 0x3025ced4 __CFMachPortPerform + 7211& CoreFoundation&&&&&&&&&&& 0x3025bed6 CFRunLoopRunSpecific + 236412& CoreFoundation&&&&&&&&&&& 0x CFRunLoopRunInMode + 4413& GraphicsServices&&&&&&&&& 0x GSEventRunModal + 26814& UIKit&&&&&&&&&&&&&&&&&&&& 0x30a5e308 -[UIApplication _run] + 40415& UIKit&&&&&&&&&&&&&&&&&&&& 0x30a671dc UIApplicationMain + 106416& MobileLines&&&&&&&&&&&&&& 0x main (main.m:16)17& MobileLines&&&&&&&&&&&&&& 0x0000202c start + 44
Now, this ismuch better. Happy debugging!
Other useful references:
如果采用上述方法还是解析不出来,则可以利用gdb来解析:
方法如下:还是在.app,和.dSYM目录下,
打开终端,输入:
/Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin 打包的.app/MyApp
要想显示在哪个类,哪一行,则使用:
(gdb) set print symbol-filename on
(gdb) p/a 0x0002b0ee
这里0x0002b0ee 是你报错程序的错误,如:
Thread 0 name:& Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0&& libobjc.A.dylib&&&&&&&&&&&&&&&&&& 0x34bc8c9a objc_msgSend + 18
1&& UIKit&&&&&&&&&&&&&&&&&&&&&&&&&&&& 0x -[UIViewController didReceiveMemoryWarning] + 10
2&& UIKit&&&&&&&&&&&&&&&&&&&&&&&&&&&& 0x3430915c -[UIViewController _didReceiveMemoryWarning:] + 8
3&& Foundation&&&&&&&&&&&&&&&&&&&&&&& 0x36b7d17c _nsnote_callback + 136
4&& CoreFoundation&&&&&&&&&&&&&&&&&&& 0x355bb208 __CFXNotificationPost_old + 396
5&& CoreFoundation&&&&&&&&&&&&&&&&&&& 0x35555ee4 _CFXNotificationPostNotification + 112
6&& Foundation&&&&&&&&&&&&&&&&&&&&&&& 0x36b7a5cc -[NSNotificationCenter postNotificationName:object:userInfo:] + 64
7&& Foundation&&&&&&&&&&&&&&&&&&&&&&& 0x36b7c1ba -[NSNotificationCenter postNotificationName:object:] + 18
8&& UIKit&&&&&&&&&&&&&&&&&&&&&&&&&&&& 0x342df35a -[UIApplication _performMemoryWarning] + 42
9&& UIKit&&&&&&&&&&&&&&&&&&&&&&&&&&&& 0x342dfd7c -[UIApplication _receivedMemoryNotification] + 120
10& UIKit&&&&&&&&&&&&&&&&&&&&&&&&&&&& 0x342dd500 _memoryStatusChanged + 36
11& CoreFoundation&&&&&&&&&&&&&&&&&&& 0x355bbd62 __CFNotificationCenterDarwinCallBack + 18
12& CoreFoundation&&&&&&&&&&&&&&&&&&& 0x355b8bd8 __CFMachPortPerform + 204
13& CoreFoundation&&&&&&&&&&&&&&&&&&& 0x355c3a90 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 20
14& CoreFoundation&&&&&&&&&&&&&&&&&&& 0x355c5838 __CFRunLoopDoSource1 + 160
15& CoreFoundation&&&&&&&&&&&&&&&&&&& 0x355c6606 __CFRunLoopRun + 514
16& CoreFoundation&&&&&&&&&&&&&&&&&&& 0x35556ebc CFRunLoopRunSpecific + 224
17& CoreFoundation&&&&&&&&&&&&&&&&&&& 0x35556dc4 CFRunLoopRunInMode + 52
18& GraphicsServices&&&&&&&&&&&&&&&&& 0x GSEventRunModal + 108
19& GraphicsServices&&&&&&&&&&&&&&&&& 0x GSEventRun + 56
20& UIKit&&&&&&&&&&&&&&&&&&&&&&&&&&&& 0x341b4d62 -[UIApplication _run] + 398
21& UIKit&&&&&&&&&&&&&&&&&&&&&&&&&&&& 0x341b2800 UIApplicationMain + 664
22& PABankiPad&&&&&&&&&&&&&&&&&&&&&&& 0xx1000 + 5656
23& PABankiPad&&&&&&&&&&&&&&&&&&&&&&& 0x000025cc 0x1000 + 5580
这里,可以用:p/a 0x
查看.app,和.dSYM与崩溃日志是否一致的方法:
dwarfdump \\uuid MyApp.app/MyApp
UUID: E2D9D241\37D3\CE06\963E2 (armv6) MyApp.app/MyApp
dwarfdump \\uuid MyApp.app.dSYM
UUID: E2D9D241\37D3\CE06\963E2 (armv6)MyApp.app.dSYM/Contents/Resources/DWARF/MyApp
对比结果是否一致.
把命令链接到所有用户可以使用
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKit.framework/Versions/A/Resources/symbolicatecrash /usr/local/bin/
sudo ln -s& /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin/usr/local/bin/
批量转换日志:(app包和dSYM还有carsh文件都放到对应的目录下了)
cd ~/Desktop/a.5c
for i in *.do
&&&&&&& echo $i
&&&&&&& symbolicatecrash $i PABankiPad.app.dSYM & $k.log
&&&&&&& ((k++))
摘自& dread}

我要回帖

更多关于 xcode crash 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信