Help Files: Fortran77: DBX





     HELP                      June 15, 1985                   F77/DBX



                      Dbx - The Source Level Debugger

     The UNIX source language debugger is called "dbx", see "man  dbx"
     for  full  details.   To  get  the  full benefit of dbx, you must
     specify the -g flag when compiling and loading.  We will use  the
     following program to illustrate the use of dbx:

                     dimension vec(9)

                     do 10 i = 1, 9
             10      vec(i) = 10.0/(i - 5)
                     end

     Compile it, execute it, and invoke dbx to examine the dump:

             % f77 -g prog.f
             prog.f:
                MAIN:
             %
             % a.out
             *** Arithmetic Exception: Floating divide by zero
             Illegal instruction (core dumped)

             % dbx
             dbx version 12 of 10/29/84 16:34 (ucbopal).
             Type 'help' for help.
             enter object file name (default is `a.out'):
             reading symbolic information ...
             (dbx)

     When dbx is running, it changes the prompt to "(dbx)".   To  exit
     dbx, use the "quit" command.  Within dbx, the "help" command sum-
     marizes some (not all) of the  dbx  commands.   The  dbx  command
     "where"  displays  a  subroutine  traceback telling which line in
     each subroutine is active:

             (dbx)
             (dbx) where
             abort at 0x15df
             f77_abort(0x8, 0x1) at 0x2c1
             sigdie(0x8, 0x9, 0x7fffec4c, 0x10a) at 0x206
             MAIN, line 4 in "prog.f"
             main(0x1, 0x7fffecb0, 0x7fffecb8) at 0x100

     If you did not compile with -g, but did load with -g (e.g. f77 -g
     *.o); "where" still gives a traceback of the names of active sub-
     routines, but without line numbers.

     The "list" command lists the  source  for  the  currently  active
     source file:

             (dbx) list
                 1           dimension vec(9)
                 2
                 3           do 10 i = 1, 9
                 4   10      vec(i) = 10.0/(i - 5)
                 5           end

     The default is to list 10 lines at a  time;  you  can  specify  a
     range of lines as in "list 32,45".  Switch the active source file
     with the "file" command.  Use the "print" command to display  the
     values  of  variables.  If an array name is specified, the entire
     array is printed:

             (dbx)
             (dbx) print vec
             [1]     -2.5
             [2]     -3.33333
             [3]     -5.0
             [4]     -10.0
             [5]     0.0
             [6]     0.0
             [7]     0.0
             [8]     0.0
             [9]     0.0

     You can also request individual elements,  e.g.:  "print  vec[2],
     vec[8]".  Note you must use square brackets around subscripts in-
     stead of parentheses.

     The "/" command, listed in "man dbx" under  "Machine  Level  Com-
     mands", allows you to list any part of memory.  It may be used to
     print part of a vector or array, something that can not be speci-
     fied with the "print" command.  The general format of "/" is:

             address/count mode

     Commonly used modes with Fortran are:

             D       print an integer in decimal
             f       print a single precision real
             g       print a double precision real
             X       print an integer or single precision real in hexadecimal
             c       print a byte as a character
             s       print a string of characters terminated by a null (0 byte)

     To print vec() with the "/" command, type:

             &vec/9 f

     This says to start displaying memory at the address "&vec", which
     is  the  address  of vector vec(), display 9 items using floating
     point format:

             (dbx) &vec/9 f
             00002c34:  -2.500000 -3.333333 -5.000000 -10.000000
             00002c44:  0.000000 0.000000 0.000000 0.000000
             00002c54:  0.000000

     The "/" command may be used to print part of a vector  or  array.
     The following prints vec(3)...vec(6):

             (dbx)
             (dbx) &vec+8/4 f
             00002c3c:  -5.000000 -10.000001 0.000000 0.000000

     The initial address uses byte arithmetic, so that &vec+8  is  the
     address of vec(3).

             


Comments to decf@euler.berkeley.edu
© 1998 UC Regents