Commit Graph

2123 Commits

Author SHA1 Message Date
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
Matthias Maennich
ee3309472a Remove <functional> usages from abg_compat
std::hash is now provided through the language standard, hence remove
the compatibility code for <functional> and adjust all users
accordingly.

	* include/abg-cxx-compat.h: Drop compatibility layer for <functional>.
	* include/abg-interned-str.h: migrate abg_compat use to std.
	* include/abg-ir.h: Likewise.
	* src/abg-hash.cc: Likewise.
	* src/abg-ir.cc: Likewise.

Signed-off-by: Matthias Maennich <maennich@google.com>
2020-12-15 08:51:07 +01:00
Matthias Maennich
47a76acf76 Drop C++03 compatibility layer
Now with C++11 as minimum standard, we can drop the facilities required
to support earlier standards. Hence purge the use of std::tr1 from the
sources.

	* include/abg-cxx-compat.h: remove compatibility with pre C++11.
	* include/abg-ir.h: Remove mention of std::tr1 from comments.
	* include/abg-sptr-utils.h: Likewise.

Signed-off-by: Matthias Maennich <maennich@google.com>
2020-12-15 08:40:10 +01:00
Giuliano Procida
04690d216a Add qualifier / typedef / array / pointer test
This change adds a test which exercises libabigail's handling of
qualified typedefs of arrays. The base type in the test case is an
array of pointers (chosen so we can also use restrict).

Various typedefs and (indirect) qualifications of this type are
created. In all cases, the resulting type should be an array of
qualified pointers.

However, abidiff reports things like

  'const volatile void* const'

changed to

  'restrict const volatile volatile void* const'

I've not attempted to check whether DWARF and ABI XML faithfully
reflect the source types. There may be trouble there as well.

For the record, these are the expected v0 types:

A = void *[7]
B = void *[7]
C = void *const[7]
D = void *const[7]
E = void *const volatile[7]
F = void *const volatile[7]
G = void *const volatile restrict[7]
H = void *const volatile restrict[7]

The v1 types should be these plus others with extra pointer
qualifiers.

	* tests/data/Makefile.am: Add new test files
	* tests/data/test-abidiff-exit/qualifier-typedef-array-v0.c:
	New test file.
	* tests/data/test-abidiff-exit/qualifier-typedef-array-v0.o:
	New test file.
	* tests/data/test-abidiff-exit/qualifier-typedef-array-v1.c:
	New test file.
	* tests/data/test-abidiff-exit/qualifier-typedef-array-v1.o:
	New test file.
	* tests/data/test-abidiff-exit/qualifier-typedef-array-report-0.txt:
	Plain diff report.
	* tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt:
	Harmless diff report.
	* tests/data/test-abidiff-exit/qualifier-typedef-array-report-2.txt:
	Leaf changes report.
	* tests/data/test-abidiff-exit/qualifier-typedef-array-report-3.txt:
	Harmless leaf changes report.
	* tests/test-abidiff-exit.cc: Run new test.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-12-10 10:04:17 +01:00
Giuliano Procida
d068f26701 ir: Arrays are indirect types for type structure similarity purposes
As described in the comments of types_have_similar_structure:

    "Two indirect types have similar structure if their underlying
    types are of the same kind and have the same name. [...] The size
    of their underlying type does not matter"

Yet, the size of array elements (a.k.a the underlying type of an array
type) is wrongly considered to matter when assessing the "type
structure similarity" relationship for arrays.

This patch fixes that.

	* src/abg-ir.cc (types_have_similar_structure): When examining
	array types, always treat element types as being underlying types
	of an indirect type.
	* tests/data/Makefile.am: Add new test case files.
	* tests/data/test-abidiff-exit/test-non-leaf-array-report.txt:
	New test case showing correct --leaf-changes-only reporting.
	* tests/data/test-abidiff-exit/test-non-leaf-array-v0.c:
	Likewise.
	* tests/data/test-abidiff-exit/test-non-leaf-array-v0.o:
	Likewise.
	* tests/data/test-abidiff-exit/test-non-leaf-array-v1.c:
	Likewise.
	* tests/data/test-abidiff-exit/test-non-leaf-array-v1.o:
	Likewise.
	* tests/test-abidiff-exit.cc: Run new test case.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-12-05 11:04:01 +01:00
Dodji Seketeli
38effc902b ir: Add better comments to types_have_similar_structure
* src/abg-ir.cc (types_have_similar_structure): Arrays are also
	indirect types, just like pointers and references, for the purpose
	of the concept of "type similarity".  Add that to the introductory
	comment of the function.  Add some more misc comments throughout
	the code base.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-12-05 11:02:24 +01:00
Giuliano Procida
f10d1fc1dd abidiff: support --dump-diff-tree with --leaf-changes-only
* src/abg-leaf-reporter.cc (leaf_reporter::report): In the
	corpus_diff override, conclude by calling
	maybe_dump_diff_tree.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-12-04 10:01:27 +01:00
Dodji Seketeli
4f8c9b170d Use C++11 for the code base
As the Enterprise Linux 6 platform has now essentially reached it's
end of life for what it's worth (the Fedora EPEL6 distribution is not
maintained anymore) nothing ties us to using C++03 only anymore.

So, I think it makes sense to move the code base to the C++11
standard.

Why C++11 and not, say, C++14 or more?  Well, the more direct reason I
see is that we need to support long life cycle platforms, the older
one being Enterprise Linux 7 currently.  This is the Fedora EPEL7
distribution, in concrete terms.  And in that distribution, the
compiler is GCC 4.8.x.  And it supports C++11.

In practise, nothing changes in the code that is already there.

The new code however can use C++11 constructs just fine.

I have updated the CONTRIBUTING file to write down some of the
unwritten cultural biases of the current code base.  Hopefully these
few lines will help to shed some light on the choices made so far.

The update to that file also enacts the use of C++11 and sets some
limits to what we expects in terms of what the code base would look
like.

configure.ac is modified to unconditionally pass -std=c++11 to the
compiler and express that in the configuration text displayed at the
end of the configuration stage.

Some Makefile.am files are updated accordingly.

	* CONTRIBUTING: Enact use of c++11. Also, we favor those who
	read/debug/maintain the code as opposed to those who write it ;-)
	* configure.ac: Switch to c++11 unconditionally.
	* src/Makefile.am: Adjust.
	* tests/Makefile.am: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-12-03 14:04:23 +01:00
Dodji Seketeli
b56e5aeb40 CONTRIBUTING: Update instructions about regression tests
* CONTRIBUTING: Update instructions about how to launch regression
	tests.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-12-03 14:04:23 +01:00
Dodji Seketeli
b167a7b7d2 Teach Automake that COPYING* files are gone from sources
The COPYING* files are not in the source distribution anymore.
Furthermore, LICENSE.txt and license-change-2020.txt files were newly
added.  This patch updates Makefile.am accordingly.

	* Makefile.am: Teach Automake that COPYING* files are gone and
	that LICENSE.txt and license-change-2020.txt were added.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-12-02 17:42:47 +01:00
Dodji Seketeli
59701daaf8 Add a license-change-2020.txt file
Add a license-change-2020.txt file which contains text explaining that
we went through a licence change in 2020 from LGPLv3+ to Apache-v2
with LLVM exception.

     * license-change-2020.txt: New file.

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 Maennich <maennich@google.com>
Signed-off-by: Matthias Klose <doko@ubuntu.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:50:22 +01:00
Dodji Seketeli
0f78e9a0fa Delete COPYING* files
* COPYING: Delete.
	* COPYING-GPLV3: Likewise.
	* COPYING-LGPLV2: Likewise.
	* COPYING-LGPLV3: 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 Maennich <maennich@google.com>
Signed-off-by: Matthias Klose <doko@ubuntu.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:59 +01:00
Dodji Seketeli
3e18713f44 Add the LICENSE.txt file
* LICENSE.txt: New file coming from
	http://llvm.org/foundation/relicensing/LICENSE.txt.

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

This is what this patch does.

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

Signed-off-by: Benjamin De Kosnik <bkoz@gnu.org>
Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Matthias Klose <doko@ubuntu.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Roland McGrath <roland@hack.frob.com>
Signed-off-by: Sinny Kumari <ksinny@gmail.com>
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
2020-12-02 11:49:13 +01:00
Dodji Seketeli
fb5749b5ee Add helper files to perform the re-licensing
* relicensing-scripts/file-licenses.orig.txt: New file that
	contains the raw set of files with SPDX identifiers denoting
	LGPLv3+ files.  It's the result of a simple command based on
	"find" and "grep".
	* relicensing-scripts/files-with-lgplv3.txt: New file
	containing the same data as the file above, but massaged to be
	easily useable by the script below.
	* relicensing-scripts/do-relicensing.sh: This is a simple command
	which performs the re-licensing on the files listed in the file
	above.

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 Maennich <maennich@google.com>
Signed-off-by: Matthias Klose <doko@ubuntu.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:48:52 +01:00
Dodji Seketeli
964bf04158 Add replace-spdx-license.sh script
This script is to replace an SPDX license ID by another one.
I.e, it's to perform an actual re-licensing of a given file.

A way to use the script is this:

    replace-spdx-license.sh  --from LGPL-3.0-or-later \
			      --to  "Apache-2.0 WITH LLVM-exception" \
			      some-file-to-relicense.cc

	* relicensing-scripts/replace-spdx-license.sh: New script.

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:48:33 +01:00
Dodji Seketeli
418ea85baf Add has-spdx-header.sh script
Add a script to detect if a file has a SPDX header and what the
advertised license is.

	   * relicensing-scripts/has-spdx-header.sh: New script.

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:45:10 +01:00
Dodji Seketeli
be6bf58308 Add missing SPDX headers to source files not specifying any license
Default to the project's defautl - LGPLv3+ - for those.

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

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

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

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

Signed-off-by: Benjamin De Kosnik <bkoz@gnu.org>
Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Matthias Klose <doko@ubuntu.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Roland McGrath <roland@hack.frob.com>
Signed-off-by: Sinny Kumari <ksinny@gmail.com>
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
2020-12-02 11:44:13 +01:00
Dodji Seketeli
2313dd1d4a Bump version number to 2.0
* configure.ac: Bump number version to 2.0

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-12-01 21:42:08 +01:00
Dodji Seketeli
d3d0eee0df Update NEWS file for 1.8
* NEWS: Update for 1.8

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-12-01 15:19:12 +01:00
Dodji Seketeli
cee237e25e Update the Changelog for 1.8
* Changelog: Update automatically with "make update-changelog'

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-12-01 15:13:57 +01:00
Dodji Seketeli
a93aaec86e Add check-self-compare to release regression testing
* Makefile.am: Make 'make tarball-and-all' run the
	'check-self-compare' target as part of the release process.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-12-01 15:11:50 +01:00
Dodji Seketeli
e1a1fd9e1a configure: add --enable-rpm415 option
It's useful to be able to force the build system into avoiding the use
of rpm 4.15 version or higher.  That version of RPM is the one that
supports RPMs from Fedora 31 or higher.  Those RPMs use the zstd
compression scheme.  Prior to Fedora 31, RPM were not using the zstd
compression scheme.  So, systems with rpm version lower than 4.15
cannot deal with RPMs coming from Fedora 31 or higher.  So on those
systems, some regression tests of libabigail who use RPMs from Fedora
33 will fail.

With this patch, one can use the --disable-rpm415 option of the
configure script to prevent those tests from running on those pre 4.15
rpm systems.

	* configure: Introduce the --{en, dis}able-rpm415 option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-12-01 11:26:27 +01:00
Dodji Seketeli
2417efb2b7 dwarf-reader: Bug 26908 - don't crash on empty DW_TAG_partial_unit
Sometimes a DW_TAG_partial_unit (imported via a DW_TAG_imported_unit)
has no children node.  That means the the DW_TAG_partial_unit has no
sub-tree.

In those cases, the dwarf-reader crashes when
ctxt.build_die_parent_relations_under tries to record the point at
which the sub-tree (which is non-existent here) of the partial unit is
imported by the DW_TAG_imported_unit DIE.

This patch avoids crashing in those cases.  As this problem is
reported on libclang-cpp.so (on Fedora 33) which takes "abidw --abidiff"
five hours and ~ 20GB of ram to complete at this point (on a power7 box)
this patch doesn't have a regression test attached.

	* src/abg-dwarf-reader.cc (die_has_children): Define new static
	function.
	(read_context::build_die_parent_relations_under): Do not try to
	instantiate an imported_unit_point type for an imported unit with
	no children node.
	(imported_unit_point::imported_unit_point): Assert that the
	imported die has a sub-tree.
	(imported_unit_point::imported_unit_point): Remove useless spaces.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-30 06:58:37 +01:00
Dodji Seketeli
264c8338cc reader: Fix off-by-one error in assert
* src/abg-reader.cc (build_subrange_type): Fix off-by-one error.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-27 21:11:59 +01:00
Dodji Seketeli
bbdf7e0f29 writer: fix off-by-one error in assertion
* src/abg-writer.cc (write_array_subrange_type): Fix off-by-one
	error in assertion.
	* src/abg-dwarf-reader.cc (build_subrange_type): Assert the length
	of the array complies with its bounds.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-27 20:51:45 +01:00
Dodji Seketeli
0a5f056393 abipkgdiff: make --self-check to fail on any change against own ABIXML
Now that several subtle causes of spurious ABI change report when
comparing a binary against its own ABIXML have been addressed, this
patch makes 'abipkgdiff --self-check' to fail on any ABI change
reported.  That is, harmless changes are not ignored anymore.

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

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

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

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

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-27 16:57:44 +01:00
Dodji Seketeli
95c53c89f3 dwarf-reader: Avoid having several functions with the same symbol
In the DWARF debug info, a C++ class can be represented by pieces
throughout a given binary.

In this picture, a given virtual member function can be represented
several times; each time in one different piece of the C++ class.  In
a given piece of the class, a virtual member function can be
represented with its ELF symbol set.  In another one, the same virtual
member function can be represented without that ELF symbol set.  And
there can also be pieces of the class that don't have a given virtual
function.

To handle this, the DWARF reader constructs one class from all its
pieces scattered around.  It adds each virtual member function to the
class as it comes across them while scanning the DWARF.

Then there is a pass at the end of the process that sets ELF symbols
to the (virtual) member functions that need it.

The problem with that pass is that it sometimes sets the same ELF
symbol to more than one virtual member function.  Those virtual member
functions all have the same mangled name that correspond to the ELF
symbol; but only one of them is meant to be associated with the ELF
symbol.  In essence, that one is the one that is exported by the ELF
binary.

This patch teaches the pass that sets the ELF symbols of function to
avoid setting the same ELF symbol to more than one function.

The patch also avoids build_function_decl to set symbol to a function
if that symbol was already set to an existing function.

This patch thus fixes a class of issues what arise when comparing a
binary against its own ABIXML representation.  Those several functions
having the same ELF symbol would cause spurious changes in that
context.

	* src/abg-dwarf-reader.cc
	(read_context::symbol_already_belongs_to_a_function): Define new
	member function.
	(read_context::fixup_functions_with_no_symbols): Use the new
	symbol_already_belongs_to_a_function function to avoid setting a
	symbol that already belongs to a function.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Adjust.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-27 16:56:25 +01:00
Dodji Seketeli
5ae7de0cb6 reader: Don't lose anonymous-ness of decl-only classes
When reading an anonymous declaration-only class from ABIXML
libabigail forgets to set the is-anonymous class.  This leads to
spurious change reports when comparing a binary against its ABIXML
representation.  Fixed thus.

Note that this doesn't yet impact any regression test but is useful
for a coming patch that will make abidw --abidiff to emit an error for
all ABI changes, not just the hard incompatible ones.  Without this
change, that coming patch will make runtestreaddwarf to fail.

	* src/abg-reader.cc (build_class_decl): Set the is-anonymous flag
	when reading a decl-only class.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-27 13:53:16 +01:00
Dodji Seketeli
a07fce3669 ir: Introduce internal pretty representation for anonymous classes
There are two views for internal pretty representation of anonymous
classes.

1/ When we look at the anonymous class itself, we use its 'flat
representation' i.e:

    'class {int blah; char bleh;}'

2/ When we look at a pointer or a reference to the anonymous class we
use its generic anonymous internal name, i.e:

   '__anonymous_struct__*'

As a general rule, libabigail always use the keyword 'class' to prefix
the name of classes for internal purposes, independent from the fact
that the type is a struct or a class.  That is a pre-requisite to be
able to canonicalize classes and structs together.  In other words, if
a class and a struct are structurally equal, they are going to be
considered equivalent by the canonicalization process.

Currently however, in the view 1/ of the pretty representation of
anonymous classes, a struct and a class will have different
representations.  For instance, and empty anonymous struct would be
represented as 'struct {}', whereas an empty anonymous class would be
represented as 'class {}'.  This prevents these two be considered
equivalent by the canonicalization process.  This leads to spurious
change reports later down the road.

In the view 2/ we have a similar but different problem: the qualified
names of the anonymous classes are not taken into account when
representing pointer or references to said anonymous classes.  Only
their unqualified generic anonymous internal names are taken into
account in the representation.  This leads to pointers/references to
anonymous classes being wrongly considered equivalent even when they
belong to different namespaces.

This patch corrects the issues related to both views 1/ and 2/.  It
should make libabigail correctly consider some anonymous classes as
equivalent (view 1) and correctly consider pointers/references to
anonymous classes as different when they belong to different
namespaces (view 2).

A number of reference tests are adjusted accordingly.

	* include/abg-fwd.h (get_class_or_union_flat_representation):
	Introduce an "internal" parameter.
	* src/abg-ir.cc (get_class_or_union_flat_representation):
	Introduce an "internal" parameter.  In the flat representation of
	a class for internal purposes, always use the prefix "class" even
	if this is a struct.
	(get_type_name): To build an internal name for a
	reference or pointer to an anonymous type, consider the namespace
	name of said type.
	(equals): In the overload for decl_base, take the namespace name
	of anonymous decls into account when comparing them.
	({var_decl, union_decl}::get_pretty_representation): Adjust calls
	to get_class_or_union_flat_representation to pass a proper
	"internal" argument.
	* src/abg-default-reporter.cc (default_reporter::report): Adjust
	the call to get_class_or_union_flat_representation to pass an
	"internal" argument set to 'false'.
	* tests/data/test-annotate/libtest23.so.abi: Adjust.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/libtest23.so.abi: Likewise.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-27 13:53:15 +01:00
Dodji Seketeli
35162bd4e3 writer: Emit definitions of declarations when they are present
Libabigail goes a long way to resolve declaration-only classes
to their definitions when it's possible.

The ABIXML writer however sometimes forgets to emit the definition of
such declarations that have been "resolved".

Later, when the binary is compared to its own ABIXML representation,
the reporting engine thus reports that the definition is lost.

This patch fixes that.

	* src/abg-writer.cc (write_class_decl, write_union_decl): Get the
	definition of the declaration if it exists and emit that.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Adjust.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
	* tests/data/test-annotate/test13-pr18894.so.abi: Likewise.
	* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-27 13:53:15 +01:00
Dodji Seketeli
b553802af8 Bug 26780 - Fix array subrange bounds (de)serialization
When serializing subrange bounds to ABIXML today the writer omits the
lower and upper bounds.  Only the length is emitted.  The reader thus
assumes that the lower bound of an array subrange is always 0.  In
Fortran however, that is not true, as the lower bound is 1.

This patch instructs the writer to emits the lower bound whenever it's
different from zero.  It also emits the upper bound in that case.  The
reader is updated accordingly to take the lower and upper bounds into
account whenever they are present.  It they are not, then the
lower bound is assumed to be zero and the upper bound is deduced from
the length, as was already the case until now.

	* src/abg-reader.cc (build_subrange_type): Read lower-bound
	attribute if present.  Then try to read upper-bound attribute as
	well.  If this is not an infinite subrange assert that the length
	must be equal to the difference between the bounds.
	* src/abg-writer.cc (write_array_subrange_type): Write the
	lower-bound if it's present and not zero.  In that case, write the
	upper-bound as well.
	* tests/data/test-diff-pkg/hdf5-1.10.6-2.fc33.x86_64.rpm: Add new
	binary test input.
	* tests/data/test-diff-pkg/hdf5-debuginfo-1.10.6-2.fc33.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/hdf5-1.10.6-2.fc33.x86_64.self-check-report-0.txt:
	Add new reference output.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Add the binary test input
	to the set of --self-check tests.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-27 13:50:47 +01:00
Dodji Seketeli
7d5ef25b9c reader: Read array subrange length into an uint64_t
We read subrange length like an integer of type 'int" today.  We
should read it as an uint64_t.  Fixed thus.

	* src/abg-reader.cc (build_subrange_type): Change the type of
	length to uint64_t and read it using strtoull.

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

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

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-25 13:17:21 +01:00
Dodji Seketeli
33223963bd tests/data/test-fedabipkgdiff: Update reference output
Instances of self_compare_task don't wrongly shadow task comparison
arguments anymore.  Instead, they properly use the task comparison
arguments of the parent class compare_task.

So in the sorting function elf_size_is_greater, we now always have
proper elf binaries size.  It follows that the sorting can now yield a
consistent result, always.

It thus appears that the reference output recorded for the
"self-comparison" test of runtestfedabipkgdiffpy3.sh was wrong.  This
patch updates it.

	* tests/data/test-fedabipkgdiff/test7-self-compare-from-fc23-dbus-glib-report-0.txt:
	Adjust.

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

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

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

Signed-off-by: Matthias Maennich <maennich@google.com>
2020-11-25 09:08:03 +01:00
Dodji Seketeli
c2ce1a38c6 dwarf-reader: support artificially generated translation units
When GCC 10 artificially generates a translation unit, the path/name
of the translation unit as given by the DW_AT_name attribute of the
translation unit DIE is the string "<artificial>".

Libabigail expects that translation units have unique file paths so
having several artificially generated translation units like this one
with the same name makes hell break loose down the road.

This patch suffixes the name of artificial DIE with their die offset
number to have a unique path name for artificially generated
translation units.

	* configure.ac: Detect if we are running on RPM >= 4.15.  If yes,
	then define the preprocessor macro RPM_4_15.  If that macro is
	defined then test-diff-pkg.cc can support RPMs from Fedora >= 31
	as those are compressed with zstd.  Earlier RPM versions don't
	support that compression scheme.
	* src/abg-dwarf-reader.cc (build_translation_unit_and_add_to_ir):
	Suffix the offset of the translation unit to its name when that
	name is "<artificial>".
	* tests/data/test-diff-pkg/mesa-libGLU-9.0.1-3.fc33.x86_64.rpm:
	New binary test input.
	* tests/data/test-diff-pkg/mesa-libGLU-debuginfo-9.0.1-3.fc33.x86_64.rpm: Likewise.
	* tests/data/test-diff-pkg/mesa-libGLU-9.0.1-3.fc33.x86_64.self-check-report-0.txt:
	New reference output for the binary test input above.
	* tests/data/Makefile.am: Add the new test inputs above to source
	distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Add the binary test
	inputs above to source distribution if we are running on an RPM
	version >= 4.15.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-24 05:04:06 +01:00
Dodji Seketeli
ddead98a51 fedabipkgdiff: make --self-compare use abipkgdiff --self-check
Now that the abipkgdiff program supports the --self-check option to
make it compare the binaries in an RPM against their own ABIXML
representation, make the --self-compare option of fedabipkgdiff use
the abipkgdiff --self-check.

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

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

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

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

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

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

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

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

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-23 17:50:05 +01:00
Dodji Seketeli
cac59a176a Bug 26769 - Fix missing types in abixml output
The symptom of the issue at hand is that sometimes there can be types
missing from the abixml output.  This happens when analysing some C++
code bases.

The core of the issue is the following.  Support we have a type
"struct S" defined somewhere as:

    struct S // #0
    {
      int  dm1;
      char dm2;
    };

    S s;

Suppose that in another translation unit, we have the class 'S' being
extended to add a member type to it:

    struct S // #1
    {
      typedef int dm1_type;
    };

    typedef S::dm1_type Integer;
    Integer something;

When emitting the abixml for the codebase, the definition of the
typedef S::dm1_type can be missing.

Note that in location #1, struct S is considered declaration-only.
It's definition is in another translation unit, in location #0.

So the abixml writer emits the 'struct S' defined in location #0, but
forgets to emit the 'struct S' in #1, which is indirectly used for the
sole purpose of using its member type S::dm1_type.

This patch emits the S::dm1_type type that is mistakenly forgotten
today.

Now that the "struct S" of #1 is also emitted, a tangent problem is
uncovered: S in #0 can be wrongly thought to be equivalent to S in #1,
for ABI purposes
This is because of an ODR-based optimization that is used for C++.
That is, the two struct S can be wrongly considered equivalent just
because they have the same name.  Note that ODR means "One Definition Rule[1]"

This patch removes the ODR-based optimization and thus fixes many of
the issues uncovered by the previous changes.

The patch also uncovered that some non-static variables were sometimes wrongly
being added to the set of exported variables, while libabigail reads
corpora from abixml.  The patch fixes this as well.

[1]: One Definition Rule: https://en.wikipedia.org/wiki/One_Definition_Rule

	* include/abg-corpus.h (corpus::{record_canonical_type,
	lookup_canonical_type}): Remove function declarations.
	* src/abg-corpus-priv.h (corpus::priv::canonical_types_): Remove
	data member.
	* src/abg-corpus.cc (corpus::{record_canonical_type,
	lookup_canonical_type}): Remove functions.
	* src/abg-ir.cc (type_eligible_for_odr_based_comparison): Remove
	static function.
	(type_base::get_canonical_type_for): Don't perform the ODR-based
	optimization for C++ anymore.
	* src/abg-reader.cc
	(read_context&::maybe_add_var_to_exported_decls): Don't add a
	variable that hasn't been added to its scope.  Otherwise, it means
	we added a variable that wasn't yet properly constructed.  Also
	add a new overload for var_decl_sptr&.
	(build_var_decl): Do not add the var to its the set of exported
	declaration before we are sure it has been fully constructed and
	added to the scope it belongs.
	(build_class_decl): Only add *static* data members to the list of
	exported declarations.
	(handle_var_decl): A var decl seen here is a global variable
	declaration.  Add it to the list of exported declarations.
	* src/abg-writer.cc (write_context::decl_only_type_is_emitted):
	Constify parameter.
	(write_translation_unit): Do not forget to emit referenced types
	that were maybe not canonicalized.  Also, avoid using noop_deleter
	when it's not necessary.
	(write_namespace_decl): Do not forget to emit canonicalized types
	that are present in namespaces other than the global namespace.
	* tests/runtestslowselfcompare.sh.in: New test that compares
	libabigail.so against its own ABIXML representation.
	* tests/Makefile.am: Add the new test runtestslowselfcompare.sh to
	source distribution.  This test is too slow to be run during the
	course of 'make check'.  It takes more than 5 minutes on my slow
	box here.  Rather, it can be run using 'make check-self-compare'.
	I plan to run this before releases now.
	* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Adjust.
	* tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-annotate/test0.abi: Likewise.
	* tests/data/test-annotate/test13-pr18894.so.abi: Likewise.
	* tests/data/test-annotate/test14-pr18893.so.abi: Likewise.
	* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
	* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
	* tests/data/test-read-dwarf/test0.abi: Likewise.
	* tests/data/test-read-dwarf/test0.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
	* tests/data/test-read-write/test28-without-std-fns-ref.xml:
	Likewise.
	* tests/data/test-read-write/test28-without-std-vars-ref.xml:
	Likewise.
	* tests/data/test-read-write/test6.xml: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-23 13:02:34 +01:00
Dodji Seketeli
de5de7b447 Make sure to canonicalize all types but decl-only classes
While looking at the remaining potential sources of instability in the
generation of type ids at abixml generation time, it occurred to me
that we still had several non canonicalized types in the system.

When a given type T is not canonicalized,
hash_as_canonical_type_or_constant later hashes it as an arbitrary
constant.  So in the ID hash map of the abixml writer, all the
non-canonicalized types will tend to end-up in the same hash map
bucket, so to speak.  More precisely, if T is equivalent to another
type T' which is canonicalized, then T and T' will end-up in different
buckets (in the same hash map) because they will have different hash
values as returned by hash_as_canonical_type_or_constant.  They will
thus end-up having different type-ids because they are in different
buckets.

The solution is to make sure that T is *also* canonicalized.  That
way, if T and T' are equivalent, they'll end-up in the same bucket and
they will have the same type-id.

In other words, all types should be canonicalized now.

The only exception to that rule is declaration-only classes and
unions.  The reason why a declaration-only type 'struct foo' needs to
stay non-canonicalized is that it must equal all the definitions of
'struct foo' that can be found elsewhere.

This patch thus canonicalizes all types that were not still not being
canonicalized.  It also adds an assert in
hash_as_canonical_type_or_constant to ensure that only
declaration-only class_or_union types are not canonicalized.

	* include/abg-fwd.h (is_declaration_only_class_or_union_type):
	Declare new ...
	* src/abg-ir.cc (is_declaration_only_class_or_union_type):
	... function.
	(clone_array): Add the cloned array subrange to
	its scope so that it can later be canonicalized.
	(synthesize_type_from_translation_unit)
	(synthesize_function_type_from_translation_unit): Canonicalize the
	synthesized types.
	(hash_as_canonical_type_or_constant): Ensure that all types are
	canonicalized.
	* src/abg-dwarf-reader.cc (maybe_canonicalize_type): Remove
	useless overload.
	(build_ir_node_for_variadic_parameter_type)
	(schedule_array_tree_for_late_canonicalization): Define new static
	functions.
	(maybe_strip_qualification): Schedule type canonicalization for
	types cloned prior to editing.
	(build_function_type): Use the new
	build_ir_node_for_variadic_parameter_type.  It takes care of
	canonicalizing variadic parameter types.
	(build_function_decl): Canonicalize the function type that is
	created here.
	(build_ir_node_from_die): Use the overload of
	maybe_canonicalize_type which canonicalizes class_or_union nodes
	directly, rather than the one which handles DIE offsets.  The
	latter was used as an optimization to reduce the size of the array
	of types scheduled for canonicalization, as DIE offsets take less
	space than pointers to IR types.  Now that we have DIE
	de-duplication, my bet is that we can do away with the former.
	And that also ensures that we miss no type for canonicalization
	purposes.
	* src/abg-reader.cc (build_array_type_def): Canonicalize the
	subrange types of the array.
	(build_type): Canonicalize all types.
	* tests/data/test-annotate/libtest23.so.abi: Adjust.
	* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Likewise.
	* tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-annotate/test0.abi: Likewise.
	* tests/data/test-annotate/test13-pr18894.so.abi: Likewise.
	* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
	* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt:
	Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt:
	Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report2.txt:
	Likewise.
	* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt:
	Likewise.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi:
	Likewise.
	* tests/data/test-read-dwarf/libtest23.so.abi: Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
	* tests/data/test-read-dwarf/test0.abi: Likewise.
	* tests/data/test-read-dwarf/test0.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-16 09:16:09 +01:00
Dodji Seketeli
90eff56227 ir: Add equality op to array_type_def::subrange_type::bound_value
* include/abg-ir.h
	(array_type_def::subrange_type::bound_value::operator==): Declare
	new ...
	* src/abg-ir.cc
	(array_type_def::subrange_type::bound_value::operator==):
	... equality operator.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-13 09:19:40 +01:00
Dodji Seketeli
2cc1ab7ee8 writer: Sort decls and fix topological sorting for types
When emitting the declarations of a given translation unit, those
declarations are not sorted.  Ooops.  This patch adds topological
sorting for those declarations, making the decls defined first to be
emitted first.  When the decls are defined at the same location then
the pretty representation is used for lexicographic sorting instead.

It turns out that during the topological sorting for types there was
some uncertainty when the declarations of the types had the same
definition location.  This patch re-uses the declaration sorting above
for the declarations of these types.

	* include/abg-ir.h (scope_decl::get_sorted_member_decls): Declare
	new member function.
	* src/abg-ir.cc (struct decl_topo_comp): New sorting functor.
	(type_topo_comp::operator()): Re-use the decl_topo_comp to sort
	type declarations.
	(scope_decl::priv::sorted_members_): Add new data member.
	(scope_decl::get_sorted_member_decls): Define new member function.
	* src/abg-writer.cc (write_translation_unit): Use the new
	scope_decl::get_sorted_member_decls.
	* tests/data/test-annotate/libtest23.so.abi: Adjust.
	* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
	* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/libtest23.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.
	* tests/data/test-read-write/test2.xml: Likewise.
	* tests/data/test-read-write/test28-without-std-fns-ref.xml:
	Likewise.
	* tests/data/test-read-write/test28-without-std-vars-ref.xml:
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-12 16:37:30 +01:00
Dodji Seketeli
3c87247cb4 Bug PR26739 - Handle qualified typedef array types
CV-qualifiers of a typedef of an array type apply to the elements of
the array.  So this can be transformed into a typedef of array type
which element type is similarly CV-qualified.

That transformation helps avoiding spurious changes that might occur
when comparing the latter form against the former even though both are
equivalent.

This patch performs that transformation, just like we already do for
CV-qualified array types which are transformed into an array of
similarly CV-qualified elements.

Performing that transformation amounts to editing the type of the
array elements.  As those types might be used by other parts of the
type graph (type node sharing), the patch "clones" the type sub-tree
of interest and edits the cloned version.  That way, the shared type
nodes are not edited.  It appears that in the existing version of
maybe_strip_qualification, the transformation of CV-qualified arrays
into arrays of CV-qualified elements was unfortunately editing shared
type nodes.  The patch fixes that and re-works the logic of*
maybe_strip_qualification to make it handle this new case and the
previous one in a somewhat generic manner.

	* include/abg-fwd.h (is_typedef_of_array, clone_array)
	(clone_typedef, clone_qualified_type, clone_array_tree): Declare
	new functions.
	(peel_qualified_or_typedef_type): Declare new overload.
	(is_array_of_qualified_element): Constify the parameter.
	* include/abg-ir.h ({qualified_type,
	typedef}_def::set_underlying_type): Add new member functions.
	(array_type_def::subrange_type::subrange_type): Make constify the
	reference to the underlying type parameter.
	* src/abg-ir.cc (is_array_of_qualified_element): Constify the
	parameter.
	(peel_qualified_or_typedef_type): Define new
	overload for type_base_sptr.
	(clone_typedef_array_qualified_type): Define static function.
	(clone_array clone_typedef, clone_qualified_type)
	(clone_array_tree, is_typedef_of_array): Define new functions.
	(qualified_type_def::get_underlying_type): Rename the return type
	shared_ptr<type_base> into type_base_sptr.
	({typedef, qualified_type}_def::set_underlying_type): Define new
	member function.
	(array_type_def::subrange_type::priv::priv): Initialize the
	'infinite_' data member.
	* src/abg-dwarf-reader.cc (maybe_strip_qualification): Handle
	qualified typedef of arrays.  Merge this with the handling of
	qualified arrays.  Note that before editing the elements of the
	array to make the array (or typedef) qualifier apply to the
	element the sub-tree is cloned to make its type nodes be
	'un-shared'.  This prevents us from editing type nodes that are
	shared by other type expressions.
	* tests/data/test-diff-filter/test-PR26739-report-0.txt: New
	reference test output.
	* tests/data/test-diff-filter/test-PR26739-2-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test-PR26739-v{0,1}.c: Source code
	of new binary test input.
	* tests/data/test-diff-filter/test-PR26739-2-v{0,1}.c: Likewise.
	* tests/data/test-diff-filter/test-PR26739-v{0,1}.o: New binary
	test inputs.
	* tests/data/test-diff-filter/test-PR26739-2-v{0,1}.o: Likewise.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-diff-filter.cc (in_out_specs): Add the test inputs
	above to this harness.
	* tests/data/test-annotate/test15-pr18892.so.abi: Adjust.
	* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-12 10:53:40 +01:00
Dodji Seketeli
baee817d3e Update test-libandroid.so.abi
Update this test reference output as per the commit below:

  b7ad7f2b Bug 26770 - Spurious declaration-only-ness induces spurious type changes

	* tests/data/test-read-dwarf/test-libandroid.so.abi: Update.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-03 08:47:26 +01:00
Matthias Maennich
38e72b262d dwarf-reader: Ignore zero length location expressions from DW_AT_location
Location expressions might occasionally be of length 0. E.g. a reason
for that are thread local variables that do not exactly have a
location to refer to. Compilers/Linkers may choose an empty location
description. E.g.  see the dwarfdump output for the added testcase
based on libandroid.so (from AOSP).

$ dwarfdump libandroid.so|egrep -B9 "gChoreographerE$"

LOCAL_SYMBOLS:
< 1><0x00000022> DW_TAG_namespace
                   DW_AT_name           android
< 2><0x00000027>   DW_TAG_variable
                     DW_AT_name           gChoreographer
                     DW_AT_type           <0x00000b65>
                     DW_AT_decl_file      0x00000003 .../choreographer.cpp
                     DW_AT_decl_line      0x00000059
                     DW_AT_location       len 0x0000: :
                     DW_AT_linkage_name   _ZN7androidL14gChoreographerE

The DW_AT_location is properly read by elfutils' dwarf_location(), but
is not useful for us to proceed with. Hence early exit on this.

	* src/abg-dwarf-reader.cc (die_location_expr): Ignore zero
	  length location expressions.
	* tests/data/Makefile.am: Add new test files.
	* tests/data/test-read-dwarf/test-libandroid.so: New test file.
	* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
	* tests/test-read-dwarf.cc: Add new test case.

Reported-by: Dan Albert <danalbert@google.com>
Reviewed-by: Giuliano Procida <gprocida@google.com>
Cc: Mark Wielaard <mark@klomp.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-02 18:07:01 +01:00
Giuliano Procida
8a0825e319 Improve enum synthetic type names
The ordering of canonical types (in an abi-instr XML element) appears
to be sensitive to the particular C++ library used and the presence of
other threads doing heap allocation. This patch forces distinct
synthetic enum-underlying types to have distinct names, which ensures
deterministic XML output order.

	* src/abg-dwarf-reader.cc
	(build_internal_underlying_enum_type_name): Add a size
	argument (and don't default is_anonymous argument). Append
	size of type to synthetic type name.
	(build_enum_underlying_type): Pass type size to
	build_internal_underlying_enum_type_name.
	* tests/data/test-abidiff-exit/test-decl-enum-report-3.txt:
	Update. Note that there may be an issue with leaf-mode
	reporting of pointer type changes.
	* tests/data/test-diff-dwarf-abixml/PR25409-librte_bus_dpaa.so.20.0.abi:
	Regenerate this (catching up with various abidw updates).
	* tests/data/test-annotate/test-anonymous-members-0.o.abi:
	Refresh with new type names.
	* tests/data/test-annotate/test0.abi: Likewise.
	* tests/data/test-annotate/test13-pr18894.so.abi: Likewise.
	* tests/data/test-annotate/test14-pr18893.so.abi: Likewise.
	* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
	* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise.
	* tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi:
	Likewise.
	* tests/data/test-read-dwarf/test0.abi: Likewise.
	* tests/data/test-read-dwarf/test0.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
2020-11-02 17:37:42 +01:00
Giuliano Procida
32343f8091 Improve and stabilise sort of member functions
The functor virtual_member_function_less_than did not take into
account linkage name which can be the only difference when multiple
destructors with differing mangled names are present.

This change adds a check for linkage names and also flattens the
control flow in the comparison method to make the logic clearer.

Lastly, this change also uses std::stable_sort, in case all that
remains is insertion order.

	* src/abg-ir.cc
	(virtual_member_function_less_than::operator()): Name
	temporaries like offsets and symbols to reduce repetition;
	test each pair of elements (including symbol presence) and
	return immediately if there's a difference; add a comparison
	of linkage name just after comparing symbol names.
	(sort_virtual_member_functions): Use stable_sort instead of
	sort.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
	Update with new ordering of member functions.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
2020-11-02 16:27:33 +01:00