|
|
1.1 root 1: .TI F77/DBX "Sep. 4, 1985"
2: Dbx - The Source Level Debugger
3:
4: The UNIX source language debugger is called "dbx".
5: This write-up illustrates how to use dbx to examine
6: the memory image of a program after a fatal error.
7: Dbx can also be used to step through the execution of a program,
8: see "man dbx" for full details.
9: To get the full benefit of dbx, you must specify the -g flag
10: when compiling and loading.
11: We will use the following program to illustrate the use of dbx:
12:
13: .nf
14: dimension vec(10)
15:
16: do 10 i = 1, 10
17: 10 vec(i) = 10.0/(i - 5)
18: end
19: .fi
20:
21: Compile it, execute it, and invoke dbx to examine the dump:
22:
23: .nf
24: % f77 -g prog.f
25: prog.f:
26: MAIN:
27: %
28: % a.out
29: *** Arithmetic Exception: Floating divide by zero
30: Illegal instruction (core dumped)
31: %
32: % dbx
33: dbx version 3.3 of 8/28/85 19:51 (ucbopal).
34: Type 'help' for help.
35: enter object file name (default is `a.out'):
36: reading symbolic information ...
37: [using memory image in core]
38: (dbx)
39: .fi
40:
41: When dbx is running, it changes the prompt to "(dbx)".
42: To exit dbx, use the "quit" command.
43: Within dbx, the "help" command summarizes some (not all) of the dbx
44: commands.
45: The dbx command "where" displays a subroutine traceback telling
46: which line in each subroutine is active:
47: .nf
48:
49: (dbx)
50: (dbx) where
51: abort() at 0x15de
52: f77_abort(0x8, 0x1) at 0xa74
53: sigdie(0x8, 0x9, 0x7fffec68, 0x12e) at 0x229
54: MAIN(), line 4 in "prog.f"
55: main(0x1, 0x7fffeccc, 0x7fffecd4) at 0x123
56:
57: .fi
58: If you did not compile with -g, but did load with -g (e.g. f77 -g *.o);
59: \&"where" still gives a traceback of the names of active subroutines,
60: but without line numbers.
61:
62: The "list" command lists the source for the currently active source
63: file:
64:
65: .nf
66: (dbx) list
67: 1 dimension vec(10)
68: 2
69: 3 do 10 i = 1, 10
70: 4 10 vec(i) = 10.0/(i - 5)
71: 5 end
72: .fi
73:
74: The default is to list 10 lines at a time; you can specify a range of
75: lines as in "list 32,45". Switch the active source file with the "file"
76: command. Use the "print" command to display the values of variables.
77: If an array name is specified, the entire array is printed:
78: .nf
79:
80: (dbx)
81: (dbx) print vec
82: [1] -2.5
83: [2] -3.33333
84: [3] -5.0
85: [4] -10.0
86: [5] 0.0
87: [6] 0.0
88: [7] 0.0
89: [8] 0.0
90: [9] 0.0
91: [10] 0.0
92:
93: .fi
94: You can also request individual elements, e.g.: "print vec[2], vec[8]".
95: Note you must use square brackets around subscripts instead of parentheses.
96:
97: The "/" command, listed in "man dbx" under "Machine Level Commands",
98: allows you to list any part of memory.
99: It may be used to print part of a vector or array, something that can not
100: be specified with the "print" command.
101: The general format of "/" is:
102:
103: address/count mode
104:
105: Commonly used modes with Fortran are:
106:
107: .nf
108: D print an integer in decimal
109: f print a single precision real
110: g print a double precision real
111: X print an integer or single precision real in hexadecimal
112: c print a byte as a character
113: s print a string of characters terminated by a null (0 byte)
114: .fi
115:
116: To print vec() with the "/" command, type:
117:
118: &vec/10 f
119:
120: This says to start displaying memory at the address "&vec", which is the
121: address of vector vec(), display 10 items using floating point format:
122:
123: .nf
124: (dbx) &vec/10 f
125: 00002c34: -2.500000 -3.333333 -5.000000 -10.000000
126: 00002c44: 0.000000 0.000000 0.000000 0.000000
127: 00002c54: 0.000000 0.000000
128: .fi
129:
130: The "/" command may be used to print part of a vector or array.
131: The following prints vec(3)...vec(6):
132:
133: .nf
134: (dbx)
135: (dbx) &vec+8/4 f
136: 00002c3c: -5.000000 -10.000001 0.000000 0.000000
137: .fi
138:
139: The initial address uses byte arithmetic, so that &vec+8 is the address
140: of vec(3).
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.