lib/Devel/ebug/Plugin/StackTrace.pm

filter: Statementstmt 75.0% 42 / 56 Branchbran 70.0% 14 / 20 Conditioncond 50.0% 10 / 20 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 62.9% 73 / 116 CC 20 SCAR 26.7
CC
20
Cov
69%
stack_trace_human
24.3
stack_trace_human_args
9.4
stack_trace
2.0
CRAP 14.4
« lib/Devel/ebug/Wire.pm ↑ Summary blib/lib/Devel/ebug/Backend/Plugin/Filenames.pm »
1 package Devel::ebug::Plugin::StackTrace;
2  
3 31 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 31 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 31 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 31 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 31 our @EXPORT = qw(stack_trace stack_trace_human stack_trace_human_args);
8  
9 31 our $VERSION = '0.69'; # VERSION
10  
11 # return the stack trace
12 16 ▶sub stack_trace {
Subroutine stack_trace: called CC=2 SCAR=7.0
Pod undocumented
13 16 my($self) = @_;
14 16 my $response = $self->talk({ command => "stack_trace" });
15 16 ▶ return @{$response->{stack_trace}||[]};
Condition50%1/2
$response->{'stack_trace'} || []
l!l
160
MC/DC0%0/1
$response->{'stack_trace'} || []
$response->{'stack_trace'}
Truth table50%1/2
A
A= $response->{'stack_trace'}
Aresult
11
00
16 }
17  
18 # return the stack trace in a human-readable format
19 14 ▶sub stack_trace_human {
Subroutine stack_trace_human: called CC=12 SCAR=31.9
Pod undocumented
20 14 my($self) = @_;
21 14 my @human;
22 14 my @stack = $self->stack_trace;
23 14 foreach my $frame (@stack) {
24 18 my $subroutine = $frame->subroutine;
25 18 my $package = $frame->package;
26 18 my @args = $frame->args;
27 18 my $first = $args[0];
28 18 my $first_class = ref($first);
29 18 my($subroutine_class, $subroutine_method) = $subroutine =~ /^(.+)::([^:])+?$/;
30 # warn "first: $first, first class: $first_class, package: $package, subroutine: $subroutine ($subroutine_class :: $subroutine_method)\n";
31  
32 18 ▶ if (defined $first && blessed($first) && $subroutine =~ /^${first_class}::/ &&
Branch: 4 branches
BranchTrueFalseTotal
if (defined $first and builtin::blessed($first) and $subroutine =~ /^$first_class::/ and $subroutine =~ /^$package/) { } 0 18 18
elsif (defined $first and builtin::blessed($first) and $subroutine =~ /^$first_class::/) { } 0 18 18
elsif ($subroutine =~ s/^$package:://) { } 11 7 18
elsif (defined $first and $subroutine_class eq $first) { } 0 7 7
Condition44%4/9
defined $first and builtin::blessed($first) and $subroutine =~ /^$first_class::/ and $subroutine =~ /^$package/
!ll&&!rl&&r
1800
defined $first and builtin::blessed($first) and $subroutine =~ /^$first_class::/
!ll&&!rl&&r
1800
defined $first and builtin::blessed($first)
!ll&&!rl&&r
6120
MC/DC0%0/4
defined $first and builtin::blessed($first) and $subroutine =~ /^$first_class::/ and $subroutine =~ /^$package/
defined $first builtin::blessed($first) $subroutine =~ /^$first_class::/ $subroutine =~ /^$package/
Truth table40%2/5
A and B and C and D
A= defined $firstB= builtin::blessed($first)C= $subroutine =~ /^$first_class::/D= $subroutine =~ /^$package/
ABCDresult
0XXX0
10XX0
110X0
11100
11111
33 $subroutine =~ /^$package/) {
34 0 $subroutine =~ s/^${first_class}:://;
35 0 shift @args;
36 0 push @human, "\$self->$subroutine" . $self->stack_trace_human_args(@args);
37 ▶ } elsif (defined $first && blessed($first) && $subroutine =~ /^${first_class}::/) {
Condition50%3/6
defined $first and builtin::blessed($first) and $subroutine =~ /^$first_class::/
!ll&&!rl&&r
1800
defined $first and builtin::blessed($first)
!ll&&!rl&&r
6120
MC/DC0%0/3
defined $first and builtin::blessed($first) and $subroutine =~ /^$first_class::/
defined $first builtin::blessed($first) $subroutine =~ /^$first_class::/
Truth table50%2/4
A and B and C
A= defined $firstB= builtin::blessed($first)C= $subroutine =~ /^$first_class::/
ABCresult
0XX0
10X0
1100
1111
38 0 $subroutine =~ s/^${first_class}:://;
39 0 shift @args;
40 0 my($name) = $first_class =~ /([^:]+)$/;
41 0 $first = '$' . lc($name);
42 0 push @human, "$first->$subroutine" . $self->stack_trace_human_args(@args);
43 } elsif ($subroutine =~ s/^${package}:://) {
44 11 push @human, "$subroutine" . $self->stack_trace_human_args(@args);
45 ▶ } elsif (defined $first && $subroutine_class eq $first) {
Condition66%2/3
defined $first and $subroutine_class eq $first
!ll&&!rl&&r
430
MC/DC0%0/2
defined $first and $subroutine_class eq $first
defined $first $subroutine_class eq $first
Truth table66%2/3
A and B
A= defined $firstB= $subroutine_class eq $first
ABresult
0X0
100
111
46 0 shift @args;
47 0 push @human, "$first->new" . $self->stack_trace_human_args(@args);
48 } else {
49 7 push @human, "$subroutine" . $self->stack_trace_human_args(@args);
50 }
51 }
52 14 return @human;
53 }
54  
55 20 ▶sub stack_trace_human_args {
Subroutine stack_trace_human_args: called CC=8 SCAR=22.4
Pod undocumented
56 20 my($self, @args) = @_;
57 20 foreach my $arg (@args) {
58 20 ▶ if (not defined $arg) {
Branch: 6 branches
BranchTrueFalseTotal
if (not defined $arg) { } 2 18 20
elsif (ref $arg eq 'ARRAY') { } 0 18 18
elsif (ref $arg eq 'HASH') { } 0 18 18
elsif (ref $arg) { } 0 18 18
elsif ($arg =~ /^-?[\d.]+$/) { } 9 9 18
elsif ($arg =~ /^[\w:]*$/) { } 1 8 9
59 2 $arg = "undef";
60 } elsif (ref($arg) eq 'ARRAY') {
61 0 $arg = "[...]";
62 } elsif (ref($arg) eq 'HASH') {
63 0 $arg = "{...}";
64 } elsif (ref($arg)) {
65 0 my($name) = ref($arg) =~ /([^:]+)$/;
66 0 $arg = '$' . lc($name);
67 } elsif ($arg =~ /^-?[\d.]+$/) {
68 # number, do nothing
69 } elsif ($arg =~ /^[\w:]*$/) {
70 1 $arg =~ s/([\'\\])/\\$1/g;
71 1 $arg = qq{'$arg'};
72 } else {
73 8 $arg =~ s/([\'\\])/\\$1/g;
74 8 $arg = qq{"$arg"};
75 }
76 }
77 20 return '(' . join(", ", @args) . ')';
78 }
79  
80 31 1;
81  
82 __END__
« lib/Devel/ebug/Wire.pm ↑ Summary blib/lib/Devel/ebug/Backend/Plugin/Filenames.pm »