Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is there a good tutorial on how to use Xcode's debugger properly? [closed]

Subject says it all really...Is there anywhere a good tutorial for Xcode's Debugger out there? I'm finding dribs and drabs of stuff but nothing comprehensive or that goes deep enough. My problem right now is that this...

#0  0x90d9c688 in objc_msgSend
#1  0x30506515 in NSPopAutoreleasePool
#2  0x30901697 in _UIApplicationHandleEvent
#3  0x32046375 in PurpleEventCallback
#4  0x30245560 in CFRunLoopRunSpecific
#5  0x30244628 in CFRunLoopRunInMode
#6  0x308f930d in -[UIApplication _run]
#7  0x309021ee in UIApplicationMain
#8  0x00001ff8 in main at main.m:14

...combined with this...

0x90d9c688  <+0024>  mov    0x20(%edx),%edi

...and this...

EXC_BAD_ACCESS

...isn't helping much. Or at all, really. I'm resorting to commenting out lines of code and there has to be a better way.

Thanks

UPDATE: I guess perhaps my venting was a bit of a distraction from the real question, though the tips have helped explain things a bit. What I'm really getting at is not only an explanation of the above, but just use of the Debugger in general. The questions that I usually have are:

  • Why does the Debugger sometimes go from the source code view to (what I'm assuming) assembly code when I step over or in? Is there a way for me to see both at the same time all the time?
  • Is there anything specific I should be looking for in the assembly code, or anything that could help in a given situation?
  • It looks as though breakpoints allow for actions, so I'm curious how that might be utilized rather than peppering my code with NSLog statements.

I know these are broad, and probably should be asked individually, but I didn't want to clutter the SO space with these topics that might already be documented elsewhere.

I also noticed there is a nearly duplicate question asked here: What are some Objective-c debugging tips?

like image 896
Philip Regan Avatar asked Sep 02 '09 00:09

Philip Regan


2 Answers

You should turn on NSZombieEnabled to debug over-release issues like this:

http://cocoadev.com/index.pl?NSZombieEnabled

http://www.fromconcentratesoftware.com/2007/08/09/nszombieenabled-for-the-debugger-adverse/

http://www.tomwhitson.co.uk/blog/2009/04/debugging-with-nszombiesenabled/

like image 79
Rob Keniger Avatar answered Sep 22 '22 01:09

Rob Keniger


The crash is inside Apple's code (that's why debugger doesn't show you the source) and cause of it is actually somewhere else – you've released a temporary object that was supposed to be released by autorelease pool. This caused autorelease pool to crash.

You're supposed to release only objects which:

  • you've retained yourself using retain
  • were returned by init, copy and new methods only (and their variants containing these words)

Unfortunately you can't learn that one from the debugger, only from documentation and experience…

You can use Clang Analyzer to find such errors (sometimes).

like image 36
Kornel Avatar answered Sep 21 '22 01:09

Kornel