Commit Graph

616 Commits

Author SHA1 Message Date
Giuliano Procida
93fae877d8 Simplify peel_typedef_pointer_or_reference_type
The second argument to this function controls whether CV qualifiers
should be stripped as well as the elements mentioned in the function
name. While it defaults to true, it is now always passed in as false.

The function contains incomplete code for peeling array types. This is
not needed or indeed wanted by its current callers.

This commits removes the peel_qual_type argument and removes the
associated behaviour. It removes the array peeling code.

There are no functional changes apart from no longer performing early
canonicalisation of certain array types.

I looked at the history of this function to see where the behaviours
originated.

bd161caa Make type_has_non_canonicalized_subtype() tighter

The function is added to help make more types, self-referential ones,
candidates for early canonicalisation.

5822798d Bug 18894 - Fix representation of enumerators in abixml format

This undid the previous change but the function remained.

c20c8c79 Fix infinite loop in peel_typedef_pointer_or_reference_type

As it says, fixing the overload that is currently in use.

6e36a438 Late canonicalize all types that reference classes when reading DWARF

This reintroduced the use of the function to control canonicalisation
by the detection of class types. It also added array peeling to the
function, but in a broken fashion as it would only work for certain
combinations of pointers, references or typedefs referring to arrays.

e9bdb488 Bug 19025 - abixml writer forgets to emit some member types

This added a use of the function in a map key comparison function.

8cc382c8 Fix emitting of referenced type in abixml writer

This undid the previous change.

1bee40c0 Do not forget to peel qualified type off when peeling types

This made the function remove CV qualifiers unconditionally.

e73901a5 Do not mark "distinct" diff nodes as being redundant

This made behaviour to remove CV qualifiers optional and newly added
is_mostly_distinct_diff disabled it.

5d6af8d5 Delay canonicalization for array and qualified types

This change switches maybe_canonicalize_type to not request CV
qualifer peeling from peel_typedef_pointer_or_reference_type.

It partially resolves the array type issue as they are separately
checked for. Presumably they shouldn't be peeled, but still are under
some circumstances.

The tests here could be subject to further refinement. Many types have
delayed canonicalisation already.

9cf76b11 abg-ir.cc: Improve types_have_similar_structure.

This change replaced the use of the function with a more delicate
matched peeling process for pointer and reference types plus
peel_qualified_or_typedef_type. It obsoleted the behaviour where CV
qualifiers were stripped.

	* include/abg-fwd.h (peel_qualified_or_typedef_type): Remove
	second argument in declarations of both overloads.
	* src/abg-comp-filter.cc (is_mostly_distinct_diff): Remove
	second argument to peel_qualified_or_typedef_type.
	* src/abg-dwarf-reader.cc (maybe_canonicalize_type): Likewise.
	* src/abg-ir.cc (peel_qualified_or_typedef_type): In both
	overloads, remove second argument peel_qual_type, simplify
	code with the assumption it was always false and remove
	incomplete array type peeling logic. In type_base_sptr
	overload, remove stray space.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-07-27 15:26:27 +02:00
Giuliano Procida
3b93574beb Remove unused is_reference_or_pointer_diff.
The function is_reference_or_pointer_diff was added in commit

85929105 Fix redundancy marking for change of types used directly

and was updated to peel typedefs as a first step in

ef9d20c9 Fix redundancy detection through fn ptr and typedef paths

which, however, also made it obsolete.

This commit removes the function's declaration and definition.
There are no functional changes.

	* include/abg-comparison.h (is_reference_or_pointer_diff):
	Drop function declaration.
	* src/abg-comparison.cc (is_reference_or_pointer_diff): Drop
	function definition.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-07-27 15:26:04 +02:00
Giuliano Procida
12baf89751 abg-comparison.h: Remove stray declaration
The functon is_reference_or_pointer_diff_to_non_basic_distinct_types
was declared in

ef9d20c9 Fix redundancy detection through fn ptr and typedef paths

but never defined. This commit removes it. There are no functional
changes.

	* include/abg-comparison
	(is_reference_or_pointer_diff_to_non_basic_distinct_types):
	Remove stray declaration.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-07-27 15:26:04 +02:00
Giuliano Procida
697347e402 Fix corpus_diff::has_net_changes for --leaf-changes-only mode
This function was not aware of --leaf-changes-only mode.

    - Stats counters for changed variables and types have
      different names in the different modes.
    - Net leaf type changes were not included in leaf mode.

For some inputs, this resulted in abidiff producing an empty report
but returning a non-zero exit status in --leaf-changes-only mode.

For other inputs the combination of both issues still resulted in the
correct return code. This included the following test-abidiff-exit
test cases:

    - test-leaf-peeling
    - test-leaf2
    - test-no-stray-comma

This patch makes corpus_diff::has_net_changes mirror emit_diff_stats,
modulo flags like --non-reachable-types which if absent can still
result in discrepancies between output and return code.

To achieve this in a more maintainable way, the patch introduces a new interface
reporter_base::diff_has_net_changes.  That interface is implemented by
all current reporters.  Each reporter focuses on its own
particularities to provide the required behavious. Then
corpus_diff:has_net_changes just has to invoke
reporter_base::diff_has_net_changes on the reporter that is currently
in used.

The tests below verify that the exit code is zero when all the changes
between the test files are suppressed.

	* include/abg-reporter.h ({reporter_base, default_reporter,
	leaf_reporter}::diff_has_net_changes): Add new virtual function.
	This breaks binary compatibility but should conserve source
	compatibility.
	* src/abg-default-reporter.cc
	(default_reporter::diff_has_net_changes): Define new member
	function.
	* src/abg-leaf-reporter.cc (leaf_reporter::diff_has_net_changes):
	Likewise.
	* src/abg-comparison.cc (corpus_diff::has_net_changes): Invoke
	reporter_base::diff_has_net_changes on the current reporter,
	rather than trying to handle all the different kinds of reporters
	here.
	(corpus_diff::priv::apply_filters_and_compute_diff_stats): Add a
	TODO to possibly delegate the implementation of this function to
	the reporters.
	* tests/data/Makefile.am: Add new test case files.
	* tests/data/test-abidiff-exit/test-net-change-report0.txt:
	Normal mode, nothing suppressed.
	* tests/data/test-abidiff-exit/test-net-change-report1.txt:
	Normal mode, everything suppressed.
	* tests/data/test-abidiff-exit/test-net-change-report2.txt:
	Leaf mode, nothing suppressed.
	* tests/data/test-abidiff-exit/test-net-change-report3.txt:
	Leaf mode, everything suppressions.
	* tests/data/test-abidiff-exit/test-net-change-v0.c: Test file
	* tests/data/test-abidiff-exit/test-net-change-v0.o: Test file
	* tests/data/test-abidiff-exit/test-net-change-v1.c: Test file
	* tests/data/test-abidiff-exit/test-net-change-v1.o: Test file
	* tests/data/test-abidiff-exit/test-net-change.abignore: This
	suppresses changes for all variables, functions and types in
	the test files, except for the 'victim' function.
	* tests/test-abidiff-exit.cc: Run new test cases.

Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-07-21 08:53:19 +02:00
Giuliano Procida
dbef379a96 Support incomplete enums in core and diff code.
This is an initial implementation of the support for incomplete, also
known as forward-declared, enum types. I've not made any attempt to
refactor or share logic with the struct/union code.

	* include/abg-comp-filter.h (has_decl_only_def_change) : Declare
	New function.
	* src/abg-comp-filter.cc (there_is_a_decl_only_enum): Define new
	static function and ...
	(type_size_changed): ... use it here.
	(has_decl_only_def_change): Define new function and ...
	(categorize_harm{less, ful}_diff_node): ... use it here.
	* include/abg-fwd.h (enums_type, decl_base_wptr): Declare new
	typedefs.
	(look_through_decl_only_class): Declare new overload for
	class_or_union*.
	(is_compatible_with_enum_type, is_compatible_with_enum_type)
	(look_through_decl_only, lookup_enum_types, lookup_enum_types):
	Declare new functions.
	* include/abg-ir.h (decl_base::{get_is_declaration_only,
	set_is_declaration_only, set_definition_of_declaration,
	get_definition_of_declaration,
	get_naked_definition_of_declaration}): Declare new member
	functions.  They were moved here from the class_or_union class.
	(class_or_union::{get_earlier_declaration,
	set_earlier_declaration, get_definition_of_declaration,
	set_definition_of_declaration,
	get_naked_definition_of_declaration, get_is_declaration_only,
	set_is_declaration_only}): Remove these member functions.
	* src/abg-ir.cc (decl_base::priv::{declaration_,
	definition_of_declaration_, naked_definition_of_declaration_,
	is_declaration_only_}): Define data members.  Moved here from
	class_or_union.
	(decl_base::priv::priv): Adjust to initialize the new data
	members.
	(decl_base::{get_earlier_declaration, set_earlier_declaration,
	get_definition_of_declaration,
	get_naked_definition_of_declaration, get_is_declaration_only,
	set_is_declaration_only, set_definition_of_declaration}): Define
	member functions.
	(operator|): In the overload for (change_kind, change_kind),
	adjust the return type of the call to
	decl_base::get_definition_of_declaration.
	(look_through_decl_only): Define new function.
	(look_through_decl_only_class): Adjust.
	(look_through_decl_only_enum): Likewise.
	(maybe_update_types_lookup_map<class_decl>): Adjust return type of
	call to decl_base::get_definition_of_declaration.
	(types_defined_same_linux_kernel_corpus_public): Use
	look_through_decl_only_class rather than open coding it.
	(class_or_union::priv::{declaration_, definition_of_declaration_,
	naked_definition_of_declaration_, is_declaration_only_}): Remove
	these data members.  They are now carried by decl_base::priv.
	(class_or_union::{g,s}et_alignment_in_bits): Adjust.
	(class_or_union::{g,s}et_size_in_bits): Likewise.
	(class_or_union::operator==): Likewise.
	(equals): Adjust the overload for class_or_union.
	(is_compatible_with_enum_type)
	* src/abg-comparison.cc (try_to_diff<class_decl>): Adjust the
	return type of decl_base::get_definition_of_declaration.
	(leaf_diff_node_marker_visitor::visit_begin): Use
	filtering::has_decl_only_def_change rather than
	filtering::has_class_decl_only_def_change.  Decl-only changes to
	enums (or any other type really) will thus not be recorded as leaf
	changes.
	* src/abg-dwarf-reader.cc (get_scope_for_die): Adjust return type
	of decl_base::get_definition_of_declaration.
	* src/abg-default-reporter.cc (default_reporter::report): Report
	enum decl-only <-> definition changes.
	* src/abg-hash.cc (class_or_union:#️⃣:operator()): In the
	overload for class_or_union& adjust the return type for
	decl_base::get_definition_of_declaration.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-07-08 16:59:56 +02:00
Giuliano Procida
401e3cded9 abg-ir.cc: Remove unused re_canonicalize function.
The function re_canonicalize was added in commit:

  286cadf8 Bug 24430 - Fold away const for array types

but later rendered obsolete by commit:

  5d6af8d5 Delay canonicalization for array and qualified types

This commit removes the function and its associated declarations.

	* include/abg-fwd.h (re_canonicalize): Remove declaration of
	obsolete function.
	* include/abg-ir.h (class {decl_base, type_base}): Remove
	re_canonicalize friend declarations from these classes.
	* src/abg-ir.cc (re_canonicalize): Remove obsolete function.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-07-07 16:26:47 +02:00
Dodji Seketeli
346e88dd76 Bug 26135 - Wrong linkage name causes anonymous classes miscomparison
When comparing decls, the overload of the 'equals' function for
instances of decl_base compares their linkage names.  If they are
different, then the decls are generally considered different.

Class declarations (and definitions) also use the 'equals' function
referred to above.  So when two classes have different linkage names,
they are always considered different.

Now let's consider the case of an anonymous class.  It doesn't have
any user-provided name, by definition.  Libabigail does, however,
assigns it an internal name for various (internal) purposes.  That
internal name is generally ignored for the purpose of (anonymous) type
comparison.  So by design, two anonymous classes can have different
internal anonymous names and yet still happen to be equal.

The root issue in this problem report is that by default, the linkage
name of a class is set to its name.  And when that class is anonymous,
its internal name is used as its linkage name.  Oops.  That leads to
anonymous classes being wrongly considered different.

This patch fixes the issue by providing additional constructors for a
class type to avoid using the internal anonymous name as its linkage
name.

Note that the same issue is present for unions so the patch does the
a similar thing for union types.

Enums are properly handled so we don't need to do anything in that
regard.

For good measure, the patch also adds an assert to
type_base::get_canonical_types_for to ensure that anonymous class or
union types don't have linkage names for now.

	* include/abg-ir.h (class_decl::class_decl): Add two overloads
	that take the "is_anonymous" flag.
	(union_decl::union_decl): Likewise.
	* src/abg-ir.cc (class_decl::class_decl): Define two overloads
	that take the "is_anonymous" flag and set the linkage name
	accordingly.
	(union_decl::union_decl): Likewise.
	(type_base::get_canonical_type_for): Assert that an anonymous
	class or union can't have a linkage name for now.
	* src/abg-dwarf-reader.cc (add_or_update_class_type)
	(add_or_update_union_type): Use a new overload for the constuctor
	of {class, union}_decl and set the "is_anonymous" flag.  Don't use
	decl_base::set_is_anonymous anymore.
	* src/abg-reader.cc (build_class_decl, build_union_decl):
	Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Adjust.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-07-06 18:26:08 +02:00
Giuliano Procida
dd1c608120 Rename declaration-definition change category.
This patch renames CLASS_DECL_ONLY_DEF_CHANGE_CATEGORY to
TYPE_DECL_ONLY_DEF_CHANGE_CATEGORY.

	* include/abg-comparison.h (TYPE_DECL_ONLY_DEF_CHANGE_CATEGORY):
	Rename CLASS_DECL_ONLY_DEF_CHANGE_CATEGORY into this.
	(EVERYTHING_CATEGORY): In the value of this enumerator, rename
	CLASS_DECL_ONLY_DEF_CHANGE_CATEGORY into
	TYPE_DECL_ONLY_DEF_CHANGE_CATEGORY.
	* src/abg-comp-filter.cc (categorize_harmless_diff_node):
	Likewise.
	* src/abg-comparison.cc (get_default_harmless_categories_bitmap):
	Likewise.
	(operator<<(ostream& o, diff_category c)): Likewise.
	* src/abg-default-reporter.cc (default_reporter::report): Likewise
	in the overload for class_or_union_diff.
	* src/abg-leaf-reporter.cc (leaf_reporter::report): Likewise in
	the overload for class_or_union_diff.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-06-29 18:06:21 +02:00
Giuliano Procida
df47240f7d Improve code comments and whitespace.
These are zero impact changes.

	* include/abg-fwd.h: Correct doc-comment reference to
	enum_type_decl.
	* src/abg-comp-filter.cc: Fix doc-comment syntax.
	* src/abg-comparison.cc (operator<<): In the diff_category
	overload, fix code indentation.
	* src/abg-default-reporter.cc (report): In the
	class_or_union_diff overload, adjust comment to reflect that
	the code is reporting changes between declaration-only and
	defined types, in either direction.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-06-25 17:49:57 +02:00
Dodji Seketeli
a5d02b95a6 Bug 26127 - abidw --annotate emits incomplete function types
When we get the qualified name of a pointer type, the result is cached
so that subsequent invocations of the getter yields a faster result.

When the pointed-to type is not yet fully constructed at the time of
the first invocation of the getter of the qualified name, what is
cached is the name of the pointer to a non-yet fully qualified type.

Then after the pointed-to type is fully constructed (and
canonicalized), the pointer type also becomes canonicalized (in that
order) and thus, the cache needs to be invalidated so that the
qualified name of the pointer to the fully qualified type is cached
again by a subsequent invocation of the getter.

The problem in this problem report is that the cache doesn't get
invalidated when the pointer type is canonicalized.

This patch fixes that.  A similar issue exists with reference and
qualified types so the patch addresses it for those types as well.

	* include/abg-ir.h (decl_base::clear_qualified_name): Declare new
	protected member function.
	({pointer_type_def, reference_type_def, qualified_type_def,
	function_type}::on_canonical_type_set): Declare virtual member
	functions.
	* src/abg-ir.cc (decl_base::clear_qualified_name): Define new
	protected member function.
	({pointer_type_def, reference_type_def, qualified_type_def,
	function_type}::on_canonical_type_set): Define virtual member
	functions.
	* tests/data/test-annotate/test17-pr19027.so.abi: Adjust.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-06-18 15:07:34 +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
Giuliano Procida
660605728f Eliminate non-ASCII characters.
There are few non-ASCII characters in various code comments. A few are
typos and the rest have obvious ASCII equivalents. This commit
replaces them all with ASCII characters.

	* include/abg-diff-utils.h: Replace "’’" with "'".
	* src/abg-elf-helpers.cc: Replace "⋅" with ".".
	* src/abg-ini.cc: Replace "@êef" with "@ref".
	* src/abg-ir.cc: Ditto.
	* src/abg-tools-utils.cc: Replace "–" with "-".

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-06-15 10:56:44 +02:00
Matthias Maennich
20b989fd3c abg-reporter: fully qualify std::string and std::ostream
In order to not unnecessarily pollute the abigail namespace and to avoid
ambiguity at compile time, fully qualify std::string and std::string.
This also resolves the issue that include/abg-reporter.h could not be
compiled standalone and therefore was broken as a public header. It
required a `using std::string` from a prior include.

	* include/abg-reporter.h (reporter_base::report) fully qualify
	std::string and std::ostream for all overloads.
	(default_reporter::report_local_typedef_changes): Likewise.
	(default_reporter::report_local_qualified_type_changes): Likewise.
	(default_reporter::report_local_reference_type_changes): Likewise.
	(default_reporter::report_local_function_type_changes): Likewise.
	(default_reporter::report): Likewise.
	(leaf_reporter::report_changes_from_diff_maps): Likewise.
	(leaf_reporter::report): Likewise.

Suggested-by: Mark Barolak <mbar@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
2020-06-11 15:10:44 +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
Dodji Seketeli
5eb4d7627a Bug 25661 - Support data member replacement by anonymous data member
We ought to detect when a data member is replaced by an anonymous data
member in a way that doesn't change the ABI in an incompatible way,
especially when that change is non equivocal.

For instance, consider this ABI-visible struct:

    struct S
    {
      int a;
    };

Now, consider that it's changed into:

    struct S
    {
      union
      {
	int a;
	char b;
      };
    };

Stricto sensu, the bit-layout of struct S doesn't change and so that
change isn't ABI-incompatible.

The current version of libabigail however flags that change as a
/potential/ issue and asks the user for further review.  It appears
that this class of changes is frequent enough to be annoying,
especially in semi-automatic ABI compliance checking setups where we
want the least possible "false positives".

This patch detects that kind of change patterns where a data member is
replaced by an anonymous data member in a benign way, in terms of ABI.

So now let's look at a more complicated example where an ABI-visible
type looks like:

struct S
{
  int a;
  int b;
  int c;
};

Now suppose that type was changed into:

struct S
{
  union
  {
    int tag[3];
    struct
    {
      int a;
      int b;
      int c;
    };
  };
};

The patch allows abidiff to recognise that kind of pattern, filter out
the detected change and report by default that the two binaries are
ABI compatible.

Here are the output that we'd get:

$ abidiff test-v0.o test-v1.o
Functions changes summary: 0 Removed, 0 Changed (1 filtered out), 0 Added function
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

When asked to show the detailed of the filtered out changes, we get:

$ abidiff --harmless test-v0.o test-v1.o
Functions changes summary: 0 Removed, 1 Changed, 0 Added function
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

1 function with some indirect sub-type change:

  [C] 'function void foo(S*)' at test-v1.cc:18:1 has some indirect sub-type changes:
    parameter 1 of type 'S*' has sub-type changes:
      in pointed to type 'struct S' at test-v1.cc:1:1:
        type size hasn't changed
        data members 'S::a', 'S::b', 'S::c' were replaced by anonymous data member:
          'union {int tag[3]; struct {int a; int b; int c;};}'

And using the leaf-node reporter, that would give:

$ abidiff --leaf-changes-only --harmless test-v0.o test-v1.o
Leaf changes summary: 1 artifact changed
Changed leaf types summary: 1 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 0 Added function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

'struct S at test-v0.cc:1:1' changed:
  type size hasn't changed
  data members 'S::a', 'S::b', 'S::c' were replaced by anonymous data member:
    'union {int tag[3]; struct {int a; int b; int c;};}'

	* include/abg-comp-filter.h (has_data_member_replaced_by_anon_dm):
	Declare new function.
	* include/abg-comparison.h (changed_var_sptr)
	(changed_var_sptrs_type): Declare new typedefs.
	(HARMLESS_DATA_MEMBER_CHANGE_CATEGORY): Add a new enumerator to
	the diff_category enum.
	(EVERYTHING_CATEGORY): In the diff_category, adjust this
	enumerator to OR the new HARMLESS_DATA_MEMBER_CHANGE_CATEGORY into
	it.
	(SUPPRESSED_CATEGORY, PRIVATE_TYPE_CATEGORY)
	(SIZE_OR_OFFSET_CHANGE_CATEGORY, VIRTUAL_MEMBER_CHANGE_CATEGORY)
	(CLASS_DECL_ONLY_DEF_CHANGE_CATEGORY)
	(FN_PARM_TYPE_TOP_CV_CHANGE_CATEGORY)
	(FN_RETURN_TYPE_CV_CHANGE_CATEGORY, VAR_TYPE_CV_CHANGE_CATEGORY)
	(VOID_PTR_TO_PTR_CHANGE_CATEGORY)
	(BENIGN_INFINITE_ARRAY_CHANGE_CATEGORY): Adjust the value of these
	enumerators of the diff_category enum.
	(class_or_union_diff::{data_members_replaced_by_adms,
	ordered_data_members_replaced_by_adms}): Declare new member
	functions.
	* include/abg-fwd.h (var_decl_wptr): Declare new typedef.
	(get_next_data_member, get_first_non_anonymous_data_member)
	(find_data_member_from_anonymous_data_member)
	(get_absolute_data_member_offset): Declare new functions.
	* include/abg-ir.h (struct anonymous_dm_hash): Declare new type.
	(anonymous_data_member_sptr_set_type): Declare new typedef.
	(class decl_base): Befriend class class_or_union.
	(class dm_context_rel): Pimpl-ify this class.
	(dm_context_rel::{g,s}et_anonymous_data_member_types): Declare new
	member functions.
	(var_decl::get_anon_dm_reliable_name): Declare new member
	function.
	(class var_decl): Make get_absolute_data_member_offset,
	get_absolute_data_member_offset be friends of this.
	(class_or_union::maybe_fixup_members_of_anon_data_member): Declare
	new protected member function.
	* src/abg-comp-filter.cc (has_data_member_replaced_by_anon_dm):
	Define new function.
	(categorize_harmless_diff_node): Use the above.
	* src/abg-comparison-priv.h
	(class_or_union_diff::priv::{dms_replaced_by_adms_,
	changed_var_sptrs_type dms_replaced_by_adms_ordered_}): Add new
	data members.
	(data_member_comp::compare_data_members): Factorize this out of ...
	(data_member_comp::operator()(decl_base_sptr&, decl_base_sptr&)):
	... this.
	(data_member_comp::operator()(changed_var_sptr&,
	changed_var_sptr&)): Add new member function.
	(sort_changed_data_members): Declare ...
	* src/abg-comparison.cc (sort_changed_data_members): ... new
	function.
	(get_default_harmless_categories_bitmap): Adjust to take the new
	abigail::comparison::HARMLESS_DATA_MEMBER_CHANGE_CATEGORY into
	account.
	(operator<<(ostream& o, diff_category c)): Likewise.
	(class_or_union_diff::ensure_lookup_tables_populated): Handle
	Handle the insertion of anonymous data members to replace existing
	data members.
	(class_or_union_diff::{data_members_replaced_by_adms,
	ordered_data_members_replaced_by_adms}): Define new accessors.
	(suppression_categorization_visitor::visit_end): Propagate the
	SUPPRESSION_CATEGORIZATION_VISITOR from changes to the type of the
	data member if the data member doesn't have real local changes.
	* src/abg-default-reporter.cc (default_reporter::report): Report
	about anonymous data members that replace data members.
	* src/abg-ir.cc (struct dm_context_rel::priv): Define new data
	structure.
	(dm_context_rel::{dm_context_rel, get_is_laid_out,
	set_is_laid_out, get_offset_in_bits, set_offset_in_bits,
	operator==, operator!=, get_anonymous_data_member,
	set_anonymous_data_member}): Define the member functions here as
	they are not inline anymore.
	(class_or_union::maybe_fixup_members_of_anon_data_member): Define
	new member function.
	(class_or_union::add_data_member): Use it.
	(get_first_non_anonymous_data_member, get_next_data_member)
	(get_absolute_data_member_offset)
	(find_data_member_from_anonymous_data_member): Define new
	functions.
	* src/abg-reporter-priv.h
	(maybe_report_data_members_replaced_by_anon_dm): Declare ...
	* src/abg-reporter-priv.cc
	(maybe_report_data_members_replaced_by_anon_dm): ... new function.
	* src/abg-leaf-reporter.cc (leaf_reporter::report): Report data
	members replaced by anonymous data members.
	* tests/data/test-diff-filter/test-PR25661-[1-6]-report-[1-4].txt: New
	test reference outputs.
	* tests/data/test-diff-filter/test-PR25661-[1-6]-v{0,1}.c: Test
	source code files.
	* tests/data/test-diff-filter/test-PR25661-[1-6]-v{0,1}.o: Test
	binary input files.
	* tests/data/Makefile.am: Add the new test files above to source
	distribution.
	* tests/test-diff-filter.cc (in_out_specs): Add the binary test
	inputs above to this test harness.
	* tests/data/test-diff-dwarf/test45-anon-dm-change-report-0.txt:
	Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-05-18 13:42:50 +02:00
Dodji Seketeli
88fcbfeced dwarf-reader: support several anonymous data members in a given class
At the moment, if a class has more than one anonymous data member, we
are just keeping the first one and dropping the others.

This patch fixes that.

Now that there is the possibility of having several anonymous data
members in a given class we need to be able to name them correctly, to
tell them apart.  That means we cannot use the name returned by
var_decl::get_name() as that name is empty for an anonymous data
member.  This patch thus introduces a new method
var_decl::get_anon_dm_reliable_name() which returns a name that is
reliable (non-empty) even when the var_decl designates an anonymous
data member.  Note that there are many situations where we still need
to have var_decl::get_name() behave like it used to, so we can't make
it invariably return what var_decl::get_anon_dm_reliable_name()
returns today.

	* include/abg-ir.h (class_or_union::find_anonymous_data_member):
	Declare a new member function.
	(class_or_union::find_data_member): Declare a new overload.
	(var_decl::get_anon_dm_reliable_name): Declare new member
	function.
	* src/abg-ir.cc (var_decl::get_pretty_representation): Make this
	work on a var_decl is going to be used to represent an anonymous
	data member even before the var_decl has been added to its finale
	scope.  This is useful to make class_or_union::find_data_member
	work on a var_decl that is to be used as an anonymous data member.
	(var_decl::get_anon_dm_reliable_name): Define new member function.
	(class_or_union::find_data_member): In the existing overload that
	takes a string, look for the named data member inside the
	anonymous data members.  Define a new overload that takes a
	var_decl_sptr, to look for anonymous data members.
	(class_or_union::find_anonymous_data_member): Define a new member
	function.
	(lookup_data_member): Use the existing
	class_or_union::find_data_member.
	* src/abg-reader.cc: (build_class_decl): Use the full anonymous
	variable for lookup, rather than its name which is empty and will
	thus give false positives.
	* src/abg-dwarf-reader.cc (add_or_update_class_type): Likewise.
	* src/abg-comparison.cc
	(class_or_union_diff::ensure_lookup_tables_populated): Name
	anonymous data members properly - as opposed to wrongly using
	their empty name.
	* src/abg-reporter-priv.cc (represent): In the overload for
	var_diff_sptr, make sure that changes to the /type/ of a variable
	declaration are always reported.
	* tests/data/test-abidiff-exit/test-member-size-report0.txt:
	Adjust as we now emit more detailed changes about anonymous data
	members.
	* tests/data/test-abidiff-exit/test-member-size-report1.txt:
	Likewise.
	* tests/data/test-annotate/test-anonymous-members-0.o.abi: Adjust
	to reflect the fact that a class can now have several anonymous
	data members.
	* tests/data/test-diff-dwarf-abixml/PR25409-librte_bus_dpaa.so.20.0.abi:
	Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt:
	Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt:
	Likewise.
	* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt:
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-05-18 13:42:50 +02:00
Dodji Seketeli
48f26ddc00 {default,leaf}-reporter: group data members changes reports together
There are two kinds of data member changes:

  1/ changes to the type or offset of a given data member
     basically, in this kind of change, the name of the data member
     remained the same.

  2/ changes where the data member (at a given offset) was replaced by
     something else completely.

Today, the comparison engine recognizes these two kinds of changes and
records them in two different data structures.  This is useful because
it allows for a finer grain analysis.

But when we report these changes, today, we report them separately and
sometimes that doesn't make sense.  For instance, because there is no
change of the 1/ kind, the reporter would say "no data member
changes", and yet go ahead and emit data member changes of the 2/ kind.

This patch groups the reporting of the two kinds of changes so that
when it says "no data member changes", it means there was no data
member changes at all.

	* include/abg-comparison.h
	(class_or_union_diff::{sorted_changed_data_members,
	count_filtered_changed_data_members,
	sorted_subtype_changed_data_members,
	count_filtered_subtype_changed_data_members}): Declare ...
	* src/abg-comparison.cc
	(class_or_union_diff::{sorted_changed_data_members,
	count_filtered_changed_data_members,
	sorted_subtype_changed_data_members,
	count_filtered_subtype_changed_data_members}): ... accessors for
	existing private data members.
	* src/abg-default-reporter.cc (default_reporter::report): In the
	class_or_union_diff& overload, group the reporting of the changes
	to data member sub-types with the replacement of data members.
	These are just data member changes after all.  Use the newly
	declared accessors for better measure.
	* src/abg-leaf-reporter.cc (leaf_reporter::report): Likewise.
	* tests/data/test-diff-dwarf/test45-anon-dm-change-report-0.txt: Adjust.
	* src/abg-leaf-reporter.cc (leaf_reporter::report): Likewise.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt:
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-05-18 13:42:50 +02:00
Giuliano Procida
38504ab66c Tidy get_pretty_representation qualified_name.
The virtual function get_pretty_representation exists in many
classes (derived from type_or_decl_base). It takes a qualified_name
argumenta and this is defaulted to true in all but one case which
seems to be an oversight.

This commit changes this for no better reason than consistency.

	* include/abg-ir.h (type_decl::get_pretty_representation)
	Change default for qualified_name parameter to true.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-05-14 16:34:30 +02:00
Mark Wielaard
66e5e36469 Don't iterate before the start of a RandomAccessOutputIterator.
Found with -D_GLIBCXX_DEBUG. You cannot go before the start of an
RandomAccessOutputIterator. Iterator -1 + 1 might seem to work,
but is actually undefined behaviour.

	* include/abg-diff-utils.h (compute_diff): Put brackets around
	p[ux].[xy]() + 1 calculation.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2020-05-13 13:00:52 +02:00
Giuliano Procida
c72f52c381 Add POSIX regex wrapper functions.
libabigail code uses the POSIX regex library consistently:

    - compile std::string to regex, with the flag REG_EXTENDED
    - store regex using a shared pointer wrapper
    - check match of regex against std::string

All the C string / std::string logic and so on is repeated at every
call site. This patch introduces wrapper functions to take care of
this logic.

There are no behavioural changes.

	* include/abg-regex.h (compile): Declare new function.
	(match): Declare new function.
	* src/abg-regex.cc (compile): Add new function wrapping
	regcomp. (match): Add new function wrapping regexec.

Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-05-11 18:30:44 +02:00
Giuliano Procida
44ce7a5755 Escape names used in symbol whitelisting regex.
There is the theoretical possibility that symbols may contain special
regex characters like '.' and '$'. This patch ensures all such
characters in symbol names are escaped before they are added to the
whitelisting regex.

	* include/regex.h (escape): New string reference holder
	class. (operator<<): Declaration of std::ostream,
	regex::escape overload.
	* include/regex.cc (operator<<): New std::ostream,
	regex::escape overload that outputs regex-escaped strings.
	* src/abg-tools-utils.cc
	(gen_suppr_spec_from_kernel_abi_whitelists): Make sure any
	special regex characters in symbol names are escaped.

Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-05-11 15:58:11 +02:00
Giuliano Procida
1a3c6ec12a Make set_drops_artifact_from_ir non-const.
Setters should be non-const but set_drops_artifact_from_ir isn't.
This patch fixes this.

This reason this didn't cause a compilation failure is that const
shared_ptr<X> is equivalent to X *const, not const X*.

Note that resolving the apparent const-safety issue will require
std::experimental::propagate_const or similar.

	* include/abg-suppression.h
	(suppression_base::set_drops_artifact_from_ir):
	Drop const qualifier.
	* src/abg-suppression.cc
	(suppression_base::set_drops_artifact_from_ir):
	Drop const qualifier.

Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-05-11 14:36:55 +02:00
Giuliano Procida
8282d92304 Remove stray semicolons.
This patch removes various stray semicolons.

	* include/abg-diff-utils.h (display_edit_script): Remove
	redundant semicolon.
	* include/abg-fwd.h (lookup_basic_type): Ditto.
	* src/abg-comparison.cc (mark_diff_as_visited):
	Ditto.	(array_diff::has_local_changes): Ditto.
	(class_diff::ensure_lookup_tables_populated): Ditto.
	* src/abg-corpus.cc
	(corpus::priv::build_unreferenced_symbols_tables): Ditto.
	* src/abg-default-reporter.cc (default_reporter::report):
	Ditto.
	* src/abg-dwarf-reader.cc (finish_member_function_reading):
	Ditto.
	* src/abg-ir.cc (is_compatible_with_class_type): Ditto.
	(enum_type_decl::enumerator::set_name): Ditto.
	* src/abg-reader.cc (read_corpus_from_input): Ditto.
	(build_function_type): Ditto.
	* src/abg-suppression.cc (type_suppression::suppresses_type):
	Ditto.

Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-05-11 14:13:20 +02:00
Matthias Maennich
246ca20049 corpus/writer: sort emitted translation units by path name
By sorting the corpora output, we achieve determinism for the emitted
XML file across multiple runs of abidw.

For that to happen, change the collection of translation units to a
std::set (instead of std::vector), sorted by absolute path name.

Test data needed adjustments, but changes are fully compatible.

	* include/abg-fwd.h: remove translation_units fwd declaration.
	* include/abg-ir.h (struct shared_translation_unit_comparator):
	Define new class.
	(translation_units): Define new typedef.
	* src/abg-corpus.cc (corpus::add): do checked insert into the
	translation_units set (rather than vector::push_back)
	* tests/data/test-annotate/test13-pr18894.so.abi: Adjust test data.
	* 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/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.

Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-05-05 13:09:34 +02:00
Dodji Seketeli
f014f8c1f0 Fix compilation with g++ 4.8.5 on el7
G++ 4.8.5 doesn't allow a function template specialization to appear
in a namespace that is different from the namespace where the function
template was declared.  Also, in that namespace, the name of the
specialized function template must be non-fully-qualified.

Fixed thus.

	* include/abg-libxml-utils.h (build_sptr<xmlTextReader>): Wrap
	this specialization in the namespace sptr_utils and do away with
	the sptr_utils qualifier.
	* include/abg-regex.h (build_sptr<regex_t>): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-05-04 13:07:24 +02:00
Giuliano Procida
186cc9ed3a Simplify generation of symbol whitelist regex.
The code to build the symbol whitelist regex uses things like seekp
and tellp to generate regexes like "^foo$|^bar$".

This patch simplifies the code, for further enhancement, resulting in
generated regexes like "^(foo|bar)$".

There should be no change in behaviour, unless whitelisted symbol
names contain special regex characters.

	* include/abg-regex.h (generate_from_strings): Declare new
	function to build a regex from some strings, representing a
	membership test.
	* src/abg-regex.cc (generate_from_strings): Implement new
	function to build a regex from some strings, representing a
	membership test, in a straightfoward fashion.
	* src/abg-tools-utils.cc
	(gen_suppr_spec_from_kernel_abi_whitelists): Replace
	regex-building code with a call to generate_from_strings.
	* tests/test-kmi-whitelist.cc: Update regexes in test.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-05-04 11:17:49 +02:00
Giuliano Procida
0082ee529f Move libxml bits out of abg-sptr-utils.h.
The header file abg-sptr-utils.h contains generic things relating to
shared pointers. It also contains shared pointer typedefs (in the
sptr_utils namespace) and template specialisations for XML types.

The last of these more naturally belong in abg-libxml-utils.h (and in
the xml namespace). This patch moves them.

There are no behavioural changes.

	* include/abg-sptr-utils.h: Remove reader_sptr and
	xml_char_sptr typedefs, from namespace
	sptr_utils. (build_sptr): Remove corresponding template
	function specialisations for these types.
	* include/abg-libxml-utils.h: Add reader_sptr and
	xml_char_sptr typedefs, to namespace xml. (build_sptr): Add
	corresponding template function specialisations for these
	types.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-05-04 11:17:30 +02:00
Giuliano Procida
ae30e5fa96 Move regex definitions to own files.
As a prelude to adding wrapper and helper functions for regex
functionality, it makes sense to move the existing regex code (the
shared pointer type and its specialised deleter) to their own files.

This patch does this and also moves various entities into a new
namespace, abigail::regex. It removes the file abg-sptr-utils.cc which
only contained regex things.

There are no behavioural changes.

	* include/Makefile.am: Add abg-regex.h.
	* src/Makefile.am: Remove abg-sptr-utils.h, add abg-regex.cc
	* include/abg-sptr-utils.h (regex_t_sptr): Remove this
	typedef, from namespace abigail::sptr_utils.
	(regex_t_deleter): Remove this struct, from namespace
	abigail::sptr_utils. (build_sptr): Remove these template
	specialisations, in duplicate, for regex_t_sptr.
	* include/abg-regex.h: New file, introduces namespace
	abigail::regex. (regex_t_sptr): Add this typedef, to namespace
	abigail::regex. (regex_t_deleter): Add this struct, to
	namespace abigail::regex. (build_sptr): Add these template
	specialisations for regex_t_sptr
	* src/abg-sptr-utils.cc: Remove this file.
	* src/abg-regex.cc: Add new file with contents effectively
	the same as abg-sptr-utils.cc.
	* src/abg-corpus-priv.h: Update regex_t_sptr namespace
	qualification.
	* src/abg-corpus.cc: Ditto.
	* src/abg-suppression-priv.h: Ditto.
	* src/abg-suppression.cc: Ditto.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-05-04 11:15:23 +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
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
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
Giuliano Procida
ef90972a4a abidiff: Remove blank line after typedef changes.
This patch removes perhaps the last remaining cause of double blank
lines in output.

The state variable emit_nl was being set to true just after emitting a
new line which resulted in a blank line after every local typedef
change report.

	* include/abg-reporter.h
	(default_reporter::report_local_typedef_changes): Change
	return type to void.
	* src/abg-default-reporter.cc:
	(default_reporter::report_local_typedef_changes): Change
	return type to void, remove emit_nl state variable and logic.
	* tests/data/test-abidiff/test-PR18791-report0.txt: Remove
	blank lines.
	* tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt:
	Ditto.
	* tests/data/test-diff-suppr/test39-opaque-type-report-0.txt:
	Ditto.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-04-01 15:54:02 +02:00
Giuliano Procida
2d5389f265 Fix size calculations for multidimensional arrays.
The code in abg-ir.cc that calculated the memory size of an array
summed, rather than multiplied, the dimensions. It also did duplicate
work for each dimension after the first.

Existing code in abg-reader.cc asserted that array size information
read from XML match freshly calculated values.

This patch corrects the calculation, eliminates the duplicate work and
updates the XML reader validation to just emit a warning if old bad
array size information is found.

	* include/abg-ir.h (array_type_def::append_subrange): Remove
	this function.
	* src/abg-ir.cc (array_type_def::set_element_type): Add a note
	about safe usage.
	(array_type_def::append_subrange): Inline this function into
	its only caller append_subranges and remove it.
	(array_type_def::append_subranges): Do correct multiplicative
	calculation of multidimensional array sizes.
	* src/abg-reader.cc (build_array_type_def): When checking
	calculated against read array sizes, warn once if value
	matches old behaviour rather than raising an assertion.
	Otherwise, before raising an assertion, emit an informative
	error message.
	* tests/data/test-annotate/test14-pr18893.so.abi: Correct
	array sizes.
	* tests/data/test-annotate/test17-pr19027.so.abi: Ditto.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Ditto.
	* tests/data/test-annotate/test7.so.abi: Ditto.
	* tests/data/test-diff-dwarf/test10-report.txt: Ditto.
	* tests/data/test-diff-dwarf/test11-report.txt: Ditto.
	* tests/data/test-read-write/test25.xml: Ditto.

Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-31 19:48:35 +02:00
Giuliano Procida
9cf76b1175 abg-ir.cc: Improve types_have_similar_structure.
This function is used to determine whether or not type differences are
"local" and is primarily used in --leaf-changes-only mode. The logic
has some issues which are addressed by this patch:

    - Any number of points-to (*) and refers-to (& and &&) components
      are peeled off the types being compared, rather than checking
      these match in number and kind.
    - This peeling is done with peel_typedef_pointer_or_reference_type
      which also peels any number of CV qualifiers (OK) and
      array-of ([N]) type components (not OK).
    - The function sets a state variable (was_indirect_type) to modify
      the behaviour of downstream comparisons, but this cannot be
      passed through recursive calls.

The effect of the indirect_type flag is to switch to comparisons by
name: identically named structs don't get introspected. Arguably, a
more useful behaviour for --leaf-changes-only mode would be to treat
any change to a named type as non-local, except in the context of the
definition of that type itself. This would be a more significant
change in behaviour.

	* include/abg-fwd.h (types_have_similar_structure): In both
	overloads, add an indirect_type argument, defaulting to
	false.
	* src/abg-ir.cc (reference_type_def constructor): Tabify.
	(types_have_similar_structure): In both overloads, add an
	indirect_type argument and update documentation text. In the
	type_base_sptr overload, pass indirect_type in the tail
	call. In the type_base* overload, replace was_indirect_type
	with indirect_type; peel CV qualifiers and typedefs without
	testing as the peel function does this; replace the
	indiscriminate peeling of qualifier/pointer/reference/array
	type components with code that checks the same
	pointer/reference/array type component is used on each side
	and makes recursive calls with indirect_type set to true; pass
	the indirect_type argument recursively when comparing other
	subtypes; move the typeid check earlier, document its purpose
	and remove unneccessary checks after later dynamic casts;
	remove an always-true conditional; add a TODO for comparing
	array types more accurately.
	* tests/data/Makefile.am: Add new test case files.
	* tests/data/test-abidiff-exit/test-leaf-peeling-v0.cc: New
	test case.
	* tests/data/test-abidiff-exit/test-leaf-peeling-v1.cc: Ditto.
	* tests/data/test-abidiff-exit/test-leaf-peeling-report.txt:
	Ditto.
	* tests/test-abidiff-exit.cc: Run new test case.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-26 11:45:03 +01:00
Giuliano Procida
b0ce702088 Eliminate redundancy in representation of local change kinds.
* include/abg-ir.h (change_kind): Remove redundant
	LOCAL_CHANGE_KIND member, renumber members and update
        comments.
	* src/abg-comparison.cc (distinct_diff::has_local_changes):
	Remove redundant LOCAL_CHANGE_KIND.
	(var_diff::has_local_changes
	* src/abg-ir.cc (equals): In the type_base,
	qualified_type_def, pointer_type_def, reference_type_def,
	array_type_def::subrange_type, array_type_def, enum_type_decl,
	typedef_decl, var_decl, function_type, function_decl,
	function_decl::parameter, class_or_union,
	class_decl::base_spec, class_decl, decl_base and scope_decl
	overloads, remove redundant LOCAL_CHANGE_KIND.
	(enum_has_non_name_change): Remove redundant
	LOCAL_CHANGE_KIND.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-20 23:25:10 +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
Dodji Seketeli
6a0e7e120b abixml-reader: Support SONAME related properties on file suppression
When comparing binary files (using abidiff for instance) libabigail
can interpret the [suppress_file] section of a suppression
specification.  If the suppression specification matches either of the
compared files, no comparison is performed.

At the moment, that doesn't work when comparing abixml files.

Thus, this patch implements that feature for abixml files.

With this patch, one can now write a suppression specification like
this:

  [suppress_file]
    soname_regexp = <some-regexp>

or

  [suppress_file]
    file_name_regexp = <some-regexp>

If either abixml file has a soname matched by such a regexp, then no
comparison is performed.

	* doc/manuals/libabigail-concepts.rst: Update the documentation to
	mention soname_regexp and soname_not_regexp is supported in the
	[suppress_file] section.
	* include/abg-suppression.h (suppression_matches_soname)
	(suppression_matches_soname_or_filename): Declare new functions.
	Make them be friends of class suppression_base.
	* src/abg-reader.cc
	(read_context::corpus_is_suppressed_by_soname_or_filename): Define
	new member function.
	(read_corpus_from_input): Apply file suppression.
	* src/abg-suppression.cc (read_file_suppression): Support
	"soname_regexp" and "soname_not_regexp" in the [suppress_file]
	section.
	(suppression_matches_soname)
	(suppression_matches_soname_or_filename): Define new functions.
	* tests/data/test-diff-suppr/libtest48-soname-abixml-report-{1,2}.txt:
	New test reference output files.
	Likewise.
	* tests/data/test-diff-suppr/libtest48-soname-abixml-suppr.txt:
	New test suppression file.
	* tests/data/test-diff-suppr/libtest48-soname-abixml-suppr-{2,3,4}.txt::
	Likewise.
	* tests/data/test-diff-suppr/libtest48-soname-abixml-v{0,1}.so: New
	test binary input files.
	* tests/data/test-diff-suppr/libtest48-soname-abixml-v{0,1}.so.abi:
	New abixml for the binary input files above.
	* tests/data/test-diff-suppr/test48-soname-abixml-v{0,1}.c: Source
	code of the binary input files above.
	* tests/data/Makefile.am: Add the above test material to source
	distribution.
	* tests/test-diff-suppr.cc (in_out_specs): Add the test input
	above to this test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-02-21 16:01:26 +01:00
Dodji Seketeli
f5fd6931f6 suppression: Better handle soname/filename properties evaluation
At the moment, we don't make any difference between these two cases:

  1/ A suppression specification has no soname or file name related
  property.

  2/ A suppression specification has a soname or file name related
  property that doesn't match the soname or file name of a given
  corpus.

In both cases 1/ and 2/ libabigail currently assumes that the
suppression specification does not match the given corpus we are
looking at.  This can be wrong, especially if we are in the case 1/
and if the suppression does have other properties that should make it
match the corpus.

This patch fixes this issue.

	* include/abg-suppression.h
	(suppression_base::has_{soname,file_name}_related_property): Add
	new member functions.
	* src/abg-dwarf-reader.cc (read_context::suppression_can_match):
	Fix the logic to make a difference between the case where the
	suppression doesn't have any soname/filename property and the case
	where the suppression does have a soname/filename property that
	does not match the current binary.
	* src/abg-reader.cc (read_context::suppression_can_match):
	Likewise.
	* src/abg-suppression-priv.h
	(suppression_base::priv::matches_soname): If the suppression does
	not have any soname related property then it doesn't match the
	soname we are looking at.
	(suppression_base::priv::matches_binary_name): If the suppression
	does not have any filename related property then it doesn't match
	the filename we are looking at.
	* src/abg-suppression.cc
	(suppression_base::has_{soname,file_name}_related_property):
	Define new member functions.
	(sonames_of_binaries_match): If the suppression does not have any
	soname related property then it doesn't match the corpora of the
	diff we are looking at.
	(names_of_binaries_match): If the suppression does not have any
	filename related property then it doesn't match the corpora of the
	diff we are looking at.
	(type_suppression::suppresses_type): Fix the logic to make a
	difference between the case where the suppression doesn't have any
	soname/filename property and the case where the suppression does
	have a soname/filename property that does not match the current
	binary.
	(function_suppression::suppresses_{function, function_symbol}):
	Likewise.
	(variable_suppression::suppresses_{variable, variable_symbol}):
	Likewise.
	(file_suppression::suppresses_file): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-02-21 11:30:20 +01:00
Matthias Maennich
91a4274c9c abg-workers: Rework the worker queue to improve concurrent behaviour
This patch refactors the abigail::workers::queue and
abigail::workers::worker implementations to avoid holding locking
primitives longer than necessary.

In particular, the queue_cond_mutex was held during the entiry worker
runtime, effectively serializing the workers. Hence, use a mutex+cond
pair for each, the input and output queue and only synchronize around
the interaction with their corresponding queues. The
tasks_todo_(mutex|cond) are meant to synchronize scheduling and
distribution of work among workers, while tasks_done_(mutex|cond) are
used for synchronizing threads when putting back the tasks to the output
queue and to hold back threads waiting for the queue and workers to
drain.

Along that way, I did some cleanup that was now possible.
 - Move entire implementation of abigail::workers::task into header.
 - Make default_notify a static member.
 - Replace the multiple constructors with one with default arguments.

	* include/abg-workers.h (workers::task): move entire
	implementation to header and drop superfluous forward declaration.
	* src/abg-workers.cc (workers::task):: Likewise.
	(workers::queue::priv): Drop queue_cond_mutex, rename queue_cond
	to tasks_todo_cond, add task_done_cond, make default_notify
	static.
	(workers::queue::priv::priv): Add default arguments to fully
	qualified constructor, drop the remaining ones.
	(workers::queue:prive::more_tasks_to_execute): Drop method.
	(workers::queue:prive::schedule_task): Do not synchronize access
	to the queue condition variable, but only on the mutex.
	(do_bring_workers_down): Likewise. Also await tasks_done to be
	empty.
	(workers::queue:prive::worker::wait_to_execute_a_task): Await
	tasks on the tasks_todo with tasks_todo_(cond|mutex) and signal
	task completion to tasks_done_cond.

Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-02-19 13:23:18 +01:00
Matthias Maennich
48c8da31c0 abg-fwd: drop duplicate forward declaration for corpus_sptr
This declaration has already been done some lines above. Drop the
duplicate.

	* include/abg-fwd.h: drop superfluous forward declaration.

Signed-off-by: Matthias Maennich <maennich@google.com>
2020-01-27 07:39:54 +00:00
Matthias Maennich
fe214f0f70 Fix / add include guards
Fix the include guards of abg-dwarf-reader.h and abg-reporter-priv.h by
moving them before any other includes where they actually belongs.
Add missing include guards for abg-libxml-utils.h and abg-libzip-utils.h.

	* include/abg-dwarf-reader.h: Move include guard to the beginning.
	* include/abg-reporter-priv.h: Likewise.
	* include/abg-libxml-utils.h: Add include guard.
	* include/abg-libzip-utils.h: Likewise.

Signed-off-by: Matthias Maennich <maennich@google.com>
2020-01-27 07:39:51 +00:00
Matthias Maennich
9ab71105eb KMI Whitelists: Drop old whitelist extraction methods
The previous commit introduces a new (tested) way of creating function
and variable suppressions from multiple whitelist definitions. Migrate
to this new way of processing KMI whitelists.

	* include/abg-tools-utils.h
	(gen_suppr_spec_from_kernel_abi_whitelist): Delete declaration.
	* src/abg-tools-utils.cc
	(gen_suppr_spec_from_kernel_abi_whitelist): Delete definition
	and migrate users to gen_suppr_spec_from_kernel_abi_whitelists.
	* tools/abidiff.cc (set_suppressions): Migrate from using
	gen_suppr_spec_from_kernel_abi_whitelist to
	gen_suppr_spec_from_kernel_abi_whitelists.
	* tools/abidw.cc (set_suppressions): Likewise.
	* tools/abipkgdiff.cc: Drop unused using definition.
	* tools/kmidiff.cc: Likewise.

Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2020-01-21 18:38:00 +00:00
Matthias Maennich
4ecde9a800 KMI Whitelists: Add functionality to make whitelists additive
If multiple KMI whitelists are specified, either by passing
--kmi-whitelist several times or by having multiple whitelist sections
in the whitelist files, the generated suppressions are created as an
intersection of symbols. That is rather unusual, as whitelisting should
rather work additive. That means that the symbols (or expressions
thereof) defined across several sections or files shall be considered a
union of symbols. This patch combines the whitelist parsing to create
exactly one function_suppression and one variable suppression. A test
case has been added to ensure the functionality is working.

Please note, migrating the existing code to this new functionality is
done in a separate commit.

	* include/abg-tools-utils.h
	(gen_suppr_spec_from_kernel_abi_whitelists): New function.
	* src/abg-tools-utils.cc
	(gen_suppr_spec_from_kernel_abi_whitelists): Likewise.
	* tests/.gitignore: Ignore new test executable.
	* tests/Makefile.am: Add new test executable.
	* tests/data/test-kmi-whitelist/whitelist-with-another-single-entry:
	New test input file.
	* tests/data/test-kmi-whitelist/whitelist-with-duplicate-entry:
	Likewise.
	* tests/data/test-kmi-whitelist/whitelist-with-single-entry:
	Likewise.
	* tests/data/test-kmi-whitelist/whitelist-with-two-sections:
	Likewise.
	* tests/data/Makefile.am: Add above test material.
	* tests/test-kmi-whitelist.cc: Add new test executable.

Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2020-01-21 18:37:43 +00:00
Matthias Maennich
ade58f9c49 Add (undocumented) support for version suffixes
Allow appending arbitrary text to the libabigail version string
representation. That is useful to identify custom versions of the
library (e.g. development versions or versions of a particular origin).

The feature can be enabled by passing VERSION_SUFFIX to `configure`,
e.g.

  $ configure VERSION_SUFFIX="-dev"

That will extend the version string to (currently) 1.7.0-dev.
The behaviour before this patch remains the default behaviour of not
appending any additional text.

The feature stays intentionally undocumented as the main release of
libabigail will usually not carry a version suffix.

	* configure.ac: add substitution for VERSION_SUFFIX
	* include/abg-version.h.in: add define for ABIGAIL_VERSION_SUFFIX
	* include/abg-config.h(abigail_get_library_version): add support
	for a version suffix
	* src/abg-config.cc(abigail_get_library_version): Likewise.
	* src/abg-tools-utils.cc(get_library_version_string): Likewise.

Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2020-01-09 17:06:31 +00:00
Dodji Seketeli
c32b8ec9f3 Bug 24690 - Support comparing non-reachable types of a binary
This patch adds the ability to compare all types of a binary,
including those types that are not reachable from global functions and
variables.

This implies that for types that are not reachable from public
interfaces, we want compare them against each others directly, without
first comparing global functions/variables and walking the graph of
reachable types from there.

The patch adds the --non-reachable-types option to abidiff and
abipkgdiff, instructing them to also compare types that are
non-reachable from global variables and functions.

Using that option, for instance, here is what the summary of
abipkgdiff now looks like, in the test case attached added by this
patch:

================ changes of 'libflatpak.so.0.10204.0'===============
  Functions changes summary: 0 Removed, 0 Changed (16 filtered out), 16 Added functions
  Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
  Unreachable types summary: 3 removed (2 filtered out), 1 changed (15 filtered out), 3 added (1 filtered out) types

You can see that there is a new summary line which starts with the
string: "Unreachable types summary:"

Then in the body of the report, those unreachable types are reported
separately.

In practise, we want to limit the unreachable types to compare
somehow, otherwise we'll end up comparing all the types of the types
of the binary and that can be huge.  So we want to limit the
unreachable type analysis to types that are defined in public headers.

So, for abipkgdiff, one can limit the analysis of non-reachable types
to those defined in public headers by supplying the --devel{1,2}
options that specifies the development packages that contain said
public headers.  For abidiff however, you'll want to use the
--headers-dir{1,2} options for that.

The patch comes with appropriate regression tests.

	* include/abg-comparison.h (string_type_base_sptr_map): Define new
	typedef.
	(diff_context::show_unreachable_types): Declare new member
	functions.
	(corpus_diff::{deleted_unreachable_types,
	deleted_unreachable_types_sorted, added_unreachable_types,
	added_unreachable_types_sorted, changed_unreachable_types,
	changed_unreachable_types_sorted}): Likewise.
	(maybe_report_unreachable_type_changes): Declare this function a
	friend of class corpus_diff.
	(corpus_diff::diff_stats::{num_added_unreachable_types,
	num_added_unreachable_types_filtered_out,
	net_num_added_unreachable_types, num_removed_unreachable_types,
	num_removed_unreachable_types_filtered_out,
	net_num_removed_unreachable_types, num_changed_unreachable_types,
	num_changed_unreachable_types_filtered_out,
	net_num_changed_unreachable_types}): Likewise.
	* src/abg-comparison-priv.h
	(diff_context::priv::show_unreachable_types_): Define new data
	member.
	(diff_context::priv::priv): Initialize the new data member.
	(diff_comp::operator()): Use pretty representation of diff
	subjects to sort them, rather than just their name.  Also, add
	comment to the other member functions of diff_comp.
	(corpus_diff::{unreachable_types_edit_script_,
	deleted_unreachable_types_, deleted_unreachable_types_sorted_,
	suppressed_deleted_unreachable_types_, added_unreachable_types_,
	added_unreachable_types_sorted_,
	suppressed_added_unreachable_types_, changed_unreachable_types_,
	changed_unreachable_types_sorted_}): Define new data members.
	(corpus_diff::priv::apply_supprs_to_added_removed_fns_vars_unreachable_types):
	Changed the name of
	corpus_diff::priv::apply_suppressions_to_added_removed_fns_vars into
	this.
	(corpus_diff::priv::{added_unreachable_type_is_suppressed,
	deleted_unreachable_type_is_suppressed,
	changed_unreachable_types_sorted, count_unreachable_types}):
	Declare new member functions.
	(corpus_diff::diff_stats::priv::{num_added_unreachable_types,
	num_added_unreachable_types_filtered_out,
	num_removed_unreachable_types,
	num_removed_unreachable_types_filtered_out,
	num_changed_unreachable_types,
	num_changed_unreachable_types_filtered_out}): Define new data
	members.
	(sort_string_type_base_sptr_map): Declare new function.
	* src/abg-comparison.cc (sort_string_type_base_sptr_map)
	(diff_context::show_unreachable_types): Define new functions.
	(corpus_diff::diff_stats::{num_added_unreachable_types,
	num_added_unreachable_types_filtered_out,
	net_num_added_unreachable_types,
	net_num_removed_unreachable_types,
	num_removed_unreachable_types_filtered_out,
	num_removed_unreachable_types}): Define new member functions.
	(diff_maps::insert_diff_node): Do not update the map "diff ->
	impacted interfaces" if the current impacted interface is nil.
	This happens if we are looking at a diff node for a change on a
	type that is not reachable from any interfaces.
	(corpus_diff::priv::ensure_lookup_tables_populated): Handle the
	edit script for unreachable types.
	(corpus_diff::priv::apply_supprs_to_added_removed_fns_vars_unreachable_types):
	Rename
	corpus_diff::priv::apply_suppressions_to_added_removed_fns_vars
	into this.  Apply suppression specifications to added and removed
	unreachable types as well.
	(corpus_diff::priv::{added,deleted}_unreachable_type_is_suppressed):
	Define new member functions.
	(corpus_diff::priv::{count_unreachable_types,
	changed_unreachable_types_sorted}): Likewise.
	(corpus_diff::priv::apply_filters_and_compute_diff_stats): Update
	statistics (including walking changed unreachable types to apply
	categorization and redundancy filters to them) related to
	unreachable types.
	(corpus_diff::priv::emit_diff_stats): Emit diff stats related to
	unreachable types.
	(corpus_diff::priv::maybe_dump_diff_tree): Dump diff tree nodes
	related to unreachable types.
	(corpus_diff::{deleted_unreachable_types,
	deleted_unreachable_types_sorted, added_unreachable_types,
	added_unreachable_types_sorted, changed_unreachable_types,
	changed_unreachable_types_sorted): Define new member functions.
	(corpus_diff::has_changes): Take deleted/added/changed unreachable
	types into account.
	(corpus_diff::has_incompatible_changes): Take net removed/changed
	unreachable types into account.
	(corpus_diff::has_net_subtype_changes): Take net removed and
	changed unreachable types into account.
	(corpus_diff::has_net_changes): Take net removed/added/changed
	unreachable types into account.
	(corpus_diff::traverse): When traversing the components of a
	corpus_diff node, make sure to traverse the changed unreachable
	types of the corpus.
	(leaf_diff_node_marker_visitor::visit_begin): Arrange for the fact
	that the current topmost interface can be nil if we are looking at
	types not reachable from global functions/variables.  Also, make
	sure that only leaf nodes that are reachable from a global
	function/variable are recorded as leaf nodes.
	(compute_diff): In the overload for corpus_sptr, compute the
	changes between types not reachable from global functions and
	variables, if the user wishes that we do so.  Also, add more
	comments.
	(apply_suppressions): Update for the name change of the function
	apply_suppressions_to_added_removed_fns_vars to
	apply_supprs_to_added_removed_fns_vars_unreachable_types.
	* include/abg-corpus.h
	(corpus::{record_type_as_reachable_from_public_interfaces,
	type_is_reachable_from_public_interfaces,
	get_types_not_reachable_from_public_interfaces}): Declare new
	member functions.
	(corpus::recording_types_reachable_from_public_interface_supported):
	Declare new virtual member function.
	(corpus_group::get_public_types_pretty_representations): Declare
	new member functons.
	(corpus_group::recording_types_reachable_from_public_interface_supported):
	Declare new virtual member function.
	* src/abg-corpus-priv.h
	(corpus::priv::{types_not_reachable_from_pub_ifaces_,
	pub_type_pretty_reprs_}): Define new data members.
	(corpus::priv::priv): Initialize the pub_type_pretty_reprs_ data
	member because it's a pointer.
	(corpus::priv::get_public_types_pretty_representations): Declare
	new member function.
	(corpus::priv::~priv): Declare a destructor.
	* src/abg-corpus.cc
	(corpus::priv::get_public_types_pretty_representations): Define
	new member function.
	(corpus::priv::~priv): Define new destructor to delete the new
	pub_type_pretty_reprs_ member pointer.
	(corpus::{record_type_as_reachable_from_public_interfaces,
	type_is_reachable_from_public_interfaces,
	get_types_not_reachable_from_public_interfaces,
	recording_types_reachable_from_public_interface_supported}):
	Define new member functions
	(corpus_group::get_public_types_pretty_representations): Likewise.
	* include/abg-diff-utils.h (struct deep_ptr_eq_functor): Document
	the equality operator.  Also, add an overload to the equality
	operator, for weak_ptr<T>.  The existing equality operator
	overload was just for shared_ptr<T>.
	* include/abg-fwd.h (is_user_defined_type): Declare function.
	* include/abg-ir.h (operator!=(const decl_base_sptr&, const
	decl_base_sptr&)): Declare new operator.
	(type_maps::get_types_sorted_by_name): Declare
	new member function.
	(decl_base::{g,s}et_is_artificial): Declare new member function.
	(function_decl::parameter::{g,s}et_artificial): Remove these
	member functions.
	* src/abg-ir.cc (operator!=(const decl_base_sptr&, const
	decl_base_sptr&)): Define new operator.
	(decl_base::priv::is_artificial_): Define new data
	member.
	(type_maps::priv::sorted_types_): Define new data member.
	(struct type_name_comp): Define new comparison functor to sort
	types based on their pretty representations.
	(decl_base::priv::priv): Initialize it.
	(decl_base::{g,s}et_is_artificial): Define new member functions.
	(type_maps::get_types_sorted_by_name): Define new member function.
	(is_user_defined_type): Define new function overloads.
	(strip_typedef, function_type::{function_type, set_parameters}):
	Adjust using decl_base::get_is_artificial rather than
	function_decl::parameter::get_artificial.
	(function_decl::parameter::priv::artificial_): Remove this data
	member.
	(function_decl::parameter::priv::priv): Adjust to the removal of
	function_decl::parameter::priv::artificial_.  This constructor
	does not take an "is_artificial" flag anymore.
	(function_decl::parameter::parameter): Adjust to the removal of
	the is_artificial flag from the arguments of the constructor of
	function_decl::parameter::parameter::priv.
	(function_decl::parameter::get_artificial): Remove this member
	function.
	* src/abg-reporter-priv.h (maybe_report_unreachable_type_changes):
	Declare new function.
	* src/abg-reporter-priv.cc
	(maybe_report_unreachable_type_changes): Define new function.
	* src/abg-default-reporter.cc (default_reporter::report): In the
	overload for corpus_diff&, report added/removed/changed types that
	are not reachable from global functions and variables using the
	new function maybe_report_unreachable_type_changes.
	* src/abg-leaf-reporter.cc (leaf_reporter::report): In the
	overload for corpus_diff, report changes to types unreachable from
	global functions or variables, using the new function
	maybe_report_unreachable_type_changes.
	* src/abg-dwarf-reader.cc (build_ir_node_from_die): When the user
	requests that all types be loaded, record relevant types as
	reachable from global functions and variables.
	(build_enum_type, add_or_update_class_type)
	(add_or_update_union_type): Read the 'is-artificial' DWARF
	attribute and set the corresponding decl_base property
	accordingly.
	(finish_member_function_reading, strip_typedef)
	(function_type::function_type): Adjust using
	decl_base::get_is_artificial, rather than
	function_decl::parameter::get_artificial.
	* include/abg-reader.h
	(consider_types_not_reachable_from_public_interfaces): Declare new
	function.
	* src/abg-reader.cc
	(read_context::m_tracking_non_reachable_types): Add new data
	member.
	(read_context::read_context): Initialize it.
	(read_context::tracking_non_reachable_types): Define accessors for
	the new data member above.
	(read_is_declaration_only): Re-indent.
	(read_is_artificial): Define new helper function.
	(build_function_parameter): Use the new read_is_artificial
	function here, rather than open-coding it.
	(build_enum_type_decl, build_class_decl, build_union_decl):
	Support reading the 'is-artificial' property by using the new
	read_is_artificial function.
	(read_corpus_from_input): If the user wants us to take
	non-reachable types into account, then make sure we do so.
	(read_tracking_non_reachable_types, read_is_non_reachable_type):
	Define new static functions.
	(handle_element_node, build_type): Read the "is-non-reachable"
	attribute on type element nodes if the user wants us to track
	non-reachable types.
	(consider_types_not_reachable_from_public_interfaces): Define new
	function.
	* src/abg-writer.cc (write_is_artificial): Define new static
	helper function.
	(annotate): Adjust using decl_base::get_is_artificial rather than
	function_decl::parameter::get_artificial.
	(write_enum_type_decl, write_class_decl_opening_tag)
	(write_union_decl_opening_tag): Support writing the
	"is-artificial" property, using the new write_is_artificial
	function.
	(write_function_type): Adjust this to use the new
	write_is_artificial rather than open-coding writing the
	'is-artificial' attribute.
	(write_is_non_reachable)
	(write_tracking_non_reachable_types): Define new static functions.
	(write_enum_type_decl, write_class_decl_opening_tag)
	(write_union_decl_opening_tag): Write the 'is-no-reachable'
	attribute when applicable.
	(write_corpus, write_corpus_group): Write the
	'tracking-non-reachable-types' attribute when applicable.
	* tools/abidiff.cc (options::options): Initialize ...
	(options::show_all_types): ... new data member.
	(display_usage): Add help string from the new
	--non-reachable-types option.
	(parse_command_line): Parse the new --non-reachable-types option.
	(set_diff_context_from_opts): Set the
	dwarf_reader::read_context::show_unreachable_types property.
	(set_native_xml_reader_options): Define new
	static function.
	(main): Load all types when analyzing the DWARF or the ABIXML
	files, if the user wants us to do so.
	* tools/abipkgdiff.cc (options::show_all_types): Define new data
	member.
	(options::options): Initialize it.
	(parse_command_line): Parse the --non-reachable-types option to
	set the options::show_all_types data member.
	(display_usage): Add a help string for the new
	--non-reachable-types option.
	(set_diff_context_from_opts): Set the
	dwarf_reader::read_context::show_unreachable_types property based
	on the options::show_all_type data member.
	(compare): Configure the read context to load all types while
	analyzing the DWARF info, depending on the options::show_all_type
	data member.
	* doc/manuals/abidiff.rst: Document the new --non-reachable-types
	option added to abidiff above.
	* doc/manuals/abipkgdiff.rst: Add documentation for the
	--non-reachable-types option.
	* tests/data/test-diff-suppr/test47-non-reachable-types-v{0,1}.c:
	Source code files of test binary input.
	* tests/data/test-diff-suppr/test47-non-reachable-types-suppr-{1,2,3,4,5}.txt:
	New test input files.
	* tests/data/test-diff-suppr/test47-non-reachable-types-report-{1,2,3,4,5,6,7,8,9,10}.txt:
	New test reference output files.
	* tests/data/test-diff-suppr/test47-non-reachable-types-v{0,1}.o.alltypes.abixml:
	New test input abixml.
	* tests/data/Makefile.am: Add the new test material to source
	distribution.
	* tests/test-diff-suppr.cc (in_out_specs): Add the new tests above
	to this test harness.
	* tests/data/test-abidiff/test-struct1-report.txt: Adjust.
	* tests/data/test-diff-pkg/PR24690/flatpak-debuginfo-1.2.4-3.fc30.x86_64.rpm:
	New input binary RPM.
	* tests/data/test-diff-pkg/PR24690/flatpak-debuginfo-1.4.0-1.fc30.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/PR24690/flatpak-devel-1.2.4-3.fc30.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/PR24690/flatpak-devel-1.4.0-1.fc30.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/PR24690/flatpak-libs-1.2.4-3.fc30.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/PR24690/flatpak-libs-1.4.0-1.fc30.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/PR24690/flatpak-libs-debuginfo-1.2.4-3.fc30.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/PR24690/flatpak-libs-debuginfo-1.4.0-1.fc30.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/PR24690/PR24690-report-0.txt: New test
	reference output.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Add the new test material
	above to this test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-01-06 14:26:00 +01:00
Dodji Seketeli
847800d497 Bug 25128 - Handle decl-only classes that differ only in size
Because DWARF sometimes emit decl-only classes (real one, with no
members) with a size property, and the rest of the time, would emit
the same decl-only class without a size property, comparing the two
might yield some false positives.

This patch handles those beasts when comparing classes.

	* include/abg-comp-filter.h (is_decl_only_class_with_size_change):
	Declare an overload.
	* include/abg-fwd.h (look_through_decl_only_class): Declare an
	overload.
	* src/abg-comp-filter.cc (is_decl_only_class_with_size_change):
	Define an overload that takes class_or_union& type. Re-write the
	previous overload in terms of this new one.
	* src/abg-ir.cc (look_through_decl_only_class): Define a new
	overload that takes a class_or_union&.  Rewrite the previous
	overload in terms of this one.
	(equals): In the overload for class_or_union&, use
	is_decl_only_class_with_size_change to detect cases of decl-only
	classes that differ only by their size attribute and avoid
	comparing them.
	* tests/data/test-annotate/test21-pr19092.so.abi: Adjust.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
	* tests/data/test-diff-filter/test41-report-0.txt: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-11-08 11:09:13 +01:00
Dodji Seketeli
1f4dbe3515 Bug 25128 - Leaf diff reporter shouldn't compare decl-only classes
The leaf_diff_node_marker_visitor pass which collects leaf diff nodes
for the leaf diff reporter considers bogus decl-only classes (that have the
is-declaration-only flag set, are empty, and yet have a non-nil size
property) originated from bogus DWARF.

The leaf reporter thus potentially reports size changes among
decl-only classes, which does not make sense.  Two decl-only classes
of the same name should always be considered equal, in this context.

This patch thus teaches the leaf_diff_node_marker_visitor to avoid
collecting a leaf diff node that is about a size change on a true
decl-only class.

	* include/abg-comp-filter.h (is_decl_only_class_with_size_change):
	Declare new function.
	* src/abg-comp-filter.cc (is_decl_only_class_with_size_change):
	Define new function.
	* src/abg-comparison.cc
	(leaf_diff_node_marker_visitor::visit_begin): Use the newly
	defined is_decl_only_class_with_size_change above to ignore bogus
	decl-only classes with a size change.
	* tests/data/test-diff-suppr/test45-abi-report-1.txt: New test input.
	* tests/data/test-diff-suppr/test45-abi-wl.xml: Likewise.
	* tests/data/test-diff-suppr/test45-abi.xml: Likewise.
	* tests/data/test-diff-suppr/test45-abi.suppr.txt: New reference
	output for the test input above.
	* tests/data/test-diff-suppr/test46-PR25128-base.xml: New test input.
	* tests/data/test-diff-suppr/test46-PR25128-new.xml: Likewise.
	* tests/data/test-diff-suppr/test46-PR25128-report-1.txt: New
	reference input for the test input above.
	* tests/data/Makefile.am: Add the new test material to source distribution.
	* tests/test-diff-suppr.cc (in_out_spec): Add the new test input
	above to this test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-11-08 11:08:38 +01:00
Dodji Seketeli
b00976517f Support symbol_name_not_regexp in [suppress_{function, variable}]
In the suppress_function and suppress_variable directives of the
suppression specification language, we lack the
'symbol_name_not_regexp' properties, that would allow users to specify
which (function/variable) symbols to *keep* as opposed to specifying
which symbols to suppress.

This patch adds that feature.  That will later allow us to make the
linux kernel symbol white lists[1] functionality use this feature;
that is, upon analysing the content of a kernel symbol whitelist which
lists a symbol named "foo", Libabigail would automatically generate a
suppression specification which contains, e.g a 'suppress_function"
directive that has this new 'symbol_name_not_regexp' property which
value is set to "foo".

Note that the patch makes sure that feature is supported when
analyzing both abixml and DWARF formats.

[1]: You can learn about what a Linux Kernel symbols white list is by
reading about it at
https://sourceware.org/libabigail/manual/kmidiff.html#environment.

	* doc/manuals/libabigail-concepts.rst: Document the new
	symbol_name_not_regexp properties for the
	suppress_{function,variable} directives.
	* include/abg-suppression.h
	({function,variable}_suppression::{g,s}et_symbol_name_not_regex_str):
	Declare new member functions.
	* src/abg-dwarf-reader.cc
	(read_context::is_elf_symbol_suppressed): Define new member functions.
	(read_context::{load_symbol_maps_from_symtab_section,
	populate_symbol_map_from_ksymtab,
	populate_symbol_map_from_ksymtab_reloc}): Drop suppressed symbols
	when reading symbol tables.
	({function,variable}_is_suppressed): Consider that in C, the
	linkage name is _by default_ the same as the function/variable
	name. Remove local variable.
	* include/abg-ir.h (elf_symbol_is_{function,variable}): Add ...
	* src/abg-ir.cc (elf_symbol_is_{function,variable}): ... new
	functions.
	* src/abg-reader.cc (build_elf_symbol): Take an additional boolean
	to detect and drop suppressed symbols.
	(build_elf_symbol_db): Adjust the call to build_elf_symbol to make
	it detect and drop suppressed symbols.
	(read_corpus_from_input): Be mindful that the set of symbols for a
	given corpus can be empty because of suppression specifications.
	* src/abg-suppression-priv.h
	({function,variable}_suppression::priv::symbol_name_not_regex[_str_]):
	Add new data members.
	(function,variable}_suppression::priv::get_symbol_name_not_regex):
	Add new member functions.
	({function,variable}_is_suppressed): Guard against empty name.
	(is_elf_symbol_suppressed): Define new function template.
	* src/abg-suppression.cc
	({function,variable}_suppression::{g,s}et_symbol_name_not_regex_str):
	Define new member functions.
	({function,variable}_suppression::suppresses_function)
	(suppression_matches_{function,variable}_sym_name)
	(read_{function,variable}_suppression): Support the new
	"symbol_name_not_regex" property.
	* tests/data/test-diff-suppr/test44-suppr-sym-name-not-regexp-report-1.txt:
	New test reference report.
	* tests/data/test-diff-suppr/test44-suppr-sym-name-not-regexp-report-2.txt:
	Likewise.
	* tests/data/test-diff-suppr/test44-suppr-sym-name-not-regexp-v{0,1}.c:
	Sources of the new test input.
	* tests/data/test-diff-suppr/test44-suppr-sym-name-not-regexp-v{0,1}.o:
	New test input binaries.
	* tests/data/test-diff-suppr/test44-suppr-sym-name-not-regexp-v{0,1}.o.abi:
	New test input abixml files.
	* tests/data/test-diff-suppr/test44-suppr-sym-name-not-regexp.suppr.txt:
	Next test suppression specification.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-diff-suppr.cc (in_out_specs): Add the input tests
	above to the test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-11-08 11:01:54 +01:00