libabigail/tools/kmidiff.cc

470 lines
13 KiB
C++
Raw Normal View History

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 notice for all source files Happy New Year 2018, I guess :-) * update-copyright.sh: New sed-based script to update the year in the copyright notice. * include/abg-comp-filter.h: Updated the year in the copyright notice. * 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-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-default-reporter.cc: Likewise. * src/abg-diff-utils.cc: Likewise. * src/abg-dwarf-reader.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-libzip-utils.cc: Likewise. * src/abg-reader.cc: Likewise. * src/abg-reporter-priv.cc: Likewise. * src/abg-reporter-priv.h: Likewise. * src/abg-sptr-utils.cc: 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/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-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-ir-walker.cc: Likewise. * tests/test-lookup-syms.cc: Likewise. * tests/test-read-dwarf.cc: Likewise. * tests/test-read-write.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. * 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/kmidiff.cc: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-01-08 16:54:56 +00:00
// Copyright (C) 2017-2018 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
//
// This file is part of the GNU Application Binary Interface Generic
// Analysis and Instrumentation Library (libabigail). This library is
// free software; you can redistribute it and/or modify it under the
// terms of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 3, or (at your option) any
// later version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this program; see the file COPYING-LGPLV3. If
// not, see <http://www.gnu.org/licenses/>.
//
// Author: Dodji Seketeli
/// @file
///
/// The source code of the Kernel Module Interface Diff tool.
#include <sys/types.h>
#include <dirent.h>
#include <fts.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;
using namespace abigail::tools_utils;
using namespace abigail::dwarf_reader;
using namespace abigail::ir;
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;
using abigail::tools_utils::gen_suppr_spec_from_kernel_abi_whitelist;
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;
using abigail::xml_reader::read_corpus_group_from_native_xml_file;
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;
bool leaf_changes_only;
bool show_impacted_interfaces;
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(),
leaf_changes_only(true),
show_impacted_interfaces(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
{}
}; // 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"
<< " --debug-info-dir2|--d2 <path> the root for the debug info of "
"the second kernel"
<< " --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"
<< " --impacted-interfaces|-i show interfaces impacted by ABI changes\n"
<< " --full-impact|-f show the full impact of changes on top-most "
"interfaces\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;
}
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;
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_added_fns(false);
ctxt->show_added_vars(false);
ctxt->show_added_symbols_unreferenced_by_debug_info
(false);
ctxt->show_symbols_unreferenced_by_debug_info
(true);
ctxt->show_leaf_changes_only(opts.leaf_changes_only);
ctxt->show_impacted_interfaces(opts.show_impacted_interfaces);
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;
}
environment_sptr env(new environment);
corpus_group_sptr group1, group2;
char *di_dir1 = 0, *di_dir2 = 0;
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)
{
di_dir1 = 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,
di_dir1,
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,
opts.verbose,
env);
print_kernel_dist_binary_paths_under(opts.kernel_dist_root1, opts);
}
else if (ftype == FILE_TYPE_XML_CORPUS_GROUP)
group1 =
read_corpus_group_from_native_xml_file(opts.kernel_dist_root1,
env.get());
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)
{
di_dir2 = 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,
di_dir2,
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,
opts.verbose,
env);
print_kernel_dist_binary_paths_under(opts.kernel_dist_root2, opts);
}
else if (ftype == FILE_TYPE_XML_CORPUS_GROUP)
group2 =
read_corpus_group_from_native_xml_file(opts.kernel_dist_root2,
env.get());
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;
}