Advertisement
priore

How to debug EXC_CRASH (SIGTRAP)

Sep 3rd, 2012
1,013
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. // First method :
  3. //
  4. // In XCode 4 click your project and choose the breakpoints tab.
  5. // At the bottom of that tab is +/- search bar, choose the + item and "Add Exeception Breakpoint".
  6. // You can leave it at All or choose Objective-C.
  7. // This way you will break in the debugger and be able to see what caused the exeception.
  8. //
  9. // Second method:
  10. //
  11. #ifdef DEBUG
  12. void eHandler(NSException *);
  13.  
  14. void eHandler(NSException *exception) {
  15.     NSLog(@"%@", exception);
  16.     NSLog(@"%@", [exception callStackSymbols]);
  17. }
  18. #endif
  19.  
  20. int main(int argc, char *argv[]) {
  21.  
  22. #ifdef DEBUG
  23.     NSSetUncaughtExceptionHandler(&eHandler);
  24. #endif
  25.  
  26. // ...rest of your main function here...
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement