To find out what happens at critical points in your program, you need to stop execution at these points and look at the contents of program variables to see if they contain the correct values. Points at which the debugger stops program execution are called breakpoints.
To set a breakpoint, use one of the forms of the stop or stopi commands.
Using a sample program, the following debugger commands set a breakpoint at line 4, run the program, continue the program, delete the breakpoint, rerun the program, and return to the shell:
(idb) stop at 4
[#1: stop at "squares.f90":4 ]
(idb) run
[1] stopped at [squares:4 0x120001880]
> 4 OPEN(UNIT=8, FILE='datafile.dat', STATUS='OLD')
(idb) cont
Process has exited with status 0
(idb) delete 1
(idb) rerun
Process has exited with status 0
(idb) quit
%
In this example:
The stop at 4 command sets a breakpoint at line 4. To set a breakpoint at the start of a subprogram (such as calc), use the stop in command (such as stop in calc).
The run command begins program execution and stops at the first breakpoint. The program is now active, allowing you to view the values of variables with print commands and perform related functions.
The cont command resumes (continues) program execution. In addition to the cont command, you can also use the step, next, run, or return commands to resume execution.
The delete 1 command shows how to delete a previously set breakpoint (with event number 1). For instance, you might need to delete a previously set breakpoint before you use the rerun command.
The rerun command runs the program again. Since there are no breakpoints, the program runs to completion.
The quit command exits the debugger and returns to the shell.
Other debugger commands include the following:
To get help on debugger commands, enter the help command.
To display previously typed debugger commands, enter the history command.
To examine the contents of a location, use the print or dump commands.
To execute a shell command, use the sh command (followed by the desired shell command). For instance, if you cannot recall the name of a FUNCTION statement, the following grep shell command displays the lines containing the letters FUNCTION, allowing use of the function name (SUBSORT) in the stop in command:
(idb)
sh
grep FUNCTION data.for
INTEGER*4 FUNCTION SUBSORT (A,B)
(idb) stop
in subsort
(idb)
See also Summary of Debugger Commands.