| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Pugs::Runtime::Tracer; |
|
2
|
|
|
|
|
|
|
|
|
3
|
22
|
|
|
22
|
|
776
|
use strict; |
|
|
22
|
|
|
|
|
51
|
|
|
|
22
|
|
|
|
|
921
|
|
|
4
|
22
|
|
|
22
|
|
126
|
use warnings; |
|
|
22
|
|
|
|
|
49
|
|
|
|
22
|
|
|
|
|
958
|
|
|
5
|
22
|
|
|
22
|
|
131
|
use base 'Exporter'; |
|
|
22
|
|
|
|
|
41
|
|
|
|
22
|
|
|
|
|
14916
|
|
|
6
|
|
|
|
|
|
|
#use Smart::Comments; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
9
|
|
|
|
|
|
|
trace_begin trace_end trace |
|
10
|
|
|
|
|
|
|
expand_tracing_code |
|
11
|
|
|
|
|
|
|
); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub trace_begin ($$$$) { |
|
14
|
1
|
|
|
1
|
0
|
17
|
my ($name, $from, $to, $pos) = @_; |
|
15
|
1
|
|
|
|
|
7
|
trace(">>BEGIN $name<< $from..$to at $pos\n"); |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub trace_end ($$$) { |
|
19
|
2
|
|
|
2
|
0
|
12
|
my ($name, $res, $pos) = @_; |
|
20
|
2
|
100
|
|
|
|
14
|
trace(">>END $name<< ", $res ? 'success' : 'fail', " at $pos\n"); |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub trace ($@) { |
|
24
|
5
|
50
|
|
5
|
0
|
2742
|
if (!defined $::PCR_TRACE_FH) { |
|
25
|
0
|
|
|
|
|
0
|
$::PCR_TRACE_FH = \*STDOUT; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
5
|
|
|
|
|
24
|
print $::PCR_TRACE_FH @_; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub expand_tracing_code { |
|
31
|
3
|
|
|
3
|
0
|
15
|
my $s = shift; |
|
32
|
3
|
50
|
|
|
|
49
|
open my $in, '<', \$s or die; |
|
33
|
3
|
|
|
|
|
5
|
my (@names, $name, $new, @has_pos); |
|
34
|
3
|
|
|
|
|
24
|
while (<$in>) { |
|
35
|
15
|
|
|
|
|
24
|
chomp; |
|
36
|
15
|
100
|
|
|
|
88
|
if (/\s+## <(\w+)>$/) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
37
|
7
|
|
|
|
|
17
|
$name = $1; |
|
38
|
7
|
|
|
|
|
12
|
push @names, $name; |
|
39
|
7
|
|
|
|
|
9
|
push @has_pos, 0; |
|
40
|
|
|
|
|
|
|
### begin: $name |
|
41
|
7
|
|
|
|
|
26
|
$new .= $_ . "\n"; |
|
42
|
|
|
|
|
|
|
} elsif (/(\s+)## pos: (\d+) (\d+)$/) { |
|
43
|
1
|
|
|
|
|
6
|
my ($tab, $from, $to) = ($1, $2, $3); |
|
44
|
1
|
|
|
|
|
2
|
$has_pos[-1] = 1; |
|
45
|
1
|
|
|
|
|
14
|
$new .= <<"_EOC_"; |
|
46
|
|
|
|
|
|
|
$_ |
|
47
|
|
|
|
|
|
|
$tab do { |
|
48
|
|
|
|
|
|
|
$tab Pugs::Runtime::Tracer::trace_begin('$name', $from, $to, \$pos); |
|
49
|
|
|
|
|
|
|
$tab my \$retval = |
|
50
|
|
|
|
|
|
|
_EOC_ |
|
51
|
|
|
|
|
|
|
} elsif (/(\s+)## <\/(\w+)>$/) { |
|
52
|
6
|
|
|
|
|
15
|
my ($tab, $n) = ($1, $2); |
|
53
|
6
|
|
|
|
|
10
|
$name = pop @names; |
|
54
|
6
|
|
|
|
|
10
|
my $has_pos = pop @has_pos; |
|
55
|
|
|
|
|
|
|
### end: $n . "<=>" . $name |
|
56
|
6
|
100
|
66
|
|
|
38
|
if (!defined $name || $n ne $name) { |
|
|
|
100
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
21
|
die "ERROR: unexpected closing tag $n>"; |
|
58
|
|
|
|
|
|
|
} elsif ($has_pos) { |
|
59
|
1
|
|
|
|
|
6
|
$new .= <<"_EOC_"; |
|
60
|
|
|
|
|
|
|
$_ |
|
61
|
|
|
|
|
|
|
$tab ; |
|
62
|
|
|
|
|
|
|
$tab Pugs::Runtime::Tracer::trace_end('$name', \$retval, \$pos); |
|
63
|
|
|
|
|
|
|
$tab \$retval; |
|
64
|
|
|
|
|
|
|
$tab } |
|
65
|
|
|
|
|
|
|
_EOC_ |
|
66
|
|
|
|
|
|
|
} |
|
67
|
5
|
100
|
|
|
|
26
|
if (!$has_pos) { |
|
68
|
|
|
|
|
|
|
#warn "No pos info found for <$n>"; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
} else { |
|
71
|
1
|
|
|
|
|
4
|
$new .= $_ . "\n"; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
} |
|
74
|
2
|
|
|
|
|
13
|
return $new; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
|
78
|
|
|
|
|
|
|
__END__ |