Commit Graph

1520 Commits

Author SHA1 Message Date
Dodji Seketeli
a7492fea56 Support ELF symbol visibility property
This patch models the ELF symbol visibility property and support
ignoring function and variable symbols that are HIDDEN and INTERNAL,
even if they have default binding.

	* include/abg-ir.h (enum elf_symbol::visibility): Define new enum.
	(elf_symbol::{elf_symbol, create}): Take a visibility parameter.
	(elf_symbol::{set, get}_visibility): Declare new accessors.
	(string_to_elf_symbol_binding): Declare new function.
	* src/abg-ir.cc (elf_symbol::priv::visibility_): New data member.
	(elf_symbol::priv::priv): Adjust.
	(elf_symbol::elf_symbol): Take a visibility parameter.
	(elf_symbol::create): Likewise
	(elf_symbol::{s,g}et_visibility): Define new accessors.
	(elf_symbol::is_public): Adjust.
	(operator<<(std::ostream&, elf_symbol::visibility)): Define new
	operator.
	(string_to_elf_symbol_visibility): Define new function.
	* src/abg-dwarf-reader.cc (stv_to_elf_symbol_visibility): Define
	new static function.
	(lookup_symbol_from_sysv_hash_tab)
	(lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_symtab)
	(create_default_var_sym, create_default_fn_sym): Adjust.
	* src/abg-reader.cc (read_elf_symbol_binding): Define new
	function.
	(build_elf_symbol): Adjust.
	* src/abg-writer.cc (write_elf_symbol_visibility): Define new
	function.
	* tests/data/test-annotate/libtest23.so.abi: Adjust.
	* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Adjust.
	* tests/data/test-annotate/libtest24-drop-fns.so.abi: Adjust.
	* tests/data/test-annotate/test0.abi: Adjust.
	* tests/data/test-annotate/test1.abi: Adjust.
	* tests/data/test-annotate/test13-pr18894.so.abi: Adjust.
	* tests/data/test-annotate/test14-pr18893.so.abi: Adjust.
	* tests/data/test-annotate/test15-pr18892.so.abi: Adjust.
	* tests/data/test-annotate/test17-pr19027.so.abi: Adjust.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Adjust.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Adjust.
	* tests/data/test-annotate/test2.so.abi: Adjust.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Adjust.
	* tests/data/test-annotate/test21-pr19092.so.abi: Adjust.
	* tests/data/test-annotate/test3.so.abi: Adjust.
	* tests/data/test-annotate/test4.so.abi: Adjust.
	* tests/data/test-annotate/test5.o.abi: Adjust.
	* tests/data/test-annotate/test6.so.abi: Adjust.
	* tests/data/test-annotate/test7.so.abi: Adjust.
	* tests/data/test-annotate/test8-qualified-this-pointer.so.abi:
	Adjust.
	* tests/data/test-read-dwarf/libtest23.so.abi: Adjust.
	* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi: Adjust.
	* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Adjust.
	* tests/data/test-read-dwarf/test0.abi: Adjust.
	* tests/data/test-read-dwarf/test1.abi: Adjust.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Adjust.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Adjust.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Adjust.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Adjust.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Adjust.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Adjust.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Adjust.
	* tests/data/test-read-dwarf/test2.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/test3.so.abi: Adjust.
	* tests/data/test-read-dwarf/test4.so.abi: Adjust.
	* tests/data/test-read-dwarf/test5.o.abi: Adjust.
	* tests/data/test-read-dwarf/test6.so.abi: Adjust.
	* tests/data/test-read-dwarf/test7.so.abi: Adjust.
	* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi:
	Adjust.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.
	* tests/data/test-read-write/test26.xml: Adjust.
	* tests/data/test-read-write/test27.xml: Adjust.
	* tests/data/test-read-write/test28-without-std-fns-ref.xml:
	Adjust.
	* tests/data/test-read-write/test28-without-std-vars-ref.xml:
	Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:47 +02:00
Dodji Seketeli
c0bfc403dc Filter top cv qualifier changes on function parameter types
When the type of a function parameter sees its top CV qualifier
change, that should never negatively affect ABI compliance.

So this patch filters out top cv qualifier changes on function
parameter types, by default.

	* include/abg-comparison.h (enum diff_category): Add a new
	FN_PARM_TYPE_TOP_CV_CHANGE_CATEGORY enumerator.  "Or" the
	enumerator to the EVERYTHING_CATEGORY enumerator.
	* src/abg-comp-filter.cc (has_fn_parm_type_cv_qual_change): Define
	new static function.
	(categorize_harmless_diff_node): Categorize changes to top cv
	qualifiers on function parameter types into the new
	FN_PARM_TYPE_TOP_CV_CHANGE_CATEGORY.
	* src/abg-comparison.cc (get_default_harmless_categories_bitmap):
	Add the new FN_PARM_TYPE_TOP_CV_CHANGE_CATEGORY category to the
	set of harmless categories.
	(operator<<(ostream&, diff_category)): Adjust to serialize
	the new FN_PARM_TYPE_TOP_CV_CHANGE_CATEGORY.
	* tests/data/test-diff-filter/libtest40-v0.so: New test input binary.
	* tests/data/test-diff-filter/libtest40-v1.so: Likewise.
	* tests/data/test-diff-filter/test40-report-0.txt: New test
	reference output.
	* tests/data/test-diff-filter/test40-v0.cc: Source code of the
	test binary above.
	* tests/data/test-diff-filter/test40-v1.cc: Likewise.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-diff-filter.cc (in_out_specs): Add new binaries to
	compare.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt:
	Adjust.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt:
	Likewise.
	* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt:
	Likewise.
	* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-1.txt:
	Likewise.

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

This is what this patch does.

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:47 +02:00
Dodji Seketeli
6eb2b268f8 Allow selective resolution of class declaration
When a class is forward-declared, resolving it to a definition that
appears later in the same translation unit or in another translation
is an interesting problem.

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

This patch resolves that randomness.

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

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

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:46 +02:00
Dodji Seketeli
8bf7b7d26b Add documentation for the kmidiff tool
* doc/manuals/kmidiff.rst: New doc file.
	* doc/manuals/Makefile.am: Add the above file to source
	distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:45 +02:00
Dodji Seketeli
077b977ce5 Allow re-using the ELF/DWARF read_context when loading a corpus group
Right now, when loading each corpus of a group, a new read_context is
created and destroyed.  That makes thousands of corpora that are
created and destroyed.  Profiling seems to argue that we'd gain in
performance by re-using the first read_context that was created
instead, and re-set it before loading a new corpus.

This is what this patch does.

	* include/abg-dwarf-reader.h (reset_read_context): Declare new
	function.
	* src/abg-dwarf-reader.cc (read_context::elf_paths_): Make this to
	be non const.
	(read_context::initialize): New function to initialize all data
	members.
	(read_context::read_context): Use the new read_context::initialize
	function, rather than initializing data members 'inline' here.
	(reset_read_context): Define a new function to reset a
	read_context so that it can be re-used to load a new corpus.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:45 +02:00
Dodji Seketeli
b9a7e99dda Add --vmlinux{1,2} option to abidw and kmidiff
When using abidw to generate an abixml for a Linux Kernel build tree,
usually, people have to copy the vmlinux binary into the directory
where modules are, so that the tool can find it.  This --vmlinux
option helps to avoid doing that copy.

Simarly, when comparing two Linux Kernel build trees, --vmlinux1 and
--vmlinux2 are there to make the tool find the vmlinux binaries to
compare, independantly from the directories under which the modules
are to be found.

	* include/abg-tools-utils.h
	(build_corpus_group_from_kernel_dist_under): Add a new
	vmlinux_path parameter.
	* src/abg-tools-utils.cc (find_vmlinux_and_module_paths): Do not
	try to find a vmlinux binary if we already have the path to one.
	(build_corpus_group_from_kernel_dist_under): Add a new
	vmlinux_path parameter.
	* tools/abidw.cc (options::vmlinux): New data member.
	(display_usage): Add a usage string for --vmlinux
	(parse_command_line): Parse the new --vmlinux option.
	(load_kernel_corpus_group_and_write_abixml): Fix some return code
	when the function fails.  Verify the presence of the vmlinux
	binary that was given.  Adjust.
	* tools/kmidiff.cc (options::{vmlinux1, vmlinux2}): New data
	members.
	(display_usage): Add a usage string for --vmlinux1 and --vmlinux2.
	(parse_command_line):  Parse the --vmlinux1 and --vmlinux2
	options.
	(main): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:45 +02:00
Dodji Seketeli
0b2e8ae156 Cache function type name computation results
get_type_name can be called over and over again on function types.
This patch caches the result of the computation of function type names
in those cases.

This is a speed optimization.

	* src/abg-ir.cc (get_type_name): Cache function type names.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:45 +02:00
Dodji Seketeli
5119f66b02 Fix innacurate test condition when reading an enum type from abixml
* src/abg-reader.cc (build_enum_type_decl): Do not check for
	errno which might have been set earlier by something else.
	Rather, check the returned value for overflow or underflow.

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

This is what this patch does.

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

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

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

This patch does just that.

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

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:43 +02:00
Dodji Seketeli
76d832115d Allow selective resolution of class declaration
When a class is forward-declared, resolving it to a definition that
appears later in the same translation unit or in another translation
is an interesting problem.

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

This patch resolves that randomness.

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

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

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

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

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

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

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

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

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

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

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

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

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

If C has an associated type, we return it.

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

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

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:42 +02:00
Dodji Seketeli
5759a92eb4 Speedup access to unreferenced symbols when loading corpus_group
This patch speeds up the invocation of
corpus_group::get_unreferenced_function_symbols and
corpus_group::get_unreferenced_variable_symbols.  It does so by
caching the result of constructing the map of of unreferenced symbol
at the time where each corpus is added to the group.

	* src/abg-corpus.cc (corpus_group::unrefed_{fun, var}_symbol_map):
	New data members.
	(corpus_group::priv::priv): Adjust.
	(corpus_group::priv::add_unref_{fun,var}_symbols): Define new
	member functions.
	(corpus_group::add_corpus): Update the map of unreferenced
	symbols.
	(corpus_group::get_unreferenced_{function,variable}_symbols)
	Adjust logic.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:41 +02:00
Dodji Seketeli
e09fc8c9e2 Initial support of de-serializing the KMI of a Linux Kernel Tree
With this patch, kmidiff knows how to compare a serialized
corpus_group that represents a Kernel Module Interface (a .kmi file)
against either another serialized .kmi file, or against a kernel tree.

The patch extends the abixml reader to make it parse an
'abi-corpus-group' element.  To do that, the patch modifies
read_corpus_from_input to make it be capable of parsing several
'abi-corpus' in a row.  That modified function is then used by a new
read_corpus_group_from_input, which is itself used by the new public
entry points read_corpus_group_from_native_xml_file and
read_corpus_group_from_native_xml.

With that read_corpus_group_from_native_xml_file building block
function, the kmidiff program is modified so that it can take either
two directory trees, two .kmi files or one directory tree and one .kmi
file.

	* include/abg-libxml-utils.h (advance_to_next_sibling_element):
	Declare new function.
	* src/abg-libxml-utils.cc (go_to_next_sibling_element_or_stay)
	(advance_to_next_sibling_element): Define new functions.
	* include/abg-reader.h (read_corpus_group_from_input)
	(read_corpus_group_from_native_xml)
	(read_corpus_group_from_native_xml_file): Declare new functions.
	* src/abg-reader.cc (read_context::m_corpus_group): New data
	member.
	(read_context::{get_corpus_group, set_corpus_group}): Define new
	member functions.
	(read_translation_unit_from_input): Cleanup logic.
	(read_corpus_from_input): Don't assume that the document is
	starting with an 'abi-corpus' element.  Support the mode where a
	caller called the xmlTextReaderExpand function (and so we are
	given an expanded xmlNodePtr) and the mode where we need to use
	the xmlTextReader API to walk through the 'abi-corpus' element.
	Also, if we are building a corpus group, do not clear what used to
	be 'per-corpus' data.  That data must be shared by all the corpora
	of a given abi-corpus-group.
	(read_corpus_group_from_input, read_corpus_group_from_native_xml)
	(read_corpus_group_from_native_xml_file): Define new functions.
	* include/abg-tools-utils.h (FILE_TYPE_XML_CORPUS_GROUP): New
	enumerator of the file_type enum.
	* src/abg-tools-utils.cc (operator<<): In the overload for
	file_type, add a case for the new FILE_TYPE_XML_CORPUS_GROUP.
	(guess_file_type): Dectect abi-corpus-group xml element.
	* tools/abidiff.cc (adjust_diff_context_for_kmidiff): Define new
	static function.
	(main): Adjust to handle the new FILE_TYPE_XML_CORPUS_GROUP.  That
	is, compare two FILE_TYPE_XML_CORPUS_GROUP if they are present.
	* tools/abilint.cc (main): Likewise.
	* tools/kmidiff.cc (main): Detect that one of two .kmi files are
	passed.  In that case, load the .kmi file(s), build a corpus_group
	of it and use it in the comparison.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:41 +02:00
Dodji Seketeli
adb656cc76 Initial support of the serialization of the KMI of a Linux Kernel Tree
We have the kmidiff program that takes two Linux Kernel trees
containing the vmlinux binary and its modules and compare their Kernel
Module Interface, aka KMI.

We need to be able to serialize (save in a file) a representation of
that KMI.  We need to load that KMI back, and compare two serialized
KMIs.

This patch implements the serialization of the KMI of a Linux Kernel
tree.  It actually serializes an instance of abigail::ir::corpus_group
that is a collection of instances of abigail::ir::corpus.  The KMI of
each individual binary (vmlinux or kernel module) is represented by
one abigail::ir::corpus.  All the corpora share the same definitions
of types and decls, whenever that makes sense.

The patch thus factorizes the routines used to walk a Linux kernel out
of the kmidiff program.  These routines are then re-used in the abidw
program to make it walk a Linux kernel tree (when the --linux-tree
option is provided), load the vmlinux and module binaries as an
instance of abigail::corpus_group and serialize it out into an output
stream.

	* include/abg-tools-utils.h (check_dir)
	(get_binary_paths_from_kernel_dist)
	(build_corpus_group_from_kernel_dist_under): Declare new
	functions.  The last two functions are being moved from
	tools/kmidiff.cc so that they can be re-used.
	* include/abg-writer.h (write_corpus): Declare one overload that
	takes a write_context parameter.
	(write_corpus_group): Declare three overloads of this new function.
	* src/abg-tools-utils.cc (check_dir): Define new function.
	(load_generate_apply_suppressions, is_vmlinux, is_kernel_module)
	(find_vmlinux_and_module_paths)
	(get_binary_paths_from_kernel_dist)
	(build_corpus_group_from_kernel_dist_under): Define new functions.
	* src/abg-writer.cc (write_context::set_annotate): Define new
	member function.
	(write_corpus): Add an overload that takes a write_context.  Adapt
	the existing overload to make it use this new one.
	(write_corpus_group): Define this new function and two additional
	overloads for it.
	* tools/kmidiff.cc (set_suppressions, is_vmlinux)
	(is_kernel_module, find_vmlinux_and_module_paths)
	(get_binary_paths_from_kernel_dist)
	(build_corpus_group_from_kernel_dist_under): Remove.
	(main): Adjust the call to
	build_corpus_group_from_kernel_dist_under as its arguments are now
	adapted since it's been factorized out into abg-tools-utils.h.
	* tools/abidw.cc (options::corpus_group_for_linux): Define new
	data member.
	(options::options): Adjust.
	(display_usage): Add help strings for the new --linux-tree option.
	(load_corpus_and_write_abixml): Factorize this function out of the
	main function.
	(load_kernel_corpus_group_and_write_abixml): Define new function.
	(main): Use the factorized load_corpus_and_write_abixml and the
	new load_corpus_and_write_abixml functions.
	* tests/test-read-write.cc: Adjust.
	* doc/manuals/abidw.rst: Add documentation for the new
	--linux-tree option.

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

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:39 +02:00
Dodji Seketeli
3220d7de0b Fix indentation glitch before the </abi-corpus> tag in abixml
* src/abg-writer.cc (write_corpus): Indent before emitting the
	closing </abi-corpus> tag.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:39 +02:00
Dodji Seketeli
f45073ecc2 Avoid emitting some empty translation units to abixml
It turned out a lot of empty translation unit can make it to the
abixml output.  This patch reduces the number of these.

	* src/abg-writer.cc (write_corpus):  Do not emit a translation
	unit that appears empty beforehand.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:39 +02:00
Dodji Seketeli
d8a1306739 Avoid emitting duplicated decls in abixml
This patch avoids emitting the same decl twice in the same ABI corpus
or corpus_group.  For the purpose of this duplication detection, a
decl is designated by its pretty representation.

The patch helps to reduce the size of the abixml files drastically by
cutting some of them, especially those representing the KMI of the
linux kernel in more than half.

	* src/abg-writer.cc (write_context::m_emitted_decls_map): New data
	member.
	(write_context::{decl_name_is_emitted, record_decl_as_emitted}):
	Define new memeber functions.
	(write_translation_unit): Do not emit a decl that has already been
	emitted.
	(write_var_decl, write_function): Record the decl as emitted.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:39 +02:00
Dodji Seketeli
56f36edcde Rename write_corpus_to_native_xml into write_corpus
Rename write_corpus_to_native_xml into write_corpus because it's a
better name.

	* include/abg-writer.h (write_corpus): Rename
	write_corpus_to_native_xml to this.
	* src/abg-writer.cc (write_corpus): Rename
	write_corpus_to_native_xml to this.
	* tests/test-read-dwarf.cc (test_task::perform): Adjust.
	* tests/test-read-write.cc: Remove a useless "using
	abigail::xml_writer::write_corpus_to_native_xml".
	* tools/abidw.cc (main): Adjust.
	* tools/abilint.cc (main): Adjust.

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:37 +02:00
Dodji Seketeli
eae7ca0426 Introduce the --kmi-whitelist option to abidiff
abidiff had an --linux-kernel-abi-whitelist option.  Rename it
--kmi-whitelist.

	* doc/manuals/abidiff.rst: Add documentation for the
	--kmi-whitelist option.
	* tools/abidiff.cc (display_usage): Emit help string for the
	--kmi-whitelist option
	(parse_command_line): Parse the new --kmi-whitelist option, of the
	-w shortcut.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:37 +02:00
Dodji Seketeli
c15eecc9a0 Make abidw support the --kmi-whitelist option
When writting out the ABI of a Linux kernel binary we must be able to
restrict it to the set of functions and global variables which ELF
symbols have names defined in a white list.

This patch adds that support, using the --kmi-whitelist
option.

	* tools/abidw.cc (options::{kabi_whitelist_paths,
	kabi_whitelist_supprs}): New data members.
	(display_usage): Add a help string for the new --kmi-whitelist
	option.
	(parse_command_line): Parse the new --kmi-whitelist option.
	(maybe_check_suppression_files): Check the presence of the linux
	kernel abi white list passed by the option --kmi-whitelist.
	(main): Ignore loading the symbol table if the kernel abi white
	list is provided.
	* doc/manuals/abidw.rst: Add documentation for the new option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:37 +02:00
Dodji Seketeli
5f92a183bb Make abipkgdiff compare two kernel packages
This patch makes abipkgdiff compare two kernel packages.  At the
moment the comparison is done by comparing each binary from the first
package to its counterpart in the second package.  No optimization is
done do represent a vmlinux binary and its modules as one single
entity.  So this is different from what kmidiff does.

	* include/abg-suppression.h
	(variable_suppression::variable_suppression): Add default arguments
	to the parameters.
	* include/abg-tools-utils.h (dir_exists, dir_is_empty)
	(string_begins_with, get_rpm_name, get_rpm_arch, get_deb_name)
	(file_is_kernel_package, file_is_kernel_debuginfo_package):
	Declare new functions.
	* src/abg-tools-utils.cc (dir_exists, dir_is_empty)
	(string_begins_with, get_deb_name, get_rpm_name, get_rpm_arch)
	(file_is_kernel_package, file_is_kernel_debuginfo_package): Define
	new functions.
	(gen_suppr_spec_from_kernel_abi_whitelist): The kernel ABI
	whitelist is made of ELF symbols names that ought to match
	functions *and* variables that have ELF symbols with those names.
	So generate variable suppression specifications as well.  Not just
	function suppression specifications.
	* tools/abipkgdiff.cc (options::{kabi_whitelist_package,
	show_symbols_not_referenced_by_debug_info, kabi_whitelist_paths,
	kabi_suppressions}): New data members.
	(options::options): Adjust.
	(package::KIND_KABI_WHITELISTS): New enumerator in the
	package::kind enum.
	(package::kabi_whitelist_package_): New data member.
	(package::{base_name, kabi_whitelist_package, }): New member
	functions.
	(display_usage): Add a help string to the new
	--linux-kernel-abi-whitelist and --no-unreferenced-symbols
	options.
	(parse_command_line): Parse the new --no-unreferenced-symbols,
	--linux-kernel-abi-whitelist and --lkaw-pkg options.
	(maybe_check_suppression_files): Check the presence of kabi
	whitelist files.
	(set_diff_context_from_opts): Consider (not) showing symbols not
	referenced by debug info.
	(compare): If we are looking at linux kernel packages, take the
	kernel abi whitelist into account, apply the suppressions
	resulting from the kabi whitelists to the ELF read context.
	(maybe_collect_kabi_whitelists)
	(get_kabi_whitelists_from_arch_under_dir)
	(maybe_handle_kabi_whitelist_pkg, maybe_collect_kabi_whitelists)
	(get_interesting_files_under_dir): Define new functions.
	(maybe_update_vector_of_package_content): Take a new
	file_name_to_look_for parameter.
	(create_maps_of_package_content)
	(extract_package_and_map_its_content): Consider the case of the
	package being a linux kernel package.
	(main): Take the potential --lkaw-pkg into account.
	* doc/manuals/abipkgdiff.rst: Add documentation for options
	--linux-kernel-abi-whitelist, --lkaw-pkg and
	--no-unreferenced-symbols.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:36 +02:00
Dodji Seketeli
04ac471f1c Avoid loading a translation unit twice from abixml
Sometimes, it can happen that a translation unit gets read twice while
loading an abixml.  This patch fixes that.

	* src/abg-reader.cc (read_translation_unit): Take (in parameter) a
	reference as the resulting translation unit.
	(get_or_read_and_add_translation_unit): Define new static
	function.
	(read_context::get_scope_for_node)
	(read_translation_unit_from_input): Use the new
	get_or_read_and_add_translation_unit.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:36 +02:00
Dodji Seketeli
8e8de9c3f5 Support loading and comparing two kernel trees
* include/abg-dwarf-reader.h (set_read_context_corpus_group)
	(read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table)
	(get_ignore_symbol_table): Declare new functions.
	* abg-dwarf-reader.cc (read_context::options_type): Define new
	type.
	(die_dependant_container_set::clear): Define new member function.
	(read_context::{bss, tesxt, rodata, data, data1}_section_): Add
	new data members.
	(read_context::{symbol_versionning_sections_loaded_,
	symbol_versionning_sections_found_}): Likewise.
	(read_context::corpus_group_): Likewise.
	(read_context::{load_in_linux_kernel_mode, load_all_types,
	show_stats, do_log_}): Replace these options by ..
	(read_context::options_): ... this instance of the new
	read_context:options_type.
	(read_context::read_context): Adjust.
	(read_context::{clear_alt_debug_info_data, clear_per_corpus_data,
	env, get_data_section_for_variable_address, load_all_types,
	load_in_linux_kernel_mode, show_stats, do_log}): Adjust.
	(create_read_context): Adjust.
	(read_context::~read_context): Define destructor.
	(read_context::{options, bss_section, text_section,
	rodata_section, data_section, data1_section, current_corpus_group,
	has_corpus_group, main_corpus_from_current_group,
	main_corpus_from_current_group,
	current_corpus_is_main_corpus_from_current_group,
	should_reuse_type_from_corpus_group}): Define new member
	functions.
	(read_context::get_die_qualified_type_name): Handle the name of
	the current translation unit.
	(read_context::load_symbol_maps): Really don't load (linux kernel
	specific) symbol maps if we were told to ignore the ELF symbol
	table.
	(set_ignore_symbol_table, get_ignore_symbol_table)
	(create_default_var_sym, create_default_fn_sym, add_symbol_to_map)
	(set_read_context_corpus_group)
	(read_and_add_corpus_to_group_from_elf): Define new functions.
	(build_type_decl, build_typedef_type, build_enum_type)
	(add_or_update_class_type)
	(add_or_update_union_type): Reuse the type being built, from the
	main corpus of the corpus group.
	(build_qualified_type): Cleanup logic.
	(build_var_decl, build_function_decl): Create a default symbol for
	the variable or function if we are supposed to ignore the symbol
	table of the current binary.  Add that symbol to the symbol table
	that is created in the read context.
	(read_debug_info_into_corpus): Don't load the ELF symbol table
	information if we are asked to ignore the symbol table.  But set
	the symbol table that we built artificially while loading
	functions and variables, into the ABI corpus being built.
	(read_context::maybe_adjust_var_sym_address): Adjust.
	(build_ir_node_from_die): Add ir node to its logical scope.  For
	the C language, the scope of a type is the global scope.
	(read_corpus_from_elf): Don't load ELF properties if we were asked
	to avoid the ELF symbol table.
	* include/abg-comparison.h (compute_diff): Declare ...
	* src/abg-comparison.cc (compute_diff): ... an overload to compare
	corpus_group.
	* tools/kmidiff.cc: New tool.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:36 +02:00
Dodji Seketeli
c99addc245 Initial support to lookup types per location
This patch adds support to associate a type to its source location.
The location being a string of the form "filepath:line:column".  The
association is done by a per-translation unit map which associates a
location to a type.

For the moment this only associates one type to a given location.  For
the general case, though, we need to associate a vector or types to a
given location.  We'll add that support later.

The patch provides lookup functions, each of which looking up a
particular kind of type by its location.

	* include/abg-fwd.h (get_name_of_qualified_type)
	(get_name_of_reference_to_type, lookup_basic_type_per_location)
	(lookup_class_type_per_location, lookup_union_type_per_location)
	(lookup_enum_type_per_location, lookup_typedef_type)
	(lookup_typedef_type_per_location, lookup_pointer_type)
	(lookup_reference_type, lookup_type_per_location)
	(lookup_type_through_translation_units)
	(lookup_type_from_translation_unit, odr_is_relevant): Declare new
	functions or new function overloads.
	* include/abg-ir.h (location::expand): Declare new member
	function.
	(type_maps::empty): Likewise.
	(operator|=): Declare an overload for qualified_type_def::CV.
	(get_string_representation_of_cv_quals)
	(get_name_of_qualified_type, lookup_qualified_type): Declare new functions.
	* src/abg-ir.cc (location::expand): Define new member function.
	(type_maps::empty): Likewise.
	(odr_is_relevant): Likewise.
	(get_string_representation_of_cv_quals)
	(get_name_of_reference_to_type, get_name_of_qualified_type)
	(lookup_union_type_per_location): Define new functions or overloads.
	(lookup_basic_type, lookup_enum_type, lookup_typedef_type)
	(lookup_qualified_type, lookup_pointer_type)
	(lookup_reference_type, lookup_type_from_translation_unit)
	(lookup_basic_type_per_location, lookup_basic_type_per_location)
	(lookup_class_type_per_location, lookup_class_type_per_location)
	(lookup_enum_type_per_location, lookup_enum_type_per_location)
	(lookup_typedef_type_per_location)
	(lookup_typedef_type_per_location, lookup_type_per_location):
	Define new overloads.
	(maybe_update_types_lookup_map)
	(maybe_update_types_lookup_map<class_decl>)
	(maybe_update_types_lookup_map<function_type>): Add a new
	use_type_name_as_key parameter.  If it's false, then associates
	the type to its location rather than to its name.
	(maybe_update_types_lookup_map): In the overloads for type_decl,
	class_decl, union_decl, enum_type, typedef_decl, array_type_def,
	record the type in the lookup map per location, in addition to the
	per-name recording.
	(qualified_type_def::build_name): Use the new
	get_name_of_qualified_type.
	(qualified_type_def::get_cv_quals_string_prefix): Use the new
	get_string_representation_of_cv_quals.
	(operator|=): Define a new overload for qualified_type_def::CV.
	(pointer_type_def::get_qualified_name): Use the new
	get_name_of_pointer_to_type.
	(reference_type_def::get_qualified_name): Use the new
	get_name_of_reference_to_type.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:36 +02:00
Dodji Seketeli
50231b5537 Create a Corpus Group API extension
To support the upcomping analysis of the Linux kernel and its modules,
we need a way to represent a union of corpora.  The first corpus
loaded would be the one representing the vmlinux binary.  Subsequent
corpora loaded would be those representing the modules.

This patch provides the new abigail::ir::corpus_group type that
represents such a corpus group.

	* include/abg-corpus.h (corpus::{find_translation_unit,
	get_type_per_loc_map}): Declare new member functions.
	(corpus::{get_architecture_name, is_empty}): Make these member functions
	const.
	(corpus::{get_sorted_fun_symbols, get_functions, get_variables,
	get_unreferenced_function_symbols,
	get_unreferenced_variable_symbols}): Make these member functions
	virtual.
	(class corpus_group): Declare a new type.
	* include/abg-fwd.h (corpus_sptr, corpus_group_sptr)
	(string_tu_map_type, istring_var_decl_ptr_map_type)
	(istring_function_decl_ptr_map_type): Define new typedefs.
	* src/abg-corpus-priv.h (corpus_priv::{path_tu_map,
	type_per_loc_map_}): Add new data members.
	* src/abg-corpus.cc (corpus_add): Complete the function comment.
	Assert that at most one translation unit of a given path can be
	added to the corpus.
	(corpus::{find_translation_unit, get_type_per_loc_map}): Define
	new member functions.
	(corpus::{get_architecture_name}): Make this member function
	const.
	(struct corpus_group::priv): Define new type.
	(corpus_group::{corpus_group, ~corpus_group, add_corpus,
	get_corpora, is_empty, get_functions, get_variables,
	get_var_symbol_map, get_fun_symbol_map, get_sorted_fun_symbols,
	get_sorted_var_symbols, get_unreferenced_function_symbols,
	get_unreferenced_variable_symbols}): Define member functions of
	the new corpus_group type.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:36 +02:00
Dodji Seketeli
fc5bb3071b Fix some typos in abidiff.cc
* tools/abidiff.cc (main): Fix typos.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:43:30 +02:00
Dodji Seketeli
039ec5e478 Avoid comparing kernel.img file from the grub2 package
The command "fedabipkgdiff --self-compare --from fc25 grub2" returns
with an error because no debug info can be found for the file
kernel.img.  That file doesn't have any debug info shipped for it.
And we shouldn't try to compare it anyway.

This patch updates the default suppression file shipped by libabigail
to make it avoid compare kernel.img files.

	* default.abignore: Do not compare kernel.img files.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:43:30 +02:00
Dodji Seketeli
d9b5306224 Bug 21567 - Fedabipkgdiff matches build distro names too tightly
The build libxcb-1.12-3.fc26 has been tagged for Fedora 27 (i.e,
fc27).

When we ask fedabipkgdiff to get the builds of libxcb for Fedora 27,
it looks for builds which release string ends with 'fc27'.  It thus
fails to pick libxcb-1.12-3.fc26.

This patch changes this behaviour by making
Brew.get_package_latest_build to first try to get builds which
release string match exactly the distro string we are looking at.

But then if no build was found, the member function then tries to get
builds for which the distro part of the release string is "less than"
(in a lexicographic way) the distro string we are looking at.

I haven't added any regression test specifically for this because we
are planning to use the libabigail-selfcheck external tool to perform
regression testing on tons of Fedora packages:
https://pagure.io/libabigail-selfcheck.  Fixing this issue is a
pre-requisite for putting that regression test infrastructure in
place.

	* tools/fedabipkgdiff (get_distro_from_string): Define new function.
	(Brew.get_package_latest_build): Also consider builds which distro
	property is less than the expected distro string that we were
	given.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 16:43:05 +02:00
Sinny Kumari
8f0f82c511 Check if return_codes list is empty in fedabipkgdiff
In fedabipkgdiff tool, some packages might have only
noarch sub-packages. In these cases, no package is
available for running abipkgdiff. This leads to
return_codes list being empty.

	* tools/fedabipkgdiff (run_abipkgdiff()): Check if
	return_codes list is empty

Signed-off-by: Sinny Kumari <sinny@redhat.com>
2017-06-14 19:34:51 +05:30
Dodji Seketeli
d1095a8b1e Do not forget to erase temporary directories in abipkgdiff
When abipkgdiff decides that two packages have no content to compare
it forgets to remove the temporary directories that were created.

	* tools/abipkgdiff.cc (maybe_erase_temp_dirs): Define new static
	function.
	(compare): Call the new maybe_erase_temp_dirs on all return
	points.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-06-13 17:04:40 +02:00
Ben Woodard
3011d2ac8d Fix more clang build warnings
* include/abg-ini.h (config::section::priv): Make this be a class,
	not a struct.
	* src/abg-dwarf-reader.cc (build_translation_unit_and_add_to_ir)
	(build_ir_node_from_die): Add parenthesis around assignment
	expressions inside conditional expression.
	* src/abg-suppression.cc (read_function_suppression): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-06-02 23:12:14 +02:00
Ben Woodard
b8a629f4a1 Fix some clang compile problems
* include/abg-comp-filter.h (class filter_base): Declare this as a
	struct.
	* include/abg-comparison.h (class filtering::filter_base):
	Likewise.
	(struct diff_traversable_base): Declare this as a class.
	* include/abg-ir.h (function_decl::parameter): Declare this before
	using it.
	* src/abg-corpus.cc
	(corpus::priv::build_unreferenced_symbols_tables): Add missing
	parenthesis around assignment expressions inside conditional
	expressions.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-06-02 22:50:06 +02:00
Sinny Kumari
847d96b1d1 Add --self-compare option in fedabipkgdiff
fedabipkgdiff tool can communicate with Fedora koji and has
capability to download and perform ABI comparison between
specified NVRs.

With addition of --self-compare option, it will be possible
to perform ABI comparison on same package. One of the important
usecase of this option is to run automated ABI checks on
packages with known expected result i.e. no ABI change. This usecase
will be useful to ensure that libabigail functionality doesn't
break with new commits made.
This option can be invoked as:
fedabipkgdiff -a --self-compare -fc24 package_name

	* bash-completion/fedabipkgdiff: Add new option --self-compare
	* tests/data/Makefile.am: Add new test file
	* tests/data/test-fedabipkgdiff/test7-self-compare-from-fc23-dbus-glib-report-0.txt:
	New reference output for testing ABI comparison on same package
	* tests/runtestfedabipkgdiff.py.in (FEDABIPKGDIFF_TEST_SPECS):
	Add test case for --self-compare
	* tools/fedabipkgdiff (build_commandline_args_parser()): Add
	new option --self-compare
	(generate_comparison_halves()): Find second comparision half in same
	package list while doing self-compare
	(self_compare_rpms_from_distro()): New function to perform ABI
	comparision on same pacakge
	(main()): Add if condition when --self-compare option is enabled
2017-05-31 16:21:14 +05:30
Dodji Seketeli
d8f09c9e89 Avoid building DIE -> parent DIE map when analyzing a C binary
The C language doesn't support namespaces.  So, in that language, the
context of a type is always the global scope.  Hence, the context of a
type DIE is always the global context associated to the current
translation unit.

Thus, when we are analyzing a C binary, we can do away with building
the DIE -> DIE parent map that we later use to get the parent of a
type DIE when we need to determine the context of a given type DIE.

This can save significant time and space.

This patch implements this optimization.

	* include/abg-ir.h (global_scope_sptr): Make this be a share_ptr
	of scope_decl, not of global_scope.
	(translation_unit::get_global_scope): Return a reference to
	scope_decl_sptr.
	* src/abg-ir.cc (translation_unit::get_global_scope): Return a
	scope_decl not a global_scope.
	* src/abg-dwarf-reader.cc (read_context::nil_scope_): Add new data
	member.
	(read_context::{global_scope, nil_scope}): Define new member functions.
	(read_context::build_die_parent_maps): Do not build the map if we
	are looking at a C (or asm) translation unit.
	(get_scope_die, get_scope_for_die): If we are looking at a C
	translation unit then do return the global scope.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-05-10 11:50:54 +02:00
Dodji Seketeli
12b80d0770 Speed up access to the definition of a class declaration-only type
While emitting an abixml output for a corpus_group representing the
KMI of a Linux kernel tree, profiling shows that during comparison of
class types, calling class_decl::get_definition_of_declaration is a
hotspot.  Especially, the fact the function returns a shared pointer
that has to be "handled" shows up in the profile.

This patch introduces a
class_decl::get_naked_definition_of_declaration that returns a
pointer.  Not a shared pointer.

The patch then uses that get_naked_definition_of_declaration function
in the comparison code for class_decl.

The patch also uses get_naked_canonical_type instead of
get_canonical_type when comparing a bunch of other types.

This makes things a little bit faster when compiled without
optimization between 2% and 5%.

	* include/abg-ir.h
	(class_or_union::get_naked_definition_of_declaration): Declare a
	new member function.
	(class_decl::get_naked_definition_of_declaration): Likewise.
	* src/abg-ir.cc ({type_decl, qualified_type_def,
	array_type_def, enum_type_decl}::operator==): Use the
	get_naked_canonical_type and get_naked.
	(class_or_union::priv::naked_definition_of_declaration_): Define
	new data member.
	(class_or_union::priv::priv): Adjust to initialize the new data
	member.
	(class_or_union::get_naked_definition_of_declaration): Define new
	member function.
	({class_or_union, class_decl}::operator==): Use the new
	get_naked_definition_of_declaration instead of
	get_definition_of_declaration.
	(equals): In the overload for class_or_union, do the same.
	(class_decl::get_naked_definition_of_declaration): Define new
	member function.
	(hash_type_or_decl): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-05-10 11:49:57 +02:00
Dodji Seketeli
3c79a560cf Speedup comparison of decl-only classes
Profiling shows that while writting out the abixml for a big
corpus_group, comparing decl-only classes is a hot spot.

This patch avoids calling the function
class_or_union::priv_->comparison_started (which appears to be
culprit) in that case.

This makes writting out the abixml of the corpus_group of the Linux
kernel be ~20% faster.

	* src/abg-ir.cc (equals): In the overload for class_decl, if we
	are looking at a decl-only class, then directly call the equals
	function for class_or_union.  That one knows how to perform the
	comparison without calling the
	class_or_union::priv_->comparison_started function, in that case.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-05-10 11:48:01 +02:00
Dodji Seketeli
258352506e Update the description of what abipkgdiff does
This updates the description of what abipkgdiff in termes of sequence
of actions.

	* tools/abipkgdiff.cc: Update the description of the sequence of
	actions performed.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-05-10 11:47:52 +02:00
Dodji Seketeli
48f7815d56 Misc cleanups in abg-writer.cc
* src/abg-writer.cc (class write_context): Fix indentation.
	(write_location, write_visibility, write_binding)
	(write_array_size_and_alignment, write_size_and_alignment): Fix
	these declarations to use the *_sptr typedefs rather than the
	explicit shared_ptr<*> types.
	(write_translation_unit): Fix comment.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-05-10 11:47:42 +02:00
Dodji Seketeli
57fafc1852 Don't consider changes to basic types as being redundant
Suppose we have two types struct A and struct B.  Suppose the two
types have members of integer type.  Suppose there are members of
integer type in struct A that are modified to become members of char
type.  Suppose, at last, that we also have members of integer type in
struct B that are modified to become members of char type.

In that case, we want to see all the changes of members which types
got changed from integer type to char type.  None of these changes
should be considered redundant.

Today, unfortunately, only the first change is reported by default.
The subsequent changes are considered to be redundant.

This patch fixes that by considering that changes that modifies the type of a
decl from a basic type into another are never considered redundant.

	* include/abg-comparison.h (is_diff_of_basic_type)
	(has_basic_type_change_only): Declare these functions ...
	* src/abg-comparison.cc (is_diff_of_basic_type)
	(has_basic_type_change_only): ... and define them.
	(redundancy_marking_visitor::visit_begin): Use the new
	has_basic_type_change_only.
	* tests/data/test-diff-filter/libtest37-v0.so: New binary test input.
	* tests/data/test-diff-filter/libtest37-v1.so: Likewise.
	* tests/data/test-diff-filter/test37-report-0.txt: New test
	reference output.
	* tests/data/test-diff-filter/test37-v0.cc: Source code of the new
	binary test input.
	* tests/data/test-diff-filter/test37-v1.cc: Likewise.
	* tests/data/Makefile.am: Update to add the new test material to
	the source distribution.
	* tests/test-diff-filter.cc (in_out_spec): Add the new test input
	to this test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-05-10 11:44:17 +02:00
Dodji Seketeli
e1fd8c095e Rename fn_parm_diff::get_type_diff into fn_parm_diff::type_diff
* include/abg-comparison.h (fn_parm_diff::type_diff): Renamed
	fn_parm_diff::get_type_diff intot his.
	* src/abg-comparison.cc (fn_parm_diff::type_diff): Likewise.
	(fn_parm_diff::report): Adjust.
	(redundancy_marking_visitor::visit_begin): Likewise.
	(is_diff_of_variadic_parameter): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-05-10 11:43:31 +02:00
Dodji Seketeli
8b2457c198 Invalidate function and variable ID cache when invoking ::set_symbol
When {function, var}_decl::set_symbol is invoked, the cache of of the
ID of the decl must be invalidated because that function changes the
ID of the decl.

This patch does just that.

	* src/abg-ir.cc ({function, var}_decl::set_symbol): Invalidate the
	ID cache.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-05-10 11:39:55 +02:00
Dodji Seketeli
ae3c88da13 Remove useless overloads of is_type
Now that there is a is_type predicate that takes a a type_or_decl_base
type, the overloads that take a decl_base or a type_base are useless
and can even lead to overload resolution issues.  This patch removes
those useless overloads.

	* include/abg-fwd.h (is_type):  Remove the overloads that take
	decl_base and type_base types.
	* src/abg-ir.cc (is_type): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-05-10 11:39:19 +02:00
Dodji Seketeli
593a8c1956 Ensure build_qualified_type can return non-qualified types
Const references are a useless redundancy because a reference is
always const.

Thus build_qualified_type can return a non-qualified type when it
figures out the qualifier is useless.

This patch adjusts build_qualified_type to recognize that.  It makes
it return a type_base_sptr rather than a qualified_type_def_sptr.

In build_ir_node_from_die, in the case where we handle qualified
types, the call to build_qualified_type is adjusted accordingly.

	* src/abg-dwarf-reader.cc (build_qualified_type): Return a
	type_base_sptr.
	(build_ir_node_from_die): Adjust the call to build_qualified_type.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-05-10 11:38:59 +02:00
Dodji Seketeli
7ee98c29f4 Fix array subranges (wrongly) having the same lower bound
In some case, some array subranges would all have the same lower
bound.

Fixed thus.

	* src/abg-dwarf-reader.cc (build_subranges_from_array_type_die):
	Consider the 'lower_bound' parameter as the default lower bound
	for each sub-ranges.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-05-10 11:28:34 +02:00
Dodji Seketeli
9fa58eca69 Fix buffer overrun in 'equals' function for arrays
I noticed a buffer overrun in the equals overload for arrays.  This
patch fixes that.

	* src/abg-ir.cc (equals): In the overload for arrays, check for
	the end of the subranges of the two arrays, not just for the first
	one.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-05-10 11:25:37 +02:00
Dodji Seketeli
c022243aac Fix a race condition in queue::priv::do_bring_workers_down
It can happen that queue::priv_::do_bring_workers_down stays forever
waiting for a task to finish (via pthread_join).  The it waits for is
itself blocked in worker::wait_to_execute_a_task, in pthread_cond_wait.

It seems to me that this is because we forget to lock the
queue::priv::queue_cond_mutex before inspecting and updating the
variables on which the wait on the condition depend.

This patch fixes that.

The patch also moves tests/test-read-write.cc over to using the work queue
to increase test coverage for the work queue interface.

	* src/abg-workers.cc (queue::priv::tasks_todo_mutex): Make this
	data member mutable.
	(more_tasks_to_execute):
	(queue::priv::do_bring_workers_down): Update the
	queue::priv::bring_workers_down only in the critical section
	defined by queue::priv::queue_cond_mutex.
	(worker::wait_to_execute_a_task): Testing for
	queue::priv::bring_workers_down is done in the critical section
	defined by queue::priv::queue_cond_mutex.  The loop over waiting
	ont the condition is also in the critical section, as it ought to
	be.
	* tests/test-read-write.cc (struct test_task): New type.
	(main): Express in terms of the new test_task type.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-18 04:21:13 -04:00