Debugging Report
Debugging Report
Debugging Report
No:21BCE5524
Introduction
Why Debug?
Debugging is definitely the most dreadful task for developers. After
all, we like to build things rather than fix bugs! Nevertheless, no one
can deny the importance of debugging. Programs or applications
that work perfectly from the first try are the exceptions and not the
rule.
How to Debug
Unit testing
Sometimes, the location in the code where the error occurred can be
clearly identified. However, that’s not always the case. Most times,
the location of the bug is unclear. Here’s where unit testing can be
helpful. It allows the programmer to run a specific part of the code
with a particular input. Doing so can ease the process of locating the
bug.
Pair programming
Debugging Tools
Debugging tools, or debuggers, are special tools that are built for the
sole use of analyzing programs and finding errors. Some debuggers
analyze a test case and run it to determine which lines of the code
didn’t execute correctly or at all. In contrast, others provide
simulations of the code’s behavior, allowing the programmer to
model how the program will behave on a given software (operating
system) based on specific dependencies.
Testing and debugging are two terms that are usually used together,
which may lead to the misunderstanding that they mean the same
thing.
In fact, they are quite different from each other. They do share some
functionality, but they differ in designs, execution, and benefits.
Both testing and debugging are essential stages of software
development and come with a variety of results. That’s why it’s
necessary to properly understand the differences between them to
optimize our software development process.
Although there is no fixed procedure to fix all bugs, there are several
techniques that can reduce your debugging efforts. A significant (if
not the entire) part of this process is spent finding the location of the
bug.
Trace-based debugging
Spectrum-based debugging
Delta debugging
Trace-Based Debugging
Slicing
1. Debugging.
2. Reverse-engineering a program.
Among those four types, dynamic slicing is the most used technique
in debugging. That is because when we debug, we have a specific test
case that produced the error, so we can use that test case as an input
to construct our slices.
Trace Debugging
In trace debugging (TD), the debugger can set a breakpoint, and
when a breakpoint is reached during program execution, the
program is suspended. Then, the programmer can examine the
program state by running it line by line. The debugger takes control
over the interpreter only, and hence the scalability of TD is the same
as that of the interpreter. During the process of finding the location
of a bug, if a bug is found before the breakpoint, then the debugging
process needs to restart to catch it.
Omniscient debugging
Algorithmic debugging
Hybrid debugging
Spectrum-Based Debugging
In spectrum-based debugging, also known as spectrum-based fault
localization (SFL), the debugging process is done by monitoring the
statements included in a particular execution tree. This is achieved
by using the program spectrum to identify the active part of the
program during its run. The program spectrum is a collection of
runtime information that gives a view of the dynamic behavior of
the program. It includes some flags corresponding to different parts
of the program. Different types of program spectra exist, such
as block hit/miss and function hit/miss. These spectra are used to
pinpoint the exact sections of the code running for specific or
abstract input.
Delta Debugging
The process of delta debugging (DD) is to minimize automated test
cases. It takes test cases that may cause the error and prepares an
error report. From that error report, minimal test cases are selected
based on their high probability of producing the error. The
minimum test cases will regenerate the same error and thus help the
developer locate the bug behind it.
There are some advanced topics and questions about the process of
debugging that are either unanswered or take the idea of debugging
to a new level. In this article, we will go through some of these
topics:
1. Anti-debugging techniques
2. Visual debuggers
Anti-Debugging Techniques
1. API-based anti-debugging
2. Flag-based anti-debugging
Using this approach, the malware will contain flags that detect
several behaviors indicating whether a debugging process has been
initiated.
3. Exception-based anti-debugging
Visual Debuggers
What makes debugging quite a challenging task is the difficulty of
understanding the abstract level behind the code. It is complicated
for our brains to follow the trace of the instructions behind our code.
Many researchers are aiming to create visual debuggers that ease the
process of debugging for many of the most used programming
languages and developing environments. One of the approaches
used to increase the efficiency of visual debuggers — and at the same
time make designing them easier — is to build application-specific
visual debuggers. Visual debuggers operate by performing some
graph mining of the execution tree to analyze and obtain a plan with
the concrete execution steps of a program for a given input.
One way to get around this is by simulating the program and then
using the simulation as a debugging tool. Margaret Martonosi, a
professor of Computer Science at Princeton, pointed out three ways
we can tackle debugging a quantum computer:
Remote debugging
Literature Review
Debugging Backwards in Time
Author Bil Lewis analyses that Over the past forty years there has
been little change in way commercial programme debuggers work.In
1961 a debugger called “DDT” existed on Digital machines which
allowed the programmer to examine,deposit,set breaks,set trace
points,igle step,etc.And the most important question is that “What
information will help the programmer most?”.He describes about
omniscient debugging that it works by collecting events at every
stage change and every method call in a program and he also
mentions about the interesting things about it. The ODB is an
implementation in pure Java which collects information by
instrumenting the byte of the target’s program as it’s loaded.We
want to be able to “revert” the program to any previous
state.Effectively this means that every change in every accessible
object or local variable constitutes aseperate state and must be
recorded.We”ll need to record each assignment in each thread and
define an ordering on them.Every object,variable,I/O stream,etc will
have a known value at each time stamp.The ODB supplies a print
format showing the class name and an index number.Every ,method
call that is recorded will be displayed in a “method trace” pane.The
format of the trace line will be <Object>.methodName(arg0,arg1)-
>retutnValue.Selecting a line in the threads pane reverts the
debugger to the nearest event in tne thread.Modelled after
EMACS,the ODB has a minibuffer which is used to execute extended
commands.The programmer may do an incremental text search
through the “trace:pane,or an event-analysis search through all
events,forwards or backwards.
We have to find “The Snake In The Grass”.For reducing the size
consumed by the bugs the ways to attack to attck this problem are
“garbage collect”old events and throw them away,instrument fewer
methods,record for a shorter time.Grabage Collection is bad that it’s
not throwing garbage away but just older events which might be an
important.By requesting that these methods not be instrumented,a
great deal of uninteresting events can be eliminated,that is “Safe
Code”.If the programmer suspects that a certain known event always
occurs before the bug,then recording could be turned on at that
point and turned off after the bug.
For large number of bugs,the ODB is highly effective.Problems that
took hours with the break point took minutes.In practice,it has
proven to be quiet easy to make bugs fit into 10 million events and
debugging even highly complex program has not been a problem.In
addition to finding the bug,the ODB allows the programmer to
confirm exactly why it is occurred.
This paper reviews the literature related to the learning and teaching
of debugging computer programs. Debugging is an important skill
that continues to be both difficult for novice programmers to learn
and challenging for computer science educators to teach. These
challenges persist despite a wealth of important research on the
subject dating back as far as the mid 1970s. Although the tools and
languages novices use for writing programs today are notably
different from those employed decades earlier, the basic problem-
solving and pragmatic skills necessary to debug them effectively are
largely similar. Hence, an understanding of the previous work on
debugging can offer computer science educators insights into how to
improve contemporary learning and teaching of debugging and may
suggest directions for future research into this important area. This
overview of the debugging literature is organized around four
questions relevant to computer science educators and education
researchers: What causes bugs to occur? What types of bugs occur?
What is the debugging process? How can we improve the learning
and teaching of debugging? We conclude with suggestions on using
the existing literature both to facilitate pedagogical improvements to
debugging education and to offer guidance for future research.
Debugging Inputs
Authors Lukas Kirschner,Ezekiel Soremekun,Andreas Zeller When a
program fails to process an input, it need not be the program code
that is at fault. It can also be that the input data is faulty, for instance
as result of data corruption. To get the data processed, one then has
to debug the input data-that is, (1) identify which parts of the input
data prevent processing, and (2) recover as much of the (valuable)
input data as possible. In this paper, we present a general-purpose
algorithm called ddmax that addresses these problems
automatically. Through experiments, ddmax maximizes the subset
of the input that can still be processed by the program, thus
recovering and repairing as much data as possible; the difference
between the original failing input and the “maximized” passing
input includes all input fragments that could not be processed. To
the best of our knowledge, ddmax is the first approach that fixes
faults in the input data without requiring program analysis. In our
evaluation, ddmax repaired about 69% of input files and recovered
about 78% of data within one minute per input.
Debugging optimized code with
dynamic deoptimization
Authors Urs Holze,Craig Chambers,David Ungar shares that SELF's
debugging system provides complete source-level debugging
(expected behavior) with globally optimized code. It shields the
debugger from optimizations performed by the compiler by
dynamically deoptimizing code on demand. Deoptimization only
affects the procedure activations that are actively being debugged;
all other code runs at full speed. Deoptimization requires the
compiler to supply debugging information at discrete interrupt
points; the compiler can still perform extensive optimizations
between interrupt points without affecting debuggability. At the
same time, the inability to interrupt between interrupt points is
invisible to the user. Our debugging system also handles
programming changes during debugging. Again, the system provides
expected behavior: it is possible to change a running program and
immediately observe the effects of the change. Dynamic
deoptimization transforms old compiled code (which may contain
inlined copies of the old version of the changed procedure) into new
versions reflecting the current source-level state. To the best of our
knowledge, SELF is the first practical system providing full expected
behavior with globally optimized code.
References
Atwood, M.E. and Ramsey, H.R. Cognitive structures in the comprehension and memory of
Research Institute for the Behavioral and Social Sciences, Alexandria, Virginia, August, 1978.
Chase, W.G. and Simon, H.A. Perception in chess. Cognitive Psychology 5, 4, Oct 1973, 55-81
ABKP86ALLEN, R., BAUMGARTNER, D., KEN- NEDY, K., AND PORTERFIELD, A. 1986.
Cha87.David Chase. Garbage Collection and Other Optimizations, Ph.D. dissertation, Computer
Library
CMR88.Deborah S. Coutant, Sue Meloy, and Michelle Ruscetta. DOC: A Practical Approach
'88 Conference on Programming Language Design and Implementation, pp. 125-134. Google
ScholarDigital Library
Debugging, 2000. [CC77] J. Cohen and N. Carpenter. A Language for Inquiring about the
Disscussion
We discussed anti-debugging techniques, visual debuggers,
debugging quantum computers, and some unanswered questions in
the field of debugging that are currently under research.
There are a number of other strategies that can be used to help the
developer locate bugs existing in the code. As a developer, I always
remind myself of a few things:
The bug may not be where you’re looking for it. Sometimes when
a developer looks for a bug, they spend a long time inspecting a
specific section of the code just to find out that the bug is
elsewhere.
Inspect the input data and test details. Sometimes, the test case
may be broken. So, it’s always a good idea to go through it and
make sure everything is on point.
All of the above are techniques used to locate bugs errors, but then
what?
Conclusion