Displaying Variables in the Debugger

To refer to a variable, use either the uppercase or lowercase letters. For example:

(idb) print J

(idb) print j

You can enter command names in uppercase:

(idb) print J

If you compiled the program with the command-line option -names as_is and you need to examine case-sensitive names, you can control whether idb is case-sensitive by setting the $lang environment variable to the name of a case-sensitive language.

Module Variables

To refer to a variable defined in a module, insert an opening quote (‘), the module name, and another opening quote (‘) before the variable name. For example, with a variable named J defined in a module named modfile (statement MODULE MODFILE), enter the following command to display its value:

(idb)    list 5,9

     5     USE MODFILE

     6      INTEGER*4 J

     7      CHARACTER*1 CHR

     8      J = 2**8

(idb)    print ‘MODFILE‘J

256

Common Block Variables

You can display the values of variables in a Fortran common block by using the debugger command print. Use the whatis command to return the type for the variable.

To display the entire common block, use the common block name.

To display a specific variable in a common block, use the variable name. For example:

(idb)     list 1,11

   1       PROGRAM EXAMPLE

   2

   3       INTEGER*4 INT4

   4       CHARACTER*1 CHR

   5       COMMON /COMSTRA/ INT4, CHR

   6

   7       CHR = 'L'

   8

   9       END

(idb)     print COMSTRA

COMMON

        INT4 = 0

        CHR = "L"

(idb)

(idb)     print CHR

"L"

If the name of a data item in a common block has the same name as the common block itself, the data item is accessed.

Derived-Type Variables

Variables in a Fortran 95/90 derived-type (TYPE statement) are represented in idb commands such as print or whatis using Fortran 95/90 syntax form.

For derived-type structures, use the derived-type variable name, a percent sign (%), and the member name. For example:

(idb)     list 3,11

    3  TYPE X

    4      INTEGER A(5)

    5    END TYPE X

    6  

    7   TYPE (X) Z

    8

    9   Z%A = 1

   10

   11   PRINT *,Z%A

(idb)     print Z%A

(1) 1

(2) 1

(3) 1

(4) 1

(5) 1

(idb)

To display the entire object, use the print command with the object name. For example:

(idb)  print Z

Record Variables

To display the value of a field in a record structure, enter the variable name as: the record name, a delimiter (either a period (.) or a percent sign (%)), and the field name.

To view all fields in a record structure, enter the name of the record structure, such as REC (instead of REC.CHR or REC%CHR).

Pointer Variables

Intel Fortran supports two types of pointers:

Fortran 95/90 Pointers

Fortran 95/90 pointers display their corresponding target data with a print command.

Comments keyed to the callouts at the right follow the example:

ifort -g point.f90

idb ./a.out

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

object file name: ./a.out

Reading symbolic information ...done

(idb) stop in ptr

[#1: stop in ptr ]

(idb) list 1:13

      1       program ptr

      2

      3       integer, target :: x(3)

      4       integer, pointer :: xp(:)

      5

      6       x = (/ 1, 2, 3/)

      7       xp => x

      8

      9       print *, "x = ", x

     10       print *, "xp = ", xp

     11

     12       end

(idb) run

[1] stopped at [ptr:6 0x120001838]

      6        x = (/ 1, 2, 3/)

(idb) whatis x

int x(1:3)

(idb) whatis xp                                    (1)

int xp(:)

(idb) s

stopped at [ptr:7 0x120001880]

      7       xp => x

(idb) s

stopped at [ptr:9 0x120001954]

      9       print *, "x = ", x                    

(idb) s

x =            1           2           3

stopped at [ptr:10 0x1200019c8]

(idb) s

 xp =            1           2           3

stopped at [point:12 0x120001ad8]

     12       end

(idb) S  

 xp =            1           2           3

(idb) whatis xp                                     (2)

int xp(1:3)

(idb) print xp

(1) 1

(2) 2

(3) 3

(idb) quit

%

  1. For the first whatis xp command, xp has not yet been assigned to point to variable x and is a generic pointer.
  2. Since xp has been assigned to point to variable x, for the second whatis xp command, xp takes the same size, shape, and values as x.

Integer Pointers

Like Fortran 95/90 pointers, integer pointers (also known as Cray*-style pointers) display the target data in their corresponding source form with a print command:

(idb) stop at 14

[#1: stop at "dfpoint.f90":14 ]

(idb) run

[1] stopped at [dfpoint:14 0x1200017e4]

(idb) list 1,14

      1       program dfpoint

      2

      3       real i(5)

      4       pointer (p,i)

      5

      6       n = 5

      7

      8       p = malloc(sizeof(i(1))*n)

      9

     10       do j = 1,5

     11          i(j) = 10*j

     12       end do

     13

>    14       end

(idb) whatis p

float (1:5) pointer p

(idb) print p

0x140003060 = (1) 10

(2) 20

(3) 30

(4) 40

(5) 50

(idb) quit

%

Array Variables

For array variables, put subscripts within parentheses, as with Fortran 95/90 source statements. For example:

(idb) assign arrayc(1)=1

 You can print out all elements of an array using its name. For example:

(idb) print arrayc

(1) 1

(2) 0

(3) 0

(idb)

Avoid displaying all elements of a large array. Instead, display specific array elements or array sections. For example, to print array element arrayc(2):

(idb) print arrayc(2)

(2) 0

Array Sections

An array section is a portion of an array that is an array itself. An array section can use subscript triplet notation consisting of a three parts: a starting element, an ending element, and a stride.

Consider the following array declarations:

INTEGER, DIMENSION(0:99)    :: arr

INTEGER, DIMENSION(0:4,0:4)  :: FiveByFive

Assume that each array has been initialized to have the value of the index in each position, for example, FiveByFive(4,4) = 44, arr(43) = 43. The following examples are array expressions that will be accepted by the debugger:

(idb) print arr(2)

2

(idb) print arr(0:9:2)

(0) = 0

(2) = 2

(4) = 4

(6) = 6

(8) = 8

(idb) print FiveByFive(:,3)

(0,3) = 3

(1,3) = 13

(2,3) = 23

(3,3) = 33

(4,3) = 43

(idb)

The only operations permissible on array sections are whatis and print.

Complex Variables

idb supports COMPLEX or COMPLEX*8, COMPLEX*16, and COMPLEX*32 variables and constants in expressions.

Consider the following Fortran program:

PROGRAM complextest

      COMPLEX*8 C8 /(2.0,8.0)/

      COMPLEX*16 C16 /(1.23,-4.56)/

      REAL*4     R4 /2.0/

      REAL*8     R8 /2.0/

      REAL*16    R16 /2.0/

 

      TYPE *, "C8=", C8

      TYPE *, "C16=", C16

    END PROGRAM

idb supports the display and assignment of COMPLEX variables and constants as well as basic arithmetic operators. For example:

Welcome to the idb Debugger Version x.x-xx

------------------

object file name: complex

Reading symbolic information ...done

(idb) stop in complextest

[#1: stop in complextest ]

(idb) run

[1] stopped at [complextest:15 0x1200017b4]

     15       TYPE *, "C8=", C8

(idb) whatis c8

complex c8

(idb) whatis c16

double complex c16

(idb) print c8

(2, 8)

(idb) print c16

(1.23, -4.56)

(idb) assign c16=(-2.3E+10,4.5e-2)

(idb) print c16

(-23000000512, 0.04500000178813934)

(idb)  

Data Types

The table below shows the Intel Fortran data types and their equivalent built-in debugger names:

Fortran 95/90 data type declaration

Debugger equivalent

CHARACTER

character

INTEGER, INTEGER(KIND=n)

integer, integer*n

LOGICAL, LOGICAL (KIND=n)

logical, logical*n

REAL, REAL(KIND=4)

real

DOUBLE PRECISION, REAL(KIND=8)

real*8

REAL(KIND=16)

real*16

COMPLEX, COMPLEX(KIND=4)

complex

DOUBLE COMPLEX, COMPLEX(KIND=8)

double complex

COMPLEX(KIND=16), COMPLEX*32

long double complex