Game Development Reference
In-Depth Information
Once you hit a particular breakpoint, it's useful to be able to step through the code
line by line, so that you can pinpoint exactly where the code goes wrong. There
are two different ways to step through the code. If you use Step Over (by pressing
F10), the code will continue to the next line without going into the code of any
functions called on the current line. So, for example, suppose you had the follow-
ing two lines of code, and the breakpoint was on the first line:
myFunction();
x = 5;
If you were to step over the first line, you would immediately jump to the second
line, and only see the results of the myFunction() call. You wouldn't see any
of the code that was executed inside of the function. If you do want to jump into a
particular function and go through it line by line, you can use Step Into (by press-
ing F11). This will go into any functions on the line, in the order in which they
are called. If you step into a function and realize you don't actually care about the
line-by-line behavior of that particular function, you can jump out of it using Step
Out (by pressing Shift+F11).
Watch
A watch allows you to track specific variables, without needing to always mouse
over them to check their values. The easiest way to add a watch is to right-click a
particular variable in the debugger and select Add Watch. When debugging, you
will then have a watch window at the bottom of the IDE that shows the current
value of the variable. If the variable is a struct or class, you may need to click the
+ symbol to expand it in order to see the member variables. As you step through
lines of code, whenever a watch variable changes, the color of the variable will
change to red. This is an easy way to eyeball what values are changing over time.
A sample watch is shown in Figure B.2 .
Search WWH ::




Custom Search