Perl Debugger Reference

March 9, 2026 ยท View on GitHub

The PerlOnJava debugger provides an interactive debugging environment similar to Perl's built-in debugger.

Starting the Debugger

./jperl -d script.pl [arguments]

The debugger stops at the first executable statement and displays:

main::(script.pl:5):
5:  my $x = 10;
  DB<1>

Debugger Commands

Execution Control

CommandDescription
sStep into - Execute one statement, stepping into subroutine calls
nNext - Execute one statement, stepping over subroutine calls
rReturn - Execute until current subroutine returns
c [line]Continue - Run until breakpoint, end, or specified line (one-time)
qQuit - Exit the debugger and program

Press Enter to repeat the last command (default: n).

Breakpoints

CommandDescription
b [line]Set breakpoint at current or specified line
b file:lineSet breakpoint at line in specified file
B [line]Delete breakpoint at current or specified line
B *Delete all breakpoints
LList all breakpoints

Source Display

CommandDescription
l [range]List source code (e.g., l 10-20, l 15)
.Show current line
TShow stack trace (call stack)

Expression Evaluation

CommandDescription
p exprPrint expression result
x exprDump expression with Data::Dumper formatting

Help

CommandDescription
h or ?Show help

Debug Variables

The debugger provides access to standard Perl debug variables:

VariableDescription
$DB::singleSingle-step mode (1 = enabled)
$DB::traceTrace mode (1 = enabled)
$DB::signalSignal flag
$DB::filenameCurrent filename
$DB::lineCurrent line number
%DB::subSubroutine locations (subname => "file:start-end")
@DB::argsArguments of current subroutine

Examples

Basic Stepping

$ ./jperl -d script.pl
main::(script.pl:5):
5:  my $x = 10;
  DB<1> n
main::(script.pl:6):
6:  my $y = foo($x);
  DB<2> s
main::(script.pl:2):
2:  my ($arg) = @_;
  DB<3>

Setting Breakpoints

  DB<1> b 15
Breakpoint set at script.pl:15
  DB<1> b other.pl:20
Breakpoint set at other.pl:20
  DB<1> L
Breakpoints:
  script.pl:15
  other.pl:20
  DB<1> c

Evaluating Expressions

  DB<1> p $x + $y
42
  DB<1> p "@DB::args"
10 20 hello
  DB<1> x \@array
$VAR1 = [
          1,
          2,
          3
        ];

Inspecting Subroutine Locations

  DB<1> p $DB::sub{"main::foo"}
script.pl:10-15
  DB<1> x \%DB::sub
$VAR1 = {
          'main::foo' => 'script.pl:10-15',
          'main::bar' => 'script.pl:20-25'
        };

Limitations

The following Perl debugger features are not yet implemented:

  • Watchpoints (w command)
  • Actions (a command)
  • Conditional breakpoints (b line condition)
  • Custom debugger modules (-d:Module)
  • Restart (R command)
  • History and command editing
  • Lexical variable inspection (expressions evaluate in package scope)

See Also