Beakpoints


Click here to change the theme.

To debug using breakpoints, the first thing to do is to have a debug version of your program built. You probably do already, but I am not assuming you do. Then what you can do is to set a breakpoint at the beginning of code that you want to debug. Breakpoints can be set using the F9 key with the cursor on the line. Then debug the program, which can be done with the F5 key. What happens is that when you debug with breakpoints set, the debugger stops when it executes a statement with a breakpoint set for it. This gives you a chance to look around at what is happening when that line is executing. You can look at the values in variables and you can look at the call stack.

Also while debugging, you can step through the code. You can have the debugger execute just the next line of code so you can see what the results are of it. The debugger calls this stepping "over"; compare this to stepping "into", which means that if the current statement is a function call of any type, then stepping "into" will cause the debugger to stop at the first statement of the function being called. If you step "over" the function call, then the function is called, but the debugger stops on the next line after the function call. Stepping into can be tricky, since sometimes the first function called is a MFC function that you do not care to see. So when that happens, I usually use the step "out" command first, which takes me back to the function call, and then do another step "into" and I repeat that until I get to my function that I want to debug.