5

Possible Duplicate:
Xcode 4.2 showing the wrong line of code on error

Xcode 4's debugger doesn't seem to halt execution anywhere near the causes of crashes in iOS Simulator. Say I introduce a bug in my code, perhaps an array out of bounds error like this:

NSMutableArray * test = [[NSMutableArray alloc] initWithCapacity:5];
[test insertObject:@"Hello" atIndex:10];

When the app inevitably crashes, I'm taken to the main function in main.m with nothing on the call stack (the 'By Thread' view) to help me find what went wrong.

Is there a debugging setting I'm missing in the build properties, perhaps? This is Xcode 4.2 on Snow Leopard if it helps.

Thanks

Community
  • 1
  • 1
Tim
  • 5,024
  • 2
  • 30
  • 58

2 Answers2

10

Go to the breakpoints panel, and add the bottom left, click the + sign and add an "Exception breakpoint".

Exceptions : All
Break : On throw.

That should solve the problem in most cases.

Oliver
  • 23,072
  • 33
  • 138
  • 230
  • Didn't work. How does one make this Apple IDE work as well as other IDEs in *all* cases? I mean, it's pretty vital to debug all of your code, not just some. :/ – Henrik Erlandsson Aug 08 '12 at 09:07
  • @HenrikErlandsson:try again, that works. I use this all the time. – Oliver Aug 08 '12 at 12:40
  • It doesn't stop at the correct line for [localvariable autorelease] EXC_BAD_ACCESS error. 'Try again'? It's pretty easy to add such a breakpoint, in fact I think nobody could fail doing so. The breakpoint could fail to stop at the correct line, however, which is certainly the case for this type of error. – Henrik Erlandsson Aug 08 '12 at 13:10
  • 1
    @HenrikErlandsson:Yes, of course. Autorelease does not act a release when it's called. It flag the data to be released, what is done later in the time. So the crash does not happens because of the autorelease, but because of a release that is called by the system on the data at the end of the event loop. Put 3 autorelease on the same data on different methods that run in a single event loop, and you won't be able to know which one is the cause of the crash. So you can't ask the debugger to know it better than you. If you call release, it's a different thing because it acts immediatly. – Oliver Aug 08 '12 at 13:59
0

Adding an Exception breakpoint in Breakpoint Navigator per this question's accepted answer - Xcode 4.2 debug doesn't symbolicate stack call - fixes the issue.

Community
  • 1
  • 1
Tim
  • 5,024
  • 2
  • 30
  • 58