++ed by:

24 PAUSE user(s)
7 non-PAUSE user(s).

Anthony Brummett


Devel::hdb - Perl debugger as a web page and REST service


hdb is a Perl debugger that uses HTML and javascript to implement the GUI. This front-end talks to a REST service provided by the debugger running with the Perl code.


To debug a Perl program, start it like this:

    perl -d:hdb youprogram.pl

It will print a message on STDERR with the URL the debugger is listening to. Point your web browser at this URL and it will bring up the debugger GUI. It defaults to listening on localhost port 8080; to use a different port, start it like this:

    perl -d:hdb=port:9876 yourprogram.pl

To specify a particular IP address to listen on:

    perl -d:hdb=host: yourprogram.pl

And to listen on any interface:

    perl -d:hdb=a yourprogram.pl


The GUI is divided into three main parts: Control buttons, Code browser and Watch expressions. Additionally, click on the thick border between the code and watch panes to slide out the breakpoint list.

Control buttons

Step In

Causes the debugger to execute the next line and stop. If the next line is a subroutine call, it will stop at the first executable line in the subroutine.

Step Over

Causes the debugger to execute the next line and stop. If the next line is a subroutine call, it will step over the call and stop when the subroutine returns.

Step Out

Causes the debugger to run the program until it returns from the current subroutine.


Resumes execution of the program until the next breakpoint.


The debugged program immediately exits. The GUI in the web browser remains running.

Code Browser

Most of the interface is taken up by the code browser. Tabs along the top show one file at a time. The "+" next to the last tab brings up a dialog to choose another file to open. Click the "x" next to a file name to close that tab.

The first tab is special: it shows the stack frames of the currently executing program and cannot be closed. The stack tab itself has tabs along the left, one tab for each stack frame; the most recent frame is at the top.

Each of these tabs shows a Code Pane. The line numbers on the left are struck through if that line is not breakable. For breakable lines, clicking on the line number will set an unconditional breakpoint and turn the number red. Right-clicking on a breakable line number will bring up a menu where a breakpoint condition and action can be set. Lines with conditional breakpoints are blue. Lines with actions have a circle outline, and are dimmed when the breakpoint is inactive.

The banner at the top of the Code Pane shows the current function and its arguments. Clicking on the banner will scroll the Code Pane to show the currently executing line.

Hover the mouse over a variable to see its value. It shows the value in whichever stack frame is being displayed. To see the values for variables in higher frames, select the appropriate frame from the tab on the left.

Watch Expressions

The right side of the GUI shows watch expressions. To add a new expression to the watch window, click on the "+". To remove a watched expression, click on the "x" next to its name. Composite types like Hashes and arrays have a blue circled number indicating how many elements belong to it. To collapse/expand them, click the blue circle.

A watched typeglob will show all the used slots within the glob. Older versions of perl will always create an undefined value in the SCALAR slot. The value for the IO slot will be the file descriptor number of the filehandle and its position as reported by sysseek(), or undef if it is closed.

Key bindings

The debugger responds to these keys, which are generally the same as the command-line debugger commands


Step in


Step over


Repeat the last 's' or 'n'


Step out






Add new watch expression


Add new file


Scroll the code window to show the current line


Open the breakpoint manager


Toggle a breakpoint on the current line

Child Processes

The debugger overrides Perl's fork() built-in so that the child process will stop with the first statement after the fork(). In the parent process' debugger window, it will pop up a dialog with two options

Open Open a new browser window and debug the child process inside it
Detach Disables the debugger in the child process, and forces it to run to completion.

Trace and Follow mode

Devel::hdb can trace the execution of a program and stop if the code path differs from that of a previously saved run. First, run the program in trace mode:

  perl -d:hdb=trace:<tracefile> yourprogram.pl

In trace mode, the program runs normally, and the debugger does not stop execution. It records information about which lines of code were run into the specified file (tracefile, in this example). Next, run the program again in follow mode:

  perl -d:hdb=follow:<tracefile> yourprogram.pl

This time, the debugger starts up normally, stopping on the first line of the program. As the program runs, the debugger reads the trace information from the specified file. The first time the current location is different than what is in the file, the debugger will stop and report which line it expected. After it stops in this way, follow mode is disabled.

Included Code

This package includes these third party libraries:


Anthony Brummett <brummett@cpan.org>


Copyright 2014, Anthony Brummett. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.

Hosting generously
sponsored by Bytemark