Debugging
Debugging
1
Debugging
Debugging is the process of fixing a bug in the software.
It refers to identifying, analyzing and removing errors.
This activity begins after the software fails to execute
properly and concludes by solving the problem and
successfully testing the software.
2
Debugging
Debugging is the activity which is performed after
successful execution of test case.
A successful test case is one which shows that the
program is not performing as intended.
It consists of determining the exact nature and
location of suspected error and fixing the error.
3
Debugging
Once errors are identified:
it is necessary identify the precise location of the
errors and to fix them.
Each debugging approach has its own advantages
and disadvantages:
each is useful in appropriate circumstances.
4
5
Brute-force method
This is the most common method of
debugging.
Here the program is loaded with print
statements to print the intermediate values
with the hope that some of the printed values
will help to identify the statement with error.
6
Symbolic Debugger
Brute force approach becomes more systematic:
with the use of a symbolic debugger,
symbolic debuggers get their name for historical
reasons
early debuggers let you only see values from a
program dump:
determine which variable it corresponds to.
7
Symbolic Debugger
Using a symbolic debugger:
values of different variables can be easily
checked and modified
single stepping to execute one instruction at a
time
break points and watch points can be set to test
the values of variables.
8
Brute-force method
This is the most common method of debugging:
least efficient method.
9
Backtracking
This is a fairly common approach.
Beginning at the statement where an
error symptom has been observed:
source code is traced backwards
until the error is discovered.
10
Example
int main(){
int i,j,s;
i=1;
while(i<=10)
{
s=s+i;
i++; j=j++;
}
printf(“%d”,s);
}
11
Backtracking
Unfortunately, as the number of source
lines to be traced back increases,
the number of potential backward paths
increases
becomes unmanageably large for
complex programs.
12
Cause-elimination
method
Determine a list of causes:
which could possibly have contributed to the error symptom.
13
Program Slicing
This technique is similar to back tracking.
14
Example
int main(){
int i,s;
i=1; s=1;
while(i<=10)
{
s=s+i;
i++;
}
printf(“%d”,s);
printf(“%d”,i);
} 15
Debugging by
Induction
This technique is based on the formulation of a single working hypothesis based on the
data, analysis of existing data and on especially collected data to prove or disapprove
the working hypothesis.
16
Debugging by
Induction
17
Debugging
Guidelines
Debugging usually requires a thorough understanding of the program
design.
18
Debugging
Guidelines
Be aware of the possibility:
an error correction may introduce new
errors.