Commit Graph

364 Commits

Author SHA1 Message Date
Dodji Seketeli
6dc5e281da abipkgdiff: Fix showing added/removed files
When two packages are different just because one adds or removes
binaries -- and no binary have any ABI change otherwise, abipkgdiff
quits early and doesn't report the added and removed binaries.

This patch fixes the issue by reporting added/removed binaries even
when no ABI comparison took place.

	* tools/abipkgdiff.cc (compare_prepared_userspace_packages): Do
	not return early if there are no binaries to compare.  Also add
	more verbose messages.
	* tests/data/test-diff-pkg/libxcrypt-4.1.1-6.el8.x86_64--libxcrypt-4.1.1-6.el8.x86_64-output-1.txt:
	New reference output file.
	* tests/data/test-diff-pkg/libxcrypt-4.1.1-6.el8.x86_64--libxcrypt-compat-4.4.18-3.el9.x86_64-report-1.txt:
	New reference output file.
	* tests/data/test-diff-pkg/libxcrypt-4.1.1-6.el8.x86_64.rpm: New
	binary input file.
	* tests/data/test-diff-pkg/libxcrypt-4.4.18-3.el9.x86_64.rpm: Likewise.
	* tests/data/test-diff-pkg/libxcrypt-compat-4.4.18-3.el9.x86_64.rpm: Likewise.
	* tests/data/test-diff-pkg/libxcrypt-compat-debuginfo-4.4.18-3.el9.x86_64.rpm: Likewise.
	* tests/data/test-diff-pkg/libxcrypt-debuginfo-4.1.1-6.el8.x86_64.rpm: Likewise.
	* tests/data/test-diff-pkg/libxcrypt-debuginfo-4.4.18-3.el9.x86_64.rpm: Likewise.
	* tests/data/Makefile.am: Add the new testing files to source
	distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Add these binary packages
	to this testing harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-09-20 09:12:00 +02:00
Dodji Seketeli
46b1ab08b0 Bug 27995 - Self comparison error from abixml file
There are several self comparison issues uncovered by comparing the
file test-PR27995.abi (provided in the bug report) against itself.
This patch address them all as well as the regressions induced on some
of the test suite and then and updates the other reference test suite
output that need it.

In the equals overload for decl_base, we compare the non-internal
versions of qualified decl names.  For var_decls of anonymous class or
union types, the non-internal version is the flat-representation of
the type.  Thus a benign change in a data member name of the anonymous
type might cause the equals function to consider the var_decls to be
wrongly different.  The internal version of the qualified decl name
should return a name that is stable for types, irrespective of these
benign variations.  The patch thus makes the equals overload for
decl_base to compare internal versions of qualified decl names instead.

The patch ensures that enum_type_decl::get_pretty_representation
return and internal pretty representation that is "stable" for
anonymous types.  Basically, all anonymous enums will have the same of
name that looks like "__anonymous_enum__".  This is to ensure two
things: first, that all anonymous enums are compared against each
other during type canonicalization, ensuring that when two anonymous
enums are canonically different, it really is because of changes in
their enumerators or basic type, not because of anything having to do
with their artificial names.  Second, that in the equals overload for
decl_base, their internal qualified name always compare equal.  This
nullifies the risk of having anonymous types compare different because
of their (non existent) name.  This is because libabigail's dwarf
reader assigns artificial unique names to anonymous types, so we don't
want to use these during actual type comparison.

We do something similar for class_decl::get_pretty_representation and
union_decl::get_pretty_representation where the pretty internal
representation for class/union decl would now be
__anonymous_{struct,union}__.

The patch scouts the uses of get_pretty_representation() to make sure
to use avoid using the internal-form of the pretty representations
when it's not warranted.  It also updates the doxygen comments of the
overloads of that function.

In the abixml reader, we were wrongly canonicalizing array types
early, even before they were fully created.  The was leading to
spurious type chances down the road.

The patch also fixes the caching of the name of function types by
making it consistent with caching of the names of the other types of
the system.  The idea is that we don't cache the name of a function
type until it's canonicalize.  This is because the type might be
edited during its pre-canonicalization life time; and that editing
might change its name.  However once the type is canonicalized, it
becomes immutable.  At that point we can cache its name, for
performance purposes.  Note that we need to do that both for the
"internal version" of the type name (used for canonilization purposes)
and the "non-internal version" one, which is used for other purposes.

This caching scheme wasn't respected for function types, so we were
caching a potentially wrong name for the type after its
canonicalization.

Last but not least, there is a problem that makes canonical type
comparison different from structural type comparison.
Let's consider these two declarations:

    typedef int FirstInt;
    typedef int SecondInt;

Now, consider these two pointer types: FirstInt* and SecondInt*;
These two pointer types are canonically different because they have
different type names.  This is because during type canonicalization,
types with the same "pretty representation" are compared against each
other.  So types with different type names will certainly have
different pretty representations and won't be compared; they are thus
going to have different canonical types.

However, FirstInt* and SecondInt* do compare equal, structurally,
because the equals overload for pointer_type_def compares the
pointed-to types of pointers by peeling off typedefs.  So, here, as
both pointed-to types are 'int' when the typedefs are peeled off, the
two pointers structurally compare equal.  This discrepancy between
structural and canonical equality introduces subtle and spurious type
changes depending on the order in which types are canonicalized.  For
instance:

    struct {FirstInt* m0;};   /* First type.  */

    struct {SecondInt* m0;};  /* Second type. */

If FirstInt* and SecondInt* are canonicalized before their containing
anonymous types, then the two anonymous types will compare different
(because FirstInt* and SecondInt* compare different) and have
different canonical types.  If, however, the anonymous types are
canonicalized before FirstInt* and SecondInt*, then will compare equal
because FirstInt* and SecondInt* are structurally equivalent.
FirstInt* and SecondInt* will be canonicalized latter and have
different canonical types (because they have different type names)
despite being structurally equivalent.

The change in the order of canonicalization can happen when
canonicalizing types from a corpus coming from DWARF as opposed to
canonicalizing types from a corpus coming from abixml.

The patch fixes this discrepancy by not peeling off typedefs from the
pointed-to types when comparing pointers.  Note that this makes us
regress on bug https://sourceware.org/bugzilla/show_bug.cgi?id=27236,
where the typedef peeling was introduced.  In hindsight, introducing
that typedef peeling was a mistake.  I'll try to address that bug
again in a subsequent patch.

	* doc/manuals/abidiff.rst: Add documentation for the --debug
	option.
	* src/abg-ir.cc (equals): In the overload for decl_base consider
	the internal version of qualified decl name.  In the overload for
	pointer_type_def do not peel typedefs off from the compared
	pointed-to types.  In the overload for typedef_decl compare the
	typedef as a decl as well.  In the overload for var_decl, compare
	variables that have the same ELF symbols without taking into
	account their qualified name, rather than their name.  Stop
	comparing data member without considering their names.
	In the overload for class_or_union, when a decl-only class that is
	ODR-relevant is compared against another type, assume that
	equality if names are equal.  This is useful in environments where
	some TUs are ODR-relevant and others aren't.
	(*::get_pretty_representation): Update doxygen comments.
	(enum_type_decl::get_pretty_representation): Return an internal
	pretty representation that is stable across all anonymous enums.
	(var_decl::get_anon_dm_reliable_name): Use the non-internal pretty
	representation for anonymous data members.
	(function_type::priv::temp_internal_cached_name_): New data
	member.
	(function_type::get_cached_name): Cache the internal name after
	the function type is canonicalized.  Make sure internal name and
	non-internal name are cached separately.
	(class_or_union::find_anonymous_data_member): Look for the anonymous
	data member by looking at its non-internal name.
	({class, union}_decl::get_pretty_representation): Use something like "class
	__anonymous_{union,struct}__" for all anonymous classes, so that they can
	all be compared against each other during type canonicalization.
	(type_has_sub_type_changes): Use non-internal pretty
	representation.
	(hash_type_or_decl, function_decl_is_less_than:): Use internal
	pretty representation for comparison here.
	* src/abg-reader.cc (read_context::maybe_canonicalize_type): Don't
	early canonicalize array types.
	* src/abg-writer.cc (annotate): Use non-internal pretty
	representation.
	* tests/data/test-diff-filter/test-PR27995-report-0.txt: New
	reference report.
	* tests/data/test-diff-filter/test-PR27995.abi: New test input
	abixml file.
	* tests/data/Makefile.am: Add test-PR27995.abi,
	test-PR27995-report-0.txt to the source distribution.
	* tests/data/test-annotate/libtest23.so.abi: Adjust.
	* tests/data/test-diff-dwarf/test6-report.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-filter/test41-report-0.txt: Adjust.
	* tests/data/test-diff-filter/test43-decl-only-def-change-leaf-report-0.txt: Adjust.
	* tests/data/test-diff-filter/test8-report.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/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-0.txt:
	Adjust.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt:
	Adjust.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.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-diff-suppr/test39-opaque-type-report-0.txt: Adjust.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Adjust.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Adjust.
	* tests/data/test-read-dwarf/libtest23.so.abi: Adjust.
	* tests/data/test-read-dwarf/test-libandroid.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/test9-pr18818-clang.so.abi: Adjust.
	* tests/test-diff-filter.cc (in_out_specs): Add the
	test-PR27995.abi to the test harness.
	* tools/abidiff.cc (options::do_debug): New data member.
	(options::options): Initialize it.
	(parse_command_line): Parse --debug.
	(main): Activate self comparison debug if the user provided
	--debug.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-08-11 17:38:14 +02:00
Ben Woodard via Libabigail
519d7ce8e5 Fix trivial typo when printing version string
When abicompat prints its version string, it does not terminate
it with a newline the way that other commands do. Contributed by
Bolo.

	* tools/abicompat.cc (main): Add a newline after version string.

Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-06-10 15:27:35 +02:00
Dodji Seketeli
d604e33793 Revert "Fix trivial typo when printing version string"
This reverts commit ad619f14ea.
2021-06-10 15:26:36 +02:00
Ben Woodard via Libabigail
ad619f14ea Fix trivial typo when printing version string
When abicompat prints its version string, it does not terminate
it with a newline the way that other commands do. Contributed by
Bolo.

Signed-off-by: Ben Woodard <woodard@redhat.com>
2021-06-10 15:22:53 +02:00
Dodji Seketeli
923a355f16 abidw: Remove temporary .typeid files when using --debug-abidiff
I noticed that the temporary typeid file generated by abidw when using
the --debug-abidiff option was left behind.  This patch removes it.

	* tools/abidw.cc (load_corpus_and_write_abixml): Remove temporary
	typeid file after its use.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-06-09 19:45:22 +02:00
Dodji Seketeli
27d2927107 Detect abixml canonical type instability during abidw --debug-abidiff
In the debugging mode of self comparison induced by the invocation of
"abidw --debug-abidiff <binary>", it's useful to be able to ensure the
following invariant:

    The pointer value of the canonical type of a type T that is
    serialized into abixml with the id string "type-id-12" (for
    instance) must keep the same canonical type pointer value when
    that abixml file is de-serialized back into memory.  This is
    possible mainly because libabigail stays loaded in memory all the
    time during both serialization and de-serialization.

This patch adds support for detecting when that invariant is not
respected.

In other words it detects when the type build from de-serializing the
type which id is "type-id-12" (for instance) has a canonical type
which pointer value is different from the pointer value of the
canonical type (of the type) that was serialized as having the type id
"type-id-12".

This is done in three phases.

The first phase happens in the code of abidw itself; after the abixml
is written on disk, another file called the "typeid file" is written
on disk as well.  That later file contains a set of records; each
record associates a "type id string" (like the type IDs that appear in
the abixml file) to the pointer value of the canonical type that
matches that type id string.  That file is thus now available for
manual inspection during a later debugger session.  This is done by
invoking the new function write_canonical_type_ids.

The second phase appears right before abixml loading time.  The typeid
file is read back and the association "type-id string" <-> is stored
in a hash map that is returned by
environment::get_type_id_canonical_type_map().  This is done by
invoking the new function load_canonical_type_ids.

The third phase happens right after the canonicalization (triggered in
the abixml reader) of a type coming from abixml, corresponding to a
given type id.  It checks if the pointer value of the canonicalization
type just computed is the same as the one associated to that type id
in the map returned by environment::get_type_id_canonical_type_map.

This is a way of verifying the "stability" of a canonical type during
its serialization and de-serialization to and from abixml and it's
done as part of "abidw --debug-abidiff <binary>".

Just as an example, here is the kind of error output that I am getting
on a real life debugging session on a binary that exhibits self
comparison error:

    $ abidw  --debug-abidiff -d <some-binary>
    error: problem detected with type 'typedef Vmalloc_t' from second corpus
    error: canonical type for type 'typedef Vmalloc_t' of type-id 'type-id-179' changed from '1a083e8' to '21369b8'
    [...]
    $

From this output, I see that the first type for which libabigail
exhibits an instability on the pointer value of the canonical type is
the type 'typedef Vmalloc_t'.  In other words, when that type is saved
to abixml, the type we read back is different.  This needs further
debugging but at least it pinpoints exactly what type we are seeing
the core issue on first.  This is of a tremendous help in the root
cause analysis needed to understand why the self comparison is
failing.

	* include/abg-ir.h (environment::get_type_id_canonical_type_map):
	Declare new data member.
	* src/abg-ir.cc (environment::priv::type_id_canonical_type_map_):
	Define new data member.
	(environment::get_type_id_canonical_type_map): Define new method.
	* include/abg-reader.h (load_canonical_type_ids): Declare new
	function.
	* src/abg-reader.cc (read_context::m_pointer_type_id_map):
	Define new data member.
	(read_context::{get_pointer_type_id_map,
	maybe_check_abixml_canonical_type_stability}): Define new methods.
	(read_context::{maybe_canonicalize_type,
	perform_late_type_canonicalizing}): Invoke
	maybe_perform_self_comparison_canonical_type_check after
	canonicalization to perform canonicalization type stability
	checking.
	(build_type): Associate the pointer value for the newly built type
	with the type id string identifying it in the abixml.  Once the
	abixml representation is dropped from memory and we are about to
	perform type canonicalization, we can still know what the type id
	of a given type coming from abixml was; it's thus possible to
	verify that the canonical type associated to that type id is the
	same as the one stored in the typeid file.
	(read_type_id_string): Define new static function.
	(load_canonical_type_ids): Define new function.
	* include/abg-writer.h (write_canonical_type_ids): Likewise.
	* src/abg-writer.cc (write_canonical_type_ids): Define new
	function overloads.
	* tools/abidw.cc (options::type_id_file_path): New data member.
	(load_corpus_and_write_abixml): Write and read back the typeid
	file.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-05-25 12:24:26 +02:00
Dodji Seketeli
104468d1a4 Detect failed self comparison in type canonicalization of abixml
During the self comparison triggered by "abidw --abidiff <binary>",
some comparison errors can happen when canonicalizing types that are
"de-serialized" from the abixml that was serialized from the input
binary.

This patch adds some debugging checks and messaging to emit a message
when a type from the abixml appears to not "match" the original type
from the initial corpus it originated from.

This is the more detailed description:

Let's consider a type T coming from the corpus of the input binary.

That input corpus is serialized into abixml and de-serialized again
into a second corpus that we shall name the abixml corpus.  From that
second corpus, let's consider the type T' that is the result of
serializing T into abixml and de-serializing it again.  T is said to
be the original type of T'.  If T is a canonical type, then T' should
equal T.  Otherwise, if T is not a canonical type, its canonical type
should equal the canonical type of T'.

For the sake of simplicity, let's consider that T is a canonical
type.  During the canonicalization of T', T' should equal T.  Each and
every canonical type coming from the abixml corpus should be equal to its
original type from the binary corpus.

If a T' is different from its original type T, then there is an
"equality problem" between T and T'.  In other words, there is a
mismatch between T and T'.  We want to be notified of that problem so
that we can debug it further and fix it.

So this patch introduces the option "abidw --debug-abidiff <binary>"
to trigger the "debug self comparison mode".  At canonicalization
time, we detect that we are in that debug self comparison mode and
during canonicalization of types from the abixml corpus, it detects
when they compare different from their counterpart from the original
corpus.

This debugging capability can be enabled at configure time with a new
--enable-debug-self-comparison configure option.  That option defines
a new WITH_DEBUG_SELF_COMPARISON compile time macro that is used to
conditionally compile the implementation of this debugging feature.

So, one example of this might look like this:

    abidw  --debug-abidiff bin:
    error: problem detected with type 'typedef Vmalloc_t' from second corpus
    error: problem detected with type 'Vmalloc_t*' from second corpus
    [...]

So that means the "typedef Vmalloc_t" read from the abixml compares
different from its original type where it should not.

So armed with this new insight, I know I need to debug that comparison
in particular to see why it wrongly results in two different types.

	* doc/manuals/abidw.rst: Add documentation for the --debug-abidiff
	option.
	* include/abg-ir.h (environment::{set_self_comparison_debug_input,
	get_self_comparison_debug_inputs, self_comparison_debug_is_on}):
	Declare new methods.
	* configure.ac: Define a new --enable-debug-self-comparison option
	that is disabled by default.  That option defines a new
	WITH_DEBUG_SELF_COMPARISON preprocessor macro.
	* src/abg-ir.cc
	(environment::priv::{first_self_comparison_corpus_,
	second_self_comparison_corpus_, self_comparison_debug_on_}): New
	data members.  Also, re-indent the data members.
	(environment::{set_self_comparison_debug_input,
	get_self_comparison_debug_inputs, self_comparison_debug_is_on}):
	Define new method.
	(type_base::get_canonical_type_for): In the "debug self comparison
	mode", if a type coming from the second corpus compares different
	from its counterpart coming from the first corpus then log a debug
	message.
	* src/abg-dwarf-reader.cc (read_debug_info_into_corpus): When
	loading the first corpus, if the debug self comparison mode is on,
	then save that corpus on the side in the environment.
	* src/abg-reader.cc (read_corpus_from_input): When loading the
	second corpus, if the debug self comparison mode is on, then save
	that corpus on the side in the environment.
	* tools/abidw.cc: Include the config.h file for preprocessor
	macros defined at configure
	(options::debug_abidiff): New data member.
	(parse_command_line): Parse the --debug-abidiff option.
	(load_corpus_and_write_abixml): Switch the self debug mode on when
	the --debug-abidiff option is provided.  Use a read_context for
	the abixml loading.  That is going to be useful for subsequent
	patches.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-05-25 12:16:25 +02:00
Dodji Seketeli
dd55550355 reader: Handle 'abi-corpus' element being possibly empty
This problem was reported at https://sourceware.org/bugzilla/show_bug.cgi?id=27616.

The abixml reader wrongly assumes that the 'abi-corpus' element is
always non-empty.  Note that until now, the only emitter of abixml
consumed in practice was abg-writer.cc and it only emits non-empty
'abi-corpus' elements.  So the issue wasn't exposed.

So, the reader assumes that an 'abi-corpus' element has at least a
text node.

For instance, consider this minimal input file named test-v0.abi:

    $cat test-v0.abi

    <abi-corpus-group architecture='elf-arm-aarch64'>
     <abi-corpus path='vmlinux' architecture='elf-arm-aarch64'>
     </abi-corpus>
    </abi-corpus-group>

    $

Now, compare it to this file where the abi-corpus element is an empty
element (doesn't even contain any text):

    $cat test-v0.abi

    <abi-corpus-group architecture='elf-arm-aarch64'>
     <abi-corpus path='vmlinux'/>
    </abi-corpus-group>

    $

comparing the two files with abidiff (wrongly) reports:

    $ abidiff test-v0.abi test-v1.abi
    ELF architecture changed
    Functions changes summary: 0 Removed, 0 Changed, 0 Added function
    Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

    architecture changed from 'elf-arm-aarch64' to ''
    $

What's happening is that read_corpus_from_input is getting out early
when it sees that the node is empty.  This is at:

   xmlNodePtr node = ctxt.get_corpus_node();
@@ -1907,10 +1925,14 @@ read_corpus_from_input(read_context& ctxt)
 	corp.set_soname(reinterpret_cast<char*>(soname_str.get()));
     }

  if (!node->children)  // <---- we get out early here and we
    return nil;         // forget about the properties of
                        // the current empty corpus element node

So, at its core, fixing the issue at hand involves avoiding the early
return there.

But then, it turns out that's not enough.

In the current setting, the different abixml processing entry points
are designed to be used in a semi "streaming" mode.

So for instance, read_translation_unit_from_input can be invoked
repeatedly to "stream in" the next translation unit at each
invocation.

Alternatively, the lower level xmlTextReaderNext can be used to
iterate over XML node until we reach the translation unit XML element
we are interested in.  At that point xmlTextReaderExpand can be used
to expand the XML node, then we let the context know that this is
the current node of the corpus that needs to be processed, using
read_context::get_corpus_node.  Once we've done that,
read_translation_unit_from_input can be called to process that
particular corpus node.  Note that the corpus node at hand, that needs
to be processed will be retrieved by read_context::get_corpus_node.

These two modes of operation are also available for
read_corpus_from_input, read_symbol_db_from_input,
read_elf_needed_from_input etc.

Today, these functions all assume that the current node returned by
read_context::get_corpus_node is the node /before/ the node of the
corpus to be processed.  So they all start looking at the /next sibling/
of the node returned by read_context::get_corpus_node.  So the code
was implicitly assuming that read_context::get_corpus_node was
pointing to a text node that was before the node of the corpus that we
want to process.

This is wrong.  read_context::get_corpus_node should just return the
current node of the corpus that needs to be processed and voila.

And so read_context::set_corpus_node should be used to set the current
node of the corpus to the current element node that needs to be processed.

That's the spirit of the change done by this patch.

As its name suggests, the existing
xml::advance_to_next_sibling_element is used to skip non element xml
nodes (including text nodes) and move to the next element node to
process, which is set to the context using
read_context::set_corpus_node.

Then the actual processing functions like read_corpus_from_input get
the node to process, using read_context::get_corpus_node and process
it rather than processing the sibling node that comes after it.

The other changes are either to prevent related crashes that I noticed
while doing various tests, update the abilint tool used to read and
debug abixml input files and add better documentation.

	* src/abg-reader.cc (read_context::get_corpus_node): Add comment
	to this member function.
	(read_translation_unit_from_input, read_symbol_db_from_input)
	(read_elf_needed_from_input): Start processing the current node of
	the corpus that needs to be processed rather than its next
	sibling.  Once the processing is done, set the new "current node
	of the corpus to be processed" properly by skipping to the next
	element node to be processed.
	(read_corpus_from_input): Don't get out early when the
	'abi-corpus' element is empty.  If, however, it has children node,
	skip to the first child element and flag it -- using
	read_context::set_corpus_node -- as being the element node to be
	processed by the processing facilities of the reader.  If we are
	in a mode where we called xmlTextReaderExpand ourselves to get the
	node to process, then it means we need to free that node
	indirectly by calling xmlTextReaderNext.  In that case, that node
	should not be flagged by read_context::set_corpus_node.  Add more
	comments.
	* src/abg-corpus.cc (corpus::is_empty): Do not crash when no
	symtab is around.
	* src/abg-libxml-utils.cc (go_to_next_sibling_element_or_stay):
	Fix typo in comment.
	(advance_to_next_sibling_element): Don't crash when given a nil
	node.
	* tests/data/test-abidiff/test-PR27616-squished-v0.abi: Add new
	test input.
	* tests/data/test-abidiff/test-PR27616-squished-v1.abi: Likewise.
	* tests/data/test-abidiff/test-PR27616-v0.xml: Likewise.
	* tests/data/test-abidiff/test-PR27616-v1.xml: Likewise.
	* tests/data/Makefile.am: Add the new test inputs above to source
	distribution.
	* tests/test-abidiff.cc (specs): Add the new tests inputs above to
	this harness.
	* tools/abilint.cc (main): Support writing corpus groups.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-05-03 17:13:31 +02:00
Matthias Maennich
3abd9742b7 dwarf reader: drop (now) unused code related to symbol table reading
The introduction of the new symtab reader incorporated much of the
existing functionality. Now that the most code parts are migrated to the
new symtab reader, we can safely remove the old code paths.

Ignoring the symbol table is not a thing anymore. The new symtab reader
does read the symtab unconditionally for consistency reasons. Hence also
remove all functionality around conditional symtab reading.

	* include/abg-dwarf-reader.h (set_ignore_symbol_table): Remove.
	(get_ignore_symbol_table): Likewise.
	* src/abg-dwarf-reader.cc (add_symbol_to_map): Likewise.
	(read_context::options_type::ignore_symbol_table): Likewise.
	(read_context::options_type): Adjust.
	(read_context::fun_addr_sym_map_): Remove.
	(read_context::fun_entry_addr_sym_map_): Likewise.
	(read_context::fun_syms_): Likewise.
	(read_context::var_addr_sym_map_): Likewise.
	(read_context::var_syms_): Likewise.
	(read_context::undefined_fun_syms_): Likewise.
	(read_context::undefined_var_syms_): Likewise.
	(read_context::initialize): Adjust.
	(read_context::lookup_elf_symbol_from_index): Remove.
	(read_context::fun_entry_addr_sym_map_sptr): Likewise.
	(read_context::fun_entry_addr_sym_map): Likewise.
	(read_context::fun_syms_sptr): Likewise.
	(read_context::fun_syms): Likewise.
	(read_context::var_syms_sptr): Likewise.
	(read_context::var_syms): Likewise.
	(read_context::undefined_fun_syms_sptr): Likewise.
	(read_context::undefined_var_syms_sptr): Likewise.
	(read_context::load_symbol_maps_from_symtab_section): Likewise.
	(read_context::load_symbol_maps): Likewise.
	(read_context::maybe_load_symbol_maps): Likewise.
	(set_ignore_symbol_table): Likewise.
	(get_ignore_symbol_table): Likewise.
	(create_default_var_sym): Likewise.
	(build_var_decl): Adjust.
	(function_is_suppressed): Likewise.
	(variable_is_suppressed): Likewise.
	(build_function_decl): Likewise.
	(add_symbol_to_map): Remove.
	(read_corpus_from_elf): Adjust.
	(build_corpus_group_from_kernel_dist_under): Likewise.
	* tools/abidw.cc (main): Likewise.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2021-04-02 15:48:23 +02:00
Ben Woodard via Libabigail
05d33d607a Bug 27512 - Remove broken zip-archive support
The optional zip archive feature was broken when the concept of
environment was introduced by commit b2e5366d3 back in 2015. Since it
wouldn't even compile and nobody noticed, we are fairly sure nobody
uses that feature. Therefore, we decided to remove it rather than fix
it.

	* configure.ac: remove --enable-zip-archive option and logic
	associated with it.
	* include/abg-libzip-utils.h: Remove.
	* src/abg-libzip-utils.cc: Likewise.
	* include/Makefile.am: remove reference to include/abg-libzip-utils.h
	that no longer exists.
	* src/Makefile.am: remove reference to src/abg-libzip-utils.cc that no
	longer exists.
	* relicensing-scripts/file-licenses.orig.txt: remove references to
	files that no longer exist.
	* relicensing-scripts/files-with-lgplv3.txt: remove references to
	files that no longer exist.
	* tests/test-write-read-archive.cc: Remove because it tests code
	that no longer exists.
	* tests/Makefile.am: remove reference to tests that no longer exist.
	* include/abg-reader.h: remove conditionally compiled code for zip
	archives.
	* include/abg-tools-utils.h: remove conditionally compiled code for
	zip archives.
	* src/abg-corpus.cc: remove conditionally compiled code for zip
	archives.
	* src/abg-reader.cc: remove conditionally compiled code for zip
	archives.
	* src/abg-tools-utils.cc: remove conditionally compiled code for zip
	archives.
	* src/abg-writer.cc: remove conditionally compiled code for zip
	archives.
	* tools/abidiff.cc: remove conditionally compiled code for zip
	archives.
	* tools/abilint.cc: remove conditionally compiled code for zip
	archives.
	* tools/abiar.c: Remove.
	* tools/Makefile.am: remove references to abiar a utility that no
	longer has a reason for existing.

Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-03-19 10:52:57 +01:00
Ben Woodard via Libabigail
701de3ba5d Fix declaratons of conditionally defined functions
Functions relating to zip archives are declared but are never compiled
when --enable-zip-archive=no, the default.

This makes sure that they are not declared when they won't be defined
due to conditional compilation.

	* include/abg-reader.h (read_corpus_from_file): Guard the
	declaration of these overloads with #ifdef WITH_ZIP_ARCHIVE.
	* tools/abilint.cc: Guard the use of
	abigail::xml_reader::read_corpus_from_file with #ifdef
	WITH_ZIP_ARCHIVE.

Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-03-08 13:05:43 +01:00
Dodji Seketeli
f433d4dbdb Revert "Fix declaratons of conditionally defined functions"
I forgot to edit the commit message of this commit to make it comply
with the rules in https://sourceware.org/git/?p=libabigail.git;a=blob;f=COMMIT-LOG-GUIDELINES.

So I am reverting commit cd2af9e5f5
2021-03-08 13:04:13 +01:00
Ben Woodard via Libabigail
cd2af9e5f5 Fix declaratons of conditionally defined functions
Functions relating to zip archives are declared but are never compiled
when --enable-zip-archive=no, the default.

This makes sure that they are not declared when they won't be defined
due to conditional compilation.

Signed-off-by: Ben Woodard <woodard@redhat.com>
2021-03-08 12:52:50 +01:00
Dodji Seketeli
23046152e0 Bump ABIXML format version to 2.0
After fixing the interpretation of the DW_AT_bit_offset attribute for
offset of bit field data members, serialized abixml might now be
incompatible with versions of Libabigail that use the previous
interpretation.

That means that comparing an abixml file generated with previous
versions of Libabigail against a corpus resulting from an analysis
performed with the current version of libabigail might yield spurious
changes due to the differences in the way we now interpret the
DW_AT_bit_offset.

Hence, this patch bumps the version of abixml files emitted from now
on to "2.0".  This version is deemed incompatible with the previous
"1.0" version.

Subsequently, an abixml file of the "1.0" format cannot be compared
against an abixml file of the "2.0" format, or against a binary
analyzed with a current version of Libabigail.

It's thus advised that abixml files of the "1.0" format version should
be re-generated with a current version of Libabigail, bumping their
format version number to the new "2.0".

	* include/abg-corpus.h (corpus::init_format_version): Declare new
	private method.
	(corpus::set_environment): Make this non-const.
	(corpus::{get,set}_format_{major,minor}_version_number): Declare
	new accessors.
	* src/abg-corpus.cc (corpus::init_format_version): Define new
	method.
	(corpus::set_environment): By default, initialize the format
	version number of the corpus to the one supported by Libabigail.
	(corpus::{get,set}_format_{major,minor}_version_number): Define
	new accessors.
	* include/abg-ir.h: Include abg-config.h to use the
	abigail::config.
	(environment::get_config): Declare new accessor.
	* src/abg-ir.cc (environment::priv::config_): Add new data member.
	(environment::get_config): Define new accessor.
	* src/abg-config.cc (config::config): Bump the format
	version number to "2.0".
	* src/abg-corpus-priv.h
	(corpus::priv::format_{major,minor}_version_number_): Add new data members.
	* src/abg-reader.cc (handle_version_attribute): Define new static
	function.
	(read_corpus_from_input, read_corpus_group_from_input): Use it to
	read the value of the "version" attribute and set the format
	version number of the corpus and corpus group accordingly.
	* src/abg-writer.cc (write_context::m_config): Remove the config
	object because we can now get it from the environment.
	(write_context::get_config): Get the config object from the
	environment.
	(write_translation_unit): Do not emit the version attribute on the
	translation unit element anymore.
	(write_version_info): Define static function.
	(write_corpus, write_corpus_group): Use it to emit version
	attribute on both the corpus and corpus group elements.
	* tools/abidiff.cc
	(emit_incomptatible_format_version_error_message): Define new
	static function.
	(main): Ensure that corpora and corpus groups being compared have
	the same major version number.
	* tests/update-test-output.py: Adjust syntax for python3.
	* tests/data/test-annotate/libtest23.so.abi: Adjust.
	* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Likewise.
	* tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-annotate/test-anonymous-members-0.o.abi:
	Likewise.
	* tests/data/test-annotate/test0.abi: Likewise.
	* tests/data/test-annotate/test1.abi: Likewise.
	* tests/data/test-annotate/test13-pr18894.so.abi: Likewise.
	* tests/data/test-annotate/test14-pr18893.so.abi: Likewise.
	* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
	* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-annotate/test2.so.abi: Likewise.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
	* tests/data/test-annotate/test3.so.abi: Likewise.
	* tests/data/test-annotate/test4.so.abi: Likewise.
	* tests/data/test-annotate/test5.o.abi: Likewise.
	* tests/data/test-annotate/test6.so.abi: Likewise.
	* tests/data/test-annotate/test7.so.abi: Likewise.
	* tests/data/test-annotate/test8-qualified-this-pointer.so.abi:
	Likewise.
	* tests/data/test-diff-dwarf-abixml/PR25409-librte_bus_dpaa.so.20.0.abi:
	Likewise.
	* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1-report-0.txt:
	Likewise.
	* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi:
	Likewise.
	* tests/data/test-diff-suppr/libtest48-soname-abixml-v0.so.abi:
	Likewise.
	* tests/data/test-diff-suppr/libtest48-soname-abixml-v1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR24378-fn-is-not-scope.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise.
	* tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: 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/test-PR26568-1.o.abi: Likewise.
	* tests/data/test-read-dwarf/test-PR26568-2.o.abi: Likewise.
	* tests/data/test-read-dwarf/test0.abi: Likewise.
	* tests/data/test-read-dwarf/test0.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test1.abi: Likewise.
	* tests/data/test-read-dwarf/test1.hash.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/test2.so.abi: Likewise.
	* tests/data/test-read-dwarf/test2.so.hash.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/test3.so.abi: Likewise.
	* tests/data/test-read-dwarf/test3.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test4.so.abi: Likewise.
	* tests/data/test-read-dwarf/test4.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test5.o.abi: Likewise.
	* tests/data/test-read-dwarf/test5.o.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test6.so.abi: Likewise.
	* tests/data/test-read-dwarf/test6.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test7.so.abi: Likewise.
	* tests/data/test-read-dwarf/test7.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.hash.abi:
	Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
	* tests/data/test-read-write/test0.xml: Likewise.
	* tests/data/test-read-write/test1.xml: Likewise.
	* tests/data/test-read-write/test10.xml: Likewise.
	* tests/data/test-read-write/test11.xml: Likewise.
	* tests/data/test-read-write/test12.xml: Likewise.
	* tests/data/test-read-write/test13.xml: Likewise.
	* tests/data/test-read-write/test14.xml: Likewise.
	* tests/data/test-read-write/test15.xml: Likewise.
	* tests/data/test-read-write/test16.xml: Likewise.
	* tests/data/test-read-write/test17.xml: Likewise.
	* tests/data/test-read-write/test18.xml: Likewise.
	* tests/data/test-read-write/test19.xml: Likewise.
	* tests/data/test-read-write/test2.xml: Likewise.
	* tests/data/test-read-write/test20.xml: Likewise.
	* tests/data/test-read-write/test21.xml: Likewise.
	* tests/data/test-read-write/test22.xml: Likewise.
	* tests/data/test-read-write/test23.xml: Likewise.
	* tests/data/test-read-write/test24.xml: Likewise.
	* tests/data/test-read-write/test25.xml: Likewise.
	* tests/data/test-read-write/test26.xml: Likewise.
	* tests/data/test-read-write/test27.xml: Likewise.
	* tests/data/test-read-write/test28-without-std-fns-ref.xml:
	Likewise.
	* tests/data/test-read-write/test28-without-std-vars-ref.xml:
	Likewise.
	* tests/data/test-read-write/test3.xml: Likewise.
	* tests/data/test-read-write/test4.xml: Likewise.
	* tests/data/test-read-write/test5.xml: Likewise.
	* tests/data/test-read-write/test6.xml: Likewise.
	* tests/data/test-read-write/test7.xml: Likewise.
	* tests/data/test-read-write/test8.xml: Likewise.
	* tests/data/test-read-write/test9.xml: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-02-01 14:09:29 +01:00
Dodji Seketeli
1d29610d51 Bug 27255 - fedabipkgdiff fails on nfs-utils on Fedora 33
When running fedabipkgdiff as:

    fedabipkgdiff --self-compare -a --from fc33 nfs-utils

I am getting:

    Error encountered while running fedabipkgdiff with error message:

Running it with the --verbose option yields more clue, though.

It turns out that fedabipkgdiff runs abipkgdiff on an RPM and gives it
the wrong associated -debuginfo RPM.

This is because the member function
RPMCollection.get_sibling_debuginfo() doesn't returns the "first"
debuginfo package that comes with a given RPM.  In the case of the
package nfs-utils-2.5.2-1.rc4.fc33.aarch64.rpm, it was using the
package nfs-utils-coreos-debuginfo-2.5.2-1.rc4.fc33.aarch64.rpm
instead of the package nfs-utils-debuginfo-2.5.2-1.rc4.fc33.aarch64.rpm.

So, of course, abipkgdiff could not find the proper debuginfo for the
binaries carried by nfs-utils-2.5.2-1.rc4.fc33.aarch64.rpm.

This happens only in cases where there a several debuginfo packages
for a given RPM.  In that case, we need to be more careful to select
the right debuginfo package and not just a random one.

This patch adds a RPMCollection.get_matching_debuginfo() member function
that does the right thing.  It thus teaches
generate_comparison_halves() to use the new function.

	* tools/fedabipkgdiff (RPMCollection::get_sibling_debuginfo):
	Update comment.
	(RPMCollection::get_matching_debuginfo): Define new function.
	(generate_comparison_halves): Use
	RPMCollection::get_matching_debuginfo instead of
	RPMCollection::get_sibling_debuginfo.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-01-27 11:20:48 +01:00
Dodji Seketeli
40709acdd5 Bug 27232 - fedabipkgdiff fails on gawk from Fedora 33
When running fedabipkgdiff on the gawk-5.1.0-2.fc33.aarch64.rpm
package we get this error message:

    Error encountered while running fedabipkgdiff with error message:

That is not a very useful error message to say the least.

The issue is that abipkgdiff returns with an "unknown error" which is
due to the fact that the gawk package contains a directory that is
owned by root.  As abipkgdiff tries to write temporary files into that
directory, it fails to do so.

The patch now writes the temporary ABIXML file into a sub-directory
that is not owned the package where we should have write privileges.

It also improves error reporting.

	* tools/abipkgdiff.cc (options::pkg{1,2}): Add new data members to
	store the packages to compare and have them available for the
	various functions that may need them down the road.
	(package::create_abi_file_path): Add new function.
	(compare_to_self): Use the new package::create_abi_file_path to
	create the path to the ABI file in a directory not owned by the
	package.  That should increase our chances of having the rights to
	write that one.  Make sure to emit error message when the
	comparison against self fails.
	({compare_task, self_compare_task}::perform): During the process
	of comparison if an internal error happens, report it.  Cleanup
	the existing reporting a little bit.
	(pkg_extraction_task::perform): Fix comment.
	* tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt:
	Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-01-26 17:41:33 +01:00
Matthias Maennich
840eca4714 abipkgdiff: Address operator precedence warning
When compiling with clang, it (rightfully) complains about an operator
precedence issue:

abipkgdiff.cc:1646:7: error: operator '?:' has lower precedence than '<<'; '<<' will be evaluated first [-Wparentheses]
      ? string("Comparison against self SUCCEEDED\n")
      ^

Fix that by properly placing the parentheses. Also, drop the superfluous
string conversion.

	* tools/abipkgdiff.cc (compare_to_self): address clang warning.

Signed-off-by: Matthias Maennich <maennich@google.com>
2021-01-26 17:19:08 +01:00
Matthias Maennich
c458e00db9 Drop unneccessary includes of abg-cxx-compat.h
Remove the unneccessary includes of abg-cxx-compat.h as users have been
migrated to use the corresponding standard includes.

	* include/abg-comparison.h: Remove include of abg-cxx-compat.h.
	* include/abg-diff-utils.h: Likewise.
	* include/abg-fwd.h: Likewise.
	* include/abg-ini.h: Likewise.
	* include/abg-interned-str.h: Likewise.
	* include/abg-ir.h: Likewise.
	* include/abg-libxml-utils.h: Likewise.
	* include/abg-libzip-utils.h: Likewise.
	* include/abg-regex.h: Likewise.
	* include/abg-reporter.h: Likewise.
	* include/abg-sptr-utils.h: Likewise.
	* include/abg-suppression.h: Likewise.
	* include/abg-tools-utils.h: Likewise.
	* include/abg-workers.h: Likewise.
	* src/abg-comp-filter.cc: Likewise.
	* src/abg-comparison-priv.h: Likewise.
	* src/abg-corpus.cc: Likewise.
	* src/abg-dwarf-reader.cc: Likewise.
	* src/abg-hash.cc: Likewise.
	* src/abg-ir.cc: Likewise.
	* src/abg-reader.cc: Likewise.
	* src/abg-suppression.cc: Likewise.
	* src/abg-tools-utils.cc: Likewise.
	* src/abg-writer.cc: Likewise.
	* tests/test-diff-suppr.cc: Likewise.
	* tests/test-read-write.cc: Likewise.
	* tools/abicompat.cc: Likewise.
	* tools/abidw.cc: Likewise.
	* tools/abilint.cc: Likewise.
	* tools/abipkgdiff.cc: Likewise.

Signed-off-by: Matthias Maennich <maennich@google.com>
2020-12-15 09:23:44 +01:00
Matthias Maennich
5d669e0126 Remove <unordered_set> usages from abg_compat
std::unordered_set is now provided through the language standard, hence
remove the compatibility code for <unordered_set> and adjust all users
accordingly.

	* include/abg-cxx-compat.h: Drop compatibility for <unordered_set>.
	* include/abg-comparison.h: migrate abg_compat use to std.
	* include/abg-interned-str.h: Likewise.
	* include/abg-suppression.h: Likewise.
	* src/abg-comparison-priv.h: Likewise.
	* src/abg-dwarf-reader.cc: Likewise.
	* tests/test-diff-suppr.cc: Likewise.
	* tools/abipkgdiff.cc: Likewise.

Signed-off-by: Matthias Maennich <maennich@google.com>
2020-12-15 09:21:38 +01:00
Matthias Maennich
de344c0122 Remove <memory> usages from abg_compat
std::shared_ptr, std::weak_ptr, std::dynamic_pointer_cast,
std::static_pointer_cast are now provided through the language standard,
hence remove the compatibility code for <memory> and adjust all users
accordingly.

	* include/abg-cxx-compat.h: Drop compatibility layer for <memory>.
	* include/abg-diff-utils.h: migrate abg_compat use to std.
	* include/abg-fwd.h: Likewise.
	* include/abg-ini.h: Likewise.
	* include/abg-interned-str.h: Likewise.
	* include/abg-libxml-utils.h: Likewise.
	* include/abg-libzip-utils.h: Likewise.
	* include/abg-regex.h: Likewise.
	* include/abg-reporter.h: Likewise.
	* include/abg-sptr-utils.h: Likewise.
	* include/abg-tools-utils.h: Likewise.
	* include/abg-workers.h: Likewise.
	* src/abg-comp-filter.cc: Likewise.
	* src/abg-comparison-priv.h: Likewise.
	* src/abg-dwarf-reader.cc: Likewise.
	* src/abg-ir.cc: Likewise.
	* src/abg-reader.cc: Likewise.
	* src/abg-suppression.cc: Likewise.
	* src/abg-tools-utils.cc: Likewise.
	* src/abg-writer.cc: Likewise.
	* tests/test-diff-filter.cc: Likewise.
	* tests/test-diff-pkg.cc: Likewise.
	* tests/test-diff-suppr.cc: Likewise.
	* tests/test-read-dwarf.cc: Likewise.
	* tests/test-read-write.cc: Likewise.
	* tests/test-types-stability.cc: Likewise.
	* tests/test-write-read-archive.cc: Likewise.
	* tools/abicompat.cc: Likewise.
	* tools/abidiff.cc: Likewise.
	* tools/abidw.cc: Likewise.
	* tools/abilint.cc: Likewise.
	* tools/abipkgdiff.cc: Likewise.

Signed-off-by: Matthias Maennich <maennich@google.com>
2020-12-15 09:08:52 +01:00
Dodji Seketeli
c80f79271a Re-license the project to Apache v2 With LLVM Exception
Thanks to the previous work done, changing the license is just a
matter of changing the SPDX identifer from "LGPL-3.0-or-later" to
"Apache-2.0 WITH LLVM-exception".  Note that for the abigail.m4,
tests/test-dot.cc and tests/test-svg.cc the change was from
"GPL-3.0-or-later WITH GCC-exception-3.1" to "Apache-2.0 WITH
LLVM-exception".  include/abg-cxx-compat.h was changed from
"LGPL-2.0-or-later" to "Apache-2.0 WITH LLVM-exception".  Source code
of programs (as opposed to source code of the library) where generally
licensed under GPL-3.0-or-later; they are also now licensed
"Apache-2.0 WITH LLVM-exception".

This is what this patch does.

	* abigail.m4: Change the SPDX identifier from "GPL-3.0-or-later
	WITH GCC-exception-3.1" to "Apache-2.0 WITH LLVM-exception"
	* include/abg-cxx-compat.h: Change the SPDX identifier from
	"LGPL-2.0-or-later" to "Apache-2.0 WITH LLVM-exception".
	* .clang-format: Change the SPDX identifier from
	  "LGPL-3.0-or-later" to "Apache-2.0 WITH LLVM-exception".
	* Makefile.am: Likewise.
	* bash-completion/Makefile.am: Likewise.
	* bash-completion/abicompat: Likewise.
	* 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.
	* configure.ac: Likewise.
	* default.abignore: Likewise.
	* doc/Makefile.am: Likewise.
	* doc/api/libabigail.doxy: Likewise.
	* doc/manuals/Makefile.am: Likewise.
	* doc/website/libabigail-website.doxy: Likewise.
	* include/Makefile.am: Likewise.
	* include/abg-comp-filter.h: Likewise.
	* include/abg-comparison.h: Likewise.
	* include/abg-config.h: Likewise.
	* include/abg-corpus.h: Likewise.
	* include/abg-diff-utils.h: Likewise.
	* include/abg-dwarf-reader.h: Likewise.
	* include/abg-fwd.h: Likewise.
	* include/abg-hash.h: Likewise.
	* include/abg-ini.h: Likewise.
	* include/abg-interned-str.h: Likewise.
	* include/abg-ir.h: Likewise.
	* include/abg-libxml-utils.h: Likewise.
	* include/abg-libzip-utils.h: Likewise.
	* include/abg-reader.h: Likewise.
	* include/abg-regex.h: Likewise.
	* include/abg-reporter.h: Likewise.
	* include/abg-sptr-utils.h: Likewise.
	* include/abg-suppression.h: Likewise.
	* include/abg-tools-utils.h: Likewise.
	* include/abg-traverse.h: Likewise.
	* include/abg-version.h.in: Likewise.
	* include/abg-viz-common.h: Likewise.
	* include/abg-viz-dot.h: Likewise.
	* include/abg-viz-svg.h: Likewise.
	* include/abg-workers.h: Likewise.
	* include/abg-writer.h: Likewise.
	* scripts/dot_to_png.sh: Likewise.
	* scripts/dot_to_svg.sh: Likewise.
	* scripts/make-verbose.sh: Likewise.
	* scripts/svg_to_plain_svg.sh: Likewise.
	* scripts/svg_to_png_and_pdf.sh: Likewise.
	* src/Makefile.am: Likewise.
	* src/abg-comp-filter.cc: Likewise.
	* src/abg-comparison-priv.h: Likewise.
	* src/abg-comparison.cc: Likewise.
	* src/abg-config.cc: Likewise.
	* src/abg-corpus-priv.h: Likewise.
	* src/abg-corpus.cc: Likewise.
	* src/abg-default-reporter.cc: Likewise.
	* src/abg-diff-utils.cc: Likewise.
	* src/abg-dwarf-reader.cc: Likewise.
	* src/abg-elf-helpers.cc: Likewise.
	* src/abg-elf-helpers.h: Likewise.
	* src/abg-hash.cc: Likewise.
	* src/abg-ini.cc: Likewise.
	* src/abg-internal.h: Likewise.
	* src/abg-ir-priv.h: Likewise.
	* src/abg-ir.cc: Likewise.
	* src/abg-leaf-reporter.cc: Likewise.
	* src/abg-libxml-utils.cc: Likewise.
	* src/abg-libzip-utils.cc: Likewise.
	* src/abg-reader.cc: Likewise.
	* src/abg-regex.cc: Likewise.
	* src/abg-reporter-priv.cc: Likewise.
	* src/abg-reporter-priv.h: Likewise.
	* src/abg-suppression-priv.h: 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.
	* tests/Makefile.am: Likewise.
	* tests/data/Makefile.am: Likewise.
	* tests/lib/catch.cc: Likewise.
	* tests/mockfedabipkgdiff.in: Likewise.
	* tests/print-diff-tree.cc: Likewise.
	* tests/runtestcanonicalizetypes.sh.in: Likewise.
	* tests/runtestdefaultsupprs.py.in: Likewise.
	* tests/runtestdefaultsupprspy3.sh.in: Likewise.
	* tests/runtestfedabipkgdiff.py.in: Likewise.
	* tests/runtestfedabipkgdiffpy3.sh.in: Likewise.
	* tests/test-abicompat.cc: Likewise.
	* tests/test-abidiff-exit.cc: Likewise.
	* tests/test-abidiff.cc: Likewise.
	* tests/test-alt-dwarf-file.cc: Likewise.
	* tests/test-annotate.cc: Likewise.
	* tests/test-core-diff.cc: Likewise.
	* tests/test-cxx-compat.cc: Likewise.
	* tests/test-diff-dwarf-abixml.cc: Likewise.
	* tests/test-diff-dwarf.cc: Likewise.
	* tests/test-diff-filter.cc: Likewise.
	* tests/test-diff-pkg.cc: Likewise.
	* tests/test-diff-suppr.cc: Likewise.
	* tests/test-diff2.cc: Likewise.
	* tests/test-dot.cc: Change the SPDX identifier from
	"GPL-3.0-or-later WITH GCC-exception-3.1" to "Apache-2.0 WITH
	LLVM-exception"
	* tests/test-elf-helpers.cc: Change the SPDX identifier from
	"LGPL-3.0-or-later" to "Apache-2.0 WITH LLVM-exception"
	* tests/test-ini.cc: Likewise.
	* tests/test-ir-walker.cc: Likewise.
	* tests/test-kmi-whitelist.cc: Likewise.
	* tests/test-lookup-syms.cc: Likewise.
	* tests/test-read-dwarf.cc: Likewise.
	* tests/test-read-write.cc: Likewise.
	* tests/test-svg.cc: Change the SPDX identifier from
	"GPL-3.0-or-later WITH GCC-exception-3.1" to "Apache-2.0 WITH
	LLVM-exception".
	* tests/test-symtab.cc: Change the SPDX identifier from
	"LGPL-3.0-or-later" to "Apache-2.0 WITH LLVM-exception"
	* tests/test-tools-utils.cc: Likewise.
	* tests/test-types-stability.cc: Likewise.
	* tests/test-utils.cc: Likewise.
	* tests/test-utils.h: Likewise.
	* tests/test-write-read-archive.cc: Likewise.
	* tests/update-test-output.py: Likewise.
	* tools/Makefile.am: Likewise.
	* tools/abiar.cc: Likewise.
	* tools/abicompat.cc: Likewise.
	* tools/abidiff.cc: Likewise.
	* tools/abidw.cc: Likewise.
	* tools/abilint.cc: Likewise.
	* tools/abipkgdiff.cc: Likewise.
	* tools/abisym.cc: Likewise.
	* tools/binilint.cc: Likewise.
	* tools/fedabipkgdiff: Likewise.
	* tools/kmidiff.cc: Likewise.
	* update-copyright.sh: Likewise.

Signed-off-by: Benjamin De Kosnik <bkoz@gnu.org>
Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Matthias Klose <doko@ubuntu.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Roland McGrath <roland@hack.frob.com>
Signed-off-by: Sinny Kumari <ksinny@gmail.com>
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
2020-12-02 11:49:13 +01:00
Dodji Seketeli
be6bf58308 Add missing SPDX headers to source files not specifying any license
Default to the project's defautl - LGPLv3+ - for those.

	* Makefile.am: Add a LGPL-3.0-or-later SPDX header prefixed
	with '##' so that that the header doesn't get emitted in the
	resulting Makefile.in file.  Note that the license of Makefile.in
	files is "FSF All Permissible License", which virtually compatible
	with anything.
	* bash-completion/Makefile.am: Likewise.
	* doc/Makefile.am: Likewise
	* doc/manuals/Makefile.am: Likewise
	* include/Makefile.am: Likewise
	* src/Makefile.am: Likewise
	* tests/Makefile.am: Likewise
	* tests/data/Makefile.am: Likewise
	* tools/Makefile.am: Likewise
	* .clang-format: Add a LGPL-3.0-or-later SPDX header.
	* bash-completion/abicompat: Likewise.
	* 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.
	* configure.ac: Likewise.
	* default.abignore: Likewise.
	* doc/api/libabigail.doxy: Likewise.
	* doc/website/libabigail-website.doxy: Likewise.
	* include/abg-version.h.in: Likewise.
	* scripts/dot_to_png.sh: Likewise.
	* scripts/dot_to_svg.sh: Likewise.
	* scripts/make-verbose.sh: Likewise.
	* scripts/svg_to_plain_svg.sh: Likewise.
	* scripts/svg_to_png_and_pdf.sh: Likewise.
	* tests/runtestcanonicalizetypes.sh.in: Likewise.
	* tests/runtestdefaultsupprs.py.in: Likewise.
	* tests/runtestdefaultsupprspy3.sh.in: Likewise.
	* tests/runtestfedabipkgdiffpy3.sh.in: Likewise.
	* tests/update-test-output.py: Likewise.
	* update-copyright.sh: Likewise.

Signed-off-by: Benjamin De Kosnik <bkoz@gnu.org>
Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Matthias Klose <doko@ubuntu.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Roland McGrath <roland@hack.frob.com>
Signed-off-by: Sinny Kumari <ksinny@gmail.com>
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
2020-12-02 11:44:56 +01:00
Matthias Maennich
58488c5f31 Replace individual license references with SPDX Identifiers
This patch replaces license headers with SPDX identifiers in all files
containing license headers.  For each file, the SPDX identifier
formally represents its current license.  Note that the list of SPDX
identifiers is available on the SPDX web site at
https://spdx.org/licenses.

For autoconf-archive/ax_prog_python_version.m4 however, there is a
little catch.  Dodji Seketeli wrote this ax_check_python_modules.m4.
Just like the other autoconf-archive macros, it makes sense to have it
under the FSF All Permissive license.  Actually, the terms of that
license was already in the file but then the license header was
wrongly set to GPLv2 with autoconf exception.  So I fixed that in this
commit by setting the SPDX identifier to FSFAP.

	* abigail.m4: Replace the license header with the SPDX identifier
	GPL-3.0-or-later WITH GCC-exception-3.1
	* autoconf-archive/ax_check_python_modules.m4: Correctly set the
	SPDX identifier to FSFAP.
	* autoconf-archive/ax_compare_version.m4: Replace the license
	header with the SPDX identifier FSFAP.
	* autoconf-archive/ax_prog_python_version.m4: Likewise.
	header with the SPDX identifier FSFAP.
	* autoconf-archive/ax_valgrind_check.m4: Likewise.
	* gen-changelog.py: Replace the license header with the SPDX
	identifier LGPL-2.0-or-later.
	* include/abg-comp-filter.h: Replace the license header with the
	SPDX identifier LGPL-3.0-or-later.
	* include/abg-comparison.h: Likewise.
	* include/abg-config.h: Likewise.
	* include/abg-corpus.h: Likewise.
	* include/abg-cxx-compat.h: Replace the license header with the
	SPDX identifier LGPL-2.0-or-later.
	* include/abg-diff-utils.h: Replace the license header with the
	SPDX identifier LGPL-3.0-or-later
	* include/abg-dwarf-reader.h: Likewise.
	* include/abg-fwd.h: Likewise.
	* include/abg-hash.h: Likewise.
	* include/abg-ini.h: Likewise.
	* include/abg-interned-str.h: Likewise.
	* include/abg-ir.h: Likewise.
	* include/abg-libxml-utils.h: Likewise.
	* include/abg-libzip-utils.h: Likewise.
	* include/abg-reader.h: Likewise.
	* include/abg-regex.h: Likewise.
	* include/abg-reporter.h: Likewise.
	* include/abg-sptr-utils.h: Likewise.
	* include/abg-suppression.h: Likewise.
	* include/abg-tools-utils.h: Likewise.
	* include/abg-traverse.h: Likewise.
	* include/abg-viz-common.h: Likewise.
	* include/abg-viz-dot.h: Likewise.
	* include/abg-viz-svg.h: Likewise.
	* include/abg-workers.h: Likewise.
	* include/abg-writer.h: Likewise.
	* install-sh: Replace the license header with the SPDX identifier MIT.
	* ltmain.sh: Replace the license header with the SPDX identifier
	GPL-2.0-or-later.  Note that this file has the libtool special
	exception which allows us to redistribute it under the general
	license of the project.
	* src/abg-comp-filter.cc: Replace the license header with the SPDX
	* src/abg-comparison-priv.h: Likewise.
	* src/abg-comparison.cc: Likewise.
	* src/abg-config.cc: Likewise.
	* src/abg-corpus-priv.h: Likewise.
	* src/abg-corpus.cc: Likewise.
	* src/abg-default-reporter.cc: Likewise.
	* src/abg-diff-utils.cc: Likewise.
	* src/abg-dwarf-reader.cc: Likewise.
	* src/abg-elf-helpers.cc: Likewise.
	* src/abg-elf-helpers.h: Likewise.
	* src/abg-regex.cc: Likewise.
	* src/abg-hash.cc: Likewise.
	* src/abg-ini.cc: Likewise.
	* src/abg-internal.h: Likewise.
	* src/abg-ir-priv.h: Likewise.
	* src/abg-ir.cc: Likewise.
	* src/abg-leaf-reporter.cc: Likewise.
	* src/abg-libxml-utils.cc: Likewise.
	* src/abg-libzip-utils.cc: Likewise.
	* src/abg-reader.cc: Likewise.
	* src/abg-reporter-priv.cc: Likewise.
	* src/abg-reporter-priv.h: Likewise.
	* src/abg-sptr-utils.cc: Likewise.
	* src/abg-suppression-priv.h: 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.
	* tests/lib/catch.cc: Likewise.
	* tests/lib/catch.hpp: Add an SPDX identifier BSL-1.0.
	* tests/mockfedabipkgdiff.in: Replace the license header with the
	SPDX identifier GPL-3.0-or-later.
	* tests/print-diff-tree.cc: Likewise.
	* tests/runtestfedabipkgdiff.py.in: Replaace the license header
	with the SPDW identifier GPL-3.0-or-later.
	* tests/test-abicompat.cc: Replace the license header with the
	SPDX identifier LGPL-3.0-or-later.
	* tests/test-abidiff-exit.cc: Likewise.
	* tests/test-abidiff.cc: Likewise.
	* tests/test-alt-dwarf-file.cc: Likewise.
	* tests/test-annotate.cc: Likewise.
	* tests/test-cxx-compat.cc: Likewise.
	* tests/test-core-diff.cc: Likewise.
	* tests/test-diff-dwarf-abixml.cc: Likewise.
	* tests/test-diff-dwarf.cc: Likewise.
	* tests/test-diff-filter.cc: Likewise.
	* tests/test-diff-pkg.cc: Likewise.
	* tests/test-diff-suppr.cc: Likewise.
	* tests/test-diff2.cc: Likewise.
	* tests/test-dot.cc: Replace the license header with the
	SPDX identifier GPL-3.0-with-GCC-exception.
	* tests/test-elf-helpers.cc: Replace the license header with the
	SPDX identifier LGPL-3.0-or-later.
	* tests/test-ini.cc: Likewise.
	* tests/test-ir-walker.cc: Likewise.
	* tests/test-kmi-whitelist.cc: Likewise.
	* tests/test-lookup-syms.cc: Likewise.
	* tests/test-read-dwarf.cc: Likewise.
	* tests/test-read-write.cc: Likewise.
	* tests/test-svg.cc: Replace the license header with the SPDX
	identifier GPL-3.0-with-GCC-exception.
	* tests/test-symtab.cc: Replace the license header with the SPDX
	identifier LGPL-3.0-or-later.
	* tests/test-tools-utils.cc: Likewise.
	* tests/test-types-stability.cc: Likewise.
	* tests/test-utils.cc: Likewise.
	* tests/test-utils.h: Likewise.
	* tests/test-write-read-archive.cc: Likewise.
	* tools/abiar.cc: Likewise.
	* tools/abicompat.cc: Likewise.
	* tools/abidiff.cc: Likewise.
	* tools/abidw.cc: Likewise.
	* tools/abilint.cc: Likewise.
	* tools/abipkgdiff.cc: Likewise.
	* tools/abisym.cc: Likewise.
	* tools/binilint.cc: Likewise.
	* tools/fedabipkgdiff: Replace the license header with the
	SPDX identifier GPL-3.0-or-later.
	* tools/kmidiff.cc: Likewise.

Signed-off-by: Benjamin De Kosnik <bkoz@gnu.org>
Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Matthias Klose <doko@ubuntu.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Roland McGrath <roland@hack.frob.com>
Signed-off-by: Sinny Kumari <ksinny@gmail.com>
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
2020-12-02 11:44:13 +01:00
Dodji Seketeli
0a5f056393 abipkgdiff: make --self-check to fail on any change against own ABIXML
Now that several subtle causes of spurious ABI change report when
comparing a binary against its own ABIXML have been addressed, this
patch makes 'abipkgdiff --self-check' to fail on any ABI change
reported.  That is, harmless changes are not ignored anymore.

	* tools/abipkgdiff.cc (compare_to_self): Report *any* ABI change.
	Not just the "net" changes.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-27 17:01:01 +01:00
Dodji Seketeli
7d5fc6a509 abidw: make --abidiff report any change against own ABIXML
Sometimes, "abidw --abidiff <binary>" would pass while
"abidw <binary> > abi; abidiff <binary> abi" would fail.

This is because "abidw --abidiff" emits an error only when the
comparison between the binary and its ABIXML representation yields and
incompatible change.

Now that many subtle causes of spurious ABI change report emitted when
comparing a binary against its own ABIXML have been fixed, this patch
makes it so that *any* change would make abidw --abidiff to emit an
error.

	* tools/abidw.cc (load_corpus_and_write_abixml): Emit an error
	when comparing the binary to its ABIXML representation yields any
	change.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-27 16:57:44 +01:00
Dodji Seketeli
6ac6cfb3f6 abipkgdiff: Avoid uncertainty when sorting worker tasks
Worker tasks that have compared the binaries of two packages are
sorted according to the sizes of the binaries they compared.  The
tasks that compared bigger binaries come first.  So the output of
these tasks is always sorted the same.

When two tasks have sorted binaries of the same size, let's sort them
by taking into account the lexicographic order of the binaries names.

	* elf_size_is_greater: Take the name of the binaries into account
	when their size is equal.  Also, assert that all comparison tasks
	have compared binaries.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-25 13:17:21 +01:00
Matthias Maennich
18b0693ca1 abipkgdiff: minor cleanups
The recent changes to abipkgdiff triggered some minor clang-tidy
diagnostics that I address in this patch.

 - removed unused using statements
 - cleaned up some mismatches between commented and actual parameter names
 - removed shadowing data members from self_compare_task and construct
   with base class constructor instead.

	* tools/abipkgdiff.cc: remove unused using statements
	(self_compare_task): remove shadowing members and delegate
	construction to base class.

Signed-off-by: Matthias Maennich <maennich@google.com>
2020-11-25 09:08:03 +01:00
Dodji Seketeli
ddead98a51 fedabipkgdiff: make --self-compare use abipkgdiff --self-check
Now that the abipkgdiff program supports the --self-check option to
make it compare the binaries in an RPM against their own ABIXML
representation, make the --self-compare option of fedabipkgdiff use
the abipkgdiff --self-check.

	* tools/fedabipkgdiff (abipkgdiff): If the user provides the
	--self-compare options, generate the abipkgdiff command by using
	the --self-check option.
	(run_abipkgdiff): Each return value of the abipkgidiff runs can be
	negative because they are unsigned values in essence, but as
	python doesn't seem to have a unsigned integer type.  So we need
	to consider the max of the absolute value of the return codes
	here.
	* tests/data/test-fedabipkgdiff/test7-self-compare-from-fc23-dbus-glib-report-0.txt:
	Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-23 17:50:06 +01:00
Dodji Seketeli
edfe5a1dec abipkgdiff: Add a new --self-check option
After the report of
https://sourceware.org/bugzilla/show_bug.cgi?id=26769 it became
apparent that we want to be able compare a binary against its ABIXML
representation, including for cases where the binaries are embedded in
RPM packages.

This patches thus introduces the --self-check option to abipkgdiff so
that it can be invoked like this:

    $ abipkgdiff --self-check --d1 libstdc++-debuginfo-10.2.1-8.fc34.x86_64.rpm --d1 gcc-debuginfo-10.2.1-8.fc34.x86_64.rpm libstdc++-10.2.1-8.fc34.x86_64.rpm

    ==== SELF CHECK SUCCEEDED for 'libstdc++.so.6.0.28'====
    $

With this option, libabigail compares each binary in the RPM against
its own ABIXML representation.

This should hopefully help to write regression tests which have as
sole inputs the links to download the RPMs.  It's also useful to ease
the process of reproducing the issue raised.

This option can now be used, for instance, by the libabigail-selfcheck
program over at https://pagure.io/libabigail-selfcheck.

	* tools/abipkgdiff.cc (options::self_check): Define new data
	member.
	(options::options): Initialize it.
	(display_usage): Add help string for the --self-check option.
	(parse_command): Parse the new --self-check option.
	(extract_deb): Add missing newline.
	(compare): Remove useless white space.
	(compare_to_self, self_compare_prepared_userspace_package)
	(self_compare_prepared_package, compare_to_self): Add new static
	functions.
	(class self_compare_task): Add new class.
	(prepare_package): Add a new overload that takes just one
	parameter.
	(elf_size_is_greater): Don't crash if the args are empty.
	(main): If the --self-check option is given, make sure we have
	just one package in argument.  Use the new compare_to_self
	function to handle the --self-check option.
	* doc/manuals/abipkgdiff.rst: Add documentation for the new
	--self-check option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-23 17:50:05 +01:00
Dodji Seketeli
ee2b54ddd9 Make abidiff and abidw support several --headers-dir{1,2} options
When handling a binary with abidiff or abidw it can be useful to
provide several different header files directories, for the cases
where the header files of the binary are scathered in several
different directories.

It thus becomes possible to invoke abidiff like this:

    abidiff --headers-dir1 first-header-dir1   \
	    --headers-dir1 second-header-dir1  \
	    --headers-dir2 first-header-dir2   \
	    --headers-dir2 second-header-dir2  \
	    binary1 binary2

This patch adds support for that.  It also modifies the
tests/test-abidiff-exit.cc test harness to make it take header
directories.  With that modification done, a new test is added in that
harness to exercise this new feature.

This should close the feature request over at
https://sourceware.org/bugzilla/show_bug.cgi?id=26565.

	* doc/manuals/abidiff.rst: Update documentation for the
	--headers-dir{1,2} options.
	* doc/manuals/abidw.rst: Likewise for the --header-dir option.
	* include/abg-tools-utils.h (gen_suppr_spec_from_headers): Add new
	overload that takes a vector of headers root dirs.
	* src/abg-tools-utils.cc (gen_suppr_spec_from_headers_root_dir):
	Define new function.
	(gen_suppr_spec_from_headers): Define a new overload that takes a
	vector of head_root_dir strings; it uses the new
	gen_suppr_spec_from_headers function.  Use the new overload in the
	previous one that takes just one head_root_dir string.
	* tools/abidiff.cc (options::headers_dirs{1,2}): Rename
	option::headers_dir{1,2} into this one and make it be a vector of
	strings rather than just a string.
	(parse_command_line): Support several --headers-dir{1,2} on the
	command line.
	(set_diff_context_from_opts, set_suppressions): Adjust.
	* tools/abidw.cc (options::headers_dirs): Renamed
	options::headers_dir into this and make it be a vector of strings
	rather than just a string.
	(parse_command_line): Support several --headers-dir on the command
	line.
	(set_suppressions): Adjust.
	* tests/data/test-abidiff-exit/test-headers-dirs/headers-a/header-a-v{0,1}.h:
	Header files of new binary test input.
	* tests/data/test-abidiff-exit/test-headers-dirs/headers-b/header-b-v{0,1}.h:
	Likewise.
	* tests/data/test-abidiff-exit/test-headers-dirs/test-headers-dir-v{0,1}.c:
	Source code of new binary test input.
	* tests/data/test-abidiff-exit/test-headers-dirs/test-headers-dir-report-{1,2}.txt:
	Reference output of new binary test input.
	* tests/data/test-abidiff-exit/test-headers-dirs/test-headers-dir-v{0,1}.o:
	New binary test input.
	* tests/data/Makefile.am: Add the new files above to source
	distribution.
	* tests/test-abidiff-exit.cc (InOutSpec::in_elfv{0,1}_path): Add
	new data members.
	(in_out_specs): Adjust the content of this array as its type
	changed.  Also, add two new entries to run the test over the new
	binary test inputs above.
	(do_prefix_strings): Define new static function.
	(main): Use it the new do_prefix_strings here.  Make abidiff
	use the --header-dir{1,2} option whenever header directories are
	specified in an entry of the in_out_specs array.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-09-18 10:27:18 +02:00
Giuliano Procida
f18a192aa6 Improve documentation of abidiff --type-id-style
* tools/abidw.cc (display_usage): In documentation of
	"--type-id-style" option, add a missing closing ')', spell
	"type id" without a '-', split overly long string over two
	lines, use "<...>" to indicate mandatory argument and improve
	description of formats.
	* doc/manuals/abidw.rst: In documentation of "--type-id-style"
	option, use "<...>" to indicate mandatory argument.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-08-04 18:41:01 +02:00
Giuliano Procida
29de666641 abg-writer: Add support for stable hash type ids.
The type ids currently emitted by the XML writer are simply type-id-1,
type-id-2 etc. Additions or removals of types early in this sequence
result in cascading changes to many other XML elements.

This commit adds support for stable type ids in the form of hashes of
libabigail's internal type names. On fairly rare occasions (typically
involving unnamed types), the names of two distinct types can be the
same. In any case, if there is a hash collision the XML writer will
find the next unused id and so preserve uniqueness.

Diffs between large XML files produced using --type-id-style hash will
be much smaller and easier to review.

This also commit adds some test cases to verify that the hashing is
actually stable across architectures.

	* doc/manuals/abidw.rst: Replace stray documentation of
	--named-type-ids with documention of new --type-id-style
	option.
	* include/abg-writer.h (type_id_style_kind): Add new enum.
	(set_type_id_style): Add new write_context setter.
	(set_common_options): Set type id style in write context.
	* include/abg-hash.h (fnv_hash): Declare new 32-bit FNV-1a
        hash function in abigail::hashing namespace.
	* src/abg-hash.h (fnv_hash): Define new 32-bit FNV-1a hash
        function in abigail::hashing namespace.
	* src/abg-writer.cc (write_context): Add m_type_id_style
        member to record type style to use, defaulting to
        SEQUENCE_TYPE_ID_STYLE; add m_used_type_id_hashes to record
        already-used hashes.
	(write_context::get_type_id_style): Add new getter.
	(write_context::set_type_id_style): Add new setter.
	(get_id_for_type): Add support for HASH_TYPE_ID_STYLE style.
	(set_type_id_style): Add new helper function.
	* tools/abidw.cc (options): Add type_id_style member.
	(display_usage): Add description of --type-id-style option.
	(parse_command_line): Parse --type-id-style option.
	* tests/data/Makefile.am: Add new hash type id ABI files.
	* tests/test-read-dwarf.cc: (InOutSpec): Add type_id_style
	member.
	(in_out_specs): Set type_id_style to SEQUENCE_TYPE_ID_STYLE in
        existing test specifications. Duplicate first 9 test cases
        with type_id_style set to HASH_TYPE_ID_STYLE.
	* tests/data/test-read-dwarf/test0.hash.abi: New ABI XML file
	with hash type ids.
	* tests/data/test-read-dwarf/test1.hash.abi: Ditto.
	* tests/data/test-read-dwarf/test2.so.hash.abi: Ditto.
	* tests/data/test-read-dwarf/test3.so.hash.abi: Ditto.
	* tests/data/test-read-dwarf/test4.so.hash.abi: Ditto.
	* tests/data/test-read-dwarf/test5.o.hash.abi: Ditto.
	* tests/data/test-read-dwarf/test6.so.hash.abi: Ditto.
	* tests/data/test-read-dwarf/test7.so.hash.abi: Ditto.
	* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.hash.abi:
	Ditto.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-06-16 10:13:01 +02:00
Matthias Maennich
4ef7e8c976 abipkgdiff: remove unused includes of elfutils/libdw.h and elf.h
Definitions from those headers are not actually used. Yet the includes
create unnecessary dependencies.

	* tools/abipkgdiff.cc: Drop unused includes.

Signed-off-by: Matthias Maennich <maennich@google.com>
2020-06-15 09:08:05 +02:00
Giuliano Procida
2b4ff3c6cf Fix HARMLESS_SYMBOL_ALIAS_CHANGE_CATEGORY spelling
The enumerator HARMLESS_SYMBOL_ALIAS_CHANGE_CATEORY has a spelling
mistake in it. This changes fixes this and also corrects the spelling
of both this and HARMLESS_UNION_CHANGE_CATEORY when output.

	* include/abg-comparison.h (enum diff_category): Rename
	HARMLESS_SYMBOL_ALIAS_CHANGE_CATEORY enumerator to
	HARMLESS_SYMBOL_ALIAS_CHANGE_CATEGORY.
	* src/abg-comp-filter.cc (categorize_harmless_diff_node): Replace
	use of HARMLESS_SYMBOL_ALIAS_CHANGE_CATEORY enumerator with
	HARMLESS_SYMBOL_ALIAS_CHANGE_CATEGORY.
	* src/abg-comparison.cc (get_default_harmless_categories_bitmap):
	Replace use of HARMLESS_SYMBOL_ALIAS_CHANGE_CATEORY enumerator
	with HARMLESS_SYMBOL_ALIAS_CHANGE_CATEGORY.
	(operator<<): In the diff_category overload, replace use of
	HARMLESS_SYMBOL_ALIAS_CHANGE_CATEORY enumerator with
	HARMLESS_SYMBOL_ALIAS_CHANGE_CATEGORY and output correct
	spelling for both this and HARMLESS_UNION_CHANGE_CATEGORY.
	* tools/abicompat.cc (create_diff_context): Replace use of
	HARMLESS_SYMBOL_ALIAS_CHANGE_CATEORY enumerator with
	HARMLESS_SYMBOL_ALIAS_CHANGE_CATEGORY.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-06-11 10:06:04 +02:00
Mark Wielaard
a9f5fb4089 Add --no-write-default-sizes option.
abidw will write out the exact same size-in-bits address for every
pointer type, reference type, function declaration and function type
even though it is always the same as the translation unit address
size. When giving the --no-write-default-sizes option these aren't
written out anymore. The reader is updated to set the default size
when none is given in the XML description.

Even though size and alignment are handled together in the reader,
default alignment is still set to zero, following commit a05384675

Note that this isn't backward compatible with older libabigail
readers, which will set the size to zero when none is given. So this
option isn't the default.

	* doc/manuals/abidw.rst: Document --no-write-default-sizes.
	* include/abg-writer.h (set_write_default_sizes): New function
	declaration.
	(set_common_options): Call set_write_default_sizes.
	* src/abg-reader.cc (build_function_decl): Get default size.
	(build_pointer_type_def): Likewise.
	(build_reference_type_def): Likewise.
	(build_function_type): Likewise.
	* src/abg-writer.cc (write_context): Add m_write_default_sizes
	bool.
	(get_write_default_sizes): New method.
	(set_write_default_sizes): Likewise.
	(write_size_and_alignment): Add default size and alignment
	parameters.
	(set_write_default_sizes): New function.
	(write_type_decl): Set default size and alignment.
	(write_pointer_type_def): Likewise.
	(write_reference_type_def): Likewise.
	(write_function_decl): Likewise.
	(write_function_type): Likewise.
	(write_class_decl_opening_tag): Likewise.
	(write_union_decl_opening_tag): Likewise.
	* tests/test-types-stability.cc (perform): Also test --abidiff
	with --no-write-default-sizes.
	* tools/abidw.cc (option): Add default_sizes bool.
	(parse_command_line): Parse --no-write-default-sizes.
	(display_usage): Add doc string for --no-write-default-sizes.

Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-04-29 11:56:40 +02:00
Mark Wielaard
b8860e1db3 Add --no-elf-needed option to drop DT_NEEDED list from corpus.
The elf-needed list is not relevant for the exported ABI of a library
so provide an option to drop it.

	* doc/manuals/abidw.rst: Document --no-elf-needed.
	* include/abg-writer.h (set_write_elf_needed): New function.
	(set_common_options): Call it.
	* src/abg-writer.cc (write_context::m_write_elf_needed): New data
	member.
	(write_context::{g,s}et_write_elf_needed): Add new accessors.
	(set_write_elf_needed): New function.
	(write_context::write_corpus): Check write_elf_needed.
	* tools/abidw.cc (options): Add write_elf_needed bool.
	(display_usage): Describe --no-elf-needed.
	(parse_command_line): Parse --no-elf-needed.

Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-04-24 15:59:30 +02:00
Mark Wielaard
8da509aaa2 Add no-parameter-names to drop function parameter names.
The function parameter names are not relevant for the (exported)
ABI. So provide an option to simply drop them from the corpus.

	* doc/manuals/abidw.rst: Add documentation for --no-parameter-names.
	* include/abg-writer.h (set_write_parameter_names): New function.
	(set_write_parameter_names): Call it.
	* src/abg-writer.cc (write_context): Add m_write_parameter_names
	bool, get_write_parameter_names and set_write_parameter_names
	functions.
	(write_context::write_function_decl): Check write_parameter_names.
	* tools/abidw.cc (options): Add write_parameter_names.
	(display_usage): Describe --no-parameter-names.
	(parse_command_line): Parse --no-parameter-names.

Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-04-24 15:34:10 +02:00
Dodji Seketeli
3036fdd832 abipkgdiff: Fix race condition while using private types suppr specs
When comparing two packages, abipkgdiff potentially spawns one thread
per pair of binaries to compare.  The suppression specifications
generated for the private types of the package are shared among those
threads.  As some internals of the suppression specifications are
constructed lazily, that can lead do some data races when more than
two threads access one of those internals.

One effective way to handle that is to make sure each thread has its
own copy of suppression specifications.

That's what this patch does.

	* tools/abipkgdiff.cc (compare_args::private_types_suppr{1,2}):
	Make these data member *not* be a reference anymore.
	(maybe_create_private_types_suppressions): Rename this into ...
	(create_private_types_suppressions): ... this.  Also, make this
	function return a copy of the vector of suppression specifications
	for private types created.
	(compare_prepared_userspace_packages): Use the new
	create_private_types_suppressions to create a copy of private
	types suppression specifications, rather than sharing it from
	package::private_types_suppressions_.
	(extract_package_and_map_its_content): Adjust to avoid creating
	the shared suppression specifications for private types.
	(package::private_types_suppressions_): Remove this data member
	that was holding the shared suppressions for private types.
	(package::private_types_suppressions): Remove these accessors.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-04-24 14:51:54 +02:00
Mark Wielaard
254cafb7d7 Add --drop-undefined-syms to abidw.
Add a drop_undefined_syms properties to the read_context that
indicates the reader wants to drop any undefined symbols (which don't
have associated addresses in the corpus). Implement this for the
dwarf_reader and abidw (when using the --drop-undefined-syms option).

	* include/abg-dwarf-reader.h (set_drop_undefined_syms):
	New declaration.
	* src/abg-dwarf-reader.cc (class read_context): Add private
	bool drop_undefined_syms_.
	(drop_undefined_syms): New getter and setter method.
	(set_drop_undefined_syms): New function.
	(function_is_suppressed): Check drop_undefined_syms on
	read_context.
	(variable_is_suppressed): Likewise.
	* src/abg-reader.cc (read_context): Add private bool
	m_drop_undefined_syms.
	(drop_undefined_syms): New getter and setter method.
	* tools/abidw.cc (struct options): Add drop_undefined_syms.
	(display_usage): Print --drop-undefined-syms.
	(parse_command_line): Parse --drop-undefined-syms.
	(main): Call set_drop_undefined_syms.

Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-04-15 14:29:55 +02:00
Mark Wielaard
aef674711a Add --drop-private-types to abidw.
To create smaller abi XML files it is useful to be able to drop
the private types from the representation.

	* tools/abidw.cc (options): Add drop_private_types bool.
	(display_usage): Add --drop-private-types.
	(parse_command_line): Parse --drop-private-types, set opts.
	(set_suppressions): Call set_drops_artifact_from_ir when
	drop_private_types set.
	* doc/manuals/abidw.rst: Document --drop-private-types.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2020-04-14 17:32:49 +02:00
Mark Wielaard
9fe85b370c Add --header-file option to add individual public header files.
Sometimes public header files are in the same directory as private
header files. In such cases --headers-dir cannot be used. Add
--header-file to add individual public header files.

	* include/abg-tools-utils.h (gen_suppr_spec_from_headers): Add
	hdr_files string vector argument.
	* src/abg-tools-utils.cc (handle_file_entry): New function that
	adds one specific file to the type_suppression. Implementation
	lifted from...
	(handle_fts_entry): ...here. Call handle_file_entry for each file.
	(gen_suppr_spec_from_headers): Also takes a header_files string
	vector as argument. Call handle_file_entry for each file entry.
	* tools/abidiff.cc (options): Add header_files1 and header_files2
	string vectors.
	(display_usage): Print --header-file1 and --header-file2 usage.
	(parse_command_line): Handle --header-file1, --hf1 and
	--header-file2, --hf2.
	(set_diff_context_from_opts): Call gen_suppr_spec_from_headers
	with header_files1 and header_files2.
	(set_suppressions): Likewise.
	* tools/abidw.cc (options): Add header_files string vector.
	(display_usage): Print --header-file usage.
	(parse_command_line): Handle --header-file1, --hf1.
	(maybe_check_header_files): New function.
	(set_suppressions): Call gen_suppr_spec_from_headers with
	header_files.
	(main): Call maybe_check_header_files.
	* tools/abilint.cc (options): Add header_files string vector.
	(display_usage): Print --header-file usage.
	(parse_command_line): Handle --header-file1, --hf1.
	(set_suppressions): Call gen_suppr_spec_from_headers with
	header_files.
	* doc/manuals/abidiff.rst: Document --header-file1, --hf1 and
	--header-file2, --hf2. Add new options to documentation of
	--drop-private-types.
	* doc/manuals/abidw.rst: Document --header-file, --hf.
	* doc/manuals/abilint.rst: Likewise.

Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-04-14 17:17:28 +02:00
Dodji Seketeli
2cda77235c abipkgdiff: fix documentation of --impacted-interface
Update the help string of the --impacted-interface option to make it
match the one from the abidiff tool.

	* tools/abipkgdiff.cc (display_usage): Use the same help string
	for the --impacted-interface option as abidiff does.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-03-18 17:33:03 +01:00
Matthias Maennich
82d84afd5b abidiff: fix documentation of --impacted-interfaces
abidiff --impacted-interfaces is supposed to show the impacted
interfaces. Hence fix the documentation to reflect that.

	* tools/abidiff.cc(display_usage): Fix doc string for
	--impacted-interfaces.

Reported-by: Saravana Kannan <saravanak@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
2020-03-18 15:29:44 +01:00
Giuliano Procida
dc5e2dd893 Tag add/remove/change lines unconditionally with [A], [D], [C].
These tags were previously only emitted by the default reporter if the
there were more than 100 (hard-coded constant) items in a a list. The
leaf reporter emitted them unconditionally. This change simplifies the
code, makes output more consistent and makes it easier to interpret
diffs of diff output.

Additionally, in the reporting of changed unreachable types, the
indentation and quoting for the deleted and added cases was missing.
This patch corrects these issues.

Finally, when doing package differences, there were no tags for
deleted/added binaries. This patch adds them.

	* src/abg-default-reporter.cc (report): In the corpus_diff
	override, remove calculations of number of changes (total) and
	comparisons against arbitrary threshold (large_num); emit [A],
	[D], [C] tags unconditionally.
	* src/abg-reporter-priv.cc
	(maybe_report_unreachable_type_changes): Remove comparisons of
	number of changes against arbitrary threshold (large_num);
	emit [A], [D], [C] tags unconditionally; fix quoting of
        deleted unreachable types; fix indentation of changed
	unreachable types.
	* tools/abipkgdiff.cc (compare_prepared_userspace_packages):
	Emit [D] and [A] tags for removed and added binaries.
	* tests/data/test-*/*report*.txt: In 109 report files, add
        tags [A], [D], [C] tags and correct some indentation and
        quoting.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-18 14:45:26 +01:00
Giuliano Procida
dcba808257 Fix interaction of --redundant and --leaf-changes-only options.
The --redundant (meaning show-redundant-changes) option is supposed to
be implied by --leaf-changes-only and this is currently implemented by
making diff_context's --leaf-changes-only setter also duplicate the
behaviour of its --redundant setter.

In both abidiff and abipkgdiff, the diff_context setters are called
unconditionally, but the relative order of the calls for these two
options is different in each case, resulting in two different issues.

In abidiff, the --redundant setter is called second, undoing the
intended side-effect of any --leaf-changes-only flag. So --redundant
is not actually turned on in --leaf-changes-only mode unless requested
explicitly.

In abipkgdiff, the leaf-changes-only setter is called second, undoing
(in non-leaf mode) the effect of any --redundant flag. So --redundant
has no effect in default reporting mode.

The fix is move to move the "--leaf-changes-only implies --redundant"
logic from the setter to the set_diff_context_from_opts functions.
This patch also documents the implied behaviour in the usage strings.

	* src/abg-comparison.cc (diff_context::show_leaf_changes_only):
	Remove "--leaf-changes-only implies --redundant" logic.
	* tools/abidiff.cc (display_usage): Mention that
	--leaf-changes-only implies --redundant.
	(set_diff_context_from_opts): Make --leaf-changes-only imply
	--redundant; document this behaviour in a comment.
	* tools/abipkgdiff.cc: Ditto.
	* tests/data/Makefile.am: Add new test case files.
	* tests/data/test-abidiff-exit/test-leaf3-report.txt: Add new
	test case, to show --leaf-changes-only implies --redundant.
	* tests/data/test-abidiff-exit/test-leaf3-v0.c: Ditto.
	* tests/data/test-abidiff-exit/test-leaf3-v0.o: Ditto.
	* tests/data/test-abidiff-exit/test-leaf3-v1.c: Ditto.
	* tests/data/test-abidiff-exit/test-leaf3-v1.o: Ditto.
	* tests/test-abidiff-exit.cc: Run new test case.
	* tests/data/test-diff-pkg/libcdio-0.94-1.fc26.x86_64--libcdio-0.94-2.fc26.x86_64-report.1.txt:
	Update abipkgdiff report with --redundant output.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-1.txt:
	Ditto.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt:
	Ditto.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-13 18:06:14 +01:00
Giuliano Procida
aadbd8cdbf abisym: Remove leading space in output.
When abisym reports a symbol as found, it currently emits a leading
space. It does not do this when reporting a symbol as not found.

This patch removes the leading space.

	* tools/abisym.cc (main): Remove leading space from output.
	* tests/data/test-lookup-syms/test0-report.txt: Remove leading
	space from expected output.
	* tests/data/test-lookup-syms/test01-report.txt: Ditto.
	* tests/data/test-lookup-syms/test02-report.txt: Ditto.
	* tests/data/test-lookup-syms/test1-1-report.txt: Ditto.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-03-10 18:03:03 +01:00
Dodji Seketeli
1d6731c438 Update copyright year to 2020
We are in February 2020 so this is long overdue.

	* include/abg-comp-filter.h: Update copyright year to 2020.
	* include/abg-comparison.h: Likewise.
	* include/abg-config.h: Likewise.
	* include/abg-corpus.h: Likewise.
	* include/abg-cxx-compat.h: Likewise.
	* include/abg-diff-utils.h: Likewise.
	* include/abg-dwarf-reader.h: Likewise.
	* include/abg-fwd.h: Likewise.
	* include/abg-hash.h: Likewise.
	* include/abg-ini.h: Likewise.
	* include/abg-interned-str.h: Likewise.
	* include/abg-ir.h: Likewise.
	* include/abg-libxml-utils.h: Likewise.
	* include/abg-libzip-utils.h: Likewise.
	* include/abg-reader.h: Likewise.
	* include/abg-reporter.h: Likewise.
	* include/abg-sptr-utils.h: Likewise.
	* include/abg-suppression.h: Likewise.
	* include/abg-tools-utils.h: Likewise.
	* include/abg-traverse.h: Likewise.
	* include/abg-viz-common.h: Likewise.
	* include/abg-viz-dot.h: Likewise.
	* include/abg-viz-svg.h: Likewise.
	* include/abg-workers.h: Likewise.
	* include/abg-writer.h: Likewise.
	* src/abg-comp-filter.cc: Likewise.
	* src/abg-comparison-priv.h: Likewise.
	* src/abg-comparison.cc: Likewise.
	* src/abg-config.cc: Likewise.
	* src/abg-corpus-priv.h: Likewise.
	* src/abg-corpus.cc: Likewise.
	* src/abg-default-reporter.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-internal.h: Likewise.
	* src/abg-ir-priv.h: Likewise.
	* src/abg-ir.cc: Likewise.
	* src/abg-leaf-reporter.cc: Likewise.
	* src/abg-libxml-utils.cc: Likewise.
	* src/abg-libzip-utils.cc: Likewise.
	* src/abg-reader.cc: Likewise.
	* src/abg-reporter-priv.cc: Likewise.
	* src/abg-reporter-priv.h: Likewise.
	* src/abg-sptr-utils.cc: Likewise.
	* src/abg-suppression-priv.h: 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.
	* tests/print-diff-tree.cc: Likewise.
	* tests/test-abicompat.cc: Likewise.
	* tests/test-abidiff-exit.cc: Likewise.
	* tests/test-abidiff.cc: Likewise.
	* tests/test-alt-dwarf-file.cc: Likewise.
	* tests/test-core-diff.cc: Likewise.
	* tests/test-diff-dwarf-abixml.cc: Likewise.
	* tests/test-diff-dwarf.cc: Likewise.
	* tests/test-diff-filter.cc: Likewise.
	* tests/test-diff-pkg.cc: Likewise.
	* tests/test-diff-suppr.cc: Likewise.
	* tests/test-diff2.cc: Likewise.
	* tests/test-dot.cc: Likewise.
	* tests/test-ini.cc: Likewise.
	* tests/test-ir-walker.cc: Likewise.
	* tests/test-lookup-syms.cc: Likewise.
	* tests/test-read-dwarf.cc: Likewise.
	* tests/test-read-write.cc: Likewise.
	* tests/test-svg.cc: Likewise.
	* tests/test-tools-utils.cc: Likewise.
	* tests/test-types-stability.cc: Likewise.
	* tests/test-utils.cc: Likewise.
	* tests/test-utils.h: Likewise.
	* tests/test-write-read-archive.cc: Likewise.
	* tools/abiar.cc: Likewise.
	* tools/abicompat.cc: Likewise.
	* tools/abidiff.cc: Likewise.
	* tools/abidw.cc: Likewise.
	* tools/abilint.cc: Likewise.
	* tools/abipkgdiff.cc: Likewise.
	* tools/abisym.cc: Likewise.
	* tools/binilint.cc: Likewise.
	* tools/kmidiff.cc: Likewise.
	* update-copyright.sh: Fix the updating script to handle not just
	"Red Hat, Inc."

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-02-21 17:05:01 +01:00
Matthias Maennich
e0088cff76 Fix some parameter name inconsistencies
Clang-tidy flags those name inconsistencies and they are trivial to fix,
hence just do it. No functional change.

	* src/abg-comparison-priv.h
	(corpus_diff::priv::count_unreachable_types): use consistent
	parameter naming.
	* tools/abidiff.cc(main): Likewise.

Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2020-02-03 14:39:18 +00:00
Giuliano Procida
95535d8f6f Don't ignore options when diffing translation units (.bi files).
There was an inconsistency in the way the diff context was used for
different file types. This change eliminates this and so .bi files now
have all the command line options applied to their diffs.

	* tests/data/Makefile.am: Add test case files.
	* tests/data/test-abidiff-exit/test-loc-*: New test cases.
	* tests/test-abidiff-exit.cc (in_out_specs): Add new test cases.
	* tools/abidiff.cc (main): Use populated ctxt for translation unit
	diff.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-02-03 14:08:26 +01:00