libabigail/tools/kmidiff.cc

530 lines
14 KiB
C++
Raw Normal View History

Re-license the project to Apache v2 With LLVM Exception Thanks to the previous work done, changing the license is just a matter of changing the SPDX identifer from "LGPL-3.0-or-later" to "Apache-2.0 WITH LLVM-exception". Note that for the abigail.m4, tests/test-dot.cc and tests/test-svg.cc the change was from "GPL-3.0-or-later WITH GCC-exception-3.1" to "Apache-2.0 WITH LLVM-exception". include/abg-cxx-compat.h was changed from "LGPL-2.0-or-later" to "Apache-2.0 WITH LLVM-exception". Source code of programs (as opposed to source code of the library) where generally licensed under GPL-3.0-or-later; they are also now licensed "Apache-2.0 WITH LLVM-exception". This is what this patch does. * abigail.m4: Change the SPDX identifier from "GPL-3.0-or-later WITH GCC-exception-3.1" to "Apache-2.0 WITH LLVM-exception" * include/abg-cxx-compat.h: Change the SPDX identifier from "LGPL-2.0-or-later" to "Apache-2.0 WITH LLVM-exception". * .clang-format: Change the SPDX identifier from "LGPL-3.0-or-later" to "Apache-2.0 WITH LLVM-exception". * Makefile.am: Likewise. * bash-completion/Makefile.am: Likewise. * bash-completion/abicompat: Likewise. * bash-completion/abidiff: Likewise. * bash-completion/abidw: Likewise. * bash-completion/abilint: Likewise. * bash-completion/abinilint: Likewise. * bash-completion/abipkgdiff: Likewise. * bash-completion/abisym: Likewise. * bash-completion/fedabipkgdiff: Likewise. * configure.ac: Likewise. * default.abignore: Likewise. * doc/Makefile.am: Likewise. * doc/api/libabigail.doxy: Likewise. * doc/manuals/Makefile.am: Likewise. * doc/website/libabigail-website.doxy: Likewise. * include/Makefile.am: Likewise. * include/abg-comp-filter.h: Likewise. * include/abg-comparison.h: Likewise. * include/abg-config.h: Likewise. * include/abg-corpus.h: Likewise. * include/abg-diff-utils.h: Likewise. * include/abg-dwarf-reader.h: Likewise. * include/abg-fwd.h: Likewise. * include/abg-hash.h: Likewise. * include/abg-ini.h: Likewise. * include/abg-interned-str.h: Likewise. * include/abg-ir.h: Likewise. * include/abg-libxml-utils.h: Likewise. * include/abg-libzip-utils.h: Likewise. * include/abg-reader.h: Likewise. * include/abg-regex.h: Likewise. * include/abg-reporter.h: Likewise. * include/abg-sptr-utils.h: Likewise. * include/abg-suppression.h: Likewise. * include/abg-tools-utils.h: Likewise. * include/abg-traverse.h: Likewise. * include/abg-version.h.in: Likewise. * include/abg-viz-common.h: Likewise. * include/abg-viz-dot.h: Likewise. * include/abg-viz-svg.h: Likewise. * include/abg-workers.h: Likewise. * include/abg-writer.h: Likewise. * scripts/dot_to_png.sh: Likewise. * scripts/dot_to_svg.sh: Likewise. * scripts/make-verbose.sh: Likewise. * scripts/svg_to_plain_svg.sh: Likewise. * scripts/svg_to_png_and_pdf.sh: Likewise. * src/Makefile.am: Likewise. * src/abg-comp-filter.cc: Likewise. * src/abg-comparison-priv.h: Likewise. * src/abg-comparison.cc: Likewise. * src/abg-config.cc: Likewise. * src/abg-corpus-priv.h: Likewise. * src/abg-corpus.cc: Likewise. * src/abg-default-reporter.cc: Likewise. * src/abg-diff-utils.cc: Likewise. * src/abg-dwarf-reader.cc: Likewise. * src/abg-elf-helpers.cc: Likewise. * src/abg-elf-helpers.h: Likewise. * src/abg-hash.cc: Likewise. * src/abg-ini.cc: Likewise. * src/abg-internal.h: Likewise. * src/abg-ir-priv.h: Likewise. * src/abg-ir.cc: Likewise. * src/abg-leaf-reporter.cc: Likewise. * src/abg-libxml-utils.cc: Likewise. * src/abg-libzip-utils.cc: Likewise. * src/abg-reader.cc: Likewise. * src/abg-regex.cc: Likewise. * src/abg-reporter-priv.cc: Likewise. * src/abg-reporter-priv.h: Likewise. * src/abg-suppression-priv.h: Likewise. * src/abg-suppression.cc: Likewise. * src/abg-tools-utils.cc: Likewise. * src/abg-traverse.cc: Likewise. * src/abg-viz-common.cc: Likewise. * src/abg-viz-dot.cc: Likewise. * src/abg-viz-svg.cc: Likewise. * src/abg-workers.cc: Likewise. * src/abg-writer.cc: Likewise. * tests/Makefile.am: Likewise. * tests/data/Makefile.am: Likewise. * tests/lib/catch.cc: Likewise. * tests/mockfedabipkgdiff.in: Likewise. * tests/print-diff-tree.cc: Likewise. * tests/runtestcanonicalizetypes.sh.in: Likewise. * tests/runtestdefaultsupprs.py.in: Likewise. * tests/runtestdefaultsupprspy3.sh.in: Likewise. * tests/runtestfedabipkgdiff.py.in: Likewise. * tests/runtestfedabipkgdiffpy3.sh.in: Likewise. * tests/test-abicompat.cc: Likewise. * tests/test-abidiff-exit.cc: Likewise. * tests/test-abidiff.cc: Likewise. * tests/test-alt-dwarf-file.cc: Likewise. * tests/test-annotate.cc: Likewise. * tests/test-core-diff.cc: Likewise. * tests/test-cxx-compat.cc: Likewise. * tests/test-diff-dwarf-abixml.cc: Likewise. * tests/test-diff-dwarf.cc: Likewise. * tests/test-diff-filter.cc: Likewise. * tests/test-diff-pkg.cc: Likewise. * tests/test-diff-suppr.cc: Likewise. * tests/test-diff2.cc: Likewise. * tests/test-dot.cc: Change the SPDX identifier from "GPL-3.0-or-later WITH GCC-exception-3.1" to "Apache-2.0 WITH LLVM-exception" * tests/test-elf-helpers.cc: Change the SPDX identifier from "LGPL-3.0-or-later" to "Apache-2.0 WITH LLVM-exception" * tests/test-ini.cc: Likewise. * tests/test-ir-walker.cc: Likewise. * tests/test-kmi-whitelist.cc: Likewise. * tests/test-lookup-syms.cc: Likewise. * tests/test-read-dwarf.cc: Likewise. * tests/test-read-write.cc: Likewise. * tests/test-svg.cc: Change the SPDX identifier from "GPL-3.0-or-later WITH GCC-exception-3.1" to "Apache-2.0 WITH LLVM-exception". * tests/test-symtab.cc: Change the SPDX identifier from "LGPL-3.0-or-later" to "Apache-2.0 WITH LLVM-exception" * tests/test-tools-utils.cc: Likewise. * tests/test-types-stability.cc: Likewise. * tests/test-utils.cc: Likewise. * tests/test-utils.h: Likewise. * tests/test-write-read-archive.cc: Likewise. * tests/update-test-output.py: Likewise. * tools/Makefile.am: Likewise. * tools/abiar.cc: Likewise. * tools/abicompat.cc: Likewise. * tools/abidiff.cc: Likewise. * tools/abidw.cc: Likewise. * tools/abilint.cc: Likewise. * tools/abipkgdiff.cc: Likewise. * tools/abisym.cc: Likewise. * tools/binilint.cc: Likewise. * tools/fedabipkgdiff: Likewise. * tools/kmidiff.cc: Likewise. * update-copyright.sh: Likewise. Signed-off-by: Benjamin De Kosnik <bkoz@gnu.org> Signed-off-by: Ben Woodard <woodard@redhat.com> Signed-off-by: Chenxiong Qi <cqi@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Jan Engelhardt <jengelh@inai.de> Signed-off-by: Jessica Yu <jeyu@kernel.org> Signed-off-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Mark Wielaard <mark@klomp.org> Signed-off-by: Matthias Klose <doko@ubuntu.com> Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com> Signed-off-by: Roland McGrath <roland@hack.frob.com> Signed-off-by: Sinny Kumari <ksinny@gmail.com> Signed-off-by: Slava Barinov <v.barinov@samsung.com>
2020-05-29 14:26:04 +00:00
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
// -*- Mode: C++ -*-
//
Update copyright year for 2023 Update the copyright years for 2023, using the script update-copyright.sh. * update-copyright.sh: Update the copyright years in this script. * include/abg-comp-filter.h: Update copyright year for 2023. * include/abg-comparison.h: Likewise. * include/abg-config.h: Likewise. * include/abg-corpus.h: Likewise. * include/abg-ctf-reader.h: Likewise. * include/abg-cxx-compat.h: Likewise. * include/abg-diff-utils.h: Likewise. * include/abg-dwarf-reader.h: Likewise. * include/abg-elf-based-reader.h: Likewise. * include/abg-elf-reader.h: Likewise. * include/abg-fe-iface.h: Likewise. * include/abg-fwd.h: Likewise. * include/abg-hash.h: Likewise. * include/abg-ini.h: Likewise. * include/abg-interned-str.h: Likewise. * include/abg-ir.h: Likewise. * include/abg-libxml-utils.h: Likewise. * include/abg-reader.h: Likewise. * include/abg-regex.h: Likewise. * include/abg-reporter.h: Likewise. * include/abg-sptr-utils.h: Likewise. * include/abg-suppression.h: Likewise. * include/abg-tools-utils.h: Likewise. * include/abg-traverse.h: Likewise. * include/abg-viz-common.h: Likewise. * include/abg-viz-dot.h: Likewise. * include/abg-viz-svg.h: Likewise. * include/abg-workers.h: Likewise. * include/abg-writer.h: Likewise. * src/abg-comp-filter.cc: Likewise. * src/abg-comparison-priv.h: Likewise. * src/abg-comparison.cc: Likewise. * src/abg-config.cc: Likewise. * src/abg-corpus-priv.h: Likewise. * src/abg-corpus.cc: Likewise. * src/abg-ctf-reader.cc: Likewise. * src/abg-default-reporter.cc: Likewise. * src/abg-diff-utils.cc: Likewise. * src/abg-dwarf-reader.cc: Likewise. * src/abg-elf-based-reader.cc: Likewise. * src/abg-elf-helpers.cc: Likewise. * src/abg-elf-helpers.h: Likewise. * src/abg-elf-reader.cc: Likewise. * src/abg-fe-iface.cc: Likewise. * src/abg-hash.cc: Likewise. * src/abg-ini.cc: Likewise. * src/abg-internal.h: Likewise. * src/abg-ir-priv.h: Likewise. * src/abg-ir.cc: Likewise. * src/abg-leaf-reporter.cc: Likewise. * src/abg-libxml-utils.cc: Likewise. * src/abg-reader.cc: Likewise. * src/abg-regex.cc: Likewise. * src/abg-reporter-priv.cc: Likewise. * src/abg-reporter-priv.h: Likewise. * src/abg-suppression-priv.h: Likewise. * src/abg-suppression.cc: Likewise. * src/abg-symtab-reader.cc: Likewise. * src/abg-symtab-reader.h: Likewise. * src/abg-tools-utils.cc: Likewise. * src/abg-traverse.cc: Likewise. * src/abg-viz-common.cc: Likewise. * src/abg-viz-dot.cc: Likewise. * src/abg-viz-svg.cc: Likewise. * src/abg-workers.cc: Likewise. * src/abg-writer.cc: Likewise. * tests/print-diff-tree.cc: Likewise. * tests/test-abicompat.cc: Likewise. * tests/test-abidiff-exit.cc: Likewise. * tests/test-abidiff.cc: Likewise. * tests/test-alt-dwarf-file.cc: Likewise. * tests/test-core-diff.cc: Likewise. * tests/test-cxx-compat.cc: Likewise. * tests/test-diff-dwarf-abixml.cc: Likewise. * tests/test-diff-dwarf.cc: Likewise. * tests/test-diff-filter.cc: Likewise. * tests/test-diff-pkg.cc: Likewise. * tests/test-diff-suppr.cc: Likewise. * tests/test-diff2.cc: Likewise. * tests/test-dot.cc: Likewise. * tests/test-elf-helpers.cc: Likewise. * tests/test-ini.cc: Likewise. * tests/test-ir-walker.cc: Likewise. * tests/test-kmi-whitelist.cc: Likewise. * tests/test-lookup-syms.cc: Likewise. * tests/test-read-ctf.cc: Likewise. * tests/test-read-dwarf.cc: Likewise. * tests/test-read-write.cc: Likewise. * tests/test-svg.cc: Likewise. * tests/test-symtab-reader.cc: Likewise. * tests/test-symtab.cc: Likewise. * tests/test-tools-utils.cc: Likewise. * tests/test-types-stability.cc: Likewise. * tests/test-utils.cc: Likewise. * tests/test-utils.h: Likewise. * tools/abicompat.cc: Likewise. * tools/abidiff.cc: Likewise. * tools/abidw.cc: Likewise. * tools/abilint.cc: Likewise. * tools/abipkgdiff.cc: Likewise. * tools/abisym.cc: Likewise. * tools/binilint.cc: Likewise. * tools/kmidiff.cc: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-01-01 17:14:26 +00:00
// Copyright (C) 2017-2023 Red Hat, Inc.
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
//
// Author: Dodji Seketeli
/// @file
///
/// The source code of the Kernel Module Interface Diff tool.
#include "config.h"
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
#include <sys/types.h>
#include <dirent.h>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include "abg-config.h"
#include "abg-tools-utils.h"
#include "abg-corpus.h"
#include "abg-dwarf-reader.h"
Initial support of de-serializing the KMI of a Linux Kernel Tree With this patch, kmidiff knows how to compare a serialized corpus_group that represents a Kernel Module Interface (a .kmi file) against either another serialized .kmi file, or against a kernel tree. The patch extends the abixml reader to make it parse an 'abi-corpus-group' element. To do that, the patch modifies read_corpus_from_input to make it be capable of parsing several 'abi-corpus' in a row. That modified function is then used by a new read_corpus_group_from_input, which is itself used by the new public entry points read_corpus_group_from_native_xml_file and read_corpus_group_from_native_xml. With that read_corpus_group_from_native_xml_file building block function, the kmidiff program is modified so that it can take either two directory trees, two .kmi files or one directory tree and one .kmi file. * include/abg-libxml-utils.h (advance_to_next_sibling_element): Declare new function. * src/abg-libxml-utils.cc (go_to_next_sibling_element_or_stay) (advance_to_next_sibling_element): Define new functions. * include/abg-reader.h (read_corpus_group_from_input) (read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Declare new functions. * src/abg-reader.cc (read_context::m_corpus_group): New data member. (read_context::{get_corpus_group, set_corpus_group}): Define new member functions. (read_translation_unit_from_input): Cleanup logic. (read_corpus_from_input): Don't assume that the document is starting with an 'abi-corpus' element. Support the mode where a caller called the xmlTextReaderExpand function (and so we are given an expanded xmlNodePtr) and the mode where we need to use the xmlTextReader API to walk through the 'abi-corpus' element. Also, if we are building a corpus group, do not clear what used to be 'per-corpus' data. That data must be shared by all the corpora of a given abi-corpus-group. (read_corpus_group_from_input, read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Define new functions. * include/abg-tools-utils.h (FILE_TYPE_XML_CORPUS_GROUP): New enumerator of the file_type enum. * src/abg-tools-utils.cc (operator<<): In the overload for file_type, add a case for the new FILE_TYPE_XML_CORPUS_GROUP. (guess_file_type): Dectect abi-corpus-group xml element. * tools/abidiff.cc (adjust_diff_context_for_kmidiff): Define new static function. (main): Adjust to handle the new FILE_TYPE_XML_CORPUS_GROUP. That is, compare two FILE_TYPE_XML_CORPUS_GROUP if they are present. * tools/abilint.cc (main): Likewise. * tools/kmidiff.cc (main): Detect that one of two .kmi files are passed. In that case, load the .kmi file(s), build a corpus_group of it and use it in the comparison. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-07 21:06:14 +00:00
#include "abg-reader.h"
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
#include "abg-comparison.h"
using std::string;
using std::vector;
using std::ostream;
using std::cout;
using std::cerr;
Allow restricting analyzed decls to exported symbols Profiling showed that the DWARF reader scans too much data. Basically, in build_translation_unit_and_add_to_ir, build_ir_node_from_die is called on every single DIE that is seen, for a given translation unit. There are interfaces (function and variable decls) that are not associated with exported ELF symbols and that are analyzed by build_ir_node_from_die nonetheless. For instance, interfaces that are visible outside of their translation units are analyzed and the types that are reachable from those interfaces are analyzed as well. Once that is done, an ABI corpus is built with the subset of interfaces that have exported ELF symbol (strictly those that are part of the ABI), but types that are not necessarily reachable from those ABI interfaces can also be put into the ABI corpus. Some tools make use of this "lose" behaviour of libabigail. For instance, abicompat precisely wants to analyze interfaces with undefined symbols. For an application, those interfaces represents the interfaces that the application expects to be provided by some shared library. When analyzing the exported interface of the Linux Kernel (or any other huge application) however, analyzing more types than necessary appears to incur a huge time penalty. So, this patch introduces an optional behaviour whereby build_translation_unit_and_add_to_ir is restricted to analyzing interfaces that have exported ELF symbols only. So only the types reachable from those interfaces are analyzed. This more than halves the time spent by "abidw --noout vmlinux". Strictly speaking, this new behaviour is triggered by a new option named --exported-interfaces-only, supported by the tools abidw, abidiff, abipkgdiff and kmidiff. When looking at the Linux Kernel however, this option is enabled by default. Note that an option --allow-non-exported-interfaces is also introduce to function under the previous model of operations. This option is enabled by default on all the tools when they are not looking at the Linux Kernel. With this enabled, analyzing the Linux Kernel is back to taking less than a minute on a reasonable machine. * doc/manuals/tools-use-libabigail.txt: New doc text. * doc/manuals/Makefile.am: Add the new tools-use-libabigail.rst tool to the source distribution. * doc/manuals/abidiff.rst: Include the new tools-use-libabigail.rst. Document the --exported-interfaces-only and --allow-non-exported-interfaces. * doc/manuals/abidw.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * include/abg-ir.h (environment::{user_set_analyze_exported_interfaces_only, analyze_exported_interfaces_only}): Declare new accessors. * src/abg-ir.cc (environment::{user_set_analyze_exported_interfaces_only, analyze_exported_interfaces_only}): Define new accessors. * src/abg-dwarf-reader.cc (die_is_variable_decl) (die_is_function_decl): Define new static functions. (read_context::is_decl_die_with_exported_symbol): Define new member function. (read_context::get_{function,variable}_address): Const-ify the Dwarf_Die* parameter. (build_translation_unit_and_add_to_ir): If the user asks to analyze exported interfaces only, the analyze only interfaces that have exported ELF symbols. (read_debug_info_into_corpus): If we are looking at the Linux Kernel, then only analyze exported interfaces unless the user asks otherwise. * src/abg-ir-priv.h (environment::priv::analyze_exported_interfaces_only_): Define new data member. * tools/abidiff.cc (options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options --exported-interfaces-only and --allow-non-exported-interfaces. (main): Pass the value of opts.exported_interfaces_only to the environment. * tools/abidw.cc (options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options (load_corpus_and_write_abixml) (load_kernel_corpus_group_and_write_abixml): Pass the value of opts.exported_interfaces_only onto the environment. * tools/abipkgdiff.cc (options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options (compare_task::perform, self_compare_task::perform): Pass the value of opts.exported_interfaces_only onto the environment. (compare_prepared_linux_kernel_packages): Likewise. * tools/kmidiff.cc(options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options (main): Pass the value of opts.exported_interfaces_only onto the environment. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-09-02 14:19:23 +00:00
using abg_compat::optional;
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
using namespace abigail::tools_utils;
using namespace abigail::ir;
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;
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
using abigail::comparison::diff_context_sptr;
using abigail::comparison::diff_context;
using abigail::comparison::translation_unit_diff_sptr;
using abigail::comparison::corpus_diff;
using abigail::comparison::corpus_diff_sptr;
using abigail::comparison::compute_diff;
Allow selective resolution of class declaration When a class is forward-declared, resolving it to a definition that appears later in the same translation unit or in another translation is an interesting problem. Until now, the declaration would be resolved to the definition of that class found in the binary. The problem is that there can be different such definitions, especially in C where there is no "One Definition Rule". In that case, the definition chosen is random. This patch resolves that randomness. For a given class declaration, if there is just one possible definition in the binary, then the declaration is resolved to that definition. If there is one definition for that declaration in the same translation unit, then the declaration is resolved to that definition. If there are more than one definitions in translation units that are not the one of the declaration, then the declaration is left unresolved. This is what I call "selective class declaration resolution". Note that an unresolved class declaration now compares different to a definition of a class of the same name. This is so that we can have an unresolved class be present in the resulting .abi file, alongside an (incompatible) definition of the same class. The change from a class declaration to its definition is filtered out by default, though. * include/abg-fwd.h (type_base_wptrs_type) (istring_type_base_wptrs_map_type): Define new typedefs. (lookup_class_types): Declare new functions. * include/abg-ir.h (environment::decl_only_class_equals_definition): Declare new accessor. (type_maps::{*_types}): Make these accessors return istring_type_base_wptrs_map_type& instead of istring_type_base_wptr_map_type&. * src/abg-dwarf-reader.cc (read_context::resolve_declaration_only_classes): Implement the new selective declaration resolution scheme. * src/abg-ir.cc (type_maps::priv::{*_types_}): Change the type of these data members from istring_type_base_wptr_map_type to istring_type_base_wptrs_map_type. (type_maps::{*_types}): Make these accessors definitions return istring_type_base_wptrs_map_type& instead of istring_type_base_wptr_map_type&. (translation_unit::bind_function_type_life_time): Adjust. (environment::priv::decl_only_class_equals_definition_): New data member. (environment::priv::priv): Initialize it. By default, a decl-only class is now considered different from its definition. (environment::decl_only_class_equals_definition): Define new accessor. (lookup_types_in_map, lookup_class_types): Define new functions. (lookup_type_in_map, lookup_union_type_per_location) (lookup_basic_type, lookup_basic_type_per_location) (lookup_class_type, lookup_class_type_per_location) (lookup_union_type, lookup_enum_type) (lookup_enum_type_per_location, lookup_typedef_type) (lookup_typedef_type_per_location, lookup_qualified_type) (lookup_pointer_type, lookup_reference_type, lookup_array_type) (lookup_function_type, maybe_update_types_lookup_map) (maybe_update_types_lookup_map<class_decl>) (maybe_update_types_lookup_map<function_type>): Adjust. (type_base::get_canonical_type_for): When doing type comparison here, we can now consider that an unresolved class declaration compares different to an incompatible class definition of the same name. So no need to look through decl-only classes in that case. (equals): In the overload for class_or_union, if environment::decl_only_class_equals_definition() is false, then an unresolved class declaration of name "N" compares different to a class definition named "N". * tests/data/test-annotate/test15-pr18892.so.abi: Adjust. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust * tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust. * tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust. * tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt: Adjust. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Adjust. * tests/data/test-diff-filter/test38/Makefile: New test material. * tests/data/test-diff-filter/test38/test38-a.c: Likewise. * tests/data/test-diff-filter/test38/test38-b.c: Likewise. * tests/data/test-diff-filter/test38/test38-c.c: Likewise. * tests/data/test-diff-filter/test38/test38-report-0.txt: Likewise. * tests/data/test-diff-filter/test38/test38-v0: Likewise. * tests/data/test-diff-filter/test38/test38-v1: Likewise. * tests/data/test-diff-filter/test38/test38.h: Likewise. * tests/data/test-diff-filter/test39/Makefile: Likewise. * tests/data/test-diff-filter/test39/test39-a-v0.c: Likewise. * tests/data/test-diff-filter/test39/test39-a-v1.c: Likewise. * tests/data/test-diff-filter/test39/test39-b-v0.c: Likewise. * tests/data/test-diff-filter/test39/test39-b-v1.c: Likewise. * tests/data/test-diff-filter/test39/test39-c-v0.c: Likewise. * tests/data/test-diff-filter/test39/test39-c-v1.c: Likewise. * tests/data/test-diff-filter/test39/test39-main.c: Likewise. * tests/data/test-diff-filter/test39/test39-report-0.txt: Likewise. * tests/data/test-diff-filter/test39/test39-v0: Likewise. * tests/data/test-diff-filter/test39/test39-v1: Likewise. * tests/data/test-diff-filter/test39/test39.h: Likewise. * tests/data/Makefile.am: Add the new test material above to the source distribution. * tests/test-diff-filter.cc (in_out_specs): Add the new test inputs above to the test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-05-17 08:19:30 +00:00
using abigail::comparison::get_default_harmless_categories_bitmap;
using abigail::comparison::get_default_harmful_categories_bitmap;
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
using abigail::suppr::suppression_sptr;
using abigail::suppr::suppressions_type;
using abigail::suppr::read_suppressions;
Initial support of de-serializing the KMI of a Linux Kernel Tree With this patch, kmidiff knows how to compare a serialized corpus_group that represents a Kernel Module Interface (a .kmi file) against either another serialized .kmi file, or against a kernel tree. The patch extends the abixml reader to make it parse an 'abi-corpus-group' element. To do that, the patch modifies read_corpus_from_input to make it be capable of parsing several 'abi-corpus' in a row. That modified function is then used by a new read_corpus_group_from_input, which is itself used by the new public entry points read_corpus_group_from_native_xml_file and read_corpus_group_from_native_xml. With that read_corpus_group_from_native_xml_file building block function, the kmidiff program is modified so that it can take either two directory trees, two .kmi files or one directory tree and one .kmi file. * include/abg-libxml-utils.h (advance_to_next_sibling_element): Declare new function. * src/abg-libxml-utils.cc (go_to_next_sibling_element_or_stay) (advance_to_next_sibling_element): Define new functions. * include/abg-reader.h (read_corpus_group_from_input) (read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Declare new functions. * src/abg-reader.cc (read_context::m_corpus_group): New data member. (read_context::{get_corpus_group, set_corpus_group}): Define new member functions. (read_translation_unit_from_input): Cleanup logic. (read_corpus_from_input): Don't assume that the document is starting with an 'abi-corpus' element. Support the mode where a caller called the xmlTextReaderExpand function (and so we are given an expanded xmlNodePtr) and the mode where we need to use the xmlTextReader API to walk through the 'abi-corpus' element. Also, if we are building a corpus group, do not clear what used to be 'per-corpus' data. That data must be shared by all the corpora of a given abi-corpus-group. (read_corpus_group_from_input, read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Define new functions. * include/abg-tools-utils.h (FILE_TYPE_XML_CORPUS_GROUP): New enumerator of the file_type enum. * src/abg-tools-utils.cc (operator<<): In the overload for file_type, add a case for the new FILE_TYPE_XML_CORPUS_GROUP. (guess_file_type): Dectect abi-corpus-group xml element. * tools/abidiff.cc (adjust_diff_context_for_kmidiff): Define new static function. (main): Adjust to handle the new FILE_TYPE_XML_CORPUS_GROUP. That is, compare two FILE_TYPE_XML_CORPUS_GROUP if they are present. * tools/abilint.cc (main): Likewise. * tools/kmidiff.cc (main): Detect that one of two .kmi files are passed. In that case, load the .kmi file(s), build a corpus_group of it and use it in the comparison. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-07 21:06:14 +00:00
using abigail::tools_utils::guess_file_type;
using abigail::tools_utils::file_type;
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
/// The options of this program.
struct options
{
bool display_usage;
bool display_version;
bool verbose;
bool missing_operand;
comparison: Add a mode to not apply filters on interface sub-graphs This patch allows to avoid applying filters on interface diff node sub-graphs because those filters are useful for interface impact analysis only, which is not needed in the leaf-node report, for instance. When using the leaf-node report, this capability speeds up corpus_diff::apply_filters_and_suppressions_before_reporting, hence the functions like corpus_diff::{has_incompatible_changes, has_net_subtype_changes} are sped up too. That patch thus adds a --no-change-categorization option to abidiff to avoid doing that change categorization (A.K.A applying filters). * doc/manuals/abidiff.rst: Document the new --no-change-categorization option. * doc/manuals/kmidiff.rst: Likewise. * include/abg-comparison.h (diff_context::perform_change_categorization): Declare new accessor member functions. * src/abg-comparison-priv.h (diff_context::priv::perform_change_categorization_): Add new data member. (diff_context::priv::priv): Initialize the new data member. * src/abg-comparison.cc (diff_context::perform_change_categorization): Define new accessor member functions. (corpus_diff::priv::apply_filters_and_compute_diff_stats): Don't apply filters on the diff node sub-graphs of interfaces when the user requested "no change categorization". * tools/abidiff.cc (options::perform_change_categorization): New data member. (options::options): Initialize the new data member. (display_usage): Add a help string for the new --no-change-categorization. (parse_command_line): Parse the new --no-change-categorization option. (set_diff_context_from_opts): Set the option on the diff context here. * tools/kmidiff.cc(options::perform_change_categorization): New data member. (options::options): Initialize the new data member. (display_usage): Add a help string for the new --no-change-categorization. (parse_command_line): Parse the new --no-change-categorization option. (set_diff_context_from_opts): Set the option on the diff context here. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-02-16 11:19:21 +00:00
bool perform_change_categorization;
bool leaf_changes_only;
Represent sizes and offsets in bytes and hexadecimal values In current change reports, sizes and offsets are represented in bits, and as decimal values. Some users prefer having those offsets be in bytes and as hexadecimal values. This commits adds 4 new options to let users see sizes and offsets be represented either in bits, bytes, decimal or hexadecimal values. * doc/manuals/abidiff.rst: Add documentation for the new --show-bits, --show-bytes, --show-hex and --show-dec options. * doc/manuals/abipkgdiff.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * include/abg-comparison.h (diff_context::{show_hex_values, show_offsets_sizes_in_bits}): Declare new member functions. * src/abg-comparison-priv.h (diff_context::priv::{hex_values_, show_offsets_sizes_in_bits_}): Declare new data members. (diff_context::priv::priv): Initialize them. * src/abg-comparison.cc (diff_context::{show_hex_values, show_offsets_sizes_in_bits}): Define new member functions. * src/abg-default-reporter.cc (default_reporter::report): Adjust the call to maybe_report_diff_for_symbol. * src/abg-leaf-reporter.cc (leaf_reporter::report): Likewise. * src/abg-reporter-priv.h (convert_bits_to_bytes) (maybe_convert_bits_to_bytes, emit_num_value, show_offset_or_size) (show_numerical_change): Declare new functions. (maybe_report_diff_for_symbol): Take a diff_context in parameter. * src/abg-reporter-priv.cc (convert_bits_to_bytes, emit_num_value) (maybe_convert_bits_to_bytes, show_numerical_change) (show_offset_or_size): Define new functions. (represent): In the overload for method_decl, var_decl, use the new emit_num_value function. (represent_data_member): Use the new show_offset_or_size function. (maybe_show_relative_offset_change): Use the new convert_bits_to_bytes, diff_context::show_offsets_sizes_in_bits, emit_num_value functions. (maybe_show_relative_offset_change): Likewise. (report_size_and_alignment_changes): Use the new emit_num_value and show_numerical_change functions. (maybe_report_diff_for_symbol): Tak a diff_context in argument. Use the new show_numerical_change function. * tests/test-diff-filter.cc (in_out_spec): Add a new entry to test hexa and bytes output. * tools/abidiff.cc (options::{show_hexadecimal_values, show_offsets_sizes_in_bits}): New data members. (options::options): Initialize them. (display_usage): New help strings for the new --show{bytes,bits,hex,dec} options. (parse_command_line): Parse the new --show{bytes,bits,hex,dec} options. (set_diff_context_from_opts) Set the diff context wrt hex and bytes values. * tools/abipkgdiff.cc (options::{show_hexadecimal_values, show_offsets_sizes_in_bits}): New data members. (options::options): Initialize them. (display_usage): New help strings for the new --show{bytes,bits,hex,dec} options. (set_diff_context_from_opts): Set the diff context wrt hex and bytes values. (parse_command_line): Parse the new --show{bytes,bits,hex,dec} options. * tools/kmidiff.cc (options::{show_hexadecimal_values, show_offsets_sizes_in_bits}): New data members. (options::options): Initialize them. (display_usage):New help strings for the new --show{bytes,bits,hex,dec} options. (parse_command_line): Parse the new --show{bytes,bits,hex,dec} options. (set_diff_context): Set the diff context wrt hex and bytes values. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report2.txt: New reference test output. * tests/data/Makefile.am: Add the new reference test output above to source distribution. * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Adjust. * tests/data/test-abicompat/test0-fn-changed-report-2.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-1.txt: 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-report-0.txt: 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-report-0.txt: Likewise. * tests/data/test-abicompat/test9-fn-changed-report-0.txt: Likewise. * tests/data/test-abidiff/test-PR18791-report0.txt: Likewise. * tests/data/test-abidiff/test-qual-type0-report.txt: Likewise. * tests/data/test-abidiff/test-struct0-report.txt: Likewise. * tests/data/test-abidiff/test-struct1-report.txt: Likewise. * tests/data/test-abidiff/test-var0-report.txt: Likewise. * tests/data/test-diff-dwarf/test0-report.txt: Likewise. * tests/data/test-diff-dwarf/test1-report.txt: Likewise. * tests/data/test-diff-dwarf/test10-report.txt: Likewise. * tests/data/test-diff-dwarf/test11-report.txt: Likewise. * tests/data/test-diff-dwarf/test13-report.txt: Likewise. * tests/data/test-diff-dwarf/test21-redundant-fn-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test22-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test26-added-parms-before-variadic-report.txt: Likewise. * tests/data/test-diff-dwarf/test27-local-base-diff-report.txt: Likewise. * tests/data/test-diff-dwarf/test3-report.txt: Likewise. * tests/data/test-diff-dwarf/test32-fnptr-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test33-fnref-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test34-pr19173-libfoo-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test35-pr19173-libfoo-long-clang-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test35-pr19173-libfoo-long-gcc-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test36-ppc64-aliases-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test37-union-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test39-union-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test40-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test43-PR22913-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test8-report.txt: Likewise. * tests/data/test-diff-dwarf/test9-report.txt: Likewise. * tests/data/test-diff-filter/test0-report.txt: Likewise. * tests/data/test-diff-filter/test01-report.txt: Likewise. * tests/data/test-diff-filter/test1-report.txt: Likewise. * tests/data/test-diff-filter/test10-report.txt: Likewise. * tests/data/test-diff-filter/test11-report.txt: Likewise. * tests/data/test-diff-filter/test13-report.txt: Likewise. * tests/data/test-diff-filter/test14-0-report.txt: Likewise. * tests/data/test-diff-filter/test14-1-report.txt: Likewise. * tests/data/test-diff-filter/test15-0-report.txt: Likewise. * tests/data/test-diff-filter/test15-1-report.txt: Likewise. * tests/data/test-diff-filter/test16-report-2.txt: Likewise. * tests/data/test-diff-filter/test16-report.txt: Likewise. * tests/data/test-diff-filter/test17-0-report.txt: Likewise. * tests/data/test-diff-filter/test17-1-report.txt: Likewise. * tests/data/test-diff-filter/test2-report.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-0.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt: Likewise. * tests/data/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-0.txt: Likewise. * tests/data/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-1.txt: Likewise. * tests/data/test-diff-filter/test29-finer-redundancy-marking-report-0.txt: Likewise. * tests/data/test-diff-filter/test3-report.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise. * tests/data/test-diff-filter/test32-ppc64le-struct-change-report0.txt: Likewise. * tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt: Likewise. * tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-1.txt: Likewise. * tests/data/test-diff-filter/test37-report-0.txt: Likewise. * tests/data/test-diff-filter/test39/test39-report-0.txt: Likewise. * tests/data/test-diff-filter/test42-leaf-report-output-0.txt: Likewise. * tests/data/test-diff-filter/test6-report.txt: Likewise. * tests/data/test-diff-filter/test9-report.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-1-report-1.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-3-report-1.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-3-report-2.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-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt: Likewise. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Likewise. * tests/data/test-diff-pkg/symlink-dir-test1-report0.txt: Likewise. * tests/data/test-diff-pkg/tarpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/tarpkg-1-report-0.txt: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test11-add-data-member-report-0.txt: Likewise. * tests/data/test-diff-suppr/test12-add-data-member-report-0.txt: Likewise. * tests/data/test-diff-suppr/test12-add-data-member-report-2.txt: Likewise. * tests/data/test-diff-suppr/test13-suppr-through-pointer-report-0.txt: Likewise. * tests/data/test-diff-suppr/test13-suppr-through-pointer-report-1.txt: Likewise. * tests/data/test-diff-suppr/test14-suppr-non-redundant-report-0.txt: Likewise. * tests/data/test-diff-suppr/test14-suppr-non-redundant-report-1.txt: Likewise. * tests/data/test-diff-suppr/test15-suppr-added-fn-report-0.txt: Likewise. * tests/data/test-diff-suppr/test15-suppr-added-fn-report-1.txt: Likewise. * tests/data/test-diff-suppr/test15-suppr-added-fn-report-5.txt: Likewise. * tests/data/test-diff-suppr/test16-suppr-removed-fn-report-0.txt: Likewise. * tests/data/test-diff-suppr/test16-suppr-removed-fn-report-2.txt: Likewise. * tests/data/test-diff-suppr/test17-suppr-added-var-report-0.txt: Likewise. * tests/data/test-diff-suppr/test17-suppr-added-var-report-2.txt: Likewise. * tests/data/test-diff-suppr/test17-suppr-added-var-report-5.txt: Likewise. * tests/data/test-diff-suppr/test18-suppr-removed-var-report-0.txt: Likewise. * tests/data/test-diff-suppr/test18-suppr-removed-var-report-2.txt: Likewise. * tests/data/test-diff-suppr/test18-suppr-removed-var-report-5.txt: Likewise. * tests/data/test-diff-suppr/test2-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-2.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-1.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-10.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-12.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-14.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-16.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-4.txt: Likewise. * tests/data/test-diff-suppr/test25-typedef-report-0.txt: Likewise. * tests/data/test-diff-suppr/test26-loc-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test26-loc-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test29-soname-report-3.txt: Likewise. * tests/data/test-diff-suppr/test29-soname-report-6.txt: Likewise. * tests/data/test-diff-suppr/test29-soname-report-8.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test30-report-0.txt: Likewise. * tests/data/test-diff-suppr/test31-report-1.txt: Likewise. * tests/data/test-diff-suppr/test32-report-0.txt: Likewise. * tests/data/test-diff-suppr/test32-report-1.txt: Likewise. * tests/data/test-diff-suppr/test33-report-0.txt: Likewise. * tests/data/test-diff-suppr/test35-leaf-report-0.txt: Likewise. * tests/data/test-diff-suppr/test36-leaf-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-8.txt: Likewise. * tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt: Likewise. * tests/data/test-diff-suppr/test8-redundant-fn-report-1.txt: Likewise. * tests/data/test-diff-suppr/test9-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-suppr/test9-changed-parm-c-report-1.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-04-20 15:31:35 +00:00
bool show_hexadecimal_values;
bool show_offsets_sizes_in_bits;
bool show_impacted_interfaces;
Allow restricting analyzed decls to exported symbols Profiling showed that the DWARF reader scans too much data. Basically, in build_translation_unit_and_add_to_ir, build_ir_node_from_die is called on every single DIE that is seen, for a given translation unit. There are interfaces (function and variable decls) that are not associated with exported ELF symbols and that are analyzed by build_ir_node_from_die nonetheless. For instance, interfaces that are visible outside of their translation units are analyzed and the types that are reachable from those interfaces are analyzed as well. Once that is done, an ABI corpus is built with the subset of interfaces that have exported ELF symbol (strictly those that are part of the ABI), but types that are not necessarily reachable from those ABI interfaces can also be put into the ABI corpus. Some tools make use of this "lose" behaviour of libabigail. For instance, abicompat precisely wants to analyze interfaces with undefined symbols. For an application, those interfaces represents the interfaces that the application expects to be provided by some shared library. When analyzing the exported interface of the Linux Kernel (or any other huge application) however, analyzing more types than necessary appears to incur a huge time penalty. So, this patch introduces an optional behaviour whereby build_translation_unit_and_add_to_ir is restricted to analyzing interfaces that have exported ELF symbols only. So only the types reachable from those interfaces are analyzed. This more than halves the time spent by "abidw --noout vmlinux". Strictly speaking, this new behaviour is triggered by a new option named --exported-interfaces-only, supported by the tools abidw, abidiff, abipkgdiff and kmidiff. When looking at the Linux Kernel however, this option is enabled by default. Note that an option --allow-non-exported-interfaces is also introduce to function under the previous model of operations. This option is enabled by default on all the tools when they are not looking at the Linux Kernel. With this enabled, analyzing the Linux Kernel is back to taking less than a minute on a reasonable machine. * doc/manuals/tools-use-libabigail.txt: New doc text. * doc/manuals/Makefile.am: Add the new tools-use-libabigail.rst tool to the source distribution. * doc/manuals/abidiff.rst: Include the new tools-use-libabigail.rst. Document the --exported-interfaces-only and --allow-non-exported-interfaces. * doc/manuals/abidw.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * include/abg-ir.h (environment::{user_set_analyze_exported_interfaces_only, analyze_exported_interfaces_only}): Declare new accessors. * src/abg-ir.cc (environment::{user_set_analyze_exported_interfaces_only, analyze_exported_interfaces_only}): Define new accessors. * src/abg-dwarf-reader.cc (die_is_variable_decl) (die_is_function_decl): Define new static functions. (read_context::is_decl_die_with_exported_symbol): Define new member function. (read_context::get_{function,variable}_address): Const-ify the Dwarf_Die* parameter. (build_translation_unit_and_add_to_ir): If the user asks to analyze exported interfaces only, the analyze only interfaces that have exported ELF symbols. (read_debug_info_into_corpus): If we are looking at the Linux Kernel, then only analyze exported interfaces unless the user asks otherwise. * src/abg-ir-priv.h (environment::priv::analyze_exported_interfaces_only_): Define new data member. * tools/abidiff.cc (options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options --exported-interfaces-only and --allow-non-exported-interfaces. (main): Pass the value of opts.exported_interfaces_only to the environment. * tools/abidw.cc (options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options (load_corpus_and_write_abixml) (load_kernel_corpus_group_and_write_abixml): Pass the value of opts.exported_interfaces_only onto the environment. * tools/abipkgdiff.cc (options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options (compare_task::perform, self_compare_task::perform): Pass the value of opts.exported_interfaces_only onto the environment. (compare_prepared_linux_kernel_packages): Likewise. * tools/kmidiff.cc(options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options (main): Pass the value of opts.exported_interfaces_only onto the environment. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-09-02 14:19:23 +00:00
optional<bool> exported_interfaces_only;
#ifdef WITH_CTF
bool use_ctf;
Add support for BTF This adds support for the BTF debug information format. It provides a new BTF front-end which can be instantiated by the function tools::create_best_elf_based_reader(). For now, the BTF front-end supports the basic types (integers, pointers, qualified types, typedefs, struct and unions and function pointers) for functions and variables as emitted for the C language by GCC. It seems to be able to support the BTF debug information emitted for the vmlinux kernel by the pahole tool as well. When configured with the --enable-btf option, the WITH_BTF pre-processor macro is defined, enabling the BTF support. That option is turned on by default if the /usr/include/bpf/btf.h header is found on the system. To disable this, one can use the --disable-btf option. The abidw and abidiff programs have been adapted to use the BTF front-end when provided with the '--btf' option, or if BTF debug information is the only one present in the binary. * configure.ac: If the header /usr/include/bpf/btf.h exists, then define the WITH_BTF pre-processor macro, unless --disable-btf was provided. * doc/manuals/abidiff.rst: Document the new --btf option. * doc/manuals/abidw.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-btf-reader.h: New header file. Contains the declaration of the new btf::reader class. * src/abg-btf-reader.cc: New source file. Contains the definitions of the new btf::reader class. * include/Makefile.am: Add the new include/abg-btf-reader.h header file to source distribution. * include/abg-corpus.h (enum origin): Add a new BTF_ORIGIN enumerator. * include/abg-tools-utils.h (file_has_btf_debug_info): Declare new function. * src/abg-tools-utils.cc (file_has_btf_debug_info): Define new function. (create_best_elf_based_reader): Adapt to support BTF input. If the user requested the BTF front-end, instantiate it. Otherwise, if the input file has only BTF debug info, instantiate the BTF front end. * include/abg-elf-reader.h (elf::reader::find_btf_section): Declare new member function. (elf::reader::{function, variable}_symbol_is_exported): Add new overloads. * src/abg-elf-reader.cc (reader::priv::btf_section): New data member. (reader::find_btf_section): Define new member function. * src/Makefile.am: Add the new abg-ctf-reader.cc file to source distribution. * tools/abidw.cc (options::use_btf): New data member. (display_usage): Add a help string for the new --btf option. (parse_command_line): Support the new --btf option. (load_corpus_and_write_abixml): If the user asked to use the btf front-end then use that one. * tools/abidiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage):: Add a help string to the new --btf options. (parse_command_line): Support the new --btf options. (main): If the user asked to use the btf front-end, then use that one. * tools/abidw.cc (options::use_btf): New data member. (options::options): Initialize it. (parse_command_line): Add a help string to the new --btf options. (load_corpus_and_write_abixml): If the user asked to use the btf front-end, then use that one. * tools/kmidiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage): Add a help string to the new --btf options. (parse_command_line): Add a help string to the new --btf options. (main): If the user asked to use the btf front-end, then use that one. * tools/abipkgdiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage): Add a help string to the new --btf options. (parse_command_line): Add a help string to the new --btf options. (compare, compare_to_self) (compare_prepared_linux_kernel_packages): If the user asked to use the btf front-end, then use that one. * tests/data/test-read-btf/test{0,1}.o: New binary test input file. * tests/data/test-read-btf/test{0,1}.c: Source code of the binary input file above. * tests/data/test-read-btf/test{0,1}.o.abi: Reference ABIXML output. * tests/data/test-abidiff-exit/btf/test0-report-{1,2}.txt: New test reference output. * tests/data/test-abidiff-exit/btf/test0-v{0,1}.o: New binary test input. * tests/data/test-abidiff-exit/btf/test0-v{0,1}.c: The source files of the binary inputs above. * tests/test-read-btf.cc: New test file to run the btf/abixml tests. * tests/Makefile.am: Add the new test files to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-10-31 09:10:52 +00:00
#endif
#ifdef WITH_BTF
bool use_btf;
#endif
string wrong_option;
string kernel_dist_root1;
string kernel_dist_root2;
string vmlinux1;
string vmlinux2;
vector<string> kabi_whitelist_paths;
vector<string> suppression_paths;
suppressions_type read_time_supprs;
suppressions_type diff_time_supprs;
shared_ptr<char> di_root_path1;
shared_ptr<char> di_root_path2;
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
options()
: display_usage(),
display_version(),
verbose(),
missing_operand(),
comparison: Add a mode to not apply filters on interface sub-graphs This patch allows to avoid applying filters on interface diff node sub-graphs because those filters are useful for interface impact analysis only, which is not needed in the leaf-node report, for instance. When using the leaf-node report, this capability speeds up corpus_diff::apply_filters_and_suppressions_before_reporting, hence the functions like corpus_diff::{has_incompatible_changes, has_net_subtype_changes} are sped up too. That patch thus adds a --no-change-categorization option to abidiff to avoid doing that change categorization (A.K.A applying filters). * doc/manuals/abidiff.rst: Document the new --no-change-categorization option. * doc/manuals/kmidiff.rst: Likewise. * include/abg-comparison.h (diff_context::perform_change_categorization): Declare new accessor member functions. * src/abg-comparison-priv.h (diff_context::priv::perform_change_categorization_): Add new data member. (diff_context::priv::priv): Initialize the new data member. * src/abg-comparison.cc (diff_context::perform_change_categorization): Define new accessor member functions. (corpus_diff::priv::apply_filters_and_compute_diff_stats): Don't apply filters on the diff node sub-graphs of interfaces when the user requested "no change categorization". * tools/abidiff.cc (options::perform_change_categorization): New data member. (options::options): Initialize the new data member. (display_usage): Add a help string for the new --no-change-categorization. (parse_command_line): Parse the new --no-change-categorization option. (set_diff_context_from_opts): Set the option on the diff context here. * tools/kmidiff.cc(options::perform_change_categorization): New data member. (options::options): Initialize the new data member. (display_usage): Add a help string for the new --no-change-categorization. (parse_command_line): Parse the new --no-change-categorization option. (set_diff_context_from_opts): Set the option on the diff context here. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-02-16 11:19:21 +00:00
perform_change_categorization(true),
leaf_changes_only(true),
Represent sizes and offsets in bytes and hexadecimal values In current change reports, sizes and offsets are represented in bits, and as decimal values. Some users prefer having those offsets be in bytes and as hexadecimal values. This commits adds 4 new options to let users see sizes and offsets be represented either in bits, bytes, decimal or hexadecimal values. * doc/manuals/abidiff.rst: Add documentation for the new --show-bits, --show-bytes, --show-hex and --show-dec options. * doc/manuals/abipkgdiff.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * include/abg-comparison.h (diff_context::{show_hex_values, show_offsets_sizes_in_bits}): Declare new member functions. * src/abg-comparison-priv.h (diff_context::priv::{hex_values_, show_offsets_sizes_in_bits_}): Declare new data members. (diff_context::priv::priv): Initialize them. * src/abg-comparison.cc (diff_context::{show_hex_values, show_offsets_sizes_in_bits}): Define new member functions. * src/abg-default-reporter.cc (default_reporter::report): Adjust the call to maybe_report_diff_for_symbol. * src/abg-leaf-reporter.cc (leaf_reporter::report): Likewise. * src/abg-reporter-priv.h (convert_bits_to_bytes) (maybe_convert_bits_to_bytes, emit_num_value, show_offset_or_size) (show_numerical_change): Declare new functions. (maybe_report_diff_for_symbol): Take a diff_context in parameter. * src/abg-reporter-priv.cc (convert_bits_to_bytes, emit_num_value) (maybe_convert_bits_to_bytes, show_numerical_change) (show_offset_or_size): Define new functions. (represent): In the overload for method_decl, var_decl, use the new emit_num_value function. (represent_data_member): Use the new show_offset_or_size function. (maybe_show_relative_offset_change): Use the new convert_bits_to_bytes, diff_context::show_offsets_sizes_in_bits, emit_num_value functions. (maybe_show_relative_offset_change): Likewise. (report_size_and_alignment_changes): Use the new emit_num_value and show_numerical_change functions. (maybe_report_diff_for_symbol): Tak a diff_context in argument. Use the new show_numerical_change function. * tests/test-diff-filter.cc (in_out_spec): Add a new entry to test hexa and bytes output. * tools/abidiff.cc (options::{show_hexadecimal_values, show_offsets_sizes_in_bits}): New data members. (options::options): Initialize them. (display_usage): New help strings for the new --show{bytes,bits,hex,dec} options. (parse_command_line): Parse the new --show{bytes,bits,hex,dec} options. (set_diff_context_from_opts) Set the diff context wrt hex and bytes values. * tools/abipkgdiff.cc (options::{show_hexadecimal_values, show_offsets_sizes_in_bits}): New data members. (options::options): Initialize them. (display_usage): New help strings for the new --show{bytes,bits,hex,dec} options. (set_diff_context_from_opts): Set the diff context wrt hex and bytes values. (parse_command_line): Parse the new --show{bytes,bits,hex,dec} options. * tools/kmidiff.cc (options::{show_hexadecimal_values, show_offsets_sizes_in_bits}): New data members. (options::options): Initialize them. (display_usage):New help strings for the new --show{bytes,bits,hex,dec} options. (parse_command_line): Parse the new --show{bytes,bits,hex,dec} options. (set_diff_context): Set the diff context wrt hex and bytes values. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report2.txt: New reference test output. * tests/data/Makefile.am: Add the new reference test output above to source distribution. * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Adjust. * tests/data/test-abicompat/test0-fn-changed-report-2.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-1.txt: 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-report-0.txt: 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-report-0.txt: Likewise. * tests/data/test-abicompat/test9-fn-changed-report-0.txt: Likewise. * tests/data/test-abidiff/test-PR18791-report0.txt: Likewise. * tests/data/test-abidiff/test-qual-type0-report.txt: Likewise. * tests/data/test-abidiff/test-struct0-report.txt: Likewise. * tests/data/test-abidiff/test-struct1-report.txt: Likewise. * tests/data/test-abidiff/test-var0-report.txt: Likewise. * tests/data/test-diff-dwarf/test0-report.txt: Likewise. * tests/data/test-diff-dwarf/test1-report.txt: Likewise. * tests/data/test-diff-dwarf/test10-report.txt: Likewise. * tests/data/test-diff-dwarf/test11-report.txt: Likewise. * tests/data/test-diff-dwarf/test13-report.txt: Likewise. * tests/data/test-diff-dwarf/test21-redundant-fn-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test22-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test26-added-parms-before-variadic-report.txt: Likewise. * tests/data/test-diff-dwarf/test27-local-base-diff-report.txt: Likewise. * tests/data/test-diff-dwarf/test3-report.txt: Likewise. * tests/data/test-diff-dwarf/test32-fnptr-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test33-fnref-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test34-pr19173-libfoo-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test35-pr19173-libfoo-long-clang-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test35-pr19173-libfoo-long-gcc-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test36-ppc64-aliases-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test37-union-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test39-union-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test40-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test43-PR22913-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test8-report.txt: Likewise. * tests/data/test-diff-dwarf/test9-report.txt: Likewise. * tests/data/test-diff-filter/test0-report.txt: Likewise. * tests/data/test-diff-filter/test01-report.txt: Likewise. * tests/data/test-diff-filter/test1-report.txt: Likewise. * tests/data/test-diff-filter/test10-report.txt: Likewise. * tests/data/test-diff-filter/test11-report.txt: Likewise. * tests/data/test-diff-filter/test13-report.txt: Likewise. * tests/data/test-diff-filter/test14-0-report.txt: Likewise. * tests/data/test-diff-filter/test14-1-report.txt: Likewise. * tests/data/test-diff-filter/test15-0-report.txt: Likewise. * tests/data/test-diff-filter/test15-1-report.txt: Likewise. * tests/data/test-diff-filter/test16-report-2.txt: Likewise. * tests/data/test-diff-filter/test16-report.txt: Likewise. * tests/data/test-diff-filter/test17-0-report.txt: Likewise. * tests/data/test-diff-filter/test17-1-report.txt: Likewise. * tests/data/test-diff-filter/test2-report.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-0.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt: Likewise. * tests/data/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-0.txt: Likewise. * tests/data/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-1.txt: Likewise. * tests/data/test-diff-filter/test29-finer-redundancy-marking-report-0.txt: Likewise. * tests/data/test-diff-filter/test3-report.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise. * tests/data/test-diff-filter/test32-ppc64le-struct-change-report0.txt: Likewise. * tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt: Likewise. * tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-1.txt: Likewise. * tests/data/test-diff-filter/test37-report-0.txt: Likewise. * tests/data/test-diff-filter/test39/test39-report-0.txt: Likewise. * tests/data/test-diff-filter/test42-leaf-report-output-0.txt: Likewise. * tests/data/test-diff-filter/test6-report.txt: Likewise. * tests/data/test-diff-filter/test9-report.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-1-report-1.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-3-report-1.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-3-report-2.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-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt: Likewise. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Likewise. * tests/data/test-diff-pkg/symlink-dir-test1-report0.txt: Likewise. * tests/data/test-diff-pkg/tarpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/tarpkg-1-report-0.txt: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test11-add-data-member-report-0.txt: Likewise. * tests/data/test-diff-suppr/test12-add-data-member-report-0.txt: Likewise. * tests/data/test-diff-suppr/test12-add-data-member-report-2.txt: Likewise. * tests/data/test-diff-suppr/test13-suppr-through-pointer-report-0.txt: Likewise. * tests/data/test-diff-suppr/test13-suppr-through-pointer-report-1.txt: Likewise. * tests/data/test-diff-suppr/test14-suppr-non-redundant-report-0.txt: Likewise. * tests/data/test-diff-suppr/test14-suppr-non-redundant-report-1.txt: Likewise. * tests/data/test-diff-suppr/test15-suppr-added-fn-report-0.txt: Likewise. * tests/data/test-diff-suppr/test15-suppr-added-fn-report-1.txt: Likewise. * tests/data/test-diff-suppr/test15-suppr-added-fn-report-5.txt: Likewise. * tests/data/test-diff-suppr/test16-suppr-removed-fn-report-0.txt: Likewise. * tests/data/test-diff-suppr/test16-suppr-removed-fn-report-2.txt: Likewise. * tests/data/test-diff-suppr/test17-suppr-added-var-report-0.txt: Likewise. * tests/data/test-diff-suppr/test17-suppr-added-var-report-2.txt: Likewise. * tests/data/test-diff-suppr/test17-suppr-added-var-report-5.txt: Likewise. * tests/data/test-diff-suppr/test18-suppr-removed-var-report-0.txt: Likewise. * tests/data/test-diff-suppr/test18-suppr-removed-var-report-2.txt: Likewise. * tests/data/test-diff-suppr/test18-suppr-removed-var-report-5.txt: Likewise. * tests/data/test-diff-suppr/test2-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-2.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-1.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-10.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-12.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-14.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-16.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-4.txt: Likewise. * tests/data/test-diff-suppr/test25-typedef-report-0.txt: Likewise. * tests/data/test-diff-suppr/test26-loc-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test26-loc-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test29-soname-report-3.txt: Likewise. * tests/data/test-diff-suppr/test29-soname-report-6.txt: Likewise. * tests/data/test-diff-suppr/test29-soname-report-8.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test30-report-0.txt: Likewise. * tests/data/test-diff-suppr/test31-report-1.txt: Likewise. * tests/data/test-diff-suppr/test32-report-0.txt: Likewise. * tests/data/test-diff-suppr/test32-report-1.txt: Likewise. * tests/data/test-diff-suppr/test33-report-0.txt: Likewise. * tests/data/test-diff-suppr/test35-leaf-report-0.txt: Likewise. * tests/data/test-diff-suppr/test36-leaf-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-8.txt: Likewise. * tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt: Likewise. * tests/data/test-diff-suppr/test8-redundant-fn-report-1.txt: Likewise. * tests/data/test-diff-suppr/test9-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-suppr/test9-changed-parm-c-report-1.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-04-20 15:31:35 +00:00
show_hexadecimal_values(true),
show_offsets_sizes_in_bits(false),
show_impacted_interfaces(false)
#ifdef WITH_CTF
,
use_ctf(false)
Add support for BTF This adds support for the BTF debug information format. It provides a new BTF front-end which can be instantiated by the function tools::create_best_elf_based_reader(). For now, the BTF front-end supports the basic types (integers, pointers, qualified types, typedefs, struct and unions and function pointers) for functions and variables as emitted for the C language by GCC. It seems to be able to support the BTF debug information emitted for the vmlinux kernel by the pahole tool as well. When configured with the --enable-btf option, the WITH_BTF pre-processor macro is defined, enabling the BTF support. That option is turned on by default if the /usr/include/bpf/btf.h header is found on the system. To disable this, one can use the --disable-btf option. The abidw and abidiff programs have been adapted to use the BTF front-end when provided with the '--btf' option, or if BTF debug information is the only one present in the binary. * configure.ac: If the header /usr/include/bpf/btf.h exists, then define the WITH_BTF pre-processor macro, unless --disable-btf was provided. * doc/manuals/abidiff.rst: Document the new --btf option. * doc/manuals/abidw.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-btf-reader.h: New header file. Contains the declaration of the new btf::reader class. * src/abg-btf-reader.cc: New source file. Contains the definitions of the new btf::reader class. * include/Makefile.am: Add the new include/abg-btf-reader.h header file to source distribution. * include/abg-corpus.h (enum origin): Add a new BTF_ORIGIN enumerator. * include/abg-tools-utils.h (file_has_btf_debug_info): Declare new function. * src/abg-tools-utils.cc (file_has_btf_debug_info): Define new function. (create_best_elf_based_reader): Adapt to support BTF input. If the user requested the BTF front-end, instantiate it. Otherwise, if the input file has only BTF debug info, instantiate the BTF front end. * include/abg-elf-reader.h (elf::reader::find_btf_section): Declare new member function. (elf::reader::{function, variable}_symbol_is_exported): Add new overloads. * src/abg-elf-reader.cc (reader::priv::btf_section): New data member. (reader::find_btf_section): Define new member function. * src/Makefile.am: Add the new abg-ctf-reader.cc file to source distribution. * tools/abidw.cc (options::use_btf): New data member. (display_usage): Add a help string for the new --btf option. (parse_command_line): Support the new --btf option. (load_corpus_and_write_abixml): If the user asked to use the btf front-end then use that one. * tools/abidiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage):: Add a help string to the new --btf options. (parse_command_line): Support the new --btf options. (main): If the user asked to use the btf front-end, then use that one. * tools/abidw.cc (options::use_btf): New data member. (options::options): Initialize it. (parse_command_line): Add a help string to the new --btf options. (load_corpus_and_write_abixml): If the user asked to use the btf front-end, then use that one. * tools/kmidiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage): Add a help string to the new --btf options. (parse_command_line): Add a help string to the new --btf options. (main): If the user asked to use the btf front-end, then use that one. * tools/abipkgdiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage): Add a help string to the new --btf options. (parse_command_line): Add a help string to the new --btf options. (compare, compare_to_self) (compare_prepared_linux_kernel_packages): If the user asked to use the btf front-end, then use that one. * tests/data/test-read-btf/test{0,1}.o: New binary test input file. * tests/data/test-read-btf/test{0,1}.c: Source code of the binary input file above. * tests/data/test-read-btf/test{0,1}.o.abi: Reference ABIXML output. * tests/data/test-abidiff-exit/btf/test0-report-{1,2}.txt: New test reference output. * tests/data/test-abidiff-exit/btf/test0-v{0,1}.o: New binary test input. * tests/data/test-abidiff-exit/btf/test0-v{0,1}.c: The source files of the binary inputs above. * tests/test-read-btf.cc: New test file to run the btf/abixml tests. * tests/Makefile.am: Add the new test files to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-10-31 09:10:52 +00:00
#endif
#ifdef WITH_BTF
,
use_btf(false)
#endif
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
{}
}; // end struct options.
/// Display the usage of the program.
///
/// @param prog_name the name of this program.
///
/// @param out the output stream the usage stream is sent to.
static void
display_usage(const string& prog_name, ostream& out)
{
emit_prefix(prog_name, out)
<< "usage: " << prog_name << " [options] kernel-modules-dir1 kernel-modules-dir2\n"
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
<< " where options can be:\n"
<< " --help|-h display this message\n"
<< " --version|-v display program version information and exit\n"
<< " --verbose display verbose messages\n"
<< " --debug-info-dir1|--d1 <path> the root for the debug info of "
"the first kernel\n"
<< " --debug-info-dir2|--d2 <path> the root for the debug info of "
"the second kernel\n"
<< " --vmlinux1|--l1 <path> the path to the first vmlinux\n"
<< " --vmlinux2|--l2 <path> the path to the second vmlinux\n"
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
<< " --suppressions|--suppr <path> specify a suppression file\n"
<< " --kmi-whitelist|-w <path> path to a kernel module interface "
"whitelist\n"
#ifdef WITH_CTF
<< " --ctf use CTF instead of DWARF in ELF files\n"
Add support for BTF This adds support for the BTF debug information format. It provides a new BTF front-end which can be instantiated by the function tools::create_best_elf_based_reader(). For now, the BTF front-end supports the basic types (integers, pointers, qualified types, typedefs, struct and unions and function pointers) for functions and variables as emitted for the C language by GCC. It seems to be able to support the BTF debug information emitted for the vmlinux kernel by the pahole tool as well. When configured with the --enable-btf option, the WITH_BTF pre-processor macro is defined, enabling the BTF support. That option is turned on by default if the /usr/include/bpf/btf.h header is found on the system. To disable this, one can use the --disable-btf option. The abidw and abidiff programs have been adapted to use the BTF front-end when provided with the '--btf' option, or if BTF debug information is the only one present in the binary. * configure.ac: If the header /usr/include/bpf/btf.h exists, then define the WITH_BTF pre-processor macro, unless --disable-btf was provided. * doc/manuals/abidiff.rst: Document the new --btf option. * doc/manuals/abidw.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-btf-reader.h: New header file. Contains the declaration of the new btf::reader class. * src/abg-btf-reader.cc: New source file. Contains the definitions of the new btf::reader class. * include/Makefile.am: Add the new include/abg-btf-reader.h header file to source distribution. * include/abg-corpus.h (enum origin): Add a new BTF_ORIGIN enumerator. * include/abg-tools-utils.h (file_has_btf_debug_info): Declare new function. * src/abg-tools-utils.cc (file_has_btf_debug_info): Define new function. (create_best_elf_based_reader): Adapt to support BTF input. If the user requested the BTF front-end, instantiate it. Otherwise, if the input file has only BTF debug info, instantiate the BTF front end. * include/abg-elf-reader.h (elf::reader::find_btf_section): Declare new member function. (elf::reader::{function, variable}_symbol_is_exported): Add new overloads. * src/abg-elf-reader.cc (reader::priv::btf_section): New data member. (reader::find_btf_section): Define new member function. * src/Makefile.am: Add the new abg-ctf-reader.cc file to source distribution. * tools/abidw.cc (options::use_btf): New data member. (display_usage): Add a help string for the new --btf option. (parse_command_line): Support the new --btf option. (load_corpus_and_write_abixml): If the user asked to use the btf front-end then use that one. * tools/abidiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage):: Add a help string to the new --btf options. (parse_command_line): Support the new --btf options. (main): If the user asked to use the btf front-end, then use that one. * tools/abidw.cc (options::use_btf): New data member. (options::options): Initialize it. (parse_command_line): Add a help string to the new --btf options. (load_corpus_and_write_abixml): If the user asked to use the btf front-end, then use that one. * tools/kmidiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage): Add a help string to the new --btf options. (parse_command_line): Add a help string to the new --btf options. (main): If the user asked to use the btf front-end, then use that one. * tools/abipkgdiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage): Add a help string to the new --btf options. (parse_command_line): Add a help string to the new --btf options. (compare, compare_to_self) (compare_prepared_linux_kernel_packages): If the user asked to use the btf front-end, then use that one. * tests/data/test-read-btf/test{0,1}.o: New binary test input file. * tests/data/test-read-btf/test{0,1}.c: Source code of the binary input file above. * tests/data/test-read-btf/test{0,1}.o.abi: Reference ABIXML output. * tests/data/test-abidiff-exit/btf/test0-report-{1,2}.txt: New test reference output. * tests/data/test-abidiff-exit/btf/test0-v{0,1}.o: New binary test input. * tests/data/test-abidiff-exit/btf/test0-v{0,1}.c: The source files of the binary inputs above. * tests/test-read-btf.cc: New test file to run the btf/abixml tests. * tests/Makefile.am: Add the new test files to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-10-31 09:10:52 +00:00
#endif
#ifdef WITH_BTF
<< " --btf use BTF instead of DWARF in ELF files\n"
#endif
comparison: Add a mode to not apply filters on interface sub-graphs This patch allows to avoid applying filters on interface diff node sub-graphs because those filters are useful for interface impact analysis only, which is not needed in the leaf-node report, for instance. When using the leaf-node report, this capability speeds up corpus_diff::apply_filters_and_suppressions_before_reporting, hence the functions like corpus_diff::{has_incompatible_changes, has_net_subtype_changes} are sped up too. That patch thus adds a --no-change-categorization option to abidiff to avoid doing that change categorization (A.K.A applying filters). * doc/manuals/abidiff.rst: Document the new --no-change-categorization option. * doc/manuals/kmidiff.rst: Likewise. * include/abg-comparison.h (diff_context::perform_change_categorization): Declare new accessor member functions. * src/abg-comparison-priv.h (diff_context::priv::perform_change_categorization_): Add new data member. (diff_context::priv::priv): Initialize the new data member. * src/abg-comparison.cc (diff_context::perform_change_categorization): Define new accessor member functions. (corpus_diff::priv::apply_filters_and_compute_diff_stats): Don't apply filters on the diff node sub-graphs of interfaces when the user requested "no change categorization". * tools/abidiff.cc (options::perform_change_categorization): New data member. (options::options): Initialize the new data member. (display_usage): Add a help string for the new --no-change-categorization. (parse_command_line): Parse the new --no-change-categorization option. (set_diff_context_from_opts): Set the option on the diff context here. * tools/kmidiff.cc(options::perform_change_categorization): New data member. (options::options): Initialize the new data member. (display_usage): Add a help string for the new --no-change-categorization. (parse_command_line): Parse the new --no-change-categorization option. (set_diff_context_from_opts): Set the option on the diff context here. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-02-16 11:19:21 +00:00
<< " --no-change-categorization | -x don't perform categorization "
"of changes, for speed purposes\n"
<< " --impacted-interfaces|-i show interfaces impacted by ABI changes\n"
<< " --full-impact|-f show the full impact of changes on top-most "
Represent sizes and offsets in bytes and hexadecimal values In current change reports, sizes and offsets are represented in bits, and as decimal values. Some users prefer having those offsets be in bytes and as hexadecimal values. This commits adds 4 new options to let users see sizes and offsets be represented either in bits, bytes, decimal or hexadecimal values. * doc/manuals/abidiff.rst: Add documentation for the new --show-bits, --show-bytes, --show-hex and --show-dec options. * doc/manuals/abipkgdiff.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * include/abg-comparison.h (diff_context::{show_hex_values, show_offsets_sizes_in_bits}): Declare new member functions. * src/abg-comparison-priv.h (diff_context::priv::{hex_values_, show_offsets_sizes_in_bits_}): Declare new data members. (diff_context::priv::priv): Initialize them. * src/abg-comparison.cc (diff_context::{show_hex_values, show_offsets_sizes_in_bits}): Define new member functions. * src/abg-default-reporter.cc (default_reporter::report): Adjust the call to maybe_report_diff_for_symbol. * src/abg-leaf-reporter.cc (leaf_reporter::report): Likewise. * src/abg-reporter-priv.h (convert_bits_to_bytes) (maybe_convert_bits_to_bytes, emit_num_value, show_offset_or_size) (show_numerical_change): Declare new functions. (maybe_report_diff_for_symbol): Take a diff_context in parameter. * src/abg-reporter-priv.cc (convert_bits_to_bytes, emit_num_value) (maybe_convert_bits_to_bytes, show_numerical_change) (show_offset_or_size): Define new functions. (represent): In the overload for method_decl, var_decl, use the new emit_num_value function. (represent_data_member): Use the new show_offset_or_size function. (maybe_show_relative_offset_change): Use the new convert_bits_to_bytes, diff_context::show_offsets_sizes_in_bits, emit_num_value functions. (maybe_show_relative_offset_change): Likewise. (report_size_and_alignment_changes): Use the new emit_num_value and show_numerical_change functions. (maybe_report_diff_for_symbol): Tak a diff_context in argument. Use the new show_numerical_change function. * tests/test-diff-filter.cc (in_out_spec): Add a new entry to test hexa and bytes output. * tools/abidiff.cc (options::{show_hexadecimal_values, show_offsets_sizes_in_bits}): New data members. (options::options): Initialize them. (display_usage): New help strings for the new --show{bytes,bits,hex,dec} options. (parse_command_line): Parse the new --show{bytes,bits,hex,dec} options. (set_diff_context_from_opts) Set the diff context wrt hex and bytes values. * tools/abipkgdiff.cc (options::{show_hexadecimal_values, show_offsets_sizes_in_bits}): New data members. (options::options): Initialize them. (display_usage): New help strings for the new --show{bytes,bits,hex,dec} options. (set_diff_context_from_opts): Set the diff context wrt hex and bytes values. (parse_command_line): Parse the new --show{bytes,bits,hex,dec} options. * tools/kmidiff.cc (options::{show_hexadecimal_values, show_offsets_sizes_in_bits}): New data members. (options::options): Initialize them. (display_usage):New help strings for the new --show{bytes,bits,hex,dec} options. (parse_command_line): Parse the new --show{bytes,bits,hex,dec} options. (set_diff_context): Set the diff context wrt hex and bytes values. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report2.txt: New reference test output. * tests/data/Makefile.am: Add the new reference test output above to source distribution. * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Adjust. * tests/data/test-abicompat/test0-fn-changed-report-2.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-1.txt: 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-report-0.txt: 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-report-0.txt: Likewise. * tests/data/test-abicompat/test9-fn-changed-report-0.txt: Likewise. * tests/data/test-abidiff/test-PR18791-report0.txt: Likewise. * tests/data/test-abidiff/test-qual-type0-report.txt: Likewise. * tests/data/test-abidiff/test-struct0-report.txt: Likewise. * tests/data/test-abidiff/test-struct1-report.txt: Likewise. * tests/data/test-abidiff/test-var0-report.txt: Likewise. * tests/data/test-diff-dwarf/test0-report.txt: Likewise. * tests/data/test-diff-dwarf/test1-report.txt: Likewise. * tests/data/test-diff-dwarf/test10-report.txt: Likewise. * tests/data/test-diff-dwarf/test11-report.txt: Likewise. * tests/data/test-diff-dwarf/test13-report.txt: Likewise. * tests/data/test-diff-dwarf/test21-redundant-fn-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test22-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test26-added-parms-before-variadic-report.txt: Likewise. * tests/data/test-diff-dwarf/test27-local-base-diff-report.txt: Likewise. * tests/data/test-diff-dwarf/test3-report.txt: Likewise. * tests/data/test-diff-dwarf/test32-fnptr-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test33-fnref-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test34-pr19173-libfoo-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test35-pr19173-libfoo-long-clang-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test35-pr19173-libfoo-long-gcc-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test36-ppc64-aliases-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test37-union-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test39-union-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test40-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test43-PR22913-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test8-report.txt: Likewise. * tests/data/test-diff-dwarf/test9-report.txt: Likewise. * tests/data/test-diff-filter/test0-report.txt: Likewise. * tests/data/test-diff-filter/test01-report.txt: Likewise. * tests/data/test-diff-filter/test1-report.txt: Likewise. * tests/data/test-diff-filter/test10-report.txt: Likewise. * tests/data/test-diff-filter/test11-report.txt: Likewise. * tests/data/test-diff-filter/test13-report.txt: Likewise. * tests/data/test-diff-filter/test14-0-report.txt: Likewise. * tests/data/test-diff-filter/test14-1-report.txt: Likewise. * tests/data/test-diff-filter/test15-0-report.txt: Likewise. * tests/data/test-diff-filter/test15-1-report.txt: Likewise. * tests/data/test-diff-filter/test16-report-2.txt: Likewise. * tests/data/test-diff-filter/test16-report.txt: Likewise. * tests/data/test-diff-filter/test17-0-report.txt: Likewise. * tests/data/test-diff-filter/test17-1-report.txt: Likewise. * tests/data/test-diff-filter/test2-report.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-0.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt: Likewise. * tests/data/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-0.txt: Likewise. * tests/data/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-1.txt: Likewise. * tests/data/test-diff-filter/test29-finer-redundancy-marking-report-0.txt: Likewise. * tests/data/test-diff-filter/test3-report.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise. * tests/data/test-diff-filter/test32-ppc64le-struct-change-report0.txt: Likewise. * tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt: Likewise. * tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-1.txt: Likewise. * tests/data/test-diff-filter/test37-report-0.txt: Likewise. * tests/data/test-diff-filter/test39/test39-report-0.txt: Likewise. * tests/data/test-diff-filter/test42-leaf-report-output-0.txt: Likewise. * tests/data/test-diff-filter/test6-report.txt: Likewise. * tests/data/test-diff-filter/test9-report.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-1-report-1.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-3-report-1.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-3-report-2.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-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt: Likewise. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Likewise. * tests/data/test-diff-pkg/symlink-dir-test1-report0.txt: Likewise. * tests/data/test-diff-pkg/tarpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/tarpkg-1-report-0.txt: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test11-add-data-member-report-0.txt: Likewise. * tests/data/test-diff-suppr/test12-add-data-member-report-0.txt: Likewise. * tests/data/test-diff-suppr/test12-add-data-member-report-2.txt: Likewise. * tests/data/test-diff-suppr/test13-suppr-through-pointer-report-0.txt: Likewise. * tests/data/test-diff-suppr/test13-suppr-through-pointer-report-1.txt: Likewise. * tests/data/test-diff-suppr/test14-suppr-non-redundant-report-0.txt: Likewise. * tests/data/test-diff-suppr/test14-suppr-non-redundant-report-1.txt: Likewise. * tests/data/test-diff-suppr/test15-suppr-added-fn-report-0.txt: Likewise. * tests/data/test-diff-suppr/test15-suppr-added-fn-report-1.txt: Likewise. * tests/data/test-diff-suppr/test15-suppr-added-fn-report-5.txt: Likewise. * tests/data/test-diff-suppr/test16-suppr-removed-fn-report-0.txt: Likewise. * tests/data/test-diff-suppr/test16-suppr-removed-fn-report-2.txt: Likewise. * tests/data/test-diff-suppr/test17-suppr-added-var-report-0.txt: Likewise. * tests/data/test-diff-suppr/test17-suppr-added-var-report-2.txt: Likewise. * tests/data/test-diff-suppr/test17-suppr-added-var-report-5.txt: Likewise. * tests/data/test-diff-suppr/test18-suppr-removed-var-report-0.txt: Likewise. * tests/data/test-diff-suppr/test18-suppr-removed-var-report-2.txt: Likewise. * tests/data/test-diff-suppr/test18-suppr-removed-var-report-5.txt: Likewise. * tests/data/test-diff-suppr/test2-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-2.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-1.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-10.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-12.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-14.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-16.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-4.txt: Likewise. * tests/data/test-diff-suppr/test25-typedef-report-0.txt: Likewise. * tests/data/test-diff-suppr/test26-loc-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test26-loc-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test29-soname-report-3.txt: Likewise. * tests/data/test-diff-suppr/test29-soname-report-6.txt: Likewise. * tests/data/test-diff-suppr/test29-soname-report-8.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test30-report-0.txt: Likewise. * tests/data/test-diff-suppr/test31-report-1.txt: Likewise. * tests/data/test-diff-suppr/test32-report-0.txt: Likewise. * tests/data/test-diff-suppr/test32-report-1.txt: Likewise. * tests/data/test-diff-suppr/test33-report-0.txt: Likewise. * tests/data/test-diff-suppr/test35-leaf-report-0.txt: Likewise. * tests/data/test-diff-suppr/test36-leaf-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-8.txt: Likewise. * tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt: Likewise. * tests/data/test-diff-suppr/test8-redundant-fn-report-1.txt: Likewise. * tests/data/test-diff-suppr/test9-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-suppr/test9-changed-parm-c-report-1.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-04-20 15:31:35 +00:00
"interfaces\n"
<< " --exported-interfaces-only analyze exported interfaces only\n"
<< " --allow-non-exported-interfaces analyze interfaces that "
Allow restricting analyzed decls to exported symbols Profiling showed that the DWARF reader scans too much data. Basically, in build_translation_unit_and_add_to_ir, build_ir_node_from_die is called on every single DIE that is seen, for a given translation unit. There are interfaces (function and variable decls) that are not associated with exported ELF symbols and that are analyzed by build_ir_node_from_die nonetheless. For instance, interfaces that are visible outside of their translation units are analyzed and the types that are reachable from those interfaces are analyzed as well. Once that is done, an ABI corpus is built with the subset of interfaces that have exported ELF symbol (strictly those that are part of the ABI), but types that are not necessarily reachable from those ABI interfaces can also be put into the ABI corpus. Some tools make use of this "lose" behaviour of libabigail. For instance, abicompat precisely wants to analyze interfaces with undefined symbols. For an application, those interfaces represents the interfaces that the application expects to be provided by some shared library. When analyzing the exported interface of the Linux Kernel (or any other huge application) however, analyzing more types than necessary appears to incur a huge time penalty. So, this patch introduces an optional behaviour whereby build_translation_unit_and_add_to_ir is restricted to analyzing interfaces that have exported ELF symbols only. So only the types reachable from those interfaces are analyzed. This more than halves the time spent by "abidw --noout vmlinux". Strictly speaking, this new behaviour is triggered by a new option named --exported-interfaces-only, supported by the tools abidw, abidiff, abipkgdiff and kmidiff. When looking at the Linux Kernel however, this option is enabled by default. Note that an option --allow-non-exported-interfaces is also introduce to function under the previous model of operations. This option is enabled by default on all the tools when they are not looking at the Linux Kernel. With this enabled, analyzing the Linux Kernel is back to taking less than a minute on a reasonable machine. * doc/manuals/tools-use-libabigail.txt: New doc text. * doc/manuals/Makefile.am: Add the new tools-use-libabigail.rst tool to the source distribution. * doc/manuals/abidiff.rst: Include the new tools-use-libabigail.rst. Document the --exported-interfaces-only and --allow-non-exported-interfaces. * doc/manuals/abidw.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * include/abg-ir.h (environment::{user_set_analyze_exported_interfaces_only, analyze_exported_interfaces_only}): Declare new accessors. * src/abg-ir.cc (environment::{user_set_analyze_exported_interfaces_only, analyze_exported_interfaces_only}): Define new accessors. * src/abg-dwarf-reader.cc (die_is_variable_decl) (die_is_function_decl): Define new static functions. (read_context::is_decl_die_with_exported_symbol): Define new member function. (read_context::get_{function,variable}_address): Const-ify the Dwarf_Die* parameter. (build_translation_unit_and_add_to_ir): If the user asks to analyze exported interfaces only, the analyze only interfaces that have exported ELF symbols. (read_debug_info_into_corpus): If we are looking at the Linux Kernel, then only analyze exported interfaces unless the user asks otherwise. * src/abg-ir-priv.h (environment::priv::analyze_exported_interfaces_only_): Define new data member. * tools/abidiff.cc (options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options --exported-interfaces-only and --allow-non-exported-interfaces. (main): Pass the value of opts.exported_interfaces_only to the environment. * tools/abidw.cc (options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options (load_corpus_and_write_abixml) (load_kernel_corpus_group_and_write_abixml): Pass the value of opts.exported_interfaces_only onto the environment. * tools/abipkgdiff.cc (options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options (compare_task::perform, self_compare_task::perform): Pass the value of opts.exported_interfaces_only onto the environment. (compare_prepared_linux_kernel_packages): Likewise. * tools/kmidiff.cc(options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options (main): Pass the value of opts.exported_interfaces_only onto the environment. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-09-02 14:19:23 +00:00
"might not be exported\n"
Represent sizes and offsets in bytes and hexadecimal values In current change reports, sizes and offsets are represented in bits, and as decimal values. Some users prefer having those offsets be in bytes and as hexadecimal values. This commits adds 4 new options to let users see sizes and offsets be represented either in bits, bytes, decimal or hexadecimal values. * doc/manuals/abidiff.rst: Add documentation for the new --show-bits, --show-bytes, --show-hex and --show-dec options. * doc/manuals/abipkgdiff.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * include/abg-comparison.h (diff_context::{show_hex_values, show_offsets_sizes_in_bits}): Declare new member functions. * src/abg-comparison-priv.h (diff_context::priv::{hex_values_, show_offsets_sizes_in_bits_}): Declare new data members. (diff_context::priv::priv): Initialize them. * src/abg-comparison.cc (diff_context::{show_hex_values, show_offsets_sizes_in_bits}): Define new member functions. * src/abg-default-reporter.cc (default_reporter::report): Adjust the call to maybe_report_diff_for_symbol. * src/abg-leaf-reporter.cc (leaf_reporter::report): Likewise. * src/abg-reporter-priv.h (convert_bits_to_bytes) (maybe_convert_bits_to_bytes, emit_num_value, show_offset_or_size) (show_numerical_change): Declare new functions. (maybe_report_diff_for_symbol): Take a diff_context in parameter. * src/abg-reporter-priv.cc (convert_bits_to_bytes, emit_num_value) (maybe_convert_bits_to_bytes, show_numerical_change) (show_offset_or_size): Define new functions. (represent): In the overload for method_decl, var_decl, use the new emit_num_value function. (represent_data_member): Use the new show_offset_or_size function. (maybe_show_relative_offset_change): Use the new convert_bits_to_bytes, diff_context::show_offsets_sizes_in_bits, emit_num_value functions. (maybe_show_relative_offset_change): Likewise. (report_size_and_alignment_changes): Use the new emit_num_value and show_numerical_change functions. (maybe_report_diff_for_symbol): Tak a diff_context in argument. Use the new show_numerical_change function. * tests/test-diff-filter.cc (in_out_spec): Add a new entry to test hexa and bytes output. * tools/abidiff.cc (options::{show_hexadecimal_values, show_offsets_sizes_in_bits}): New data members. (options::options): Initialize them. (display_usage): New help strings for the new --show{bytes,bits,hex,dec} options. (parse_command_line): Parse the new --show{bytes,bits,hex,dec} options. (set_diff_context_from_opts) Set the diff context wrt hex and bytes values. * tools/abipkgdiff.cc (options::{show_hexadecimal_values, show_offsets_sizes_in_bits}): New data members. (options::options): Initialize them. (display_usage): New help strings for the new --show{bytes,bits,hex,dec} options. (set_diff_context_from_opts): Set the diff context wrt hex and bytes values. (parse_command_line): Parse the new --show{bytes,bits,hex,dec} options. * tools/kmidiff.cc (options::{show_hexadecimal_values, show_offsets_sizes_in_bits}): New data members. (options::options): Initialize them. (display_usage):New help strings for the new --show{bytes,bits,hex,dec} options. (parse_command_line): Parse the new --show{bytes,bits,hex,dec} options. (set_diff_context): Set the diff context wrt hex and bytes values. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report2.txt: New reference test output. * tests/data/Makefile.am: Add the new reference test output above to source distribution. * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Adjust. * tests/data/test-abicompat/test0-fn-changed-report-2.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-1.txt: 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-report-0.txt: 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-report-0.txt: Likewise. * tests/data/test-abicompat/test9-fn-changed-report-0.txt: Likewise. * tests/data/test-abidiff/test-PR18791-report0.txt: Likewise. * tests/data/test-abidiff/test-qual-type0-report.txt: Likewise. * tests/data/test-abidiff/test-struct0-report.txt: Likewise. * tests/data/test-abidiff/test-struct1-report.txt: Likewise. * tests/data/test-abidiff/test-var0-report.txt: Likewise. * tests/data/test-diff-dwarf/test0-report.txt: Likewise. * tests/data/test-diff-dwarf/test1-report.txt: Likewise. * tests/data/test-diff-dwarf/test10-report.txt: Likewise. * tests/data/test-diff-dwarf/test11-report.txt: Likewise. * tests/data/test-diff-dwarf/test13-report.txt: Likewise. * tests/data/test-diff-dwarf/test21-redundant-fn-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test22-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test26-added-parms-before-variadic-report.txt: Likewise. * tests/data/test-diff-dwarf/test27-local-base-diff-report.txt: Likewise. * tests/data/test-diff-dwarf/test3-report.txt: Likewise. * tests/data/test-diff-dwarf/test32-fnptr-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test33-fnref-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test34-pr19173-libfoo-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test35-pr19173-libfoo-long-clang-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test35-pr19173-libfoo-long-gcc-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test36-ppc64-aliases-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test37-union-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test39-union-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test40-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test43-PR22913-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test8-report.txt: Likewise. * tests/data/test-diff-dwarf/test9-report.txt: Likewise. * tests/data/test-diff-filter/test0-report.txt: Likewise. * tests/data/test-diff-filter/test01-report.txt: Likewise. * tests/data/test-diff-filter/test1-report.txt: Likewise. * tests/data/test-diff-filter/test10-report.txt: Likewise. * tests/data/test-diff-filter/test11-report.txt: Likewise. * tests/data/test-diff-filter/test13-report.txt: Likewise. * tests/data/test-diff-filter/test14-0-report.txt: Likewise. * tests/data/test-diff-filter/test14-1-report.txt: Likewise. * tests/data/test-diff-filter/test15-0-report.txt: Likewise. * tests/data/test-diff-filter/test15-1-report.txt: Likewise. * tests/data/test-diff-filter/test16-report-2.txt: Likewise. * tests/data/test-diff-filter/test16-report.txt: Likewise. * tests/data/test-diff-filter/test17-0-report.txt: Likewise. * tests/data/test-diff-filter/test17-1-report.txt: Likewise. * tests/data/test-diff-filter/test2-report.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-0.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt: Likewise. * tests/data/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-0.txt: Likewise. * tests/data/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-1.txt: Likewise. * tests/data/test-diff-filter/test29-finer-redundancy-marking-report-0.txt: Likewise. * tests/data/test-diff-filter/test3-report.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise. * tests/data/test-diff-filter/test32-ppc64le-struct-change-report0.txt: Likewise. * tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt: Likewise. * tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-1.txt: Likewise. * tests/data/test-diff-filter/test37-report-0.txt: Likewise. * tests/data/test-diff-filter/test39/test39-report-0.txt: Likewise. * tests/data/test-diff-filter/test42-leaf-report-output-0.txt: Likewise. * tests/data/test-diff-filter/test6-report.txt: Likewise. * tests/data/test-diff-filter/test9-report.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-1-report-1.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-3-report-1.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-3-report-2.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-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt: Likewise. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Likewise. * tests/data/test-diff-pkg/symlink-dir-test1-report0.txt: Likewise. * tests/data/test-diff-pkg/tarpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/tarpkg-1-report-0.txt: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test11-add-data-member-report-0.txt: Likewise. * tests/data/test-diff-suppr/test12-add-data-member-report-0.txt: Likewise. * tests/data/test-diff-suppr/test12-add-data-member-report-2.txt: Likewise. * tests/data/test-diff-suppr/test13-suppr-through-pointer-report-0.txt: Likewise. * tests/data/test-diff-suppr/test13-suppr-through-pointer-report-1.txt: Likewise. * tests/data/test-diff-suppr/test14-suppr-non-redundant-report-0.txt: Likewise. * tests/data/test-diff-suppr/test14-suppr-non-redundant-report-1.txt: Likewise. * tests/data/test-diff-suppr/test15-suppr-added-fn-report-0.txt: Likewise. * tests/data/test-diff-suppr/test15-suppr-added-fn-report-1.txt: Likewise. * tests/data/test-diff-suppr/test15-suppr-added-fn-report-5.txt: Likewise. * tests/data/test-diff-suppr/test16-suppr-removed-fn-report-0.txt: Likewise. * tests/data/test-diff-suppr/test16-suppr-removed-fn-report-2.txt: Likewise. * tests/data/test-diff-suppr/test17-suppr-added-var-report-0.txt: Likewise. * tests/data/test-diff-suppr/test17-suppr-added-var-report-2.txt: Likewise. * tests/data/test-diff-suppr/test17-suppr-added-var-report-5.txt: Likewise. * tests/data/test-diff-suppr/test18-suppr-removed-var-report-0.txt: Likewise. * tests/data/test-diff-suppr/test18-suppr-removed-var-report-2.txt: Likewise. * tests/data/test-diff-suppr/test18-suppr-removed-var-report-5.txt: Likewise. * tests/data/test-diff-suppr/test2-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-2.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-1.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-10.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-12.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-14.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-16.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-4.txt: Likewise. * tests/data/test-diff-suppr/test25-typedef-report-0.txt: Likewise. * tests/data/test-diff-suppr/test26-loc-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test26-loc-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test29-soname-report-3.txt: Likewise. * tests/data/test-diff-suppr/test29-soname-report-6.txt: Likewise. * tests/data/test-diff-suppr/test29-soname-report-8.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test30-report-0.txt: Likewise. * tests/data/test-diff-suppr/test31-report-1.txt: Likewise. * tests/data/test-diff-suppr/test32-report-0.txt: Likewise. * tests/data/test-diff-suppr/test32-report-1.txt: Likewise. * tests/data/test-diff-suppr/test33-report-0.txt: Likewise. * tests/data/test-diff-suppr/test35-leaf-report-0.txt: Likewise. * tests/data/test-diff-suppr/test36-leaf-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-8.txt: Likewise. * tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt: Likewise. * tests/data/test-diff-suppr/test8-redundant-fn-report-1.txt: Likewise. * tests/data/test-diff-suppr/test9-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-suppr/test9-changed-parm-c-report-1.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-04-20 15:31:35 +00:00
<< " --show-bytes show size and offsets in bytes\n"
<< " --show-bits show size and offsets in bits\n"
<< " --show-hex show size and offset in hexadecimal\n"
<< " --show-dec show size and offset in decimal\n";
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
}
/// Parse the command line of the program.
///
/// @param argc the number of arguments on the command line, including
/// the program name.
///
/// @param argv the arguments on the command line, including the
/// program name.
///
/// @param opts the options resulting from the command line parsing.
///
/// @return true iff the command line parsing went fine.
bool
parse_command_line(int argc, char* argv[], options& opts)
{
if (argc < 2)
return false;
for (int i = 1; i < argc; ++i)
{
if (argv[i][0] != '-')
{
if (opts.kernel_dist_root1.empty())
opts.kernel_dist_root1 = argv[i];
else if (opts.kernel_dist_root2.empty())
opts.kernel_dist_root2 = argv[i];
else
return false;
}
else if (!strcmp(argv[i], "--verbose"))
opts.verbose = true;
else if (!strcmp(argv[i], "--version")
|| !strcmp(argv[i], "-v"))
{
opts.display_version = true;
return true;
}
else if (!strcmp(argv[i], "--help")
|| !strcmp(argv[i], "-h"))
{
opts.display_usage = true;
return true;
}
else if (!strcmp(argv[i], "--debug-info-dir1")
|| !strcmp(argv[i], "--d1"))
{
int j = i + 1;
if (j >= argc)
{
opts.missing_operand = true;
opts.wrong_option = argv[i];
return true;
}
// elfutils wants the root path to the debug info to be
// absolute.
opts.di_root_path1 =
abigail::tools_utils::make_path_absolute(argv[j]);
++i;
}
else if (!strcmp(argv[i], "--debug-info-dir2")
|| !strcmp(argv[i], "--d2"))
{
int j = i + 1;
if (j >= argc)
{
opts.missing_operand = true;
opts.wrong_option = argv[i];
return true;
}
// elfutils wants the root path to the debug info to be
// absolute.
opts.di_root_path2 =
abigail::tools_utils::make_path_absolute(argv[j]);
++i;
}
else if (!strcmp(argv[i], "--vmlinux1")
|| !strcmp(argv[i], "--l1"))
{
int j = i + 1;
if (j >= argc)
{
opts.missing_operand = true;
opts.wrong_option = argv[i];
return false;
}
opts.vmlinux1 = argv[j];
++i;
}
else if (!strcmp(argv[i], "--vmlinux2")
|| !strcmp(argv[i], "--l2"))
{
int j = i + 1;
if (j >= argc)
{
opts.missing_operand = true;
opts.wrong_option = argv[i];
return false;
}
opts.vmlinux2 = argv[j];
++i;
}
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
else if (!strcmp(argv[i], "--kmi-whitelist")
|| !strcmp(argv[i], "-w"))
{
int j = i + 1;
if (j >= argc)
{
opts.missing_operand = true;
opts.wrong_option = argv[i];
return false;
}
opts.kabi_whitelist_paths.push_back(argv[j]);
++i;
}
else if (!strcmp(argv[i], "--suppressions")
|| !strcmp(argv[i], "--suppr"))
{
int j = i + 1;
if (j >= argc)
{
opts.missing_operand = true;
opts.wrong_option = argv[i];
return false;
}
opts.suppression_paths.push_back(argv[j]);
++i;
}
#ifdef WITH_CTF
else if (!strcmp(argv[i], "--ctf"))
opts.use_ctf = true;
Add support for BTF This adds support for the BTF debug information format. It provides a new BTF front-end which can be instantiated by the function tools::create_best_elf_based_reader(). For now, the BTF front-end supports the basic types (integers, pointers, qualified types, typedefs, struct and unions and function pointers) for functions and variables as emitted for the C language by GCC. It seems to be able to support the BTF debug information emitted for the vmlinux kernel by the pahole tool as well. When configured with the --enable-btf option, the WITH_BTF pre-processor macro is defined, enabling the BTF support. That option is turned on by default if the /usr/include/bpf/btf.h header is found on the system. To disable this, one can use the --disable-btf option. The abidw and abidiff programs have been adapted to use the BTF front-end when provided with the '--btf' option, or if BTF debug information is the only one present in the binary. * configure.ac: If the header /usr/include/bpf/btf.h exists, then define the WITH_BTF pre-processor macro, unless --disable-btf was provided. * doc/manuals/abidiff.rst: Document the new --btf option. * doc/manuals/abidw.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-btf-reader.h: New header file. Contains the declaration of the new btf::reader class. * src/abg-btf-reader.cc: New source file. Contains the definitions of the new btf::reader class. * include/Makefile.am: Add the new include/abg-btf-reader.h header file to source distribution. * include/abg-corpus.h (enum origin): Add a new BTF_ORIGIN enumerator. * include/abg-tools-utils.h (file_has_btf_debug_info): Declare new function. * src/abg-tools-utils.cc (file_has_btf_debug_info): Define new function. (create_best_elf_based_reader): Adapt to support BTF input. If the user requested the BTF front-end, instantiate it. Otherwise, if the input file has only BTF debug info, instantiate the BTF front end. * include/abg-elf-reader.h (elf::reader::find_btf_section): Declare new member function. (elf::reader::{function, variable}_symbol_is_exported): Add new overloads. * src/abg-elf-reader.cc (reader::priv::btf_section): New data member. (reader::find_btf_section): Define new member function. * src/Makefile.am: Add the new abg-ctf-reader.cc file to source distribution. * tools/abidw.cc (options::use_btf): New data member. (display_usage): Add a help string for the new --btf option. (parse_command_line): Support the new --btf option. (load_corpus_and_write_abixml): If the user asked to use the btf front-end then use that one. * tools/abidiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage):: Add a help string to the new --btf options. (parse_command_line): Support the new --btf options. (main): If the user asked to use the btf front-end, then use that one. * tools/abidw.cc (options::use_btf): New data member. (options::options): Initialize it. (parse_command_line): Add a help string to the new --btf options. (load_corpus_and_write_abixml): If the user asked to use the btf front-end, then use that one. * tools/kmidiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage): Add a help string to the new --btf options. (parse_command_line): Add a help string to the new --btf options. (main): If the user asked to use the btf front-end, then use that one. * tools/abipkgdiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage): Add a help string to the new --btf options. (parse_command_line): Add a help string to the new --btf options. (compare, compare_to_self) (compare_prepared_linux_kernel_packages): If the user asked to use the btf front-end, then use that one. * tests/data/test-read-btf/test{0,1}.o: New binary test input file. * tests/data/test-read-btf/test{0,1}.c: Source code of the binary input file above. * tests/data/test-read-btf/test{0,1}.o.abi: Reference ABIXML output. * tests/data/test-abidiff-exit/btf/test0-report-{1,2}.txt: New test reference output. * tests/data/test-abidiff-exit/btf/test0-v{0,1}.o: New binary test input. * tests/data/test-abidiff-exit/btf/test0-v{0,1}.c: The source files of the binary inputs above. * tests/test-read-btf.cc: New test file to run the btf/abixml tests. * tests/Makefile.am: Add the new test files to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-10-31 09:10:52 +00:00
#endif
#ifdef WITH_BTF
else if (!strcmp(argv[i], "--btf"))
opts.use_btf = true;
#endif
comparison: Add a mode to not apply filters on interface sub-graphs This patch allows to avoid applying filters on interface diff node sub-graphs because those filters are useful for interface impact analysis only, which is not needed in the leaf-node report, for instance. When using the leaf-node report, this capability speeds up corpus_diff::apply_filters_and_suppressions_before_reporting, hence the functions like corpus_diff::{has_incompatible_changes, has_net_subtype_changes} are sped up too. That patch thus adds a --no-change-categorization option to abidiff to avoid doing that change categorization (A.K.A applying filters). * doc/manuals/abidiff.rst: Document the new --no-change-categorization option. * doc/manuals/kmidiff.rst: Likewise. * include/abg-comparison.h (diff_context::perform_change_categorization): Declare new accessor member functions. * src/abg-comparison-priv.h (diff_context::priv::perform_change_categorization_): Add new data member. (diff_context::priv::priv): Initialize the new data member. * src/abg-comparison.cc (diff_context::perform_change_categorization): Define new accessor member functions. (corpus_diff::priv::apply_filters_and_compute_diff_stats): Don't apply filters on the diff node sub-graphs of interfaces when the user requested "no change categorization". * tools/abidiff.cc (options::perform_change_categorization): New data member. (options::options): Initialize the new data member. (display_usage): Add a help string for the new --no-change-categorization. (parse_command_line): Parse the new --no-change-categorization option. (set_diff_context_from_opts): Set the option on the diff context here. * tools/kmidiff.cc(options::perform_change_categorization): New data member. (options::options): Initialize the new data member. (display_usage): Add a help string for the new --no-change-categorization. (parse_command_line): Parse the new --no-change-categorization option. (set_diff_context_from_opts): Set the option on the diff context here. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-02-16 11:19:21 +00:00
else if (!strcmp(argv[i], "--no-change-categorization")
|| !strcmp(argv[i], "-x"))
opts.perform_change_categorization = false;
else if (!strcmp(argv[i], "--impacted-interfaces")
|| !strcmp(argv[i], "-i"))
opts.show_impacted_interfaces = true;
else if (!strcmp(argv[i], "--full-impact")
|| !strcmp(argv[i], "-f"))
opts.leaf_changes_only = false;
Allow restricting analyzed decls to exported symbols Profiling showed that the DWARF reader scans too much data. Basically, in build_translation_unit_and_add_to_ir, build_ir_node_from_die is called on every single DIE that is seen, for a given translation unit. There are interfaces (function and variable decls) that are not associated with exported ELF symbols and that are analyzed by build_ir_node_from_die nonetheless. For instance, interfaces that are visible outside of their translation units are analyzed and the types that are reachable from those interfaces are analyzed as well. Once that is done, an ABI corpus is built with the subset of interfaces that have exported ELF symbol (strictly those that are part of the ABI), but types that are not necessarily reachable from those ABI interfaces can also be put into the ABI corpus. Some tools make use of this "lose" behaviour of libabigail. For instance, abicompat precisely wants to analyze interfaces with undefined symbols. For an application, those interfaces represents the interfaces that the application expects to be provided by some shared library. When analyzing the exported interface of the Linux Kernel (or any other huge application) however, analyzing more types than necessary appears to incur a huge time penalty. So, this patch introduces an optional behaviour whereby build_translation_unit_and_add_to_ir is restricted to analyzing interfaces that have exported ELF symbols only. So only the types reachable from those interfaces are analyzed. This more than halves the time spent by "abidw --noout vmlinux". Strictly speaking, this new behaviour is triggered by a new option named --exported-interfaces-only, supported by the tools abidw, abidiff, abipkgdiff and kmidiff. When looking at the Linux Kernel however, this option is enabled by default. Note that an option --allow-non-exported-interfaces is also introduce to function under the previous model of operations. This option is enabled by default on all the tools when they are not looking at the Linux Kernel. With this enabled, analyzing the Linux Kernel is back to taking less than a minute on a reasonable machine. * doc/manuals/tools-use-libabigail.txt: New doc text. * doc/manuals/Makefile.am: Add the new tools-use-libabigail.rst tool to the source distribution. * doc/manuals/abidiff.rst: Include the new tools-use-libabigail.rst. Document the --exported-interfaces-only and --allow-non-exported-interfaces. * doc/manuals/abidw.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * include/abg-ir.h (environment::{user_set_analyze_exported_interfaces_only, analyze_exported_interfaces_only}): Declare new accessors. * src/abg-ir.cc (environment::{user_set_analyze_exported_interfaces_only, analyze_exported_interfaces_only}): Define new accessors. * src/abg-dwarf-reader.cc (die_is_variable_decl) (die_is_function_decl): Define new static functions. (read_context::is_decl_die_with_exported_symbol): Define new member function. (read_context::get_{function,variable}_address): Const-ify the Dwarf_Die* parameter. (build_translation_unit_and_add_to_ir): If the user asks to analyze exported interfaces only, the analyze only interfaces that have exported ELF symbols. (read_debug_info_into_corpus): If we are looking at the Linux Kernel, then only analyze exported interfaces unless the user asks otherwise. * src/abg-ir-priv.h (environment::priv::analyze_exported_interfaces_only_): Define new data member. * tools/abidiff.cc (options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options --exported-interfaces-only and --allow-non-exported-interfaces. (main): Pass the value of opts.exported_interfaces_only to the environment. * tools/abidw.cc (options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options (load_corpus_and_write_abixml) (load_kernel_corpus_group_and_write_abixml): Pass the value of opts.exported_interfaces_only onto the environment. * tools/abipkgdiff.cc (options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options (compare_task::perform, self_compare_task::perform): Pass the value of opts.exported_interfaces_only onto the environment. (compare_prepared_linux_kernel_packages): Likewise. * tools/kmidiff.cc(options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options (main): Pass the value of opts.exported_interfaces_only onto the environment. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-09-02 14:19:23 +00:00
else if (!strcmp(argv[i], "--exported-interfaces-only"))
opts.exported_interfaces_only = true;
else if (!strcmp(argv[i], "--allow-non-exported-interfaces"))
opts.exported_interfaces_only = false;
Represent sizes and offsets in bytes and hexadecimal values In current change reports, sizes and offsets are represented in bits, and as decimal values. Some users prefer having those offsets be in bytes and as hexadecimal values. This commits adds 4 new options to let users see sizes and offsets be represented either in bits, bytes, decimal or hexadecimal values. * doc/manuals/abidiff.rst: Add documentation for the new --show-bits, --show-bytes, --show-hex and --show-dec options. * doc/manuals/abipkgdiff.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * include/abg-comparison.h (diff_context::{show_hex_values, show_offsets_sizes_in_bits}): Declare new member functions. * src/abg-comparison-priv.h (diff_context::priv::{hex_values_, show_offsets_sizes_in_bits_}): Declare new data members. (diff_context::priv::priv): Initialize them. * src/abg-comparison.cc (diff_context::{show_hex_values, show_offsets_sizes_in_bits}): Define new member functions. * src/abg-default-reporter.cc (default_reporter::report): Adjust the call to maybe_report_diff_for_symbol. * src/abg-leaf-reporter.cc (leaf_reporter::report): Likewise. * src/abg-reporter-priv.h (convert_bits_to_bytes) (maybe_convert_bits_to_bytes, emit_num_value, show_offset_or_size) (show_numerical_change): Declare new functions. (maybe_report_diff_for_symbol): Take a diff_context in parameter. * src/abg-reporter-priv.cc (convert_bits_to_bytes, emit_num_value) (maybe_convert_bits_to_bytes, show_numerical_change) (show_offset_or_size): Define new functions. (represent): In the overload for method_decl, var_decl, use the new emit_num_value function. (represent_data_member): Use the new show_offset_or_size function. (maybe_show_relative_offset_change): Use the new convert_bits_to_bytes, diff_context::show_offsets_sizes_in_bits, emit_num_value functions. (maybe_show_relative_offset_change): Likewise. (report_size_and_alignment_changes): Use the new emit_num_value and show_numerical_change functions. (maybe_report_diff_for_symbol): Tak a diff_context in argument. Use the new show_numerical_change function. * tests/test-diff-filter.cc (in_out_spec): Add a new entry to test hexa and bytes output. * tools/abidiff.cc (options::{show_hexadecimal_values, show_offsets_sizes_in_bits}): New data members. (options::options): Initialize them. (display_usage): New help strings for the new --show{bytes,bits,hex,dec} options. (parse_command_line): Parse the new --show{bytes,bits,hex,dec} options. (set_diff_context_from_opts) Set the diff context wrt hex and bytes values. * tools/abipkgdiff.cc (options::{show_hexadecimal_values, show_offsets_sizes_in_bits}): New data members. (options::options): Initialize them. (display_usage): New help strings for the new --show{bytes,bits,hex,dec} options. (set_diff_context_from_opts): Set the diff context wrt hex and bytes values. (parse_command_line): Parse the new --show{bytes,bits,hex,dec} options. * tools/kmidiff.cc (options::{show_hexadecimal_values, show_offsets_sizes_in_bits}): New data members. (options::options): Initialize them. (display_usage):New help strings for the new --show{bytes,bits,hex,dec} options. (parse_command_line): Parse the new --show{bytes,bits,hex,dec} options. (set_diff_context): Set the diff context wrt hex and bytes values. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report2.txt: New reference test output. * tests/data/Makefile.am: Add the new reference test output above to source distribution. * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Adjust. * tests/data/test-abicompat/test0-fn-changed-report-2.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-1.txt: 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-report-0.txt: 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-report-0.txt: Likewise. * tests/data/test-abicompat/test9-fn-changed-report-0.txt: Likewise. * tests/data/test-abidiff/test-PR18791-report0.txt: Likewise. * tests/data/test-abidiff/test-qual-type0-report.txt: Likewise. * tests/data/test-abidiff/test-struct0-report.txt: Likewise. * tests/data/test-abidiff/test-struct1-report.txt: Likewise. * tests/data/test-abidiff/test-var0-report.txt: Likewise. * tests/data/test-diff-dwarf/test0-report.txt: Likewise. * tests/data/test-diff-dwarf/test1-report.txt: Likewise. * tests/data/test-diff-dwarf/test10-report.txt: Likewise. * tests/data/test-diff-dwarf/test11-report.txt: Likewise. * tests/data/test-diff-dwarf/test13-report.txt: Likewise. * tests/data/test-diff-dwarf/test21-redundant-fn-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test22-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test26-added-parms-before-variadic-report.txt: Likewise. * tests/data/test-diff-dwarf/test27-local-base-diff-report.txt: Likewise. * tests/data/test-diff-dwarf/test3-report.txt: Likewise. * tests/data/test-diff-dwarf/test32-fnptr-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test33-fnref-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test34-pr19173-libfoo-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test35-pr19173-libfoo-long-clang-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test35-pr19173-libfoo-long-gcc-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test36-ppc64-aliases-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test37-union-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test39-union-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test40-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test43-PR22913-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test8-report.txt: Likewise. * tests/data/test-diff-dwarf/test9-report.txt: Likewise. * tests/data/test-diff-filter/test0-report.txt: Likewise. * tests/data/test-diff-filter/test01-report.txt: Likewise. * tests/data/test-diff-filter/test1-report.txt: Likewise. * tests/data/test-diff-filter/test10-report.txt: Likewise. * tests/data/test-diff-filter/test11-report.txt: Likewise. * tests/data/test-diff-filter/test13-report.txt: Likewise. * tests/data/test-diff-filter/test14-0-report.txt: Likewise. * tests/data/test-diff-filter/test14-1-report.txt: Likewise. * tests/data/test-diff-filter/test15-0-report.txt: Likewise. * tests/data/test-diff-filter/test15-1-report.txt: Likewise. * tests/data/test-diff-filter/test16-report-2.txt: Likewise. * tests/data/test-diff-filter/test16-report.txt: Likewise. * tests/data/test-diff-filter/test17-0-report.txt: Likewise. * tests/data/test-diff-filter/test17-1-report.txt: Likewise. * tests/data/test-diff-filter/test2-report.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-0.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt: Likewise. * tests/data/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-0.txt: Likewise. * tests/data/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-1.txt: Likewise. * tests/data/test-diff-filter/test29-finer-redundancy-marking-report-0.txt: Likewise. * tests/data/test-diff-filter/test3-report.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise. * tests/data/test-diff-filter/test32-ppc64le-struct-change-report0.txt: Likewise. * tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt: Likewise. * tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-1.txt: Likewise. * tests/data/test-diff-filter/test37-report-0.txt: Likewise. * tests/data/test-diff-filter/test39/test39-report-0.txt: Likewise. * tests/data/test-diff-filter/test42-leaf-report-output-0.txt: Likewise. * tests/data/test-diff-filter/test6-report.txt: Likewise. * tests/data/test-diff-filter/test9-report.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-1-report-1.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-3-report-1.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-3-report-2.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-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt: Likewise. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Likewise. * tests/data/test-diff-pkg/symlink-dir-test1-report0.txt: Likewise. * tests/data/test-diff-pkg/tarpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/tarpkg-1-report-0.txt: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test11-add-data-member-report-0.txt: Likewise. * tests/data/test-diff-suppr/test12-add-data-member-report-0.txt: Likewise. * tests/data/test-diff-suppr/test12-add-data-member-report-2.txt: Likewise. * tests/data/test-diff-suppr/test13-suppr-through-pointer-report-0.txt: Likewise. * tests/data/test-diff-suppr/test13-suppr-through-pointer-report-1.txt: Likewise. * tests/data/test-diff-suppr/test14-suppr-non-redundant-report-0.txt: Likewise. * tests/data/test-diff-suppr/test14-suppr-non-redundant-report-1.txt: Likewise. * tests/data/test-diff-suppr/test15-suppr-added-fn-report-0.txt: Likewise. * tests/data/test-diff-suppr/test15-suppr-added-fn-report-1.txt: Likewise. * tests/data/test-diff-suppr/test15-suppr-added-fn-report-5.txt: Likewise. * tests/data/test-diff-suppr/test16-suppr-removed-fn-report-0.txt: Likewise. * tests/data/test-diff-suppr/test16-suppr-removed-fn-report-2.txt: Likewise. * tests/data/test-diff-suppr/test17-suppr-added-var-report-0.txt: Likewise. * tests/data/test-diff-suppr/test17-suppr-added-var-report-2.txt: Likewise. * tests/data/test-diff-suppr/test17-suppr-added-var-report-5.txt: Likewise. * tests/data/test-diff-suppr/test18-suppr-removed-var-report-0.txt: Likewise. * tests/data/test-diff-suppr/test18-suppr-removed-var-report-2.txt: Likewise. * tests/data/test-diff-suppr/test18-suppr-removed-var-report-5.txt: Likewise. * tests/data/test-diff-suppr/test2-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-2.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-1.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-10.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-12.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-14.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-16.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-4.txt: Likewise. * tests/data/test-diff-suppr/test25-typedef-report-0.txt: Likewise. * tests/data/test-diff-suppr/test26-loc-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test26-loc-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test29-soname-report-3.txt: Likewise. * tests/data/test-diff-suppr/test29-soname-report-6.txt: Likewise. * tests/data/test-diff-suppr/test29-soname-report-8.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test30-report-0.txt: Likewise. * tests/data/test-diff-suppr/test31-report-1.txt: Likewise. * tests/data/test-diff-suppr/test32-report-0.txt: Likewise. * tests/data/test-diff-suppr/test32-report-1.txt: Likewise. * tests/data/test-diff-suppr/test33-report-0.txt: Likewise. * tests/data/test-diff-suppr/test35-leaf-report-0.txt: Likewise. * tests/data/test-diff-suppr/test36-leaf-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-8.txt: Likewise. * tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt: Likewise. * tests/data/test-diff-suppr/test8-redundant-fn-report-1.txt: Likewise. * tests/data/test-diff-suppr/test9-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-suppr/test9-changed-parm-c-report-1.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-04-20 15:31:35 +00:00
else if (!strcmp(argv[i], "--show-bytes"))
opts.show_offsets_sizes_in_bits = false;
else if (!strcmp(argv[i], "--show-bits"))
opts.show_offsets_sizes_in_bits = true;
else if (!strcmp(argv[i], "--show-hex"))
opts.show_hexadecimal_values = true;
else if (!strcmp(argv[i], "--show-dec"))
opts.show_hexadecimal_values = false;
else
{
opts.wrong_option = argv[i];
return false;
}
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
}
return true;
}
/// Check that the suppression specification files supplied are
/// present. If not, emit an error on stderr.
///
/// @param opts the options instance to use.
///
/// @return true if all suppression specification files are present,
/// false otherwise.
static bool
maybe_check_suppression_files(const options& opts)
{
for (vector<string>::const_iterator i = opts.suppression_paths.begin();
i != opts.suppression_paths.end();
++i)
if (!check_file(*i, cerr, "abidiff"))
return false;
for (vector<string>::const_iterator i =
opts.kabi_whitelist_paths.begin();
i != opts.kabi_whitelist_paths.end();
++i)
if (!check_file(*i, cerr, "abidiff"))
return false;
return true;
}
/// Setup the diff context from the program's options.
///
/// @param ctxt the diff context to consider.
///
/// @param opts the options to set the context.
static void
set_diff_context(diff_context_sptr ctxt, const options& opts)
{
ctxt->default_output_stream(&cout);
ctxt->error_output_stream(&cerr);
ctxt->show_relative_offset_changes(true);
ctxt->show_redundant_changes(false);
ctxt->show_locs(true);
ctxt->show_linkage_names(false);
ctxt->show_symbols_unreferenced_by_debug_info
(true);
comparison: Add a mode to not apply filters on interface sub-graphs This patch allows to avoid applying filters on interface diff node sub-graphs because those filters are useful for interface impact analysis only, which is not needed in the leaf-node report, for instance. When using the leaf-node report, this capability speeds up corpus_diff::apply_filters_and_suppressions_before_reporting, hence the functions like corpus_diff::{has_incompatible_changes, has_net_subtype_changes} are sped up too. That patch thus adds a --no-change-categorization option to abidiff to avoid doing that change categorization (A.K.A applying filters). * doc/manuals/abidiff.rst: Document the new --no-change-categorization option. * doc/manuals/kmidiff.rst: Likewise. * include/abg-comparison.h (diff_context::perform_change_categorization): Declare new accessor member functions. * src/abg-comparison-priv.h (diff_context::priv::perform_change_categorization_): Add new data member. (diff_context::priv::priv): Initialize the new data member. * src/abg-comparison.cc (diff_context::perform_change_categorization): Define new accessor member functions. (corpus_diff::priv::apply_filters_and_compute_diff_stats): Don't apply filters on the diff node sub-graphs of interfaces when the user requested "no change categorization". * tools/abidiff.cc (options::perform_change_categorization): New data member. (options::options): Initialize the new data member. (display_usage): Add a help string for the new --no-change-categorization. (parse_command_line): Parse the new --no-change-categorization option. (set_diff_context_from_opts): Set the option on the diff context here. * tools/kmidiff.cc(options::perform_change_categorization): New data member. (options::options): Initialize the new data member. (display_usage): Add a help string for the new --no-change-categorization. (parse_command_line): Parse the new --no-change-categorization option. (set_diff_context_from_opts): Set the option on the diff context here. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-02-16 11:19:21 +00:00
ctxt->perform_change_categorization(opts.perform_change_categorization);
ctxt->show_leaf_changes_only(opts.leaf_changes_only);
ctxt->show_impacted_interfaces(opts.show_impacted_interfaces);
Represent sizes and offsets in bytes and hexadecimal values In current change reports, sizes and offsets are represented in bits, and as decimal values. Some users prefer having those offsets be in bytes and as hexadecimal values. This commits adds 4 new options to let users see sizes and offsets be represented either in bits, bytes, decimal or hexadecimal values. * doc/manuals/abidiff.rst: Add documentation for the new --show-bits, --show-bytes, --show-hex and --show-dec options. * doc/manuals/abipkgdiff.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * include/abg-comparison.h (diff_context::{show_hex_values, show_offsets_sizes_in_bits}): Declare new member functions. * src/abg-comparison-priv.h (diff_context::priv::{hex_values_, show_offsets_sizes_in_bits_}): Declare new data members. (diff_context::priv::priv): Initialize them. * src/abg-comparison.cc (diff_context::{show_hex_values, show_offsets_sizes_in_bits}): Define new member functions. * src/abg-default-reporter.cc (default_reporter::report): Adjust the call to maybe_report_diff_for_symbol. * src/abg-leaf-reporter.cc (leaf_reporter::report): Likewise. * src/abg-reporter-priv.h (convert_bits_to_bytes) (maybe_convert_bits_to_bytes, emit_num_value, show_offset_or_size) (show_numerical_change): Declare new functions. (maybe_report_diff_for_symbol): Take a diff_context in parameter. * src/abg-reporter-priv.cc (convert_bits_to_bytes, emit_num_value) (maybe_convert_bits_to_bytes, show_numerical_change) (show_offset_or_size): Define new functions. (represent): In the overload for method_decl, var_decl, use the new emit_num_value function. (represent_data_member): Use the new show_offset_or_size function. (maybe_show_relative_offset_change): Use the new convert_bits_to_bytes, diff_context::show_offsets_sizes_in_bits, emit_num_value functions. (maybe_show_relative_offset_change): Likewise. (report_size_and_alignment_changes): Use the new emit_num_value and show_numerical_change functions. (maybe_report_diff_for_symbol): Tak a diff_context in argument. Use the new show_numerical_change function. * tests/test-diff-filter.cc (in_out_spec): Add a new entry to test hexa and bytes output. * tools/abidiff.cc (options::{show_hexadecimal_values, show_offsets_sizes_in_bits}): New data members. (options::options): Initialize them. (display_usage): New help strings for the new --show{bytes,bits,hex,dec} options. (parse_command_line): Parse the new --show{bytes,bits,hex,dec} options. (set_diff_context_from_opts) Set the diff context wrt hex and bytes values. * tools/abipkgdiff.cc (options::{show_hexadecimal_values, show_offsets_sizes_in_bits}): New data members. (options::options): Initialize them. (display_usage): New help strings for the new --show{bytes,bits,hex,dec} options. (set_diff_context_from_opts): Set the diff context wrt hex and bytes values. (parse_command_line): Parse the new --show{bytes,bits,hex,dec} options. * tools/kmidiff.cc (options::{show_hexadecimal_values, show_offsets_sizes_in_bits}): New data members. (options::options): Initialize them. (display_usage):New help strings for the new --show{bytes,bits,hex,dec} options. (parse_command_line): Parse the new --show{bytes,bits,hex,dec} options. (set_diff_context): Set the diff context wrt hex and bytes values. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report2.txt: New reference test output. * tests/data/Makefile.am: Add the new reference test output above to source distribution. * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Adjust. * tests/data/test-abicompat/test0-fn-changed-report-2.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-1.txt: 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-report-0.txt: 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-report-0.txt: Likewise. * tests/data/test-abicompat/test9-fn-changed-report-0.txt: Likewise. * tests/data/test-abidiff/test-PR18791-report0.txt: Likewise. * tests/data/test-abidiff/test-qual-type0-report.txt: Likewise. * tests/data/test-abidiff/test-struct0-report.txt: Likewise. * tests/data/test-abidiff/test-struct1-report.txt: Likewise. * tests/data/test-abidiff/test-var0-report.txt: Likewise. * tests/data/test-diff-dwarf/test0-report.txt: Likewise. * tests/data/test-diff-dwarf/test1-report.txt: Likewise. * tests/data/test-diff-dwarf/test10-report.txt: Likewise. * tests/data/test-diff-dwarf/test11-report.txt: Likewise. * tests/data/test-diff-dwarf/test13-report.txt: Likewise. * tests/data/test-diff-dwarf/test21-redundant-fn-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test22-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test26-added-parms-before-variadic-report.txt: Likewise. * tests/data/test-diff-dwarf/test27-local-base-diff-report.txt: Likewise. * tests/data/test-diff-dwarf/test3-report.txt: Likewise. * tests/data/test-diff-dwarf/test32-fnptr-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test33-fnref-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test34-pr19173-libfoo-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test35-pr19173-libfoo-long-clang-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test35-pr19173-libfoo-long-gcc-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test36-ppc64-aliases-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test37-union-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test39-union-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test40-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test43-PR22913-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test8-report.txt: Likewise. * tests/data/test-diff-dwarf/test9-report.txt: Likewise. * tests/data/test-diff-filter/test0-report.txt: Likewise. * tests/data/test-diff-filter/test01-report.txt: Likewise. * tests/data/test-diff-filter/test1-report.txt: Likewise. * tests/data/test-diff-filter/test10-report.txt: Likewise. * tests/data/test-diff-filter/test11-report.txt: Likewise. * tests/data/test-diff-filter/test13-report.txt: Likewise. * tests/data/test-diff-filter/test14-0-report.txt: Likewise. * tests/data/test-diff-filter/test14-1-report.txt: Likewise. * tests/data/test-diff-filter/test15-0-report.txt: Likewise. * tests/data/test-diff-filter/test15-1-report.txt: Likewise. * tests/data/test-diff-filter/test16-report-2.txt: Likewise. * tests/data/test-diff-filter/test16-report.txt: Likewise. * tests/data/test-diff-filter/test17-0-report.txt: Likewise. * tests/data/test-diff-filter/test17-1-report.txt: Likewise. * tests/data/test-diff-filter/test2-report.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-0.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt: Likewise. * tests/data/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-0.txt: Likewise. * tests/data/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-1.txt: Likewise. * tests/data/test-diff-filter/test29-finer-redundancy-marking-report-0.txt: Likewise. * tests/data/test-diff-filter/test3-report.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise. * tests/data/test-diff-filter/test32-ppc64le-struct-change-report0.txt: Likewise. * tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt: Likewise. * tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-1.txt: Likewise. * tests/data/test-diff-filter/test37-report-0.txt: Likewise. * tests/data/test-diff-filter/test39/test39-report-0.txt: Likewise. * tests/data/test-diff-filter/test42-leaf-report-output-0.txt: Likewise. * tests/data/test-diff-filter/test6-report.txt: Likewise. * tests/data/test-diff-filter/test9-report.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-1-report-1.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-3-report-1.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-3-report-2.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-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt: Likewise. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Likewise. * tests/data/test-diff-pkg/symlink-dir-test1-report0.txt: Likewise. * tests/data/test-diff-pkg/tarpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/tarpkg-1-report-0.txt: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test11-add-data-member-report-0.txt: Likewise. * tests/data/test-diff-suppr/test12-add-data-member-report-0.txt: Likewise. * tests/data/test-diff-suppr/test12-add-data-member-report-2.txt: Likewise. * tests/data/test-diff-suppr/test13-suppr-through-pointer-report-0.txt: Likewise. * tests/data/test-diff-suppr/test13-suppr-through-pointer-report-1.txt: Likewise. * tests/data/test-diff-suppr/test14-suppr-non-redundant-report-0.txt: Likewise. * tests/data/test-diff-suppr/test14-suppr-non-redundant-report-1.txt: Likewise. * tests/data/test-diff-suppr/test15-suppr-added-fn-report-0.txt: Likewise. * tests/data/test-diff-suppr/test15-suppr-added-fn-report-1.txt: Likewise. * tests/data/test-diff-suppr/test15-suppr-added-fn-report-5.txt: Likewise. * tests/data/test-diff-suppr/test16-suppr-removed-fn-report-0.txt: Likewise. * tests/data/test-diff-suppr/test16-suppr-removed-fn-report-2.txt: Likewise. * tests/data/test-diff-suppr/test17-suppr-added-var-report-0.txt: Likewise. * tests/data/test-diff-suppr/test17-suppr-added-var-report-2.txt: Likewise. * tests/data/test-diff-suppr/test17-suppr-added-var-report-5.txt: Likewise. * tests/data/test-diff-suppr/test18-suppr-removed-var-report-0.txt: Likewise. * tests/data/test-diff-suppr/test18-suppr-removed-var-report-2.txt: Likewise. * tests/data/test-diff-suppr/test18-suppr-removed-var-report-5.txt: Likewise. * tests/data/test-diff-suppr/test2-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-2.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-1.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-10.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-12.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-14.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-16.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-4.txt: Likewise. * tests/data/test-diff-suppr/test25-typedef-report-0.txt: Likewise. * tests/data/test-diff-suppr/test26-loc-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test26-loc-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test29-soname-report-3.txt: Likewise. * tests/data/test-diff-suppr/test29-soname-report-6.txt: Likewise. * tests/data/test-diff-suppr/test29-soname-report-8.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test30-report-0.txt: Likewise. * tests/data/test-diff-suppr/test31-report-1.txt: Likewise. * tests/data/test-diff-suppr/test32-report-0.txt: Likewise. * tests/data/test-diff-suppr/test32-report-1.txt: Likewise. * tests/data/test-diff-suppr/test33-report-0.txt: Likewise. * tests/data/test-diff-suppr/test35-leaf-report-0.txt: Likewise. * tests/data/test-diff-suppr/test36-leaf-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-8.txt: Likewise. * tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt: Likewise. * tests/data/test-diff-suppr/test8-redundant-fn-report-1.txt: Likewise. * tests/data/test-diff-suppr/test9-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-suppr/test9-changed-parm-c-report-1.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-04-20 15:31:35 +00:00
ctxt->show_hex_values(opts.show_hexadecimal_values);
ctxt->show_offsets_sizes_in_bits(opts.show_offsets_sizes_in_bits);
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
Allow selective resolution of class declaration When a class is forward-declared, resolving it to a definition that appears later in the same translation unit or in another translation is an interesting problem. Until now, the declaration would be resolved to the definition of that class found in the binary. The problem is that there can be different such definitions, especially in C where there is no "One Definition Rule". In that case, the definition chosen is random. This patch resolves that randomness. For a given class declaration, if there is just one possible definition in the binary, then the declaration is resolved to that definition. If there is one definition for that declaration in the same translation unit, then the declaration is resolved to that definition. If there are more than one definitions in translation units that are not the one of the declaration, then the declaration is left unresolved. This is what I call "selective class declaration resolution". Note that an unresolved class declaration now compares different to a definition of a class of the same name. This is so that we can have an unresolved class be present in the resulting .abi file, alongside an (incompatible) definition of the same class. The change from a class declaration to its definition is filtered out by default, though. * include/abg-fwd.h (type_base_wptrs_type) (istring_type_base_wptrs_map_type): Define new typedefs. (lookup_class_types): Declare new functions. * include/abg-ir.h (environment::decl_only_class_equals_definition): Declare new accessor. (type_maps::{*_types}): Make these accessors return istring_type_base_wptrs_map_type& instead of istring_type_base_wptr_map_type&. * src/abg-dwarf-reader.cc (read_context::resolve_declaration_only_classes): Implement the new selective declaration resolution scheme. * src/abg-ir.cc (type_maps::priv::{*_types_}): Change the type of these data members from istring_type_base_wptr_map_type to istring_type_base_wptrs_map_type. (type_maps::{*_types}): Make these accessors definitions return istring_type_base_wptrs_map_type& instead of istring_type_base_wptr_map_type&. (translation_unit::bind_function_type_life_time): Adjust. (environment::priv::decl_only_class_equals_definition_): New data member. (environment::priv::priv): Initialize it. By default, a decl-only class is now considered different from its definition. (environment::decl_only_class_equals_definition): Define new accessor. (lookup_types_in_map, lookup_class_types): Define new functions. (lookup_type_in_map, lookup_union_type_per_location) (lookup_basic_type, lookup_basic_type_per_location) (lookup_class_type, lookup_class_type_per_location) (lookup_union_type, lookup_enum_type) (lookup_enum_type_per_location, lookup_typedef_type) (lookup_typedef_type_per_location, lookup_qualified_type) (lookup_pointer_type, lookup_reference_type, lookup_array_type) (lookup_function_type, maybe_update_types_lookup_map) (maybe_update_types_lookup_map<class_decl>) (maybe_update_types_lookup_map<function_type>): Adjust. (type_base::get_canonical_type_for): When doing type comparison here, we can now consider that an unresolved class declaration compares different to an incompatible class definition of the same name. So no need to look through decl-only classes in that case. (equals): In the overload for class_or_union, if environment::decl_only_class_equals_definition() is false, then an unresolved class declaration of name "N" compares different to a class definition named "N". * tests/data/test-annotate/test15-pr18892.so.abi: Adjust. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust * tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust. * tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust. * tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt: Adjust. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Adjust. * tests/data/test-diff-filter/test38/Makefile: New test material. * tests/data/test-diff-filter/test38/test38-a.c: Likewise. * tests/data/test-diff-filter/test38/test38-b.c: Likewise. * tests/data/test-diff-filter/test38/test38-c.c: Likewise. * tests/data/test-diff-filter/test38/test38-report-0.txt: Likewise. * tests/data/test-diff-filter/test38/test38-v0: Likewise. * tests/data/test-diff-filter/test38/test38-v1: Likewise. * tests/data/test-diff-filter/test38/test38.h: Likewise. * tests/data/test-diff-filter/test39/Makefile: Likewise. * tests/data/test-diff-filter/test39/test39-a-v0.c: Likewise. * tests/data/test-diff-filter/test39/test39-a-v1.c: Likewise. * tests/data/test-diff-filter/test39/test39-b-v0.c: Likewise. * tests/data/test-diff-filter/test39/test39-b-v1.c: Likewise. * tests/data/test-diff-filter/test39/test39-c-v0.c: Likewise. * tests/data/test-diff-filter/test39/test39-c-v1.c: Likewise. * tests/data/test-diff-filter/test39/test39-main.c: Likewise. * tests/data/test-diff-filter/test39/test39-report-0.txt: Likewise. * tests/data/test-diff-filter/test39/test39-v0: Likewise. * tests/data/test-diff-filter/test39/test39-v1: Likewise. * tests/data/test-diff-filter/test39/test39.h: Likewise. * tests/data/Makefile.am: Add the new test material above to the source distribution. * tests/test-diff-filter.cc (in_out_specs): Add the new test inputs above to the test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-05-17 08:19:30 +00:00
ctxt->switch_categories_off(get_default_harmless_categories_bitmap());
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
if (!opts.diff_time_supprs.empty())
ctxt->add_suppressions(opts.diff_time_supprs);
}
/// Print information about the kernel (and modules) binaries found
/// under a given directory.
///
/// Note that this function actually look for the modules iff the
/// --verbose option was provided.
///
/// @param root the directory to consider.
///
/// @param opts the options to use during the search.
static void
print_kernel_dist_binary_paths_under(const string& root, const options &opts)
{
string vmlinux;
vector<string> modules;
if (opts.verbose)
Bug 21730 - Make abipkgdiff compare Linux Kernel packages as expected This is the initial patch that makes abipkgdiff recognize Linux kernel packages passed in argument and do the right thing. abipkgdiff gets the vmlinux binary from the debug info package, considers the union of that vmlinux binary and the thousands of kernel modules that we shall name "the Kernel". It then compares ABI (actually Kernel/Module Interface, a.k.a KMI) of the Kernel of the first package against the KMI of the Kernel of the second package. * include/abg-tools-utils.h (get_vmlinux_path_from_kernel_dist): Declare new function. (get_binary_paths_from_kernel_dist): Re-organize order of parameters. (file_is_kernel_package, file_is_kernel_debuginfo_package): Make the file_path parameter be const. (build_corpus_group_from_kernel_dist_under): Take an additional debug_info_root parameter. * src/abg-tools-utils.cc (file_is_kernel_package) (file_is_kernel_debuginfo_package): Const-ify the file_name parameter. (find_vmlinux_path): Define new static function. (get_binary_paths_from_kernel_dist): Re-organize the order of parameters. The debug_info_root_path parameter is now an input parameter. (get_vmlinux_path_from_kernel_dist): Define new function. (get_binary_paths_from_kernel_dist): Adjust invocation of get_binary_paths_from_kernel_dist. (build_corpus_group_from_kernel_dist_under): Take an additional debug_info_root parameter. * tools/abidw.cc (load_kernel_corpus_group_and_write_abixml): Adjust invocation to build_corpus_group_from_kernel_dist_under. * tools/abipkgdiff.cc (create_maps_of_package_content): Don't map the content of a Linux Kernel package. (compare_prepared_userspace_packages) (compare_prepared_linux_kernel_packages, compare_prepared): Define new functions. (compare): Use the new functions above here. * tools/kmidiff.cc (print_kernel_dist_binary_paths_under): Adjust the invocation of get_binary_paths_from_kernel_dist. (main): Adjust the invocation of build_corpus_group_from_kernel_dist_under. Make sure that a kernel package is accompanied by a debug info package. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-10 09:54:13 +00:00
if (get_binary_paths_from_kernel_dist(root, /*debug_info_root_path*/"",
vmlinux, modules))
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
{
cout << "Found kernel binaries under: '" << root << "'\n";
if (!vmlinux.empty())
cout << "[linux kernel binary]\n"
<< " '" << vmlinux << "'\n";
if (!modules.empty())
{
cout << "[linux kernel module binaries]\n";
for (vector<string>::const_iterator p = modules.begin();
p != modules.end();
++p)
cout << " '" << *p << "' \n";
}
cout << "\n";
}
}
int
main(int argc, char* argv[])
{
options opts;
if (!parse_command_line(argc, argv, opts))
{
emit_prefix(argv[0], cerr)
<< "unrecognized option: "
<< opts.wrong_option << "\n"
<< "try the --help option for more information\n";
return 1;
}
if (opts.missing_operand)
{
emit_prefix(argv[0], cerr)
<< "missing operand to option: " << opts.wrong_option <<"\n"
<< "try the --help option for more information\n";
return 1;
}
if (!maybe_check_suppression_files(opts))
return 1;
if (opts.display_usage)
{
display_usage(argv[0], cout);
return 1;
}
if (opts.display_version)
{
emit_prefix(argv[0], cout)
<< abigail::tools_utils::get_library_version_string()
<< "\n";
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
return 0;
}
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
environment env;
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
Allow restricting analyzed decls to exported symbols Profiling showed that the DWARF reader scans too much data. Basically, in build_translation_unit_and_add_to_ir, build_ir_node_from_die is called on every single DIE that is seen, for a given translation unit. There are interfaces (function and variable decls) that are not associated with exported ELF symbols and that are analyzed by build_ir_node_from_die nonetheless. For instance, interfaces that are visible outside of their translation units are analyzed and the types that are reachable from those interfaces are analyzed as well. Once that is done, an ABI corpus is built with the subset of interfaces that have exported ELF symbol (strictly those that are part of the ABI), but types that are not necessarily reachable from those ABI interfaces can also be put into the ABI corpus. Some tools make use of this "lose" behaviour of libabigail. For instance, abicompat precisely wants to analyze interfaces with undefined symbols. For an application, those interfaces represents the interfaces that the application expects to be provided by some shared library. When analyzing the exported interface of the Linux Kernel (or any other huge application) however, analyzing more types than necessary appears to incur a huge time penalty. So, this patch introduces an optional behaviour whereby build_translation_unit_and_add_to_ir is restricted to analyzing interfaces that have exported ELF symbols only. So only the types reachable from those interfaces are analyzed. This more than halves the time spent by "abidw --noout vmlinux". Strictly speaking, this new behaviour is triggered by a new option named --exported-interfaces-only, supported by the tools abidw, abidiff, abipkgdiff and kmidiff. When looking at the Linux Kernel however, this option is enabled by default. Note that an option --allow-non-exported-interfaces is also introduce to function under the previous model of operations. This option is enabled by default on all the tools when they are not looking at the Linux Kernel. With this enabled, analyzing the Linux Kernel is back to taking less than a minute on a reasonable machine. * doc/manuals/tools-use-libabigail.txt: New doc text. * doc/manuals/Makefile.am: Add the new tools-use-libabigail.rst tool to the source distribution. * doc/manuals/abidiff.rst: Include the new tools-use-libabigail.rst. Document the --exported-interfaces-only and --allow-non-exported-interfaces. * doc/manuals/abidw.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * include/abg-ir.h (environment::{user_set_analyze_exported_interfaces_only, analyze_exported_interfaces_only}): Declare new accessors. * src/abg-ir.cc (environment::{user_set_analyze_exported_interfaces_only, analyze_exported_interfaces_only}): Define new accessors. * src/abg-dwarf-reader.cc (die_is_variable_decl) (die_is_function_decl): Define new static functions. (read_context::is_decl_die_with_exported_symbol): Define new member function. (read_context::get_{function,variable}_address): Const-ify the Dwarf_Die* parameter. (build_translation_unit_and_add_to_ir): If the user asks to analyze exported interfaces only, the analyze only interfaces that have exported ELF symbols. (read_debug_info_into_corpus): If we are looking at the Linux Kernel, then only analyze exported interfaces unless the user asks otherwise. * src/abg-ir-priv.h (environment::priv::analyze_exported_interfaces_only_): Define new data member. * tools/abidiff.cc (options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options --exported-interfaces-only and --allow-non-exported-interfaces. (main): Pass the value of opts.exported_interfaces_only to the environment. * tools/abidw.cc (options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options (load_corpus_and_write_abixml) (load_kernel_corpus_group_and_write_abixml): Pass the value of opts.exported_interfaces_only onto the environment. * tools/abipkgdiff.cc (options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options (compare_task::perform, self_compare_task::perform): Pass the value of opts.exported_interfaces_only onto the environment. (compare_prepared_linux_kernel_packages): Likewise. * tools/kmidiff.cc(options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options (main): Pass the value of opts.exported_interfaces_only onto the environment. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-09-02 14:19:23 +00:00
if (opts.exported_interfaces_only.has_value())
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
env.analyze_exported_interfaces_only(*opts.exported_interfaces_only);
Allow restricting analyzed decls to exported symbols Profiling showed that the DWARF reader scans too much data. Basically, in build_translation_unit_and_add_to_ir, build_ir_node_from_die is called on every single DIE that is seen, for a given translation unit. There are interfaces (function and variable decls) that are not associated with exported ELF symbols and that are analyzed by build_ir_node_from_die nonetheless. For instance, interfaces that are visible outside of their translation units are analyzed and the types that are reachable from those interfaces are analyzed as well. Once that is done, an ABI corpus is built with the subset of interfaces that have exported ELF symbol (strictly those that are part of the ABI), but types that are not necessarily reachable from those ABI interfaces can also be put into the ABI corpus. Some tools make use of this "lose" behaviour of libabigail. For instance, abicompat precisely wants to analyze interfaces with undefined symbols. For an application, those interfaces represents the interfaces that the application expects to be provided by some shared library. When analyzing the exported interface of the Linux Kernel (or any other huge application) however, analyzing more types than necessary appears to incur a huge time penalty. So, this patch introduces an optional behaviour whereby build_translation_unit_and_add_to_ir is restricted to analyzing interfaces that have exported ELF symbols only. So only the types reachable from those interfaces are analyzed. This more than halves the time spent by "abidw --noout vmlinux". Strictly speaking, this new behaviour is triggered by a new option named --exported-interfaces-only, supported by the tools abidw, abidiff, abipkgdiff and kmidiff. When looking at the Linux Kernel however, this option is enabled by default. Note that an option --allow-non-exported-interfaces is also introduce to function under the previous model of operations. This option is enabled by default on all the tools when they are not looking at the Linux Kernel. With this enabled, analyzing the Linux Kernel is back to taking less than a minute on a reasonable machine. * doc/manuals/tools-use-libabigail.txt: New doc text. * doc/manuals/Makefile.am: Add the new tools-use-libabigail.rst tool to the source distribution. * doc/manuals/abidiff.rst: Include the new tools-use-libabigail.rst. Document the --exported-interfaces-only and --allow-non-exported-interfaces. * doc/manuals/abidw.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * include/abg-ir.h (environment::{user_set_analyze_exported_interfaces_only, analyze_exported_interfaces_only}): Declare new accessors. * src/abg-ir.cc (environment::{user_set_analyze_exported_interfaces_only, analyze_exported_interfaces_only}): Define new accessors. * src/abg-dwarf-reader.cc (die_is_variable_decl) (die_is_function_decl): Define new static functions. (read_context::is_decl_die_with_exported_symbol): Define new member function. (read_context::get_{function,variable}_address): Const-ify the Dwarf_Die* parameter. (build_translation_unit_and_add_to_ir): If the user asks to analyze exported interfaces only, the analyze only interfaces that have exported ELF symbols. (read_debug_info_into_corpus): If we are looking at the Linux Kernel, then only analyze exported interfaces unless the user asks otherwise. * src/abg-ir-priv.h (environment::priv::analyze_exported_interfaces_only_): Define new data member. * tools/abidiff.cc (options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options --exported-interfaces-only and --allow-non-exported-interfaces. (main): Pass the value of opts.exported_interfaces_only to the environment. * tools/abidw.cc (options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options (load_corpus_and_write_abixml) (load_kernel_corpus_group_and_write_abixml): Pass the value of opts.exported_interfaces_only onto the environment. * tools/abipkgdiff.cc (options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options (compare_task::perform, self_compare_task::perform): Pass the value of opts.exported_interfaces_only onto the environment. (compare_prepared_linux_kernel_packages): Likewise. * tools/kmidiff.cc(options::exported_interfaces_only): Define new data member. (display_usage): Add new help strings for --exported-interfaces-only and --allow-non-exported-interfaces. (parse_command_line): Parse the new options (main): Pass the value of opts.exported_interfaces_only onto the environment. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-09-02 14:19:23 +00:00
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
corpus_group_sptr group1, group2;
string debug_info_root_dir;
Add support for BTF This adds support for the BTF debug information format. It provides a new BTF front-end which can be instantiated by the function tools::create_best_elf_based_reader(). For now, the BTF front-end supports the basic types (integers, pointers, qualified types, typedefs, struct and unions and function pointers) for functions and variables as emitted for the C language by GCC. It seems to be able to support the BTF debug information emitted for the vmlinux kernel by the pahole tool as well. When configured with the --enable-btf option, the WITH_BTF pre-processor macro is defined, enabling the BTF support. That option is turned on by default if the /usr/include/bpf/btf.h header is found on the system. To disable this, one can use the --disable-btf option. The abidw and abidiff programs have been adapted to use the BTF front-end when provided with the '--btf' option, or if BTF debug information is the only one present in the binary. * configure.ac: If the header /usr/include/bpf/btf.h exists, then define the WITH_BTF pre-processor macro, unless --disable-btf was provided. * doc/manuals/abidiff.rst: Document the new --btf option. * doc/manuals/abidw.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-btf-reader.h: New header file. Contains the declaration of the new btf::reader class. * src/abg-btf-reader.cc: New source file. Contains the definitions of the new btf::reader class. * include/Makefile.am: Add the new include/abg-btf-reader.h header file to source distribution. * include/abg-corpus.h (enum origin): Add a new BTF_ORIGIN enumerator. * include/abg-tools-utils.h (file_has_btf_debug_info): Declare new function. * src/abg-tools-utils.cc (file_has_btf_debug_info): Define new function. (create_best_elf_based_reader): Adapt to support BTF input. If the user requested the BTF front-end, instantiate it. Otherwise, if the input file has only BTF debug info, instantiate the BTF front end. * include/abg-elf-reader.h (elf::reader::find_btf_section): Declare new member function. (elf::reader::{function, variable}_symbol_is_exported): Add new overloads. * src/abg-elf-reader.cc (reader::priv::btf_section): New data member. (reader::find_btf_section): Define new member function. * src/Makefile.am: Add the new abg-ctf-reader.cc file to source distribution. * tools/abidw.cc (options::use_btf): New data member. (display_usage): Add a help string for the new --btf option. (parse_command_line): Support the new --btf option. (load_corpus_and_write_abixml): If the user asked to use the btf front-end then use that one. * tools/abidiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage):: Add a help string to the new --btf options. (parse_command_line): Support the new --btf options. (main): If the user asked to use the btf front-end, then use that one. * tools/abidw.cc (options::use_btf): New data member. (options::options): Initialize it. (parse_command_line): Add a help string to the new --btf options. (load_corpus_and_write_abixml): If the user asked to use the btf front-end, then use that one. * tools/kmidiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage): Add a help string to the new --btf options. (parse_command_line): Add a help string to the new --btf options. (main): If the user asked to use the btf front-end, then use that one. * tools/abipkgdiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage): Add a help string to the new --btf options. (parse_command_line): Add a help string to the new --btf options. (compare, compare_to_self) (compare_prepared_linux_kernel_packages): If the user asked to use the btf front-end, then use that one. * tests/data/test-read-btf/test{0,1}.o: New binary test input file. * tests/data/test-read-btf/test{0,1}.c: Source code of the binary input file above. * tests/data/test-read-btf/test{0,1}.o.abi: Reference ABIXML output. * tests/data/test-abidiff-exit/btf/test0-report-{1,2}.txt: New test reference output. * tests/data/test-abidiff-exit/btf/test0-v{0,1}.o: New binary test input. * tests/data/test-abidiff-exit/btf/test0-v{0,1}.c: The source files of the binary inputs above. * tests/test-read-btf.cc: New test file to run the btf/abixml tests. * tests/Makefile.am: Add the new test files to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-10-31 09:10:52 +00:00
corpus::origin requested_fe_kind = corpus::DWARF_ORIGIN;
#ifdef WITH_CTF
Add support for BTF This adds support for the BTF debug information format. It provides a new BTF front-end which can be instantiated by the function tools::create_best_elf_based_reader(). For now, the BTF front-end supports the basic types (integers, pointers, qualified types, typedefs, struct and unions and function pointers) for functions and variables as emitted for the C language by GCC. It seems to be able to support the BTF debug information emitted for the vmlinux kernel by the pahole tool as well. When configured with the --enable-btf option, the WITH_BTF pre-processor macro is defined, enabling the BTF support. That option is turned on by default if the /usr/include/bpf/btf.h header is found on the system. To disable this, one can use the --disable-btf option. The abidw and abidiff programs have been adapted to use the BTF front-end when provided with the '--btf' option, or if BTF debug information is the only one present in the binary. * configure.ac: If the header /usr/include/bpf/btf.h exists, then define the WITH_BTF pre-processor macro, unless --disable-btf was provided. * doc/manuals/abidiff.rst: Document the new --btf option. * doc/manuals/abidw.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-btf-reader.h: New header file. Contains the declaration of the new btf::reader class. * src/abg-btf-reader.cc: New source file. Contains the definitions of the new btf::reader class. * include/Makefile.am: Add the new include/abg-btf-reader.h header file to source distribution. * include/abg-corpus.h (enum origin): Add a new BTF_ORIGIN enumerator. * include/abg-tools-utils.h (file_has_btf_debug_info): Declare new function. * src/abg-tools-utils.cc (file_has_btf_debug_info): Define new function. (create_best_elf_based_reader): Adapt to support BTF input. If the user requested the BTF front-end, instantiate it. Otherwise, if the input file has only BTF debug info, instantiate the BTF front end. * include/abg-elf-reader.h (elf::reader::find_btf_section): Declare new member function. (elf::reader::{function, variable}_symbol_is_exported): Add new overloads. * src/abg-elf-reader.cc (reader::priv::btf_section): New data member. (reader::find_btf_section): Define new member function. * src/Makefile.am: Add the new abg-ctf-reader.cc file to source distribution. * tools/abidw.cc (options::use_btf): New data member. (display_usage): Add a help string for the new --btf option. (parse_command_line): Support the new --btf option. (load_corpus_and_write_abixml): If the user asked to use the btf front-end then use that one. * tools/abidiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage):: Add a help string to the new --btf options. (parse_command_line): Support the new --btf options. (main): If the user asked to use the btf front-end, then use that one. * tools/abidw.cc (options::use_btf): New data member. (options::options): Initialize it. (parse_command_line): Add a help string to the new --btf options. (load_corpus_and_write_abixml): If the user asked to use the btf front-end, then use that one. * tools/kmidiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage): Add a help string to the new --btf options. (parse_command_line): Add a help string to the new --btf options. (main): If the user asked to use the btf front-end, then use that one. * tools/abipkgdiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage): Add a help string to the new --btf options. (parse_command_line): Add a help string to the new --btf options. (compare, compare_to_self) (compare_prepared_linux_kernel_packages): If the user asked to use the btf front-end, then use that one. * tests/data/test-read-btf/test{0,1}.o: New binary test input file. * tests/data/test-read-btf/test{0,1}.c: Source code of the binary input file above. * tests/data/test-read-btf/test{0,1}.o.abi: Reference ABIXML output. * tests/data/test-abidiff-exit/btf/test0-report-{1,2}.txt: New test reference output. * tests/data/test-abidiff-exit/btf/test0-v{0,1}.o: New binary test input. * tests/data/test-abidiff-exit/btf/test0-v{0,1}.c: The source files of the binary inputs above. * tests/test-read-btf.cc: New test file to run the btf/abixml tests. * tests/Makefile.am: Add the new test files to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-10-31 09:10:52 +00:00
if (opts.use_ctf)
requested_fe_kind = corpus::CTF_ORIGIN;
#endif
#ifdef WITH_BTF
if (opts.use_btf)
requested_fe_kind = corpus::BTF_ORIGIN;
#endif
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
if (!opts.kernel_dist_root1.empty())
{
Initial support of de-serializing the KMI of a Linux Kernel Tree With this patch, kmidiff knows how to compare a serialized corpus_group that represents a Kernel Module Interface (a .kmi file) against either another serialized .kmi file, or against a kernel tree. The patch extends the abixml reader to make it parse an 'abi-corpus-group' element. To do that, the patch modifies read_corpus_from_input to make it be capable of parsing several 'abi-corpus' in a row. That modified function is then used by a new read_corpus_group_from_input, which is itself used by the new public entry points read_corpus_group_from_native_xml_file and read_corpus_group_from_native_xml. With that read_corpus_group_from_native_xml_file building block function, the kmidiff program is modified so that it can take either two directory trees, two .kmi files or one directory tree and one .kmi file. * include/abg-libxml-utils.h (advance_to_next_sibling_element): Declare new function. * src/abg-libxml-utils.cc (go_to_next_sibling_element_or_stay) (advance_to_next_sibling_element): Define new functions. * include/abg-reader.h (read_corpus_group_from_input) (read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Declare new functions. * src/abg-reader.cc (read_context::m_corpus_group): New data member. (read_context::{get_corpus_group, set_corpus_group}): Define new member functions. (read_translation_unit_from_input): Cleanup logic. (read_corpus_from_input): Don't assume that the document is starting with an 'abi-corpus' element. Support the mode where a caller called the xmlTextReaderExpand function (and so we are given an expanded xmlNodePtr) and the mode where we need to use the xmlTextReader API to walk through the 'abi-corpus' element. Also, if we are building a corpus group, do not clear what used to be 'per-corpus' data. That data must be shared by all the corpora of a given abi-corpus-group. (read_corpus_group_from_input, read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Define new functions. * include/abg-tools-utils.h (FILE_TYPE_XML_CORPUS_GROUP): New enumerator of the file_type enum. * src/abg-tools-utils.cc (operator<<): In the overload for file_type, add a case for the new FILE_TYPE_XML_CORPUS_GROUP. (guess_file_type): Dectect abi-corpus-group xml element. * tools/abidiff.cc (adjust_diff_context_for_kmidiff): Define new static function. (main): Adjust to handle the new FILE_TYPE_XML_CORPUS_GROUP. That is, compare two FILE_TYPE_XML_CORPUS_GROUP if they are present. * tools/abilint.cc (main): Likewise. * tools/kmidiff.cc (main): Detect that one of two .kmi files are passed. In that case, load the .kmi file(s), build a corpus_group of it and use it in the comparison. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-07 21:06:14 +00:00
file_type ftype = guess_file_type(opts.kernel_dist_root1);
if (ftype == FILE_TYPE_DIR)
{
debug_info_root_dir = opts.di_root_path1.get()
? opts.di_root_path1.get()
: "";
Initial support of de-serializing the KMI of a Linux Kernel Tree With this patch, kmidiff knows how to compare a serialized corpus_group that represents a Kernel Module Interface (a .kmi file) against either another serialized .kmi file, or against a kernel tree. The patch extends the abixml reader to make it parse an 'abi-corpus-group' element. To do that, the patch modifies read_corpus_from_input to make it be capable of parsing several 'abi-corpus' in a row. That modified function is then used by a new read_corpus_group_from_input, which is itself used by the new public entry points read_corpus_group_from_native_xml_file and read_corpus_group_from_native_xml. With that read_corpus_group_from_native_xml_file building block function, the kmidiff program is modified so that it can take either two directory trees, two .kmi files or one directory tree and one .kmi file. * include/abg-libxml-utils.h (advance_to_next_sibling_element): Declare new function. * src/abg-libxml-utils.cc (go_to_next_sibling_element_or_stay) (advance_to_next_sibling_element): Define new functions. * include/abg-reader.h (read_corpus_group_from_input) (read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Declare new functions. * src/abg-reader.cc (read_context::m_corpus_group): New data member. (read_context::{get_corpus_group, set_corpus_group}): Define new member functions. (read_translation_unit_from_input): Cleanup logic. (read_corpus_from_input): Don't assume that the document is starting with an 'abi-corpus' element. Support the mode where a caller called the xmlTextReaderExpand function (and so we are given an expanded xmlNodePtr) and the mode where we need to use the xmlTextReader API to walk through the 'abi-corpus' element. Also, if we are building a corpus group, do not clear what used to be 'per-corpus' data. That data must be shared by all the corpora of a given abi-corpus-group. (read_corpus_group_from_input, read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Define new functions. * include/abg-tools-utils.h (FILE_TYPE_XML_CORPUS_GROUP): New enumerator of the file_type enum. * src/abg-tools-utils.cc (operator<<): In the overload for file_type, add a case for the new FILE_TYPE_XML_CORPUS_GROUP. (guess_file_type): Dectect abi-corpus-group xml element. * tools/abidiff.cc (adjust_diff_context_for_kmidiff): Define new static function. (main): Adjust to handle the new FILE_TYPE_XML_CORPUS_GROUP. That is, compare two FILE_TYPE_XML_CORPUS_GROUP if they are present. * tools/abilint.cc (main): Likewise. * tools/kmidiff.cc (main): Detect that one of two .kmi files are passed. In that case, load the .kmi file(s), build a corpus_group of it and use it in the comparison. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-07 21:06:14 +00:00
group1 =
build_corpus_group_from_kernel_dist_under(opts.kernel_dist_root1,
debug_info_root_dir,
opts.vmlinux1,
Initial support of de-serializing the KMI of a Linux Kernel Tree With this patch, kmidiff knows how to compare a serialized corpus_group that represents a Kernel Module Interface (a .kmi file) against either another serialized .kmi file, or against a kernel tree. The patch extends the abixml reader to make it parse an 'abi-corpus-group' element. To do that, the patch modifies read_corpus_from_input to make it be capable of parsing several 'abi-corpus' in a row. That modified function is then used by a new read_corpus_group_from_input, which is itself used by the new public entry points read_corpus_group_from_native_xml_file and read_corpus_group_from_native_xml. With that read_corpus_group_from_native_xml_file building block function, the kmidiff program is modified so that it can take either two directory trees, two .kmi files or one directory tree and one .kmi file. * include/abg-libxml-utils.h (advance_to_next_sibling_element): Declare new function. * src/abg-libxml-utils.cc (go_to_next_sibling_element_or_stay) (advance_to_next_sibling_element): Define new functions. * include/abg-reader.h (read_corpus_group_from_input) (read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Declare new functions. * src/abg-reader.cc (read_context::m_corpus_group): New data member. (read_context::{get_corpus_group, set_corpus_group}): Define new member functions. (read_translation_unit_from_input): Cleanup logic. (read_corpus_from_input): Don't assume that the document is starting with an 'abi-corpus' element. Support the mode where a caller called the xmlTextReaderExpand function (and so we are given an expanded xmlNodePtr) and the mode where we need to use the xmlTextReader API to walk through the 'abi-corpus' element. Also, if we are building a corpus group, do not clear what used to be 'per-corpus' data. That data must be shared by all the corpora of a given abi-corpus-group. (read_corpus_group_from_input, read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Define new functions. * include/abg-tools-utils.h (FILE_TYPE_XML_CORPUS_GROUP): New enumerator of the file_type enum. * src/abg-tools-utils.cc (operator<<): In the overload for file_type, add a case for the new FILE_TYPE_XML_CORPUS_GROUP. (guess_file_type): Dectect abi-corpus-group xml element. * tools/abidiff.cc (adjust_diff_context_for_kmidiff): Define new static function. (main): Adjust to handle the new FILE_TYPE_XML_CORPUS_GROUP. That is, compare two FILE_TYPE_XML_CORPUS_GROUP if they are present. * tools/abilint.cc (main): Likewise. * tools/kmidiff.cc (main): Detect that one of two .kmi files are passed. In that case, load the .kmi file(s), build a corpus_group of it and use it in the comparison. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-07 21:06:14 +00:00
opts.suppression_paths,
opts.kabi_whitelist_paths,
opts.read_time_supprs,
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
opts.verbose, env,
requested_fe_kind);
Initial support of de-serializing the KMI of a Linux Kernel Tree With this patch, kmidiff knows how to compare a serialized corpus_group that represents a Kernel Module Interface (a .kmi file) against either another serialized .kmi file, or against a kernel tree. The patch extends the abixml reader to make it parse an 'abi-corpus-group' element. To do that, the patch modifies read_corpus_from_input to make it be capable of parsing several 'abi-corpus' in a row. That modified function is then used by a new read_corpus_group_from_input, which is itself used by the new public entry points read_corpus_group_from_native_xml_file and read_corpus_group_from_native_xml. With that read_corpus_group_from_native_xml_file building block function, the kmidiff program is modified so that it can take either two directory trees, two .kmi files or one directory tree and one .kmi file. * include/abg-libxml-utils.h (advance_to_next_sibling_element): Declare new function. * src/abg-libxml-utils.cc (go_to_next_sibling_element_or_stay) (advance_to_next_sibling_element): Define new functions. * include/abg-reader.h (read_corpus_group_from_input) (read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Declare new functions. * src/abg-reader.cc (read_context::m_corpus_group): New data member. (read_context::{get_corpus_group, set_corpus_group}): Define new member functions. (read_translation_unit_from_input): Cleanup logic. (read_corpus_from_input): Don't assume that the document is starting with an 'abi-corpus' element. Support the mode where a caller called the xmlTextReaderExpand function (and so we are given an expanded xmlNodePtr) and the mode where we need to use the xmlTextReader API to walk through the 'abi-corpus' element. Also, if we are building a corpus group, do not clear what used to be 'per-corpus' data. That data must be shared by all the corpora of a given abi-corpus-group. (read_corpus_group_from_input, read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Define new functions. * include/abg-tools-utils.h (FILE_TYPE_XML_CORPUS_GROUP): New enumerator of the file_type enum. * src/abg-tools-utils.cc (operator<<): In the overload for file_type, add a case for the new FILE_TYPE_XML_CORPUS_GROUP. (guess_file_type): Dectect abi-corpus-group xml element. * tools/abidiff.cc (adjust_diff_context_for_kmidiff): Define new static function. (main): Adjust to handle the new FILE_TYPE_XML_CORPUS_GROUP. That is, compare two FILE_TYPE_XML_CORPUS_GROUP if they are present. * tools/abilint.cc (main): Likewise. * tools/kmidiff.cc (main): Detect that one of two .kmi files are passed. In that case, load the .kmi file(s), build a corpus_group of it and use it in the comparison. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-07 21:06:14 +00:00
print_kernel_dist_binary_paths_under(opts.kernel_dist_root1, opts);
}
else if (ftype == FILE_TYPE_XML_CORPUS_GROUP)
group1 =
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
abixml::read_corpus_group_from_abixml_file(opts.kernel_dist_root1,
env);
Initial support of de-serializing the KMI of a Linux Kernel Tree With this patch, kmidiff knows how to compare a serialized corpus_group that represents a Kernel Module Interface (a .kmi file) against either another serialized .kmi file, or against a kernel tree. The patch extends the abixml reader to make it parse an 'abi-corpus-group' element. To do that, the patch modifies read_corpus_from_input to make it be capable of parsing several 'abi-corpus' in a row. That modified function is then used by a new read_corpus_group_from_input, which is itself used by the new public entry points read_corpus_group_from_native_xml_file and read_corpus_group_from_native_xml. With that read_corpus_group_from_native_xml_file building block function, the kmidiff program is modified so that it can take either two directory trees, two .kmi files or one directory tree and one .kmi file. * include/abg-libxml-utils.h (advance_to_next_sibling_element): Declare new function. * src/abg-libxml-utils.cc (go_to_next_sibling_element_or_stay) (advance_to_next_sibling_element): Define new functions. * include/abg-reader.h (read_corpus_group_from_input) (read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Declare new functions. * src/abg-reader.cc (read_context::m_corpus_group): New data member. (read_context::{get_corpus_group, set_corpus_group}): Define new member functions. (read_translation_unit_from_input): Cleanup logic. (read_corpus_from_input): Don't assume that the document is starting with an 'abi-corpus' element. Support the mode where a caller called the xmlTextReaderExpand function (and so we are given an expanded xmlNodePtr) and the mode where we need to use the xmlTextReader API to walk through the 'abi-corpus' element. Also, if we are building a corpus group, do not clear what used to be 'per-corpus' data. That data must be shared by all the corpora of a given abi-corpus-group. (read_corpus_group_from_input, read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Define new functions. * include/abg-tools-utils.h (FILE_TYPE_XML_CORPUS_GROUP): New enumerator of the file_type enum. * src/abg-tools-utils.cc (operator<<): In the overload for file_type, add a case for the new FILE_TYPE_XML_CORPUS_GROUP. (guess_file_type): Dectect abi-corpus-group xml element. * tools/abidiff.cc (adjust_diff_context_for_kmidiff): Define new static function. (main): Adjust to handle the new FILE_TYPE_XML_CORPUS_GROUP. That is, compare two FILE_TYPE_XML_CORPUS_GROUP if they are present. * tools/abilint.cc (main): Likewise. * tools/kmidiff.cc (main): Detect that one of two .kmi files are passed. In that case, load the .kmi file(s), build a corpus_group of it and use it in the comparison. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-07 21:06:14 +00:00
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
}
if (!opts.kernel_dist_root2.empty())
{
Initial support of de-serializing the KMI of a Linux Kernel Tree With this patch, kmidiff knows how to compare a serialized corpus_group that represents a Kernel Module Interface (a .kmi file) against either another serialized .kmi file, or against a kernel tree. The patch extends the abixml reader to make it parse an 'abi-corpus-group' element. To do that, the patch modifies read_corpus_from_input to make it be capable of parsing several 'abi-corpus' in a row. That modified function is then used by a new read_corpus_group_from_input, which is itself used by the new public entry points read_corpus_group_from_native_xml_file and read_corpus_group_from_native_xml. With that read_corpus_group_from_native_xml_file building block function, the kmidiff program is modified so that it can take either two directory trees, two .kmi files or one directory tree and one .kmi file. * include/abg-libxml-utils.h (advance_to_next_sibling_element): Declare new function. * src/abg-libxml-utils.cc (go_to_next_sibling_element_or_stay) (advance_to_next_sibling_element): Define new functions. * include/abg-reader.h (read_corpus_group_from_input) (read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Declare new functions. * src/abg-reader.cc (read_context::m_corpus_group): New data member. (read_context::{get_corpus_group, set_corpus_group}): Define new member functions. (read_translation_unit_from_input): Cleanup logic. (read_corpus_from_input): Don't assume that the document is starting with an 'abi-corpus' element. Support the mode where a caller called the xmlTextReaderExpand function (and so we are given an expanded xmlNodePtr) and the mode where we need to use the xmlTextReader API to walk through the 'abi-corpus' element. Also, if we are building a corpus group, do not clear what used to be 'per-corpus' data. That data must be shared by all the corpora of a given abi-corpus-group. (read_corpus_group_from_input, read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Define new functions. * include/abg-tools-utils.h (FILE_TYPE_XML_CORPUS_GROUP): New enumerator of the file_type enum. * src/abg-tools-utils.cc (operator<<): In the overload for file_type, add a case for the new FILE_TYPE_XML_CORPUS_GROUP. (guess_file_type): Dectect abi-corpus-group xml element. * tools/abidiff.cc (adjust_diff_context_for_kmidiff): Define new static function. (main): Adjust to handle the new FILE_TYPE_XML_CORPUS_GROUP. That is, compare two FILE_TYPE_XML_CORPUS_GROUP if they are present. * tools/abilint.cc (main): Likewise. * tools/kmidiff.cc (main): Detect that one of two .kmi files are passed. In that case, load the .kmi file(s), build a corpus_group of it and use it in the comparison. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-07 21:06:14 +00:00
file_type ftype = guess_file_type(opts.kernel_dist_root2);
if (ftype == FILE_TYPE_DIR)
{
debug_info_root_dir = opts.di_root_path2.get()
? opts.di_root_path2.get()
: "";
Initial support of de-serializing the KMI of a Linux Kernel Tree With this patch, kmidiff knows how to compare a serialized corpus_group that represents a Kernel Module Interface (a .kmi file) against either another serialized .kmi file, or against a kernel tree. The patch extends the abixml reader to make it parse an 'abi-corpus-group' element. To do that, the patch modifies read_corpus_from_input to make it be capable of parsing several 'abi-corpus' in a row. That modified function is then used by a new read_corpus_group_from_input, which is itself used by the new public entry points read_corpus_group_from_native_xml_file and read_corpus_group_from_native_xml. With that read_corpus_group_from_native_xml_file building block function, the kmidiff program is modified so that it can take either two directory trees, two .kmi files or one directory tree and one .kmi file. * include/abg-libxml-utils.h (advance_to_next_sibling_element): Declare new function. * src/abg-libxml-utils.cc (go_to_next_sibling_element_or_stay) (advance_to_next_sibling_element): Define new functions. * include/abg-reader.h (read_corpus_group_from_input) (read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Declare new functions. * src/abg-reader.cc (read_context::m_corpus_group): New data member. (read_context::{get_corpus_group, set_corpus_group}): Define new member functions. (read_translation_unit_from_input): Cleanup logic. (read_corpus_from_input): Don't assume that the document is starting with an 'abi-corpus' element. Support the mode where a caller called the xmlTextReaderExpand function (and so we are given an expanded xmlNodePtr) and the mode where we need to use the xmlTextReader API to walk through the 'abi-corpus' element. Also, if we are building a corpus group, do not clear what used to be 'per-corpus' data. That data must be shared by all the corpora of a given abi-corpus-group. (read_corpus_group_from_input, read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Define new functions. * include/abg-tools-utils.h (FILE_TYPE_XML_CORPUS_GROUP): New enumerator of the file_type enum. * src/abg-tools-utils.cc (operator<<): In the overload for file_type, add a case for the new FILE_TYPE_XML_CORPUS_GROUP. (guess_file_type): Dectect abi-corpus-group xml element. * tools/abidiff.cc (adjust_diff_context_for_kmidiff): Define new static function. (main): Adjust to handle the new FILE_TYPE_XML_CORPUS_GROUP. That is, compare two FILE_TYPE_XML_CORPUS_GROUP if they are present. * tools/abilint.cc (main): Likewise. * tools/kmidiff.cc (main): Detect that one of two .kmi files are passed. In that case, load the .kmi file(s), build a corpus_group of it and use it in the comparison. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-07 21:06:14 +00:00
group2 =
build_corpus_group_from_kernel_dist_under(opts.kernel_dist_root2,
debug_info_root_dir,
opts.vmlinux2,
Initial support of de-serializing the KMI of a Linux Kernel Tree With this patch, kmidiff knows how to compare a serialized corpus_group that represents a Kernel Module Interface (a .kmi file) against either another serialized .kmi file, or against a kernel tree. The patch extends the abixml reader to make it parse an 'abi-corpus-group' element. To do that, the patch modifies read_corpus_from_input to make it be capable of parsing several 'abi-corpus' in a row. That modified function is then used by a new read_corpus_group_from_input, which is itself used by the new public entry points read_corpus_group_from_native_xml_file and read_corpus_group_from_native_xml. With that read_corpus_group_from_native_xml_file building block function, the kmidiff program is modified so that it can take either two directory trees, two .kmi files or one directory tree and one .kmi file. * include/abg-libxml-utils.h (advance_to_next_sibling_element): Declare new function. * src/abg-libxml-utils.cc (go_to_next_sibling_element_or_stay) (advance_to_next_sibling_element): Define new functions. * include/abg-reader.h (read_corpus_group_from_input) (read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Declare new functions. * src/abg-reader.cc (read_context::m_corpus_group): New data member. (read_context::{get_corpus_group, set_corpus_group}): Define new member functions. (read_translation_unit_from_input): Cleanup logic. (read_corpus_from_input): Don't assume that the document is starting with an 'abi-corpus' element. Support the mode where a caller called the xmlTextReaderExpand function (and so we are given an expanded xmlNodePtr) and the mode where we need to use the xmlTextReader API to walk through the 'abi-corpus' element. Also, if we are building a corpus group, do not clear what used to be 'per-corpus' data. That data must be shared by all the corpora of a given abi-corpus-group. (read_corpus_group_from_input, read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Define new functions. * include/abg-tools-utils.h (FILE_TYPE_XML_CORPUS_GROUP): New enumerator of the file_type enum. * src/abg-tools-utils.cc (operator<<): In the overload for file_type, add a case for the new FILE_TYPE_XML_CORPUS_GROUP. (guess_file_type): Dectect abi-corpus-group xml element. * tools/abidiff.cc (adjust_diff_context_for_kmidiff): Define new static function. (main): Adjust to handle the new FILE_TYPE_XML_CORPUS_GROUP. That is, compare two FILE_TYPE_XML_CORPUS_GROUP if they are present. * tools/abilint.cc (main): Likewise. * tools/kmidiff.cc (main): Detect that one of two .kmi files are passed. In that case, load the .kmi file(s), build a corpus_group of it and use it in the comparison. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-07 21:06:14 +00:00
opts.suppression_paths,
opts.kabi_whitelist_paths,
opts.read_time_supprs,
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
opts.verbose, env,
requested_fe_kind);
Initial support of de-serializing the KMI of a Linux Kernel Tree With this patch, kmidiff knows how to compare a serialized corpus_group that represents a Kernel Module Interface (a .kmi file) against either another serialized .kmi file, or against a kernel tree. The patch extends the abixml reader to make it parse an 'abi-corpus-group' element. To do that, the patch modifies read_corpus_from_input to make it be capable of parsing several 'abi-corpus' in a row. That modified function is then used by a new read_corpus_group_from_input, which is itself used by the new public entry points read_corpus_group_from_native_xml_file and read_corpus_group_from_native_xml. With that read_corpus_group_from_native_xml_file building block function, the kmidiff program is modified so that it can take either two directory trees, two .kmi files or one directory tree and one .kmi file. * include/abg-libxml-utils.h (advance_to_next_sibling_element): Declare new function. * src/abg-libxml-utils.cc (go_to_next_sibling_element_or_stay) (advance_to_next_sibling_element): Define new functions. * include/abg-reader.h (read_corpus_group_from_input) (read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Declare new functions. * src/abg-reader.cc (read_context::m_corpus_group): New data member. (read_context::{get_corpus_group, set_corpus_group}): Define new member functions. (read_translation_unit_from_input): Cleanup logic. (read_corpus_from_input): Don't assume that the document is starting with an 'abi-corpus' element. Support the mode where a caller called the xmlTextReaderExpand function (and so we are given an expanded xmlNodePtr) and the mode where we need to use the xmlTextReader API to walk through the 'abi-corpus' element. Also, if we are building a corpus group, do not clear what used to be 'per-corpus' data. That data must be shared by all the corpora of a given abi-corpus-group. (read_corpus_group_from_input, read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Define new functions. * include/abg-tools-utils.h (FILE_TYPE_XML_CORPUS_GROUP): New enumerator of the file_type enum. * src/abg-tools-utils.cc (operator<<): In the overload for file_type, add a case for the new FILE_TYPE_XML_CORPUS_GROUP. (guess_file_type): Dectect abi-corpus-group xml element. * tools/abidiff.cc (adjust_diff_context_for_kmidiff): Define new static function. (main): Adjust to handle the new FILE_TYPE_XML_CORPUS_GROUP. That is, compare two FILE_TYPE_XML_CORPUS_GROUP if they are present. * tools/abilint.cc (main): Likewise. * tools/kmidiff.cc (main): Detect that one of two .kmi files are passed. In that case, load the .kmi file(s), build a corpus_group of it and use it in the comparison. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-07 21:06:14 +00:00
print_kernel_dist_binary_paths_under(opts.kernel_dist_root2, opts);
}
else if (ftype == FILE_TYPE_XML_CORPUS_GROUP)
group2 =
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
abixml::read_corpus_group_from_abixml_file(opts.kernel_dist_root2,
env);
Support loading and comparing two kernel trees * include/abg-dwarf-reader.h (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table) (get_ignore_symbol_table): Declare new functions. * abg-dwarf-reader.cc (read_context::options_type): Define new type. (die_dependant_container_set::clear): Define new member function. (read_context::{bss, tesxt, rodata, data, data1}_section_): Add new data members. (read_context::{symbol_versionning_sections_loaded_, symbol_versionning_sections_found_}): Likewise. (read_context::corpus_group_): Likewise. (read_context::{load_in_linux_kernel_mode, load_all_types, show_stats, do_log_}): Replace these options by .. (read_context::options_): ... this instance of the new read_context:options_type. (read_context::read_context): Adjust. (read_context::{clear_alt_debug_info_data, clear_per_corpus_data, env, get_data_section_for_variable_address, load_all_types, load_in_linux_kernel_mode, show_stats, do_log}): Adjust. (create_read_context): Adjust. (read_context::~read_context): Define destructor. (read_context::{options, bss_section, text_section, rodata_section, data_section, data1_section, current_corpus_group, has_corpus_group, main_corpus_from_current_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Define new member functions. (read_context::get_die_qualified_type_name): Handle the name of the current translation unit. (read_context::load_symbol_maps): Really don't load (linux kernel specific) symbol maps if we were told to ignore the ELF symbol table. (set_ignore_symbol_table, get_ignore_symbol_table) (create_default_var_sym, create_default_fn_sym, add_symbol_to_map) (set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Define new functions. (build_type_decl, build_typedef_type, build_enum_type) (add_or_update_class_type) (add_or_update_union_type): Reuse the type being built, from the main corpus of the corpus group. (build_qualified_type): Cleanup logic. (build_var_decl, build_function_decl): Create a default symbol for the variable or function if we are supposed to ignore the symbol table of the current binary. Add that symbol to the symbol table that is created in the read context. (read_debug_info_into_corpus): Don't load the ELF symbol table information if we are asked to ignore the symbol table. But set the symbol table that we built artificially while loading functions and variables, into the ABI corpus being built. (read_context::maybe_adjust_var_sym_address): Adjust. (build_ir_node_from_die): Add ir node to its logical scope. For the C language, the scope of a type is the global scope. (read_corpus_from_elf): Don't load ELF properties if we were asked to avoid the ELF symbol table. * include/abg-comparison.h (compute_diff): Declare ... * src/abg-comparison.cc (compute_diff): ... an overload to compare corpus_group. * tools/kmidiff.cc: New tool. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-03 09:00:57 +00:00
}
abidiff_status status = abigail::tools_utils::ABIDIFF_OK;
if (group1 && group2)
{
diff_context_sptr diff_ctxt(new diff_context);
set_diff_context(diff_ctxt, opts);
corpus_diff_sptr diff= compute_diff(group1, group2, diff_ctxt);
if (diff->has_net_changes())
status = abigail::tools_utils::ABIDIFF_ABI_CHANGE;
if (diff->has_incompatible_changes())
status |= abigail::tools_utils::ABIDIFF_ABI_INCOMPATIBLE_CHANGE;
if (diff->has_changes())
diff->report(cout);
}
else
status = abigail::tools_utils::ABIDIFF_ERROR;
return status;
}