`
yidongkaifa
  • 浏览: 4065195 次
文章分类
社区版块
存档分类
最新评论

获取普通用户 iOS 设备上的 Crash Log 的方法

 
阅读更多
方法1:用工具直接获取 iPhone 设备上 /var/mobile/Library/Logs/CrashReporter中的 Crash 报告文件。(Mac 下用 PhoneView/iTools/iExplorer,Windows下用、iFunBox、iTools、91助手等)。

方法2:如果 iTunes 同步,则同步后Crash日志会同步到电脑上,把以下目录中的Crash提取打包即可:
Mac OS X:~/Library/Logs/CrashReporter/MobileDevice
Windows XP:C:\Documents and Settings\Application Data\Apple computer\Logs\CrashReporter

Windows 7/Vista: C:\Users\AppData\Roaming\Apple computer\Logs\CrashReporter/MobileDevice/

分析log的方法:

你可以在文章中所提到的目录中找不到symbolicatecrash,因为它在新的SDK中被移到了这里:

/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/

DTDeviceKit.framework/Versions/A/Resources/symbolicatecrash

大概说明一下是:

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" 工具怎么用.一般只要:symbolicatecrashreport.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 arefrustrated because they have to hunt bugs instead of doing something creative andrewarding.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 tothe 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 usersretrievethem. 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 strippedsymbols. If you ever saw a crash log like this, read on:

Thread 0 Crashed:0   libobjc.A.dylib           0x300c87ec 0x300bb000 + 552761   MobileLines               0x00006434 0x1000 + 215562   MobileLines               0x000064c2 0x1000 + 216983   UIKit                     0x30a740ac 0x30a54000 + 1312444   UIKit                     0x30a66110 0x30a54000 + 740005   UIKit                     0x30a6565c 0x30a54000 + 712606   GraphicsServices          0x3169b0b4 0x31696000 + 206607   GraphicsServices          0x3169d818 0x31696000 + 307448   IOMobileFramebuffer       0x31f3e8f8 0x31f3d000 + 63929   com.apple.framework.IOKit 0x30f342b8 0x30f30000 + 1708010  CoreFoundation            0x3025ced4 0x30229000 + 21269211  CoreFoundation            0x3025bed6 0x30229000 + 20859812  CoreFoundation            0x3025b584 0x30229000 + 20621213  GraphicsServices          0x316998e4 0x31696000 + 1456414  UIKit                     0x30a5e308 0x30a54000 + 4173615  UIKit                     0x30a671dc 0x30a54000 + 7830016  MobileLines               0x00002090 0x1000 + 424017  MobileLines               0x0000202c 0x1000 + 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×00006434 0×1000 + 21556″is, even though I have all the source code. Thanks to Apple Developer Tools and toCraig Hockenberry whowrote about it, we have a perfect solution calledsymbolicatecrash.

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-hoption provides the minimal help:

$ symbolicatecrash -h
usage:

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.

Options:
-A Only symbolicate the application, not libraries
-h Display this message
-v Verbose

To add symbols to the crash log you need thedSYM 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               0x00006434 -[BoardView setSelectedPiece:] (BoardView.m:321)2   MobileLines               0x000064c2 -[BoardView touchesBegan:withEvent:] (BoardView.m:349)3   UIKit                     0x30a740ac -[UIWindow sendEvent:] + 2644   UIKit                     0x30a66110 -[UIApplication sendEvent:] + 2485   UIKit                     0x30a6565c _UIApplicationHandleEvent + 40886   GraphicsServices          0x3169b0b4 PurpleEventCallback + 4287   GraphicsServices          0x3169d818 HeartbeatVBLCallback + 1528   IOMobileFramebuffer       0x31f3e8f8 IOMobileFramebufferNotifyFunc + 1249   com.apple.framework.IOKit 0x30f342b8 IODispatchCalloutFromCFMessage + 30410  CoreFoundation            0x3025ced4 __CFMachPortPerform + 7211  CoreFoundation            0x3025bed6 CFRunLoopRunSpecific + 236412  CoreFoundation            0x3025b584 CFRunLoopRunInMode + 4413  GraphicsServices          0x316998e4 GSEventRunModal + 26814  UIKit                     0x30a5e308 -[UIApplication _run] + 40415  UIKit                     0x30a671dc UIApplicationMain + 106416  MobileLines               0x00002090 main (main.m:16)17  MobileLines               0x0000202c start + 44

Now, this ismuchbetter. Happy debugging!

Other useful references:

gdb查看:

如果采用上述方法还是解析不出来,则可以利用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 0x34309146 -[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 0x3417d418 GSEventRunModal + 108
19 GraphicsServices 0x3417d4c4 GSEventRun + 56
20 UIKit 0x341b4d62 -[UIApplication _run] + 398
21 UIKit 0x341b2800 UIApplicationMain + 664
22 PABankiPad 0x000026180x1000 + 5656
23 PABankiPad 0x000025cc 0x1000 + 5580


这里,可以用:p/a0x00002618

查看.app,和.dSYM与崩溃日志是否一致的方法:

输入命令:

dwarfdump ‐‐uuid MyApp.app/MyApp

返回内容:

UUID: E2D9D241‐37D3‐CE06‐7272‐653B813963E2 (armv6) MyApp.app/MyApp

输入命令:

dwarfdump ‐‐uuid MyApp.app.dSYM

返回内容

UUID: E2D9D241‐37D3‐CE06‐7272‐653B813963E2 (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/a1201s4z1.5c
pwd
k=1
for i in *.crash;do
echo $i
symbolicatecrash $i PABankiPad.app.dSYM > $k.log
((k++))
done


分享到:
评论

相关推荐

    iOS crash log

    ios 奔溃log 奔溃 左右摇动 进去奔溃log 分析,记录每次奔溃信息

    iOS Crash文件分析方法汇总

    今天跟大家一起聊聊iOSCrash文件的几种分析方法,都是平时比较常用的,有需要的小伙伴可以参考下

    查看iOS Crash logs的方法

    当应用在设备中运行发生崩溃,iOS将记录这些错误日志并且创建了崩溃报告(Crash Report)。崩溃报告中包含了iOS的版本、日期、异常类型、堆栈跟踪以及其他信息。 ① 在Xcode中查看崩溃报告 当应用还在开发过程中发生...

    A crash log symbolicating Mac app _ 一个图形化的崩溃日志符号化工具.zip

    A crash log symbolicating Mac app _ 一个图形化的崩溃日志符号化工具.zip

    ios-一个iOS调试工具,监控所有HTTP请求,自动捕获Crash分析。.zip

    一个iOS调试工具,监控所有HTTP请求,自动捕获Crash分析。 1.当出现功能异常时,有很大可能是与服务器的接口交互有数据异常,不管是客户端参数传错还是服务器返回结果错误,都不需要连接电脑调试了,只要打开...

    iOS 开发,上帝之眼可以看到 Log,Crash,Network,ANR,Leak,CPU,RAM,FPS,NetFlow,Folder 等等等等,炒鸡方便.zip

    可以看到 Log,Crash,Network,ANR,Leak,CPU,RAM,FPS,NetFlow,Folder 等等等等,炒鸡方便。.zip,使用基于swift的一行代码自动显示日志、崩溃、网络、anr、泄漏、cpu、ram、fps、netflow、文件夹等。就像上帝睁开眼睛

    用go语言实现的android crash log分析系统.zip

    硬件与设备:单片机、EDA、proteus、RTOS、包括计算机硬件、服务器、网络设备、存储设备、移动设备等 操作系统:LInux、IOS、树莓派、安卓开发、微机操作系统、网络操作系统、分布式操作系统等。此外,还有嵌入式...

    monkey4ios:monkey ios测试工具

    CrashMonkey4IOSiOS Monkey Test Tool.###简要说明:支持真机测试、模拟器测试支持收集系统日志(Systemlog)、崩溃日志(Crashlog)、instrument行为日志支持测试报告截图,绘制行为轨迹支持测试设备信息收集使用最新版...

    Software.Trace.and.Log.Analysis.A.Pattern.Reference.2nd.Edition

    Pattern-oriented trace and log analysis is applicable to troubleshooting and debugging Windows, Mac OS X, Linux, FreeBSD, Android, iOS, z/OS, and any other possible computer platform. Its pattern ...

    iOS 12适配以及问题小记

    前言 本文主要给大家介绍了关于iOS12适配及问题的相关内容,分享出来供大家参考学习,下面话不多说...crash log: 1,-[_UIStatusBarIdentifier isEqualToString:]: unrecognized selector sent to instance 0x283452820

    支持记录log和替换NSLog功能

    这个源码是支持记录log和替换NSLog功能,源码CCLogSystem,CCLogSytem是个人项目中用来替换NSLog,并可以...4)支持捕获Crash信息,区分普通Log和Crash Log; 5)支持CCLog和NSLog两种输出方式; 6)Log文件自动清理。

    dSYM.app.zip

    iOS 设备中会有日志文件保存我们每个应用出错的函数内存地址,通过 Xcode 的 Organizer 可以将 iOS 设备中的 DeviceLog 导出成 crash 文件, 这个时候我们就可以通过出错的函数地址去查询 dSYM 文件中程序对应的函数...

    dSYM.app dSYM Carsh文件分析工具

    iOS 设备中会有日志文件保存我们每个应用出错的函数内存地址,通过 Xcode 的 Organizer 可以将 iOS 设备中的 DeviceLog 导出成 crash 文件, 这个时候我们就可以通过出错的函数地址去查询 dSYM 文件中程序对应的函数...

    一个iOS调试工具

    作者JxbSir,源码JxbDebugTool,一个iOS调试工具,监控所有HTTP请求,自动捕获Crash分析。 1.当出现功能异常时,有很大可能是与服务器的接口交互有数据异常,不管是客户端参数传错还是服务器返回结果错误,都不需要...

    百度地图毕业设计源码-alibaba-iOS-interview-question:阿里巴巴-iOS-面试问题

    这种方法可能是最容易的方法了。 要使用Xcode符号化 crash log,你需要下面所列的3个文件: crash报告(.crash文件) 符号文件 (.dsymb文件) 应用程序文件 (appName.app文件,把IPA文件后缀改为zip,然后解压,...

    smart_monkey-0.4.2

    CrashMonkey4IOSiOS Monkey Test Tool.###简要说明:支持真机测试、模拟器测试支持收集系统日志(Systemlog)、崩溃日志(Crashlog)、instrument行为日志支持测试报告截图,绘制行为轨迹支持测试设备信息收集使用最新版...

    DataTransHub:跨平台AndroidiOS海量数据上报组件,基于Xlog完善,解决Xlog痛点问题

    DataTransHub主要用于数据的上报,Flog主要用于log的上报。 实现客户端海量数据的高性能上报,上报过程不会block任何操作,实现高性能上报,基于腾讯Xlog的数据压缩和加密算法,实现数据的高压缩比压缩和加密存储。...

    dsym文件分析工具

    当release的版本 crash的时候,会有一个日志文件,包含出错的内存地址, 使用symbolicatecrash工具能够把日志和dSYM文件转换成可以阅读的log信息,也就是将内存地址,转换成程序里的函数或变量和所属于的 文件名.

    LeakEye:LeakEye是受PLeakSniffer启发的swift编写的内存泄漏监视器

    该库源自项目,该项目可以使用一行代码自动显示Log,Crash,Network,ANR,Leak,CPU,RAM,FPS,NetFlow,Folder等。 就像上帝睁开眼睛 书与原理 我写了一本书 ,每章记录了实现细节的过程功能以及探索的方式。...

Global site tag (gtag.js) - Google Analytics