Preparing Your Program for Debugging

Use the ifort command with certain options to create an executable program for debugging.

Debugging Options

To use the debugger, you should specify the ifort command and the -g command-line option. Traceback information and symbol table information are both necessary for debugging. If you specify -g, the compiler provides the symbol table and traceback information needed for symbolic debugging. (The -notraceback option cancels the traceback information.)

Likely uses of these options at the various stages of program development are as follows:

During early stages of program development, use the -g option to create unoptimized code (optimization level -O0). This option also might be chosen later to debug reported problems from later stages.

Traceback and symbol table information result in a larger object file. During the later stages of program development, use -g0 or -g1 to minimize the object file size and, as a result, the memory needed for program execution, usually with optimized code. (The -g0 option eliminates the traceback information.)

When you have finished debugging your program, you can recompile and relink to create an optimized executable program or remove traceback and symbol table information with the strip command. (See strip(1).)

See the -debug keyword option in the Compiler Options reference to learn more about settings that enhance debugging.

Starting the Debugger

To invoke the debugger, enter the debugger shell command and the name of the executable program.

The following commands create (compile and link) the executable program and invoke the interface to the debugger:

ifort -g -o squares squares.f90

idb squares

Linux Application Debugger for xx-bit applications, Version x.x, Build xxxx

object file name: squares

reading symbolic information ... done

(idb)

In this example, the ifort command:

The idb shell command runs the debugger, specifying the executable program squares.

At the debugger prompt (idb), you can enter a debugger command.

See also the online Intel ® Debugger (IDB) Manual.