Using Predefined Variables
Certain read-only ksh
predefined variables are provided. The variables listed in the following
table are always valid.
|
|
$ins
|
Disassembly of the current instruction.
|
$lineno
|
Current line number in decimal.
|
$vlineno
|
Current “visiting” line number in decimal.
|
$line
|
Contents of the current line.
|
$func
|
Name of the current function.
|
$vfunc
|
Name of the current “visiting” function.
|
$class
|
Name of the class to which $func
belongs.
|
$vclass
|
Name of the class to which $vfunc
belongs.
|
$file
|
Name of the current file.
|
$vfile
|
Name of the current file being visited.
|
$loadobj
|
Name of the current loadable object.
|
$vloadobj
|
Name of the current loadable object being visited.
|
$scope
|
Scope of the current PC in back-quote notation.
|
$vscope
|
Scope of the visited PC in back-quote notation.
|
$funcaddr
|
Address of $func in hex.
|
$caller
|
Name of the function calling $func.
|
$dllist
|
After a dlopen or dlclose
event, contains the list of load objects just loaded or unloaded.
The first word of dllist is a + (plus sign) or a
- (minus sign) depending on whether a dlopen or a
dlclose has occurred.
|
$newhandlerid
|
ID of the most recently created handler. This variable has an
undefined value after any command that deletes handlers. Use the
variable immediately after creating a handler.
dbx cannot capture all of the handler IDs for
a command that creates multiple handlers.
|
$firedhandlers
|
List of handler ids that caused the most recent stoppage. The
handlers on the list are marked with *(an asterisk) in the output of
the status command.
|
$proc
|
Process ID of the current process being debugged.
|
$lwp
|
ID of the current LWP.
|
$thread
|
Thread ID of the current thread.
|
$newlwp
|
ID of a newly created LWP.
|
$newthread
|
ID of a newly created thread.
|
$prog
|
Full path name of the program being debugged.
|
$oprog
|
Previous value of $prog, which is used to get
back to what you were debugging following an
exec(), when the full path name of the
program reverts to - (dash). While $prog is
expanded to a full path name, $oprog contains the
program path as specified on the command line or to the
debug command. If exec()
is called more than once, there is no way to return to the original
program.
|
$exec32
|
True if the dbx binary is 32-bit.
|
$exitcode
|
Exit status from the last run of the program. The value is an
empty string if the process has not exited.
|
$booting
|
Set to true if the event occurs during the boot
process. Whenever a new program is debugged, it is first booted so
that the list and location of shared libraries can be ascertained.
The process is then killed. This sequence is termed
“booting”.
While booting is occurring, all events are still available. Use
this variable to distinguish, for example, the
sync and syncrtld events
occurring during a debugging run and the ones occurring during a
normal run.
|
$machtype
|
If a program is loaded, returns its machine type:
sparcv8, sparcv8+,
sparcv9,
x86,
or
x86_64.
Otherwise, returns unknown.
|
$datamodel
|
If a program is loaded, returns its data model:
ilp32 or lp64. Otherwise,
returns unknown. To find the model of the program
you've just loaded, use the following in your
.dbxrc file:
when prog_new -perm {
echo machine: $machtype $datamodel;
}
|
|
The following example shows that whereami can be
implemented:
function whereami {
echo Stopped in $func at line $lineno in file $(basename $file)
echo "$lineno\t$line"
}
Variables Valid for when Command
The
variables described in this section are valid only within the body of a
when command.
$handlerid
During the execution of the body, $handlerid is the ID of
the when command to which the body belongs. The following
commands are equivalent:
when X -temp { do_stuff; }
when X { do_stuff; delete $handlerid; }
Variables Valid for when Command and Specific Events
Certain
variables are valid only within the body of a when
command and for specific events, as shown in the following tables.
Table 3 Variables Valid for sig Event
|
|
$sig
|
Signal number that caused the event
|
$sigstr
|
Name of $sig
|
$sigcode
|
Subcode of $sig if applicable
|
$sigcodestr
|
Name of $sigcode
|
$sigsender
|
Process ID of sender of the signal, if appropriate
|
|
Table 4 Variable Valid for exit Event
|
|
$exitcode
|
Value of the argument passed to _exit(2) or
exit(3) or the return value of
main
|
|
Table 5 Variable Valid for dlopen and dlclose
Events
|
|
$dlobj
|
Pathname of the load object dlopened or dlclosed
|
|
Table 6 Variables Valid for sysin and sysout
Events
|
|
$syscode
|
System call number
|
$sysname
|
System call name
|
|
Table 7 Variable Valid for proc_gone Events
|
|
$reason
|
One of signal, exit,
kill, or detach
|
|
Table 8 Variables Valid for thr_create Event
|
|
$newthread
|
ID of the newly created thread, for example,
t@5
|
$newlwp
|
ID of the newly created LWP, for example,
l@4
|
|
Table 9 Variables Valid for access Event
|
|
$watchaddr
|
The address being written to, read from, or executed
|
$watchmode
|
One of the following: r for read, w for write, x for execute;
followed by one of the following: a for after, b for
before
|
|