Commit Graph

1200 Commits

Author SHA1 Message Date
Dodji Seketeli
dbf6c14f46 Update ChangeLog before 1.0.rc3
* ChangeLog: Update for 1.0.rc3

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-03-08 08:47:32 +01:00
Dodji Seketeli
9afc906822 Update NEWS file for 1.0.rc3
* NEWS: update for 1.0.rc3

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-03-08 08:42:37 +01:00
Dodji Seketeli
ff91eea8cf Walk function_type_diff tree in a deterministic way
Some children nodes of function_type_diff are traversed in a
non-deterministic order depending on the ordering of elements in an
unordered_map.  This can lead to spurious reporting differences
between e.g the x86_64 an i686 platforms.

This patch sorts the parameter diff children nodes of
function_type_diff using the parameter index.

	* src/abg-comparison.cc
	(function_type_diff::priv::{sorted_subtype_changed_parms_,
	sorted_changed_parms_by_id_}): Add two data members.
	(function_type_diff::ensure_lookup_tables_populated): Sort the
	changed parameters here ...
	(function_type_diff::report): ... not here.
	(function_type_diff::chain_into_hierarchy): Chain the *sorted*
	changed parameters.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-03-07 16:43:19 +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
d78ad0e349 Add --verbose to abidw
* doc/manuals/abidw.rst: Update the manual for the new --verbose
	option.
	* tools/abidw.cc (options::do_log): New data member.
	(options::options): Initialize it.
	(display_usage): New string for --verbose.
	(parse_command_line): Parse the --verbose option.
	(main): Set the the logging option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-25 16:49:38 +01:00
Dodji Seketeli
c0bc52bab8 Update copyright information
* tools/abidiff.cc: Update copyright info for 2016.
	* tools/abidw.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-25 16:49:38 +01:00
Dodji Seketeli
12d56c861b Make libabigail link with pthread
Since libabigail now uses pthreads via the abigail::workers namespace,
the libabigail shared library should link with pthreads.  Many to
Michi Henning for raising this.

	* src/Makefile.am: Add -pthread to libabigail_la_LDFLAGS.
	* tools/Makefile.am: Do not use abinilint_LDFLAGS when it should
	be abinilint_LDADD.  This one was fixed by Michi Henning.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-24 23:07:28 +01:00
Dodji Seketeli
f48c0ef201 Update mentions to the build dependencies in the doc
There are holes in the list of dependencies mentioned in the
document.  This patch plugs some of them.

Many thanks to Michi Henning for raising this.

	* COMPILING: Mention elfutils, libtool, autoconf, automake and
	libtool.
	* doc/website/mainpage.txt: Mention automake and libtool.  Fix a typo.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-24 21:53:03 +01:00
Dodji Seketeli
0a5fe64a5c Bug 19706 - Core dump from abidiff with suppression
I forgot that functions that have no elf symbol can still make it to
the internal diff representation, so we always need to take that into
account.

	* src/abg-comparison.cc
	(function_suppression::suppresses_function): Make sure a function
	has a symbol before (de)referencing it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-24 17:40:43 +01:00
Dodji Seketeli
cf233e4fc2 Some small speed optimizations
* include/abg-ir.h (var_decl::get_naked_type): Declare new member function.
	* src/abg-ir.cc (var_decl::get_naked_type): Define it.
	(equals): For the var_decl overload, avoid copying symbol
	smart pointers.  Likewise for variable type smart pointers.
	(hash_type_or_decl): Avoid accessing canonical type smart pointer.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-24 15:13:20 +01:00
Dodji Seketeli
a6aa328731 Mist style cleanups
Various style cleanups and comment additions here and there.

	* include/abg-ir.h: Add missing comments.  Space cleanups.  Use
	shorter typedefs rather than long template instantiation names.
	Use string rather than the longer std::string.
	* src/abg-ir.cc: Space cleanups. Add missing comments.  User
	shorter typedefs.
	* src/abg-reader.cc: Likewise.
	* src/abg-writer.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-24 15:13:20 +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
Dodji Seketeli
445923157d Update copyright notice
* include/abg-corpus.h: Update copyright notice.
	* include/abg-dwarf-reader.h: Likewise.
	* src/abg-comparison.cc: Likewise.
	* src/abg-corpus.cc: Likewise.
	* src/abg-ir.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-24 15:10:00 +01:00
Dodji Seketeli
daf673341e Fix crash when handling templates with empty patterns
* src/abg-ir.cc (function_tdecl::traverse): Do not crash when
	traversing a template with empty pattern.
	(class_tdecl::operator==): Do not crash when comparing templates
	with empty patterns.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-23 14:16:59 +01:00
Dodji Seketeli
6668baaff4 Add missing inequality operators for ABI artifacts
Some ABI artifact declared in the internal representation don't have
inequality operator (!=) declared.  I thought relying on the !=
operator provided by std::rel_ops would be enough, but it's not.
Sometimes, especially for smart pointers to ABI artifacts we do not
want the != operator of shared_ptr to be picked by argument dependent
lookup.  Rather, we want the deep operator!= to be picked up.  In certain
cases, this was causing subtle spurious change comparison reports.

This patch thus systematically declares (and defines) operator!=
whenever operator== is declared.

	* include/abg-ir.h ({translation_unit, elf_symbol::version,
	context_rel, decl_base, type_base, type_decl,
	array_type_def::subrange_type, enum_type_def::enumerator,
	dm_context_rel, template_parameter}::operator!=): Declare.
	(operator==): Make the overload form translation_unit_sptr,
	scope_decl_sptr, class_decl::base_spec_sptr,
	class_decl::member_function_template_sptr,
	class_decl::member_class_template_sptr take const references.
	(operator!=): Declare an an overload for the non-member operator
	!= of translation_unit_sptr, elf_symbol_sptr,
	type_or_decl_base_sptr, type_base_sptr, scope_decl_sptr,
	type_decl, qualified_type_def_sptr, pointer_type_def_sptr,
	reference_type_def_sptr, enum_type_decl_sptr, class_decl_sptr,
	class_decl::base_spec_sptr,
	class_decl::member_function_template_sptr,
	class_decl::member_class_template_sptr.
	* src/abg-ir.cc ({translation_unit, elf_symbol::version,
	context_rel, decl_base, type_base, type_decl,
	array_type_def::subrange_type, enum_type_def::enumerator,
	dm_context_rel, template_parameter}::operator!=): Define.
	(operator==): Make the overload for translation_unit_sptr,
	scope_decl_sptr, class_decl::base_spec_sptr,
	class_decl::member_function_template_sptr,
	class_decl::member_class_template_sptr take const references.
	(operator!=): Define an an overload for the non-member operator !=
	of translation_unit_sptr, elf_symbol_sptr, type_or_decl_base_sptr,
	type_base_sptr, scope_decl_sptr, type_decl,
	qualified_type_def_sptr, pointer_type_def_sptr,
	reference_type_def_sptr, enum_type_decl_sptr, class_decl_sptr,
	class_decl::base_spec_sptr,
	class_decl::member_function_template_sptr,
	class_decl::member_class_template_sptr.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-23 14:00:07 +01:00
Dodji Seketeli
9d5b898f28 Make the tree pass distcheck again.
I forgot to add a test reference output file to the source
distribution and this breaks "make distcheck".

Fixed thus.

	* tests/data/Makefile.am: Add file
	test-diff-suppr/test28-add-aliased-function-report-0.txt to source
	distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-20 13:01:26 +01:00
Dodji Seketeli
e62901963f Bug 19658 - Type canonicalization slow for the 2nd binary loaded
When loading two binaries (e.g, when the library is used by abidiff),
and when the second one does have deep types (e.g, classes with
recursively deep hierarchies) with lots of duplicated types in lots of
translation units, canonicalizing the types of the second binaries can
take a *lot* of time, given the quadratic nature of the structural
type comparisons that take place and the cheer number of those type
comparisons (because of the duplication).

There is already an optimization based on the One Definition Rule in
the canonicalization code.  That optimization avoids structural
comparison of types of the same corpus which have the same name.  But
then, this optimization only works on types of the first corpus.

As soon as we are loading a second corpus, all types being
canonicalized are coming from a corpus that is different from the
first corpus, by definition.  So a structural comparison is taking
place for *all* those types.

The patch extends the existing optimization to make it work on the
second corpus being loaded.  Once a type from the second corpus is
canonicalized, the canonical type is cached inside the corpus.  Then,
later, when a type with the same name has to be canonicalized, the
system looks inside the cache of that corpus to see if there is a
canonicalized type the same name.

I tested the patch on this command:

    abipkgdiff --d1 nss-debuginfo-3.19.1-8.el6_7.i686.rpm \
               --d2 nss-debuginfo-3.21.0-0.1.el6_7.i686.rpm \
               nss-3.19.1-8.el6_7.i686.rpm \
               nss-3.21.0-0.1.el6_7.i686.rpm

I whitnessed a x10 speedup, at least.

On binaries that don't have a lot of duplicated deep types, the patch
doesn't have any noticeable effect.  At lesat It doesn't slow things
down in that case.

	* include/abg-corpus.h (corpus::{record_canonical_type,
	lookup_canonical_type}): Declare new member functions.
	* src/abg-corpus.cc (corpus::priv::canonical_types_): New data
	member.
	(corpus::{record_canonical_type, lookup_canonical_type}): Define
	new member functions.
	* src/abg-ir.cc (type_base::get_canonical_type_for): Cache the
	canonical type inside the corpus of the type being canonicalized.
	Then later when canonicalizing another type, lookup in the cache
	inside its corpus to see if there is a type with the same name.
	* 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.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-18 16:06:13 +01:00
Dodji Seketeli
9cef1838c9 Add --verbose option to abidiff
This is useful to see the progress of e.g type canonicalization and
visually spot where it takes times on some big binaries.

To do this, this patch enables logging in libabigail itself too.

	* doc/manuals/abidiff.rst: Add documentation for new --verbose
	option.
	* include/abg-dwarf-reader.h (set_do_log): Declare new function.
	* src/abg-dwarf-reader.cc (read_context::do_log_): New data
	member.
	(read_context::read_context): Initialize the new data member.
	(read_context::do_log): Define accessors.
	(set_do_log): Define new function;
	(read_context::canonicalize_types_scheduled)
	(read_debug_info_into_corpus): Add logs.
	* tools/abidiff.cc (options::do_log): New data member.
	(options::options): Initialize it.
	(display_usage): Add an usage string for --verbose.
	(parse_command_line): Parse the new --verbose option.
	(main): Set the dwarf reader's context wrt presence of the
	--verbose option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-18 16:06:13 +01:00
Dodji Seketeli
ec9a667f39 Fix indentation
* tools/abipkgdiff.cc (parse_command_line): Fix a wrong indentation.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-18 16:06:13 +01:00
Dodji Seketeli
1bb3461d1d Bug 19638 - DWARF reader fails to link clone function to its declaration
There are three mains issues that cause the reported problem.  Let's
look at them closely.

Suppose there is a DIE of a member function Klass::clone_of_foo, which
is a clone of the DIE of the function Klass_foo, which is the concrete
instance of the DIE of the declaration of Klass::foo.

When libabigail's DWARF reader sees the DIE for Klass::clone_of_foo,
it fails to get the context of the declaration of Klass::clone_of_foo
-- which is Klass::foo.

So, in the model built by libabigail, the symbol of
Klass::clone_of_foo never gets associated to Klass::foo.  It thus
looks like Klass::clone is never defined.  It also looks like that
symbol is unreferenced.  From there, a number of bad things happen.
This is the first root cause of the reported problem.  I call it issue
1/.

2/ While looking at this, I noticed that libabigail uses the
underlying symbol name of a given function as the linkage name of that
function, rather than using the value of the DW_AT_linkage_name DWARF
property.  This usually works, until the the function has a symbol
which has several aliases.  In that case, depending on the symbol
alias that is used, a given function can have different linkage names.
This causes problems later at comparison time.  This is issue 2/.

3/ I also noticed that in the libabigail model, even if type Klass
does have all its member functions (including Klass::foo) defined in
in a particular translation unit TU1 , the same Klass in another
translation unit TU2 might not have that Klass::foo defined, just
because that function is not used in TU2.  So after type
canonicalization, if the version of Klass that is kept is the one from
TU2, we end up with a type Klass *NOT* having Klass::foo defined.
Sometimes, it's just that one member function in the canonical type
doesn't have any underlying symbol, whereas the same member function
in another type of the same class of equivalence as the canonical type
does have that an underlying symbol.  This is issue 3/.

To address issue 1/ the patch fixes build_ir_node_from_die, in the
case where a DW_TAG_subprogram DIE is being handled.  It fixes the
case of finding the root interface of the clone of a function
definition.  The patch also fixes a bug in build_function_decl that
prevents it to update the linkage name of a function, *if* that
function already had one.  This was preventing build_function_decl to
adjust the linkage name of a function which is a clone of an original
function which already had a non-empty linkage name.

To address 2/ the patch makes function_decl::get_id return the linkage
name of the function, *if* it exists (rather than primarily returning
the ID of the underlying symbol).

To address 3/ the patch implements the copying of member functions or
underlying function symbols missing from the canonical type -- but
otherwise present in the type that has just been canonicalized.

	* include/abg-ir.h (decl_base::set_linkage_name): Make this member
	function virtual.
	(class_decl::string_mem_fn_ptr_map_type): Define new member type.
	(class_decl::find_member_function): Declare new member function.
	(copy_member_function): Declare new function.  Declare it as
	friend of class_decl.
	(method_decl::set_linkage_name): Declare an overload for this
	virtual function.
	* src/abg-dwarf-reader.cc (build_function_decl): Allow updating of
	linkage_name even if the linkage_name was already defined.
	(build_ir_node_from_die): In the case DW_TAG_subprogram, make the
	lookup of scope of the DIE work even if it has both an abstract
	origin and a specification (DW_AT_abstract_origin and
	DW_AT_specification).
	* src/abg-ir.cc (maybe_adjust_canonical_type): Define new
	function.
	(canonicalize): Use it.
	(function_decl::get_id): Return the linkage name first, if it
	exist.
	(class_decl::priv::mem_fns_map_): New data member.
	(class_decl::find_member_function): Define new member function.
	(class_decl::method_decl::set_linkage_name): Likewise.
	(class_decl::add_member_function): Update the new data member
	class_decl::priv::mem_fns_map_.
	(copy_member_function): Define new static function.
	* tests/data/test-abidiff/test-PR18791-report0.txt: Adjust.
	* 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/test16-pr18904.so.abi: Adjust.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Adjust.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Adjust.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Adjust.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Adjust.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-17 16:30:01 +01:00
Dodji Seketeli
f8761a48af Add function lookup by linkage name to libabigail::corpus
Until now, it was not possible to lookup a function declaration from a
corpus, using a symbol name for the function.  This patch adds that
functionnality, which is useful, at least for debugging purposes.

	* include/abg-corpus.h (corpus::lookup_functions): Declare new
	member function.
	* src/abg-corpus.cc (class corpus::exported_decls_builder::priv):
	Make class corpus be a friend of this type.
	(corpus::exported_decls_builder::priv::add_fn_to_id_fns_map): Fix
	a thinko that was preventing the fn_id -> functions map from ever
	being filled.  Fix this function to make it associate each aliases
	of a given function to the function, in the hash table.
	(corpus::lookup_functions): Define new member function.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-17 14:20:43 +01:00
Dodji Seketeli
421aa4ab5f Fix style cleanups
* include/abg-ir.h (method_type::{method_type, set_class_type,
	get_type, set_type}): Use type_base_sptr and class_decl_sptr
	instead of the full non-typedefed name.
	(method_type):Do some cleanups in the definition of the
	convenience typedefs.
	* src/abg-ir.cc (method_type::{method_type, set_class_type,
	get_type, set_type}): Use type_base_sptr and class_decl_sptr
	instead of the full non-typedefed name.
	* src/abg-writer.cc (write_class_decl): Add a comment.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-17 13:08:24 +01:00
Dodji Seketeli
1eecd89ee1 Bug 19619 - failing to suppress added aliased function reports for C++
Libabigail is designed to avoid suppressing a change report about an
added (or removed) function if that function has aliases.  For the
change report to be suppressed, the condition of the suppression
specification must match all the aliases of the symbol of the
function.  This is to avoid suppressing change reports about aliases
by error.

If the binary results from a C program, the name of the function is
the same as the name of its underlying symbol.  So if the condition of
the suppression specification is the property "name_regexp", the value
of the condition can be made to match the names of all the aliases of
the underlying symbol of the function.  In that case, if value of the
property name_regexp does *NOT* match all the aliases, then it's OK
for the "change report suppression sub-system" to avoid suppressing
the change report.

But if the binary results from a C++ program, the name of the function
is *different* from the name of its underlying symbol.  If the
condition of the suppression specification is the property
"name_regexp", there is *NO* way for the user to provide a value which
matches *ANY* of the names of the underlying function symbols while
also matching the name of the function.  So in this case, the "change
report suppression sub-system" should assume that the user wants to
suppress the change reports about all the aliases of the function.

In this problem report, the issue is that in the case of a C++ program
for which the user provided the "name_regexp" property, Libabigail is
expecting the "name_regexp" to match all the aliased symbol
names. Which is not possible.  So the suppression specification is not
suppressing the change report about the added function, just because
the function has an alias.

This patch fixes the issue by taking into account the difference
between languages where the name of the function is the same as the
name of their underlying symbol and languages where it is not.

	* src/abg-comparison.cc
	(function_suppression::suppresses_function): Make the evaluation
	of the "name" and "name_regexp" consider the cases of languages in
	which the function name is the same as the symbol name and the
	case of languages in which it is not.  In the former case, all
	symbol alias names must be matched.  In the latter case, if "name"
	and "name_regexp" match the function name, the suppression
	specification is considered to match the report about the function
	change.  Also, use the elf_symbol::is_main_symbol() predicate to
	test for the symbol being a main symbol, rather than using
	error-prone pointer equality.
	* tests/data/test-diff-suppr/test27-add-aliased-function-0.suppr:
	New test input.
	* tests/data/test-diff-suppr/test27-add-aliased-function-1.suppr: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-2.suppr: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-3.suppr: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-4.suppr: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-report-4.txt: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-report-5.txt: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-v0.cc: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-v0.o: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-v1.cc: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-v1.o: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-0.suppr: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-1.suppr: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-2.suppr: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-3.suppr: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-4.suppr: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-5.suppr: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-report-4.txt: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-report-5.txt: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-report-6.txt: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-v0.c: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-v0.o: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-v1.c: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-v1.o: Likewise.
	* tests/data/Makefile.am: Add the new test material above to the
	source distribution.
	* tests/test-diff-suppr.cc: Add the new test inputs above to this
	test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-13 08:47:41 +01:00
Dodji Seketeli
c2d32394b9 Emit more informational messages on unrecognized options
This is like what was done for abififf, but for abicompat, abidw,
abipkgdiff and abilint.

	* tools/abicompat.cc (options::prog_name): New data member.
	(display_help, perform_compat_check_in_normal_mode)
	(perform_compat_check_in_weak_mode, main): Prefix error messages
	with the name of the program.
	* tools/abidw.cc (options::wrong_option): New data member.
	(display_help): Prefix error messages with the name of the
	program.n
	(parse_command_line): Record the name of the unrecognized option.
	(main): Tell the name of the unrecognized option.  Prefix error
	messages with the name of the program.
	* tools/abilint.cc (optionqs::wrong_option): New data member
	(display_usage): Prefix error messages with the name of the
	program.
	(parse_command_line): Record the name of the unrecognized option.
	(main): Tell the name of the unrecognized option.  Prefix error
	messages with the name of the program.
	* tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New
	data members.
	(package::erase_extraction_directory, display_usage, extract_rpm)
	(extract_deb, extract_tar)
	(erase_created_temporary_directories_parent, extract_package)
	(compare, create_maps_of_package_content): Prefix error messages
	with the name of the program.
	(maybe_check_suppression_files): Adjust.
	(parse_command_line): Record the name of the unrecognized option,
	and the name of option which lacks an operand.
	(main): Give the name of the unrecognized option.  Prefix error
	messages with the name of the program.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 12:37:04 +01:00
Dodji Seketeli
b0335a42d5 Prefix abidiff error message with the 'abidiff' program name
* include/abg-tools-utils.h (emit_prefix): Declare new function.
	(check_file): Add a new parameter with a default value, so that
	existing code keeps compiling.
	* src/abg-tools-utils.cc (emit_prefix): Define new function.
	(check_file): Use the emit_prefix function and give it the program
	name passed as a new parameter.
	* tools/abidiff.cc (display_usage, main): Use the new emit_prefix
	to prefix error messages.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 10:12:38 +01:00
Dodji Seketeli
5c07fdcc2e Bug 19606 - Need better error message for invalid options
This patch instructs abidiff to mentions the wrong option when it
encounters an unknown option.

It also instructs it to mention the option when reporting about
a missing option argument.

	* tools/abidiff.cc (options::wrong_option): New data member.
	(parse_command_line): Record the name of the unknown option and of
	the option which value is missing.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-11 16:07:34 +01:00
Dodji Seketeli
5a80db04f4 Add a comment about libabigail needing elfutils 0.159 at least.
* configure.ac: Add a comment saying that we require at least
	elfutils 0.159.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-11 12:37:03 +01:00
Dodji Seketeli
0cb928083d Talk about mandatory properties in suppress_* directives
The documentation doesn't talk about the mandatory properties in the
suppress_type, suppress_function and suppress_variable sections.

Fixed thus.

	* doc/manuals/libabigail-concepts.rst: Talk about the mandatory
	properties for suppress_type, suppress_function and
	suppress_variable directives.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-11 11:41:42 +01:00
Dodji Seketeli
21a85fbbdf Make abipkgdiff check for the presence of suppression spec files
* tools/abipkgdiff.cc (maybe_check_suppression_files): Define new
	static function.
	(main): Use it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-11 09:40:41 +01:00
Dodji Seketeli
ff408a3d07 Make abipkgdiff return correct exit code on usage error
* tools/abipkgdiff.cc (main): Return the correct error code on
	usage error.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-11 09:40:41 +01:00
Dodji Seketeli
2c4efc0c3e Bug 19604 - abidiff --suppressions doesn't complain about invalid file name
* tools/abidiff.cc (maybe_check_suppression_files): Define new
	static function.
	(main): Use it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-11 09:39:10 +01:00
Dodji Seketeli
ef2211831f Use proper WIFEXITED and WEXITSTATUS macros to get exit code
It turns out we were wrongly getting the exit code of some processes
being executed by the "system()" invocation.  The patch uses the
WIFEXITED and WEXITSTATUS macro as documented in the man page for
"system".

	* tests/test-diff-dwarf-abixml.cc (main): Use WIFEXITED and
	WEXITSTATUS macros to get the return code of the abidiff program.
	* tests/test-diff-filter.cc (test_task::perform): Likewise.
	* tests/test-diff-pkg.cc (main): Likewise.
	* tests/test-diff-suppr.cc (main): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-10 22:06:01 +01:00
Dodji Seketeli
4b7e295b20 Bug 19596 - Incorrect exit status for incompatible ABI change
The comparison engine doesn't take virtual offset changes into account
when deciding if a diff node carries an incompatible change.  This is
obviously an oversight.

Fixed thus.

	* include/abg-comparison.h (enum diff_category): Adjust the
	comment for enumerator VIRTUAL_MEMBER_CHANGE_CATEGORY; changes of
	this category are incompatible ABI changes.
	(corpus_diff::diff_stats::num_func_with_virtual_offset_changes):
	Declare new accessors.
	* src/abg-comparison.cc
	(corpus_diff::diff_stats::priv::num_func_with_virt_offset_changes):
	New data member.
	(corpus_diff::diff_stats::priv::priv): Initialize the new data
	member.
	(corpus_diff::diff_stats::num_func_with_virtual_offset_changes):
	Define new accessors.
	(corpus_diff::priv::apply_filters_and_compute_diff_stats): Use the
	new accessor to set the number of functions with virtual offset
	changes onto the stats data structure.
	(corpus_diff::has_incompatible_changes): Take functions with
	virtual offset changes into account.
 	* tests/test-abidiff-exit.cc: New test harness to test for exit
	codes of abidiff.
	* tests/Makefile.am: Build the new test harness runtestabidiff
	from the test-abidiff-exit.cc source file.
	* tests/data/test-abidiff-exit/test1-voffset-change-report0.txt:
	New reference test output.
	* tests/data/test-abidiff-exit/test1-voffset-change-v0.cc: New
	test input source code.
	* tests/data/test-abidiff-exit/test1-voffset-change-v0.o: New test input.
	* tests/data/test-abidiff-exit/test1-voffset-change-v1.cc: New
	test input source code.
	* tests/data/test-abidiff-exit/test1-voffset-change-v1.o: New test input.
	* tests/data/Makefile.am: tests/data/Makefile.am: Add the new test
	inputs above to the source distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-10 21:31:53 +01:00
Dodji Seketeli
31aef952c8 Fix synthesizing of reference type
Libabigail fails to synthesize a non-existing reference type to an
existing type.

This is similar to the previous commit "2f88edd Fix synthesizing of
pointer type" which, obviously dealt with pointer types.

This patch adds support for synthesizing a reference type to an
existing type.

	* src/abg-ir.cc (synthesize_type_from_translation_unit): Support
	synthesizing reference types.
	* tests/data/test-abicompat/libtest9-fn-changed-v0.so: Add new
	test input.
	* tests/data/test-abicompat/libtest9-fn-changed-v1.so: Likewise.
	* tests/data/test-abicompat/test9-fn-changed-app: Likewise.
	* tests/data/test-abicompat/test9-fn-changed-app.cc: : Likewise.
	* tests/data/test-abicompat/test9-fn-changed-report-0.txt: Likewise.
	* tests/data/test-abicompat/test9-fn-changed-v0.cc: Likewise.
	* tests/data/test-abicompat/test9-fn-changed-v0.h: Likewise.
	* tests/data/test-abicompat/test9-fn-changed-v1.cc: Likewise.
	* tests/data/test-abicompat/test9-fn-changed-v1.h: Likewise.
	* tests/data/Makefile.am: Add the new material to source
	distribution.
	* tests/test-abicompat.cc (in_out_specs): Add the new test inputs
	to the test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-04 11:26:22 +01:00
Dodji Seketeli
2f88edd3b3 Fix synthesizing of pointer type
Libabigail fails to to synthesize a non-existing pointer type to an
existing type.

This makes abicompat fail in weak mode when trying to detect changes
to a function type where the parameter is a pointer to a structure
which changed.  In the application, the function is invoked and a
pointer to the structure is passed to it.  It appears that the type of
structure is defined in the debug info of the application, but not the
pointer to that structure.  So abicompat needs to synthesize that
pointer to struct in order to synthesize the type of the function, and
so, compare it to the type of the function coming from the library.

It appears that synthesizing a pointer type (to an existing type) is
not supported.  Only synthesizing qualified type was supported.

This patch adds support for that and thus fixes the abicompat test
case that is attached.

	* include/abg-ir.h: Update copyright.
	* src/abg-ir.cc (synthesize_type_from_translation_unit): Support
	synthesizing pointer types.

	* tests/data/test-abicompat/libtest8-fn-changed-libapp-v0.so: New
	test input.
	* tests/data/test-abicompat/libtest8-fn-changed-libapp-v1.so: Likewise.
	* tests/data/test-abicompat/test8-fn-changed-app: Likewise.
	* tests/data/test-abicompat/test8-fn-changed-app.c: Likewise.
	* tests/data/test-abicompat/test8-fn-changed-libapp-v0.c: Likewise.
	* tests/data/test-abicompat/test8-fn-changed-libapp-v0.h: Likewise.
	* tests/data/test-abicompat/test8-fn-changed-libapp-v1.c: Likewise.
	* tests/data/test-abicompat/test8-fn-changed-libapp-v1.h: Likewise.
	* tests/data/test-abicompat/test8-fn-changed-report-0.txt: Likewise.
	* tests/data/Makefile.am: Add the new test input files to source
	distribution.
	* tests/test-abicompat.cc (in_out_specs): Add the new test inputs
	above to the test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-03 13:00:51 +01:00
Mark Wielaard
d01c536a5e Remove defined but not used functions pointed out by GCC6.
abg-ir.cc:6041:1: warning: ‘abigail::ir::decl_base_sptr abigail::ir::convert_node_to_decl(std::tr1::shared_ptr<_Tp>) [with NodeKind = abigail::ir::decl_base]’ defined but not used [-Wunused-function]
 convert_node_to_decl(decl_base_sptr node)
 ^~~~~~~~~~~~~~~~~~~~

abg-ir.cc:5990:1: warning: ‘const string& abigail::ir::get_node_name(std::tr1::shared_ptr<_Tp>) [with NodeKind = abigail::ir::decl_base]’ defined but not used -Wunused-function]
 get_node_name(decl_base_sptr node)
 ^~~~~~~~~~~~~

	* src/abg-ir.cc (convert_node_to_decl(decl_base_sptr)): Remove
	definition.
	(get_node_name(decl_base_sptr)): Likewise.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2016-01-28 09:33:15 +01:00
Mark Wielaard
eea4bf067b Make make more silent.
Silent rules already are the default, but automake and make both still
tell which directory is being entered/build. Disable printing from make.

	* Makefile.am (AM_MAKEFLAGS): Set --no-print-directory.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2016-01-28 09:18:05 +01:00
Mark Wielaard
6b0b68fbf7 Fix GCC6 -Wmisleading-indentation warnings.
These two issues pointed out by GCC6 are harmless, but might confuse
a reader of the code. Just properly indent the code.

	* src/abg-dwarf-reader.cc (find_import_unit_point_before_die):
	Properly indent code after if clause.
	* src/abg-ini.cc (write_property_value): Properly indent return
	statement after else clause.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2016-01-28 09:00:46 +01:00
Dodji Seketeli
2dc323b972 Fix abicompat's handling of library types not used by the application
When abicompat sees a type defined by the library but not used by the
application, it behaves as if the application has that type defined as
"void".  So it compares both types (void and the library type) and
report the difference.  Hugh.

This patch fixes that by avoiding comparison when the application
doesn't use a particular library type.

	* tools/abicompat.cc (perform_compat_check_in_weak_mode): If the
	application doesn't use a given type defined and exported by the
	library, then skip it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-27 14:18:47 +01:00
Dodji Seketeli
35b7a928ef Do not crash when looking up a type from global scope
* src/abg-ir.cc (lookup_type_in_scope): Gently Handle empty access
	path.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-27 13:44:01 +01:00
Dodji Seketeli
8c1acaeb08 Comparing aliases of the same symbol must be done by pointer
Different aliases of the same symbol are considered equal.  This is at
least how the elf_symbol::operator== is intended to work.

What makes the different aliases be different is their pointer value.
This patch fixes several spots where these assumptions are not
respected.

	* src/abg-ir.cc (elf_symbol::operator==): Fix thinko and
	indentation.  What was I thinking ...
	(elf_symbol::add_alias)
	(compute_aliases_for_elf_symbol): Do not compare aliases using the
	equality operator, because it considers all aliases of a given
	symbol as equal.  Rather, use elf_symbol::is_main_symbol() to test
	if an alias is the main symbol alias.
	* src/abg-comp-filter.cc (function_name_changed_but_not_symbol):
	Likewise.
	* src/abg-corpus.cc
	(corpus::priv::build_unreferenced_symbols_tables): Likewise.
	* src/abg-writer.cc (write_elf_symbol_aliases): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-25 17:02:52 +01:00
Dodji Seketeli
066ebbdf0e Bug 19204 - libabigail aborts on DWARF referencing non-existing DIE
In this bug the DWARF reader tries to get the parent of a DIE
(referred-to by its offset) which is not defined in the debug info.
The DIE is not defined, but it's referred-to by another DIE of the
debug info.  This definitely looks like a faulty DWARF.

The DWARF reader aborts because, obviously, it cannot get the parent
DIE of a DIE that is not defined.

This patch changes the behaviour of the DWARF reader in this case.
Rather than aborting, the DWARF reader just drops the DIE (which
refers to a non-existing DIE) on the floor.  It thus do not abort on
such faulty DWARF anymore.

	* src/abg-dwarf-reader.cc (get_parent_die): If we couldn't find
	the parent of a given DIE, return false, do not abort.  Also,
	assert that if we don't find the parent of a DIE in the main debug
	info, we don't find it in the alternate debug info either (and
	vice versa).  This is because I'd like to abort on cases where we
	look for a DIE in the wrong debug info; those cases are likely to
	be hint that the DWARF reader is doing something wrong which ought
	to be investigated and fixed.
	(get_scope_for_die): If we couldn't get the parent of the DIE,
	then return a nil scope.
	* tests/data/test-types-stability/pr19204-libtcmalloc.so.4.2.6-xlc:
	New test binary input.
	* tests/data/Makefile.am: Add the new binary test input to the
	source distribution.
	* tests/test-types-stability.cc (elf_paths): Account for the new
	binary input.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-21 10:48:32 +01:00
Dodji Seketeli
11c89cad3e Pass parm of elf_symbol::add_alias by reference
* include/abg-ir.h (elf_symbol::add_alias): Pass parameter by
	reference.
	* src/abg-ir.cc (elf_symbol::add_alias): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-20 14:02:04 +01:00
Dodji Seketeli
640b3a2f59 Bug 19141 - Libabigail doesn't support common ELF symbols
Libabigail's internal representation of elf symbols fails to account
for common symbols in relocatable files.  There can be several common
symbols of the same name (defined in a section of SHN_COMMON kind).
In that case, Libabigail wrongly considers these multiple instances of
the same common symbol as being alias, and that breaks some
basic assumptions about aliases.  Oops.

This patch adds support for the common symbols (and the fact that
relocatable files can have several instances of the same common
symbol) and amends the ELF reader to make it properly represent those.
	* include/abg-ir.h (elf_symbol::elf_symbol): Take a new flag to
	say if the symbol is common.
	(elf_symbol::{is_common_symbol, has_other_common_instances,
	get_next_common_instance, add_common_instance}): New member functions.
	* src/abg-ir.cc (elf_symbol::priv::{is_common_,
	next_common_instance_): New data members.
	(elf_symbol::priv::priv): Adjust.
	(elf_symbol::{elf_symbol, create}): Take a new flag to say if the
	symbol is common.
	(textually_equals): Adjust to account for symbol common-ness.
	(elf_symbol::{is_common_symbol, has_other_common_instances,
	get_next_common_instance, add_common_instance}): Define new member
	functions.
	(elf_symbol::add_alias): Drive-by fix; compare symbols using
	pointer value.  Value comparison is not necessary.
	* src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab)
	(lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_symtab)
	(read_context::lookup_elf_symbol_from_index): Adjust the creation
	of the symbol to account for common-ness.
	(read_context::load_symbol_maps): Recognize instances of a given
	common symbol and represent them as such.  Do not mistake this
	with symbol aliases.
	* src/abg-reader.cc (build_elf_symbol): Adjust the creation of the
	symbol to account for common-ness.
	* src/abg-writer.cc (write_elf_symbol): Adjust symbol
	serialization to account common-ness.
	* tests/data/test-types-stability/pr19141-get5d.o: Add new test
	binary input.
	* tests/data/test-types-stability/pr19142-topo.o: Likewise.
	* tests/data/Makefile.am: Add the new test inputs to source distribution.
	* tests/test-types-stability.cc (elf_paths): The the new test
	inputs into account.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-20 13:37:52 +01:00
Dodji Seketeli
c3869ecc7b Bug 19434 - invalid character in attribute value
* include/abg-tools-utils.h (string_is_ascii_identifier): Declare
	new function.
	* src/abg-tools-utils.cc (string_is_ascii_identifier): Define new function.
	* src/abg-dwarf-reader.cc (build_function_type): Discard parameter
	name if it's made of non-identifier ascii characters.
	* tests/data/test-types-stability/pr19434-elf0: New test binary input file.
	* tests/data/Makefile.am: Add the new test input to source distribution.
	* tests/test-types-stability.cc: Test the new test input into account.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-18 18:23:19 +01:00