Reading iPhone crash logs

Source: Internet
Author: User

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 got Ted 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 shocould get the crash log and send it to the developer, who shocould examine it, find the bug and fix it.

IPhone OS and Mac OS X are remarkably similar ubuntures. 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/
* Windows XP: C: \ Documents ents and Settings \ Application Data \ Apple Computer \ logs \ crashreporter/
* Windows Vista: C: \ Users \ appdata \ roaming \ Apple Computer \ logs \ crashreporter/mobiledevice/

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               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 "average elines 0 × 00006434 0 × 1000 + 21556" is, even though I have all the source code. thanks to Apple developer tools and to Craig Hockenberry who wrote 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/iPhone OS. 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
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 the dsym file generated by the linker when you compiled your application for appstore. in other words, when you build for appstore you shoshould keep the dsym package in a safe place backed up by time machine. this is very important. you shoshould 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 cancelines. 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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.