Dodji Seketeli [Thu, 5 Jan 2017 23:48:24 +0000 (00:48 +0100)]
Better de-duplicate classes, unions, enums in non-odr contexts
When reading an ELF/DWARF binary that doesn't support the One
Definition Rule[1] (aka ODR), type de-duplication is done on a
per-translation unit basis only. That means that a type definition
must be unique only in a given translation unit, in that case.
[1]: https://en.wikipedia.org/wiki/One_Definition_Rule
When handling big C binaries like the Linux Kernel, this implies a lot
of type duplication still, as the same type can be re-defined in a lot
of different translation units.
This patch tries to de-duplicate types on a per-corpus basis, even in
cases where the ODR doesn't apply. It does so by noting that if two
types of the same kind and name are seen in two different translation
units and yet have the same source location (are defined in the same
spot) then they are the same type.
The patch does this for class, union and enum types as these seem to
be the kinds of types which are duplicated the most and thus consume
the most memory and later take the most time to canonicalize. In a
subsequent patch, we might want to try to de-duplicate typedef types
too, and see if gain anything.
Comparing two linux kernels shows that with this patch, we come back
to a speed (and memory consumption) that is comparable to when we were
considering C-based binaries as being suited to our (too aggressive)
ODR-based type de-duplication algorithm.
Below are the output of the comparison measured with /usr/bin/time
with the aggressive ODR-based type de-duplication algorithm and with
this patch. We compare the vmlinux binary coming from the package
kernel-3.10.0-515 against the one from kernel-3.10.0-327.el7.x86_64.
We use the kabi whitelists provided by the relevant
kernel-abi-whitelists packages for these kernels to restrict the
comparison to a meaningful subset of interfaces.
52.66user 0.64system 0:53.34elapsed 99%CPU (0avgtext+0avgdata 944416maxresident)k 0inputs+48outputs (0major+250750minor)pagefaults 0swaps
vs:
51.04user 0.87system 0:51.91elapsed 100%CPU (0avgtext+0avgdata 972560maxresident)k
0inputs+232outputs (0major+279983minor)pagefaults 0swaps
The full invocation and results are available at:
http://people.redhat.com/~dseketel/kabidiff/vmlinuz-3.10.0-327.el7.x86_64--vmlinuz-3.10.0-515.el7.x86_64.diff.whitelisted.with-unions.txt
vs
http://people.redhat.com/~dseketel/kabidiff/vmlinuz-3.10.0-327.el7.x86_64--vmlinuz-3.10.0-515.el7.x86_64.diff.whitelisted.with-unions.with-non-odr-support.txt
Note that to be able to compare the two kernels, the current tree must
contain the necessary patches that make libabigail understand Linux
Kernel binaries.
* src/abg-dwarf-reader.cc (build_enum_type)
(add_or_update_class_type, add_or_update_union_type): When the ODR
is not relevant, use the location of the type to detect if two
enum, class or union types of the same name actually represent the
same type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 6 Jan 2017 00:41:09 +0000 (01:41 +0100)]
Adjust some reference outputs of the test-read-dwarf test harness
* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Ondrej Oprala [Tue, 3 Jan 2017 23:03:08 +0000 (00:03 +0100)]
Bug 18754 - Add the "--no-added-syms" option to abidiff
With this option, abidiff is now able to filter out added
symbols just like abipkgdiff is.
* doc/manuals/abidiff.rst: Document the new --no-added-syms
option.
* tools/abidiff.cc (struct options): Add show_added_syms and
set it to true by default.
(display_usage): Document the new options --no-added-syms. If
this is the only suppression option specified, it is equivalent
to specifying --show_{changed,deleted}_{fns,vars} as arguments
to abidiff. If any of those options are specified before
--no-added-syms, then it has no effect.
(parse_command_line): Parse the new option and set
show_added_{fns,vars,syms} and show_all_{fns,vars} to false if
--no-added-syms is specified.
* tests/test-diff-filter.cc: Add a test for the new option.
* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt:
Reference results for the new test.
* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-1.txt:
Likewise.
* tests/data/Makefile.am: Add the above test files to the list of
test data.
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 5 Jan 2017 10:22:51 +0000 (11:22 +0100)]
Update copyright year on a bunch of files
* include/abg-corpus.h: Update copyright year to 2017.
* src/abg-dwarf-reader.cc: Likewise.
* src/abg-ir.cc: Likewise.
* src/abg-reader.cc: Likewise.
* src/abg-writer.cc: Likewise.
* tools/abicompat.cc: Likewise.
* tools/abidw.cc: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 5 Jan 2017 10:21:14 +0000 (11:21 +0100)]
[apidoc] Allow brief description at the top of class description pages
* doc/api/libabigail.doxy: Don't disable "brief member desc".
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 5 Jan 2017 09:58:14 +0000 (10:58 +0100)]
Misc style fixes
* include/abg-corpus.h: Remove corpus_sptr typedef. It's in
abg-fwd.h now.
* src/abg-ir.cc: Remove some unnecessary vertical space.
* src/abg-reader.cc (build_function_decl): Cleanup some asserts.
* src/abg-writer.cc (write_function_type): Each the inspection of
the type id from within the debugger.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 5 Jan 2017 09:50:45 +0000 (10:50 +0100)]
Misc comments and apidoc fixes
* src/abg-dwarf-reader.cc (lookup_symbol_from_gnu_hash_tab): Fix
typo in comment.
* tools/abicompat.cc (perform_compat_check_in_weak_mode): Better
comments.
* tools/abidw.cc (dislay_usage): Fix white spaces.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Conflicts:
tools/abidw.cc
Dodji Seketeli [Wed, 4 Jan 2017 23:57:10 +0000 (00:57 +0100)]
Speedup set_member_is_static
set_member_is_static dominates some performance profile because that
function compares data members before their types are canonicalizing.
This means the comparison is done structurally. So it's potentially
super long.
This patch fixes the issue by comparing data members by just looking at
their names, and that should be enough.
* src/abg-ir.cc (set_member_is_static): When comparing data
members, consider only their names.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 4 Jan 2017 23:50:34 +0000 (00:50 +0100)]
Avoid unnecessary updates to type lookup maps
In class_or_union::set_is_declaration_only we should update the type
lookup maps only when a class type that was previously a
declaration-only type is now a defined type. Otherwise, updating the type
lookup maps is unnecessary and profiling shows that it takes a
significant amount of time.
This patch does away with the unnecessary attempts to update type
lookup maps.
* src/abg-ir.cc (class_or_union::get_is_declaration_only): Try
to update the type maps only when a declaration-only class
type is now defined.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 5 Jan 2017 11:39:41 +0000 (12:39 +0100)]
Update tests/data/test-read-dwarf/*.abi files
After the preceding patch series to handle ABI corpora in which the
ODR is not applicable (and the inevitable fallouts) this patch updates
the reference output for the test-read-dwarf test harness.
* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise.
* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise.
* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise.
* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Likewise.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 5 Jan 2017 11:35:18 +0000 (12:35 +0100)]
Update tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi
After the preceding patch series to handle ABI corpora in which the
ODR is not applicable (and the inevitable fallouts) this patch updates
the reference output for the test-diff-dwarf-abixml test harness.
* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi:
Update.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 5 Jan 2017 09:32:48 +0000 (10:32 +0100)]
[abixml writer] Make sure all function types are emitted
The abixml writer forgets to emit some function types that are only
referenced by other types. Fixed thus.
Note that the necessary adjustment to reference outputs of abidw in
the regression test suite is not provided with this patch to ease
backporting. Those adjustments are in a patch that comes at the end
of this patch series.
* src/abg-writer.cc (write_translation_unit): Fix logic to avoid
forgetting referenced function types.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 5 Jan 2017 08:55:13 +0000 (09:55 +0100)]
[abixml writer] Fix comparison of pointer to types
When two type pointers designate two types with the same pretty
printed representatin don't already have an associated type id, the
comparison code was mistakenly associating them with empty type id.
This patch fixes that.
Note that the necessary adjustment to reference outputs of abidw in
the regression test suite is not provided with this patch to ease
backporting. Those adjustments are in a patch that comes at the end
of this patch series.
* src/abg-writer.cc (type_ptr_comp::operator()): Do not add an
empty type id string to the type -> type id map when the entry for
a given type is empty.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 5 Jan 2017 00:05:04 +0000 (01:05 +0100)]
[dwarf-reader] Don't early canonicalize function types
Make sure we don't early-canonicalize function types. We need to wait
after the end of building the ABI corpus before canonicalizing these.
Normally this should be taken care of by using
type_has_non_canonicalized_subtype but there are cases where that
function does not detect that a type has sub-types that are not
canonicalized.
Fixed thus.
* src/abg-dwarf-reader.cc (maybe_canonicalize_type):
Late-canonicalize function types.
signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 4 Jan 2017 23:15:40 +0000 (00:15 +0100)]
Fix qualified name caching for some types
When ::get_qualified_name() is invoked for some types, the value is
cached for performance reasons.
One thing to keep in mind is that the structure of a type can change
between the time when the type is first built and the time when it's
canonicalized. This is because the type can be built progressively,
with sub-types being added over time until the type is fully built.
Then it can be canonicalized.
So if ::get_qualified_name is invoked on a non-canonicalized type and
the result is cached, then that result might not reflect the state of
the type *after* its canonicalized. So the cached value might be
wrong.
To address that issue, the solution is to *not* cache the result of
::get_qualified_name() until the type is canonicalized. After the
type is canonicalized and so we know the structur of the type won't
change, then the result of ::get_qualified_name is cached.
And this is what this patch does for qualified, pointer and array
types.
Note that the necessary update to the regression test suite is not
provided with this patch. It's provided by a separate patch at the
end of the current series of patches.
* src/abg-ir.cc ({qualified, pointer,
array}_type_def::get_qualified_name): Don't cache internal and
non-internal qualified name when the type is not canonicalized.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 4 Jan 2017 22:54:16 +0000 (23:54 +0100)]
Cleanup ODR-based type canonicalization optimization gating logic
During type canonicalization we use an ODR-based optimization which
consists of saying that if two types of the same kind have the same
name and are defined in the same ABI corpus, then they are the same
type -- whithout needing to actually perform a structural comparison
of both types. This speeds up type canonicalization greatly for types
that are duplicated in the ABI corpus.
The condition to apply that ODR-based optimization is basically that
the binary we are looking at must be in C++.
This patch just makes that condition clearer.
* src/abg-ir.cc (type_base::get_canonical_type_for): Make it clear
that the ODR-based optimization is allowed only on C++ ABI
corpora.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 4 Jan 2017 16:03:27 +0000 (17:03 +0100)]
Fix a typo in method name computation
It turns out we forget a "return" keyword when we want to return the
name of a method. Ooops.
Fixed thus.
Please note that this patch doesn't come with its necessary update to
the tests/data/test-read-dwarf/test9-pr18818-clang.so.abi and
tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi
files. Those updates to regression tests are coming in a subsequent
patch.
* src/abg-ir.cc (get_method_type_name): Really return the method
name.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 5 Jan 2017 10:31:07 +0000 (11:31 +0100)]
Update 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
After the preceding patch series to handle ABI corpora in which the
ODR is not applicable (and the inevitable fallouts) this patch updates
the reference output for the test-diff-pkg test harness.
* 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.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 5 Jan 2017 11:03:35 +0000 (12:03 +0100)]
Update tests/data/test-read-write/test27.xml
After the preceding patch series to handle ABI corpora in which the
ODR is not applicable (and the inevitable fallouts) this patch updates
the reference output for the test-read-write test harness.
* tests/data/test-read-write/test27.xml: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 4 Jan 2017 09:50:52 +0000 (10:50 +0100)]
[dwarf-reader] Handle per translation-unit type de-duplication
Until now, when the elf/dwarf reader builds ABI artifacts, it performs
type de-duplication by considering that a type with a given name should
be defined only once in a given ABI corpus. This is per-corpus
de-duplication.
The problem with that approach is that it assumes that the binary
respects the One Definition Rule[1], aka ODR. But then many non-C++
binaries don't respect the ODR.
So, for non-c++ binaries, we shouldn't assume the ODR. We should be
able to assume a per translation unit (aka per-tu) de-duplication.
That is, consider that a type with a given name is defined just once
in a given translation unit. Or perform no de-deplication at all,
depending on the kind of type we are looking at.
And this is what this patch does. It allows the ELF/DWARF reader to
perform per-tu type de-duplication by assuming that it's only in a given
translation unit that a type definition must be unique. It also allows it
perform no de-duplication at all for some kind of types.
In practice, function types are de-duplicated on a per-tu basis if ODR
is not relevant, otherwise, they are de-duplicated on a per-corpus
basis when ODR is relevant.
For most of the other types, if ODR is not relevant, then no
de-duplication is performed at all. Otherwise, for these types, if
ODR is relevant, per-corpus de-duplication is performed.
* src/abg-dwarf-reader.cc
(read_context::per_tu_name_artefacts_map_): New data member.
(read_context::clear_per_translation_unit_data): Clear the new
read_context::per_tu_name_artefacts_map_.
(read_context::associate_die_to_decl): Take a flag to say if we
should associate a DIE to its representation and another one to
say if the association should be done per-tu or per-corpus.
(read_context::lookup_{type_artifact, artifact}_from_die): Update
apidoc.
(read_context::lookup_artifact_from_die_representation): Likewise.
(read_context::{associate_die_to_artifact_by_repr,
associate_die_to_artifact_by_repr_internal,
associate_die_to_type}): Take a flag to say if the associating
should be done on a per-tu basis.
(read_context::lookup_{type_artifact, artifact}_from_die_per_tu):
New member functions.
(read_context::{lookup_artifact_from_per_tu_die_representation,
odr_is_relevant}): Likewise.
(build_enum_type, add_or_update_class_type)
(add_or_update_union_type): If ODR is not relevant, do not perform
per-corpus de-duplication.
(build_pointer_type_def, build_typedef_type): Do not associate the
type to its representation as these kinds of typs are not
de-duplicated.
(build_function_type): If ODR is not relevant, perform per-tu
de-duplication. When ODR is relevant, per-corpus de-duplication
is performed.
(build_or_get_fn_decl_if_not_suppressed): Function decls are
always de-duplicated per-corpus.
(build_ir_node_from_die): For data members, do not update the die
representation map as data members are not de-duplicated. Do not
do it for function decls either.
[1]: https://en.wikipedia.org/wiki/One_Definition_Rule
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 2 Jan 2017 21:40:39 +0000 (22:40 +0100)]
Handle per translation unit and per corpus types maps
Today, whenever a type is added to its scope, a map that associates
the qualified type name to the type is updated. There is only one
such map in a given ABI corpus.
So whenever a type is looked up from its name, it's that per-corpus
type map that is used.
This setup makes libabigail type lookup be tailored only for binaries
that respect the One Definition Rule of C++[1] (aka ODR) which
basically says that there should be only one type of a given name in
an ABI corpus.
It turns out that many binaries, especically C binaries, don't respect
the ODR. So a type "struct foo" can be defined in a file a.c and
another *different* type "struct foo" can also be defined in b.c.
What a useful and safe feature! Not.
For those binaries, just having one type map doesn't work. We need to
have one type map per translation unit, and one map per-corpus map.
This is the strategy implemented by this patch.
With this patch, whenever a type is added to its scope, a
per translation unit type map is updated. The per corpus map is
updated as well. If there are more than one type of a given name, the
entry in the per corpus type map for that type is left empty.
Type lookup now potentially becomes a two phases lookup. Whenever a
type is looked up from its name, the per corpus type map is looked at
first. If the type is not in that per corpus type map, then the per
translation unit type maps are lookup up, in sequence.
The patch thus re-visits the type maps updating and lookup routines to
adapt them to the new scheme. The patch also updates the clients of
the type map updating and lookup code.
Note that this patch is part of a series of patches which aims to move
libabigails away from its ODR-centric organization to make it work
well also on binary where the ODR is not relevant. As such, the patch
doesn't assure that "make check" passes. To have "make check" pass,
you need to have all the patches of the series applied.
[1]: https://en.wikipedia.org/wiki/One_Definition_Rule
* include/abg-fwd.h (lookup_type_in_corpus): Remove. This is to
be replaced by the new lookup_type below.
(lookup_{basic, class, union, enum, typedef, qualified, pointer,
reference, array, function, class_or_typedef,
class_typedef_or_enum}_type):
(lookup_class_type_through_scopes, lookup_type)
(lookup_type_through_scopes, lookup_or_synthesize_fn_type)
* src/abg-ir-priv.h (struct translation_unit::priv): Move this
private type here, from abg-ir.h.
(synthesize_type_from_translation_unit): Declare new functions.
* include/abg-ir.h (class type_maps): Define new type.
(translation_unit::get_function_types): Remove.
(translation_unit::get_types): Now return a type_maps.
(translation_unit::get_live_fn_types): Declare new type.
(class decl_base): Make canonicalize be a friend of this class.
* src/abg-ir.cc (struct translation_unit::priv): Move this to
abg-ir-priv.h
(struct type_maps::priv): Define new type.
(type_maps::{basic, class, union, enum, typedef, qualified,
pointer, reference, array, function}_types): Define new accessors.
(translation_unit::bind_function_type_life_time): Adjust.
(translation_unit::get_function_types): Remove accessor.
(translation_unit::get_types, get_live_fn_types): Define new
accessors.
(lookup_type_in_translation_unit)
(lookup_class_type_in_translation_unit)
(lookup_function_type_in_translation_unit)
(synthesize_type_from_translation_unit)
(synthesize_function_type_from_translation_unit)
(lookup_class_type_in_translation_unit) Remove function
definitions.
(lookup_type_in_map): Define function template.
(lookup_{basic, class, union, typedef, class_or_typedef,
class_typedef_or_enum, qualified, pointer, reference, array,
function}_type): Define functions.
(lookup_function_type, lookup_type_through_scopes)
(lookup_class_type_through_scopes)
(lookup_basic_type_through_translation_units)
(lookup_union_type_through_translation_units)
(lookup_enum_type_through_translation_units)
(lookup_class_type_through_translation_units)
(lookup_typedef_type_through_translation_units)
(lookup_qualified_type_through_translation_units)
(lookup_pointer_type_through_translation_units)
(lookup_reference_type_through_translation_units)
(lookup_array_type_through_translation_units)
(lookup_function_type_through_translation_units)
(lookup_type_through_translation_units)
(lookup_or_synthesize_fn_type, lookup_type): Likewise.
(maybe_update_types_lookup_map)
(maybe_update_types_lookup_map<class_decl>)
(maybe_update_types_lookup_map<function_type>): Define function
template, specilizations and functions.
(synthesize_type_from_translation_unit)
(synthesize_function_type_from_translation_unit): Define
functions.
* include/abg-corpus.h (corpus::get_types): Declare new accessor.
* src/abg-corpus.cc (corpus::priv::get_types): Define new
accessor.
(corpus::get_types): Likewise.
(lookup_type_in_corpus, lookup_class_type_in_corpus)
(lookup_type_in_corpus, lookup_function_type_in_corpus)
(maybe_update_types_lookup_map)
(maybe_update_types_lookup_map<class_decl>)
(maybe_update_types_lookup_map<function_type>): Remove.
(lookup_{basic, class, union, enum, typedef, qualified, pointer,
reference, array, function, class_or_typedef,
class_typedef_or_enum}_type): Likewise.
* src/abg-corpus-priv.h (corpus::priv::{basic, class, union,
typedef, qualified, pointer, reference, array, function}_types):
Remove these data members.
(corpus::priv::get_scopes): Remove member function.
(corpus::priv::get_{basic, class, union, enum, typedef, qualified,
pointer, reference, array, function}_types): Remove member
function declarations.
(corpus::priv::types_): New data member.
(corpus::priv::get_types): Declare new member function.
(lookup_{basic, class, enum, typedef, class_or_typedef, qualified,
pointer, reference, array, function}_type): Declare new functions.
* src/abg-dwarf-reader.cc
(read_context::resolve_declaration_only_classes)
(build_translation_unit_and_add_to_ir): Adjust use of
lookup_class_type.
* src/abg-reader.cc (read_context::type_is_from_translation_unit):
Adjust to the use of lookup_function_type_in_translation_unit that
got renamed into lookup_function_type.
* src/abg-writer.cc (type_ptr_cmp::operator()): New operator
implementation.
(read_context::sort_type): Add new overloads.
(write_translation_unit): Adjust to get the function types from
the new translation_unit::get_live_fn_types and sort them.
* tools/abicompat.cc (perform_compat_check_in_weak_mode): Adjust
to use the new lookup_or_synthesize_fn_type, in lieu of
lookup_function_type_in_corpus. Adjust to use lookup_type in lieu
of lookup_type_in_corpus.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 21 Dec 2016 19:50:08 +0000 (20:50 +0100)]
Make abg-fwd.h use *_sptr typedefs
Until now, the abg-fwd.h where the necessary forward generic
declarations where put didn't contain the convenience typedefs of the
form foo_sptr that designate a shared pointer to type foo.
This patch moves these convenience typedefs as well as the missing
forward declarations from abg-ir.h to abg-fwd.h. The patch also
adjusts the function declarations in abg-fwd.h to make them use these
convenience typedefs.
* include/abg-ir.h: Move convience typedef declarations and some
necessary forward declarations to ...
* include/abg-fwd.h: ... here.
(is_enum_type, is_var_decl): Take a pointer to type_or_decl_base.
(lookup_type_in_scope): Return a type_base_sptr.
(lookup_type_through_scopes): Introduce this to later replace the
overload of lookup_type_in_translation_unit that takes a list of
strings.
(lookup_type_in_scope): Return a type_base_sptr, not a
decl_base_sptr.
* src/abg-ir.cc (lookup_type_in_scope, lookup_node_in_scope)
(lookup_var_decl_in_scope): Adjust.
(is_enum_type, is_var_decl): Take a pointer to type_or_decl_base.
(lookup_node_in_scope): Return a type_or_decl_base_sptr.
(lookup_type_in_scope): Return a type_base_sptr.
(lookup_node_in_translation_unit): Return a
type_or_decl_base_sptr.
(lookup_type_through_scopes): Replace
lookup_type_in_translation_unit.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Chenxiong Qi [Sun, 18 Dec 2016 15:43:24 +0000 (23:43 +0800)]
Fix wrong variable name
* tools/fedabipkgdiff: (diff_latest_rpms_based_on_distros): Fix
wrong variable name distro.
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Chenxiong Qi [Sun, 18 Dec 2016 15:12:51 +0000 (23:12 +0800)]
Warn properly when cannot find peer RPM
* tools/fedabipkgdiff: (RPMCollection.get_peer_rpm): Return None
when cannot find peer RPM due to nonexistent arch.
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Chenxiong Qi [Mon, 19 Dec 2016 11:09:53 +0000 (12:09 +0100)]
Read Koji config via Koji API
Besides reading Koji config via Koji API read_config, option --topdir is
also renamed to --topurl that is the correct one should be used.
* tools/fedabipkgdiff: Read DEFAULT_KOJI_TOPURL and
DEFAULT_KOJI_SERVER from Koji config via Koji API read_config.
(build_commandline_args_parser): --topdir is renamed to
--topurl.
* doc/manuals/fedabipkgdiff.rst: Rename --topdir to --topurl.
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Chenxiong Qi [Mon, 19 Dec 2016 11:07:12 +0000 (12:07 +0100)]
Follow moved packages when download
This patch makes fedabipkgdiff able to follow the new place to download
packages.
* tools/fedabipkgdiff: (download_rpm) Add --location to curl
CLI.
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Chenxiong Qi [Tue, 13 Dec 2016 06:06:21 +0000 (14:06 +0800)]
More document for local RPMs comparison
* doc/manuals/fedabipkgdiff.rst: Add more document for local RPMs
comparison. Also fixed a typo.
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Ondrej Oprala [Thu, 15 Dec 2016 19:15:38 +0000 (20:15 +0100)]
Properly report missing files for abipkgdiff
Currently, if abipkgdiff is given a path to a nonexistent file,
it propagates all the way until package classification
and ends up being reported as "PKG should be a valid package file",
which doesn't hint it's not there at all.
* tools/abipkgdiff.cc: (class options): Add the "nonexistent_file" flag
(parse_command_line): Check if the files given exist.
(main): Check the nonexistent_file flag. If any of the input
files don't exist, report it and exit. Also, for present and future test
uniformity, only show the base names of the packages when using their
names in error output.
* tests/test-diff-pkg.cc: Add a new regression test.
* tests/data/test-diff-pkg/test-nonexistent-report-0.txt: The
expected output of the above regression test.
* tests/data/Makefile.am: Add the above file to the list.
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Dodji Seketeli [Thu, 15 Dec 2016 14:06:51 +0000 (15:06 +0100)]
Misc style cleanup
* src/abg-dwarf-reader.cc (build_function_type): Remove
unnecessary new line.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 15 Dec 2016 14:09:35 +0000 (15:09 +0100)]
make is_anonymous_type work for unions and classes
* src/abg-ir.cc (is_anonymous_type): Make this work for class or
union types, no only classes.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 15 Dec 2016 13:29:38 +0000 (14:29 +0100)]
Naming typedefs of classes are not read properly from abixml
When loading a class from abixml and when that class has a naming
typedef, build_class_decl fails to build the naming typedef from its
ID because it calls read_context::get_type_decl() instead of
read_context::build_or_get_type_decl().
This patch fixes that issue by using
read_context::build_or_get_type_decl rather than
read_context::get_type_decl.
Also, as read_context::build_or_get_type_decl can trigger the creation
of a class (and recursively call build_class_decl), it needs to be
called after the class type being built is marked as work-in-progress
(aka WIP). So the handling of the naming typedef is moved to after
the class type being built is marked as WIP.
* src/abg-reader.cc (build_class_decl): Use
read_context::build_or_get_type_decl rather than
read_context::get_type_decl to build the naming typedef referred
to by the class being built. Move the handling of naming typedefs
after the class is marked as WIP and keyed.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 15 Dec 2016 13:12:57 +0000 (14:12 +0100)]
Don't early-canonicalize function types when reading abixml
When reading from an abixml file, we sometimes canonicalize function
types before the entire abixml file is read. This can lead to, e.g, a
function type that is not yet fully built being canonicalized too
early and so its canonical type being wrong because it reflects the
state of the function type at canonicalization time -- but then that
state changed later.
This patch fixes that by forcing us to late-canonicalize function
types, just like we do for all aggregate types.
* src/abg-reader.cc (read_context::maybe_canonicalize_type):
late-canonicalize function types too.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Ondrej Oprala [Mon, 12 Dec 2016 15:37:54 +0000 (16:37 +0100)]
Check --enable-rpm dependencies more rigorously
If a user has explicitly specified --enable-rpm when running
"configure", it will now fail unless both rpm2cpio and cpio
are present on the system.
* configure.ac: Check if both rpm2cpio and cpio
exist on the system. If not, disable the option and fail the
configuration if --enable-rpm was specified explicitly.
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Ondrej Oprala [Mon, 12 Dec 2016 15:08:01 +0000 (16:08 +0100)]
abipkgdiff doesn't mention --no-default-suppression in help
* tools/abipkgdiff.cc (display_usage): Mention
--no-default-suppression as one of the options.
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Ondrej Oprala [Mon, 12 Dec 2016 14:44:29 +0000 (15:44 +0100)]
Fix a few remarks made by cppcheck
* src/abg-comparison.cc (types_or_decls_equal::operator()): Pass
arguments by reference.
(class_diff::ensure_lookup_tables_populated): Expression
!A || (A && B) can be reduced to !A || B.
* src/abg-suppression.cc (suppression_matches_type_no_name):
Likewise.
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Ondrej Oprala [Fri, 9 Dec 2016 22:01:58 +0000 (23:01 +0100)]
Bug 19272 - abipkgdiff doesn't report arch change
Previously, architecture change wasn't included in the incompatible
changes check.
This patch makes corpus_diff::has_incompatible_changes take
architecture change into account.
It turns out corpus_diff::has_net_changes wasn't taking architecture
or soname change into account either. This patch fixes that as well.
The patch also updates abicompat.cc to make it use
corpus_diff::has_net_changes() and
corpus_diff::has_incompatible_changes(), instead of open-coding these
member functions.
* src/abg-comparison.cc (corpus_diff::has_incompatible_changes):
The architecture change into account.
(corpus_diff::has_net_changes): Take architecture and soname
changes into account.
* tools/abicompat.cc (perform_compat_check_in_normal_mode): Use
corpus_diff::{has_net_changes, has_incompatible_changes}.
* tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.armv7hl.rpm: New
test input.
* tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt:
New test reference output.
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-diff-pkg.cc (in_out_spec): Compare the new package
above against an x86_64 one.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Chenxiong Qi [Thu, 11 Aug 2016 13:48:00 +0000 (21:48 +0800)]
Bug 20380 - Compare two local RPMs
Bug 20270 is also fixed.
This patch allows developer to compare two local RPMs in form
fedabipkgdiff some/place/foo.rpm another/place/bar.rpm
But, network is still needed to talk with Koji.
This patch also introduces new terms for libabigail, that is the
subject, ancillary package, and comparison half. Subject represents a
package that is subject of the ABI comparison, a subject could be a RPM
and maybe it would be a DEB or some other kind of "package". A subject
may have several ancillary packages that are used to compare the
subject. Generally, a subject may have devel, debuginfo, or both.
* configure.ac: add dependent mimetype module.
* doc/manuals/fedabipkgdiff.rst: Update to add document for the
new use case of comparing two local RPMs.
* tests/data/Makefile.am: Include new RPMs for tests.
* tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.100.2-2.fc20.x86_64.rpm:
New RPM for running test.
* tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.106-1.fc23.x86_64.rpm:
Likewise.
* tests/data/test-fedabipkgdiff/nss-util/nss-util-3.12.6-1.fc14.x86_64.rpm:
Likewise.
* tests/data/test-fedabipkgdiff/nss-util/nss-util-3.24.0-2.0.fc25.x86_64.rpm:
Likewise.
* tests/data/test-fedabipkgdiff/nss-util/nss-util-devel-3.24.0-2.0.fc25.x86_64.rpm:
Likewise.
* tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt:
Rename filename by adding .rpm extension.
* tests/data/test-fedabipkgdiff/test5-same-dir-dbus-glib-0.100.2-2.fc20.x86_64--dbus-glib-0.106-1.fc23.x86_64-report-0.txt:
New reference output for testing comparing local RPMs.
* tests/data/test-fedabipkgdiff/test6-missing-devel-debuginfo-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt:
New reference output for testing comparison without non-existent
debuginfo or development package.
* tests/runtestfedabipkgdiff.py.in (FEDABIPKGDIFF_TEST_SPECS):
Rename filename for test4. Add two new test cases.
(run_fedabipkgdiff_tests): Remove semicolon and trailing
whitespaces.
(main): Likewise.
(ensure_output_dir_created): Likewise.
* tools/fedabipkgdiff: Require some new modules.
Fix of return code.
(PkgInfo): Renamed to ComparisonHalf.
(match_nvr): New method to determine if a string matches format
of N-V-R.
(match_nvra): New method to determine if a string matches format
of N-V-R.A.
(is_rpm_file): New method to guess if a file is a RPM file.
(RPM.is_peer): New method to determine if current RPM is a peer
of another.
(RPM.filename): Use Koji module API to construct the filename.
(RPM.nvra): Get nvra from filename instead of constructing
manually that is duplicated with Koji module API.
(RPMCollection): New class to represent a set of RPMs.
(generate_pkg_info_pair_for_abipkgdiff): New method working as a
generator to yeild comparison halves for running abipkgdiff.
(Brew.getRPM): Fix string format with incorrect argument.
(Brew.select_rpms_from_a_build): Return instance of
RPMCollection.
(abipkgdiff): If there is no debuginfo or development package,
just ignore it and leave a warning. If --error-on-warning is
specified, raise an exception instead. Arguments are modified
to represent the new name ComparisonHalf, and relative docstring
is also updated.
(magic_construct): Removed.
(run_abipkgdiff): Rewrite.
(make_rpms_usable_for_abipkgdiff): Removed.
(diff_local_rpm_with_latest_rpm_from_koji): Rewrite by using
RPMCollection.
(diff_latest_rpms_based_on_distros): Likewise.
(diff_two_nvras_from_koji): Likewise.
(diff_from_two_rpm_files): New method to compare two local RPMs.
(build_commandline_args_parser): Add new option
--error-on-warning.
(main): Add support to compare local RPMs.
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 12 Dec 2016 11:14:21 +0000 (12:14 +0100)]
Fix template_decl::hash::operator()
While hashing template_decl we inadvertently forget the contribution
of the name of the type to the hash.
This was spotted by Ondrej Oprala.
Fixed thus.
* src/abg-hash.cc (template_decl::hash::operator()): Combine the
contribution of the qualified name to the contribution of the type
name to the hash.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 8 Dec 2016 23:37:43 +0000 (00:37 +0100)]
Fix aborting when reading .foo symbols from a ppc64 binary
On ppc64, the value of a function symbol is *usually* the pointer to
the function. That function pointer value refers to an index inside
the ".opd" (Official Procedure Descriptor) section. That section is a
record of tripplets values. One of these values is the address of the
entry point of the function. A debug information entry for a
function, in DWARF, refers to the entry point of the function; not to
the function pointer address.
So libabigail builds a table that associates a function entry point
address to its function pointer address.
So, if a function is named "foo", it has an entry in the symbol table
for the symbol name "foo"; the value of that symbol is the function
pointer address of foo, which refers to an offset in the ".opd"
section.
But then it turns out that there is also going to be an entry in the
symbol table for an artificial symbol named ".foo". Pleast note the
dot before the suffix "foo". The value of the ".foo" symbol is the
address of the entry point of the function "foo"; it's an address in
the ".text" section this time.
Libabigail's ELF symbols reading code was (wrongly) expecting all
entries in the symbol table that refer to function to have values that
are offset in the ".opd" section. It wasn't expecting the ".foo"
symbols whose value are an address in the ".text" section.
This patch fixes the ELF symbol reading code to make it be aware of
the ".foo" symbols too.
* abg-dwarf-reader.cc (read_context::find_opd_section): Fix
comment.
(read_context::load_symbol_maps): If for a given function entry
point (that we got by looking at the ".opd" section for a given
function pointer value) we already had an entry in the
function_entry_address -> symbol, maybe it means that the previous
entry that we had was from an entry in the symbol table which
value was directly the entry point address of a function. In that
case, if the name of the symbol is "foo", the name of the symbol
which value is directly the entry point address is ".foo". What
we do in this case is that we just keep the reference to the "foo"
symbol in the function_entry_address -> symbol map.
(read_context::address_is_in_opd_section): Define new member
function.
* tests/data/test-diff-pkg/gmp-4.3.1-10.el6.ppc64.rpm: New test input.
* tests/data/test-diff-pkg/gmp-4.3.1-7.el6_2.2.ppc64.rpm: Likewise.
* tests/data/test-diff-pkg/gmp-debuginfo-4.3.1-10.el6.ppc64.rpm: Likewise.
* tests/data/test-diff-pkg/gmp-debuginfo-4.3.1-7.el6_2.2.ppc64.rpm: Likewise.
* tests/data/test-diff-pkg/gmp-4.3.1-7.el6_2.2.ppc64--gmp-4.3.1-10.el6.ppc64-report-0.txt:
New test reference output.
* tests/data/Makefile.am: Add the new test input and reference
output to source distribution.
* tests/test-diff-pkg.cc (in_out_specs): Add the new test inputs
and reference output to the set of inputs that are compared.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 5 Dec 2016 09:11:19 +0000 (10:11 +0100)]
Bug 20927 - Segfault when $HOME is not set
When comparing two binaries with abi{pkg}diff, if $HOME is not set, we
segfault at some places because we don't expect that. I ran "make
check" after doing "unset HOME" to help me catch most of those places.
This patch updates the code to handle that case.
* src/abg-tools-utils.cc
(get_default_user_suppression_file_path): Handle the case where
the HOME environment variable is not set.
* tools/abipkgdiff.cc (package::extracted_packages_parent_dir):
Likewise. When $HOME is empty set then use $TMPDIR. If it's
empty too then use "/tmp".
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 2 Dec 2016 13:41:07 +0000 (14:41 +0100)]
Bug 20887 - Show relative change of offsets
Until now, an offset change is reported by showing the old and new
offsets of the data member that changed.
This patch adds the string "(by +N bits)" with 'N' being the number of
bits by which the offset of the data member was increased, or "(by -N
bits) if the offset of the data member was decreased of N bits.
The patch also emits a string that says "size hasn't changed" if the
size of the structure did not change.
This can be disabled by a new --no-show-relative-offset-changes
option.
* doc/manuals/abidiff.rst: Document the new
--no-show-relative-offset-changes.
* doc/manuals/abipkgdiff.rst: Likewise.
* include/abg-comparison.h
(diff_context::show_relative_offset_changes): New accessors.
* include/abg-ir.h ({set,get}_data_member_offset): Return uint64_t
instead of the less portable size_t.
* src/abg-comparison.cc
(diff_context::priv::show_relative_offset_changes_): New data
member.
(dif_context::show_relative_offset_changes): Define accessor.
(maybe_show_relative_offset_change): Define new function.
(represent): In the overload for var_diff, call the new
maybe_show_relative_offset_change.
(report_size_and_alignment_changes): If the size of the type
didn't change then say it now.
* src/abg-ir.cc (set_data_member_offset, get_data_member_offset):
Take or return a uint64_t instead of a size_t.
* tools/abidiff.cc (options::show_relative_offset_changes): New
data member.
(options::options): Initialize it.
(display_usage): Display help string for the new
--no-show-relative-offset-changes.
(parse_command_line): Parse the new
--no-show-relative-offset-changes options.
(set_diff_context_from_opts): Set the
"show-relative-offset-changes" flag according to the new option.n
* tools/abipkgdiff.cc (options::show_relative_offset_changes): New
data member.
(options::options): Initialize it.
(display_usage): Add help string for the new
--no-show-relative-offset-changes option.
(set_diff_context_from_opts): Set the
"show-relative-offset-changes" flag according to the new option.
(parse_command_line): Parse the new command line option.
* tests/data/test-diff-dwarf/test40-report-0.txt: Add new
reference output.
* tests/data/test-diff-dwarf/test40-v0.c: Source code of the first
test binary.
* tests/data/test-diff-dwarf/test40-v1.c: Source code of the
second test binay.
* tests/data/test-diff-dwarf/libtest40-v0.so: New first test binary.
* tests/data/test-diff-dwarf/libtest40-v1.so: New second test binary.
* tests/test-diff-dwarf.cc (in_out_spec): Add the new test
binaries above to the set of binaries that are compared.
* tests/data/Makefile.am: Add the new test material to source
distribution.
* tests/data/test-abicompat/test7-fn-changed-report-0.txt: Adjust.
* tests/data/test-abidiff/test-PR18791-report0.txt: Likewise.
* tests/data/test-abidiff/test-enum0-report.txt: Likewise.
* tests/data/test-abidiff/test-enum1-report.txt: Likewise.
* tests/data/test-abidiff/test-struct1-report.txt: Likewise.
* tests/data/test-diff-dwarf/test0-report.txt: Likewise.
* tests/data/test-diff-dwarf/test1-report.txt: Likewise.
* tests/data/test-diff-dwarf/test10-report.txt: Likewise.
* tests/data/test-diff-dwarf/test11-report.txt: Likewise.
* tests/data/test-diff-dwarf/test13-report.txt: Likewise.
* tests/data/test-diff-dwarf/test15-enum-report.txt: Likewise.
* tests/data/test-diff-dwarf/test27-local-base-diff-report.txt: Likewise.
* tests/data/test-diff-dwarf/test32-fnptr-changes-report-0.txt: Likewise.
* tests/data/test-diff-dwarf/test33-fnref-changes-report-0.txt: Likewise.
* tests/data/test-diff-dwarf/test38-union-report-0.txt: Likewise.
* tests/data/test-diff-dwarf/test4-report.txt: Likewise.
* tests/data/test-diff-dwarf/test5-report.txt: Likewise.
* tests/data/test-diff-dwarf/test6-report.txt: Likewise.
* tests/data/test-diff-dwarf/test8-report.txt: Likewise.
* tests/data/test-diff-filter/test0-report.txt: Likewise.
* tests/data/test-diff-filter/test01-report.txt: Likewise.
* tests/data/test-diff-filter/test1-report.txt: Likewise.
* tests/data/test-diff-filter/test13-report.txt: Likewise.
* tests/data/test-diff-filter/test16-report-2.txt: Likewise.
* tests/data/test-diff-filter/test16-report.txt: Likewise.
* tests/data/test-diff-filter/test17-0-report.txt: Likewise.
* tests/data/test-diff-filter/test17-1-report.txt: Likewise.
* tests/data/test-diff-filter/test18-report.txt: Likewise.
* tests/data/test-diff-filter/test19-enum-report-1.txt: Likewise.
* tests/data/test-diff-filter/test2-report.txt: Likewise.
* tests/data/test-diff-filter/test23-redundant-fn-parm-change-report-0.txt:
Likewise.
* tests/data/test-diff-filter/test24-compatible-vars-report-1.txt:
Likewise.
* tests/data/test-diff-filter/test25-cyclic-type-report-0.txt:
Likewise.
* tests/data/test-diff-filter/test25-cyclic-type-report-1.txt:
Likewise.
* tests/data/test-diff-filter/test26-qualified-redundant-node-report-0.t:
Likewise.xt
* tests/data/test-diff-filter/test26-qualified-redundant-node-report-1.txt:
Likewise.
* tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt:
Likewise.
* tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt:
Likewise.
* tests/data/test-diff-filter/test29-finer-redundancy-marking-report-0.txt:
Likewise.
* tests/data/test-diff-filter/test3-report.txt: Likewise.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt:
Likewise.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt:
Likewise.
* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt:
Likewise.
* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt:
Likewise.
* tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt: Likewise.
* tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt: Likewise.
* tests/data/test-diff-pkg/tbb-4.1-9.
20130314.fc22.x86_64--tbb-4.3-3.
20141204.fc23.x86_64-report-0.txt: Likewise.
* tests/data/test-diff-pkg/tbb-4.1-9.
20130314.fc22.x86_64--tbb-4.3-3.
20141204.fc23.x86_64-report-1.txt: Likewise.
* tests/data/test-diff-suppr/test0-type-suppr-report-0.txt: Likewise.
* tests/data/test-diff-suppr/test0-type-suppr-report-3.txt: Likewise.
* tests/data/test-diff-suppr/test0-type-suppr-report-5.txt: Likewise.
* tests/data/test-diff-suppr/test0-type-suppr-report-7.txt: Likewise.
* tests/data/test-diff-suppr/test1-typedef-suppr-report-0.txt: Likewise.
* tests/data/test-diff-suppr/test1-typedef-suppr-report-2.txt: Likewise.
* tests/data/test-diff-suppr/test10-changed-parm-c-report-0.txt: Likewise.
* tests/data/test-diff-suppr/test2-struct-suppr-report-0.txt: Likewise.
* tests/data/test-diff-suppr/test23-alias-filter-report-0.txt: Likewise.
* tests/data/test-diff-suppr/test23-alias-filter-report-2.txt: Likewise.
* tests/data/test-diff-suppr/test3-struct-suppr-report-0.txt: Likewise.
* tests/data/test-diff-suppr/test3-struct-suppr-report-1.txt: Likewise.
* tests/data/test-diff-suppr/test3-struct-suppr-report-2.txt: Likewise.
* tests/data/test-diff-suppr/test30-report-0.txt: Likewise.
* tests/data/test-diff-suppr/test4-local-suppr-report-0.txt: Likewise.
* tests/data/test-diff-suppr/test4-local-suppr-report-1.txt: Likewise.
* tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Likewise.
* tests/data/test-diff-suppr/test5-fn-suppr-report-1.txt: Likewise.
* tests/data/test-diff-suppr/test5-fn-suppr-report-2.txt: Likewise.
* tests/data/test-diff-suppr/test5-fn-suppr-report-3.txt: Likewise.
* tests/data/test-diff-suppr/test5-fn-suppr-report-4.txt: Likewise.
* tests/data/test-diff-suppr/test5-fn-suppr-report-5.txt: Likewise.
* tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise.
* tests/data/test-diff-suppr/test6-fn-suppr-report-0.txt: Likewise.
* tests/data/test-diff-suppr/test6-fn-suppr-report-1.txt: Likewise.
* tests/data/test-diff-suppr/test6-fn-suppr-report-2.txt: Likewise.
* tests/data/test-diff-suppr/test6-fn-suppr-report-3.txt: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-report-0.txt: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-report-1.txt: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-report-2.txt: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-report-3.txt: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-report-4.txt: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-report-7.txt: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-report-8.txt: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 2 Dec 2016 11:54:49 +0000 (12:54 +0100)]
Rename tests/update-test-read-dwarf-output.py
Renamed tests/update-test-read-dwarf-output.py into
tests/update-test-output.py as it can be used for all tests that emit
an output and compare it against a reference output.
* tests/update-test-output.py: renamed
tests/update-test-read-dwarf-output.py into this. Update its
comments. Make this script executable.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 30 Nov 2016 10:01:38 +0000 (11:01 +0100)]
Add tests/data/test-diff-suppr/test33-report-0.txt to tarball
I forgot to add the file testing file
tests/data/test-diff-suppr/test33-report-0.txt to
tests/data/Makefile.am. This makes the test runtestdiffsupp fail
under 'make distcheck'.
Fixed thus.
* tests/data/Makefile.am: Add test-diff-suppr/test33-report-0.txt.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 30 Nov 2016 08:28:34 +0000 (09:28 +0100)]
Bug 20670 - abipkgdiff aborts if $XDG_CACHE_HOME does not exist
This patch creates $XDG_CACHE_HOME if it doesn't exist, rather than
just aborting.
* tools/abipkgdiff.cc (package::extracted_packages_parent_dir):
Ensure that the cache directory is created, even when
XDG_CACHE_HOME is set. Also, remove the now useless "using
abigail::tools_utils::get_random_number_as_string" statement.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 9 Nov 2016 14:10:27 +0000 (15:10 +0100)]
Very light speed improvements
When comparing of two kernel trees showed that for huge changesets
involving highly recursive types, leaf functions used by the
categorization code dominate the performance profile.
This patch introduces some changes that help gain around 30 seconds
(out of 14 minutes) on a non-optimized build, when comparing 4.7 nd
4.8 fedora kernels (between fedora 24 and 26).
* include/abg-comp-filter.h (has_harmless_name_change): Pass smart
pointers by reference.
* src/abg-comp-filter.cc (access_changed)
(function_name_changed_but_not_symbol)
(non_static_data_member_type_size_changed)
(static_data_member_type_size_changed, is_compatible_change)
(decl_name_changed, has_harmless_name_change): Pass smart
pointers by reference.
* include/abg-ir.h (decl_base::set_context_rel): Take a bare
pointer, not a smart pointer.
* src/abg-ir.cc (decl_base::priv::context_): Make this data member
be a naked pointer, not a smart pointer.
(decl_base::priv::priv): Initialize it.
(decl_base::priv::~priv): New constructor.
(decl_base::{get_context_rel, set_scope}): Adjust.
(class_decl::method_decl::{method_decl, set_scope}): Likewise.
(equals): In the overload for var_decl, compare the type of the
var first as that might be faster (to detect var_decls with
different types) in the general case where types are
canonicalized.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 8 Nov 2016 10:48:58 +0000 (11:48 +0100)]
Introduce on-the-fly type canonicalization
During canonicalization of a type T, when T is structurally compared
to an already canonicalized type C, it can happen that
non-canonicalized sub-types of T are structurally compared again and
again to canonicalized sub-types of C.
This patch introduces a new optimization or those cases: on-the-fly
type canonicalized.
That means, if a not-yet-canonicalized sub-type S of the type T being
canonicalized structurally compares equal to a canonicalized sub-type,
then the canonical type of S is said to be the canonical type of the
canonicalized sub-type. So sub-type S is canonicalized, on-the-fly,
during canonicalization of type T.
This considerably speeds up the canonicalization process while doing
"abidiff vmlinux vmlinux". It goes from taking forever to taking 45
seconds on a non-optimized build.
* include/abg-ir.h (environment::do_on_the_fly_canonicalization):
Declare new member functions.
({type_base, function_type}::priv_): Make this public so that
static non-member functions defined in abg-ir.cc can access it.
* src/abg-ir.cc
(environment::priv::do_on_the_fly_canonicalization_): New data
member.
(environment::priv::priv): Initialize it.
(environment::do_on_the_fly_canonicalization): Define new member
functions.
(type_base::get_canonical_type_for): Trigger on-the-fly
canonicalization during comparison of the type being canonicalized
and an already canonicalized type.
(types_are_being_compared, maybe_propagate_canonical_type): Define
new static functions.
(equals): In overloads for class_decl and function_type, call
maybe_propagate_canonical_type when the two types compare equal.
* 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-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Sun, 6 Nov 2016 11:15:41 +0000 (12:15 +0100)]
Fix pretty representation of array types
It turned out we were wrongly emitting the pretty representation of
array types in two cases:
1/ in case of qualified array types: a const array of string type
was being pretty-represented as: "const string[]" instead of
"string[] const".
2/ in case of array with an empty sub-range DIE; that is a sub-range
DIE with no attribute at all. For instance an array of char with an
empty sub-range DIE was being represented as: "char", instead of
"char[]".
This patch fixes 1 and 2. It also updates numerous test reference
output files.
* include/abg-ir.h (array_type_def::is_infinite): Fix indentation.
* src/abg-ir.cc (qualified_type_def::build_name): An empty set of
sub-ranges for a vector is represented by "[]".
(array_type_def::is_infinite): If a vector has no sub-range, that
means it has an infinite size. Adjust comment.
* tests/data/test-diff-filter/test33-report-0.txt: 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/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/test19-pr19023-libtcmalloc_and_profiler.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>
Dodji Seketeli [Tue, 11 Oct 2016 13:06:02 +0000 (15:06 +0200)]
Support naming typedef and use them to speed up type canonicalization
There is a common C idiom in which an anonymous struct is named using
a typedef:
typedef struct {int member;} anonymous_struct_type;
The typedef name "anonymous_struct_type" becomes the name of the
otherwise anonymous struct. That is what a naming typedef is.
So, the nice thing about naming typedefs is that an anonymous class
type suddenly becomes non anymous. So that type becomes eligible to
the ODR-based optimization during type canonicalization. That speeds
up type canonicalization, at least for 'abidw'.
This patch represents naming typedefs for class_decl types in the
internal representation. The patch also changes the meaning of an
anonymous class. Whenever such a class becomes named by a typedef,
the class is not considered anonymous anymore, at least for the
purpose of type canonicalization.
* include/abg-ir.h (typedef_decl_wptr): New typedef.
(class_decl::{g,s}et_naming_typedef): Declare new member
functions.
* src/abg-dwarf-reader.cc (build_typedef_type): When the
underlying type of a typedef is an anonymous class, the class type
is said to have a naming typedef.
* src/abg-ir.cc (is_anonymous_type): An anonymous class that has
a naming typedef is said to not be anonymous anymore.
(class_decl::priv::naming_typedef): New data member.
(class_decl::{g,s}et_naming_typedef): Define new member functions.
(class_decl::get_pretty_representation): When called for internal
purposes (e.g, for type canonicalization) compute the pretty
representation of the class by using its typedef name, when class
is anonymous and has a naming typedef.
* src/abg-reader.cc (build_class_decl): Read the new
"naming-typedef-id" attribute.
* src/abg-writer.cc (write_naming_typedef): New function.
(write_class_decl_opening_tag): Use the new write_naming_typedef
function.
* tests/data/test-read-dwarf/libtest23.so.abi: Adjust.
* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
Likewise.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 2 Nov 2016 11:33:35 +0000 (12:33 +0100)]
Implement de-duplication for types and decls at DWARF loading time
Many types and decls are redefined in every translation unit that make
up an ELF binary. This patch detects that a DIE represents a type or
decl that has already been defined in the current corpus and so will
not create a new internal representation for it.
The patch defines facilities to build the pretty representation of a
type or decl. It's by looking at the pretty representation of a DIE
that the patch detects that a different DIE has already defined the
same type or decl.
The patch also fixes detection of the const-ness of member functions
as there were many cases where const member functions were not
recognized as const. This fix makes it so that the pretty
representation of the DIE of said member functions match the pretty
representation of their internal representation, as far as the
const-ness is concerned.
One bit of infrastructure change that is used by the const-ness fix is
that method_type now carries const-ness. So a method_decl that has a
const method_type is going to be const itself.
* include/abg-ir.h (method_type::priv_): Introduce new pimpl
pointer here.
(method_type::class_type_): Move this into the pimpl idiom.
(method_type::method_type): Take a new is_const flag.
(method_type::get_class_type): Make this method out-of-line.
(method_type::{s,g}et_is_const): Declare new member functions.
(get_method_type_name): Declare this function as a friend of
the method_type type.
* src/abg-dwarf-reader.cc: Include the new abg-ir-priv.h and
abg-corpus-priv.h.
(typedef die_tu_map_type): Fix comment.
(typedef die_istring_map_type): New typedef.
(class read_context::die_source_dependant_container_set): New
class template.
(read_context::{die_qualified_name_maps_, die_pretty_repr_maps_,
die_pretty_type_repr_maps_}): Define new data members.
(read_context::{get_die_qualified_name, get_die_qualified_name,
get_die_qualified_type_name, get_die_pretty_type_representation,
get_die_pretty_representation, lookup_type_artifact_from_die,
lookup_artifact_from_die, lookup_artifact_from_die_representation,
associate_die_to_artifact_by_repr,
associate_die_to_artifact_by_repr_internal,
lookup_type_from_die}): Define new member functions.
(read_context::lookup_type_from_die_offset): Fix comment.
(get_parent_die, get_scope_die, die_is_decl)
(die_is_namespace, die_is_unspecified, die_is_void_type)
(die_is_pointer_type, die_is_reference_type)
(die_is_pointer_or_reference_type, die_is_class_type)
(die_has_object_pointer, die_this_pointer_from_object_pointer)
(die_this_pointer_is_const, is_decl_tag)
(die_object_pointer_is_for_const_method, die_is_at_class_scope)
(die_name, die_qualified_type_name, die_qualified_decl_name)
(die_qualified_name, die_qualified_type_name_empty)
(die_return_and_parm_names_from_fn_type_die)
(die_function_signature, die_peel_qual_ptr)
(die_function_type_is_method_type, die_pretty_print_type)
(die_pretty_print_decl, die_pretty_print)
(build_subranges_from_array_type_die)
(build_or_get_fn_decl_if_not_suppressed)
(lookup_class_or_typedef_type)
(lookup_class_typedef_or_enum_type_from_corpus)
(is_function_for_die_a_member_of_class)
(add_or_update_member_function): Define new static functions.
(read_context::associate_die_to_decl): Call
associate_die_to_artifact_by_repr.
(read_context::{associate_die_to_type,
schedule_type_for_late_canonicalization}): Take just one "die"
parameter rather than taking a die offset and a die source; adjust
accordingly.
(maybe_canonicalize_type): Likewise.
(finish_member_function_reading): Take a const reference to
function_decl_sptr.
(die_loc_and_name): Use the new die_name function.
(die_is_type): Rename is_type_die into this.
(build_type_decl): Take a new "where_offset" parameter. Adjust.
If a type of the same name as the one for the current DIE is is
already present, do not create a new type; just return the
already-existing one.
(build_enum_type): Take a new "where_offset" parameter. Adjust.
(finish_member_function_reading): Pass two smart pointers by const
reference. Assert that the type of the member function is a
method_type. Some light cleanups.
(add_or_update_class_type): Rename build_class_type_and_add_to_ir.
If a DIE defining the same class has already been seen, then
return that class; don't construct any other internal
representation for the same class. Better handle the updating of
member data and functions. Do not duplicate member types.
(build_qualified_type, build_pointer_type_def)
(build_reference_type): Support de-duplication here.
(build_function_type): Likewise. Support detection and building
of method type. This also supports *const* method type building.
(build_array_type): Use the new
build_subranges_from_array_type_die.
(build_type_decl): Cleanup logic.
(build_or_get_var_decl_if_not_suppressed): Renamed
build_var_decl_if_not_suppressed into this. Perform
de-duplication for data members.
(build_function_decl): Don't set an empty source location. If the
function type cannot be constructed, do not construct the function
decl either. Adjust.
(build_ir_node_from_die): Adjust. When building a function for a
DW_TAG_subroutine_type DIE, use the new
build_or_get_fn_decl_if_not_suppressed.
* src/abg-ir.cc (translation_unit::bind_function_type_life_time):
Fix comment.
(strip_typedef): Adjust.
(qualified_type_def::build_name): Set the prefix name of a the
name of a noop qualifier to "noop-qual", just like what is done in
the new die_qualified_name function.
(struct method_type::priv): New priv type for the method_type
class.
(method_type::method_type): Take a new 'is_const' parameter.
Adjust as the method_type is now pimpl'ed.
(method_type::{get_class_type, set_is_const, get_is_const}):
Define new member functions.
(function_decl::get_pretty_representation_of_declarator): Better
detecter of const-ness.
(class_decl::insert_member_decl): Better setting of the
const-ness.
(class_decl::method_decl::method_decl): Adjust. Deduce the
const-ness of the method_decl from the const-ness of its
method_type.
(copy_member_function): Adjust.
(set_member_is_static): Do not assume a non-nil scope anymore
because member_decl can now be scope-less, at least for a little
while.
* src/abg-reader.cc (push_decl_to_current_scope): Adjust.
(build_function_decl): Style adjustment. Adjust for method_type
const-ness changes.
(build_function_type): Likewise. Also, support the new
"method-class-id" property that flags a function type as being a
method type.
* src/abg-writer.cc (write_function_decl): Style fixes.
(write_function_type): Likewise. Emit a new "method-class-id"
property for function type that is actually a method type. That
property's value is the id of the class of the method type.
* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi: Adjust.
* tests/data/test-diff-dwarf/test0-report.txt: Adjust.
* tests/data/test-diff-filter/test0-report.txt: Adjust.
* tests/data/test-diff-filter/test01-report.txt: Adjust.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Adjust.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Adjust.
* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Adjust.
* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: 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/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-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-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/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/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/test8-qualified-this-pointer.so.abi: Adjust.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 1 Nov 2016 13:05:45 +0000 (14:05 +0100)]
Setup per-corpus type maps indexed by type names
This patch creates per-corpus maps that associate, for a certain kind
of type, the fully qualified name of the type to the type.
So there is a map for class_decl, one for enum_type_decl, one for
type_decl, etc.
These maps are populated when a new type is added to its scope.
The patch defines overloads of the function
maybe_update_types_lookup_map() that update the right map, depending
on the kind of type we are looking at.
Note that there also is a map in each class that associates a
signature string to a member functions. This is so that member
functions of a given class can be looked up by signature.
This is so that looking up a type becomes now much faster than having
to walk all the translation units of a corpus to find one.
Note that this patch is specifically part of the series of patches
that implements types and declarations de-duplication while reading
DWARF information.
The patch might slightly change the output of abi serialization or
comparison so it needs some adjustments of some test reference files.
That adjustment is not done here. Rather, it's done at once in
another patch of the set.
* include/abg-corpus.h (corpus::priv_): Make this public so that
functions from outside of the class can access it. These
functions are meant to be used only by code that is *inside*
libabigail.so, though.
* src/abg-corpus-priv.h: New file.
* src/abg-corpus.cc: Include the new abg-corpus-priv.h file.
(struct regex_t_deleter): Move this to abg-sptr-utils.h.
(build_sptr<regex_t>): Move the declaration of this function
template specialization to abg-sptr-utils.h and its definition to
abg-sptr-utils.cc.
(typedef regex_t_sptrs_type, typedef str_var_ptr_map_type)
(struct corpus::exported_decls_builder::priv, struct
corpus::priv): Move these declarations to the new
abg-corpus-priv.h.
(maybe_update_types_lookup_map): Define overloads of this (one per
kind of type).
(lookup_{basic, class, enum, typedef, class_or_typedef,
class_typedef_or_enum, qualified, pointer, reference, array,
function}_type): Define new functions.
* include/abg-ir.h (typedef istring_type_base_wptr_map_type)
(typedef istring_type_or_decl_base_sptr_map_type): Declare new
typedefs.
(class_decl::find_member_function_from_signature): Declare new
member function.
* src/abg-ir.cc: Include the new abg-corpus-priv.h file.
(maybe_update_types_lookup_map): Remove this initial function.
There are now new overloads in abg-corpus.cc for it.
(scope_decl::{add_member_decl, insert_member_decl}): Adjust.
(class_decl::{set_is_declaration_only, find_member_function,
add_member_function}): Adjust.
(class_decl::find_member_function_from_signature): Define new
member function.
* include/abg-sptr-utils.h (struct regex_t_deleter): Declare new
type.
(build_sptr<regex_t>): New build function template
specializations.
* src/abg-sptr-utils.cc: New file.
* src/Makefile.am: Add src/abg-sptr-utils.cc and
src/abg-corpus-priv.h to the build system.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 1 Nov 2016 12:25:05 +0000 (13:25 +0100)]
Allow pretty printing function decls for internal purposes
It appears that function_decl::get_pretty_representation doesn't make
the difference between internal and non-internal purposes. This patch
fixes that by making the helper
get_pretty_representation_of_declarator() take an "internal" flag and
calls that.
* include/abg-ir.h
(function_decl::get_pretty_representation_of_declarator): Take an
"internal" flag.
* src/abg-ir.cc
(function_decl::get_pretty_representation_of_declarator): Take an
"internal" flag.
(function_decl::get_pretty_representation): Pass the "internal"
flag to the function
function_decl::get_pretty_representation_of_declarator.
(function_decl::parameter::get_type_name): Better handle variadic
parameter type.
(function_decl::parameter::get_type_pretty_representation):
Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Sat, 26 Nov 2016 11:29:12 +0000 (12:29 +0100)]
Make bash completion files non-executable
* bash-completion/abicompat: Make this be non-executable.
* bash-completion/abidiff: Likewise.
* bash-completion/abidw: Likewise.
* bash-completion/abilint: Likewise.
* bash-completion/abinilint: Likewise.
* bash-completion/abipkgdiff: Likewise.
* bash-completion/abisym: Likewise.
* bash-completion/fedabipkgdiff: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Sat, 26 Nov 2016 10:01:45 +0000 (11:01 +0100)]
A suppressed diff node implies suppressing all equivalent nodes too
When a diff node N is suppressed (for instance, using the
--headers-dir{1,2} option of abidiff}, it's only that diff node that
is suppressed. We forget to suppress diff nodes that are equivalent
to N.
Here is why we forget to suppress diff ndoes that are equivalent.
apply_suppressions walks the diff node graph to mark diff nodes as
suppressed. But it does the walking by making sure each diff node's
*class of equivalence* is visited once. This is not only a way to
prevent infinite loops while visiting the graph, but also an
optimization as it avoids walking two equivalent diff nodes.
But then it can happen that we forget to categorize some diff nodes
inside a given class of equivalence, even though we categorized some
others.
This patch makes it so that when a diff node inside a class of
equivalence is categorized as SUPPRESSED, the canonical diff node of
that class of equivalence is categorized as SUPPRESSED too. That way,
to know if a diff node is suppressed, we just need to look at its
canonical diff node.
While doing this, I noticed that abidiff and abipkgdiff are not
dropping private types from libabigail's internal representation, even
though the Library now has that capability. The patch fixes that.
But then the patch adds a --dont-drop-private-types option to abidiff
to avoid dropping those private types from the IR, so that regression
tests can make sure that a suppressed diff node implies suppression
all equivalent nodes too.
* doc/manuals/abidiff.rst b/doc/manuals/abidiff.rst: Document the
new --dont-drop-private-types option.
* src/abg-comparison.cc (diff::is_filtered_out): If the canonical
type was suppressed then the current diff node is filtered out.
(suppression_categorization_visitor::visit_{begin,end}):
Categorized the canonical node as SUPPRESSED if the current node
is suppressed.
* tools/abidiff.cc (options::drop_private_types): New data member.
(options::options): Initialize it.
(display_usage): Add new help string for the new
--dont-drop-private-types option.
(parse_command_line): Parse the new --dont-drop-private-types
option.
(set_suppressions): Generate suppression specification from header
directories given in parameter and stick them to the read context.
* tools/abipkgdiff.cc (compare): Likewise.
* tests/data/test-diff-suppr/libtest34-v0.so: New test input.
* tests/data/test-diff-suppr/libtest34-v1.so: Likewise.
* tests/data/test-diff-suppr/test34-report-0.txt: New reference
report.
* tests/data/test-diff-suppr/test34-v0.c: Source code for the new
test input.
* tests/data/test-diff-suppr/test34-v1.c: Likewise.
* tests/data/test-diff-suppr/test34-priv-include-dir-v0/test34-priv-include-v0.h:
Likewise.
* tests/data/test-diff-suppr/test34-priv-include-dir-v1/test34-priv-include-v1.h:
Likewise.
* tests/data/test-diff-suppr/test34-pub-include-dir-v0/test34-pub-include-v0.h:
Likewise.
* tests/data/test-diff-suppr/test34-pub-include-dir-v1/test34-pub-include-v1.h:
Likewise.
* tests/data/Makefile.am: Add new test input material above to
source distribution.
* tests/test-diff-suppr.cc (in_out_spec): Compare the two new test
library provided. Add --dont-drop-private-types to test30*.
signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Sat, 26 Nov 2016 09:37:19 +0000 (10:37 +0100)]
Forgot to consider libtest33-v{0,1}.so in test-diff-suppr.cc
I forgot the make test-diff-suppr.cc run over libtest33-v{0,1}.so even
though this test was added to the source distribution. Fixed thus.
* tests/data/test-diff-suppr/test33-report-0.txt: New refernce report.
* tests/test-diff-suppr.cc (in_out_specs): Compare libtest33-v0.so
and libtest33-v1.so.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 24 Nov 2016 16:53:20 +0000 (17:53 +0100)]
Bump version number to 1.0.rc7
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 24 Nov 2016 16:52:27 +0000 (17:52 +0100)]
Update website for 1.0.rc6
* doc/website/mainpage.txt: Update for 1.0.rc6 release
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 23 Nov 2016 09:54:44 +0000 (10:54 +0100)]
Update NEWS and ChangeLog for 1.0.rc6
* ChangeLog: Update this automatically using "make
update-changelog".
* NEWS: update this by editing the output of 'git shortlog
libabigail-1.0.rc5..HEAD'.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 24 Nov 2016 10:24:04 +0000 (11:24 +0100)]
Avoid using size_t to get DWARF data
This can cause issues on i686 compared to x86_64 as size_t has
different size on these two platforms. Rather, use int64_t which has
the same fixed size on both platforms.
* src/abg-dwarf-reader.cc (die_size_in_bits, die_location_expr):
Take uint64_t rather than size_t and adjust.
(expr_result::const_value_): Make this be int64_t rather than
ssize_t.
(expr_result::expr_result): Take int64_t rather than ssize_t.
(expr_result::const_value): Return int64_t rather than ssize_t.
(expr_result::{operator(), operator=, operator+=}): Make these
operators return or take int64_t.
too.
(op_pushes_constant_value, op_manipulates_stack)
(op_is_arith_logic, op_is_control_flow)
(eval_last_constant_dwarf_sub_expr, die_member_offset)
(die_virtual_function_index): Take
uint64_t rather than size_t, or int64_t rather than ssize_t.
(finish_member_function_reading, build_class_type_and_add_to_ir)
(build_union_type_and_add_to_ir): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 24 Nov 2016 09:32:18 +0000 (10:32 +0100)]
Fix a compiler warning issued by GCC 6.2.1
* src/abg-dwarf-reader.cc (find_import_unit_point_between_dies):
Parameter 5 of find_import_unit_point_between_dies is not of type
Dwarf_Off.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 24 Nov 2016 09:30:59 +0000 (10:30 +0100)]
Fix offset type mismatch
* src/abg-dwarf-reader.cc (die_member_offset): The last two
parameters of die_unsigned_constant_attribute must be of type
uint64_t.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 24 Nov 2016 08:45:31 +0000 (09:45 +0100)]
Fix indentation in abg-writer.cc
* src/abg-writer.cc (write_union_decl_opening_tag): Fix
indentation.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 23 Nov 2016 17:12:50 +0000 (18:12 +0100)]
Support reading data member offset from DW_AT_bit_offset
There are times where the DW_AT_data_member_location attribute is set
to zero and where the actual offset of the data member is the value of
the DW_AT_bit_offset. This seems to be happening when a union type is
involved.
To get the offset of a data member, this patch makes us read the
DW_AT_bit_offset when it's present. Otherwise, it gets the offset
from the DW_AT_data_member_location as we used to do.
In the passing the patch fixes the offset of base classes; the
nubmer of bytes value was what was being used, rather than the number
bits value.
* src/abg-dwarf-reader.cc (die_member_offset): Better comments.
Support reading the bit offset also from the DW_AT_bit_offset
attribute when it's present. Make sure this always returns a
value in bits.
(build_class_type_and_add_to_ir): No need to multiply (by 8) the
value returned by die_member_offset anymore because it's now in
bits directly.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Adjust.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-read-dwarf/test11-pr18828.so.abi: Adjust.
* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.
* tests/data/test-read-dwarf/test13-pr18894.so.abi: Adjust.
* tests/data/test-read-dwarf/test14-pr18893.so.abi: Adjust.
* tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust.
* tests/data/test-read-dwarf/test16-pr18904.so.abi: Adjust.
* tests/data/test-read-dwarf/test17-pr19027.so.abi: Adjust.
* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Adjust.
* tests/data/test-read-dwarf/test21-pr19092.so.abi: Adjust.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 23 Nov 2016 13:55:59 +0000 (14:55 +0100)]
Lexicographically sort union data members in change reports
Until now, when reporting about struct or union changes, data members
were sorted by using their offset; the data member with the smallest
offset coming first.
But then in unions, all data member have the same offset. In that
case, the patch sort them lexicographically, by taking their name into
account.
* src/abg-comparison.cc (data_member_comp::operator()): Data
members with the same offset are sorted lexicographically, by
taking their name into account.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt:
Adjust.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt:
Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 23 Nov 2016 12:13:19 +0000 (13:13 +0100)]
Better diagnostics when wget is missing
When wget is missing building the fedabipkgdiff tool is disabled.
This patch fixes diagnostics in that case.
* configure.ac: When wget is missing then make the disabling of
the building of the fedabipkgdiff tool show up in the
configuration summary and emit a notice.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 15 Nov 2016 00:16:46 +0000 (01:16 +0100)]
Support union types
This patch makes Libabigail understand C and C++ union types. It
defines a new class abigail::ir::union_decl to represent the
declaration of a union type. It also defines a new type
abigail::comparison::union_diff to represent the changes between two
union types. The patch then adds facilities to read union types from
DWARF and abixml and also to write union types into the abixml format.
As union types and class types have a lot in common, the patch tries
very hard to share code between the abigail::ir::class_decl and
abigail::ir::union_decl. To do so, a new class
abigail::ir::class_or_union is created. It's the base class for both
abigai::ir::class_decl and abigail::ir::union_decl. Its data members
and methods represent the set of data and behaviour that are common to
classes and unions. A lot of code and data that were initially in
abigail::ir::class_decl got moved into the new
abigail::ir::class_or_union class.
Similary, the patch creates a new class
abigail::comparison::class_or_union_diff that is a base class for both
the existing class abigail::comparison::class_diff and the newly
created class abigail::comparison::union_diff. The new class
abigail::comparison::class_or_union_diff contains data and behaviour
that are common to both union_diff and class_diff and that were
previously in class_diff.
The rest of the patch is mostly adjustment so that code that was
supposed to work with class class_decl only can now work with class
class_or_union when it makes sense. Similarly for class_diff and
class_or_union_diff.
The patch adds regression tests into the test suite and adjust many
existing tests involving binaries that contain union types; the
reference output of those tests now take union types into account.
* include/abg-fwd.h (class_or_union, union_decl): Forward-declare
new types.
(is_class_or_union_type, is_union_type): Declare new functions.
* include/abg-ir.h (method_type::class_type_): Make this be of
class_or_union_wptr type.
(method_type::method_type): Make the class_type parameter be of
class_or_union_wptr type.
(method_type::{g,s}et_class_type): Take or return a
class_or_union_sptr.
(member_base, method_decl, member_function_template)
(member_class_template, member_base::hash)
(member_function_template::hash, member_class_template::hash):
Take these class types out of the class_decl scope.
(is_method_decl): Adjust.
(operator==, opertor!=): Adjust overloads for
member_function_template_sptr and member_class_template_sptr.
(class class_or_union): Declare new type.
(class class_decl): Make this class inherit class_or_union class.
(class_decl::{add_member_decl, insert_member_decl,
remove_member_decl, set_size_in_bits, get_size_in_bits,
get_alignment_in_bits, set_alignment_in_bits,
get_is_declaration_only, set_is_declaration_only,
set_definition_of_declaration, get_definition_of_declaration,
get_earlier_declaration, set_earlier_declaration,
insert_member_type, add_member_type, remove_member_type,
get_member_type, find_member_type, add_data_member,
get_data_members, find_data_member, get_non_static_data_members,
add_member_function, get_member_functions, find_member_function,
add_member_function_template, get_member_function_templates,
add_member_class_template, get_member_class_templates): Move these
to the parent class class_or_union.
(copy_member_function, equals): Add overloads for class_or_union.
(struct class_or_union::hash): Declare new type.
(class union_decl): Declare new type.
(equals, copy_member_function): New overloads for class union_decl
type.
(ir_node_visitor::visit): Add new overloads for union_decl* and
class_or_union*.
* src/abg-ir.cc (get_member_function_is_ctor)
(set_member_function_is_ctor, get_member_function_is_dtor)
(set_member_function_is_dtor, get_member_function_is_const)
(set_member_function_is_const, get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual, set_member_function_is_virtual)
(maybe_update_types_lookup_map, get_location)
(get_method_type_name, is_at_global_scope, is_at_class_scope):
Adjust.
(is_class_or_union_type, is_union_type): Define new functions.
(type_base::get_canonical_type_for, maybe_adjust_canonical_type)
(method_type::method_type, method_type::set_class_type)
(function_decl::get_pretty_representation)
(function_decl::get_first_non_implicit_parm)
(function_decl::clone): Adjust.
(equals): Adjust the overload for function_type.
(struct class_or_union::priv): Define new type.
(class::priv::{declaration_, definition_of_declaration_,
member_types_, data_members_, non_static_data_members_,
member_functions_, mem_fns_map_, member_function_templates_,
member_class_templates_, is_declaration_only_}): Move these data
member into class_or_union::priv.
(class_priv::{mark_as_being_compared, unmark_as_being_compared,
comparison_started}): Moved these member functions to
class_or_union::priv.
(class_or_union::{class_or_union, traverse, ~class_or_union,
add_member_decl, remove_member_decl, insert_member_type,
add_member_type, get_size_in_bits, remove_member_type,
get_alignment_in_bits, set_alignment_in_bits, set_size_in_bits,
get_is_declaration_only, set_is_declaration_only,
set_definition_of_declaration, get_definition_of_declaration,
get_earlier_declaration, set_earlier_declaration,
get_member_types, find_member_type, add_data_member,
get_data_member, find_data_member, add_member_function,
get_member_functions, find_member_function,
add_member_function_template, get_member_function_templates,
add_member_class_template, get_member_class_templates,
has_no_member, insert_member_decl, operator==}): Define new member
functions.
(class_decl::{add_member_decl, remove_member_decl,
insert_member_type, add_member_type, get_size_in_bits,
remove_member_type, get_alignment_in_bits, set_alignment_in_bits,
set_size_in_bits, get_is_declaration_only,
set_is_declaration_only, set_definition_of_declaration,
get_earlier_declaration, set_earlier_declaration,
get_member_types, find_member_type, add_data_member,
get_data_member, find_data_member, add_member_function,
get_member_functions, find_member_function,
add_member_function_template, get_member_function_templates,
add_member_class_template, get_member_class_templates): Move these
member functions into class_or_union.
(class_decl::{class_decl, get_definition_of_declaration,
insert_member_decl, add_member_function, has_no_base_nor_member}):
Adjust.
(equals, copy_member_function): Define new overloads for
class_or_union.
(equals): Adjust the overload for class_decl.
(method_decl::{method_decl, set_linkage_name, ~method_decl,
get_type, set_scope}): Remove from the class_decl scope.
(member_base::operator==, member_function_template::operator==):
Likewise.
(member_function_template::traverse)
(member_class_template::operator==)
(member_class_template::traverse): Likewise.
(operator==, operator!=): Adjust the overlod for
member_function_template_sptr.
(is_method_decl, fixup_virtual_member_function)
(set_member_is_static): Adjust.
(virtual_member_function_less_than::operator()): Likewise.
(union_decl::{union_decl, get_pretty_representation, operator==,
traverse}): Define new member functions.
(equals, copy_member_function): Define new overloads for
union_decl.
(hash_type_or_decl): Adjust.
(ir_node_visitor::visit_{begin, end}): Adjust. Add new overloads
for class_or_union* and union_decl*.
* include/abg-comparison.h (changed_member_function_sptr)
(string_member_function_sptr_map): Adjust these typedefs.
(class class_or_union_diff): Declare new type.
(class_diff): Adjust to make this inherit the new
class_or_union_diff type.
(class_diff::{get_priv, member_types_changes,
data_members_changes, inserted_data_members, deleted_data_members,
member_fn_tmpls_changes, member_fn_tmpls_changes,
member_class_tmpls_changes}): These member functions got moved
into -- and shared with -- class_or_union_diff class.
(class union_diff): Declare new type.
(typedef union_diff_sptr): New typedef.
(compute_diff): New overload for union_diff
(is_class_diff, is_union_diff): Declare new functions.
* src/abg-comparison.cc (is_class_diff, is_union_diff): Define new
functions.
(compute_diff_for_types): Support union_decl.
(represent): Adjust.
(represent_data_member): Do not show offset information for data
members of unions as all union data members are at offset 0.
(struct class_or_union_diff::priv): New type.
(class_or_union_diff::priv::{member_type_has_changed,
subtype_changed_dm, member_class_tmpl_has_changed,
get_deleted_non_static_data_members_number,
get_inserted_non_static_data_members_number,
count_filtered_subtype_changed_dm, count_filtered_changed_dm,
count_filtered_changed_mem_fns, count_filtered_inserted_mem_fns,
count_filtered_deleted_mem_fns}): Define new member functions.
(class_or_union_diff::{class_or_union_diff, finish_diff_type,
lookup_tables_empty, lookup_tables_empty,
ensure_lookup_tables_populated, allocate_priv_data, get_priv,
~class_or_union_diff, first_class_or_union, second_class_or_union,
member_types_changes, member_types_changes, data_members_changes,
inserted_data_members, deleted_data_members, member_fns_changes,
changed_member_fns, member_fns_changes, inserted_member_fns,
member_fn_tmpls_changes, member_fn_tmpls_changes,
member_class_tmpls_changes, member_class_tmpls_changes,
has_changes, has_local_changes, report, chain_into_hierarchy}):
Define new member functions.
(class_diff::priv::{member_types_changes_, data_members_changes,
member_fn_tmpls_changes_, member_class_tmpls_changes_,
deleted_member_types_, inserted_member_types_,
changed_member_types_, sorted_changed_member_types_,
deleted_data_members_, deleted_dm_by_offset_,
inserted_data_members_, inserted_dm_by_offset_,
subtype_changed_dm_, sorted_subtype_changed_dm_, changed_dm_,
sorted_changed_dm_, deleted_member_functions_,
inserted_member_functions_, changed_member_functions_,
sorted_changed_member_functions_, deleted_member_class_tmpls_,
inserted_member_class_tmpls_, changed_member_class_tmpls_,
sorted_changed_member_class_tmpls_}): Move these data members into
class_or_union_diff::priv.
(class_diff::{clear_lookup_tables, lookup_tables_empty,
ensure_lookup_tables_populate}): Adjust.
(class_diff::allocate_priv_data): Define new function.
(class_diff::priv::{count_filtered_changed_mem_fns,
count_filtered_inserted_mem_fns, count_filtered_deleted_mem_fns,
chain_into_hierarchy, class_diff}): Likewise.
(class_diff::{member_types_changes, data_members_changes,
inserted_data_members, deleted_data_members,
member_fn_tmpls_changes, member_fn_tmpls_changes,
member_class_tmpls_changes}): These are deleted as they got moved
to class_or_union_diff.
(class_diff::report): Adjust.
(union_diff::{clear_lookup_tables, lookup_tables_empty,
ensure_lookup_tables_populated, allocate_priv_data, union_diff,
finish_diff_type, first_union_decl, second_union_decl,
get_pretty_representation, report}): Define new functions.
(compute_diff): Define an overload for union_decl_sptr.
(function_decl_diff::report): Adjust.
(corpus_diff::priv::apply_suppressions_to_added_removed_fns_vars):
Adjust.
(corpus_diff::report): Adjust.
* src/abg-hash.cc (member_base::hash::operator)
(member_function_template::hash::operator)
(member_class_template::hash::operator): Move these out of the
class_decl scope.
(class_or_union::hash::operator): Define new member function.
(class_decl::hash::operator): Adjust.
(type_base::dynamic_hash::operator): Support hashing of
union_decl. Adjust.
* src/abg-suppression.cc (type_suppression::suppresses_diff):
Adjust.
* src/abg-dwarf-reader.cc (typedef die_class_or_union_map_type):
Define new typedef.
(read_context::{die_wip_classes_map_,
alternate_die_wip_classes_map_, type_unit_die_wip_classes_map_):
Make these data member have type die_class_or_union_map_type.
(read_context::{lookup_type_from_die_offset, die_wip_classes_map,
is_wip_class_die_offset, resolve_declaration_only_classes}):
Adjust.
(finish_member_function_reading, build_class_type_and_add_to_ir)
(build_function_type, build_function_decl, build_reference_type)
(type_is_suppressed, build_function_decl)
(maybe_canonicalize_type, maybe_set_member_type_access_specifier):
Adjust.
(build_union_type_and_add_to_ir): Define new static function.
(build_ir_node_from_die): Support DW_TAG_union_type DIE tag.
* src/abg-reader.cc (handle_element_node): Handle union_decl.
(build_function_decl, build_function_decl_if_not_suppressed):
Adjust.
(build_union_decl_if_not_suppressed, build_union_decl)
(handle_union_decl): Define new functions.
(build_class_decl): Adjust.
* src/abg-writer.cc (record_decl_only_type_as_emitted): Adjust.
(write_decl): Adjust. Support writting union_decl type.
p (write_class_decl_opening_tag, write_class_decl): Adjust. Call
the new write_class_or_union_is_declaration_only.
(write_union_decl_opening_tag, write_union_decl): Define new
static functions.
(write_member_tpe): Support writting union decl.
* tests/test-diff-dwarf.cc (in_out_specs): Add new tests for this
union type support.
* tests/data/test-diff-dwarf/libtest37-union-v0.so: New test input.
* tests/data/test-diff-dwarf/libtest37-union-v1.so: Likewise.
* tests/data/test-diff-dwarf/libtest38-union-v0.so: Likewise.
* tests/data/test-diff-dwarf/libtest38-union-v1.so: Likewise.
* tests/data/test-diff-dwarf/libtest39-union-v0.so: Likewise.
* tests/data/test-diff-dwarf/libtest39-union-v1.so: Likewise.
* tests/data/test-diff-dwarf/test37-union-report-0.txt: Likewise.
* tests/data/test-diff-dwarf/test38-union-report-0.txt: Likewise.
* tests/data/test-diff-dwarf/test39-union-report-0.txt: Likewise.
* tests/data/test-diff-dwarf/test37-union-v0.cc: Source code for
new test input.
* tests/data/test-diff-dwarf/test37-union-v1.cc: Likewise.
* tests/data/test-diff-dwarf/test38-union-v0.cc: Likewise.
* tests/data/test-diff-dwarf/test38-union-v1.cc: Likewise.
* tests/data/test-diff-dwarf/test39-union-v0.cc: Likewise.
* tests/data/test-diff-dwarf/test39-union-v1.cc: Likewise.
* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi:
Update test reference.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt:
Likewise.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt:
Likewise.
* tests/data/test-read-dwarf/libtest23.so.abi: Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
Likewise.
* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Likewise.
* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
Likewise.
* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
Likewise.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi:
Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 10 Nov 2016 12:06:50 +0000 (13:06 +0100)]
Support empty properties in INI files
The ini file parser doesn't support parsing properties with no value.
This patch adds that feature, as it turned out to be a pre-requisite
for reading Linux Kernel ABI whitelist files.
* include/abg-ini.h (simple_property::simple_property): Add a new
constructor for empty values.
(simple_property::has_empty_value): Declare new member function.
* src/abg-ini.cc (simple_property::{simple_property,
has_empty_value}): Define new member functions.
(read_context::read_property): Support reading a property with no
value.
(write_property_value, write_property): Support writting a
property with empty value.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 10 Nov 2016 08:52:42 +0000 (09:52 +0100)]
Rename config::property_vector into config::properties_type
This renaming makes the code looks more consistent.
* include/abg-ini.h (config::properties_type): Rename the typedef
config::property_vector into this.
(config::section::{section, get_properties, set_properties}):
Adjust.
* src/abg-ini.cc (config::section::priv::properties_): Adjust the
name of its type.
(config::section::{section, get_properties, set_properties,
find_property}): Adjust.
(write_section): Adjust.
* src/abg-suppression.cc (read_function_suppression): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 9 Nov 2016 14:29:20 +0000 (15:29 +0100)]
Apply harmless and harmful filters in one pass
When comparing linux kernels with lots of changes, walking changes
twice just to apply harmless and harmful change filters was dominating
the performance profile.
This patch performs the harmless and harmful filtering in one pass.
This makes the overall comparison go from 15 minutes to 10 minutes
when comparing a 4.7 kernel from fedora24 and a 4.8 kernel from
fedora26.
* include/abg-comp-filter.h (class harmless_harmful_filter):
Decalre new class.
(typedef harmless_harmful_filter_sptr): Declare new typedef.
(class harmless_filter, class harmful_filter): Remove these class
declarations.
(typedef harmful_filter_sptr, harmless_filter_sptr): Remove these
typedefs.
* src/abg-comp-filter.cc (categorize_harmless_diff_node)
(categorize_harmful_diff_node): Define new static functions.
({harmless, harmful}_filter::{visit, visit_end}): Remove these
member functions.
(harmless_harmful_filter::{visit, visit_end}): Define new member
functions.
* src/abg-comparison.cc (diff_context::diff_context): Register the
new harmless_harmful_filter, and remove the premier
harmless_filter and harmful_filter.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the
commit. # On branch kabidiff-dedup # Changes to be committed: #
(use "git reset HEAD <file>..." to unstage) # # modified:
include/abg-comp-filter.h # modified: src/abg-comp-filter.cc #
modified: src/abg-comparison.cc # # Untracked files: # (use "git
add <file>..." to include in what will be committed) # # diff.txt
# prtests/ # tests/data/test-read-dwarf/libtest23.so.abi.conflict
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 8 Nov 2016 11:22:50 +0000 (12:22 +0100)]
Avoid stripping typedefs too much
strip_typedef re-constructs entire type trees and canonicalize them.
Calling it a lot on very deep and recursive trees can be costly.
Unfortunately, categorization of changes uses strip_typedef quite a
bit to determine if the two types that are different are still
compatible. When used on changesets generating from comparing two
Linux Kernels, it makes changes categorization dominate CPU usage
profiles.
This patch avoids using strip_typedef to determine if two types are
compatible and thus speeds up type categorization of changes involving
lots of deep and recursive type trees.
* src/abg-ir.cc (types_are_compatible)
(is_compatible_with_class_type): Do not strip typedefs. Just get
their leaf types.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 8 Nov 2016 11:31:03 +0000 (12:31 +0100)]
Misc style cleanups in abg-ir.cc
* src/abg-ir.cc (equals): In overloads for function_type and
class_decl, avoid returning a constant when we can return a
variable like in the rest of the code.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 1 Nov 2016 10:37:41 +0000 (11:37 +0100)]
Factorize out string representation of array_type_def::subrange_type
As we are going to need to print names of array types from DIEs
directly, we'll need to represent names of subranges.
This patch factorizes the string representation of the
array_type_def::subrange_type type.
* src/abg-ir.cc (array_type_def::subrange_type::{as_string,
vector_as_string}): Define methods.
(array_type_def::get_subrange_representation): Use the new
vector_as_string method.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 1 Nov 2016 10:16:55 +0000 (11:16 +0100)]
Factorize out parsing of integral types
Until now, integral_type has been just a "private" helper type used in
the building of a type_decl.
Now it's going to be helpful in determining the name of an integral
type, directly from DIEs -- without having to build a type_decl.
This patch factorizes out the parsing and building of an integral_type
by introducing a src/abg-ir-priv.h file that is meant to declare
interfaces that are going to be private to libabigail.so but usable by
all of its modules.
* src/abg-ir-priv.h: New file.
* src/Makefile.am: Add abg-ir-priv.h to the build system.
* src/abg-ir.cc: Include the new abg-ir-priv.h header file.
(class_integral_type): Move this type
declaration to the new abg-ir-priv.h header.
(integral_type::modifiers_type): Make this non-static.
(parse_integral_type): This new overload is a factorized out of
...
(integral_type::integral_type): ... here.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 31 Oct 2016 17:29:41 +0000 (18:29 +0100)]
Misc style fixes in abg-ir.cc
* src/abg-ir.cc (get_function_type_name,
get_pretty_representation): Misc style fixes.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 31 Oct 2016 15:31:38 +0000 (16:31 +0100)]
Consider a method_decl as always being a member decl
The is_member_decl() function considers that a decl is a member decl
only if it's at class scope.
In preparation for the support of incremental building of method
decls, a method decl, even before being added to its final class, must
always be considered as a member decl. This allows for instance, the
proper pretty printing of the method decl even before it's added to
its class.
This patch prepares the upcoming support of incremental building of
method decls by making is_member_decl() work on a method_decl that
hasn't yet been added to a class, so that is not, strictly-speaking,
at class scope yet.
* src/abg-ir.cc (is_member_decl): Consider a method decl as always
being a member decl.
(is_member_function): Use is_member_decl.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 31 Oct 2016 12:52:53 +0000 (13:52 +0100)]
Cleanup void and variadic parameter type interfaces
While working on something else, it appeared that renaming
abigail::environment::get_void_type_decl() to
abigail::environment::get_void_type() and
abigail::environment::get_variadic_parameter_type_decl() to
abigail::environment::get_variadic_parameter_type() would be an
improvement.
This patch implements that.
* include/abg-ir.h (environment::{get_void_type,
get_variadic_parameter_type}): Renamed get_void_type_decl and
get_variadic_parameter_type_decl to these.
(environment::is_void_type): Remove the overload that takes a bare
pointer.
(environment::is_variadic_parameter_type): Declare new member
function.
* src/abg-ir.cc (environment::void_type_): Renamed the data member
void_type_decl_ into this.
(environment::variadic_marker_type_): Renamed the data member
variadic_marker_type_decl_ into this.
(environment::{get_void_type, get_variadic_parameter_type}):
Renamed get_void_type_decl and get_variadic_parameter_type_decl to
these.
(environment::is_void_type): Take a smart pointer now.
(environment::is_variadic_parameter_type): Define new member
function.
(synthesize_function_type_from_translation_unit): Adjust.
(function_decl::parameter::get_pretty_representation): Likewise.
* src/abg-comparison.cc (is_diff_of_variadic_parameter_type):
Adjust.
* src/abg-dwarf-reader.cc (build_function_type)
(build_ir_node_for_void_type): Likewise.
* src/abg-reader.cc (build_function_parameter)
(build_function_decl, build_function_type): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 31 Oct 2016 11:26:22 +0000 (12:26 +0100)]
Cleanup some entry points in abg-fwd.h
While looking at something else I came accross some interface cleanup
opportunities, as usual. This patch honours some of those
opportunities.
* include/abg-fwd.h (add_decl_to_scope): Pass the scope smart
pointer by reference.
(is_member_type): pass the type smart pointer by reference.
(is_function_decl, is_pointer_type, is_reference_type)
(is_qualified_type, is_function_type, is_method_type)
(is_array_type): Take a type_or_decl base pointer, rather than
either a decl_base or type_base pointer.
* include/abg-ir.h (translation_unit::set_corpus): Take a pointer
to non-const corpus.
(translation_unit::get_corpus): Add a non-const overload.
(type_or_decl_base::get_corpus): Likewise.
(type_or_decl_base::set_translation_unit): Take a pointer to
non-corpus translation_unit.
(type_or_decl_base::get_translation_unit): Add a non-const
overload.
(scope_decl::{add_member_decl, insert_member_decl}): Pass the
member smart pointer by reference.
(scope_decl::remove_member_decl): Take a non-const smart pointer.
(class_decl::add_member_decl): Pass the decl smart pointer by
reference.
(is_method_decl): Take pointer or reference to type_or_decl_base
rather than function_decl.
* src/abg-ir.cc (translation_unit::priv::corpus): Make this a
pointer to non-const corpus.
(translation_unit::set_corpus): Take a pointer to non-const
corpus.
(translation_unit::get_corpus): Add a non-const overload.
(translation_unit::get_global_scope): Adjust.
(translation_unit::bind_function_type_life_time): Adjust.
(type_or_decl_base::translation_unit): Make this a pointer to
non-const translation_unit.
(type_or_decl_base::get_corpus): Likewise.
(type_or_decl_base::set_translation_unit): Take a pointer to
non-corpus translation_unit.
(type_or_decl_base::get_translation_unit): Add a non-const
overload.
(is_member_type): pass the type smart pointer by reference.
(scope_decl::{add_member_decl, insert_member_decl}): Take a
reference to the member decl smart pointer. Adjust.
(class_decl::add_member_decl): Likewise.
(scope_decl::remove_member_decl): Take a non-const smart pointer.
(add_decl_to_scope): Pass the scope smart pointer by reference.
(is_decl, is_function_decl, is_pointer_type, is_reference_type)
(is_qualified_type, is_function_type, is_method_type)
(is_method_decl, is_array_type): Take a type_or_decl base pointer,
rather than either a decl_base or type_base pointer.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 31 Oct 2016 13:13:06 +0000 (14:13 +0100)]
Fix abigail::ir::get_type_scope()
It appears that abigail::ir::get_type_scope() was always returning nil
due to a thinko. Oops. This pach fixes that.
* src/abg-ir.cc (get_type_scope): Do not always return nil.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 27 Oct 2016 14:05:35 +0000 (16:05 +0200)]
Bug 20740 Broken check for dwarf_getalt in configure.ac
There is a missing space around the "=" operator in the conditional
expression of the test below:
if test x$FOUND_DWARF_GETALT_IN_LIBDW=xyes; then
AC_DEFINE([LIBDW_HAS_DWARF_GETALT], 1,
[Defined if libdw has the function dwarf_getalt])
fi
This patch fixes that. Oops.
* configure.ac: Add missing spaces around the "=" of a conditional
expression.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 11 Oct 2016 13:08:13 +0000 (15:08 +0200)]
Canonicalize function types when reading from DWARF
Up until now, only function types pointed to by a pointer to function
was canonicalized. This patch also canonicalizes function types that
are used as types for function declarations.
* src/abg-dwarf-reader.cc (build_function_decl): Canonicalize
function types.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 11 Oct 2016 11:08:25 +0000 (13:08 +0200)]
Misc cleanups here and there
While looking at something else, the usual cleanup spree came up.
* src/abg-dwarf-reader.cc (canonicalize_types_scheduled): Fix
identation.
* src/abg-reader.cc (build_class_decl): Use class_decl_sptr rather
than shared_ptr<class_decl>.
* src/abg-writer.cc (write_class_is_declaration_only)
(write_is_struct, write_decl, write_decl_in_scope)
(write_type_decl, write_qualified_type_def)
(write_pointer_type_def, write_reference_type_def)
(write_array_type_def, write_enum_type_decl, write_typedef_decl)
(write_elf_symbol, write_var_decl, write_function_decl)
(write_member_type_opening_tag, write_member_type)
(write_class_decl_opening_tag, write_class_decl): Cleanup
parameters to use the right typedef, rather than the long
shared_ptr<*> form. Pass the shared pointers by reference as
well.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 10 Oct 2016 09:08:05 +0000 (11:08 +0200)]
Cleanup namespace importing in abg-interned-str.h
* include/abg-interned-str.h: Inject std::tr1::shared_ptr,
std::string and std::ostream inside the abigail namespace.
(interned_string::{interned_string, raw, operator==, operator!=,
operator<): Adjust.
(operator==, operator!=, operator<<, operator+): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 7 Oct 2016 13:46:02 +0000 (15:46 +0200)]
Cleanup functions to detect infinite comparison of class_decl
While looking around, I found some things in need of a cleanup. This
patch addresses those.
* src/abg-ir.cc (class_decl::priv::unmark_as_being_compared): In
the overload that takes a pointer to class_decl, re-use the
overload that takes a reference.
(class_decl::priv::comparison_started): Do not crash if the klass
pointer is nil.
(equals): In the overload for class_decl&, undef the RESULT macro
when it's not used anymore.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 7 Oct 2016 13:26:30 +0000 (15:26 +0200)]
Cleanup class_decl inifite comparison detection
We recently used a new type interned_string_set_type to detect
infinite comparison of function_type type. This patch uses the same
type for class_decl infinite comparison detection.
* src/abg-ir.cc (environment::priv::classes_being_compared_): Make
this use the new interned_string_set_type type.
(class_decl::priv::{mark_as_being_compared, comparison_started}):
Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 10 Oct 2016 09:20:04 +0000 (11:20 +0200)]
Apply ODR-based type comparison optimization to function types
Inside a given ABI corpus, during type canonicalization, function
types are compared structurally (member-wise). Note that on the other
hand, class, enums and basic types are compared using an ODR-based
optimization: only their type names are compared.
This makes function types comparison be *super slow* for ABI corpora
with a lot of function types.
This patch fixes that by enabling the ODR-based comparison
optimization for function types too, during type canonicalization.
* src/abg-ir.cc (type_eligible_for_odr_based_comparison):
Factorize this out of type_base::get_canonical_type_for. Also,
add function types to the set of types to use the ODR-based
comparison optimization on.
(type_base::get_canonical_type_for): Use the new
type_eligible_for_odr_based_comparison function.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 7 Oct 2016 10:38:27 +0000 (12:38 +0200)]
Prevent infinite loops while comparing two function_type
While comparing two function types a given sub-type can itself have a
sub-type that *is* the same function_type as the one we are looking
at. In that case, an infinite loop appears.
This patch detects those cases, similarly to what we do for class_decl
and avoids the eventual infinite loop.
* include/abg-ir.h (class environment): Make class function_type
be a friend of this class.
(class function_type): Make the equality function for
function_types be a friend of this class.
* src/abg-ir.cc (environment::priv::fn_types_being_compared_): New
data member.
(function_type::priv::{mark_as_being_compared,
unmark_as_being_compared, comparison_started}): Define new member
functions.
(equals): In the overload for function_types, if any of the the
function_type being compared is already being compared, return
early saying that the two function_types are equal. This avoids
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 6 Oct 2016 11:53:49 +0000 (13:53 +0200)]
Define a new interned_string_set_type typedef
In order to prepare other changes to come, this patch declares an
unordered set of abigail::interned_string.
* include/abg-interned-str.h (interned_string_set_type): Define a new
typedef for unordered_set<interned_string>.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 23 Sep 2016 12:42:24 +0000 (14:42 +0200)]
Update reference output of runtestreaddwarf
The test runtestreaddwarf emits some spurious output on stdout. This
test updates the reference output to remove that spurious output.
* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.
* tests/data/test-read-dwarf/test17-pr19027.so.abi: Adjust.
* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Adjust.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Matthias Klose [Wed, 21 Sep 2016 16:42:51 +0000 (18:42 +0200)]
Fix typo in abipkgdiff
* tools/abipkgdiff.cc (extract_deb): Fix typo.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 12 Sep 2016 10:09:59 +0000 (12:09 +0200)]
Better handle fedabipkgdiff dependencies detection
Even when the configure script is executed without the
--enable-fedabipkgdiff switch, if one of the dependencies of
fedabipkgdiff is missing (e.g, python), it fails with a fatal error.
It should rather just disable fedabipkgdiff in that case.
This patch fixes this behaviour. It makes it so that it's only when
the --enable-fedabipkgdiff switch provided that a missing dependency
results in a fatal hard error.
* configure.ac: It's only when --enable-fedabipkgdiff is provided
that a missing dependency of the fedabipkgdiff program results in
a fatal error. Otherwise, building fedabipkgdiff is just
disabled.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 16 Sep 2016 13:57:34 +0000 (15:57 +0200)]
Add default suppression specifications for C++ binaries
For C++ libraries that are not libstdc++ or boost, this patch defines
default suppression specifications that drop function or variables that
we know are from namespaces that are not meant to be part of the API.
By doing so, we also decrease the memory needed to process the
binaries.
* default.abignore: Add suppressions for non-libstdc++ and
non-boost C++ libraries.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 20 Sep 2016 13:54:51 +0000 (15:54 +0200)]
Add default suppression specification for webkitgtk
This patch adds default suppression specifications for webkitgtk and
webkit2gtk so that unnecessary ABI artifacts are dropped from the
in-memory IR. This dramatically helps to lower the memory usage of
libabigail while analyzing the webkit2gtk libraries.
* default.abignore: New suppression specifications for webkitgtk.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 19 Sep 2016 16:03:19 +0000 (18:03 +0200)]
Drop suppressed ABI artifacts from the IR
This patch allows dropping suppressed ABI artifacts from the in-memory
internal representation right during the DWARF or abixml reading.
In practise, this means that abidw and abilint now have a
--suppressions options to give them suppression specifications. If a
suppression specification that has the "drop" property matches an ABI
artifact (type, function or variable) then that artifact is dropped
from the internal representation. This also applies to abidiff.
Note that now, by default, ABI artifacts (types) that are suppressed
due to the --headers-dir{1,2} option of abidiff are now also dropped
from the IR as well. Incidentally, abidw and abilint tools now have a
--header-dir option too.
* doc/manuals/abidw.rst: Document the new --suppressions and
--headers-dir options off the abidw tool.
* doc/manuals/abilint.rst: Document the new --suppressions and
--headers-dir options on the abilint tool.
* doc/manuals/libabigail-concepts.rst: Document the new "drop" and
"name_not_regexp" properties on suppression directives.
* include/abg-corpus.h (corpus::corpus): Add a default argument to
the path parameter.
* src/abg-suppression-priv.h: New private header file.
* src/Makefile.am: Add the new abg-suppression-priv.h file to
source distribution.
* include/abg-suppression.h ({suppression_base, type_suppression,
function_suppression, variable_suppression}::priv): Make these
public.
(suppression_base::{g,s}et_drops_artifact_from_ir): Declare new
member functions.
(type_suppression::{suppressed_type}): Likewise.
(suppression_base::{names,sonames}_of_binaries_match): Remove
member functions.
(function_suppression::{get_name, set_name, get_name_regex_str,
set_name_regex_str}): Renamed get_function_name,
set_function_name, get_function_name_regex_str,
set_function_name_regex_str into these.
({variable,function}_suppression::{g,s}et_name_not_regex_str):
Declare new member functions.
* src/abg-suppression.cc: Include the new abg-suppression-priv.h
private header.
(class suppression_base::priv, class type_suppression::priv, class
function_suppression::parameter_spec::priv, class
function_suppression::priv, class variable_suppression::priv):
Move these types to that new private header.
(suppression_base::{g,s}et_drops_artifact_from_ir)
(function_suppression::{g,s}et_name_not_regex_str)
(variable_suppression::{g,s}et_name_not_regex_str): New member
functions.
(sonames_of_binaries_match): New static function, taken from
suppression_base::sonames_of_binaries_match.
(names_of_binaries_match): New static function, taken from
suppression_base::names_of_binaries_match.
(suppression_matches_type_no_name): New static function.
(type_suppression::suppresses_type): Adjust
(function_suppression::suppresses_function)
(variable_suppression::suppresses_variable): Adjust. Evaluate the
new "name_not_regexp" property.
(suppression_matches_type_name)
(suppression_matches_type_location)
(suppression_matches_type_name_or_location)
(suppression_matches_function_name)
(suppression_matches_function_sym_name)
(suppression_matches_variable_name)
(suppression_matches_variable_sym_name, suppression_matches_type):
New functions.
(read_type_suppression): Support the new "drop_artifacts" and
"drop" properties.
(read_function_suppression, read_variable_suppression): Support
the new "drop_artifacts", "drop", and "name_not_regexp"
properties.
(function_suppression::{g,s}et_name): Renamed
{g,s}et_function_name into these.
(function_suppression::set_name_not_regex_str): Renamed
{g,s}et_name_regex_str into this.
(function_suppression::suppresses_function_symbol): Adjust.
* include/abg-dwarf-reader.h (add_read_context_suppressions):
Declare new function.
* src/abg-dwarf-reader.cc: Use the new private
abg-suppression-priv.h header file.
(read_context::supprs_): New data member.
(read_context::get_suppressions): New member function.
(read_context::get_die_source): Make this const.
(read_context::tu_die_imported_unit_points_map): Add a const
overload.
(read_context::cur_transl_unit): Renamed current_translation_unit
unit into this;
(read_context::cur_tu): Remove or rename into cur_transl_unit.
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_enum_type, build_pointer_type_def, build_reference_type)
(build_function_type, build_array_type, build_function_decl):
Adjust.
(read_context::{suppression_can_match,
suppression_matches_function_sym_name,
suppression_matches_function_name,
suppression_matches_variable_sym_name,
suppression_matches_variable_name,
suppression_matches_type_name_or_location,
suppression_matches_type_name}): Add member functions.
(die_signed_constant_attribute): Remove this as dead code.
(die_location, die_loc_and_name)
(find_import_unit_point_between_dies)
(find_import_unit_point_before_die, get_parent_die): Make the
read_context& parameter be const and adjust as required.
(build_var_decl_if_not_suppressed, function_is_suppressed)
(variable_is_suppressed, type_is_suppressed): Define new static
functions.
(add_read_context_suppressions): Define new function.
(build_class_type_and_add_to_ir): Do not add suppressed static
data members to the IR.
(build_ir_node_from_die): Do not add suppressed enum types, class
types, variables or functions to the IR. Adjust for the
read_context::cur_tu -> read_context::cur_transl_unit rename.
* include/abg-reader.h (read_context_sptr): Declare new type.
(create_native_xml_read_context, read_corpus_from_input)
(add_read_context_suppressions): Declare new functions.
* src/abg-reader.cc: Include the new private
abg-suppression-priv.h header file.
(read_context::m_exported_decls_builder): Renamed
m_exported_decls_builder_ into this.
(read_context::get_exported_decls_builder): Adjust.
(read_context::get_cur_scope): Make this const.
(read_location): Take a const read_context and adjust.
(read_corpus_from_input): Make this non-static.
(build_namespace_decl): Don't abort if trying to add an artifact
to the IR doesn't succeed. It might be suppressed now.
(read_context::{m_path, m_supprs}): New data members.
(read_context::{g,s}et_path): New member functions.
(read_context::{get_suppressions,
suppression_matches_function_name, suppression_can_match,
suppression_matches_function_name,
suppression_matches_function_sym_name,
suppression_matches_variable_name,
suppression_matches_variable_sym_name,
suppression_matches_type_name_or_location}): Likewise.
(add_read_context_suppressions, create_native_xml_read_context)
(read_corpus_from_native_xml): New functions.
(build_function_decl_if_not_suppressed, function_is_suppressed)
(type_is_suppressed, build_var_decl_if_not_suppressed)
(variable_is_suppressed, build_enum_type_decl_if_not_suppressed)
(build_class_decl_if_not_suppressed): New static functions.
(build_class_decl): Add member types that are being built early,
so that their sub-types can be evaluated for suppression. Do not
add suppressed static data members or suppressed member functions
to the IR.
(build_type): Do not add an enum type or a class type to the IR if
they are suppressed.
(handle_enum_type_decl): Do not add an enum type to the IR if its
suppressed.
(handle_var_decl): Likewise for a variable decl.
(handle_function_decl): Likewise for a function decl.
(handle_class_decl): Likewise for a class decl.
* src/abg-tools-utils.cc (handle_fts_entry): Drop suppressed ABI
from the IR.
* tools/abidiff.cc (display_usage): Fix help strings for
--headers-dirs{1,2}.
(set_suppressions): New static function.
(main): Adjust. Release the memory used by read_context early.
* tools/abidw.cc (options::{headers_dir, suppression_paths}):
(display_usage): New help strings for the new --header-dir and
--suppressions options.
(parse_command_line): Parse the new --header-dir and
--suppressions options.
(maybe_check_suppression_files, set_suppressions): New static
functions.
(main): Use the two new functions above. Free the memory used by
the read context before working with the corpus.
* tools/abilint.cc (options::suppression_paths):
(display_usage): New help strings for the new --header-dir and
--suppressions options.
(parse_command_line): Parse the new --header-dir and
--suppressions options.
(maybe_check_suppression_files, set_suppressions): New static
functions.
(main): Use the two new functions above. Free the memory used by
the read context before working with the corpus.
* tests/data/test-diff-suppr/test24-soname-suppr-{2,3].txt:
Adjust.
* tests/data/test-diff-suppr/test29-suppr-6.txt: Likewise.
* tests/data/test-diff-suppr/test29-suppr-8.txt: Likewise.
* tests/data/test-diff-suppr/libtest31-v{0,1}.so: New test input.
* tests/data/test-diff-suppr/libtest31.suppr: Likewise
* tests/data/test-diff-suppr/libtest32-v{0,1}.so: Likewise.
* tests/data/test-diff-suppr/libtest32-0.suppr: Likewise.
* tests/data/test-diff-suppr/libtest33-v{0,1}.so: Likewise.
* tests/data/test-diff-suppr/test31-report-{0,1}.txt: Likewise.
* tests/data/test-diff-suppr/test31-v{0,1}.cc: Likewise.
* tests/data/test-diff-suppr/test32-report-{0,1}.txt: Likewise.
* tests/data/test-diff-suppr/test32-v{0,1}.c: Likewise.
* tests/data/test-diff-suppr/test33-suppr-1.txt: Likewise.
* tests/data/test-diff-suppr/test33-v{0,1}.cc: Likewise.
* tests/data/test-diff-suppr/test33-v{0,1}.h: Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns.so: Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
* tests/data/test-read-dwarf/test24-drop-fns-0.suppr: Likewise.
* tests/data/test-read-dwarf/test24-drop-fns.cc: Likewise.
* tests/data/test-read-write/test28-drop-std-fns.abignore:
Likewise.
* tests/data/test-read-write/test28-drop-std-vars.abignore:
Likewise.
* tests/data/test-read-write/test28-without-std-fns-ref.xml:
Likewise.
* tests/data/test-read-write/test28-without-std-fns.xml: Likewise.
* tests/data/test-read-write/test28-without-std-vars-ref.xml:
Likewise.
* tests/data/test-read-write/test28-without-std-vars.xml:
Likewise.
* tests/data/test-read-write/test28.xml: Likewise.
* tests/data/Makefile.am: Add the new test artifacts to source
distribution.
* tests/test-diff-suppr.cc (in_out_spec): Take the new test inputs
into account.
* tests/test-read-dwarf.cc (Inoutspec::in_suppr_spec_path): New
data member.
(in_out_spec): Adjust. The new test inputs into account.
(set_suppressions): New static function.
(handle_in_out_spec): Adjust.
* tests/test-read-write.cc (Inoutspec::{in_suppr_spec_path,
ref_out_path}): New data members.
(in_out_spec): Adjust. Take new test inputs into account.
(main): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 19 Sep 2016 08:30:13 +0000 (10:30 +0200)]
Pimplify the abigail::ir::scope_decl type
The abigail::ir::scope_decl still has its data member members be
visible from its header file. This patch hides those data member
using the pimpl idiom, just as what is done other types throughout the
project.
* include/abg-ir.h (scope_decl::{priv, priv_sptr}) Declare new types.
(scope_decl::priv_): New pimpl data member.
(scope_decl::{member_, member_scopes}): Move this as data member
of the new scope_decl::priv type in the abg-ir.cc file.
(scope_decl::{scope_decl, get_member_decls, get_member_scopes,
is_empty}): Make these inline member functions be out-of-line.
* src/abg-ir.cc (struct scope_decl::priv): Define new type.
(scope_decl::{scope_decl, get_member_decls, get_member_scopes,
is_empty}): Define these new member functions here. They were
inline in the include/abg-ir.h header files before.
(scope_decl::{add_member_decl, insert_member_decl,
remove_member_decl}): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 19 Sep 2016 08:19:05 +0000 (10:19 +0200)]
Add new helper functions
In preparation of dropping ABI artifacts from the IR, add new generic
helper functions.
* include/abg-fwd.h (get_location, build_qualified_name): Declare
new functions.
* include/abg-ir.h (is_method_decl): Declare two new overloads of
this function.
* src/abg-ir.cc (get_location, build_qualified_name)
(is_method_decl): Define these functions declared above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 19 Sep 2016 08:40:53 +0000 (10:40 +0200)]
Do not emit empty namespaces in abixml
Today The abixml writer emits namespaces even if they are empty or
contain empty namespaces. This leads to abixml files that are
unnecessarily big and verbose. This patch prevents that.
* include/abg-ir.h
(namespace_decl::is_empty_or_has_empty_sub_namespaces): Declare
new function ...
* src/abg-ir.cc
(namespace_decl::is_empty_or_has_empty_sub_namespaces): ... and
define it.
* src/abg-writer.cc (write_namespace_decl): Do not write empty
namespaces or namespaces containing empty namespaces.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.
* tests/data/test-read-dwarf/test11-pr18828.so.abi: Adjust.
* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.
* tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust.
* tests/data/test-read-dwarf/test16-pr18904.so.abi: Adjust.
* tests/data/test-read-dwarf/test17-pr19027.so.abi: Adjust.
* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Adjust.
* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Adjust.
* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Adjust.
* tests/data/test-read-dwarf/test21-pr19092.so.abi: Adjust.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Adjust.
* tests/data/test-read-dwarf/libtest23.so.abi: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 21 Sep 2016 10:04:38 +0000 (12:04 +0200)]
Fix misleading indentation issues
This patch fixes misleading indentation mistakes reported by GCC 6.1.1
* tools/abipkgdiff.cc (compare): Likewise.
* tools/abisym.cc (main): Fix misleading indentation.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 30 Aug 2016 07:41:01 +0000 (09:41 +0200)]
Bug 20534 - abipkgdiff wrongly displays the name of added binary files
abipkgdiff displays an address instead of displaying the name of the
added binary file. This patch, which is from a diff that Sinny Kumari
attached to the bugzilla entry, fixes the issue.
* tools/abipkgdiff.cc (compare): Show the name of the added
binary, rather than its address.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 24 Aug 2016 08:37:08 +0000 (10:37 +0200)]
Bug 20420 - Wrong ODR-based type comparison optimization on qualified type
During type canonicalizing, qualified types are being compared using
the ODR-based optimization. This is wrong because, for instance, it's
not because two types from the same ABI corpus are both const
anonymous structs that they are meant to be equivalent.
This patch fixes the issue by applying the ODR-based comparison
optimization only to built-in types and non-anonymous struct and
enums.
The reproducer is a glibc package that takes a while to compare so
it's not suitable for inclusion in the test suite.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 23 Aug 2016 10:38:36 +0000 (12:38 +0200)]
Don't walk diff trees indefinitely when applying suppressions
When applying suppressions to diff graphs, if the same diff node
appears twice in the graph in a way that creates a cycle, we can get
trapped in the cycle when walking the graph. That results in a an
infinite loop. Note that the infinite loop appears in the
diff::traverse member function, in the for-loop that walks the
children nodes of a given node.
This patch avoids walking the same node twice when applying
suppressions.
The test binaries that exhibit the issue come from the two following
packages:
rh-mariadb101-mariadb-10.1.14-2.el6 and rh-mariadb101-mariadb-10.1.16-1.el6.
The sub-packages compared are
rh-mariadb101-mariadb-server-10.1.14-2.el6.x86_64.rpm and
rh-mariadb101-mariadb-server-10.1.16-1.el6.x86_64.rpm.
The debug info packages are
rh-mariadb101-mariadb-debuginfo-10.1.16-1.el6.x86_64.rpm and
rh-mariadb101-mariadb-debuginfo-10.1.14-2.el6.x86_64.rpm.
Once the packages are properly extracted the command line that
exhibits the infinite loop is:
abidiff --d1 rh-mariadb101-mariadb-10.1.14-2.el6.x86_64/usr/lib/debug --d2 rh-mariadb101-mariadb-10.1.16-1.el6.x86_64/usr/lib/debug rh-mariadb101-mariadb-10.1.14-2.el6.x86_64/opt/rh/rh-mariadb101/root/usr/lib64/mysql/plugin/ha_connect.so rh-mariadb101-mariadb-10.1.16-1.el6.x86_64/opt/rh/rh-mariadb101/root/usr/lib64/mysql/plugin/ha_connect.so
This patch has no test because of the cheer size of these packages;
the debug info packages alone take more than 100MB :-( I really hope
we set up a separate repository with big test packages to overcome
this. Maybe something using fedabipkgdiff ...
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 27 Jul 2016 10:18:58 +0000 (12:18 +0200)]
Control symbols exported from libabigail.so
Symbols of pretty much all member functions of types that are meant to
be "private" to translation units that contribute to libabigail.so
were exported because we didn't do much to prevent that.
This patch starts controlling the set of symbols that are exported.
By default, symbols of any entity declared in a translation unit that
contributes to libabigail.so are hidden by default. Only symbols of
entities declared in public headers (headers in include/*.h) are
exported.
There are many ways to achieve that. This patch chooses to avoid
cluttering declarations of entities in the public header by adding
__attribute__((visibility="default")) to every declared type of
function in there.
Rather, the patch uses "#pragma GCC visibility push(default)" before
entities declared on those headers. By doing so, all those entities
have their symbol marked as "visible" by the compiler. Once the
header are #included, the #pragma GCC visibility pop" is used, so that
anything else has its symbol be hidden from that point on.
Note that for ease of maintenance the patch uses the macros
ABG_BEGIN_EXPORT_DECLARATIONS and ABG_END_EXPORT_DECLARATIONS rather
than using the pragma directive directly.
I believe this is a more elegant way of handling visibility, compared
to cluttering every single declaration in public headers with a
"__attribute__((visibility=("default")))" or with a macro which
expands to it.
This reduces the the set of symbols exported by libabigail.so from
20000+ to less than 5000.
* VISIBILITY: New documentation about this visiblity business.
* CONTRIBUTING: Update the "contributing guide" to refer to symbol
visibility issues.
* configure.ac: Define a variable VISIBILITY_FLAGS that is set to
the -fvisibility=hidden flag to pass to GCC, when its available.
* src/Makefile.am: Add VISIBILITY to source distribution. Also
add COMPILING and COMMIT-LOG-GUIDELINES that were missing.
* src/Makefile.am: Use the new $(VISIBILITY_FLAGS) when buiding
the library.
* tests/Makefile.am: Use the new $(VISIBILITY_FLAGS) when buiding
tests.
* tools/Makefile.am: Use the new $(VISIBILITY_FLAGS) when buiding
tools.
* src/abg-comp-filter.cc: Enclose inclusion of public headers in
ABG_BEGIN_EXPORT_DECLARATIONS and ABG_END_EXPORT_DECLARATIONS to
export the symbols of entities declared in there.
* src/abg-comparison.cc: Likewise.
* src/abg-config.cc: Likewise.
* src/abg-corpus.cc: Likewise.
* src/abg-diff-utils.cc: Likewise.
* src/abg-dwarf-reader.cc: Likewise.
* src/abg-hash.cc: Likewise.
* src/abg-ini.cc: Likewise.
* src/abg-ir.cc: Likewise.
* src/abg-libxml-utils.cc: Likewise.
* src/abg-libzip-utils.cc: Likewise.
* src/abg-reader.cc: Likewise.
* src/abg-suppression.cc: Likewise.
* src/abg-tools-utils.cc: Likewise.
* src/abg-traverse.cc: Likewise.
* src/abg-viz-common.cc: Likewise.
* src/abg-viz-dot.cc: Likewise.
* src/abg-viz-svg.cc: Likewise.
* src/abg-workers.cc: Likewise.
* src/abg-writer.cc: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>