Dpkg/Shlibs/SymbolFile.pm

filter: Statementstmt 87.3% 324 / 371 Branchbran 78.0% 153 / 196 Conditioncond 70.7% 75 / 106 MC/DCmcdc 47.4% 28 / 59 Subroutinesub 82.9% 34 / 41 Podpod 6.4% 2 / 31 totaltotal 76.6% 616 / 804 CC 163 SCAR 26.8
CC
163
Cov
82%
output
31.8
find_matching_pattern
23.4
lookup_pattern
20.9
CRAP 14.6
« Dpkg/Shlibs.pm ↑ Summary Dpkg/Deps/KnownFacts.pm »
1 # Copyright © 2007 Raphaël Hertzog <hertzog@debian.org>
2 # Copyright © 2009-2010 Modestas Vainius <modax@debian.org>
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16  
17 =encoding utf8
18  
19 =head1 NAME
20  
21 Dpkg::Shlibs::SymbolFile - represent a symbols file
22  
23 =head1 DESCRIPTION
24  
25 This module provides a class to handle symbols files.
26  
27 B<Note>: This is a private module, its API can change at any time.
28  
29 =cut
30  
31 package Dpkg::Shlibs::SymbolFile 0.01;
32  
33 2 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 2 ▶use Dpkg::Gettext;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 2 ▶use Dpkg::ErrorHandling;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 2 ▶use Dpkg::Version;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 2 ▶use Dpkg::Control::Fields;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 2 ▶use Dpkg::Shlibs::Symbol;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 2 ▶use Dpkg::Arch qw(get_host_arch);
Subroutine BEGIN: called CC=1 SCAR=0.0
41  
42 2 ▶use parent qw(Dpkg::Interface::Storable);
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 2 my %internal_symbol = (
45 __bss_end__ => 1, # arm
46 __bss_end => 1, # arm
47 _bss_end__ => 1, # arm
48 __bss_start => 1, # ALL
49 __bss_start__ => 1, # arm
50 __data_start => 1, # arm
51 __do_global_ctors_aux => 1, # ia64
52 __do_global_dtors_aux => 1, # ia64
53 __do_jv_register_classes => 1, # ia64
54 _DYNAMIC => 1, # ALL
55 _edata => 1, # ALL
56 _end => 1, # ALL
57 __end__ => 1, # arm
58 __exidx_end => 1, # armel
59 __exidx_start => 1, # armel
60 _fbss => 1, # mips, mipsel
61 _fdata => 1, # mips, mipsel
62 _fini => 1, # ALL
63 _ftext => 1, # mips, mipsel
64 _GLOBAL_OFFSET_TABLE_ => 1, # hppa, mips, mipsel
65 __gmon_start__ => 1, # hppa
66 __gnu_local_gp => 1, # mips, mipsel
67 _gp => 1, # mips, mipsel
68 _init => 1, # ALL
69 _PROCEDURE_LINKAGE_TABLE_ => 1, # sparc, alpha
70 _SDA2_BASE_ => 1, # powerpc
71 _SDA_BASE_ => 1, # powerpc
72 );
73  
74 2 for my $i (14 .. 31) {
75 # Many powerpc specific symbols.
76 36 $internal_symbol{"_restfpr_$i"} = 1;
77 36 $internal_symbol{"_restfpr_$i\_x"} = 1;
78 36 $internal_symbol{"_restgpr_$i"} = 1;
79 36 $internal_symbol{"_restgpr_$i\_x"} = 1;
80 36 $internal_symbol{"_savefpr_$i"} = 1;
81 36 $internal_symbol{"_savegpr_$i"} = 1;
82 }
83  
84 18206 ▶sub symbol_is_internal {
Subroutine symbol_is_internal: called CC=6 SCAR=17.9
Pod undocumented
85 18206 my ($symbol, $include_groups) = @_;
86  
87 18206 ▶ return 1 if exists $internal_symbol{$symbol};
Branch: 1 branch
BranchTrueFalseTotal
if exists $internal_symbol{$symbol} 99 18107 18206
88  
89 # The ARM Embedded ABI spec states symbols under this namespace as
90 # possibly appearing in output objects.
91 18107 ▶ return 1 if not ${$include_groups}{aeabi} and $symbol =~ /^__aeabi_/;
Branch: 1 branch
BranchTrueFalseTotal
if not do { $include_groups }->{"aeabi"} and $symbol =~ /^__aeabi_/u 8 18099 18107
Condition100%3/3
not do { $include_groups }->{"aeabi"} and $symbol =~ /^__aeabi_/u
!ll&&!rl&&r
10180898
MC/DC100%2/2
not do { $include_groups }->{"aeabi"} and $symbol =~ /^__aeabi_/u
not do { $include_groups }->{"aeabi"} $symbol =~ /^__aeabi_/u
Truth table100%3/3
not(A) and B
A= not do { $include_groups }->{"aeabi"}B= $symbol =~ /^__aeabi_/u
ABresult
0X0
100
111
92  
93 # The GNU implementation of the OpenMP spec, specifies symbols under
94 # this namespace as possibly appearing in output objects.
95 18099 return 1 if not ${$include_groups}{gomp}
96 18099 ▶ and $symbol =~ /^\.gomp_critical_user_/;
Branch: 1 branch
BranchTrueFalseTotal
if not do { $include_groups }->{"gomp"} and $symbol =~ /^\.gomp_critical_user_/u 8 18091 18099
Condition100%3/3
not do { $include_groups }->{"gomp"} and $symbol =~ /^\.gomp_critical_user_/u
!ll&&!rl&&r
10180818
MC/DC100%2/2
not do { $include_groups }->{"gomp"} and $symbol =~ /^\.gomp_critical_user_/u
not do { $include_groups }->{"gomp"} $symbol =~ /^\.gomp_critical_user_/u
Truth table100%3/3
not(A) and B
A= not do { $include_groups }->{"gomp"}B= $symbol =~ /^\.gomp_critical_user_/u
ABresult
0X0
100
111
97  
98 18091 return 0;
99 }
100  
101 43 ▶sub new {
Subroutine new: called CC=5 SCAR=16.6
Pod undocumented
102 43 my ($this, %opts) = @_;
103 43 ▶ my $class = ref($this) || $this;
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
0430
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
104 43 my $self = \%opts;
105 43 bless $self, $class;
106 43 ▶ $self->{arch} //= get_host_arch();
Condition66%2/3
$self->{"arch"} //= get_host_arch()
l!l&&r!l&&!r
10330
MC/DC0%0/2
$self->{"arch"} //= get_host_arch()
$self->{"arch"} get_host_arch()
Truth table66%2/3
A //= B
A= $self->{"arch"}B= get_host_arch()
ABresult
1X1
011
000
107 43 $self->clear();
108 43 ▶ if (exists $self->{filename}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"filename"}) 43 0 43
109 43 ▶ $self->load($self->{filename}) if -e $self->{filename};
Branch: 1 branch
BranchTrueFalseTotal
if -e $self->{"filename"} 37 6 43
110 }
111 43 return $self;
112 }
113  
114 46972 ▶sub get_arch {
Subroutine get_arch: called CC=1 SCAR=0.0
Pod undocumented
115 46972 my $self = shift;
116 46972 return $self->{arch};
117 }
118  
119 43 ▶sub clear {
Subroutine clear: called CC=1 SCAR=0.0
Pod undocumented
120 43 my $self = shift;
121 43 $self->{objects} = {};
122 }
123  
124 0 ▶sub clear_except {
Subroutine clear_except: not called CC=3 SCAR=24.8
Pod undocumented
125 0 my ($self, @ids) = @_;
126  
127 0 my %has = map { $_ => 1 } @ids;
128 0 foreach my $objid (keys %{$self->{objects}}) {
129 0 ▶ delete $self->{objects}{$objid} unless exists $has{$objid};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $has{$objid} 0 0 0
130 }
131 }
132  
133 53 ▶sub get_sonames {
Subroutine get_sonames: called CC=1 SCAR=0.0
Pod undocumented
134 53 my $self = shift;
135 53 return keys %{$self->{objects}};
136 }
137  
138 90 ▶sub get_symbols {
Subroutine get_symbols: called CC=4 SCAR=17.2
Pod undocumented
139 90 my ($self, $soname) = @_;
140 90 ▶ if (defined $soname) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $soname) { } 90 0 90
141 90 my $obj = $self->get_object($soname);
142 90 ▶ return (defined $obj) ? values %{$obj->{syms}} : ();
Branch: 1 branch
BranchTrueFalseTotal
defined $obj ? : 90 0 90
143 } else {
144 0 my @syms;
145 0 foreach my $soname ($self->get_sonames()) {
146 0 push @syms, $self->get_symbols($soname);
147 }
148 0 return @syms;
149 }
150 }
151  
152 59 ▶sub get_patterns {
Subroutine get_patterns: called CC=4 SCAR=14.8
Pod undocumented
153 59 my ($self, $soname) = @_;
154 59 my @patterns;
155 59 ▶ if (defined $soname) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $soname) { } 59 0 59
156 59 my $obj = $self->get_object($soname);
157 59 foreach my $alias (values %{$obj->{patterns}{aliases}}) {
158 36 push @patterns, values %$alias;
159 }
160 59 return (@patterns, @{$obj->{patterns}{generic}});
161 } else {
162 0 foreach my $soname ($self->get_sonames()) {
163 0 push @patterns, $self->get_patterns($soname);
164 }
165 0 return @patterns;
166 }
167 }
168  
169 # Create a symbol from the supplied string specification.
170 5251 ▶sub create_symbol {
Subroutine create_symbol: called CC=4 SCAR=14.0
Pod undocumented
171 5251 my ($self, $spec, %opts) = @_;
172 my $symbol = (exists $opts{base}) ? $opts{base} :
173 5251 ▶ Dpkg::Shlibs::Symbol->new();
Branch: 1 branch
BranchTrueFalseTotal
exists $opts{'base'} ? : 5242 9 5251
174  
175 5251 ▶ my $ret = $opts{dummy} ? $symbol->parse_symbolspec($spec, default_minver => 0) :
Branch: 1 branch
BranchTrueFalseTotal
$opts{'dummy'} ? : 1 5250 5251
176 $symbol->parse_symbolspec($spec);
177 5251 ▶ if ($ret) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ret) 5251 0 5251
178 5251 $symbol->initialize(arch => $self->get_arch());
179 5251 return $symbol;
180 }
181 0 return;
182 }
183  
184 14439 ▶sub add_symbol {
Subroutine add_symbol: called CC=4 SCAR=13.9
Pod undocumented
185 14439 my ($self, $symbol, $soname) = @_;
186 14439 my $object = $self->get_object($soname);
187  
188 14439 ▶ if ($symbol->is_pattern()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($symbol->is_pattern) { } 79 14360 14439
189 79 ▶ if (my $alias_type = $symbol->get_alias_type()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $alias_type = $symbol->get_alias_type) { } 46 33 79
190 46 ▶ $object->{patterns}{aliases}{$alias_type} //= {};
Condition100%2/2
$object->{"patterns"}{"aliases"}{$alias_type} //= {}
l!l
2224
MC/DC100%1/1
$object->{"patterns"}{"aliases"}{$alias_type} //= {}
$object->{"patterns"}{"aliases"}{$alias_type}
Truth table100%2/2
A
A= $object->{"patterns"}{"aliases"}{$alias_type}
Aresult
11
00
191 # Alias hash for matching.
192 46 my $aliases = $object->{patterns}{aliases}{$alias_type};
193 46 $aliases->{$symbol->get_symbolname()} = $symbol;
194 } else {
195 # Otherwise assume this is a generic sequential pattern. This
196 # should be always safe.
197 33 push @{$object->{patterns}{generic}}, $symbol;
198 }
199 79 return 'pattern';
200 } else {
201 # Invalidate the minimum version cache.
202 14360 $object->{minver_cache} = [];
203 14360 $object->{syms}{$symbol->get_symbolname()} = $symbol;
204 14360 return 'sym';
205 }
206 }
207  
208 5248 ▶sub _new_symbol {
Subroutine _new_symbol: called CC=3 SCAR=11.0
209 5248 ▶ my $base = shift || 'Dpkg::Shlibs::Symbol';
Condition100%2/2
shift() || 'Dpkg::Shlibs::Symbol'
l!l
405208
MC/DC100%1/1
shift() || 'Dpkg::Shlibs::Symbol'
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
210 5248 ▶ return (ref $base) ? $base->clone(@_) : $base->new(@_);
Branch: 1 branch
BranchTrueFalseTotal
ref $base ? : 40 5208 5248
211 }
212  
213 # Option state is only used for recursive calls.
214 55 ▶sub parse {
Subroutine parse: called CC=17 SCAR=28.4
Pod documented
215 55 my ($self, $fh, $file, %opts) = @_;
216 55 ▶ my $state = $opts{state} //= {};
Condition100%2/2
$opts{"state"} //= {}
l!l
1837
MC/DC100%1/1
$opts{"state"} //= {}
$opts{"state"}
Truth table100%2/2
A
A= $opts{"state"}
Aresult
11
00
217  
218 55 ▶ if (exists $state->{seen}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $state->{'seen'}) { } 18 37 55
219 # Avoid include loops.
220 18 ▶ return if exists $state->{seen}{$file};
Branch: 1 branch
BranchTrueFalseTotal
if exists $state->{"seen"}{$file} 2 16 18
221 } else {
222 37 $self->{filename} = $file;
223 37 $state->{seen} = {};
224 }
225 53 $state->{seen}{$file} = 1;
226  
227 53 ▶ if (not ref $state->{obj_ref}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $state->{"obj_ref"}) 37 16 53
228 # Init ref to name of current object/lib.
229 37 ${$state->{obj_ref}} = undef;
230 }
231  
232 53 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 5333 53 5386
233 5333 chomp;
234  
235 5333 ▶ if (/^(?:\s+|#(?:DEPRECATED|MISSING): ([^#]+)#\s*)(.*)/) {
Branch: 6 branches
BranchTrueFalseTotal
if (/^(?:\s+|#(?:DEPRECATED|MISSING): ([^#]+)#\s*)(.*)/u) { } 5242 91 5333
elsif (/^(\(.*\))?#include\s+"([^"]+)"/u) { } 18 73 91
elsif (/^#|^$/u) { } 10 63 73
elsif (/^\|\s*(.*)$/u) { } 16 47 63
elsif (/^\*\s*([^:]+):\s*(.*\S)\s*$/u) { } 4 43 47
elsif (/^(\S+)\s+(.*)$/u) { } 43 0 43
236 5242 ▶ if (not defined ${$state->{obj_ref}}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined ${$$state{"obj_ref"};}) 0 5242 5242
237 0 error(g_('symbol information must be preceded by a header (file %s, line %s)'), $file, $.);
238 }
239 # Symbol specification.
240 5242 ▶ my $deprecated = ($1) ? Dpkg::Version->new($1) : 0;
Branch: 1 branch
BranchTrueFalseTotal
$1 ? : 44 5198 5242
241 5242 my $sym = _new_symbol($state->{base_symbol}, deprecated => $deprecated);
242 5242 ▶ if ($self->create_symbol($2, base => $sym)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->create_symbol($2, 'base', $sym)) { } 5242 0 5242
243 5242 $self->add_symbol($sym, ${$state->{obj_ref}});
244 } else {
245 0 warning(g_('cannot parse line in %s: %s'), $file, $_);
246 }
247 } elsif (/^(\(.*\))?#include\s+"([^"]+)"/) {
248 18 my $tagspec = $1;
249 18 my $filename = $2;
250 18 my $dir = $file;
251 18 my $old_base_symbol = $state->{base_symbol};
252 18 my $new_base_symbol;
253 18 ▶ if (defined $tagspec) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tagspec) 6 12 18
254 6 $new_base_symbol = _new_symbol($old_base_symbol);
255 6 $new_base_symbol->parse_tagspec($tagspec);
256 }
257 18 $state->{base_symbol} = $new_base_symbol;
258 # Strip filename.
259 18 $dir =~ s{[^/]+$}{};
260 18 $self->load("$dir$filename", %opts);
261 18 $state->{base_symbol} = $old_base_symbol;
262 } elsif (/^#|^$/) {
263 # Skip possible comments and empty lines.
264 } elsif (/^\|\s*(.*)$/) {
265 # Alternative dependency template.
266 16 push @{$self->{objects}{${$state->{obj_ref}}}{deps}}, "$1";
267 } elsif (/^\*\s*([^:]+):\s*(.*\S)\s*$/) {
268 # Add meta-fields.
269 4 $self->{objects}{${$state->{obj_ref}}}{fields}{field_capitalize($1)} = $2;
270 } elsif (/^(\S+)\s+(.*)$/) {
271 # New object and dependency template.
272 43 ${$state->{obj_ref}} = $1;
273 43 ▶ if (exists $self->{objects}{${$state->{obj_ref}}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'objects'}{${$state->{'obj_ref'};}}) { } 2 41 43
274 # Update/override infos only.
275 2 $self->{objects}{${$state->{obj_ref}}}{deps} = [ "$2" ];
276 } else {
277 # Create a new object.
278 41 $self->create_object(${$state->{obj_ref}}, "$2");
279 }
280 } else {
281 0 warning(g_('cannot parse line in %s: %s'), $file, $_);
282 }
283 }
284 53 delete $state->{seen}{$file};
285 }
286  
287 # Beware: we reuse the data structure of the provided symfile so make
288 # sure to not modify them after having called this function.
289 0 ▶sub merge_object_from_symfile {
Subroutine merge_object_from_symfile: not called CC=2 SCAR=17.9
Pod undocumented
290 0 my ($self, $src, $objid) = @_;
291 0 ▶ if (not $self->has_object($objid)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->has_object($objid)) { } 0 0 0
292 0 $self->{objects}{$objid} = $src->get_object($objid);
293 } else {
294 0 warning(g_('tried to merge the same object (%s) twice in a symfile'), $objid);
295 }
296 }
297  
298 54 ▶sub replace_metavars($self, $var, %opts)
Subroutine replace_metavars: called CC=4 SCAR=13.9
Pod undocumented
299 {
300 54 ▶ return if $opts{template_mode};
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"template_mode"} 6 48 54
301  
302 48 ▶ if (exists $opts{package}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opts{"package"}) 10 38 48
303 10 $var->$* =~ s/#PACKAGE#/$opts{package}/g;
304 }
305 48 ▶ if (exists $opts{version}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opts{"version"}) 4 44 48
306 4 $var->$* =~ s/#CURVER#/(= $opts{version})/g;
307 }
308 }
309  
310 32 ▶sub output {
Subroutine output: called CC=26 SCAR=34.6
Pod documented
311 32 my ($self, $fh, %opts) = @_;
312 32 ▶ $opts{template_mode} //= 0;
Condition100%2/2
$opts{"template_mode"} //= 0
l!l
428
MC/DC100%1/1
$opts{"template_mode"} //= 0
$opts{"template_mode"}
Truth table100%2/2
A
A= $opts{"template_mode"}
Aresult
11
00
313 32 ▶ $opts{with_deprecated} //= 1;
Condition50%1/2
$opts{"with_deprecated"} //= 1
l!l
032
MC/DC0%0/1
$opts{"with_deprecated"} //= 1
$opts{"with_deprecated"}
Truth table50%1/2
A
A= $opts{"with_deprecated"}
Aresult
11
00
314 32 ▶ $opts{with_pattern_matches} //= 0;
Condition50%1/2
$opts{"with_pattern_matches"} //= 0
l!l
032
MC/DC0%0/1
$opts{"with_pattern_matches"} //= 0
$opts{"with_pattern_matches"}
Truth table50%1/2
A
A= $opts{"with_pattern_matches"}
Aresult
11
00
315 32 my $res = '';
316 32 foreach my $soname (sort $self->get_sonames()) {
317 32 my @deps = $self->get_dependencies($soname);
318 32 my $dep_first = shift @deps;
319 32 $self->replace_metavars(\$dep_first, %opts);
320 32 ▶ print { $fh } "$soname $dep_first\n" if defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
if defined $fh 16 16 32
321 32 ▶ $res .= "$soname $dep_first\n" if defined wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if defined wantarray 16 16 32
322  
323 32 foreach my $dep_next (@deps) {
324 20 $self->replace_metavars(\$dep_next, %opts);
325 20 ▶ print { $fh } "| $dep_next\n" if defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
if defined $fh 12 8 20
326 20 ▶ $res .= "| $dep_next\n" if defined wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if defined wantarray 8 12 20
327 }
328 32 my $f = $self->{objects}{$soname}{fields};
329 32 foreach my $field (sort keys %{$f}) {
330 2 my $value = $f->{$field};
331 2 $self->replace_metavars(\$value, %opts);
332 2 ▶ print { $fh } "* $field: $value\n" if defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
if defined $fh 2 0 2
333 2 ▶ $res .= "* $field: $value\n" if defined wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if defined wantarray 0 2 2
334 }
335  
336 32 my @symbols;
337 32 ▶ if ($opts{template_mode}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{'template_mode'}) { } 4 28 32
338 # Exclude symbols matching a pattern, but include patterns
339 # themselves.
340 4 @symbols = grep { not $_->get_pattern() } $self->get_symbols($soname);
341 4 push @symbols, $self->get_patterns($soname);
342 } else {
343 28 @symbols = $self->get_symbols($soname);
344 }
345 32 foreach my $sym (sort { $a->get_symboltempl() cmp
346 $b->get_symboltempl() } @symbols) {
347 13986 ▶ next if $sym->{deprecated} and not $opts{with_deprecated};
Branch: 1 branch
BranchTrueFalseTotal
if $sym->{"deprecated"} and not $opts{"with_deprecated"} 0 13986 13986
Condition66%2/3
$sym->{"deprecated"} and not $opts{"with_deprecated"}
!ll&&!rl&&r
138541320
MC/DC0%0/2
$sym->{"deprecated"} and not $opts{"with_deprecated"}
$sym->{"deprecated"} not $opts{"with_deprecated"}
Truth table66%2/3
A and not(B)
A= $sym->{"deprecated"}B= not $opts{"with_deprecated"}
ABresult
0X0
100
111
348 # Do not dump symbols from foreign arch unless dumping a template.
349 next if not $opts{template_mode} and
350 13986 ▶ not $sym->arch_is_concerned($self->get_arch());
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"template_mode"} or $sym->arch_is_concerned($self->get_arch) 84 13902 13986
Condition100%3/3
$opts{"template_mode"} or $sym->arch_is_concerned($self->get_arch)
l!l&&r!l&&!r
1181378484
MC/DC100%2/2
$opts{"template_mode"} or $sym->arch_is_concerned($self->get_arch)
$opts{"template_mode"} $sym->arch_is_concerned($self->get_arch)
Truth table100%3/3
A or B
A= $opts{"template_mode"}B= $sym->arch_is_concerned($self->get_arch)
ABresult
1X1
011
000
351 # Dump symbol specification. Dump symbol tags only in template
352 # mode.
353 13902 ▶ print { $fh } $sym->get_symbolspec($opts{template_mode}), "\n" if defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
if defined $fh 4678 9224 13902
354 13902 ▶ $res .= $sym->get_symbolspec($opts{template_mode}) . "\n" if defined wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if defined wantarray 9224 4678 13902
355 # Dump pattern matches as comments (if requested).
356 13902 ▶ if ($opts{with_pattern_matches} && $sym->is_pattern()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"with_pattern_matches"} and $sym->is_pattern) 0 13902 13902
Condition33%1/3
$opts{"with_pattern_matches"} and $sym->is_pattern
!ll&&!rl&&r
1390200
MC/DC0%0/2
$opts{"with_pattern_matches"} and $sym->is_pattern
$opts{"with_pattern_matches"} $sym->is_pattern
Truth table33%1/3
A and B
A= $opts{"with_pattern_matches"}B= $sym->is_pattern
ABresult
0X0
100
111
357 0 for my $match (sort { $a->get_symboltempl() cmp
358 $b->get_symboltempl() } $sym->get_pattern_matches())
359 {
360 0 ▶ print { $fh } '#MATCH:', $match->get_symbolspec(0), "\n" if defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
if defined $fh 0 0 0
361 0 ▶ $res .= '#MATCH:' . $match->get_symbolspec(0) . "\n" if defined wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if defined wantarray 0 0 0
362 }
363 }
364 }
365 }
366 32 return $res;
367 }
368  
369 # Tries to match a symbol name and/or version against the patterns defined.
370 # Returns a pattern which matches (if any).
371 9632 ▶sub find_matching_pattern {
Subroutine find_matching_pattern: called CC=19 SCAR=31.5
Pod undocumented
372 9632 my ($self, $refsym, $sonames, $inc_deprecated) = @_;
373 9632 ▶ $inc_deprecated //= 0;
Condition50%1/2
$inc_deprecated //= 0
l!l
96320
MC/DC0%0/1
$inc_deprecated //= 0
$inc_deprecated
Truth table50%1/2
A
A= $inc_deprecated
Aresult
11
00
374 9632 ▶ my $name = (ref $refsym) ? $refsym->get_symbolname() : $refsym;
Branch: 1 branch
BranchTrueFalseTotal
ref $refsym ? : 436 9196 9632
375  
376 339 ▶ my $pattern_ok = sub {
Subroutine __ANON__: called CC=4 SCAR=18.9
377 339 my $p = shift;
378 339 ▶ return defined $p && ($inc_deprecated || ! $p->{deprecated}) &&
Condition33%3/9
defined $p && ($inc_deprecated || !$p->{'deprecated'}) && $p->arch_is_concerned($self->get_arch)
!ll&&!rl&&r
00339
defined $p and $inc_deprecated || !$p->{"deprecated"}
!ll&&!rl&&r
00339
$inc_deprecated or not $p->{"deprecated"}
l!l&&r!l&&!r
33900
MC/DC0%0/4
defined $p && ($inc_deprecated || !$p->{'deprecated'}) && $p->arch_is_concerned($self->get_arch)
defined $p $inc_deprecated not $p->{"deprecated"} $p->arch_is_concerned($self->get_arch)
Truth table16%1/6
A and B or not(C) && D
A= defined $pB= $inc_deprecatedC= not $p->{"deprecated"}D= $p->arch_is_concerned($self->get_arch)
ABCDresult
0XXX0
100X0
11X00
10100
11X11
10111
379 $p->arch_is_concerned($self->get_arch());
380 9632 };
381  
382 9632 ▶ foreach my $soname ((ref($sonames) eq 'ARRAY') ? @$sonames : $sonames) {
Branch: 1 branch
BranchTrueFalseTotal
ref $sonames eq 'ARRAY' ? : 0 9632 9632
383 9632 my $obj = $self->get_object($soname);
384 9632 my ($type, $pattern);
385 9632 ▶ next unless defined $obj;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $obj 0 9632 9632
386  
387 9632 my $all_aliases = $obj->{patterns}{aliases};
388 9632 for my $type (Dpkg::Shlibs::Symbol::ALIAS_TYPES) {
389 19223 ▶ if (exists $all_aliases->{$type} && keys(%{$all_aliases->{$type}})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $all_aliases->{$type} and keys %{$$all_aliases{$type};}) 545 18678 19223
Condition66%2/3
exists $all_aliases->{$type} and keys %{$$all_aliases{$type};}
!ll&&!rl&&r
186780545
MC/DC50%1/2
exists $all_aliases->{$type} and keys %{$$all_aliases{$type};}
exists $all_aliases->{$type} keys %{$$all_aliases{$type};}
Truth table66%2/3
A and B
A= exists $all_aliases->{$type}B= keys %{$$all_aliases{$type};}
ABresult
0X0
100
111
390 545 my $aliases = $all_aliases->{$type};
391 545 my $converter = $aliases->{(keys %$aliases)[0]};
392 545 ▶ if (my $alias = $converter->convert_to_alias($name)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $alias = $converter->convert_to_alias($name)) 544 0 544
393 544 ▶ if ($alias && exists $aliases->{$alias}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alias and exists $aliases->{$alias}) 72 472 544
Condition66%2/3
$alias and exists $aliases->{$alias}
!ll&&!rl&&r
047272
MC/DC50%1/2
$alias and exists $aliases->{$alias}
$alias exists $aliases->{$alias}
Truth table66%2/3
A and B
A= $aliasB= exists $aliases->{$alias}
ABresult
0X0
100
111
394 72 $pattern = $aliases->{$alias};
395 72 ▶ last if $pattern_ok->($pattern);
Branch: 1 branch
BranchTrueFalseTotal
if &$pattern_ok($pattern) 72 0 72
396 # Otherwise not found yet.
397 0 $pattern = undef;
398 }
399 }
400 }
401 }
402  
403 # Now try generic patterns and use the first that matches.
404 9631 ▶ if (not defined $pattern) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pattern) 9559 72 9631
405 9559 for my $p (@{$obj->{patterns}{generic}}) {
406 267 ▶ if ($pattern_ok->($p) && $p->matches_rawname($name)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$pattern_ok($p) and $p->matches_rawname($name)) 123 144 267
Condition66%2/3
&$pattern_ok($p) and $p->matches_rawname($name)
!ll&&!rl&&r
0144123
MC/DC50%1/2
&$pattern_ok($p) and $p->matches_rawname($name)
&$pattern_ok($p) $p->matches_rawname($name)
Truth table66%2/3
A and B
A= &$pattern_ok($p)B= $p->matches_rawname($name)
ABresult
0X0
100
111
407 123 $pattern = $p;
408 123 last;
409 }
410 }
411 }
412 9631 ▶ if (defined $pattern) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pattern) 195 9436 9631
413 195 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 195 195
414 return (
415 0 symbol => $pattern,
416 soname => $soname,
417 );
418 } else {
419 195 return $pattern;
420 }
421 }
422 }
423 9436 return;
424 }
425  
426 # merge_symbols($object, $minver)
427 #
428 # Needs $Objdump->get_object($soname) as parameter.
429 # Do not merge symbols found in the list of (arch-specific) internal symbols.
430 33 ▶sub merge_symbols {
Subroutine merge_symbols: called CC=16 SCAR=27.7
Pod undocumented
431 33 my ($self, $object, $minver) = @_;
432  
433 33 my $soname = $object->{SONAME};
434 33 ▶ error(g_('cannot merge symbols from objects without SONAME'))
Branch: 1 branch
BranchTrueFalseTotal
unless $soname 0 33 33
435 unless $soname;
436  
437 33 my %include_groups = ();
438 33 my $groups = $self->get_field($soname, 'Allow-Internal-Symbol-Groups');
439 33 ▶ if (defined $groups) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $groups) 2 31 33
440 2 $include_groups{$_} = 1 foreach (split ' ', $groups);
441 }
442  
443 33 my %dynsyms;
444 33 foreach my $sym ($object->get_exported_dynamic_symbols()) {
445 my $name = $sym->{name} . '@' .
446 18206 ▶ ($sym->{version} ? $sym->{version} : 'Base');
Branch: 1 branch
BranchTrueFalseTotal
$sym->{'version'} ? : 18206 0 18206
447 18206 my $symobj = $self->lookup_symbol($name, $soname);
448 18206 ▶ if (symbol_is_internal($sym->{name}, \%include_groups)) {
Branch: 1 branch
BranchTrueFalseTotal
if (symbol_is_internal($sym->{"name"}, \%include_groups)) 115 18091 18206
449 115 ▶ next unless defined $symobj;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $symobj 99 16 115
450  
451 16 ▶ if ($symobj->has_tag('allow-internal')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($symobj->has_tag('allow-internal')) { } 8 8 16
452 # Allow the symbol.
453 } else {
454 # Ignore the symbol.
455 8 next;
456 }
457 }
458 18099 $dynsyms{$name} = $sym;
459 }
460  
461 33 ▶ unless ($self->has_object($soname)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->has_object($soname)) 4 29 33
462 4 $self->create_object($soname, '');
463 }
464 # Scan all symbols provided by the objects.
465 33 my $obj = $self->get_object($soname);
466 # Invalidate the minimum version cache - it is not sufficient to
467 # invalidate in add_symbol(), since we might change a minimum version
468 # for a particular symbol without adding it.
469 33 $obj->{minver_cache} = [];
470 33 foreach my $name (keys %dynsyms) {
471 18027 my $sym;
472 18027 ▶ if ($sym = $self->lookup_symbol($name, $obj, 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sym = $self->lookup_symbol($name, $obj, 1)) { } 8831 9196 18027
473 # If the symbol is already listed in the file.
474 8831 $sym->mark_found_in_library($minver, $self->get_arch());
475 } else {
476 # The exact symbol is not present in the file, but it might match
477 # a pattern.
478 9196 my $pattern = $self->find_matching_pattern($name, $obj, 1);
479 9195 ▶ if (defined $pattern) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pattern) { } 195 9000 9195
480 195 $pattern->mark_found_in_library($minver, $self->get_arch());
481 195 $sym = $pattern->create_pattern_match(symbol => $name);
482 } else {
483 # Symbol without any special info as no pattern matched.
484 9000 $sym = Dpkg::Shlibs::Symbol->new(
485 symbol => $name,
486 minver => $minver,
487 );
488 }
489 9195 $self->add_symbol($sym, $obj);
490 }
491 }
492  
493 # Process all symbols which could not be found in the library.
494 32 foreach my $sym ($self->get_symbols($soname)) {
495 18191 ▶ if (not exists $dynsyms{$sym->get_symbolname()}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $dynsyms{$sym->get_symbolname}) 166 18025 18191
496 166 $sym->mark_not_found_in_library($minver, $self->get_arch());
497 }
498 }
499  
500 # Deprecate patterns which did not match anything.
501 32 for my $pattern (grep { $_->get_pattern_matches() == 0 }
502 $self->get_patterns($soname)) {
503 4 $pattern->mark_not_found_in_library($minver, $self->get_arch());
504 }
505 }
506  
507 0 ▶sub is_empty {
Subroutine is_empty: not called CC=2 SCAR=17.9
Pod undocumented
508 0 my $self = shift;
509 0 ▶ return scalar(keys %{$self->{objects}}) ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
scalar keys %{$$self{'objects'};} ? : 0 0 0
510 }
511  
512 56 ▶sub has_object {
Subroutine has_object: called CC=1 SCAR=0.0
Pod undocumented
513 56 my ($self, $soname) = @_;
514 56 return exists $self->{objects}{$soname};
515 }
516  
517 70017 ▶sub get_object {
Subroutine get_object: called CC=2 SCAR=6.9
Pod undocumented
518 70017 my ($self, $soname) = @_;
519 70017 ▶ return ref($soname) ? $soname : $self->{objects}{$soname};
Branch: 1 branch
BranchTrueFalseTotal
ref $soname ? : 36422 33595 70017
520 }
521  
522 45 ▶sub create_object {
Subroutine create_object: called CC=1 SCAR=0.0
Pod undocumented
523 45 my ($self, $soname, @deps) = @_;
524 45 $self->{objects}{$soname} = {
525 syms => {},
526 fields => {},
527 patterns => {
528 aliases => {},
529 generic => [],
530 },
531 deps => [ @deps ],
532 minver_cache => []
533 };
534 }
535  
536 0 ▶sub get_dependency {
Subroutine get_dependency: not called CC=2 SCAR=17.9
Pod undocumented
537 0 my ($self, $soname, $dep_id) = @_;
538 0 ▶ $dep_id //= 0;
Condition0%0/2
$dep_id //= 0
l!l
00
MC/DC0%0/1
$dep_id //= 0
$dep_id
Truth table0%0/2
A
A= $dep_id
Aresult
11
00
539 0 return $self->get_object($soname)->{deps}[$dep_id];
540 }
541  
542 4 ▶sub get_smallest_version {
Subroutine get_smallest_version: called CC=7 SCAR=19.6
Pod undocumented
543 4 my ($self, $soname, $dep_id) = @_;
544 4 ▶ $dep_id //= 0;
Condition50%1/2
$dep_id //= 0
l!l
04
MC/DC0%0/1
$dep_id //= 0
$dep_id
Truth table50%1/2
A
A= $dep_id
Aresult
11
00
545 4 my $so_object = $self->get_object($soname);
546 return $so_object->{minver_cache}[$dep_id]
547 4 ▶ if defined $so_object->{minver_cache}[$dep_id];
Branch: 1 branch
BranchTrueFalseTotal
if defined $so_object->{"minver_cache"}[$dep_id] 0 4 4
548 4 my $minver;
549 4 foreach my $sym ($self->get_symbols($so_object)) {
550 16 ▶ next if $dep_id != $sym->{dep_id};
Branch: 1 branch
BranchTrueFalseTotal
if $dep_id != $sym->{"dep_id"} 2 14 16
551 14 ▶ $minver //= $sym->{minver};
Condition66%2/3
$minver //= $sym->{"minver"}
l!l&&r!l&&!r
1040
MC/DC0%0/2
$minver //= $sym->{"minver"}
$minver $sym->{"minver"}
Truth table66%2/3
A //= B
A= $minverB= $sym->{"minver"}
ABresult
1X1
011
000
552 14 ▶ if (version_compare($minver, $sym->{minver}) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (&version_compare($minver, $sym->{"minver"}) > 0) 6 8 14
553 6 $minver = $sym->{minver};
554 }
555 }
556 4 $so_object->{minver_cache}[$dep_id] = $minver;
557 4 return $minver;
558 }
559  
560 32 ▶sub get_dependencies {
Subroutine get_dependencies: called CC=1 SCAR=0.0
Pod undocumented
561 32 my ($self, $soname) = @_;
562 32 return @{$self->get_object($soname)->{deps}};
563 }
564  
565 33 ▶sub get_field {
Subroutine get_field: called CC=3 SCAR=11.0
Pod undocumented
566 33 my ($self, $soname, $name) = @_;
567 33 ▶ if (my $obj = $self->get_object($soname)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $obj = $self->get_object($soname)) 29 4 33
568 29 ▶ if (exists $obj->{fields}{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $obj->{"fields"}{$name}) 2 27 29
569 2 return $obj->{fields}{$name};
570 }
571 }
572 31 return;
573 }
574  
575 # Tries to find a symbol like the $refsym and returns its descriptor.
576 # $refsym may also be a symbol name.
577 45607 ▶sub lookup_symbol {
Subroutine lookup_symbol: called CC=10 SCAR=23.0
Pod undocumented
578 45607 my ($self, $refsym, $sonames, $inc_deprecated) = @_;
579 45607 ▶ $inc_deprecated //= 0;
Condition100%2/2
$inc_deprecated //= 0
l!l
2734418263
MC/DC100%1/1
$inc_deprecated //= 0
$inc_deprecated
Truth table100%2/2
A
A= $inc_deprecated
Aresult
11
00
580 45607 ▶ my $name = (ref $refsym) ? $refsym->get_symbolname() : $refsym;
Branch: 1 branch
BranchTrueFalseTotal
ref $refsym ? : 9302 36305 45607
581  
582 45607 ▶ foreach my $so ((ref($sonames) eq 'ARRAY') ? @$sonames : $sonames) {
Branch: 1 branch
BranchTrueFalseTotal
ref $sonames eq 'ARRAY' ? : 0 45607 45607
583 45607 ▶ if (my $obj = $self->get_object($so)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $obj = $self->get_object($so)) 37027 8580 45607
584 37027 my $sym = $obj->{syms}{$name};
585 37027 ▶ if ($sym and ($inc_deprecated or not $sym->{deprecated}))
Branch: 1 branch
BranchTrueFalseTotal
if ($sym and $inc_deprecated || !$sym->{"deprecated"}) 26594 10433 37027
Condition100%6/6
$sym and $inc_deprecated || !$sym->{"deprecated"}
!ll&&!rl&&r
10425826594
$inc_deprecated or not $sym->{"deprecated"}
l!l&&r!l&&!r
1767089248
MC/DC100%3/3
$sym and $inc_deprecated || !$sym->{"deprecated"}
$sym $inc_deprecated not $sym->{"deprecated"}
Truth table100%4/4
A and B or not(C)
A= $symB= $inc_deprecatedC= not $sym->{"deprecated"}
ABCresult
0XX0
1000
11X1
1011
586 {
587 26594 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 2 26592 26594
588 return (
589 2 symbol => $sym,
590 soname => $so,
591 );
592 } else {
593 26592 return $sym;
594 }
595 }
596 }
597 }
598 19013 return;
599 }
600  
601 # Tries to find a pattern like the $refpat and returns its descriptor.
602 # $refpat may also be a pattern spec.
603 88 ▶sub lookup_pattern {
Subroutine lookup_pattern: called CC=19 SCAR=30.4
Pod undocumented
604 88 my ($self, $refpat, $sonames, $inc_deprecated) = @_;
605 88 ▶ $inc_deprecated //= 0;
Condition100%2/2
$inc_deprecated //= 0
l!l
808
MC/DC100%1/1
$inc_deprecated //= 0
$inc_deprecated
Truth table100%2/2
A
A= $inc_deprecated
Aresult
11
00
606 # If $refsym is a string, we need to create a dummy ref symbol.
607 88 ▶ $refpat = $self->create_symbol($refpat, dummy => 1) if ! ref($refpat);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $refpat 1 87 88
608  
609 88 ▶ if ($refpat && $refpat->is_pattern()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($refpat and $refpat->is_pattern) 88 0 88
Condition33%1/3
$refpat and $refpat->is_pattern
!ll&&!rl&&r
0088
MC/DC0%0/2
$refpat and $refpat->is_pattern
$refpat $refpat->is_pattern
Truth table33%1/3
A and B
A= $refpatB= $refpat->is_pattern
ABresult
0X0
100
111
610 88 ▶ foreach my $soname ((ref($sonames) eq 'ARRAY') ? @$sonames : $sonames) {
Branch: 1 branch
BranchTrueFalseTotal
ref $sonames eq 'ARRAY' ? : 0 88 88
611 88 ▶ if (my $obj = $self->get_object($soname)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $obj = $self->get_object($soname)) 88 0 88
612 88 my $pat;
613 88 ▶ if (my $type = $refpat->get_alias_type()) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $type = $refpat->get_alias_type) { } 41 47 88
elsif ($refpat->get_pattern_type eq 'generic') { } 47 0 47
614 41 ▶ if (exists $obj->{patterns}{aliases}{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $obj->{"patterns"}{"aliases"}{$type}) 41 0 41
615 41 $pat = $obj->{patterns}{aliases}{$type}{$refpat->get_symbolname()};
616 }
617 } elsif ($refpat->get_pattern_type() eq 'generic') {
618 47 for my $p (@{$obj->{patterns}{generic}}) {
619 120 ▶ if (($inc_deprecated || ! $p->{deprecated}) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($inc_deprecated || !$p->{"deprecated"} and $p->equals($refpat, "versioning", 0)) 47 73 120
Condition100%6/6
$inc_deprecated || !$p->{"deprecated"} and $p->equals($refpat, "versioning", 0)
!ll&&!rl&&r
56847
$inc_deprecated or not $p->{"deprecated"}
l!l&&r!l&&!r
77385
MC/DC100%3/3
$inc_deprecated || !$p->{"deprecated"} and $p->equals($refpat, "versioning", 0)
$inc_deprecated not $p->{"deprecated"} $p->equals($refpat, "versioning", 0)
Truth table100%5/5
A or not(B) and C
A= $inc_deprecatedB= not $p->{"deprecated"}C= $p->equals($refpat, "versioning", 0)
ABCresult
00X0
1X00
0100
1X11
0111
620 $p->equals($refpat, versioning => 0))
621 {
622 47 $pat = $p;
623 47 last;
624 }
625 }
626 }
627 88 ▶ if ($pat && ($inc_deprecated || ! $pat->{deprecated})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pat and $inc_deprecated || !$pat->{"deprecated"}) 86 2 88
Condition83%5/6
$pat and $inc_deprecated || !$pat->{"deprecated"}
!ll&&!rl&&r
0286
$inc_deprecated or not $pat->{"deprecated"}
l!l&&r!l&&!r
45412
MC/DC66%2/3
$pat and $inc_deprecated || !$pat->{"deprecated"}
$pat $inc_deprecated not $pat->{"deprecated"}
Truth table75%3/4
A and B or not(C)
A= $patB= $inc_deprecatedC= not $pat->{"deprecated"}
ABCresult
0XX0
1000
11X1
1011
628 86 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 86 86
629 return (
630 0 symbol => $pat,
631 soname => $soname,
632 );
633 } else {
634 86 return $pat;
635 }
636 }
637 }
638 }
639 }
640 2 return;
641 }
642  
643 # Get symbol object reference either by symbol name or by a reference object.
644 0 ▶sub get_symbol_object {
Subroutine get_symbol_object: not called CC=2 SCAR=17.9
Pod undocumented
645 0 my ($self, $refsym, $soname) = @_;
646 0 my $sym = $self->lookup_symbol($refsym, $soname, 1);
647 0 ▶ if (! defined $sym) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $sym) 0 0 0
648 0 $sym = $self->lookup_pattern($refsym, $soname, 1);
649 }
650 0 return $sym;
651 }
652  
653 21 ▶sub get_new_symbols {
Subroutine get_new_symbols: called CC=16 SCAR=28.4
Pod undocumented
654 21 my ($self, $ref, %opts) = @_;
655 my $with_optional = (exists $opts{with_optional}) ?
656 21 ▶ $opts{with_optional} : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $opts{'with_optional'} ? : 0 21 21
657 21 my @res;
658 21 foreach my $soname ($self->get_sonames()) {
659 21 ▶ next if not $ref->has_object($soname);
Branch: 1 branch
BranchTrueFalseTotal
unless $ref->has_object($soname) 0 21 21
660  
661 # Scan raw symbols first.
662 21 ▶ foreach my $sym (grep { ($with_optional || ! $_->is_optional())
Condition83%5/6
($with_optional || !$_->is_optional) && $_->is_legitimate($self->get_arch)
!ll&&!rl&&r
581269301
$with_optional or not $_->is_optional
l!l&&r!l&&!r
0942758
MC/DC66%2/3
($with_optional || !$_->is_optional) && $_->is_legitimate($self->get_arch)
$with_optional not $_->is_optional $_->is_legitimate($self->get_arch)
Truth table60%3/5
A or not(B) && C
A= $with_optionalB= not $_->is_optionalC= $_->is_legitimate($self->get_arch)
ABCresult
00X0
1X00
0100
1X11
0111
663 && $_->is_legitimate($self->get_arch()) }
664 $self->get_symbols($soname))
665 {
666 9301 my $refsym = $ref->lookup_symbol($sym, $soname, 1);
667 9301 my $isnew;
668 9301 ▶ if (defined $refsym) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $refsym) { } 8823 478 9301
669 # If the symbol exists in the $ref symbol file, it might
670 # still be new if $refsym is not legitimate.
671 8823 $isnew = not $refsym->is_legitimate($self->get_arch());
672 } else {
673 # If the symbol does not exist in the $ref symbol file, it does
674 # not mean that it is new. It might still match a pattern in the
675 # symbol file. However, due to performance reasons, first check
676 # if the pattern that the symbol matches (if any) exists in the
677 # ref symbol file as well.
678 478 ▶ $isnew = not (
Condition66%4/6
$sym->get_pattern && $ref->lookup_pattern($sym->get_pattern, $soname, 1) || $ref->find_matching_pattern($sym, $soname, 1)
l!l&&r!l&&!r
420436
$sym->get_pattern and $ref->lookup_pattern($sym->get_pattern, $soname, 1)
!ll&&!rl&&r
436042
MC/DC33%1/3
$sym->get_pattern && $ref->lookup_pattern($sym->get_pattern, $soname, 1) || $ref->find_matching_pattern($sym, $soname, 1)
$sym->get_pattern $ref->lookup_pattern($sym->get_pattern, $soname, 1) $ref->find_matching_pattern($sym, $soname, 1)
Truth table40%2/5
A and B || C
A= $sym->get_patternB= $ref->lookup_pattern($sym->get_pattern, $soname, 1)C= $ref->find_matching_pattern($sym, $soname, 1)
ABCresult
11X1
0X11
1011
0X00
1000
679 ($sym->get_pattern() and $ref->lookup_pattern($sym->get_pattern(), $soname, 1)) or
680 $ref->find_matching_pattern($sym, $soname, 1)
681 );
682 }
683 9301 ▶ push @res, { symbol => $sym, soname => $soname } if $isnew;
Branch: 1 branch
BranchTrueFalseTotal
if $isnew 446 8855 9301
684 }
685  
686 # Now scan patterns.
687 21 ▶ foreach my $p (grep { ($with_optional || ! $_->is_optional())
Condition66%4/6
($with_optional || !$_->is_optional) && $_->is_legitimate($self->get_arch)
!ll&&!rl&&r
14035
$with_optional or not $_->is_optional
l!l&&r!l&&!r
03514
MC/DC33%1/3
($with_optional || !$_->is_optional) && $_->is_legitimate($self->get_arch)
$with_optional not $_->is_optional $_->is_legitimate($self->get_arch)
Truth table40%2/5
A or not(B) && C
A= $with_optionalB= not $_->is_optionalC= $_->is_legitimate($self->get_arch)
ABCresult
00X0
1X00
0100
1X11
0111
688 && $_->is_legitimate($self->get_arch()) }
689 $self->get_patterns($soname))
690 {
691 35 my $refpat = $ref->lookup_pattern($p, $soname, 0);
692 # If reference pattern was not found or it is not legitimate,
693 # considering current one as new.
694 35 ▶ if (not defined $refpat or
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $refpat and $refpat->is_legitimate($self->get_arch)) 2 33 35
Condition66%2/3
defined $refpat and $refpat->is_legitimate($self->get_arch)
!ll&&!rl&&r
2033
MC/DC50%1/2
defined $refpat and $refpat->is_legitimate($self->get_arch)
defined $refpat $refpat->is_legitimate($self->get_arch)
Truth table66%2/3
A and B
A= defined $refpatB= $refpat->is_legitimate($self->get_arch)
ABresult
0X0
100
111
695 not $refpat->is_legitimate($self->get_arch()))
696 {
697 2 push @res, { symbol => $p , soname => $soname };
698 }
699 }
700 }
701 21 return @res;
702 }
703  
704 13 ▶sub get_lost_symbols {
Subroutine get_lost_symbols: called CC=1 SCAR=0.0
Pod undocumented
705 13 my ($self, $ref, %opts) = @_;
706 13 return $ref->get_new_symbols($self, %opts);
707 }
708  
709  
710 0 ▶sub get_new_libs {
Subroutine get_new_libs: not called CC=3 SCAR=24.8
Pod undocumented
711 0 my ($self, $ref) = @_;
712 0 my @res;
713 0 foreach my $soname ($self->get_sonames()) {
714 0 ▶ push @res, $soname if not $ref->get_object($soname);
Branch: 1 branch
BranchTrueFalseTotal
unless $ref->get_object($soname) 0 0 0
715 }
716 0 return @res;
717 }
718  
719 0 ▶sub get_lost_libs {
Subroutine get_lost_libs: not called CC=1 SCAR=6.9
Pod undocumented
720 0 my ($self, $ref) = @_;
721 0 return $ref->get_new_libs($self);
722 }
723  
724 =head1 CHANGES
725  
726 =head2 Version 0.xx
727  
728 This is a private module.
729  
730 =cut
731  
732 2 1;
« Dpkg/Shlibs.pm ↑ Summary Dpkg/Deps/KnownFacts.pm »