Commit Graph

52 Commits

Author SHA1 Message Date
Dodji Seketeli
522cc62b9b abidw: Add --abixml-version
Add a command line option to display the version number of the ABIXML
output format.

	* doc/manuals/abidw.rst: Document the --abixml-version command
	line option.
	* configure.ac (ABIXML_VERSION_MAJOR, ABIXML_VERSION_MINOR):
	Define these two new autoconf variables.
	* include/abg-config.h (abigail_get_abixml_version): Declare new
	function.
	* include/abg-tools-utils.h (get_abixml_version_string): Declare
	new function.
	* include/abg-version.h.in (ABIGAIL_ABIXML_VERSION_MAJOR)
	(ABIGAIL_ABIXML_VERSION_MINOR): Define new preprocessor macros.
	* src/abg-config.cc (config::config): Initialize
	config::m_format_{minor,major} using the newly defined
	preprocessor macros ABIGAIL_ABIXML_VERSION_M{IN,AJ}OR.
	* src/abg-tools-utils.cc (get_abixml_version_string): Define new
	function.
	* tools/abidw.cc (options::display_abixml_version): Define new
	data member.
	(options::options): Initialize it.
	(display_usage): Emit a help string for the new --abixml-version
	option.
	(parse_command_line): Parse the --abixml-version string.
	(main): Emit the abixml version when asked.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-11-12 18:31:28 +01:00
Matthias Maennich
86c06ad684 Consistently use std::unique_ptr for private implementations (pimpl)
In the absence of non-refcounting smart pointers before C++11,
std::shared_ptr was commonly used instead. Having bumped the standard to
C++11, allows us to use std::unique_ptr consistently avoiding any costs
involved with shared_ptr ref counting. Hence do that and add default
virtual destructors where required.

	* include/abg-comparison.h (diff_maps): use unique_ptr for priv_
	(diff_context): Likewise.
	(diff_traversable_base): Likewise.
	(type_diff_base): Likewise.
	(decl_diff_base): Likewise.
	(distinct_diff): Likewise.
	(var_diff): Likewise.
	(pointer_diff): Likewise.
	(reference_diff): Likewise.
	(array_diff): Likewise.
	(qualified_type_diff): Likewise.
	(enum_diff): Likewise.
	(class_or_union_diff): Likewise.
	(class_diff): Likewise.
	(base_diff): Likewise.
	(scope_diff): Likewise.
	(fn_parm_diff): Likewise.
	(function_type_diff): Likewise.
	(function_decl_diff): Likewise.
	(typedef_diff): Likewise.
	(translation_unit_diff): Likewise.
	(diff_stats): Likewise.
	(diff_node_visitor): Likewise.
	* include/abg-corpus.h (corpus): Likewise.
	(exported_decls_builder): Likewise.
	(corpus_group): Likewise.
	* include/abg-ini.h (property): Likewise.
	(property_value): Likewise.
	(string_property_value): Likewise.
	(list_property_value): Likewise.
	(tuple_property_value): Likewise.
	(simple_property): Likewise.
	(list_property): Likewise.
	(tuple_property): Likewise.
	(config): Likewise.
	(section): Likewise.
	(function_call_expr): Likewise.
	* include/abg-interned-str.h (interned_string_pool): Likewise.
	* include/abg-ir.h (environment): Likewise.
	(location_manager): Likewise.
	(type_maps): Likewise.
	(translation_unit): Likewise.
	(elf_symbol::version): Likewise.
	(type_or_decl_base): Likewise.
	(scope_decl): Likewise.
	(qualified_type_def): Likewise.
	(pointer_type_def): Likewise.
	(array_type_def): Likewise.
	(subrange_type): Likewise.
	(enum_type_decl): Likewise.
	(enum_type_decl::enumerator): Likewise.
	(typedef_decl): Likewise.
	(dm_context_rel): Likewise.
	(var_decl): Likewise.
	(function_decl::parameter): Likewise.
	(function_type): Likewise.
	(method_type): Likewise.
	(template_decl): Likewise.
	(template_parameter): Likewise.
	(type_tparameter): Likewise.
	(non_type_tparameter): Likewise.
	(template_tparameter): Likewise.
	(type_composition): Likewise.
	(function_tdecl): Likewise.
	(class_tdecl): Likewise.
	(class_decl::base_spec): Likewise.
	(ir_node_visitor): Likewise.
	* include/abg-suppression.h (suppression_base): Likewise.
	(type_suppression::insertion_range): Likewise.
	(type_suppression::insertion_range::boundary): Likewise.
	(type_suppression::insertion_range::integer_boundary): Likewise.
	(type_suppression::insertion_range::fn_call_expr_boundary): Likewise.
	(function_suppression): Likewise.
	(function_suppression::parameter_spec): Likewise.
	(file_suppression): Likewise.
	* include/abg-tools-utils.h (temp_file): Likewise.
	(timer): Likewise.
	* include/abg-traverse.h (traversable_base): Likewise.
	* include/abg-workers.h (queue): Likewise.
	* src/abg-comparison.cc (diff_context): add default destructor.
	(diff_maps): Likewise.
	(corpus_diff): Likewise.
	(diff_node_visitor): Likewise.
	(class_or_union_diff::get_priv): adjust return type.
	(class_diff::get_priv): adjust return type.
	* src/abg-corpus.cc (corpus): add default destructor.
	* src/abg-ir.cc (location_manager): Likewise.
	(type_maps): Likewise.
	(elf_symbol::version): Likewise.
	(array_type_def::subrange_type): Likewise.
	(enum_type_decl::enumerator): Likewise.
	(function_decl::parameter): Likewise.
	(class_decl::base_spec): Likewise.
	(ir_node_visitor): Likewise.

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

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

Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-03-19 10:52:57 +01:00
Matthias Maennich
c458e00db9 Drop unneccessary includes of abg-cxx-compat.h
Remove the unneccessary includes of abg-cxx-compat.h as users have been
migrated to use the corresponding standard includes.

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

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

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

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

This is what this patch does.

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

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

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

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

Signed-off-by: Benjamin De Kosnik <bkoz@gnu.org>
Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Matthias Klose <doko@ubuntu.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Roland McGrath <roland@hack.frob.com>
Signed-off-by: Sinny Kumari <ksinny@gmail.com>
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
2020-12-02 11:44:13 +01:00
Dodji Seketeli
247f50dbf3 abg-tools-utils: Fix comment
* include/abg-tools-utils.h (enum abidiff_status): Fix a comment.

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

It thus becomes possible to invoke abidiff like this:

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

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

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

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-09-18 10:27:18 +02:00
Mark Wielaard
9fe85b370c Add --header-file option to add individual public header files.
Sometimes public header files are in the same directory as private
header files. In such cases --headers-dir cannot be used. Add
--header-file to add individual public header files.

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

Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-04-14 17:17:28 +02:00
Dodji Seketeli
1d6731c438 Update copyright year to 2020
We are in February 2020 so this is long overdue.

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-02-21 17:05:01 +01:00
Matthias Maennich
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
Dodji Seketeli
3df54522b8 Add timing to the verbose logs of abidw
While doing my recent optimization work, it became useful to have an
idea of the time different parts of the processing pipeline are
taking.

This patch introduces an abigail::tools_utils::timer type that is easy
to use to time a given part of the code and emit the elapsed time to
an output stream.

This abigail::tools_utils::timer type is thus used to time various
parts of the processing pipeline involved in abidw.  Just using the
existing --verbose option now yields timing information.

	* include/abg-tools-utils.h (class timer): Declare new type.
	(operator<<(ostream&, const timer&)): Declare new streaming
	operator for the new timer type.
	* src/abg-tools-utils.cc (struct timer::priv): Define new type.
	(timer::{timer, start, stop, value_in_seconds, value,
	value_as_string, ~timer}): Define member functions.
	(operator<<(ostream& o, const timer& t)): Define streaming
	operator.
	(build_corpus_group_from_kernel_dist_under): Add timing logs to
	the linux kernel reading process.
	* src/abg-dwarf-reader.cc
	(read_context::canonicalize_types_scheduled): Add timing logs to
	type canonicalization.
	(read_debug_info_into_corpus): Add timing logs for the whole debug
	info loading and internal representation building process.
	* tools/abidw.cc (load_corpus_and_write_abixml): Add timing logs
	for the binary loading and serizalization process.
	(load_kernel_corpus_group_and_write_abixml): Add timing logs the
	Linux Kernel binary loading and writing process.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-07-19 10:46:42 +02:00
Matthias Maennich
85f185a684 abg-tools-utils: add missing header include guards
* include/abg-tools-utils.h: add header include guards

Signed-off-by: Matthias Maennich <maennich@google.com>
2019-07-09 18:45:55 +02:00
Matthias Maennich
beededda29 Add compatibility layer for C++11 mode
Introduce a compatibility layer for C++11 code by adding
include/abg-cxx-compat.h. abg-cxx-compat defines a new namespace
abg_compat and defines
	abg_compat::hash
	abg_compat::shared_ptr
	abg_compat::weak_ptr
	abg_compat::dynamic_pointer_cast
	abg_compat::static_pointer_cast
	abg_compat::unordered_map
	abg_compat::unordered_set
based on definitions from std::tr1 (std=gnu++98) or std:: (std=gnu++11).

I decided for introducing abg_compat:: rather than polluting abigail::
to allow an easier transition to C++11 at a later time and to not subtly
break existing code.

As the shared_ptr in C++11 defines shared_ptr::operator bool() explicit,
some locations where a shared_ptr is assigned to boolean, needed to be
adjusted to explicitly cast to bool.

	* include/abg-cxx-compat.h: new file introducing the abg_compat
	  namespace to provide C++11 functionality from either std::tr1
	  or std::
	* include/Makefile.am: Add the new abg-cxx-compat.h to source
	  distribution.
	* include/abg-comparison.h: replace std::tr1 usage by abg_compat
	  and adjust includes accordingly: likewise
	* include/abg-diff-utils.h: likewise
	* include/abg-fwd.h: likewise
	* include/abg-ini.h: likewise
	* include/abg-interned-str.h: likewise
	* include/abg-ir.h: likewise
	* include/abg-libxml-utils.h: likewise
	* include/abg-libzip-utils.h: likewise
	* include/abg-reporter.h: likewise
	* include/abg-sptr-utils.h: likewise
	* include/abg-suppression.h: likewise
	* include/abg-tools-utils.h: likewise
	* include/abg-workers.h: likewise
	* src/abg-comp-filter.cc: likewise
	* src/abg-comparison-priv.h: likewise
	* src/abg-corpus.cc: likewise
	* src/abg-dwarf-reader.cc: likewise
	* src/abg-hash.cc: likewise
	* src/abg-ir.cc: likewise
	* src/abg-reader.cc: likewise
	* src/abg-suppression.cc: likewise
	* src/abg-tools-utils.cc: likewise
	* src/abg-writer.cc: likewise
	* tests/test-diff-filter.cc: likewise
	* tests/test-diff-pkg.cc: likewise
	* tests/test-read-dwarf.cc: likewise
	* tests/test-read-write.cc: likewise
	* tests/test-types-stability.cc: likewise
	* tests/test-write-read-archive.cc: likewise
	* tools/abicompat.cc: likewise
	* tools/abidiff.cc: likewise
	* tools/abidw.cc: likewise
	* tools/abilint.cc: likewise
	* tools/abipkgdiff.cc: likewise

Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-07-09 18:05:28 +02:00
Matthias Maennich
42cd02a9be Drop requirement to compile with GNU extensions
__gnu_cxx::stdio_filebuf is a GNU extension only available in certain
std libraries. It is not e.g. in libc++. In order to be able to compile
with using libc++, replace the usage of __gnu_cxx::stdio_filebuf with
standard C++ methods. In this case, reopen the temporary file with a
std::fstream and expose that stream rather than the previously exposed
std::iostream.

	* include/abg-tools-utils.h (get_stream): Change return type to
	  std::fstream
	* src/abg-corpus.cc: remove unused #include of ext/stdio_filebuf.h
	* src/abg-tools-utils (temp_file::priv): remove filebuf_ member,
	  and replace iostream_ by fstream_ with changing the shared_ptr
	  type accordingly
	  (temp_file::priv::priv): initialize fstream_ based on
	  temporary file name
	  (temp_file::priv::~priv): adjust destruction accordingly
	  (temp_file::is_good): test the fstream rather than the fd
	  (temp_file::get_stream): adjust return type to std::fstream
	  and adjust implementation based on the changes in temp_file::priv
	* src/Makefile.am: remove gnu extension from c++ standard flag
	* tests/Makefile.am: likewise

Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-07-09 17:16:59 +02:00
Dodji Seketeli
bf100fcb41 Fully account for anonymous-ness of scopes when comparing decl names
When comparing internal decl names (as part of decl comparison), we
need to take into account the fact that a given decl might be
anonymous and that it might have anonymous scopes in its tree of
containing scopes.

For instance, "__anonymous_struct__1::foo" and
"__anonymous_struct__2::foo" are considered equivalent.

So are "__anonymous_struct__1::foo::__anonymous_struct__2::bar" and
"__anonymous_struct__10::foo::__anonymous_struct__11::bar".

But "__anonymous_struct__1::bar::__anonymous_struct__2::baz" and
"__anonymous_struct__10::foo::__anonymous_struct__11::bar" are not.

This patch introduces the function tools_utils::decl_names_equal that
compares fully qualified names by taking into account anonymous
component names.

That function is thus used in the equals() function overload for
decl_base types.  Because tools_utils::decl_names_equal compares strings the
usual way (character by character) it's slower than comparing
instances of interned_string in a O(1) time.  So the patch carefully
tries to use tools_utils::decl_names_equal sparringly; that is, it
uses it only when we are looking at decls that have some anonymous
scope.  That way, we use the fast interned_string comparison most of
the time.  By doing this, we barely see any performance degradation
while running abidw --noout on a full blown vmlinux binary.

	* include/abg-ir.h (decl_base::{get_has_anonymous_parent,
	set_has_anonymous_parent,
	get_is_anonymous_or_has_anonymous_parent}): Declare new member
	functions.
	* src/abg-ir.cc (decl_base::priv::has_anonymous_parent_): Define
	new data member.
	(decl_base::priv): Initialize the new data member.
	(decl_base::{get_has_anonymous_parent, set_has_anonymous_parent,
	get_is_anonymous_or_has_anonymous_parent}): Define new member
	functions.
	(equals): In the overload for decl_base, use the new
	decl_names_equal for decls that have anonymous scopes.
	(scope_decl::add_member_decl): Propagate the
	decl_base::has_anonymous_parent_ property.
	* include/abg-tools-utils.h
	(get_anonymous_struct_internal_name_prefix)
	(get_anonymous_union_internal_name_prefix)
	(get_anonymous_enum_internal_name_prefix, decl_names_equal):
	Declare new functions.
	* src/abg-comp-filter.cc (has_harmless_name_change): Handle the
	case where the name change is actually from an anonymous name to
	another one, using the new decl_names_equal function.
	* src/abg-dwarf-reader.cc
	(get_internal_anonymous_die_prefix_name): Renamed
	get_internal_anonynous_die_base_name into this.  Use the new
	get_anonymous_{struct, union, enum}_internal_name_prefix functions
	here.
	(get_internal_anonymous_die_name, die_qualified_type_name)
	(build_enum_type, add_or_update_class_type)
	(add_or_update_union_type): Adjust.
	* src/abg-tools-utils.cc (get_anonymous_struct_internal_name_prefix)
	(get_anonymous_union_internal_name_prefix)
	(get_anonymous_enum_internal_name_prefix, decl_names_equal):
	Define new functions.
	* tests/test-tools-utils.cc: New test file.
	* tests/Makefile.am: Add new runtesttoolsutils test, built from
	test-tools-utils.cc.
	* tests/data/test-diff-dwarf/test46-rust-report-0.txt: Adjust.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt:
	Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-06-21 11:42:44 +02:00
Dodji Seketeli
047342467c Update copyright for 2019
* include/abg-comp-filter.h: Update copyright for 2019
	* include/abg-comparison.h: Update copyright for 2019
	* include/abg-config.h: Update copyright for 2019
	* include/abg-corpus.h: Update copyright for 2019
	* include/abg-diff-utils.h: Update copyright for 2019
	* include/abg-dwarf-reader.h: Update copyright for 2019
	* include/abg-fwd.h: Update copyright for 2019
	* include/abg-hash.h: Update copyright for 2019
	* include/abg-ini.h: Update copyright for 2019
	* include/abg-interned-str.h: Update copyright for 2019
	* include/abg-ir.h: Update copyright for 2019
	* include/abg-libxml-utils.h: Update copyright for 2019
	* include/abg-libzip-utils.h: Update copyright for 2019
	* include/abg-reader.h: Update copyright for 2019
	* include/abg-reporter.h: Update copyright for 2019
	* include/abg-sptr-utils.h: Update copyright for 2019
	* include/abg-suppression.h: Update copyright for 2019
	* include/abg-tools-utils.h: Update copyright for 2019
	* include/abg-traverse.h: Update copyright for 2019
	* include/abg-viz-common.h: Update copyright for 2019
	* include/abg-viz-dot.h: Update copyright for 2019
	* include/abg-viz-svg.h: Update copyright for 2019
	* include/abg-workers.h: Update copyright for 2019
	* include/abg-writer.h: Update copyright for 2019
	* src/abg-comp-filter.cc: Update copyright for 2019
	* src/abg-comparison-priv.h: Update copyright for 2019
	* src/abg-comparison.cc: Update copyright for 2019
	* src/abg-config.cc: Update copyright for 2019
	* src/abg-corpus-priv.h: Update copyright for 2019
	* src/abg-corpus.cc: Update copyright for 2019
	* src/abg-default-reporter.cc: Update copyright for 2019
	* src/abg-diff-utils.cc: Update copyright for 2019
	* src/abg-dwarf-reader.cc: Update copyright for 2019
	* src/abg-hash.cc: Update copyright for 2019
	* src/abg-ini.cc: Update copyright for 2019
	* src/abg-internal.h: Update copyright for 2019
	* src/abg-ir-priv.h: Update copyright for 2019
	* src/abg-ir.cc: Update copyright for 2019
	* src/abg-leaf-reporter.cc: Update copyright for 2019
	* src/abg-libxml-utils.cc: Update copyright for 2019
	* src/abg-libzip-utils.cc: Update copyright for 2019
	* src/abg-reader.cc: Update copyright for 2019
	* src/abg-reporter-priv.cc: Update copyright for 2019
	* src/abg-reporter-priv.h: Update copyright for 2019
	* src/abg-sptr-utils.cc: Update copyright for 2019
	* src/abg-suppression-priv.h: Update copyright for 2019
	* src/abg-suppression.cc: Update copyright for 2019
	* src/abg-tools-utils.cc: Update copyright for 2019
	* src/abg-traverse.cc: Update copyright for 2019
	* src/abg-viz-common.cc: Update copyright for 2019
	* src/abg-viz-dot.cc: Update copyright for 2019
	* src/abg-viz-svg.cc: Update copyright for 2019
	* src/abg-workers.cc: Update copyright for 2019
	* src/abg-writer.cc: Update copyright for 2019
	* tests/print-diff-tree.cc: Update copyright for 2019
	* tests/test-abicompat.cc: Update copyright for 2019
	* tests/test-abidiff-exit.cc: Update copyright for 2019
	* tests/test-abidiff.cc: Update copyright for 2019
	* tests/test-alt-dwarf-file.cc: Update copyright for 2019
	* tests/test-core-diff.cc: Update copyright for 2019
	* tests/test-diff-dwarf-abixml.cc: Update copyright for 2019
	* tests/test-diff-dwarf.cc: Update copyright for 2019
	* tests/test-diff-filter.cc: Update copyright for 2019
	* tests/test-diff-pkg.cc: Update copyright for 2019
	* tests/test-diff-suppr.cc: Update copyright for 2019
	* tests/test-diff2.cc: Update copyright for 2019
	* tests/test-ini.cc: Update copyright for 2019
	* tests/test-ir-walker.cc: Update copyright for 2019
	* tests/test-lookup-syms.cc: Update copyright for 2019
	* tests/test-read-dwarf.cc: Update copyright for 2019
	* tests/test-read-write.cc: Update copyright for 2019
	* tests/test-types-stability.cc: Update copyright for 2019
	* tests/test-utils.cc: Update copyright for 2019
	* tests/test-utils.h: Update copyright for 2019
	* tests/test-write-read-archive.cc: Update copyright for 2019
	* tools/abiar.cc: Update copyright for 2019
	* tools/abicompat.cc: Update copyright for 2019
	* tools/abidiff.cc: Update copyright for 2019
	* tools/abidw.cc: Update copyright for 2019
	* tools/abilint.cc: Update copyright for 2019
	* tools/abipkgdiff.cc: Update copyright for 2019
	* tools/abisym.cc: Update copyright for 2019
	* tools/binilint.cc: Update copyright for 2019
	* tools/kmidiff.cc: Update copyright for 2019
	* update-copyright.sh: Update new year to 2019

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-01-07 14:54:47 +01:00
Dodji Seketeli
3c0701d59d Support having several debuginfo search dirs for a binary
There are use cases where the split debuginfo file of a given binary
is under a given root directory and that the split debuginfo file
itself depends on an alternate debuginfo file that is under another
unrelated root directory.

In that case, the dwarf reader must be able to look for the debuginfo
files under several unrelated root directories.  The tools abidiff and
abidw must thus support having several occurences of the option
--debug-info-dir1 (or --debug-info-dir2) meaning that the debuginfo
files for the binary must be looked for under several root
directories.

This is what this patch does.

	* doc/manuals/abidiff.rst: Adjust doc for the
	--debug-info-dir{1,2} that can now be provided several times.
	* include/abg-dwarf-reader.h ({create, reset}_read_context)
	(read_corpus_from_elf): Take a vector of debug info root dirs.
	* include/abg-tools-utils.h (trim_leading_string)
	(find_file_under_dir, make_path_absolute_to_be_freed)
	(convert_char_stars_to_char_star_stars): Declare new functions.
	* src/abg-dwarf-reader.cc (find_alt_debug_info_link): Renamed
	find_alt_debug_info_location into this.
	(find_alt_debug_info_path): Define new static function.
	(find_alt_debug_info): Take a vector of debug info root dirs.  Use
	the new find_alt_debug_info_path to look into the debug info root
	dirs for the alt debug info.
	(read_context::debug_info_root_paths_): Define new data member.
	(read_context::read_context): Take a vector of debug info root
	dirs and initialize the new read_context::debug_info_root_paths_.
	(read_context::{initialize, create_default_dwfl}): Take a vector
	of debug info root dirs and adjust.
	(read_context::{add_debug_info_root_paths,
	add_debug_info_root_path, find_alt_debug_info}): Define new member
	functions.
	(read_context::load_debug_info): Look into the debug info roots
	for split debug info files.
	(create_read_context, read_corpus_from_elf): Take a vector of
	debug info root dirs and adjust.
	(has_alt_debug_info): Adjust.
	* src/abg-tools-utils.cc (trim_leading_string)
	(make_path_absolute_to_be_freed, find_file_under_dir)
	(convert_char_stars_to_char_star_stars): Define new functions.
	(entry_of_file_with_name): Define new static function.
	(build_corpus_group_from_kernel_dist_under): Adjust.
	* tests/print-diff-tree.cc (main): Adjust.
	* tests/test-diff-dwarf.cc (main): Adjust.
	* tests/test-ir-walker.cc (main): Adjust.
	* tests/test-read-dwarf.cc (main): Adjust.
	* tools/abicompat.cc (main): Adjust.
	* tools/abidiff.cc (options::di_root_paths{1,2}): Changed
	di_root_path{1,2} into this, change their types into vectors of
	allocated char*.
	(options::prepared_di_root_paths{1,2}): Define new data members.
	(options::~options): Define new destructor.
	(parse_command_line): Adjust.
	(prepare_di_root_paths): Define new static function.
	(handle_error): Remove arguments input_file_name,
	debug_info_dir{1,2}.  Now just take an instance of options
	instead.  Adjust.
	(main): Adjust.
	* tools/abidw.cc (options::dir_root_paths): Renamed dir_root_path
	into this and make it be a vector of allocated char*.
	(options::prepared_di_root_paths): Define new data member.
	(options::~options): Free the allocated char* in
	options::dir_root_paths.
	(parse_command_line): Support several --debug-info-dir.
	(load_corpus_and_write_abixml): Adjust.
	(prepare_di_root_paths): Define static function.
	(main): Adjust.
	* tools/abilint.cc (main): Adjust.
	* tools/abipkgdiff.cc (compare): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-11-08 09:03:32 +01:00
Dodji Seketeli
90b4e7676c PR23641 - Type definition DIE matched by a supprspec but not its decl
Suppose we have two versions of a library which are almost identical.
Suppose the difference between the two binaries is a slight difference of
ordering in how the linker put together what the DWARF describes.

Then, while processing the debug info of the first library, libabigail
first comes across the forward declaration of a type T.  Suppose that
declaration is not matched by any private type suppression
specification.  Libabigail is going to keep the declaration of T and
build an internal representation (IR) for it.  It's also going to
build an IR for types and decls using T like "T*" or "T* var".

Now suppose that while processing the debug info of the second
library, libabigail first comes across the *definition* of T --
because in this second library, that definition comes first.  Suppose
that the definition is matched by a private type suppression
specification, unlike the declaration in the first library.  In this
case, T is going to be dropped, and no IR is going to be built for it.
If other types or decl like 'T*' or 'T *var" refer to this
*definition* of T, they will be dropped too.

We'll end up with those two libraries that are identical (modulo the
order in which libabigail sees type declarations and their
definitions) and are considered different when a suppression
specification makes us drop T: the second library appears to
libabigail as if T was removed from it.

This is the problem addressed by this patch.

When the definition of a type T is suppressed because it's considered
private then we look if there was a forward declaration for it
elsewhere, that is not matched by the private type suppression
specification.  If we encountered such a type declaration then it
means that declaration is in effect an "opaque" version of T.  So
rather than just dropping T altogether, we keep (and build an IR) for
its opaque version only.  And we drop the definition of T.

This seems to fix the issue.

I can't seem to reproduce the slight re-ordering of DIEs descriptions that
uncover the issue so I'll rely on integration tests to catch future
regressions on this issue, rather than on unit tests.  Sigh.

	* include/abg-tools-utils.h (PRIVATE_TYPES_SUPPR_SPEC_NAME):
	Remove this extern constant definition.
	* src/abg-dwarf-reader.cc (type_is_suppressed): Add an overload
	that takes an additional type_is_private output parameter.
	(get_opaque_version_of_type): New static function.
	(build_ir_node_from_die): For class types, get the opaque version
	for suppressed private types rather than dropping them altogether.
	* src/abg-reader.cc (type_is_suppressed): Adjust.
	* src/abg-suppression-priv.h (type_is_suppressed): Add an overload
	that takes a type_is_private output parameter.
	* include/abg-suppression.h (get_private_types_suppr_spec_label)
	(is_private_type_suppr_spec): Declare new functions.
	* src/abg-suppression.cc
	(get_private_types_suppr_spec_label, is_private_type_suppr_spec):
	Define new functions.
	(suppression_matches_type_name_or_location): Use the new
	get_private_types_suppr_spec_label rather than a global extern
	variable.
	* src/abg-tools-utils.cc (handle_fts_entry): Adjust to use the new
	get_private_types_suppr_spec_label.
	(gen_suppr_spec_from_headers): Handle the case or an empty headers
	root dir.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-09-21 17:56:48 +02:00
Jonathan Wakely
4d99280d27 Rename misleading remove_trailing_white_spaces functions
Trailing implies only whitespace at the end is removed, but these
functions also remove leading whitespace.

	* include/abg-tools-utils.h (trim_white_space): Renamed
	remove_trailing_white_spaces into this.
	* src/abg-ini.cc (trim_white_space): Likewise.
	* src/abg-tools-utils.cc (get_dsos_provided_by_rpm): Adjust.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-04-16 13:57:27 +02:00
Dodji Seketeli
2939397c13 Make abipkgdiff avoid comparing private DSOs from RPMs
When an RPM contains a DSO which SONAME is not listed in the
"provides" property of the package, abipkgdiff ought to consider that
DSO as private to the RPM.  It should thus *NOT* consider that DSO
when comparing ABIs, at least, by default.

This is as per the discussion that was held at
https://pagure.io/task-abicheck/issue/8 and that led to the proposal
https://pagure.io/task-abicheck/issue/8#comment-492466.

This patch implements that scheme.

Basically, the patch looks at the SONAMEs listed in the "provides"
property of the RPM and consider them as the SONAMEs of the set of
"public" DSOs of the RPM.

Thus, if the RPM has a DSO that has no SONAME of one that is not
listed in the set of public SONAMEs of the package, then that DSO is
not considered for ABI comparison.

The patch also introduces a new --private-dso option that disables
this behaviour and compares all DSOs, including those that would be
meant to be private.

	* doc/manuals/abipkgdiff.rst: Add documentation for the new
	--private-dso option.
	* include/abg-tools-utils.h (execute_command_and_get_output)
	(execute_command_and_get_output, remove_trailing_white_spaces):
	Declare new functions.
	* src/abg-tools-utils.cc (execute_command_and_get_output)
	(get_dsos_provided_by_rpm, remove_trailing_white_spaces): Define
	new functions.
	* tests/test-diff-pkg.cc (in_out_specs): Add the new --private-dso
	option where it makes sense.
	* tools/abipkgdiff.cc (options::compare_private_dsos): Add new
	data member.
	(options::options): Initialize it.
	(package::public_dso_sonames_): Add new data member.
	(package::public_dso_sonames): Add new accessors pair.
	(display_usage): Add a help string for the new --private-dso
	option.
	(maybe_create_public_dso_sonames_set)
	(must_compare_public_dso_only): Define new static functions.
	(create_maps_of_package_content): Call the new
	maybe_create_public_dso_sonames_set.  Skip packages which SONAME
	is not in the set of public SONAMES.
	(parse_command_line): Parse the new --private-dso option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-03-28 14:22:35 +02:00
Dodji Seketeli
3001e78a4f Fix symlinks paths handling in abipkgdiff
When elements of an RPMs are referred to using a path that contains
symlinks, we need to resolve the symlinks in order to be able to
compare those paths.  We are not doing this fully and so we are
hitting corner cases where things break down in subtle ways.

This patch fixes that.

	* include/abg-tools-utils.h (real_path): Declare new function.
	* src/abg-tools-utils.cc (real_path): Define it.
	* tools/abipkgdiff.cc (package::convert_path_to_relative): Use the
	new real_path function to consider real path (where symlinks are
	resolved) of the extraction directory of the package.
	(get_interesting_files_under_dir): Similarly, use the new
	real_path function to consider the real path of the directory we
	are exploring.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-01-12 13:38:01 +01:00
Dodji Seketeli
2df84dd767 Fix version revision number printing in tools --help option
The revision number of the version string is junk since 1.0.  This
patch fixes that.

The patch also comes up with a function that returns a version string,
rather than having client code constructing the version string on
their own.

	* configure.ac: Properly set the VERSION_REVISION macro.
	* include/abg-tools-utils.h (get_library_version_string): Declare
	new function.
	* src/abg-tools-utils.cc (get_library_version_string): Define the
	new function.
	(gen_suppr_spec_from_kernel_abi_whitelist): Dis-ambiguate the use
	of the 'config' type.
	* tools/abicompat.cc (main): Use the new
	abigail::tools_utils::get_library_version_string function.
	* tools/abidiff.cc (main): Likewise.
	* tools/abidw.cc (main): Likewise.
	* tools/abilint.cc (main): Likewise.
	* tools/abipkgdiff.cc (main): Likewise.
	* tools/abisym.cc (main): Likewise.
	* tools/kmidiff.cc (main): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-01-09 18:27:09 +01:00
Dodji Seketeli
b3c3049fdd Update copyright notice for all source files
Happy New Year 2018, I guess :-)

	* update-copyright.sh: New sed-based script to update the year
	in the copyright notice.
	* include/abg-comp-filter.h: Updated the year in the copyright
	notice.
	* include/abg-comparison.h: Likewise.
	* include/abg-config.h: Likewise.
	* include/abg-corpus.h: Likewise.
	* include/abg-diff-utils.h: Likewise.
	* include/abg-dwarf-reader.h: Likewise.
	* include/abg-fwd.h: Likewise.
	* include/abg-hash.h: Likewise.
	* include/abg-ini.h: Likewise.
	* include/abg-interned-str.h: Likewise.
	* include/abg-ir.h: Likewise.
	* include/abg-libxml-utils.h: Likewise.
	* include/abg-libzip-utils.h: Likewise.
	* include/abg-reader.h: Likewise.
	* include/abg-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-ir-walker.cc: Likewise.
	* tests/test-lookup-syms.cc: Likewise.
	* tests/test-read-dwarf.cc: Likewise.
	* tests/test-read-write.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.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-01-08 18:24:26 +01:00
Dodji Seketeli
8028cdd236 Bug 22488 - Make abipkgdiff handle different binaries with same basename
Some packages might have different binaries with the same soname and
basename, but at different paths.  In that case, abipkgdiff messes
things up because it only either consider the soname or the basename
of the binary.

This patch makes abipkgdiff to always consider the full path of the
binary inside the package.

	* include/abg-tools-utils.h (string_suffix)
	(sorted_strings_common_prefix): Declare new functions.
	(dir_name): Take a new keep_separator_at_end parameter at the end.
	* src/abg-tools-utils.cc (dir_name): Take a new
	keep_separator_at_end parameter at the end.  Add a comment for it
	and update.
	(string_suffix, sorted_strings_common_prefix): Define new
	functions.
	(common_prefix): Define new static function.
	* tools/abipkgdiff.cc (get_interesting_files_under_dir): Forward
	declare this pre-existing static function.
	(package::{common_paths_prefix_, elf_file_paths_}): New data
	members.
	(package::{common_paths_prefix, elf_file_paths,
	convert_path_to_relative, convert_path_to_unique_suffix,
	load_elf_file_paths}): New member functions.
	(create_maps_of_package_content): Use the new
	package::{load_elf_file_paths, convert_path_to_unique_suffix}
	functions.
	(compare_prepared_userspace_packages): Show relative paths of
	package elements in reported.
	* tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt:
	Update test ouptut.
	* tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt:
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-12-06 16:01:55 +01:00
Dodji Seketeli
eead00efb0 Bug 22436 - make abipkgdiff accept several debuginfo packages
Sometimes, the debug information for one given package P can have been
split into several packages.  In that case, we need abipkgdiff to
consider several debug info packages for a given input binary package.

This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package>
option, for a given input package.

	* doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can
	be provided several times on the command line.
	* tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the
	debug_package{1,2} data members into this, and make them be vector
	of strings, rather than just strings.
	(package::debug_info_packages_): Renamed
	package::debug_info_package_ into this and make it be a vector of
	package_sptr, rather than just a package_sptr.
	(package::debug_info_packages): Renamed the method
	package::debug_info_package into this and -- for the getter
	overload -- make it return a vector of package_sptr, rather than
	just a package_sptr.  Likewise for the setter overload.  Add a
	non-const getter overload.
	(package::erase_extraction_directories)
	(extract_package_and_map_its_content): Adjust.
	(extract_rpm, extract_deb): Do not erase the content of the
	extraction directory (if it was pre-existing) prior to extracting
	the RPM/deb into it.
	(pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and
	make it be a vector of packages, rather than just a package.
	(pkg_extraction::pkg_extraction): Adjust to take a package_sptr
	rather than just a package.  Add an overload to take a vector of
	packages_sptr.
	(pkg_extraction::perform): Extract the vector of package that the
	task is not responsible for, not just one random package.
	(extract_package_and_map_its_content): Adjust.
	(prepare_packages): Take smart pointers to package rather than
	just packages.  Adjust accordingly.
	(compare_prepared_package): Make the overload that takes two
	packages to take two smart pointers of packages.
	(compare): Make the overload that takes two package take two
	package_sptr.
	(parse_command_line): Parse having --d{1,2} several times for a
	given input package.
	(main): Take several debug info packages for one input file.
	* include/abg-tools-utils.h (split_string): Declare ...
	* src/abg-tools-utils.cc (split_string): ... new function.
	* tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm:
	Add a new RPM test input file.
	* tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt:
	new reference output file.
	* tests/data/Makefile.am: Add the new test input files above to source
	distribution.
	* tests/test-diff-pkg.cc (in_out_spec): Add new test entry to
	specify two debug info packages for one input package.
	(test_task::perform): Support having several debug info package
	paths in the IntOutSpec::{first,second}_in_debug_package_path data
	member.  The debug info packages paths are separated by either a
	white space or commas.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 17:15:20 +01:00
Dodji Seketeli
a1b6a3d351 Bug 21730 - Make abipkgdiff compare Linux Kernel packages as expected
This is the initial patch that makes abipkgdiff recognize Linux kernel
packages passed in argument and do the right thing.

abipkgdiff gets the vmlinux binary from the debug info package,
considers the union of that vmlinux binary and the thousands of kernel
modules that we shall name "the Kernel".  It then compares ABI
(actually Kernel/Module Interface, a.k.a KMI) of the Kernel of the
first package against the KMI of the Kernel of the second package.

	* include/abg-tools-utils.h (get_vmlinux_path_from_kernel_dist):
	Declare new function.
	(get_binary_paths_from_kernel_dist): Re-organize order of
	parameters.
	(file_is_kernel_package, file_is_kernel_debuginfo_package): Make
	the file_path parameter be const.
	(build_corpus_group_from_kernel_dist_under): Take an additional
	debug_info_root parameter.
	* src/abg-tools-utils.cc (file_is_kernel_package)
	(file_is_kernel_debuginfo_package): Const-ify the file_name
	parameter.
	(find_vmlinux_path): Define new static function.
	(get_binary_paths_from_kernel_dist): Re-organize the order of
	parameters.  The debug_info_root_path parameter is now an input
	parameter.
	(get_vmlinux_path_from_kernel_dist): Define new function.
	(get_binary_paths_from_kernel_dist): Adjust invocation of
	get_binary_paths_from_kernel_dist.
	(build_corpus_group_from_kernel_dist_under): Take an additional
	debug_info_root parameter.
	* tools/abidw.cc (load_kernel_corpus_group_and_write_abixml):
	Adjust invocation to build_corpus_group_from_kernel_dist_under.
	* tools/abipkgdiff.cc (create_maps_of_package_content):  Don't map
	the content of a Linux Kernel package.
	(compare_prepared_userspace_packages)
	(compare_prepared_linux_kernel_packages, compare_prepared): Define
	new functions.
	(compare): Use the new functions above here.
	* tools/kmidiff.cc (print_kernel_dist_binary_paths_under): Adjust
	the invocation of get_binary_paths_from_kernel_dist.
	(main): Adjust the invocation of
	build_corpus_group_from_kernel_dist_under.  Make sure that a
	kernel package is accompanied by a debug info package.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:36 +02:00
Dodji Seketeli
08e760221b Support Linux Kernel ABI whitelist files
Enterprise Linux (at least) kernels come with ABI whitelist files that list the
names of the set of functions to be considered when looking at the ABI
exposed by the kernel to its modules.

This patch adds a new --linux-kernel-abi-whitelist option to abidiff
so that it drops changes that relate to functions that are *NOT*
defined in the whitelist.

The patch reads the whitelist file and generates one or several
instances of function_suppression that are applied when the two
binaries are loaded.

	* include/abg-suppression.h
	(function_suppression::function_suppression): Make the declaration
	of the default constructor public.
	* src/abg-suppression-priv.h (function_suppression::priv::priv):
	Declare a default constructor.
	* src/abg-suppression.cc
	(function_suppression::function_suppression): Define default
	constructor.
	* include/abg-tools-utils.h
	(gen_suppr_spec_from_kernel_abi_whitelist): Declare new function.
	* src/abg-tools-utils.cc
	(gen_suppr_spec_from_kernel_abi_whitelist): Define new function.
	* tools/abidiff.cc (options::kernel_abi_whitelist_paths):
	(display_usage): Display a help string for the new
	--linux-kernel-abi-whitelist option.
	(parse_command_line): Parse the --linux-kernel-abi-whitelist from
	the command line.
	(maybe_check_suppression_files): Check the presence of the kernel
	abi whitelist files.
	(set_suppressions): Generate suppression specifications from the
	whitelist files.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-06 12:41:57 +01:00
Dodji Seketeli
5a24ffcd61 Add ABG_ASSERT_NOT_REACHED macro
Adding this macro to abort at places where the execution flow
shouldn't take us to.  Using this is more explicit (self-documented)
than using abort.

This patch replaces the use of abort() in abg-dwarf-reader.cc.

	* include/abg-tools-utils.h (ABG_ASSERT_NOT_REACHED): New macro.
	* src/abg-dwarf-reader.cc (stt_to_elf_symbol_type)
	(stb_to_elf_symbol_binding, get_elf_class_size_in_bytes)
	(build_ir_node_from_die): Use the new ABG_ASSERT_NOT_REACHED macro
	in lieu of just calling abort().

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-07-26 20:04:23 +02:00
Dodji Seketeli
b36ca1501e Bug 20180 - Support system-wide suppression specifications
This patch adds support for loading system and user level suppression
specifications for libabigail tools.

At launch time, relevant libabigail tools (abidiff, abipkgdiff
fedabipkgdiff for now) read the default system suppression
specification file, if it's present, from a file which path is the
value of the environment variable
LIBABIGAIL_DEFAULT_SYSTEM_SUPPRESSION_FILE, if set, or from the file
$libdir/libabigail/default.abignore.

Then it reads the user system suppression specification file, if it's
present, from a file which path is the value of the environment
variable LIBABIGAIL_DEFAULT_USER_SUPPRESSION_FILE, if set, or from the
file $HOME/.abignore.

The content of the user system suppression file is merged with the
content of default system suppression file.

That content is also merged with the content of the suppression
specification files that might be provided by the --suppressions
command line option of the invoked tools.

The resulting set of all these suppression specifications is thus used
to filter the ABI change reports that are emitted.

abidiff, abipkgdiff and abipkgdiff gain a --no-default-suppression
option to avoid loading any of these default suppression specification
files.

The patch also installs a default.abignore file into $(pkglibdir).
Note that on x86_64, that directory is /usr/lib64/libabigail.  Now we
just need to think about the content of that default.abignore file.

	* doc/manuals/abidiff.rst: Document the default suppression
	scheme, its interaction with the --supprs option and the new
	--no-default option.
	* doc/manuals/abipkgdiff.rst: Likewise.
	* doc/manuals/fedabipkgdiff.rst: Likewise.
	* configure.ac: Generate the tests/runtestdefaultsupprs.py file
	from the new tests/runtestdefaultsupprs.py.in template.
	* default.abignore: New file.
	* Makefile.am: Add it to source distribution.
	* src/Makefile.am: Define the ABIGAIL_ROOT_SYSTEM_LIBDIR
	preprocessor macro that is set the value of the $libdir autotools
	macro.
	* include/abg-tools-utils.h: Update copyright years.
	(get_system_libdir, get_default_system_suppression_file_path)
	(get_default_user_suppression_file_path)
	(load_default_system_suppressions)
	(load_default_user_suppressions): Declare new functions
	* src/abg-tools-utils.cc (get_system_libdir)
	(get_default_system_suppression_file_path)
	(get_default_user_suppression_file_path)
	(load_default_system_suppressions)
	(load_default_user_suppressions): Define new functions.
	(is_regular_file): Amend this so that it return true for symlinks
	to regular files too.
	(is_dir): Amend this so that it returns true for symlinks to
	directories too.
	* tools/abidiff.cc (options::no_default_supprs): New data member.
	(options::options): Initialize the new data member.
	(display_usage): Display a new help string for the new
	--no-default-suppression command line option.
	(parse_command_line): Parse this new command line option.
	(set_diff_context_from_opts): Load the default suppression
	specifications, unless --no-default-suppression or --supprs was
	provided.
	* tools/abipkgdiff.cc (options::no_default_supprs): New data
	member.
	(options::options): Initialize the new data member.
	(parse_command_line): Parse the new --no-default-suppression
	command line option.
	(main): Load the default suppression specifications, unless
	--no-default-suppression or --supprs was provided.
	* tools/fedabipkgdiff (abipkgdiff): Add --no-default-suppression
	to the invocation of abipkgdiff if it was provided on the command
	line.
	(build_commandline_args_parser): Parse the new
	--no-default-suppression command line option.
	* tests/runtestdefaultsupprs.py.in: New test harness template.
	* tests/Makefile.am: Add the new runtestdefaultsupprs.py to the
	set of tests.
	* tests/data/test-default-supprs/test0-type-suppr-0.suppr: New
	test input.
	* tests/data/test-default-supprs/test0-type-suppr-report-0.txt: Likewise.
	* tests/data/test-default-supprs/test0-type-suppr-v0.o: Likewise.
	* tests/data/test-default-supprs/test0-type-suppr-v1.o: Likewise.
	* tests/data/test-default-supprs/dirpkg-1-dir-report-0.txt:
	Likewise.
	* tests/data/test-default-supprs/dirpkg-1-dir1: Likewise.
	* tests/data/test-default-supprs/dirpkg-1-dir2: Likewise.
	* tests/data/Makefile.am: Add new the new tests input above to
	Makefile.am.
	* tests/runtestcanonicalizetypes.sh.in: Pass
	--no-default-suppression to abidiff invocations.
	* tests/runtestdefaultsupprs.py.in: Likewise.
	* tests/test-abidiff-exit.cc: Likewise.
	* tests/test-diff-dwarf-abixml.cc: Likewise.
	* tests/test-diff-filter.cc: Likewise.
	* tests/test-diff-suppr.cc: Likewise.
	* tools/abidiff.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-30 18:39:49 +02:00
Dodji Seketeli
e19bf5627a Make abi{pkg}diff filter out changes about private types
This is to address the following enhancement requests:

    #19588 - Add a --headers-dir1 and --headers-dir2 option to abidiff
    #19948 - Add --devel-pkg1 and --devel-pkg2 options to abipkgdiff

When the user specifies where to find header files for two binaries
(or packages) being compared, this patch generates a type suppression
specification that filters out change reports about types that are
defined in files that are not in the set of header files specified.

The type suppression specification also suppresses change reports
about changed/added/removed virtual member functions which enclosing
class type matches the type suppression specification.

There is a corner case that the patch handles too, and that is
exhibited by the accompanying test case for abidiff.  There can be a
class defined by DWARF as having no source location and as being a
pure declaration.  This can be a class declaration that has inline
virtual members only, and one or several non-defined virtual methods
too.  When that declaration is included in a source file, GCC
generates debug info that describes that class as being a
declaration-only class with no source declaration.  This patch
considers such a class as being non defined; you know, like a true
opaque type.  So it's considered being not defined in any public
header file.  Changes to this kind of class are thus filtered out.

	* include/abg-comp-filter.h: Update copyright year.
	* src/abg-comp-filter.cc (has_virtual_mem_fn_change): Make this
	static function become exported.
	(has_virtual_mem_fn_change): Declare new function.
	* include/abg-suppression.h
	(suppression_base::{get,set}_is_artificial): Declare new
	accessors.
	(type_suppression::get_source_locations_to_keep): Return an
	unordered set of strings, not a vector.  Add a non-const overload.
	(type_suppression::set_source_locations_to_keep): Set an unordered
	set of strings, not a vector.
	* src/abg-suppression.cc (suppression_base::priv::is_artificial_):
	New data member.
	(suppression_base::priv::priv): Initialize the new data member.
	(suppression_base::{get,set}_is_artificial): Define new accessors.
	(type_suppression::priv::source_locations_to_keep_): Change the
	vector of strings representing source file names into unordered
	set of string.
	(type_suppression::get_source_locations_to_keep): Return an
	unordered set of strings, not a vector.  Define a non-const
	overload.
	(type_suppression::set_source_locations_to_keep): Set an unordered
	set of strings, not a vector.
	(type_suppression::suppresses_diff): Make this suppress virtual
	member function diffs if the enclosing type of the changed virtual
	member is suppressed by the current type_suppression.
	(read_type_suppression): Adjust to use the fact that the source
	locations are not stored in an unordered set, not in a vector
	anymore.  Otherwise, using a vector here make things too slow.
	(type_suppression::suppresses_type): Likewise.  Also, If the type
	we are looking at has no location because it's a true opaque type
	and if the current suppression is an artificial suppression that
	is meant to suppress change reports about non-public types, then
	suppress the type.
	* include/abg-tools-utils.h (gen_suppr_spec_from_headers): Declare
	new public function.
	* src/abg-tools-utils.cc (PRIVATE_TYPES_SUPPR_SPEC_NAME): Define a
	new constant variable.
	(handle_fts_entry): Define new static function.
	(gen_suppr_spec_from_headers): Define new public function.
	* src/abg-comparison.cc
	(corpus_diff::priv::apply_suppressions_to_added_removed_fns_vars):
	If a type suppression suppresses a given class C, make it change
	added/removed virtual functions whose enclosing type is C.
	* tools/abidiff.cc (options::{headers_dir1, headers_dir2}): New
	data members.
	(display_usage): Add help strings for --headers-dir1 and
	--headers-dir2.
	(parse_command_line): Parse the new --headers-dir1 and
	--headers-dir2 options.
	(set_diff_context_from_opts): Generate suppression specifications
	to filter out changes on private types, if --headers-dir1 or
	--headers-dir2 is given.
	* tools/abipkgdiff.cc (options::{devel_package1, devel_package2}):
	New data members.
	(typedef package_sptr): New typedef.
	(enum package::kind): New enum.
	(package::kind_): New data member.  This replaces ...
	(package::is_debug_info_): ... this data member.
	(package::{devel_package_, private_types_suppressions_}): New data
	members.
	(package::package): Adjust.
	(package::get_kind): Define new member function.  This replaces
	...
	(package::is_debug_info): ... this member function overload.
	(package::set_kind): Define new member functin.  It replaces ...
	(package::is_debug_info): ... this member function overload.
	(package::{devel_package, private_types_suppressions}): Define new
	accessors.
	(package::erase_extraction_directies): Erase the sub-directory
	where development packages are extracted to.
	(compare_args::private_types_suppr{1,2}): New data members.
	(compare_args::compare_args): Adjust.
	(display_usage): Add help strings for --devel-pkg1/--devel-pkg2.
	(compare): Make the overload that compares elf files take private
	types suppressions.  Add the private types suppressions to the
	diff context.
	(pthread_routine_compare): Adjust the call to compare.
	(maybe_create_private_types_suppressions): Define new static
	function.
	(pthread_routine_extract_pkg_and_map_its_content): If a devel
	package was specified for the main package then extract it in
	parallel with the other package extraction.  When the extraction
	is done, create private types suppressions by visiting the
	directories that contain the header files.
	(compare): In the overload that compares packages by scheduling
	comparison of individual elf files that are in the packages, pass
	in the private type suppressions too.
	(parse_command_line): Parse the new --devel-pkg{1,2} command line
	options.
	(main): Associate the devel package to the main package, if the
	--devel-pkg{1,2}.
	* doc/manuals/abidiff.rst: Add documentation about the new
	--headers-dir1 and --headers-dir2 options.
	* doc/manuals/abipkgdiff.rst: Likewise, add documentation about
	the new --devel-pkg1 and --devel-pkg2 libraries.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt:
	New test reference output.
	* tests/data/test-diff-pkg/tbb-devel-4.1-9.20130314.fc22.x86_64.rpm:
	New test input package.
	* tests/data/test-diff-pkg/tbb-devel-4.3-3.20141204.fc23.x86_64.rpm: Likewise.
	* tests/test-diff-pkg.cc b/tests/test-diff-pkg.cc
	(InOutSpec::{first,second}_in_devel_package_path): New data
	members.
	(in_out_specs): Adjust.  Also, add a new entry describing the new
	test inputs above.
	(test_task::perform): When the new test entry contains devel
	packages, pass them to abipkgdiff using the --devel1 and --devel2
	options.
	* tests/data/test-diff-suppr/test30-include-dir-v0/test30-pub-lib-v0.h:
	A new test input source code.
	* tests/data/test-diff-suppr/test30-include-dir-v1/test30-pub-lib-v1.h: Likewise.
	* tests/data/test-diff-suppr/test30-priv-lib-v0.cc: Likewise.
	* tests/data/test-diff-suppr/test30-priv-lib-v0.h: Likewise.
	* tests/data/test-diff-suppr/test30-priv-lib-v1.cc: Likewise.
	* tests/data/test-diff-suppr/test30-priv-lib-v1.h: Likewise.
	* tests/data/test-diff-suppr/test30-pub-lib-v0.cc: Likewise.
	* tests/data/test-diff-suppr/test30-pub-lib-v0.so: Add new test
	binary input.
	* tests/data/test-diff-suppr/test30-pub-lib-v1.cc: Add new test
	input source code.
	* tests/data/test-diff-suppr/test30-pub-lib-v1.so: Add new test
	binary input.
	* tests/data/test-diff-suppr/test30-report-0.txt: Add new test
	reference output.
	* tests/data/test-diff-suppr/test30-report-1.txt: Add new test
	reference output.
	* tests/test-diff-suppr.cc (InOutSpec::headers_dir{1,2}): New data
	members.
	(InOutSpec::abidiff_options): Renamed the bidiff_options data
	member into this.
	(in_out_specs): Adjust.  Also, added the new test input above to
	this.
	(main): Adjust to invoke abidiff with the new --hd1 and --hd2
	options if the input specs for the tests has the new
	InOutSpec::headers_dir{1,2} data member set.  Renamed bidiff into
	abidiff.
	* tests/data/Makefile.am: Add the new test inputs to the source
	distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-24 10:32:08 +02:00
Dodji Seketeli
67435cf6cd Bug 19867 - abipkgdiff skips symbolic links
When comparing two directories, abipkgdiff skips symbolic links
pointing to ELF binaries altogether.  It only consider regular files.
This is a problem when abipkgdiff is given two directories that only
contain symbolic links.  In that case, abipkgdiff just performs no
comparison.

This patch makes abipkgdiff resolve the symbolic link to its target
file.

	* include/abg-tools-utils.h (maybe_get_symlink_target_file_path):
	Declare new function.
	* src/abg-tools-utils.cc (get_stat): Use lstat here, not stat.
	Update comment.
	* tools/abipkgdiff.cc (first_package_tree_walker_callback_fn)
	(second_package_tree_walker_callback_fn): Follow symbolic links to
	elf files to get their target paths, and only work with that
	target path.
	(maybe_get_symlink_target_file_path): Define new function.
	* test-diff-pkg/symlink-dir-test1-report0.txt New test material.
	* test-diff-pkg/symlink-dir-test1/dir1/symlinks/foo.o: Likewise.
	* test-diff-pkg/symlink-dir-test1/dir1/symlinks/libfoo.so: Likewise.
	* test-diff-pkg/symlink-dir-test1/dir1/targets/foo.c: Likewise.
	* test-diff-pkg/symlink-dir-test1/dir1/targets/foo.o: Likewise.
	* test-diff-pkg/symlink-dir-test1/dir1/targets/libfoo.so: Likewise.
	* test-diff-pkg/symlink-dir-test1/dir2/symlinks/foo.o: Likewise.
	* test-diff-pkg/symlink-dir-test1/dir2/symlinks/libfoo.so: Likewise.
	* test-diff-pkg/symlink-dir-test1/dir2/targets/foo.c: Likewise.
	* test-diff-pkg/symlink-dir-test1/dir2/targets/foo.o: Likewise.
	* test-diff-pkg/symlink-dir-test1/dir2/targets/libfoo.so: Likewise.
	* tests/data/Makefile.am: Add the new test material to source
	distribution.
	* tests/test-diff-pkg.cc (in_out_spec): Run this test harness
	over the new test material above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-03-25 13:52:02 +01:00
Dodji Seketeli
61a0a8b2c0 Fix a typo in include/abg-tools-utils.h
* include/abg-tools-utils.h (enum abidiff_status): Fix typo in
	comment.

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

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-18 18:23:19 +01:00
Dodji Seketeli
7b35e89315 Bug 19139 - DWARF reader doesn't handle garbage in function names
In this bug, the DWARF debug info of the binary (generated by Intel's
ICC compiler) has interesting constructs like:

     [ 6b5a0]    subprogram
		 decl_line            (data2) 787
		 decl_column          (data1) 15
		 decl_file            (data1) 46
		 declaration          (flag)
		 accessibility        (data1) public (1)
		 type                 (ref4) [ 6b56a]
		 prototyped           (flag)
		 name                 (string) "ldiv"
		 MIPS_linkage_name    (string) "ldiv"
     [ 6b5b6]      formal_parameter
		   type                 (ref4) [ 5f2aa]
		   name                 (string) "$Ë2"
     [ 6b5bf]      formal_parameter
		   type                 (ref4) [ 5f2aa]
		   name                 (string) "$Ë3"

Note the strings that make up the name of the formal parameters of the
function, near the end:

     [ 6b5b6]      formal_parameter
		   type                 (ref4) [ 5f2aa]
		   name                 (string) "$Ë2"
     [ 6b5bf]      formal_parameter
		   type                 (ref4) [ 5f2aa]
		   name                 (string) "$Ë3"

The strings "$Ë2" and $Ë3" (which are the names of the
parameters of the function) are garbage.

Libabigail's DWARF reader naively uses those strings as names for the
function parameters, in the type of the function.

Then, the abixml writer emits an XML document, with these strings as
property values, representing the name of the type of the function.

And of course, the XML later chokes when it tries to read that XML
document, saying that the property is not valid UTF-8.

This patch addresses the issue by dropping those garbage names on the
floor, for function type names.  In that context, any string that is
not made of ASCII characters is considered as being garbage, for now.

The patch, in the abixml writer, also escapes function parameters
names so that they don't contain characters that are not allowed in
XML.  The abixml reader already handles the un-escaping of the names
it reads, so I think there is nothing to do there.

Ultimately, I guess I should get the unicode value of the characters
of that string, encode the string into UTF-8 and use the result as the
name for the parameter.  That would mean using UTF-8 strings for
function parameter names, and, for all declarations names.  But that
is too much for worfk too little gain for now.  The great majority of
the binaries we are dealing with are still using ASCII for declaration
names.

The patch also introduces a new test harness that runs "abidw
--abidiff" on a bunch of input binaries.  This harness runs over the
binaries that were submitted in this bug report.

	* include/abg-tools-utils.h (string_is_ascii): Declare new
	function ...
	* src/abg-tools-utils.cc (string_is_ascii): ... and define it.
	* src/abg-writer.cc (write_function_type): Escape forbidden XML
	characters in function type names.
	* src/abg-dwarf-reader.cc (build_function_type):  If a parameter
	name is not ascii, drop it on the floor.
	* tests/data/test-types-stability/pr19139-DomainNeighborMapInst.o:
	New test input binary.
	* tests/data/test-types-stability/pr19202-libmpi_gpfs.so.5.0:
	Likewise.
	* tests/data/Makefile.am: Add the new binaries above to the build
	system.
	* tests/test-types-stability.cc: New test harness.
	* tests/Makefile.am: Add the new test harness to the build system.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-11-05 16:40:22 +01:00
Dodji Seketeli
4173b2a421 Add a missing function declaration
* include/abg-tools-utils.h (dir_name): Add missing function
	declaration.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-09-21 15:22:35 +02:00
Dodji Seketeli
585fc4c33c Make abipkgdiff compare tar archives containing binaries
This patch adds support for comparing the ABI of binaries contained in
a tar archive.

If the archive is compressed with gzip, bzip2, lzip, lzma or xz, then
abipkgdiff recognizes the usual relevant file extensions and lets the
GNU tar program handle the decompression.

If the archive is not compressed, abipkgdiff recognizes the UStar
(Uniform Standard Tape ARchive) format, even if the archive file name
doesn't end with the .tar extension, and lets the GNU tar program
handle the extraction.  If the file ends up with the .tar extension
anyway (even if it's not in the UStar format, abipkgdiff lets the GNU
tar program handle its extraction.

	* config.h.in (WITH_TAR): New configuration preprocessor macro.
	* configure.ac: Add a new --enable-tar option.  It's turned on
	automatically if the tar program is found in the PATH.  Adjust the
	build configuration report to add the tar archive support.
	* include/abg-tools-utils.h (string_ends_with): Declare new
	function.
	(enum file_type): Add a new FILE_TYPE_TAR enumerator.
	* src/abg-tools-utils.cc (string_ends_with): Define new function.
	(operator<<(ostream&, file_type)): Serialize the new FILE_TYPE_TAR
	enumerator.
	(guess_file_type): Detect UStar format file by reading its magic
	number.  Detect compressed tar files based on the file path
	extension.
	* tools/abipkgdiff.cc (extract_tar): Define new function.
	(extract_package): Handle tar packages.
	(main): Handle tar archives.
	* tools/abidiff.cc (main): Handle the new FILE_TYPE_TAR
	enumerator.
	* tools/abilint.cc (main): Likewise.
	* tests/data/test-diff-pkg/tarpkg-0-dir{1,2}.ta{,r,.bz2, gz}: New
	test input tarballs.
	* tests/data/test-diff-pkg/tarpkg-0-report-0.txt: New test output
	reference.
	* tests/data/Makefile.am: Add the new test data file above to
	source distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Add new tests cases.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-22 14:32:20 +02:00
Dodji Seketeli
fca8506ab9 Misc style fixes in abipkgdiff
* include/abg-tools-utils.h (enum file_type): Fix the comment for
	for the FILE_TYPE_DEB enumerator.
	* tools/abipkgdiff.cc (main): Fix the style of the conditions.
	Also, fix the text emitted.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-22 12:19:27 +02:00
Dodji Seketeli
d7dbbf0d50 Make abipkgdiff compare directories containing binaries
abipkgdiff knows how to compare the ABI of binaries contained in .deb
and .rpm files.  This patch adds support for comparing the ABI of
binaries contained in two directories.

	* include/abg-tools-utils.h (enum file_type): Add a new
	FILE_TYPE_DIR enumerator.
	* src/abg-tools-utils.cc (operator<<(ostream&, file_type)):
	Support serialization of the new FILE_TYPE_DIR enumerator.
	(guess_file_type): Detect that the path given is a directory.
	* tools/abipkgdiff.cc (package::package): If the package is a
	directory, then set its extracted directory path to the path of
	the directory.
	(package::erase_extraction_directory): Do not erase the extraction
	directory if the package is a directory provided by the user.
	(extract_package): If the package is a directory provided by the
	user, then there is nothing to extract.
	(main): If the first package is a directory, then the second one
	should be a directory as well.
	* tools/abidiff.cc (main): Support directories as input.
	* tools/abilint.cc (main): Likewise.
	* tests/data/test-diff-pkg/dirpkg-0-dir{1,2}/libobj-v0.so: New
	binary test inputs.
	* test/data/test-diff-pkg/dirpkg-0-report-0.txt: New input test
	file.
	* tests/data/test-diff-pkg/dirpkg-1-dir{1,2}/obj-v0.cc: Source
	code of the binary test inputs above.
	* tests/data/Makefile.am: Add the new files above to the source
	distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Add the new test input
	files above to the set of tests this harness has to run over.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-22 12:19:27 +02:00
Matthias Klose
4df0a4d952 Add support for .deb files to abipkgdiff
This lets abipkgdiff compare debian binary packages.

The patch contains test cases for debian package with split debug info
that is referenced by the build-id scheme.  These test cases come from
the bug report https://sourceware.org/bugzilla/show_bug.cgi?id=18792,
more particularly from the attachment
https://sourceware.org/bugzilla/attachment.cgi?id=8516.

	* include/abg-tools-utils.h (file_type): Add FILE_TYPE_DEB.
	* tools/abipkgdiff.cc (extract_deb): New.
	(extract_package, main): Handle FILE_TYPE_DEB.
	* src/abg-tools-utils.cc (operator<<): Handle FILE_TYPE_DEB.
	(guess_file_type): Detect FILE_TYPE_DEB.
	* tools/abidiff.cc (main): Handle FILE_TYPE_DEB.
	* tools/abilint.cc (main): Handle FILE_TYPE_DEB.
	* tests/data/test-diff-pkg/libsigc++-2.0-0c2a-dbgsym_2.4.0-1_amd64.ddeb:
	Input debian debug info package; to be compared by the test
	harness runtestdiffpkg.
	* tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64.deb:
	Input debian package; to be compared by the test harness
	runtestdiffpkg.
	* tests/data/test-diff-pkg/libsigc++-2.0-0v5-dbgsym_2.4.1-1ubuntu2_amd64.ddeb:
	Input debug info package
	* tests/data/test-diff-pkg/libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64.deb:
	Input debian package; to be compared by the test harness
	runtestdiffpkg.
	* tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt:
	Reference output for the comparison of the packages above.
	* tests/data/Makefile.am: Add the new files above to the source distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Add the input packages
	above to the set of files to be compared by this test harness.

Signed-off-by: Matthias Klose <doko@debian.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 13:36:23 +02:00
Dodji Seketeli
f681c33970 Remove use of tmpnam from abilint
We were using the unsafe tmpnam function in abilint.  This patch
creates a helper type abigail::tools_utils::temp_file that does away
with the use tmpnam in abilint.

	* include/abg-tools-utils.h (abigail::tools_utils::temp_file):
	Declare new type.
	(abigail::tools_utils::temp_file_sptr): New typedef.
	* src/abg-tools-utils.cc (temp_file::priv): Define new type.
	(temp_file::{temp_file, is_good, get_path, get_stream, create}):
	Define new member functions.
	* tools/abilint.cc (main): Do not use tmpnam anymore.  Use the new
	abigail::tools_utils::temp_file type instead.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-20 10:06:17 +02:00
Dodji Seketeli
1ddde3d9d0 Try to avoid a race condition when abipkgdiff extracts packages.
abipkgdiff extracts the content of the first package in a directory
named <tmpdir>/package1 and the content second package in
<tmpdir>/package2.  If two independant instances of abipkgdiff are
launched at the same time, they are going to walk on each others'
toes, to say the least.

This patch extracts the content of each package in directory named
<tmpdir>/<randomname>/package1, where randomname is supposed to be a
random number, and so should be unique, most of the time.

I guess we should try harder to generate a randomname that is unique
when we see that the directory <tmpdir>/<randomname> exists already,
but for now, what we have is good enough, or at least better than what
we have had so far.

	* include/abg-tools-utils.h (get_random_number)
	(get_random_number_as_string): Declare new functions.
	* src/abg-tools-utils.cc (get_random_number)
	(get_random_number_as_string): Define them.
	* tools/abipkgdiff.cc
	(package::extracted_package_parent_dir_path): New data member.
	(package::package): Initialize
	package::extracted_package_parent_dir_path to
	<tmpdir>/<randomname>, with randomname being a random number
	represented as a string.
	(extract_rpm): Make sure to create a hierarchy of directories, not
	just a directory.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-20 00:02:00 +02:00
Sinny Kumari
b55e516d49 Guess RPM file type
To run abipkgdiff between two pacakges, it should know whether
input files are valid pacakge file or not. This patch detects RPM and SRPM
pacakge file type. abipkgdiff uses it to know whether input files are
valid RPM pacakge file or not.

	* include/abg-tools-utils.h (file_type): Added member
	FILE_TYPE_RPM and FILE_TYPE_SRPM
	(operator<<): New function declaration.
	* src/abg-tools-utils.cc (file_type): Detect RPM and
	SRPM file type
	(operator<<): New function definition
	* tools/abidiff.cc (main): Check for RPM and SRPM
	file type as well.
	* tools/abilint.cci (main): Check for RPM and SRPM file
	type as well.
	* tools/abipkgdiff.cc (main): Check whether input files
	to abipkgdiff are valid RPM files or not.

Signed-off-by: Sinny Kumari <sinny@redhat.com>
2015-07-17 10:07:37 +02:00