DEBUGGING
DEBUGGING
DEBUGGING
• Testing phase of SDLC can be divided into two parts :
3. BackTracking
Debugging Techniques
• 1. Debugging with memory dump
• • In this technique, a printout of all registers and relevant
memory locations is obtained and studied. The relevant
data and program stored in these registers and memory
locations are observed for any bug in the program
• • This method is used as the last option
• • Following are some drawbacks of this method:
• i. It is difficult to establish the correspondence between
storage locations and the variables in a source program.
• ii. Memory dump might contain massive amount of
irrelevant data
• iii. It is limited to static state of the program as it shows
state of the program at only one instant of time.
Debugging Techniques
• 2. Debugging with watch points
• • Programs final output may not give sufficient clues about the
bug. But, intermediate execution points may provide sufficient
cause of the problem. These points are known as watch points.
• • Debugging with watch points can be implemented with the
following methods:
• i. Output statements
• • In this method, output or print statements are inserted at various
watch points to check the status of variables.
• • The program is compiled and executed with these output
statements.
• Execution of output statements may give some clues to find the
bug.
• • Drawbacks of this method are :
• a. It may require many changes in the program which may mask
an
• error or introduce new errors in the program.
• b. After bug analysis, we may forget to remove the
addedstatements which may cause misinterpretations in the
result
Debugging Techniques
• ii. Breakpoint Execution
• • This is an advanced form of the watch point used with an automated
• debugger program.
• • Break point is a watch point inserted at various places in the program.
• Program is executed up to the breakpoint inserted so that we can
examine the status at that point. Afterwards, the program will resume
and will be executed further until next breakpoint.
• • Breakpoints allows controlled execution of program with necessary
stops
• for intermediate examinations.
• • Advantages of breakpoints over output statements :
• a. There is no need to compile the program after inserting breakpoints
• b. Removing the breakpoints after their requirement is easy
• c. The status of variable or particular conditions can be observed at the
breakpoint. No need to wait for complete execution of the program as
in the case of output statements.
Debugging Techniques
• • Breakpoints can be categorized as follows :
• a. Unconditional breakpoint :-
• It is a simple breakpoint without any condition to be evaluated.
Its execution stops the execution of the program
• b. Conditional breakpoint :-
• At his breakpoint, one Boolean expression is evaluated and if
true, the breakpoint will cause a stop; otherwise execution will
continue.
• c. Temporary breakpoint :
• This breakpoint is used only once in the program. After
executing once, the temporary breakpoint is automatically
removed.
• d. Internal breakpoint :
• These breakpoints are added by the debugger itself for its own
purposes and these are invisible to the user
Debugging Techniques
• iii. Single stepping
• • Single stepping allows the user to watch the status or
condition of
• variables after execution of every single instruction
• • Single stepping is implemented with the help of internal
breakpoints.
• Step-into
• • It means execution proceeds into any function in the current
source statement and stops at the first executable source line
in that function
• ii. Step-over
• • It is also called skip, instead of step.
• It treats function calls as an atomic operation without single
stepping through the called function.
Debugging Techniques
• 3.BackTracking
• • This is a logical approach for debugging
a program.
Debugging Techniques
• Following are the steps for backtracking process :
• i. Observe the symptoms of the failure at the output and reach the site
where the symptoms can be uncovered. For example, one value is not
getting displayed on the output due to non-working of function X.
• ii. From that site, trace the source code starting backwards and move
to the highest level of abstraction of design, the bug will be found in
this path.
• iii. Slowly isolate the module where bug resides using data flow
diagrams of the module.
• iv. Logical backtracking in the isolated module will lead to the actual
bug and error can thus be removed.
• • The person doing debugging using backtracking method must have
knowledge regarding design of the system in order to understand the
logical flow of the program.
• • This is more effective as compared to other methods to locate errors
quickly.
DEBUGGERS
1. Eclipse debugger API used in a range of IDEs:
Eclipse IDE (Java) Nodeclipse (JavaScript)
2. Firefox JavaScript debugger
3. GDB - the GNU debugger
4. LLDB
5. Microsoft Visual Studio Debugger
6. Radare2
7. Valgrind
8. WDW, the OpenWatcom debugger
9. WinDbg