| 1 | # The original notice of B::Size: | ||||||||||||||||||||||||||||
| 2 | # B::TerseSize.pm | ||||||||||||||||||||||||||||
| 3 | # Copyright (c) 1999 Doug MacEachern. All rights reserved. | ||||||||||||||||||||||||||||
| 4 | # This module is free software; you can redistribute and/or modify | ||||||||||||||||||||||||||||
| 5 | # it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # portions of this module are based on B::Terse, by Malcolm Beattie | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | package B::Size2::Terse; | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use constant IS_MODPERL => ($ENV{MOD_PERL} || 0); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.1
Condition50%1/2
$ENV{'MOD_PERL'} || 0
MC/DC0%0/1
$ENV{'MOD_PERL'} || 0
$ENV{'MOD_PERL'}
Truth table50%1/2
A
A= $ENV{'MOD_PERL'}
| |||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use constant MP2 => ($ENV{MOD_PERL_API_VERSION} || 0) == 2 ? 1 : 0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=11.7
Branch: 1 branch
Condition50%1/2
$ENV{'MOD_PERL_API_VERSION'} || 0
MC/DC0%0/1
$ENV{'MOD_PERL_API_VERSION'} || 0
$ENV{'MOD_PERL_API_VERSION'}
Truth table50%1/2
A
A= $ENV{'MOD_PERL_API_VERSION'}
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use B (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use B::Size2 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 2 | our $VERSION = "2.07"; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 2 | my $opcount; | |||||||||||||||||||||||||||
| 22 | my $opsize; | ||||||||||||||||||||||||||||
| 23 | 2 | my $copsize; | |||||||||||||||||||||||||||
| 24 | 2 | my $curcop; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 293 | ▶ | sub UNIVERSAL::op_size { | ||||||||||||||||||||||||||
|
Subroutine
op_size: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 293 | $opcount++; | |||||||||||||||||||||||||||
| 28 | 293 | my $size = shift->size; | |||||||||||||||||||||||||||
| 29 | 293 | $opsize += $size; | |||||||||||||||||||||||||||
| 30 | 293 | $copsize += $size; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 2 | my $mouse_attr = | |||||||||||||||||||||||||||
| 34 | qq( onclick='javascript: return false') . | ||||||||||||||||||||||||||||
| 35 | qq( onmouseout='window.status=""; return true'); | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub op_html_name { | ||||||||||||||||||||||||||
|
Subroutine
op_html_name: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 38 | 0 | my($op, $sname) = @_; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | $sname =~ s/(\s+)$//; | |||||||||||||||||||||||||||
| 41 | 0 | ▶ | my $pad = $1 || ""; | ||||||||||||||||||||||||||
|
Condition0%0/2
$1 || ''
MC/DC0%0/1
$1 || ''
$1
Truth table0%0/2
A
A= $1
| |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | my $desc = sprintf | ||||||||||||||||||||||||||
|
Condition0%0/2
B::OP::op_desc($op->type) || 'unknown'
MC/DC0%0/1
B::OP::op_desc($op->type) || 'unknown'
B::OP::op_desc($op->type)
Truth table0%0/2
A
A= B::OP::op_desc($op->type)
| |||||||||||||||||||||||||||||
| 43 | qq(onmouseover='window.status="%s"; return true'), | ||||||||||||||||||||||||||||
| 44 | B::OP::op_desc($op->type) || "unknown"; | ||||||||||||||||||||||||||||
| 45 | 0 | ▶ | my $href = $curcop ? $curcop->line : ""; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | return qq(<a $desc $mouse_attr href="#$href">$sname</a>$pad); | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub peekop { | ||||||||||||||||||||||||||
|
Subroutine
peekop: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 51 | 0 | my $op = shift; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | my $size = $op->size; | |||||||||||||||||||||||||||
| 54 | 0 | $opcount++; | |||||||||||||||||||||||||||
| 55 | 0 | $opsize += $size; | |||||||||||||||||||||||||||
| 56 | 0 | $copsize += $size; | |||||||||||||||||||||||||||
| 57 | 0 | my $name; | |||||||||||||||||||||||||||
| 58 | 0 | my $sname = sprintf "%-13s", $op->name; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | if (IS_MODPERL) { | |||||||||||||||||||||||||||
| 61 | $name = op_html_name($op, $sname); | ||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | else { | ||||||||||||||||||||||||||||
| 64 | 0 | $name = $sname; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | my $addr = sprintf "0x%lx", $$op; | |||||||||||||||||||||||||||
| 68 | 0 | $addr = qq(<a name="$addr">$addr</a>) if IS_MODPERL; | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | return sprintf qq(%-6s $name $addr {%d bytes}), | |||||||||||||||||||||||||||
| 71 | B::class($op), $size; | ||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 2 | my $hr = "=" x 60; | |||||||||||||||||||||||||||
| 75 | 2 | my %filelex = (); | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 2 | ▶ | sub package_size { | ||||||||||||||||||||||||||
|
Subroutine
package_size: called CC=11 SCAR=24.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 78 | 2 | my($package) = @_; | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | #local *UNIVERSAL::op_size = \&universal_op_size; | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 2 | my %retval = (); | |||||||||||||||||||||||||||
| 83 | 2 | my $total_opsize = 0; | |||||||||||||||||||||||||||
| 84 | 2 | my $total_opcount = 0; | |||||||||||||||||||||||||||
| 85 | 2 | my $stash; | |||||||||||||||||||||||||||
| 86 | { | ||||||||||||||||||||||||||||
| 87 | 2 | ▶ | no strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 88 | 2 | $stash = \%{"$package\::"}; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 2 | for (keys %$stash) { | |||||||||||||||||||||||||||
| 92 | 151 | my $name = $package . "::$_"; | |||||||||||||||||||||||||||
| 93 | 151 | my $has_code = 0; | |||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | { | ||||||||||||||||||||||||||||
| 96 | 2 | ▶ | no strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 97 | 151 | $has_code = *{$name}{CODE}; #defined() expects CvROOT || CvXSUB | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 151 | ▶ | unless ($has_code) { #CV_walk will measure | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 133 | $total_opsize += | |||||||||||||||||||||||||||
| 102 | B::Sizeof::GV + B::Sizeof::XPVGV + B::Sizeof::GP; | ||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | #measure global variables | ||||||||||||||||||||||||||||
| 106 | 151 | for my $type (qw(ARRAY HASH SCALAR)) { | |||||||||||||||||||||||||||
| 107 | 453 | ▶ | next if $name =~ /::$/; #stash | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | 336 | ▶ | next unless /^[\w_]/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 279 | ▶ | next if /^_</; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | 81 | my $ref = do { | |||||||||||||||||||||||||||
| 111 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 112 | 81 | *{$name}{$type}; | |||||||||||||||||||||||||||
| 113 | }; | ||||||||||||||||||||||||||||
| 114 | 81 | ▶ | next unless defined $ref; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 32 | my $obj = B::svref_2object($ref); | |||||||||||||||||||||||||||
| 116 | 32 | ▶ | next if ref($obj) eq 'B::NULL'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 8 | my $tsize = $obj->size; | |||||||||||||||||||||||||||
| 118 | 8 | $total_opsize += $tsize; | |||||||||||||||||||||||||||
| 119 | 8 | $retval{"*${_}{$type}"} = {'size' => $tsize}; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 151 | ▶ | next unless defined $has_code; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 18 | CV_walk('slow', $name, 'op_size'); | |||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 16 | for (keys %{ $filelex{$package} }) { | |||||||||||||||||||||||||||
| 127 | 0 | my $fsize = $filelex{$package}->{$_}; | |||||||||||||||||||||||||||
| 128 | 0 | $total_opsize += $opsize; | |||||||||||||||||||||||||||
| 129 | 0 | $retval{"my ${_} = ...;"} = | |||||||||||||||||||||||||||
| 130 | {'size' => $fsize}; | ||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | 16 | %filelex = (); | |||||||||||||||||||||||||||
| 133 | 16 | $total_opsize += $opsize; | |||||||||||||||||||||||||||
| 134 | 16 | $total_opcount += $opcount; | |||||||||||||||||||||||||||
| 135 | 16 | $retval{$_} = {'count' => $opcount, 'size' => $opsize}; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 0 | return (\%retval, $total_opcount, $total_opsize); | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 2 | my $b_objsym = \&B::objsym; | |||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 0 | ▶ | sub objsym { | ||||||||||||||||||||||||||
|
Subroutine
objsym: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 144 | 0 | my $obj = shift; | |||||||||||||||||||||||||||
| 145 | 0 | my $value = $b_objsym->($obj); | |||||||||||||||||||||||||||
| 146 | 0 | ▶ | return unless $value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 0 | sprintf qq(<a href="#0x%lx">$value</a>), $$obj; | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 18 | ▶ | sub CV_walk { | ||||||||||||||||||||||||||
|
Subroutine
CV_walk: called CC=6 SCAR=18.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 151 | 18 | my($order, $objname, $meth) = @_; | |||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 18 | ▶ | $meth ||= 'terse_size'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$meth ||= "terse_size"
MC/DC0%0/1
$meth ||= "terse_size"
$meth
Truth table50%1/2
A
A= $meth
| |||||||||||||||||||||||||||||
| 154 | 18 | my $cvref = \&{$objname}; | |||||||||||||||||||||||||||
| 155 | 18 | my $cv = B::svref_2object($cvref); | |||||||||||||||||||||||||||
| 156 | 18 | my($package, $func) = ($objname =~ /(.*)::([^:]+)$/); | |||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 18 | $opsize = B::Sizeof::GV + B::Sizeof::XPVGV + B::Sizeof::GP; | |||||||||||||||||||||||||||
| 159 | 18 | $opcount = 0; | |||||||||||||||||||||||||||
| 160 | 18 | $curcop = ""; | |||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 18 | my $gv = $cv->GV; | |||||||||||||||||||||||||||
| 163 | 18 | $opsize += length $gv->NAME; | |||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 18 | ▶ | if (my $stash = $cv->is_alias($package)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | 16 | return; | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 2 | $opsize += B::Sizeof::XPVCV; | |||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 2 | $opsize += B::Sizeof::SV; | |||||||||||||||||||||||||||
| 172 | 2 | ▶ | if ($cv->FLAGS & B::SVf_POK) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | 0 | $opsize += B::Sizeof::XPV + length $cv->PV; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | else { | ||||||||||||||||||||||||||||
| 176 | 2 | $opsize += B::Sizeof::XPVIV; #IVX == -1 for no prototype | |||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 2 | init_curpad_names($cvref); | |||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 2 | ▶ | no strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 182 | 2 | local *B::objesym = \&objsym if IS_MODPERL; | |||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 2 | ▶ | if ($order eq 'exec') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 185 | 0 | B::walkoptree_exec($cv->START, $meth); | |||||||||||||||||||||||||||
| 186 | } else { | ||||||||||||||||||||||||||||
| 187 | 2 | B::walkoptree_slow($cv->ROOT, $meth); | |||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 2 | ▶ | curcop_info() if $curcop; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 2 | my($padsize, $padsummary) = PADLIST_size($cv); | |||||||||||||||||||||||||||
| 193 | 0 | $opsize += $padsize; | |||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 0 | $padsummary; | |||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 0 | ▶ | sub terse_size { | ||||||||||||||||||||||||||
|
Subroutine
terse_size: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 199 | 0 | my($order, $objname) = @_; | |||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 0 | my $padsummary = CV_walk($order, $objname); | |||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 0 | print "\n$hr\nTotals: $opsize bytes | $opcount OPs\n$hr\n"; | |||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 0 | ▶ | if ($padsummary) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | 0 | print "\nPADLIST summary:\n"; | |||||||||||||||||||||||||||
| 207 | 0 | print @$padsummary; | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 2 | my @curpad_names = (); | |||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 2 | ▶ | sub init_curpad_names { | ||||||||||||||||||||||||||
|
Subroutine
init_curpad_names: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 214 | 2 | my $cv = B::svref_2object(shift); | |||||||||||||||||||||||||||
| 215 | 2 | my $padlist = $cv->PADLIST; | |||||||||||||||||||||||||||
| 216 | 2 | ▶ | return unless $padlist->can('ARRAY'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 217 | 2 | my $padnames = ($padlist->ARRAY)[0]; | |||||||||||||||||||||||||||
| 218 | 2 | ▶ | return unless $padnames->can('ARRAY'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 219 | 2 | @curpad_names = $padnames->ARRAY; | |||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 0 | ▶ | sub compile { | ||||||||||||||||||||||||||
|
Subroutine
compile: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 223 | 0 | my $order = shift; | |||||||||||||||||||||||||||
| 224 | 0 | my @options = @_; | |||||||||||||||||||||||||||
| 225 | 0 | ▶ | B::clearsym() if defined &B::clearsym; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 0 | ▶ | if (@options) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 229 | 0 | my $objname; | |||||||||||||||||||||||||||
| 230 | 0 | foreach $objname (@options) { | |||||||||||||||||||||||||||
| 231 | 0 | ▶ | $objname = "main::$objname" unless $objname =~ /::/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | 0 | terse_size($order, $objname); | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | 0 | } else { | |||||||||||||||||||||||||||
| 236 | 0 | ▶ | if ($order eq "exec") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | 0 | ▶ | return sub { B::walkoptree_exec(B::main_start, "terse_size"); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 238 | 0 | ▶ | curcop_info() if $curcop} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 239 | 0 | } else { | |||||||||||||||||||||||||||
| 240 | 0 | ▶ | return sub { B::walkoptree_slow(B::main_root, "terse_size"); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 241 | 0 | ▶ | curcop_info() if $curcop} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | 0 | } | |||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 0 | ▶ | sub indent { | ||||||||||||||||||||||||||
|
Subroutine
indent: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 247 | 0 | my $level = shift; | |||||||||||||||||||||||||||
| 248 | 0 | return " " x $level; | |||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | #thanks B::Deparse | ||||||||||||||||||||||||||||
| 252 | 48 | ▶ | sub padname { | ||||||||||||||||||||||||||
|
Subroutine
padname: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 253 | 48 | my($sv) = @_; | |||||||||||||||||||||||||||
| 254 | 48 | ▶ | if (!( ref $sv && $sv->FLAGS & (B::SVf_POK | B::SVp_POK) != 0 )) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $sv and
MC/DC50%1/2
ref $sv and
ref $sv
Truth table66%2/3
A and B
A= ref $svB=
| |||||||||||||||||||||||||||||
| 255 | 47 | return '?'; | |||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||
| 257 | 1 | my $str = $sv->PVX; | |||||||||||||||||||||||||||
| 258 | 1 | my $ix = index($str, "\0"); | |||||||||||||||||||||||||||
| 259 | 1 | ▶ | $str = substr($str, 0, $ix) if $ix != -1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 260 | 1 | return $str; | |||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 0 | ▶ | sub B::OP::terse_size { | ||||||||||||||||||||||||||
|
Subroutine
terse_size: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 264 | 0 | my ($op, $level) = @_; | |||||||||||||||||||||||||||
| 265 | 0 | my $t = $op->targ; | |||||||||||||||||||||||||||
| 266 | 0 | my $targ = ""; | |||||||||||||||||||||||||||
| 267 | 0 | ▶ | if ($t > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 268 | 0 | my $name = B::OP::op_name($op->targ); | |||||||||||||||||||||||||||
| 269 | 0 | my $desc = B::OP::op_desc($op->targ); | |||||||||||||||||||||||||||
| 270 | 0 | ▶ | if ($op->type == 0) { #OP_NULL | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 271 | 0 | ▶ | $targ = $name eq $desc ? " [$name]" : | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 272 | sprintf " [%s - %s]", $name, $desc; | ||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||
| 274 | else { | ||||||||||||||||||||||||||||
| 275 | 0 | $targ = sprintf " [targ %d - %s]", $t, | |||||||||||||||||||||||||||
| 276 | padname($curpad_names[$t]); | ||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | 0 | print indent($level), peekop($op), $targ, "\n"; | |||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | 0 | ▶ | sub B::SVOP::terse_size { | ||||||||||||||||||||||||||
|
Subroutine
terse_size: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 283 | 0 | my ($op, $level) = @_; | |||||||||||||||||||||||||||
| 284 | 0 | print indent($level), peekop($op), " "; | |||||||||||||||||||||||||||
| 285 | 0 | $op->sv->terse_size(0); | |||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | 0 | ▶ | sub B::GVOP::terse_size { | ||||||||||||||||||||||||||
|
Subroutine
terse_size: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 289 | 0 | my ($op, $level) = @_; | |||||||||||||||||||||||||||
| 290 | 0 | print indent($level), peekop($op), " "; | |||||||||||||||||||||||||||
| 291 | 0 | $op->gv->terse_size(0); | |||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 0 | ▶ | sub B::PMOP::terse_size { | ||||||||||||||||||||||||||
|
Subroutine
terse_size: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 295 | 0 | my ($op, $level) = @_; | |||||||||||||||||||||||||||
| 296 | 0 | my $precomp = $op->precomp; | |||||||||||||||||||||||||||
| 297 | 0 | ▶ | print indent($level), peekop($op), | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 298 | (defined($precomp) ? " /$precomp/\n" : " (regexp not compiled)\n"); | ||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | 0 | ▶ | sub B::PVOP::terse_size { | ||||||||||||||||||||||||||
|
Subroutine
terse_size: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 302 | 0 | my ($op, $level) = @_; | |||||||||||||||||||||||||||
| 303 | 0 | print indent($level), peekop($op), " ", B::cstring($op->pv), "\n"; | |||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | 2 | my $hr2 = "-" x 60; | |||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | 0 | ▶ | *cop_file = B::COP->can('file') || sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 309 | 0 | shift->filegv->SV->PV; | |||||||||||||||||||||||||||
| 310 | 2 | ▶ | }; | ||||||||||||||||||||||||||
|
Condition33%1/3
'B::COP'->can('file') || sub {
(shift())->filegv->SV->PV;
}
MC/DC0%0/2
'B::COP'->can('file') || sub {
(shift())->filegv->SV->PV;
}
'B::COP'->can('file')
sub {
(shift())->filegv->SV->PV;
}
Truth table33%1/3
A || B
A= 'B::COP'->can('file')B= sub {
(shift())->filegv->SV->PV;
}
| |||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 0 | ▶ | sub curcop_info { | ||||||||||||||||||||||||||
|
Subroutine
curcop_info: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 313 | 0 | my $line = $curcop->line; | |||||||||||||||||||||||||||
| 314 | 0 | my $linestr = "line $line"; | |||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | 0 | ▶ | if ($line > 0 && IS_MODPERL) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$line > 0 and 0
MC/DC0%0/1
$line > 0 and 0
$line > 0
Truth table0%0/2
A
A= $line > 0
| |||||||||||||||||||||||||||||
| 317 | 0 | my $anchor = ""; | |||||||||||||||||||||||||||
| 318 | 0 | ▶ | if ($line > 10) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 319 | 0 | $anchor = "#" . ($line - 10); | |||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||
| 321 | 0 | my $window = sprintf "offset=%d&len=%d", $line - 100, $line + 100; | |||||||||||||||||||||||||||
| 322 | 0 | my $args = sprintf "noh_fileline=1&filename=%s&line=%d&$window", | |||||||||||||||||||||||||||
| 323 | cop_file($curcop), $line; | ||||||||||||||||||||||||||||
| 324 | 0 | my $uri = MP2 ? Apache2::RequestUtil->request()->location() : Apache->request->location; | |||||||||||||||||||||||||||
| 325 | 0 | $linestr = qq(<a name="$line" target=top href="$uri?$args$anchor">$linestr</a>); | |||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 0 | print "\n[$linestr size: $copsize bytes]\n"; | |||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 0 | ▶ | sub B::COP::terse_size { | ||||||||||||||||||||||||||
|
Subroutine
terse_size: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 332 | 0 | my ($op, $level) = @_; | |||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | 0 | ▶ | my $label = $op->label || ""; | ||||||||||||||||||||||||||
|
Condition0%0/2
$op->label || ''
MC/DC0%0/1
$op->label || ''
$op->label
Truth table0%0/2
A
A= $op->label
| |||||||||||||||||||||||||||||
| 335 | 0 | ▶ | if ($label) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 336 | 0 | $label = " label ".B::cstring($label); | |||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | 0 | ▶ | curcop_info() if $curcop; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | 0 | $copsize = 0; | |||||||||||||||||||||||||||
| 342 | 0 | $curcop = $op; | |||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | 0 | print "\n$hr2\n", indent($level), peekop($op), "$label\n"; | |||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | 0 | ▶ | sub B::PV::terse_size { | ||||||||||||||||||||||||||
|
Subroutine
terse_size: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 349 | 0 | my ($sv, $level) = @_; | |||||||||||||||||||||||||||
| 350 | 0 | print indent($level); | |||||||||||||||||||||||||||
| 351 | 0 | my $pv = B::cstring($sv->PV); | |||||||||||||||||||||||||||
| 352 | 0 | B::Size2::escape_html(\$pv) if IS_MODPERL; | |||||||||||||||||||||||||||
| 353 | 0 | printf "%s %s\n", B::class($sv), $pv; | |||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | 0 | ▶ | sub B::AV::terse_size { | ||||||||||||||||||||||||||
|
Subroutine
terse_size: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 357 | 0 | my ($sv, $level) = @_; | |||||||||||||||||||||||||||
| 358 | 0 | print indent($level); | |||||||||||||||||||||||||||
| 359 | 0 | printf "%s FILL %d\n", B::class($sv), $sv->FILL; | |||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | 0 | ▶ | sub B::GV::terse_size { | ||||||||||||||||||||||||||
|
Subroutine
terse_size: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 363 | 0 | my ($gv, $level) = @_; | |||||||||||||||||||||||||||
| 364 | 0 | my $stash = $gv->STASH->NAME; | |||||||||||||||||||||||||||
| 365 | 0 | ▶ | if ($stash eq "main") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 366 | 0 | $stash = ""; | |||||||||||||||||||||||||||
| 367 | } else { | ||||||||||||||||||||||||||||
| 368 | 0 | $stash = $stash . "::"; | |||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||
| 370 | 0 | print indent($level); | |||||||||||||||||||||||||||
| 371 | 0 | printf "%s *%s%s\n", B::class($gv), $stash, $gv->NAME; | |||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | 0 | ▶ | sub B::IV::terse_size { | ||||||||||||||||||||||||||
|
Subroutine
terse_size: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 375 | 0 | my ($sv, $level) = @_; | |||||||||||||||||||||||||||
| 376 | 0 | print indent($level); | |||||||||||||||||||||||||||
| 377 | 0 | printf "%s %d\n", B::class($sv), $sv->IV; | |||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | 0 | ▶ | sub B::NV::terse_size { | ||||||||||||||||||||||||||
|
Subroutine
terse_size: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 381 | 0 | my ($sv, $level) = @_; | |||||||||||||||||||||||||||
| 382 | 0 | print indent($level); | |||||||||||||||||||||||||||
| 383 | 0 | printf "%s %s\n", B::class($sv), $sv->NV; | |||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | 0 | ▶ | sub B::RV::terse_size { | ||||||||||||||||||||||||||
|
Subroutine
terse_size: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 387 | 0 | my ($sv, $level) = @_; | |||||||||||||||||||||||||||
| 388 | 0 | print indent($level); | |||||||||||||||||||||||||||
| 389 | 0 | printf "%s \n", B::class($sv); | |||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | 0 | ▶ | sub B::NULL::terse_size { | ||||||||||||||||||||||||||
|
Subroutine
terse_size: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 393 | 0 | my ($sv, $level) = @_; | |||||||||||||||||||||||||||
| 394 | 0 | print indent($level); | |||||||||||||||||||||||||||
| 395 | 0 | printf "%s \n", B::class($sv); | |||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | 0 | ▶ | sub B::SPECIAL::terse_size { | ||||||||||||||||||||||||||
|
Subroutine
terse_size: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 399 | 0 | my ($sv, $level) = @_; | |||||||||||||||||||||||||||
| 400 | 0 | print indent($level); | |||||||||||||||||||||||||||
| 401 | 0 | printf "%s #%d %s\n", B::class($sv), $$sv, $B::specialsv_name[$$sv]; | |||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | 2 | my $padname_max = 0; | |||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | 2 | ▶ | sub PADLIST_size { | ||||||||||||||||||||||||||
|
Subroutine
PADLIST_size: called CC=11 SCAR=37.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 407 | 2 | my $cv = shift; | |||||||||||||||||||||||||||
| 408 | 2 | ▶ | my $obj = UNIVERSAL::isa($cv, "B::CV") ? $cv : B::svref_2object($cv); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | 2 | ▶ | if (! $obj->PADLIST->isa('B::PADLIST')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 411 | 0 | return $obj->size; | |||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | 2 | my $size = (B::Sizeof::AV + B::Sizeof::XPVAV) * 3; #padlist, names, values | |||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | 2 | my($padnames, $padvals) = $obj->PADLIST->ARRAY; | |||||||||||||||||||||||||||
| 418 | 2 | my @names = $padnames->ARRAY; | |||||||||||||||||||||||||||
| 419 | 2 | $padname_max = 0; | |||||||||||||||||||||||||||
| 420 | my @names_pv = map { | ||||||||||||||||||||||||||||
| 421 | 2 | my $pv = padname($_); | |||||||||||||||||||||||||||
| 422 | 48 | ▶ | $padname_max = length($pv) > $padname_max ? | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 423 | length($pv) : $padname_max; | ||||||||||||||||||||||||||||
| 424 | 48 | $pv; | |||||||||||||||||||||||||||
| 425 | } @names; | ||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | 2 | my @vals = $padvals->ARRAY; | |||||||||||||||||||||||||||
| 428 | 2 | my $fill = $padnames->FILL; | |||||||||||||||||||||||||||
| 429 | 0 | my $fill_len = length $fill; | |||||||||||||||||||||||||||
| 430 | 0 | my @retval = (); | |||||||||||||||||||||||||||
| 431 | 0 | my $wantarray = wantarray; | |||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | 0 | ▶ | for (my $i = 0; $i <= $fill; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 434 | 0 | my $entsize = $names[$i]->size; | |||||||||||||||||||||||||||
| 435 | 0 | my $is_fake = $names[$i]->FLAGS & B::SVf_FAKE; | |||||||||||||||||||||||||||
| 436 | 0 | ▶ | if ($is_fake) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 437 | 0 | $entsize += B::Sizeof::SV; # just a reference to outside scope | |||||||||||||||||||||||||||
| 438 | 0 | my $outside = $obj->OUTSIDE; | |||||||||||||||||||||||||||
| 439 | 0 | ▶ | if ($outside->can('GV') && B::class($outside->GV) eq 'SPECIAL') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$outside->can("GV") and B::class($outside->GV) eq "SPECIAL"
MC/DC0%0/2
$outside->can("GV") and B::class($outside->GV) eq "SPECIAL"
$outside->can("GV")
B::class($outside->GV) eq "SPECIAL"
Truth table0%0/3
A and B
A= $outside->can("GV")B= B::class($outside->GV) eq "SPECIAL"
| |||||||||||||||||||||||||||||
| 440 | 0 | $filelex{ $obj->GV->STASH->NAME }->{ $names_pv[$i] } = | |||||||||||||||||||||||||||
| 441 | $vals[$i]->size; | ||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||
| 443 | else { | ||||||||||||||||||||||||||||
| 444 | #XXX nested/anonsubs | ||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||
| 447 | else { | ||||||||||||||||||||||||||||
| 448 | 0 | $entsize += $vals[$i]->size; | |||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||
| 450 | 0 | $size += $entsize; | |||||||||||||||||||||||||||
| 451 | 0 | ▶ | next unless $wantarray; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | 0 | my $class = B::class($vals[$i]); | |||||||||||||||||||||||||||
| 454 | 0 | my $byteinfo = sprintf "[%-4s %3d bytes]", | |||||||||||||||||||||||||||
| 455 | $class, $entsize; | ||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | 2 | ▶ | no warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 458 | 0 | ▶ | push @retval, sprintf "%${fill_len}d: %${padname_max}s %s %s\n", | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 459 | $i, | ||||||||||||||||||||||||||||
| 460 | $names_pv[$i], | ||||||||||||||||||||||||||||
| 461 | $byteinfo, | ||||||||||||||||||||||||||||
| 462 | $is_fake ? '__SvFAKE__' : $vals[$i]->sizeval; | ||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | 0 | ▶ | return $wantarray ? ($size, \@retval) : $size; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||
| 468 | #hmm, I wonder if B::Deparse could be used instead | ||||||||||||||||||||||||||||
| 469 | 0 | ▶ | sub Apache::Status::noh_fileline { | ||||||||||||||||||||||||||
|
Subroutine
noh_fileline: not called CC=18 SCAR=58.3
| |||||||||||||||||||||||||||||
| 470 | 0 | my $r = shift; | |||||||||||||||||||||||||||
| 471 | 0 | my %args = $r->args; | |||||||||||||||||||||||||||
| 472 | 0 | ▶ | my $offset = $args{offset} || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{'offset'} || 0
MC/DC0%0/1
$args{'offset'} || 0
$args{'offset'}
Truth table0%0/2
A
A= $args{'offset'}
| |||||||||||||||||||||||||||||
| 473 | 0 | ▶ | my $len = $args{len} || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{'len'} || 0
MC/DC0%0/1
$args{'len'} || 0
$args{'len'}
Truth table0%0/2
A
A= $args{'len'}
| |||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | 0 | local *FH; | |||||||||||||||||||||||||||
| 476 | 0 | my $filename = $args{filename}; | |||||||||||||||||||||||||||
| 477 | 0 | $r->send_http_header('text/html'); | |||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||
| 479 | 0 | ▶ | unless (Apache::Status::status_config($r, "StatusTerseSize")) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 480 | 0 | print "sorry, StatusTerseSize not enabled\n"; | |||||||||||||||||||||||||||
| 481 | 0 | return 0; | |||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | 0 | ▶ | unless (exists $main::{"_<$filename"}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 485 | #useithreads doesnt gv_fetchfile() | ||||||||||||||||||||||||||||
| 486 | 0 | my $in_inc = 0; | |||||||||||||||||||||||||||
| 487 | 0 | for (keys %INC) { | |||||||||||||||||||||||||||
| 488 | 0 | ▶ | if ($INC{$_} eq $filename) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 489 | 0 | $in_inc = 1; | |||||||||||||||||||||||||||
| 490 | 0 | $main::{"_<$filename"} = $_; | |||||||||||||||||||||||||||
| 491 | 0 | last; | |||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||
| 494 | 0 | ▶ | unless ($in_inc) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 495 | 0 | print "sorry, `$filename' is not a file used by Perl\n"; | |||||||||||||||||||||||||||
| 496 | 0 | return 0; | |||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||
| 500 | 0 | my $i = 0; | |||||||||||||||||||||||||||
| 501 | 0 | $r->print('<pre>'); | |||||||||||||||||||||||||||
| 502 | 0 | ▶ | if ($offset > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 503 | 0 | printf "%4d..%d [...]\n", 1, $offset-1; | |||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||
| 505 | 0 | ▶ | open FH, $filename or die $!; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 506 | 0 | ▶ | while (<FH>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 507 | 0 | $i++; | |||||||||||||||||||||||||||
| 508 | 0 | ▶ | next if $len > 0 and $i > $len; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$len > 0 and $i > $len
MC/DC0%0/2
$len > 0 and $i > $len
$len > 0
$i > $len
Truth table0%0/3
A and B
A= $len > 0B= $i > $len
| |||||||||||||||||||||||||||||
| 509 | 0 | ▶ | next if $offset > 0 and $i < $offset; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$offset > 0 and $i < $offset
MC/DC0%0/2
$offset > 0 and $i < $offset
$offset > 0
$i < $offset
Truth table0%0/3
A and B
A= $offset > 0B= $i < $offset
| |||||||||||||||||||||||||||||
| 510 | 0 | chomp; | |||||||||||||||||||||||||||
| 511 | 0 | s/^\t/ /; #indent proper | |||||||||||||||||||||||||||
| 512 | 0 | my $lineno = sprintf "%4d", $i; | |||||||||||||||||||||||||||
| 513 | 0 | B::Size2::escape_html(\$_); | |||||||||||||||||||||||||||
| 514 | 0 | ▶ | my $line = ($i == $args{line}) ? | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 515 | \qq(<font color="#FF0000">$_</font>) : \$_; | ||||||||||||||||||||||||||||
| 516 | 0 | print qq($lineno: <a name=$i>$$line</a>\n); | |||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||
| 519 | 0 | ▶ | if ($len > 0 and $i > $len) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$len > 0 and $i > $len
MC/DC0%0/2
$len > 0 and $i > $len
$len > 0
$i > $len
Truth table0%0/3
A and B
A= $len > 0B= $i > $len
| |||||||||||||||||||||||||||||
| 520 | 0 | printf "%4d..%d [...]\n", $len+1, $i; | |||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||
| 522 | 0 | close FH; | |||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||
| 524 | 0 | 0; | |||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | 0 | ▶ | sub Apache2::Status::noh_fileline { | ||||||||||||||||||||||||||
|
Subroutine
noh_fileline: not called CC=18 SCAR=58.3
| |||||||||||||||||||||||||||||
| 528 | 0 | my $r = shift; | |||||||||||||||||||||||||||
| 529 | 0 | my $args = $r->args; | |||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||
| 531 | 0 | require CGI; | |||||||||||||||||||||||||||
| 532 | 0 | my $CGI = CGI->new($args); | |||||||||||||||||||||||||||
| 533 | 0 | my %params = map { $_ => $CGI->param($_) } $CGI->param(); | |||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | 0 | ▶ | my $offset = $params{offset} || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$params{'offset'} || 0
MC/DC0%0/1
$params{'offset'} || 0
$params{'offset'}
Truth table0%0/2
A
A= $params{'offset'}
| |||||||||||||||||||||||||||||
| 536 | 0 | ▶ | my $len = $params{len} || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$params{'len'} || 0
MC/DC0%0/1
$params{'len'} || 0
$params{'len'}
Truth table0%0/2
A
A= $params{'len'}
| |||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | 0 | local *FH; | |||||||||||||||||||||||||||
| 539 | 0 | my $filename = $params{filename}; | |||||||||||||||||||||||||||
| 540 | 0 | $r->content_type('text/html'); | |||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||
| 542 | 0 | ▶ | unless (Apache2::Status::status_config($r, "StatusTerseSize")) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 543 | 0 | print "sorry, StatusTerseSize not enabled\n"; | |||||||||||||||||||||||||||
| 544 | 0 | return 0; | |||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||
| 547 | 0 | ▶ | unless (exists $main::{"_<$filename"}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 548 | #useithreads doesnt gv_fetchfile() | ||||||||||||||||||||||||||||
| 549 | 0 | my $in_inc = 0; | |||||||||||||||||||||||||||
| 550 | 0 | for (keys %INC) { | |||||||||||||||||||||||||||
| 551 | 0 | ▶ | if ($INC{$_} eq $filename) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 552 | 0 | $in_inc = 1; | |||||||||||||||||||||||||||
| 553 | 0 | $main::{"_<$filename"} = $_; | |||||||||||||||||||||||||||
| 554 | 0 | last; | |||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||
| 557 | 0 | ▶ | unless ($in_inc) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 558 | 0 | print "sorry, '$filename' is not a file used by Perl\n"; | |||||||||||||||||||||||||||
| 559 | 0 | return 0; | |||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||
| 563 | 0 | my $i = 0; | |||||||||||||||||||||||||||
| 564 | 0 | $r->print('<pre>'); | |||||||||||||||||||||||||||
| 565 | 0 | ▶ | if ($offset > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 566 | 0 | printf "%4d..%d [...]\n", 1, $offset-1; | |||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||
| 568 | 0 | ▶ | open FH, $filename or die $!; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 569 | 0 | ▶ | while (<FH>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 570 | 0 | $i++; | |||||||||||||||||||||||||||
| 571 | 0 | ▶ | next if $len > 0 and $i > $len; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$len > 0 and $i > $len
MC/DC0%0/2
$len > 0 and $i > $len
$len > 0
$i > $len
Truth table0%0/3
A and B
A= $len > 0B= $i > $len
| |||||||||||||||||||||||||||||
| 572 | 0 | ▶ | next if $offset > 0 and $i < $offset; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$offset > 0 and $i < $offset
MC/DC0%0/2
$offset > 0 and $i < $offset
$offset > 0
$i < $offset
Truth table0%0/3
A and B
A= $offset > 0B= $i < $offset
| |||||||||||||||||||||||||||||
| 573 | 0 | chomp; | |||||||||||||||||||||||||||
| 574 | 0 | s/^\t/ /; #indent proper | |||||||||||||||||||||||||||
| 575 | 0 | my $lineno = sprintf "%4d", $i; | |||||||||||||||||||||||||||
| 576 | 0 | B::Size2::escape_html(\$_); | |||||||||||||||||||||||||||
| 577 | 0 | ▶ | my $line = ($i == $params{line}) ? | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 578 | \qq(<font color="#FF0000">$_</font>) : \$_; | ||||||||||||||||||||||||||||
| 579 | 0 | print qq($lineno: <a name=$i>$$line</a>\n); | |||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||
| 582 | 0 | ▶ | if ($len > 0 and $i > $len) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$len > 0 and $i > $len
MC/DC0%0/2
$len > 0 and $i > $len
$len > 0
$i > $len
Truth table0%0/3
A and B
A= $len > 0B= $i > $len
| |||||||||||||||||||||||||||||
| 583 | 0 | printf "%4d..%d [...]\n", $len+1, $i; | |||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||
| 585 | 0 | close FH; | |||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||
| 587 | 0 | 0; | |||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||
| 590 | 0 | ▶ | sub max { | ||||||||||||||||||||||||||
|
Subroutine
max: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 591 | 0 | my($cur, $maybe) = @_; | |||||||||||||||||||||||||||
| 592 | 0 | ▶ | $maybe > $cur ? $maybe : $cur; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||
| 595 | 2 | my %summary_cache = (); | |||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||
| 597 | 0 | ▶ | sub apache_package_size { | ||||||||||||||||||||||||||
|
Subroutine
apache_package_size: not called CC=4 SCAR=26.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 598 | 0 | my $package = shift; | |||||||||||||||||||||||||||
| 599 | 0 | my($subs, $opcount, $opsize); | |||||||||||||||||||||||||||
| 600 | 0 | my $keys = 0; | |||||||||||||||||||||||||||
| 601 | 0 | my $cache = {}; | |||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||
| 603 | { | ||||||||||||||||||||||||||||
| 604 | 0 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||
| 605 | 0 | $keys = keys %{"$package\::"}; | |||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||
| 608 | 0 | ▶ | if ($cache = $summary_cache{$package}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 609 | 0 | ▶ | if ($cache->{'keys'} == $keys) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 610 | 0 | ▶ | return @{ $cache->{'data'} } if $cache->{'data'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||
| 614 | 0 | $cache->{'keys'} = $keys; | |||||||||||||||||||||||||||
| 615 | 0 | $summary_cache{$package} = $cache; | |||||||||||||||||||||||||||
| 616 | 0 | @{ $cache->{'data'} } = B::Size2::Terse::package_size($package); | |||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||
| 619 | 0 | ▶ | sub status_memory_usage { | ||||||||||||||||||||||||||
|
Subroutine
status_memory_usage: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 620 | 0 | my($r, $q) = @_; | |||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||
| 622 | 0 | if (MP2) { | |||||||||||||||||||||||||||
| 623 | unless (Apache2::Status::status_config($r, "StatusTerseSize")) { | ||||||||||||||||||||||||||||
| 624 | return ["StatusTerseSize is not enabled"]; | ||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||
| 627 | else { | ||||||||||||||||||||||||||||
| 628 | 0 | ▶ | unless (Apache::Status::status_config($r, "StatusTerseSize")) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 629 | 0 | return ["StatusTerseSize is not enabled"]; | |||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||
| 633 | 0 | ▶ | unless ($r->dir_config("StatusTerseSizeMainSummary")) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 634 | 0 | return ["StatusTerseSizeMainSummary is not enabled"]; | |||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||
| 637 | 0 | my $script = MP2 ? $r->uri : $q->script_name; | |||||||||||||||||||||||||||
| 638 | 0 | my $stab = Devel::Symdump->rnew('main'); | |||||||||||||||||||||||||||
| 639 | 0 | my %total; | |||||||||||||||||||||||||||
| 640 | 0 | my @retval = ('<pre>'); | |||||||||||||||||||||||||||
| 641 | 0 | my($clen, $slen, $nlen); | |||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||
| 643 | 0 | for my $package ('main', $stab->packages) { | |||||||||||||||||||||||||||
| 644 | 0 | my($subs, $opcount, $opsize) = apache_package_size($package); | |||||||||||||||||||||||||||
| 645 | 0 | $total{$package} = {'count' => $opcount, 'size' => $opsize}; | |||||||||||||||||||||||||||
| 646 | 0 | $nlen = max($nlen, length $package); | |||||||||||||||||||||||||||
| 647 | 0 | $slen = max($slen, length $opsize); | |||||||||||||||||||||||||||
| 648 | 0 | $clen = max($clen, length $opcount); | |||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||
| 651 | 0 | for (sort { $total{$b}->{size} <=> $total{$a}->{size} } keys %total) { | |||||||||||||||||||||||||||
| 652 | 0 | my $link = qq(<a href="$script/$_?noh_b_package_size">); | |||||||||||||||||||||||||||
| 653 | push @retval, | ||||||||||||||||||||||||||||
| 654 | sprintf "$link%-${nlen}s</a> %${slen}d bytes | %${clen}d OPs\n", | ||||||||||||||||||||||||||||
| 655 | 0 | $_, $total{$_}->{size}, $total{$_}->{count}; | |||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||
| 657 | 0 | \@retval; | |||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||
| 660 | 2 | if (MP2) { | |||||||||||||||||||||||||||
| 661 | Apache2::Status->menu_item( | ||||||||||||||||||||||||||||
| 662 | 'status_memory_usage' => "Memory Usage", | ||||||||||||||||||||||||||||
| 663 | \&status_memory_usage, | ||||||||||||||||||||||||||||
| 664 | ); | ||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||
| 666 | 0 | elsif (IS_MODPERL and Apache->module("Apache::Status")) { | |||||||||||||||||||||||||||
| 667 | Apache::Status->menu_item( | ||||||||||||||||||||||||||||
| 668 | 'status_memory_usage' => "Memory Usage", | ||||||||||||||||||||||||||||
| 669 | \&status_memory_usage, | ||||||||||||||||||||||||||||
| 670 | ); | ||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||
| 673 | 2 | 1; | |||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||
| 675 | __END__ | ||||||||||||||||||||||||||||