Debugging programs written in f95 with the NAG debugger dbx90

Warning : This page has not been fully tested yet!! I'll announce in lectures when it has been

Debugging programs is generally a difficult task. One has to be able to understand when, where and why the bug appears. One way would be to use print-statements in the program to monitor the status of the program variables during the execution. This can be time-consuming process because generally one does not know where exactly the error occurs. Sometimes a special debugging pogram like dbx90 for NAG f95 is helpful. We give here only a very brief overview how to get it going.

Compiling

For debugging a f95-program with the dbx90-debugger, it should be compiled with the switch:

-g90

Starting the debugger

The debugger is started by typing dbx90 <program_name>

If the executable is named a.out the debugger is called by:

$ dbx90 a.out

As a result, dbx90 prompt will appear after some messages about the system and program:

(dbx90)

From there on you can start using dbx90 commands.

Some basic commands

For built-in help type help.

Some basic commands include:

list
lists 10 lines of the program starting from the current execution point. Note that for better understanding of the actual code it would be a good idea to start simultaneously an editor with the same source-file with linenumbering switched on.
stop at <line_number>
inserts a breakpoint at given line-number in current sourcefile.
run
starts the program.
next
execute next line in the code without stepping into subroutines/functions.
step
execute one line in the code, but if the line is a call to a subroutine/function, step into. Note that commands up and down can be used to move out or back in (without changing the execution point) the subroutine/function. (This can be usefule for setting breakpoints or examining variable values outside the subroutine/function.)
where
prints information about current execution point. Especially useful when the program crashed somewhere and you want to know where.
cont
continue the program execution
print <variable_name>
print out the variable contence. Note that f95 array syntax can be used to print out whole or partial arrays with one command. Try
display_<variable_name>
similar to print but the variable is printed out after each step.
undisplay_<variable_name>
undisplay items.
For more information on a specific command type help <command> form the dbx90-prompt. Please read also subsection "Debugging with dbx90" from the "NAGWare Compilers and Tools, f95 Compiler Rel. 4.0" manual that is available in hard copy.

Good luck with hunting bugs:-)

E Vainikko 2001-12-10