Contents:
The Sdb Debugger
The Dbx Debugger
This section presents the debugging utilities for the UNIX environment:
Sdb (available in SVR4 but not Solaris 2.0)
Dbx (Solaris 2.0 only)
These debuggers take an executable object file and its
corefile-the core image file produced when objfile
is executed.
The debuggers then provide a controlled environment
for the execution of the program.
If objfile
and corefile
are not specified,
a.out is taken as the default object file and core
as the default core image file.
Each debugging utility is listed among the UNIX commands in Section 2 of this guide.
Sdb, the symbolic debugger, is used for checking assembly programs, executable C and FORTRAN programs, and core files resulting from aborted programs. It has the following command-line syntax:
sdb [
options
] [objfile
[corefile
[dir
]]]
A - in place of corefile
will force sdb to ignore any
core image file.
Ignore symbolic data; treat addresses as file offsets.
n
Don't stop processes that receive signal number n
.
See the signal system call for values of n
.
-s may be used more than once.
Print version information (and exit if no objfile
is given).
Make objfile
and corefile
writable.
Suppress warning messages about older files.
In the "Commands" section below, commands use
the specifiers m
, l
, and
n
. m
is the display format of an
address. (Addresses are specified by a variable or a line number.)
l
is the address length. n
stands for the line number.
Characters starting at variable's address.
Character.
Decimal.
32-bit floating.
64-bit double precision floating.
Disassemble machine-language instructions; print address using numbers and symbols.
Same as i, but print address using numbers only.
Octal.
Pointer to procedure.
Print character(s) at address pointed to by (string pointer) variable.
Unsigned decimal.
Hexadecimal.
Length specifiers are meaningful only with
m
values of c, d, o, u, or x.
One byte.
Two bytes (half word).
Four bytes (long word).
Refer to the previous specifiers when reviewing the sdb commands, which are grouped below:
t | Print a stack trace. |
T | Print the top line of the stack trace. |
variable / clm | Print variable according to length l and format m . Number c specifies how much memory (in units of l ) to display. |
n ? lm
variable :? lm | Print from a.out and procedure variable according to length l and format m . Default lm is i. |
variable = lm
n = lm
number = lm | Print the address of |
variable ! value | Assign value to variable . |
x | Display the machine registers and the machine instructions. |
X | Display the machine instructions. |
e | Print name of current file. |
e proc | Set current file to file containing procedure proc . |
e file | Set current file to file . |
e dir / | Append directory dir to directory list. |
p | Print current line. |
w | Print ten lines surrounding the current line. |
z | Print ten lines (starting at current); reset current line to last line. |
/ regexp / | Search ahead for regular expression regexp . |
? regexp ? | Search back for regular expression regexp . |
n | Set current line to n and print it. |
count + | Advance count lines; print new current line. |
count - | Go back count lines; print new current line. |
n a | Set a breakpoint at line number n and inform the user. |
[n ] b commands | Set breakpoint at line number |
[n ] c count | Continue after a breakpoint or, if |
[n ] C count | Same as c, but reactivate any signal that stopped program. |
n g count | Continue at line number |
[count ] r args | Run the program with the specified arguments. Ignore |
[count ] r | Rerun the program with the previously specified arguments.
Ignore |
[count ] R | Run the program with the no arguments. Ignore |
[level ] [v ] | This command is used when single-stepping via s, S, or m.
v turns off verbose mode; omit v to turn on verbose mode.
If |
proc (a1 ,a2 ,...) | Execute procedure |
B | Print active breakpoints. |
[n ] d | Delete breakpoint at line number n . |
D | Remove all breakpoints. |
i count | Single-step count machine-language instructions. |
I count | Same as i, but reactivate any signal that stopped program. |
k | Kill the program you're debugging. |
l | Print the previous line executed. |
M | Print the address maps. |
var $m count
addr :m count | Single-step |
q | Exit sdb. |
s [count ] | Single-step count lines. |
S [count ] | Same as s, but skip called functions. |
# text | Supply a text comment ignored by sdb. |
! cmd | Execute cmd with sh. |
newline | Display the next line or memory location, or disassemble the next instruction. |
EOF | Scroll the display ten lines. |
< file | Execute commands contained in file . |
string | Print a quoted string . C escape characters
are recognized. |
V | Print the sdb version number. |