|
|
|
Debugging is a vital part of programming. Whenever a program doesn't do what you expect, even if it doesn't blow up, you should turn to the debugger to see what's really going on. Debugging Vocabulary Probably the most important word in debugging is breakpoint. A breakpoint is a spot in your program, a single line of code, where you would like to pause. Perhaps you are wondering how many times a loop is executed, whether control transfers inside a certain if statement, or whether a function is even called. Setting a breakpoint on a line will make execution stop when that line is about to be executed. At that point you may want the program to be off and running again or want to move through your code a line or so at a time. You may want to know some of your variables' values or see how control transferred to this point by examining the call stack. Often, you'll spot the cause of a bug and correct your code on the spot. When it's time to move along, there are a number of ways you might like execution to resume. These are explained in the following list: • Go--Execute to the next breakpoint or, if there are no more breakpoints, until the program completes. • Restart--Start again from the beginning. • Step Over--Execute only the next statement, and then pause again. If it is a function call, run the whole function and pause after returning from it. • Step Into--Execute just the next statement, but if it is a function, go into it and pause before executing the first statement in the function. • Step Out--Execute the rest of the current function and pause in the function that called this one. • Run to Cursor--Start running and stop a few (or many) lines from here, where the cursor is positioned. Most information made available to you by the debugger is in the form of new windows. These are discussed in the following sections.
|
|
|
|
|
| |
|