How to display the exact line of code causing application crash in xcode 4 debugger like in xcode 3.2
Asked Answered
M

1

12

I just downloaded xcode 4 recently and have read the xcode transition guide, however, I am still wondering how do I get the same feature for debugger in xcode 4 like in xcode 3.2.

When I program in xcode 3.2 and run my application, if my code happened to cause a crash in the program, I could just press command+shift+y and I'll get the debugger mode appearing, which will shows which lines that it crashes. However, I can't seem to get this working for xcode 4.

I know that I can look at which line that actually causes the crash by looking at the stacktrace, however, having that functionality in xcode 3.2 really saves me time. Just wondering if anyone knows how to do this in xcode 4 as well.

Maun answered 28/3, 2011 at 1:40 Comment(0)
B
32

You need to add an exception breakpoint. Select the Breakpoint Navigator, click the Add (+) button at the bottom, then choose Add Exception Breakpoint... This should cause the debugger to pause any time it encounters an exception. Note, you have to have the Breakpoints button enabled (to the right of the Scheme selector in the toolbar). Note also, in Xcode 4, Run with breakpoints enabled is synonymous with "Build and Debug" in previous versions.

Berfield answered 28/3, 2011 at 14:28 Comment(3)
Great!!! Really, it should be enabled by default! I wasted a lot of time, debugging line by line.Cuneiform
Not all exceptions are yours to care about. Consider deep exceptions in the QTKit framework when dealing with a camera. In many cases, exceptions are generated and handled by generating an error you're supposed to catch and deal with or present. At that point, debugging assembly likely won't help; examining the error and trying to take corrective measures in your app is the best approach at your app's level, since it'd be an unavoidable (by your app) system event.Berfield
My point is, Xcode doesn't make a lot of potentially confusing assumptions about how you want the debugger to behave, but it does make it easy to flip a switch and break on exceptions in Objective-C.Berfield

© 2022 - 2024 — McMap. All rights reserved.