| 1 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | package DB::Skip; | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | # ABSTRACT: make the perl debugger skip statements in given packages or subs | ||||||||||||||||||||||||||||
| 7 | 1 | our $VERSION = '1.132980'; # VERSION | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | { | ||||||||||||||||||||||||||||
| 11 | 1 | my $old_db; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub old_db { | ||||||||||||||||||||||||||
|
Subroutine
old_db: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | 0 | my ( $class, $ref ) = @_; | |||||||||||||||||||||||||||
| 15 | 0 | ▶ | $old_db = $ref if $ref; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | 0 | return $old_db; | |||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: not called CC=6 SCAR=35.9
| |||||||||||||||||||||||||||||
| 21 | 0 | my ( $class, %opts ) = @_; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | $opts{$_} ||= [] for qw( pkgs subs ); | ||||||||||||||||||||||||||
|
Condition0%0/2
$opts{$_} ||= []
MC/DC0%0/1
$opts{$_} ||= []
$opts{$_}
Truth table0%0/2
A
A= $opts{$_}
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | my @pkg_regex = grep { ref and ref eq "Regexp" } @{ $opts{pkgs} }; | ||||||||||||||||||||||||||
|
Condition0%0/3
ref $_ && ref $_ eq 'Regexp'
MC/DC0%0/2
ref $_ && ref $_ eq 'Regexp'
ref $_
ref $_ eq 'Regexp'
Truth table0%0/3
A && B
A= ref $_B= ref $_ eq 'Regexp'
| |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | my @sub_regex = grep { ref and ref eq "Regexp" } @{ $opts{subs} }; | ||||||||||||||||||||||||||
|
Condition0%0/3
ref $_ && ref $_ eq 'Regexp'
MC/DC0%0/2
ref $_ && ref $_ eq 'Regexp'
ref $_
ref $_ eq 'Regexp'
Truth table0%0/3
A && B
A= ref $_B= ref $_ eq 'Regexp'
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | my %pkg_skip = map { $_ => 1 } grep { !ref } @{ $opts{pkgs} }; | |||||||||||||||||||||||||||
| 29 | 0 | my %sub_skip = map { $_ => 1 } grep { !ref } @{ $opts{subs} }; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | $class->old_db( \&DB::DB ) if !$class->old_db; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | my $new_DB = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||
| 34 | 0 | my $lvl = 0; | |||||||||||||||||||||||||||
| 35 | 0 | ▶ | while ( my ( $pkg ) = caller( $lvl++ ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | return if $pkg eq "DB" or $pkg =~ /^DB::/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pkg eq "DB" or $pkg =~ /^DB::/
MC/DC0%0/2
$pkg eq "DB" or $pkg =~ /^DB::/
$pkg eq "DB"
$pkg =~ /^DB::/
Truth table0%0/3
A or B
A= $pkg eq "DB"B= $pkg =~ /^DB::/
| |||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | my ( $pkg ) = caller; | |||||||||||||||||||||||||||
| 40 | 0 | ▶ | return if $pkg_skip{$pkg}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | my ( undef, undef, undef, $sub ) = caller( 1 ); | |||||||||||||||||||||||||||
| 43 | 0 | ▶ | return if $sub and $sub_skip{$sub}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$sub and $sub_skip{$sub}
MC/DC0%0/2
$sub and $sub_skip{$sub}
$sub
$sub_skip{$sub}
Truth table0%0/3
A and B
A= $subB= $sub_skip{$sub}
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | for my $pkg_re ( @pkg_regex ) { | |||||||||||||||||||||||||||
| 46 | 0 | ▶ | next if !$pkg_re; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 0 | ▶ | return if $pkg =~ $pkg_re; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | for my $sub_re ( @sub_regex ) { | |||||||||||||||||||||||||||
| 51 | 0 | ▶ | next if !$sub_re; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | return if $sub =~ $sub_re; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | goto &{ $class->old_db }; | |||||||||||||||||||||||||||
| 56 | 0 | }; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | { | ||||||||||||||||||||||||||||
| 59 | 0 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||
| 60 | 0 | *DB::DB = $new_DB; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | return; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 1 | 1; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | __END__ | ||||||||||||||||||||||||||||