Monday, January 3, 2011

perl debugger commands

INVOKING THE DEBUGGER
 
perl -d script.pl


- QUITTING THE DEBUGGER
q
NOTE: All the commands below are executed from within the debugger.


- LISTING THE SOURCE CODE
- List next window of lines
l

- List a specific line
l line_number

- List first window of lines from a specific subroutine
l subroutine_name

- View some lines of code around the current line
v


- BREAKPOINTS
- Set a breakpoint in the current line:
b

- Set a breakpoint before a specified line:
b line_number condition

"condition" is optional; if present, the breakpoint is activated only when the condition is met (example: b 12 $color == "red").

- Set a breakpoint before a specified subroutine:
b subroutine_name condition

"condition" is optional; if present, the breakpoint is activated only when the condition is met.
NOTE: "subroutine_name" can be a code reference variable, in this case "condition" cannot be used

- List all breakpoints defined
L b

- Delete a breakpoint from a specified line
B line_number

- Delete all breakpoints
B *


- STEPPING THROUGH THE CODE
- Execute a single statement, descending into subroutine calls
s

- Execute a single statement, without descending into subroutine calls
n

- Execute all statements until the return of the current subroutine
r

- Execute all remaining statements (optionally inserting a one-time-only breakpoint)
c # no breakpoint
c line_number # insert breakpoint
c subroutine_name #insert breakpoint