2020-05-29 14:26:04 +00:00
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2017-01-17 18:41:51 +00:00
|
|
|
// -*- Mode: C++ -*-
|
|
|
|
//
|
|
|
|
// Author: Ondrej Oprala
|
|
|
|
|
|
|
|
/// @file
|
|
|
|
///
|
|
|
|
/// This program tests the annotation capabilities of the library.
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include "abg-tools-utils.h"
|
|
|
|
#include "test-utils.h"
|
|
|
|
|
|
|
|
using std::cerr;
|
|
|
|
using std::string;
|
2021-11-11 05:53:42 +00:00
|
|
|
using abigail::tests::emit_test_status_and_update_counters;
|
|
|
|
using abigail::tests::emit_test_summary;
|
2017-01-17 18:41:51 +00:00
|
|
|
|
|
|
|
struct InOutSpec
|
|
|
|
{
|
|
|
|
const char* in_elf_path;
|
|
|
|
const char* in_report_path;
|
|
|
|
const char* out_report_path;
|
|
|
|
};
|
|
|
|
|
|
|
|
InOutSpec in_out_specs[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"data/test-read-dwarf/test0",
|
|
|
|
"data/test-annotate/test0.abi",
|
|
|
|
"output/test-annotate/test0.abi"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-dwarf/test1",
|
|
|
|
"data/test-annotate/test1.abi",
|
|
|
|
"output/test-annotate/test1.abi"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-dwarf/test2.so",
|
|
|
|
"data/test-annotate/test2.so.abi",
|
|
|
|
"output/test-annotate/test2.so.abi"
|
|
|
|
},
|
|
|
|
{
|
Add regression tests for ctf reading
This patch implements some regression tests for ctf reading.
Since the code shares a lot of functionalities already used
in the readi-dwarf test, a library was built and test common
harness were moved to a common location. So input files for
test-read-{dwarf,ctf}.cc now are located in:
tests/data/test-read-common directory, ABIs description are
stored in the same location but in a separate file, one for
each binary debugging information: (e.g, test4-ctf.so.abi
and test4-dwarf.so.abi)
* tests/test-read-ctf.cc: New ctf reading regression test.
* tests/test-read-common.cc: New library to be used with
test-read-{ctf,dwarf}.cc.
* tests/test-read-common.h: Likewise.
* tests/test-annotate.cc (in_out_specs): Adjust path for input files.
* tests/Makefile.am: Build new tests/test-read-ctf.cc file.
* tests/data/Makefile.am: Add test inputs and expected files.
Add libtestreadcommon.a test library and use it for test-read-{ctf,dwarf}.
* tests/test-read-dwarf.cc: Adapt test to use libtestreadcommon.a in
test-read-common.{cc,h}.
* tests/data/test-annotate/test3.so.abi: Adjust ELF input path file
location to ./tests/data/test-read-common.
* tests/data/test-annotate/test4.so.abi: Likewise.
* tests/data/test-read-common/PR26261: Move test harness to
test-read-common directory.
* tests/data/test-read-common/PR27700: Likewise.
* tests/data/test-read-common/test-PR26568-*: Likewise.
* tests/data/test-read-common/test3.{c,so}: Likewise.
* tests/data/test-read-common/test4.{c,so}: Likewise.
* tests/data/test-read-common/crti*: Helper object to export
_init and _fini sysmbols.
* tests/data/test-read-ctf/test-ambiguous-struct-A.c: New testcase.
* tests/data/test-read-ctf/test-ambiguous-struct-B.c: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-a.c: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-b.c: Likewise.
* tests/data/test-read-ctf/test-enum.c: Likewise.
* tests/data/test-read-ctf/test-enum-many.c: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.c: Likewise.
* tests/data/test-read-ctf/test-struct-iteration.c: Likewise.
* tests/data/test-read-ctf/test-dynamic-array.c: Likewise.
* tests/data/test-read-ctf/test0.c: Likewise.
* tests/data/test-read-ctf/test1.c: Likewise.
* tests/data/test-read-ctf/test2.c: Likewise.
* tests/data/test-read-ctf/test5.c: Likewise.
* tests/data/test-read-ctf/test7.{c,h}: Likewise.
* tests/data/test-read-ctf/test8.c: Likewise.
* tests/data/test-read-ctf/test9.c: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Testcase
expected result.
* tests/data/test-read-ctf/PR26261/PR26261-exe.abi: Likewise.
* tests/data/test-read-ctf/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-a.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-b.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-many.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-struct-iteration.o.abi: Likewise.
* tests/data/test-read-ctf/test-dynamic-array.o.abi: Likewise.
* tests/data/test-read-ctf/test0: Likewise.
* tests/data/test-read-ctf/test0*.abi: Likewise.
* tests/data/test-read-ctf/test1.so: Likewise.
* tests/data/test-read-ctf/test1*.abi: Likewise.
* tests/data/test-read-ctf/test2.so: Likewise.
* tests/data/test-read-ctf/test2*.abi: Likewise.
* tests/data/test-read-ctf/test3.so.abi: Likewise.
* tests/data/test-read-ctf/test4*.abi: Likewise.
* tests/data/test-read-ctf/test5.o.abi: Likewise.
* tests/data/test-read-ctf/test7.o.abi: Likewise.
* tests/data/test-read-ctf/test8.o.abi: Likewise.
* tests/data/test-read-ctf/test9.o.abi: Likewise.
* tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: Update
expected abixml file.
* tests/data/test-read-dwarf/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-dwarf/test-PR26568-1.*.abi: Likewise.
* tests/data/test-read-dwarf/test3*.abi: Likewise.
* tests/data/test-read-dwarf/test4*.abi: Likewise.
* doc/api/libabigail.doxy: Add tests/test-read-common.{cc,h} to
doxygen.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-12-14 06:25:15 +00:00
|
|
|
"data/test-read-common/test3.so",
|
2017-01-17 18:41:51 +00:00
|
|
|
"data/test-annotate/test3.so.abi",
|
|
|
|
"output/test-annotate/test3.so.abi"
|
|
|
|
},
|
|
|
|
{
|
Add regression tests for ctf reading
This patch implements some regression tests for ctf reading.
Since the code shares a lot of functionalities already used
in the readi-dwarf test, a library was built and test common
harness were moved to a common location. So input files for
test-read-{dwarf,ctf}.cc now are located in:
tests/data/test-read-common directory, ABIs description are
stored in the same location but in a separate file, one for
each binary debugging information: (e.g, test4-ctf.so.abi
and test4-dwarf.so.abi)
* tests/test-read-ctf.cc: New ctf reading regression test.
* tests/test-read-common.cc: New library to be used with
test-read-{ctf,dwarf}.cc.
* tests/test-read-common.h: Likewise.
* tests/test-annotate.cc (in_out_specs): Adjust path for input files.
* tests/Makefile.am: Build new tests/test-read-ctf.cc file.
* tests/data/Makefile.am: Add test inputs and expected files.
Add libtestreadcommon.a test library and use it for test-read-{ctf,dwarf}.
* tests/test-read-dwarf.cc: Adapt test to use libtestreadcommon.a in
test-read-common.{cc,h}.
* tests/data/test-annotate/test3.so.abi: Adjust ELF input path file
location to ./tests/data/test-read-common.
* tests/data/test-annotate/test4.so.abi: Likewise.
* tests/data/test-read-common/PR26261: Move test harness to
test-read-common directory.
* tests/data/test-read-common/PR27700: Likewise.
* tests/data/test-read-common/test-PR26568-*: Likewise.
* tests/data/test-read-common/test3.{c,so}: Likewise.
* tests/data/test-read-common/test4.{c,so}: Likewise.
* tests/data/test-read-common/crti*: Helper object to export
_init and _fini sysmbols.
* tests/data/test-read-ctf/test-ambiguous-struct-A.c: New testcase.
* tests/data/test-read-ctf/test-ambiguous-struct-B.c: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-a.c: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-b.c: Likewise.
* tests/data/test-read-ctf/test-enum.c: Likewise.
* tests/data/test-read-ctf/test-enum-many.c: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.c: Likewise.
* tests/data/test-read-ctf/test-struct-iteration.c: Likewise.
* tests/data/test-read-ctf/test-dynamic-array.c: Likewise.
* tests/data/test-read-ctf/test0.c: Likewise.
* tests/data/test-read-ctf/test1.c: Likewise.
* tests/data/test-read-ctf/test2.c: Likewise.
* tests/data/test-read-ctf/test5.c: Likewise.
* tests/data/test-read-ctf/test7.{c,h}: Likewise.
* tests/data/test-read-ctf/test8.c: Likewise.
* tests/data/test-read-ctf/test9.c: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Testcase
expected result.
* tests/data/test-read-ctf/PR26261/PR26261-exe.abi: Likewise.
* tests/data/test-read-ctf/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-a.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-b.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-many.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-struct-iteration.o.abi: Likewise.
* tests/data/test-read-ctf/test-dynamic-array.o.abi: Likewise.
* tests/data/test-read-ctf/test0: Likewise.
* tests/data/test-read-ctf/test0*.abi: Likewise.
* tests/data/test-read-ctf/test1.so: Likewise.
* tests/data/test-read-ctf/test1*.abi: Likewise.
* tests/data/test-read-ctf/test2.so: Likewise.
* tests/data/test-read-ctf/test2*.abi: Likewise.
* tests/data/test-read-ctf/test3.so.abi: Likewise.
* tests/data/test-read-ctf/test4*.abi: Likewise.
* tests/data/test-read-ctf/test5.o.abi: Likewise.
* tests/data/test-read-ctf/test7.o.abi: Likewise.
* tests/data/test-read-ctf/test8.o.abi: Likewise.
* tests/data/test-read-ctf/test9.o.abi: Likewise.
* tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: Update
expected abixml file.
* tests/data/test-read-dwarf/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-dwarf/test-PR26568-1.*.abi: Likewise.
* tests/data/test-read-dwarf/test3*.abi: Likewise.
* tests/data/test-read-dwarf/test4*.abi: Likewise.
* doc/api/libabigail.doxy: Add tests/test-read-common.{cc,h} to
doxygen.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-12-14 06:25:15 +00:00
|
|
|
"data/test-read-common/test4.so",
|
2017-01-17 18:41:51 +00:00
|
|
|
"data/test-annotate/test4.so.abi",
|
|
|
|
"output/test-annotate/test4.so.abi"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-dwarf/test5.o",
|
|
|
|
"data/test-annotate/test5.o.abi",
|
|
|
|
"output/test-annotate/test5.o.abi"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-dwarf/test6.so",
|
|
|
|
"data/test-annotate/test6.so.abi",
|
|
|
|
"output/test-annotate/test6.so.abi"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-dwarf/test7.so",
|
|
|
|
"data/test-annotate/test7.so.abi",
|
|
|
|
"output/test-annotate/test7.so.abi"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-dwarf/test8-qualified-this-pointer.so",
|
|
|
|
"data/test-annotate/test8-qualified-this-pointer.so.abi",
|
|
|
|
"output/test-annotate/test8-qualified-this-pointer.so.abi"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-dwarf/test13-pr18894.so",
|
|
|
|
"data/test-annotate/test13-pr18894.so.abi",
|
|
|
|
"output/test-annotate/test13-pr18894.so.abi",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-dwarf/test14-pr18893.so",
|
|
|
|
"data/test-annotate/test14-pr18893.so.abi",
|
|
|
|
"output/test-annotate/test14-pr18893.so.abi",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-dwarf/test15-pr18892.so",
|
|
|
|
"data/test-annotate/test15-pr18892.so.abi",
|
|
|
|
"output/test-annotate/test15-pr18892.so.abi",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-dwarf/test17-pr19027.so",
|
|
|
|
"data/test-annotate/test17-pr19027.so.abi",
|
|
|
|
"output/test-annotate/test17-pr19027.so.abi",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so",
|
|
|
|
"data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi",
|
|
|
|
"output/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so",
|
|
|
|
"data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi",
|
|
|
|
"output/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so",
|
|
|
|
"data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi",
|
|
|
|
"output/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-dwarf/test21-pr19092.so",
|
|
|
|
"data/test-annotate/test21-pr19092.so.abi",
|
|
|
|
"output/test-annotate/test21-pr19092.so.abi",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-dwarf/libtest23.so",
|
|
|
|
"data/test-annotate/libtest23.so.abi",
|
|
|
|
"output/test-annotate/libtest23.so.abi",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-dwarf/libtest24-drop-fns.so",
|
|
|
|
"data/test-annotate/libtest24-drop-fns.so.abi",
|
|
|
|
"output/test-annotate/libtest24-drop-fns.so.abi",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-dwarf/libtest24-drop-fns.so",
|
|
|
|
"data/test-annotate/libtest24-drop-fns-2.so.abi",
|
|
|
|
"output/test-annotate/libtest24-drop-fns-2.so.abi",
|
|
|
|
},
|
Handle several member anonymous types of the same kind
When there are several anonymous types (e.g, anonymous classes, unions
or enums) in a given class or union, libabigail's internals do
struggle.
An anonymous class, for instance, is named __anonymous_struct__. When
there are more than one of these inside a given class, then we can't
name and look them up, because they all have the same name.
Incidentally, when add_or_update_class_type completes a class type
that was initially constructed before, it fails to determine that an
anonymous member type of that class was already present in that
context. It thus wrongly duplicates anonymous structs/unions/enums in
there and that leads to spurious textual (abixml) representation
differences later, where duplicated anonymous member types would
appear intermittently, depending on the order in which the class was
built.
This patch addresses this general issue by naming anonymous member
types in a way that allows several of them to exist. That is, if there
are two anonymous structs in a class, they are going to be named
__anonymous_struct__ and __anonymous_struct__1. We do follow a
similar scheme for anonymous unions and enums. This is handled by the
DWARF reader that builds the internal representation.
While looking at this issue, I also fixed a tangent bug; some DWARF
emitters wrongly *define* types in the scope of a
DW_TAG_subroutine_type or DW_TAG_array_type. We handle that by
actually defining those types in the scope of that subroutine or
array. But then it appears that if that scope itself a class and if
the type defined is an anonymous type, then putting that anonymous
type in the class scope might interfere with the *naming* of the
existing legit anonymous types of that scope. I decided to put those
anonymous types in the containing namespace instead. We'll see how
that goes in real time use.
The patch also updates lots of existing tests and adds a new one.
* include/abg-ir.h
(class_or_union::get_num_anonymous_member_{classes, unions,
enums}): Declare new member functions.
* src/abg-dwarf-reader.cc (get_internal_anonynous_die_base_name)
(build_internal_anonymous_die_name)
(get_internal_anonymous_die_name, is_anonymous_type_die): Define
new static functions.
(die_qualified_type_name): Use the new
get_internal_anonymous_die_name.
(get_scope_for_die): Fix this to put anonymous types that were
wrongly emitted into the scope of DW_TAG_subroutine_type or
DW_TAG_array_type by buggy DWARF emitters into the enclosing
namespace, rather than into the enclosing class/union.
(build_enum_type): Take the scope of the enum to have a chance to
properly name potential anonymous enums.
(lookup_class_typedef_or_enum_type_from_corpus): Take an anonymous
member type index for when the DIE we are lookup up represents an
anonymous type. Support proper building of the internal anonymous
name of the anonymous type we are lookup up.
(add_or_update_class_type): Use the new
get_internal_anonynous_die_base_name and
build_internal_anonymous_die_name functions. Support making sure
that the anonymous member type we are adding to the class wasn't
already there, especially for cases where we are updating a class
type.
(add_or_update_union_type): Use the new
get_internal_anonynous_die_base_name and
build_internal_anonymous_die_name functions.
(build_ir_node_from_die): Adjust the use of build_enum_type to
pass it the scope of the enum type we are building.
* src/abg-ir.cc (lookup_union_type): Add a new overload.
(lookup_class_or_typedef_type): Use the new overload of
lookup_union_type above to support looking up union types too.
(class_or_union::get_num_anonymous_member_{classes, unions,
enums}): Define new member functions.
* src/abg-reporter-priv.cc (represent): Detect when anonymous
types of anonymous data members have their internal names change,
probably because anonymous member types were inserted in the scope.
* tests/data/Makefile.am: Add the new test-anonymous-members-0.*
test input files to the source distribution.
* tests/data/test-annotate/test-anonymous-members-0.cc: New test
input file.
* tests/data/test-annotate/test-anonymous-members-0.o: Likewise.
* tests/data/test-annotate/test-anonymous-members-0.o.abi: Likewise.
* tests/data/test-annotate/test17-pr19027.so.abi: Adjust.
* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
Likewise.
* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.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
* 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/PR22122-libftdc.so.abi: Likewise.
* tests/data/test-read-dwarf/test12-pr18844.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/test21-pr19092.so.abi: Likewise.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
Likewise.
* tests/test-annotate.cc (int_out_specs): Add the new test inputs
to this test harness.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-05-07 08:22:29 +00:00
|
|
|
{
|
|
|
|
"data/test-annotate/test-anonymous-members-0.o",
|
|
|
|
"data/test-annotate/test-anonymous-members-0.o.abi",
|
|
|
|
"output/test-annotate/test-anonymous-members-0.o.abi",
|
|
|
|
},
|
2022-09-19 14:52:26 +00:00
|
|
|
{
|
|
|
|
"data/test-read-dwarf/PR29443-missing-xx.o",
|
|
|
|
"data/test-annotate/PR29443-missing-xx.o.annotated.abi",
|
|
|
|
"output/test-annotate/PR29443-missing-xx.o.annotated.abi",
|
|
|
|
},
|
Bug 30260 - Support pointer-to-member type
This adds support for C++ pointer-to-member types.
Here is a screenshot of what this patch enables libabigail to do:
$ cat -n test-ptr-to-mbr-v0.cc
1 struct X
2 {
3 void f(int);
4 int a;
5 };
6
7 int X::* pmi = &X::a;
8 void (X::* pmf)(int) = &X::f;
9
$ diff -u test-ptr-to-mbr-v0.cc test-ptr-to-mbr-v1.cc
--- test-ptr-to-mbr-v0.cc 2023-11-22 15:22:04.258260701 +0100
+++ test-ptr-to-mbr-v1.cc 2023-11-22 15:23:02.482621214 +0100
@@ -1,9 +1,8 @@
struct X
{
- void f(int);
- int a;
+ void f(int, char);
+ char a;
};
-int X::* pmi = &X::a;
-void (X::* pmf)(int) = &X::f;
-
+auto pmi = &X::a;
+auto pmf = &X::f;
$ abidiff test-ptr-to-mbr-v0.o test-ptr-to-mbr-v1.o
Functions changes summary: 0 Removed, 0 Changed, 0 Added function
Variables changes summary: 0 Removed, 2 Changed, 0 Added variables
2 Changed variables:
[C] 'void (X::* pmf)(int)' was changed to 'void (X::* pmf)(int, char)' at test-ptr-to-mbr-v1.cc:8:1:
type of variable changed:
pointer-to-member type changed from: 'void (X::*)(int) to: 'void (X::*)(int, char)'
in containing type 'struct X' of pointed-to-member type 'void (X::*)(int)' at test-ptr-to-mbr-v1.cc:1:1:
type size changed from 32 to 8 (in bits)
1 data member change:
type of 'int a' changed:
type name changed from 'int' to 'char'
type size changed from 32 to 8 (in bits)
[C] 'int X::* pmi' was changed to 'char X::* pmi' at test-ptr-to-mbr-v1.cc:7:1:
type of variable changed:
pointer-to-member type changed from: 'int X::* to: 'char X::*'
in data member type 'int' of pointed-to-member type 'int X::*':
type name changed from 'int' to 'char'
type size changed from 32 to 8 (in bits)
containing type of pointer-to-member 'struct X' changed at test-ptr-to-mbr-v0.cc:1:1, as reported earlier
$
* include/abg-comparison.h (class ptr_to_mbr_diff): Declare new
class.
(ptr_to_mbr_diff_sptr): Declare new typedef.
(compute_diff): Declare new overload for ptr_to_mbr_diff.
(ptr_to_mbr_type_sptr): Declare new typedef.
* src/abg-comparison-priv.h (struct ptr_to_mbr_diff::priv): Define
* src/abg-comparison.cc (compute_diff_for_types): Support new
ptr_to_mbr_type type.
(ptr_to_mbr_diff::{ptr_to_mbr_diff, first_ptr_to_mbr_type,
second_ptr_to_mbr_type, member_type_diff, containing_type_diff,
has_changes, has_local_changes, get_pretty_representation, report,
chain_into_hierarchy, ~ptr_to_mbr_diff}): Define member functions
of class ptr_to_mbr_diff.
(compute_diff): Define overload for ptr_to_mbr_type_sptr.
* include/abg-fwd.h (ptr_to_mbr_type_sptr): Declare new typedef.
(is_ptr_to_mbr_type, is_pointer_to_ptr_to_mbr_type)
(is_typedef_of_maybe_qualified_class_or_union_type): Declare new
functions.
* include/abg-ir.h (type_maps::ptr_to_mbr_types): Declare new
accessor.
(POINTER_TO_MEMBER_TYPE): Add new enumerator to enum
type_or_decl_base::type_or_decl_kind.
(class ptr_to_mbr_type): Declare new class.
(equals): Declare new overload for ptr_to_mbr_type.
(ir_node_visitor::visit_{begin,end}): Declare new member
functions.
* src/abg-ir.cc (ptr_to_mbr_declaration_name)
(ptr_to_mbr_declaration_name, add_outer_ptr_to_mbr_type_expr)
(add_outer_pointer_to_ptr_to_mbr_type_expr): Define new static
functions.
(type_maps::priv::ptr_to_mbr_types_): Define new
data member.
(type_maps::ptr_to_mbr_types): Define new accessor.
(is_ptr_to_mbr_type, is_pointer_to_ptr_to_mbr_type)
(is_typedef_of_maybe_qualified_class_or_union_type): Define new
functions.
(maybe_update_types_lookup_map, equals): Define new overloads for
ptr_to_mbr_type_sptr.
(is_npaf_type): Use is_ptr_to_mbr_type.
(maybe_update_types_lookup_map): In the overload for
decl_base_sptr, call the new overload for ptr_to_mbr_type_sptr
above.
(struct ptr_to_mbr_type::priv): Define new struct.
(ptr_to_mbr_type::{ptr_to_mbr_type, get_member_type,
get_containing_type, operator==, get_qualified_name, traverse,
~ptr_to_mbr_type}): Define member functions of ptr_to_mbr_type.
(types_have_similar_structure): Support the new ptr_to_mbr_type
type.
(ir_node_visitor::visit_{begin,end}): Add new member functions.
(var_decl::get_pretty_representation): Support pretty-printing
pointer-to-member types.
(pointer_declaration_name, array_declaration_name): Likewise.
* include/abg-reporter.h ({reporter_base, default_reporter,
leaf_reporter}::report): Add an overload for ptr_to_mbr_diff.
(default_reporter::report_local_ptr_to_mbr_type_changes): Declare
a member function.
private data class of ptr_to_mbr_diff.
* src/abg-default-reporter.cc
(default_reporter::report_local_ptr_to_mbr_type_changes): Define
member functions.
(default_reporter::report): Define an overload for
ptr_to_mbr_diff.
* src/abg-leaf-reporter.cc (leaf_reporter::report): Likewise.
* src/abg-dwarf-reader.cc (build_ptr_to_mbr_type): Define new
function.
(build_ir_node_from_die): Use the new build_ptr_to_mbr_type
function.
* src/abg-reader.cc (build_ptr_to_mbr_type): Define new function.
(build_type): Use the new build_ptr_to_mbr_type above.
* src/abg-writer.cc (write_ptr_to_mbr_type): Define new function.
(write_type, write_decl, write_member_type): Use the new
write_ptr_to_mbr_type above.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr1-output-1.txt:
Add new test material.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr1-v0.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr1-v0.o:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr1-v1.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr1-v1.o:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr2-output-1.txt:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr2-v0.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr2-v0.o:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr2-v1.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr2-v1.o:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr3-output-1.txt:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr3-v0.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr3-v0.o:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr3-v1.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr3-v1.o:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr4-output-1.txt:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr4-v0.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr4-v0.o:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr4-v1.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr4-v1.o:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr5-output-1.txt:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr5-v0.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr5-v0.o:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr5-v1.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr5-v1.o:
Likewise.
* tests/data/test-read-dwarf/test-pointer-to-member-1.cc:
Likewise.
* tests/data/test-read-dwarf/test-pointer-to-member-1.o: Likewise.
* tests/data/test-read-dwarf/test-pointer-to-member-1.o.abi:
Likewise.
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-abidiff-exit.cc (in_out_specs): Add the test material
above to this test harness.
* tests/test-annotate.cc (in_out_specs): Likewise.
* tests/test-read-dwarf.cc: Likewise.
* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Adjust.
* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-11-30 15:54:30 +00:00
|
|
|
{
|
|
|
|
"data/test-read-dwarf/test-pointer-to-member-1.o",
|
|
|
|
"data/test-annotate/test-pointer-to-member-1.o.annotated.abi",
|
|
|
|
"output/test-annotate/test-pointer-to-member-1.o.annotated.abi",
|
|
|
|
},
|
2017-01-17 18:41:51 +00:00
|
|
|
// This should be the last entry.
|
|
|
|
{NULL, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
main()
|
|
|
|
{
|
|
|
|
using abigail::tests::get_src_dir;
|
|
|
|
using abigail::tests::get_build_dir;
|
|
|
|
using abigail::tools_utils::ensure_parent_dir_created;
|
|
|
|
|
2021-11-11 05:53:42 +00:00
|
|
|
unsigned int total_count = 0, passed_count = 0, failed_count = 0;
|
|
|
|
|
2017-01-17 18:41:51 +00:00
|
|
|
string in_elf_path, ref_report_path, out_report_path;
|
|
|
|
string abidw;
|
|
|
|
|
|
|
|
abidw = string(get_build_dir()) + "/tools/abidw "
|
Emit & read undefined interfaces to & from ABIXML
This patch teaches the ABIXML writer to emit information about
undefined interfaces. It also teaches the ABIXML reader to read
information about undefined interfaces.
It introduces two new ABIXML elements:
'undefined-elf-function-symbols' and 'undefined-elf-variable-symbols'
to represent undefined function and variable symbols.
Then, in the 'abi-instr' element functions and variables that
reference undefined elf symbols now have an 'elf-symbol-id' attribute
referencing the undefined symbol listed in the new
'undefined-elf-variable-symbols' or 'undefined-elf-function-symbols'
element.
The patch introduces tests that perform compatibility checks done on
ABIXML files.
* include/abg-writer.h (set_write_undefined_symbols): Declare new
function.
(set_common_options): Use the new set_write_undefined_symbols in
this function template.
* src/abg-dwarf-reader.cc (reader::{get_die_language, die_is_in_c,
die_is_in_cplus_plus, die_is_in_c_or_cplusplus}): Move these
member functions into ...
(get_die_language, die_is_in_c, die_is_in_cplus_plus)
(die_is_in_c_or_cplusplus): ... these static non-member functions.
(fn_die_equal_by_linkage_name): Adjust and remove the now useless
reader parameter.
(compare_dies, get_scope_die, function_is_suppressed)
(variable_is_suppressed): Adjust.
(build_translation_unit_and_add_to_ir): When we are asked to load
undefined symbol, make sure to also analyze top-level class types
and if we are in C++, also analyze top-level unions and structs as
these might also have some undefined interfaces.
* src/abg-reader.cc (build_elf_symbol_db): Let's not construct and
return the symbol DB anymore. Rather, let's let the caller
construct it, so we can just update it with the input gathered.
(read_symbol_db_from_input): Support getting undefined function
and variable symbols from the new undefined-elf-function-symbols
and undefined-elf-variable-symbols elements. Note that undefined
and defined function symbols go into the same symbol DB whereas
undefined and defined variable symbols go into another symbol DB.
Now, we suppose that the variable & symbol DBs are allocated by
the caller. We pass it down to build_elf_symbol_db that populates
it. Maybe we should rename build_elf_symbol_db into
populate_elf_symbol_db.
(reader::read_corpus): Allocate the function
and variable symbol DB and let read_symbol_db_from_input populate
it. Sort functions and variables after reading the whole ABIXML.
* src/abg-writer.cc (write_context::write_context): Define new
data member.
(write_context::write_context): Initialize it.
(write_context::{get,set}::write_undefined_symbols): Define
accessors.
(set_write_undefined_symbols): Define a new function.
(write_context::decl_is_emitted): Add a new overload.
(write_elf_symbol_reference): Add a writer context and a corpus
parameter. If the symbol is not in the corpus or if the symbol is
undefined and we were not asked to emit undefined symbols then do
not emit any reference to it.
(write_translation_unit): Emit the undefined functions and
variables that belong to the current translation unit, along with
their reference to the undefined ELF symbol they are associated
to.
(write_var_decl, write_function_decl): Let
write_elf_symbol_reference decide whether it should emit the
reference to ELF symbol or not, as it now know how to make that
decision.
(write_corpus): Write the undefined function & variable ELF symbol
data bases. These in the new 'undefined-elf-function-symbols' and
'undefined-elf-variable-symbols' elements.
* tools/abidw.cc (options::load_undefined_interfaces): Define new
data member.
(options:options): Initialize it.
(display_usage): Add a help string for the
--no-load-undefined-interfaces option.
(parse_command_line): Parse the --no-load-undefined-interfaces
option.
(set_generic_options): Set the
fe_iface::option_type::load_undefined_interfaces option.
* doc/manuals/abidw.rst: Document the new
--no-load-undefined-interfaces of abidw.
* tests/data/test-abicompat/test10/libtest10-with-exported-symbols.so:
New binary input file.
* tests/data/test-abicompat/test10/libtest10-with-incompatible-exported-symbols.so:
New binary input file.
* tests/data/test-abicompat/test10/libtest10-with-incompatible-exported-symbols.so.abi:
New abixml input file.
* tests/data/test-abicompat/test10/test10-app-with-undefined-symbols:
New binary input file.
* tests/data/test-abicompat/test10/test10-app-with-undefined-symbols.abi:
New abixml input file.
* tests/data/test-abicompat/test10/test10-app-with-undefined-symbols.cc:
New source file for binary test input
* tests/data/test-abicompat/test10/test10-fn-changed-report-0.txt:
New source file for binary test input
* tests/data/test-abicompat/test10/test10-fn-changed-report-1.txt:
New source file for binary test input
* tests/data/test-abicompat/test10/test10-fn-changed-report-2.txt:
New source file for binary test input
* tests/data/test-abicompat/test10/test10-fn-changed-report-3.txt:
New source file for binary test input
* tests/data/test-abicompat/test10/test10-fn-changed-report-4.txt:
New source file for binary test input
* tests/data/test-abicompat/test10/test10-with-exported-symbols.cc:
New source file for binary test input
* tests/data/test-abicompat/test10/test10-with-exported-symbols.h:
New source file for binary test input
* tests/data/test-abicompat/test10/test10-with-incompatible-exported-symbols.cc:
New source file for binary test input
* tests/data/test-abicompat/test10/test10-with-incompatible-exported-symbols.h:
New source file for binary test input.
* tests/data/Makefile.am: Add new test input files to source
distribution.
* tests/test-abicompat.cc (in_out_specs): Add the new test inputs
to this test harness.
* tests/test-annotate.cc (main): Use the new
--no-load-undefined-interfaces option of abidw to keep the old
behavior.
* tests/test-read-common.cc (test_task::serialize_corpus): Do not
emit undefined symbols.
* tests/test-read-dwarf.cc (test_task_dwarf::perform): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2024-03-08 14:31:44 +00:00
|
|
|
"--annotate --no-corpus-path --no-architecture --no-load-undefined-interfaces";
|
2017-01-17 18:41:51 +00:00
|
|
|
for (InOutSpec* s = in_out_specs; s->in_elf_path; ++s)
|
|
|
|
{
|
2021-11-11 05:53:42 +00:00
|
|
|
bool is_ok = true;
|
2017-01-17 18:41:51 +00:00
|
|
|
in_elf_path = string(get_src_dir()) + "/tests/" + s->in_elf_path;
|
|
|
|
ref_report_path = string(get_src_dir()) + "/tests/" + s->in_report_path;
|
|
|
|
out_report_path =
|
|
|
|
string(get_build_dir()) + "/tests/" + s->out_report_path;
|
|
|
|
if (!ensure_parent_dir_created(out_report_path))
|
|
|
|
{
|
|
|
|
cerr << "could not create parent directory for "
|
|
|
|
<< out_report_path;
|
|
|
|
is_ok = false;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
string cmd = abidw + " " + in_elf_path + " > " + out_report_path;
|
|
|
|
|
|
|
|
bool abidw_ok = true;
|
|
|
|
if (system(cmd.c_str()))
|
|
|
|
abidw_ok = false;
|
|
|
|
|
|
|
|
if (abidw_ok)
|
|
|
|
{
|
2021-11-11 05:53:42 +00:00
|
|
|
string diff_cmd =
|
2022-05-30 07:55:01 +00:00
|
|
|
"diff -w -u " + ref_report_path + " " + out_report_path;
|
2021-11-11 05:53:42 +00:00
|
|
|
if (system(diff_cmd.c_str()))
|
2017-01-17 18:41:51 +00:00
|
|
|
is_ok &=false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
is_ok &= false;
|
|
|
|
}
|
2021-11-11 05:53:42 +00:00
|
|
|
|
|
|
|
emit_test_status_and_update_counters(is_ok, cmd, passed_count,
|
|
|
|
failed_count, total_count);
|
2017-01-17 18:41:51 +00:00
|
|
|
}
|
|
|
|
|
2021-11-11 05:53:42 +00:00
|
|
|
emit_test_summary(total_count, passed_count, failed_count);
|
|
|
|
|
|
|
|
return failed_count;
|
2017-01-17 18:41:51 +00:00
|
|
|
}
|