Commit Graph

378 Commits

Author SHA1 Message Date
Dodji Seketeli
ccdc44b3eb Setup per-corpus type maps indexed by type names
This patch creates per-corpus maps that associate, for a certain kind
of type, the fully qualified name of the type to the type.

So there is a map for class_decl, one for enum_type_decl, one for
type_decl, etc.

These maps are populated when a new type is added to its scope.

The patch defines overloads of the function
maybe_update_types_lookup_map() that update the right map, depending
on the kind of type we are looking at.

Note that there also is a map in each class that associates a
signature string to a member functions.  This is so that member
functions of a given class can be looked up by signature.

This is so that looking up a type becomes now much faster than having
to walk all the translation units of a corpus to find one.

Note that this patch is specifically part of the series of patches
that implements types and declarations de-duplication while reading
DWARF information.

The patch might slightly change the output of abi serialization or
comparison so it needs some adjustments of some test reference files.
That adjustment is not done here.  Rather, it's done at once in
another patch of the set.

	* include/abg-corpus.h (corpus::priv_): Make this public so that
	functions from outside of the class can access it.  These
	functions are meant to be used only by code that is *inside*
	libabigail.so, though.
	* src/abg-corpus-priv.h: New file.
	* src/abg-corpus.cc: Include the new abg-corpus-priv.h file.
	(struct regex_t_deleter): Move this to abg-sptr-utils.h.
	(build_sptr<regex_t>): Move the declaration of this function
	template specialization to abg-sptr-utils.h and its definition to
	abg-sptr-utils.cc.
	(typedef regex_t_sptrs_type, typedef str_var_ptr_map_type)
	(struct corpus::exported_decls_builder::priv, struct
	corpus::priv): Move these declarations to the new
	abg-corpus-priv.h.
	(maybe_update_types_lookup_map): Define overloads of this (one per
	kind of type).
	(lookup_{basic, class, enum, typedef, class_or_typedef,
	class_typedef_or_enum, qualified, pointer, reference, array,
	function}_type): Define new functions.
	* include/abg-ir.h (typedef istring_type_base_wptr_map_type)
	(typedef istring_type_or_decl_base_sptr_map_type): Declare new
	typedefs.
	(class_decl::find_member_function_from_signature): Declare new
	member function.
	* src/abg-ir.cc: Include the new abg-corpus-priv.h file.
	(maybe_update_types_lookup_map): Remove this initial function.
	There are now new overloads in abg-corpus.cc for it.
	(scope_decl::{add_member_decl, insert_member_decl}): Adjust.
	(class_decl::{set_is_declaration_only, find_member_function,
	add_member_function}): Adjust.
	(class_decl::find_member_function_from_signature): Define new
	member function.
	* include/abg-sptr-utils.h (struct regex_t_deleter): Declare new
	type.
	(build_sptr<regex_t>): New build function template
	specializations.
	* src/abg-sptr-utils.cc: New file.
	* src/Makefile.am: Add src/abg-sptr-utils.cc and
	src/abg-corpus-priv.h to the build system.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-29 16:16:43 +01:00
Dodji Seketeli
f27520d767 A suppressed diff node implies suppressing all equivalent nodes too
When a diff node N is suppressed (for instance, using the
--headers-dir{1,2} option of abidiff}, it's only that diff node that
is suppressed.  We forget to suppress diff nodes that are equivalent
to N.

Here is why we forget to suppress diff ndoes that are equivalent.

apply_suppressions walks the diff node graph to mark diff nodes as
suppressed.  But it does the walking by making sure each diff node's
*class of equivalence* is visited once.  This is not only a way to
prevent infinite loops while visiting the graph, but also an
optimization as it avoids walking two equivalent diff nodes.

But then it can happen that we forget to categorize some diff nodes
inside a given class of equivalence, even though we categorized some
others.

This patch makes it so that when a diff node inside a class of
equivalence is categorized as SUPPRESSED, the canonical diff node of
that class of equivalence is categorized as SUPPRESSED too.  That way,
to know if a diff node is suppressed, we just need to look at its
canonical diff node.

While doing this, I noticed that abidiff and abipkgdiff are not
dropping private types from libabigail's internal representation, even
though the Library now has that capability.  The patch fixes that.
But then the patch adds a --dont-drop-private-types option to abidiff
to avoid dropping those private types from the IR, so that regression
tests can make sure that a suppressed diff node implies suppression
all equivalent nodes too.

	* doc/manuals/abidiff.rst b/doc/manuals/abidiff.rst: Document the
	new --dont-drop-private-types option.
	* src/abg-comparison.cc (diff::is_filtered_out): If the canonical
	type was suppressed then the current diff node is filtered out.
	(suppression_categorization_visitor::visit_{begin,end}):
	Categorized the canonical node as SUPPRESSED if the current node
	is suppressed.
	* tools/abidiff.cc (options::drop_private_types): New data member.
	(options::options): Initialize it.
	(display_usage): Add new help string for the new
	--dont-drop-private-types option.
	(parse_command_line): Parse the new --dont-drop-private-types
	option.
	(set_suppressions): Generate suppression specification from header
	directories given in parameter and stick them to the read context.
	* tools/abipkgdiff.cc (compare): Likewise.
	* tests/data/test-diff-suppr/libtest34-v0.so: New test input.
	* tests/data/test-diff-suppr/libtest34-v1.so: Likewise.
	* tests/data/test-diff-suppr/test34-report-0.txt: New reference
	report.
	* tests/data/test-diff-suppr/test34-v0.c: Source code for the new
	test input.
	* tests/data/test-diff-suppr/test34-v1.c: Likewise.
	* tests/data/test-diff-suppr/test34-priv-include-dir-v0/test34-priv-include-v0.h:
	Likewise.
	* tests/data/test-diff-suppr/test34-priv-include-dir-v1/test34-priv-include-v1.h:
	Likewise.
	* tests/data/test-diff-suppr/test34-pub-include-dir-v0/test34-pub-include-v0.h:
	Likewise.
	* tests/data/test-diff-suppr/test34-pub-include-dir-v1/test34-pub-include-v1.h:
	Likewise.
	* tests/data/Makefile.am: Add new test input material above to
	source distribution.
	* tests/test-diff-suppr.cc (in_out_spec): Compare the two new test
	library provided.  Add --dont-drop-private-types to test30*.

signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-26 11:54:19 +01:00
Dodji Seketeli
eac363eb66 Forgot to consider libtest33-v{0,1}.so in test-diff-suppr.cc
I forgot the make test-diff-suppr.cc run over libtest33-v{0,1}.so even
though this test was added to the source distribution.  Fixed thus.

	* tests/data/test-diff-suppr/test33-report-0.txt: New refernce report.
	* tests/test-diff-suppr.cc (in_out_specs): Compare libtest33-v0.so
	and libtest33-v1.so.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-26 10:37:19 +01:00
Dodji Seketeli
09a15b6e60 Support reading data member offset from DW_AT_bit_offset
There are times where the DW_AT_data_member_location attribute is set
to zero and where the actual offset of the data member is the value of
the DW_AT_bit_offset.  This seems to be happening when a union type is
involved.

To get the offset of a data member, this patch makes us read the
DW_AT_bit_offset when it's present.  Otherwise, it gets the offset
from the DW_AT_data_member_location as we used to do.

In the passing the patch fixes the offset of base classes; the
nubmer of bytes value was what was being used, rather than the number
bits value.

	* src/abg-dwarf-reader.cc (die_member_offset): Better comments.
	Support reading the bit offset also from the DW_AT_bit_offset
	attribute when it's present.  Make sure this always returns a
	value in bits.
	(build_class_type_and_add_to_ir): No need to multiply (by 8) the
	value returned by die_member_offset anymore because it's now in
	bits directly.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Adjust.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Adjust.
	* tests/data/test-read-dwarf/test1.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/test19-pr19023-libtcmalloc_and_profiler.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.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-24 15:25:43 +01:00
Dodji Seketeli
630c334705 Lexicographically sort union data members in change reports
Until now, when reporting about struct or union changes, data members
were sorted by using their offset; the data member with the smallest
offset coming first.

But then in unions, all data member have the same offset.  In that
case, the patch sort them lexicographically, by taking their name into
account.

	* src/abg-comparison.cc (data_member_comp::operator()): Data
	members with the same offset are sorted lexicographically, by
	taking their name into account.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt:
	Adjust.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt:
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-23 15:00:51 +01:00
Dodji Seketeli
e7c920edbc Support union types
This patch makes Libabigail understand C and C++ union types.  It
defines a new class abigail::ir::union_decl to represent the
declaration of a union type.  It also defines a new type
abigail::comparison::union_diff to represent the changes between two
union types.  The patch then adds facilities to read union types from
DWARF and abixml and also to write union types into the abixml format.

As union types and class types have a lot in common, the patch tries
very hard to share code between the abigail::ir::class_decl and
abigail::ir::union_decl.  To do so, a new class
abigail::ir::class_or_union is created.  It's the base class for both
abigai::ir::class_decl and abigail::ir::union_decl.  Its data members
and methods represent the set of data and behaviour that are common to
classes and unions.  A lot of code and data that were initially in
abigail::ir::class_decl got moved into the new
abigail::ir::class_or_union class.

Similary, the patch creates a new class
abigail::comparison::class_or_union_diff that is a base class for both
the existing class abigail::comparison::class_diff and the newly
created class abigail::comparison::union_diff.  The new class
abigail::comparison::class_or_union_diff contains data and behaviour
that are common to both union_diff and class_diff and that were
previously in class_diff.

The rest of the patch is mostly adjustment so that code that was
supposed to work with class class_decl only can now work with class
class_or_union when it makes sense.  Similarly for class_diff and
class_or_union_diff.

The patch adds regression tests into the test suite and adjust many
existing tests involving binaries that contain union types; the
reference output of those tests now take union types into account.

	* include/abg-fwd.h (class_or_union, union_decl): Forward-declare
	new types.
	(is_class_or_union_type, is_union_type): Declare new functions.
	* include/abg-ir.h (method_type::class_type_): Make this be of
	class_or_union_wptr type.
	(method_type::method_type): Make the class_type parameter be of
	class_or_union_wptr type.
	(method_type::{g,s}et_class_type): Take or return a
	class_or_union_sptr.
	(member_base, method_decl, member_function_template)
	(member_class_template, member_base::hash)
	(member_function_template::hash, member_class_template::hash):
	Take these class types out of the class_decl scope.
	(is_method_decl): Adjust.
	(operator==, opertor!=): Adjust overloads for
	member_function_template_sptr and member_class_template_sptr.
	(class class_or_union): Declare new type.
	(class class_decl): Make this class inherit class_or_union class.
	(class_decl::{add_member_decl, insert_member_decl,
	remove_member_decl, set_size_in_bits, get_size_in_bits,
	get_alignment_in_bits, set_alignment_in_bits,
	get_is_declaration_only, set_is_declaration_only,
	set_definition_of_declaration, get_definition_of_declaration,
	get_earlier_declaration, set_earlier_declaration,
	insert_member_type, add_member_type, remove_member_type,
	get_member_type, find_member_type, add_data_member,
	get_data_members, find_data_member, get_non_static_data_members,
	add_member_function, get_member_functions, find_member_function,
	add_member_function_template, get_member_function_templates,
	add_member_class_template, get_member_class_templates): Move these
	to the parent class class_or_union.
	(copy_member_function, equals): Add overloads for class_or_union.
	(struct class_or_union::hash): Declare new type.
	(class union_decl): Declare new type.
	(equals, copy_member_function): New overloads for class union_decl
	type.
	(ir_node_visitor::visit): Add new overloads for union_decl* and
	class_or_union*.
	* src/abg-ir.cc (get_member_function_is_ctor)
	(set_member_function_is_ctor, get_member_function_is_dtor)
	(set_member_function_is_dtor, get_member_function_is_const)
	(set_member_function_is_const, get_member_function_vtable_offset)
	(set_member_function_vtable_offset)
	(get_member_function_is_virtual, set_member_function_is_virtual)
	(maybe_update_types_lookup_map, get_location)
	(get_method_type_name, is_at_global_scope, is_at_class_scope):
	Adjust.
	(is_class_or_union_type, is_union_type): Define new functions.
	(type_base::get_canonical_type_for, maybe_adjust_canonical_type)
	(method_type::method_type, method_type::set_class_type)
	(function_decl::get_pretty_representation)
	(function_decl::get_first_non_implicit_parm)
	(function_decl::clone): Adjust.
	(equals): Adjust the overload for function_type.
	(struct class_or_union::priv): Define new type.
	(class::priv::{declaration_, definition_of_declaration_,
	member_types_, data_members_, non_static_data_members_,
	member_functions_, mem_fns_map_, member_function_templates_,
	member_class_templates_, is_declaration_only_}): Move these data
	member into class_or_union::priv.
	(class_priv::{mark_as_being_compared, unmark_as_being_compared,
	comparison_started}): Moved these member functions to
	class_or_union::priv.
	(class_or_union::{class_or_union, traverse, ~class_or_union,
	add_member_decl, remove_member_decl, insert_member_type,
	add_member_type, get_size_in_bits, remove_member_type,
	get_alignment_in_bits, set_alignment_in_bits, set_size_in_bits,
	get_is_declaration_only, set_is_declaration_only,
	set_definition_of_declaration, get_definition_of_declaration,
	get_earlier_declaration, set_earlier_declaration,
	get_member_types, find_member_type, add_data_member,
	get_data_member, find_data_member, add_member_function,
	get_member_functions, find_member_function,
	add_member_function_template, get_member_function_templates,
	add_member_class_template, get_member_class_templates,
	has_no_member, insert_member_decl, operator==}): Define new member
	functions.
	(class_decl::{add_member_decl, remove_member_decl,
	insert_member_type, add_member_type, get_size_in_bits,
	remove_member_type, get_alignment_in_bits, set_alignment_in_bits,
	set_size_in_bits, get_is_declaration_only,
	set_is_declaration_only, set_definition_of_declaration,
	get_earlier_declaration, set_earlier_declaration,
	get_member_types, find_member_type, add_data_member,
	get_data_member, find_data_member, add_member_function,
	get_member_functions, find_member_function,
	add_member_function_template, get_member_function_templates,
	add_member_class_template, get_member_class_templates): Move these
	member functions into class_or_union.
	(class_decl::{class_decl, get_definition_of_declaration,
	insert_member_decl, add_member_function, has_no_base_nor_member}):
	Adjust.
	(equals, copy_member_function): Define new overloads for
	class_or_union.
	(equals): Adjust the overload for class_decl.
	(method_decl::{method_decl, set_linkage_name, ~method_decl,
	get_type, set_scope}): Remove from the class_decl scope.
	(member_base::operator==, member_function_template::operator==):
	Likewise.
	(member_function_template::traverse)
	(member_class_template::operator==)
	(member_class_template::traverse): Likewise.
	(operator==, operator!=): Adjust the overlod for
	member_function_template_sptr.
	(is_method_decl, fixup_virtual_member_function)
	(set_member_is_static): Adjust.
	(virtual_member_function_less_than::operator()): Likewise.
	(union_decl::{union_decl, get_pretty_representation, operator==,
	traverse}): Define new member functions.
	(equals, copy_member_function): Define new overloads for
	union_decl.
	(hash_type_or_decl): Adjust.
	(ir_node_visitor::visit_{begin, end}): Adjust. Add new overloads
	for class_or_union* and union_decl*.
	* include/abg-comparison.h (changed_member_function_sptr)
	(string_member_function_sptr_map): Adjust these typedefs.
	(class class_or_union_diff): Declare new type.
	(class_diff): Adjust to make this inherit the new
	class_or_union_diff type.
	(class_diff::{get_priv, member_types_changes,
	data_members_changes, inserted_data_members, deleted_data_members,
	member_fn_tmpls_changes, member_fn_tmpls_changes,
	member_class_tmpls_changes}): These member functions got moved
	into -- and shared with -- class_or_union_diff class.
	(class union_diff): Declare new type.
	(typedef union_diff_sptr): New typedef.
	(compute_diff): New overload for union_diff
	(is_class_diff, is_union_diff): Declare new functions.
	* src/abg-comparison.cc (is_class_diff, is_union_diff): Define new
	functions.
	(compute_diff_for_types): Support union_decl.
	(represent):  Adjust.
	(represent_data_member): Do not show offset information for data
	members of unions as all union data members are at offset 0.
	(struct class_or_union_diff::priv): New type.
	(class_or_union_diff::priv::{member_type_has_changed,
	subtype_changed_dm, member_class_tmpl_has_changed,
	get_deleted_non_static_data_members_number,
	get_inserted_non_static_data_members_number,
	count_filtered_subtype_changed_dm, count_filtered_changed_dm,
	count_filtered_changed_mem_fns, count_filtered_inserted_mem_fns,
	count_filtered_deleted_mem_fns}): Define new member functions.
	(class_or_union_diff::{class_or_union_diff, finish_diff_type,
	lookup_tables_empty, lookup_tables_empty,
	ensure_lookup_tables_populated, allocate_priv_data, get_priv,
	~class_or_union_diff, first_class_or_union, second_class_or_union,
	member_types_changes, member_types_changes, data_members_changes,
	inserted_data_members, deleted_data_members, member_fns_changes,
	changed_member_fns, member_fns_changes, inserted_member_fns,
	member_fn_tmpls_changes, member_fn_tmpls_changes,
	member_class_tmpls_changes, member_class_tmpls_changes,
	has_changes, has_local_changes, report, chain_into_hierarchy}):
	Define new member functions.
	(class_diff::priv::{member_types_changes_, data_members_changes,
	member_fn_tmpls_changes_, member_class_tmpls_changes_,
	deleted_member_types_, inserted_member_types_,
	changed_member_types_, sorted_changed_member_types_,
	deleted_data_members_, deleted_dm_by_offset_,
	inserted_data_members_, inserted_dm_by_offset_,
	subtype_changed_dm_, sorted_subtype_changed_dm_, changed_dm_,
	sorted_changed_dm_, deleted_member_functions_,
	inserted_member_functions_, changed_member_functions_,
	sorted_changed_member_functions_, deleted_member_class_tmpls_,
	inserted_member_class_tmpls_, changed_member_class_tmpls_,
	sorted_changed_member_class_tmpls_}): Move these data members into
	class_or_union_diff::priv.
	(class_diff::{clear_lookup_tables, lookup_tables_empty,
	ensure_lookup_tables_populate}): Adjust.
	(class_diff::allocate_priv_data): Define new function.
	(class_diff::priv::{count_filtered_changed_mem_fns,
	count_filtered_inserted_mem_fns, count_filtered_deleted_mem_fns,
	chain_into_hierarchy, class_diff}): Likewise.
	(class_diff::{member_types_changes, data_members_changes,
	inserted_data_members, deleted_data_members,
	member_fn_tmpls_changes, member_fn_tmpls_changes,
	member_class_tmpls_changes}): These are deleted as they got moved
	to class_or_union_diff.
	(class_diff::report): Adjust.
	(union_diff::{clear_lookup_tables, lookup_tables_empty,
	ensure_lookup_tables_populated, allocate_priv_data, union_diff,
	finish_diff_type, first_union_decl, second_union_decl,
	get_pretty_representation, report}): Define new functions.
	(compute_diff): Define an overload for union_decl_sptr.
	(function_decl_diff::report): Adjust.
	(corpus_diff::priv::apply_suppressions_to_added_removed_fns_vars):
	Adjust.
	(corpus_diff::report): Adjust.
	* src/abg-hash.cc (member_base:#️⃣:operator)
	(member_function_template:#️⃣:operator)
	(member_class_template:#️⃣:operator): Move these out of the
	class_decl scope.
	(class_or_union:#️⃣:operator): Define new member function.
	(class_decl:#️⃣:operator): Adjust.
	(type_base::dynamic_hash::operator): Support hashing of
	union_decl.  Adjust.
	* src/abg-suppression.cc (type_suppression::suppresses_diff):
	Adjust.
	* src/abg-dwarf-reader.cc (typedef die_class_or_union_map_type):
	Define new typedef.
	(read_context::{die_wip_classes_map_,
	alternate_die_wip_classes_map_, type_unit_die_wip_classes_map_):
	Make these data member have type die_class_or_union_map_type.
	(read_context::{lookup_type_from_die_offset, die_wip_classes_map,
	is_wip_class_die_offset, resolve_declaration_only_classes}):
	Adjust.
	(finish_member_function_reading, build_class_type_and_add_to_ir)
	(build_function_type, build_function_decl, build_reference_type)
	(type_is_suppressed, build_function_decl)
	(maybe_canonicalize_type, maybe_set_member_type_access_specifier):
	Adjust.
	(build_union_type_and_add_to_ir): Define new static function.
	(build_ir_node_from_die): Support DW_TAG_union_type DIE tag.
	* src/abg-reader.cc (handle_element_node): Handle union_decl.
	(build_function_decl, build_function_decl_if_not_suppressed):
	Adjust.
	(build_union_decl_if_not_suppressed, build_union_decl)
	(handle_union_decl): Define new functions.
	(build_class_decl): Adjust.
	* src/abg-writer.cc (record_decl_only_type_as_emitted): Adjust.
	(write_decl): Adjust. Support writting union_decl type.
p	(write_class_decl_opening_tag, write_class_decl): Adjust.  Call
	the new write_class_or_union_is_declaration_only.
	(write_union_decl_opening_tag, write_union_decl): Define new
	static functions.
	(write_member_tpe): Support writting union decl.
	* tests/test-diff-dwarf.cc (in_out_specs): Add new tests for this
	union type support.
	* tests/data/test-diff-dwarf/libtest37-union-v0.so: New test input.
	* tests/data/test-diff-dwarf/libtest37-union-v1.so: Likewise.
	* tests/data/test-diff-dwarf/libtest38-union-v0.so: Likewise.
	* tests/data/test-diff-dwarf/libtest38-union-v1.so: Likewise.
	* tests/data/test-diff-dwarf/libtest39-union-v0.so: Likewise.
	* tests/data/test-diff-dwarf/libtest39-union-v1.so: Likewise.
	* tests/data/test-diff-dwarf/test37-union-report-0.txt: Likewise.
	* tests/data/test-diff-dwarf/test38-union-report-0.txt: Likewise.
	* tests/data/test-diff-dwarf/test39-union-report-0.txt: Likewise.
	* tests/data/test-diff-dwarf/test37-union-v0.cc: Source code for
	new test input.
	* tests/data/test-diff-dwarf/test37-union-v1.cc: Likewise.
	* tests/data/test-diff-dwarf/test38-union-v0.cc: Likewise.
	* tests/data/test-diff-dwarf/test38-union-v1.cc: Likewise.
	* tests/data/test-diff-dwarf/test39-union-v0.cc: Likewise.
	* tests/data/test-diff-dwarf/test39-union-v1.cc: Likewise.
	* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi:
	Update test reference.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt:
	Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt:
	Likewise.
	* tests/data/test-read-dwarf/libtest23.so.abi: Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi:
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-22 16:22:25 +01:00
Dodji Seketeli
8bc0fc3f3d Update reference output of runtestreaddwarf
The test runtestreaddwarf emits some spurious output on stdout.  This
test updates the reference output to remove that spurious output.

	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Adjust.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Adjust.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-09-23 14:42:24 +02:00
Dodji Seketeli
98c8d61684 Drop suppressed ABI artifacts from the IR
This patch allows dropping suppressed ABI artifacts from the in-memory
internal representation right during the DWARF or abixml reading.

In practise, this means that abidw and abilint now have a
--suppressions options to give them suppression specifications.  If a
suppression specification that has the "drop" property matches an ABI
artifact (type, function or variable) then that artifact is dropped
from the internal representation.  This also applies to abidiff.

Note that now, by default, ABI artifacts (types) that are suppressed
due to the --headers-dir{1,2} option of abidiff are now also dropped
from the IR as well.  Incidentally, abidw and abilint tools now have a
--header-dir option too.

	* doc/manuals/abidw.rst: Document the new --suppressions and
	--headers-dir options off the abidw tool.
	* doc/manuals/abilint.rst: Document the new --suppressions and
	--headers-dir options on the abilint tool.
	* doc/manuals/libabigail-concepts.rst: Document the new "drop" and
	"name_not_regexp" properties on suppression directives.
	* include/abg-corpus.h (corpus::corpus): Add a default argument to
	the path parameter.
	* src/abg-suppression-priv.h: New private header file.
	* src/Makefile.am: Add the new abg-suppression-priv.h file to
	source distribution.
	* include/abg-suppression.h ({suppression_base, type_suppression,
	function_suppression, variable_suppression}::priv): Make these
	public.
	(suppression_base::{g,s}et_drops_artifact_from_ir): Declare new
	member functions.
	(type_suppression::{suppressed_type}): Likewise.
	(suppression_base::{names,sonames}_of_binaries_match): Remove
	member functions.
	(function_suppression::{get_name, set_name, get_name_regex_str,
	set_name_regex_str}): Renamed get_function_name,
	set_function_name, get_function_name_regex_str,
	set_function_name_regex_str into these.
	({variable,function}_suppression::{g,s}et_name_not_regex_str):
	Declare new member functions.
	* src/abg-suppression.cc: Include the new abg-suppression-priv.h
	private header.
	(class suppression_base::priv, class type_suppression::priv, class
	function_suppression::parameter_spec::priv, class
	function_suppression::priv, class variable_suppression::priv):
	Move these types to that new private header.
	(suppression_base::{g,s}et_drops_artifact_from_ir)
	(function_suppression::{g,s}et_name_not_regex_str)
	(variable_suppression::{g,s}et_name_not_regex_str): New member
	functions.
	(sonames_of_binaries_match): New static function, taken from
	suppression_base::sonames_of_binaries_match.
	(names_of_binaries_match): New static function, taken from
	suppression_base::names_of_binaries_match.
	(suppression_matches_type_no_name): New static function.
	(type_suppression::suppresses_type): Adjust
	(function_suppression::suppresses_function)
	(variable_suppression::suppresses_variable): Adjust.  Evaluate the
	new "name_not_regexp" property.
	(suppression_matches_type_name)
	(suppression_matches_type_location)
	(suppression_matches_type_name_or_location)
	(suppression_matches_function_name)
	(suppression_matches_function_sym_name)
	(suppression_matches_variable_name)
	(suppression_matches_variable_sym_name, suppression_matches_type):
	New functions.
	(read_type_suppression): Support the new "drop_artifacts" and
	"drop" properties.
	(read_function_suppression, read_variable_suppression): Support
	the new "drop_artifacts", "drop", and "name_not_regexp"
	properties.
	(function_suppression::{g,s}et_name): Renamed
	{g,s}et_function_name into these.
	(function_suppression::set_name_not_regex_str): Renamed
	{g,s}et_name_regex_str into this.
	(function_suppression::suppresses_function_symbol): Adjust.
	* include/abg-dwarf-reader.h (add_read_context_suppressions):
	Declare new function.
	* src/abg-dwarf-reader.cc: Use the new private
	abg-suppression-priv.h header file.
	(read_context::supprs_): New data member.
	(read_context::get_suppressions): New member function.
	(read_context::get_die_source): Make this const.
	(read_context::tu_die_imported_unit_points_map): Add a const
	overload.
	(read_context::cur_transl_unit): Renamed current_translation_unit
	unit into this;
	(read_context::cur_tu): Remove or rename into cur_transl_unit.
	(get_scope_for_die, build_translation_unit_and_add_to_ir)
	(build_enum_type, build_pointer_type_def, build_reference_type)
	(build_function_type, build_array_type, build_function_decl):
	Adjust.
	(read_context::{suppression_can_match,
	suppression_matches_function_sym_name,
	suppression_matches_function_name,
	suppression_matches_variable_sym_name,
	suppression_matches_variable_name,
	suppression_matches_type_name_or_location,
	suppression_matches_type_name}): Add member functions.
	(die_signed_constant_attribute): Remove this as dead code.
	(die_location, die_loc_and_name)
	(find_import_unit_point_between_dies)
	(find_import_unit_point_before_die, get_parent_die): Make the
	read_context& parameter be const and adjust as required.
	(build_var_decl_if_not_suppressed, function_is_suppressed)
	(variable_is_suppressed, type_is_suppressed): Define new static
	functions.
	(add_read_context_suppressions): Define new function.
	(build_class_type_and_add_to_ir): Do not add suppressed static
	data members to the IR.
	(build_ir_node_from_die): Do not add suppressed enum types, class
	types, variables or functions to the IR.  Adjust for the
	read_context::cur_tu -> read_context::cur_transl_unit rename.
	* include/abg-reader.h (read_context_sptr): Declare new type.
	(create_native_xml_read_context, read_corpus_from_input)
	(add_read_context_suppressions): Declare new functions.
	* src/abg-reader.cc: Include the new private
	abg-suppression-priv.h header file.
	(read_context::m_exported_decls_builder): Renamed
	m_exported_decls_builder_ into this.
	(read_context::get_exported_decls_builder): Adjust.
	(read_context::get_cur_scope): Make this const.
	(read_location): Take a const read_context and adjust.
	(read_corpus_from_input): Make this non-static.
	(build_namespace_decl): Don't abort if trying to add an artifact
	to the IR doesn't succeed.  It might be suppressed now.
	(read_context::{m_path, m_supprs}): New data members.
	(read_context::{g,s}et_path): New member functions.
	(read_context::{get_suppressions,
	suppression_matches_function_name, suppression_can_match,
	suppression_matches_function_name,
	suppression_matches_function_sym_name,
	suppression_matches_variable_name,
	suppression_matches_variable_sym_name,
	suppression_matches_type_name_or_location}): Likewise.
	(add_read_context_suppressions, create_native_xml_read_context)
	(read_corpus_from_native_xml): New functions.
	(build_function_decl_if_not_suppressed, function_is_suppressed)
	(type_is_suppressed, build_var_decl_if_not_suppressed)
	(variable_is_suppressed, build_enum_type_decl_if_not_suppressed)
	(build_class_decl_if_not_suppressed): New static functions.
	(build_class_decl): Add member types that are being built early,
	so that their sub-types can be evaluated for suppression.  Do not
	add suppressed static data members or suppressed member functions
	to the IR.
	(build_type): Do not add an enum type or a class type to the IR if
	they are suppressed.
	(handle_enum_type_decl): Do not add an enum type to the IR if its
	suppressed.
	(handle_var_decl): Likewise for a variable decl.
	(handle_function_decl): Likewise for a function decl.
	(handle_class_decl): Likewise for a class decl.
	* src/abg-tools-utils.cc (handle_fts_entry): Drop suppressed ABI
	from the IR.
	* tools/abidiff.cc (display_usage): Fix help strings for
	--headers-dirs{1,2}.
	(set_suppressions): New static function.
	(main): Adjust.  Release the memory used by read_context early.
	* tools/abidw.cc (options::{headers_dir, suppression_paths}):
	(display_usage): New help strings for the new --header-dir and
	--suppressions options.
	(parse_command_line): Parse the new --header-dir and
	--suppressions options.
	(maybe_check_suppression_files, set_suppressions): New static
	functions.
	(main): Use the two new functions above.  Free the memory used by
	the read context before working with the corpus.
	* tools/abilint.cc (options::suppression_paths):
	(display_usage): New help strings for the new --header-dir and
	--suppressions options.
	(parse_command_line): Parse the new --header-dir and
	--suppressions options.
	(maybe_check_suppression_files, set_suppressions): New static
	functions.
	(main): Use the two new functions above.  Free the memory used by
	the read context before working with the corpus.
	* tests/data/test-diff-suppr/test24-soname-suppr-{2,3].txt:
	Adjust.
	* tests/data/test-diff-suppr/test29-suppr-6.txt: Likewise.
	* tests/data/test-diff-suppr/test29-suppr-8.txt: Likewise.
	* tests/data/test-diff-suppr/libtest31-v{0,1}.so: New test input.
	* tests/data/test-diff-suppr/libtest31.suppr: Likewise
	* tests/data/test-diff-suppr/libtest32-v{0,1}.so: Likewise.
	* tests/data/test-diff-suppr/libtest32-0.suppr: Likewise.
	* tests/data/test-diff-suppr/libtest33-v{0,1}.so: Likewise.
	* tests/data/test-diff-suppr/test31-report-{0,1}.txt: Likewise.
	* tests/data/test-diff-suppr/test31-v{0,1}.cc: Likewise.
	* tests/data/test-diff-suppr/test32-report-{0,1}.txt: Likewise.
	* tests/data/test-diff-suppr/test32-v{0,1}.c: Likewise.
	* tests/data/test-diff-suppr/test33-suppr-1.txt: Likewise.
	* tests/data/test-diff-suppr/test33-v{0,1}.cc: Likewise.
	* tests/data/test-diff-suppr/test33-v{0,1}.h: Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns.so: Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-read-dwarf/test24-drop-fns-0.suppr: Likewise.
	* tests/data/test-read-dwarf/test24-drop-fns.cc: Likewise.
	* tests/data/test-read-write/test28-drop-std-fns.abignore:
	Likewise.
	* tests/data/test-read-write/test28-drop-std-vars.abignore:
	Likewise.
	* tests/data/test-read-write/test28-without-std-fns-ref.xml:
	Likewise.
	* tests/data/test-read-write/test28-without-std-fns.xml: Likewise.
	* tests/data/test-read-write/test28-without-std-vars-ref.xml:
	Likewise.
	* tests/data/test-read-write/test28-without-std-vars.xml:
	Likewise.
	* tests/data/test-read-write/test28.xml: Likewise.
	* tests/data/Makefile.am: Add the new test artifacts to source
	distribution.
	* tests/test-diff-suppr.cc (in_out_spec): Take the new test inputs
	into account.
	* tests/test-read-dwarf.cc (Inoutspec::in_suppr_spec_path): New
	data member.
	(in_out_spec): Adjust.  The new test inputs into account.
	(set_suppressions): New static function.
	(handle_in_out_spec): Adjust.
	* tests/test-read-write.cc (Inoutspec::{in_suppr_spec_path,
	ref_out_path}): New data members.
	(in_out_spec): Adjust.  Take new test inputs into account.
	(main): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-09-21 18:35:08 +02:00
Dodji Seketeli
756cdc113b Do not emit empty namespaces in abixml
Today The abixml writer emits namespaces even if they are empty or
contain empty namespaces.  This leads to abixml files that are
unnecessarily big and verbose.  This patch prevents that.

	* include/abg-ir.h
	(namespace_decl::is_empty_or_has_empty_sub_namespaces): Declare
	new function ...
	* src/abg-ir.cc
	(namespace_decl::is_empty_or_has_empty_sub_namespaces): ... and
	define it.
	* src/abg-writer.cc (write_namespace_decl): Do not write empty
	namespaces or namespaces containing empty namespaces.
	* tests/data/test-read-dwarf/test9-pr18818-clang.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/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/libtest23.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-09-21 18:35:07 +02:00
Dodji Seketeli
103a6eb94f Control symbols exported from libabigail.so
Symbols of pretty much all member functions of types that are meant to
be "private" to translation units that contribute to libabigail.so
were exported because we didn't do much to prevent that.

This patch starts controlling the set of symbols that are exported.

By default, symbols of any entity declared in a translation unit that
contributes to libabigail.so are hidden by default.  Only symbols of
entities declared in public headers (headers in include/*.h) are
exported.

There are many ways to achieve that.  This patch chooses to avoid
cluttering declarations of entities in the public header by adding
__attribute__((visibility="default")) to every declared type of
function in there.

Rather, the patch uses "#pragma GCC visibility push(default)" before
entities declared on those headers.  By doing so, all those entities
have their symbol marked as "visible" by the compiler.  Once the
header are #included, the #pragma GCC visibility pop" is used, so that
anything else has its symbol be hidden from that point on.

Note that for ease of maintenance the patch uses the macros
ABG_BEGIN_EXPORT_DECLARATIONS and ABG_END_EXPORT_DECLARATIONS rather
than using the pragma directive directly.

I believe this is a more elegant way of handling visibility, compared
to cluttering every single declaration in public headers with a
"__attribute__((visibility=("default")))" or with a macro which
expands to it.

This reduces the the set of symbols exported by libabigail.so from
20000+ to less than 5000.

	* VISIBILITY: New documentation about this visiblity business.
	* CONTRIBUTING: Update the "contributing guide" to refer to symbol
	visibility issues.
	* configure.ac: Define a variable VISIBILITY_FLAGS that is set to
	the -fvisibility=hidden flag to pass to GCC, when its available.
	* src/Makefile.am: Add VISIBILITY to source distribution.  Also
	add COMPILING and COMMIT-LOG-GUIDELINES that were missing.
	* src/Makefile.am: Use the new $(VISIBILITY_FLAGS) when buiding
	the library.
	* tests/Makefile.am: Use the new $(VISIBILITY_FLAGS) when buiding
	tests.
	* tools/Makefile.am: Use the new $(VISIBILITY_FLAGS) when buiding
	tools.
	* src/abg-comp-filter.cc: Enclose inclusion of public headers in
	ABG_BEGIN_EXPORT_DECLARATIONS and ABG_END_EXPORT_DECLARATIONS to
	export the symbols of entities declared in there.
	* src/abg-comparison.cc: Likewise.
	* src/abg-config.cc: Likewise.
	* src/abg-corpus.cc: Likewise.
	* src/abg-diff-utils.cc: Likewise.
	* src/abg-dwarf-reader.cc: Likewise.
	* src/abg-hash.cc: Likewise.
	* src/abg-ini.cc: Likewise.
	* src/abg-ir.cc: Likewise.
	* src/abg-libxml-utils.cc: Likewise.
	* src/abg-libzip-utils.cc: Likewise.
	* src/abg-reader.cc: Likewise.
	* src/abg-suppression.cc: Likewise.
	* src/abg-tools-utils.cc: Likewise.
	* src/abg-traverse.cc: Likewise.
	* src/abg-viz-common.cc: Likewise.
	* src/abg-viz-dot.cc: Likewise.
	* src/abg-viz-svg.cc: Likewise.
	* src/abg-workers.cc: Likewise.
	* src/abg-writer.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-07-27 12:51:02 +02:00
Dodji Seketeli
8b2f4ac43f Support DW_TAG_type_unit
Type units sections are sections in which the compiler emits types
uniquely identified by a signature.  This is so that the linker can
later discard redundant types (types having the same signature) from
the debug info and thus reduce the overall size of debug info.

These types are children DIEs of DW_TAG_type_unit.

Because DIEs coming from that .debug_types section can have the same
offset as DIEs coming from the .debug_info section, this patch defines
a new DIE source to identify DIEs coming from .debug_types section.
The name of that new source is the new TYPE_UNIT_DIE_SOURCE enumerator
of the die_source enum.  The patch also creates the necessary maps
containing DIEs coming from this new source and adjusts the
accompanying accessors accordingly.

	* src/abg-dwarf-reader.cc (TYPE_UNIT_DIE_SOURCE): New enumerator
	in enum die_source.
	(read_context::{type_unit_die_decl_map_, type_unit_die_type_map_,
	type_unit_die_wip_classes_map_,
	type_unit_die_wip_function_types_map_,
	type_unit_types_to_canonicalize_,
	type_units_tu_die_imported_unit_points_map_,
	type_section_die_parent_map_}): New data members.
	(read_context::{get_die_source, associate_die_to_decl,
	lookup_decl_from_die_offset, die_type_map, clear_die_type_maps,
	die_wip_classes_map, die_wip_function_types_map,
	types_to_canonicalize, clear_types_to_canonicalize,
	tu_die_imported_unit_points_map, die_parent_map}): Support
	TYPE_UNIT_DIE_SOURCE.
	(get_parent_die, get_scope_for_die): Likewise.
	(read_context::{lookup_decl_from_type_unit_die_offset,
	type_section_die_parent_map}): Define new member functions.
	(read_context::build_die_parent_maps): Build a DIE -> parent map
	for DIEs coming from the .debug_types section.
	* tests/data/test-read-dwarf/libtest23.so: New test input.
	* tests/data/test-read-dwarf/libtest23.so.abi: New reference output.
	* tests/data/test-read-dwarf/test23-first-tu.cc: Source code of
	the new binary above.
	* tests/data/test-read-dwarf/test23-second-tu.cc: Likewise.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-read-dwarf.cc (in_out_specs): Make this test harness
	execute over the new test input and reference output.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-07-26 20:07:03 +02:00
Chenxiong Qi
1a00cad493 Make fedabipkgdiff consistent with Libabigail's other tests
In the libabigail project, almost all the tests for the tools follow a
similar pattern.  The test contains a set of input files to compare.
The result of the comparison is thus compared to a set of reference
comparison result.

This approach is already documented in the CONTRIBUTING file.

There are several interesting properties with this scheme.  First, it
capture the behaviour of the tools, including what is shown to the
user.

Second, it eases the job of a hacker who wants to add a new test for a
new behaviour of a given tool.  The user just has to provide:

  1/ A new reference output of the new use case of the tool (that is easily
     constructed by using the tool itself and saving its output) and add an
     entry to array of entries that describe what to compare

  2/ A new set of inputs to the tool

And voila.

Unfortunately, fedabipkgdiff tests don't follow this scheme.  That
make them surprising to hackers who read the source code of the
existing tests, at very least.  Also, the fedabipkgdiff tests were
only unit tests.  They were not testing the tool as used by users in
general.

This patch makes the fedabipkgdiff tests follow the general approach
of the tests of the other Libabigail tools.

The patch first craetes a program names tests/mockfedabipkgdiff.  It's
a wrapper around tools/fedabipkgdiff.  It overloads the Koji client of
fedabipkgdiff with a fake Koji client that gets the Fedora packages
locally, from tests/data/test-fedabipkgdiff/packages.  In other words,
mockfedabipkgdiff is fedabipkgdiff without going to the network.

I believe that in the future, tests/mockfedabipkgdiff should be killed
when fedabipkgdiff is able to cache a local description of a local
partial view of a Koji repository, along with the build packages that
were already downloaded.

That way, calling fedabipkgdiff twice with the same set of option
should make the tool perform correctly without going to the netword on
the second invocation.  We should be able to save the local partial
view of the Koji repository under e.g,
tests/data/test-fedabipkgdiff/local-koji and tell fedabipkgdiff to use
that, instead of using the network.  But we are not there yet.  So for
now, I am using mockfedabipkgdiff.

Then, tests/runtestfedabipkdiff.py.in has been re-written to use
tests/mockfedabipkgdiff and to look like what is described in
CONTRIBUTING as far as how Libabigail tools' tests are organized:
mockfedabipkgdiff is called to perform a comparison.  The result of
the comparison is then compared (using GNU diff) to a reference
comparison result file.

Please note that tests/runtestfedabipkdiff.py is relatively fast for
the moment.  But when it contains much more tests and start becoming
slow, then we'll need to change the code to run several comparisons in
parallel, just like we do today in tests/test-diff-filter.cc.  At that
point, I believe I'll just re-write this in C++, just like
tests/test-diff-filter.cc because that will allow us to have true
concurrent code based on the abigail:workers API.  For now, I am
keeping this in Python also because I think that keeps Chenxiong happy
;-)

To be sure that fedabipkgdiff (and its underlying abipkgdiff) are
really comparing all the packages they are supposed to compare and
also all the binaries in those packages, I have added a new
--show-identical-binaries to abipkgdiff and fedabipkgdiff.  That
option shows the name of the binaries (and packages) that are
compared, *even if* the ABI of those binaries are identical.  Because
otherwise, today, if two binaries (or packages) have the same ABI,
nothing is displayed.

For instance, here is the result of comparing a package against
itself, using this new --show-identical-binaries options:

    dodji@adjoa:patches$ ./tools/fedabipkgdiff --abipkgdiff ./build/tools/abipkgdiff --show-identical-binaries  dbus-glib-0.80-3.fc12.x86_64.rpm dbus-glib-0.80-3.fc12.x86_64.rpm
    Comparing the ABI of binaries between dbus-glib-0.80-3.fc12.x86_64.rpm and dbus-glib-0.80-3.fc12.x86_64.rpm:

    ================ changes of 'dbus-binding-tool'===============
    No ABI change detected
    ================ end of changes of 'dbus-binding-tool'===============

    ================ changes of 'libdbus-glib-1.so.2.1.0'===============
    No ABI change detected
    ================ end of changes of 'libdbus-glib-1.so.2.1.0'===============
    dodji@adjoa:patches$

And here is what this command before that patch would do:

    dodji@adjoa:patches$ ./tools/fedabipkgdiff --abipkgdiff ../master/build/tools/abipkgdiff dbus-glib-0.80-3.fc12.x86_64.rpm dbus-glib-0.80-3.fc12.x86_64.rpm
    Comparing the ABI of binaries between dbus-glib-0.80-3.fc12.x86_64.rpm and dbus-glib-0.80-3.fc12.x86_64.rpm:
    dodji@adjoa:patches$

The rest of the patch is mostly new test inputs material and the
necessary adjustments following all the changes above.

	* configure.ac: Do not require Python dependencies itertools,
	unittest and StringIO anymore as they are not used anymore.
	Require new module tempfile now.  Generate new executable script
	tests/mockfedabipkgdiff from tests/mockfedabipkgdiff.in.
	* doc/manuals/abipkgdiff.rst: Add doc for new option
	--show-identical-binaries to abipkgdiff
	* doc/manuals/fedabipkgdiff.rst: Add doc for new options
	--show-identical-binaries to fedabipkgdiff.
	* tools/abipkgdiff.cc (options::show_identical_binaries): New data
	member.
	(options::options): Initialize new data member.
	(display_usage): Add a new help string for the new
	--show-identical-binaries option.
	(parse_command_line): Parse the newq --show-identical-binaries
	command line switch.
	(pthread_routine_compare): When the comparison of two binaries is
	empty, if --show-identical-binaries was provided, then emit some
	output saying the comparison did yield the empty set.
	* tools/fedabipkgdiff (DEFAULT_ABIPKGDIFF): Store the default path
	to abipkgdiff in this new global variable.  Naming this default
	path is useful because it can then be cleanly overloaded when
	using mock.patch.
	(build_path_to_abipkgdiff): Return the new DEFAULT_ABIPKGDIFF
	global variable.
	(cmd): Parse the new --show-identical-binaries command line
	switch.
	* tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt:
	New reference output.
	* tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt:
	Likewise.
	* tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt:
	Likewise.
	* tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt:
	Likewise.
	* tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt:
	Likewise.
	* tests/mockfedabipkgdiff.in: New uninstalled script template.
	* tests/runtestfedabipkgdiff.py.in (counter)
	(temp_file_or_dir_prefix, UtilsTest, RPMTest, LocalRPMTest)
	(RunAbipkgdiffTest, GetPackageLatestBuildTest, DownloadRPMTest)
	(BrewListRPMsTest, AssertionHelper, MockGlobalConfig)
	(BUILT_ABIPKGDIFF, CompareABIFromCommandLineTest): Remove these
	classes, global variables and functions.
	(FEDABIPKGDIFF, TEST_SRC_DIR, TEST_BUILD_DIR, INPUT_DIR)
	(OUTPUT_DIR, FEDABIPKGDIFF_TEST_SPECS): New global variables.
	(ensure_output_dir_created, run_fedabipkgdiff_tests, main): New
	functions.
	* tests/test-diff-pkg.cc (in_out_specs): Add
	tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt
	to the set of reference outputs to consider.
	* tests/Makefile.am: Add non-installed script mockfedabipkgdiff to
	source distribution. Also added
	tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt,
	tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt,
	tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt,
	tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt
	and
	tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt
	to source distribution.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-07-15 19:41:08 +02:00
Dodji Seketeli
e88892c0b1 Fix spurious type size change report for distinct_diff
When looking at diff of two distinct types it can happen that the
change report mentions a type size change even when the two type sizes
are equal.

This patch fixes that.

	* src/abg-comparison.cc (report_size_and_alignment_changes):
	Report size change only when the sizes are different.
	* tests/data/test-diff-filter/test33-report-0.txt: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-07-13 23:45:49 +02:00
Dodji Seketeli
ca133d551b Bug 20199 - Consider integral type synonyms as being equal
In this problem report, Abigail's type comparison engine considers
e.g, "unsigned short" and "short unsigned int" as being different
types because they have different name strings.  This is wrong.

This patch canonicalize the names of integral types, so that e.g,
"short unsigned", "unsigned short" and "unsigned short int" all have
the same name which would be "unsigned short int".

	* src/abg-ir.cc (class integral_type): New class declaration and
	definition.
	(operator|, operator&, operator&=): New non-member bitwise
	operators for integral_type.
	(parse_integral_type_modifier, parse_base_integral_type)
	(parse_integral_type_modifier): New static function definitions.
	(type_decl::type_decl): Use the parse_integral_type to parse an
	integral type out of the current type_decl being built and
	transform the current type name into a canonical form.
	* tests/data/test-abidiff/test-PR18791-v0.so.abi: Adjust.
	* tests/data/test-abidiff/test-PR18791-v1.so.abi: Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise.
	* tests/data/test-diff-filter/test33-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test34-report-0.txt: Likewise.
	* 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: Likewise.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-07-13 23:37:43 +02:00
Dodji Seketeli
5b9ef4d091 Bug 20332 - too many ...'s counted as parameters
GCC can generate several DW_TAG_unspecified_parameters for a given
function.  Abigail's DWARF reader is recklessly creating a variadic
function parameter in its internal representation (IR) each time it
sees a DW_TAG_unspecified_parameters.  This leads to functions having
several variadic parameters in the final IR.  And this is wrong.

This patch fixes the problem by creating a variadic parameter only for
the first DW_TAG_unspecified_parameters encountered for a given
function DIE.

	* src/abg-dwarf-reader.cc (build_function_type): Create a variadic
	parameter just for the first DW_TAG_unspecified_parameters seen.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Adjust.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Adjust.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-07-08 09:51:24 +02:00
Dodji Seketeli
93fea0667e Better recognize qualified void type
This fixes Bug 20329 - DW_TAG_const_type with no DW_AT_type not recognized as "const void".

It appears that GCC sometimes emits "const void" types by emitting a
const type DIE with no type attribute.  The DWARF reader didn't
recognize that construct as a qualified void type.

This patch teaches the DWARF reader to recognize that construct.

It also appears that "const void" and "void" are equivalent and can be
emitted interchangeably by compilers (Intel and GCC) in their debug
info.  That can lead to spurious ABI change reports saying that a type
"const void" was changed into a "void" type.

This patch transforms an occurrence of "const void" type into a "void"
type in the internal representation when reading DWARF.  This does
away with the spurious change that appears when comparing selected
binaries emitted with the intel against binaries emitted with GCC.

	* include/abg-ir.h (environment::is_void_type): Declare new member
	function.
	* src/abg-ir.cc (environment::is_void_type): Define new member
	function.
	* src/abg-dwarf-reader.cc (maybe_strip_qualification): Strip const
	qualifier from const void.
	* tests/data/test-diff-filter/test34-libjemalloc.so.2-gcc-6.1.0:
	New test input.
	* tests/data/test-diff-filter/test34-libjemalloc.so.2-intel-16.0.3: Likewise.
	* tests/data/test-diff-filter/test34-report-0.txt: New reference output.
	* tests/data/Makefile.am: Add the new files above to the source
	distribution.
	* tests/test-diff-filter.cc (in_out_specs): Compare the two new
	binaries above.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Adjust.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.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/test1.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>
2016-07-07 14:04:10 +02:00
Dodji Seketeli
10ce99e428 Bug 20194 - Fail to recognize void type represented by DW_TAG_base_type
This patch makes the DWARF reader recognize a "void" type expressed as
a DW_TAG_base_type of size zero and named "void".

	* src/abg-dwarf-reader.cc (build_type_decl): Recognize a
	DW_TAG_base_type of size zero and of name "void" as a void
	type.
	* tests/data/test-diff-filter/test33-libelf.so.0.8.13-gcc: New
	binary test input.
	* tests/data/test-diff-filter/test33-libelf.so.0.8.13-intel16.0.3: Likewise.
	* tests/data/test-diff-filter/test33-report-0.txt: New reference output.
	* tests/data/Makefile.am: Add the new files above to source
	distribution.
	* tests/test-diff-filter.cc (in_out_specs): Make this test harness
	run over the new test inputs above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-07-05 12:52:52 +02:00
Dodji Seketeli
4a751787b0 Fix python interpreter path for el6
On el6, the python interpreter is not found at /bin/python, so let's
use /usr/bin/python in tests/runtestdefaultsupprs.py.in.

	* tests/runtestdefaultsupprs.py.in: Use the python interpreter at
	/usr/bin/python, not the one at /bin/python.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-06-28 09:12:40 +02:00
Chenxiong Qi
95b12167fa Fix package NVR comparison in fedabipkgdiff
When sorting two packages by their {Name Value Release} triplet to
select the latest one, just doing a string comparison of the NVRs is
wrong.  Take for example the packages foo-0.10-1.fc25 and
foo-0.2-1.fc25.  A basic string comparison will result in the string
"foo-0.10-1.fc25" being less than "foo-0.2-1.fc25", and thus
foo-0.2-1.fc25 will be selected as the latest package.  And that is
wrong, because the latest one is obviously foo-0.10-1.fc25.

So, after some research on this, I figured rpm.labelCompare is a
better choice to appropriately compare two NVRs.

Another reason why I chose rpm.labelCompare is because the latest
build in fedabipkgdiff means a build with the latest version.release
within a specific Fedora distribution such as fc23 or fc25.

	* configure.ac: Add new dependency.
	* tests/runtestfedabipkgdiff.py.in (builds): Add new builds for
	running tests to test selecting latest build from a package.
	(packages): Add new package gnutls.
	(GetPackageLatestBuildTest.{test_get_latest_one,
	test_cannot_find_a_latest_build_with_invalid_distro}): Use new
	builds of package gnutls to run tests.
	* tools/fedabipkgdiff (cmp_nvr): New function used to compare nvrs
	by Python built-in function sorted.
	(Brew.listBuilds): Use the new cmp_nvr function.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-06-11 09:10:10 +02:00
Chenxiong Qi
69d2dcd163 Bug 20135 - Make fedabipkgdiff compare ABIs using devel packages
This patch makes fedabipkgdiff compare the ABI of two packages by
taking into account their associated devel packages, along with their
debug info packages.  Taking devel packages into account makes the
tool report changes about types that are defined in public header
files only.  This helps decrease the amount of change reports about
types not defined in public headers.

This is now the default behaviour.

However, if the user provides the new --no-devel-pkg command line
option, then the devel package is not taken into account during the
ABI comparison.

	* doc/manuals/fedabipkgdiff.rst: Add documentation for the new
	--no-devel-pkg command line option, as well as for the new default
	behaviour of taking devel packages into account during ABI
	comparison.
	* tools/fedabipkgdiff (PkgInfo): Add new attribute
	devel_package.
	(RPM.is_devel): New property to determine if rpm is a
	development package.
	(LocalRPM._find_rpm): New method to find a specific rpm.
	(LocalRPM.find_debuginfo): Use new method _find_rpm to find
	debuginfo package.
	(LocalRPM.find_devel): New method to find an associated
	development package.
	(Brew.select_rpms_from_a_build): RPMs selector method is
	changed to select development package also.
	(abipkgdiff): Construct and run abipkgdiff with and without
	--devel-pkg[12] options.
	(magic_construct): Construct PkgInfo with development package.
	(run_abipkgdiff): Run abipkgdiff against rpms with development
	packages.
	(diff_local_rpm_with_latest_rpm_from_koji): Find development
	package, and call method abipkgdiff with development package.
	(build_commandline_args_parser): add new option --no-devel-pkg.
	* tests/runtestfedabipkgdiff.py.in (packages): Add new package
	nss-util.
	(builds): Add new builds of nss-utils, nss-util-3.12.6-1.fc14
	and nss-util-3.24.0-2.0.fc25.
	(rpms): Add new associated rpms of the two new builds.
	(AssertionHelper.assert_functions_changes_summary): New method
	to match and assert functions changes summary.
	(AssertionHelper.assert_abi_comparison_result): Changed to
	support to help assert functions changes summary.
	(MockGlobalConfig.{no_devel_pkg, check_all_subpackages}): New
	fake options with default value for running tests.
	(RPMTest.setUp): add new development package for running test
	case.
	(RPMTest.test_is_devel): New test to test is_devel property.
	(RunAbipkgdiffTest.setUp): Add new development packages for
	running test case.
	(RunAbipkgdiffTest.{test_all_success, test_all_failure,
	test_partial_failure}): Mock global config.
	(RunAbipkgdiffWithDSOOnlyOptionTest): Removed.
	(CompareABIFromCommandLineTest.test_compare_with_no_devel_pkg):
	New test to test fedabipkgdiff with or without --no-devel-pkg
	option.
	* tests/data/Makefile.am: Add new rpms.
	* tests/data/test-fedabipkgdiff/packages/nss-util/3.12.6/1.fc14/
	x86_64/nss-util-3.12.6-1.fc14.x86_64.rpm: New rpm for running
	tests.
	* tests/data/test-fedabipkgdiff/packages/nss-util/3.12.6/1.fc14/
	x86_64/nss-util-debuginfo-3.12.6-1.fc14.x86_64.rpm: New rpm for
	running tests.
	* tests/data/test-fedabipkgdiff/packages/nss-util/3.12.6/1.fc14/
	x86_64/nss-util-devel-3.12.6-1.fc14.x86_64.rpm: New rpm for
	running tests.
	* tests/data/test-fedabipkgdiff/packages/nss-util/3.24.0/2.0.fc25/
	x86_64/nss-util-3.24.0-2.0.fc25.x86_64.rpm: New rpm for running
	tests.
	* tests/data/test-fedabipkgdiff/packages/nss-util/3.24.0/2.0.fc25/
	x86_64/nss-util-debuginfo-3.24.0-2.0.fc25.x86_64.rpm: New rpm
	for running tests.
	* tests/data/test-fedabipkgdiff/packages/nss-util/3.24.0/2.0.fc25/
	x86_64/nss-util-devel-3.24.0-2.0.fc25.x86_64.rpm: New rpm for
	running tests.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-06-09 11:11:33 +02:00
Chenxiong Qi
70614e18f1 Add integration tests for fedabipkgdiff
A new test case class is introduced as integration tests, that is able to
test fedabipkgdiff ability against supported use cases and with other
command line options. Currently, integration tests only aim to ensure
whether expected comparison against rpms and binaries really happen.

	* configure.ac: do not detect shutil module.
	* tests/runtestfedabipkgdiff.py.in: do not import shutil
	anymore.
	(BUILT_ABIPKGDIFF): new global variable to reference the
	abipkgdiff built from source code, as the new test case' tests
	require this command directly rather than mocking the
	global_config.
	(test_data_dir): convert variable name to uppercase,
	reference to the test data directory by absolute path instead of
	relative path.
	(TEST_TOPDIR): new global variable to use data directory as the
	topdir passed to fedabpkgdiff to download rpms.
	(TEST_DOWNLOAD_CACHE_DIR): new global variable referencing a
	fake download cache directory for tests only.
	(packages, builds, rpms): new global variables as a fake
	storage holding packages, builds and rpms.
	(AssertionHelper): new class helping to assert abipkgdiff
	result easily.
	(MockClientSession): new class to mock koji.ClientSession.
	(MockGlobalConfig.abipkgdiff): set this option to global
	variable BUILT_ABIPKGDIFF.
	(MockKojiClientSessin): removed.
	(mock_get_session): removed.
	(GetPackageLatestBuildTest.{test_get_latest_one,
	test_cannot_find_a_latest_build_with_invalid_distro,
	test_cannot_find_a_latest_build_with_invalid_distro}): mock
	koji.ClientSession with new class MockClientSession. Remove
	invalid documentation from docstring. Use new package rather
	than httpd.
	(DownloadRPMTest.setUp): remove self.download_dir and use global
	TEST_DOWNLOAD_CACHE_DIR.
	(DownloadRPMTest.tearDown): do not remove download cache
	directory.
	(DownloadRPMTest.make_remote_file_url): do not omit positional
	argument specifiers in string format.
	(DownloadRPMTest.{test_succeed_to_download_a_rpm,
	test_failed_to_download_a_rpm}): set fake download cache
	directory to mocked get_download_dir in mock.patch decorator.
	(BrewListRPMsTest.test_select_specific_rpms): use new
	MockClientSession to mock koji.ClientSession. Rewrite test by
	using the new package listed in global variable packages.
	(RunAbipkgdiffWithDSOOnlyOptionTest.{test_abipkgdiff_with_dso_only,
	test_abipkgdiff_without_dso_only}): set fake download cache
	directory to mocked get_download_dir in mock.patch decorator.
	(CompareABIFromCommandLineTest): new integration test case.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.100.2/2.fc20/
	i686/dbus-glib-0.100.2-2.fc20.i686.rpm: new rpm for running tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.100.2/2.fc20/
	i686/dbus-glib-debuginfo-0.100.2-2.fc20.i686.rpm: new rpm for
	running tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.100.2/2.fc20/
	i686/dbus-glib-devel-0.100.2-2.fc20.i686.rpm: new rpm for
	running tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.100.2/2.fc20/
	x86_64/dbus-glib-0.100.2-2.fc20.x86_64.rpm: new rpm for running
	tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.100.2/2.fc20/
	x86_64/dbus-glib-debuginfo-0.100.2-2.fc20.x86_64.rpm: new rpm
	for running tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.100.2/2.fc20/
	x86_64/dbus-glib-devel-0.100.2-2.fc20.x86_64.rpm: new rpm for
	running tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.106/1.fc23/
	i686/dbus-glib-0.106-1.fc23.i686.rpm: new rpm for running tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.106/1.fc23/
	i686/dbus-glib-debuginfo-0.106-1.fc23.i686.rpm: new rpm for
	running tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.106/1.fc23/
	i686/dbus-glib-devel-0.106-1.fc23.i686.rpm: new rpm for running
	tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.106/1.fc23/
	x86_64/dbus-glib-0.106-1.fc23.x86_64.rpm: new rpm for running
	tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.106/1.fc23/
	x86_64/dbus-glib-debuginfo-0.106-1.fc23.x86_64.rpm: new rpm for
	running tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.106/1.fc23/
	x86_64/dbus-glib-devel-0.106-1.fc23.x86_64.rpm: new rpm for
	running tests.
	* tests/data/Makefile.am: add new rpms.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-06-01 11:41:55 +02:00
Dodji Seketeli
3e47efb112 Escape all characters when reading a string in ini files
It turns out that when parsing foo = bar\[a-z\], the '[' and ']'
characters where not being escaped while parsing the string
"bar\[a-z\]".

This patch fixes that.

	* src/abg-ini.cc (read_context::peek): Take an output parameter to
	tell the caller when this function escaped the returned
	character.  Added an overload without this new parameter.
	(read_context::read_string): Accept all characters as part of the
	string.
	* tests/data/test-diff-suppr/test7-var-suppr-9.suppr: New test
	input.
	* tests/data/test-diff-suppr/test7-var-suppr-report-9.txt: New
	test reference output.
	* tests/data/Makefile.am: Add the files above to source
	distribution.
	* tests/test-diff-suppr.cc (in_out_spec): Run a new comparison of
	libtest7-var-suppr-v{0,1}.so this time using the new
	test7-var-suppr-9.suppr specification that exercices a string with
	the escaped characters that we were having difficulty with.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-31 12:37:57 +02:00
Dodji Seketeli
b36ca1501e Bug 20180 - Support system-wide suppression specifications
This patch adds support for loading system and user level suppression
specifications for libabigail tools.

At launch time, relevant libabigail tools (abidiff, abipkgdiff
fedabipkgdiff for now) read the default system suppression
specification file, if it's present, from a file which path is the
value of the environment variable
LIBABIGAIL_DEFAULT_SYSTEM_SUPPRESSION_FILE, if set, or from the file
$libdir/libabigail/default.abignore.

Then it reads the user system suppression specification file, if it's
present, from a file which path is the value of the environment
variable LIBABIGAIL_DEFAULT_USER_SUPPRESSION_FILE, if set, or from the
file $HOME/.abignore.

The content of the user system suppression file is merged with the
content of default system suppression file.

That content is also merged with the content of the suppression
specification files that might be provided by the --suppressions
command line option of the invoked tools.

The resulting set of all these suppression specifications is thus used
to filter the ABI change reports that are emitted.

abidiff, abipkgdiff and abipkgdiff gain a --no-default-suppression
option to avoid loading any of these default suppression specification
files.

The patch also installs a default.abignore file into $(pkglibdir).
Note that on x86_64, that directory is /usr/lib64/libabigail.  Now we
just need to think about the content of that default.abignore file.

	* doc/manuals/abidiff.rst: Document the default suppression
	scheme, its interaction with the --supprs option and the new
	--no-default option.
	* doc/manuals/abipkgdiff.rst: Likewise.
	* doc/manuals/fedabipkgdiff.rst: Likewise.
	* configure.ac: Generate the tests/runtestdefaultsupprs.py file
	from the new tests/runtestdefaultsupprs.py.in template.
	* default.abignore: New file.
	* Makefile.am: Add it to source distribution.
	* src/Makefile.am: Define the ABIGAIL_ROOT_SYSTEM_LIBDIR
	preprocessor macro that is set the value of the $libdir autotools
	macro.
	* include/abg-tools-utils.h: Update copyright years.
	(get_system_libdir, get_default_system_suppression_file_path)
	(get_default_user_suppression_file_path)
	(load_default_system_suppressions)
	(load_default_user_suppressions): Declare new functions
	* src/abg-tools-utils.cc (get_system_libdir)
	(get_default_system_suppression_file_path)
	(get_default_user_suppression_file_path)
	(load_default_system_suppressions)
	(load_default_user_suppressions): Define new functions.
	(is_regular_file): Amend this so that it return true for symlinks
	to regular files too.
	(is_dir): Amend this so that it returns true for symlinks to
	directories too.
	* tools/abidiff.cc (options::no_default_supprs): New data member.
	(options::options): Initialize the new data member.
	(display_usage): Display a new help string for the new
	--no-default-suppression command line option.
	(parse_command_line): Parse this new command line option.
	(set_diff_context_from_opts): Load the default suppression
	specifications, unless --no-default-suppression or --supprs was
	provided.
	* tools/abipkgdiff.cc (options::no_default_supprs): New data
	member.
	(options::options): Initialize the new data member.
	(parse_command_line): Parse the new --no-default-suppression
	command line option.
	(main): Load the default suppression specifications, unless
	--no-default-suppression or --supprs was provided.
	* tools/fedabipkgdiff (abipkgdiff): Add --no-default-suppression
	to the invocation of abipkgdiff if it was provided on the command
	line.
	(build_commandline_args_parser): Parse the new
	--no-default-suppression command line option.
	* tests/runtestdefaultsupprs.py.in: New test harness template.
	* tests/Makefile.am: Add the new runtestdefaultsupprs.py to the
	set of tests.
	* tests/data/test-default-supprs/test0-type-suppr-0.suppr: New
	test input.
	* tests/data/test-default-supprs/test0-type-suppr-report-0.txt: Likewise.
	* tests/data/test-default-supprs/test0-type-suppr-v0.o: Likewise.
	* tests/data/test-default-supprs/test0-type-suppr-v1.o: Likewise.
	* tests/data/test-default-supprs/dirpkg-1-dir-report-0.txt:
	Likewise.
	* tests/data/test-default-supprs/dirpkg-1-dir1: Likewise.
	* tests/data/test-default-supprs/dirpkg-1-dir2: Likewise.
	* tests/data/Makefile.am: Add new the new tests input above to
	Makefile.am.
	* tests/runtestcanonicalizetypes.sh.in: Pass
	--no-default-suppression to abidiff invocations.
	* tests/runtestdefaultsupprs.py.in: Likewise.
	* tests/test-abidiff-exit.cc: Likewise.
	* tests/test-diff-dwarf-abixml.cc: Likewise.
	* tests/test-diff-filter.cc: Likewise.
	* tests/test-diff-suppr.cc: Likewise.
	* tools/abidiff.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-30 18:39:49 +02:00
Dodji Seketeli
af3e2fd570 Add --abipkgdiff option to fedabipkgdiff
When running the 'fedabipkgdiff' tool that is in the build directory,
before "make install", we want to use the 'abipkgdiff' command line
tool that is in the build directory, not the one that might be
at $PATH/bin/abipkgdiff.

To do so, this patch adds a --abipkgdiff <path/to/a/given/abipkgdiff>
option so that the user can chose where to find the 'abipkgdiff'
binary to use.

Note that there is no regression test for this option yet because for
that, we'd this bug to be fixed first:
https://sourceware.org/bugzilla/show_bug.cgi?id=20147.

	* tools/fedabipkgdiff (build_path_to_abipkgdiff): Define new
	function.
	(abipkgdiff): Invoke the new build_path_to_abipkgdiff() here.
	(build_commandline_args_parser): Parse the new --abipkgdiff
	option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-30 16:24:53 +02:00
Dodji Seketeli
7013500ca7 Add test data for tests/runtestfedabipkgdiff.py
While applying the patch 59917a8 and resolving the conflicts that
arose then, I forgot to git add the RPMs that were needed by the
accompanying test.

This test fixes that.

	* tests/data/test-fedabipkgdiff/dbus-glib-0.104-3.fc23.x86_64.rpm:
	New file.
	* tests/data/test-fedabipkgdiff/dbus-glib-0.80-3.fc12.x86_64.rpm: Likewise.
	* tests/data/test-fedabipkgdiff/dbus-glib-debuginfo-0.104-3.fc23.x86_64.rpm:
	Likewise.
	* tests/data/test-fedabipkgdiff/dbus-glib-debuginfo-0.80-3.fc12.x86_64.rpm:
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-25 12:29:28 +02:00
Chenxiong Qi
59917a8118 Bug 20085 - Add --dso-only option to fedabipkgdiff
abipkgdiff supports --dso-only to compare only ABI of shared libraries
instead of all binaries. So, with adding this option to fedabipkgdiff,
its user is also able to let fedabipkgdiff compare ABI of shared
libraries, or not.

	* tools/fedabipkgdiff: Do not import shlex anymore.
	(ABIDIFF_OK, ABIDIFF_ERROR, ABIDIFF_USAGE_ERROR)
	(ABIDIFF_ABI_CHANGE): New global constant variables.
	(abipkgdiff): Pass the --dso-only option to the abipkgdiff command
	line tool, if that option was passed to fedabipkgdiff. Build this
	abipkgdiff command invocation from an array of strings, rather
	than from formatting a string.  This makes us get rid of the shlex
	module.  Fix typo in dry-run logged string.  If there was an
	internal error reported by abipkgdiff, report it to stderr.
	(build_commandline_args_parser): Parse the --dso-only command line
	option.
	* tests/runtestfedabipkgdiff.py.in (fedabipkgdiff_mod): Fix a typo
	in initializing this global variable.
	(test_data_dir): New global variable, that is used to reference
	tests/data/test-fedabipkgdiff/.
	(RunAbipkgdiffTest.{test_all_success, test_partial_failure}): Fix
	typo.
	(Mockglobalconfig.{koji_topdir, dso_only}): New data members.
	(GetPackageLatestBuildTest.{test_get_latest_one,
	test_cannot_find_a_latest_build_with_invalid_distro,
	test_succeed_to_download_a_rpm, test_failed_to_download_a_rpm}):
	Fix typo.
	(BrewListRPMsTest.test_select_specific_rpms): Fix typo.
	(RunAbipkgdiffWithDSOOnlyOptionTest): New test case class.
	* doc/manuals/fedabipkgdiff.rst: update document for this new
	--dso-only option.
	* tests/data/test-fedabipkgdiff/dbus-glib-0.104-3.fc23.x86_64.rpm:
	New symbolic link to
	test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64.rpm.
	* tests/data/test-fedabipkgdiff/dbus-glib-0.80-3.fc12.x86_64.rpm:
	New symbolic link to
	test-diff-pkg/dbus-glib-0.80-3.fc12.x86_64.rpm.
	* tests/data/test-fedabipkgdiff/dbus-glib-debuginfo-0.104-3.fc23.x86_64.rpm:
	New symbolic link to
	test-diff-pkg/dbus-glib-debuginfo-0.104-3.fc23.x86_64.rpm.
	* tests/data/test-fedabipkgdiff/dbus-glib-debuginfo-0.80-3.fc12.x86_64.rpm:
	New symbolic link to
	test-diff-pkg/dbus-glib-debuginfo-0.80-3.fc12.x86_64.rpm.
	* tests/data/Makefile.am: add tests/data/test-fedabipkgdiff so
	that this data directory and all things within it can be included
	in tarball.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-25 09:42:21 +02:00
Dodji Seketeli
e19bf5627a Make abi{pkg}diff filter out changes about private types
This is to address the following enhancement requests:

    #19588 - Add a --headers-dir1 and --headers-dir2 option to abidiff
    #19948 - Add --devel-pkg1 and --devel-pkg2 options to abipkgdiff

When the user specifies where to find header files for two binaries
(or packages) being compared, this patch generates a type suppression
specification that filters out change reports about types that are
defined in files that are not in the set of header files specified.

The type suppression specification also suppresses change reports
about changed/added/removed virtual member functions which enclosing
class type matches the type suppression specification.

There is a corner case that the patch handles too, and that is
exhibited by the accompanying test case for abidiff.  There can be a
class defined by DWARF as having no source location and as being a
pure declaration.  This can be a class declaration that has inline
virtual members only, and one or several non-defined virtual methods
too.  When that declaration is included in a source file, GCC
generates debug info that describes that class as being a
declaration-only class with no source declaration.  This patch
considers such a class as being non defined; you know, like a true
opaque type.  So it's considered being not defined in any public
header file.  Changes to this kind of class are thus filtered out.

	* include/abg-comp-filter.h: Update copyright year.
	* src/abg-comp-filter.cc (has_virtual_mem_fn_change): Make this
	static function become exported.
	(has_virtual_mem_fn_change): Declare new function.
	* include/abg-suppression.h
	(suppression_base::{get,set}_is_artificial): Declare new
	accessors.
	(type_suppression::get_source_locations_to_keep): Return an
	unordered set of strings, not a vector.  Add a non-const overload.
	(type_suppression::set_source_locations_to_keep): Set an unordered
	set of strings, not a vector.
	* src/abg-suppression.cc (suppression_base::priv::is_artificial_):
	New data member.
	(suppression_base::priv::priv): Initialize the new data member.
	(suppression_base::{get,set}_is_artificial): Define new accessors.
	(type_suppression::priv::source_locations_to_keep_): Change the
	vector of strings representing source file names into unordered
	set of string.
	(type_suppression::get_source_locations_to_keep): Return an
	unordered set of strings, not a vector.  Define a non-const
	overload.
	(type_suppression::set_source_locations_to_keep): Set an unordered
	set of strings, not a vector.
	(type_suppression::suppresses_diff): Make this suppress virtual
	member function diffs if the enclosing type of the changed virtual
	member is suppressed by the current type_suppression.
	(read_type_suppression): Adjust to use the fact that the source
	locations are not stored in an unordered set, not in a vector
	anymore.  Otherwise, using a vector here make things too slow.
	(type_suppression::suppresses_type): Likewise.  Also, If the type
	we are looking at has no location because it's a true opaque type
	and if the current suppression is an artificial suppression that
	is meant to suppress change reports about non-public types, then
	suppress the type.
	* include/abg-tools-utils.h (gen_suppr_spec_from_headers): Declare
	new public function.
	* src/abg-tools-utils.cc (PRIVATE_TYPES_SUPPR_SPEC_NAME): Define a
	new constant variable.
	(handle_fts_entry): Define new static function.
	(gen_suppr_spec_from_headers): Define new public function.
	* src/abg-comparison.cc
	(corpus_diff::priv::apply_suppressions_to_added_removed_fns_vars):
	If a type suppression suppresses a given class C, make it change
	added/removed virtual functions whose enclosing type is C.
	* tools/abidiff.cc (options::{headers_dir1, headers_dir2}): New
	data members.
	(display_usage): Add help strings for --headers-dir1 and
	--headers-dir2.
	(parse_command_line): Parse the new --headers-dir1 and
	--headers-dir2 options.
	(set_diff_context_from_opts): Generate suppression specifications
	to filter out changes on private types, if --headers-dir1 or
	--headers-dir2 is given.
	* tools/abipkgdiff.cc (options::{devel_package1, devel_package2}):
	New data members.
	(typedef package_sptr): New typedef.
	(enum package::kind): New enum.
	(package::kind_): New data member.  This replaces ...
	(package::is_debug_info_): ... this data member.
	(package::{devel_package_, private_types_suppressions_}): New data
	members.
	(package::package): Adjust.
	(package::get_kind): Define new member function.  This replaces
	...
	(package::is_debug_info): ... this member function overload.
	(package::set_kind): Define new member functin.  It replaces ...
	(package::is_debug_info): ... this member function overload.
	(package::{devel_package, private_types_suppressions}): Define new
	accessors.
	(package::erase_extraction_directies): Erase the sub-directory
	where development packages are extracted to.
	(compare_args::private_types_suppr{1,2}): New data members.
	(compare_args::compare_args): Adjust.
	(display_usage): Add help strings for --devel-pkg1/--devel-pkg2.
	(compare): Make the overload that compares elf files take private
	types suppressions.  Add the private types suppressions to the
	diff context.
	(pthread_routine_compare): Adjust the call to compare.
	(maybe_create_private_types_suppressions): Define new static
	function.
	(pthread_routine_extract_pkg_and_map_its_content): If a devel
	package was specified for the main package then extract it in
	parallel with the other package extraction.  When the extraction
	is done, create private types suppressions by visiting the
	directories that contain the header files.
	(compare): In the overload that compares packages by scheduling
	comparison of individual elf files that are in the packages, pass
	in the private type suppressions too.
	(parse_command_line): Parse the new --devel-pkg{1,2} command line
	options.
	(main): Associate the devel package to the main package, if the
	--devel-pkg{1,2}.
	* doc/manuals/abidiff.rst: Add documentation about the new
	--headers-dir1 and --headers-dir2 options.
	* doc/manuals/abipkgdiff.rst: Likewise, add documentation about
	the new --devel-pkg1 and --devel-pkg2 libraries.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt:
	New test reference output.
	* tests/data/test-diff-pkg/tbb-devel-4.1-9.20130314.fc22.x86_64.rpm:
	New test input package.
	* tests/data/test-diff-pkg/tbb-devel-4.3-3.20141204.fc23.x86_64.rpm: Likewise.
	* tests/test-diff-pkg.cc b/tests/test-diff-pkg.cc
	(InOutSpec::{first,second}_in_devel_package_path): New data
	members.
	(in_out_specs): Adjust.  Also, add a new entry describing the new
	test inputs above.
	(test_task::perform): When the new test entry contains devel
	packages, pass them to abipkgdiff using the --devel1 and --devel2
	options.
	* tests/data/test-diff-suppr/test30-include-dir-v0/test30-pub-lib-v0.h:
	A new test input source code.
	* tests/data/test-diff-suppr/test30-include-dir-v1/test30-pub-lib-v1.h: Likewise.
	* tests/data/test-diff-suppr/test30-priv-lib-v0.cc: Likewise.
	* tests/data/test-diff-suppr/test30-priv-lib-v0.h: Likewise.
	* tests/data/test-diff-suppr/test30-priv-lib-v1.cc: Likewise.
	* tests/data/test-diff-suppr/test30-priv-lib-v1.h: Likewise.
	* tests/data/test-diff-suppr/test30-pub-lib-v0.cc: Likewise.
	* tests/data/test-diff-suppr/test30-pub-lib-v0.so: Add new test
	binary input.
	* tests/data/test-diff-suppr/test30-pub-lib-v1.cc: Add new test
	input source code.
	* tests/data/test-diff-suppr/test30-pub-lib-v1.so: Add new test
	binary input.
	* tests/data/test-diff-suppr/test30-report-0.txt: Add new test
	reference output.
	* tests/data/test-diff-suppr/test30-report-1.txt: Add new test
	reference output.
	* tests/test-diff-suppr.cc (InOutSpec::headers_dir{1,2}): New data
	members.
	(InOutSpec::abidiff_options): Renamed the bidiff_options data
	member into this.
	(in_out_specs): Adjust.  Also, added the new test input above to
	this.
	(main): Adjust to invoke abidiff with the new --hd1 and --hd2
	options if the input specs for the tests has the new
	InOutSpec::headers_dir{1,2} data member set.  Renamed bidiff into
	abidiff.
	* tests/data/Makefile.am: Add the new test inputs to the source
	distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-24 10:32:08 +02:00
Dodji Seketeli
b28cb4ec6d Fix whitespaces in autotools files
* configure.ac: Fix some white spaces.
	* tests/Makefile.am: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-22 23:20:13 +02:00
Dodji Seketeli
1fc1032e7d Fix invocation of delete operator in test-read-dwarf.cc
* tests/test-read-dwarf.cc (main): Call delete[], not delete.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-22 23:20:13 +02:00
Dodji Seketeli
ce5e4889b1 Plug leak of debug info handles
On recent elfutils where the libdw's function dwarf_getalt exists, we
don't need to try and find the alternate debug info file ourselves by
using the function dwfl_standard_find_debuginfo.  Furthermore, when we
use that function on those recent elfutils versions, we leak the elf
resources allocated in the debug info resources; we also leak the file
descriptor to access the alternate debug info sections.

More generally, we also leak debug info handles used to access debug
info when using get_soname_of_elf_file and get_type_of_elf_file.

This patch plugs those leaks.

In the first case, if the function dwarf_getalt exists, the patch just
uses it to get the alternate debug info.  Otherwise, the patch uses
the dwfl_standard_find_debuginfo function like we used to, but then it
tries hard to free the file descriptor and debuginfo memory of the
alternate debug info.

	* configure.ac: Check the presence of dwarf_getalt in libdw.  If
	it's present, define the preprocessor macro
	LIBDW_HAS_DWARF_GETALT.  Update the autoconf configuration
	summary.
	* src/abg-dwarf-reader.cc: Add config.h.
	(find_alt_debug_info_location): Factorize this out of ...
	(find_alt_debug_info): ... this function.  Use dwarf_getalt if
	present, otherwise, keep using dwfl_standard_find_debuginfo.  In
	the later case, return the file descriptor opened to access the
	alternate debug info, by parameter, so that the caller can fclose
	it.
	(read_context::alt_fd_): New data member.
	(read_context::read_context): Initialize the new alt_fd_ data
	member.
	(read_context::load_debug_info): Store the file descriptor used to
	access the alternate debug info into the new alt_fd_ data member.
	(read_context::~read_context): New desctructor.
	(get_soname_of_elf_file, get_type_of_elf_file): Free the elf
	handle.
	(read_context::load_debug_info): Be paranoid in making sure we
	never override alt_dwarf_.
	* tests/data/test-alt-dwarf-file/test0-report.txt: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-22 23:20:13 +02:00
Dodji Seketeli
3dbe842159 Support running "make check-valgrind"
This patch allows maintainers to run:

     make -C <builddir>/tests check-valgrind

This runs the test suite under the Valgrind memory checker.

It also adds this target:

   make -C <builddir>/tests check-valgrind-memcheck-recursive

It runs the memcheck tool on the tests so that programs forked by them
are memchecked too.  This is to allow to memcheck the libabigail tools
that are forked by the individual tests.

	* autoconf-archive/ax_valgrind_check.m4: Add new file.  Copied it
	from http://www.gnu.org/software/autoconf-archive/ax_valgrind_check.html.
	* configure.ac: Include the new ax_valgrind_check.m4 file.
	Initialize the valgrind checking on tests.  Update the configure
	status.
	* tests/test-valgrind-suppressions.supp: New valgrind suppression
	file to silence memcheck leak errors from python.
	* tests/Makefile.am: Add test-valgrind-suppressions.supp to source
	distribution.  Add check-valgrind-memcheck-recursive target.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-22 23:20:12 +02:00
Dodji Seketeli
20ffce5239 Do not run fedabipkgdiff tests if --enable-fedabipkgdiff is turned off
* tests/Makefile.am: Make running runtestfedabipkgdiff be
	dependent on ENABLE_FEDABIPKGDIFF.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-16 13:12:05 +02:00
Chenxiong Qi
57dcfb18f5 Bug 19428 - New fedabipkgdiff utility
fedabipkgdiff is a convenient way to compare the ABI of Fedora
packages easily.

The first version of fedabipkgdiff introduced by this patch lets users
perform operations like:

    fedabipkgdiff --from fc23 foo-0.1-1.fc23.x86_64.rpm
    fedabipkgdiff --from fc23 --to fc24 foo
    fedabipkgdiff foo-0.1-1.fc23 foo-0.1-1.fc24
    fedabipkgdiff foo-0.1-1.fc23.i686 foo-0.1-1.fc24.i686
    fedabipkgdiff --all-subpackages foo-0.1-1.fc23 foo-0.1-1.fc24

	* autoconf-archive/ax_compare_version.m4: New file copied from the
	autoconf-archive project.
	* autoconf-archive/ax_prog_python_version.m4: Likewise.
	* autoconf-archive/ax_python_module.m4: Likewise.
	* Makefile.am: Add the new files above to the source distribution.
	* configure.ac: Include the new m4 macros from the autoconf
	archive. Add a new --enable-fedabipkgdiff option. Update the
	report at the end of the configure process to show the status of
	the fedabipkgdiff feature. Add check for prerequisite python
	modules argparse, glob, logging, os, re, shlex, subprocess, sys,
	itertools, urlparse, itertools, shutil, unittest, xdg, koji and
	mock.  These are necessary for the unit test of
	fedabipkgdiff. Generate tests/runtestfedabipkgdiff.py into the
	build directory, from the tests/runtestfedabipkgdiff.py.in input
	file.
	* tools/Makefile.am: Include the fedabipkgdiff to the source
	distribution and install it if the "fedabipkgdiff" feature is
	enabled.
	* tests/Makefile.am: Rename runtestfedabipkgdiff.sh into
	runtestfedabipkgdiff.py.  Add the new runtestfedabipkgdiff.py.in
	autoconf template file in here.
	* tests/runtestfedabipkgdiff.py.in: New unit test file.
	* tools/fedabipkgdiff: New fedabipkgdiff tool.
	* doc/manuals/fedabipkgdiff.rst: New manual.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-13 00:42:36 +02:00
Dodji Seketeli
080b88c9a1 Implement a [suppress_file] suppression directive
abidiff, abipkgdiff and abicompat now recognize a [suppress_file]
directive in suppression specifications.  That directive instructs the
tool to avoid loading some binaries altogether.

This is the first directive that won't act on the result of the
comparison of two binaries.  It actually acts earlier and prevents the
tool from loading some binaries altogether.

The directive looks like:

    [suppress_file]
      # Don't load any library named lib_private*.so
      file_name_regexp = lib_private.*\\.so

This prevents the tool from loading (and thus comparing) any library
which name matches the pattern "lib_private*.so".

    [suppress_file]
      # Only load libraries name lib_public*.so
      file_name_not_regexp = lib_public.*\\.so

This instructs the tool to only load (and compare) files which name
match the pattern "lib_public*.so".

	* doc/manuals/libabigail-concepts.rst: Document the new
	'suppress_file' directive.
	* include/abg-suppression.h (file_suppression): Define new class.
	(file_suppression_sptr): Define new typedef.
	(is_file_suppression, file_is_suppressed): Declare new functions.
	* src/abg-suppression.cc ():
	(read_file_suppression, is_file_suppression, file_is_suppressed):
	Define new functions.
	(file_suppression::{file_suppression, suppresses_file,
	~file_suppression}): Define new member functions.
	* tools/abidiff.cc (main): If a suppression specification
	suppresses one of the input files, then do not perform the
	comparison.
	* tools/abipkgdiff.cc (compare): If a suppression specification
	suppresses a file that is to be compared, then do not perform the
	comparison.
	* tools/abicompat.cc (create_diff_context): New static function.
	(perform_compat_check_in_normal_mode)
	(perform_compat_check_in_weak_mode): Adjust to take a context in
	parameter.  Do not create a diff context here anymore, do not load
	suppression files here either.
	(main): Use the new create_diff_context to create a diff context
	and initialize it, including loading suppression specifications.
	If any suppression specification suppresses a file to load, then
	do not load perform any compatibility checking.  Adjust
	invocations of perform_compat_check_in_weak_mode and
	perform_compat_check_in_normal_mode to pass the diff context.
	* tests/data/test-diff-suppr/test0-type-suppr-3.suppr: New test
	input.
	* tests/data/test-diff-suppr/test0-type-suppr-4.suppr: Likewise.
	* tests/data/test-diff-suppr/test0-type-suppr-report-4.txt: Likewise.
	* tests/data/test-diff-suppr/test0-type-suppr-5.suppr: Likewise.
	* tests/data/test-diff-suppr/test0-type-suppr-report-5.txt:
	Likewise.
	* tests/data/test-diff-suppr/test0-type-suppr-6.suppr: Likewise.
	* tests/data/test-diff-suppr/test0-type-suppr-report-6.txt:
	Likewise.
	* tests/data/test-diff-suppr/test0-type-suppr-report-7.txt:
	Likewise.
	* tests/test-diff-suppr.cc (in_out_specs): Use the new test
	inputs.
	* tests/data/test-abicompat/test0-fn-changed-1.suppr: New test
	input.
	* tests/data/test-abicompat/test0-fn-changed-report-3.txt:
	Likewise.
	* tests/test-abicompat.cc (in_out_specs):: Use the new test
	inputs.
	* tests/data/Makefile.am: Add the new test material to source
	distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-08 12:39:26 +02:00
Dodji Seketeli
b885e6283f Bug 20015 - support file_name_not_regexp and soname_not_regexp in suppr specs
The supression directives suppress_type, suppress_function and
suppress_variable support the two properties below, among others:

    file_name_regexp = <some-regexp>
    soname_regexp = <some-regexp>

When the regular expression matches either the file name or the
soname, then the suppression directive is activated.

This patch adds the support for these two additional properties for
these suppression directives:

    file_name_not_regexp = <some-regexp>
    soname_not_regexp = <some-regexp>

These activate the current suppression directive if the regular
expression does *NOT* match the file name or soname.

This is very helpful to express change report suppressions like:

    "suppress all ABI change reports for all libraries but those with
    file names (or sonames) with the pattern libfoobar.*"

	* include/abg-comparison.h
	(suppression_base::{get,set}_file_name_not_regex_str): Declare new
	member functions.
	(suppression_base::{get,set}_soname_not_regex_str): Likewise.
	(suppression_base::{names,sonames}_of_binaries_match): Likewise.
	* src/abg-comparison.cc
	(suppression_base::priv::get_file_name_regex): Fix comment.
	(suppression_base::priv::get_file_name_not_regex): New member
	function.
	(suppression_base::priv::get_soname_regex): Fix comment.
	(suppression_base::priv::get_soname_not_regex): New member
	function.
	(suppression_base::{get,set}_file_name_not_regex_str): Define new
	member functions.
	(suppression_base::{get,set}_soname_not_regex_str): Likewise.
	(suppression_base::{names,sonames}_of_binaries_match): Likewise.
	These got factorized out of type_suppression::suppresses_type,
	function_suppression::suppresses_function,
	function_suppression::suppresses_function_symbol,
	variable_suppression::suppresses_variable,
	variable_suppression::suppresses_variable_symbol.
	(type_suppression::suppresses_type): Use the new
	suppression_base::{names,sonames}_of_binaries_match.
	(read_type_suppression): Read the new file_name_not_regexp and
	soname_not_regexp properties.
	(function_suppression::{suppresses_function,
	suppresses_function_symbol}): Use the new
	suppression_base::{names,sonames}_of_binaries_match.
	(read_function_suppression): Read the new file_name_not_regexp and
	soname_not_regexp properties.
	(variable_suppression::{suppresses_variable,
	variable_suppression::suppresses_variable_symbol}): Use the new
	suppression_base::{names,sonames}_of_binaries_match.
	(read_variable_suppression): Use the new
	suppression_base::{names,sonames}_of_binaries_match.
	* doc/manuals/libabigail-concepts.rst: Document the new
	file_name_not_regexp and soname_not_regexp suppression properties.
	* tests/data/test-diff-suppr/test24-soname-report-10.txt: New test
	reference output.
	* tests/data/test-diff-suppr/test24-soname-report-11.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-12.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-13.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-14.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-15.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-16.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-9.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-suppr-10.txt: New test input.
	* tests/data/test-diff-suppr/test24-soname-suppr-11.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-suppr-12.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-suppr-13.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-suppr-14.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-suppr-15.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-suppr-16.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-suppr-9.txt: Likewise.
	* tests/data/test-diff-suppr/test29-soname-report-2.txt: New test
	reference output.
	* tests/data/test-diff-suppr/test29-soname-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test29-soname-report-4.txt: Likewise.
	* tests/data/test-diff-suppr/test29-soname-report-5.txt: Likewise.
	* tests/data/test-diff-suppr/test29-soname-report-6.txt: Likewise.
	* tests/data/test-diff-suppr/test29-soname-report-7.txt: Likewise.
	* tests/data/test-diff-suppr/test29-soname-report-8.txt: Likewise.
	* tests/data/test-diff-suppr/test29-suppr-2.txt: New test input.
	* tests/data/test-diff-suppr/test29-suppr-3.txt: Likewise.
	* tests/data/test-diff-suppr/test29-suppr-4.txt: Likewise.
	* tests/data/test-diff-suppr/test29-suppr-5.txt: Likewise.
	* tests/data/test-diff-suppr/test29-suppr-6.txt: Likewise.
	* tests/data/test-diff-suppr/test29-suppr-7.txt: Likewise.
	* tests/data/test-diff-suppr/test29-suppr-8.txt: Likewise.
	* tests/data/Makefile.am: Add the new test material to source
	distribution.
	* tests/test-diff-suppr.cc (in_out_specs): Make this test harness
	run over the new test inputs.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-04-27 23:58:50 +02:00
Dodji Seketeli
2529f84ae0 Bug 19964 - Cannot load function aliases on ppc64
Registering alias of functions on ppc64 seems to be broken since this
commit:

    11f5dba Bug 19885 - Cannot associates a function DIE to a symbol on powerpc64

This is because the ppc64-specific code tries to register a symbol
alias that was already registered as an alias by the arch-agnostic
code.

This patch fixes that.

	* src/abg-dwarf-reader.cc (read_context::load_symbol_maps): While
	filling the ppc64-specific "function-entry-address => symbol" map,
	if we stumble accross a function-entry-address that belongs to an
	alias of 'symbol', then assume the alias must have been registered
	as an alias already, by the platform-agnostic code.  Do not try to
	register the alias again.
	* tests/data/Makefile.am: Add the new test input binaries to the
	source distribution.
	* tests/data/test-diff-dwarf/libtest36-ppc64-aliases-v0.so: New
	binary test input.
	* tests/data/test-diff-dwarf/libtest36-ppc64-aliases-v1.so: Likewise.
	* tests/data/test-diff-dwarf/test36-ppc64-aliases-report-0.txt:
	New test reference output.
	* tests/data/test-diff-dwarf/test36-ppc64-aliases-v0.cc: Source
	code for the new binary test input above.
	* tests/data/test-diff-dwarf/test36-ppc64-aliases-v1.cc: Likewise.
	* tests/test-diff-dwarf.cc: Add the new test input to the list of
	test inputs considered by this test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-04-25 14:48:11 +02:00
Sinny Kumari
8944ceb9ef Bug 19961 - Distinguish between PI executable and shared library
In the ELF format, Position Independent Executables (aka PIE) and
shared libraries are marked as being of type ET_DYN.  So just looking
at the type of the ELF file is not enough to discriminate a position
independent executable from a shared library.

And this is the problem.  Libabigail just looks at the type of the ELF
file to discriminate PIE binaries from shared libraries binaries.

So it treats both kinds of binaries as being shared libraries.  When
we run abipkgdiff with the --dso-only option, the tool considers both
PIEs and shared libraries, even though the intent of the --dso-only
option is have the tool consider shared libraries only.

With this patch, we introduce a new enumerator ELF_TYPE_PI_EXEC (to
the elf_type enum) for PIE binaries.  From now on, a file will be
properly recognized as being of the ELF_TYPE_DSO kind only if it is a
shared library.

	* include/abg-dwarf-reader.h (elf_type): Add new enumerator
	ELF_TYPE_PI_EXEC.
	* src/abg-dwarf-reader.cc
	(lookup_data_tag_from_dynamic_segment): New function for
	data tag lookup in dynamic segment of an elf
	(elf_file_type): Return ELF_TYPE_PI_EXEC file type for
	a PI executable.
	(get_elf_file_type): Change this to take an elf handle.
	(get_type_of_elf_file): New function that got factorized out of ...
	(load_dt_soname_and_needed): ... this one.
	* tools/abipkgdiff.cc (create_maps_of_package_content): Also
	consider ELF_TYPE_PI_EXEC file type.
	(compare): Likewise.
	* tests/test-diff-pkg.cc (in_out_specs): Test case additions
	* tests/data/Makefile.am: Include test files
	* tests/data/test-diff-pkg/tarpkg-1-dir1.tar.gz: New test data
	* tests/data/test-diff-pkg/tarpkg-1-dir2.tar.gz: New test data
	* tests/data/test-diff-pkg/tarpkg-1-report-0.txt: New test result

Signed-off-by: Sinny Kumari <sinny@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-04-20 17:05:16 +02:00
Dodji Seketeli
f6c182bb56 Ease use of soname_regexp/file_name_regexp in suppr specs
In a suppression specification, soname_regexp or file_name_regexp
cannot be the only property of a suppression directive.  For instance,
the suppression specification below won't work:

    [suppress_type]
      # suppress all change reports about *any type* from the library
      # libtestfoo.so
      file_name_regexp = libtestfoo.so

This is because as documented in the manual, the suppression directive
'suppress_type' requires that some other properties be specified.  For
instance, the below would work:

    [suppress_type]
      name_regexp = .*
      file_name_regexp

This was done on purpose to prevent folks from inadvertently
suppressing too much of change report bits.

But experience is showing that this is surprising some users.  And in
hindsight, I kind of agree it's surprising.

So this patch allows the first example to work, as seems to be
expected.

The patch allows the first example to work for the suppress_function
and suppress_variable directive too.

	* doc/manuals/libabigail-concepts.rst: Update the manual to
	reflect the changes in the suppression_type, suppress_function and
	suppress_variable directives.
	* src/abg-comparison.cc (read_type_suppression): Accept that
	the suppress_type directive contains only file_name_regexp
	or the soname_regexp property.
	(read_function_suppression): Likewise for the suppress_function
	directive.
	(read_variable_suppression): Likewise for the suppress_variable
	directive.
	* tests/data/test-diff-suppr/libtest29-soname-v0.so: New binary
	test input.
	* tests/data/test-diff-suppr/libtest29-soname-v1.so: Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-5.txt: New
	reference test output.
	* tests/data/test-diff-suppr/test24-soname-report-6.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-7.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-8.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-suppr-5.txt: New test
	suppression file.
	* tests/data/test-diff-suppr/test24-soname-suppr-6.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-suppr-7.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-suppr-8.txt: Likewise.
	* tests/data/test-diff-suppr/test29-soname-report-0.txt: New
	reference test output.
	* tests/data/test-diff-suppr/test29-soname-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test29-soname-v0.cc: Source code for
	the new binary output above.
	* tests/data/test-diff-suppr/test29-soname-v1.cc: Likewise.
	* tests/data/test-diff-suppr/test29-suppr-0.txt: New test
	suppression file.
	* tests/data/test-diff-suppr/test29-suppr-1.txt: Likewise.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-diff-suppr.cc (in_out_specs): Make this test harness
	run over the new test input above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-04-16 21:47:20 +02:00
Dodji Seketeli
d06c4cd2ca Fix comments in tests/test-diff-pkg.cc
* tests/test-diff-pkg.cc: Fix the wording of the introductory
	comments.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-03-31 10:13:49 +02:00
Dodji Seketeli
11f5dbaab2 Bug 19885 - Cannot associates a function DIE to a symbol on powerpc64
On powerpc 64 ELFv1, the address of a function is different from the
address of the entry point of that function.  The value of a en ELF
symbol represents the address of the function, whereas the
DW_AT_low_pc DWARF attribute of a function DIE points to the entry
point address of the function.  So to get the symbol a function's
DW_AT_low_pc points to, one needs to get the address of the function
*from* the address of its entry point.

More precisely, on ppc64, the address of a function is the address of
a function descriptor.  The function descriptor is a set of three 64
bits addresses.  The first element of the triplet is the function
entry pointer address.  So to get the symbol a given function entry
point address belongs to, one must get to the function descriptor
which contains said function entry point address.  And function
descriptors are in the ".opd" special section.

Unfortunately, Libabigail's  ELF/DWARF reader has no knowledge of all
this.  So it cannot get the symbol of a given function DWARF
description.  So it considers all functions as having no ELF symbols.
So it shows no ABI change pertaining to function sub-types on ppc64.

This patch makes Libabigail support function descriptors on ppc64 so
it can detect changes on function sub-types there.

	* src/abg-dwarf-reader.cc (read_context::{opd_section_,
	fun_entry_addr_sym_map_}): New data members.
	(read_context::read_context): Initialize the new opd_section_ data
	member.
	(read_context::{find_opd_section,
	lookup_ppc64_elf_fn_entry_pointer_address,
	fun_entry_addr_sym_map_sptr, fun_entry_addr_sym_map,
	elf_architecture_is_ppc64, elf_architecture_is_big_endian}): New
	member functions.
	(read_context::lookup_elf_fn_symbol_from_address): Adjust to use
	the new read_context::fun_entry_addr_sym_map() function.
	(read_context::load_symbol_maps): Populate the function entry
	addresses -> symbol map, for ppc64 ELFv1.
	(read_context::load_elf_properties): Renamed
	read_context::load_remaining_elf_data into this.
	(read_corpus_from_elf): Load elf properties before trying to load
	elf symbols information.
	* tests/data/test-diff-filter/libtest32-struct-change-v0.so: New
	binary test input, compiled for ppc64le.
	* tests/data/test-diff-filter/libtest32-struct-change-v1.so: Likewise.
	* tests/data/test-diff-filter/test32-ppc64le-struct-change-report0.txt:
	New test reference output.
	* tests/data/test-diff-filter/test32-ppc64le-struct-change-v0.c:
	Source code of the new binary test input above.
	* tests/data/test-diff-filter/test32-ppc64le-struct-change-v1.c:
	Likewise.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-diff-filter.cc (in_out_spec): Make this test harness
	run over the new test input binaries above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-03-30 20:17:42 +02:00
Dodji Seketeli
67435cf6cd Bug 19867 - abipkgdiff skips symbolic links
When comparing two directories, abipkgdiff skips symbolic links
pointing to ELF binaries altogether.  It only consider regular files.
This is a problem when abipkgdiff is given two directories that only
contain symbolic links.  In that case, abipkgdiff just performs no
comparison.

This patch makes abipkgdiff resolve the symbolic link to its target
file.

	* include/abg-tools-utils.h (maybe_get_symlink_target_file_path):
	Declare new function.
	* src/abg-tools-utils.cc (get_stat): Use lstat here, not stat.
	Update comment.
	* tools/abipkgdiff.cc (first_package_tree_walker_callback_fn)
	(second_package_tree_walker_callback_fn): Follow symbolic links to
	elf files to get their target paths, and only work with that
	target path.
	(maybe_get_symlink_target_file_path): Define new function.
	* test-diff-pkg/symlink-dir-test1-report0.txt New test material.
	* test-diff-pkg/symlink-dir-test1/dir1/symlinks/foo.o: Likewise.
	* test-diff-pkg/symlink-dir-test1/dir1/symlinks/libfoo.so: Likewise.
	* test-diff-pkg/symlink-dir-test1/dir1/targets/foo.c: Likewise.
	* test-diff-pkg/symlink-dir-test1/dir1/targets/foo.o: Likewise.
	* test-diff-pkg/symlink-dir-test1/dir1/targets/libfoo.so: Likewise.
	* test-diff-pkg/symlink-dir-test1/dir2/symlinks/foo.o: Likewise.
	* test-diff-pkg/symlink-dir-test1/dir2/symlinks/libfoo.so: Likewise.
	* test-diff-pkg/symlink-dir-test1/dir2/targets/foo.c: Likewise.
	* test-diff-pkg/symlink-dir-test1/dir2/targets/foo.o: Likewise.
	* test-diff-pkg/symlink-dir-test1/dir2/targets/libfoo.so: Likewise.
	* tests/data/Makefile.am: Add the new test material to source
	distribution.
	* tests/test-diff-pkg.cc (in_out_spec): Run this test harness
	over the new test material above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-03-25 13:52:02 +01:00
Dodji Seketeli
10b029b385 Bug 19844 - Cannot try to canonicalize a type that is being constructed
maybe_canonicalize_type aborts because the assertion that
read_context::lookup_type_from_die_offset should always return a type
is violated.  read_context::lookup_type_from_die_offset is called on
the offset of a DIE of a type that is being constructed.  The problem
is that that fonction only looks in the map of types that are fully
constructed.

This patch addresses the issue by making
read_context::lookup_type_from_die_offset look up class and function
types being constructed as well.

While doing that I had to add maps for class and function types being
constructed and that are in the alternate debug info section.  I
adjusted the accessors for class and function types accordingly.  The
code using those accessors was adjusted accordingly as well.

The patch also prevents maybe_canonicalize_type for DIEs which no type
was built for, in buid_ir_node_from_die.  This is particularly for
DW_TAG_class_type and DW_TAG_structure_type DIEs.

	* src/abg-dwarf-reader.cc
	(read_context::{alternate_die_wip_classes_map_,
	alternate_die_wip_function_types_map_}): New data members.
	(read_context::lookup_type_from_die_offset): Lookup WIP class and
	function types too.
	(read_context::{die_wip_classes_map, die_wip_function_types_map}):
	Take a flag saying if we should get the map for the alternate
	debug info section or not.
	(read_context::{is_wip_class_die_offset,
	is_wip_function_type_die_offset}): Take a flagy saying if the DIE
	is in the alternate debug info section or not.
	(build_class_type_and_add_to_ir, build_function_type)
	(maybe_canonicalize_type): Adjust.
	(build_ir_node_from_die): Do not call maybe_canonicalize_type on
	type DIEs which no type has been constructed for.
	* tests/data/test-diff-pkg/gtk2-debuginfo-2.24.22-5.el7.i686.rpm:
	New test input.
	* tests/data/test-diff-pkg/gtk2-debuginfo-2.24.28-8.el7.i686.rpm:
	Likewise.
	* tests/data/test-diff-pkg/gtk2-immodule-xim-2.24.22-5.el7.i686.rpm:
	Likewise.
	* tests/data/test-diff-pkg/gtk2-immodule-xim-2.24.28-8.el7.i686.rpm:
	Likewise.
	* tests/data/test-diff-pkg/gtk2-immodule-xim-2.24.22-5.el7.i686--gtk2-immodule-xim-2.24.28-8.el7.i686-report-0.txt:
	New test reference output.
	* tests/data/Makefile.am: Add the new test material to the source
	distribution.
	* tests/test-diff-pkg.cc (in_out_spec): Make this test harness run
	on the new test input above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-03-18 18:15:29 +01:00
Dodji Seketeli
d611e96460 Fix potential race condition in test-diff-pkg.cc
The output of several tar file tests for abipkgdiff have the same
name.  This is can be a race condition now that these tests are run in
parallel, potentially.

This patch fixes the issue by giving each test output file a different
name.

	* tests/test-diff-pkg.cc (in_out_spec): Make the tar format tests
	output have different names.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-03-08 14:34:58 +01:00
Dodji Seketeli
9efa6af3e2 Fix reference to test file in Makefile.am
* tests/data/Makefile.am: Fix bogus reference to
	libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-03-07 15:13:04 +01:00
Dodji Seketeli
326992f0e1 Bug 19780 - abipkgdiff doesn't support parallel execution
package::extracted_packages_parent_dir() is not returning a unique
directory path.  So several abipkgdiff processes end up using the same
temporary directory.  Ooops.

This patch addresses the issue by making that function use mkdtemp().

The patch also makes the unit tests for abipkgdiff run the instances
of abipkgdiff in parallel so that we test this once and for all.

	* tools/abipkgdiff.cc: Update copyright notice.
	(package::extracted_packages_parent_dir): Use mkdtemp to generate
	the unique root directory under which packages are extracted.
	* tests/test-diff-pkg.cc (struct test_task): New type.
	(main): Use worker threads to run abipkgdiff in parallel,
	depending on the number of CPUs advertised by the underlying
	machine.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-03-07 14:15:08 +01:00
Dodji Seketeli
3cf729c3ee Bug 19778 - diff_has_ancestor_filtered_out() loops forever
It appears that there can be cycles in the path made of ancestors.  In
that case, diff_has_ancestors_filtered_out() just loops forever.
Oops.

This patch addresses that issue by making
diff_has_ancestors_filtered_out() detect cycles.

	* src/abg-comparison.cc (diff_has_ancestor_filtered_out): Add an
	overload that takes an additional map of pointer values.  Make the
	older overload call the new one.
	* tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm: New test material.
	* 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:
	New reference output.
	* tests/data/test-diff-pkg/libICE-1.0.9-2.el7.x86_64.rpm: New test material.
	* tests/data/test-diff-pkg/libICE-debuginfo-1.0.6-1.el6.x86_64.rpm: New test material.
	* tests/data/test-diff-pkg/libICE-debuginfo-1.0.9-2.el7.x86_64.rpm:
	New test material.
	* tests/data/Makefile.am: Add the new test material to source distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Run this test harness
	over the new tests material above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-03-07 12:30:13 +01:00
Dodji Seketeli
ba1b9916ac Forgot to add test2-filtered-removed-fns-v{0,1}.o
I forgot to add these files as part of my previous commit

	* test2-filtered-removed-fns-v{0,1}.o: Add these test input files.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-03-07 12:29:54 +01:00
Dodji Seketeli
ddc21ed73e Bug 19596 - Suppressed removed symbol changes still considered incompatible
Libabigail considers a removed function (or global variable) as being
an incompatible change, whether it has been suppressed or not.
Likewise, even if all function sub-type changes have been suppressed,
changed virtual offset on functions are still considered incompatible.

Thus, abidiff still returns an exit code that reflects an incompatible
change even if the removed symbol change was suppressed.

The rule should rather be that if incompatible changes have been
suppressed, abidiff (and the other tools) should take that into
account and not return an exit code that reflects incompatible
changes.

This patch implements that rule, at least for the incompatible changes
that are detected so far.

	* src/abg-comparison.cc (corpus_diff::has_incompatible_changes):
	Consider the *net* number of removed function and variable
	symbols.  Also, if all function sub-type changes have been
	suppressed, then no virtual offset change should be considered
	incompatible.
	* tests/data/test-abidiff-exit/test1-voffset-change-report1.txt
	* tests/data/test-abidiff-exit/test1-voffset-change.abignore
	* tests/data/test-abidiff-exit/test2-filtered-removed-fns-report0.txt
	* tests/data/test-abidiff-exit/test2-filtered-removed-fns-report1.txt
	* tests/data/test-abidiff-exit/test2-filtered-removed-fns-v0.c
	* tests/data/test-abidiff-exit/test2-filtered-removed-fns-v1.c
	* tests/data/test-abidiff-exit/test2-filtered-removed-fns.abignore
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-abidiff-exit.cc (InOutSpec::in_suppr_path): New data
	member.
	(in_out_specs): Adjust. Add new test inputs.
	(main): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-03-04 01:02:46 +01:00
Dodji Seketeli
2bbe75a08a Fixup virtual member functions with linkage and no underlying symbol
This is from the problem report at
https://sourceware.org/bugzilla/show_bug.cgi?id=19707.

GCC 5.3.1, when invoked with -g -O2 emits some debug info where some
virtual member functions with linkage name have no reference to any
underlying symbol.  When that binary is compared to its counterpart
compiled with -g, the member function in question does have an
underlying symbol and thus the comparison of the enclosing types yield
a spurious change report like:

    method virtual void unity::scopes::ScopeBase::stop() didn't have any
    linkage name, and it now has: '_ZN5unity6scopes9ScopeBase4stopEv'

This patch introduces a pass in the DWARF reader which fixes up
virtual member function with linkage and no underlying symbol.  If
there is a symbol with a name equals to the linkage name, the virtual
member function has its underlying symbol set to that symbol.

This fixes the spurious change report.

	* src/abg-dwarf-reader.cc (die_function_decl_map_type): New
	typedef.
	(read_context::die_function_with_no_symbol_map_): New data member.
	(read_context::die_function_decl_with_no_symbol_map): New
	accessor.
	(read_context::fixup_functions_with_no_symbols): New member
	function.
	(finish_member_function_reading): Take a read_context.  Schedule
	virtual member functions with linkage and no underlying symbol to
	be fixed up after all the debug info is read.
	(build_function_decl): After a virtual member function_decl has
	been updated, if it has its underlying symbol and was scheduled
	for fixup, then de-schedule it.
	(build_class_type_and_add_to_ir, build_ir_node_from_die): Adjust
	call to finish_member_function_reading.
	(read_corpus_from_elf): Move the pure ELF (symbol and other mundane
	information) information reading ...
	(read_debug_info_into_corpus): ...  here.  Make it happen *before*
	actual reading of DWARF information.  We need symbol information
	to be present and fully set before we start reading debug info.
	This is so that we can know when a virtual member function doesn't
	need to be fixed up.  Also, perform the fixup after the debug
	information was read.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-25 16:49:39 +01:00
Dodji Seketeli
cf8eba68c3 Implement string interning for Libabigail
This patch implements string interning optimization.  One can read
about the principles of this optimization at
https://en.wikipedia.org/wiki/String_interning.

The patch introduces an abigail::interned_string type, as well as an
abigail::interned_string_pool type.  Each environment type owns a
string pool and strings are interned in that pool for all types and
decls of that environments.  The interned_string has methods to
interact seemingly with std::string including a hashing function.  Of
course hashing and comparing interned_string is faster than for
std::string.

To enable ABI artifacts to intern strings, each constructor of ABI
artifacts now takes the environment it's constructed in as parameter.
From the environment, it can thus use the interned string pool.

The patch then changes declaration names to be of type
interned_string, and performs the necessary adjustments.  The hash
maps that hash strings coming from those declaration names are
adjusted to hash interned_string.

	* include/Makefile.am: Add the new abg-interned-str.h file to
	source distribution.
	* include/abg-corpus.h (corpus::corpus): Re-arrange the order of
	* src/abg-corpus.cc
	(corpus::exported_decls_builder::priv::get_id): Return
	interned_string rather than std::string.
	(corpus::corpus): Re-arrange the order of parameters: take an
	environment as first parameter.  parameters: take an environment
	as first parameter.
	* include/abg-dwarf-reader.h (lookup_symbol_from_elf)
	(lookup_public_function_symbol_from_elf): Likewise.
	* src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab)
	(lookup_symbol_from_gnu_hash_tab)
	(lookup_symbol_from_elf_hash_tab, lookup_symbol_from_symtab)
	(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf)
	(lookup_public_variable_symbol_from_elf, lookup_symbol_from_elf)
	(lookup_public_function_symbol_from_elf): Take an environment as
	first parameter and adjust.
	(build_translation_unit_and_add_to_ir)
	(build_namespace_decl_and_add_to_ir, build_type_decl)
	(build_enum_type, finish_member_function_reading)
	(build_class_type_and_add_to_ir, build_function_type)
	(read_debug_info_into_corpus, read_corpus_from_elf): Adjust.
	* include/abg-fwd.h: Include abg-interned-str.h
	(get_type_name, get_function_type_name, get_method_type_name):
	Return a interned_string, rather than a std::string.
	* include/abg-interned-str.h: New declarations for interned strings
	and their pool.
	* include/abg-ir.h (environment::intern): Declare new method.
	(elf_symbol::{g,s}et_environment): Likewise.
	(type_or_decl_base::type_or_decl_base): Make the default
	constructor private.
	({translation, type_or_decl_base}::set_environment)
	(set_environment_for_artifact): Take a const environment*.
	(elf_symbol::elf_symbol)
	(elf_symbol::create)
	(type_or_decl_base::type_or_decl_base)
	(translation::translation, decl_base::decl_base)
	(scope_decl::scope_decl, type_base::type_base)
	(type_decl::type_decl, scope_type_decl::scope_type_decl)
	(namespace_decl::namespace_decl)
	(enum_type_decl::enumerator::enumerator)
	(function_type::function_type, method_type::method_type)
	(template_decl::template_decl, function_tdecl::function_tdecl)
	(class_tdecl::class_tdecl, class_decl::class_decl): Take an
	environment.
	(type_or_decl_base::operator=)
	(enum_type_decl::enumerator::get_environment): Declare new method.
	(decl_base::{peek_qualified_name, peek_temporary_qualified_name,
	get_qualified_name, get_name, get_qualified_parent_name,
	get_linkage_name}, qualified_type_def::get_qualified_name)
	(reference_type_def::get_qualified_name)
	(array_type_def::get_qualified_name)
	(enum_type_decl::enumerator::{get_name, get_qualified_name})
	({var,function}_decl::get_id)
	(function_decl::parameter::{get_type_name, get_name_id}): Return
	an interned_string, rather than a std::string.
	(decl_base::{set_qualified_name, set_temporary_qualified_name,
	get_qualified_name, set_linkage_name})
	(qualified_type_def::get_qualified_name)
	(reference_type_def::get_qualified_name)
	(array_type_def::get_qualified_name)
	(function_decl::parameter::get_qualified_name): Take an
	interned_string, rather than a std::string.
	(class_decl::member_{class,function}_template::member_{class,function}_template):
	Adjust.
	* src/abg-ir.cc (environment_setter::env_): Make this be a pointer
	to const environment.
	(environment_setter::visit_begin): Adjust.
	(interned_string_pool::priv): Define new type.
	(interned_string_pool::*): Define the method declared in
	abg-interned-str. h.
	(operator==, operator!=, operator+): Define operator for interned_string and
	std::string
	(operator<<): Define for interned_string.
	(translation_unit::priv::env_): Make this be a pointer to const
	environment.
	(translation_unit::priv::priv): Take a pointer to const
	environment.
	(elf_symbol::priv::env_): New data member.
	(elf_symbol::priv::priv): Adjust.  Make an overoad take an
	environment.
	(translation_unit::{g,s}et_environment): Adjust.
	(interned_string_bool_map_type): New typedef.
	(environment::priv::classes_being_compared_): Make this hastable
	of string be a hashtable of interned_string.
	(environment::priv::string_pool_): New data member.
	(environment::{get_void_type_decl,
	get_variadic_parameter_type_decl}): Adjust.
	(type_or_decl_base::priv::env_): Make this be a pointer to const
	environment.
	(type_or_decl::base::priv::priv): Adjust.
	(type_or_decl_base::set_environment)
	(set_environment_for_artifact): Take a pointer to const
	environment.
	(elf_symbol::{g,s}et_environment, environment::intern)
	(type_or_decl_base::operator=): Define new methods.
	(decl_base::priv::{name_, qualified_parent_name_,
	temporary_qualified_name_, qualified_name_, linkage_name_}): Make
	these data member be of tpe interned_string.
	(decl_base::priv::priv): Make this take an environment. Adjust.
	(decl_base::{peek_qualified_name, peek_temporary_qualified_name,
	get_linkage_name, get_qualified_parent_name, get_name,
	get_qualified_name}, get_type_name, get_function_type_name)
	(get_method_type_name, get_node_name)
	(qualified_type_def::get_qualified_name)
	(pointer_type_def::get_qualified_name)
	(array_type_def::get_qualified_name)
	(enum_type_decl::enumerator::get_qualified_name)
	(var_decl::get_id, function_decl::get_id)
	(function_decl::parameter::get_{name_id, type_name}): Return an
	interned_string.
	(decl_base::{set_qualified_name, set_temporary_qualified_name})
	(qualified_type_def::get_qualified_name)
	(pointer_type_def::get_qualified_name)
	(reference_type_def::get_qualified_name)
	(array_type_def::get_qualified_name)
	(function_decl::parameter::get_qualified_name): Take an
	interned_string.
	(decl_base::{set_name, set_linkage_name}): Intern the std::string
	passed in parameter.
	(equals): In the overload for decl_base, adjust for a little speed
	optimization that is justified by profiling.
	(pointer_type_def::priv::{internal_qualified_name_,
	temp_internal_qualified_name_}): Make these data member be
	interned_string.
	(enum_type_decl::enumerator::priv::env_): New data member.
	(enum_type_decl::enumerator::priv::{name_, qualified_name}): Make
	these data member be of type interned_string.
	(enum_type_decl::enumerator::get_environment): New method.
	(enum_type_decl::enumerator::priv::priv) Adjust.
	(typedef_decl::operator==): Implement a little speed optimization.
	(var_decl::priv::nake_type_): New data member.
	(var_decl::priv::id_): Make this data member be of type
	interned_string.
	(equals): In the overload for var_decl, function_type,
	function_decl, adjust for the use of interned_string.
	(function_decl::priv::id_): Make this be of type interned_string.
	(scope_decl::{add_member_decl, insert_member_decl})
	(lookup_function_type_in_translation_unit)
	(synthesize_type_from_translation_unit, lookup_node_in_scope)
	(lookup_type_in_scope, scope_decl::scope_decl)
	(qualified_type_def::qualified_type_def)
	(qualified_type_def::get_qualified_name)
	(pointer_type_def::pointer_type_def)
	(reference_type_def::reference_type_def)
	(array_type_def::array_type_def, array_type_def::append_subrange)
	(array_type_def::get_qualified_name)
	(enum_type_decl::enum_type_decl)
	(enum_type_decl::enumerator::get_qualified_name)
	(enum_type_decl::enumerator::set_name)
	(typedef_decl::typedef_decl, var_decl::var_decl)
	(function_type::function_type, method_type::method_type)
	(function_decl::function_decl)
	(function_decl::parameter::parameter)
	(class_decl::priv::comparison_started)
	(class_decl::add_base_specifier)
	(class_decl::base_spec::base_spec)
	(class_decl::method_decl::method_decl)
	(type_tparameter::type_tparameter)
	(non_type_tparameter::non_type_tparameter)
	(template_tparameter::template_tparameter)
	(type_composition::type_composition)
	(function_tdecl::function_tdecl, class_tdecl::class_tdecl)
	(qualified_name_setter::do_update): Adjust.
	(translation_unit::translation_unit, elf_symbol::elf_symbol)
	(elf_symbol::create, type_or_decl_base::type_or_decl_base)
	(decl_base::decl_base, type_base::type_base)
	(type_decl::type_decl, scope_type_decl::scope_type_decl)
	(namespace_decl::namespace_decl)
	(enum_type_decl::enumerator::enumerator, class_decl::class_decl)
	(template_decl::template_decl, function_tdecl::function_tdecl)
	(class_tdecl::class_tdecl): Take an environment.
	* src/abg-comparison.cc
	(function_suppression::suppresses_function): Adjust.
	* src/abg-reader.cc (read_translation_unit)
	(read_corpus_from_input, build_namespace_decl, build_elf_symbol)
	(build_function_parameter, build_function_decl, build_type_decl)
	(build_function_type, build_enum_type_decl, build_enum_type_decl)
	(build_class_decl, build_function_tdecl, build_class_tdecl)
	(read_corpus_from_native_xml): Likewise.
	* src/abg-writer.cc (id_manager::m_cur_id): Make this mutable.
	(id_manager::m_env): New data member.
	(id_manager::id_manager): Adjust.
	(id_manager::get_environment): New method.
	(id_manager::{get_id, get_id_with_prefix}): Return an
	interned_string.
	(type_ptr_map): Make this be a hash map of type_base* ->
	interned_string, rather a type_base* -> string.
	(write_context::m_env): New data member.
	(write_context::m_type_id_map): Make this data member be mutable.
	(write_context::m_emitted_type_id_map): Make this be a hash map of
	interned_string -> bool, rather than string -> bool.
	(write_context::write_context): Take an environment and adjust.
	(write_context::get_environment): New method.
	(write_context::get_id_manager): New const overload.
	(write_context::get_id_for_type): Return an interned_string; adjust.
	(write_context::{record_type_id_as_emitted,
	record_type_as_referenced}): Adjust.
	(write_context::type_id_is_emitted): Take an interned_string.
	(write_context::{type_is_emitted,
	record_decl_only_type_as_emitted}): Adjust.
	(write_translation_unit, write_corpus_to_native_xml, dump):
	Adjust.
	* tools/abisym.cc (main): Adjust.
	* tests/data/test-read-write/test22.xml: Adjust.
	* tests/data/test-read-write/test23.xml: Adjust.
	* tests/data/test-read-write/test26.xml: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-24 15:13:20 +01:00