Commit Graph

10 Commits

Author SHA1 Message Date
Dodji Seketeli
6eb2b268f8 Allow selective resolution of class declaration
When a class is forward-declared, resolving it to a definition that
appears later in the same translation unit or in another translation
is an interesting problem.

Until now, the declaration would be resolved to the definition of that
class found in the binary.  The problem is that there can be different
such definitions, especially in C where there is no "One Definition
Rule".  In that case, the definition chosen is random.

This patch resolves that randomness.

For a given class declaration, if there is just one possible
definition in the binary, then the declaration is resolved to that
definition.  If there is one definition for that declaration in the
same translation unit, then the declaration is resolved to that
definition.  If there are more than one definitions in translation
units that are not the one of the declaration, then the declaration is
left unresolved.  This is what I call "selective class declaration resolution".

Note that an unresolved class declaration now compares different to a
definition of a class of the same name.  This is so that we can have
an unresolved class be present in the resulting .abi file, alongside
an (incompatible) definition of the same class.  The change from a class
declaration to its definition is filtered out by default, though.

	* include/abg-fwd.h (type_base_wptrs_type)
	(istring_type_base_wptrs_map_type): Define new typedefs.
	(lookup_class_types): Declare new functions.
	* include/abg-ir.h
	(environment::decl_only_class_equals_definition): Declare new
	accessor.
	(type_maps::{*_types}): Make these accessors return
	istring_type_base_wptrs_map_type& instead of
	istring_type_base_wptr_map_type&.
	* src/abg-dwarf-reader.cc
	(read_context::resolve_declaration_only_classes): Implement the
	new selective declaration resolution scheme.
	* src/abg-ir.cc (type_maps::priv::{*_types_}): Change the type of
	these data members from istring_type_base_wptr_map_type to
	istring_type_base_wptrs_map_type.
	(type_maps::{*_types}): Make these accessors definitions return
	istring_type_base_wptrs_map_type& instead of
	istring_type_base_wptr_map_type&.
	(translation_unit::bind_function_type_life_time): Adjust.
	(environment::priv::decl_only_class_equals_definition_): New data
	member.
	(environment::priv::priv): Initialize it.  By default, a decl-only
	class is now considered different from its definition.
	(environment::decl_only_class_equals_definition): Define new
	accessor.
	(lookup_types_in_map, lookup_class_types): Define new functions.
	(lookup_type_in_map, lookup_union_type_per_location)
	(lookup_basic_type, lookup_basic_type_per_location)
	(lookup_class_type, lookup_class_type_per_location)
	(lookup_union_type, lookup_enum_type)
	(lookup_enum_type_per_location, lookup_typedef_type)
	(lookup_typedef_type_per_location, lookup_qualified_type)
	(lookup_pointer_type, lookup_reference_type, lookup_array_type)
	(lookup_function_type, maybe_update_types_lookup_map)
	(maybe_update_types_lookup_map<class_decl>)
	(maybe_update_types_lookup_map<function_type>): Adjust.
	(type_base::get_canonical_type_for): When doing type comparison
	here, we can now consider that an unresolved class declaration
	compares different to an incompatible class definition of the same
	name.  So no need to look through decl-only classes in that case.
	(equals): In the overload for class_or_union, if
	environment::decl_only_class_equals_definition() is false, then an
	unresolved class declaration of name "N" compares different to a
	class definition named "N".
	* tests/data/test-annotate/test15-pr18892.so.abi: Adjust.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust.
	* tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt:
	Adjust.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt:
	Adjust.
	* tests/data/test-diff-filter/test38/Makefile: New test material.
	* tests/data/test-diff-filter/test38/test38-a.c: Likewise.
	* tests/data/test-diff-filter/test38/test38-b.c: Likewise.
	* tests/data/test-diff-filter/test38/test38-c.c: Likewise.
	* tests/data/test-diff-filter/test38/test38-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test38/test38-v0: Likewise.
	* tests/data/test-diff-filter/test38/test38-v1: Likewise.
	* tests/data/test-diff-filter/test38/test38.h: Likewise.
	* tests/data/test-diff-filter/test39/Makefile: Likewise.
	* tests/data/test-diff-filter/test39/test39-a-v0.c: Likewise.
	* tests/data/test-diff-filter/test39/test39-a-v1.c: Likewise.
	* tests/data/test-diff-filter/test39/test39-b-v0.c: Likewise.
	* tests/data/test-diff-filter/test39/test39-b-v1.c: Likewise.
	* tests/data/test-diff-filter/test39/test39-c-v0.c: Likewise.
	* tests/data/test-diff-filter/test39/test39-c-v1.c: Likewise.
	* tests/data/test-diff-filter/test39/test39-main.c: Likewise.
	* tests/data/test-diff-filter/test39/test39-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test39/test39-v0: Likewise.
	* tests/data/test-diff-filter/test39/test39-v1: Likewise.
	* tests/data/test-diff-filter/test39/test39.h: Likewise.
	* tests/data/Makefile.am: Add the new test material above to the
	source distribution.
	* tests/test-diff-filter.cc (in_out_specs): Add the new test
	inputs above to the test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:46 +02:00
Dodji Seketeli
5529a51a96 Do not report about voffset when it's not set in debug info
Sometimes some virtual member functions don't have any virtual offset
set in the debug info.  This happens for virtual destructors
sometimes.  In that case, the ABI change report should not refer to
that unset virtual offset as being '0'.  Rather, it shouldn't refer to
it at all.

This is what this patch does.

	* include/abg-ir.h (mem_fn_context_rel::mem_fn_context_rel):
	Initialize the virtual offset to -1.
	* src/abg-comparison.cc (represent): In the overload to represent
	a method_decl, do not represent the vofffset if it's not set.
	* src/abg-writer.cc (write_voffset): The virtual offset is signed
	because if it's -1, it means no offset is set.
	* tests/data/test-annotate/test14-pr18893.so.abi: Adjust.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Adjust.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Adjust.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Adjust.
	* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi:
	Adjust.
	* tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt: Adjust.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Adjust.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Adjust.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Adjust.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Adjust.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Adjust.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:44 +02:00
Dodji Seketeli
4672ba4f4c Speedup DIE representation computing esp function signature in C
For DIE originating from C, we now compute canonical DIEs.  We then
use that to compare DIEs to see if they are equal or not.  So string
representation of DIEs are now used only to reduce the number of DIEs
comparisons that is performed during DIE canonicalization.

We can thus just use function names (rather than a full
die_function_signature) as a way to reduce the number of structural
comparisons of DIEs during canonicalization.

This patch does just that.

Note that in the future when we perform DIEs canonicalization and comparison for
C++, we can avoid computing full function DIE signatures for C++ too.

	* src/abg-dwarf-reader.cc (die_function_signature): For C DIEs,
	just return the (linkage) name of the function.
	* tests/data/test-annotate/test15-pr18892.so.abi: Adjust.
	* tests/data/test-annotate/test21-pr19092.so.abi: Adjust.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:43 +02:00
Dodji Seketeli
b555713b47 Avoid de-duplicating different C types that have identical name
This patch introduces the concept of canonical DIEs.

To date, when two C types have the same string representation [1] and
are defined at the same location, they are considered to be the same,
just as in C++.

[1]: String representation of a type: For a type named
"Foo" that is a structure, the representation is "struct Foo"

This patch introduces more finesse in determining if two types are
different.

It implements comparing the DIEs of the types, directly from the DWARF
representation.  When comparing pointers, typedefs and qualified
types, the underlying type is compared recursively.

The type de-duplication scheme is now centered around two data
structures.

    1/ A map that associates the string representation of a type with
    a vector of the offsets of the type DIEs that have the same
    representation.  Members of this vector denotes DIEs of types that
    are *different* even if they all have the same representation.
    Each DIE in a given vector is the canonical DIE of its class of
    equivalence.  This map is the map of all canonical DIEs organized
    by the representation of those canonical DIEs.

    2/ A map that associates the offset of the canonical type DIE with
    the resulting internal representation of the type.  Here, the
    internal representation is an instance of the
    abigail::ir::type_base type.  This map is the map of the types
    associated to the canonical type DIEs.

There is also a vector that associates a DIE 'D' to its canonical DIE
'C'.  The index of the vector is the offset of 'D' and the value of
the element at that index is 'C'.

Thus, each time we are about to create (or get) an internal
representation for a type DIE denoted 'D', we first get the canonical
DIE of 'D', denoted C.  If C doesn't exist, we create it.  That is, we
add a new entry in the map 1/.  Then we look in map 2/ to see if the C
(and thus D) has a associated type.

If C has an associated type, we return it.

If C has no associated type, we create a type for it (and thus for D)
and we associate the new type to the offsets of both D and C.

The rest of the patch is mostly boiler plate and adjustment to
accomodate this new de-duplication scheme.

	* src/abg-dwarf-reader.cc (die_decl_map_type, die_type_map_type):
	Remove these typedefs.
	(die_artefact_map_type, istring_dwarf_offsets_map_type): New
	typedefs.
	(die_is_at_class_scope, die_qualified_type_name)
	(die_qualified_decl_name, die_qualified_type_name_empty)
	(die_return_and_parm_names_from_fn_type_die)
	(die_function_type_is_method_type):
	Const-ify the read_context& parameter.
	(read_context::die_source_dependant_container_set::get_container):
	Likewise.
	(read_context::{name_artefacts_map_, per_tu_name_artefacts_map_,
	die_decl_map_, alternate_die_decl_map_, type_unit_die_decl_map_,
	die_type_map_, alternate_die_type_map_, type_unit_die_type_map_}):
	Remove data members.
	(read_context::{die_decl_map, alternate_die_decl_map,
	associate_die_to_decl_primary, associate_die_to_decl_alternate,
	associate_die_to_decl_from_type_unit,
	lookup_decl_from_die_offset_primary,
	lookup_decl_from_die_offset_alternate,
	lookup_decl_from_type_unit_die_offset,
	lookup_type_artifact_from_die_per_tu,
	lookup_artifact_from_per_tu_die_representation,
	associate_die_to_artifact_by_repr,
	associate_die_to_artifact_by_repr_internal, clear_die_type_maps}):
	Remove member functions.
	(read_context::{decl_die_repr_die_offsets_maps_,
	type_die_repr_die_offsets_maps_, decl_die_artefact_maps_,
	type_die_artefact_maps_, dwarf_expr_eval_context_}): Add new data
	members.
	(read_context::clear_per_translation_unit_data): Don't clear
	read_context::per_tu_name_artefacts_map_ data member as it's
	removed.
	(read_context::clear_per_corpus_data): Don't clear
	read_context::name_artefacts_map_ and all the other relevant data
	members that got removed.
	(read_context::{dwarf_per_die_source,
	decl_die_repr_die_offsets_maps, type_die_repr_die_offsets_maps,
	get_canonical_die, get_die_from_offset, decl_die_artefact_maps,
	type_die_artefact_maps, dwarf_expr_eval_ctxt}): Add new member
	functions.
	(compare_dies, compare_as_decl_dies)
	(compare_as_type_dies, maybe_finish_function_decl_reading)
	(die_is_anonymous): Define new functions.
	(read_context::associate_die_to_decl): Remove the
	do_associate_by_repr_per_tu parameter.  Use the new
	read_context::{decl_die_artefact_maps_, get_canonical_die} member
	functions.
	(read_context::lookup_decl_from_die_offset): Use Dwarf_Off rather
	than size_t for the type of the die_offset parameter.  Use the
	lookup_artifact_from_die_offset member function.
	(read_context::lookup_type_artifact_from_die): Const-ify.  In one
	overload, take a new 'die_as_type' parameter.  Use the new
	get_canonical_die, type_die_artefact_maps and
	decl_die_artefact_maps member functions.  In the second overload,
	use the first overload.
	(read_context::odr_is_relevant): Add an overload that takes a DIE.
	(read_context::associate_die_to_type): Remove the
	do_associate_by_repr and do_associate_per_tu parameters.  Use the
	new get_canonical_die and type_die_artefact_maps member functions.
	(read_context::lookup_type_from_die): Use the new
	lookup_artifact_from_die member function.
	(read_context::lookup_type_from_die_offset): Use the new
	type_die_artefact_maps member function.  When the found artifact
	is a function_decl, return its type.
	(read_context::schedule_type_for_late_canonicalization):  Use the
	new get_canonical_die and type_die_artefact_maps member functions.
	(die_function_signature): Const-ify.  Get the scope name right
	even for scopes that are not types.
	(die_member_offset): Make eval_last_constant_dwarf_sub_expr use
	the new cached DWARF expression evalution context.
	(get_parent_die): Support where_offset equals to zero.  This means
	we are looking at a C binary, basically.
	(build_enum_type) : Use the new overload of
	read_context::odr_is_relevant that takes a DIE.  Adjust.
	(add_or_update_union_type, add_or_update_class_type): Don't lookup
	classes/unions per location anymore.  Now that we can compare DIEs
	in a fined grain manner, the approximation of the location is not
	useful anymore.
	(build_pointer_type)
	(build_function_type): Associate DIE to type if we reuse an
	existing type.
	(build_or_get_fn_decl_if_not_suppressed):  When re-using a
	function decl internal representation from an equivalent DIE that
	we've seen before, it can happen that we want to augment that
	function decl internal representation with new properties coming
	from the DIE we are currently looking at; do that here.
	(is_function_for_die_a_member_of_class): Remove the "where_offset"
	parameter.
	(add_or_update_member_function): Adjust.
	* tests/data/test-annotate/libtest23.so.abi: Adjust.
	* tests/data/test-annotate/test13-pr18894.so.abi: Adjust.
	* tests/data/test-annotate/test14-pr18893.so.abi: Adjust.
	* tests/data/test-annotate/test15-pr18892.so.abi: Adjust.
	* tests/data/test-annotate/test17-pr19027.so.abi: Adjust.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Adjust.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Adjust.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Adjust.
	* tests/data/test-annotate/test21-pr19092.so.abi: Adjust.
	* tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt: Adjust.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-0.txt: Adjust.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-1.txt: Adjust.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Adjust.
	* tests/data/test-read-dwarf/libtest23.so.abi: Adjust.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Adjust.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Adjust.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Adjust.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Adjust.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Adjust.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Adjust.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Adjust.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Adjust.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Adjust.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Adjust.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:42 +02:00
Dodji Seketeli
1d6cb6fdbc Adjust test reference outputs after changes in abg-writer.cc
After the latest commits to avoid emitting empty translation units and
dupicated decls, and also to fix some indention issues in the abixml
output, this patch updates the reference outputs of the abixml
regression tests.

	* tests/data/test-annotate/test13-pr18894.so.abi: Adjust.
	* tests/data/test-annotate/test14-pr18893.so.abi: Adjust.
	* tests/data/test-annotate/test15-pr18892.so.abi: Adjust.
	* tests/data/test-annotate/test17-pr19027.so.abi: Adjust.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Adjust.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Adjust.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Adjust.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Adjust.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Adjust.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:39 +02:00
Dodji Seketeli
a2a6d7e56a Update the reference output of regression tests after kabidiff work
* tests/data/test-annotate/test0.abi: Adjust.
	* tests/data/test-annotate/test13-pr18894.so.abi: Adjust.
	* tests/data/test-annotate/test14-pr18893.so.abi: Adjust.
	* tests/data/test-annotate/test15-pr18892.so.abi: Adjust.
	* tests/data/test-annotate/test17-pr19027.so.abi: Adjust.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Adjust.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Adjust.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Adjust.
	* tests/data/test-annotate/test21-pr19092.so.abi: Adjust.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Adjust.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-0.txt: Adjust.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-1.txt: Adjust.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Adjust.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Adjust.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Adjust.
	* tests/data/test-read-dwarf/test0.abi: Adjust.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Adjust.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Adjust.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Adjust.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Adjust.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Adjust.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Adjust.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Adjust.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Adjust.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Adjust.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Adjust.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:37 +02:00
Dodji Seketeli
d65585a772 Fix virtual members sorting to unbreak the build on EL6
When two virtual members functions have the same virtual index, the
same pretty representation, and one of them has no ELF symbols, then
they might be sorted in a way or in an other.  This sorting hazard
breaks the runtestreaddwarf test on EL6.

This patch addresses that to make the virtual member function that has
no ELF symbol to come before the one with an ELF symbol.

Also, it turned out that runtestannotate is broken on EL6 too because
we are trying to demangle c++11-mangled symbols in there, and the
demangler (which is C++<11 only) on that platform doesn't really like
that.  So this patch removes the tests in which there are c++11 symbols
that we try to demangle.

	* src/abg-ir.cc (virtual_member_function_less_than::operator()):
	Update comment.  When two virtual functions have the same virtual
	index and one of them has no ELF symbol, then that function is
	less than the one with an ELF symbol.
	* tests/data/Makefile.am: Remove
	test-annotate/{test9-pr18818-clang.so.abi, test11-pr18828.so.abi,
	test12-pr18844.so.abi, test16-pr18904.so.abi,
	test22-pr19097-libstdc++.so.6.0.17.so.abi}.
	* tests/data/test-annotate/test10-pr18818-gcc.so.abi: Remove.
	* tests/data/test-annotate/test11-pr18828.so.abi: Likewise.
	* tests/data/test-annotate/test12-pr18844.so.abi: Likewise.
	* tests/data/test-annotate/test16-pr18904.so.abi: Likewise.
	* tests/data/test-annotate/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.
	* tests/test-annotate.cc (in_out_specs):  Remove those tests above
	which input files have been removed.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-03-03 12:56:44 +01:00
Dodji Seketeli
059c86ec0b Bug 20476 - Compare virtual member functions when comparing classes
There are cases where a virtual member function doesn't have an
implementation that is defined and publicly exported.  This is the
cases for virtual pure classes.

Even in those cases, users might want to detect vtable changes on
virtual member pure classes (interfaces).

Now that, for C++ binaries, all the partial representations of a class
are merged into one class (in a given binary), we can envision to
compare virtual member functions of classes as part of comparing two
classes.

This is what this patch does.  While comparing two classes, the
virtual member functions are compared too.

Note that as there can be several virtual member functions that have
the same vtable offset (think about a virtual destructor that might
have several generated functions that 'conceptually' share the same
vtable offset), comparing the virtual functions can be a little bit
non-trivial.

The approach taken is to check that in the first set of virtual
functions, each virtual function actually matches at least one virtual
function in the second set.  And the match is a "loose" one.  That is,
it doesn't take into account the symbol name or the mangled name.

The patch also fixes the "less than" operator used to sort virtual
member functions.

There is also a buglet in the way we compute the highest vtable offset
number today.  This patch provides a new function named
class_decl::get_biggest_vtable_offset that is used in the change reports.

The patch also fixes a related bug in where we were forgetting to
report about added and removed virtual member functions without an
associated elf symbol.  This patch fixes that.

	* include/abg-ir.h (class_decl::get_biggest_vtable_offset):
	Declare new member function.
	* src/abg-ir.cc (virtual_member_function_less_than::operator()):
	Either compare the symbol id strings if the functions have
	symbols or just compare their pretty representations.
	(class_decl::get_biggest_vtable_offset): Define new member
	function.
	(methods_equal_modulo_elf_symbol)
	(method_matches_at_least_one_in_vector): New static methods.
	(equals): In the overload for classes, compare the virtual member
	functions while comparing classes.
	* src/abg-comparison.cc (represent): In the overload for
	method_decl_sptr, fix the way we compute the highest vtable offset
	number for a give class_decl.
	(class_decl::ensure_lookup_tables_populated): Don't forget added
	and removed virtual member functions in the report for changed
	classes.
	* tests/data/test-diff-dwarf/libtest41-PR20476-hidden-old.so: New
	test binary input file.
	* tests/data/test-diff-dwarf/libtest41-PR20476-hidden-new.so: Likewise.
	* tests/data/test-diff-dwarf/test41-PR20476-hidden-report-0.txt:
	New reference output.
	* tests/data/Makefile.am: Add the new test material above to the
	source distribution.
	* tests/test-diff-dwarf.cc (in_out_spec): Add the new tests
	here.
	* tests/data/test-annotate/test10-pr18818-gcc.so.abi: Adjust.
	* tests/data/test-annotate/test11-pr18828.so.abi: Adjust.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Adjust.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Adjust.
	* tests/data/test-annotate/test22-pr19097-libstdc++.so.6.0.17.so.abi: Adjust.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Adjust.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Adjust.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Adjust.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Adjust.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Adjust.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Adjust.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Adjust.
2017-02-14 12:49:47 +01:00
Dodji Seketeli
1e1b3159a0 Adjust reference output of test-annotate
* tests/data/test-annotate/test15-pr18892.so.abi: Adjust this
	reference output.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-13 22:14:54 +01:00
Ondrej Oprala
aba99e5106 Bug 20970 - Add a --annotate option to abidw
This option annotates (read "pretty-prints") the types and elf symbols
in the form of XML comments in the ABIXML output emitted by the abidw
command.

Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>

	* doc/manuals/abidiff.rst: Document the '--no-corpus-path'
	option.
	* doc/manuals/abidw.rst: Document the '--no-corpus-path'
	and '--annotate' options.
	* include/abg-libxml-utils.h ({un,}escape_xml_comment): Add
	new function declarations.
	* include/abg-writer.h: Add new annotate functions
	(write_{translation_unit,corpus_to_{archive,native_xml_file}}):
	Add an optional "annotate" parameter defaulting to "false".
	* src/abg-libxml-utils.cc ({un,}escape_xml_comment): Add
	new function definitions.
	* src/abg-writer.cc (annotate): Define new templatized function
	and specialize it for necessary cases.
	* tests/Makefile.am: Add runtestannotate as a new test.
	* tests/data/Makefile.am: Add paths to below reference test
	outputs.
	* tests/data/test-annotate/libtest23.so.abi: New reference test
	output.
	* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Likewise.
	* tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-annotate/test0.abi: Likewise.
	* tests/data/test-annotate/test1.abi: Likewise.
	* tests/data/test-annotate/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-annotate/test11-pr18828.so.abi: Likewise.
	* tests/data/test-annotate/test12-pr18844.so.abi: Likewise.
	* tests/data/test-annotate/test13-pr18894.so.abi: Likewise.
	* tests/data/test-annotate/test14-pr18893.so.abi: Likewise.
	* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
	* tests/data/test-annotate/test16-pr18904.so.abi: Likewise.
	* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise.
	* tests/data/test-annotate/test2.so.abi: Likewise.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
	* tests/data/test-annotate/test22-pr19097-libstdc++.so.6.0.17.so.abi: Likewise.
	* tests/data/test-annotate/test3.so.abi: Likewise.
	* tests/data/test-annotate/test4.so.abi: Likewise.
	* tests/data/test-annotate/test5.o.abi: Likewise.
	* tests/data/test-annotate/test6.so.abi: Likewise.
	* tests/data/test-annotate/test7.so.abi: Likewise.
	* tests/data/test-annotate/test8-qualified-this-pointer.so.abi: Likewise.
	* tests/data/test-annotate/test9-pr18818-clang.so.abi: Likewise.
	* tests/test-annotate.cc: New test for ABIXML annotations.
	* tools/abidiff.cc: Add the new option '--no-corpus-path'.
	* tools/abidw.cc: Likewise. Also add the '--annotate' option.

reviews round 1

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-24 15:41:37 +01:00