Search
Goodies

Social Networks
Designs I Like
« Beyond the UISplitViewController | Main | Using iRate in your app - asking for user reviews »
Monday
May162011

Looking for the offending line of code - how I do it

For beginners. Really.
You run an application on your device and it crashes. You want to know what was the context of the crash and at which line of code the crash happens. Here is what I do to find out.

If the application uses library like CrashReporter (see previous post on similar subject: Processing user's crash logs (when symbolicate don't work)), you can get the crash report by email. Then, open Xcode's Organizer, select Archives. In my case, when doing a test session, I build my own Ad Hoc version of my app, then install it on my test device via a service like www.testflightapp.com (I could use Organizer too! But I really like TestFlightApp service). For that purpose, I build an archive.

Next, right click on an Archive then select Show in Finder. You'll see something like this.

In the finder, right click this file, select Show Package Content. You'll see something like this.
Just extract the .dSYM file along with the application itself. Put those files in a folder. The folder content should look like this:
Next, put the crash log too in that folder. Open a Terminal session, change the current directory to the just created folder (simply type cd then drag and drop the folder on the Terminal windows). Following my previous on the subject, simple enter the command as illustrated here:
The hexadecimal code that follows the /uPasswords is taken on the crash report. The call stack is in reverse order of method invocations. The final step is to look at the method definition and see at the indicated line of code to see where the application actually crashed - in PasswordGenViewController.m:1403 <- this is the line number). That is it.
Thread 0 Crashed:
0   libsystem_kernel.dylib              0x3354300c 0x33532000 + 69644
1   libsystem_c.dylib                   0x337cff95 0x337bd000 + 77717
2   uPasswords                          0x000f0f0d 0x1000 + 982797
3   CoreFoundation                      0x3669f7d3 0x36601000 + 649171
4   libobjc.A.dylib                     0x361fa06b 0x361f4000 + 24683
5   libstdc++.6.dylib                   0x3168ae3d 0x31648000 + 273981
6   libstdc++.6.dylib                   0x3168ae91 0x31648000 + 274065
7   libstdc++.6.dylib                   0x3168af61 0x31648000 + 274273
8   libobjc.A.dylib                     0x361f8c8b 0x361f4000 + 19595
9   CoreFoundation                      0x3669f491 0x36601000 + 648337
10  CoreFoundation                      0x3669f4cb 0x36601000 + 648395
11  Foundation                          0x3343c053 0x33412000 + 172115
12  uPasswords                          0x000117e3 0x1000 + 67555
13  CoreFoundation                      0x3660f571 0x36601000 + 58737
14  UIKit                               0x36df3ec9 0x36dd7000 + 118473
15  UIKit                               0x36e80c21 0x36dd7000 + 695329
...
28  CoreFoundation                      0x3667883f 0x36601000 + 489535
29  CoreFoundation                      0x3667960d 0x36601000 + 493069
30  CoreFoundation                      0x36609ec3 0x36601000 + 36547
31  CoreFoundation                      0x36609dcb 0x36601000 + 36299
32  GraphicsServices                    0x3194341f 0x3193f000 + 17439
33  GraphicsServices                    0x319434cb 0x3193f000 + 17611
34  UIKit                               0x36e05d69 0x36dd7000 + 191849
35  UIKit                               0x36e03807 0x36dd7000 + 182279
36  uPasswords                          0x00002437 0x1000 + 5175

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>