DB::cmd_b_sub or DB::break_subroutine functions set a breakpoint at the beginning of an arbitrary function. You can go through the code to find a set of arguments to jump to this function. For instance,
sub add_breakpoints_for_module { my $module = shift; return unless $INC{"perl5db.pl"};
This code should run after loading the appropriate modules.
But how to use this idea as a separate library. Save this code to Devel/ModuleBreaker.pm somewhere on the @INC path and call the debugger as
perl -d:ModuleBreaker=Some::Module,Some::Other::Module script_to_debug.pl args
.
# Devel/ModuleBreaker.pm - automatically break in all subs in arbitrary modules package Devel::ModuleBreaker; sub import { my ($class,@modules) = @_; our @POSTPONE = @modules; require "perl5db.pl"; } CHECK {
And here is a version that breaks routines that match arbitrary patterns (which should make it easier to split inside submodules). It uses the %DB::sub table, which contains information about all loaded routines (including anonymous subsystems).
package Devel::SubBreaker;
source share