6.2. Debugger CommandsThe debugger understands the following commands.
< [command] Sets a Perl command to run before every debugger prompt. A multiline command may be entered by backslashing the newlines. With no command, the list of actions is reset.
<CR> Repeats last n or s command.
> [command] Sets a Perl command to run after the prompt when you've just given a command to return to executing the script. A multiline command may be entered by backslashing the newlines.
>> [command] Adds to the list of Perl commands to run after each debugger prompt.
! -number Reruns numberth-to-last command.
! pattern Reruns last command that started with pattern. See O recallCommand.
!! cmd Runs cmd in a subprocess (which reads from DB::IN and writes to DB::OUT). See O shellBang.
|| dbcmd Same as |dbcmd, but DB::OUT is temporarily select ed as well. Often used with commands that would otherwise produce long output, such as: |V main
= [alias value] Defines a command alias. If alias and valueare omitted, lists all current aliases.
a [line] command Sets an action to be done before the line is executed. The following steps are taken:
For example, the following prints the value of $foo (and DB FOUND) every time line 53 is passed: a 53 print "DB FOUND $foo\n"
b [line] [condition] Sets a breakpoint at line, which must begin an executable statement. If line is omitted, sets a breakpoint on the line that is about to be executed. condition, if given, is evaluated each time the statement is reached, and a breakpoint is taken if condition is true: b 237 $x > 30 b 33 /pattern/i
b subname [condition] Sets a (possibly conditional) breakpoint at the first line of the named subroutine.
b load filename Sets a breakpoint on requireing the given file.
b postpone subname [condition] Sets a (possibly conditional) breakpoint at the first line of subroutine subname after it has been compiled.
b compile subname Stops after the subroutine has been compiled.
c [line | sub] Continues, optionally inserting a one-time-only breakpoint at the specified line or subroutine.
d [line] Deletes the breakpoint at the specified line. If line is omitted, deletes the breakpoint on the line that is about to be executed..
H [-number] Displays last number commands. If number is omitted, it lists all previous commands. Only commands longer than one character are listed.
h [command] Prints a help message, listing the available debugger commands. If you supply another debugger command as an argument to the h command, it prints out the description for just that command. The command h h produces a more compact help listing designed to fit on one screen.
l [linespec] If linespec is omitted, lists the next few lines. Otherwise, lists the lines specified by linespec, which can be one of the following:
Also see the w and - commands.
m expr evals the expression in array context and prints methods callable on the first element of the result.
m class Prints methods callable via the given class.
O [opt[="val"]] [opt'val'] [opt?] Sets or queries option values. If omitted, val defaults to 1. opt? displays the value of option opt. opt can be abbreviated to the shortest unique string, and multiple options can be specified. The possible options are:
The following options affect what happens with the V, X, and x commands:
During startup, debugger options are initialized from $ENV{PERLDB_OPTS}. You can set the additional initialization options TTY, noTTY, ReadLine, and NonStop there. See Section 6.4, "Customizing the Debugger" later in this chapter for more information.
p expr Same as print DB::OUT expr in the current package. In particular, does not dump nested data structures and objects, unlike the x command. The DB::OUT handle is opened to /dev/tty (or perhaps an editor window) no matter where standard output may have been redirected to.
R Restarts the debugger. As much of your history is maintained across the sessions as possible, but some internal settings and command-line options may be lost.
S [[!]pattern] Lists subroutine names matching (or, if ! is specified, not matching) pattern. If pattern is omitted, lists all subroutines.
s [expr] Single steps. Executes until it reaches the beginning of another statement, descending into subroutine calls. If an expression is supplied that includes a function call, the function is also single-stepped.
T Produces a stack backtrace. For example: DB<2> T $ = main::infested called from file 'Ambulation.pm' line 10 @ = Ambulation::legs(1, 2, 3, 4) called from file 'camel_flea' line 7 $ = main::pests('bactrian', 4) called from file 'camel_flea' line 4 The lefthand character ($ or @) tells whether the function was called in a scalar or list context. The example shows three lines because it was three functions deep when the stack backtrace ran.
t expr Traces through execution of expr.
V [pkg [vars]] Displays all (or some) variables in package pkg using a data pretty-printer (which displays keys and their values for hashes, makes control characters printable, prints nested data structures in a legible fashion, and so on). pkg defaults to the main package. Make sure you enter the identifiers without a type specifier such as $ or @, like this: V DB filename line In place of a variable name, you can use ~pattern or !pattern to print existing variables with names that either match or don't match the specified regular expression.
w [line] Lists a window of a few lines around the given line, or lists the current line if line is omitted.
x expr evals the expression in a list context and dumps out the result in a pretty-printed fashion. Unlike the print command above, prints nested data structures recursively. Copyright © 2002 O'Reilly & Associates. All rights reserved. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|