Debugging
Debugging
LECTURE
Debugging
Presentation Outline
- Debugging
- Bug Management
- Reporting
- Bug/Defect Types
- Defect Report
- Methods of Debugging
- Error Analysis
Debugging
Debugging is a two-step process that begins when you find an error as a result
of a successful test case.
In the latter 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 fashion.
Difference between Testing and Debugging
TESTING DEBUGGING
Testing is the process of executing Correcting these errors or bugs
a program or system with the aim (found during testing) is
of findings errors or bugs. debugging.
Bug
What is a BUG
States of a bug:
1) New
2) Open
3) Assign
4) Test
5) Verified
6) Deferred
7) Reopened
8. Rejected
9) Closed
Description of Stages
New: When the bug is posted for the first time, its state will be NEW. This
means that the bug is not yet approved.
Open: After a tester has posted a bug, the lead of the tester approves that the
bug is genuine and he changes the state as OPEN.
Assign: Once the lead changes the state as OPEN, he assigns the bug to
corresponding developer or developer team. The state of the bug now is
changed to “ASSIGN”.
Deferred: The bug, changed to deferred state means the bug is expected to
be fixed in next releases. The reasons for changing the bug to this state
have many factors. Some of them are priority of the bug may be low, lack
of time for the release or the bug may not have major effect on the
software.
Description of Stages
Pending Reject: If the developers think that a particular behavior of the
system, which the tester reports as a bug has to be same and the bug is
invalid, in that case, the bug is rejected and marked as ‘Pending Reject’.
Rejected/Invalid: Some times developer or team lead can mark the bug as
Rejected or invalid if the system is working according to specifications and
bug is just due to some misinterpretation.
Pending Retest: After the bug is fixed, it is passed back to the testing team
to get retested and the status of ‘Pending Retest’ is assigned to it.
Retest: The testing team leader changes the status of the bug, which is
previously marked with ‘Pending Retest’ to ‘Retest’ and assigns it to a
tester for retesting.
Duplicate: If the bug is repeated twice or the two bugs mention the same
concept of the bug, then one bug status is changed to “DUPLICATE”.
Verified: Once the bug is fixed and the status is changed to TEST, the tester
tests the bug. If the bug is not present in the software, he approves that
the bug is fixed and changes the status to VERIFIED.
Description of Stages
Could not reproduce: If developer is not able to reproduce the bug by the
steps given in bug report by QA then developer can mark the bug as
‘CNR’. QA needs action to check if bug is reproduced and can assign to
developer with detailed reproducing steps.
Reopened: If the bug still exists even after the bug is fixed by the developer,
the tester changes the status to REOPENED. The bug traverses the life
cycle once again.
Closed: Once the bug is fixed, it is tested by the tester. If the tester feels that
the bug no longer exists in the software, he changes the status of the bug
to CLOSED. This state means that the bug is fixed, tested and approved.
Most big software projects maintain two lists of "known bugs"— those known
to the software team, and those to be told to users. This is not
dissimulation, but users are not concerned with the internal workings of
the product. The second list informs users about bugs that are not fixed in
the current release, or not fixed at all, and a workaround may be offered.
• The developers often don't have time or it is not economical to fix all non-
severe bugs.
• The bug could be fixed in a new version or patch that is not yet released.
• The changes to the code required to fix the bug would be large, and
would bring with them the chance of introducing other bugs into the
system.
• It's "not a bug". A misunderstanding has arisen between expected and
provided behavior
Common Types Of Computer Bugs
Maths bugs
• Division by zero
• Arithmetic overflow or underflow
Logic bugs
• Infinite loops and infinite recursion
Syntax bugs
• Use of the wrong operator, such as performing assignment instead of
equality
Resource bugs
• Using an un-initialized variable
• Resource leaks, where a finite system resource such as memory or file
handles are exhausted by repeated allocation without release.
• Buffer overflow, in which a program tries to store data past the end of
allocated storage.
Defects that are detected by the tester are classified into categories by the
nature of the defect. The following are the classification
Showstopper (X): The impact of the defect is severe and the system cannot
go into the production environment without resolving the defect since an
interim solution may not be available.
Critical (C): The impact of the defect is severe, however an interim solution is
available. The defect should not hinder the test process in any way.
Non critical (N): All defects that are not in the X or C category are deemed to
be in the N category. These are also the defects that could potentially be
resolved via documentation and user training. These can be GUI defects.
Defect Report
Date of execution: The date on which the test case which resulted in a
defect was executed.
Status:New,Open,Assign,Test,Verified,Deferred,Reopened,Rejected,Closed.
Defect description: Description as to how the defect was found, the exact
steps that should be taken to simulate the defect, other notes and
attachments if any.
Defect Report
Test Case Reference No: The number of the test case and script in
combination which resulted in the defect
Owner: The name of the tester who executed the test case
Test case description: The instructions in the test cases for the step in
which the error occurred
Expected Result: The expected result after the execution of the instructions
in the test case descriptions
History of the defect: Normally taken care of the automated tool used for
defect tracking and reporting.
Attachments: The screen shot showing the defect should be captured and
attached
2. Debugging by Induction
3. Debugging by Deduction
4. Debugging by Backtracking
5. Debugging by Testing
Debugging by Brute Force
The most common scheme for debugging a program is the “brute force”
method. It is popular because it requires little thought and is the least
mentally taxing of the methods, but it is inefficient and generally
unsuccessful.
• It requires you to change the program; such changes can mask the error, or
introduce new errors.
• It may work on small programs, but the cost of using it in large programs
like operating systems is quite large.
Again, this method is largely hit or miss and often results in an excessive
amount of irrelevant data.
Debugging by Brute Force
The general problem with these brute force methods is that they ignore the
process of thinking.
There also is some evidence to indicate that whether the debugging teams are
experienced programmers or students, people who use their brains rather
than a set of aids work faster and more accurately in finding program
errors.
2. Organize the data. Remember that induction implies that you’re processing
from the particulars to the general, so the second step is to structure the
pertinent data to let you observe the patterns.
3. Devise a hypothesis. Next, study the relationships among the clues and
devise, using the patterns that might be visible in the structure of the
clues, one or more hypotheses about the cause of the error.
4. Prove the hypothesis. A major mistake at this point, given the pressures
under which debugging usually is performed, is skipping this step and
jumping to conclusions to fix the problem. However, it is vital to prove the
reasonableness of the hypothesis before you proceed. If you skip this
step, you’ll probably succeed in correcting only the problem symptom, not
the problem itself.
5. Fix the Error. If hypothesis is proved successfully then go on to fix the error
else repeat steps 3 and 4
Debugging by Deduction
The process of deduction proceeds from some general theories or premises,
using the processes of elimination and refinement, to arrive at a
conclusion (the location of the error). See the Figure
Debugging by Deduction
2. Use the data to eliminate possible causes. Carefully examine all of the data,
particularly by looking for contradictions, and try to eliminate all but one
of the possible causes. If all are eliminated, you need more data through
additional test cases to devise new theories.
3. Refine the remaining hypothesis. The possible cause at this point might be
correct, but it is unlikely to be specific enough to pinpoint the error.
Hence, the next step is to use the available clues to refine the theory.
4. Prove the remaining hypothesis. This vital step is identical to step 4 in the
induction method.
Debugging by Backtracking
In other words, start at the point where the program gives the incorrect
result—such as where incorrect data were printed.
At this point you deduce from the observed output what the values of the
program’s variables must have been. By performing a mental reverse
execution of the program from this point and repeatedly using the
process of “if this was the state of the program at this point, then this
must have been the state of the program up here,” you can quickly
pinpoint the error.
Debugging by Testing
The last “thinking type” debugging method is the use of test cases. consider
two types of test cases:
Test cases for testing, where the purpose of the test cases is to expose a
previously undetected error, and
Test cases for debugging, where the purpose is to provide information useful in
locating a suspected error.
The difference between the two is that test cases for testing tend to be “fat”
because you are trying to cover many conditions in a small number of test
cases. Test cases for debugging, on the other hand, are “slim” since you
want to cover only a single condition or a few conditions in each test case.