Redirection

There are two classes of commands in dbx: redirectable and non-redirectable. The non-redirectable commands take language expressions or patterns as arguments. Since the I/O redirection operators are also expression operators in the languages that dbx supports, any command that takes an expression treats the I/O operators as expression operators.

Examples of non-redirectable commands are: assign, bsearch, call, display, dump, examine, files, funcs, hide, print, run, rerun, search, stop, stopi, trace, tracei, undisplay, whatis, where, whereis, which.

To redirect commands, you can put the I/O redirection before the command keyword:

(dbx) >foo print a > b

If you wish to pipe the output of a non-redirectable command, you can wrap the command in curly braces:

(dbx) { print *p; } | awk '/member[0-3]/ { print }'

Only dbx output may be redirected in this manner; output produced by the target process (via printf(), for example) still goes to the stdout of the target process:

(dbx) >foo print printf("hello")

causes hello to appear on the terminal, and the file foo to contain

printf("hello") = 5

which is the return value of the printf() call function to be made non-redirectable (so it can accept language expressions as arguments).


Note - Non-redirectable commands also do not recognize # as the start of a comment. To add a comment to such a command, use ;#.

Using some dbx commands in a pipe may have undesired results. Any command that modifies the state of the target process (or modifies dbx's information concerning the state of the target process) will not behave as expected in a pipe. Commands that should not be used in pipes include: alias, attach, bsearch, call, catch, check, clear, collector, cont, dbxenv, debug, delete, detach, display, down, fix, frame, func, handler, hide, ignore, import, intercept, kill, language, next, nexti, pathmap, pop, quit, replay, rerun, restore, run, save, search, set, setenv, step, stepi, stop, stopi, suppress, trace, tracei, unalias, uncheck, undisplay, unhide, unintercept, unsuppress, up, use, when, wheni.

To redirect these commands, use a temp file:

(dbx) >/tmp/xxx call foo(); cat /tmp/xxx | sed 's/foo/FOO/'