mirror of
git://sourceware.org/git/libabigail.git
synced 2025-02-08 17:47:13 +00:00
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>
243 lines
7.4 KiB
Makefile
243 lines
7.4 KiB
Makefile
SUBDIRS = data
|
|
|
|
ZIP_ARCHIVE_TESTS =
|
|
if ENABLE_ZIP_ARCHIVE
|
|
ZIP_ARCHIVE_TESTS += runtestwritereadarchive
|
|
if ENABLE_CXX11
|
|
ZIP_ARCHIVE_TESTS += runtestdot
|
|
endif
|
|
endif
|
|
|
|
AM_CXXFLAGS = $(VISIBILITY_FLAGS)
|
|
|
|
CXX11_TESTS =
|
|
if ENABLE_CXX11
|
|
CXX11_TESTS += runtestsvg
|
|
endif
|
|
|
|
FEDABIPKGDIFF_TEST =
|
|
if ENABLE_FEDABIPKGDIFF
|
|
if ENABLE_RUNNING_TESTS_WITH_PY3
|
|
FEDABIPKGDIFF_TEST += runtestfedabipkgdiffpy3.sh
|
|
else
|
|
FEDABIPKGDIFF_TEST += runtestfedabipkgdiff.py
|
|
endif
|
|
endif
|
|
|
|
RUN_TEST_SLOW_SELF_COMPARE=runtestslowselfcompare.sh
|
|
|
|
# rather expensive tests (keep in this order), > 1s runtime
|
|
TESTS= \
|
|
$(RUN_TEST_SLOW_SELF_COMPARE) \
|
|
runtestdiffsuppr \
|
|
runtesttypesstability \
|
|
runtestdiffpkg \
|
|
runtestannotate \
|
|
runtestdifffilter \
|
|
runtestreaddwarf \
|
|
runtestcanonicalizetypes.sh
|
|
|
|
# rather cheap tests
|
|
TESTS+= \
|
|
runtestabicompat \
|
|
runtestabidiff \
|
|
runtestabidiffexit \
|
|
runtestaltdwarf \
|
|
runtestcorediff \
|
|
runtestcxxcompat \
|
|
runtestdiffdwarf \
|
|
runtestdiffdwarfabixml \
|
|
runtestelfhelpers \
|
|
runtestini \
|
|
runtestkmiwhitelist \
|
|
runtestlookupsyms \
|
|
runtestreadwrite \
|
|
runtestsymtab \
|
|
runtesttoolsutils \
|
|
$(FEDABIPKGDIFF_TEST) \
|
|
$(ZIP_ARCHIVE_TESTS) \
|
|
$(CXX11_TESTS)
|
|
|
|
if ENABLE_RUNNING_TESTS_WITH_PY3
|
|
TESTS += runtestdefaultsupprspy3.sh
|
|
else
|
|
TESTS += runtestdefaultsupprs.py
|
|
endif
|
|
|
|
EXTRA_DIST = \
|
|
runtestcanonicalizetypes.sh.in \
|
|
runtestfedabipkgdiff.py.in \
|
|
runtestslowselfcompare.sh.in \
|
|
mockfedabipkgdiff.in \
|
|
test-valgrind-suppressions.supp
|
|
|
|
if ENABLE_RUNNING_TESTS_WITH_PY3
|
|
EXTRA_DIST += \
|
|
runtestfedabipkgdiffpy3.sh.in \
|
|
runtestdefaultsupprspy3.sh.in
|
|
endif
|
|
|
|
CLEANFILES = \
|
|
runtestcanonicalizetypes.output.txt \
|
|
runtestcanonicalizetypes.output.final.txt
|
|
|
|
noinst_PROGRAMS= $(TESTS) testirwalker testdiff2 printdifftree
|
|
noinst_SCRIPTS = mockfedabipkgdiff
|
|
noinst_LTLIBRARIES = libtestutils.la libcatch.la
|
|
|
|
libtestutils_la_SOURCES= \
|
|
test-utils.h \
|
|
test-utils.cc
|
|
|
|
libtestutils_la_CXXFLAGS= \
|
|
-DABIGAIL_SRC_DIR=\"${abs_top_srcdir}\" \
|
|
-DABIGAIL_BUILD_DIR=\"${abs_top_builddir}\"
|
|
|
|
libcatch_la_SOURCES = lib/catch.cc lib/catch.hpp
|
|
|
|
runtestreadwrite_SOURCES=test-read-write.cc
|
|
runtestreadwrite_LDADD=libtestutils.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtestwritereadarchive_SOURCES=test-write-read-archive.cc
|
|
runtestwritereadarchive_LDADD= libtestutils.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtestreaddwarf_SOURCES=test-read-dwarf.cc
|
|
runtestreaddwarf_LDADD=libtestutils.la $(top_builddir)/src/libabigail.la
|
|
runtestreaddwarf_LDFLAGS=-pthread
|
|
|
|
runtestannotate_SOURCES=test-annotate.cc
|
|
runtestannotate_LDADD=libtestutils.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtestlookupsyms_SOURCES=test-lookup-syms.cc
|
|
runtestlookupsyms_LDADD=libtestutils.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtestaltdwarf_SOURCES=test-alt-dwarf-file.cc
|
|
runtestaltdwarf_LDADD=libtestutils.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtestcorediff_SOURCES=test-core-diff.cc
|
|
runtestcorediff_LDADD=libtestutils.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtestabidiff_SOURCES = test-abidiff.cc
|
|
runtestabidiff_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtestabidiffexit_SOURCES = test-abidiff-exit.cc
|
|
runtestabidiffexit_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtestdiffdwarf_SOURCES = test-diff-dwarf.cc
|
|
runtestdiffdwarf_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtestdifffilter_SOURCES = test-diff-filter.cc
|
|
runtestdifffilter_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtestdiffsuppr_SOURCES = test-diff-suppr.cc
|
|
runtestdiffsuppr_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtestdiffdwarfabixml_SOURCES = test-diff-dwarf-abixml.cc
|
|
runtestdiffdwarfabixml_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtestabicompat_SOURCES = test-abicompat.cc
|
|
runtestabicompat_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtestdiffpkg_SOURCES = test-diff-pkg.cc
|
|
runtestdiffpkg_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtesttypesstability_SOURCES = test-types-stability.cc
|
|
runtesttypesstability_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtestini_SOURCES = test-ini.cc
|
|
runtestini_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtesttoolsutils_SOURCES = test-tools-utils.cc
|
|
runtesttoolsutils_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtestkmiwhitelist_SOURCES = test-kmi-whitelist.cc
|
|
runtestkmiwhitelist_LDADD = libtestutils.la libcatch.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtestelfhelpers_SOURCES = test-elf-helpers.cc
|
|
runtestelfhelpers_LDADD = libcatch.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtestcxxcompat_SOURCES = test-cxx-compat.cc
|
|
runtestcxxcompat_LDADD = libcatch.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtestsymtab_SOURCES = test-symtab.cc
|
|
runtestsymtab_LDADD = libtestutils.la libcatch.la $(top_builddir)/src/libabigail.la
|
|
|
|
runtestsvg_SOURCES=test-svg.cc
|
|
runtestsvg_LDADD=$(top_builddir)/src/libabigail.la
|
|
|
|
runtestdot_SOURCES = test-dot.cc
|
|
runtestdot_LDADD = $(top_builddir)/src/libabigail.la
|
|
|
|
testirwalker_SOURCES=test-ir-walker.cc
|
|
testirwalker_LDADD=$(top_builddir)/src/libabigail.la
|
|
|
|
testdiff2_SOURCES=test-diff2.cc
|
|
testdiff2_LDADD=$(top_builddir)/src/libabigail.la
|
|
|
|
printdifftree_SOURCES = print-diff-tree.cc
|
|
printdifftree_LDADD = $(top_builddir)/src/libabigail.la
|
|
|
|
runtestslowselfcompare_sh_SOURCES =
|
|
runtestslowselfcompare.sh$(EXEEXT):
|
|
|
|
runtestcanonicalizetypes_sh_SOURCES =
|
|
runtestcanonicalizetypes.sh$(EXEEXT):
|
|
|
|
runtestfedabipkgdiff_py_SOURCES =
|
|
runtestfedabipkgdiff.py$(EXEEXT):
|
|
|
|
runtestdefaultsupprs_py_SOURCES =
|
|
runtestdefaultsupprs.py$(EXEEXT):
|
|
|
|
runtestfedabipkgdiffpy3_sh_SOURCES =
|
|
runtestfedabipkgdiffpy3.sh$(EXEEXT):
|
|
|
|
runtestdefaultsupprspy3_sh_SOURCES =
|
|
runtestdefaultsupprspy3.sh$(EXEEXT):
|
|
|
|
AM_CPPFLAGS=-I${abs_top_srcdir}/include -I${abs_top_srcdir}/src \
|
|
-I${abs_top_builddir}/include -I${abs_top_srcdir}/tools -fPIC
|
|
|
|
clean-local: clean-local-check
|
|
.PHONY: clean-local-check
|
|
|
|
clean-local-check:
|
|
-rm -rf ${builddir}/output *.svg *.gv
|
|
|
|
@VALGRIND_CHECK_RULES@
|
|
VALGRIND_SUPPRESSIONS_FILES = ${srcdir}/test-valgrind-suppressions.supp
|
|
|
|
# These are flags passed to Valgrind so that it follows children
|
|
# processes of the test programs. This is because many test programs
|
|
# actually fork libabigail command line tools, and we want to valgrind
|
|
# those libabigail command line tools as well.
|
|
#
|
|
# The problem though is that there are many other command line
|
|
# programs that are forked too. For instance, /bin/sh is forked
|
|
# because tests are using the system() function to execute commands.
|
|
# So we must tell Valgrind to avoid following a bunch of command line
|
|
# programs that we don't care about and that take a lot of time to
|
|
# valgrind.
|
|
RECURSIVE_VALGRIND_FLAGS = \
|
|
--num-callers=30 \
|
|
--trace-children=yes \
|
|
--trace-children-skip=/bin/diff,/bin/rm,/bin/mkdir,/bin/cd,*cpio,/bin/dpkg,/bin/rpm,/bin/test,/bin/tar,/bin/sed,/bin/ls,/bin/g++,/*collect*,/bin/ld
|
|
|
|
# Use the target below to run tests under Valgrind's memcheck tool by
|
|
# telling it to follow children process, so that it can also check
|
|
# libabigail tools that are forked by the tests. This usually takes a
|
|
# while. So, to launch just one test in this configuration, if you
|
|
# are in the top-most source directory you can do:
|
|
#
|
|
# make -C <build-directory>/tests check-valgrind-memcheck-recursive TESTS=runtestdiffsuppr
|
|
|
|
check-valgrind-memcheck-recursive:
|
|
$(MAKE) check-valgrind-memcheck VALGRIND_FLAGS="${RECURSIVE_VALGRIND_FLAGS}"
|
|
|
|
check-valgrind-helgrind-recursive:
|
|
$(MAKE) check-valgrind-helgrind VALGRIND_FLAGS="${RECURSIVE_VALGRIND_FLAGS}"
|
|
|
|
check-self-compare:
|
|
$(MAKE) check TESTS=runtestslowselfcompare.sh ENABLE_SLOW_TEST=yes
|
|
|