Chapter 42. The Perl Debugger

The Perl symbolic debugger is invoked with perl -d.

Any input to the debugger that is not one of the commands enumerated below is evaluated as a Perl expression.

a [ line ] command

Sets an action for line.

A [ line ]

Deletes the action at the given line; default is the current line. If line is *, deletes all line actions.

b [ line [ condition ] ]

Sets a breakpoint at line; default is the current line.

b subname [ condition ]

Sets a breakpoint at the named subroutine.

b compile subname

Stops after the subroutine is compiled.

b load file

Sets a breakpoint at requireing the given file.

b postpone subname [ condition ]

Sets a breakpoint at the first line of the subroutine after it is compiled.

B [ line ]

Deletes the breakpoint at the given line; default is the current line. If line is *, deletes all breakpoints.

c [ line ]

Continues (until line, or another breakpoint, or exit).

f file

Switches to file and starts listing it.

h

Prints out a long help message.

h cmd

Prints out help for debugger command cmd.

h h

Prints out a concise help message.

H [ -number ]

Displays the last -number commands.

l [ range ]

Lists a range of lines. range may be a number, start - end, start + amount, or a subroutine name. If range is omitted, lists the next screenful.

l subname

Lists the named subroutine.

L [ a|b|w ]

Lists lines with actions, breakpoints, or watches.

m class

Prints the methods callable via the given class.

m expr

Evaluates the expression in list context, prints the methods callable on the first element of the result.

man [ topic ]

Views system documentation.

M

Shows versions of loaded modules.

n [ expr ]

Single steps around the subroutine call.

o [ opt [ = val ] ]

Sets values of debugger options. Default value is true.

o opt ?

Queries values of debugger options.

p expr

Evaluates expr in list context and prints the result. See also x on the next page.

q

Quits the debugger. An end of file condition on the debugger input will also quit.

r

Returns from the current subroutine.

R

Restarts the debugger.

s [ expr ]

Single steps.

source file

Executes the debugger commands in the named file.

S [ ! ] pattern

Lists the names of all subroutines [not] matching the pattern.

t

Toggles trace mode.

t expr

Traces through execution of expr.

T

Prints a stack trace.

v [ line ]

Lists a screenful of lines around the specified line.

V [ package [ pattern ] ]

Lists variables matching pattern in a package. Default package is main.

w expr

Adds a global watch-expression.

W [ expr ]

Deletes the global watch-expression. If expr is *, deletes all watch-expressions.

x expr

Evaluates expr in list context and dumps the result.

X [ pattern ]

Like V, but assumes the current package.

y [ n [ pattern ] ]

Like V, but lists lexicals in higher scope n. Requires the optional module PadWalker.

Returns to the executed line.

Lists the previous screenful of lines.

= [ alias [ value ] ]

Sets or queries an alias, or lists the current aliases.

/pattern [ / ]

Searches forward for pattern.

?pattern [ ? ]

Searches backward for pattern.

< command

Sets an action to be executed before every debugger prompt. If command is ?, lists current actions.

<< command

Adds an action to the list of actions to be executed before every debugger prompt.

> command

Sets an action to be executed after every debugger prompt. If command is ?, lists current actions.

>> command

Adds an action to the list of actions to be executed after every debugger prompt.

{ command

Defines a debugger command to run before each prompt. If command is ?, lists current commands.

{{ command

Adds a debugger command to the list of debugger commands to run before each prompt.

! [ [ - ] number ]

Re-executes a command. Default is the previous command.

! [ pattern ]

Re-executes the last command that started with pattern.

!! [ command ]

Runs command in a sub-process.

| cmd

Runs debugger command cmd through the current pager.

|| cmd

Same as | cmd, but selects DB::OUT as well.

Pressing the Enter or Return key at the debugger prompt will repeat the last s or n command.

The debugger uses environment variables DISPLAY, EMACS, LESS, MANPATH, PERL5DB, PAGER, OS2_SHELL, SHELL, TERM and WINDOWID, as well as several other variables all starting with PERLDB_.

perldebug, perldebtut.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset