Debugging on the iPhone

Member
Posts: 61
Joined: 2009.01
Post: #1
I'm sure this has been asked already, but I couldn't find anything that really referred to what I need to know.

Basically, I'm coming from a Java background, where if something breaks I get a nice error message like this:
Code:
java.lang.NullPointerException:
     Entity.foo(150)
     Entity.goo(210)
     Model.hoo(57)
     Main.main(18)
That's heavy paraphrasing but basically the idea is that I'm able to see an exact stack trace that shows where the code went. It started in main, and main called hoo (at line 18), which in turn called goo (at line 57), and then called foo (at line 210), which is where the null pointer exception occurred (at line 150). So then I can very easily go to line 150 in my Entity class and then look and see that it says something like "position.move" and from that and the type of error reported I know that position was never assigned (is null).

I am going nuts trying to debug iPhone programs. The error reporting is just awful. I get no such verbose messages - instead, the debugger usually just opens and gives me a worthless stack trace:

Quote:-dealloc
-applicationDidBecomeActive
-applicationWillResignActive
-applicationDidFinishLaunching

Code:
2009-01-27 14:59:26.851 Valet[5402:20b] Stack: (
    2441167115,
    2519879227,
    2441166571,
    2441166634,
    2422913023,
    2422378888,
    58430,
    47940,
    34547,
    28468,
    2422615587,
    2440669989,
    2440670424,
    827737600,
    827737797,
    816114840,
    816160916,
    10256,
    10110
)

This has no reference whatsoever to my own code or to my line numbers. So I usually spend around a half hour making a ton of breakpoints and printfs to trace the code on my own and find the single line that was causing the problem.

It is mind boggling to me that this would be the only option. I have read that there is something called NSZombie, although that appears to only be in Cocoa. In any case, is there a way to get nicer messages or to pinpoint the line of code that caused the problem? Or is there a better way to debug on the iPhone?

Thanks a lot.
Quote this message in a reply
Member
Posts: 61
Joined: 2009.01
Post: #2
Judging by the silence I guess there is no way to do this. Alas.
Quote this message in a reply
Apprentice
Posts: 12
Joined: 2009.01
Post: #3
try 'backtrace' after your program tanks - or take a look at the current "stack" in the debugger window
you can also look at the gdb options for showing symbols, etc. Take a look at the GDB manual
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Debugging problem dcavanagh 1 1,718 Feb 24, 2009 02:50 PM
Last Post: dcavanagh
  Much higher framerate when not debugging monteboyd 6 3,146 Feb 24, 2009 12:10 PM
Last Post: CarbonX