line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Carp::Trace; |
2
|
1
|
|
|
1
|
|
1352
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
3
|
1
|
|
|
1
|
|
2042
|
use Data::Dumper; |
|
1
|
|
|
|
|
9420
|
|
|
1
|
|
|
|
|
83
|
|
4
|
1
|
|
|
1
|
|
904
|
use Devel::Caller::Perl qw[called_args]; |
|
1
|
|
|
|
|
4347
|
|
|
1
|
|
|
|
|
7
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
BEGIN { |
7
|
1
|
|
|
1
|
|
36
|
use vars qw[@ISA @EXPORT $VERSION $DEPTH $OFFSET $ARGUMENTS]; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
90
|
|
8
|
1
|
|
|
1
|
|
5
|
use Exporter; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
55
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
19
|
@ISA = 'Exporter'; |
11
|
1
|
|
|
|
|
409
|
@EXPORT = 'trace'; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$OFFSET = 0; |
15
|
|
|
|
|
|
|
$DEPTH = 0; |
16
|
|
|
|
|
|
|
$ARGUMENTS = 0; |
17
|
|
|
|
|
|
|
$VERSION = '0.12'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub trace { |
20
|
2
|
|
50
|
2
|
1
|
10410
|
my $level = shift || $DEPTH || 0; |
21
|
2
|
|
50
|
|
|
16
|
my $offset = shift || $OFFSET || 0; |
22
|
2
|
|
100
|
|
|
14
|
my $args = shift || $ARGUMENTS || 0; |
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
|
|
4
|
my $trace = ''; |
25
|
2
|
|
|
|
|
3
|
my $i = 1 + $OFFSET; |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
4
|
while (1) { |
28
|
11
|
50
|
33
|
|
|
37
|
last if $level && $level < $i; |
29
|
|
|
|
|
|
|
|
30
|
11
|
|
|
|
|
50
|
my @caller = caller($i); |
31
|
11
|
100
|
|
|
|
637
|
last unless scalar @caller; |
32
|
|
|
|
|
|
|
|
33
|
9
|
|
|
|
|
25
|
my ($package, $filename, $line, $subroutine, $hasargs, $wantarray, |
34
|
|
|
|
|
|
|
$evaltext, $is_require, $hints, $bitmask) = @caller; |
35
|
|
|
|
|
|
|
|
36
|
9
|
50
|
|
|
|
43
|
my $string = $subroutine eq '(eval)' |
|
|
100
|
|
|
|
|
|
37
|
|
|
|
|
|
|
? $package . '::' . $subroutine . qq| [$i]| |
38
|
|
|
|
|
|
|
. (defined $evaltext ? qq[\n\t$evaltext] : '') |
39
|
|
|
|
|
|
|
: $subroutine . qq| [$i]|; |
40
|
9
|
|
|
|
|
13
|
$string =~ s/\n;$/;/gs; |
41
|
|
|
|
|
|
|
|
42
|
9
|
|
|
|
|
11
|
$string .= qq[\n\t]; |
43
|
|
|
|
|
|
|
|
44
|
9
|
50
|
|
|
|
18
|
$string .= q[require|use - ] if $is_require; |
45
|
9
|
100
|
|
|
|
22
|
$string .= defined $wantarray |
|
|
100
|
|
|
|
|
|
46
|
|
|
|
|
|
|
? $wantarray ? 'list - ' : 'scalar - ' |
47
|
|
|
|
|
|
|
: 'void - '; |
48
|
9
|
100
|
|
|
|
19
|
$string .= $hasargs ? 'new stash' : 'no new stash'; |
49
|
9
|
|
|
|
|
20
|
$string .= qq[\n\t] . $filename . ' line ' . $line . qq[\n]; |
50
|
|
|
|
|
|
|
|
51
|
9
|
100
|
|
|
|
19
|
if ($args) { |
52
|
4
|
|
|
|
|
5
|
local $Data::Dumper::Varname = 'ARGS'; |
53
|
4
|
|
|
|
|
5
|
local $Data::Dumper::Indent = 1; |
54
|
|
|
|
|
|
|
|
55
|
4
|
|
|
|
|
26
|
for my $line ( split $/, Dumper( called_args($i) ) ) { |
56
|
8
|
|
|
|
|
122
|
$string .= "\t$line\n"; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
9
|
|
|
|
|
162
|
$trace = $string . $trace; |
61
|
|
|
|
|
|
|
|
62
|
9
|
|
|
|
|
25
|
$i++; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
2
|
|
|
|
|
75
|
return $trace; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |