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
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
// -*- Mode: C++ -*-
|
|
|
|
//
|
2023-01-01 17:14:26 +00:00
|
|
|
// Copyright (C) 2021-2023 Oracle, Inc.
|
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
|
|
|
//
|
|
|
|
// Author: Guillermo E. Martinez
|
|
|
|
|
|
|
|
/// @file
|
|
|
|
///
|
|
|
|
/// This file implement the CTF testsuite. It reads ELF binaries
|
|
|
|
/// containing CTF, save them in XML corpus files and diff the
|
|
|
|
/// corpus files against reference XML corpus files.
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <fstream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include "abg-ctf-reader.h"
|
|
|
|
#include "test-read-common.h"
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using std::cerr;
|
2022-05-16 18:32:54 +00:00
|
|
|
using std::vector;
|
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
|
|
|
|
|
|
|
using abigail::tests::read_common::InOutSpec;
|
|
|
|
using abigail::tests::read_common::test_task;
|
|
|
|
using abigail::tests::read_common::display_usage;
|
|
|
|
using abigail::tests::read_common::options;
|
|
|
|
|
|
|
|
using abigail::xml_writer::SEQUENCE_TYPE_ID_STYLE;
|
|
|
|
using abigail::xml_writer::HASH_TYPE_ID_STYLE;
|
|
|
|
using abigail::tools_utils::emit_prefix;
|
|
|
|
|
Make Front Ends first class citizens
This patch is a reorganization of the code to better support the need
for having several different front-ends.
In the libabigail pipeline of operation, a front-end is the part of
the pipeline that analyses the input file. For instance, to analyse
an ELF file, there is going to be one front-end. To analyse an ABIXML
file, there is going to be another front-end.
The middle-end is the part of the pipeline that interacts with the
internal representation of ABIs. The middle-end knows how to analyse,
compare ABI corpora provide an internal representation of the
comparison result and analyse it as well.
The back-end would be the part of the front-end that knows how to
serialize internal representations of ABIs and ABI comparison results.
One could thus imagine a front-end that understands the DWARF debug
info format embedded in an ELF file. Another front-end would be
dedicated to the CTF debug info format, and so on.
Front-ends can share capabilities. For instance, DWARF and CTF
front-ends are ELF based front end. As such, they share capabilities
to understand the ELF format. They don't share much with the ABIXML
front-end, however, as it's based on XML, which has almost nothing in
common with ELF.
To support this organization of concepts, this patch introduces a new
hierarchy of types in the form of C++ classes.
All front-ends implements the "Front End Interface". As such, they
all inherit the abigail::fe_iface class.
That class provides properties and behaviours that are shared by all
front-ends that libabigail supports today. Namely, that class
provides access to some of the options that are relevant to operating
the front-end, to the ABI corpus or corpus group being constructed and
to the suppression specifications that are considered. It also
provides an abstract interface to perform the actual loading of the
ABI corpus. That abstract interface has to be implemented by every
single concrete front-end that is provided in libabigail.
Then, there is the "ELF Reader" front-end. Its class name is
abigail::elf::reader. It inherits the abigail::fe_iface class and
implements the fe_iface::load_corpus() so that the ELF properties of
the ELF file be loaded and exposed in the ABI corpus as returned by
the fe_iface::corpus() accessor. This ELF reader front-end also
provides lots of capabilities that are specific to accessing ELF
content.
Then, there is a common base class for ELF-based front-ends to come,
named abigail::elf_based_reader, which inherits the abigail::elf::reader
class. The purpose of this base class is to provide common properties
and behaviours that are necessary to implement things like a DWARF or
a CTF front-end, or any other front-end to support an ELF-based debug
info format.
Then, there is a CTF front-end which class is named
abigail::ctf::reader. It inherits the abigail::elf_based_reader class
and implements the fe_iface::load_corpus() interface to load and
analyse the CTF-specific properties of the ELF file. To do this,
abigail::ctf::reader::load_corpus() re-uses the abigail::elf::load_corpus() member
function to load the generic ELF parts of the ABI corpus. This reader
then constructs the internal representation of the ABI corpus and
passes it to the middle-end for further analysis.
Then, there is a DWARF front-end which class is named
abigail::dwarf::reader. It inherits the abigail::elf_based_reader
class and implements the fe_iface::load_corpus() interface to load and
analyse the DWARF-specific properties of the ELF file. To do this,
abigail::dwarf::reader re-uses the abigail::elf::load_corpus() member
function to load the generic ELF parts of the ABI corpus, just like
what the CTF front-end does. And then, just like the CTF front-end,
this reader then constructs the internal representation of the ABI
corpus and passes it to the middle-end for further analysis.
Lastly, there is an ABIXML front-end which class is named
abigail::abixml::reader. It inherits the abigail::fe_iface class
directly. Note that unlike the two previous front-ends, this one
doesn't inherit the elf_based_reader base class, for reasons that
should be obvious to the astute reader by now. So, this front-end
implements the abigail::fe_iface::load_corpus() abstract interface to
load the properties for the ABI corpus represented in the ABIXML
format, construct the internal representation and pass it to the
middle-end for further analysis.
The code of the tools got adapted to use these front-ends.
The support of CTF is still guarded by #ifdef WITH_CTF pre-processor
macros, but the one cool side effect is that the amount of guarded
code is reduced. Basically, it's only the creation of the CTF
front-end that is guarded. After its creation, what is returned is an
instance of abigail::elf_based_reader::reader, exactly like what is
returned by the creation of a DWARF front-end. Thus, the rest of the
code is exactly the same, regardless of the kind of front-end. I
believe this results in a more elegant and maintainable code.
As a proof-of-concept, this patch also provides the
create_best_elf_based_reader function. This function analyses the ELF
file and depending on the kind of debug info it provides, returns the
right front-end for it. Maybe at some point, all the #ifdef WITH_CTF
guard pre-processing macros will be constrained in a single function
like this one that will take the decision of instantiating the right
front-end. The rest of the code will be as generic as it gets.
The patch adjusts the reference abixml files produced by the CTF
front-end because it now emits the <elf-needed> XML element which was
not emitted before. This is done because the CTF front-end inherits
the elf-reader which reads the "elf-needed" property from the binary,
without explicit intervention from the CTF front-end.
The patch passes 'make distcheck' on all the supported platforms.
* include/abg-fwd.h (build_internal_underlying_enum_type_name):
Move this here from src/abg-dwarf-reader.cc.
* include/abg-elf-reader-common.h: Delete this file. Its content
is going to be put in the new include/abg-elf-reader.h.
* src/abg-elf-reader-common.cc: Likewise.
* include/abg-{elf-based-reader, elf-reader, fe-iface}.h: Add new
files.
* src/abg-fe-iface.cc: Likewise.
* include/Makefile.am: Add the new file abg-fe-iface.h,
abg-elf-based-reader.h and abg-elf-reader.h to source distribution
and remove include/abg-elf-reader-common.h from source
distribution.
* src/abg-ir.cc (build_internal_underlying_enum_type_name): Move
this here from abg-dwarf-reader.cc so that it can be used by other
readers.
* include/abg-reader.h (abigail::abixml::reader): Rename the
namespace abigail::xml_reader into this one.
(read_context, create_native_xml_read_context)
(read_context_get_path, read_corpus_from_native_xml)
(read_corpus_from_native_xml_file)
(read_corpus_group_from_native_xml)
(read_corpus_group_from_native_xml_file): Remove.
(read_translation_unit_from_file)
(read_translation_unit_from_buffer)
(read_translation_unit_from_istream)
(read_translation_unit)
(consider_types_not_reachable_from_public_interfaces)
(get_types_from_type_id, get_artifact_used_by_relation_map)
(load_canonical_type_ids): Take an fe_iface&, not a read_context.
(create_reader): Declare new function that returns a
fe_iface_sptr.
(read_corpus_from_abixml, read_corpus_from_abixml_file)
(read_corpus_group_from_abixml)
(read_corpus_group_from_abixml_file): Declare new functions.
* src/abg-reader.cc (namespace abixml): Rename the
xml_reader namespace into this.
(abixml::reader_sptr): New typedef.
(abixml::reader): Rename read_context into this. Make it
inherit the fe_iface interface.
(abixml::reader::{m_path, m_env, m_corpus, m_corpus_group,
m_exported_decls_builder, m_supprs}): Remove these data members
that are now part of the fe_iface parent type.
(abixml::reader::{set_environment, get_corpus, set_corpus,
set_corpus_group, maybe_add_fn_to_exported_decls,
maybe_add_var_to_exported_decls,
maybe_check_abixml_canonical_type_stability,
suppression_matches_function_sym_name,
suppression_matches_variable_name,
suppression_matches_variable_sym_name}): Remove.
(read_corpus_from_input): Remove. Actually the code of this went
into abixml::reader::read_context().
(abixml::reader::get_libxml_reader): Rename the get_reader
member function into this.
(abixml::add_reader_suppressions): Rename
add_read_context_suppressions into this.
(abixml::reader::read_corpus): Implement this virtual
member function if the fe_iface parent interface.
(maybe_set_naming_typedef, advance_cursor)
(handle_version_attribute, walk_xml_node_to_map_type_ids)
(read_elf_needed_from_input, read_symbol_db_from_input)
(get_or_read_and_add_translation_unit, build_needed)
(read_elf_needed_from_input, add_read_context_suppressions)
(maybe_set_artificial_location, maybe_set_naming_typedef)
(build_namespace_decl, build_elf_symbol)
(build_elf_symbol_from_reference, build_elf_symbol_db)
(build_function_parameter, build_function_decl)
(build_function_decl_if_not_suppressed, function_is_suppressed)
(type_is_suppressed, build_var_decl_if_not_suppressed)
(variable_is_suppressed, variable_is_suppressed, build_var_decl)
(build_type_decl, build_qualified_type_decl)
(build_pointer_type_def, build_reference_type_def)
(build_function_type, build_subrange_type, build_array_type_def)
(build_enum_type_decl_if_not_suppressed, build_enum_type_decl)
(build_typedef_decl, build_class_decl_if_not_suppressed)
(build_union_decl_if_not_suppressed, build_class_decl)
(build_union_decl, build_function_tdecl, build_class_tdecl)
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_non_type_tparameter)
(build_template_tparameter, build_template_parameter, build_type)
(handle_type_decl, handle_namespace_decl)
(handle_qualified_type_decl, handle_pointer_type_def)
(handle_reference_type_def, handle_function_type)
(handle_array_type_def, handle_enum_type_decl)
(handle_typedef_decl, handle_var_decl, handle_function_decl)
(handle_class_decl, handle_union_decl, handle_function_tdecl)
(read_translation_unit_from_istream): Take or use an
abixml::reader rather than a read_context.
(read_translation_unit, read_translation_unit_from_input)
(consider_types_not_reachable_from_public_interfaces)
(get_types_from_type_id, get_artifact_used_by_relation_map)
(read_corpus_group_from_input, read_translation_unit)
(handle_element_node, read_location, read_artificial_location)
(load_canonical_type_ids) : Take an fe_iface&, not a read_context.
(create_abixml_reader): Rename create_native_xml_read_context
into this. Make it return a fe_iface_sptr.
(read_corpus_from_abixml): Rename read_corpus_from_abixml into
this.
(read_corpus_from_abixml_file): Rename
read_corpus_from_native_xml_file into this.
(read_context_get_path): Remove.
* include/abg-tools-utils.h
(abigail::tools_utils::{file_has_dwarf_debug_info,
file_has_ctf_debug_info}): Declare new functions.
(create_best_elf_based_reader): Declare new function.
* include/abg-corpus.h (corpus::add): Pass the translation unit by
reference.
(corpus::exported_decls_builder::maybe_add_{fn,var}_to_exported_fns):
Take a const parameter.
* src/abg-corpus-priv.h
(corpus::exported_decls_builder::priv::add_{fn,var}_to_exported):
Take a const parameter and adjust.
* src/abg-corpus.cc
(corpus::exported_decls_builder::maybe_add_{fn,var}_to_exported_fns):
Take a const parameter.
(corpus::add): Take a reference to translation_unit_sptr.
* include/abg-suppression.h (abigail::fe_iface): Forward-declare
this.
(abigail::{suppression_sptr, suppressions_type}): Declare these
types here.
(abigail::suppr::{suppression_can_match,
suppression_matches_function_name,
suppression_matches_function_sym_name,
suppression_matches_variable_name,
suppression_matches_variable_sym_name,
suppression_matches_type_name_or_location,
is_elf_symbol_suppressed, is_elf_symbol_suppressed,
is_function_suppressed, is_variable_suppressed,
is_type_suppressed}): Declare these functions here.
* src/abg-suppression-priv.h (function_is_suppressed)
(variable_is_suppressed, type_is_suppressed)
(is_elf_symbol_suppressed): Remove these template functions.
* src/abg-suppression.cc (suppression_matches_function_name)
(suppression_matches_function_sym_name): Remove.
(variable_is_suppressed, suppression_can_match)
(suppression_matches_function_name)
(suppression_matches_function_sym_name)
(suppression_matches_variable_name)
(suppression_matches_variable_sym_name)
(suppression_matches_type_name_or_location)
(is_elf_symbol_suppressed, is_elf_symbol_suppressed)
(is_function_suppressed, is_variable_suppressed)
(is_type_suppressed): New functions.
* include/abg-ctf-reader.h (abigail::ctf::{read_context,
create_read_context, read_corpus,
read_and_add_corpus_to_group_from_elf,
set_read_context_corpus_group, reset_read_context, dic_type_key}):
Remove.
(ctf::{create_reader, reset_reader}): Declare new
functions.
* src/abg-ctf-reader.cc (read_context): Remove.
(process_ctf_typedef, process_ctf_base_type)
(build_ir_node_for_variadic_parameter_type)
(process_ctf_function_type, process_ctf_sou_members)
(process_ctf_forward_type, process_ctf_struct_type)
(process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type)
(process_ctf_enum_type, fill_ctf_section)
(lookup_symbol_in_ctf_archive, dic_type_key): Forward-declare
these static functions.
(ctf::reader): New class that is the abstraction
of the CTF reader. It extends the abigail::elf_based_reader
class. This is a renaming of the
abigail::ctf::read_context class.
(ctf::reader::{elf_handler, elf_fd,
elf_handler_dbg, elf_fd_dbg, symtab, debug_info_root_paths_,
debug_info_root_paths_}): Remove these data members as they are
now properties of the abigail::elf_reader class, which is a parent
class of this abigail::ctf::reader class.
(ctf::reader::{exported_decls_builder,
maybe_add_fn_to_exported_decls, current_corpus_group,
has_corpus_group, main_corpus_from_current_group,
current_corpus_is_main_corpus_from_current_group,
should_reuse_type_from_corpus_group}): Remove these accessors
that can now be used from the parent classes abigail::{elf_reader,
elf_based_reader}.
(ctf::reader::reader): This now delegates to the constructor of
elf_based_reader. It doesn't pass any argument to initialize()
anymore.
(ctf::reader::initialize): Add an overload with no
parameter. In the other overload, do not take a pointer to an
environment as no new environment can be passed to the instance of
reader that is being reset. Adjust the code of the initializer to
reflect all the data members that got removed.
(ctf::{env, find_ctfa_file, slurp_elf_info,
process_ctf_archive, process_ctf_type, lookup_type, read_corpus,
~reader}): New member functions. Most of these were free-form
functions that took ctf::read_context as first parameter.
In read_corpus, do not set the corpus::LINUX_KERNEL_BINARY_ORIGIN
origin as that is now done by elf::reader when it reads the
binary.
(lookup_type): Remove. These are now member functions of the
ctf::reader class.
(process_ctf_typedef, process_ctf_base_type)
(build_ir_node_for_variadic_parameter_type)
(process_ctf_function_type, process_ctf_sou_members)
(process_ctf_forward_type, process_ctf_struct_type)
(process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type): Take a
ctf::reader rather an ctf::read_context. Adjust the
content of the functions.
(process_ctf_type, lookup_type, process_ctf_archive): Remove these
and turn them into member functions of ctf::reader.
(open_elf_handler, close_elf_handler, find_alt_debuginfo): Remove
these ELF handling functions as ELF handling is now done by the
elf_reader parent class.
(fill_ctf_section): Take a const pointer to Elf_Scn.
(slurp_elf_info, find_ctfa_file): Remove this and make it be a
member of ctf::reader. Also, make it handle only CTF
reader specific pieces. slurp_elf_info now delegates the reading
of generic ELF properties to elf::reader by calling
elf::reader::read_corpus().
(create_read_context, read_corpus, set_read_context_corpus_group)
(read_and_add_corpus_to_group_from_elf): Remove these functions.
(create_reader, reset_reader): Create new functions
(dic_type_key): Make this static.
* include/abg-dwarf-reader.h (abigail::dwarf::elf_type):
Move this enum into the namespace abigail::elf_reader in the file
include/abg-elf-reader.h.
(abigail::dwarf::{read_context, read_context_sptr,
create_read_context, read_context_get_path, reset_read_context,
add_read_context_suppressions, set_read_context_corpus_group,
read_corpus_from_elf, read_and_add_corpus_to_group_from_elf,
read_and_add_corpus_to_group_from_elf,
add_read_context_suppressions, refers_to_alt_debug_info,
has_alt_debug_info, get_soname_of_elf_file, get_type_of_elf_file,
set_debug_info_root_path, get_debug_info_root_path,
get_show_stats, set_show_stats, set_drop_undefined_syms,
set_do_log, set_environment, get_environment}): Remove.
* src/abg-dwarf-reader.cc (struct dwfl_deleter, dwfl_sptr)
(addr_elf_symbol_sptr_map_type, address_set_type)
(address_set_sptr): Delete these types.
(read_context::options_type): Remove. The data members of this
type got moved to struct fe_iface::options_type.
(find_alt_debug_info_link, find_alt_debug_info_path)
(find_alt_debug_info, lookup_data_tag_from_dynamic_segment)
(elf_file_type, refers_to_alt_debug_info, has_alt_debug_info)
(get_soname_of_elf_file, get_type_of_elf_file) : Remove these ELF
specific functions from here; move them to the elf_reader
namespace.
(dwarf::reader): Create new class that extends
elf_based_reader. dwarf::read_context is renamed into this
type, actually.
(dwarf::reader::die_source_dependant_container_set::get_container):
Adjust.
(dwarf::reader::{supprs_, dwarf_version_,
offline_callbacks_, debug_info_root_paths_, handle_, dwarf_,
alt_fd_, alt_dwarf_, alt_debug_info_path_, elf_module_,
elf_handle_, elf_path_, symtab_section_, cur_corpus_group_,
cur_corpus_, dt_needed_, dt_soname_, elf_architecture_,
exported_decls_builder_, options_, drop_undefined_syms_}): Remove
these ELF-related data members to move them into the elf_reader
namespace.
(maybe_propagate_canonical_type)
(build_translation_unit_and_add_to_ir, build_ir_node_from_die)
(add_or_update_class_type, add_or_update_union_type)
(build_ir_node_for_void_type)
(build_ir_node_for_variadic_parameter_type, build_function_decl)
(function_is_suppressed, build_or_get_fn_decl_if_not_suppressed)
(build_var_decl, build_or_get_var_decl_if_not_suppressed)
(variable_is_suppressed)
(propagate_canonical_type)
(get_parent_die, get_scope_die, die_is_at_class_scope)
(die_location, die_qualified_type_name, die_qualified_name)
(die_qualified_type_name_empty)
(die_return_and_parm_names_from_fn_type_die)
(die_function_signature, die_function_type_is_method_type)
(die_pretty_print_type, die_pretty_print_decl, die_pretty_print)
(maybe_canonicalize_type, build_subrange_type)
(build_subranges_from_array_type_die, compare_dies, die_location)
(die_loc_and_name, die_is_effectively_public_decl)
(maybe_cache_type_comparison_result)
(get_cached_type_comparison_result)
(maybe_get_cached_type_comparison_result, die_is_at_class_scope)
(die_function_type_is_method_type, die_member_offset)
(die_qualified_type_name, die_qualified_decl_name)
(die_qualified_name, die_qualified_type_name_empty)
(die_return_and_parm_names_from_fn_type_die)
(die_function_signature, die_pretty_print_type)
(die_pretty_print_decl, die_pretty_print)
(at_least_one_decl_only_among_odr_relevant_dies)
(compare_as_type_dies, compare_as_decl_and_type_dies)
(fn_die_equal_by_linkage_name, try_canonical_die_comparison)
(maybe_propagate_canonical_type, propagate_canonical_type)
(compare_dies, compare_dies_during_canonicalization)
(find_import_unit_point_between_dies, get_parent_die)
(get_scope_die, find_lower_bound_in_imported_unit_points)
(build_translation_unit_and_add_to_ir)
(build_namespace_decl_and_add_to_ir, build_type_decl)
(build_enum_underlying_type, build_enum_type)
(finish_member_function_reading)
(maybe_finish_function_decl_reading)
(lookup_class_or_typedef_from_corpus)
(is_function_for_die_a_member_of_class)
(add_or_update_member_function, add_or_update_class_type)
(add_or_update_union_type, build_qualified_type)
(schedule_array_tree_for_late_canonicalization)
(maybe_strip_qualification, build_pointer_type_def)
(build_reference_type, build_function_type, build_subrange_type)
(build_subranges_from_array_type_die, build_array_type)
(build_typedef_type, build_or_get_var_decl_if_not_suppressed)
(build_var_decl, function_is_suppressed)
(build_or_get_fn_decl_if_not_suppressed, variable_is_suppressed)
(type_is_suppressed, type_is_suppressed)
(get_opaque_version_of_type, create_default_fn_sym)
(build_function_decl, maybe_canonicalize_type)
(build_ir_node_from_die)
(build_ir_node_for_variadic_parameter_type): Take a reference to
the new dwarf::reader rather than to the previous
read_context. Adjust the function body.
(return_comparison_result): Adjust.
(dwarf::reader::reader): Adjust this from
read_context::read_context.
(dwarf::reader::initialize): Adjust from
dwarf::read_context::initialize.
(dwarf::reader::create): New factory static member
function.
(dwarf::reader::~reader): This doesn't have to clear
anything for now.
(dwarf::reader::read_corpus): New virtual member function
which implements the fe_iface::read_corpus pure virtual interface.
This now delegates the reading of the generic ELF properties to
elf::reader by calling elf::reader::read_corpus().
Newer front-ends will be able to do the same.
(dwarf::reader::reset_corpus): New member function.
(dwarf::reader::read_debug_info_into_corpus): Adjust. This
is now a member function. Also, do not set the
corpus::LINUX_KERNEL_BINARY_ORIGIN here as it's now set by the
elf::reader when it loads the binary.
(dwarf::reader::{env, drop_undefined_syms,
drop_undefined_syms, dwarf_elf_handle, dwarf_per_die_source,
elf_path, compute_canonical_die_offset, get_die_source,
get_die_from_offset, get_die_qualified_name,
get_die_pretty_type_representation, get_die_qualified_type_name,
get_die_pretty_representation, odr_is_relevant,
set_canonical_die_offset, get_canonical_die_offset,
erase_canonical_die_offset, die_wip_classes_map,
die_wip_function_types_map, compare_before_canonicalisation,
resolve_declaration_only_classes, resolve_declaration_only_enums,
symbol_already_belongs_to_a_function,
fixup_functions_with_no_symbols, canonicalize_types_scheduled,
tu_die_imported_unit_points_map, die_parent_map,
find_symbol_table_section, get_variable_address,
exported_decls_builder, load_all_types, load_in_linux_kernel_mode,
show_stats, do_log, build_die_parent_maps): Adjust.
(offset_pairs_stack_type::rdr_): Changed the ctxt_ into this.
(offset_pairs_stack_type::offset_pairs_stack_type): Adjust.
(offset_pairs_stack_type::{erase_redundant_type_pair_entry,
cancel_canonical_propagated_type}): Adjust.
(dwarf::reader::{get_suppressions, offline_callbacks,
create_default_dwfl, dwfl_handle, elf_module, elf_handle,
add_debug_info_root_paths, add_debug_info_root_path,
find_alt_debug_info, dwarf, alt_dwarf, alt_debug_info_path,
current_corpus, reset_current_corpus, current_corpus_group,
has_corpus_group, main_corpus_from_current_group,
current_corpus_is_main_corpus_from_current_group,
should_reuse_type_from_corpus_group, function_symbol_is_exported,
variable_symbol_is_exported, symtab, dt_needed, dt_soname,
elf_architecture, is_elf_symbol_suppressed,
load_dt_soname_and_needed, load_elf_architecture,
load_elf_properties, maybe_add_fn_to_exported_decls,
maybe_add_var_to_exported_decls}): Remove these member functions
as they got moved into the elf_reader namespace or into the
fe_iface class.
(dwarf::read_context::{suppression_can_match,
suppression_matches_function_sym_name,
suppression_matches_function_name,
suppression_matches_variable_name,
suppression_matches_variable_sym_name,
suppression_matches_type_name_or_location}): Move these into the
suppr namespace. Make it take an additional parameter that is
reference fe_iface.
(dwarf::reader::load_debug_info): Remove. This became
merged into dwarf::read_debug_info_into_corpus.
(dwarf::{set_debug_info_root_path,
get_debug_info_root_path, get_show_stats, set_drop_undefined_syms,
set_do_log}): Remove.
(add_read_context_suppressions)
(set_read_context_corpus_group, read_corpus_from_elf): Remove.
(read_debug_info_into_corpus): This became a member function of
dwarf::reader.
(create_reader): Renamed create_read_context into this.
Make it return an elf_based_reader_sptr, like the other front-end
factory functions. Adjust.
(reset_dwarf_reader): Renamed reset_read_context into this.
Adjust.
(read_corpus_from_elf): Adjust.
* src/abg-elf-based-reader.cc: New file.
* src/abg-elf-helpers.h (struct dwfl_deleter, dwfl_sptr)
(addr_elf_symbol_sptr_map_type, address_set_sptr): Move these
types here from abg-dwarf-reader.cc
(initialize_dwfl_callbacks, lookup_data_tag_from_dynamic_segment):
* src/abg-elf-helpers.cc (lookup_data_tag_from_dynamic_segment)
(lookup_data_tag_from_dynamic_segment, initialize_dwfl_callbacks)
(create_new_dwfl_handle, get_soname_of_elf_file): New functions
that got moved here from the factorizing of abg-dwarf-reader.cc
and abg-ctf-reader.cc.
* src/abg-tools-utils.cc (file_has_dwarf_debug_info)
(file_has_ctf_debug_info): New functions.
(load_generate_apply_suppressions): Take an elf_based_reader, not
a dwarf::read_context.
(maybe_load_vmlinux_dwarf_corpus): Adjust the body to use the new
front-end types.
* src/Makefile.am: Add the new files src/abg-{fe-iface,
elf-based-reader, elf-reader}.cc to source distribution. Remove
src/abg-elf-reader-common.cc.
* tools/Makefile.am: Factorize linking to libabigail.so by using
LDADD.
* tools/abicompat.cc (read_corpus, main): Adjust.
* tools/abidiff.cc (set_suppressions)
(set_native_xml_reader_options, handle_error, main): Adjust.
* tools/abidw.cc (set_suppressions, load_corpus_and_write_abixml)
(load_kernel_corpus_group_and_write_abixml): Adjust.
* tools/abilint.cc (build_type_use_tree, show_how_type_is_used)
(set_suppressions, main): Adjust.
* tools/abipkgdiff.cc (elf_file::type, compare, compare_to_self)
(create_maps_of_package_content)
(compare_prepared_userspace_packages)
(self_compare_prepared_userspace_package): Adjust.
* tools/abisym.cc: Adjust invocation to
abigail::dwarf::lookup_symbol_from_elf, from
abigail::dwarf_reader::lookup_symbol_from_elf.
* tools/kmidiff.cc (main): Adjust.
* tests/print-diff-tree.cc (main): Adjust.
* tests/test-abidiff.cc (main): Likewise.
* tests/test-diff-dwarf.cc (main): Likewise.
* tests/test-ir-walker.cc (main): Likewise.
* tests/test-read-ctf.cc (test_task_ctf::perform): Likewise.
* tests/test-read-dwarf.cc: Remove the useless "using" statements.
* tests/test-read-write.cc: Likewise.
* tests/test-symtab.cc (read_corpus, TEST_CASE)
(assert_symbol_count): Adjust.
* tests/data/test-read-ctf/test0.abi: Adjust.
* tests/data/test-read-ctf/test0.hash.abi: Likewise.
* tests/data/test-read-ctf/test1.so.abi: Likewise.
* tests/data/test-read-ctf/test1.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test2.so.abi: Likewise.
* tests/data/test-read-ctf/test2.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test3.so.abi: Likewise.
* tests/data/test-read-ctf/test3.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test4.so.abi: Likewise.
* tests/data/test-read-ctf/test4.so.hash.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-15 16:26:37 +00:00
|
|
|
using namespace abigail;
|
|
|
|
|
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
|
|
|
static InOutSpec in_out_specs[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"data/test-read-ctf/test0",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test0.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test0.abi",
|
|
|
|
"--ctf"
|
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-ctf/test0",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
HASH_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test0.hash.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test0.hash.abi",
|
|
|
|
"--ctf"
|
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-ctf/test1.so",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test1.so.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test1.so.abi",
|
|
|
|
"--ctf"
|
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-ctf/test1.so",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
HASH_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test1.so.hash.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test1.so.hash.abi",
|
|
|
|
"--ctf"
|
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-ctf/test2.so",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test2.so.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test2.so.abi",
|
|
|
|
"--ctf"
|
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-ctf/test2.so",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
HASH_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test2.so.hash.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test2.so.hash.abi",
|
|
|
|
"--ctf"
|
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",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test3.so.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test3.so.abi",
|
|
|
|
"--ctf"
|
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",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
HASH_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test3.so.hash.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test3.so.hash.abi",
|
|
|
|
"--ctf"
|
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-ctf/test-enum-many.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
HASH_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-enum-many.o.hash.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test-enum-many.o.hash.abi",
|
|
|
|
"--ctf"
|
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-ctf/test-ambiguous-struct-A.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
HASH_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test-ambiguous-struct-A.o.hash.abi",
|
|
|
|
"--ctf"
|
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-ctf/test-ambiguous-struct-B.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
HASH_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-ambiguous-struct-B.o.hash.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test-ambiguous-struct-B.o.hash.abi",
|
|
|
|
"--ctf"
|
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-ctf/test-conflicting-type-syms-a.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
HASH_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-conflicting-type-syms-a.o.hash.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test-conflicting-type-syms-a.o.hash.abi",
|
|
|
|
"--ctf"
|
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-ctf/test-conflicting-type-syms-b.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
HASH_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-conflicting-type-syms-b.o.hash.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test-conflicting-type-syms-b.o.hash.abi",
|
|
|
|
"--ctf"
|
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",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test4.so.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test4.so.abi",
|
|
|
|
"--ctf"
|
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",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
HASH_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test4.so.hash.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test4.so.hash.abi",
|
|
|
|
"--ctf"
|
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-ctf/test5.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test5.o.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test5.o.abi",
|
|
|
|
"--ctf"
|
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-ctf/test7.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test7.o.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test7.o.abi",
|
|
|
|
"--ctf"
|
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-ctf/test8.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test8.o.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test8.o.abi",
|
|
|
|
"--ctf"
|
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-ctf/test9.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test9.o.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test9.o.abi",
|
|
|
|
"--ctf"
|
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-ctf/test-enum.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-enum.o.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test-enum.o.abi",
|
|
|
|
"--ctf"
|
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-ctf/test-enum-symbol.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
HASH_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-enum-symbol.o.hash.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test-enum-symbol.o.hash.abi",
|
|
|
|
"--ctf"
|
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-ctf/test-dynamic-array.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-dynamic-array.o.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test-dynamic-array.o.abi",
|
|
|
|
"--ctf"
|
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
|
|
|
},
|
2022-04-29 14:05:19 +00:00
|
|
|
{
|
|
|
|
"data/test-read-ctf/test-anonymous-fields.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-anonymous-fields.o.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"output/test-read-ctf/test-anonymous-fields.o.abi",
|
|
|
|
"--ctf"
|
2022-04-29 14:05:19 +00:00
|
|
|
},
|
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/PR27700/test-PR27700.o",
|
|
|
|
"",
|
|
|
|
"data/test-read-common/PR27700/pub-incdir",
|
|
|
|
HASH_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/PR27700/test-PR27700.abi",
|
|
|
|
"output/test-read-ctf/PR27700/test-PR27700.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"--ctf"
|
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
|
|
|
},
|
ctf-reader: Assert on ir::hash_as_canonical_type_or_constant
In some scenarios where we declare same data types `recursively' such
as: like linked list, functions that accept the same pointer to function
as arguments, forward types declarations to build structures with member
fields with mutual dependencies, etc., an assertion is trigger:
abidw: ../../../libabigail-upstream/src/abg-ir.cc:25251: size_t
abigail::ir::hash_as_canonical_type_or_constant(const
abigail::ir::type_base*): Assertion `__abg_cond__' failed.
It is happening because the recursively behavior of `process_ctf_type'
and `process_ctf_*' used to register ctf types doesn't verify when a
ctf_type was processed and registered before by their subsequence
_recursive_ calls, so `type_base' object is built more than once and the
second time when it is inserted in `types_maps', it refuses in a silent
way, being that the key was already inserted, however
`add_decl_to_scope', `bind_function_type_life_time' successfully
registered the ctf type object. In this patch `process_ctf_type'
delegates register types task to `process_ctf_*' functions guaranteeing
a single ctf type registration, also it improves the performance looking
for the type before start to build it again.
* src/abg-ctf-reader.cc (process_ctf_base_type): Add new
`translation_unit_sptr' parameter. Add condition to validate
success 'base_type' construction and register type object.
(process_ctf_typedef): Add `lookup_type' to get a `type_base'
object when this was previously created, if this is not the
case, register ctf type. Add condition to validate success
'base_type' construction and register type object.
(process_ctf_function_type): Likewise.
(process_ctf_array_type): Likewise.
(process_ctf_qualified_type): Likewise.
(process_ctf_pointer_type): Likewise.
(process_ctf_struct_type): Add `add_decl_to_scope'.
(process_ctf_union_type): Likewise.
(process_ctf_type): Add `lookup_type' to get a `type_base'
object when this was previously created. Delegate register
type object to `process_ctf_*'.
* tests/data/Makefile.am: Add tests I/O and expected files.
* tests/data/test-read-ctf/test-array-of-pointers.[co]: New
testcase.
* tests/data/test-read-ctf/test-list-struct.[co]: Likewise.
* tests/data/test-read-ctf/test-callback.[co]: Likewise.
* tests/data/test-read-ctf/test-callback2.[co]: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.[co]: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.[co]: Likewise.
* tests/data/test-read-ctf/test-array-of-pointers.abi:
Expected test output.
* tests/data/test-read-ctf/test-callback.abi: Likewise.
* tests/data/test-read-ctf/test-callback2.abi: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.abi: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.abi: Likewise.
* tests/data/test-read-ctf/test-list-struct.abi: Likewise.
* tests/test-read-ctf.cc: Add testcases to CTF test harness.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-12-21 19:29:55 +00:00
|
|
|
{
|
|
|
|
"data/test-read-ctf/test-callback.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-callback.abi",
|
|
|
|
"output/test-read-ctf/test-callback.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"--ctf"
|
ctf-reader: Assert on ir::hash_as_canonical_type_or_constant
In some scenarios where we declare same data types `recursively' such
as: like linked list, functions that accept the same pointer to function
as arguments, forward types declarations to build structures with member
fields with mutual dependencies, etc., an assertion is trigger:
abidw: ../../../libabigail-upstream/src/abg-ir.cc:25251: size_t
abigail::ir::hash_as_canonical_type_or_constant(const
abigail::ir::type_base*): Assertion `__abg_cond__' failed.
It is happening because the recursively behavior of `process_ctf_type'
and `process_ctf_*' used to register ctf types doesn't verify when a
ctf_type was processed and registered before by their subsequence
_recursive_ calls, so `type_base' object is built more than once and the
second time when it is inserted in `types_maps', it refuses in a silent
way, being that the key was already inserted, however
`add_decl_to_scope', `bind_function_type_life_time' successfully
registered the ctf type object. In this patch `process_ctf_type'
delegates register types task to `process_ctf_*' functions guaranteeing
a single ctf type registration, also it improves the performance looking
for the type before start to build it again.
* src/abg-ctf-reader.cc (process_ctf_base_type): Add new
`translation_unit_sptr' parameter. Add condition to validate
success 'base_type' construction and register type object.
(process_ctf_typedef): Add `lookup_type' to get a `type_base'
object when this was previously created, if this is not the
case, register ctf type. Add condition to validate success
'base_type' construction and register type object.
(process_ctf_function_type): Likewise.
(process_ctf_array_type): Likewise.
(process_ctf_qualified_type): Likewise.
(process_ctf_pointer_type): Likewise.
(process_ctf_struct_type): Add `add_decl_to_scope'.
(process_ctf_union_type): Likewise.
(process_ctf_type): Add `lookup_type' to get a `type_base'
object when this was previously created. Delegate register
type object to `process_ctf_*'.
* tests/data/Makefile.am: Add tests I/O and expected files.
* tests/data/test-read-ctf/test-array-of-pointers.[co]: New
testcase.
* tests/data/test-read-ctf/test-list-struct.[co]: Likewise.
* tests/data/test-read-ctf/test-callback.[co]: Likewise.
* tests/data/test-read-ctf/test-callback2.[co]: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.[co]: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.[co]: Likewise.
* tests/data/test-read-ctf/test-array-of-pointers.abi:
Expected test output.
* tests/data/test-read-ctf/test-callback.abi: Likewise.
* tests/data/test-read-ctf/test-callback2.abi: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.abi: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.abi: Likewise.
* tests/data/test-read-ctf/test-list-struct.abi: Likewise.
* tests/test-read-ctf.cc: Add testcases to CTF test harness.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-12-21 19:29:55 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-ctf/test-array-of-pointers.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-array-of-pointers.abi",
|
|
|
|
"output/test-read-ctf/test-array-of-pointers.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"--ctf"
|
ctf-reader: Assert on ir::hash_as_canonical_type_or_constant
In some scenarios where we declare same data types `recursively' such
as: like linked list, functions that accept the same pointer to function
as arguments, forward types declarations to build structures with member
fields with mutual dependencies, etc., an assertion is trigger:
abidw: ../../../libabigail-upstream/src/abg-ir.cc:25251: size_t
abigail::ir::hash_as_canonical_type_or_constant(const
abigail::ir::type_base*): Assertion `__abg_cond__' failed.
It is happening because the recursively behavior of `process_ctf_type'
and `process_ctf_*' used to register ctf types doesn't verify when a
ctf_type was processed and registered before by their subsequence
_recursive_ calls, so `type_base' object is built more than once and the
second time when it is inserted in `types_maps', it refuses in a silent
way, being that the key was already inserted, however
`add_decl_to_scope', `bind_function_type_life_time' successfully
registered the ctf type object. In this patch `process_ctf_type'
delegates register types task to `process_ctf_*' functions guaranteeing
a single ctf type registration, also it improves the performance looking
for the type before start to build it again.
* src/abg-ctf-reader.cc (process_ctf_base_type): Add new
`translation_unit_sptr' parameter. Add condition to validate
success 'base_type' construction and register type object.
(process_ctf_typedef): Add `lookup_type' to get a `type_base'
object when this was previously created, if this is not the
case, register ctf type. Add condition to validate success
'base_type' construction and register type object.
(process_ctf_function_type): Likewise.
(process_ctf_array_type): Likewise.
(process_ctf_qualified_type): Likewise.
(process_ctf_pointer_type): Likewise.
(process_ctf_struct_type): Add `add_decl_to_scope'.
(process_ctf_union_type): Likewise.
(process_ctf_type): Add `lookup_type' to get a `type_base'
object when this was previously created. Delegate register
type object to `process_ctf_*'.
* tests/data/Makefile.am: Add tests I/O and expected files.
* tests/data/test-read-ctf/test-array-of-pointers.[co]: New
testcase.
* tests/data/test-read-ctf/test-list-struct.[co]: Likewise.
* tests/data/test-read-ctf/test-callback.[co]: Likewise.
* tests/data/test-read-ctf/test-callback2.[co]: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.[co]: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.[co]: Likewise.
* tests/data/test-read-ctf/test-array-of-pointers.abi:
Expected test output.
* tests/data/test-read-ctf/test-callback.abi: Likewise.
* tests/data/test-read-ctf/test-callback2.abi: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.abi: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.abi: Likewise.
* tests/data/test-read-ctf/test-list-struct.abi: Likewise.
* tests/test-read-ctf.cc: Add testcases to CTF test harness.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-12-21 19:29:55 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-ctf/test-functions-declaration.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-functions-declaration.abi",
|
|
|
|
"output/test-read-ctf/test-functions-declaration.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"--ctf"
|
ctf-reader: Assert on ir::hash_as_canonical_type_or_constant
In some scenarios where we declare same data types `recursively' such
as: like linked list, functions that accept the same pointer to function
as arguments, forward types declarations to build structures with member
fields with mutual dependencies, etc., an assertion is trigger:
abidw: ../../../libabigail-upstream/src/abg-ir.cc:25251: size_t
abigail::ir::hash_as_canonical_type_or_constant(const
abigail::ir::type_base*): Assertion `__abg_cond__' failed.
It is happening because the recursively behavior of `process_ctf_type'
and `process_ctf_*' used to register ctf types doesn't verify when a
ctf_type was processed and registered before by their subsequence
_recursive_ calls, so `type_base' object is built more than once and the
second time when it is inserted in `types_maps', it refuses in a silent
way, being that the key was already inserted, however
`add_decl_to_scope', `bind_function_type_life_time' successfully
registered the ctf type object. In this patch `process_ctf_type'
delegates register types task to `process_ctf_*' functions guaranteeing
a single ctf type registration, also it improves the performance looking
for the type before start to build it again.
* src/abg-ctf-reader.cc (process_ctf_base_type): Add new
`translation_unit_sptr' parameter. Add condition to validate
success 'base_type' construction and register type object.
(process_ctf_typedef): Add `lookup_type' to get a `type_base'
object when this was previously created, if this is not the
case, register ctf type. Add condition to validate success
'base_type' construction and register type object.
(process_ctf_function_type): Likewise.
(process_ctf_array_type): Likewise.
(process_ctf_qualified_type): Likewise.
(process_ctf_pointer_type): Likewise.
(process_ctf_struct_type): Add `add_decl_to_scope'.
(process_ctf_union_type): Likewise.
(process_ctf_type): Add `lookup_type' to get a `type_base'
object when this was previously created. Delegate register
type object to `process_ctf_*'.
* tests/data/Makefile.am: Add tests I/O and expected files.
* tests/data/test-read-ctf/test-array-of-pointers.[co]: New
testcase.
* tests/data/test-read-ctf/test-list-struct.[co]: Likewise.
* tests/data/test-read-ctf/test-callback.[co]: Likewise.
* tests/data/test-read-ctf/test-callback2.[co]: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.[co]: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.[co]: Likewise.
* tests/data/test-read-ctf/test-array-of-pointers.abi:
Expected test output.
* tests/data/test-read-ctf/test-callback.abi: Likewise.
* tests/data/test-read-ctf/test-callback2.abi: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.abi: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.abi: Likewise.
* tests/data/test-read-ctf/test-list-struct.abi: Likewise.
* tests/test-read-ctf.cc: Add testcases to CTF test harness.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-12-21 19:29:55 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-ctf/test-forward-type-decl.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-forward-type-decl.abi",
|
|
|
|
"output/test-read-ctf/test-forward-type-decl.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"--ctf"
|
ctf-reader: Assert on ir::hash_as_canonical_type_or_constant
In some scenarios where we declare same data types `recursively' such
as: like linked list, functions that accept the same pointer to function
as arguments, forward types declarations to build structures with member
fields with mutual dependencies, etc., an assertion is trigger:
abidw: ../../../libabigail-upstream/src/abg-ir.cc:25251: size_t
abigail::ir::hash_as_canonical_type_or_constant(const
abigail::ir::type_base*): Assertion `__abg_cond__' failed.
It is happening because the recursively behavior of `process_ctf_type'
and `process_ctf_*' used to register ctf types doesn't verify when a
ctf_type was processed and registered before by their subsequence
_recursive_ calls, so `type_base' object is built more than once and the
second time when it is inserted in `types_maps', it refuses in a silent
way, being that the key was already inserted, however
`add_decl_to_scope', `bind_function_type_life_time' successfully
registered the ctf type object. In this patch `process_ctf_type'
delegates register types task to `process_ctf_*' functions guaranteeing
a single ctf type registration, also it improves the performance looking
for the type before start to build it again.
* src/abg-ctf-reader.cc (process_ctf_base_type): Add new
`translation_unit_sptr' parameter. Add condition to validate
success 'base_type' construction and register type object.
(process_ctf_typedef): Add `lookup_type' to get a `type_base'
object when this was previously created, if this is not the
case, register ctf type. Add condition to validate success
'base_type' construction and register type object.
(process_ctf_function_type): Likewise.
(process_ctf_array_type): Likewise.
(process_ctf_qualified_type): Likewise.
(process_ctf_pointer_type): Likewise.
(process_ctf_struct_type): Add `add_decl_to_scope'.
(process_ctf_union_type): Likewise.
(process_ctf_type): Add `lookup_type' to get a `type_base'
object when this was previously created. Delegate register
type object to `process_ctf_*'.
* tests/data/Makefile.am: Add tests I/O and expected files.
* tests/data/test-read-ctf/test-array-of-pointers.[co]: New
testcase.
* tests/data/test-read-ctf/test-list-struct.[co]: Likewise.
* tests/data/test-read-ctf/test-callback.[co]: Likewise.
* tests/data/test-read-ctf/test-callback2.[co]: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.[co]: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.[co]: Likewise.
* tests/data/test-read-ctf/test-array-of-pointers.abi:
Expected test output.
* tests/data/test-read-ctf/test-callback.abi: Likewise.
* tests/data/test-read-ctf/test-callback2.abi: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.abi: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.abi: Likewise.
* tests/data/test-read-ctf/test-list-struct.abi: Likewise.
* tests/test-read-ctf.cc: Add testcases to CTF test harness.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-12-21 19:29:55 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-ctf/test-list-struct.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-list-struct.abi",
|
|
|
|
"output/test-read-ctf/test-list-struct.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"--ctf"
|
ctf-reader: Assert on ir::hash_as_canonical_type_or_constant
In some scenarios where we declare same data types `recursively' such
as: like linked list, functions that accept the same pointer to function
as arguments, forward types declarations to build structures with member
fields with mutual dependencies, etc., an assertion is trigger:
abidw: ../../../libabigail-upstream/src/abg-ir.cc:25251: size_t
abigail::ir::hash_as_canonical_type_or_constant(const
abigail::ir::type_base*): Assertion `__abg_cond__' failed.
It is happening because the recursively behavior of `process_ctf_type'
and `process_ctf_*' used to register ctf types doesn't verify when a
ctf_type was processed and registered before by their subsequence
_recursive_ calls, so `type_base' object is built more than once and the
second time when it is inserted in `types_maps', it refuses in a silent
way, being that the key was already inserted, however
`add_decl_to_scope', `bind_function_type_life_time' successfully
registered the ctf type object. In this patch `process_ctf_type'
delegates register types task to `process_ctf_*' functions guaranteeing
a single ctf type registration, also it improves the performance looking
for the type before start to build it again.
* src/abg-ctf-reader.cc (process_ctf_base_type): Add new
`translation_unit_sptr' parameter. Add condition to validate
success 'base_type' construction and register type object.
(process_ctf_typedef): Add `lookup_type' to get a `type_base'
object when this was previously created, if this is not the
case, register ctf type. Add condition to validate success
'base_type' construction and register type object.
(process_ctf_function_type): Likewise.
(process_ctf_array_type): Likewise.
(process_ctf_qualified_type): Likewise.
(process_ctf_pointer_type): Likewise.
(process_ctf_struct_type): Add `add_decl_to_scope'.
(process_ctf_union_type): Likewise.
(process_ctf_type): Add `lookup_type' to get a `type_base'
object when this was previously created. Delegate register
type object to `process_ctf_*'.
* tests/data/Makefile.am: Add tests I/O and expected files.
* tests/data/test-read-ctf/test-array-of-pointers.[co]: New
testcase.
* tests/data/test-read-ctf/test-list-struct.[co]: Likewise.
* tests/data/test-read-ctf/test-callback.[co]: Likewise.
* tests/data/test-read-ctf/test-callback2.[co]: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.[co]: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.[co]: Likewise.
* tests/data/test-read-ctf/test-array-of-pointers.abi:
Expected test output.
* tests/data/test-read-ctf/test-callback.abi: Likewise.
* tests/data/test-read-ctf/test-callback2.abi: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.abi: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.abi: Likewise.
* tests/data/test-read-ctf/test-list-struct.abi: Likewise.
* tests/test-read-ctf.cc: Add testcases to CTF test harness.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-12-21 19:29:55 +00:00
|
|
|
},
|
|
|
|
{
|
ctf-reader: Add support to read CTF information from the Linux Kernel
This patch is meant to extract ABI information from the CTF data
stored in the Linux kernel build directory. It depends on the
vmlinux.ctfa archive file.
In order to generate the CTF information, the Linux Kernel build
system must support the 'make ctf' command, which causes the compiler
to be run with -gctf, thus emitting the CTF information for the
Kernel.
The target 'ctf' in the Linux Makefile generates a 'vmlinux.ctfa' file
that will be used by the ctf reader in libabigail. The 'vmlinux.ctfa'
archive has multiple 'ctf dictionaries' called "CTF archive members".
There is one CTF archive member for built-in kernel modules (in
`vmlinux') and one for each out-of-tree kernel module organized in a
parent-child hierarchy.
There is also a CTF archive member called `shared_ctf' which is a
parent dictionary containing shared symbols and CTF types used by more
than one kernel object. These common types are stored in 'types_map'
in the ctf reader, ignoring the ctf dictionary name. The CTF API has
the machinery for looking for a shared type in the parent dictionary
referred to in a given child dictionary. This CTF layout can be dumped
by using the objdump tool.
Due to the fact that the _same_ ctf archive is used to build the
vmlinux corpus the corpora of the kernel module (which, by the way,
all belong to the same corpus group), the high number of open/close on
the CTF archive is very time consuming during the ctf extraction.
So, the performance is improved up to 300% (from ~2m:50s to ~50s) by
keeping the ctf archive open for a given group, and thus, by using the
same ctf_archive_t pointer while building all the various corpora.
We just invoke `reset_read_context' for each new corpus. Note that
the `read_context::ctfa` data member should be updated if the
corpus::origin data member is set to `LINUX_KERNEL_BINARY_ORIGIN' and
the file to be process is not 'vmlinux'.
Note that `ctf_close' must be called after processing all group's
members so it is executed from the destructor of `reader_context'.
The basic algorithm used to generate the Linux corpus is the
following:
1. Looking for: vmlinux, *.ko objects, and vmlinux.ctfa files. The
first files are used to extract the ELF symbols, and the last one
contains the CTF type information for non-static variables and
functions symbols.
2. `process_ctf_archive' iterates on public symbols for vmlinux and
its modules, using the name of the symbol, ctf reader search for CTF
information in its dictionary, if the information was found it
builds a `var_decl' or `function_decl' depending of `ctf_type_kind'
result.
This algorithm is also applied to ELF files (exec, dyn, rel), so
instead of iterating on all ctf_types it just loops on the public
symbols.
* abg-elf-reader-common.h: Include ctf-api.h file.
(read_and_add_corpus_to_group_from_elf, set_read_context_corpus_group)
(reset_read_context, dic_type_key): Declare new member functions.
* include/abg-ir.cc (types_defined_same_linux_kernel_corpus_public): Use
bitwise to know the corpus `origin'.
* src/abg-ctf-reader.cc: Include map, algorithms header files.
(read_context::type_map): Change from unordered_map to std::map storing
ctf dictionary name as part of the key.
(read_context::is_elf_exec): Add new member variable.
(read_context::{cur_corpus_, cur_corpus_group_}): Likewise.
(read_context::unknown_types_set): Likewise.
(read_context::{current_corpus_group, main_corpus_from_current_group,
has_corpus_group, current_corpus_is_main_corpus_from_current_group,
should_reuse_type_from_corpus_group}): Add new member functions.
(read_context::{add_unknown_type, lookup_unknown_type, initialize}):
Likewise.
(read_context::{add_type, lookup_type}): Add new `ctf_dict_t' type
argument.
(ctf_reader::{process_ctf_typedef, process_ctf_base_type,
process_ctf_function_type, process_ctf_forward_type,
process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type,
process_ctf_qualified_type, process_ctf_enum_type}): Add code to `reuse'
types already registered in main corpus `should_reuse_type_from_corpus_group'.
Use new `lookup_type' and `add_type' operations on `read_context::types_map'.
Replace function calls to the new ctf interface. Add verifier to not build
types duplicated by recursive calling chain.
(ctf_reader::process_ctf_type): Add code to return immediately if the
ctf type is unknown. Add unknown types to `unknown_types_set'.
(ctf_reader::process_ctf_archive): Change comment.
Add code to iterate over global symbols, searching by symbol name in the
ctf dictionary using `ctf_lookup_{variable,by_symbol_name}' depending of
the ELF file type and corpus type, creating a `{var,fuc}_decl' using the
return type of `ctf_type_kind'. Also close the ctf dict and call
`canonicalize_all_types'.
(slurp_elf_info): Set `is_elf_exec' depending of ELF type. Also return
success if corpus origin is Linux and symbol table was read.
(ctf_reader::read_corpus): Add current corpus. Set corpus origin to
`LINUX_KERNEL_BINARY_ORIGIN' if `is_linux_kernel' returns true. Verify
the ctf reader status, now the ctf archive is 'opened' using
`ctf_arc{open,bufopen}' depending if the corpus origin has
`corpus::LINUX_KERNEL_BINARY_ORIGIN' bit set. Use
`sort_{function,variables}' calls after extract ctf information.
`ctf_close' is called from `read_context' destructor.
(read:context::{set_read_context_corpus_group, reset_read_context,
read_and_add_corpus_to_group_from_elf, dic_type_key): Add new member
function implementation.
* include/abg-tools-utils.h (build_corpus_group_from_kernel_dist_under):
Add `origin' parameter with default `corpus::DWARF_ORIGIN'.
* src/abg-tools-utils.cc: Use `abg-ctf-reader.h' file.
(maybe_load_vmlinux_dwarf_corpus): Add new function.
(maybe_load_vmlinux_ctf_corpus): Likewise.
(build_corpus_group_from_kernel_dist_under): Update comments.
Add new `origin' argument. Use `maybe_load_vmlinux_dwarf_corpus'
or `maybe_load_vmlinux_ctf_corpus' according to `origin' value.
* src/abg-corpus.h (corpus::origin): Update `origin' type
values in enum.
* src/abg-corpus-priv.h (corpus::priv): Replace `origin' type
from `corpus::origin' to `uint32_t'.
* src/abg-corpus.cc (corpus::{get,set}_origin): Replace data
type from `corpus::origin' to `uint32_t'.
* tools/abidw.cc (main): Use of --ctf argument to set format debug.
* tests/test-read-ctf.cc: Add new tests to harness.
* tests/data/test-read-ctf/test-PR27700.abi: New test expected
result.
* tests/data/test-read-ctf/test-anonymous-fields.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-many-ctf.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum-many.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum-symbol-ctf.o.hash.abi: Likewise.
* tests/data/test-read-common/test-PR26568-2.o: Adjust.
* tests/data/test-read-ctf/test-PR26568-1.o.abi: Likewise.
* tests/data/test-read-ctf/test-PR26568-2.o.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.c: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.o: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-array-of-pointers.abi: Likewise.
* tests/data/test-read-ctf/test-callback.abi: Likewise.
* tests/data/test-read-ctf/test-callback2.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-dynamic-array.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-ctf.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum.o.abi: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.abi: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.abi: Likewise.
* tests/data/test-read-ctf/test-list-struct.abi: Likewise.
* tests/data/test-read-ctf/test0: Likewise.
* tests/data/test-read-ctf/test0.abi: Likewise.
* tests/data/test-read-ctf/test0.c: Likewise.
* tests/data/test-read-ctf/test0.hash.abi: Likewise.
* tests/data/test-read-ctf/test1.so.abi: Likewise.
* tests/data/test-read-ctf/test1.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test2.so.abi: Likewise.
* tests/data/test-read-ctf/test2.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test3.so.abi: Likewise.
* tests/data/test-read-ctf/test3.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test4.so.abi: Likewise.
* tests/data/test-read-ctf/test4.so.hash.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.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-05-04 22:29:30 +00:00
|
|
|
"data/test-read-common/test-PR26568-1.o",
|
ctf-reader: Assert on ir::hash_as_canonical_type_or_constant
In some scenarios where we declare same data types `recursively' such
as: like linked list, functions that accept the same pointer to function
as arguments, forward types declarations to build structures with member
fields with mutual dependencies, etc., an assertion is trigger:
abidw: ../../../libabigail-upstream/src/abg-ir.cc:25251: size_t
abigail::ir::hash_as_canonical_type_or_constant(const
abigail::ir::type_base*): Assertion `__abg_cond__' failed.
It is happening because the recursively behavior of `process_ctf_type'
and `process_ctf_*' used to register ctf types doesn't verify when a
ctf_type was processed and registered before by their subsequence
_recursive_ calls, so `type_base' object is built more than once and the
second time when it is inserted in `types_maps', it refuses in a silent
way, being that the key was already inserted, however
`add_decl_to_scope', `bind_function_type_life_time' successfully
registered the ctf type object. In this patch `process_ctf_type'
delegates register types task to `process_ctf_*' functions guaranteeing
a single ctf type registration, also it improves the performance looking
for the type before start to build it again.
* src/abg-ctf-reader.cc (process_ctf_base_type): Add new
`translation_unit_sptr' parameter. Add condition to validate
success 'base_type' construction and register type object.
(process_ctf_typedef): Add `lookup_type' to get a `type_base'
object when this was previously created, if this is not the
case, register ctf type. Add condition to validate success
'base_type' construction and register type object.
(process_ctf_function_type): Likewise.
(process_ctf_array_type): Likewise.
(process_ctf_qualified_type): Likewise.
(process_ctf_pointer_type): Likewise.
(process_ctf_struct_type): Add `add_decl_to_scope'.
(process_ctf_union_type): Likewise.
(process_ctf_type): Add `lookup_type' to get a `type_base'
object when this was previously created. Delegate register
type object to `process_ctf_*'.
* tests/data/Makefile.am: Add tests I/O and expected files.
* tests/data/test-read-ctf/test-array-of-pointers.[co]: New
testcase.
* tests/data/test-read-ctf/test-list-struct.[co]: Likewise.
* tests/data/test-read-ctf/test-callback.[co]: Likewise.
* tests/data/test-read-ctf/test-callback2.[co]: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.[co]: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.[co]: Likewise.
* tests/data/test-read-ctf/test-array-of-pointers.abi:
Expected test output.
* tests/data/test-read-ctf/test-callback.abi: Likewise.
* tests/data/test-read-ctf/test-callback2.abi: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.abi: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.abi: Likewise.
* tests/data/test-read-ctf/test-list-struct.abi: Likewise.
* tests/test-read-ctf.cc: Add testcases to CTF test harness.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-12-21 19:29:55 +00:00
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
ctf-reader: Add support to read CTF information from the Linux Kernel
This patch is meant to extract ABI information from the CTF data
stored in the Linux kernel build directory. It depends on the
vmlinux.ctfa archive file.
In order to generate the CTF information, the Linux Kernel build
system must support the 'make ctf' command, which causes the compiler
to be run with -gctf, thus emitting the CTF information for the
Kernel.
The target 'ctf' in the Linux Makefile generates a 'vmlinux.ctfa' file
that will be used by the ctf reader in libabigail. The 'vmlinux.ctfa'
archive has multiple 'ctf dictionaries' called "CTF archive members".
There is one CTF archive member for built-in kernel modules (in
`vmlinux') and one for each out-of-tree kernel module organized in a
parent-child hierarchy.
There is also a CTF archive member called `shared_ctf' which is a
parent dictionary containing shared symbols and CTF types used by more
than one kernel object. These common types are stored in 'types_map'
in the ctf reader, ignoring the ctf dictionary name. The CTF API has
the machinery for looking for a shared type in the parent dictionary
referred to in a given child dictionary. This CTF layout can be dumped
by using the objdump tool.
Due to the fact that the _same_ ctf archive is used to build the
vmlinux corpus the corpora of the kernel module (which, by the way,
all belong to the same corpus group), the high number of open/close on
the CTF archive is very time consuming during the ctf extraction.
So, the performance is improved up to 300% (from ~2m:50s to ~50s) by
keeping the ctf archive open for a given group, and thus, by using the
same ctf_archive_t pointer while building all the various corpora.
We just invoke `reset_read_context' for each new corpus. Note that
the `read_context::ctfa` data member should be updated if the
corpus::origin data member is set to `LINUX_KERNEL_BINARY_ORIGIN' and
the file to be process is not 'vmlinux'.
Note that `ctf_close' must be called after processing all group's
members so it is executed from the destructor of `reader_context'.
The basic algorithm used to generate the Linux corpus is the
following:
1. Looking for: vmlinux, *.ko objects, and vmlinux.ctfa files. The
first files are used to extract the ELF symbols, and the last one
contains the CTF type information for non-static variables and
functions symbols.
2. `process_ctf_archive' iterates on public symbols for vmlinux and
its modules, using the name of the symbol, ctf reader search for CTF
information in its dictionary, if the information was found it
builds a `var_decl' or `function_decl' depending of `ctf_type_kind'
result.
This algorithm is also applied to ELF files (exec, dyn, rel), so
instead of iterating on all ctf_types it just loops on the public
symbols.
* abg-elf-reader-common.h: Include ctf-api.h file.
(read_and_add_corpus_to_group_from_elf, set_read_context_corpus_group)
(reset_read_context, dic_type_key): Declare new member functions.
* include/abg-ir.cc (types_defined_same_linux_kernel_corpus_public): Use
bitwise to know the corpus `origin'.
* src/abg-ctf-reader.cc: Include map, algorithms header files.
(read_context::type_map): Change from unordered_map to std::map storing
ctf dictionary name as part of the key.
(read_context::is_elf_exec): Add new member variable.
(read_context::{cur_corpus_, cur_corpus_group_}): Likewise.
(read_context::unknown_types_set): Likewise.
(read_context::{current_corpus_group, main_corpus_from_current_group,
has_corpus_group, current_corpus_is_main_corpus_from_current_group,
should_reuse_type_from_corpus_group}): Add new member functions.
(read_context::{add_unknown_type, lookup_unknown_type, initialize}):
Likewise.
(read_context::{add_type, lookup_type}): Add new `ctf_dict_t' type
argument.
(ctf_reader::{process_ctf_typedef, process_ctf_base_type,
process_ctf_function_type, process_ctf_forward_type,
process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type,
process_ctf_qualified_type, process_ctf_enum_type}): Add code to `reuse'
types already registered in main corpus `should_reuse_type_from_corpus_group'.
Use new `lookup_type' and `add_type' operations on `read_context::types_map'.
Replace function calls to the new ctf interface. Add verifier to not build
types duplicated by recursive calling chain.
(ctf_reader::process_ctf_type): Add code to return immediately if the
ctf type is unknown. Add unknown types to `unknown_types_set'.
(ctf_reader::process_ctf_archive): Change comment.
Add code to iterate over global symbols, searching by symbol name in the
ctf dictionary using `ctf_lookup_{variable,by_symbol_name}' depending of
the ELF file type and corpus type, creating a `{var,fuc}_decl' using the
return type of `ctf_type_kind'. Also close the ctf dict and call
`canonicalize_all_types'.
(slurp_elf_info): Set `is_elf_exec' depending of ELF type. Also return
success if corpus origin is Linux and symbol table was read.
(ctf_reader::read_corpus): Add current corpus. Set corpus origin to
`LINUX_KERNEL_BINARY_ORIGIN' if `is_linux_kernel' returns true. Verify
the ctf reader status, now the ctf archive is 'opened' using
`ctf_arc{open,bufopen}' depending if the corpus origin has
`corpus::LINUX_KERNEL_BINARY_ORIGIN' bit set. Use
`sort_{function,variables}' calls after extract ctf information.
`ctf_close' is called from `read_context' destructor.
(read:context::{set_read_context_corpus_group, reset_read_context,
read_and_add_corpus_to_group_from_elf, dic_type_key): Add new member
function implementation.
* include/abg-tools-utils.h (build_corpus_group_from_kernel_dist_under):
Add `origin' parameter with default `corpus::DWARF_ORIGIN'.
* src/abg-tools-utils.cc: Use `abg-ctf-reader.h' file.
(maybe_load_vmlinux_dwarf_corpus): Add new function.
(maybe_load_vmlinux_ctf_corpus): Likewise.
(build_corpus_group_from_kernel_dist_under): Update comments.
Add new `origin' argument. Use `maybe_load_vmlinux_dwarf_corpus'
or `maybe_load_vmlinux_ctf_corpus' according to `origin' value.
* src/abg-corpus.h (corpus::origin): Update `origin' type
values in enum.
* src/abg-corpus-priv.h (corpus::priv): Replace `origin' type
from `corpus::origin' to `uint32_t'.
* src/abg-corpus.cc (corpus::{get,set}_origin): Replace data
type from `corpus::origin' to `uint32_t'.
* tools/abidw.cc (main): Use of --ctf argument to set format debug.
* tests/test-read-ctf.cc: Add new tests to harness.
* tests/data/test-read-ctf/test-PR27700.abi: New test expected
result.
* tests/data/test-read-ctf/test-anonymous-fields.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-many-ctf.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum-many.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum-symbol-ctf.o.hash.abi: Likewise.
* tests/data/test-read-common/test-PR26568-2.o: Adjust.
* tests/data/test-read-ctf/test-PR26568-1.o.abi: Likewise.
* tests/data/test-read-ctf/test-PR26568-2.o.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.c: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.o: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-array-of-pointers.abi: Likewise.
* tests/data/test-read-ctf/test-callback.abi: Likewise.
* tests/data/test-read-ctf/test-callback2.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-dynamic-array.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-ctf.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum.o.abi: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.abi: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.abi: Likewise.
* tests/data/test-read-ctf/test-list-struct.abi: Likewise.
* tests/data/test-read-ctf/test0: Likewise.
* tests/data/test-read-ctf/test0.abi: Likewise.
* tests/data/test-read-ctf/test0.c: Likewise.
* tests/data/test-read-ctf/test0.hash.abi: Likewise.
* tests/data/test-read-ctf/test1.so.abi: Likewise.
* tests/data/test-read-ctf/test1.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test2.so.abi: Likewise.
* tests/data/test-read-ctf/test2.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test3.so.abi: Likewise.
* tests/data/test-read-ctf/test3.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test4.so.abi: Likewise.
* tests/data/test-read-ctf/test4.so.hash.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.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-05-04 22:29:30 +00:00
|
|
|
"data/test-read-ctf/test-PR26568-1.o.abi",
|
|
|
|
"output/test-read-ctf/test-PR26568-1.o.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"--ctf"
|
ctf-reader: Assert on ir::hash_as_canonical_type_or_constant
In some scenarios where we declare same data types `recursively' such
as: like linked list, functions that accept the same pointer to function
as arguments, forward types declarations to build structures with member
fields with mutual dependencies, etc., an assertion is trigger:
abidw: ../../../libabigail-upstream/src/abg-ir.cc:25251: size_t
abigail::ir::hash_as_canonical_type_or_constant(const
abigail::ir::type_base*): Assertion `__abg_cond__' failed.
It is happening because the recursively behavior of `process_ctf_type'
and `process_ctf_*' used to register ctf types doesn't verify when a
ctf_type was processed and registered before by their subsequence
_recursive_ calls, so `type_base' object is built more than once and the
second time when it is inserted in `types_maps', it refuses in a silent
way, being that the key was already inserted, however
`add_decl_to_scope', `bind_function_type_life_time' successfully
registered the ctf type object. In this patch `process_ctf_type'
delegates register types task to `process_ctf_*' functions guaranteeing
a single ctf type registration, also it improves the performance looking
for the type before start to build it again.
* src/abg-ctf-reader.cc (process_ctf_base_type): Add new
`translation_unit_sptr' parameter. Add condition to validate
success 'base_type' construction and register type object.
(process_ctf_typedef): Add `lookup_type' to get a `type_base'
object when this was previously created, if this is not the
case, register ctf type. Add condition to validate success
'base_type' construction and register type object.
(process_ctf_function_type): Likewise.
(process_ctf_array_type): Likewise.
(process_ctf_qualified_type): Likewise.
(process_ctf_pointer_type): Likewise.
(process_ctf_struct_type): Add `add_decl_to_scope'.
(process_ctf_union_type): Likewise.
(process_ctf_type): Add `lookup_type' to get a `type_base'
object when this was previously created. Delegate register
type object to `process_ctf_*'.
* tests/data/Makefile.am: Add tests I/O and expected files.
* tests/data/test-read-ctf/test-array-of-pointers.[co]: New
testcase.
* tests/data/test-read-ctf/test-list-struct.[co]: Likewise.
* tests/data/test-read-ctf/test-callback.[co]: Likewise.
* tests/data/test-read-ctf/test-callback2.[co]: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.[co]: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.[co]: Likewise.
* tests/data/test-read-ctf/test-array-of-pointers.abi:
Expected test output.
* tests/data/test-read-ctf/test-callback.abi: Likewise.
* tests/data/test-read-ctf/test-callback2.abi: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.abi: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.abi: Likewise.
* tests/data/test-read-ctf/test-list-struct.abi: Likewise.
* tests/test-read-ctf.cc: Add testcases to CTF test harness.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-12-21 19:29:55 +00:00
|
|
|
},
|
2022-03-18 01:30:36 +00:00
|
|
|
{
|
ctf-reader: Add support to read CTF information from the Linux Kernel
This patch is meant to extract ABI information from the CTF data
stored in the Linux kernel build directory. It depends on the
vmlinux.ctfa archive file.
In order to generate the CTF information, the Linux Kernel build
system must support the 'make ctf' command, which causes the compiler
to be run with -gctf, thus emitting the CTF information for the
Kernel.
The target 'ctf' in the Linux Makefile generates a 'vmlinux.ctfa' file
that will be used by the ctf reader in libabigail. The 'vmlinux.ctfa'
archive has multiple 'ctf dictionaries' called "CTF archive members".
There is one CTF archive member for built-in kernel modules (in
`vmlinux') and one for each out-of-tree kernel module organized in a
parent-child hierarchy.
There is also a CTF archive member called `shared_ctf' which is a
parent dictionary containing shared symbols and CTF types used by more
than one kernel object. These common types are stored in 'types_map'
in the ctf reader, ignoring the ctf dictionary name. The CTF API has
the machinery for looking for a shared type in the parent dictionary
referred to in a given child dictionary. This CTF layout can be dumped
by using the objdump tool.
Due to the fact that the _same_ ctf archive is used to build the
vmlinux corpus the corpora of the kernel module (which, by the way,
all belong to the same corpus group), the high number of open/close on
the CTF archive is very time consuming during the ctf extraction.
So, the performance is improved up to 300% (from ~2m:50s to ~50s) by
keeping the ctf archive open for a given group, and thus, by using the
same ctf_archive_t pointer while building all the various corpora.
We just invoke `reset_read_context' for each new corpus. Note that
the `read_context::ctfa` data member should be updated if the
corpus::origin data member is set to `LINUX_KERNEL_BINARY_ORIGIN' and
the file to be process is not 'vmlinux'.
Note that `ctf_close' must be called after processing all group's
members so it is executed from the destructor of `reader_context'.
The basic algorithm used to generate the Linux corpus is the
following:
1. Looking for: vmlinux, *.ko objects, and vmlinux.ctfa files. The
first files are used to extract the ELF symbols, and the last one
contains the CTF type information for non-static variables and
functions symbols.
2. `process_ctf_archive' iterates on public symbols for vmlinux and
its modules, using the name of the symbol, ctf reader search for CTF
information in its dictionary, if the information was found it
builds a `var_decl' or `function_decl' depending of `ctf_type_kind'
result.
This algorithm is also applied to ELF files (exec, dyn, rel), so
instead of iterating on all ctf_types it just loops on the public
symbols.
* abg-elf-reader-common.h: Include ctf-api.h file.
(read_and_add_corpus_to_group_from_elf, set_read_context_corpus_group)
(reset_read_context, dic_type_key): Declare new member functions.
* include/abg-ir.cc (types_defined_same_linux_kernel_corpus_public): Use
bitwise to know the corpus `origin'.
* src/abg-ctf-reader.cc: Include map, algorithms header files.
(read_context::type_map): Change from unordered_map to std::map storing
ctf dictionary name as part of the key.
(read_context::is_elf_exec): Add new member variable.
(read_context::{cur_corpus_, cur_corpus_group_}): Likewise.
(read_context::unknown_types_set): Likewise.
(read_context::{current_corpus_group, main_corpus_from_current_group,
has_corpus_group, current_corpus_is_main_corpus_from_current_group,
should_reuse_type_from_corpus_group}): Add new member functions.
(read_context::{add_unknown_type, lookup_unknown_type, initialize}):
Likewise.
(read_context::{add_type, lookup_type}): Add new `ctf_dict_t' type
argument.
(ctf_reader::{process_ctf_typedef, process_ctf_base_type,
process_ctf_function_type, process_ctf_forward_type,
process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type,
process_ctf_qualified_type, process_ctf_enum_type}): Add code to `reuse'
types already registered in main corpus `should_reuse_type_from_corpus_group'.
Use new `lookup_type' and `add_type' operations on `read_context::types_map'.
Replace function calls to the new ctf interface. Add verifier to not build
types duplicated by recursive calling chain.
(ctf_reader::process_ctf_type): Add code to return immediately if the
ctf type is unknown. Add unknown types to `unknown_types_set'.
(ctf_reader::process_ctf_archive): Change comment.
Add code to iterate over global symbols, searching by symbol name in the
ctf dictionary using `ctf_lookup_{variable,by_symbol_name}' depending of
the ELF file type and corpus type, creating a `{var,fuc}_decl' using the
return type of `ctf_type_kind'. Also close the ctf dict and call
`canonicalize_all_types'.
(slurp_elf_info): Set `is_elf_exec' depending of ELF type. Also return
success if corpus origin is Linux and symbol table was read.
(ctf_reader::read_corpus): Add current corpus. Set corpus origin to
`LINUX_KERNEL_BINARY_ORIGIN' if `is_linux_kernel' returns true. Verify
the ctf reader status, now the ctf archive is 'opened' using
`ctf_arc{open,bufopen}' depending if the corpus origin has
`corpus::LINUX_KERNEL_BINARY_ORIGIN' bit set. Use
`sort_{function,variables}' calls after extract ctf information.
`ctf_close' is called from `read_context' destructor.
(read:context::{set_read_context_corpus_group, reset_read_context,
read_and_add_corpus_to_group_from_elf, dic_type_key): Add new member
function implementation.
* include/abg-tools-utils.h (build_corpus_group_from_kernel_dist_under):
Add `origin' parameter with default `corpus::DWARF_ORIGIN'.
* src/abg-tools-utils.cc: Use `abg-ctf-reader.h' file.
(maybe_load_vmlinux_dwarf_corpus): Add new function.
(maybe_load_vmlinux_ctf_corpus): Likewise.
(build_corpus_group_from_kernel_dist_under): Update comments.
Add new `origin' argument. Use `maybe_load_vmlinux_dwarf_corpus'
or `maybe_load_vmlinux_ctf_corpus' according to `origin' value.
* src/abg-corpus.h (corpus::origin): Update `origin' type
values in enum.
* src/abg-corpus-priv.h (corpus::priv): Replace `origin' type
from `corpus::origin' to `uint32_t'.
* src/abg-corpus.cc (corpus::{get,set}_origin): Replace data
type from `corpus::origin' to `uint32_t'.
* tools/abidw.cc (main): Use of --ctf argument to set format debug.
* tests/test-read-ctf.cc: Add new tests to harness.
* tests/data/test-read-ctf/test-PR27700.abi: New test expected
result.
* tests/data/test-read-ctf/test-anonymous-fields.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-many-ctf.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum-many.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum-symbol-ctf.o.hash.abi: Likewise.
* tests/data/test-read-common/test-PR26568-2.o: Adjust.
* tests/data/test-read-ctf/test-PR26568-1.o.abi: Likewise.
* tests/data/test-read-ctf/test-PR26568-2.o.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.c: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.o: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-array-of-pointers.abi: Likewise.
* tests/data/test-read-ctf/test-callback.abi: Likewise.
* tests/data/test-read-ctf/test-callback2.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-dynamic-array.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-ctf.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum.o.abi: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.abi: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.abi: Likewise.
* tests/data/test-read-ctf/test-list-struct.abi: Likewise.
* tests/data/test-read-ctf/test0: Likewise.
* tests/data/test-read-ctf/test0.abi: Likewise.
* tests/data/test-read-ctf/test0.c: Likewise.
* tests/data/test-read-ctf/test0.hash.abi: Likewise.
* tests/data/test-read-ctf/test1.so.abi: Likewise.
* tests/data/test-read-ctf/test1.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test2.so.abi: Likewise.
* tests/data/test-read-ctf/test2.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test3.so.abi: Likewise.
* tests/data/test-read-ctf/test3.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test4.so.abi: Likewise.
* tests/data/test-read-ctf/test4.so.hash.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.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-05-04 22:29:30 +00:00
|
|
|
"data/test-read-common/test-PR26568-2.o",
|
2022-03-18 01:30:36 +00:00
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
ctf-reader: Add support to read CTF information from the Linux Kernel
This patch is meant to extract ABI information from the CTF data
stored in the Linux kernel build directory. It depends on the
vmlinux.ctfa archive file.
In order to generate the CTF information, the Linux Kernel build
system must support the 'make ctf' command, which causes the compiler
to be run with -gctf, thus emitting the CTF information for the
Kernel.
The target 'ctf' in the Linux Makefile generates a 'vmlinux.ctfa' file
that will be used by the ctf reader in libabigail. The 'vmlinux.ctfa'
archive has multiple 'ctf dictionaries' called "CTF archive members".
There is one CTF archive member for built-in kernel modules (in
`vmlinux') and one for each out-of-tree kernel module organized in a
parent-child hierarchy.
There is also a CTF archive member called `shared_ctf' which is a
parent dictionary containing shared symbols and CTF types used by more
than one kernel object. These common types are stored in 'types_map'
in the ctf reader, ignoring the ctf dictionary name. The CTF API has
the machinery for looking for a shared type in the parent dictionary
referred to in a given child dictionary. This CTF layout can be dumped
by using the objdump tool.
Due to the fact that the _same_ ctf archive is used to build the
vmlinux corpus the corpora of the kernel module (which, by the way,
all belong to the same corpus group), the high number of open/close on
the CTF archive is very time consuming during the ctf extraction.
So, the performance is improved up to 300% (from ~2m:50s to ~50s) by
keeping the ctf archive open for a given group, and thus, by using the
same ctf_archive_t pointer while building all the various corpora.
We just invoke `reset_read_context' for each new corpus. Note that
the `read_context::ctfa` data member should be updated if the
corpus::origin data member is set to `LINUX_KERNEL_BINARY_ORIGIN' and
the file to be process is not 'vmlinux'.
Note that `ctf_close' must be called after processing all group's
members so it is executed from the destructor of `reader_context'.
The basic algorithm used to generate the Linux corpus is the
following:
1. Looking for: vmlinux, *.ko objects, and vmlinux.ctfa files. The
first files are used to extract the ELF symbols, and the last one
contains the CTF type information for non-static variables and
functions symbols.
2. `process_ctf_archive' iterates on public symbols for vmlinux and
its modules, using the name of the symbol, ctf reader search for CTF
information in its dictionary, if the information was found it
builds a `var_decl' or `function_decl' depending of `ctf_type_kind'
result.
This algorithm is also applied to ELF files (exec, dyn, rel), so
instead of iterating on all ctf_types it just loops on the public
symbols.
* abg-elf-reader-common.h: Include ctf-api.h file.
(read_and_add_corpus_to_group_from_elf, set_read_context_corpus_group)
(reset_read_context, dic_type_key): Declare new member functions.
* include/abg-ir.cc (types_defined_same_linux_kernel_corpus_public): Use
bitwise to know the corpus `origin'.
* src/abg-ctf-reader.cc: Include map, algorithms header files.
(read_context::type_map): Change from unordered_map to std::map storing
ctf dictionary name as part of the key.
(read_context::is_elf_exec): Add new member variable.
(read_context::{cur_corpus_, cur_corpus_group_}): Likewise.
(read_context::unknown_types_set): Likewise.
(read_context::{current_corpus_group, main_corpus_from_current_group,
has_corpus_group, current_corpus_is_main_corpus_from_current_group,
should_reuse_type_from_corpus_group}): Add new member functions.
(read_context::{add_unknown_type, lookup_unknown_type, initialize}):
Likewise.
(read_context::{add_type, lookup_type}): Add new `ctf_dict_t' type
argument.
(ctf_reader::{process_ctf_typedef, process_ctf_base_type,
process_ctf_function_type, process_ctf_forward_type,
process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type,
process_ctf_qualified_type, process_ctf_enum_type}): Add code to `reuse'
types already registered in main corpus `should_reuse_type_from_corpus_group'.
Use new `lookup_type' and `add_type' operations on `read_context::types_map'.
Replace function calls to the new ctf interface. Add verifier to not build
types duplicated by recursive calling chain.
(ctf_reader::process_ctf_type): Add code to return immediately if the
ctf type is unknown. Add unknown types to `unknown_types_set'.
(ctf_reader::process_ctf_archive): Change comment.
Add code to iterate over global symbols, searching by symbol name in the
ctf dictionary using `ctf_lookup_{variable,by_symbol_name}' depending of
the ELF file type and corpus type, creating a `{var,fuc}_decl' using the
return type of `ctf_type_kind'. Also close the ctf dict and call
`canonicalize_all_types'.
(slurp_elf_info): Set `is_elf_exec' depending of ELF type. Also return
success if corpus origin is Linux and symbol table was read.
(ctf_reader::read_corpus): Add current corpus. Set corpus origin to
`LINUX_KERNEL_BINARY_ORIGIN' if `is_linux_kernel' returns true. Verify
the ctf reader status, now the ctf archive is 'opened' using
`ctf_arc{open,bufopen}' depending if the corpus origin has
`corpus::LINUX_KERNEL_BINARY_ORIGIN' bit set. Use
`sort_{function,variables}' calls after extract ctf information.
`ctf_close' is called from `read_context' destructor.
(read:context::{set_read_context_corpus_group, reset_read_context,
read_and_add_corpus_to_group_from_elf, dic_type_key): Add new member
function implementation.
* include/abg-tools-utils.h (build_corpus_group_from_kernel_dist_under):
Add `origin' parameter with default `corpus::DWARF_ORIGIN'.
* src/abg-tools-utils.cc: Use `abg-ctf-reader.h' file.
(maybe_load_vmlinux_dwarf_corpus): Add new function.
(maybe_load_vmlinux_ctf_corpus): Likewise.
(build_corpus_group_from_kernel_dist_under): Update comments.
Add new `origin' argument. Use `maybe_load_vmlinux_dwarf_corpus'
or `maybe_load_vmlinux_ctf_corpus' according to `origin' value.
* src/abg-corpus.h (corpus::origin): Update `origin' type
values in enum.
* src/abg-corpus-priv.h (corpus::priv): Replace `origin' type
from `corpus::origin' to `uint32_t'.
* src/abg-corpus.cc (corpus::{get,set}_origin): Replace data
type from `corpus::origin' to `uint32_t'.
* tools/abidw.cc (main): Use of --ctf argument to set format debug.
* tests/test-read-ctf.cc: Add new tests to harness.
* tests/data/test-read-ctf/test-PR27700.abi: New test expected
result.
* tests/data/test-read-ctf/test-anonymous-fields.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-many-ctf.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum-many.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum-symbol-ctf.o.hash.abi: Likewise.
* tests/data/test-read-common/test-PR26568-2.o: Adjust.
* tests/data/test-read-ctf/test-PR26568-1.o.abi: Likewise.
* tests/data/test-read-ctf/test-PR26568-2.o.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.c: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.o: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-array-of-pointers.abi: Likewise.
* tests/data/test-read-ctf/test-callback.abi: Likewise.
* tests/data/test-read-ctf/test-callback2.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-dynamic-array.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-ctf.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum.o.abi: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.abi: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.abi: Likewise.
* tests/data/test-read-ctf/test-list-struct.abi: Likewise.
* tests/data/test-read-ctf/test0: Likewise.
* tests/data/test-read-ctf/test0.abi: Likewise.
* tests/data/test-read-ctf/test0.c: Likewise.
* tests/data/test-read-ctf/test0.hash.abi: Likewise.
* tests/data/test-read-ctf/test1.so.abi: Likewise.
* tests/data/test-read-ctf/test1.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test2.so.abi: Likewise.
* tests/data/test-read-ctf/test2.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test3.so.abi: Likewise.
* tests/data/test-read-ctf/test3.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test4.so.abi: Likewise.
* tests/data/test-read-ctf/test4.so.hash.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.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-05-04 22:29:30 +00:00
|
|
|
"data/test-read-ctf/test-PR26568-2.o.abi",
|
|
|
|
"output/test-read-ctf/test-PR26568-2.o.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"--ctf"
|
ctf-reader: Add support to read CTF information from the Linux Kernel
This patch is meant to extract ABI information from the CTF data
stored in the Linux kernel build directory. It depends on the
vmlinux.ctfa archive file.
In order to generate the CTF information, the Linux Kernel build
system must support the 'make ctf' command, which causes the compiler
to be run with -gctf, thus emitting the CTF information for the
Kernel.
The target 'ctf' in the Linux Makefile generates a 'vmlinux.ctfa' file
that will be used by the ctf reader in libabigail. The 'vmlinux.ctfa'
archive has multiple 'ctf dictionaries' called "CTF archive members".
There is one CTF archive member for built-in kernel modules (in
`vmlinux') and one for each out-of-tree kernel module organized in a
parent-child hierarchy.
There is also a CTF archive member called `shared_ctf' which is a
parent dictionary containing shared symbols and CTF types used by more
than one kernel object. These common types are stored in 'types_map'
in the ctf reader, ignoring the ctf dictionary name. The CTF API has
the machinery for looking for a shared type in the parent dictionary
referred to in a given child dictionary. This CTF layout can be dumped
by using the objdump tool.
Due to the fact that the _same_ ctf archive is used to build the
vmlinux corpus the corpora of the kernel module (which, by the way,
all belong to the same corpus group), the high number of open/close on
the CTF archive is very time consuming during the ctf extraction.
So, the performance is improved up to 300% (from ~2m:50s to ~50s) by
keeping the ctf archive open for a given group, and thus, by using the
same ctf_archive_t pointer while building all the various corpora.
We just invoke `reset_read_context' for each new corpus. Note that
the `read_context::ctfa` data member should be updated if the
corpus::origin data member is set to `LINUX_KERNEL_BINARY_ORIGIN' and
the file to be process is not 'vmlinux'.
Note that `ctf_close' must be called after processing all group's
members so it is executed from the destructor of `reader_context'.
The basic algorithm used to generate the Linux corpus is the
following:
1. Looking for: vmlinux, *.ko objects, and vmlinux.ctfa files. The
first files are used to extract the ELF symbols, and the last one
contains the CTF type information for non-static variables and
functions symbols.
2. `process_ctf_archive' iterates on public symbols for vmlinux and
its modules, using the name of the symbol, ctf reader search for CTF
information in its dictionary, if the information was found it
builds a `var_decl' or `function_decl' depending of `ctf_type_kind'
result.
This algorithm is also applied to ELF files (exec, dyn, rel), so
instead of iterating on all ctf_types it just loops on the public
symbols.
* abg-elf-reader-common.h: Include ctf-api.h file.
(read_and_add_corpus_to_group_from_elf, set_read_context_corpus_group)
(reset_read_context, dic_type_key): Declare new member functions.
* include/abg-ir.cc (types_defined_same_linux_kernel_corpus_public): Use
bitwise to know the corpus `origin'.
* src/abg-ctf-reader.cc: Include map, algorithms header files.
(read_context::type_map): Change from unordered_map to std::map storing
ctf dictionary name as part of the key.
(read_context::is_elf_exec): Add new member variable.
(read_context::{cur_corpus_, cur_corpus_group_}): Likewise.
(read_context::unknown_types_set): Likewise.
(read_context::{current_corpus_group, main_corpus_from_current_group,
has_corpus_group, current_corpus_is_main_corpus_from_current_group,
should_reuse_type_from_corpus_group}): Add new member functions.
(read_context::{add_unknown_type, lookup_unknown_type, initialize}):
Likewise.
(read_context::{add_type, lookup_type}): Add new `ctf_dict_t' type
argument.
(ctf_reader::{process_ctf_typedef, process_ctf_base_type,
process_ctf_function_type, process_ctf_forward_type,
process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type,
process_ctf_qualified_type, process_ctf_enum_type}): Add code to `reuse'
types already registered in main corpus `should_reuse_type_from_corpus_group'.
Use new `lookup_type' and `add_type' operations on `read_context::types_map'.
Replace function calls to the new ctf interface. Add verifier to not build
types duplicated by recursive calling chain.
(ctf_reader::process_ctf_type): Add code to return immediately if the
ctf type is unknown. Add unknown types to `unknown_types_set'.
(ctf_reader::process_ctf_archive): Change comment.
Add code to iterate over global symbols, searching by symbol name in the
ctf dictionary using `ctf_lookup_{variable,by_symbol_name}' depending of
the ELF file type and corpus type, creating a `{var,fuc}_decl' using the
return type of `ctf_type_kind'. Also close the ctf dict and call
`canonicalize_all_types'.
(slurp_elf_info): Set `is_elf_exec' depending of ELF type. Also return
success if corpus origin is Linux and symbol table was read.
(ctf_reader::read_corpus): Add current corpus. Set corpus origin to
`LINUX_KERNEL_BINARY_ORIGIN' if `is_linux_kernel' returns true. Verify
the ctf reader status, now the ctf archive is 'opened' using
`ctf_arc{open,bufopen}' depending if the corpus origin has
`corpus::LINUX_KERNEL_BINARY_ORIGIN' bit set. Use
`sort_{function,variables}' calls after extract ctf information.
`ctf_close' is called from `read_context' destructor.
(read:context::{set_read_context_corpus_group, reset_read_context,
read_and_add_corpus_to_group_from_elf, dic_type_key): Add new member
function implementation.
* include/abg-tools-utils.h (build_corpus_group_from_kernel_dist_under):
Add `origin' parameter with default `corpus::DWARF_ORIGIN'.
* src/abg-tools-utils.cc: Use `abg-ctf-reader.h' file.
(maybe_load_vmlinux_dwarf_corpus): Add new function.
(maybe_load_vmlinux_ctf_corpus): Likewise.
(build_corpus_group_from_kernel_dist_under): Update comments.
Add new `origin' argument. Use `maybe_load_vmlinux_dwarf_corpus'
or `maybe_load_vmlinux_ctf_corpus' according to `origin' value.
* src/abg-corpus.h (corpus::origin): Update `origin' type
values in enum.
* src/abg-corpus-priv.h (corpus::priv): Replace `origin' type
from `corpus::origin' to `uint32_t'.
* src/abg-corpus.cc (corpus::{get,set}_origin): Replace data
type from `corpus::origin' to `uint32_t'.
* tools/abidw.cc (main): Use of --ctf argument to set format debug.
* tests/test-read-ctf.cc: Add new tests to harness.
* tests/data/test-read-ctf/test-PR27700.abi: New test expected
result.
* tests/data/test-read-ctf/test-anonymous-fields.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-many-ctf.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum-many.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum-symbol-ctf.o.hash.abi: Likewise.
* tests/data/test-read-common/test-PR26568-2.o: Adjust.
* tests/data/test-read-ctf/test-PR26568-1.o.abi: Likewise.
* tests/data/test-read-ctf/test-PR26568-2.o.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.c: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.o: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-array-of-pointers.abi: Likewise.
* tests/data/test-read-ctf/test-callback.abi: Likewise.
* tests/data/test-read-ctf/test-callback2.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-dynamic-array.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-ctf.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum.o.abi: Likewise.
* tests/data/test-read-ctf/test-forward-type-decl.abi: Likewise.
* tests/data/test-read-ctf/test-functions-declaration.abi: Likewise.
* tests/data/test-read-ctf/test-list-struct.abi: Likewise.
* tests/data/test-read-ctf/test0: Likewise.
* tests/data/test-read-ctf/test0.abi: Likewise.
* tests/data/test-read-ctf/test0.c: Likewise.
* tests/data/test-read-ctf/test0.hash.abi: Likewise.
* tests/data/test-read-ctf/test1.so.abi: Likewise.
* tests/data/test-read-ctf/test1.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test2.so.abi: Likewise.
* tests/data/test-read-ctf/test2.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test3.so.abi: Likewise.
* tests/data/test-read-ctf/test3.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test4.so.abi: Likewise.
* tests/data/test-read-ctf/test4.so.hash.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.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-05-04 22:29:30 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-ctf/test-callback2.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-callback2.abi",
|
|
|
|
"output/test-read-ctf/test-callback2.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"--ctf"
|
2022-03-18 01:30:36 +00:00
|
|
|
},
|
2022-08-15 19:32:09 +00:00
|
|
|
// out-of-tree kernel module.
|
|
|
|
{
|
|
|
|
"data/test-read-ctf/test-linux-module.ko",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-linux-module.abi",
|
|
|
|
"output/test-read-ctf/test-linux-module.abi",
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
"--ctf"
|
|
|
|
},
|
2022-12-21 20:12:33 +00:00
|
|
|
{
|
|
|
|
"data/test-read-ctf/test-alias.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-alias.o.abi",
|
|
|
|
"output/test-read-ctf/test-alias.o.abi",
|
2022-12-22 15:49:49 +00:00
|
|
|
"--ctf"
|
2022-12-21 20:12:33 +00:00
|
|
|
},
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
// CTF fallback feature.
|
|
|
|
{
|
|
|
|
"data/test-read-ctf/test-fallback.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-fallback.abi",
|
|
|
|
"output/test-read-ctf/test-fallback.abi",
|
|
|
|
NULL,
|
2022-08-15 19:32:09 +00:00
|
|
|
},
|
2022-11-29 12:42:43 +00:00
|
|
|
{
|
|
|
|
"data/test-read-ctf/test-bitfield.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-bitfield.abi",
|
|
|
|
"output/test-read-ctf/test-bitfield.abi",
|
|
|
|
"--ctf",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-ctf/test-bitfield-enum.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-bitfield-enum.abi",
|
|
|
|
"output/test-read-ctf/test-bitfield-enum.abi",
|
|
|
|
"--ctf",
|
2022-11-17 03:43:03 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"data/test-read-ctf/test-const-array.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-const-array.abi",
|
|
|
|
"output/test-read-ctf/test-const-array.abi",
|
|
|
|
"--ctf",
|
|
|
|
},
|
2022-11-17 03:43:04 +00:00
|
|
|
{
|
|
|
|
"data/test-read-ctf/test-array-mdimension.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-array-mdimension.abi",
|
|
|
|
"output/test-read-ctf/test-array-mdimension.abi",
|
|
|
|
"--ctf",
|
|
|
|
},
|
2022-11-17 03:43:05 +00:00
|
|
|
{
|
|
|
|
"data/test-read-ctf/test-array-size.o",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
SEQUENCE_TYPE_ID_STYLE,
|
|
|
|
"data/test-read-ctf/test-array-size.abi",
|
|
|
|
"output/test-read-ctf/test-array-size.abi",
|
|
|
|
"--ctf",
|
|
|
|
},
|
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
|
|
|
// This should be the last entry.
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
{NULL, NULL, NULL, SEQUENCE_TYPE_ID_STYLE, NULL, NULL, NULL}
|
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
|
|
|
};
|
|
|
|
|
|
|
|
/// Task specialization to perform CTF tests.
|
|
|
|
struct test_task_ctf : public test_task
|
|
|
|
{
|
|
|
|
test_task_ctf(const InOutSpec &s,
|
|
|
|
string& a_out_abi_base,
|
|
|
|
string& a_in_elf_base,
|
|
|
|
string& a_in_abi_base);
|
|
|
|
virtual void
|
|
|
|
perform();
|
|
|
|
|
|
|
|
virtual
|
|
|
|
~test_task_ctf()
|
|
|
|
{}
|
|
|
|
}; // end struct test_task_ctf
|
|
|
|
|
|
|
|
/// Constructor.
|
|
|
|
///
|
|
|
|
/// Task to be executed for each CTF test entry in @ref
|
|
|
|
/// abigail::tests::read_common::InOutSpec.
|
|
|
|
/// @param InOutSpec the array containing set of tests.
|
|
|
|
///
|
|
|
|
/// @param a_out_abi_base the output base directory for abixml files.
|
|
|
|
///
|
|
|
|
/// @param a_in_elf_base the input base directory for object files.
|
|
|
|
///
|
|
|
|
/// @param a_in_elf_base the input base directory for expected
|
|
|
|
/// abixml files.
|
|
|
|
test_task_ctf::test_task_ctf(const InOutSpec &s,
|
|
|
|
string& a_out_abi_base,
|
|
|
|
string& a_in_elf_base,
|
|
|
|
string& a_in_abi_base)
|
|
|
|
: test_task(s, a_out_abi_base, a_in_elf_base, a_in_abi_base)
|
|
|
|
{}
|
|
|
|
|
|
|
|
/// The thread function to execute each CTF test entry in @ref
|
|
|
|
/// abigail::tests::read_common::InOutSpec.
|
|
|
|
///
|
|
|
|
/// This reads the corpus into memory, saves it to disk, loads it
|
|
|
|
/// again and compares the new in-memory representation against the
|
|
|
|
void
|
|
|
|
test_task_ctf::perform()
|
|
|
|
{
|
Use environment by reference.
This patch simplifies how the environment is created and passed around
the functions that create front ends. With this change, the
environment can simply be allocated on the stack and passed by
reference to the libabigail pipeline.
At the core of this change, type_or_decl_base::priv now carries a
const reference to an environment rather than a pointer. The side
effect is that type_or_decl_base can no longer be copied. This is not
a problem because throughout the years I could see that the use case
to copy ABI artifacts is just not there. Similarly, elf_symbol::priv
carries a const reference to environment now, no more a pointer.
Getters, setters and code that use the environment from the ABI
artifacts are updated accordingly.
The DWARF front-end can now be created by code that looks like this,
for instance:
vector<char**> debug_info_paths;
abigail::ir::environment env;
abigail::ctf_reader::read_context_sptr reader =
abigail::dwarf_reader::create_read_context("elf/file/to/analyze",
debug_info_paths, env);
elf_reader::status reading_status;
corpus_sptr abi_corpus =
abigail::dwarf_reader::read_corpus_from_elf(reader, reading_status);
/* then do something with the resulting abi_corpus*/
Note how, you don't need to use the "new" operator to instantiate the
"env" object of type environment. It can sit on the stack and it's
passed to the read_corpus_from_elf function by reference.
In other words, the internal representation types have been changed to
refer to the environment by reference, rather than requiring a pointer
to it.
* include/abg-corpus.h (corpus::corpus)
(corpus_group::corpus_group): Take environment&, not environment*
as parameter.
(corpus::{get_environment, set_environment}): Take or return
environment&, not environment*.
* src/abg-corpus.cc (corpus::corpus): Likewise.
(corpus::{get_environment, set_environment}): Likewise.
(corpus::add): Don't update the environment of the translation
unit.
(corpus::{record_type_as_reachable_from_public_interfaces,
type_is_reachable_from_public_interfaces, init_format_version,
add_corpus}): Adjust for accessing a reference to environment,
rather than a pointer.
* include/abg-ctf-reader.h (create_read_context): Take or return
environment&, not environment*.
* src/abg-ctf-reader.cc (read_context::ir_env): Make this a
reference to environment, not pointer anymore.
(read_context::read_context): Initialize the reference to
environment.
(read_context::initialize): Do not re-set the environment.
(process_ctf_base_type)
(build_ir_node_for_variadic_parameter_type)
(process_ctf_enum_type, read_corpus): Adjust for accessing a
reference to environment, rather than a pointer.
(create_read_context, reset_read_context): Take environment&, not
environment*.
* include/abg-dwarf-reader.h (create_read_context)
(reset_read_context, read_corpus_from_elf)
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Likewise.
* src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab)
(lookup_symbol_from_elf_hash_tab, lookup_symbol_from_symtab)
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Likewise.
(read_context::options_type::env): Make this be a reference to
environment, not a pointer.
(read_context::options::options): Remove the default constructor.
Add a new one to initialize the environment data member.
(read_context::read_context): Take environment&, not environment*.
Initialize the options_ data member.
(read_context::initialize): Do not take or initialize an
environment anymore.
(read_context::env): Return or take environment&, not
environment*.
(read_context::{get_die_qualified_name,
get_die_qualified_type_name, get_die_pretty_type_representation,
get_die_pretty_representation, compare_before_canonicalisation})
(build_translation_unit_and_add_to_ir, build_function_type)
(build_typedef_type, read_debug_info_into_corpus)
(read_debug_info_into_corpus, build_ir_node_from_die)
(build_ir_node_for_variadic_parameter_type, has_alt_debug_info):
Adjust to use an environment&, not a pointer.
(create_default_fn_sym, create_read_context)
(read_corpus_from_elf, lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf): Take environment&, not
environment*.
(reset_read_context): Do not take or reset environment* anymore.
* include/abg-fwd.h (type_or_void): Likewise.
* include/abg-ir.h (translation_unit::translation_unit): Likewise.
(translation_unit::{get_environment, set_environment}): Likewise.
(elf_symbol::elf_symbol): Likewise.
(elf_symbol::create): Remove the overload that takes no
parameter. Then for overload that take parameters then take
environment&, not environment*.
(elf_symbol::get_environment): Take environment&, not
environment*.
(type_or_decl_base::type_or_decl_base): Make the copy constructor
and assignment operator private.
(type_or_decl_base::{s,g}et_environment): Take or return
environment& not environment*.
(type_or_decl_base::set_environment_for_artifact): Erase these
methods.
(decl_base::decl_base): Make copy constructor private. Take or
return environment&, not environment* for the other constructors.
(scope_decl::scope_decl): Take or return environment&, not
environment*.
(type_base::type_base): Likewise.
(scope_type_decl::scope_type_decl): Likewise.
(namespace_decl::namespace_decl): Likewise.
(qualified_type_def::qualified_type_def): Likewise.
(pointer_type_def::pointer_type_def): Likewise.
(reference_type_def::reference_type_def): Likewise.
(array_type_def::subrange_type::subrange_type): Likewise.
(enum_type_def::enumerator::enumerator): Likewise.
(enum_type_def::enumerator::{get_name, get_qualified_name}):
Return a string&, no more interned_string&. As the enumerator
don't have an enumerator anymore, there is no way to intern the
string anymore. Hopefully this won't incur a performance loss.
(typedef_decl::typedef_decl, function_type::function_type)
(method_type::method_type, template_decl::template_decl)
(function_tdecl::function_tdecl, class_tdecl::class_tdecl)
(class_or_union::class_or_union, class_decl::class_decl)
(union_decl::union_decl): Take or return environment&, not
environment*.
* include/abg-reader.h (read_translation_unit_from_file)
(read_translation_unit_from_buffer)
(read_translation_unit_from_istream)
(create_native_xml_read_context, create_native_xml_read_context)
(read_corpus_from_native_xml, read_corpus_from_native_xml_file)
(read_corpus_group_from_native_xml)
(read_corpus_group_from_native_xml_file): Likewise.
* include/abg-tools-utils.h
(build_corpus_group_from_kernel_dist_under): Likewise.
* src/abg-tools-utils.cc (maybe_load_vmlinux_dwarf_corpus)
(maybe_load_vmlinux_ctf_corpus)
(build_corpus_group_from_kernel_dist_under): Likewise.
* include/abg-writer.h (create_write_context): Likewise.
* src/abg-writer.cc (id_manager::m_env, id_manager::id_manager)
(id_manager::get_environment, id_manager::get_id)
(id_manager::get_id_with_prefix): Adjust.
(write_context::m_env, write_context::write_context)
(write_context::get_environment, write_context::get_config)
(write_context::get_id_for_type, write_context::decl_is_emitted)
(write_context::record_decl_as_emitted, create_write_context)
(write_class_decl): Likewise.
* src/abg-comparison.cc (compute_diff): Stop ensuring that the two
artifacts being compare are in the same environment. Now that the
environment is passed by reference, the potential for
accendentally comparing artifacts coming from different
environments is very low, given how the API is used in practice.
This is in the overloads for decl_base_sptr, type_base_sptr,
var_decl_sptr, pointer_type_def_sptr, array_type_def_sptr,
reference_type_def_sptr, qualified_type_def_sptr,
enum_type_decl_sptr, class_decl_sptr, class_decl::base_spec_sptr,
union_decl_sptr, scope_decl_sptr, function_decl::parameter_sptr,
function_type_sptr, function_decl_sptr, type_decl_sptr,
typedef_decl_sptr, translation_unit_sptr, corpus_sptr.
* src/abg-corpus-priv.h (corpus::priv::env): Make this be a
reference to environments, not a pointer.
(corpus::priv::priv): Pass environment&, not environment*.
* src/abg-ir-priv.h (translation_unit::priv::env_): Make this an
environment&, not an environment* anymore.
(translation_unit::priv::priv): Take an environment&, not an
environment*.
(environment::priv::{confirm_ct_propagation_for_types_dependant_on,
confirm_ct_propagation,
cancel_ct_propagation_for_types_dependant_on,
mark_as_being_compared, unmark_as_being_compared,
comparison_started, mark_as_being_compared, comparison_started}):
Adjust to use an environment&, not a pointer.
* src/abg-ir.cc (class environment_setter): Remove this class.
(push_composite_type_comparison_operands)
(pop_composite_type_comparison_operands, try_canonical_compare)
(return_comparison_result, translation_unit::{get_global_scope,
bind_function_type_life_time}): Adjust.
(translation_unit::{translation_unit, get_environment}): Take or
get an environment&, not an environment*. Remove the getter that
returns an environment*.
(elf_symbol::priv::env_): Make this an environment&, not an
environment*.
(elf_symbol::priv::priv): Adjust.
(elf_symbol::elf_symbol): Remove the default constructor. Change
the one that takes an environment.
(elf_symbol::create): Remove the default one. Adjust the one that
takes an environment.
(elf_symbol::get_environment): Adjust.
(elf_symbol::set_environment_for_artifact): Remove.
(environment::{get_void_type, get_variadic_parameter_type}):
Adjust.
(type_or_decl_base::priv::env_): Make this be a const
environment&, not a const environment*.
(type_or_decl_base::priv::priv): Adjust.
(type_or_decl_base::type_or_decl_base): Remove the default and
copy constructor.
(type_or_decl_base::{set_environment, operator=})
(set_environment_for_artifact): Remove.
(type_or_decl_base::get_environment): Adjust.
(decl_base::{decl_base, set_name, set_naming_typedef,
set_linkage_name}): Adjust.
(get_decl_name_for_comparison, strip_typedef)
(strip_useless_const_qualification): Adjust.
(scope_decl::{scope_decl, add_member_decl, insert_member_decl}):
Adjust.
(get_generic_anonymous_internal_type_name, get_type_name)
(get_name_of_pointer_to_type, get_name_of_reference_to_type)
(get_name_of_qualified_type, get_function_type_name)
(get_method_type_name, is_void_pointer_type, lookup_basic_type)
(lookup_union_type, lookup_union_type_per_location)
(lookup_enum_type, lookup_typedef_type, lookup_pointer_type)
(lookup_type, lookup_basic_type_per_location)
(lookup_basic_type_per_location, lookup_basic_type)
(lookup_class_type, lookup_class_types)
(lookup_class_type_per_location, lookup_union_type)
(lookup_enum_type, lookup_enum_types)
(lookup_enum_type_per_location, lookup_typedef_type)
(lookup_typedef_type_per_location, maybe_update_types_lookup_map)
(maybe_update_types_lookup_map)
(synthesize_type_from_translation_unit)
(synthesize_function_type_from_translation_unit)
(demangle_cplus_mangled_name, type_or_void)
(types_defined_same_linux_kernel_corpus_public)
(compare_types_during_canonicalization)
(type_base::get_canonical_type_for, type_base::type_base)
(type_base::get_cached_pretty_representation)
(type_decl::type_decl, type_decl::get_qualified_name): Adjust.
(scope_type_decl::scope_type_decl)
(namespace_decl::namespace_decl, qualified_type_def::build_name)
(qualified_type_def::qualified_type_def)
(qualified_type_def::get_qualified_name)
(qualified_type_def::set_underlying_type)
(pointer_type_def::pointer_type_def)
(pointer_type_def::set_pointed_to_type)
(reference_type_def::reference_type_def)
(reference_type_def::set_pointed_to_type)
(array_type_def::subrange_type::subrange_type)
(array_type_def::array_type_def, array_type_def::update_size)
(array_type_def::set_element_type)
(array_type_def::append_subranges)
(array_type_def::get_qualified_name, enum_has_non_name_change):
Adjust.
(enum_type_decl::enumerator::priv::env_): Remove this pointer to
env. This is because the enumerator must be copy-able. As the
enumerator doesn't have an env anymore, it can't intern strings.
So the enumerator name and qualified name is not going to be
interned. If that incurs a performance hit, we'll reconsider this
decision. For now, it seems to work OK. As it simplifies things,
I am keeping this for now.
(enum_type_decl::enumerator::priv::{name, qualified_name}): Make
this be string, not interned_string.
(enum_type_decl::enumerator::get_environment): Remove.
(enum_type_decl::enumerator::priv::priv): Adjust.
(enum_type_decl::enumerator::enumerator)
(enum_type_decl::enumerator::operator=)
(enum_type_decl::enumerator::get_name)
(enum_type_decl::enumerator::get_qualified_name)
(enum_type_decl::enumerator::set_name): Likewise.
(typedef_decl::typedef_decl): Adjust.
(var_decl::get_id, var_decl::get_qualified_name): Adjust.
(function_type::function_type, method_type::method_type)
(function_decl::get_pretty_representation_of_declarator)
(function_decl::set_symbol): Likewise.
(function_decl::get_id, function_decl::parameter::get_type)
(function_decl::parameter::get_type_name)
(function_decl::parameter::get_type_pretty_representation)
(function_decl::parameter::get_name_id)
(class_or_union::class_or_union, class_decl::class_decl)
(class_decl::add_base_specifier, union_decl::union_decl)
(union_decl::union_decl, template_decl::template_decl)
(class_tdecl::class_tdecl)
(maybe_cancel_propagated_canonical_type)
(dump_classes_being_compared)
(dump_fn_types_being_compared, copy_member_function)
(maybe_propagate_canonical_type, keep_type_alive)
(is_non_canonicalized_type, qualified_name_setter::do_update):
Likewise.
(equals): Adjust the overloads for var_decl, function_type,
class_or_union, class_decl, union_decl.
* src/abg-reader.cc (read_context::m_env): Make this be an
environment&, not an environment*.
(read_context::read_context): Adjust
(read_context::set_environment): Remove.
(read_context::{get_environment,
maybe_check_abixml_canonical_type_stability}): Adjust.
(read_corpus_from_input, read_corpus_group_from_native_xml)
(read_corpus_group_from_native_xml_file)
(read_translation_unit_from_file)
(read_translation_unit_from_buffer, read_translation_unit)
(maybe_map_type_with_type_id, build_namespace_decl)
(build_elf_symbol, build_function_parameter, build_function_decl)
(build_function_type, build_enum_type_decl, build_class_decl)
(build_union_decl, build_function_tdecl, build_class_tdecl)
(build_type_tparameter, read_translation_unit_from_istream)
(create_native_xml_read_context, read_corpus_from_native_xml):
Likewise.
* src/abg-symtab-reader.h (symtab::load): Likewise.
* src/abg-symtab-reader.cc (symtab::load): Likewise.
* tests/print-diff-tree.cc (main): Likewise.
* tests/test-abidiff.cc (main): Likewise.
* tests/test-diff-dwarf.cc (main): Likewise.
* tests/test-ir-walker.cc (main): Likewise.
* tests/test-read-ctf.cc (test_task_ctf::perform): Likewise.
* tests/test-symtab.cc (read_corpus): Likewise.
* tools/abicompat.cc (read_corpus, main): Likewise.
* tools/abidiff.cc (main): Likewise.
* tools/abidw.cc (load_corpus_and_write_abixml)
(load_kernel_corpus_group_and_write_abixml, main): Likewise.
* tools/abilint.cc (main): Likewise.
* tools/abipkgdiff.cc (compare, compare_to_self)
(compare_prepared_linux_kernel_packages, compare_task::perform):
Likewise.
* tools/abisym.cc (main): Likewise.
* tools/kmidiff.cc (main): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-10 11:00:44 +00:00
|
|
|
abigail::ir::environment env;
|
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
|
|
|
|
|
|
|
set_in_elf_path();
|
|
|
|
set_in_suppr_spec_path();
|
|
|
|
|
Make Front Ends first class citizens
This patch is a reorganization of the code to better support the need
for having several different front-ends.
In the libabigail pipeline of operation, a front-end is the part of
the pipeline that analyses the input file. For instance, to analyse
an ELF file, there is going to be one front-end. To analyse an ABIXML
file, there is going to be another front-end.
The middle-end is the part of the pipeline that interacts with the
internal representation of ABIs. The middle-end knows how to analyse,
compare ABI corpora provide an internal representation of the
comparison result and analyse it as well.
The back-end would be the part of the front-end that knows how to
serialize internal representations of ABIs and ABI comparison results.
One could thus imagine a front-end that understands the DWARF debug
info format embedded in an ELF file. Another front-end would be
dedicated to the CTF debug info format, and so on.
Front-ends can share capabilities. For instance, DWARF and CTF
front-ends are ELF based front end. As such, they share capabilities
to understand the ELF format. They don't share much with the ABIXML
front-end, however, as it's based on XML, which has almost nothing in
common with ELF.
To support this organization of concepts, this patch introduces a new
hierarchy of types in the form of C++ classes.
All front-ends implements the "Front End Interface". As such, they
all inherit the abigail::fe_iface class.
That class provides properties and behaviours that are shared by all
front-ends that libabigail supports today. Namely, that class
provides access to some of the options that are relevant to operating
the front-end, to the ABI corpus or corpus group being constructed and
to the suppression specifications that are considered. It also
provides an abstract interface to perform the actual loading of the
ABI corpus. That abstract interface has to be implemented by every
single concrete front-end that is provided in libabigail.
Then, there is the "ELF Reader" front-end. Its class name is
abigail::elf::reader. It inherits the abigail::fe_iface class and
implements the fe_iface::load_corpus() so that the ELF properties of
the ELF file be loaded and exposed in the ABI corpus as returned by
the fe_iface::corpus() accessor. This ELF reader front-end also
provides lots of capabilities that are specific to accessing ELF
content.
Then, there is a common base class for ELF-based front-ends to come,
named abigail::elf_based_reader, which inherits the abigail::elf::reader
class. The purpose of this base class is to provide common properties
and behaviours that are necessary to implement things like a DWARF or
a CTF front-end, or any other front-end to support an ELF-based debug
info format.
Then, there is a CTF front-end which class is named
abigail::ctf::reader. It inherits the abigail::elf_based_reader class
and implements the fe_iface::load_corpus() interface to load and
analyse the CTF-specific properties of the ELF file. To do this,
abigail::ctf::reader::load_corpus() re-uses the abigail::elf::load_corpus() member
function to load the generic ELF parts of the ABI corpus. This reader
then constructs the internal representation of the ABI corpus and
passes it to the middle-end for further analysis.
Then, there is a DWARF front-end which class is named
abigail::dwarf::reader. It inherits the abigail::elf_based_reader
class and implements the fe_iface::load_corpus() interface to load and
analyse the DWARF-specific properties of the ELF file. To do this,
abigail::dwarf::reader re-uses the abigail::elf::load_corpus() member
function to load the generic ELF parts of the ABI corpus, just like
what the CTF front-end does. And then, just like the CTF front-end,
this reader then constructs the internal representation of the ABI
corpus and passes it to the middle-end for further analysis.
Lastly, there is an ABIXML front-end which class is named
abigail::abixml::reader. It inherits the abigail::fe_iface class
directly. Note that unlike the two previous front-ends, this one
doesn't inherit the elf_based_reader base class, for reasons that
should be obvious to the astute reader by now. So, this front-end
implements the abigail::fe_iface::load_corpus() abstract interface to
load the properties for the ABI corpus represented in the ABIXML
format, construct the internal representation and pass it to the
middle-end for further analysis.
The code of the tools got adapted to use these front-ends.
The support of CTF is still guarded by #ifdef WITH_CTF pre-processor
macros, but the one cool side effect is that the amount of guarded
code is reduced. Basically, it's only the creation of the CTF
front-end that is guarded. After its creation, what is returned is an
instance of abigail::elf_based_reader::reader, exactly like what is
returned by the creation of a DWARF front-end. Thus, the rest of the
code is exactly the same, regardless of the kind of front-end. I
believe this results in a more elegant and maintainable code.
As a proof-of-concept, this patch also provides the
create_best_elf_based_reader function. This function analyses the ELF
file and depending on the kind of debug info it provides, returns the
right front-end for it. Maybe at some point, all the #ifdef WITH_CTF
guard pre-processing macros will be constrained in a single function
like this one that will take the decision of instantiating the right
front-end. The rest of the code will be as generic as it gets.
The patch adjusts the reference abixml files produced by the CTF
front-end because it now emits the <elf-needed> XML element which was
not emitted before. This is done because the CTF front-end inherits
the elf-reader which reads the "elf-needed" property from the binary,
without explicit intervention from the CTF front-end.
The patch passes 'make distcheck' on all the supported platforms.
* include/abg-fwd.h (build_internal_underlying_enum_type_name):
Move this here from src/abg-dwarf-reader.cc.
* include/abg-elf-reader-common.h: Delete this file. Its content
is going to be put in the new include/abg-elf-reader.h.
* src/abg-elf-reader-common.cc: Likewise.
* include/abg-{elf-based-reader, elf-reader, fe-iface}.h: Add new
files.
* src/abg-fe-iface.cc: Likewise.
* include/Makefile.am: Add the new file abg-fe-iface.h,
abg-elf-based-reader.h and abg-elf-reader.h to source distribution
and remove include/abg-elf-reader-common.h from source
distribution.
* src/abg-ir.cc (build_internal_underlying_enum_type_name): Move
this here from abg-dwarf-reader.cc so that it can be used by other
readers.
* include/abg-reader.h (abigail::abixml::reader): Rename the
namespace abigail::xml_reader into this one.
(read_context, create_native_xml_read_context)
(read_context_get_path, read_corpus_from_native_xml)
(read_corpus_from_native_xml_file)
(read_corpus_group_from_native_xml)
(read_corpus_group_from_native_xml_file): Remove.
(read_translation_unit_from_file)
(read_translation_unit_from_buffer)
(read_translation_unit_from_istream)
(read_translation_unit)
(consider_types_not_reachable_from_public_interfaces)
(get_types_from_type_id, get_artifact_used_by_relation_map)
(load_canonical_type_ids): Take an fe_iface&, not a read_context.
(create_reader): Declare new function that returns a
fe_iface_sptr.
(read_corpus_from_abixml, read_corpus_from_abixml_file)
(read_corpus_group_from_abixml)
(read_corpus_group_from_abixml_file): Declare new functions.
* src/abg-reader.cc (namespace abixml): Rename the
xml_reader namespace into this.
(abixml::reader_sptr): New typedef.
(abixml::reader): Rename read_context into this. Make it
inherit the fe_iface interface.
(abixml::reader::{m_path, m_env, m_corpus, m_corpus_group,
m_exported_decls_builder, m_supprs}): Remove these data members
that are now part of the fe_iface parent type.
(abixml::reader::{set_environment, get_corpus, set_corpus,
set_corpus_group, maybe_add_fn_to_exported_decls,
maybe_add_var_to_exported_decls,
maybe_check_abixml_canonical_type_stability,
suppression_matches_function_sym_name,
suppression_matches_variable_name,
suppression_matches_variable_sym_name}): Remove.
(read_corpus_from_input): Remove. Actually the code of this went
into abixml::reader::read_context().
(abixml::reader::get_libxml_reader): Rename the get_reader
member function into this.
(abixml::add_reader_suppressions): Rename
add_read_context_suppressions into this.
(abixml::reader::read_corpus): Implement this virtual
member function if the fe_iface parent interface.
(maybe_set_naming_typedef, advance_cursor)
(handle_version_attribute, walk_xml_node_to_map_type_ids)
(read_elf_needed_from_input, read_symbol_db_from_input)
(get_or_read_and_add_translation_unit, build_needed)
(read_elf_needed_from_input, add_read_context_suppressions)
(maybe_set_artificial_location, maybe_set_naming_typedef)
(build_namespace_decl, build_elf_symbol)
(build_elf_symbol_from_reference, build_elf_symbol_db)
(build_function_parameter, build_function_decl)
(build_function_decl_if_not_suppressed, function_is_suppressed)
(type_is_suppressed, build_var_decl_if_not_suppressed)
(variable_is_suppressed, variable_is_suppressed, build_var_decl)
(build_type_decl, build_qualified_type_decl)
(build_pointer_type_def, build_reference_type_def)
(build_function_type, build_subrange_type, build_array_type_def)
(build_enum_type_decl_if_not_suppressed, build_enum_type_decl)
(build_typedef_decl, build_class_decl_if_not_suppressed)
(build_union_decl_if_not_suppressed, build_class_decl)
(build_union_decl, build_function_tdecl, build_class_tdecl)
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_non_type_tparameter)
(build_template_tparameter, build_template_parameter, build_type)
(handle_type_decl, handle_namespace_decl)
(handle_qualified_type_decl, handle_pointer_type_def)
(handle_reference_type_def, handle_function_type)
(handle_array_type_def, handle_enum_type_decl)
(handle_typedef_decl, handle_var_decl, handle_function_decl)
(handle_class_decl, handle_union_decl, handle_function_tdecl)
(read_translation_unit_from_istream): Take or use an
abixml::reader rather than a read_context.
(read_translation_unit, read_translation_unit_from_input)
(consider_types_not_reachable_from_public_interfaces)
(get_types_from_type_id, get_artifact_used_by_relation_map)
(read_corpus_group_from_input, read_translation_unit)
(handle_element_node, read_location, read_artificial_location)
(load_canonical_type_ids) : Take an fe_iface&, not a read_context.
(create_abixml_reader): Rename create_native_xml_read_context
into this. Make it return a fe_iface_sptr.
(read_corpus_from_abixml): Rename read_corpus_from_abixml into
this.
(read_corpus_from_abixml_file): Rename
read_corpus_from_native_xml_file into this.
(read_context_get_path): Remove.
* include/abg-tools-utils.h
(abigail::tools_utils::{file_has_dwarf_debug_info,
file_has_ctf_debug_info}): Declare new functions.
(create_best_elf_based_reader): Declare new function.
* include/abg-corpus.h (corpus::add): Pass the translation unit by
reference.
(corpus::exported_decls_builder::maybe_add_{fn,var}_to_exported_fns):
Take a const parameter.
* src/abg-corpus-priv.h
(corpus::exported_decls_builder::priv::add_{fn,var}_to_exported):
Take a const parameter and adjust.
* src/abg-corpus.cc
(corpus::exported_decls_builder::maybe_add_{fn,var}_to_exported_fns):
Take a const parameter.
(corpus::add): Take a reference to translation_unit_sptr.
* include/abg-suppression.h (abigail::fe_iface): Forward-declare
this.
(abigail::{suppression_sptr, suppressions_type}): Declare these
types here.
(abigail::suppr::{suppression_can_match,
suppression_matches_function_name,
suppression_matches_function_sym_name,
suppression_matches_variable_name,
suppression_matches_variable_sym_name,
suppression_matches_type_name_or_location,
is_elf_symbol_suppressed, is_elf_symbol_suppressed,
is_function_suppressed, is_variable_suppressed,
is_type_suppressed}): Declare these functions here.
* src/abg-suppression-priv.h (function_is_suppressed)
(variable_is_suppressed, type_is_suppressed)
(is_elf_symbol_suppressed): Remove these template functions.
* src/abg-suppression.cc (suppression_matches_function_name)
(suppression_matches_function_sym_name): Remove.
(variable_is_suppressed, suppression_can_match)
(suppression_matches_function_name)
(suppression_matches_function_sym_name)
(suppression_matches_variable_name)
(suppression_matches_variable_sym_name)
(suppression_matches_type_name_or_location)
(is_elf_symbol_suppressed, is_elf_symbol_suppressed)
(is_function_suppressed, is_variable_suppressed)
(is_type_suppressed): New functions.
* include/abg-ctf-reader.h (abigail::ctf::{read_context,
create_read_context, read_corpus,
read_and_add_corpus_to_group_from_elf,
set_read_context_corpus_group, reset_read_context, dic_type_key}):
Remove.
(ctf::{create_reader, reset_reader}): Declare new
functions.
* src/abg-ctf-reader.cc (read_context): Remove.
(process_ctf_typedef, process_ctf_base_type)
(build_ir_node_for_variadic_parameter_type)
(process_ctf_function_type, process_ctf_sou_members)
(process_ctf_forward_type, process_ctf_struct_type)
(process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type)
(process_ctf_enum_type, fill_ctf_section)
(lookup_symbol_in_ctf_archive, dic_type_key): Forward-declare
these static functions.
(ctf::reader): New class that is the abstraction
of the CTF reader. It extends the abigail::elf_based_reader
class. This is a renaming of the
abigail::ctf::read_context class.
(ctf::reader::{elf_handler, elf_fd,
elf_handler_dbg, elf_fd_dbg, symtab, debug_info_root_paths_,
debug_info_root_paths_}): Remove these data members as they are
now properties of the abigail::elf_reader class, which is a parent
class of this abigail::ctf::reader class.
(ctf::reader::{exported_decls_builder,
maybe_add_fn_to_exported_decls, current_corpus_group,
has_corpus_group, main_corpus_from_current_group,
current_corpus_is_main_corpus_from_current_group,
should_reuse_type_from_corpus_group}): Remove these accessors
that can now be used from the parent classes abigail::{elf_reader,
elf_based_reader}.
(ctf::reader::reader): This now delegates to the constructor of
elf_based_reader. It doesn't pass any argument to initialize()
anymore.
(ctf::reader::initialize): Add an overload with no
parameter. In the other overload, do not take a pointer to an
environment as no new environment can be passed to the instance of
reader that is being reset. Adjust the code of the initializer to
reflect all the data members that got removed.
(ctf::{env, find_ctfa_file, slurp_elf_info,
process_ctf_archive, process_ctf_type, lookup_type, read_corpus,
~reader}): New member functions. Most of these were free-form
functions that took ctf::read_context as first parameter.
In read_corpus, do not set the corpus::LINUX_KERNEL_BINARY_ORIGIN
origin as that is now done by elf::reader when it reads the
binary.
(lookup_type): Remove. These are now member functions of the
ctf::reader class.
(process_ctf_typedef, process_ctf_base_type)
(build_ir_node_for_variadic_parameter_type)
(process_ctf_function_type, process_ctf_sou_members)
(process_ctf_forward_type, process_ctf_struct_type)
(process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type): Take a
ctf::reader rather an ctf::read_context. Adjust the
content of the functions.
(process_ctf_type, lookup_type, process_ctf_archive): Remove these
and turn them into member functions of ctf::reader.
(open_elf_handler, close_elf_handler, find_alt_debuginfo): Remove
these ELF handling functions as ELF handling is now done by the
elf_reader parent class.
(fill_ctf_section): Take a const pointer to Elf_Scn.
(slurp_elf_info, find_ctfa_file): Remove this and make it be a
member of ctf::reader. Also, make it handle only CTF
reader specific pieces. slurp_elf_info now delegates the reading
of generic ELF properties to elf::reader by calling
elf::reader::read_corpus().
(create_read_context, read_corpus, set_read_context_corpus_group)
(read_and_add_corpus_to_group_from_elf): Remove these functions.
(create_reader, reset_reader): Create new functions
(dic_type_key): Make this static.
* include/abg-dwarf-reader.h (abigail::dwarf::elf_type):
Move this enum into the namespace abigail::elf_reader in the file
include/abg-elf-reader.h.
(abigail::dwarf::{read_context, read_context_sptr,
create_read_context, read_context_get_path, reset_read_context,
add_read_context_suppressions, set_read_context_corpus_group,
read_corpus_from_elf, read_and_add_corpus_to_group_from_elf,
read_and_add_corpus_to_group_from_elf,
add_read_context_suppressions, refers_to_alt_debug_info,
has_alt_debug_info, get_soname_of_elf_file, get_type_of_elf_file,
set_debug_info_root_path, get_debug_info_root_path,
get_show_stats, set_show_stats, set_drop_undefined_syms,
set_do_log, set_environment, get_environment}): Remove.
* src/abg-dwarf-reader.cc (struct dwfl_deleter, dwfl_sptr)
(addr_elf_symbol_sptr_map_type, address_set_type)
(address_set_sptr): Delete these types.
(read_context::options_type): Remove. The data members of this
type got moved to struct fe_iface::options_type.
(find_alt_debug_info_link, find_alt_debug_info_path)
(find_alt_debug_info, lookup_data_tag_from_dynamic_segment)
(elf_file_type, refers_to_alt_debug_info, has_alt_debug_info)
(get_soname_of_elf_file, get_type_of_elf_file) : Remove these ELF
specific functions from here; move them to the elf_reader
namespace.
(dwarf::reader): Create new class that extends
elf_based_reader. dwarf::read_context is renamed into this
type, actually.
(dwarf::reader::die_source_dependant_container_set::get_container):
Adjust.
(dwarf::reader::{supprs_, dwarf_version_,
offline_callbacks_, debug_info_root_paths_, handle_, dwarf_,
alt_fd_, alt_dwarf_, alt_debug_info_path_, elf_module_,
elf_handle_, elf_path_, symtab_section_, cur_corpus_group_,
cur_corpus_, dt_needed_, dt_soname_, elf_architecture_,
exported_decls_builder_, options_, drop_undefined_syms_}): Remove
these ELF-related data members to move them into the elf_reader
namespace.
(maybe_propagate_canonical_type)
(build_translation_unit_and_add_to_ir, build_ir_node_from_die)
(add_or_update_class_type, add_or_update_union_type)
(build_ir_node_for_void_type)
(build_ir_node_for_variadic_parameter_type, build_function_decl)
(function_is_suppressed, build_or_get_fn_decl_if_not_suppressed)
(build_var_decl, build_or_get_var_decl_if_not_suppressed)
(variable_is_suppressed)
(propagate_canonical_type)
(get_parent_die, get_scope_die, die_is_at_class_scope)
(die_location, die_qualified_type_name, die_qualified_name)
(die_qualified_type_name_empty)
(die_return_and_parm_names_from_fn_type_die)
(die_function_signature, die_function_type_is_method_type)
(die_pretty_print_type, die_pretty_print_decl, die_pretty_print)
(maybe_canonicalize_type, build_subrange_type)
(build_subranges_from_array_type_die, compare_dies, die_location)
(die_loc_and_name, die_is_effectively_public_decl)
(maybe_cache_type_comparison_result)
(get_cached_type_comparison_result)
(maybe_get_cached_type_comparison_result, die_is_at_class_scope)
(die_function_type_is_method_type, die_member_offset)
(die_qualified_type_name, die_qualified_decl_name)
(die_qualified_name, die_qualified_type_name_empty)
(die_return_and_parm_names_from_fn_type_die)
(die_function_signature, die_pretty_print_type)
(die_pretty_print_decl, die_pretty_print)
(at_least_one_decl_only_among_odr_relevant_dies)
(compare_as_type_dies, compare_as_decl_and_type_dies)
(fn_die_equal_by_linkage_name, try_canonical_die_comparison)
(maybe_propagate_canonical_type, propagate_canonical_type)
(compare_dies, compare_dies_during_canonicalization)
(find_import_unit_point_between_dies, get_parent_die)
(get_scope_die, find_lower_bound_in_imported_unit_points)
(build_translation_unit_and_add_to_ir)
(build_namespace_decl_and_add_to_ir, build_type_decl)
(build_enum_underlying_type, build_enum_type)
(finish_member_function_reading)
(maybe_finish_function_decl_reading)
(lookup_class_or_typedef_from_corpus)
(is_function_for_die_a_member_of_class)
(add_or_update_member_function, add_or_update_class_type)
(add_or_update_union_type, build_qualified_type)
(schedule_array_tree_for_late_canonicalization)
(maybe_strip_qualification, build_pointer_type_def)
(build_reference_type, build_function_type, build_subrange_type)
(build_subranges_from_array_type_die, build_array_type)
(build_typedef_type, build_or_get_var_decl_if_not_suppressed)
(build_var_decl, function_is_suppressed)
(build_or_get_fn_decl_if_not_suppressed, variable_is_suppressed)
(type_is_suppressed, type_is_suppressed)
(get_opaque_version_of_type, create_default_fn_sym)
(build_function_decl, maybe_canonicalize_type)
(build_ir_node_from_die)
(build_ir_node_for_variadic_parameter_type): Take a reference to
the new dwarf::reader rather than to the previous
read_context. Adjust the function body.
(return_comparison_result): Adjust.
(dwarf::reader::reader): Adjust this from
read_context::read_context.
(dwarf::reader::initialize): Adjust from
dwarf::read_context::initialize.
(dwarf::reader::create): New factory static member
function.
(dwarf::reader::~reader): This doesn't have to clear
anything for now.
(dwarf::reader::read_corpus): New virtual member function
which implements the fe_iface::read_corpus pure virtual interface.
This now delegates the reading of the generic ELF properties to
elf::reader by calling elf::reader::read_corpus().
Newer front-ends will be able to do the same.
(dwarf::reader::reset_corpus): New member function.
(dwarf::reader::read_debug_info_into_corpus): Adjust. This
is now a member function. Also, do not set the
corpus::LINUX_KERNEL_BINARY_ORIGIN here as it's now set by the
elf::reader when it loads the binary.
(dwarf::reader::{env, drop_undefined_syms,
drop_undefined_syms, dwarf_elf_handle, dwarf_per_die_source,
elf_path, compute_canonical_die_offset, get_die_source,
get_die_from_offset, get_die_qualified_name,
get_die_pretty_type_representation, get_die_qualified_type_name,
get_die_pretty_representation, odr_is_relevant,
set_canonical_die_offset, get_canonical_die_offset,
erase_canonical_die_offset, die_wip_classes_map,
die_wip_function_types_map, compare_before_canonicalisation,
resolve_declaration_only_classes, resolve_declaration_only_enums,
symbol_already_belongs_to_a_function,
fixup_functions_with_no_symbols, canonicalize_types_scheduled,
tu_die_imported_unit_points_map, die_parent_map,
find_symbol_table_section, get_variable_address,
exported_decls_builder, load_all_types, load_in_linux_kernel_mode,
show_stats, do_log, build_die_parent_maps): Adjust.
(offset_pairs_stack_type::rdr_): Changed the ctxt_ into this.
(offset_pairs_stack_type::offset_pairs_stack_type): Adjust.
(offset_pairs_stack_type::{erase_redundant_type_pair_entry,
cancel_canonical_propagated_type}): Adjust.
(dwarf::reader::{get_suppressions, offline_callbacks,
create_default_dwfl, dwfl_handle, elf_module, elf_handle,
add_debug_info_root_paths, add_debug_info_root_path,
find_alt_debug_info, dwarf, alt_dwarf, alt_debug_info_path,
current_corpus, reset_current_corpus, current_corpus_group,
has_corpus_group, main_corpus_from_current_group,
current_corpus_is_main_corpus_from_current_group,
should_reuse_type_from_corpus_group, function_symbol_is_exported,
variable_symbol_is_exported, symtab, dt_needed, dt_soname,
elf_architecture, is_elf_symbol_suppressed,
load_dt_soname_and_needed, load_elf_architecture,
load_elf_properties, maybe_add_fn_to_exported_decls,
maybe_add_var_to_exported_decls}): Remove these member functions
as they got moved into the elf_reader namespace or into the
fe_iface class.
(dwarf::read_context::{suppression_can_match,
suppression_matches_function_sym_name,
suppression_matches_function_name,
suppression_matches_variable_name,
suppression_matches_variable_sym_name,
suppression_matches_type_name_or_location}): Move these into the
suppr namespace. Make it take an additional parameter that is
reference fe_iface.
(dwarf::reader::load_debug_info): Remove. This became
merged into dwarf::read_debug_info_into_corpus.
(dwarf::{set_debug_info_root_path,
get_debug_info_root_path, get_show_stats, set_drop_undefined_syms,
set_do_log}): Remove.
(add_read_context_suppressions)
(set_read_context_corpus_group, read_corpus_from_elf): Remove.
(read_debug_info_into_corpus): This became a member function of
dwarf::reader.
(create_reader): Renamed create_read_context into this.
Make it return an elf_based_reader_sptr, like the other front-end
factory functions. Adjust.
(reset_dwarf_reader): Renamed reset_read_context into this.
Adjust.
(read_corpus_from_elf): Adjust.
* src/abg-elf-based-reader.cc: New file.
* src/abg-elf-helpers.h (struct dwfl_deleter, dwfl_sptr)
(addr_elf_symbol_sptr_map_type, address_set_sptr): Move these
types here from abg-dwarf-reader.cc
(initialize_dwfl_callbacks, lookup_data_tag_from_dynamic_segment):
* src/abg-elf-helpers.cc (lookup_data_tag_from_dynamic_segment)
(lookup_data_tag_from_dynamic_segment, initialize_dwfl_callbacks)
(create_new_dwfl_handle, get_soname_of_elf_file): New functions
that got moved here from the factorizing of abg-dwarf-reader.cc
and abg-ctf-reader.cc.
* src/abg-tools-utils.cc (file_has_dwarf_debug_info)
(file_has_ctf_debug_info): New functions.
(load_generate_apply_suppressions): Take an elf_based_reader, not
a dwarf::read_context.
(maybe_load_vmlinux_dwarf_corpus): Adjust the body to use the new
front-end types.
* src/Makefile.am: Add the new files src/abg-{fe-iface,
elf-based-reader, elf-reader}.cc to source distribution. Remove
src/abg-elf-reader-common.cc.
* tools/Makefile.am: Factorize linking to libabigail.so by using
LDADD.
* tools/abicompat.cc (read_corpus, main): Adjust.
* tools/abidiff.cc (set_suppressions)
(set_native_xml_reader_options, handle_error, main): Adjust.
* tools/abidw.cc (set_suppressions, load_corpus_and_write_abixml)
(load_kernel_corpus_group_and_write_abixml): Adjust.
* tools/abilint.cc (build_type_use_tree, show_how_type_is_used)
(set_suppressions, main): Adjust.
* tools/abipkgdiff.cc (elf_file::type, compare, compare_to_self)
(create_maps_of_package_content)
(compare_prepared_userspace_packages)
(self_compare_prepared_userspace_package): Adjust.
* tools/abisym.cc: Adjust invocation to
abigail::dwarf::lookup_symbol_from_elf, from
abigail::dwarf_reader::lookup_symbol_from_elf.
* tools/kmidiff.cc (main): Adjust.
* tests/print-diff-tree.cc (main): Adjust.
* tests/test-abidiff.cc (main): Likewise.
* tests/test-diff-dwarf.cc (main): Likewise.
* tests/test-ir-walker.cc (main): Likewise.
* tests/test-read-ctf.cc (test_task_ctf::perform): Likewise.
* tests/test-read-dwarf.cc: Remove the useless "using" statements.
* tests/test-read-write.cc: Likewise.
* tests/test-symtab.cc (read_corpus, TEST_CASE)
(assert_symbol_count): Adjust.
* tests/data/test-read-ctf/test0.abi: Adjust.
* tests/data/test-read-ctf/test0.hash.abi: Likewise.
* tests/data/test-read-ctf/test1.so.abi: Likewise.
* tests/data/test-read-ctf/test1.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test2.so.abi: Likewise.
* tests/data/test-read-ctf/test2.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test3.so.abi: Likewise.
* tests/data/test-read-ctf/test3.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test4.so.abi: Likewise.
* tests/data/test-read-ctf/test4.so.hash.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-15 16:26:37 +00:00
|
|
|
abigail::fe_iface::status status =
|
|
|
|
abigail::fe_iface::STATUS_UNKNOWN;
|
2022-05-16 18:32:54 +00:00
|
|
|
vector<char**> di_roots;
|
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
|
|
|
ABG_ASSERT(abigail::tools_utils::file_exists(in_elf_path));
|
|
|
|
|
Make Front Ends first class citizens
This patch is a reorganization of the code to better support the need
for having several different front-ends.
In the libabigail pipeline of operation, a front-end is the part of
the pipeline that analyses the input file. For instance, to analyse
an ELF file, there is going to be one front-end. To analyse an ABIXML
file, there is going to be another front-end.
The middle-end is the part of the pipeline that interacts with the
internal representation of ABIs. The middle-end knows how to analyse,
compare ABI corpora provide an internal representation of the
comparison result and analyse it as well.
The back-end would be the part of the front-end that knows how to
serialize internal representations of ABIs and ABI comparison results.
One could thus imagine a front-end that understands the DWARF debug
info format embedded in an ELF file. Another front-end would be
dedicated to the CTF debug info format, and so on.
Front-ends can share capabilities. For instance, DWARF and CTF
front-ends are ELF based front end. As such, they share capabilities
to understand the ELF format. They don't share much with the ABIXML
front-end, however, as it's based on XML, which has almost nothing in
common with ELF.
To support this organization of concepts, this patch introduces a new
hierarchy of types in the form of C++ classes.
All front-ends implements the "Front End Interface". As such, they
all inherit the abigail::fe_iface class.
That class provides properties and behaviours that are shared by all
front-ends that libabigail supports today. Namely, that class
provides access to some of the options that are relevant to operating
the front-end, to the ABI corpus or corpus group being constructed and
to the suppression specifications that are considered. It also
provides an abstract interface to perform the actual loading of the
ABI corpus. That abstract interface has to be implemented by every
single concrete front-end that is provided in libabigail.
Then, there is the "ELF Reader" front-end. Its class name is
abigail::elf::reader. It inherits the abigail::fe_iface class and
implements the fe_iface::load_corpus() so that the ELF properties of
the ELF file be loaded and exposed in the ABI corpus as returned by
the fe_iface::corpus() accessor. This ELF reader front-end also
provides lots of capabilities that are specific to accessing ELF
content.
Then, there is a common base class for ELF-based front-ends to come,
named abigail::elf_based_reader, which inherits the abigail::elf::reader
class. The purpose of this base class is to provide common properties
and behaviours that are necessary to implement things like a DWARF or
a CTF front-end, or any other front-end to support an ELF-based debug
info format.
Then, there is a CTF front-end which class is named
abigail::ctf::reader. It inherits the abigail::elf_based_reader class
and implements the fe_iface::load_corpus() interface to load and
analyse the CTF-specific properties of the ELF file. To do this,
abigail::ctf::reader::load_corpus() re-uses the abigail::elf::load_corpus() member
function to load the generic ELF parts of the ABI corpus. This reader
then constructs the internal representation of the ABI corpus and
passes it to the middle-end for further analysis.
Then, there is a DWARF front-end which class is named
abigail::dwarf::reader. It inherits the abigail::elf_based_reader
class and implements the fe_iface::load_corpus() interface to load and
analyse the DWARF-specific properties of the ELF file. To do this,
abigail::dwarf::reader re-uses the abigail::elf::load_corpus() member
function to load the generic ELF parts of the ABI corpus, just like
what the CTF front-end does. And then, just like the CTF front-end,
this reader then constructs the internal representation of the ABI
corpus and passes it to the middle-end for further analysis.
Lastly, there is an ABIXML front-end which class is named
abigail::abixml::reader. It inherits the abigail::fe_iface class
directly. Note that unlike the two previous front-ends, this one
doesn't inherit the elf_based_reader base class, for reasons that
should be obvious to the astute reader by now. So, this front-end
implements the abigail::fe_iface::load_corpus() abstract interface to
load the properties for the ABI corpus represented in the ABIXML
format, construct the internal representation and pass it to the
middle-end for further analysis.
The code of the tools got adapted to use these front-ends.
The support of CTF is still guarded by #ifdef WITH_CTF pre-processor
macros, but the one cool side effect is that the amount of guarded
code is reduced. Basically, it's only the creation of the CTF
front-end that is guarded. After its creation, what is returned is an
instance of abigail::elf_based_reader::reader, exactly like what is
returned by the creation of a DWARF front-end. Thus, the rest of the
code is exactly the same, regardless of the kind of front-end. I
believe this results in a more elegant and maintainable code.
As a proof-of-concept, this patch also provides the
create_best_elf_based_reader function. This function analyses the ELF
file and depending on the kind of debug info it provides, returns the
right front-end for it. Maybe at some point, all the #ifdef WITH_CTF
guard pre-processing macros will be constrained in a single function
like this one that will take the decision of instantiating the right
front-end. The rest of the code will be as generic as it gets.
The patch adjusts the reference abixml files produced by the CTF
front-end because it now emits the <elf-needed> XML element which was
not emitted before. This is done because the CTF front-end inherits
the elf-reader which reads the "elf-needed" property from the binary,
without explicit intervention from the CTF front-end.
The patch passes 'make distcheck' on all the supported platforms.
* include/abg-fwd.h (build_internal_underlying_enum_type_name):
Move this here from src/abg-dwarf-reader.cc.
* include/abg-elf-reader-common.h: Delete this file. Its content
is going to be put in the new include/abg-elf-reader.h.
* src/abg-elf-reader-common.cc: Likewise.
* include/abg-{elf-based-reader, elf-reader, fe-iface}.h: Add new
files.
* src/abg-fe-iface.cc: Likewise.
* include/Makefile.am: Add the new file abg-fe-iface.h,
abg-elf-based-reader.h and abg-elf-reader.h to source distribution
and remove include/abg-elf-reader-common.h from source
distribution.
* src/abg-ir.cc (build_internal_underlying_enum_type_name): Move
this here from abg-dwarf-reader.cc so that it can be used by other
readers.
* include/abg-reader.h (abigail::abixml::reader): Rename the
namespace abigail::xml_reader into this one.
(read_context, create_native_xml_read_context)
(read_context_get_path, read_corpus_from_native_xml)
(read_corpus_from_native_xml_file)
(read_corpus_group_from_native_xml)
(read_corpus_group_from_native_xml_file): Remove.
(read_translation_unit_from_file)
(read_translation_unit_from_buffer)
(read_translation_unit_from_istream)
(read_translation_unit)
(consider_types_not_reachable_from_public_interfaces)
(get_types_from_type_id, get_artifact_used_by_relation_map)
(load_canonical_type_ids): Take an fe_iface&, not a read_context.
(create_reader): Declare new function that returns a
fe_iface_sptr.
(read_corpus_from_abixml, read_corpus_from_abixml_file)
(read_corpus_group_from_abixml)
(read_corpus_group_from_abixml_file): Declare new functions.
* src/abg-reader.cc (namespace abixml): Rename the
xml_reader namespace into this.
(abixml::reader_sptr): New typedef.
(abixml::reader): Rename read_context into this. Make it
inherit the fe_iface interface.
(abixml::reader::{m_path, m_env, m_corpus, m_corpus_group,
m_exported_decls_builder, m_supprs}): Remove these data members
that are now part of the fe_iface parent type.
(abixml::reader::{set_environment, get_corpus, set_corpus,
set_corpus_group, maybe_add_fn_to_exported_decls,
maybe_add_var_to_exported_decls,
maybe_check_abixml_canonical_type_stability,
suppression_matches_function_sym_name,
suppression_matches_variable_name,
suppression_matches_variable_sym_name}): Remove.
(read_corpus_from_input): Remove. Actually the code of this went
into abixml::reader::read_context().
(abixml::reader::get_libxml_reader): Rename the get_reader
member function into this.
(abixml::add_reader_suppressions): Rename
add_read_context_suppressions into this.
(abixml::reader::read_corpus): Implement this virtual
member function if the fe_iface parent interface.
(maybe_set_naming_typedef, advance_cursor)
(handle_version_attribute, walk_xml_node_to_map_type_ids)
(read_elf_needed_from_input, read_symbol_db_from_input)
(get_or_read_and_add_translation_unit, build_needed)
(read_elf_needed_from_input, add_read_context_suppressions)
(maybe_set_artificial_location, maybe_set_naming_typedef)
(build_namespace_decl, build_elf_symbol)
(build_elf_symbol_from_reference, build_elf_symbol_db)
(build_function_parameter, build_function_decl)
(build_function_decl_if_not_suppressed, function_is_suppressed)
(type_is_suppressed, build_var_decl_if_not_suppressed)
(variable_is_suppressed, variable_is_suppressed, build_var_decl)
(build_type_decl, build_qualified_type_decl)
(build_pointer_type_def, build_reference_type_def)
(build_function_type, build_subrange_type, build_array_type_def)
(build_enum_type_decl_if_not_suppressed, build_enum_type_decl)
(build_typedef_decl, build_class_decl_if_not_suppressed)
(build_union_decl_if_not_suppressed, build_class_decl)
(build_union_decl, build_function_tdecl, build_class_tdecl)
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_non_type_tparameter)
(build_template_tparameter, build_template_parameter, build_type)
(handle_type_decl, handle_namespace_decl)
(handle_qualified_type_decl, handle_pointer_type_def)
(handle_reference_type_def, handle_function_type)
(handle_array_type_def, handle_enum_type_decl)
(handle_typedef_decl, handle_var_decl, handle_function_decl)
(handle_class_decl, handle_union_decl, handle_function_tdecl)
(read_translation_unit_from_istream): Take or use an
abixml::reader rather than a read_context.
(read_translation_unit, read_translation_unit_from_input)
(consider_types_not_reachable_from_public_interfaces)
(get_types_from_type_id, get_artifact_used_by_relation_map)
(read_corpus_group_from_input, read_translation_unit)
(handle_element_node, read_location, read_artificial_location)
(load_canonical_type_ids) : Take an fe_iface&, not a read_context.
(create_abixml_reader): Rename create_native_xml_read_context
into this. Make it return a fe_iface_sptr.
(read_corpus_from_abixml): Rename read_corpus_from_abixml into
this.
(read_corpus_from_abixml_file): Rename
read_corpus_from_native_xml_file into this.
(read_context_get_path): Remove.
* include/abg-tools-utils.h
(abigail::tools_utils::{file_has_dwarf_debug_info,
file_has_ctf_debug_info}): Declare new functions.
(create_best_elf_based_reader): Declare new function.
* include/abg-corpus.h (corpus::add): Pass the translation unit by
reference.
(corpus::exported_decls_builder::maybe_add_{fn,var}_to_exported_fns):
Take a const parameter.
* src/abg-corpus-priv.h
(corpus::exported_decls_builder::priv::add_{fn,var}_to_exported):
Take a const parameter and adjust.
* src/abg-corpus.cc
(corpus::exported_decls_builder::maybe_add_{fn,var}_to_exported_fns):
Take a const parameter.
(corpus::add): Take a reference to translation_unit_sptr.
* include/abg-suppression.h (abigail::fe_iface): Forward-declare
this.
(abigail::{suppression_sptr, suppressions_type}): Declare these
types here.
(abigail::suppr::{suppression_can_match,
suppression_matches_function_name,
suppression_matches_function_sym_name,
suppression_matches_variable_name,
suppression_matches_variable_sym_name,
suppression_matches_type_name_or_location,
is_elf_symbol_suppressed, is_elf_symbol_suppressed,
is_function_suppressed, is_variable_suppressed,
is_type_suppressed}): Declare these functions here.
* src/abg-suppression-priv.h (function_is_suppressed)
(variable_is_suppressed, type_is_suppressed)
(is_elf_symbol_suppressed): Remove these template functions.
* src/abg-suppression.cc (suppression_matches_function_name)
(suppression_matches_function_sym_name): Remove.
(variable_is_suppressed, suppression_can_match)
(suppression_matches_function_name)
(suppression_matches_function_sym_name)
(suppression_matches_variable_name)
(suppression_matches_variable_sym_name)
(suppression_matches_type_name_or_location)
(is_elf_symbol_suppressed, is_elf_symbol_suppressed)
(is_function_suppressed, is_variable_suppressed)
(is_type_suppressed): New functions.
* include/abg-ctf-reader.h (abigail::ctf::{read_context,
create_read_context, read_corpus,
read_and_add_corpus_to_group_from_elf,
set_read_context_corpus_group, reset_read_context, dic_type_key}):
Remove.
(ctf::{create_reader, reset_reader}): Declare new
functions.
* src/abg-ctf-reader.cc (read_context): Remove.
(process_ctf_typedef, process_ctf_base_type)
(build_ir_node_for_variadic_parameter_type)
(process_ctf_function_type, process_ctf_sou_members)
(process_ctf_forward_type, process_ctf_struct_type)
(process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type)
(process_ctf_enum_type, fill_ctf_section)
(lookup_symbol_in_ctf_archive, dic_type_key): Forward-declare
these static functions.
(ctf::reader): New class that is the abstraction
of the CTF reader. It extends the abigail::elf_based_reader
class. This is a renaming of the
abigail::ctf::read_context class.
(ctf::reader::{elf_handler, elf_fd,
elf_handler_dbg, elf_fd_dbg, symtab, debug_info_root_paths_,
debug_info_root_paths_}): Remove these data members as they are
now properties of the abigail::elf_reader class, which is a parent
class of this abigail::ctf::reader class.
(ctf::reader::{exported_decls_builder,
maybe_add_fn_to_exported_decls, current_corpus_group,
has_corpus_group, main_corpus_from_current_group,
current_corpus_is_main_corpus_from_current_group,
should_reuse_type_from_corpus_group}): Remove these accessors
that can now be used from the parent classes abigail::{elf_reader,
elf_based_reader}.
(ctf::reader::reader): This now delegates to the constructor of
elf_based_reader. It doesn't pass any argument to initialize()
anymore.
(ctf::reader::initialize): Add an overload with no
parameter. In the other overload, do not take a pointer to an
environment as no new environment can be passed to the instance of
reader that is being reset. Adjust the code of the initializer to
reflect all the data members that got removed.
(ctf::{env, find_ctfa_file, slurp_elf_info,
process_ctf_archive, process_ctf_type, lookup_type, read_corpus,
~reader}): New member functions. Most of these were free-form
functions that took ctf::read_context as first parameter.
In read_corpus, do not set the corpus::LINUX_KERNEL_BINARY_ORIGIN
origin as that is now done by elf::reader when it reads the
binary.
(lookup_type): Remove. These are now member functions of the
ctf::reader class.
(process_ctf_typedef, process_ctf_base_type)
(build_ir_node_for_variadic_parameter_type)
(process_ctf_function_type, process_ctf_sou_members)
(process_ctf_forward_type, process_ctf_struct_type)
(process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type): Take a
ctf::reader rather an ctf::read_context. Adjust the
content of the functions.
(process_ctf_type, lookup_type, process_ctf_archive): Remove these
and turn them into member functions of ctf::reader.
(open_elf_handler, close_elf_handler, find_alt_debuginfo): Remove
these ELF handling functions as ELF handling is now done by the
elf_reader parent class.
(fill_ctf_section): Take a const pointer to Elf_Scn.
(slurp_elf_info, find_ctfa_file): Remove this and make it be a
member of ctf::reader. Also, make it handle only CTF
reader specific pieces. slurp_elf_info now delegates the reading
of generic ELF properties to elf::reader by calling
elf::reader::read_corpus().
(create_read_context, read_corpus, set_read_context_corpus_group)
(read_and_add_corpus_to_group_from_elf): Remove these functions.
(create_reader, reset_reader): Create new functions
(dic_type_key): Make this static.
* include/abg-dwarf-reader.h (abigail::dwarf::elf_type):
Move this enum into the namespace abigail::elf_reader in the file
include/abg-elf-reader.h.
(abigail::dwarf::{read_context, read_context_sptr,
create_read_context, read_context_get_path, reset_read_context,
add_read_context_suppressions, set_read_context_corpus_group,
read_corpus_from_elf, read_and_add_corpus_to_group_from_elf,
read_and_add_corpus_to_group_from_elf,
add_read_context_suppressions, refers_to_alt_debug_info,
has_alt_debug_info, get_soname_of_elf_file, get_type_of_elf_file,
set_debug_info_root_path, get_debug_info_root_path,
get_show_stats, set_show_stats, set_drop_undefined_syms,
set_do_log, set_environment, get_environment}): Remove.
* src/abg-dwarf-reader.cc (struct dwfl_deleter, dwfl_sptr)
(addr_elf_symbol_sptr_map_type, address_set_type)
(address_set_sptr): Delete these types.
(read_context::options_type): Remove. The data members of this
type got moved to struct fe_iface::options_type.
(find_alt_debug_info_link, find_alt_debug_info_path)
(find_alt_debug_info, lookup_data_tag_from_dynamic_segment)
(elf_file_type, refers_to_alt_debug_info, has_alt_debug_info)
(get_soname_of_elf_file, get_type_of_elf_file) : Remove these ELF
specific functions from here; move them to the elf_reader
namespace.
(dwarf::reader): Create new class that extends
elf_based_reader. dwarf::read_context is renamed into this
type, actually.
(dwarf::reader::die_source_dependant_container_set::get_container):
Adjust.
(dwarf::reader::{supprs_, dwarf_version_,
offline_callbacks_, debug_info_root_paths_, handle_, dwarf_,
alt_fd_, alt_dwarf_, alt_debug_info_path_, elf_module_,
elf_handle_, elf_path_, symtab_section_, cur_corpus_group_,
cur_corpus_, dt_needed_, dt_soname_, elf_architecture_,
exported_decls_builder_, options_, drop_undefined_syms_}): Remove
these ELF-related data members to move them into the elf_reader
namespace.
(maybe_propagate_canonical_type)
(build_translation_unit_and_add_to_ir, build_ir_node_from_die)
(add_or_update_class_type, add_or_update_union_type)
(build_ir_node_for_void_type)
(build_ir_node_for_variadic_parameter_type, build_function_decl)
(function_is_suppressed, build_or_get_fn_decl_if_not_suppressed)
(build_var_decl, build_or_get_var_decl_if_not_suppressed)
(variable_is_suppressed)
(propagate_canonical_type)
(get_parent_die, get_scope_die, die_is_at_class_scope)
(die_location, die_qualified_type_name, die_qualified_name)
(die_qualified_type_name_empty)
(die_return_and_parm_names_from_fn_type_die)
(die_function_signature, die_function_type_is_method_type)
(die_pretty_print_type, die_pretty_print_decl, die_pretty_print)
(maybe_canonicalize_type, build_subrange_type)
(build_subranges_from_array_type_die, compare_dies, die_location)
(die_loc_and_name, die_is_effectively_public_decl)
(maybe_cache_type_comparison_result)
(get_cached_type_comparison_result)
(maybe_get_cached_type_comparison_result, die_is_at_class_scope)
(die_function_type_is_method_type, die_member_offset)
(die_qualified_type_name, die_qualified_decl_name)
(die_qualified_name, die_qualified_type_name_empty)
(die_return_and_parm_names_from_fn_type_die)
(die_function_signature, die_pretty_print_type)
(die_pretty_print_decl, die_pretty_print)
(at_least_one_decl_only_among_odr_relevant_dies)
(compare_as_type_dies, compare_as_decl_and_type_dies)
(fn_die_equal_by_linkage_name, try_canonical_die_comparison)
(maybe_propagate_canonical_type, propagate_canonical_type)
(compare_dies, compare_dies_during_canonicalization)
(find_import_unit_point_between_dies, get_parent_die)
(get_scope_die, find_lower_bound_in_imported_unit_points)
(build_translation_unit_and_add_to_ir)
(build_namespace_decl_and_add_to_ir, build_type_decl)
(build_enum_underlying_type, build_enum_type)
(finish_member_function_reading)
(maybe_finish_function_decl_reading)
(lookup_class_or_typedef_from_corpus)
(is_function_for_die_a_member_of_class)
(add_or_update_member_function, add_or_update_class_type)
(add_or_update_union_type, build_qualified_type)
(schedule_array_tree_for_late_canonicalization)
(maybe_strip_qualification, build_pointer_type_def)
(build_reference_type, build_function_type, build_subrange_type)
(build_subranges_from_array_type_die, build_array_type)
(build_typedef_type, build_or_get_var_decl_if_not_suppressed)
(build_var_decl, function_is_suppressed)
(build_or_get_fn_decl_if_not_suppressed, variable_is_suppressed)
(type_is_suppressed, type_is_suppressed)
(get_opaque_version_of_type, create_default_fn_sym)
(build_function_decl, maybe_canonicalize_type)
(build_ir_node_from_die)
(build_ir_node_for_variadic_parameter_type): Take a reference to
the new dwarf::reader rather than to the previous
read_context. Adjust the function body.
(return_comparison_result): Adjust.
(dwarf::reader::reader): Adjust this from
read_context::read_context.
(dwarf::reader::initialize): Adjust from
dwarf::read_context::initialize.
(dwarf::reader::create): New factory static member
function.
(dwarf::reader::~reader): This doesn't have to clear
anything for now.
(dwarf::reader::read_corpus): New virtual member function
which implements the fe_iface::read_corpus pure virtual interface.
This now delegates the reading of the generic ELF properties to
elf::reader by calling elf::reader::read_corpus().
Newer front-ends will be able to do the same.
(dwarf::reader::reset_corpus): New member function.
(dwarf::reader::read_debug_info_into_corpus): Adjust. This
is now a member function. Also, do not set the
corpus::LINUX_KERNEL_BINARY_ORIGIN here as it's now set by the
elf::reader when it loads the binary.
(dwarf::reader::{env, drop_undefined_syms,
drop_undefined_syms, dwarf_elf_handle, dwarf_per_die_source,
elf_path, compute_canonical_die_offset, get_die_source,
get_die_from_offset, get_die_qualified_name,
get_die_pretty_type_representation, get_die_qualified_type_name,
get_die_pretty_representation, odr_is_relevant,
set_canonical_die_offset, get_canonical_die_offset,
erase_canonical_die_offset, die_wip_classes_map,
die_wip_function_types_map, compare_before_canonicalisation,
resolve_declaration_only_classes, resolve_declaration_only_enums,
symbol_already_belongs_to_a_function,
fixup_functions_with_no_symbols, canonicalize_types_scheduled,
tu_die_imported_unit_points_map, die_parent_map,
find_symbol_table_section, get_variable_address,
exported_decls_builder, load_all_types, load_in_linux_kernel_mode,
show_stats, do_log, build_die_parent_maps): Adjust.
(offset_pairs_stack_type::rdr_): Changed the ctxt_ into this.
(offset_pairs_stack_type::offset_pairs_stack_type): Adjust.
(offset_pairs_stack_type::{erase_redundant_type_pair_entry,
cancel_canonical_propagated_type}): Adjust.
(dwarf::reader::{get_suppressions, offline_callbacks,
create_default_dwfl, dwfl_handle, elf_module, elf_handle,
add_debug_info_root_paths, add_debug_info_root_path,
find_alt_debug_info, dwarf, alt_dwarf, alt_debug_info_path,
current_corpus, reset_current_corpus, current_corpus_group,
has_corpus_group, main_corpus_from_current_group,
current_corpus_is_main_corpus_from_current_group,
should_reuse_type_from_corpus_group, function_symbol_is_exported,
variable_symbol_is_exported, symtab, dt_needed, dt_soname,
elf_architecture, is_elf_symbol_suppressed,
load_dt_soname_and_needed, load_elf_architecture,
load_elf_properties, maybe_add_fn_to_exported_decls,
maybe_add_var_to_exported_decls}): Remove these member functions
as they got moved into the elf_reader namespace or into the
fe_iface class.
(dwarf::read_context::{suppression_can_match,
suppression_matches_function_sym_name,
suppression_matches_function_name,
suppression_matches_variable_name,
suppression_matches_variable_sym_name,
suppression_matches_type_name_or_location}): Move these into the
suppr namespace. Make it take an additional parameter that is
reference fe_iface.
(dwarf::reader::load_debug_info): Remove. This became
merged into dwarf::read_debug_info_into_corpus.
(dwarf::{set_debug_info_root_path,
get_debug_info_root_path, get_show_stats, set_drop_undefined_syms,
set_do_log}): Remove.
(add_read_context_suppressions)
(set_read_context_corpus_group, read_corpus_from_elf): Remove.
(read_debug_info_into_corpus): This became a member function of
dwarf::reader.
(create_reader): Renamed create_read_context into this.
Make it return an elf_based_reader_sptr, like the other front-end
factory functions. Adjust.
(reset_dwarf_reader): Renamed reset_read_context into this.
Adjust.
(read_corpus_from_elf): Adjust.
* src/abg-elf-based-reader.cc: New file.
* src/abg-elf-helpers.h (struct dwfl_deleter, dwfl_sptr)
(addr_elf_symbol_sptr_map_type, address_set_sptr): Move these
types here from abg-dwarf-reader.cc
(initialize_dwfl_callbacks, lookup_data_tag_from_dynamic_segment):
* src/abg-elf-helpers.cc (lookup_data_tag_from_dynamic_segment)
(lookup_data_tag_from_dynamic_segment, initialize_dwfl_callbacks)
(create_new_dwfl_handle, get_soname_of_elf_file): New functions
that got moved here from the factorizing of abg-dwarf-reader.cc
and abg-ctf-reader.cc.
* src/abg-tools-utils.cc (file_has_dwarf_debug_info)
(file_has_ctf_debug_info): New functions.
(load_generate_apply_suppressions): Take an elf_based_reader, not
a dwarf::read_context.
(maybe_load_vmlinux_dwarf_corpus): Adjust the body to use the new
front-end types.
* src/Makefile.am: Add the new files src/abg-{fe-iface,
elf-based-reader, elf-reader}.cc to source distribution. Remove
src/abg-elf-reader-common.cc.
* tools/Makefile.am: Factorize linking to libabigail.so by using
LDADD.
* tools/abicompat.cc (read_corpus, main): Adjust.
* tools/abidiff.cc (set_suppressions)
(set_native_xml_reader_options, handle_error, main): Adjust.
* tools/abidw.cc (set_suppressions, load_corpus_and_write_abixml)
(load_kernel_corpus_group_and_write_abixml): Adjust.
* tools/abilint.cc (build_type_use_tree, show_how_type_is_used)
(set_suppressions, main): Adjust.
* tools/abipkgdiff.cc (elf_file::type, compare, compare_to_self)
(create_maps_of_package_content)
(compare_prepared_userspace_packages)
(self_compare_prepared_userspace_package): Adjust.
* tools/abisym.cc: Adjust invocation to
abigail::dwarf::lookup_symbol_from_elf, from
abigail::dwarf_reader::lookup_symbol_from_elf.
* tools/kmidiff.cc (main): Adjust.
* tests/print-diff-tree.cc (main): Adjust.
* tests/test-abidiff.cc (main): Likewise.
* tests/test-diff-dwarf.cc (main): Likewise.
* tests/test-ir-walker.cc (main): Likewise.
* tests/test-read-ctf.cc (test_task_ctf::perform): Likewise.
* tests/test-read-dwarf.cc: Remove the useless "using" statements.
* tests/test-read-write.cc: Likewise.
* tests/test-symtab.cc (read_corpus, TEST_CASE)
(assert_symbol_count): Adjust.
* tests/data/test-read-ctf/test0.abi: Adjust.
* tests/data/test-read-ctf/test0.hash.abi: Likewise.
* tests/data/test-read-ctf/test1.so.abi: Likewise.
* tests/data/test-read-ctf/test1.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test2.so.abi: Likewise.
* tests/data/test-read-ctf/test2.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test3.so.abi: Likewise.
* tests/data/test-read-ctf/test3.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test4.so.abi: Likewise.
* tests/data/test-read-ctf/test4.so.hash.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-15 16:26:37 +00:00
|
|
|
abigail::elf_based_reader_sptr rdr = ctf::create_reader(in_elf_path,
|
|
|
|
di_roots, env);
|
|
|
|
ABG_ASSERT(rdr);
|
Represent undefined corpus interfaces to analyze app compatibility
In the text below, the term interface means the "declaration of either
a function or a global variable".
To analyze the compatibility between an application and a dependent
library, one has essentially to analyze the interfaces of the
application that have undefined symbols (aka undefined interfaces from
the application) and see how they relate to the same interfaces coming
from the library but with symbols that are defined and exported from
the library (aka defined/exported interfaces from the library).
An interface that is undefined in the application and defined in the
library is an interface that the application consumes from the
library.
In other words an undefined interface from an application is an
interface that the application expects and an interface that is
exported by a library is an interface that the library provides.
If comparing the expected interface against the provided interface
yields a meaningful difference, then that might mean there is an
incompatibility between the application and the library on that
interface.
This patch uses this scheme to re-implement the weak mode of ABI
compatibility between an application and a library.
The patch adds the concept of undefined functions and variables to the
ABI corpus. Then it teaches the DWARF reader how to construct the IR
for these undefined interfaces. Then it revisits the weak mode of
operation of abicompat to make it compare the interfaces expected from
the application against the corresponding interfaces provided by
library. The patch also teaches the weak mode abicompat how to detect
incompatibilities between the interfaces that plugin expects and the
interfaces provided by the application.
This patch makes the CTF front-end construct undefined interfaces. A
subsequent patch is needed to construct undefined interfaces from the
BTF front-end however.
* include/abg-corpus.h (corpus::{lookup_variable,
get_undefined_functions, get_undefined_variables}): Declare new
member functions.
(corpus::exported_decls_builder::maybe_add_{fn,var}_to_exported_fns):
Make this return a boolean.
* include/abg-fe-iface.h (fe_iface::options_type): Add a new
load_undefined_interfaces enumerator.
(fe_iface::add_fn_to_exported_or_undefined_decls): Rename
maybe_add_fn_to_exported_decls into this.
(fe_iface::add_var_to_exported_or_undefined_decls): Rename
maybe_add_var_to_exported_decls into this.
* src/abg-btf-reader.cc (reader::build_ir_node_from_btf_type):
Adjust call to maybe_add_fn_to_exported_decls as
add_fn_to_exported_or_undefined_decls. Similarly, adjust call to
maybe_add_var_to_exported_decls as
add_var_to_exported_or_undefined_decls.
* src/abg-corpus-priv.h (corpus::priv::undefined_{fns,vars}): Add
new member variables.
* src/abg-corpus.cc
(corpus::exported_decls_builder::maybe_add_{fn,var}_to_exported_fns):
Return a bool iff the decl was added to the set of exported decls.
(corpus::{lookup_variable, get_undefined_functions,
get_undefined_variables}): Define new member functions.
(corpus::sort_{functions,variables}): Sort the undefined decls
too.
* (corpus::lookup_{function,variable}_symbol): Lookup the symbol
also among undefined symbols, not just among defined symbols.
* src/abg-ctf-reader.cc (reader::process_ctf_archive): Adjust call
to maybe_add_fn_to_exported_decls as
add_fn_to_exported_or_undefined_decls. Similarly, adjust call to
maybe_add_var_to_exported_decls as
add_var_to_exported_or_undefined_decls. Also, sort functions &
variables in the corpus.
* src/abg-dwarf-reader.cc (die_name_and_linkage_name): Define new
static function.
(reader::fixup_functions_with_no_symbols): Adjust call to
maybe_add_fn_to_exported_decls as
add_fn_to_exported_or_undefined_decls.
(reader::{is_decl_die_with_undefined_symbol,
load_undefined_interfaces}): Define new member functions.
(build_translation_unit_and_add_to_ir): Analyze DIEs of interfaces
that have undefined symbols if we were asked to load undefined
interfaces.
(variable_is_suppressed): Add a boolean parameter to tell if the
var is decl-only. Use that decl-only flag to determine if the
variable is suppressed. A non-member decl-only variable won't be
suppressed if we were asked to load undefined interfaces.
(build_or_get_var_decl_if_not_suppressed): Add a boolean parameter
to tell if the var is decl-only.
(potential_member_fn_should_be_dropped): A potential non-virtual
member function with no symbol is now dropped on the floor
regardless of it has a mangled name or not.
(build_var_decl): If the var has an undefined symbol, then set
that symbol.
(build_function_decl): If the function has an undefined symbol,
then set that symbol.
(build_ir_node_from_die): Add a var or function with undefined
symbol to the set of undefined vars or functions of the current
corpus.
* src/abg-fe-iface.cc
(fe_iface::add_fn_to_exported_or_undefined_decls): Renamed
fe_iface::maybe_add_fn_to_exported_decls into this. If the
function has an undefined symbol then add the function to the set
of undefined functions.
(fe_iface::add_var_to_exported_or_undefined_decls): Renamed
fe_iface::maybe_add_var_to_exported_decls into this. If the
variable has an undefined symbol then add the variable to the set
of undefined variables.
* src/abg-ir.cc (elf_symbol::is_variable): Undefined symbol with
type STT_NOTYPE are actually for undefined variables.
(maybe_adjust_canonical_type): It's here, after type
canonicalization that a member function is added to either the set
of defined & exported functions, or to the set of functions with
undefined symbols.
* src/abg-reader.cc (build_function_decl, build_class_decl)
(build_union_decl, handle_var_decl): Adjust.
* src/abg-symtab-reader.cc
(symtab::{lookup_undefined_function_symbol,
lookup_undefined_variable_symbol, function_symbol_is_undefined,
variable_symbol_is_undefined,
collect_undefined_fns_and_vars_linkage_names}): Define new member
functions.
(symtab::symtab): Initialize the new
cached_undefined_symbol_names_ data member.
* src/abg-symtab-reader.h
(symtab::{lookup_undefined_function_symbol,
lookup_undefined_variable_symbol, function_symbol_is_undefined,
variable_symbol_is_undefined,
collect_undefined_fns_and_vars_linkage_names}): Declare new member
functions.
(symtab::{undefined_variable_linkage_names_,
cached_undefined_symbol_names_}): Define new data members.
(symtab::load_): Consider undefined symbol of type STT_NOTYPE as
being undefined global variables. It's what I am seeing in ELF
binaries.
* src/abg-symtab-reader.h
(symtab::{lookup_undefined_function_symbol,
lookup_undefined_variable_symbol, function_symbol_is_undefined,
variable_symbol_is_undefined}): Declare new member functions.
(symtab::{undefined_function_linkage_names_,
undefined_variable_linkage_names_}): Define new member variables.
* src/abg-writer.cc (write_var_decl, write_function_decl): Emit a
reference to a symbol only when the symbol is defined.
* tools/abicompat.cc (report_function_changes)
(report_variable_changes)
(compare_expected_against_provided_functions)
(compare_expected_against_provided_variables): Define new static
functions.
(perform_compat_check_in_weak_mode): Use the new static functions
above. Compare interfaces expected by the application corpus
against interfaces provided by the library. Report the changes.
Do that in the reverse direction as well.
(read_corpus): Instruct the corpus reader to load the set of
undefined interfaces too.
* tests/data/test-abicompat/test6-var-changed-app: Remove file.
* tests/data/test-abicompat/test6-var-changed-app.cc: Likewise.
* tests/data/test-abicompat/libtest6-undefined-var.so: Add new
binary input file.
* tests/data/test-abicompat/test6-undefined-var.cc: Add sourcefile
for the binary input file above.
* tests/data/test-abicompat/test6-var-changed-report-2.txt: New
reference output file.
* tests/data/Makefile.am: Update the list of distributed files
accordingly.
* tests/data/test-abicompat/libtest5-fn-changed-libapp-v0.so:
Adjust.
* tests/data/test-abicompat/libtest5-fn-changed-libapp-v1.so:
Likewise.
* tests/data/test-abicompat/libtest6-var-changed-libapp-v0.so:
Likewise.
* tests/data/test-abicompat/libtest6-var-changed-libapp-v1.so:
Likewise.
* tests/data/test-abicompat/libtest7-fn-changed-libapp-v0.so:
Likewise.
* tests/data/test-abicompat/libtest7-fn-changed-libapp-v1.so:
Likewise.
* tests/data/test-abicompat/libtest8-fn-changed-libapp-v0.so:
Likewise.
* tests/data/test-abicompat/libtest8-fn-changed-libapp-v1.so:
Likewise.
* tests/data/test-abicompat/libtest9-fn-changed-v0.so: Likewise.
* tests/data/test-abicompat/libtest9-fn-changed-v1.so: Likewise.
* tests/data/test-abicompat/test5-fn-changed-app: Likewise.
* tests/data/test-abicompat/test6-var-changed-libapp-v0.cc:
Likewise.
* tests/data/test-abicompat/test6-var-changed-libapp-v1.cc:
Likewise.
* tests/data/test-abicompat/test6-var-changed-report-0.txt:
Likewise.
* tests/data/test-abicompat/test6-var-changed-report-1.txt:
Likewise.
* tests/data/test-abicompat/test7-fn-changed-app: Likewise.
* tests/data/test-abicompat/test7-fn-changed-report-1.txt:
Likewise.
* tests/data/test-abicompat/test7-fn-changed-report-2.txt:
Likewise.
* tests/data/test-abicompat/test8-fn-changed-app: Likewise.
* tests/data/test-abicompat/test8-fn-changed-libapp-v1.c:
Likewise.
* tests/data/test-abicompat/test9-fn-changed-app: Likewise.
* tests/data/test-abicompat/test9-fn-changed-app.cc: Likewise.
* tests/data/test-annotate/libtest23.so.abi: Likewise.
* 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/test1.abi: Likewise.
* tests/data/test-annotate/test14-pr18893.so.ab: Likewise.i
* 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/test2.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-annotate/test8-qualified-this-pointer.so.abi:
Likewise.
* tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt:
Likewise.
* tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt:
Likewise.
* tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt:
Likewise.
* tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt:
Likewise.
* tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt:
Likewise.
* tests/data/test-fedabipkgdiff/vte291-0.39.1-1.fc22.x86_64--vte291-0.39.90-1.fc22.x86_64-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/PR26261/PR26261-exe.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-libaaudio.so.abi: Likewise.
* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
* tests/data/test-read-dwarf/test1.abi: Likewise.
* tests/data/test-read-dwarf/test1.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/test2.so.abi: Likewise.
* tests/data/test-read-dwarf/test2.so.hash.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/test8-qualified-this-pointer.so.abi:
Likewise.
* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.hash.abi:
Likewise.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
* tests/test-abicompat.cc (in_out_specs): Adjust.
* tests/test-read-ctf.cc (test_task_ctf::perform): Do not load
undefined interfaces, by default.
* tests/test-symtab.cc (Symtab::SimpleSymtabs)
(Symtab::SymtabWithWhitelist, Symtab::AliasedFunctionSymbols):
Adjust the expected undefined variable symbols counts.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2024-02-21 09:54:57 +00:00
|
|
|
rdr->options().load_undefined_interfaces = false;
|
Make Front Ends first class citizens
This patch is a reorganization of the code to better support the need
for having several different front-ends.
In the libabigail pipeline of operation, a front-end is the part of
the pipeline that analyses the input file. For instance, to analyse
an ELF file, there is going to be one front-end. To analyse an ABIXML
file, there is going to be another front-end.
The middle-end is the part of the pipeline that interacts with the
internal representation of ABIs. The middle-end knows how to analyse,
compare ABI corpora provide an internal representation of the
comparison result and analyse it as well.
The back-end would be the part of the front-end that knows how to
serialize internal representations of ABIs and ABI comparison results.
One could thus imagine a front-end that understands the DWARF debug
info format embedded in an ELF file. Another front-end would be
dedicated to the CTF debug info format, and so on.
Front-ends can share capabilities. For instance, DWARF and CTF
front-ends are ELF based front end. As such, they share capabilities
to understand the ELF format. They don't share much with the ABIXML
front-end, however, as it's based on XML, which has almost nothing in
common with ELF.
To support this organization of concepts, this patch introduces a new
hierarchy of types in the form of C++ classes.
All front-ends implements the "Front End Interface". As such, they
all inherit the abigail::fe_iface class.
That class provides properties and behaviours that are shared by all
front-ends that libabigail supports today. Namely, that class
provides access to some of the options that are relevant to operating
the front-end, to the ABI corpus or corpus group being constructed and
to the suppression specifications that are considered. It also
provides an abstract interface to perform the actual loading of the
ABI corpus. That abstract interface has to be implemented by every
single concrete front-end that is provided in libabigail.
Then, there is the "ELF Reader" front-end. Its class name is
abigail::elf::reader. It inherits the abigail::fe_iface class and
implements the fe_iface::load_corpus() so that the ELF properties of
the ELF file be loaded and exposed in the ABI corpus as returned by
the fe_iface::corpus() accessor. This ELF reader front-end also
provides lots of capabilities that are specific to accessing ELF
content.
Then, there is a common base class for ELF-based front-ends to come,
named abigail::elf_based_reader, which inherits the abigail::elf::reader
class. The purpose of this base class is to provide common properties
and behaviours that are necessary to implement things like a DWARF or
a CTF front-end, or any other front-end to support an ELF-based debug
info format.
Then, there is a CTF front-end which class is named
abigail::ctf::reader. It inherits the abigail::elf_based_reader class
and implements the fe_iface::load_corpus() interface to load and
analyse the CTF-specific properties of the ELF file. To do this,
abigail::ctf::reader::load_corpus() re-uses the abigail::elf::load_corpus() member
function to load the generic ELF parts of the ABI corpus. This reader
then constructs the internal representation of the ABI corpus and
passes it to the middle-end for further analysis.
Then, there is a DWARF front-end which class is named
abigail::dwarf::reader. It inherits the abigail::elf_based_reader
class and implements the fe_iface::load_corpus() interface to load and
analyse the DWARF-specific properties of the ELF file. To do this,
abigail::dwarf::reader re-uses the abigail::elf::load_corpus() member
function to load the generic ELF parts of the ABI corpus, just like
what the CTF front-end does. And then, just like the CTF front-end,
this reader then constructs the internal representation of the ABI
corpus and passes it to the middle-end for further analysis.
Lastly, there is an ABIXML front-end which class is named
abigail::abixml::reader. It inherits the abigail::fe_iface class
directly. Note that unlike the two previous front-ends, this one
doesn't inherit the elf_based_reader base class, for reasons that
should be obvious to the astute reader by now. So, this front-end
implements the abigail::fe_iface::load_corpus() abstract interface to
load the properties for the ABI corpus represented in the ABIXML
format, construct the internal representation and pass it to the
middle-end for further analysis.
The code of the tools got adapted to use these front-ends.
The support of CTF is still guarded by #ifdef WITH_CTF pre-processor
macros, but the one cool side effect is that the amount of guarded
code is reduced. Basically, it's only the creation of the CTF
front-end that is guarded. After its creation, what is returned is an
instance of abigail::elf_based_reader::reader, exactly like what is
returned by the creation of a DWARF front-end. Thus, the rest of the
code is exactly the same, regardless of the kind of front-end. I
believe this results in a more elegant and maintainable code.
As a proof-of-concept, this patch also provides the
create_best_elf_based_reader function. This function analyses the ELF
file and depending on the kind of debug info it provides, returns the
right front-end for it. Maybe at some point, all the #ifdef WITH_CTF
guard pre-processing macros will be constrained in a single function
like this one that will take the decision of instantiating the right
front-end. The rest of the code will be as generic as it gets.
The patch adjusts the reference abixml files produced by the CTF
front-end because it now emits the <elf-needed> XML element which was
not emitted before. This is done because the CTF front-end inherits
the elf-reader which reads the "elf-needed" property from the binary,
without explicit intervention from the CTF front-end.
The patch passes 'make distcheck' on all the supported platforms.
* include/abg-fwd.h (build_internal_underlying_enum_type_name):
Move this here from src/abg-dwarf-reader.cc.
* include/abg-elf-reader-common.h: Delete this file. Its content
is going to be put in the new include/abg-elf-reader.h.
* src/abg-elf-reader-common.cc: Likewise.
* include/abg-{elf-based-reader, elf-reader, fe-iface}.h: Add new
files.
* src/abg-fe-iface.cc: Likewise.
* include/Makefile.am: Add the new file abg-fe-iface.h,
abg-elf-based-reader.h and abg-elf-reader.h to source distribution
and remove include/abg-elf-reader-common.h from source
distribution.
* src/abg-ir.cc (build_internal_underlying_enum_type_name): Move
this here from abg-dwarf-reader.cc so that it can be used by other
readers.
* include/abg-reader.h (abigail::abixml::reader): Rename the
namespace abigail::xml_reader into this one.
(read_context, create_native_xml_read_context)
(read_context_get_path, read_corpus_from_native_xml)
(read_corpus_from_native_xml_file)
(read_corpus_group_from_native_xml)
(read_corpus_group_from_native_xml_file): Remove.
(read_translation_unit_from_file)
(read_translation_unit_from_buffer)
(read_translation_unit_from_istream)
(read_translation_unit)
(consider_types_not_reachable_from_public_interfaces)
(get_types_from_type_id, get_artifact_used_by_relation_map)
(load_canonical_type_ids): Take an fe_iface&, not a read_context.
(create_reader): Declare new function that returns a
fe_iface_sptr.
(read_corpus_from_abixml, read_corpus_from_abixml_file)
(read_corpus_group_from_abixml)
(read_corpus_group_from_abixml_file): Declare new functions.
* src/abg-reader.cc (namespace abixml): Rename the
xml_reader namespace into this.
(abixml::reader_sptr): New typedef.
(abixml::reader): Rename read_context into this. Make it
inherit the fe_iface interface.
(abixml::reader::{m_path, m_env, m_corpus, m_corpus_group,
m_exported_decls_builder, m_supprs}): Remove these data members
that are now part of the fe_iface parent type.
(abixml::reader::{set_environment, get_corpus, set_corpus,
set_corpus_group, maybe_add_fn_to_exported_decls,
maybe_add_var_to_exported_decls,
maybe_check_abixml_canonical_type_stability,
suppression_matches_function_sym_name,
suppression_matches_variable_name,
suppression_matches_variable_sym_name}): Remove.
(read_corpus_from_input): Remove. Actually the code of this went
into abixml::reader::read_context().
(abixml::reader::get_libxml_reader): Rename the get_reader
member function into this.
(abixml::add_reader_suppressions): Rename
add_read_context_suppressions into this.
(abixml::reader::read_corpus): Implement this virtual
member function if the fe_iface parent interface.
(maybe_set_naming_typedef, advance_cursor)
(handle_version_attribute, walk_xml_node_to_map_type_ids)
(read_elf_needed_from_input, read_symbol_db_from_input)
(get_or_read_and_add_translation_unit, build_needed)
(read_elf_needed_from_input, add_read_context_suppressions)
(maybe_set_artificial_location, maybe_set_naming_typedef)
(build_namespace_decl, build_elf_symbol)
(build_elf_symbol_from_reference, build_elf_symbol_db)
(build_function_parameter, build_function_decl)
(build_function_decl_if_not_suppressed, function_is_suppressed)
(type_is_suppressed, build_var_decl_if_not_suppressed)
(variable_is_suppressed, variable_is_suppressed, build_var_decl)
(build_type_decl, build_qualified_type_decl)
(build_pointer_type_def, build_reference_type_def)
(build_function_type, build_subrange_type, build_array_type_def)
(build_enum_type_decl_if_not_suppressed, build_enum_type_decl)
(build_typedef_decl, build_class_decl_if_not_suppressed)
(build_union_decl_if_not_suppressed, build_class_decl)
(build_union_decl, build_function_tdecl, build_class_tdecl)
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_non_type_tparameter)
(build_template_tparameter, build_template_parameter, build_type)
(handle_type_decl, handle_namespace_decl)
(handle_qualified_type_decl, handle_pointer_type_def)
(handle_reference_type_def, handle_function_type)
(handle_array_type_def, handle_enum_type_decl)
(handle_typedef_decl, handle_var_decl, handle_function_decl)
(handle_class_decl, handle_union_decl, handle_function_tdecl)
(read_translation_unit_from_istream): Take or use an
abixml::reader rather than a read_context.
(read_translation_unit, read_translation_unit_from_input)
(consider_types_not_reachable_from_public_interfaces)
(get_types_from_type_id, get_artifact_used_by_relation_map)
(read_corpus_group_from_input, read_translation_unit)
(handle_element_node, read_location, read_artificial_location)
(load_canonical_type_ids) : Take an fe_iface&, not a read_context.
(create_abixml_reader): Rename create_native_xml_read_context
into this. Make it return a fe_iface_sptr.
(read_corpus_from_abixml): Rename read_corpus_from_abixml into
this.
(read_corpus_from_abixml_file): Rename
read_corpus_from_native_xml_file into this.
(read_context_get_path): Remove.
* include/abg-tools-utils.h
(abigail::tools_utils::{file_has_dwarf_debug_info,
file_has_ctf_debug_info}): Declare new functions.
(create_best_elf_based_reader): Declare new function.
* include/abg-corpus.h (corpus::add): Pass the translation unit by
reference.
(corpus::exported_decls_builder::maybe_add_{fn,var}_to_exported_fns):
Take a const parameter.
* src/abg-corpus-priv.h
(corpus::exported_decls_builder::priv::add_{fn,var}_to_exported):
Take a const parameter and adjust.
* src/abg-corpus.cc
(corpus::exported_decls_builder::maybe_add_{fn,var}_to_exported_fns):
Take a const parameter.
(corpus::add): Take a reference to translation_unit_sptr.
* include/abg-suppression.h (abigail::fe_iface): Forward-declare
this.
(abigail::{suppression_sptr, suppressions_type}): Declare these
types here.
(abigail::suppr::{suppression_can_match,
suppression_matches_function_name,
suppression_matches_function_sym_name,
suppression_matches_variable_name,
suppression_matches_variable_sym_name,
suppression_matches_type_name_or_location,
is_elf_symbol_suppressed, is_elf_symbol_suppressed,
is_function_suppressed, is_variable_suppressed,
is_type_suppressed}): Declare these functions here.
* src/abg-suppression-priv.h (function_is_suppressed)
(variable_is_suppressed, type_is_suppressed)
(is_elf_symbol_suppressed): Remove these template functions.
* src/abg-suppression.cc (suppression_matches_function_name)
(suppression_matches_function_sym_name): Remove.
(variable_is_suppressed, suppression_can_match)
(suppression_matches_function_name)
(suppression_matches_function_sym_name)
(suppression_matches_variable_name)
(suppression_matches_variable_sym_name)
(suppression_matches_type_name_or_location)
(is_elf_symbol_suppressed, is_elf_symbol_suppressed)
(is_function_suppressed, is_variable_suppressed)
(is_type_suppressed): New functions.
* include/abg-ctf-reader.h (abigail::ctf::{read_context,
create_read_context, read_corpus,
read_and_add_corpus_to_group_from_elf,
set_read_context_corpus_group, reset_read_context, dic_type_key}):
Remove.
(ctf::{create_reader, reset_reader}): Declare new
functions.
* src/abg-ctf-reader.cc (read_context): Remove.
(process_ctf_typedef, process_ctf_base_type)
(build_ir_node_for_variadic_parameter_type)
(process_ctf_function_type, process_ctf_sou_members)
(process_ctf_forward_type, process_ctf_struct_type)
(process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type)
(process_ctf_enum_type, fill_ctf_section)
(lookup_symbol_in_ctf_archive, dic_type_key): Forward-declare
these static functions.
(ctf::reader): New class that is the abstraction
of the CTF reader. It extends the abigail::elf_based_reader
class. This is a renaming of the
abigail::ctf::read_context class.
(ctf::reader::{elf_handler, elf_fd,
elf_handler_dbg, elf_fd_dbg, symtab, debug_info_root_paths_,
debug_info_root_paths_}): Remove these data members as they are
now properties of the abigail::elf_reader class, which is a parent
class of this abigail::ctf::reader class.
(ctf::reader::{exported_decls_builder,
maybe_add_fn_to_exported_decls, current_corpus_group,
has_corpus_group, main_corpus_from_current_group,
current_corpus_is_main_corpus_from_current_group,
should_reuse_type_from_corpus_group}): Remove these accessors
that can now be used from the parent classes abigail::{elf_reader,
elf_based_reader}.
(ctf::reader::reader): This now delegates to the constructor of
elf_based_reader. It doesn't pass any argument to initialize()
anymore.
(ctf::reader::initialize): Add an overload with no
parameter. In the other overload, do not take a pointer to an
environment as no new environment can be passed to the instance of
reader that is being reset. Adjust the code of the initializer to
reflect all the data members that got removed.
(ctf::{env, find_ctfa_file, slurp_elf_info,
process_ctf_archive, process_ctf_type, lookup_type, read_corpus,
~reader}): New member functions. Most of these were free-form
functions that took ctf::read_context as first parameter.
In read_corpus, do not set the corpus::LINUX_KERNEL_BINARY_ORIGIN
origin as that is now done by elf::reader when it reads the
binary.
(lookup_type): Remove. These are now member functions of the
ctf::reader class.
(process_ctf_typedef, process_ctf_base_type)
(build_ir_node_for_variadic_parameter_type)
(process_ctf_function_type, process_ctf_sou_members)
(process_ctf_forward_type, process_ctf_struct_type)
(process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type): Take a
ctf::reader rather an ctf::read_context. Adjust the
content of the functions.
(process_ctf_type, lookup_type, process_ctf_archive): Remove these
and turn them into member functions of ctf::reader.
(open_elf_handler, close_elf_handler, find_alt_debuginfo): Remove
these ELF handling functions as ELF handling is now done by the
elf_reader parent class.
(fill_ctf_section): Take a const pointer to Elf_Scn.
(slurp_elf_info, find_ctfa_file): Remove this and make it be a
member of ctf::reader. Also, make it handle only CTF
reader specific pieces. slurp_elf_info now delegates the reading
of generic ELF properties to elf::reader by calling
elf::reader::read_corpus().
(create_read_context, read_corpus, set_read_context_corpus_group)
(read_and_add_corpus_to_group_from_elf): Remove these functions.
(create_reader, reset_reader): Create new functions
(dic_type_key): Make this static.
* include/abg-dwarf-reader.h (abigail::dwarf::elf_type):
Move this enum into the namespace abigail::elf_reader in the file
include/abg-elf-reader.h.
(abigail::dwarf::{read_context, read_context_sptr,
create_read_context, read_context_get_path, reset_read_context,
add_read_context_suppressions, set_read_context_corpus_group,
read_corpus_from_elf, read_and_add_corpus_to_group_from_elf,
read_and_add_corpus_to_group_from_elf,
add_read_context_suppressions, refers_to_alt_debug_info,
has_alt_debug_info, get_soname_of_elf_file, get_type_of_elf_file,
set_debug_info_root_path, get_debug_info_root_path,
get_show_stats, set_show_stats, set_drop_undefined_syms,
set_do_log, set_environment, get_environment}): Remove.
* src/abg-dwarf-reader.cc (struct dwfl_deleter, dwfl_sptr)
(addr_elf_symbol_sptr_map_type, address_set_type)
(address_set_sptr): Delete these types.
(read_context::options_type): Remove. The data members of this
type got moved to struct fe_iface::options_type.
(find_alt_debug_info_link, find_alt_debug_info_path)
(find_alt_debug_info, lookup_data_tag_from_dynamic_segment)
(elf_file_type, refers_to_alt_debug_info, has_alt_debug_info)
(get_soname_of_elf_file, get_type_of_elf_file) : Remove these ELF
specific functions from here; move them to the elf_reader
namespace.
(dwarf::reader): Create new class that extends
elf_based_reader. dwarf::read_context is renamed into this
type, actually.
(dwarf::reader::die_source_dependant_container_set::get_container):
Adjust.
(dwarf::reader::{supprs_, dwarf_version_,
offline_callbacks_, debug_info_root_paths_, handle_, dwarf_,
alt_fd_, alt_dwarf_, alt_debug_info_path_, elf_module_,
elf_handle_, elf_path_, symtab_section_, cur_corpus_group_,
cur_corpus_, dt_needed_, dt_soname_, elf_architecture_,
exported_decls_builder_, options_, drop_undefined_syms_}): Remove
these ELF-related data members to move them into the elf_reader
namespace.
(maybe_propagate_canonical_type)
(build_translation_unit_and_add_to_ir, build_ir_node_from_die)
(add_or_update_class_type, add_or_update_union_type)
(build_ir_node_for_void_type)
(build_ir_node_for_variadic_parameter_type, build_function_decl)
(function_is_suppressed, build_or_get_fn_decl_if_not_suppressed)
(build_var_decl, build_or_get_var_decl_if_not_suppressed)
(variable_is_suppressed)
(propagate_canonical_type)
(get_parent_die, get_scope_die, die_is_at_class_scope)
(die_location, die_qualified_type_name, die_qualified_name)
(die_qualified_type_name_empty)
(die_return_and_parm_names_from_fn_type_die)
(die_function_signature, die_function_type_is_method_type)
(die_pretty_print_type, die_pretty_print_decl, die_pretty_print)
(maybe_canonicalize_type, build_subrange_type)
(build_subranges_from_array_type_die, compare_dies, die_location)
(die_loc_and_name, die_is_effectively_public_decl)
(maybe_cache_type_comparison_result)
(get_cached_type_comparison_result)
(maybe_get_cached_type_comparison_result, die_is_at_class_scope)
(die_function_type_is_method_type, die_member_offset)
(die_qualified_type_name, die_qualified_decl_name)
(die_qualified_name, die_qualified_type_name_empty)
(die_return_and_parm_names_from_fn_type_die)
(die_function_signature, die_pretty_print_type)
(die_pretty_print_decl, die_pretty_print)
(at_least_one_decl_only_among_odr_relevant_dies)
(compare_as_type_dies, compare_as_decl_and_type_dies)
(fn_die_equal_by_linkage_name, try_canonical_die_comparison)
(maybe_propagate_canonical_type, propagate_canonical_type)
(compare_dies, compare_dies_during_canonicalization)
(find_import_unit_point_between_dies, get_parent_die)
(get_scope_die, find_lower_bound_in_imported_unit_points)
(build_translation_unit_and_add_to_ir)
(build_namespace_decl_and_add_to_ir, build_type_decl)
(build_enum_underlying_type, build_enum_type)
(finish_member_function_reading)
(maybe_finish_function_decl_reading)
(lookup_class_or_typedef_from_corpus)
(is_function_for_die_a_member_of_class)
(add_or_update_member_function, add_or_update_class_type)
(add_or_update_union_type, build_qualified_type)
(schedule_array_tree_for_late_canonicalization)
(maybe_strip_qualification, build_pointer_type_def)
(build_reference_type, build_function_type, build_subrange_type)
(build_subranges_from_array_type_die, build_array_type)
(build_typedef_type, build_or_get_var_decl_if_not_suppressed)
(build_var_decl, function_is_suppressed)
(build_or_get_fn_decl_if_not_suppressed, variable_is_suppressed)
(type_is_suppressed, type_is_suppressed)
(get_opaque_version_of_type, create_default_fn_sym)
(build_function_decl, maybe_canonicalize_type)
(build_ir_node_from_die)
(build_ir_node_for_variadic_parameter_type): Take a reference to
the new dwarf::reader rather than to the previous
read_context. Adjust the function body.
(return_comparison_result): Adjust.
(dwarf::reader::reader): Adjust this from
read_context::read_context.
(dwarf::reader::initialize): Adjust from
dwarf::read_context::initialize.
(dwarf::reader::create): New factory static member
function.
(dwarf::reader::~reader): This doesn't have to clear
anything for now.
(dwarf::reader::read_corpus): New virtual member function
which implements the fe_iface::read_corpus pure virtual interface.
This now delegates the reading of the generic ELF properties to
elf::reader by calling elf::reader::read_corpus().
Newer front-ends will be able to do the same.
(dwarf::reader::reset_corpus): New member function.
(dwarf::reader::read_debug_info_into_corpus): Adjust. This
is now a member function. Also, do not set the
corpus::LINUX_KERNEL_BINARY_ORIGIN here as it's now set by the
elf::reader when it loads the binary.
(dwarf::reader::{env, drop_undefined_syms,
drop_undefined_syms, dwarf_elf_handle, dwarf_per_die_source,
elf_path, compute_canonical_die_offset, get_die_source,
get_die_from_offset, get_die_qualified_name,
get_die_pretty_type_representation, get_die_qualified_type_name,
get_die_pretty_representation, odr_is_relevant,
set_canonical_die_offset, get_canonical_die_offset,
erase_canonical_die_offset, die_wip_classes_map,
die_wip_function_types_map, compare_before_canonicalisation,
resolve_declaration_only_classes, resolve_declaration_only_enums,
symbol_already_belongs_to_a_function,
fixup_functions_with_no_symbols, canonicalize_types_scheduled,
tu_die_imported_unit_points_map, die_parent_map,
find_symbol_table_section, get_variable_address,
exported_decls_builder, load_all_types, load_in_linux_kernel_mode,
show_stats, do_log, build_die_parent_maps): Adjust.
(offset_pairs_stack_type::rdr_): Changed the ctxt_ into this.
(offset_pairs_stack_type::offset_pairs_stack_type): Adjust.
(offset_pairs_stack_type::{erase_redundant_type_pair_entry,
cancel_canonical_propagated_type}): Adjust.
(dwarf::reader::{get_suppressions, offline_callbacks,
create_default_dwfl, dwfl_handle, elf_module, elf_handle,
add_debug_info_root_paths, add_debug_info_root_path,
find_alt_debug_info, dwarf, alt_dwarf, alt_debug_info_path,
current_corpus, reset_current_corpus, current_corpus_group,
has_corpus_group, main_corpus_from_current_group,
current_corpus_is_main_corpus_from_current_group,
should_reuse_type_from_corpus_group, function_symbol_is_exported,
variable_symbol_is_exported, symtab, dt_needed, dt_soname,
elf_architecture, is_elf_symbol_suppressed,
load_dt_soname_and_needed, load_elf_architecture,
load_elf_properties, maybe_add_fn_to_exported_decls,
maybe_add_var_to_exported_decls}): Remove these member functions
as they got moved into the elf_reader namespace or into the
fe_iface class.
(dwarf::read_context::{suppression_can_match,
suppression_matches_function_sym_name,
suppression_matches_function_name,
suppression_matches_variable_name,
suppression_matches_variable_sym_name,
suppression_matches_type_name_or_location}): Move these into the
suppr namespace. Make it take an additional parameter that is
reference fe_iface.
(dwarf::reader::load_debug_info): Remove. This became
merged into dwarf::read_debug_info_into_corpus.
(dwarf::{set_debug_info_root_path,
get_debug_info_root_path, get_show_stats, set_drop_undefined_syms,
set_do_log}): Remove.
(add_read_context_suppressions)
(set_read_context_corpus_group, read_corpus_from_elf): Remove.
(read_debug_info_into_corpus): This became a member function of
dwarf::reader.
(create_reader): Renamed create_read_context into this.
Make it return an elf_based_reader_sptr, like the other front-end
factory functions. Adjust.
(reset_dwarf_reader): Renamed reset_read_context into this.
Adjust.
(read_corpus_from_elf): Adjust.
* src/abg-elf-based-reader.cc: New file.
* src/abg-elf-helpers.h (struct dwfl_deleter, dwfl_sptr)
(addr_elf_symbol_sptr_map_type, address_set_sptr): Move these
types here from abg-dwarf-reader.cc
(initialize_dwfl_callbacks, lookup_data_tag_from_dynamic_segment):
* src/abg-elf-helpers.cc (lookup_data_tag_from_dynamic_segment)
(lookup_data_tag_from_dynamic_segment, initialize_dwfl_callbacks)
(create_new_dwfl_handle, get_soname_of_elf_file): New functions
that got moved here from the factorizing of abg-dwarf-reader.cc
and abg-ctf-reader.cc.
* src/abg-tools-utils.cc (file_has_dwarf_debug_info)
(file_has_ctf_debug_info): New functions.
(load_generate_apply_suppressions): Take an elf_based_reader, not
a dwarf::read_context.
(maybe_load_vmlinux_dwarf_corpus): Adjust the body to use the new
front-end types.
* src/Makefile.am: Add the new files src/abg-{fe-iface,
elf-based-reader, elf-reader}.cc to source distribution. Remove
src/abg-elf-reader-common.cc.
* tools/Makefile.am: Factorize linking to libabigail.so by using
LDADD.
* tools/abicompat.cc (read_corpus, main): Adjust.
* tools/abidiff.cc (set_suppressions)
(set_native_xml_reader_options, handle_error, main): Adjust.
* tools/abidw.cc (set_suppressions, load_corpus_and_write_abixml)
(load_kernel_corpus_group_and_write_abixml): Adjust.
* tools/abilint.cc (build_type_use_tree, show_how_type_is_used)
(set_suppressions, main): Adjust.
* tools/abipkgdiff.cc (elf_file::type, compare, compare_to_self)
(create_maps_of_package_content)
(compare_prepared_userspace_packages)
(self_compare_prepared_userspace_package): Adjust.
* tools/abisym.cc: Adjust invocation to
abigail::dwarf::lookup_symbol_from_elf, from
abigail::dwarf_reader::lookup_symbol_from_elf.
* tools/kmidiff.cc (main): Adjust.
* tests/print-diff-tree.cc (main): Adjust.
* tests/test-abidiff.cc (main): Likewise.
* tests/test-diff-dwarf.cc (main): Likewise.
* tests/test-ir-walker.cc (main): Likewise.
* tests/test-read-ctf.cc (test_task_ctf::perform): Likewise.
* tests/test-read-dwarf.cc: Remove the useless "using" statements.
* tests/test-read-write.cc: Likewise.
* tests/test-symtab.cc (read_corpus, TEST_CASE)
(assert_symbol_count): Adjust.
* tests/data/test-read-ctf/test0.abi: Adjust.
* tests/data/test-read-ctf/test0.hash.abi: Likewise.
* tests/data/test-read-ctf/test1.so.abi: Likewise.
* tests/data/test-read-ctf/test1.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test2.so.abi: Likewise.
* tests/data/test-read-ctf/test2.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test3.so.abi: Likewise.
* tests/data/test-read-ctf/test3.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test4.so.abi: Likewise.
* tests/data/test-read-ctf/test4.so.hash.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-15 16:26:37 +00:00
|
|
|
corpus_sptr corp = rdr->read_corpus(status);
|
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
|
|
|
|
|
|
|
// if there is no output and no input, assume that we do not care about the
|
|
|
|
// actual read result, just that it succeeded.
|
|
|
|
if (!spec.in_abi_path && !spec.out_abi_path)
|
|
|
|
{
|
|
|
|
// Phew! we made it here and we did not crash! yay!
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!corp)
|
|
|
|
{
|
|
|
|
error_message = string("failed to read ") + in_elf_path + "\n";
|
|
|
|
is_ok = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
corp->set_path(spec.in_elf_path);
|
|
|
|
// Do not take architecture names in comparison so that these
|
|
|
|
// test input binaries can come from whatever arch the
|
|
|
|
// programmer likes.
|
|
|
|
corp->set_architecture_name("");
|
|
|
|
|
|
|
|
if (!(is_ok = set_out_abi_path()))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!(is_ok = serialize_corpus(out_abi_path, corp)))
|
|
|
|
return;
|
|
|
|
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
if (!(is_ok = run_abidw()))
|
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
|
|
|
return;
|
|
|
|
|
|
|
|
if (!(is_ok = run_diff()))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Create a new CTF instance for task to be execute by the testsuite.
|
|
|
|
///
|
|
|
|
/// @param s the @ref abigail::tests::read_common::InOutSpec
|
|
|
|
/// tests container.
|
|
|
|
///
|
|
|
|
/// @param a_out_abi_base the output base directory for abixml files.
|
|
|
|
///
|
|
|
|
/// @param a_in_elf_base the input base directory for object files.
|
|
|
|
///
|
|
|
|
/// @param a_in_abi_base the input base directory for abixml files.
|
|
|
|
///
|
|
|
|
/// @return abigail::tests::read_common::test_task instance.
|
|
|
|
static test_task*
|
|
|
|
new_task(const InOutSpec* s, string& a_out_abi_base,
|
|
|
|
string& a_in_elf_base, string& a_in_abi_base)
|
|
|
|
{
|
|
|
|
return new test_task_ctf(*s, a_out_abi_base,
|
|
|
|
a_in_elf_base, a_in_abi_base);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
options opts;
|
|
|
|
if (!parse_command_line(argc, argv, opts))
|
|
|
|
{
|
|
|
|
if (!opts.wrong_option.empty())
|
|
|
|
emit_prefix(argv[0], cerr)
|
|
|
|
<< "unrecognized option: " << opts.wrong_option << "\n";
|
|
|
|
display_usage(argv[0], cerr);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// compute number of tests to be executed.
|
|
|
|
const size_t num_tests = sizeof(in_out_specs) / sizeof(InOutSpec) - 1;
|
|
|
|
|
|
|
|
return run_tests(num_tests, in_out_specs, opts, new_task);
|
|
|
|
}
|