Thursday, May 6, 2010

Using the Debugger in XCode

Using XCode 3.2.1:

STARTING UP THE DEBUGGER:

To start up your application in debug mode, click the Breakpoints icon on the Project Toolbar. You will notice that Build and Run turns into Build and Debug.


VIEWING DEBUGGER/CONSOLE WINDOWS:

To open the Debugger window when debugging, go to Run > Debugger. To see the Console, same thing: Run > Console. You can also open these windows by clicking the relevant icons on the Debugger strip.

STACK TRACE:
Add 'objc_exception_throw' as a breakpoint via Run > Debugger > Show Breakpoints.  When you run your app on the simulator in Debug mode and an exception occurs anywhere in your code, the app will stop and you can usually view a stack trace of your code.  This is because the debugger is now set up to catch 'objc_exception_throw'.


EXPRESSIONS(I.E. WATCHING VARIABLES):
Also, if you want to see what certain variables are, you can use the Expressions window via Run > Show > Expressions.

STATIC ANALYZER:
Select Run > Build and Analyze to run the Static Analyzer. This will uhhh "analyze" your code for things like possible memory leaks and other possible errors that the compiler would not necessarily catch(i.e. setting a variable to zero, and then dividing by that). NOTE: this found the memory leak that is/was in getDeckCount().


No comments:

Post a Comment