/usr/local/lib/perl5/site_perl/5.44.0/Devel/Symdump.pm

filter: Statementstmt 0.0% 0 / 187 Branchbran 0.0% 0 / 62 Conditioncond 0.0% 0 / 48 MC/DCmcdc 0.0% 0 / 27 Subroutinesub 0.0% 0 / 15 Podpod 100% 7 / 7 totaltotal 2.0% 7 / 346 CC 64 SCAR 56.8
CC
64
Cov
0%
_symdump
756.0
diff
132.0
inh_tree
56.0
CRAP 293.7
« /usr/local/lib/perl5/5.44.0/x86_64-linux/Sys/Hostname.pm ↑ Summary /usr/local/lib/perl5/5.44.0/x86_64-linux/Time/HiRes.pm »
1 package Devel::Symdump;
2  
3 use 5.003;
4 use Carp ();
5 use strict;
6 use vars qw($Defaults $VERSION *ENTRY $MAX_RECURSION);
7  
8 $VERSION = '2.18';
9 $MAX_RECURSION = 97;
10  
11 $Defaults = {
12 'RECURS' => 0,
13 'AUTOLOAD' => {
14 'packages' => 1,
15 'scalars' => 1,
16 'arrays' => 1,
17 'hashes' => 1,
18 'functions' => 1,
19 'ios' => 1,
20 'unknowns' => 1,
21 },
22 'SEEN' => {},
23 };
24  
25 sub rnew {
26 0 ▶ my($class,@packages) = @_;
Subroutine rnew: not called CC=1 SCAR=6.9
Pod documented
27 no strict "refs";
28 0 my $self = bless {%${"$class\::Defaults"}}, $class;
29 0 $self->{RECURS}++;
30 0 $self->_doit(@packages);
31 }
32  
33 sub new {
34 0 ▶ my($class,@packages) = @_;
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
35 no strict "refs";
36 0 my $self = bless {%${"$class\::Defaults"}}, $class;
37 0 $self->_doit(@packages);
38 }
39  
40 sub _doit {
41 0 ▶ my($self,@packages) = @_;
Subroutine _doit: not called CC=2 SCAR=17.9
42 0 ▶ @packages = ("main") unless @packages;
Branch: 1 branch
BranchTrueFalseTotal
unless @packages 0 0 0
43 0 $self->{RESULT} = $self->_symdump(@packages);
44 0 return $self;
45 }
46  
47 sub _symdump {
48 0 ▶ my($self,@packages) = @_ ;
Subroutine _symdump: not called CC=27 SCAR=66.3
49 0 my($key,$val,$num,$pack,@todo,$tmp);
50 0 my $result = {};
51 0 foreach $pack (@packages){
52 no strict;
53 0 ▶ while (($key,$val) = each(%{*{"$pack\::"}})) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{*{"${pack}::";};}) 0 0 0
54 0 my $gotone = 0;
55 0 local(*ENTRY) = $val;
56 #### SCALAR ####
57 0 ▶ if (defined $val && defined *ENTRY{SCALAR}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $val and defined *ENTRY{"SCALAR"}) 0 0 0
Condition0%0/3
defined $val and defined *ENTRY{"SCALAR"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $val and defined *ENTRY{"SCALAR"}
defined $val defined *ENTRY{"SCALAR"}
Truth table0%0/3
A and B
A= defined $valB= defined *ENTRY{"SCALAR"}
ABresult
0X0
100
111
58 0 $result->{$pack}{SCALARS}{$key}++;
59 0 $gotone++;
60 }
61 #### ARRAY ####
62 0 ▶ if (defined $val && defined *ENTRY{ARRAY}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $val and defined *ENTRY{"ARRAY"}) 0 0 0
Condition0%0/3
defined $val and defined *ENTRY{"ARRAY"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $val and defined *ENTRY{"ARRAY"}
defined $val defined *ENTRY{"ARRAY"}
Truth table0%0/3
A and B
A= defined $valB= defined *ENTRY{"ARRAY"}
ABresult
0X0
100
111
63 0 $result->{$pack}{ARRAYS}{$key}++;
64 0 $gotone++;
65 }
66 #### HASH ####
67 0 ▶ if (defined $val && defined *ENTRY{HASH} && $key !~ /::/) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $val and defined *ENTRY{"HASH"} and not $key =~ /::/) 0 0 0
Condition0%0/6
defined $val and defined *ENTRY{"HASH"} and not $key =~ /::/
!ll&&!rl&&r
000
defined $val and defined *ENTRY{"HASH"}
!ll&&!rl&&r
000
MC/DC0%0/3
defined $val and defined *ENTRY{"HASH"} and not $key =~ /::/
defined $val defined *ENTRY{"HASH"} not $key =~ /::/
Truth table0%0/4
A and B and not(C)
A= defined $valB= defined *ENTRY{"HASH"}C= not $key =~ /::/
ABCresult
0XX0
10X0
1100
1111
68 0 $result->{$pack}{HASHES}{$key}++;
69 0 $gotone++;
70 }
71 #### PACKAGE ####
72 0 ▶ if (defined $val && defined *ENTRY{HASH} && $key =~ /::$/ &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $val and defined *ENTRY{"HASH"} and $key =~ /::$/ and $key ne "main::" and $key ne "<none>::") 0 0 0
Condition0%0/12
defined $val and defined *ENTRY{"HASH"} and $key =~ /::$/ and $key ne "main::" and $key ne "<none>::"
!ll&&!rl&&r
000
defined $val and defined *ENTRY{"HASH"} and $key =~ /::$/ and $key ne "main::"
!ll&&!rl&&r
000
defined $val and defined *ENTRY{"HASH"} and $key =~ /::$/
!ll&&!rl&&r
000
defined $val and defined *ENTRY{"HASH"}
!ll&&!rl&&r
000
MC/DC0%0/5
defined $val and defined *ENTRY{"HASH"} and $key =~ /::$/ and $key ne "main::" and $key ne "<none>::"
defined $val defined *ENTRY{"HASH"} $key =~ /::$/ $key ne "main::" $key ne "<none>::"
Truth table0%0/6
A and B and C and D and E
A= defined $valB= defined *ENTRY{"HASH"}C= $key =~ /::$/D= $key ne "main::"E= $key ne "<none>::"
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
73 $key ne "main::" && $key ne "<none>::") {
74 0 ▶ my($p) = $pack ne "main" ? "$pack\::" : "";
Branch: 1 branch
BranchTrueFalseTotal
$pack ne 'main' ? : 0 0 0
75 0 ($p .= $key) =~ s/::$//;
76 0 $result->{$pack}{PACKAGES}{$p}++;
77 0 $gotone++;
78 0 ▶ if (++$self->{SEEN}{*$val} > $Devel::Symdump::MAX_RECURSION){
Branch: 1 branch
BranchTrueFalseTotal
if (++$self->{"SEEN"}{*$val} > $MAX_RECURSION) 0 0 0
79 0 next;
80 }
81 0 push @todo, $p;
82 }
83 #### FUNCTION ####
84 0 ▶ if (defined $val && defined *ENTRY{CODE}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $val and defined *ENTRY{"CODE"}) 0 0 0
Condition0%0/3
defined $val and defined *ENTRY{"CODE"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $val and defined *ENTRY{"CODE"}
defined $val defined *ENTRY{"CODE"}
Truth table0%0/3
A and B
A= defined $valB= defined *ENTRY{"CODE"}
ABresult
0X0
100
111
85 0 $result->{$pack}{FUNCTIONS}{$key}++;
86 0 $gotone++;
87 }
88  
89 #### IO #### had to change after 5.003_10
90 0 ▶ if ($] > 5.003_10){
Branch: 1 branch
BranchTrueFalseTotal
if ($] > 5.0031) { } 0 0 0
91 0 ▶ if (defined $val && defined *ENTRY{IO}){ # fileno and telldir...
Branch: 1 branch
BranchTrueFalseTotal
if (defined $val and defined *ENTRY{"IO"}) 0 0 0
Condition0%0/3
defined $val and defined *ENTRY{"IO"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $val and defined *ENTRY{"IO"}
defined $val defined *ENTRY{"IO"}
Truth table0%0/3
A and B
A= defined $valB= defined *ENTRY{"IO"}
ABresult
0X0
100
111
92 0 $result->{$pack}{IOS}{$key}++;
93 0 $gotone++;
94 }
95 } else {
96 #### FILEHANDLE ####
97 0 ▶ if (defined fileno(ENTRY)){
Branch: 2 branches
BranchTrueFalseTotal
if (defined fileno ENTRY) { } 0 0 0
elsif (defined telldir ENTRY) { } 0 0 0
98 0 $result->{$pack}{IOS}{$key}++;
99 0 $gotone++;
100 } elsif (defined telldir(ENTRY)){
101 #### DIRHANDLE ####
102 0 $result->{$pack}{IOS}{$key}++;
103 0 $gotone++;
104 }
105 }
106  
107 #### SOMETHING ELSE ####
108 0 ▶ unless ($gotone) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($gotone) 0 0 0
109 0 $result->{$pack}{UNKNOWNS}{$key}++;
110 }
111 }
112 }
113  
114 return (@todo && $self->{RECURS})
115 0 ▶ ? { %$result, %{$self->_symdump(@todo)} }
Branch: 1 branch
BranchTrueFalseTotal
@todo && $self->{'RECURS'} ? : 0 0 0
Condition0%0/3
@todo and $self->{"RECURS"}
!ll&&!rl&&r
000
MC/DC0%0/2
@todo and $self->{"RECURS"}
@todo $self->{"RECURS"}
Truth table0%0/3
A and B
A= @todoB= $self->{"RECURS"}
ABresult
0X0
100
111
116 : $result;
117 }
118  
119 sub _partdump {
120 0 ▶ my($self,$part)=@_;
Subroutine _partdump: not called CC=4 SCAR=30.0
121 0 my ($pack, @result);
122 0 my $prepend = "";
123 0 foreach $pack (keys %{$self->{RESULT}}){
124 0 ▶ $prepend = "$pack\::" unless $part eq 'PACKAGES';
Branch: 1 branch
BranchTrueFalseTotal
unless $part eq "PACKAGES" 0 0 0
125 0 ▶ push @result, map {"$prepend$_"} keys %{$self->{RESULT}{$pack}{$part} || {}};
Condition0%0/2
$self->{'RESULT'}{$pack}{$part} || {}
l!l
00
MC/DC0%0/1
$self->{'RESULT'}{$pack}{$part} || {}
$self->{'RESULT'}{$pack}{$part}
Truth table0%0/2
A
A= $self->{'RESULT'}{$pack}{$part}
Aresult
11
00
126 }
127 0 return @result;
128 }
129  
130 # this is needed so we don't try to AUTOLOAD the DESTROY method
131 0 ▶sub DESTROY {}
Subroutine DESTROY: not called CC=1 SCAR=0.0
132  
133 sub as_string {
134 0 ▶ my $self = shift;
Subroutine as_string: not called CC=2 SCAR=17.9
Pod documented
135 0 my($type,@m);
136 0 for $type (sort keys %{$self->{'AUTOLOAD'}}) {
137 0 push @m, $type;
138 push @m, "\t" . join "\n\t", map {
139 0 s/([\000-\037\177])/ '^' . pack('c', ord($1) ^ 64) /eg;
140 0 $_;
141 } sort $self->_partdump(uc $type);
142 }
143 0 return join "\n", @m;
144 }
145  
146 sub as_HTML {
147 0 ▶ my $self = shift;
Subroutine as_HTML: not called CC=2 SCAR=17.9
Pod documented
148 0 my($type,@m);
149 0 push @m, "<TABLE>";
150 0 for $type (sort keys %{$self->{'AUTOLOAD'}}) {
151 0 push @m, "<TR><TD valign=top><B>$type</B></TD>";
152 push @m, "<TD>" . join ", ", map {
153 0 s/([\000-\037\177])/ '^' .
154 pack('c', ord($1) ^ 64)
155 0 /eg; $_;
156 } sort $self->_partdump(uc $type);
157 0 push @m, "</TD></TR>";
158 }
159 0 push @m, "</TABLE>";
160 0 return join "\n", @m;
161 }
162  
163 sub diff {
164 0 ▶ my($self,$second) = @_;
Subroutine diff: not called CC=11 SCAR=48.8
Pod documented
165 0 my($type,@m);
166 0 for $type (sort keys %{$self->{'AUTOLOAD'}}) {
167 0 my(%first,%second,%all,$symbol);
168 0 foreach $symbol ($self->_partdump(uc $type)){
169 0 $first{$symbol}++;
170 0 $all{$symbol}++;
171 }
172 0 foreach $symbol ($second->_partdump(uc $type)){
173 0 $second{$symbol}++;
174 0 $all{$symbol}++;
175 }
176 0 my(@typediff);
177 0 foreach $symbol (sort keys %all){
178 0 ▶ next if $first{$symbol} && $second{$symbol};
Branch: 1 branch
BranchTrueFalseTotal
if $first{$symbol} and $second{$symbol} 0 0 0
Condition0%0/3
$first{$symbol} and $second{$symbol}
!ll&&!rl&&r
000
MC/DC0%0/2
$first{$symbol} and $second{$symbol}
$first{$symbol} $second{$symbol}
Truth table0%0/3
A and B
A= $first{$symbol}B= $second{$symbol}
ABresult
0X0
100
111
179 0 ▶ push @typediff, "- $symbol" unless $second{$symbol};
Branch: 1 branch
BranchTrueFalseTotal
unless $second{$symbol} 0 0 0
180 0 ▶ push @typediff, "+ $symbol" unless $first{$symbol};
Branch: 1 branch
BranchTrueFalseTotal
unless $first{$symbol} 0 0 0
181 }
182 0 foreach (@typediff) {
183 0 s/([\000-\037\177])/ '^' . pack('c', ord($1) ^ 64) /eg;
184 }
185 0 ▶ push @m, $type, @typediff if @typediff;
Branch: 1 branch
BranchTrueFalseTotal
if @typediff 0 0 0
186 }
187 0 return join "\n", @m;
188 }
189  
190 sub inh_tree {
191 0 ▶ my($self) = @_;
Subroutine inh_tree: not called CC=7 SCAR=40.3
Pod documented
192 0 ▶ return $self->{INHTREE} if ref $self && defined $self->{INHTREE};
Branch: 1 branch
BranchTrueFalseTotal
if ref $self and defined $self->{"INHTREE"} 0 0 0
Condition0%0/3
ref $self and defined $self->{"INHTREE"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $self and defined $self->{"INHTREE"}
ref $self defined $self->{"INHTREE"}
Truth table0%0/3
A and B
A= ref $selfB= defined $self->{"INHTREE"}
ABresult
0X0
100
111
193 0 my($inherited_by) = {};
194 0 my($m)="";
195 0 my(@isa) = grep /\bISA$/, Devel::Symdump->rnew->arrays;
196 0 my $isa;
197 0 foreach $isa (sort @isa) {
198 0 $isa =~ s/::ISA$//;
199 0 my($isaisa);
200 no strict 'refs';
201 0 foreach $isaisa (@{"$isa\::ISA"}){
202 0 $inherited_by->{$isaisa}{$isa}++;
203 }
204 }
205 0 my $item;
206 0 foreach $item (sort keys %$inherited_by) {
207 0 $m .= "$item\n";
208 0 $m .= _inh_tree($item,$inherited_by);
209 }
210 0 ▶ $self->{INHTREE} = $m if ref $self;
Branch: 1 branch
BranchTrueFalseTotal
if ref $self 0 0 0
211 0 $m;
212 }
213  
214 sub _inh_tree {
215 0 ▶ my($package,$href,$depth) = @_;
Subroutine _inh_tree: not called CC=5 SCAR=34.0
216 0 ▶ return unless defined $href;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $href 0 0 0
217 0 ▶ $depth ||= 0;
Condition0%0/2
$depth ||= 0
l!l
00
MC/DC0%0/1
$depth ||= 0
$depth
Truth table0%0/2
A
A= $depth
Aresult
11
00
218 0 $depth++;
219 0 ▶ if ($depth > 100){
Branch: 1 branch
BranchTrueFalseTotal
if ($depth > 100) 0 0 0
220 0 warn "Deep recursion in ISA\n";
221 0 return;
222 }
223 0 my($m) = "";
224 # print "DEBUG: package[$package]depth[$depth]\n";
225 0 my $i;
226 0 foreach $i (sort keys %{$href->{$package}}) {
227 0 $m .= qq{\t} x $depth;
228 0 $m .= qq{$i\n};
229 0 $m .= _inh_tree($i,$href,$depth);
230 }
231 0 $m;
232 }
233  
234 sub isa_tree{
235 0 ▶ my($self) = @_;
Subroutine isa_tree: not called CC=5 SCAR=34.0
Pod documented
236 0 ▶ return $self->{ISATREE} if ref $self && defined $self->{ISATREE};
Branch: 1 branch
BranchTrueFalseTotal
if ref $self and defined $self->{"ISATREE"} 0 0 0
Condition0%0/3
ref $self and defined $self->{"ISATREE"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $self and defined $self->{"ISATREE"}
ref $self defined $self->{"ISATREE"}
Truth table0%0/3
A and B
A= ref $selfB= defined $self->{"ISATREE"}
ABresult
0X0
100
111
237 0 my(@isa) = grep /\bISA$/, Devel::Symdump->rnew->arrays;
238 0 my($m) = "";
239 0 my($isa);
240 0 foreach $isa (sort @isa) {
241 0 $isa =~ s/::ISA$//;
242 0 $m .= qq{$isa\n};
243 0 $m .= _isa_tree($isa)
244 }
245 0 ▶ $self->{ISATREE} = $m if ref $self;
Branch: 1 branch
BranchTrueFalseTotal
if ref $self 0 0 0
246 0 $m;
247 }
248  
249 sub _isa_tree{
250 0 ▶ my($package,$depth) = @_;
Subroutine _isa_tree: not called CC=4 SCAR=30.0
251 0 ▶ $depth ||= 0;
Condition0%0/2
$depth ||= 0
l!l
00
MC/DC0%0/1
$depth ||= 0
$depth
Truth table0%0/2
A
A= $depth
Aresult
11
00
252 0 $depth++;
253 0 ▶ if ($depth > 100){
Branch: 1 branch
BranchTrueFalseTotal
if ($depth > 100) 0 0 0
254 0 warn "Deep recursion in ISA\n";
255 0 return;
256 }
257 0 my($m) = "";
258 # print "DEBUG: package[$package]depth[$depth]\n";
259 0 my $isaisa;
260 no strict 'refs';
261 0 foreach $isaisa (@{"$package\::ISA"}) {
262 0 $m .= qq{\t} x $depth;
263 0 $m .= qq{$isaisa\n};
264 0 $m .= _isa_tree($isaisa,$depth);
265 }
266 0 $m;
267 }
268  
269 AUTOLOAD {
270 0 ▶ my($self,@packages) = @_;
Subroutine AUTOLOAD: not called CC=5 SCAR=34.0
271 0 ▶ unless (ref $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self) 0 0 0
272 0 $self = $self->new(@packages);
273 }
274 no strict "vars";
275 0 (my $auto = $AUTOLOAD) =~ s/.*:://;
276  
277 0 $auto =~ s/(file|dir)handles/ios/;
278 0 my $compat = $1;
279  
280 0 ▶ unless ($self->{'AUTOLOAD'}{$auto}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"AUTOLOAD"}{$auto}) 0 0 0
281 0 Carp::croak("invalid Devel::Symdump method: $auto()");
282 }
283  
284 0 my @syms = $self->_partdump(uc $auto);
285 0 ▶ if (defined $compat) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $compat) 0 0 0
286 no strict 'refs';
287 0 local $^W; # bleadperl@26631 introduced an io warning here
288 0 ▶ if ($compat eq "file") {
Branch: 1 branch
BranchTrueFalseTotal
if ($compat eq 'file') { } 0 0 0
289 0 @syms = grep { defined(fileno($_)) } @syms;
290 } else {
291 0 @syms = grep { _is_dirhandle($_) } @syms;
292 }
293 }
294 0 return @syms; # make sure now it gets context right
295 }
296  
297 use Config ();
298 use constant HAVE_TELLDIR => $Config::Config{d_telldir};
299 sub _is_dirhandle {
300 0 ▶ my ($glob) = @_;
Subroutine _is_dirhandle: not called CC=1 SCAR=6.9
301 0 if ( HAVE_TELLDIR ) {
302 0 return defined(telldir($glob));
303 }
304 else {
305 if ( !ref $glob ) {
306 no strict 'refs';
307 $glob = \*{$glob};
308 }
309 require B;
310 my $obj = B::svref_2object($glob);
311 return if !$obj || !eval{ $obj->IO; $obj->IO->IoTYPE; 1 };
312 my $mode = $obj->IO->IoTYPE;
313 return $mode eq "\0" ? 1 : 0;
314 }
315 }
316  
317 1;
318  
319 __END__
« /usr/local/lib/perl5/5.44.0/x86_64-linux/Sys/Hostname.pm ↑ Summary /usr/local/lib/perl5/5.44.0/x86_64-linux/Time/HiRes.pm »