0

Xcode 5.1 no longer officially supports GDB, instead defaulting only to LLDB. The problem with LLDB is that it shows no useful debug information on app crashes. Furthermore, all Exception Breakpoints simply break on main.m. This makes debugging ridiculously tedious. I read here on SO that this is a common problem with LLDB and that GDB does a better job.

How do I enable GDB for xcode 5.1?

Razor Storm
  • 12,167
  • 20
  • 88
  • 148
  • Not really an answer to the question, but maybe a solution to the problem. Check this post for setting breakpoints when exceptions are thrown instead of when they don't get caught. http://stackoverflow.com/questions/1163981/how-to-add-a-breakpoint-to-objc-exception-throw – David Berry Apr 17 '14 at 20:25
  • Unfortunately this seems out of date. The solution for xcode 4 and 5 is what I've already done (Add all exception breakpoint), and it breaks in main.m – Razor Storm Apr 17 '14 at 20:30
  • Don't use "All Objective-C Exceptions" set an explicit breakpoint on `objc_exception_throw` and `-[NSException raise]` That seems to work for me. Note that many exceptions are actually thrown from deep within the bowels of UIKit during event handling, so you won't get a lot of information from them anyway. – David Berry Apr 17 '14 at 20:37

1 Answers1

0

There is no way to use gdb with more recent Xcodes.

I don't know what you mean by "it shows no useful debug information on app crashes." Probably best to file a bug with bugreporter.apple.com with some more detail, there may be a way to get lldb to work correctly for you.

I am also not sure what you are seeing when you say "all Exception Breakpoints break on main.m". If you go to the lldb console and do:

(lldb) break list

are the breakpoints actually on main.m?

One thing to be a little careful about with the Xcode 5 Debugging UI (maybe this started with 4, I can't remember.) When your program stops due to a crash or exception in a stack frame that starts with frames that have no debug information, Xcode will actually select the first frame up the stack that has debug information. This is to avoid showing people screens full of disassembly, which some folks find frightening... So the source frame will show, say, main.m, though the actual bottom-most frame is something else.

Xcode also has a "stack compression" feature that will hide "uninteresting" frames. That can also make this kind of stop confusing - though it will generally show the bottom-most frame you might miss that and only see your source frame. The stack compression can be turned off if you don't like it.

Make sure that is not what you are seeing.

Jim Ingham
  • 25,260
  • 2
  • 55
  • 63
  • I think that's what must be happening. The crash happened somewhere deep in the innards of UIKit so it simply crashed into main.m. As for no debug message showing up it ended up being because I had a framework that was swallowing all exceptions. I turned that off and it works fine now. – Razor Storm Apr 22 '14 at 18:28