Commit Graph

1085 Commits

Author SHA1 Message Date
Dodji Seketeli
fbba4bf0ed Fix template comparison operators
There are two issues in comparing templates currently.

One is that comparing member class template recurses for ever (oops).

The other is that the logic of comparing function templates is wrong
and leads to false comparisons.

	* include/abg-ir.h (function_tdecl::operator==): Introduce a new
	virtual member operator that takes a function_tdecl&.
	* src/abg-ir.cc
	(class_decl::member_function_template::operator==): Avoid the
	static cast in the overload for member_base.  In the overload for
	member_class_template, avoid infinite recursion.
	(function_tdecl::operator==): In the overload for decl_base, do
	not do the real work here in the overload for decl_base Rather,
	the real work is done in the new overload for function_tdecl, and
	all other overloads call that one.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-29 16:23:15 +02:00
Dodji Seketeli
9ab2c3a3fd Use size/alignment of class definition when requested on declaration
Sometimes during hashing the "type sub-object" of a class can be
queried for its size or alignment.  In those case, if the class is a
declaration that happens to be accompanied with a definition, its the
size/alignment of the definition that we want, not the one of the
declaration, that is zero.  Otherwise, this can cause spurious hashing
changes between two class types that are otherwise equivalent modulo
the use of a class declaration.

This patch being part of a series that aims at fixing a number of type
hashing issues, the regression tests are adjusted at the end of the
series, not here.

	* include/abg-ir.h (type_base::{set_size_in_bits,
	set_alignment_in_bits}): Make these member functions virtual.
	(class_decl::{set_size_in_bits, get_size_in_bits,
	get_alignment_in_bits, set_alignment_in_bits}): Declare these
	virtual member functions.
	* src/abg-ir.cc (class_decl::{set_size_in_bits, get_size_in_bits,
	get_alignment_in_bits, set_alignment_in_bits}): Define these
	virtual functions.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-29 16:23:15 +02:00
Dodji Seketeli
f609f3b8b9 Fix type lookup algorithm
Until now, the type lookup algorithm was broken for c++.  For two
reasons:

  1/ The algorithm to break a fully qualified type name into name
    components is buggy.  When given the type name:
      foo<ns1::t1, ns1::t2>::t3
    the components making up the name are: "foo<ns1", "t1, ns1", "t2>"
    and "t3.  That is wrong.  The components should be:
    "foo<ns1::t1, ns2::t2>" and "t3".

  2/ When a type is found, if it's a declaration, it's skipped.  This
  is wrong because if the declaration is accompanied with a
  definition, it should be returned.

This patch addresses the two issues above.  It allows more
declaration-only classes to be resolved and so reduces the number of
spurious hashing differences between two instances of the same type
which should otherwise have the same hash.

There is no regression test update with this patch because we really
need the full series this patch is part of, to fix the type hashing
correctness issues we have.  So the regression test updates are coming
at the end of the series.

	* src/abg-ir.cc (find_next_delim_in_cplus_type): Define new static
	function.
	(fqn_to_components): Use the new function above to break up a
	fully qualified name into components, rather than the too simple
	string::find_first_of() we were using previously.
	(lookup_node_in_scope): If the found type (class) is a
	declaration-only and if it has a definition, then return it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-29 16:23:15 +02:00
Dodji Seketeli
d169d57e54 Make decl hashing always take qualified name into account
* src/abg-hash.cc (decl_base:#️⃣:operator()(const decl_base&)):
	Always hash the qualified name of the decl.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-29 16:23:15 +02:00
Dodji Seketeli
85feb73bad Accept base classes which types are compatible with class type
Until now, a base class had to be a class itself.  It couldn't be a
typedef to a class, for instance. Clang's debug info does allow base
classes which are compatible with classes (e.g, typedefs of classes),
which is correct.  We ought to accept that.  Hence this patch.

	* include/abg-fwd.h (is_compatible_with_class_type): Declare a new
	overload.
	* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Rather
	than requiring that base classes be of class type, just require
	that they be compatible with class types.
	* src/abg-ir.cc (is_compatible_with_class_type): Define a new
	overload.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-29 16:23:15 +02:00
Dodji Seketeli
1bac4fd992 Harden function_decl::get_pretty_representation()
This function can abort when called on a function_decl that is not a
member function.  This patch addresses that issue.

	* src/abg-ir.cc (function_decl::get_pretty_representation): Make
	sure the function type is a member function before calling
	get_member_function_is_{virtual,ctor,dtor,const}.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-29 16:23:15 +02:00
Dodji Seketeli
173a2c9939 Don't cache type qualified name before canonicalization
Caching the qualified name of a given type has always been subject to
subtle bugs.  If the qualified name is queried (so it's computed)
before the type is added into its final content, then what is cached
is a non-qualified type name.  Later when the type is finally added to
its context, querying its qualified name will just yield the cached
non-qualified name.  And that has impact on hashing and comparison.

We needed a way to signal that the type is "fully built and added to
its final context".  When the type is fully built then we can cache
its qualified name.

This patch uses the presence of the canonical type as the signal; if
the canonical type is present then the type is fully built and added
to its final context.  And then at that point the cached qualified
name is used.

Note that this patch is the first of a series fixing several things
that influence hashing, comparison, the reading and writing of abixml.
It's only at the end of the series that an update to regression tests
is provided.  In between, some patches of the series are going to
"break" the regression tests.  That is fine.

	* src/abg-ir.cc (decl_base::{get_qualified_parent_name,
	get_qualified_name}): Use the qualified name cache only if the
	type is fully built, i.e, when its canonical type is present.
	(qualified_type_def::get_qualified_name): Likewise.
	(pointer_type_def::get_qualified_name): Likewise.
	(reference_type_def::get_qualified_name): Likewise.
	(array_type_def::get_qualified_name): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-29 16:21:34 +02:00
Dodji Seketeli
72b42c3090 Misc style cleanups
* configure.ac: Fix some spelling typos.
	* src/abg-tools-utils.cc (guess_file_type): Fix indentation.
	* tests/test-diff-pkg.cc (int_out_specs): Add some vertical spaces
	for better legibility.
	* tools/abidiff.cc (main): Add a missing space.
	* tools/abipkgdiff.cc (extract_deb): Fix a typo in the comment.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-22 14:32:20 +02:00
Dodji Seketeli
585fc4c33c Make abipkgdiff compare tar archives containing binaries
This patch adds support for comparing the ABI of binaries contained in
a tar archive.

If the archive is compressed with gzip, bzip2, lzip, lzma or xz, then
abipkgdiff recognizes the usual relevant file extensions and lets the
GNU tar program handle the decompression.

If the archive is not compressed, abipkgdiff recognizes the UStar
(Uniform Standard Tape ARchive) format, even if the archive file name
doesn't end with the .tar extension, and lets the GNU tar program
handle the extraction.  If the file ends up with the .tar extension
anyway (even if it's not in the UStar format, abipkgdiff lets the GNU
tar program handle its extraction.

	* config.h.in (WITH_TAR): New configuration preprocessor macro.
	* configure.ac: Add a new --enable-tar option.  It's turned on
	automatically if the tar program is found in the PATH.  Adjust the
	build configuration report to add the tar archive support.
	* include/abg-tools-utils.h (string_ends_with): Declare new
	function.
	(enum file_type): Add a new FILE_TYPE_TAR enumerator.
	* src/abg-tools-utils.cc (string_ends_with): Define new function.
	(operator<<(ostream&, file_type)): Serialize the new FILE_TYPE_TAR
	enumerator.
	(guess_file_type): Detect UStar format file by reading its magic
	number.  Detect compressed tar files based on the file path
	extension.
	* tools/abipkgdiff.cc (extract_tar): Define new function.
	(extract_package): Handle tar packages.
	(main): Handle tar archives.
	* tools/abidiff.cc (main): Handle the new FILE_TYPE_TAR
	enumerator.
	* tools/abilint.cc (main): Likewise.
	* tests/data/test-diff-pkg/tarpkg-0-dir{1,2}.ta{,r,.bz2, gz}: New
	test input tarballs.
	* tests/data/test-diff-pkg/tarpkg-0-report-0.txt: New test output
	reference.
	* tests/data/Makefile.am: Add the new test data file above to
	source distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Add new tests cases.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-22 14:32:20 +02:00
Dodji Seketeli
fca8506ab9 Misc style fixes in abipkgdiff
* include/abg-tools-utils.h (enum file_type): Fix the comment for
	for the FILE_TYPE_DEB enumerator.
	* tools/abipkgdiff.cc (main): Fix the style of the conditions.
	Also, fix the text emitted.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-22 12:19:27 +02:00
Dodji Seketeli
d7dbbf0d50 Make abipkgdiff compare directories containing binaries
abipkgdiff knows how to compare the ABI of binaries contained in .deb
and .rpm files.  This patch adds support for comparing the ABI of
binaries contained in two directories.

	* include/abg-tools-utils.h (enum file_type): Add a new
	FILE_TYPE_DIR enumerator.
	* src/abg-tools-utils.cc (operator<<(ostream&, file_type)):
	Support serialization of the new FILE_TYPE_DIR enumerator.
	(guess_file_type): Detect that the path given is a directory.
	* tools/abipkgdiff.cc (package::package): If the package is a
	directory, then set its extracted directory path to the path of
	the directory.
	(package::erase_extraction_directory): Do not erase the extraction
	directory if the package is a directory provided by the user.
	(extract_package): If the package is a directory provided by the
	user, then there is nothing to extract.
	(main): If the first package is a directory, then the second one
	should be a directory as well.
	* tools/abidiff.cc (main): Support directories as input.
	* tools/abilint.cc (main): Likewise.
	* tests/data/test-diff-pkg/dirpkg-0-dir{1,2}/libobj-v0.so: New
	binary test inputs.
	* test/data/test-diff-pkg/dirpkg-0-report-0.txt: New input test
	file.
	* tests/data/test-diff-pkg/dirpkg-1-dir{1,2}/obj-v0.cc: Source
	code of the binary test inputs above.
	* tests/data/Makefile.am: Add the new files above to the source
	distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Add the new test input
	files above to the set of tests this harness has to run over.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-22 12:19:27 +02:00
Dodji Seketeli
ae5e1be5c3 [dwarf reader] Support reference types without explicit DW_AT_byte_size
On x86_64 at least, in the debug info emitted by Clang, reference
types don't necessarily have the DW_AT_byte_size property.  In that
case, assume the size of the pointer type is the address size of the
current translation unit, rather than giving up and not building the
type.

	* src/abg-dwarf-reader.cc (build_reference_type): If the type DIE
	has no DW_AT_byte_size, assume the type size is the translation
	unit's address size.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-22 09:41:23 +02:00
Dodji Seketeli
12123aede6 [dwarf reader] Support pointer types without explicit DW_AT_byte_size
On x86_64 at least, in the debug info emitted by Clang, pointer types
don't necessarily have the DW_AT_byte_size property.  In that case,
assume the size of the pointer type is the address size of the
current translation unit, rather than giving up and not building the
type.

	* abg-dwarf-reader.cc (build_pointer_type_def): If the type DIE
	has no DW_AT_byte_size, assume the type size is the translation
	unit's address size.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-21 20:16:38 +02:00
Dodji Seketeli
d1c6ef0cb5 make abipkgdiff compile with GCC 4.4.7
GCC 4.4.7 won't let us declare an instance of string with __thread.
So for now, package::extracted_packages_parent_dir() juststores its string
globally.  We are single-threaded for now anyway.

	* tools/abipkgdiff.cc (package::extracted_packages_parent_dir):
	The string holding the dir name is no more __thread, as this won't
	compile with GCC 4.4.7

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-21 13:08:38 +02:00
Dodji Seketeli
1f8fed586d Misc style fixes
* src/abg-dwarf-reader.cc (read_context::die_type_map): Fix typo
	in the comment.
	* src/abg-ir.cc (peel_typedef_type): Fix typo in the comment.
	* src/abg-reader.cc
	(read_context::perform_late_type_canonicalizing): Fix a type in
	the comment.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-21 12:43:37 +02:00
Dodji Seketeli
45be4d7fdd Make get_pretty_representation work on method types
Until now, get_pretty_representation() considered method types just as
function types.  This patch makes it know about them specifically.  This
useful for debugging, at least.

	* include/abg-fwd.h (is_method_type): Declare new overloads for
	naked pointers.
	(get_method_type_name): Declare new functions.
	(get_pretty_representation): Declare new overloads for
	method_type.
	* src/abg-ir.cc (get_function_type_name): If the function type is
	a method type, handle it as such.
	(get_method_type_name): Define new functions.
	(get_pretty_representation): If the function type is a method
	type, handle it as such.
	(get_pretty_representation): Define new overloads for method_type
	and pointer/reference to method_type.
	(is_method_type): Add overloads for naked pointers.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-21 12:43:37 +02:00
Dodji Seketeli
ddb17eddba Hash a class declaration the same as its definition
A class declaration hashes differently from its definition.

Since the abixml format can now use a class element id before defining
it, it's more consistent to stop representing class declarations in
the abixml format, when the class is actually defined in the corpus.

So this patch now hashes a class declaration the same as its
definition, when the definition is present.  If the definition is not
present then the hash value of the declaration is just zero.  This is
consistent with what is done elsewhere in the code as a hash value of
zero means the hash could not be computed, somehow, as the type
comparison code knows that a type with hash value zero can be equal to
a type with a hash value that is different from zero.

As a result, many tests which use the abixml format have been adjusted
to reflect the new form of abixml where class declarations are now
omitted when these declarations are accompanied with their definition.
I made sure that abidiff reports that former abixml output and the new
one are equivalent.

After this change abixml outputs should contain less redundant type
declarations.  This is another step toward normalizing the abixml
output.

	* src/abg-hash.cc (class_decl:#️⃣:operator()(const class_decl&)):
	If the class declaration has a definition, hash its definition
	instead.  Otherwise, if the class declaration has no definition,
	just return a zero hash, like what we were doing before.
	* src/abg-reader.cc (read_context::maybe_canonicalize_type): Do
	not early canonicalize method types because most of the time, when
	this function is called, the method hasn't been added to its
	parent class yet.  So wait until late before canonicalizing.
	* src/abg-writer.cc (write_class_is_declaration_only): Do not emit
	the "is-declaration-only" property if the declaration has a
	definition.
	(write_class_decl): If the class declaration has a definition,
	emit the definition instead.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
	* tests/data/test-read-write/test18.xml: Likewise.
	* tests/data/test-read-write/test20.xml: Likewise.
	* tests/data/test-read-write/test21.xml: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-21 12:07:19 +02:00
Dodji Seketeli
7bcaf67504 Add a --stats to abidiff and abidw
For now, this new --stats emits diagnostics about the number of types
canonicalized at the very end of building the ABI corpus as well as
the number of types that were scheduled for late canonicalizing and
that couldn't be canonicalized.

	* include/abg-dwarf-reader.h (get_show_stats)
	(set_show_stats): New accessors for a new "show_stats" property of
	the dwarf reader context.
	* src/abg-dwarf-reader.cc: Include iostream to use std::cerr.
	(dwarf_reader::show_stats_): New data member.
	(dwarf_reader::dwarf_reader): Initialize it.
	(dwarf_reader::show_stats)
	(get_show_stats)
	(set_show_stats): Define new accessors.
	(dwarf_reader::die_type_map): Add const overload to this accessor.
	(dwarf_reader::lookup_type_from_die_offset): Make this accessor
	const.
	(dwarf_reader::add_late_canonicalized_types_stats): New member
	function.
	(dwarf_reader::perform_late_type_canonicalizing): Emit the
	statistics about late-canonicalized types if the user asked for
	it.
	* tools/abidiff.cc (options::show_stats): New data member.
	(options::options): Initialize it.
	(display_usage): Document it.
	(parse_command_line): Parse the new --stats option.
	(main): Create a dwarf reader context, set the show_stats to it
	and then use that context to read the corpora before diffing them.
	* tools/abidw.cc (options::show_stats): New data member.
	(options::options): Initialize it.
	(display_usage): Document it.
	(parse_command_line): Parse the new --stats option.
	(main): Set the show_stats to the dwarf reader context before
	using it.
	* doc/manuals/abidiff.rst: Update the manual.
	* doc/manuals/abidw.rst: Update the manual.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-20 13:25:42 +02:00
Dodji Seketeli
4f5c0326a4 Canonicalize all types that got scheduled for late canonicalization
Until now, when late type canonicalization time come (after having
read all of the ABI corpus), the types scheduled for late
canonicalization were considered and only those that don't have
non-canonicalized sub-types were canonicalized.

This patch just canonicalizes all the scheduled type.  As a result,
all types should now be canonicalized, so type comparison should be as
fast as a pointer comparison now.  But then, loading DWARF is now even
longer, type canonicalization needs to happen.

	* src/abg-dwarf-reader.cc
	(read_context::canonicalize_types_scheduled): Canonicalize all
	types scheduled for late canonicalization.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-20 11:44:45 +02:00
Dodji Seketeli
9e656c7e49 Propagate canonical type of a class definition to its declaration
When a class type definition has its canonical type set, propagate it
to the class declaration.

	* src/abg-ir.cc: (canonicalize): Propagate the canonical type of
	the type definition to its declaration.
	(class_decl::set_definition_of_declaration): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-19 18:53:43 +02:00
Dodji Seketeli
bd161caa52 Make type_has_non_canonicalized_subtype() tighter
type_has_non_canonicalized_subtype() gives up too quickly.

For instance, suppose it's looking a type 'foo'.  If foo has no
canonicalized type yet and has a data member which type is foo* (for
instance), then type_has_non_canonicalized_subtype() just sees that
type 'foo*' has no canonicalized type, and so it returns, saying that
he found a non-canonicalized subtype for foo.

In that case though, what type_has_non_canonicalized_subtype() should
do is detect that foo* is a pointer to foo itself, so it shouldn't
count as a non-canonicalized sub-type.  It should keep going and look
for other meaningful non-canonicalized sub-types.

And this what this patch does.  It changes the sub-type walker that
type_has_non_canonicalized_subtype() uses, so that

   - it doesn't flag sub-types that refer to the type we are looking
     at as non-canonicalized sub-types.  This is for sub-types that
     are combinations of pointers, references and typedefs.

   - it doesn't consider sub-types of member functions of the type we
     are looking at, unless that member function is virtual.

The result is that more types are canonicalized early during DWARF
reading, and so there are less types to store on the side for late
canonicalization.  This can have a big impact on, e.g, C++ libraries
with tens of thousands of types.

	* include/abg-fwd.h (is_typedef, is_pointer_type)
	(is_reference_type): Declare new overloads.
	(peel_typedef_type): Renamed get_typedef_underlying_type into
	this.
	(peel_pointer_type, peel_reference_type)
	(peel_typedef_pointer_or_reference_type): Declare new functions.
	* src/abg-ir.cc (peel_typedef_type): Renamed
	get_typedef_underlying_type into this.
	(is_typedef, is_pointer_type, is_reference_type): Define new
	overloads.
	(peel_pointer_type, peel_reference_type)
	(peel_typedef_pointer_or_reference_type): Define new functions.
	(non_canonicalized_subtype_detector::has_non_canonical_type_):
	Make the type of this data member be a type_base*, not a bool.
	This is so that we can return the first non-canonicalized subtype
	of the type we are looking at.
	(non_canonicalized_subtype_detector::non_canonicalized_subtype_detector):
	Adjust the data member initialization.
	(non_canonicalized_subtype_detector::visit_begin): Add an overload
	for function_decl*, to avoid looking into non-virtual member
	functions.
	In the overload for type_base*, peel typedefs, pointers and
	reference of each sub-type that has no canonical type, to see if
	refers to the type we are actually walking.  If yes, then keep
	going.
	(type_has_non_canonicalized_subtype): Return the non-canonicalized
	sub-type found.
	* src/abg-comparison.cc (type_suppression::suppresses_diff):
	Adjust for the get_typedef_underlying_type -> peel_typedef_type
	renaming.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-19 18:12:27 +02:00
Dodji Seketeli
39b2e8b7d5 Make decl_base::get_qualified_name() work when decl context changes
decl_base::get_qualified_name() caches its result.  So when it's
first called on a decl that is not added to a scope, what is returned
is a non-qualified name.  Which is all right.  But then when the decl
is later added to a scope, the cached result of
decl_base::get_qualified_name() is not longer correct.

This patch resets the cache of decl_base::get_qualified_name() when
the decl gets added to a new scope.

	* include/abg-ir.h (class decl_base): Make class scope_decl a
	friend of decl_base.
	(type_base::priv_): Make this protected, rather than private.
	* src/abg-ir.cc (scope_decl::add_member_decl)
	(scope_decl::insert_member_decl): Reset the cache of the result of
	decl_base::get_qualified_name().
	* tests/data/test-abidiff/test-PR18791-report0.txt: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-19 18:09:29 +02:00
Dodji Seketeli
ba5b4452d5 Bug 18844 - assert failure in abidw at abg-dwarf-reader.cc:6537
The DWARF reader is not scheduling a declaration-only class for
resolution when the class has member types.  When reading the code of
build_class_type_and_add_to_ir(), we see that the scheduling is done
before getting out of the function.  But then, building members of the
class can trigger another invocation of
build_class_type_and_add_to_ir() before the current invocation
returns.  In that case, the declaration-only class being built appears
as not being scheduled for resolution.  And that is what violates the
assertion that declaration-only classes should be scheduled for
resolution whenever they are used.

This patch addresses the issue by scheduling the resolution earlier, when
we know we are dealing with a declaration-only class, and before
dealing with members of that classes.

	* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir):
	Schedule declaration-only class resolution before the class
	appears as usable as to other types being built.
	* tests/data/test-read-dwarf/test12-pr18844.so: Add a new binary
	test input.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: The reference
	ABI XML output for the binary above.
	* tests/data/Makefile.am: Add the new test inputs above to the
	source distribution.
	* tests/test-read-dwarf.cc (in_out_specs): Add the new test inputs
	above to the set of input this test harness has to run over.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-18 12:33:57 +02:00
Dodji Seketeli
fce31333cb Fix a little glitch in the test suite
* test-read-dwarf.cc (in_out_specs): Emit the output of the test11
	to output/test-read-dwarf/test11-pr18828.so.abi, not
	output/test-read-dwarf/test10-pr18828.so.abi.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-18 12:31:45 +02:00
Dodji Seketeli
f7f37dec12 Escape XML property names that were not escaped before
Apparently we are not escaping XML property names for 'typedef-decl',
'namespace-decl' and 'var-decl' elements.  I think it's not necessary
for  namespace-decl, but well, you never know.

	* src/abg-writer.cc (write_namespace_decl, write_typedef_decl)
	(write_var_decl): Escape the XML characters that are forbidden in
	XML properties, and that are emitted as value of the 'name'
	property.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-18 12:07:18 +02:00
Dodji Seketeli
f38c19f8da Bug 18828 - Handle force-resolving of multiple declarations-only of the same type
When a declaration-only type that is used in a context where it needs
to be complete (and no definition is present for that type in the ABI
corpus) handle cases where that type is was actually declared several
times.

	* src/abg-dwarf-reader.cc
	(read_context::resolve_declaration_only_classes): Accept that a
	class that needs to be force-resolved might have been declared
	several times.  In that case, some instances of that
	declaration-only class might have already been resolved (or
	completed).
	* tests/data/test-read-dwarf/test11-pr18828.so: New binary input.
	It comes from bug https://sourceware.org/bugzilla/show_bug.cgi?id=18828.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: The reference
	output for the binary above.
	* tests/data/Makefile.am: Add the test input files above to source
	distribution.
	* tests/test-read-dwarf.cc (in_out_specs): Add the test inputs
	above to the set of input this test harness has to run over.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-15 00:26:39 +02:00
Dodji Seketeli
88ae73fdf9 Avoid declaring a type several times in the same TU in the XML format
It appears a lot of duplicated type declarations can appear in a given
translation unit.  This patch avoids that.

	* src/abg-writer.cc (write_context::{record_type_id_as_emitted,
	record_type_as_emitted, type_id_is_emitted, type_is_emitted,
	clear_emitted_types_map}): New member functions.
	(write_context::m_emitted_type_id_map): New data member.
	(write_translation_unit): Clear the per-translation unit map of
	emitted types.  Do not emit a type that has already been emitted
	in this translation unit.
	(write_namespace_decl): Do not emit a type that has already been
	emitted in this translation unit.
	(write_type_decl, write_qualified_type_def)
	(write_pointer_type_def, write_reference_type_def)
	(write_array_type_def, write_typedef_decl, write_class_decl)
	(write_type_tparameter, write_template_tparameter): Record the
	type we've just written as having been written out.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust as
	duplicated declarations got removed.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-15 00:03:07 +02:00
Dodji Seketeli
dc3211e647 Misc style fixes in the XMLABI writer
This patch aligns some data members and function parameters.  It also
makes use of the *_sptr typedef, rather than the longer
shared_ptr<something> types in function parameters.

	* src/abg-writer.cc (write_context): Align data members.
	(write_translation_unit): Remove useless horizontal white spaces.
	(write_decl, write_qualified_type_def, write_pointer_type_def)
	(write_reference_type_def, write_array_type_def)
	(write_enum_type_decl, write_typedef_decl, write_class_decl)
	(write_type_tparameter): Use the *_sptr typedefs rather than the
	longer form of shared_ptr<sometype> in function signatures.
	(write_enum_type_decl): In this function in particular, indent a
	line properly.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 23:45:14 +02:00
Dodji Seketeli
dd15667e8e Fix typos in abipkgdiff
* tools/abipkgdiff.cc (display_usage): s/pompare/compare.  Give a
	better help message for --help.
	(extract_rpm): Insert a space after the path of the package being
	extracted, when emitting a verbose message.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 16:50:18 +02:00
Dodji Seketeli
f271e4c460 Install the manpage for abipkgdiff
* doc/manuals/Makefile.am (section1_manpages): Add abipkgdiff.1 to
	the set of manpages to be install into section 1.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 16:48:35 +02:00
Dodji Seketeli
160961f3cb Bug 18818 - abidw aborts on a class with a non-complete base class
On some binaries with debug info emitted by "Ubuntu clang version
3.6.0-2ubuntu1" and "GNU C++ 4.9.2" (as the value of the
DW_AT_producer property), it seems some classes can have a base class
that is not complete.  E.g, the debug info (that I have extracted
using the command eu-readelf --debug-dump=info
<the-binary-attached-to-the-bug>) has these relevant pieces:

    [...]

     [  5ff7]        class_type
		     containing_type      (ref4) [  7485]
		     name                 (strp) "system_error"
		     byte_size            (data1) 40
		     decl_file            (data1) 46
		     decl_line            (data1) 22
     [  6003]          inheritance
		       type                 (ref4) [  7480]
    [...]

Here, we are looking at the type system_error (actually
boost::system::system_error) that inherits the type which DIE is
referred to as offset '7480'.

Then the definition of the DIE at offset 7480 is:

    [...]

     [  7480]      class_type
		   name                 (strp) "runtime_error"
		   declaration          (flag_present)
     [  7485]      class_type
		   name                 (strp) "exception"
		   declaration          (flag_present)
    [...]

You can see that the type "runtime_error" (actually
std::runtime_error) has the flag DW_AT_declaration set, marking it as
a declaration (with no definition yet).  And no other DIE in the same
translation unit
(src/third_party/boost-1.56.0/libs/filesystem/src/codecvt_error_category.cpp)
or in the same DSO provides the definition for that declaration.

I believe this is ill-formed.  A base class should be defined and have
a layout completed expressed and accessible from the translation unit
it's used in.

The patch I am proposing detects that the base class is still
incomplete when we finish loading the current binary.  In that case,
the base class is made complete with a size of 1.  Meaning it's an
empty class (with no data member and no base class).  This works as a
viable work-around *if* the producer only omitted definitions for
empty classes.  We'll need to fix the producers eventually.

	* src/abg-dwarf-reader.cc
	(read_context::decl_only_classes_to_force_defined_map_): New data
	member.
	(read_context::declaration_only_classes_to_force_defined): New
	accessors.
	(read_context::schedule_declaration_only_class_for_forced_resolution):
	New member function.
	(build_class_type_and_add_to_ir): If a base class is a
	declaration-only class then mark it as needing to be force-defined
	*if* it's still not defined at the end of the abi corpus loading.
	(read_context::resolve_declaration_only_classes): If
	declaration-only classes that need to force-defined are present
	and not defined (when we reach the end of the ABI corpus) then
	force-define them as empty classes.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so: New test
	binary input file.  This comes from a user binary submitted to bug
	https://sourceware.org/bugzilla/show_bug.cgi?id=18818.  The
	original URL to the binary is
	https://sourceware.org/bugzilla/attachment.cgi?id=8518.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so: New binary
	input file.  This comes from the same bug report as above.  The
	original URL to the binary is
	https://sourceware.org/bugzilla/attachment.cgi?id=8511.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: New
	reference output file.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
	* tests/data/Makefile.am: Add the new files above to the source
	distribution.
	* tests/test-read-dwarf.cc (in_out_specs): Add the test inputs
	above the set of tests input this harness has to run over.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 16:22:14 +02:00
Dodji Seketeli
4b680be2a8 Update the abipkgdiff manual to say that .deb files are now supported
* doc/manuals/abipkgdiff.rst: Say that .deb fiel are now supported
	by abipkgdiff.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 15:24:59 +02:00
Dodji Seketeli
57e2cb9e07 Update comment about the supported formats in abipkgdiff
* tools/abipkgdiff.cc: Now that .deb packages are supported, say
	it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 15:24:12 +02:00
Dodji Seketeli
28090bad1b Make the support of RPM and DEB package formats conditional
If at configure time the libabigail source tarball detects that
rpm2cpio and cpio are present then it enables the support for rpm
files.  Users can explicitly enable or disable that support by passing
--enable-rpm or --disable-rpm to configure.

Similarly if it detects that dpkg is present at configure time then it
enables the support for deb files.  Users can explicitly enable or
disable that support by passing --enable-deb or --disable-deb to
configure.

	* config.h.in: Define WITH_DEB and WITH_RPM pre-processor macros.
	* configure.ac: Add --enable-{rpm,deb} switches.  Check for
	rpm2cpio and cpio programs, unless --disable-rpm was provided.  If
	they are found and if --enable-rpm=auto was provided, then
	consider that --enable-rpm=yes was provided.  In that case, set
	the WITH_RPM macro to 1.  Otherwise, undefine that macro.
	Similarly, check for dpkg unless --disable-deb was provided.  If
	it's found and if --enable-deb=auto was provided, consider that
	--enable-deb=yes was provided.  In that case, set the WITH_DEB
	macro to 1.  Otherwise, undefine that macro.  Define the
	ENABLE_RPM and ENABLE_DEB conditional automake variables, if the
	rpm resp. deb support is enabled.  Emit a notice about the rpm and
	deb features being enabled or not, at the end of the configure
	process.
	* tests/test-diff-pkg.cc: Include the config.h header.
	(in_out_spec): Guard rpm tests by the WITH_RPM macro.  Similarly,
	guard deb tests by the WITH_DEB macro.
	* tools/abipkgdiff.cc: Include the config.h header.
	(extract_rpm): Guard this function definition with the WITH_RPM
	macro.
	(extract_deb): Guard this function definition with the WITH_DEB
	macro.
	(extract_package): Guard the handling of rpm packages with the
	WITH_RPM macro and the handling of deb package with the WITH_DEB
	macro.  If a package not-support package format is encountered,
	emit an appropriate error message and error out.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 13:40:32 +02:00
Matthias Klose
4df0a4d952 Add support for .deb files to abipkgdiff
This lets abipkgdiff compare debian binary packages.

The patch contains test cases for debian package with split debug info
that is referenced by the build-id scheme.  These test cases come from
the bug report https://sourceware.org/bugzilla/show_bug.cgi?id=18792,
more particularly from the attachment
https://sourceware.org/bugzilla/attachment.cgi?id=8516.

	* include/abg-tools-utils.h (file_type): Add FILE_TYPE_DEB.
	* tools/abipkgdiff.cc (extract_deb): New.
	(extract_package, main): Handle FILE_TYPE_DEB.
	* src/abg-tools-utils.cc (operator<<): Handle FILE_TYPE_DEB.
	(guess_file_type): Detect FILE_TYPE_DEB.
	* tools/abidiff.cc (main): Handle FILE_TYPE_DEB.
	* tools/abilint.cc (main): Handle FILE_TYPE_DEB.
	* tests/data/test-diff-pkg/libsigc++-2.0-0c2a-dbgsym_2.4.0-1_amd64.ddeb:
	Input debian debug info package; to be compared by the test
	harness runtestdiffpkg.
	* tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64.deb:
	Input debian package; to be compared by the test harness
	runtestdiffpkg.
	* tests/data/test-diff-pkg/libsigc++-2.0-0v5-dbgsym_2.4.1-1ubuntu2_amd64.ddeb:
	Input debug info package
	* tests/data/test-diff-pkg/libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64.deb:
	Input debian package; to be compared by the test harness
	runtestdiffpkg.
	* tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt:
	Reference output for the comparison of the packages above.
	* tests/data/Makefile.am: Add the new files above to the source distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Add the input packages
	above to the set of files to be compared by this test harness.

Signed-off-by: Matthias Klose <doko@debian.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 13:36:23 +02:00
Dodji Seketeli
393fe3166b Add configure check for rm and mkdir used by abipkgdiff
* configure.ac: Add configure checks for rm and mkdir used by
	abipkgdiff.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 13:31:30 +02:00
Dodji Seketeli
9d601b2663 Fix a comment in configure.ac
* configure.ac: Fix a comment.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 13:31:30 +02:00
Dodji Seketeli
8798649dbe Do not remove api and website source files by accident
When the root source dir is used as root build dir, make clean can
remove the content of ${abs_builddir}/api which is then equal to
${abs_srcdir}/api.  Oops.  This patch fixes this.

	* doc/Makefile.am: Do not remove the entirety of the build dir of
	doxygen for the apidoc and the website as these can be also the
	source dirs.  Rather, remove that is under the html/ sub-directory
	of the build dir, as this is always generated by doxygen.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 13:31:30 +02:00
Dodji Seketeli
56112bae3b Add an abipkgdiff --fail-no-dbg command line option
* tools/abipkgdiff.cc (options::fail_if_no_debug_info): New data
	member.
	(options::options): Initialize it.
	(display_usage): Document it.
	(compare): If the user asked for it, fail if the we couldn't file
	the debug info for the corpus files being compared.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-13 23:26:53 +02:00
Dodji Seketeli
c09bb53ab1 Add -h and -d option shortcuts to abidw
Added a -h option shortcut for the --help option and a -d option
shortcut for the --debug-info-dir option, to the abidw program.

	* tools/abidw.cc (display_usage): Added a documentation string.
	(parse_command_line): Parse the new -h and -d shortcuts.
	* doc/manuals/abidw.rst: Update the manual.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-13 23:26:53 +02:00
Dodji Seketeli
71acc72064 Add a -h option shortcut to abidiff
Added a -h shortcut for --help to the abidiff program.n

	* tools/abidiff.cc (display_usage): Add documentation for the new
	switch.
	(parse_command_line): Parse the -h option.
	* doc/manuals/abidiff.rst: Update the manual.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-13 23:26:53 +02:00
Dodji Seketeli
da870f3598 Add a -h shortcup to abipkgdiff --help
* tools/abipkgdiff.cc (display_usage): Document the -h shortcut.
	(parse_command_line): Parse the -h shortcut to --help.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-13 23:26:52 +02:00
Dodji Seketeli
242e49a321 Bug 18791 - libabigail fails to read the output of abidw
The reader fails to set the access specifier for a member type.  Fixed
thus.

	* src/abg-reader.cc (read_context::get_scope_for_node): Take an
	access_specifier output parameter to set the access specifier of
	the current node in its scope.  Update the function to set the
	access_specifier.
	(read_context::build_or_get_type_decl): Adjust to set the access
	specifier of the type we are building, in case it's a member type.
	* tests/data/test-abidiff/test-PR18791-v{0,1}.so.abi: New test input files.
	* tests/data/test-abidiff/test-PR18791-report0.txt: New test
	output reference.
	* tests/data/Makefile.am: Add the new test material to the source
	distribution.
	* tests/test-abidiff.cc (specs): Add the new test inputs to the set of
	input files this test harness has to run over.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-09 02:11:17 +02:00
Dodji Seketeli
11b536e4fc Fix a thinko in language support de-serialization
A thinko was preventing us from reading the value of the "language"
property in the XML format.  Fixed thus.

	* src/abg-ir.cc (string_to_translation_unit_language): Fix
	thinko.  What was I thinking ...

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-09 02:10:09 +02:00
Dodji Seketeli
9f7c07460d Add --no-added-syms to abipkgdiff
With this new option the tool ignores added functions, variables and
their symbols.

	* tools/abipkgdiff.cc (options::show_added_syms): New data member.
	(options::options): Initialize it.
	(parse_command_line): Parse the new --no-added-syms option and set
	the options::show_added_syms flag accordingly.
	(display_usage): Add a help string for the new option.
	(set_diff_context_from_opts): Set the diff context according to
	the state of the new options::show_added_syms flag.
	* doc/manuals/abipkgdiff.rst: Add manual entry for the new
	--no-added-syms options.
	* tests/data/test-diff-pkg/test-rpm-report-5.txt: New test
	reference input file.
	* tests/data/Makefile.am: Add the new file above to source
	distribution.
	* tests/test-diff-pkg.cc (InOutSpec::prog_options): New data
	member.
	(in_out_specs): Adjust.  Add a new input to run the test again
	with --no-added-syms.
	(main): Adjust to pass the program options contained in
	InOutSpec::prog_options to abipkgdiff.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>

fixup! Add --no-added-syms to abipkgdiff

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-06 15:22:38 +02:00
Dodji Seketeli
465b25e0d8 Update diff stats when added symbols are removed from change report
Until now, when added symbols were removed from the diff output, the
diff stat was not properly updated.  This patch fixes that.

	* include/abg-comparison.h (diff_context_wptr)
	(corpus_diff::diff_stats_sptr): New typedefs.
	(corpus_diff::diff_stats::diff_stats): Make this constructor take
	a diff_context_sptr.  Make the default constructor private.
	* src/abg-comparison.cc (corpus_diff::diff_stats::priv::ctxt_):
	New data member.  This is a weak pointer to a diff_context.
	(corpus_diff::diff_stats::priv::priv): Take a diff_context_sptr
	and initialize the weak pointer ctxt_ to it.
	(corpus_diff::diff_stats::priv::ctxt): New accessor to the
	diff_context hold by the diff_stats.
	(corpus_diff::diff_stats::{num_removed_func_filtered_out,
	num_added_func_filtered_out, num_removed_vars_filtered_out,
	num_added_vars_filtered_out, num_removed_func_syms_filtered_out,
	num_added_func_syms_filtered_out,
	num_removed_var_syms_filtered_out,
	num_added_var_syms_filtered_out}): If the user asked for the added
	[or removed] variables/functions/symbols to be ignored, the
	accessors for the number of filtered added/removed variables/functions/symbols
	return the total number of added/removed
	variables/functions/symbols; that is, say that *all* added/removed
	variables/functions/symbols got filtered out.
	(corpus_diff::priv::diff_stats_): Turn this data member into a
	[shared] pointer to diff_stats.
	(corpus_diff::priv::filters_and_suppr_applied_): Remove this data
	member.  Now that diff_stats_ is a pointer, we don't need this
	boolean anymore.
	(corpus_diff::apply_filters_and_suppressions_before_reporting):
	Adjust to the fact that filters_and_suppr_applied_ is gone, and
	that diff_stats_ is now a pointer.
	(corpus_diff::report): Control un-referenced added symbols
	reporting with
	diff_context::show_added_symbols_unreferenced_by_debug_info()

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-06 15:15:41 +02:00
Dodji Seketeli
a746f4afee Make applying supp specs through pointer access look through typedefs
Consider the declaration of the exported function bar() below:

    struct _OpaqueType {int member;};

    typedef struct _OpaqueType Type;

    void bar(Type*);

Once the *definition of struct _OpaqueType and bar() are compiled into
a shared library, if a layout change happens to struct _OpaqueType,
then abidiff rightfully reports that bar() is impacted by the layout
change to struct _OpaqueType.

But then, the following suppression specification won't silence the
ABI change report:

    [suppress_type]
      name = _OpaqueType
      type_kind = struct
      accessed_through = pointer

This is because strictly speaking, it's not struct _OpaqueType that is
accessed through a pointer, from function bar(); it's the type 'Type',
(which is a typedef of struct _OpaqueType) that is accessed though a
pointer.

But then, as 'Type' and 'struct _OpaqueType' are the same type (modulo
the typedef), this behaviour is not super useful.  It would be more
interesting if the suppression specification could silence the ABI
change report.

And this is what this patch does.

	* include/abg-comparison.h (type_suppression::suppresses_type):
	Declare new member function.
	(get_typedef_diff_underlying_type_diff): Declare new function.
	* include/abg-fwd.h (get_typedef_underlying_type): Likewise.
	* src/abg-comparison.cc (type_suppression::suppresses_type):
	Define new member function.
	(get_typedef_diff_underlying_type_diff): Define new function.
	(type_suppression::suppresses_diff): After looking through the
	different kind of access methods, use the new
	type_suppression::suppresses_type(), rather than doing lots of
	stuff ourselves here.  But then, if the suppression doesn't apply
	to the subjects of the diff, look through typedefs and try to
	apply the suppression again.
	* src/abg-ir.cc (get_typedef_underlying_type): Define new
	function.
	* tests/data/test-diff-suppr/libtest25-typedef-v{0,1}.so: New
	binary test input files.
	* tests/data/test-diff-suppr/test25-typedef-v{0,1}.c: Source code
	for the binary test input files above.
	* tests/data/test-diff-suppr/test25-typedef-report-{0, 1}.txt: New test
	input files.
	* tests/data/test-diff-suppr/test25-typedef-suppr-0.txt: New test
	input file.
	* tests/data/Makefile.am: Add the new test material to the source
	distribution.
	* tests/test-diff-suppr.cc (in_out_specs): Add the test inputs
	above to the set of test inputs this harness has to run over.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-01 14:34:46 +02:00
Dodji Seketeli
f0d319ab42 Make abipkgdiff erase the *parent* directory of temporary files
abipkgdiff was erasing the temporary files created by it wasn't
erasing the parent directory containing them.  Fixed thus.

	* tools/abipkgdiff.cc
	(erase_created_temporary_directories_parent): New static function.
	(compare): After comparison, erase the temporary parent directory
	as well.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-24 14:09:55 +02:00
Dodji Seketeli
88a1e8d6a0 Make the name of the removed variable section be consistent
The removed functions section is introduced by the string "Removed
functions", whereas the removed variables section is introduced by the
string "Deleted variables".  This patch makes the latter be "Removed
variables" just like for the functions.

	* src/abg-comparison.cc (corpus_diff::report): Introduce the
	section of removed variables with the string "Removed variable",
	rather than with the string "Deleted variable".
	* tests/data/test-abicompat/test2-var-removed-report-0.txt: Adjust.
	* tests/data/test-diff-suppr/test18-suppr-removed-var-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test18-suppr-removed-var-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test18-suppr-removed-var-report-5.txt: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-24 14:06:29 +02:00
Dodji Seketeli
e5cf9d1f60 Consider default symbol versions when computing added/removed fns/vars
When computing the set of added function or variable symbols, if a
symbol S with no version symbol was present in a given corpus and that
symbol gained a *DEFAULT* version V in the second corpus, we should
not consider that a new symbol S was added (and that the former S was
removed) because:

  1/ S was already present in the first corpus
  2/ applications linked to the first corpus and that were using S
  (with no version) there, will automatically use the S with version V
  in the second corpus, without needing any re-linking; the
  power of symbol versioning!

Rather, it's just that S gained a default symbol version.

This patch implements that.

	* include/abg-corpus.h (corpus::{lookup_function_symbol,
	lookup_variable_symbol}): Take a elf_symbol::version object,
	rather than a string representing the version.  Add an overload
	that takes an elf_symbol.
	* src/abg-corpus.cc (find_symbol_by_version): New static function.
	(corpus::{lookup_function_symbol, lookup_variable_symbol}): Take a
	elf_symbol::version object, rather than a string representing the
	version.  Add an overload that takes an elf_symbol.  If the looked
	up symbol has no version and if the corpus contains a symbol with
	the same name and with a default version, then return that latter
	symbol if the corpus doesn't contain a symbol with the same name
	and empty version.
	* src/abg-comparison.cc
	(class_diff::ensure_lookup_tables_populated): Adjust.
	(corpus_diff::priv::ensure_lookup_tables_populated): Before
	deciding that a symbol has been added, if the symbol has a default
	version, make sure no symbol with the same name and without
	version was present in the former corpus.  Similarly, before
	deciding that a symbol has been removed, if the symbol has no
	version, make sure the latter corpus has no symbol with the same
	name and with a default version.
	* tests/data/test-diff-dwarf/test12-report.txt: Adjust.  The
	function should not be considered as added, because its symbol
	(and version) was already present in the former DSO.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-24 14:04:11 +02:00