- Whenever there is a gap between an expected output and an actual output of a program, the program needs to be debugged.
- An error in a program is called bug, and debugging means finding and removing the errors present in the program.
- Debugging involves executing the program in a controlled fashion.
- During debugging, the execution of a program can monitor at every step.
- In the debug mode, activities such as starting the execution and stopping the execution are in the hands of the debugger.
- The debugger provides the facility to execute a program up to the specified instruction by inserting a breakpoint.
- It gives a chance to examine the values assigned to the variables present in the program at any instant and, if required, offers an opportunity to update the program.
- Types of debugging procedures:
A debug monitor is a program that monitors the execution of a program and reports the state of a program during its execution. It may interfere in the execution process, depending on the actions carried out by a debugger (person). In order to initiate the process of debugging, a programmer must compile the program with the debug option first. This option, along with other information, generates a table that stores the information about the variables used in a program and their addresses.
Assertions mechanisms used by a debugger to catch the errors at a stage before the execution of a program. Sometimes, while programming, some assumptions made about the data involved in the computation. If these assumptions went wrong during the execution of the program, it may lead to erroneous results. For this, a programmer can make use of an assert statement. Assertions the statements used in programs, which always associated with Boolean conditions. If an assert() statement evaluated to be true, nothing happens. But if it realized that the statement is false, the execution program halts.