The processes of V & V and debugging are normally interleaved. As you discover faults in the program that you are testing, you have to change the program to correct these faults. However, testing (or, more generally verification and validation) and debugging have different goals:
Figure 1: The debugging process
There is no simple method for program debugging. Skilled debuggers look for patterns in the test output where the defect is exhibited and use their knowledge of the type of defect, the output pattern, the programming language and the programming process to locate the defect. When you are debugging, you can use your knowledge of common programmer errors (such as failing to increment a counter) and match these against the observed patterns. You should also look for characteristic programming language errors, such as pointer misdirection in C.
Locating the faults in a program is not always a simple process because the fault may not be close to the point where the program failed. To locate a program fault, you may have to design additional tests that reproduce the original fault and that pinpoint its location in the program. You may have to trace the program manually, line by line. Debugging tools that collect information about the program’s execution may also help you locate the source of a problem.
Interactive debugging tools are generally part of a set of language support tools that are integrated with a compilation system. They provide a specialised run-time environment for the program that allows access to the compiler symbol table and, from there, to the values of program variables. You can control execution by ‘stepping’ through the program statement by statement. After each statement has been executed, you can examine the values of variables and so discover the location of the fault.
After a defect in the program has been discovered, you have to correct it and revalidate the system. This may involve reinspecting the program or regression testing where existing tests are executed again. Regression testing is used to check that the changes made to a program have not introduced new faults. Experience has shown that a high proportion of fault ‘repairs’ are either incomplete or introduce new faults into the program.
The Wikipedia article on debugging is quite good.