Previous | Contents | Index |
To refer to a variable, use either the uppercase or lowercase letters. For example:
(ladebug) print J (ladebug) print j |
You can enter command names in uppercase:
(ladebug) PRINT J |
If you compile the program with the
f90
command option
-names as_is
and you need to examine case-sensitive names, you can control whether
Ladebug is case sensitive by setting the $lang environment variable to
the name of a case-sensitive language (see Section 4.8).
4.6.1 DIGITAL Fortran 90 Module Variables
To refer to a variable defined in a module, insert a dollar sign ($), the module name, and another dollar sign ($) 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:
(ladebug) list 5,9 5 USE MODFILE 6 INTEGER*4 J 7 CHARACTER*1 CHR 8 J = 2**8 (ladebug) PRINT $MODFILE$J 256 |
You can display the values of variables in a Fortran common block by using debugger commands such as print or whatis .
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:
(ladebug) list 1,11 1 PROGRAM EXAMPLE 2 3 INTEGER*4 INT4 4 CHARACTER*1 CHR 5 COMMON /COM_STRA/ INT4, CHR 6 7 CHR = 'L' 8 9 END (ladebug) PRINT COM_STRA COMMON INT4 = 0 CHR = "L" (ladebug) (ladebug) 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.
4.6.3 DIGITAL Fortran 90 Derived-Type Variables
Variables in a Fortran 90 derived-type (TYPE statement) are represented in Ladebug commands such as print or whatis using Fortran 90 syntax form.
For derived-type structures, use the derived-type variable name, a percent sign (%), and the member name. For example:
(ladebug) 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 (ladebug) PRINT Z%A (1) 1 (2) 1 (3) 1 (4) 1 (5) 1 (ladebug) |
To display the value of a field in a record structure, type 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, type the name of the record
structure, such as REC (instead of REC.CHR or REC%CHR) in the previous
example.
4.6.5 DIGITAL Fortran 90 Pointer Variables
DIGITAL Fortran 90 supports two types of pointers:
Fortran 90 pointers display their corresponding target data with a print command. You must specify the -ladebug option to provide Ladebug with information about pointers to arrays.
% f90 -g -ladebug point.f90 % ladebug ./a.out Welcome to the Ladebug Debugger Version x.x-xx ------------------ object file name: ./a.out Reading symbolic information ...done (ladebug) stop in ptr [#1: stop in ptr ] (ladebug) 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 (ladebug) run [1] stopped at [ptr:6 0x120001838] 6 x = (/ 1, 2, 3/) (ladebug) whatis x int x(1:3) (ladebug) whatis xp (1) int xp(:) (ladebug) s stopped at [ptr:7 0x120001880] 7 xp => x (ladebug) s stopped at [ptr:9 0x120001954] 9 print *, "x = ", x (ladebug) s x = 1 2 3 stopped at [ptr:10 0x1200019c8] (ladebug) s xp = 1 2 3 stopped at [point:12 0x120001ad8] 12 end (ladebug) S xp = 1 2 3 (ladebug) whatis xp (2) int xp(1:3) (ladebug) print xp (1) 1 (2) 2 (3) 3 (ladebug) quit % |
Like Fortran 90 pointers, DIGITAL Fortran (CRAY-style) pointers (POINTER statement) display the target data in their corresponding source form with a print command.
(ladebug) stop at 14 [#1: stop at "dfpoint.f90":14 ] (ladebug) run [1] stopped at [dfpoint:14 0x1200017e4] (ladebug) 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 (ladebug) whatis p float (1:5) pointer p (ladebug) print p 0x140003060 = (1) 10 (2) 20 (3) 30 (4) 40 (5) 50 (ladebug) quit % |
For array variables, put subscripts within parentheses (( )), as with Fortran 90 source statements. For example:
(ladebug) assign arrayc(1)=1 |
You can print out all elements of an array using its name. For example:
(ladebug) print arrayc (1) 1 (2) 0 (3) 0 (ladebug) |
Avoid displaying all elements of a large array. Instead, display specific array elements or array sections. For example, to print array element arrayc(2):
(ladebug) print arrayc(2) (2) 0 |
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:
(ladebug) print arr(2) 2 (ladebug) print arr(0:9:2) (0) = 0 (2) = 2 (4) = 4 (6) = 6 (8) = 8 (ladebug) print FiveByFive(:,3) (0,3) = 3 (1,3) = 13 (2,3) = 23 (3,3) = 33 (4,3) = 43 (ladebug) |
The only operations permissible on array sections are whatis and print.
4.6.6.2 Assignment to Arrays
Assignment to array elements are supported by Ladebug.
For information about assigning values to whole arrays and array
sections, see the Fortran chapter in the DIGITAL UNIX Ladebug Debugger Manual: Command-Line Interface.
4.6.7 Complex Variables
Ladebug supports COMPLEX, COMPLEX*8, and COMPLEX*16 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 |
Ladebug supports the display and assignment of COMPLEX variables and constants as well as basic arithmetic operators. For example:
Welcome to the Ladebug Debugger Version x.x-xx ------------------ object file name: complex Reading symbolic information ...done (ladebug) stop in complextest [#1: stop in complextest ] (ladebug) run [1] stopped at [complextest:15 0x1200017b4] 15 TYPE *, "C8=", C8 (ladebug) whatis c8 complex c8 (ladebug) whatis c16 double complex c16 (ladebug) print c8 (2, 8) (ladebug) print c16 (1.23, -4.56) (ladebug) assign c16=(-2.3E+10,4.5e-2) (ladebug) print c16 (-23000000512, 0.04500000178813934) (ladebug) |
The DIGITAL Fortran 90 data types and their equivalent built-in debugger names are as follows:
Fortran 90 Data Type Declaration | Debugger Equivalent |
---|---|
CHARACTER | character |
INTEGER, INTEGER(KIND= n) | integer |
LOGICAL, LOGICAL (KIND= n) | logical |
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 |
For a list of known Ladebug limitations, see the Fortran chapter in the
DIGITAL UNIX Ladebug Debugger Manual: Command-Line Interface.
4.7 Expressions in Debugger Commands
Expressions in debugger commands use Fortran 90 source language syntax for operators and expressions. The DIGITAL Fortran 90 operators include the following:
For a complete list of operators, see the DIGITAL Fortran Language Reference Manual.
Enclose debugger command expressions between curly braces ({ }). For example, the expression print k in the following statement is enclosed between curly braces ({ }):
(ladebug) when at 12 {print k} |
The Ladebug debugger lets you debug mixed-language programs. Program flow of control across subprograms written in different languages is transparent.
The debugger automatically identifies the language of the current subprogram or code segment on the basis of information embedded in the executable file. For example, if program execution is suspended in a subprogram in Fortran, the current language is Fortran. If the debugger stops the program in a C function, the current language becomes C. The debugger uses the current language to determine the valid expression syntax and the semantics used to evaluate an expression.
The debugger sets the $lang variable to the language of the current subprogram or code segment. By manually setting the $lang debugger variable, you can force the debugger to interpret expressions used in commands by the rules and semantics of a particular language. For example, you can check the current setting of $lang and change it as follows:
(ladebug) print $lang "C++" (ladebug) set $lang = "Fortran" |
When the
$lang
environment variable is set to "Fortran", names are case
insensitive. To make names case-sensitive when the program was compiled
with the
-names as_is
option, specify another language for the
$lang
environment variable, such as C, view the variable, then set the
$lang
environment variable to "Fortran".
4.9 Debugging a Program that Generates an Exception
If your program encounters an exception at run-time, to make it easier to debug the program, you should recompile and relink with the following f90 options before debugging the cause of the exception:
If requested, Ladebug will catch and handle exceptions before the DIGITAL Fortran 90 run-time library. This prevents the DIGITAL Fortran 90 run-time library from displaying exception handling messages.
Use the Ladebug commands catch and ignore to control whether Ladebug handles (catches) exceptions or ignores them:
To obtain the appropriate DIGITAL Fortran 90 run-time error message when debugging a program that generates an exception (especially one that allows program continuation), you may need to use the appropriate ignore command before running the program. For instance, use the following command to tell the debugger to ignore floating-point exceptions and pass them through to the DIGITAL Fortran 90 run-time library:
(ladebug) ignore fpe |
In cases where you need to locate the part of the program causing an
exception, consider using the where
command.
4.10 Locating Unaligned Data
As discussed in Chapter 5, unaligned data can slow program execution. You should determine the cause of the unaligned data, fix the source code (if necessary), and recompile and relink the program.
If your program encounters unaligned data at run-time, to make it easier to debug the program, you should recompile and relink with the following f90 options before debugging the cause of the exception:
Locating Unaligned Data With Ladebug
To determine the cause of the unaligned data when using Ladebug, follow these steps:
% ladebug testprog |
(ladebug) catch unaligned |
(ladebug) run Unaligned access pid=28413 <a.out> va=140000154 pc=3ff80805d60 ra=1200017e8 type=stl Thread received signal BUS stopped at [oops:13 0x120001834] 13 end |
(ladebug) list 12 12 i4 = 1 > 13 end |
(ladebug) where |
Locating Unaligned Data With dbx
To determine the cause of the unaligned data when using dbx, follow these steps:
% dbx testprog |
(dbx) stopi at 0x1200017f0 stopi at 0x1200017f0] |
(dbx) run [2] stopi at 0x1200017f0] [2] stopped at >*[oops:12, 0x1200017f0] stl r3, 0(r1) |
(dbx) where |
If a subprogram uses alternate entry points (ENTRY statement within the subprogram), Ladebug handles alternate entry points as a separate subprogram, including:
Previous | Next | Contents | Index |