File Coverage

blib/lib/Devel/SubBreaker.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition 1 2 50.0
subroutine 1 1 100.0
pod n/a
total 5 6 83.3


line stmt bran cond sub pod time code
1             package Devel::SubBreaker;
2             our $VERSION = 0.03;
3             sub import {
4 1     1   12 our @patterns = @_[1..$#_];
5 1   50     8 my $E = $ENV{PERL5DBX} || 'require "perl5db.pl"';
6 1         54 eval $E;
7             }
8             CHECK { # expect compile-time mods have been loaded before CHECK phase
9             foreach my $sub (sort keys %DB::sub) {
10              
11             # exclude some pragmas, core modules, and modules integral to the
12             # debugger, as breaking inside these modules can cause problems
13             # This list is constructed by trial-and-error so that it does
14             # not cause any problems for perl v5.08 through v5.26.
15             #
16             # If you encounter any additional modules and pragmas that must
17             # be excluded for this module to function, submit a bug report to
18             # http://rt.cpan.org/NoAuth/Bugs.html?Dist=Devel-ModuleBreaker
19              
20              
21             next if $sub =~ /^warnings::/;
22             next if $sub =~ /^Carp::/;
23             next if $sub =~ /^Config::/;
24             next if $sub =~ /^IO::/;
25             next if $sub =~ /^DB::/;
26             next if $sub =~ /^Devel::\w+Breaker::/;
27             next if $sub =~ /^Exporter::/;
28             next if $sub =~ /^Symbol::/;
29             next if $sub =~ /^XSLoader::/;
30             next if $sub =~ /^base::/;
31             next if $sub =~ /^bytes::/;
32             next if $sub =~ /^feature::/;
33             next if $sub =~ /^overload::/;
34             next if $sub =~ /^lib::/;
35             next if $sub =~ /^strict::/;
36             next if $sub =~ /^vars::/;
37             next if $sub =~ /^dumpvar::/;
38             next if $sub eq 'main::BEGIN';
39             next if $sub =~ /t.bptracker.pl/;
40              
41             for (our @patterns) {
42             if ($sub =~ qr/$_/) {
43             DB::cmd_b_sub($sub);
44             last;
45             }
46             }
47             }
48             }
49             1;
50              
51             =head1 NAME
52              
53             Devel::SubBreaker - set breakpoints in many arbitrary subroutines simultaneously
54              
55             =head1 VERSION
56              
57             0.03
58              
59             =head1 SYNOPSIS
60              
61             $ perl -d:SubBreaker=sub1,sub2,Module3,regexp4 script_to_debug.pl
62              
63             =head1 DESCRPITION
64              
65             C seeks to simplify the process of settings breakpoints
66             in a collection of subroutines from a distribution, a single module, or
67             just any subroutine name that matches an arbitrary pattern. It does not
68             require the debugger user to enumerate the subroutines to be stepped through,
69             so it is useful for unfamiliar distributions or distributions under development
70             where subroutine names may be in flux.
71              
72             This module was inspired by a
73             L.
74              
75             =head1 USAGE
76              
77             To use this module, pass this command-line argument to C
78              
79             -d:SubBreaker=pattern[,pattern2[,...]]
80              
81             where C, C, etc. are any valid perl regular expressions.
82             In the L<< C phase|perlmod/"BEGIN,-UNITCHECK,-CHECK,-INIT-and-END" >>
83             of the program, a breakpoint will be set at the start of any subroutine
84             whose fully qualified subroutine name (given by
85             L<< C<%DB::sub>|DB/"%DB::sub" >>) matches one of the given regular expressions.
86             This includes anonymous subroutines that are known at compile time.
87              
88             =head2 EXAMPLES
89              
90             =over 4
91              
92             =item * Set a breakpoint in all subs in module C and all
93             C submodules:
94              
95             perl -d:SubBreaker=^Floop::Blert ...
96              
97             =item * Set a breakpoint in all subs just in module C:
98              
99             perl -d:SubBreaker=^Floop::Blert::\\w+$ ...
100              
101             =item * Set a breakpoint in every known subroutine:
102              
103             perl -d:SubBreaker=^ ...
104              
105             =item * Set a breakpoint in all anonymous subroutines
106              
107             perl -d:SubBreaker=__ANON__ ...
108              
109             =back
110              
111             =head1 SUPPORT
112              
113             This module is part of the L distribution.
114             See L for support information about this module.
115              
116             =head1 SEE ALSO
117              
118             L, L
119              
120             =head1 AUTHOR
121              
122             Marty O'Brien, Emob at cpan.orgE
123              
124             =head1 LICENSE AND COPYRIGHT
125              
126             Copyright 2018 Marty O'Brien
127              
128             This program is free software; you can redistribute it and/or modify it
129             under the terms of either: the GNU General Public License as published
130             by the Free Software Foundation; or the Artistic License.
131              
132             See http://dev.perl.org/licenses/ for more information.
133              
134             =cut