Debugger Customization

The debugger probably contains enough configuration hooks that you'll never have to modify it yourself. You may change the behavior of debugger from within the debugger using its O command, from the command line via the PERLDB_OPTS environment variable, and by running any preset commands stored in rc files.

Editor Support for Debugging

The debugger's command-line history mechanism doesn't provide command-line editing like many shells do: you can't retrieve previous lines with ^p, or move to the beginning of the line with ^a, although you can execute previous lines with using the exclamation point syntax familiar to shell users. However, if you install the Term::ReadKey and Term::ReadLine modules from CPAN, you will have full editing capabilities similar to what GNU readline(3) provides.

If you have emacs installed on your system, it can interact with the Perl debugger to provide an integrated software development environment reminiscent of its interactions with C debuggers. Perl comes with a start file for making emacs act like a syntax-directed editor that understands (some of) Perl's syntax. Look in the emacs directory of the Perl source distribution. Users of vi should also look into vim (and gvim, the mousey and windy version) for coloring of Perl keywords.

A similar setup by one of us (Tom) for interacting with any vendor-shipped vi and the X11 window system is also available. This works similarly to the integrated multiwindow support that emacs provides, where the debugger drives the editor. However, at the time of this writing, its eventual location in the Perl distribution is uncertain. But we thought you should know of the possibility.

Customizing with Init Files

You can do some customization by setting up either a perldb or perldb.ini file (depending on your operating system), which contains initialization code. This init file holds Perl code, not debugger commands, and is processed before the PERLDB_OPTS environment variable is looked at. For instance, you could make aliases by adding entries to the %DB::alias hash this way:

$alias{len} = 's/^len(.*)/p length($1)/'; $alias{stop} = 's/^stop (at|in)/b/'; $alias{ps} = 's/^ps\b/p scalar /'; $alias{quit} = 's/^quit(\s*)/exit/'; $alias{help} = 's/^help\s*$/|h/';


You can change options from within your init file using function calls into the debugger's internal API:

parse_options("NonStop=1 LineInfo=db.out AutoTrace=1 frame=2");


If your init file defines the subroutine afterinit, that function is called after debugger initialization ends. The init file may be located in the current directory or in the home directory. Because this file contains arbitrary Perl commands, for security reasons, it must be owned by the superuser or the current user, and writable by no one but its owner.

If you want to modify the debugger, copy perl5db.pl from the Perl library to another name and hack it to your heart's content. You'll then want to set your PERL5DB environment variable to say something like this:

BEGIN {
 require "myperl5db.pl" }


As a last resort, you could also use PERL5DB to customize the debugger by directly setting internal variables or calling internal debugger functions. Be aware, though, that any variables and functions not documented either here or else in the online perldebug, perldebguts, or DB manpages are considered to be for internal use only and are subject to change without notice.

Debugger Options

The debugger has numerous options that you can set with the O command, either interactively or from the environment or from an init file.

The following options affect what happens with the V, X, and x commands: