| 1 | package Devel::Confess::Source; | ||||||||||||||||||||||||||||||||||||
| 2 | 4 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||
| 6 | sub import { | ||||||||||||||||||||||||||||||||||||
| 7 | 10 | ▶ | $^P |= "$]" >= 5.010 ? 0x400 : do { | ||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=3 SCAR=18.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 8 | *DB::DB = sub {} | ||||||||||||||||||||||||||||||||||||
| 9 | 0 | ▶ | unless defined &DB::DB; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 10 | 0 | 0x02; | |||||||||||||||||||||||||||||||||||
| 11 | }; | ||||||||||||||||||||||||||||||||||||
| 12 | } | ||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||
| 14 | my $want_color = $^O ne 'MSWin32' ? 1 : eval { | ||||||||||||||||||||||||||||||||||||
| 15 | require Win32::Console::ANSI; | ||||||||||||||||||||||||||||||||||||
| 16 | Win32::Console::ANSI->import; | ||||||||||||||||||||||||||||||||||||
| 17 | 1; | ||||||||||||||||||||||||||||||||||||
| 18 | }; | ||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||
| 20 | sub source_trace { | ||||||||||||||||||||||||||||||||||||
| 21 | 19 | ▶ | my ($skip, $context, $evalonly) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
source_trace: called CC=16 SCAR=28.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 22 | 19 | ▶ | $skip ||= 1; | ||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$skip ||= 1
MC/DC0%0/1
$skip ||= 1
$skip
Truth table50%1/2
A
A= $skip
| |||||||||||||||||||||||||||||||||||||
| 23 | 19 | $skip += $Carp::CarpLevel; | |||||||||||||||||||||||||||||||||||
| 24 | 19 | ▶ | $context ||= 3; | ||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$context ||= 3
MC/DC0%0/1
$context ||= 3
$context
Truth table50%1/2
A
A= $context
| |||||||||||||||||||||||||||||||||||||
| 25 | 19 | my $i = $skip; | |||||||||||||||||||||||||||||||||||
| 26 | 19 | my @out; | |||||||||||||||||||||||||||||||||||
| 27 | 19 | ▶ | while (my ($pack, $file, $line) = (caller($i++))[0..2]) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 28 | next | ||||||||||||||||||||||||||||||||||||
| 29 | 154 | ▶ | if $Carp::Internal{$pack} || $Carp::CarpInternal{$pack}; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$Carp::Internal{$pack} or $Carp::CarpInternal{$pack}
MC/DC100%2/2
$Carp::Internal{$pack} or $Carp::CarpInternal{$pack}
$Carp::Internal{$pack}
$Carp::CarpInternal{$pack}
Truth table100%3/3
A or B
A= $Carp::Internal{$pack}B= $Carp::CarpInternal{$pack}
| |||||||||||||||||||||||||||||||||||||
| 30 | next | ||||||||||||||||||||||||||||||||||||
| 31 | 104 | ▶ | if $evalonly && $file !~ /^\(eval \d+\)(?:\[|$)/; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$evalonly and not $file =~ /^\(eval \d+\)(?:\[|$)/
MC/DC0%0/2
$evalonly and not $file =~ /^\(eval \d+\)(?:\[|$)/
$evalonly
not $file =~ /^\(eval \d+\)(?:\[|$)/
Truth table33%1/3
A and not(B)
A= $evalonlyB= not $file =~ /^\(eval \d+\)(?:\[|$)/
| |||||||||||||||||||||||||||||||||||||
| 32 | 104 | ▶ | my $lines = _get_content($file) || next; | ||||||||||||||||||||||||||||||||||
|
Condition50%1/2
_get_content($file) || (next)
MC/DC0%0/1
_get_content($file) || (next)
_get_content($file)
Truth table50%1/2
A
A= _get_content($file)
| |||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||
| 34 | 104 | my $start = $line - $context; | |||||||||||||||||||||||||||||||||||
| 35 | 104 | ▶ | $start = 1 if $start < 1; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 36 | 104 | ▶ | $start = $#$lines if $start > $#$lines; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 37 | 104 | my $end = $line + $context; | |||||||||||||||||||||||||||||||||||
| 38 | 104 | ▶ | $end = $#$lines if $end > $#$lines; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||
| 40 | 104 | my $context = "context for $file line $line:\n"; | |||||||||||||||||||||||||||||||||||
| 41 | 104 | for my $read_line ($start..$end) { | |||||||||||||||||||||||||||||||||||
| 42 | 646 | my $code = $lines->[$read_line]; | |||||||||||||||||||||||||||||||||||
| 43 | 646 | $code =~ s/\n\z//; | |||||||||||||||||||||||||||||||||||
| 44 | 646 | ▶ | if ($want_color && $read_line == $line) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$want_color and $read_line == $line
MC/DC50%1/2
$want_color and $read_line == $line
$want_color
$read_line == $line
Truth table66%2/3
A and B
A= $want_colorB= $read_line == $line
| |||||||||||||||||||||||||||||||||||||
| 45 | 97 | $code = "\e[30;43m$code\e[m"; | |||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||
| 47 | 646 | $context .= sprintf "%5s : %s\n", $read_line, $code; | |||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||
| 49 | 104 | push @out, $context; | |||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||
| 51 | 19 | ▶ | return '' | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 52 | if !@out; | ||||||||||||||||||||||||||||||||||||
| 53 | 19 | return join(('=' x 75) . "\n", | |||||||||||||||||||||||||||||||||||
| 54 | '', | ||||||||||||||||||||||||||||||||||||
| 55 | join(('-' x 75) . "\n", @out), | ||||||||||||||||||||||||||||||||||||
| 56 | '', | ||||||||||||||||||||||||||||||||||||
| 57 | ); | ||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||
| 60 | sub _get_content { | ||||||||||||||||||||||||||||||||||||
| 61 | 104 | ▶ | my $file = shift; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_get_content: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||
| 62 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 63 | 104 | ▶ | if (exists $::{'_<'.$file} && @{ '::_<'.$file }) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
exists $main::main::{'_<' . $file} and @{'::_<' . $file;}
MC/DC100%2/2
exists $main::main::{'_<' . $file} and @{'::_<' . $file;}
exists $main::main::{'_<' . $file}
@{'::_<' . $file;}
Truth table100%3/3
A and B
A= exists $main::main::{'_<' . $file}B= @{'::_<' . $file;}
| |||||||||||||||||||||||||||||||||||||
| 64 | 56 | return \@{ '::_<'.$file }; | |||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||
| 66 | elsif ($file =~ /^\(eval \d+\)(?:\[.*\])?$/) { | ||||||||||||||||||||||||||||||||||||
| 67 | 7 | return ["Can't get source of evals unless debugger available!"]; | |||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||
| 69 | elsif (open my $fh, '<', $file) { | ||||||||||||||||||||||||||||||||||||
| 70 | 41 | my @lines = ('', <$fh>); | |||||||||||||||||||||||||||||||||||
| 71 | 41 | return \@lines; | |||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||
| 73 | else { | ||||||||||||||||||||||||||||||||||||
| 74 | 0 | return ["Source file not available!"]; | |||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||
| 78 | 1; | ||||||||||||||||||||||||||||||||||||