libabigail/tests/test-read-dwarf.cc
Dodji Seketeli d4ca1088e4 Bug 30260 - Support pointer-to-member type
This adds support for C++ pointer-to-member types.

Here is a screenshot of what this patch enables libabigail to do:

    $ cat -n test-ptr-to-mbr-v0.cc
	 1	struct X
	 2	{
	 3	  void f(int);
	 4	  int a;
	 5	};
	 6
	 7	int X::* pmi = &X::a;
	 8	void (X::* pmf)(int) = &X::f;
	 9

    $ diff -u test-ptr-to-mbr-v0.cc test-ptr-to-mbr-v1.cc
    --- test-ptr-to-mbr-v0.cc	2023-11-22 15:22:04.258260701 +0100
    +++ test-ptr-to-mbr-v1.cc	2023-11-22 15:23:02.482621214 +0100
    @@ -1,9 +1,8 @@
     struct X
     {
    -  void f(int);
    -  int a;
    +  void f(int, char);
    +  char a;
     };

    -int X::* pmi = &X::a;
    -void (X::* pmf)(int) = &X::f;
    -
    +auto pmi = &X::a;
    +auto pmf = &X::f;

    $ abidiff test-ptr-to-mbr-v0.o test-ptr-to-mbr-v1.o
    Functions changes summary: 0 Removed, 0 Changed, 0 Added function
    Variables changes summary: 0 Removed, 2 Changed, 0 Added variables

    2 Changed variables:

      [C] 'void (X::* pmf)(int)' was changed to 'void (X::* pmf)(int, char)' at test-ptr-to-mbr-v1.cc:8:1:
	type of variable changed:
	  pointer-to-member type changed from: 'void (X::*)(int) to: 'void (X::*)(int, char)'
	  in containing type 'struct X' of pointed-to-member type 'void (X::*)(int)' at test-ptr-to-mbr-v1.cc:1:1:
	    type size changed from 32 to 8 (in bits)
	    1 data member change:
	      type of 'int a' changed:
		type name changed from 'int' to 'char'
		type size changed from 32 to 8 (in bits)

      [C] 'int X::* pmi' was changed to 'char X::* pmi' at test-ptr-to-mbr-v1.cc:7:1:
	type of variable changed:
	  pointer-to-member type changed from: 'int X::* to: 'char X::*'
	  in data member type 'int' of pointed-to-member type 'int X::*':
	    type name changed from 'int' to 'char'
	    type size changed from 32 to 8 (in bits)
	  containing type of pointer-to-member 'struct X' changed at test-ptr-to-mbr-v0.cc:1:1, as reported earlier

    $

	* include/abg-comparison.h (class ptr_to_mbr_diff): Declare new
	class.
	(ptr_to_mbr_diff_sptr): Declare new typedef.
	(compute_diff): Declare new overload for ptr_to_mbr_diff.
	(ptr_to_mbr_type_sptr): Declare new typedef.
	* src/abg-comparison-priv.h (struct ptr_to_mbr_diff::priv): Define
	* src/abg-comparison.cc (compute_diff_for_types): Support new
	ptr_to_mbr_type type.
	(ptr_to_mbr_diff::{ptr_to_mbr_diff, first_ptr_to_mbr_type,
	second_ptr_to_mbr_type, member_type_diff, containing_type_diff,
	has_changes, has_local_changes, get_pretty_representation, report,
	chain_into_hierarchy, ~ptr_to_mbr_diff}): Define member functions
	of class ptr_to_mbr_diff.
	(compute_diff): Define overload for ptr_to_mbr_type_sptr.
	* include/abg-fwd.h (ptr_to_mbr_type_sptr): Declare new typedef.
	(is_ptr_to_mbr_type, is_pointer_to_ptr_to_mbr_type)
	(is_typedef_of_maybe_qualified_class_or_union_type): Declare new
	functions.
	* include/abg-ir.h (type_maps::ptr_to_mbr_types): Declare new
	accessor.
	(POINTER_TO_MEMBER_TYPE): Add new enumerator to enum
	type_or_decl_base::type_or_decl_kind.
	(class ptr_to_mbr_type): Declare new class.
	(equals): Declare new overload for ptr_to_mbr_type.
	(ir_node_visitor::visit_{begin,end}): Declare new member
	functions.
	* src/abg-ir.cc (ptr_to_mbr_declaration_name)
	(ptr_to_mbr_declaration_name, add_outer_ptr_to_mbr_type_expr)
	(add_outer_pointer_to_ptr_to_mbr_type_expr): Define new static
	functions.
	(type_maps::priv::ptr_to_mbr_types_): Define new
	data member.
	(type_maps::ptr_to_mbr_types): Define new accessor.
	(is_ptr_to_mbr_type, is_pointer_to_ptr_to_mbr_type)
	(is_typedef_of_maybe_qualified_class_or_union_type): Define new
	functions.
	(maybe_update_types_lookup_map, equals): Define new overloads for
	ptr_to_mbr_type_sptr.
	(is_npaf_type): Use is_ptr_to_mbr_type.
	(maybe_update_types_lookup_map): In the overload for
	decl_base_sptr, call the new overload for ptr_to_mbr_type_sptr
	above.
	(struct ptr_to_mbr_type::priv): Define new struct.
	(ptr_to_mbr_type::{ptr_to_mbr_type, get_member_type,
	get_containing_type, operator==, get_qualified_name, traverse,
	~ptr_to_mbr_type}): Define member functions of ptr_to_mbr_type.
	(types_have_similar_structure): Support the new ptr_to_mbr_type
	type.
	(ir_node_visitor::visit_{begin,end}): Add new member functions.
	(var_decl::get_pretty_representation): Support pretty-printing
	pointer-to-member types.
	(pointer_declaration_name, array_declaration_name): Likewise.
	* include/abg-reporter.h ({reporter_base, default_reporter,
	leaf_reporter}::report): Add an overload for ptr_to_mbr_diff.
	(default_reporter::report_local_ptr_to_mbr_type_changes): Declare
	a member function.
	private data class of ptr_to_mbr_diff.
	* src/abg-default-reporter.cc
	(default_reporter::report_local_ptr_to_mbr_type_changes): Define
	member functions.
	(default_reporter::report): Define an overload for
	ptr_to_mbr_diff.
	* src/abg-leaf-reporter.cc (leaf_reporter::report): Likewise.
	* src/abg-dwarf-reader.cc (build_ptr_to_mbr_type): Define new
	function.
	(build_ir_node_from_die): Use the new build_ptr_to_mbr_type
	function.
	* src/abg-reader.cc (build_ptr_to_mbr_type): Define new function.
	(build_type): Use the new build_ptr_to_mbr_type above.
	* src/abg-writer.cc (write_ptr_to_mbr_type): Define new function.
	(write_type, write_decl, write_member_type): Use the new
	write_ptr_to_mbr_type above.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr1-output-1.txt:
	Add new test material.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr1-v0.cc:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr1-v0.o:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr1-v1.cc:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr1-v1.o:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr2-output-1.txt:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr2-v0.cc:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr2-v0.o:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr2-v1.cc:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr2-v1.o:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr3-output-1.txt:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr3-v0.cc:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr3-v0.o:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr3-v1.cc:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr3-v1.o:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr4-output-1.txt:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr4-v0.cc:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr4-v0.o:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr4-v1.cc:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr4-v1.o:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr5-output-1.txt:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr5-v0.cc:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr5-v0.o:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr5-v1.cc:
	Likewise.
	* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr5-v1.o:
	Likewise.
	* tests/data/test-read-dwarf/test-pointer-to-member-1.cc:
	Likewise.
	* tests/data/test-read-dwarf/test-pointer-to-member-1.o: Likewise.
	* tests/data/test-read-dwarf/test-pointer-to-member-1.o.abi:
	Likewise.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-abidiff-exit.cc (in_out_specs): Add the test material
	above to this test harness.
	* tests/test-annotate.cc (in_out_specs): Likewise.
	* tests/test-read-dwarf.cc: Likewise.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Adjust.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-12-01 15:43:53 +01:00

712 lines
17 KiB
C++

// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// -*- Mode: C++ -*-
//
// Copyright (C) 2013-2023 Red Hat, Inc.
//
// Author: Dodji Seketeli
/// @file read ELF binaries containing DWARF, 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 "test-read-common.h"
#include "abg-dwarf-reader.h"
using std::vector;
using std::string;
using std::cerr;
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::tests::get_build_dir;
using abigail::xml_writer::SEQUENCE_TYPE_ID_STYLE;
using abigail::xml_writer::HASH_TYPE_ID_STYLE;
using abigail::xml_writer::type_id_style_kind;
using abigail::tools_utils::emit_prefix;
using namespace abigail;
static InOutSpec in_out_specs[] =
{
{
"data/test-read-dwarf/test0",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test0.abi",
"output/test-read-dwarf/test0.abi",
NULL,
},
{
"data/test-read-dwarf/test0",
"",
"",
HASH_TYPE_ID_STYLE,
"data/test-read-dwarf/test0.hash.abi",
"output/test-read-dwarf/test0.hash.abi",
NULL,
},
{
"data/test-read-dwarf/test1",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test1.abi",
"output/test-read-dwarf/test1.abi",
NULL,
},
{
"data/test-read-dwarf/test1",
"",
"",
HASH_TYPE_ID_STYLE,
"data/test-read-dwarf/test1.hash.abi",
"output/test-read-dwarf/test1.hash.abi",
NULL,
},
{
"data/test-read-dwarf/test2.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test2.so.abi",
"output/test-read-dwarf/test2.so.abi",
NULL,
},
{
"data/test-read-dwarf/test2.so",
"",
"",
HASH_TYPE_ID_STYLE,
"data/test-read-dwarf/test2.so.hash.abi",
"output/test-read-dwarf/test2.so.hash.abi",
NULL,
},
{
"data/test-read-common/test3.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test3.so.abi",
"output/test-read-dwarf/test3.so.abi",
NULL,
},
{
"data/test-read-common/test3.so",
"",
"",
HASH_TYPE_ID_STYLE,
"data/test-read-dwarf/test3.so.hash.abi",
"output/test-read-dwarf/test3.so.hash.abi",
NULL,
},
// suppress all except the main symbol of a group of aliases
{
"data/test-read-common/test3.so",
"data/test-read-common/test3-alias-1.suppr",
"",
HASH_TYPE_ID_STYLE,
"data/test-read-dwarf/test3-alias-1.so.hash.abi",
"output/test-read-dwarf/test3-alias-1.so.hash.abi",
NULL,
},
// suppress the main symbol of a group of aliases
{
"data/test-read-common/test3.so",
"data/test-read-common/test3-alias-2.suppr",
"",
HASH_TYPE_ID_STYLE,
"data/test-read-dwarf/test3-alias-2.so.hash.abi",
"output/test-read-dwarf/test3-alias-2.so.hash.abi",
NULL,
},
// suppress all except one non main symbol of a group of aliases
{
"data/test-read-common/test3.so",
"data/test-read-common/test3-alias-3.suppr",
"",
HASH_TYPE_ID_STYLE,
"data/test-read-dwarf/test3-alias-3.so.hash.abi",
"output/test-read-dwarf/test3-alias-3.so.hash.abi",
NULL,
},
// suppress all symbols of a group of aliases
{
"data/test-read-common/test3.so",
"data/test-read-common/test3-alias-4.suppr",
"",
HASH_TYPE_ID_STYLE,
"data/test-read-dwarf/test3-alias-4.so.hash.abi",
"output/test-read-dwarf/test3-alias-4.so.hash.abi",
NULL,
},
// suppress the main symbols with alias (function+variable) in .o file
{
"data/test-read-dwarf/test-suppressed-alias.o",
"data/test-read-dwarf/test-suppressed-alias.suppr",
"",
HASH_TYPE_ID_STYLE,
"data/test-read-dwarf/test-suppressed-alias.o.abi",
"output/test-read-dwarf/test-suppressed-alias.o.abi",
NULL,
},
{
"data/test-read-common/test4.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test4.so.abi",
"output/test-read-dwarf/test4.so.abi",
NULL,
},
{
"data/test-read-common/test4.so",
"",
"",
HASH_TYPE_ID_STYLE,
"data/test-read-dwarf/test4.so.hash.abi",
"output/test-read-dwarf/test4.so.hash.abi",
NULL,
},
{
"data/test-read-dwarf/test5.o",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test5.o.abi",
"output/test-read-dwarf/test5.o.abi",
NULL,
},
{
"data/test-read-dwarf/test5.o",
"",
"",
HASH_TYPE_ID_STYLE,
"data/test-read-dwarf/test5.o.hash.abi",
"output/test-read-dwarf/test5.o.hash.abi",
NULL,
},
{
"data/test-read-dwarf/test6.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test6.so.abi",
"output/test-read-dwarf/test6.so.abi",
NULL,
},
{
"data/test-read-dwarf/test6.so",
"",
"",
HASH_TYPE_ID_STYLE,
"data/test-read-dwarf/test6.so.hash.abi",
"output/test-read-dwarf/test6.so.hash.abi",
NULL,
},
{
"data/test-read-dwarf/test7.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test7.so.abi",
"output/test-read-dwarf/test7.so.abi",
NULL,
},
{
"data/test-read-dwarf/test7.so",
"",
"",
HASH_TYPE_ID_STYLE,
"data/test-read-dwarf/test7.so.hash.abi",
"output/test-read-dwarf/test7.so.hash.abi",
NULL,
},
{
"data/test-read-dwarf/test8-qualified-this-pointer.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test8-qualified-this-pointer.so.abi",
"output/test-read-dwarf/test8-qualified-this-pointer.so.abi",
NULL,
},
{
"data/test-read-dwarf/test8-qualified-this-pointer.so",
"",
"",
HASH_TYPE_ID_STYLE,
"data/test-read-dwarf/test8-qualified-this-pointer.so.hash.abi",
"output/test-read-dwarf/test8-qualified-this-pointer.so.hash.abi",
NULL,
},
{
"data/test-read-dwarf/test9-pr18818-clang.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test9-pr18818-clang.so.abi",
"output/test-read-dwarf/test9-pr18818-clang.so.abi",
NULL,
},
{
"data/test-read-dwarf/test10-pr18818-gcc.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test10-pr18818-gcc.so.abi",
"output/test-read-dwarf/test10-pr18818-gcc.so.abi",
NULL,
},
{
"data/test-read-dwarf/test11-pr18828.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test11-pr18828.so.abi",
"output/test-read-dwarf/test11-pr18828.so.abi",
NULL,
},
{
"data/test-read-dwarf/test12-pr18844.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test12-pr18844.so.abi",
"output/test-read-dwarf/test12-pr18844.so.abi",
NULL,
},
{
"data/test-read-dwarf/test13-pr18894.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test13-pr18894.so.abi",
"output/test-read-dwarf/test13-pr18894.so.abi",
NULL,
},
{
"data/test-read-dwarf/test14-pr18893.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test14-pr18893.so.abi",
"output/test-read-dwarf/test14-pr18893.so.abi",
NULL,
},
{
"data/test-read-dwarf/test15-pr18892.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test15-pr18892.so.abi",
"output/test-read-dwarf/test15-pr18892.so.abi",
NULL,
},
{
"data/test-read-dwarf/test16-pr18904.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test16-pr18904.so.abi",
"output/test-read-dwarf/test16-pr18904.so.abi",
NULL,
},
{
"data/test-read-dwarf/test17-pr19027.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test17-pr19027.so.abi",
"output/test-read-dwarf/test17-pr19027.so.abi",
NULL,
},
{
"data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi",
"output/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi",
NULL,
},
{
"data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi",
"output/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi",
NULL,
},
{
"data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi",
"output/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi",
NULL,
},
{
"data/test-read-dwarf/test21-pr19092.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test21-pr19092.so.abi",
"output/test-read-dwarf/test21-pr19092.so.abi",
NULL,
},
{
"data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi",
"output/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi",
NULL,
},
{
"data/test-read-dwarf/libtest23.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/libtest23.so.abi",
"output/test-read-dwarf/libtest23.so.abi",
NULL,
},
{
"data/test-read-dwarf/libtest24-drop-fns.so",
"data/test-read-dwarf/test24-drop-fns-0.suppr",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/libtest24-drop-fns.so.abi",
"output/test-read-dwarf/libtest24-drop-fns.so.abi",
NULL,
},
{
"data/test-read-dwarf/libtest24-drop-fns.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/libtest24-drop-fns-2.so.abi",
"output/test-read-dwarf/libtest24-drop-fns-2.so.abi",
NULL,
},
{
"data/test-read-dwarf/PR22015-libboost_iostreams.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/PR22015-libboost_iostreams.so.abi",
"output/test-read-dwarf/PR22015-libboost_iostreams.so.abi",
NULL,
},
{
"data/test-read-dwarf/PR22122-libftdc.so",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/PR22122-libftdc.so.abi",
"output/test-read-dwarf/PR22122-libftdc.so.abi",
NULL,
},
{
"data/test-read-dwarf/PR24378-fn-is-not-scope.o",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/PR24378-fn-is-not-scope.abi",
"output/test-read-dwarf/PR24378-fn-is-not-scope.abi",
NULL,
},
#if defined(HAVE_R_AARCH64_ABS64_MACRO) && defined(HAVE_R_AARCH64_PREL32_MACRO)
{
"data/test-read-dwarf/PR25007-sdhci.ko",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/PR25007-sdhci.ko.abi",
"output/test-read-dwarf/PR25007-sdhci.ko.abi",
NULL,
},
#endif
#if defined HAVE_DW_FORM_strx
{
"data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi",
"output/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi",
NULL,
},
#endif
{
"data/test-read-dwarf/test25-bogus-binary.elf",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
NULL,
NULL,
NULL,
},
{
"data/test-read-dwarf/test26-bogus-binary.elf",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
NULL,
NULL,
NULL,
},
{
"data/test-read-dwarf/test27-bogus-binary.elf",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
NULL,
NULL,
NULL,
},
{
"data/test-read-common/PR26261/PR26261-exe",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/PR26261/PR26261-exe.abi",
"output/test-read-dwarf/PR26261/PR26261-exe.abi",
NULL,
},
{
"data/test-read-common/test-PR26568-1.o",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test-PR26568-1.o.abi",
"output/test-read-dwarf/test-PR26568-1.o.abi",
NULL,
},
{
"data/test-read-common/test-PR26568-2.o",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test-PR26568-2.o.abi",
"output/test-read-dwarf/test-PR26568-2.o.abi",
NULL,
},
{
"data/test-read-dwarf/test-libandroid.so",
"",
"",
HASH_TYPE_ID_STYLE,
"data/test-read-dwarf/test-libandroid.so.abi",
"output/test-read-dwarf/test-libandroid.so.abi",
NULL,
},
{
"data/test-read-common/PR27700/test-PR27700.o",
"",
"data/test-read-common/PR27700/pub-incdir",
HASH_TYPE_ID_STYLE,
"data/test-read-dwarf/PR27700/test-PR27700.abi",
"output/test-read-dwarf/PR27700/test-PR27700.abi",
NULL,
},
{
"data/test-read-dwarf/test-libaaudio.so",
"",
"",
HASH_TYPE_ID_STYLE,
"data/test-read-dwarf/test-libaaudio.so.abi",
"output/test-read-dwarf/test-libaaudio.so.abi",
NULL,
},
{
"data/test-read-dwarf/PR28584/PR28584-smv.clang.o",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/PR28584/PR28584-smv.clang.o.abi",
"output/test-read-dwarf/PR28584/PR28584-smv.clang.o.abi",
NULL,
},
{
"data/test-read-dwarf/PR29443-missing-xx.o",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/PR29443-missing-xx.o.abi",
"output/test-read-dwarf/PR29443-missing-xx.o.abi",
NULL,
},
{
"data/test-read-dwarf/PR29692-kdelibs3-libkjava.so.1.0.0",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/PR29692-kdelibs3-libkjava.so.1.0.0.abi",
"output/test-read-dwarf/PR29692-kdelibs3-libkjava.so.1.0.0.abi",
NULL,
},
{
"data/test-read-dwarf/test-pointer-to-member-1.o",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test-pointer-to-member-1.o.abi",
"output/test-read-dwarf/test-pointer-to-member-1.o.abi",
NULL,
},
// DWARF fallback feature.
{
"data/test-read-dwarf/test-fallback.o",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/test-fallback.abi",
"output/test-read-dwarf/test-fallback.abi",
#ifdef WITH_CTF
"--ctf",
#else
NULL,
#endif
},
// This should be the last entry.
{NULL, NULL, NULL, SEQUENCE_TYPE_ID_STYLE, NULL, NULL, NULL}
};
using abigail::suppr::suppression_sptr;
using abigail::suppr::suppressions_type;
using abigail::suppr::read_suppressions;
/// Task specialization to perform DWARF tests.
struct test_task_dwarf : public test_task
{
test_task_dwarf(const InOutSpec &s,
string& a_out_abi_base,
string& a_in_elf_base,
string& a_in_abi_base);
virtual void
perform();
virtual
~test_task_dwarf()
{}
}; // end struct test_task_dwarf
/// Constructor.
///
/// Task to be executed for each DWARF 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_dwarf::test_task_dwarf(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 DWARF 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_dwarf::perform()
{
set_in_elf_path();
set_in_suppr_spec_path();
set_in_public_headers_path();
if (!set_out_abi_path()
|| in_elf_path.empty())
return;
string abidw = string(get_build_dir()) + "/tools/abidw";
string drop_private_types;
if (!in_public_headers_path.empty())
drop_private_types += "--headers-dir " + in_public_headers_path +
" --drop-private-types";
string type_id_style = "sequence";
if (spec.type_id_style == HASH_TYPE_ID_STYLE)
type_id_style = "hash";
string cmd = abidw + " --no-architecture "
+ " --type-id-style " + type_id_style
+ " --no-corpus-path "
+ drop_private_types + " " + in_elf_path
+" > " + out_abi_path;
if (system(cmd.c_str()))
{
error_message = string("abidw failed:\n")
+ "command was: '" + cmd + "'\n";
return;
}
if (!(is_ok = run_abidw()))
return;
if (!(is_ok = run_diff()))
return;
}
/// Create a new DWARF 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_dwarf(*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);
}