NAME
DB::Pluggable - add plugin support for the Perl debugger
SYNOPSIS
$ cat ~/.perldb
use DB::Pluggable;
use YAML;
$DB::PluginHandler = DB::Pluggable->new(config => Load <<EOYAML);
global:
log:
level: error
plugins:
- module: BreakOnTestNumber
EOYAML
$DB::PluginHandler->run;
$ perl -d foo.pl
DESCRIPTION
This class adds plugin support to the Perl debugger. It is based on Hook::Modular, so see its documentation for details.
You need to have a ~/.perldb
file (see perldebug for details) that invokes the plugin mechanism. The one in the synopsis will do, and there is a more commented one in this distribution's etc/perldb
file.
Plugins should live in the DB::Pluggable::
namespace, like DB::Pluggable::BreakOnTestNumber does.
HOOKS
This class is very much in beta, so it's more like a proof of concept. Therefore, not all hooks imaginable have been added, only the ones to make this demo work. If you want more hooks or if the current hooks don't work for you, let me know.
The following hooks exist:
- plugin.init
-
Called at the beginning of the
run()
method. The hook doesn't get any arguments. - db.watchfunction
-
Called from within
DB::watchfunction()
. If you want the debugger to call the function, you need to enable it by callingenable_watchfunction()
somewhere within your plugin. It's a good idea to enable it as late as possible because it is being called very often. See the DB::Pluggable::BreakOnTestNumber source code for an example. The hook doesn't get any arguments. - db.cmd.b
-
Called when the
b
debugger command (used to set breakpoints) is invoked. Seerun()
below for what the hook should return.The hook passes these named arguments:
- cmd
-
This is the first argument passed to
DB::cmd_b()
. - line
-
This is the second argument passed to
DB::cmd_b()
. This is the most important argument as it contains the command line. See the DB::Pluggable::BreakOnTestNumber source code for an example. - dbline
-
This is the third argument passed to
DB::cmd_b()
.
METHODS
- enable_watchfunction
-
Tells the debugger to call
DB::watchfunction()
, which in turn calls thedb.watchfunction
hook on all plugins that have registered it. - run
-
First it calls the
plugin.init
hook, then it enables hooks for the relevant debugger commands (see above for which hooks are available).Each command-related hook should return the appropriate constant from DB::Pluggable::Constants - either
HANDLED
if the hook has handled the command, orDECLINED
if it didn't. If no hook hasHANDLED
the command, the default command subroutine (e.g.,DB::cmd_b()
) fromperl5db.pl
will be called.
DB::Pluggable inherits from Hook::Modular.
The superclass Hook::Modular defines these methods and functions:
new(), add_plugin_path(), add_rewrite_task(), add_to_rule_namespaces(),
autoload_plugin(), bootstrap(), context(), dumper(), error(),
extract_package(), home_dir(), init(), is_loaded(), load_cache(),
load_plugin(), load_plugins(), log(), register_hook(),
rewrite_config(), rule_namespaces(), run_hook(), run_hook_once(),
run_main(), set_context(), should_log()
The superclass Class::Accessor::Fast defines these methods and functions:
make_accessor(), make_ro_accessor(), make_wo_accessor()
The superclass Class::Accessor defines these methods and functions:
_carp(), _croak(), _mk_accessors(), accessor_name_for(),
best_practice_accessor_name_for(), best_practice_mutator_name_for(),
follow_best_practice(), get(), mk_accessors(), mk_ro_accessors(),
mk_wo_accessors(), mutator_name_for(), set()
TAGS
If you talk about this module in blogs, on del.icio.us or anywhere else, please use the dbpluggable
tag.
VERSION
This document describes version 0.02 of DB::Pluggable.
BUGS AND LIMITATIONS
No bugs have been reported.
Please report any bugs or feature requests to <bug-db-pluggable@rt.cpan.org
>, or through the web interface at http://rt.cpan.org.
INSTALLATION
See perlmodinstall for information and options on installing Perl modules.
AVAILABILITY
The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit <http://www.perl.com/CPAN/> to find a CPAN site near you. Or see <http://www.perl.com/CPAN/authors/id/M/MA/MARCEL/>.
AUTHOR
Marcel Grünauer, <marcel@cpan.org>
COPYRIGHT AND LICENSE
Copyright 2007-2008 by Marcel Grünauer
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.