Perl Debugger Refcard A4
Perl Debugger Refcard A4
Listing Code
f filename . l l lineno l subname l start+nlines l start-end v [lineno] /pattern[/] ?pattern[?] c c subname c lineno n s < CR> r R rerun rerun number rerun -n T t [expr] view source in le filename display next line to be executed list next window of lines list previous window of lines list single line lineno list lines starting at subname list lines start list lines start to end search forwards for [pattern] search backwards for [pattern] continue execution set one-time bkpt at subname and continue set one-time bkpt at lineno and continue next statement single step repeat last n or s continue, stop on return from current sub restart debugger rerun session to current position rerun session to numbered command rerun session to numberth-to-last command print a stack trace set tracing on, off or toggle
Andrew Ford
refcards.comTM
The perl debugger is included in the standard Perl distribution and is invoked on a program with the -d switch: perl -d program You can start a debugger session without a program by saying: perl -d -e 0
Debugger Commands
The debugger reads commands from the les .perldb in the current and home directories, and stops before the rst run-time executable statement, displaying the line it is about to execute and a prompt: DB<1> If you run code from the debugger and hit another breakpoint, the prompt will look like DB<<42>>. The numbers within the angle brackets are the command numbers, used when repeating commands. Any input to the debugger that is not recognized is executed as Perl code in the current package. Prexing a command with | pipes the output to your current pager.
Controlling Execution
Setting Options
o option=expr ... o option ... o option? ...
Debugger Variables
%DB::alias $DB::doccmd $DB::single $DB::signal $DB::trace $DB::fork_TTY table of command aliases
Environment Variables
PERL5DB PERLDB_OPTS PERL_DEBUG_MSTATS denes the debugger code to be run species options to the debugger reports memory usage information
Debugger Control
! number H [-number] source filename save filename = alias string = !! command
Examining Data
p x m i M S V X y e E expr [depth] expr expr class [[!]pattern] [pkg [[ | !]vars]] [[ | !]vars] [level [[ | !]vars]]
Debugging Options
Options are case insensitive and may be abbreviated. ArrayDepth AutoTrace trace mode CompactDump DieLevel DumpDBFiles DumpDepth DumpPackages DumpReused Frame GlobPrint control printing of contents of globs HiBit control quoting of characters \200\377 InhibitExit prevent stepping off end of script LineInfo MaxTraceLen NonStop enter non-interactive mode until interrupted NoTTY Ornaments Pager program to use for piped commands Quote PrintRet RecallCommand ReadLine RemotePort ShellBang SignalLevel TkRunning TTY undefPrint UsageOnly VeryCompact WarnLevel WindowSize code list window size
Perl Debugger Quick Reference Card Revision 0.1 for Perl Debugger version 5.8.x
A refcards.comTM quick reference card.
refcards.com is a trademark of Ford & Mason Ltd.
[July 2007]
Published by Ford & Mason Ltd. 2007 Andrew Ford and Ford & Mason Ltd. All rights reserved. Permission is granted to print and duplicate this card for personal or individual, internal business use. Download from refcards.com.