Unformatted text preview: likely to be detected before you complete the manual
Manual execution of a program is a tedious process requiring lot of concentration.
Hence this method is normally used only for simple and small programs.
Putting Print Statements in the Program Code
Another approach is to put several print or write statements at appropriate
locations in the program so that the values of different variables can be
printed/displayed to indicate intermediate computations results. The program is recompiled and executed with these statements. These statements print/display the
values of intermediate computations telling you what is happening during the
execution of the program. The cause of the problem is very likely to be detected
by doing a proper analysis of the printed/displayed intermediate results. Once the
errors have been found and corrected, these print or write statements are removed
from the program.
Using a Debugger
This is the most commonly used approach. A debugger is a software tool that
assists the programmer in following the program's execution step-by-step by
allowing him/her to display intermediate calculation results and field values
whenever desired. In effect, a debugger helps the programmer in debugging the
program logic much more easily than having to put (and later remove) print/write
statements into the program's source code. Almost all modern programming
language processors are supported with some kind of debugger. When using a debugger for debugging program logic, you can move either from
statement to statement or from one checkpoint to another, pausing the execution of
the program as needed to examine the values of key variables or machine registers.
Most debuggers support two kinds of checkpoints called breakpoints and
watchpoints. They are briefly explained below:
Breakpoint. A breakpoint is a point at which the debugger stops during
program execution and awaits your further command. When it stops you may
instruct it to display the current values of key variables or machine registers. A
debugger provides you the flexibility of setting or re...
View Full Document
This document was uploaded on 04/07/2014.
- Spring '14