[SCM] Debian Qt/KDE packaging tools branch, improved-gensymbols, updated. debian/0.5.3-18-g5eadb2d
Modestas Vainius
modax at alioth.debian.org
Sun Jan 10 16:09:38 UTC 2010
The following commit has been merged in the improved-gensymbols branch:
commit 5eadb2d26cd9d9567ac9ba9810790a8f31c74e1d
Author: Modestas Vainius <modestas at vainius.eu>
Date: Sun Jan 10 16:23:28 2010 +0200
Update to the latest version.
---
symbolshelper/Dpkg/Shlibs/Cppfilt.pm | 11 ++--
symbolshelper/Dpkg/Shlibs/Symbol.pm | 107 ++++++++++++++++--------------
symbolshelper/Dpkg/Shlibs/SymbolFile.pm | 15 ++---
symbolshelper/dpkg-gensymbols.1 | 90 +++++++++++++++-----------
4 files changed, 118 insertions(+), 105 deletions(-)
diff --git a/symbolshelper/Dpkg/Shlibs/Cppfilt.pm b/symbolshelper/Dpkg/Shlibs/Cppfilt.pm
index cc6a0a1..c2cfdae 100644
--- a/symbolshelper/Dpkg/Shlibs/Cppfilt.pm
+++ b/symbolshelper/Dpkg/Shlibs/Cppfilt.pm
@@ -41,10 +41,10 @@ sub get_cppfilt {
$filt = { from => undef, to => undef,
last_symbol => "", last_result => "" };
$filt->{pid} = fork_and_exec(exec => [ 'c++filt',
- '--no-verbose',
- "--format=$type" ],
- from_pipe => \$filt->{from},
- to_pipe => \$filt->{to});
+ '--no-verbose',
+ "--format=$type" ],
+ from_pipe => \$filt->{from},
+ to_pipe => \$filt->{to});
internerr(_g("unable to execute c++filt")) unless defined $filt->{from};
$filt->{from}->autoflush(1);
@@ -58,8 +58,7 @@ sub get_cppfilt {
# intact. If neither whole $symbol nor portion of it could be demangled, undef
# is returned.
sub cppfilt_demangle {
- my $symbol = shift;
- my $type = shift;
+ my ($symbol, $type) = @_;
# Start or get c++filt 'object' for the requested type.
my $filt = get_cppfilt($type);
diff --git a/symbolshelper/Dpkg/Shlibs/Symbol.pm b/symbolshelper/Dpkg/Shlibs/Symbol.pm
index 2dcedc3..5ae47b8 100644
--- a/symbolshelper/Dpkg/Shlibs/Symbol.pm
+++ b/symbolshelper/Dpkg/Shlibs/Symbol.pm
@@ -25,6 +25,9 @@ use Dpkg::Version;
use Storable qw();
use Dpkg::Shlibs::Cppfilt;
+# Supported alias types in the order of matching preference
+use constant 'ALIAS_TYPES' => qw(c++ symver);
+
sub new {
my $this = shift;
my $class = ref($this) || $this;
@@ -146,26 +149,43 @@ sub initialize {
# Look for tags marking symbol patterns. The pattern may match multiple
# real symbols.
+ my $type;
if ($self->has_tag('c++')) {
# Raw symbol name is always demangled to the same alias while demangled
# symbol name cannot be reliably converted back to raw symbol name.
# Therefore, we can use hash for mapping.
- $self->init_pattern('alias-c++'); # Alias subtype is c++.
+ $type = 'alias-c++';
+ }
+
+ if ($self->has_tag('symver')) {
+ # Each symbol is matched against its version rather than full
+ # name at version string.
+ $type = (defined $type) ? 'generic' : 'alias-symver';
}
- # Wildcard is an alias based pattern. It gets recognized here even if it is
- # not specially tagged.
- if (my $ver = $self->get_wildcard_version()) {
- error(_g("you can't use wildcards on unversioned symbols: %s"), $_) if $ver eq "Base";
- $self->init_pattern(($self->is_pattern()) ? 'generic' : 'alias-wildcard');
- $self->{pattern}{wildcard} = 1;
+ # Support old style wildcard syntax as well. That's basically a symver
+ # with implicit optional tag.
+ if ($self->get_symbolname() =~ /^\*@(.*)$/) {
+ error(_g("you can't use wildcards on unversioned symbols: %s"), $_) if $1 eq "Base";
+ # symver pattern needs symbol name to be its version. However, keeping
+ # dumping this as old style wildcard in the output.
+ unless (defined $self->{symbol_templ}) {
+ $self->{symbol_templ} = $self->get_symbolname();
+ }
+ $type = (defined $type) ? 'generic' : 'alias-symver';
+ $self->{symbol} = $1;
+ $self->{pattern}{old_wildcard} = 1;
}
- # As soon as regexp is involved, we need to match each real
+
+ # As soon as regex is involved, we need to match each real
# symbol against each pattern (aka 'generic' pattern).
- if ($self->has_tag('regexp')) {
- $self->init_pattern('generic');
+ if ($self->has_tag('regex')) {
+ $type = 'generic';
# Pre-compile regular expression for better performance.
- my $regexp = $self->get_symbolname();
- $self->{pattern}{regexp} = qr/$regexp/;
+ my $regex = $self->get_symbolname();
+ $self->{pattern}{regex} = qr/$regex/;
+ }
+ if (defined $type) {
+ $self->init_pattern($type);
}
}
@@ -190,14 +210,6 @@ sub set_symbolname {
}
}
-sub get_wildcard_version {
- my $self = shift;
- if ($self->get_symbolname() =~ /^\*@(.*)$/) {
- return $1;
- }
- return undef;
-}
-
sub has_tags {
my $self = shift;
return scalar (@{$self->{tagorder}});
@@ -241,7 +253,7 @@ sub equals {
# Compare names and tag sets
return 0 if $self->{symbol} ne $other->{symbol};
- return 0 if scalar(@{$self->{tagorder}}) != scalar(@{$self->{tagorder}});
+ return 0 if scalar(@{$self->{tagorder}}) != scalar(@{$other->{tagorder}});
for (my $i = 0; $i < scalar(@{$self->{tagorder}}); $i++) {
my $tag = $self->{tagorder}->[$i];
@@ -258,7 +270,8 @@ sub equals {
sub is_optional {
my $self = shift;
- return $self->has_tag("optional");
+ return $self->has_tag("optional") ||
+ (exists $self->{pattern} && exists $self->{pattern}{old_wildcard});
}
sub is_arch_specific {
@@ -290,8 +303,7 @@ sub get_pattern {
# Initialises this symbol as a pattern of the specified type.
sub init_pattern {
- my $self = shift;
- my $type = shift;
+ my ($self, $type) = @_;
$self->{pattern}{type} = $type;
# To be filled with references to symbols matching this pattern.
@@ -346,16 +358,16 @@ sub create_pattern_match {
# the current pattern ($self). Returns undef if the supplied raw name is not
# transformable to alias.
sub convert_to_alias {
- my $self = shift;
- my $rawname = shift;
- my $type = shift || $self->get_alias_type();
+ my ($self, $rawname, $type) = @_;
+ $type = $self->get_alias_type() unless $type;
+
if ($type) {
- if ($type eq 'wildcard') {
- # In case of wildcard, alias is like "*@SYMBOL_VERSION". Extract
- # symbol version from the rawname.
- return "*\@$1" if ($rawname =~ /\@([^@]+)$/);
+ if ($type eq 'symver') {
+ # In case of symver, alias is symbol version. Extract it from the
+ # rawname.
+ return "$1" if ($rawname =~ /\@([^@]+)$/);
} elsif ($rawname =~ /^_Z/ && $type eq "c++") {
- return cppfilt_demangle($rawname, "gnu-v3");
+ return cppfilt_demangle($rawname, "auto");
}
}
return undef;
@@ -384,9 +396,13 @@ sub get_symbolspec {
my $spec = "";
$spec .= "#MISSING: $self->{deprecated}#" if $self->{deprecated};
$spec .= " ";
- if ($template_mode && $self->has_tags()) {
- $spec .= sprintf('%s%3$s%s%3$s', $self->get_tagspec(),
- $self->get_symboltempl(), $self->{symbol_quoted} || "");
+ if ($template_mode) {
+ if ($self->has_tags()) {
+ $spec .= sprintf('%s%3$s%s%3$s', $self->get_tagspec(),
+ $self->get_symboltempl(), $self->{symbol_quoted} || "");
+ } else {
+ $spec .= $self->get_symboltempl();
+ }
} else {
$spec .= $self->get_symbolname();
}
@@ -451,9 +467,7 @@ sub is_eligible_as_new {
# Determine whether a supplied raw symbol name matches against current ($self)
# symbol or pattern.
sub matches_rawname {
- my $self = shift;
- my $rawname = shift;
-
+ my ($self, $rawname) = @_;
my $target = $rawname;
my $ok = 1;
my $do_eq_match = 1;
@@ -461,22 +475,15 @@ sub matches_rawname {
if ($self->is_pattern()) {
# Process pattern tags in the order they were specified.
for my $tag (@{$self->{tagorder}}) {
- if ($tag eq "c++") {
- # Demangle it.
- $ok = not not ($target = $self->convert_to_alias($target, "c++"));
- } elsif ($tag eq "regexp") {
- # Symbol name is a regexp. Match it against the target
+ if (grep { $tag eq $_ } ALIAS_TYPES) {
+ $ok = not not ($target = $self->convert_to_alias($target, $tag));
+ } elsif ($tag eq "regex") {
+ # Symbol name is a regex. Match it against the target
$do_eq_match = 0;
- $ok = ($target =~ $self->{pattern}{regexp});
+ $ok = ($target =~ $self->{pattern}{regex});
}
last if not $ok;
}
- if ($ok) {
- # Wildcards are checked last
- if ($self->{pattern}{wildcard}) {
- $target = $self->convert_to_alias($target, "wildcard");
- }
- }
}
# Equality match by default
diff --git a/symbolshelper/Dpkg/Shlibs/SymbolFile.pm b/symbolshelper/Dpkg/Shlibs/SymbolFile.pm
index 0e3153d..2105ffe 100644
--- a/symbolshelper/Dpkg/Shlibs/SymbolFile.pm
+++ b/symbolshelper/Dpkg/Shlibs/SymbolFile.pm
@@ -25,10 +25,6 @@ use Dpkg::Control::Fields;
use Dpkg::Shlibs::Symbol;
use Dpkg::Arch qw(get_host_arch);
-# Supported alias types in the order of matching preference
-# See: find_matching_pattern().
-use constant 'ALIAS_TYPES' => qw(c++ wildcard);
-
my %blacklist = (
'__bss_end__' => 1, # arm
'__bss_end' => 1, # arm
@@ -108,9 +104,8 @@ sub clear_except {
# Create a symbol from the supplied string specification.
sub create_symbol {
- my $self = shift;
- my $spec = shift;
- my $symbol = shift || Dpkg::Shlibs::Symbol->new();
+ my ($self, $spec, $symbol) = @_;
+ $symbol = Dpkg::Shlibs::Symbol->new() unless defined $symbol;
if ($symbol->parse($spec)) {
$symbol->initialize(arch => $self->{arch});
@@ -287,6 +282,8 @@ sub dump {
# Do not dump symbols from foreign arch unless dumping a template.
next if not $opts{template_mode} and
not $sym->arch_is_concerned($self->{arch});
+ # Dump symbol specification. Dump symbol tags only in template mode.
+ print $fh $sym->get_symbolspec($opts{template_mode}), "\n";
# Dump pattern matches as comments (if requested)
if ($opts{with_pattern_matches} && $sym->is_pattern()) {
for my $match (sort { $a->get_symboltempl() cmp
@@ -295,8 +292,6 @@ sub dump {
print $fh "#MATCH:", $match->get_symbolspec(0), "\n";
}
}
- # Dump symbol specification. Dump symbol tags only in template mode.
- print $fh $sym->get_symbolspec($opts{template_mode}), "\n";
}
}
}
@@ -319,7 +314,7 @@ sub find_matching_pattern {
next unless defined $obj;
my $all_aliases = $obj->{patterns}{aliases};
- for my $type (ALIAS_TYPES) {
+ for my $type (Dpkg::Shlibs::Symbol::ALIAS_TYPES) {
if (exists $all_aliases->{$type}) {
my $aliases = $all_aliases->{$type};
if (my $alias = $aliases->{converter}->convert_to_alias($name)) {
diff --git a/symbolshelper/dpkg-gensymbols.1 b/symbolshelper/dpkg-gensymbols.1
index 0287ffa..43ed70f 100644
--- a/symbolshelper/dpkg-gensymbols.1
+++ b/symbolshelper/dpkg-gensymbols.1
@@ -162,8 +162,12 @@ some low level toolchain libraries like libgcc.
Denotes \fIc++\fR symbol pattern. See \fBUsing symbol patterns\fR subsection
below.
.TP
-.B regexp
-Denotes \fIregexp\fR symbol pattern. See \fBUsing symbol patterns\fR subsection
+.B symver
+Denotes \fIsymver\fR (symbol version) symbol pattern. See \fBUsing symbol
+patterns\fR subsection below.
+.TP
+.B regex
+Denotes \fIregex\fR symbol pattern. See \fBUsing symbol patterns\fR subsection
below.
.SS Using symbol patterns
.P
@@ -172,9 +176,15 @@ symbols from the library. \fBdpkg-gensymbols\fR will attempt to match each
pattern against each real symbol that does \fInot\fR have a specific symbol
counterpart defined in the symbol file. Whenever the first matching pattern is
found, all its tags and properties will be used as a basis specification of the
-symbol. If neither pattern matches, the symbol will be considered as MISSING.
-Please also note that patterns are in the same way affected by \fIoptional\fR,
-\fIarch\fR and other standard tags whenever possible.
+symbol. If neither pattern matches, the symbol will be considered as new.
+
+A pattern is considered lost if it does not match any symbol in the library. By
+default this will trigger a \fBdpkg-gensymbols\fR failure under \fI-c1\fR or
+higher level. However, if the failure is undesired, the pattern may be marked
+with the \fIoptional\fR tag. Then if the pattern does not match anything, it
+will only appear in the diff as MISSING. Moreover, like any symbol, the patten
+may be limited to the specific architectures with the \fIarch\fR tag. Please
+refer to \fBStandard symbol tags\fR subsection above for more information.
Patterns are an extension of the \fIdeb\-symbols(5)\fR format hence they are
only valid in symbol file templates. Pattern specification syntax is not any
@@ -183,7 +193,7 @@ specification serves as an expression to be matched against \fIname at version\fR
of the real symbol. In order to distinguish among different pattern types, a
pattern will typically be tagged with a special tag.
-At the moment, \fBdpkg\-gensymbols\fR supports three atomic pattern types:
+At the moment, \fBdpkg\-gensymbols\fR supports three basic pattern types:
.TP 3
.B c++
This pattern is denoted by the \fIc++\fR tag. It matches only C++ symbols by
@@ -216,30 +226,33 @@ for them). However, as these collisions happen on the ABI level, they should
not degrade quality of the symbol file.
.RE
.TP
-.B wildcards
-Wildcard patterns are denoted by the string of the form \fI*@version\fR in the
-symbol name field, e.g. "*@GLIBC_2.0". Well maintained libraries have
+.B symver
+This pattern is denoted by the \fIsymver\fR tag. Well maintained libraries have
versioned symbols where each version corresponds to the upstream version where
-the symbol got added. If that's the case, you can use wildcard patterns to
-match any symbol associated to the specific version. So "*@GLIBC_2.0" would
-match all symbols associated to the version GLIBC_2.0. For example:
+the symbol got added. If that's the case, you can use a \fIsymver\fR pattern to
+match any symbol associated to the specific version. For example:
.RS
.PP
libc.so.6 libc6 #MINVER#
- *@GLIBC_2.0 2.0
+ (symver)GLIBC_2.0 2.0
[...]
- *@GLIBC_2.7 2.7
+ (symver)GLIBC_2.7 2.7
access at GLIBC_2.0 2.2
.PP
All symbols associated with versions GLIBC_2.0 and GLIBC_2.7 will lead to
minimal version of 2.0 and 2.7 respectively with the exception of the symbol
access at GLIBC_2.0. The latter will lead to a minimal dependency on libc6 version
-2.2 despite being in the scope of the wildcard "*@GLIBC_2.0" because specific
-symbols take precedence over patterns.
+2.2 despite being in the scope of the "(symver)GLIBC_2.0" pattern because
+specific symbols take precedence over patterns.
+.P
+Please note that while old style wildcard patterns (denoted by "*@version" in
+the symbol name field) are still supported, they have been deprecated by new
+style syntax "(symver|optional)version". For example, "*@GLIBC_2.0 2.0" should
+be written as "(symver|optional)GLIBC_2.0 2.0" if the same behaviour is needed.
.RE
.TP
-.B regexp
-Regular expression patterns are denoted by the \fIregexp\fR tag. They match by
+.B regex
+Regular expression patterns are denoted by the \fIregex\fR tag. They match by
the perl regular expression specified in the symbol name field. A regular
expression is matched as it is, therefore do not forget to start it with the
\fI^\fR character or it may match any part of the real symbol
@@ -247,8 +260,8 @@ expression is matched as it is, therefore do not forget to start it with the
.RS
.PP
libdummy.so.1 libdummy1 #MINVER#
- (regexp)"^mystack_.*@Base$" 1.0
- (regexp|optional)"private" 1.0
+ (regex)"^mystack_.*@Base$" 1.0
+ (regex|optional)"private" 1.0
.P
Symbols like "mystack_new at Base", "mystack_push at Base", "mystack_pop at Base" etc.
will be matched by the first pattern while e.g. "ng_mystack_new at Base" won't.
@@ -256,35 +269,34 @@ The second pattern will match all symbols having the string "private" in their
names and matches will inherit \fIoptional\fR tag from the pattern.
.RE
.P
-Atomic patterns listed above can be combined where it makes sense. In that
-case, they are processed in the order in which the tags are specified. Since
-wildcard pattern does not have a specific tag, it is processed last if the
-symbol specification looks like a wildcard. For example, both
+Basic patterns listed above can be combined where it makes sense. In that case,
+they are processed in the order in which the tags are specified. For example,
+both
.PP
- (c++|regexp)"^NSA::ClassA::Private::privmethod\\d\\(int\\)@Base" 1.0
- (regexp|c++)N3NSA6ClassA7Private11privmethod\\dEi at Base 1.0
+ (c++|regex)"^NSA::ClassA::Private::privmethod\\d\\(int\\)@Base" 1.0
+ (regex|c++)N3NSA6ClassA7Private11privmethod\\dEi at Base 1.0
.P
will match symbols "_ZN3NSA6ClassA7Private11privmethod1Ei at Base" and
"_ZN3NSA6ClassA7Private11privmethod2Ei at Base". When matching the first pattern,
-the raw symbol is first demangled as c++ symbol, then the demangled name is
+the raw symbol is first demangled as C++ symbol, then the demangled name is
matched against the regular expression. On the other hand, when matching the
second pattern, regular expression is matched against the raw symbol name, then
-the symbol is tested if it is c++ one by attempting to demangle it. A failure
-of any atomic pattern will result in the failure of the whole pattern.
+the symbol is tested if it is C++ one by attempting to demangle it. A failure
+of any basic pattern will result in the failure of the whole pattern.
Therefore, for example, "__N3NSA6ClassA7Private11privmethod\\dEi at Base" will not
-match either of the patterns because it is not a valid c++ symbol.
+match either of the patterns because it is not a valid C++ symbol.
.P
-In general, all patterns are divided into two groups: aliases (atomic c++ and
-wildcards) and generic patterns (regexp, all combinations of multiple atomic
-patterns). Matching of atomic alias-based patterns is fast (O(1)) while
-generic patterns are O(N) (N - generic pattern count) for each symbol.
+In general, all patterns are divided into two groups: aliases (basic \fIc++\fR
+and \fIsymver\fR) and generic patterns (\fIregex\fR, all combinations of
+multiple basic patterns). Matching of basic alias-based patterns is fast (O(1))
+while generic patterns are O(N) (N - generic pattern count) for each symbol.
Therefore, it is recommended not to overuse generic patterns.
.P
-When multiple patterns match the same real symbol, aliases (first c++, then
-wildcards) are preferred over generic patterns. Generic patterns are matched in
-the order they are found in the symbol file template until the first success.
-Please note, however, that manual reordering of template file entries is not
-recommended because \fBdpkg-gensymbols\fR generates diffs based on the
+When multiple patterns match the same real symbol, aliases (first \fIc++\fR,
+then \fIsymver\fR) are preferred over generic patterns. Generic patterns are
+matched in the order they are found in the symbol file template until the first
+success. Please note, however, that manual reordering of template file entries
+is not recommended because \fBdpkg-gensymbols\fR generates diffs based on the
alphanumerical order of their names.
.SS Using includes
.P
--
Debian Qt/KDE packaging tools
More information about the pkg-kde-commits
mailing list