Xcode 3.x used to be much better about showing the line number from your program When Apple released Xcode 4.0, it rarely showed the source line of your crash any more. It's gotten slightly better in subsequent releases, but still fails to do so with annoying frequency.
There are a few things you can do to help with this:
Make sure you are running a debug build. Debug builds include full symbols. Also, release builds are highly optimized, to the point where the compiler mixes multiple source lines in the executable, eliminates local variables, etc.
In the "Debug Navigator" area, grab the slider at the bottom-left of the window and drag it all the way to the right (show most detail.) This will show the entire call stack, which lets you see ALL the calls.
One other trick that's quite helpful:
Add a breakpoint for all exceptions and copy it to "user" so it is in every project. Here's what you do:
- Select the Breakpoints Navigator in the left-most column of the Xcode project window.
- At the bottom of the left column, click the plus sign ("+")
- Select "Add Exception Breakpoint"
- For the "Exception" option, choose "Objective C." this skips internal exceptions from system C++ libraries like the security framework
- Choose the default values (break on throw, don't continue executing) for everything else and click done.
- Right-click/control click on your new breakpoint in the breakpoints list and select Move Breakpoint To>User.
Now, when your program crashes, it's more likely to display an exception message and/or the source line.
P.S. When you delete breakpoints, you can select entire groups of breakpoints to delete. Make sure you delete just your project breakpoints, and not this user breakpoint, or you'll have to add it again. I used to be in the habit of clicking in the breakpoints list, pressing command A to select them all, and hitting the delete key. I had to train myself to click on the project header instead of doing a select all.
Animated GIF created with Face Dancer
, available for free in the app store.
I'm available for one-on-one help at CodeMentor