Commit Graph

1363 Commits

Author SHA1 Message Date
Dodji Seketeli
1b94d60780 Allow pretty printing function decls for internal purposes
It appears that function_decl::get_pretty_representation doesn't make
the difference between internal and non-internal purposes.  This patch
fixes that by making the helper
get_pretty_representation_of_declarator() take an "internal" flag and
calls that.

	* include/abg-ir.h
	(function_decl::get_pretty_representation_of_declarator): Take an
	"internal" flag.
	* src/abg-ir.cc
	(function_decl::get_pretty_representation_of_declarator): Take an
	"internal" flag.
	(function_decl::get_pretty_representation): Pass the "internal"
	flag to the function
	function_decl::get_pretty_representation_of_declarator.
	(function_decl::parameter::get_type_name):  Better handle variadic
	parameter type.
	(function_decl::parameter::get_type_pretty_representation):
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-29 16:16:31 +01:00
Dodji Seketeli
484a5ad172 Make bash completion files non-executable
* bash-completion/abicompat: Make this be non-executable.
	* bash-completion/abidiff: Likewise.
	* bash-completion/abidw: Likewise.
	* bash-completion/abilint: Likewise.
	* bash-completion/abinilint: Likewise.
	* bash-completion/abipkgdiff: Likewise.
	* bash-completion/abisym: Likewise.
	* bash-completion/fedabipkgdiff: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-26 12:29:12 +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
03d5abdd24 Bump version number to 1.0.rc7
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-24 17:53:20 +01:00
Dodji Seketeli
a02d433aab Update website for 1.0.rc6
* doc/website/mainpage.txt: Update for 1.0.rc6 release

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-24 17:52:27 +01:00
Dodji Seketeli
14d48647a4 Update NEWS and ChangeLog for 1.0.rc6
* ChangeLog: Update this automatically using "make
	update-changelog".
	* NEWS: update this by editing the output of 'git shortlog
	libabigail-1.0.rc5..HEAD'.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-24 15:28:29 +01:00
Dodji Seketeli
10384b66de Avoid using size_t to get DWARF data
This can cause issues on i686 compared to x86_64 as size_t has
different size on these two platforms.  Rather, use int64_t which has
the same fixed size on both platforms.

	* src/abg-dwarf-reader.cc (die_size_in_bits, die_location_expr):
	Take uint64_t rather than size_t and adjust.
	(expr_result::const_value_): Make this be int64_t rather than
	ssize_t.
	(expr_result::expr_result): Take int64_t rather than ssize_t.
	(expr_result::const_value): Return int64_t rather than ssize_t.
	(expr_result::{operator(), operator=, operator+=}): Make these
	operators return or take int64_t.
	too.
	(op_pushes_constant_value, op_manipulates_stack)
	(op_is_arith_logic, op_is_control_flow)
	(eval_last_constant_dwarf_sub_expr, die_member_offset)
	(die_virtual_function_index): Take
	uint64_t rather than size_t, or int64_t rather than ssize_t.
	(finish_member_function_reading, build_class_type_and_add_to_ir)
	(build_union_type_and_add_to_ir): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-24 15:25:44 +01:00
Dodji Seketeli
ab9d7b3bca Fix a compiler warning issued by GCC 6.2.1
* src/abg-dwarf-reader.cc (find_import_unit_point_between_dies):
	Parameter 5 of find_import_unit_point_between_dies is not of type
	Dwarf_Off.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-24 15:25:44 +01:00
Dodji Seketeli
b970ed1dda Fix offset type mismatch
* src/abg-dwarf-reader.cc (die_member_offset): The last two
	parameters of die_unsigned_constant_attribute must be of type
	uint64_t.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-24 15:25:43 +01:00
Dodji Seketeli
889898152c Fix indentation in abg-writer.cc
* src/abg-writer.cc (write_union_decl_opening_tag): Fix
	indentation.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-24 15:25:43 +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
a44a4c1068 Better diagnostics when wget is missing
When wget is missing building the fedabipkgdiff tool is disabled.
This patch fixes diagnostics in that case.

	* configure.ac: When wget is missing then make the disabling of
	the building of the fedabipkgdiff tool show up in the
	configuration summary and emit a notice.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-23 13:15:02 +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
f9ed75b8c4 Support empty properties in INI files
The ini file parser doesn't support parsing properties with no value.
This patch adds that feature, as it turned out to be a pre-requisite
for reading Linux Kernel ABI whitelist files.

	* include/abg-ini.h (simple_property::simple_property): Add a new
	constructor for empty values.
	(simple_property::has_empty_value): Declare new member function.
	* src/abg-ini.cc (simple_property::{simple_property,
	has_empty_value}): Define new member functions.
	(read_context::read_property): Support reading a property with no
	value.
	(write_property_value, write_property): Support writting a
	property with empty value.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-10 14:09:51 +01:00
Dodji Seketeli
b96ecbc065 Rename config::property_vector into config::properties_type
This renaming makes the code looks more consistent.

	* include/abg-ini.h (config::properties_type): Rename the typedef
	config::property_vector into this.
	(config::section::{section, get_properties, set_properties}):
	Adjust.
	* src/abg-ini.cc (config::section::priv::properties_): Adjust the
	name of its type.
	(config::section::{section, get_properties, set_properties,
	find_property}): Adjust.
	(write_section): Adjust.
	* src/abg-suppression.cc (read_function_suppression): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-10 14:09:50 +01:00
Dodji Seketeli
9224f40c52 Apply harmless and harmful filters in one pass
When comparing linux kernels with lots of changes, walking changes
twice just to apply harmless and harmful change filters was dominating
the performance profile.

This patch performs the harmless and harmful filtering in one pass.
This makes the overall comparison go from 15 minutes to 10 minutes
when comparing a 4.7 kernel from fedora24 and a 4.8 kernel from
fedora26.

	* include/abg-comp-filter.h (class harmless_harmful_filter):
	Decalre new class.
	(typedef harmless_harmful_filter_sptr): Declare new typedef.
	(class harmless_filter, class harmful_filter): Remove these class
	declarations.
	(typedef harmful_filter_sptr, harmless_filter_sptr): Remove these
	typedefs.
	* src/abg-comp-filter.cc (categorize_harmless_diff_node)
	(categorize_harmful_diff_node): Define new static functions.
	({harmless, harmful}_filter::{visit, visit_end}): Remove these
	member functions.
	(harmless_harmful_filter::{visit, visit_end}): Define new member
	functions.
	* src/abg-comparison.cc (diff_context::diff_context): Register the
	new harmless_harmful_filter, and remove the premier
	harmless_filter and harmful_filter.

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

	# Please enter the commit message for your changes. Lines starting
	# with '#' will be ignored, and an empty message aborts the
	commit.  # On branch kabidiff-dedup # Changes to be committed: #
	(use "git reset HEAD <file>..." to unstage) # # modified:
	include/abg-comp-filter.h # modified: src/abg-comp-filter.cc #
	modified: src/abg-comparison.cc # # Untracked files: # (use "git
	add <file>..." to include in what will be committed) # # diff.txt
	# prtests/ # tests/data/test-read-dwarf/libtest23.so.abi.conflict

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-10 14:09:50 +01:00
Dodji Seketeli
ce6513ee72 Avoid stripping typedefs too much
strip_typedef re-constructs entire type trees and canonicalize them.
Calling it a lot on very deep and recursive trees can be costly.

Unfortunately, categorization of changes uses strip_typedef quite a
bit to determine if the two types that are different are still
compatible.  When used on changesets generating from comparing two
Linux Kernels, it makes changes categorization dominate CPU usage
profiles.

This patch avoids using strip_typedef to determine if two types are
compatible and thus speeds up type categorization of changes involving
lots of deep and recursive type trees.

	* src/abg-ir.cc (types_are_compatible)
	(is_compatible_with_class_type): Do not strip typedefs.  Just get
	their leaf types.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-10 14:09:50 +01:00
Dodji Seketeli
7ea7d7c4a9 Misc style cleanups in abg-ir.cc
* src/abg-ir.cc (equals): In overloads for function_type and
	class_decl, avoid returning a constant when we can return a
	variable like in the rest of the code.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-08 12:47:33 +01:00
Dodji Seketeli
ff0b07e711 Factorize out string representation of array_type_def::subrange_type
As we are going to need to print names of array types from DIEs
directly, we'll need to represent names of subranges.

This patch factorizes the string representation of the
array_type_def::subrange_type type.

	* src/abg-ir.cc (array_type_def::subrange_type::{as_string,
	vector_as_string}): Define methods.
	(array_type_def::get_subrange_representation): Use the new
	vector_as_string method.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-03 15:13:38 +01:00
Dodji Seketeli
c4f75fbada Factorize out parsing of integral types
Until now, integral_type has been just a "private" helper type used in
the building of a type_decl.

Now it's going to be helpful in determining the name of an integral
type, directly from DIEs -- without having to build a type_decl.

This patch factorizes out the parsing and building of an integral_type
by introducing a src/abg-ir-priv.h file that is meant to declare
interfaces that are going to be private to libabigail.so but usable by
all of its modules.

	* src/abg-ir-priv.h: New file.
	* src/Makefile.am: Add abg-ir-priv.h to the build system.
	* src/abg-ir.cc: Include the new abg-ir-priv.h header file.
	(class_integral_type): Move this type
	declaration to the new abg-ir-priv.h header.
	(integral_type::modifiers_type): Make this non-static.
	(parse_integral_type): This new overload is a factorized out of
	...
	(integral_type::integral_type): ... here.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-03 15:13:17 +01:00
Dodji Seketeli
1bc96d17e1 Misc style fixes in abg-ir.cc
* src/abg-ir.cc (get_function_type_name,
          get_pretty_representation): Misc style fixes.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-03 15:13:10 +01:00
Dodji Seketeli
0ca774c85a Consider a method_decl as always being a member decl
The is_member_decl() function considers that a decl is a member decl
only if it's at class scope.

In preparation for the support of incremental building of method
decls, a method decl, even before being added to its final class, must
always be considered as a member decl.  This allows for instance, the
proper pretty printing of the method decl even before it's added to
its class.

This patch prepares the upcoming support of incremental building of
method decls by making is_member_decl() work on a method_decl that
hasn't yet been added to a class, so that is not, strictly-speaking,
at class scope yet.

	* src/abg-ir.cc (is_member_decl): Consider a method decl as always
	being a member decl.
	(is_member_function): Use is_member_decl.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-03 15:12:56 +01:00
Dodji Seketeli
6c100a88b5 Cleanup void and variadic parameter type interfaces
While working on something else, it appeared that renaming
abigail::environment::get_void_type_decl() to
abigail::environment::get_void_type() and
abigail::environment::get_variadic_parameter_type_decl() to
abigail::environment::get_variadic_parameter_type() would be an
improvement.

This patch implements that.

	* include/abg-ir.h (environment::{get_void_type,
	get_variadic_parameter_type}): Renamed get_void_type_decl and
	get_variadic_parameter_type_decl to these.
	(environment::is_void_type): Remove the overload that takes a bare
	pointer.
	(environment::is_variadic_parameter_type): Declare new member
	function.
	* src/abg-ir.cc (environment::void_type_): Renamed the data member
	void_type_decl_ into this.
	(environment::variadic_marker_type_): Renamed the data member
	variadic_marker_type_decl_ into this.
	(environment::{get_void_type, get_variadic_parameter_type}):
	Renamed get_void_type_decl and get_variadic_parameter_type_decl to
	these.
	(environment::is_void_type): Take a smart pointer now.
	(environment::is_variadic_parameter_type): Define new member
	function.
	(synthesize_function_type_from_translation_unit): Adjust.
	(function_decl::parameter::get_pretty_representation): Likewise.
	* src/abg-comparison.cc (is_diff_of_variadic_parameter_type):
	Adjust.
	* src/abg-dwarf-reader.cc (build_function_type)
	(build_ir_node_for_void_type): Likewise.
	* src/abg-reader.cc (build_function_parameter)
	(build_function_decl, build_function_type): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-03 15:12:46 +01:00
Dodji Seketeli
c86ffddab7 Cleanup some entry points in abg-fwd.h
While looking at something else I came accross some interface cleanup
opportunities, as usual.  This patch honours some of those
opportunities.

	* include/abg-fwd.h (add_decl_to_scope): Pass the scope smart
	pointer by reference.
	(is_member_type): pass the type smart pointer by reference.
	(is_function_decl, is_pointer_type, is_reference_type)
	(is_qualified_type, is_function_type, is_method_type)
	(is_array_type): Take a type_or_decl base pointer, rather than
	either a decl_base or type_base pointer.
	* include/abg-ir.h (translation_unit::set_corpus): Take a pointer
	to non-const corpus.
	(translation_unit::get_corpus): Add a non-const overload.
	(type_or_decl_base::get_corpus): Likewise.
	(type_or_decl_base::set_translation_unit): Take a pointer to
	non-corpus translation_unit.
	(type_or_decl_base::get_translation_unit): Add a non-const
	overload.
	(scope_decl::{add_member_decl, insert_member_decl}): Pass the
	member smart pointer by reference.
	(scope_decl::remove_member_decl): Take a non-const smart pointer.
	(class_decl::add_member_decl): Pass the decl smart pointer by
	reference.
	(is_method_decl): Take pointer or reference to type_or_decl_base
	rather than function_decl.
	* src/abg-ir.cc (translation_unit::priv::corpus): Make this a
	pointer to non-const corpus.
	(translation_unit::set_corpus): Take a pointer to non-const
	corpus.
	(translation_unit::get_corpus): Add a non-const overload.
	(translation_unit::get_global_scope): Adjust.
	(translation_unit::bind_function_type_life_time): Adjust.
	(type_or_decl_base::translation_unit): Make this a pointer to
	non-const translation_unit.
	(type_or_decl_base::get_corpus): Likewise.
	(type_or_decl_base::set_translation_unit): Take a pointer to
	non-corpus translation_unit.
	(type_or_decl_base::get_translation_unit): Add a non-const
	overload.
	(is_member_type): pass the type smart pointer by reference.
	(scope_decl::{add_member_decl, insert_member_decl}): Take a
	reference to the member decl smart pointer.  Adjust.
	(class_decl::add_member_decl): Likewise.
	(scope_decl::remove_member_decl): Take a non-const smart pointer.
	(add_decl_to_scope): Pass the scope smart pointer by reference.
	(is_decl, is_function_decl, is_pointer_type, is_reference_type)
	(is_qualified_type, is_function_type, is_method_type)
	(is_method_decl, is_array_type): Take a type_or_decl base pointer,
	rather than either a decl_base or type_base pointer.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-03 15:12:29 +01:00
Dodji Seketeli
672491e874 Fix abigail::ir::get_type_scope()
It appears that abigail::ir::get_type_scope() was always returning nil
due to a thinko. Oops.  This pach fixes that.

	* src/abg-ir.cc (get_type_scope): Do not always return nil.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-03 15:12:20 +01:00
Dodji Seketeli
ae1cade4ab Bug 20740 Broken check for dwarf_getalt in configure.ac
There is a missing space around the "=" operator in the conditional
expression of the test below:

  if test x$FOUND_DWARF_GETALT_IN_LIBDW=xyes; then
     AC_DEFINE([LIBDW_HAS_DWARF_GETALT], 1,
               [Defined if libdw has the function dwarf_getalt])
  fi

This patch fixes that.  Oops.

	* configure.ac: Add missing spaces around the "=" of a conditional
	expression.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-10-27 16:05:35 +02:00
Dodji Seketeli
7458409169 Canonicalize function types when reading from DWARF
Up until now, only function types pointed to by a pointer to function
was canonicalized.  This patch also canonicalizes function types that
are used as types for function declarations.

	* src/abg-dwarf-reader.cc (build_function_decl): Canonicalize
	function types.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-10-11 15:12:42 +02:00
Dodji Seketeli
0f3af2b3bc Misc cleanups here and there
While looking at something else, the usual cleanup spree came up.

	* src/abg-dwarf-reader.cc (canonicalize_types_scheduled): Fix
	identation.
	* src/abg-reader.cc (build_class_decl): Use class_decl_sptr rather
	than shared_ptr<class_decl>.
	* src/abg-writer.cc (write_class_is_declaration_only)
	(write_is_struct, write_decl, write_decl_in_scope)
	(write_type_decl, write_qualified_type_def)
	(write_pointer_type_def, write_reference_type_def)
	(write_array_type_def, write_enum_type_decl, write_typedef_decl)
	(write_elf_symbol, write_var_decl, write_function_decl)
	(write_member_type_opening_tag, write_member_type)
	(write_class_decl_opening_tag, write_class_decl): Cleanup
	parameters to use the right typedef, rather than the long
	shared_ptr<*> form.  Pass the shared pointers by reference as
	well.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-10-11 15:12:31 +02:00
Dodji Seketeli
31cd5d77b8 Cleanup namespace importing in abg-interned-str.h
* include/abg-interned-str.h: Inject std::tr1::shared_ptr,
	std::string and std::ostream inside the abigail namespace.
	(interned_string::{interned_string, raw, operator==, operator!=,
	operator<): Adjust.
	(operator==, operator!=, operator<<, operator+): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-10-10 12:57:47 +02:00
Dodji Seketeli
f0f5233903 Cleanup functions to detect infinite comparison of class_decl
While looking around, I found some things in need of a cleanup.  This
patch addresses those.

	* src/abg-ir.cc (class_decl::priv::unmark_as_being_compared): In
	the overload that takes a pointer to class_decl, re-use the
	overload that takes a reference.
	(class_decl::priv::comparison_started): Do not crash if the klass
	pointer is nil.
	(equals): In the overload for class_decl&, undef the RESULT macro
	when it's not used anymore.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-10-10 12:57:25 +02:00
Dodji Seketeli
8bb9d3aedc Cleanup class_decl inifite comparison detection
We recently used a new type interned_string_set_type to detect
infinite comparison of function_type type.  This patch uses the same
type for class_decl infinite comparison detection.

	* src/abg-ir.cc (environment::priv::classes_being_compared_): Make
	this use the new interned_string_set_type type.
	(class_decl::priv::{mark_as_being_compared, comparison_started}):
	Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-10-10 12:57:12 +02:00
Dodji Seketeli
e083531584 Apply ODR-based type comparison optimization to function types
Inside a given ABI corpus, during type canonicalization, function
types are compared structurally (member-wise).  Note that on the other
hand, class, enums and basic types are compared using an ODR-based
optimization: only their type names are compared.

This makes function types comparison be *super slow* for ABI corpora
with a lot of function types.

This patch fixes that by enabling the ODR-based comparison
optimization for function types too, during type canonicalization.

	* src/abg-ir.cc (type_eligible_for_odr_based_comparison):
	Factorize this out of type_base::get_canonical_type_for.  Also,
	add function types to the set of types to use the ODR-based
	comparison optimization on.
	(type_base::get_canonical_type_for): Use the new
	type_eligible_for_odr_based_comparison function.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-10-10 12:56:02 +02:00
Dodji Seketeli
4324b82e99 Prevent infinite loops while comparing two function_type
While comparing two function types a given sub-type can itself have a
sub-type that *is* the same function_type as the one we are looking
at.  In that case, an infinite loop appears.

This patch detects those cases, similarly to what we do for class_decl
and avoids the eventual infinite loop.

	* include/abg-ir.h (class environment): Make class function_type
	be a friend of this class.
	(class function_type): Make the equality function for
	function_types be a friend of this class.
	* src/abg-ir.cc (environment::priv::fn_types_being_compared_): New
	data member.
	(function_type::priv::{mark_as_being_compared,
	unmark_as_being_compared, comparison_started}): Define new member
	functions.
	(equals): In the overload for function_types, if any of the the
	function_type being compared is already being compared, return
	early saying that the two function_types are equal.  This avoids

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-10-10 12:55:22 +02:00
Dodji Seketeli
607dbff271 Define a new interned_string_set_type typedef
In order to prepare other changes to come, this patch declares an
unordered set of abigail::interned_string.

	* include/abg-interned-str.h (interned_string_set_type): Define a new
	typedef for unordered_set<interned_string>.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-10-10 12:55:02 +02: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
Matthias Klose
91a81e40a2 Fix typo in abipkgdiff
* tools/abipkgdiff.cc (extract_deb): Fix typo.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-09-21 19:08:23 +02:00
Dodji Seketeli
ce293c2d43 Better handle fedabipkgdiff dependencies detection
Even when the configure script is executed without the
--enable-fedabipkgdiff switch, if one of the dependencies of
fedabipkgdiff is missing (e.g, python), it fails with a fatal error.

It should rather just disable fedabipkgdiff in that case.

This patch fixes this behaviour.  It makes it so that it's only when
the --enable-fedabipkgdiff switch provided that a missing dependency
results in a fatal hard error.

	* configure.ac: It's only when --enable-fedabipkgdiff is provided
	that a missing dependency of the fedabipkgdiff program results in
	a fatal error.  Otherwise, building fedabipkgdiff is just
	disabled.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-09-21 19:08:22 +02:00
Dodji Seketeli
6c6a8341dd Add default suppression specifications for C++ binaries
For C++ libraries that are not libstdc++ or boost, this patch defines
default suppression specifications that drop function or variables that
we know are from namespaces that are not meant to be part of the API.
By doing so, we also decrease the memory needed to process the
binaries.

	* default.abignore: Add suppressions for non-libstdc++ and
	non-boost C++ libraries.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-09-21 18:35:08 +02:00
Dodji Seketeli
67ca48da29 Add default suppression specification for webkitgtk
This patch adds default suppression specifications for webkitgtk and
webkit2gtk so that unnecessary ABI artifacts are dropped from the
in-memory IR.  This dramatically helps to lower the memory usage of
libabigail while analyzing the webkit2gtk libraries.

	* default.abignore: New suppression specifications for webkitgtk.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-09-21 18:35:08 +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
24b418795e Pimplify the abigail::ir::scope_decl type
The abigail::ir::scope_decl still has its data member members be
visible from its header file.  This patch hides those data member
using the pimpl idiom, just as what is done other types throughout the
project.

	* include/abg-ir.h (scope_decl::{priv, priv_sptr}) Declare new types.
	(scope_decl::priv_): New pimpl data member.
	(scope_decl::{member_, member_scopes}): Move this as data member
	of the new scope_decl::priv type in the abg-ir.cc file.
	(scope_decl::{scope_decl, get_member_decls, get_member_scopes,
	is_empty}): Make these inline member functions be out-of-line.
	* src/abg-ir.cc (struct scope_decl::priv): Define new type.
	(scope_decl::{scope_decl, get_member_decls, get_member_scopes,
	is_empty}): Define these new member functions here.  They were
	inline in the include/abg-ir.h header files before.
	(scope_decl::{add_member_decl, insert_member_decl,
	remove_member_decl}): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-09-21 18:35:07 +02:00
Dodji Seketeli
e73c0ed0fb Add new helper functions
In preparation of dropping ABI artifacts from the IR, add new generic
helper functions.

	* include/abg-fwd.h (get_location, build_qualified_name): Declare
	new functions.
	* include/abg-ir.h (is_method_decl): Declare two new overloads of
	this function.
	* src/abg-ir.cc (get_location, build_qualified_name)
	(is_method_decl): Define these functions declared above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-09-21 18:35:07 +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
a97547f905 Fix misleading indentation issues
This patch fixes misleading indentation mistakes reported by GCC 6.1.1

	* tools/abipkgdiff.cc (compare): Likewise.
	* tools/abisym.cc (main): Fix misleading indentation.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-09-21 12:06:51 +02:00
Dodji Seketeli
3227d2156a Bug 20534 - abipkgdiff wrongly displays the name of added binary files
abipkgdiff displays an address instead of displaying the name of the
added binary file.  This patch, which is from a diff that Sinny Kumari
attached to the bugzilla entry, fixes the issue.

	* tools/abipkgdiff.cc (compare): Show the name of the added
	binary, rather than its address.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-08-30 09:44:28 +02:00
Dodji Seketeli
237734dd94 Bug 20420 - Wrong ODR-based type comparison optimization on qualified type
During type canonicalizing, qualified types are being compared using
the ODR-based optimization.  This is wrong because, for instance, it's
not because two types from the same ABI corpus are both const
anonymous structs that they are meant to be equivalent.

This patch fixes the issue by applying the ODR-based comparison
optimization only to built-in types and non-anonymous struct and
enums.

The reproducer is a glibc package that takes a while to compare so
it's not suitable for inclusion in the test suite.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-08-24 10:37:08 +02:00
Dodji Seketeli
09154361a4 Don't walk diff trees indefinitely when applying suppressions
When applying suppressions to diff graphs, if the same diff node
appears twice in the graph in a way that creates a cycle, we can get
trapped in the cycle when walking the graph.  That results in a an
infinite loop.  Note that the infinite loop appears in the
diff::traverse member function, in the for-loop that walks the
children nodes of a given node.

This patch avoids walking the same node twice when applying
suppressions.

The test binaries that exhibit the issue come from the two following
packages:

rh-mariadb101-mariadb-10.1.14-2.el6 and	rh-mariadb101-mariadb-10.1.16-1.el6.

The sub-packages compared are
rh-mariadb101-mariadb-server-10.1.14-2.el6.x86_64.rpm and
rh-mariadb101-mariadb-server-10.1.16-1.el6.x86_64.rpm.

The debug info packages are
rh-mariadb101-mariadb-debuginfo-10.1.16-1.el6.x86_64.rpm and
rh-mariadb101-mariadb-debuginfo-10.1.14-2.el6.x86_64.rpm.

Once the packages are properly extracted the command line that
exhibits the infinite loop is:

    abidiff --d1 rh-mariadb101-mariadb-10.1.14-2.el6.x86_64/usr/lib/debug --d2 rh-mariadb101-mariadb-10.1.16-1.el6.x86_64/usr/lib/debug rh-mariadb101-mariadb-10.1.14-2.el6.x86_64/opt/rh/rh-mariadb101/root/usr/lib64/mysql/plugin/ha_connect.so rh-mariadb101-mariadb-10.1.16-1.el6.x86_64/opt/rh/rh-mariadb101/root/usr/lib64/mysql/plugin/ha_connect.so

This patch has no test because of the cheer size of these packages;
the debug info packages alone take more than 100MB :-( I really hope
we set up a separate repository with big test packages to overcome
this.  Maybe something using fedabipkgdiff ...

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-08-23 12:38:36 +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