0% found this document useful (0 votes)
39 views21 pages

Debugging

Uploaded by

KOVID BAJAJ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views21 pages

Debugging

Uploaded by

KOVID BAJAJ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 21

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.

 As the code size becomes large, it becomes difficult to print intermediate


values after each statement.

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.

 tests are conducted to eliminate each.

 A related technique of identifying error by examining error symptoms:


 software fault tree analysis.

13
Program Slicing
 This technique is similar to back tracking.

 However, the search space is reduced by defining slices.

 A slice is defined for a particular variable at a particular statement:


 set of source lines preceding this statement which can influence the value of the variable.

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.

 Debugging may sometimes require full redesign of the system.

 A common mistake novice programmers often make:


 not fixing the error but the error symptoms.

18
Debugging
Guidelines
Be aware of the possibility:
an error correction may introduce new
errors.

After every round of error-fixing:

regression testing must be carried out.


19
Testing vs Debugging
S.No Testing Debugging

1 Testing gets started with known This is manual step by step


conditions with expected results. unstructured and unreliable
process to find and removes a
specific bug from the system.

2 It performed based on the testing It performed based on the type


type which we need to perform of bug.
unit testing, integration testing,
system testing, user acceptance
testing, stress, load, performance
testing etc.

3 Testing is the process which can Debugging is the process which


be planned, designed and cannot be so forced.
executed.

4 It is the process to identify the It is the process to give the


failure of implemented code. absolution to code failure.
20
5 It is a demonstration of error or It is always treated as a
Testing vs Debugging
S.No Testing Debugging

6 Testing is the display of errors It is a deductive process

7 Design knowledge is not Detailed design knowledge is


required for testing the system definitely required to perform
under test. Any person with or debugging.
without test case can do
testing.

8 Testing can be outsourced to Debugging cannot be outsourced


outside team as well. to outside team. It must be done
by inside development team.

9 Most of the test cases in Automation in the debugging


testing can be automated. cannot possible.

10 Testing is the process to Debugging is the process to


identify the bugs in the system identify the root cause 21
of the
under test. bugs.

You might also like