Debugging Approaches in Software Engineering


Debugging occurs as a consequence of successful testing. Debugging is an action that results in the removal of the error. It should be an orderly process. The external manifestation of the error and the internal cause of the error may have no obvious relationship to one another.

Debugging will always have one of two outcomes:
1. The cause will be found and corrected.
2. The cause will not be found. In the other case, the person performing debugging may suspect a cause, design one or more test cases to help validate that suspicion and work toward error correction in an iterative action.

Debugging Approaches:

1. Brute force method: It is the most common method of debugging but is the least efficient method. In this approach, print statements are inserted throughout the program to print the intermediate values with the hope that some of the printed values will help to identify the statement in error. This approach becomes more systematic with the use of a symbolic debugger also called a source code debugger.

2. Backtracking: This is also a fairly common approach. In this approach, starting from the statement at which an error symptom has been observed, the source code is traced backwards until the error is discovered. Unfortunately, as the number of source lines to be traced back increases, the number of potential backward paths increases.

3. Cause elimination method: In this approach, once a failure is observed, the symptoms of the failure are noted. Based on the failure symptoms, the causes which could have contributed to the symptom are developed and tests are conducted to eliminate each. A related technique of identification of the error from the error symptom is the software fault tree analysis.

4. Program slicing: This technique is similar to backtracking. In the backtracking approach, one often has to examine a large number of statements. However, the search space is reduced by defining slices. A slice of a program for a particular variable and at a particular statement is the set of source lines preceding this statement that can influence the value of that variable. Program slicing makes use of the fact that an error in the value of a variable can be caused by the statements on which it is data-dependent.