Monday, November 21, 2011

Debugging clue-less crash XCode

This is taken from web,but forgot what site it was,I had it on my sticky notes.


I thought I would share this, I'm sure most of you already know, but just in case, cos I find it pretty useful.


Whenever we get one of those crashes where there is no trace on the debug window, there are a few things we ca do, after the crash, don't close the app just yet, go to the debug window, and first, type "bt", that will give you a stack trace of the executing just after the crash, on top of the list you will see the last point that caused the crash, may be code on your classes or from some of the frameworks, find the first one that belongs to your code, there will be a number, for example #5, type "f 5" and that will jump to that part of the code. Now, if you want to debug values of any variables at that point, type "p variable_name" or you can even call a function or expression. If the variable is an object, you will see the pointer, if not, the value. If the variable is an object, use "po variable_name" to get the value, note you may get an memory error, that would mean that variable is nil (maybe the cause of your crash).

So in summary:
  • bt: display stack trace
  • f X: jump to code line
  • p variable: display variable value, pointer of basic type
  • po variable: display object variable value
Maybe this is trivial for some people, but I discovered time ago after more than one year developing on XCode!!


No comments:

Post a Comment