Debugging a Program With dbx

Command Reference

when

To execute command(s) when the specified event occurs:


when event-specification
 { command(s); 
}

stop

To stop execution at a given event:


stop event-specification

To stop execution now and update displays. Whereas normally the process is continued after the body has executed, the stop command prevents that. This form is only valid within the body of a when:


stop -update

Same as above, but does not update displays:


stop -noupdate

step

The step command is equivalent to:


when step -temp { stop; }; cont

The step command can take a sig argument. A step by itself cancels the current signal just like cont does. To forward the signal, you must explicitly give the signal. You can use the variable $sig to step the program forwarding it the current signal:


step -sig $sig

cancel

Only valid within the body of when. The cancel command cancels any signal that might have been delivered, and lets the process continue. For example:


when sig SIGINT { echo signal info;  cancel; }

status

The status command lists handlers, those created by trace, when, and stop. status lists the given handler. If the handler is disabled, its hid is printed inside square brackets [ ] instead of parentheses ( ).


status [-s] -h hid

The output of status can be redirected to a file. Nominally, the format is unchanged during redirection. You can use the -s flag to produce output that allows a handler to be reinstated using the source command. If the -h option is used, hidden handlers are also listed.

The original technique of redirecting handlers using status and sourcing the file was a way to compensate for the lack of handler enabling and disabling functionality.

delete

The delete command deletes breakpoints and other handlers.


delete [-h] all -all -temp hid
 [hid ...
]

delete hid deletes the specified handler.

delete all, delete 0 (zero), or delete -all deletes all handlers including temporary handlers.

delete -temp deletes only all temporary handlers.

-h hid is required if hid is a hidden handler. -h all deletes all hidden handlers as well.

clear

clear with no arguments deletes all handlers based on breakpoints at the location where the process stopped. clear line deletes all handlers based on breakpoints on the given line.

clear line

handler

A handler is created for each event that needs to be managed in a debugging session. The commands trace, stop, and when create handlers. Each of these commands returns a number known as the handler ID (hid). The handler, status, and delete commands manipulate or provide information about handlers in a generic fashion.


handler [ -disable | -enable ] all hid
 [...]

handler -disable hid disables the specified event.

handler -disable all disables all handlers.

handler -enable hid enables the specified handler.

handler -enable all enables all handlers.


handler [ -count hid  [new-count-limit
] | -reset  hid ]

handler -count hid returns the count of the event in the form current-count/limit (same as printed by status). limit might be the keyword infinity. Use the ksh modifiers ${#} and ${##} to split the printed value.

handler -count hid new-count-limit assigns a new count limit to the given handler.

handler -reset hid resets the count of the handler to 0 (zero).