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.
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.
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:
You can change options from within your init file using function calls into the debugger's internal API:$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/';
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.parse_options("NonStop=1 LineInfo=db.out AutoTrace=1 frame=2");
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:
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.BEGIN { require "myperl5db.pl" }
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 characters used to recall a command or spawn a shell. By default, both are set to !.
Program to use for output of pager-piped commands (those beginning with a | character.) By default, $ENV{PAGER} will be used. Because the debugger uses your current terminal characteristics for bold and underlining, if the chosen pager does not pass escape sequences through unchanged, the output of some debugger commands will not be readable when sent through the pager.
Set the level of verbosity. By default, the debugger leaves your exceptions and warnings alone because altering them can break correctly running programs.
To disable this default safe mode, set these values to something higher than 0. At a level of 1, you get backtraces upon receiving any kind of warning (this is often annoying) or exception (this is often valuable). Unfortunately, the debugger cannot distinguish fatal exceptions from nonfatal ones. If dieLevel is 1, then your nonfatal exceptions are also traced and unceremoniously altered if they came from evaled strings or from any kind of eval within modules you're attempting to load. If dieLevel is 2, the debugger doesn't care where they came from: it usurps your exception handler and prints out a trace, and then modifies all exceptions with its own embellishments. This may perhaps be useful for some tracing purposes, but it tends to hopelessly confuse any program that takes its exception handling seriously.
The debugger will attempt to print a message when any uncaught INT, BUS, or SEGV signal arrives. If you're in a slow syscall (like a wait or an accept, or a read from your keyboard or a socket) and haven't set up your own $SIG{INT} handler, then you won't be able to Control-C your way back to the debugger, because the debugger's own $SIG{INT} handler doesn't understand that it needs to raise an exception to longjmp(3) out of slow syscalls.
Set the trace mode (similar to t command, but can be put into PERLDB_OPTS).
Assign the file or pipe to print line number info to. If it is a pipe (say, |visual_perl_db), then a short message is used. This is the mechanism used to interact with a slave editor or visual debugger, such as the special vi or emacs hooks, or the ddd graphical debugger.
Affects screen appearance of the command line (see the online docs for Term::ReadLine). There is currently no way to disable ornaments, which can render some output illegible on some displays or with some pagers. This is considered a bug.
Affects printing of messages on entry and exit from subroutines. If frame & 2 is false, messages are printed on entry only. (Printing on exit might be useful if interspersed with other messages.)
If frame & 4, arguments to functions are printed, plus context and caller info. If frame & 8, overloaded stringify and tied FETCH are enabled on the printed arguments. If frame & 16, the return value from the subroutine is printed.
The length at which the argument list is truncated is governed by the next option.
Length to truncate the argument list when the frame option's bit 4 is set.
The following options affect what happens with the V, X, and x commands:
Print only the first n elements. If n is omitted, all of the elements will be printed.
Change the style of array and hash output. If compactDump is enabled, short arrays may be printed on one line.
Display arrays holding debugged files.
Change the style of string display. The default value for quote is auto; you can enable double-quotish or single-quotish format by setting it to " or ', respectively. By default, characters with their high bit set are printed verbatim.
Instead of showing the contents of a package's variables, with this option enabled, you get a rudimentary per-package memory usage dump based on the total size of the strings found in package variables. Because the package symbol table is used, lexical variables are ignored.
Copyright © 2001 O'Reilly & Associates. All rights reserved.