229

Debugging Perl
Debugger Instructions

  • Perl's debugger instructions enable the control of flow, setting of and stopping at breakpoints, tracing, and so on

  • The basic instruction set consists of 40 commands

      Command Description
      h [command] Prints out a help message
      p expr Prints out the specified expression or value
      x expr Evaluates the specified expression and prints the result
      V [pkg [vars]] Display all (or some) variables in a package (default=main)
      X [vars] Same as V currentpackage [vars]
      T Produce a stack backtrace
      s [expr] Single step through a statement (enters subroutines)
      n Single step through a statement (steps over subroutines)
      <CR> Repeat last n or s command
      c [line] Conintue until an optionally specified line number
      l List next few lines
      l min+incr List incr+1 lines starting at min
      l min-max List lines min through max
      l line List a single line
      l subname List a few lines of a subroutine
      - List previous few lines
      w [line] List window (a few lines) around a given optional line
      . Return the debugger pointer to the last-executed line
      f filename Switch to viewing a different file
      /pattern/ Search forward for the pattern
      ?pattern? Search backward for the pattern
      L List all breakpoints and actions for the current file
      S [[!]pattern] List subroutine names matching (or not matching) pattern
      t Toggle trace mode (prints each executing line)
      t expr Trace through execution of expr
      b [line] [condition] Set a breakpoint at line with optional condition
      b subname [condition] Set a breakpoint for a subroutine with optional condition
      d [line] Delete breakpoint at the specified line
      D Delete all breakpoints
      a [line] command Set an action to be done before line is executed
      A Delete all actions
      O [opt[=val]] Set query values of options (???)
      < command Set action to happen before every debugger prompt
      > command Set action to happen after every debugger prompt
      ! number Redo a previous command
      ! -number Redo number'th to the last command
      ! pattern Redo last command that started with pattern
      !! cmd Run a command in a subprocess
      H -number Display last number commands
      q or ^D Quit out of the debugger
      R Restart the debugger
      |dbcmd Run the debugger command piping STDOUT to $ENV{PAGER}
      ||dbcmd Same as |dbcmd but temporarily selects STDOUT
      = [alias value] Define a command alias (or list aliases)
      command Execute command as a perl statement