Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode always stopping at main.m after a crash

In the past, with the old and good Xcode 3, every time I had a crash, Xcode stopped at the offending line showing the crash. It was good times, nice to debug.

Now with Xcode 4.2, every time the app crashes, it stops at main.m at this line

int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");

that gives no clue to what is causing the crash. The problem can be in any class but it will always stop on main.m when it crashes.

is there a way to make it work correctly again?

thanks

note: I have asked this before on SO, but the solution given that time was proved to be not satisfactory and the problem persists.

like image 493
Duck Avatar asked Nov 30 '11 04:11

Duck


2 Answers

They changed the behavior, follow this tutorial to break on all exceptions

EDIT:(Link might rot, so I will duplicate the info here)

One of the hidden gems in Xcode 4.2 is the “Exception Breakpoint” feature. Once you enable it, your debugging life becomes much easier because whenever an exception is thrown in your app, Xcode will bring up the line of code that caused the exception to occur. This is particularly useful if your call stack window is empty (which I have seen happen sometimes while working on iOS apps). Instead of relying on a brief error message in the Output pane, which doesn’t contain much more than the type of exception and its error message, you get to see exactly where the problem is!

You can add an Exception Breakpoint by opening up the Breakpoint Navigator pane, and clicking on the X button in the bottom left corner:

After clicking the “Add Exception Breakpoint…” menu item, you will see this breakpoint configuration view open up:

Click the Done button and you will the new Exception Breakpoint in your list of breakpoints. If you want to have all of your Xcode workspaces include the Exception Breakpoint, right-click (Ctrl + click) on it and open the “Move Breakpoint To” menu item:

After clicking “User” in the submenu, you will see that the Exception Breakpoint is in the User group of breakpoints. Open up another project and it automatically be included in the list of breakpoints.

Happy debugging!

like image 193
BarrettJ Avatar answered Oct 21 '22 17:10

BarrettJ


Just try the below steps which worked for me.

  1. Open Preferences, select Behaviors tab.
  2. Select "Run exits unexpectedly" from left column.
  3. Select "Show debugger with current views".

Unfortunately this is reverted back to main.m in the editor again :) Now you need to follow below steps

  1. Open Preferences, select Behaviors tab.
  2. Just go to "run completes"
  3. There find the "Show" line and click the checkbox
  4. On the same line modify target to go to "Current" in the dropdown menu.

This should work

like image 45
Krishna Kishore Avatar answered Oct 21 '22 15:10

Krishna Kishore