| 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'} || []
MC/DC0%0/1
$response->{'stack_trace'} || []
$response->{'stack_trace'}
Truth table50%1/2
A
A= $response->{'stack_trace'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition44%4/9
defined $first and builtin::blessed($first) and $subroutine =~ /^$first_class::/ and $subroutine =~ /^$package/
defined $first and builtin::blessed($first) and $subroutine =~ /^$first_class::/
defined $first and builtin::blessed($first)
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/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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::/
defined $first and builtin::blessed($first)
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::/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||