libabigail/include/abg-corpus.h

322 lines
7.0 KiB
C
Raw Normal View History

// -*- mode: C++ -*-
//
Update copyright years * include/abg-comp-filter.h: Update copyright years. * 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-ir.h: Likewise. * include/abg-libxml-utils.h: Likewise. * include/abg-libzip-utils.h: Likewise. * include/abg-reader.h: Likewise. * include/abg-sptr-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-writer.h: Likewise. * src/abg-comp-filter.cc: Likewise. * src/abg-comparison.cc: Likewise. * src/abg-config.cc: Likewise. * src/abg-corpus.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-ir.cc: Likewise. * src/abg-libxml-utils.cc: Likewise. * src/abg-libzip-utils.cc: Likewise. * src/abg-reader.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-writer.cc: Likewise. * tests/print-diff-tree.cc: Likewise. * tests/test-abidiff.cc: Likewise. * tests/test-alt-dwarf-file.cc: Likewise. * tests/test-core-diff.cc: Likewise. * tests/test-diff-dwarf.cc: Likewise. * tests/test-diff-filter.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-utils.cc: Likewise. * tests/test-utils.h: Likewise. * tests/test-write-read-archive.cc: Likewise. * tools/abg-tools-utils.cc: Likewise. * tools/abg-tools-utils.h: Likewise. * tools/abiar.cc: Likewise. * tools/abidiff.cc: Likewise. * tools/abidw.cc: Likewise. * tools/abilint.cc: Likewise. * tools/abisym.cc: Likewise. * tools/binilint.cc: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-01-07 12:53:58 +00:00
// Copyright (C) 2013-2015 Red Hat, Inc.
//
// 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/>.
/// @file
#ifndef __ABG_CORPUS_H__
#define __ABG_CORPUS_H__
#include <abg-ir.h>
namespace abigail
{
Introduce/use translation_unit & global_scope types * abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove. (abi_corpus::add): New function to add a translation unit. (abi_corpus::get_translation_units): New declaration. * abg-corpus.cc (abi_corpus::*): Remove all the definitions of abi_corpus for now, as the abi_corpus type is not used anymore -- for now at least. * src/abg-ir.h (add_decl_to_scope, get_global_scope) (get_translation_unit, is_global_scope, is_decl_at_global_scope) (class translation_unit, class global_scope): New declarations * src/abg-ir.cc (translation_unit::translation_unit) (translation_unit::get_global_scope) (translation_unit::get_loc_mgr, translation_unit::get_loc_mgr) (translation_unit::is_empty, get_global_scope) (get_translation_unit, is_global_scope, is_global_scope) (is_decl_at_global_scope, global_scope::~global_scope): New definitions. (scope_decl::scope_decl, scope_decl::scope_decl) (scope_decl::add_member_decl, scope_decl::get_member_decls): Move to abg-ir.h, inline. * src/abg-reader.h (read_file): Don't use abi_corpus in the api. Rather, use translation_unit. * src/abg-reader.cc (read_context::get_cur_scope): Now that we have a specific instance of global_scope to represent global scope, don't play games with empty scopes to detect a global scope. (read_context::get_translation_unit): New definition. (read_context::finish_decl_creation, finish_type_decl_creation): (read_input, read_file, read_location, handle_element) (handle_type_decl) (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl): Don't use abi_corpus anymore. Rather, the translation unit a decl belongs to is accessible from the decl itself. * src/abg-writer.h (write_to_ostream): Use translation_unit in this API, rather than abi_corpus. * src/abg-writer.cc (write_translation_unit): Rename write_corpus into this. And stop using abi_corpus here. (write_to_ostream, write_corpus, write_location, write_decl) (write_type_decl, write_namespace_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl, write_var_decl): Stop using abi_corpus. Use the translation_unit that is accessible from the decl being serialized, if need be. * test-read-write.cc (main): De-serialize the input into an instance of translation_unit, not an abi_corpus anymore, and serialize that translation_unit.
2013-04-03 12:36:22 +00:00
namespace ir
{
Prepare serialization API for multiple backends * include/abg-reader.h: New file with abigail::xml_reader APIs. * include/abg-writer.h: New file with abigail::xml_writer APIs. * include/Makefile.am: Add the new files above to the source distribution. * src/abg-reader.cc: Update top-file comments. (namespace xml_reader): Rename namespace reader into this. (read_to_translation_unit, read_corpus_from_archive): New static functions. (read_translation_unit_from_file) (read_translation_unit_from_file, read_corpus_from_file): New entry points. (struct array_deleter): New functor. (translation_unit::read): Remove this. * src/abg-writer.cc: Update top file comments. (namespace xml_writer): Rename namespace writer into this. (struct archive_write_ctxt): New internal type. (create_archive_write_context, write_translation_unit_to_archive) (write_translation_unit, write_corpus_to_archive): New low level static functions overloads. (write_corpus_to_archive, write_translation_unit): Public higher level overloads. (translation_unit::write): Remove. (dump): Update for new xml_writer namespace. * include/abg-ir.h (translation_unit::{read, write}): Remove these serialization methods. * include/abg-corpus.h (corpus_sptr): New convenience typedef. (corpus::{read, write}): Remove these methods. * src/abg-corpus.cc (corpus::{read, write}) (corpus::impl::{serialized_tus, archive}): Remove these members. (corpus::impl::{get_archive, close_archive, write_tu_to_archive, read_to_translation_unit}): Remove these methods. * tests/test-bidiff.cc (main): Update for usage of the new xml_reader API. * tests/test-read-write.cc (main): Likewise. Update for the usage of the new xml_writer API, too. * tests/test-walker.cc (main): Update for the usage of the new xml_reader API. * tests/test-write-read-archive.cc (main): Likewise. And for the xml_writer API, too. * tools/biar.cc (add_tus_to_archive, extract_tus_from_archive): Likewise. * tools/bidiff.cc (main): Likewise, for xml_reader APIs. * tools/bilint.cc (main): Likewise, for xml_writer APIs, too. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-04 08:44:20 +00:00
class corpus;
/// A convenience typedef for shared pointer to @ref corpus.
typedef shared_ptr<corpus> corpus_sptr;
Introduce/use translation_unit & global_scope types * abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove. (abi_corpus::add): New function to add a translation unit. (abi_corpus::get_translation_units): New declaration. * abg-corpus.cc (abi_corpus::*): Remove all the definitions of abi_corpus for now, as the abi_corpus type is not used anymore -- for now at least. * src/abg-ir.h (add_decl_to_scope, get_global_scope) (get_translation_unit, is_global_scope, is_decl_at_global_scope) (class translation_unit, class global_scope): New declarations * src/abg-ir.cc (translation_unit::translation_unit) (translation_unit::get_global_scope) (translation_unit::get_loc_mgr, translation_unit::get_loc_mgr) (translation_unit::is_empty, get_global_scope) (get_translation_unit, is_global_scope, is_global_scope) (is_decl_at_global_scope, global_scope::~global_scope): New definitions. (scope_decl::scope_decl, scope_decl::scope_decl) (scope_decl::add_member_decl, scope_decl::get_member_decls): Move to abg-ir.h, inline. * src/abg-reader.h (read_file): Don't use abi_corpus in the api. Rather, use translation_unit. * src/abg-reader.cc (read_context::get_cur_scope): Now that we have a specific instance of global_scope to represent global scope, don't play games with empty scopes to detect a global scope. (read_context::get_translation_unit): New definition. (read_context::finish_decl_creation, finish_type_decl_creation): (read_input, read_file, read_location, handle_element) (handle_type_decl) (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl): Don't use abi_corpus anymore. Rather, the translation unit a decl belongs to is accessible from the decl itself. * src/abg-writer.h (write_to_ostream): Use translation_unit in this API, rather than abi_corpus. * src/abg-writer.cc (write_translation_unit): Rename write_corpus into this. And stop using abi_corpus here. (write_to_ostream, write_corpus, write_location, write_decl) (write_type_decl, write_namespace_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl, write_var_decl): Stop using abi_corpus. Use the translation_unit that is accessible from the decl being serialized, if need be. * test-read-write.cc (main): De-serialize the input into an instance of translation_unit, not an abi_corpus anymore, and serialize that translation_unit.
2013-04-03 12:36:22 +00:00
/// This is the abstraction of a set of translation units (themselves
/// seen as bundles of unitary abi artefacts like types and decls)
/// bundled together as a corpus. A corpus is thus the Application
/// binary interface of a program, a library or just a set of modules
/// put together.
class corpus
{
public:
Build the set of exported decls directly during DWARF loading Until now, after the ABI corpus was built from DWARF, the translation units of the corpus were walked and each function was considered for addition into the set of exported decls. During that walking, a first version of the set was put into a std::list and then, a set of filters (user-provided tunables like a list of regular expressions to keep or remove some functions from the exported decls) is applied to that list and the final set of exported decls is put in a std::vector. Profiling has shown that this process of building the set of exported decls is a hot spot and also that the current use of std::list was a big memory consumer especially on binaries with large exported symbol tables. So this patch builds the set of exported decls "on the fly", during DWARF reading, as opposed to waiting after the DWARF is read and having to walk the corpus again. The corpus defines a policy object that encapsulates the methods for determining if a function or variable ought to be part of the set of exported decls. The DWARF reader uses that policy object to determine which functions and variables among those built during the reading ought be part of the exported decls; the policy object also has a reference to the final vector (managed by the corpus) that must hold the exported decls, so the decls are put in that vector directly without unnecessary copying. Profiling also showed that the string copying done by {var_decl,function_decl}::get_id() was a hot spot. So the patch returns a reference there. With this patch applied, the peak memory consumption of abidiff on libabigail.so itself (abidiff libabigail.so libabigail.so) is 54MB of resident and takes 2 minutes and 16s (on my slow system). Without the patch the peak consumption was more than 300MB and it was taking slightly longer. For the test of bug https://sourceware.org/bugzilla/show_bug.cgi?id=17948, memory consumtion and wall clock time spent is down from 3.4GB and 1m59s to 760MB and 0m43s. * include/abg-ir.h ({var,function}_decl::get_id): Return a reference. * src/abg-ir.cc ({var,function}_decl::get_id): Return a reference to the string rather than copying it over. * include/abg-corpus.h (class corpus::exported_decls_builder): Declare new type. (corpus::{sort_functions, sort_variables, maybe_drop_some_exported_decls, get_exported_decls_builder}): Declare new methods. * src/abg-corpus.h (corpus::exported_decls_builder::priv): Define new type. (class symtab_build_visitor_type): Remove this type that is useless now. (corpus::exported_decls_builder::{exported_decls_builder, exported_functions, exported_variables, maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}): Define new functions. (corpus::priv::is_public_decl_table_built): Remove this data member. It's now useless. (corpus::priv::priv): Adjust. (corpus::priv::build_public_decl_table): Remove this member function. It's now useless. (corpus::{priv::build_unreferenced_symbols_tables, get_functions, get_variables}): No need to build the public decls table here. It's already built by the time the corpus is read from DWARF now. (corpus::{sort_functions, sort_variables, maybe_drop_some_exported_decls, get_exported_decls_builder}): Define new member functions. * src/abg-dwarf-reader.cc (read_context::exported_decls_builder): New data member. (read_context::read_context): Initialize it. (read_context::{exported_decls_builder, maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}): Define new member functions. (read_debug_info_into_corpus): Get the the new 'exported_decls_builder' object from the corpus and stick it into the read context so the DWARF reading code can use it to build the exported decls set. When the DWARF reading is done, sort the set of exported functions and variables that was built. (build_ir_node_from_die): When a function or variable is built, consider putting it into the set of exported decls. * tools/abicompat.cc (main): Now that the exported decls is built *before* we had a chance to stick the list of symbol IDs to keep, call corpus::maybe_drop_some_exported_decls() to update the set of exported decls we should consider for the corpus. was applied to that list and the final Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-23 19:39:32 +00:00
struct priv;
/// Convenience typedef for shared_ptr of corpus::priv
typedef shared_ptr<priv> priv_sptr;
/// A convenience typedef for std::vector<string>.
typedef vector<string> strings_type;
/// Convenience typedef for std::vector<abigail::ir::function_decl*>
typedef vector<function_decl*> functions;
///Convenience typedef for std::vector<abigail::ir::var_decl*>
typedef vector<var_decl*> variables;
class exported_decls_builder;
/// Convenience typedef for shared_ptr<exported_decls_builder>.
typedef shared_ptr<exported_decls_builder> exported_decls_builder_sptr;
/// This abstracts where the corpus comes from. That is, either it
/// has been read from the native xml format, from DWARF or built
/// artificially using the library's API.
enum origin
{
ARTIFICIAL_ORIGIN = 0,
NATIVE_XML_ORIGIN,
DWARF_ORIGIN
};
private:
Initial support for diffing ABI corpus files * include/abg-comparison.h (string_function_ptr_map) (changed_function_ptr, string_changed_function_ptr_map) (corpus_diff_sptr): New convenience typedefs. (translation_unit_diff): Add comments. (class corpus_diff): New type. (compute_diff): New overload for corpus_diff. * include/abg-corpus.h (corpus::{functions, variables}): New typedefs. (corpus::{operator==, get_functions, get_variables}): New members. * include/abg-diff-utils.h (struct deep_ptr_eq_functor): New functor. * include/abg-ir.h (translation_unit::operator==): New member equality operator. * src/abg-comparison.cc (struct corpus_diff::priv): New private struct holding the private members of corpus_diff. (corpus_diff::priv::{lookup_tables_empty, clear_lookup_tables, ensure_lookup_tables_populated}): Define new private member functions. (corpus_diff::{corpus_diff, first_corpus, second_corpus, function_changes, variable_changes, length, report}): New public members. (struct noop_deleter): New struct. (compute_diff): New implementation for corpus_diff. * src/abg-corpus.cc (struct corpus::priv): Renamed corpus::impl into this. Add new fns, vars and is_symbol_table_built data members. (corpus::priv::build_symbol_table): New member function. (class symtab_build_visitor_type): New visitor type to build the symbol table. (struct func_comp, struct var_comp): New comparison functors. (corpus::priv::build_symbol_table): Define new member function. (corpus::{corpus, add, get_translation_units, operator==, get_functions, get_variables}): Define new members. * src/abg-ir.cc (translation_unit::operator==): Define new member equality operator. (operator==(translation_unit_sptr l, translation_unit_sptr r)): Define new equality operator. * tools/abg-tools-utils.h (enum file_type): New enum. (guess_file_type): Declare new function. * tools/abg-tools-utils.cc (guess_file_type): define new function. * tools/bidiff.cc (main): Guess the type of the files given in input and support elf files reading and diffing. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-23 13:05:19 +00:00
shared_ptr<priv> priv_;
corpus();
public:
Introduce the concept of environment There are resources needed by the type system and other artifacts of libabigail. Today, when the life time of those resources need to be greater than all of artifacts of Abigail, then said resources are made global. But then global resources are not great, if anything because they complicate the future use of the library in concurrent computing setups. As I was in the need to add one resource to be used by the type system, I decided to sit down and first overhaul how these long lived resources needed to be handled. And here comes the concept of "environment". An environment is a place where one can put resources that need to live longer than all the other artifacts of the Abigail system. And so, the code that creates Abigail artifacts needs and environment of for said artifacts to use. In other words, artifacts now use an environment. This has interesting and strong implications. We can only compare two artifacts if they use the same environment. This is quite a strong requirement. But then when this requirement is fulfilled, comparing two types amounts to just comparing two pointer values; hash values for types can also be cached. Now *that* is great for speed of comparison, is it not? This patch introduce the concept environment (which is basically a new abigail::ir::environment type), removes the global variables and uses the environment instead. Each ABI artifact (either type or decl) now has a ::get_environment() member function to get its environment. This patch also disables the caching of hash values because the caching must happen only *after* all types have been canonicalized. We were not respecting that requirement until now, and that introduces wrong hash values. A subsequent patch is going to re-introduce hash value caching again, once the infrastructure is in place to set a flag in the environment (hah!) once type canonicalization is done, and then later read that flag when some client code requests a hash value, to know if we should look in the hash value cache or not. The patch obviously changes the output of numerous regression tests (if anything b/c it disables hash value caching) so 'make check' yields regressions. But then, it's only the subsequent patch that updates the tests. * include/abg-ir.h: Adjust note about memory management. (class environment): Declare new class. (translation_unit::translation_unit): Take an environment in parameter. (translation_unit::{g,s}et_environment): Declare new member functions. (type_or_decl_base::{g,s}et_environment): Likewise. (type_or_decl_base::{get_cached_hash_value, set_cached_hash_value}): Change the name of decl_base::peek_hash_value() and decl_base::set_hash() here into these and move them here. (type_or_decl_base::hashing_started): Move decl_base::hashing_started() here. ({g,s}et_environment_for_artifact): Declare new functions. (class decl_base): Move member functions hashing_started(), peek_hash_value() and set_hash() on to the type_or_decl_base base class. (scope_decl::scope_decl): Initialize the virtual member type_or_decl_base(). (type_decl::{get_void_type_decl, get_variadic_parameter_type_decl}): Remove these static member functions. They are now non-static member functions of the new environment type. * src/abg-ir.cc (class environment_setter): New internal class. (get_canonical_types_map): Remove. This now becomes a member function of the environment type. (class usage_watchdog): Remove. (usage_watchdog_{s,w}ptr): Remove these typedefs. (get_usage_watchdog_wptr, ref_usage_watchdog) (maybe_cleanup_type_system_data): Remove these functions. (translation_unit::priv::usage_watchdog_): Remove data member. (translation_unit::priv::env_): New data member. (translation_unit::priv::priv): Take an environment and initialize the new env_ data member. Do not initialize the removed usage_watchdog_. (translation_unit::translation_unit): Take an environment parameter. (translation_unit::get_global_scope): Set the environment of a new global scope. (translation_unit::{g,s}et_environment): New accessors. (translation_unit::bind_function_type_life_time): Set the environment of the function type. (struct environment::priv): New class. (environment::{environment, ~environment, get_canonical_types_map, get_variadic_parameter_type_decl, canonicalization_is_done}): New member functions. (struct type_or_decl_base::priv): New class. (type_or_decl_base::{type_or_decl_base, hashing_started, get_cached_hash_value, set_cached_hash_value, set_environment, get_environment, traverse}): New member functions. ({s,g}get_environment_for_artifact): New functions. (decl_base::priv::{hash_, hashing_started}): Remove. (decl_base::priv::priv): Adjust. (decl_base::decl_base): In the copy constructor, initialize the virtual base type_or_decl_base. Do not initialize hash_ and hashing_started data member that got removed. (decl_base::{hashing_started, peek_hash_value, set_hash}): Remove member functions. (strip_typedef): Set the environment of the new type which has its typedefs stripped off. Adjust the call to type_or_void(). (scope_decl::{add, insert}_member_decl): Set the environment of the new member decl to the environment of its scope. (synthesize_type_from_translation_unit) (synthesize_function_type_from_translation_unit): Set the environment for the newly synthesized type. Adjust calls to type_or_void(). (type_or_void): Take an environment in parameter. Get the void type from the environment. (get_canonical_types_map): Remove. (type_base::get_canonical_type_for): Get the canonical types map from the environment, not from a global variable. (type_decl::{get_void_type_decl, get_variadic_parameter_type_decl}): Remove. (pointer_type_def::pointer_type_def): Adjust call to type_or_void. (reference_type_def::reference_type_def): Likewise. (function_decl::parameter::get_pretty_representation): Get the variadic parameter type decl from the environment. (class_decl::priv::classes_being_compared_): Remove static data member. (class_decl::priv::{mark_as_being_compared, unmark_as_being_compared, comparison_started): Use the "classes being compared" map from the environment. (class_decl::base_spec::get_hash): Adjust. (keep_type_alive): Get the alive types array from the environment) not from a global variable anymore. (get_next_string): Put the counter in thread-local storage. * src/abg-hash.cc (scope_decl::hash::operator()) (function_decl::hash::operator()): Do not handle caching (here). * include/abg-corpus.h (corpus::{g,s}et_environment): Declare new accessors. * src/abg-corpus.cc (corpus::priv::env): New data member. (corpus::priv::priv): Initialize it. (corpus::corpus): Take an environment in parameter. (corpus::{g,s}et_environment): Define new member functions (corpus::add): Set the environment of the newly added translation unit, if it's not set already set. In any case, assert that the translation unit must use the same environment as the corpus. * include/abg-dwarf-reader.h (create_read_context) (read_corpus_from_elf): Take an environment parameter. ({s,g}et_debug_info_root_path, {s,g}et_environment): Declare new functions. * src/abg-dwarf-reader.cc (read_context::{env_, offline_callbacks_}): New data members. (read_context::read_context): Initialize them. (read_context::clear_per_translation_unit_data): Do not touch the void type declaration, it doesn't belong to the translation unit. (read_context::{env, offline_callbacks}): New accessors. (read_context::{create_default_dwfl}): New member function. (read_context::dwfl_handle): Add a setter overload. ({s,g}et_debug_info_root_path): Define new accessors. (create_default_dwfl, create_dwfl_sptr, create_default_dwfl_sptr): Remove these. (build_translation_unit_and_add_to_ir): Adjust to pass the environment to the newly created translation unit. (build_function_decl): Adjust to pass the environment to the created function and parameter types. Get variadic parameter type node from the current environment, not from a global variable. And do not try to canonicalize function types here. (read_debug_info_into_corpus): Set the environment of the newly created corpus. (build_ir_node_for_void_type): Get the void type node from the current environment, rather than from a global variable. (create_read_context): Take the environment in parameter. Create the default dwarf front end library handle using the new member function of the read context. Set the current environment used by the reader. (read_corpus_from_elf): Take an environment in parameter. Overhaul. This is now simpler. (has_alt_debug_info): Adjust the call to create_read_context() to make it pass an empty environment. * include/abg-fwd.h (class environment): Forward declare. * include/abg-reader.h (read_translation_unit_from_file) (read_translation_unit_from_buffer) (read_translation_unit_from_istream) (read_corpus_from_native_xml): Take an environment in parameter. * src/abg-reader.cc (read_context::m_env): New data member. (read_context::read_context): Initialize it. (read_context::{get_environment, set_environment}): New data member. (read_translation_unit): Set environment of the new translation unit. (read_corpus_from_input): Set the environment of the new corpus. (read_translation_unit_from_file) (read_translation_unit_from_buffer) (read_translation_unit_from_istream, read_corpus_from_native_xml): Take an environment in parameter. (build_function_parameter): Get variadic parameter type from the environment. * src/abg-comparison.cc (compute_diff): Add asserts in all the overloads to ensure that the artifact being compared come from the same environment. * tests/print-diff-tree.cc (main): Create an env for the ABI artifacts to use. * tests/test-abidiff.cc (main): Likewise. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-ir-walker.cc (main): Likewise. * tests/test-read-dwarf.cc (main): Likewise. * tests/test-read-write.cc (main): Likewise. * tools/abicompat.cc (main): Likewise. * tools/abidiff.cc (main): Likewise. * tools/abidw.cc (main): Likewise. * tools/abilint.cc (main): Likewise. * tools/abipkgdiff.cc (main): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-09-07 20:27:50 +00:00
corpus(const string&, ir::environment*);
environment*
get_environment();
const environment*
get_environment() const;
void
set_environment(environment*) const;
void
add(const translation_unit_sptr);
const translation_units&
Introduce/use translation_unit & global_scope types * abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove. (abi_corpus::add): New function to add a translation unit. (abi_corpus::get_translation_units): New declaration. * abg-corpus.cc (abi_corpus::*): Remove all the definitions of abi_corpus for now, as the abi_corpus type is not used anymore -- for now at least. * src/abg-ir.h (add_decl_to_scope, get_global_scope) (get_translation_unit, is_global_scope, is_decl_at_global_scope) (class translation_unit, class global_scope): New declarations * src/abg-ir.cc (translation_unit::translation_unit) (translation_unit::get_global_scope) (translation_unit::get_loc_mgr, translation_unit::get_loc_mgr) (translation_unit::is_empty, get_global_scope) (get_translation_unit, is_global_scope, is_global_scope) (is_decl_at_global_scope, global_scope::~global_scope): New definitions. (scope_decl::scope_decl, scope_decl::scope_decl) (scope_decl::add_member_decl, scope_decl::get_member_decls): Move to abg-ir.h, inline. * src/abg-reader.h (read_file): Don't use abi_corpus in the api. Rather, use translation_unit. * src/abg-reader.cc (read_context::get_cur_scope): Now that we have a specific instance of global_scope to represent global scope, don't play games with empty scopes to detect a global scope. (read_context::get_translation_unit): New definition. (read_context::finish_decl_creation, finish_type_decl_creation): (read_input, read_file, read_location, handle_element) (handle_type_decl) (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl): Don't use abi_corpus anymore. Rather, the translation unit a decl belongs to is accessible from the decl itself. * src/abg-writer.h (write_to_ostream): Use translation_unit in this API, rather than abi_corpus. * src/abg-writer.cc (write_translation_unit): Rename write_corpus into this. And stop using abi_corpus here. (write_to_ostream, write_corpus, write_location, write_decl) (write_type_decl, write_namespace_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl, write_var_decl): Stop using abi_corpus. Use the translation_unit that is accessible from the decl being serialized, if need be. * test-read-write.cc (main): De-serialize the input into an instance of translation_unit, not an abi_corpus anymore, and serialize that translation_unit.
2013-04-03 12:36:22 +00:00
get_translation_units() const;
Initial writing/reading of an ABI corpus to an archive * configure.ac: Support detection of libzip dependency. Define new DEPS_CFLAGS and DEPS_LIBS variables for use in Makefile.am to refer to the dependency headers and libraries. * doc/website/mainpage.txt: Update this to talk about the new libzip dependency. * include/Makefile.am: Add abg-libzip-utils.h to the build system. * include/abg-corpus.h (corps): Hide abigail::corpus's private behind a pimpl idiom. (corpus::{drop_translation_units, get_file_path, set_file_path, write, read}): New methods. * include/abg-libxml-utils.h (new_reader_from_buffer): Declare new function. * include/abg-libzip-utils.h: New file. * src/Makefile.am: Add abg-corpus.cc and abg-libzip-utils.cc to the build system. Refer to the library and headers dependencies via the new DEPS_LIBS and DEPS_CFLAGS variables. * src/abg-corpus.cc: New file. * src/abg-ir.cc (translation::set_path): New method. * src/abg-libxml-utils.cc (new_reader_from_buffer): Define new function. * src/abg-libzip-utils.cc: New file. * src/abg-reader.cc (translation_unit::read): New overload. * src/abg-writer.cc: Inject the names from the std namespace into the abigail namespace, rather than into abigail::writer. (abigail::translation_unit::write): New overload. This can now use ofstream and the other stuff from std that are injected in the abigail:: namespace. * tests/Makefile.am: Add tests/test-write-read-archive.cc to the build system; use that to build runtestwritereadarchive. Also add the input test data from tests/data/test-write-read-archive/test[0-4].xml. * /tests/data/test-write-read-archive/test[0-4].xml: New test input data files. * tests/test-write-read-archive.cc: New test for this archive write/read support. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 13:18:59 +00:00
void
drop_translation_units();
origin
get_origin() const;
void
set_origin(origin);
Initial writing/reading of an ABI corpus to an archive * configure.ac: Support detection of libzip dependency. Define new DEPS_CFLAGS and DEPS_LIBS variables for use in Makefile.am to refer to the dependency headers and libraries. * doc/website/mainpage.txt: Update this to talk about the new libzip dependency. * include/Makefile.am: Add abg-libzip-utils.h to the build system. * include/abg-corpus.h (corps): Hide abigail::corpus's private behind a pimpl idiom. (corpus::{drop_translation_units, get_file_path, set_file_path, write, read}): New methods. * include/abg-libxml-utils.h (new_reader_from_buffer): Declare new function. * include/abg-libzip-utils.h: New file. * src/Makefile.am: Add abg-corpus.cc and abg-libzip-utils.cc to the build system. Refer to the library and headers dependencies via the new DEPS_LIBS and DEPS_CFLAGS variables. * src/abg-corpus.cc: New file. * src/abg-ir.cc (translation::set_path): New method. * src/abg-libxml-utils.cc (new_reader_from_buffer): Define new function. * src/abg-libzip-utils.cc: New file. * src/abg-reader.cc (translation_unit::read): New overload. * src/abg-writer.cc: Inject the names from the std namespace into the abigail namespace, rather than into abigail::writer. (abigail::translation_unit::write): New overload. This can now use ofstream and the other stuff from std that are injected in the abigail:: namespace. * tests/Makefile.am: Add tests/test-write-read-archive.cc to the build system; use that to build runtestwritereadarchive. Also add the input test data from tests/data/test-write-read-archive/test[0-4].xml. * /tests/data/test-write-read-archive/test[0-4].xml: New test input data files. * tests/test-write-read-archive.cc: New test for this archive write/read support. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 13:18:59 +00:00
string&
get_path() const;
Initial writing/reading of an ABI corpus to an archive * configure.ac: Support detection of libzip dependency. Define new DEPS_CFLAGS and DEPS_LIBS variables for use in Makefile.am to refer to the dependency headers and libraries. * doc/website/mainpage.txt: Update this to talk about the new libzip dependency. * include/Makefile.am: Add abg-libzip-utils.h to the build system. * include/abg-corpus.h (corps): Hide abigail::corpus's private behind a pimpl idiom. (corpus::{drop_translation_units, get_file_path, set_file_path, write, read}): New methods. * include/abg-libxml-utils.h (new_reader_from_buffer): Declare new function. * include/abg-libzip-utils.h: New file. * src/Makefile.am: Add abg-corpus.cc and abg-libzip-utils.cc to the build system. Refer to the library and headers dependencies via the new DEPS_LIBS and DEPS_CFLAGS variables. * src/abg-corpus.cc: New file. * src/abg-ir.cc (translation::set_path): New method. * src/abg-libxml-utils.cc (new_reader_from_buffer): Define new function. * src/abg-libzip-utils.cc: New file. * src/abg-reader.cc (translation_unit::read): New overload. * src/abg-writer.cc: Inject the names from the std namespace into the abigail namespace, rather than into abigail::writer. (abigail::translation_unit::write): New overload. This can now use ofstream and the other stuff from std that are injected in the abigail:: namespace. * tests/Makefile.am: Add tests/test-write-read-archive.cc to the build system; use that to build runtestwritereadarchive. Also add the input test data from tests/data/test-write-read-archive/test[0-4].xml. * /tests/data/test-write-read-archive/test[0-4].xml: New test input data files. * tests/test-write-read-archive.cc: New test for this archive write/read support. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 13:18:59 +00:00
void
set_path(const string&);
Initial writing/reading of an ABI corpus to an archive * configure.ac: Support detection of libzip dependency. Define new DEPS_CFLAGS and DEPS_LIBS variables for use in Makefile.am to refer to the dependency headers and libraries. * doc/website/mainpage.txt: Update this to talk about the new libzip dependency. * include/Makefile.am: Add abg-libzip-utils.h to the build system. * include/abg-corpus.h (corps): Hide abigail::corpus's private behind a pimpl idiom. (corpus::{drop_translation_units, get_file_path, set_file_path, write, read}): New methods. * include/abg-libxml-utils.h (new_reader_from_buffer): Declare new function. * include/abg-libzip-utils.h: New file. * src/Makefile.am: Add abg-corpus.cc and abg-libzip-utils.cc to the build system. Refer to the library and headers dependencies via the new DEPS_LIBS and DEPS_CFLAGS variables. * src/abg-corpus.cc: New file. * src/abg-ir.cc (translation::set_path): New method. * src/abg-libxml-utils.cc (new_reader_from_buffer): Define new function. * src/abg-libzip-utils.cc: New file. * src/abg-reader.cc (translation_unit::read): New overload. * src/abg-writer.cc: Inject the names from the std namespace into the abigail namespace, rather than into abigail::writer. (abigail::translation_unit::write): New overload. This can now use ofstream and the other stuff from std that are injected in the abigail:: namespace. * tests/Makefile.am: Add tests/test-write-read-archive.cc to the build system; use that to build runtestwritereadarchive. Also add the input test data from tests/data/test-write-read-archive/test[0-4].xml. * /tests/data/test-write-read-archive/test[0-4].xml: New test input data files. * tests/test-write-read-archive.cc: New test for this archive write/read support. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 13:18:59 +00:00
Support reading and comparing soname from ELF files Libabigail's DWARF reader doesn't read the DT_SONAME tag from the .dynamic section. The abigail::corpus type doesn't have a property for that tag either. And the comparison engine doesn't take that tag in when comparing corpora. This patch modifies the DWARF reader to read the DT_SONAME and DT_NEEDED tags from the .dynamic section. The value of DT_SONAME tag is then saved in the new corpus property accessed by the new abigail::corpus::get_soname() accessor. The comparison engine has also been modified to compare the sonames of two corpora being compared. Note that the value of the DT_NEEDED elf tag is saved in a new corpus property that is accessed via the new abigail::corpus::get_needed() getter. This property is not used yet. This patch also adds a unit test for this new feature. * include/abg-corpus.h (corpus::{get_needed, set_needed, get_soname, set_soname}): Declare new accessors. * src/abg-corpus.cc (corpus::priv::{needed, soname}): New data members. (corpus::{get_needed, set_needed, get_soname, set_soname}): Define new accessors. (corpus::is_empty): Take dt_needed and dt_soname in account in computing empty-ness. * src/abg-dwarf-reader.cc (read_context::{dt_needed_, dt_soname_}): New data members. (read_context::{dt_needed, dt_soname}): New accessors. (read_context::load_dt_soname_and_needed): New member function. (read_corpus_from_elf): Call the new read_context::load_dt_soname_and_needed() to read the dt_soname and dt_needed tags. Set them to the corpus. * include/abg-comparison.h (diff_context::show_soname_change): Declare new accessors. * src/abg-comparison.cc (diff_context::priv::show_soname_change_): New data member. (diff_context::priv::priv): Initialize the new data member diff_context::priv::show_soname_change_. (diff_context::show_soname_change): Define new accessors. (corpus_diff::priv::sonames_equal_): New data member. (corpus_diff::priv::priv): Initialize the new data member corpus_diff::priv::sonames_equal_. (corpus_diff::length): Take the new priv_->sonames_equals_ data member in account. (corpus_diff::{report, priv::emit_diff_stats}): If the sonames changed and we are allowed to report it, then report it. (compute_diff): In the variant for corpus_diff, do not forget to compare the sonames. * src/abg-reader.cc (build_needed, read_elf_needed_from_input): Define new static functions. (read_corpus_from_input): Read the 'soname' attribute from the 'abi-corpus' xml element node. * src/abg-writer.cc (write_elf_needed): Define new static function. (write_corpus_to_native_xml): Write a new 'elf-needed' xml element node that contains one xml 'dependency' element node per dependency to emit. This uses the new write_elf_needed() function above. * tests/data/test-diff-dwarf/libtest19-soname-v0.so: New test input data. * tests/data/test-diff-dwarf/libtest19-soname-v1.so: Likewise. * tests/data/test-diff-dwarf/test19-soname-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test19-soname-v0.c: Source code of the first binary above. * tests/data/test-diff-dwarf/test19-soname-v1.c: Source code of the second binary above. * tests/test-diff-dwarf.cc (in_out_specs): Add the test input above to the list of test input to run this harness on. * tests/data/Makefile.am: Add the new test input data above. * tests/data/test-read-dwarf/test{0,1}.abi: Adjust. * tests/data/test-read-dwarf/test{2,3,4,6,}.so.abi: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-07 20:01:20 +00:00
const vector<string>&
get_needed() const;
void
set_needed(const vector<string>&);
const string&
get_soname();
void
set_soname(const string&);
Detect and report changes in ELF architecture Libabigail does not take in account the architecture of the ELF file it reads. This patch changes that to represent the ELF architecture as a string, detect when that architecture changes accross two corpora being compared and emit a report about that change. * configure.ac: Detect the presence of libebl.a and add it to the list of library we depend on to build libabigail. Report when libelf.so is not found. * include/abg-comparison.h: (diff_context::show_architecture_change): Declare new accessors. (corpus_diff::architecture_changed): Declare new method. * include/abg-corpus.h (corpus::{get,set}_architecture_name): Declare new accessors. * src/abg-comparison.cc (diff_context::priv::show_architecture_change_): New data member. (diff_context::priv::priv): Initialize it. (diff_context::show_architecture_change): Define new accessors. (function_decl_diff::report): Report when the size/alignment of the function address changes. (corpus_diff::priv::architectures_equal_): New data member. (corpus_diff::priv::priv): Initialize it. (corpus_diff::priv::emit_diff_stats): Take in account changes of architecture. (corpus_diff::architecture_changed): Define new method. (corpus_diff::length): Take in account changes of architecture. (corpus_diff::report): Report about changes of architecture. (compute_diff): In the overload for corpus_diff_sptr, detect changes fo architecture. * src/abg-corpus.cc (corpus_priv::architecture_name): Define new data member. (corpus::{get,set}_architecture_name): Define new method. * src/abg-dwarf-reader.cc: Include elfutils/libebl.h to use ebl_openbackend() and ebl_backend_name() (read_context::elf_architecture_): Define new data member. (read_context::elf_architecture): Define new accessor. (read_context::{load_elf_architecture, load_remaining_elf_data}): Define new methods. (read_corpus_from_elf): Use ctxt.load_remaining_elf_data() in lieu of ctxt.load_dt_soname_and_needed. Stick the architecture into the corpus. * src/abg-reader.cc (read_corpus_from_input): Read the 'architecture' XML property. * src/abg-writer.cc (write_corpus_to_native_xml): Write the 'architecture' XML property. * tests/data/test-diff-dwarf/libtest-23-diff-arch-v0-32.so: New test input file. * tests/data/test-diff-dwarf/libtest-23-diff-arch-v0-64.so: Likewise. * tests/data/test-diff-dwarf/test-23-diff-arch-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test-23-diff-arch-v0.cc: Source code for the binary test input files above. * tests/data/Makefile.am: Add the new test input files to the source distribution. * tests/test-diff-dwarf.cc (in_out_specs): Add the new test input data to the set of input data to run this test harness over. * tests/test-read-dwarf.cc (main): Do not take the architecture in account during comparisons. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-01-07 12:45:53 +00:00
const string&
get_architecture_name();
void
set_architecture_name(const string&);
bool
is_empty() const;
Initial support for diffing ABI corpus files * include/abg-comparison.h (string_function_ptr_map) (changed_function_ptr, string_changed_function_ptr_map) (corpus_diff_sptr): New convenience typedefs. (translation_unit_diff): Add comments. (class corpus_diff): New type. (compute_diff): New overload for corpus_diff. * include/abg-corpus.h (corpus::{functions, variables}): New typedefs. (corpus::{operator==, get_functions, get_variables}): New members. * include/abg-diff-utils.h (struct deep_ptr_eq_functor): New functor. * include/abg-ir.h (translation_unit::operator==): New member equality operator. * src/abg-comparison.cc (struct corpus_diff::priv): New private struct holding the private members of corpus_diff. (corpus_diff::priv::{lookup_tables_empty, clear_lookup_tables, ensure_lookup_tables_populated}): Define new private member functions. (corpus_diff::{corpus_diff, first_corpus, second_corpus, function_changes, variable_changes, length, report}): New public members. (struct noop_deleter): New struct. (compute_diff): New implementation for corpus_diff. * src/abg-corpus.cc (struct corpus::priv): Renamed corpus::impl into this. Add new fns, vars and is_symbol_table_built data members. (corpus::priv::build_symbol_table): New member function. (class symtab_build_visitor_type): New visitor type to build the symbol table. (struct func_comp, struct var_comp): New comparison functors. (corpus::priv::build_symbol_table): Define new member function. (corpus::{corpus, add, get_translation_units, operator==, get_functions, get_variables}): Define new members. * src/abg-ir.cc (translation_unit::operator==): Define new member equality operator. (operator==(translation_unit_sptr l, translation_unit_sptr r)): Define new equality operator. * tools/abg-tools-utils.h (enum file_type): New enum. (guess_file_type): Declare new function. * tools/abg-tools-utils.cc (guess_file_type): define new function. * tools/bidiff.cc (main): Guess the type of the files given in input and support elf files reading and diffing. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-23 13:05:19 +00:00
bool
operator==(const corpus&) const;
Add a symbol database to the ABI Corpus & support symbol aliases * include/abg-corpus.h (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}): Declare new accessors. (corpus::lookup_{variable,function}_symbol): Declare new member functions. * src/abg-corpus.cc (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}): Define new accessors. (corpus::lookup_{variable,function}_symbol): Define new member functions. * include/abg-ir.h (string_elf_symbol_sptr_map_type) (string_elf_symbol_sptr_map_sptr, elf_symbols) (string_elf_symbols_map_type, string_elf_symbols_map_sptr): New convenience typedefs. (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, has_aliases, add_alias, get_id_string, get_name_and_version_from_id, operator=}): Declare new member functions. * src/abg-ir.cc (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, has_aliases, add_alias, get_id_string, get_name_and_version_from_id, operator=}): Define new member functions. * include/abg-reader.h (read_corpus_from_file): Take a shared pointer to corpus. * src/abg-reader.cc (read_context::{g,s}et_corpus): Define these. (build_elf_symbol_db, build_elf_symbol_from_reference) (read_symbol_db_from_input): Define new functions. (read_corpus_from_input): Adjust. Make it read symbol databases. (build_elf_symbol): Harden this. (build_{var,function}_decl): Read the symbol reference. Do not read the local symbol serialization anymore. (read_corpus_from_archive): Adjust. (read_corpus_from_file): Take a reference to a shared pointer to corpus, rather than a reference to the corpus. (read_corpus_from_native_xml): Only keep the overload that returns a corpus. Set the current context with the corpus. * src/abg-dwarf-reader.cc (addr_elf_symbol_sptr_map_type) (addr_elf_symbol_sptr_map_sptr): New convenience typedefs. (read_context::{fun_sym_addr_sym_index_map_, var_sym_addr_sym_index_map_): Remove. (read_context::{fun,var}_addr_sym_map_): New. Replace the above that got removed. (read_context::{var,fun}_syms_): New. (read_context::lookup_elf_{fn,var}_symbol_from_address): Adjust. (read_context::{fun,var}_addr_sym_map{_sptr}): New. (read_context::{fun,var}_syms{_sptr}): New. (read_context::load_symbol_maps): Replace read_context::load_symbol_addr_to_index_maps. Adjust to load all the new maps. (read_context::maybe_load_symbol_maps): New. (read_debug_info_into_corpus): Renamed build_corpus into this. Update to load symbol maps and set it to the corpus. * src/abg-writer.cc (write_context::get_fun_symbol_map): New accessor. (write_elf_symbol_aliases, write_elf_symbol_reference) (write_elf_symbols_table): Define new static functions. (write_var_decl): Write the reference to the underlying symbol of the variable. Do not write the full symbol here anymore. (write_function_decl): Likewise, write the reference to the underlying symbol of the function. Do not write the full symbol here anymore. (write_corpus_to_native_xml): Write the symbol databases at the beginning of the corpus document. * src/abg-comparison.cc (corpus_diff::priv::ensure_lookup_tables_populated): Now that the corpus has symbols, check if a the symbol of an allegedly deleted function (resp. variable) is deleted; if not, then do not report the function (resp. variable) as deleted. Similarly, check if the symbol of an allegedly added function (resp. variable) is added. if not, the do not report the function (resp. variable) as added. * tests/test-write-read-archive.cc (main): Adjust. * tools/biar.cc (extract_tus_from_archive): Likewise. * tests/data/test-diff-filter/test9-report.txt: Adjust. * tests/data/test-read-dwarf/test0.abi: Likewise. * tests/data/test-read-dwarf/test1.abi: Likewise. * tests/data/test-read-dwarf/test2.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-28 14:33:35 +00:00
void
set_fun_symbol_map(string_elf_symbols_map_sptr);
Support reading undefined symbols from an ELF file In preparation to support the upcoming 'abicompat' tool, we need the ABI corpus type to capture the symbols that are undefined in a given ELF file. This patch changes the ELF reader to capture the undefined symbols as well as the symbol versions they need to be satisfied. These undefined symbols are then stored in the instance ABI corpus build as a result of the reading of the ELF file. At the moment, these undefined symbols are not serialized to the native XML format of libabigail yet. I guess I'll do that in a subsequent patch. * include/abg-corpus.h (corpus::{set_undefined_fun_symbol_map, set_undefined_var_symbol_map, get_undefined_fun_symbol_map_sptr, get_undefined_fun_symbol_map, get_sorted_undefined_fun_symbols, get_undefined_var_symbol_map_sptr, get_undefined_var_symbol_map, get_sorted_undefined_var_symbols}): Declare new methods ... * src/abg-corpus.cc (corpus::{set_undefined_fun_symbol_map, set_undefined_var_symbol_map, get_undefined_fun_symbol_map_sptr, get_undefined_fun_symbol_map, get_sorted_undefined_fun_symbols, get_undefined_var_symbol_map_sptr, get_undefined_var_symbol_map, get_sorted_undefined_var_symbols}): ... and define them. (struct corpus::priv::{undefined_var_symbol_map, sorted_undefined_var_symbols, undefined_fun_symbol_map, sorted_undefined_fun_symbols}): New data members. * src/abg-dwarf-reader.cc (get_symbol_versionning_sections): Also return the SHT_GNU_verneed section. (get_version_needed_for_versym): New static function. (get_version_definition_for_versym): Factorize this function out of .. (get_version_for_symbol): ... this one. Take a flag that says if we want the definition version or the needed version of a symbol. Extend the implementation using the two new function get_version_needed_for_versym() and get_version_definition_for_versym() above. This function now returns the version either for a defined & exported symbol, or for an undefined symbol. (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_symtab): Adjust for the change of signature of get_version_for_symbol(). (read_context::{undefined_fun_syms_, undefined_var_syms_}): New data members. (read_context::lookup_elf_symbol_from_index): Adjust for invocation of the new signature of get_version_for_symbol(). (read_context::{undefined_fun_syms_sptr, undefined_fun_syms, undefined_var_syms_sptr, undefined_var_syms}): Define new methods. (read_context::load_symbol_maps): Add support for loading undefined symbols and their versions. (read_context::maybe_load_symbol_maps): Take in account the need to load undefined symbols as well. (read_corpus_from_elf): Once the undefined symbols have been read from the ELF file, stuff them into the resulting ABI corpus that has been built. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 10:16:28 +00:00
void
set_undefined_fun_symbol_map(string_elf_symbols_map_sptr);
Add a symbol database to the ABI Corpus & support symbol aliases * include/abg-corpus.h (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}): Declare new accessors. (corpus::lookup_{variable,function}_symbol): Declare new member functions. * src/abg-corpus.cc (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}): Define new accessors. (corpus::lookup_{variable,function}_symbol): Define new member functions. * include/abg-ir.h (string_elf_symbol_sptr_map_type) (string_elf_symbol_sptr_map_sptr, elf_symbols) (string_elf_symbols_map_type, string_elf_symbols_map_sptr): New convenience typedefs. (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, has_aliases, add_alias, get_id_string, get_name_and_version_from_id, operator=}): Declare new member functions. * src/abg-ir.cc (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, has_aliases, add_alias, get_id_string, get_name_and_version_from_id, operator=}): Define new member functions. * include/abg-reader.h (read_corpus_from_file): Take a shared pointer to corpus. * src/abg-reader.cc (read_context::{g,s}et_corpus): Define these. (build_elf_symbol_db, build_elf_symbol_from_reference) (read_symbol_db_from_input): Define new functions. (read_corpus_from_input): Adjust. Make it read symbol databases. (build_elf_symbol): Harden this. (build_{var,function}_decl): Read the symbol reference. Do not read the local symbol serialization anymore. (read_corpus_from_archive): Adjust. (read_corpus_from_file): Take a reference to a shared pointer to corpus, rather than a reference to the corpus. (read_corpus_from_native_xml): Only keep the overload that returns a corpus. Set the current context with the corpus. * src/abg-dwarf-reader.cc (addr_elf_symbol_sptr_map_type) (addr_elf_symbol_sptr_map_sptr): New convenience typedefs. (read_context::{fun_sym_addr_sym_index_map_, var_sym_addr_sym_index_map_): Remove. (read_context::{fun,var}_addr_sym_map_): New. Replace the above that got removed. (read_context::{var,fun}_syms_): New. (read_context::lookup_elf_{fn,var}_symbol_from_address): Adjust. (read_context::{fun,var}_addr_sym_map{_sptr}): New. (read_context::{fun,var}_syms{_sptr}): New. (read_context::load_symbol_maps): Replace read_context::load_symbol_addr_to_index_maps. Adjust to load all the new maps. (read_context::maybe_load_symbol_maps): New. (read_debug_info_into_corpus): Renamed build_corpus into this. Update to load symbol maps and set it to the corpus. * src/abg-writer.cc (write_context::get_fun_symbol_map): New accessor. (write_elf_symbol_aliases, write_elf_symbol_reference) (write_elf_symbols_table): Define new static functions. (write_var_decl): Write the reference to the underlying symbol of the variable. Do not write the full symbol here anymore. (write_function_decl): Likewise, write the reference to the underlying symbol of the function. Do not write the full symbol here anymore. (write_corpus_to_native_xml): Write the symbol databases at the beginning of the corpus document. * src/abg-comparison.cc (corpus_diff::priv::ensure_lookup_tables_populated): Now that the corpus has symbols, check if a the symbol of an allegedly deleted function (resp. variable) is deleted; if not, then do not report the function (resp. variable) as deleted. Similarly, check if the symbol of an allegedly added function (resp. variable) is added. if not, the do not report the function (resp. variable) as added. * tests/test-write-read-archive.cc (main): Adjust. * tools/biar.cc (extract_tus_from_archive): Likewise. * tests/data/test-diff-filter/test9-report.txt: Adjust. * tests/data/test-read-dwarf/test0.abi: Likewise. * tests/data/test-read-dwarf/test1.abi: Likewise. * tests/data/test-read-dwarf/test2.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-28 14:33:35 +00:00
void
set_var_symbol_map(string_elf_symbols_map_sptr);
Support reading undefined symbols from an ELF file In preparation to support the upcoming 'abicompat' tool, we need the ABI corpus type to capture the symbols that are undefined in a given ELF file. This patch changes the ELF reader to capture the undefined symbols as well as the symbol versions they need to be satisfied. These undefined symbols are then stored in the instance ABI corpus build as a result of the reading of the ELF file. At the moment, these undefined symbols are not serialized to the native XML format of libabigail yet. I guess I'll do that in a subsequent patch. * include/abg-corpus.h (corpus::{set_undefined_fun_symbol_map, set_undefined_var_symbol_map, get_undefined_fun_symbol_map_sptr, get_undefined_fun_symbol_map, get_sorted_undefined_fun_symbols, get_undefined_var_symbol_map_sptr, get_undefined_var_symbol_map, get_sorted_undefined_var_symbols}): Declare new methods ... * src/abg-corpus.cc (corpus::{set_undefined_fun_symbol_map, set_undefined_var_symbol_map, get_undefined_fun_symbol_map_sptr, get_undefined_fun_symbol_map, get_sorted_undefined_fun_symbols, get_undefined_var_symbol_map_sptr, get_undefined_var_symbol_map, get_sorted_undefined_var_symbols}): ... and define them. (struct corpus::priv::{undefined_var_symbol_map, sorted_undefined_var_symbols, undefined_fun_symbol_map, sorted_undefined_fun_symbols}): New data members. * src/abg-dwarf-reader.cc (get_symbol_versionning_sections): Also return the SHT_GNU_verneed section. (get_version_needed_for_versym): New static function. (get_version_definition_for_versym): Factorize this function out of .. (get_version_for_symbol): ... this one. Take a flag that says if we want the definition version or the needed version of a symbol. Extend the implementation using the two new function get_version_needed_for_versym() and get_version_definition_for_versym() above. This function now returns the version either for a defined & exported symbol, or for an undefined symbol. (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_symtab): Adjust for the change of signature of get_version_for_symbol(). (read_context::{undefined_fun_syms_, undefined_var_syms_}): New data members. (read_context::lookup_elf_symbol_from_index): Adjust for invocation of the new signature of get_version_for_symbol(). (read_context::{undefined_fun_syms_sptr, undefined_fun_syms, undefined_var_syms_sptr, undefined_var_syms}): Define new methods. (read_context::load_symbol_maps): Add support for loading undefined symbols and their versions. (read_context::maybe_load_symbol_maps): Take in account the need to load undefined symbols as well. (read_corpus_from_elf): Once the undefined symbols have been read from the ELF file, stuff them into the resulting ABI corpus that has been built. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 10:16:28 +00:00
void
set_undefined_var_symbol_map(string_elf_symbols_map_sptr);
Add a symbol database to the ABI Corpus & support symbol aliases * include/abg-corpus.h (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}): Declare new accessors. (corpus::lookup_{variable,function}_symbol): Declare new member functions. * src/abg-corpus.cc (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}): Define new accessors. (corpus::lookup_{variable,function}_symbol): Define new member functions. * include/abg-ir.h (string_elf_symbol_sptr_map_type) (string_elf_symbol_sptr_map_sptr, elf_symbols) (string_elf_symbols_map_type, string_elf_symbols_map_sptr): New convenience typedefs. (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, has_aliases, add_alias, get_id_string, get_name_and_version_from_id, operator=}): Declare new member functions. * src/abg-ir.cc (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, has_aliases, add_alias, get_id_string, get_name_and_version_from_id, operator=}): Define new member functions. * include/abg-reader.h (read_corpus_from_file): Take a shared pointer to corpus. * src/abg-reader.cc (read_context::{g,s}et_corpus): Define these. (build_elf_symbol_db, build_elf_symbol_from_reference) (read_symbol_db_from_input): Define new functions. (read_corpus_from_input): Adjust. Make it read symbol databases. (build_elf_symbol): Harden this. (build_{var,function}_decl): Read the symbol reference. Do not read the local symbol serialization anymore. (read_corpus_from_archive): Adjust. (read_corpus_from_file): Take a reference to a shared pointer to corpus, rather than a reference to the corpus. (read_corpus_from_native_xml): Only keep the overload that returns a corpus. Set the current context with the corpus. * src/abg-dwarf-reader.cc (addr_elf_symbol_sptr_map_type) (addr_elf_symbol_sptr_map_sptr): New convenience typedefs. (read_context::{fun_sym_addr_sym_index_map_, var_sym_addr_sym_index_map_): Remove. (read_context::{fun,var}_addr_sym_map_): New. Replace the above that got removed. (read_context::{var,fun}_syms_): New. (read_context::lookup_elf_{fn,var}_symbol_from_address): Adjust. (read_context::{fun,var}_addr_sym_map{_sptr}): New. (read_context::{fun,var}_syms{_sptr}): New. (read_context::load_symbol_maps): Replace read_context::load_symbol_addr_to_index_maps. Adjust to load all the new maps. (read_context::maybe_load_symbol_maps): New. (read_debug_info_into_corpus): Renamed build_corpus into this. Update to load symbol maps and set it to the corpus. * src/abg-writer.cc (write_context::get_fun_symbol_map): New accessor. (write_elf_symbol_aliases, write_elf_symbol_reference) (write_elf_symbols_table): Define new static functions. (write_var_decl): Write the reference to the underlying symbol of the variable. Do not write the full symbol here anymore. (write_function_decl): Likewise, write the reference to the underlying symbol of the function. Do not write the full symbol here anymore. (write_corpus_to_native_xml): Write the symbol databases at the beginning of the corpus document. * src/abg-comparison.cc (corpus_diff::priv::ensure_lookup_tables_populated): Now that the corpus has symbols, check if a the symbol of an allegedly deleted function (resp. variable) is deleted; if not, then do not report the function (resp. variable) as deleted. Similarly, check if the symbol of an allegedly added function (resp. variable) is added. if not, the do not report the function (resp. variable) as added. * tests/test-write-read-archive.cc (main): Adjust. * tools/biar.cc (extract_tus_from_archive): Likewise. * tests/data/test-diff-filter/test9-report.txt: Adjust. * tests/data/test-read-dwarf/test0.abi: Likewise. * tests/data/test-read-dwarf/test1.abi: Likewise. * tests/data/test-read-dwarf/test2.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-28 14:33:35 +00:00
const string_elf_symbols_map_sptr
get_fun_symbol_map_sptr() const;
const string_elf_symbols_map_type&
get_fun_symbol_map() const;
Support reading undefined symbols from an ELF file In preparation to support the upcoming 'abicompat' tool, we need the ABI corpus type to capture the symbols that are undefined in a given ELF file. This patch changes the ELF reader to capture the undefined symbols as well as the symbol versions they need to be satisfied. These undefined symbols are then stored in the instance ABI corpus build as a result of the reading of the ELF file. At the moment, these undefined symbols are not serialized to the native XML format of libabigail yet. I guess I'll do that in a subsequent patch. * include/abg-corpus.h (corpus::{set_undefined_fun_symbol_map, set_undefined_var_symbol_map, get_undefined_fun_symbol_map_sptr, get_undefined_fun_symbol_map, get_sorted_undefined_fun_symbols, get_undefined_var_symbol_map_sptr, get_undefined_var_symbol_map, get_sorted_undefined_var_symbols}): Declare new methods ... * src/abg-corpus.cc (corpus::{set_undefined_fun_symbol_map, set_undefined_var_symbol_map, get_undefined_fun_symbol_map_sptr, get_undefined_fun_symbol_map, get_sorted_undefined_fun_symbols, get_undefined_var_symbol_map_sptr, get_undefined_var_symbol_map, get_sorted_undefined_var_symbols}): ... and define them. (struct corpus::priv::{undefined_var_symbol_map, sorted_undefined_var_symbols, undefined_fun_symbol_map, sorted_undefined_fun_symbols}): New data members. * src/abg-dwarf-reader.cc (get_symbol_versionning_sections): Also return the SHT_GNU_verneed section. (get_version_needed_for_versym): New static function. (get_version_definition_for_versym): Factorize this function out of .. (get_version_for_symbol): ... this one. Take a flag that says if we want the definition version or the needed version of a symbol. Extend the implementation using the two new function get_version_needed_for_versym() and get_version_definition_for_versym() above. This function now returns the version either for a defined & exported symbol, or for an undefined symbol. (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_symtab): Adjust for the change of signature of get_version_for_symbol(). (read_context::{undefined_fun_syms_, undefined_var_syms_}): New data members. (read_context::lookup_elf_symbol_from_index): Adjust for invocation of the new signature of get_version_for_symbol(). (read_context::{undefined_fun_syms_sptr, undefined_fun_syms, undefined_var_syms_sptr, undefined_var_syms}): Define new methods. (read_context::load_symbol_maps): Add support for loading undefined symbols and their versions. (read_context::maybe_load_symbol_maps): Take in account the need to load undefined symbols as well. (read_corpus_from_elf): Once the undefined symbols have been read from the ELF file, stuff them into the resulting ABI corpus that has been built. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 10:16:28 +00:00
const string_elf_symbols_map_sptr
get_undefined_fun_symbol_map_sptr() const;
const string_elf_symbols_map_type&
get_undefined_fun_symbol_map() const;
const elf_symbols&
get_sorted_fun_symbols() const;
Support reading undefined symbols from an ELF file In preparation to support the upcoming 'abicompat' tool, we need the ABI corpus type to capture the symbols that are undefined in a given ELF file. This patch changes the ELF reader to capture the undefined symbols as well as the symbol versions they need to be satisfied. These undefined symbols are then stored in the instance ABI corpus build as a result of the reading of the ELF file. At the moment, these undefined symbols are not serialized to the native XML format of libabigail yet. I guess I'll do that in a subsequent patch. * include/abg-corpus.h (corpus::{set_undefined_fun_symbol_map, set_undefined_var_symbol_map, get_undefined_fun_symbol_map_sptr, get_undefined_fun_symbol_map, get_sorted_undefined_fun_symbols, get_undefined_var_symbol_map_sptr, get_undefined_var_symbol_map, get_sorted_undefined_var_symbols}): Declare new methods ... * src/abg-corpus.cc (corpus::{set_undefined_fun_symbol_map, set_undefined_var_symbol_map, get_undefined_fun_symbol_map_sptr, get_undefined_fun_symbol_map, get_sorted_undefined_fun_symbols, get_undefined_var_symbol_map_sptr, get_undefined_var_symbol_map, get_sorted_undefined_var_symbols}): ... and define them. (struct corpus::priv::{undefined_var_symbol_map, sorted_undefined_var_symbols, undefined_fun_symbol_map, sorted_undefined_fun_symbols}): New data members. * src/abg-dwarf-reader.cc (get_symbol_versionning_sections): Also return the SHT_GNU_verneed section. (get_version_needed_for_versym): New static function. (get_version_definition_for_versym): Factorize this function out of .. (get_version_for_symbol): ... this one. Take a flag that says if we want the definition version or the needed version of a symbol. Extend the implementation using the two new function get_version_needed_for_versym() and get_version_definition_for_versym() above. This function now returns the version either for a defined & exported symbol, or for an undefined symbol. (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_symtab): Adjust for the change of signature of get_version_for_symbol(). (read_context::{undefined_fun_syms_, undefined_var_syms_}): New data members. (read_context::lookup_elf_symbol_from_index): Adjust for invocation of the new signature of get_version_for_symbol(). (read_context::{undefined_fun_syms_sptr, undefined_fun_syms, undefined_var_syms_sptr, undefined_var_syms}): Define new methods. (read_context::load_symbol_maps): Add support for loading undefined symbols and their versions. (read_context::maybe_load_symbol_maps): Take in account the need to load undefined symbols as well. (read_corpus_from_elf): Once the undefined symbols have been read from the ELF file, stuff them into the resulting ABI corpus that has been built. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 10:16:28 +00:00
const elf_symbols&
get_sorted_undefined_fun_symbols() const;
Add a symbol database to the ABI Corpus & support symbol aliases * include/abg-corpus.h (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}): Declare new accessors. (corpus::lookup_{variable,function}_symbol): Declare new member functions. * src/abg-corpus.cc (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}): Define new accessors. (corpus::lookup_{variable,function}_symbol): Define new member functions. * include/abg-ir.h (string_elf_symbol_sptr_map_type) (string_elf_symbol_sptr_map_sptr, elf_symbols) (string_elf_symbols_map_type, string_elf_symbols_map_sptr): New convenience typedefs. (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, has_aliases, add_alias, get_id_string, get_name_and_version_from_id, operator=}): Declare new member functions. * src/abg-ir.cc (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, has_aliases, add_alias, get_id_string, get_name_and_version_from_id, operator=}): Define new member functions. * include/abg-reader.h (read_corpus_from_file): Take a shared pointer to corpus. * src/abg-reader.cc (read_context::{g,s}et_corpus): Define these. (build_elf_symbol_db, build_elf_symbol_from_reference) (read_symbol_db_from_input): Define new functions. (read_corpus_from_input): Adjust. Make it read symbol databases. (build_elf_symbol): Harden this. (build_{var,function}_decl): Read the symbol reference. Do not read the local symbol serialization anymore. (read_corpus_from_archive): Adjust. (read_corpus_from_file): Take a reference to a shared pointer to corpus, rather than a reference to the corpus. (read_corpus_from_native_xml): Only keep the overload that returns a corpus. Set the current context with the corpus. * src/abg-dwarf-reader.cc (addr_elf_symbol_sptr_map_type) (addr_elf_symbol_sptr_map_sptr): New convenience typedefs. (read_context::{fun_sym_addr_sym_index_map_, var_sym_addr_sym_index_map_): Remove. (read_context::{fun,var}_addr_sym_map_): New. Replace the above that got removed. (read_context::{var,fun}_syms_): New. (read_context::lookup_elf_{fn,var}_symbol_from_address): Adjust. (read_context::{fun,var}_addr_sym_map{_sptr}): New. (read_context::{fun,var}_syms{_sptr}): New. (read_context::load_symbol_maps): Replace read_context::load_symbol_addr_to_index_maps. Adjust to load all the new maps. (read_context::maybe_load_symbol_maps): New. (read_debug_info_into_corpus): Renamed build_corpus into this. Update to load symbol maps and set it to the corpus. * src/abg-writer.cc (write_context::get_fun_symbol_map): New accessor. (write_elf_symbol_aliases, write_elf_symbol_reference) (write_elf_symbols_table): Define new static functions. (write_var_decl): Write the reference to the underlying symbol of the variable. Do not write the full symbol here anymore. (write_function_decl): Likewise, write the reference to the underlying symbol of the function. Do not write the full symbol here anymore. (write_corpus_to_native_xml): Write the symbol databases at the beginning of the corpus document. * src/abg-comparison.cc (corpus_diff::priv::ensure_lookup_tables_populated): Now that the corpus has symbols, check if a the symbol of an allegedly deleted function (resp. variable) is deleted; if not, then do not report the function (resp. variable) as deleted. Similarly, check if the symbol of an allegedly added function (resp. variable) is added. if not, the do not report the function (resp. variable) as added. * tests/test-write-read-archive.cc (main): Adjust. * tools/biar.cc (extract_tus_from_archive): Likewise. * tests/data/test-diff-filter/test9-report.txt: Adjust. * tests/data/test-read-dwarf/test0.abi: Likewise. * tests/data/test-read-dwarf/test1.abi: Likewise. * tests/data/test-read-dwarf/test2.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-28 14:33:35 +00:00
const string_elf_symbols_map_sptr
get_var_symbol_map_sptr() const;
const string_elf_symbols_map_type&
get_var_symbol_map() const;
Support reading undefined symbols from an ELF file In preparation to support the upcoming 'abicompat' tool, we need the ABI corpus type to capture the symbols that are undefined in a given ELF file. This patch changes the ELF reader to capture the undefined symbols as well as the symbol versions they need to be satisfied. These undefined symbols are then stored in the instance ABI corpus build as a result of the reading of the ELF file. At the moment, these undefined symbols are not serialized to the native XML format of libabigail yet. I guess I'll do that in a subsequent patch. * include/abg-corpus.h (corpus::{set_undefined_fun_symbol_map, set_undefined_var_symbol_map, get_undefined_fun_symbol_map_sptr, get_undefined_fun_symbol_map, get_sorted_undefined_fun_symbols, get_undefined_var_symbol_map_sptr, get_undefined_var_symbol_map, get_sorted_undefined_var_symbols}): Declare new methods ... * src/abg-corpus.cc (corpus::{set_undefined_fun_symbol_map, set_undefined_var_symbol_map, get_undefined_fun_symbol_map_sptr, get_undefined_fun_symbol_map, get_sorted_undefined_fun_symbols, get_undefined_var_symbol_map_sptr, get_undefined_var_symbol_map, get_sorted_undefined_var_symbols}): ... and define them. (struct corpus::priv::{undefined_var_symbol_map, sorted_undefined_var_symbols, undefined_fun_symbol_map, sorted_undefined_fun_symbols}): New data members. * src/abg-dwarf-reader.cc (get_symbol_versionning_sections): Also return the SHT_GNU_verneed section. (get_version_needed_for_versym): New static function. (get_version_definition_for_versym): Factorize this function out of .. (get_version_for_symbol): ... this one. Take a flag that says if we want the definition version or the needed version of a symbol. Extend the implementation using the two new function get_version_needed_for_versym() and get_version_definition_for_versym() above. This function now returns the version either for a defined & exported symbol, or for an undefined symbol. (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_symtab): Adjust for the change of signature of get_version_for_symbol(). (read_context::{undefined_fun_syms_, undefined_var_syms_}): New data members. (read_context::lookup_elf_symbol_from_index): Adjust for invocation of the new signature of get_version_for_symbol(). (read_context::{undefined_fun_syms_sptr, undefined_fun_syms, undefined_var_syms_sptr, undefined_var_syms}): Define new methods. (read_context::load_symbol_maps): Add support for loading undefined symbols and their versions. (read_context::maybe_load_symbol_maps): Take in account the need to load undefined symbols as well. (read_corpus_from_elf): Once the undefined symbols have been read from the ELF file, stuff them into the resulting ABI corpus that has been built. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 10:16:28 +00:00
const string_elf_symbols_map_sptr
get_undefined_var_symbol_map_sptr() const;
const string_elf_symbols_map_type&
get_undefined_var_symbol_map() const;
const elf_symbols&
get_sorted_var_symbols() const;
Support reading undefined symbols from an ELF file In preparation to support the upcoming 'abicompat' tool, we need the ABI corpus type to capture the symbols that are undefined in a given ELF file. This patch changes the ELF reader to capture the undefined symbols as well as the symbol versions they need to be satisfied. These undefined symbols are then stored in the instance ABI corpus build as a result of the reading of the ELF file. At the moment, these undefined symbols are not serialized to the native XML format of libabigail yet. I guess I'll do that in a subsequent patch. * include/abg-corpus.h (corpus::{set_undefined_fun_symbol_map, set_undefined_var_symbol_map, get_undefined_fun_symbol_map_sptr, get_undefined_fun_symbol_map, get_sorted_undefined_fun_symbols, get_undefined_var_symbol_map_sptr, get_undefined_var_symbol_map, get_sorted_undefined_var_symbols}): Declare new methods ... * src/abg-corpus.cc (corpus::{set_undefined_fun_symbol_map, set_undefined_var_symbol_map, get_undefined_fun_symbol_map_sptr, get_undefined_fun_symbol_map, get_sorted_undefined_fun_symbols, get_undefined_var_symbol_map_sptr, get_undefined_var_symbol_map, get_sorted_undefined_var_symbols}): ... and define them. (struct corpus::priv::{undefined_var_symbol_map, sorted_undefined_var_symbols, undefined_fun_symbol_map, sorted_undefined_fun_symbols}): New data members. * src/abg-dwarf-reader.cc (get_symbol_versionning_sections): Also return the SHT_GNU_verneed section. (get_version_needed_for_versym): New static function. (get_version_definition_for_versym): Factorize this function out of .. (get_version_for_symbol): ... this one. Take a flag that says if we want the definition version or the needed version of a symbol. Extend the implementation using the two new function get_version_needed_for_versym() and get_version_definition_for_versym() above. This function now returns the version either for a defined & exported symbol, or for an undefined symbol. (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_symtab): Adjust for the change of signature of get_version_for_symbol(). (read_context::{undefined_fun_syms_, undefined_var_syms_}): New data members. (read_context::lookup_elf_symbol_from_index): Adjust for invocation of the new signature of get_version_for_symbol(). (read_context::{undefined_fun_syms_sptr, undefined_fun_syms, undefined_var_syms_sptr, undefined_var_syms}): Define new methods. (read_context::load_symbol_maps): Add support for loading undefined symbols and their versions. (read_context::maybe_load_symbol_maps): Take in account the need to load undefined symbols as well. (read_corpus_from_elf): Once the undefined symbols have been read from the ELF file, stuff them into the resulting ABI corpus that has been built. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 10:16:28 +00:00
const elf_symbols&
get_sorted_undefined_var_symbols() const;
Add a symbol database to the ABI Corpus & support symbol aliases * include/abg-corpus.h (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}): Declare new accessors. (corpus::lookup_{variable,function}_symbol): Declare new member functions. * src/abg-corpus.cc (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}): Define new accessors. (corpus::lookup_{variable,function}_symbol): Define new member functions. * include/abg-ir.h (string_elf_symbol_sptr_map_type) (string_elf_symbol_sptr_map_sptr, elf_symbols) (string_elf_symbols_map_type, string_elf_symbols_map_sptr): New convenience typedefs. (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, has_aliases, add_alias, get_id_string, get_name_and_version_from_id, operator=}): Declare new member functions. * src/abg-ir.cc (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, has_aliases, add_alias, get_id_string, get_name_and_version_from_id, operator=}): Define new member functions. * include/abg-reader.h (read_corpus_from_file): Take a shared pointer to corpus. * src/abg-reader.cc (read_context::{g,s}et_corpus): Define these. (build_elf_symbol_db, build_elf_symbol_from_reference) (read_symbol_db_from_input): Define new functions. (read_corpus_from_input): Adjust. Make it read symbol databases. (build_elf_symbol): Harden this. (build_{var,function}_decl): Read the symbol reference. Do not read the local symbol serialization anymore. (read_corpus_from_archive): Adjust. (read_corpus_from_file): Take a reference to a shared pointer to corpus, rather than a reference to the corpus. (read_corpus_from_native_xml): Only keep the overload that returns a corpus. Set the current context with the corpus. * src/abg-dwarf-reader.cc (addr_elf_symbol_sptr_map_type) (addr_elf_symbol_sptr_map_sptr): New convenience typedefs. (read_context::{fun_sym_addr_sym_index_map_, var_sym_addr_sym_index_map_): Remove. (read_context::{fun,var}_addr_sym_map_): New. Replace the above that got removed. (read_context::{var,fun}_syms_): New. (read_context::lookup_elf_{fn,var}_symbol_from_address): Adjust. (read_context::{fun,var}_addr_sym_map{_sptr}): New. (read_context::{fun,var}_syms{_sptr}): New. (read_context::load_symbol_maps): Replace read_context::load_symbol_addr_to_index_maps. Adjust to load all the new maps. (read_context::maybe_load_symbol_maps): New. (read_debug_info_into_corpus): Renamed build_corpus into this. Update to load symbol maps and set it to the corpus. * src/abg-writer.cc (write_context::get_fun_symbol_map): New accessor. (write_elf_symbol_aliases, write_elf_symbol_reference) (write_elf_symbols_table): Define new static functions. (write_var_decl): Write the reference to the underlying symbol of the variable. Do not write the full symbol here anymore. (write_function_decl): Likewise, write the reference to the underlying symbol of the function. Do not write the full symbol here anymore. (write_corpus_to_native_xml): Write the symbol databases at the beginning of the corpus document. * src/abg-comparison.cc (corpus_diff::priv::ensure_lookup_tables_populated): Now that the corpus has symbols, check if a the symbol of an allegedly deleted function (resp. variable) is deleted; if not, then do not report the function (resp. variable) as deleted. Similarly, check if the symbol of an allegedly added function (resp. variable) is added. if not, the do not report the function (resp. variable) as added. * tests/test-write-read-archive.cc (main): Adjust. * tools/biar.cc (extract_tus_from_archive): Likewise. * tests/data/test-diff-filter/test9-report.txt: Adjust. * tests/data/test-read-dwarf/test0.abi: Likewise. * tests/data/test-read-dwarf/test1.abi: Likewise. * tests/data/test-read-dwarf/test2.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-28 14:33:35 +00:00
const elf_symbol_sptr
lookup_function_symbol(const string& n) const;
Add a symbol database to the ABI Corpus & support symbol aliases * include/abg-corpus.h (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}): Declare new accessors. (corpus::lookup_{variable,function}_symbol): Declare new member functions. * src/abg-corpus.cc (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}): Define new accessors. (corpus::lookup_{variable,function}_symbol): Define new member functions. * include/abg-ir.h (string_elf_symbol_sptr_map_type) (string_elf_symbol_sptr_map_sptr, elf_symbols) (string_elf_symbols_map_type, string_elf_symbols_map_sptr): New convenience typedefs. (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, has_aliases, add_alias, get_id_string, get_name_and_version_from_id, operator=}): Declare new member functions. * src/abg-ir.cc (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, has_aliases, add_alias, get_id_string, get_name_and_version_from_id, operator=}): Define new member functions. * include/abg-reader.h (read_corpus_from_file): Take a shared pointer to corpus. * src/abg-reader.cc (read_context::{g,s}et_corpus): Define these. (build_elf_symbol_db, build_elf_symbol_from_reference) (read_symbol_db_from_input): Define new functions. (read_corpus_from_input): Adjust. Make it read symbol databases. (build_elf_symbol): Harden this. (build_{var,function}_decl): Read the symbol reference. Do not read the local symbol serialization anymore. (read_corpus_from_archive): Adjust. (read_corpus_from_file): Take a reference to a shared pointer to corpus, rather than a reference to the corpus. (read_corpus_from_native_xml): Only keep the overload that returns a corpus. Set the current context with the corpus. * src/abg-dwarf-reader.cc (addr_elf_symbol_sptr_map_type) (addr_elf_symbol_sptr_map_sptr): New convenience typedefs. (read_context::{fun_sym_addr_sym_index_map_, var_sym_addr_sym_index_map_): Remove. (read_context::{fun,var}_addr_sym_map_): New. Replace the above that got removed. (read_context::{var,fun}_syms_): New. (read_context::lookup_elf_{fn,var}_symbol_from_address): Adjust. (read_context::{fun,var}_addr_sym_map{_sptr}): New. (read_context::{fun,var}_syms{_sptr}): New. (read_context::load_symbol_maps): Replace read_context::load_symbol_addr_to_index_maps. Adjust to load all the new maps. (read_context::maybe_load_symbol_maps): New. (read_debug_info_into_corpus): Renamed build_corpus into this. Update to load symbol maps and set it to the corpus. * src/abg-writer.cc (write_context::get_fun_symbol_map): New accessor. (write_elf_symbol_aliases, write_elf_symbol_reference) (write_elf_symbols_table): Define new static functions. (write_var_decl): Write the reference to the underlying symbol of the variable. Do not write the full symbol here anymore. (write_function_decl): Likewise, write the reference to the underlying symbol of the function. Do not write the full symbol here anymore. (write_corpus_to_native_xml): Write the symbol databases at the beginning of the corpus document. * src/abg-comparison.cc (corpus_diff::priv::ensure_lookup_tables_populated): Now that the corpus has symbols, check if a the symbol of an allegedly deleted function (resp. variable) is deleted; if not, then do not report the function (resp. variable) as deleted. Similarly, check if the symbol of an allegedly added function (resp. variable) is added. if not, the do not report the function (resp. variable) as added. * tests/test-write-read-archive.cc (main): Adjust. * tools/biar.cc (extract_tus_from_archive): Likewise. * tests/data/test-diff-filter/test9-report.txt: Adjust. * tests/data/test-read-dwarf/test0.abi: Likewise. * tests/data/test-read-dwarf/test1.abi: Likewise. * tests/data/test-read-dwarf/test2.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-28 14:33:35 +00:00
const elf_symbol_sptr
lookup_function_symbol(const string& symbol_name,
Consider default symbol versions when computing added/removed fns/vars When computing the set of added function or variable symbols, if a symbol S with no version symbol was present in a given corpus and that symbol gained a *DEFAULT* version V in the second corpus, we should not consider that a new symbol S was added (and that the former S was removed) because: 1/ S was already present in the first corpus 2/ applications linked to the first corpus and that were using S (with no version) there, will automatically use the S with version V in the second corpus, without needing any re-linking; the power of symbol versioning! Rather, it's just that S gained a default symbol version. This patch implements that. * include/abg-corpus.h (corpus::{lookup_function_symbol, lookup_variable_symbol}): Take a elf_symbol::version object, rather than a string representing the version. Add an overload that takes an elf_symbol. * src/abg-corpus.cc (find_symbol_by_version): New static function. (corpus::{lookup_function_symbol, lookup_variable_symbol}): Take a elf_symbol::version object, rather than a string representing the version. Add an overload that takes an elf_symbol. If the looked up symbol has no version and if the corpus contains a symbol with the same name and with a default version, then return that latter symbol if the corpus doesn't contain a symbol with the same name and empty version. * src/abg-comparison.cc (class_diff::ensure_lookup_tables_populated): Adjust. (corpus_diff::priv::ensure_lookup_tables_populated): Before deciding that a symbol has been added, if the symbol has a default version, make sure no symbol with the same name and without version was present in the former corpus. Similarly, before deciding that a symbol has been removed, if the symbol has no version, make sure the latter corpus has no symbol with the same name and with a default version. * tests/data/test-diff-dwarf/test12-report.txt: Adjust. The function should not be considered as added, because its symbol (and version) was already present in the former DSO. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-24 12:04:11 +00:00
const elf_symbol::version& version) const;
const elf_symbol_sptr
lookup_function_symbol(const elf_symbol& symbol) const;
Add a symbol database to the ABI Corpus & support symbol aliases * include/abg-corpus.h (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}): Declare new accessors. (corpus::lookup_{variable,function}_symbol): Declare new member functions. * src/abg-corpus.cc (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}): Define new accessors. (corpus::lookup_{variable,function}_symbol): Define new member functions. * include/abg-ir.h (string_elf_symbol_sptr_map_type) (string_elf_symbol_sptr_map_sptr, elf_symbols) (string_elf_symbols_map_type, string_elf_symbols_map_sptr): New convenience typedefs. (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, has_aliases, add_alias, get_id_string, get_name_and_version_from_id, operator=}): Declare new member functions. * src/abg-ir.cc (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, has_aliases, add_alias, get_id_string, get_name_and_version_from_id, operator=}): Define new member functions. * include/abg-reader.h (read_corpus_from_file): Take a shared pointer to corpus. * src/abg-reader.cc (read_context::{g,s}et_corpus): Define these. (build_elf_symbol_db, build_elf_symbol_from_reference) (read_symbol_db_from_input): Define new functions. (read_corpus_from_input): Adjust. Make it read symbol databases. (build_elf_symbol): Harden this. (build_{var,function}_decl): Read the symbol reference. Do not read the local symbol serialization anymore. (read_corpus_from_archive): Adjust. (read_corpus_from_file): Take a reference to a shared pointer to corpus, rather than a reference to the corpus. (read_corpus_from_native_xml): Only keep the overload that returns a corpus. Set the current context with the corpus. * src/abg-dwarf-reader.cc (addr_elf_symbol_sptr_map_type) (addr_elf_symbol_sptr_map_sptr): New convenience typedefs. (read_context::{fun_sym_addr_sym_index_map_, var_sym_addr_sym_index_map_): Remove. (read_context::{fun,var}_addr_sym_map_): New. Replace the above that got removed. (read_context::{var,fun}_syms_): New. (read_context::lookup_elf_{fn,var}_symbol_from_address): Adjust. (read_context::{fun,var}_addr_sym_map{_sptr}): New. (read_context::{fun,var}_syms{_sptr}): New. (read_context::load_symbol_maps): Replace read_context::load_symbol_addr_to_index_maps. Adjust to load all the new maps. (read_context::maybe_load_symbol_maps): New. (read_debug_info_into_corpus): Renamed build_corpus into this. Update to load symbol maps and set it to the corpus. * src/abg-writer.cc (write_context::get_fun_symbol_map): New accessor. (write_elf_symbol_aliases, write_elf_symbol_reference) (write_elf_symbols_table): Define new static functions. (write_var_decl): Write the reference to the underlying symbol of the variable. Do not write the full symbol here anymore. (write_function_decl): Likewise, write the reference to the underlying symbol of the function. Do not write the full symbol here anymore. (write_corpus_to_native_xml): Write the symbol databases at the beginning of the corpus document. * src/abg-comparison.cc (corpus_diff::priv::ensure_lookup_tables_populated): Now that the corpus has symbols, check if a the symbol of an allegedly deleted function (resp. variable) is deleted; if not, then do not report the function (resp. variable) as deleted. Similarly, check if the symbol of an allegedly added function (resp. variable) is added. if not, the do not report the function (resp. variable) as added. * tests/test-write-read-archive.cc (main): Adjust. * tools/biar.cc (extract_tus_from_archive): Likewise. * tests/data/test-diff-filter/test9-report.txt: Adjust. * tests/data/test-read-dwarf/test0.abi: Likewise. * tests/data/test-read-dwarf/test1.abi: Likewise. * tests/data/test-read-dwarf/test2.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-28 14:33:35 +00:00
const elf_symbol_sptr
lookup_variable_symbol(const string& n) const;
Add a symbol database to the ABI Corpus & support symbol aliases * include/abg-corpus.h (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}): Declare new accessors. (corpus::lookup_{variable,function}_symbol): Declare new member functions. * src/abg-corpus.cc (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}): Define new accessors. (corpus::lookup_{variable,function}_symbol): Define new member functions. * include/abg-ir.h (string_elf_symbol_sptr_map_type) (string_elf_symbol_sptr_map_sptr, elf_symbols) (string_elf_symbols_map_type, string_elf_symbols_map_sptr): New convenience typedefs. (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, has_aliases, add_alias, get_id_string, get_name_and_version_from_id, operator=}): Declare new member functions. * src/abg-ir.cc (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, has_aliases, add_alias, get_id_string, get_name_and_version_from_id, operator=}): Define new member functions. * include/abg-reader.h (read_corpus_from_file): Take a shared pointer to corpus. * src/abg-reader.cc (read_context::{g,s}et_corpus): Define these. (build_elf_symbol_db, build_elf_symbol_from_reference) (read_symbol_db_from_input): Define new functions. (read_corpus_from_input): Adjust. Make it read symbol databases. (build_elf_symbol): Harden this. (build_{var,function}_decl): Read the symbol reference. Do not read the local symbol serialization anymore. (read_corpus_from_archive): Adjust. (read_corpus_from_file): Take a reference to a shared pointer to corpus, rather than a reference to the corpus. (read_corpus_from_native_xml): Only keep the overload that returns a corpus. Set the current context with the corpus. * src/abg-dwarf-reader.cc (addr_elf_symbol_sptr_map_type) (addr_elf_symbol_sptr_map_sptr): New convenience typedefs. (read_context::{fun_sym_addr_sym_index_map_, var_sym_addr_sym_index_map_): Remove. (read_context::{fun,var}_addr_sym_map_): New. Replace the above that got removed. (read_context::{var,fun}_syms_): New. (read_context::lookup_elf_{fn,var}_symbol_from_address): Adjust. (read_context::{fun,var}_addr_sym_map{_sptr}): New. (read_context::{fun,var}_syms{_sptr}): New. (read_context::load_symbol_maps): Replace read_context::load_symbol_addr_to_index_maps. Adjust to load all the new maps. (read_context::maybe_load_symbol_maps): New. (read_debug_info_into_corpus): Renamed build_corpus into this. Update to load symbol maps and set it to the corpus. * src/abg-writer.cc (write_context::get_fun_symbol_map): New accessor. (write_elf_symbol_aliases, write_elf_symbol_reference) (write_elf_symbols_table): Define new static functions. (write_var_decl): Write the reference to the underlying symbol of the variable. Do not write the full symbol here anymore. (write_function_decl): Likewise, write the reference to the underlying symbol of the function. Do not write the full symbol here anymore. (write_corpus_to_native_xml): Write the symbol databases at the beginning of the corpus document. * src/abg-comparison.cc (corpus_diff::priv::ensure_lookup_tables_populated): Now that the corpus has symbols, check if a the symbol of an allegedly deleted function (resp. variable) is deleted; if not, then do not report the function (resp. variable) as deleted. Similarly, check if the symbol of an allegedly added function (resp. variable) is added. if not, the do not report the function (resp. variable) as added. * tests/test-write-read-archive.cc (main): Adjust. * tools/biar.cc (extract_tus_from_archive): Likewise. * tests/data/test-diff-filter/test9-report.txt: Adjust. * tests/data/test-read-dwarf/test0.abi: Likewise. * tests/data/test-read-dwarf/test1.abi: Likewise. * tests/data/test-read-dwarf/test2.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-28 14:33:35 +00:00
const elf_symbol_sptr
lookup_variable_symbol(const string& symbol_name,
Consider default symbol versions when computing added/removed fns/vars When computing the set of added function or variable symbols, if a symbol S with no version symbol was present in a given corpus and that symbol gained a *DEFAULT* version V in the second corpus, we should not consider that a new symbol S was added (and that the former S was removed) because: 1/ S was already present in the first corpus 2/ applications linked to the first corpus and that were using S (with no version) there, will automatically use the S with version V in the second corpus, without needing any re-linking; the power of symbol versioning! Rather, it's just that S gained a default symbol version. This patch implements that. * include/abg-corpus.h (corpus::{lookup_function_symbol, lookup_variable_symbol}): Take a elf_symbol::version object, rather than a string representing the version. Add an overload that takes an elf_symbol. * src/abg-corpus.cc (find_symbol_by_version): New static function. (corpus::{lookup_function_symbol, lookup_variable_symbol}): Take a elf_symbol::version object, rather than a string representing the version. Add an overload that takes an elf_symbol. If the looked up symbol has no version and if the corpus contains a symbol with the same name and with a default version, then return that latter symbol if the corpus doesn't contain a symbol with the same name and empty version. * src/abg-comparison.cc (class_diff::ensure_lookup_tables_populated): Adjust. (corpus_diff::priv::ensure_lookup_tables_populated): Before deciding that a symbol has been added, if the symbol has a default version, make sure no symbol with the same name and without version was present in the former corpus. Similarly, before deciding that a symbol has been removed, if the symbol has no version, make sure the latter corpus has no symbol with the same name and with a default version. * tests/data/test-diff-dwarf/test12-report.txt: Adjust. The function should not be considered as added, because its symbol (and version) was already present in the former DSO. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-24 12:04:11 +00:00
const elf_symbol::version& version) const;
const elf_symbol_sptr
lookup_variable_symbol(const elf_symbol& symbol) const;
Initial support for diffing ABI corpus files * include/abg-comparison.h (string_function_ptr_map) (changed_function_ptr, string_changed_function_ptr_map) (corpus_diff_sptr): New convenience typedefs. (translation_unit_diff): Add comments. (class corpus_diff): New type. (compute_diff): New overload for corpus_diff. * include/abg-corpus.h (corpus::{functions, variables}): New typedefs. (corpus::{operator==, get_functions, get_variables}): New members. * include/abg-diff-utils.h (struct deep_ptr_eq_functor): New functor. * include/abg-ir.h (translation_unit::operator==): New member equality operator. * src/abg-comparison.cc (struct corpus_diff::priv): New private struct holding the private members of corpus_diff. (corpus_diff::priv::{lookup_tables_empty, clear_lookup_tables, ensure_lookup_tables_populated}): Define new private member functions. (corpus_diff::{corpus_diff, first_corpus, second_corpus, function_changes, variable_changes, length, report}): New public members. (struct noop_deleter): New struct. (compute_diff): New implementation for corpus_diff. * src/abg-corpus.cc (struct corpus::priv): Renamed corpus::impl into this. Add new fns, vars and is_symbol_table_built data members. (corpus::priv::build_symbol_table): New member function. (class symtab_build_visitor_type): New visitor type to build the symbol table. (struct func_comp, struct var_comp): New comparison functors. (corpus::priv::build_symbol_table): Define new member function. (corpus::{corpus, add, get_translation_units, operator==, get_functions, get_variables}): Define new members. * src/abg-ir.cc (translation_unit::operator==): Define new member equality operator. (operator==(translation_unit_sptr l, translation_unit_sptr r)): Define new equality operator. * tools/abg-tools-utils.h (enum file_type): New enum. (guess_file_type): Declare new function. * tools/abg-tools-utils.cc (guess_file_type): define new function. * tools/bidiff.cc (main): Guess the type of the files given in input and support elf files reading and diffing. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-23 13:05:19 +00:00
const functions&
get_functions() const;
Build the set of exported decls directly during DWARF loading Until now, after the ABI corpus was built from DWARF, the translation units of the corpus were walked and each function was considered for addition into the set of exported decls. During that walking, a first version of the set was put into a std::list and then, a set of filters (user-provided tunables like a list of regular expressions to keep or remove some functions from the exported decls) is applied to that list and the final set of exported decls is put in a std::vector. Profiling has shown that this process of building the set of exported decls is a hot spot and also that the current use of std::list was a big memory consumer especially on binaries with large exported symbol tables. So this patch builds the set of exported decls "on the fly", during DWARF reading, as opposed to waiting after the DWARF is read and having to walk the corpus again. The corpus defines a policy object that encapsulates the methods for determining if a function or variable ought to be part of the set of exported decls. The DWARF reader uses that policy object to determine which functions and variables among those built during the reading ought be part of the exported decls; the policy object also has a reference to the final vector (managed by the corpus) that must hold the exported decls, so the decls are put in that vector directly without unnecessary copying. Profiling also showed that the string copying done by {var_decl,function_decl}::get_id() was a hot spot. So the patch returns a reference there. With this patch applied, the peak memory consumption of abidiff on libabigail.so itself (abidiff libabigail.so libabigail.so) is 54MB of resident and takes 2 minutes and 16s (on my slow system). Without the patch the peak consumption was more than 300MB and it was taking slightly longer. For the test of bug https://sourceware.org/bugzilla/show_bug.cgi?id=17948, memory consumtion and wall clock time spent is down from 3.4GB and 1m59s to 760MB and 0m43s. * include/abg-ir.h ({var,function}_decl::get_id): Return a reference. * src/abg-ir.cc ({var,function}_decl::get_id): Return a reference to the string rather than copying it over. * include/abg-corpus.h (class corpus::exported_decls_builder): Declare new type. (corpus::{sort_functions, sort_variables, maybe_drop_some_exported_decls, get_exported_decls_builder}): Declare new methods. * src/abg-corpus.h (corpus::exported_decls_builder::priv): Define new type. (class symtab_build_visitor_type): Remove this type that is useless now. (corpus::exported_decls_builder::{exported_decls_builder, exported_functions, exported_variables, maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}): Define new functions. (corpus::priv::is_public_decl_table_built): Remove this data member. It's now useless. (corpus::priv::priv): Adjust. (corpus::priv::build_public_decl_table): Remove this member function. It's now useless. (corpus::{priv::build_unreferenced_symbols_tables, get_functions, get_variables}): No need to build the public decls table here. It's already built by the time the corpus is read from DWARF now. (corpus::{sort_functions, sort_variables, maybe_drop_some_exported_decls, get_exported_decls_builder}): Define new member functions. * src/abg-dwarf-reader.cc (read_context::exported_decls_builder): New data member. (read_context::read_context): Initialize it. (read_context::{exported_decls_builder, maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}): Define new member functions. (read_debug_info_into_corpus): Get the the new 'exported_decls_builder' object from the corpus and stick it into the read context so the DWARF reading code can use it to build the exported decls set. When the DWARF reading is done, sort the set of exported functions and variables that was built. (build_ir_node_from_die): When a function or variable is built, consider putting it into the set of exported decls. * tools/abicompat.cc (main): Now that the exported decls is built *before* we had a chance to stick the list of symbol IDs to keep, call corpus::maybe_drop_some_exported_decls() to update the set of exported decls we should consider for the corpus. was applied to that list and the final Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-23 19:39:32 +00:00
void
sort_functions();
Initial support for diffing ABI corpus files * include/abg-comparison.h (string_function_ptr_map) (changed_function_ptr, string_changed_function_ptr_map) (corpus_diff_sptr): New convenience typedefs. (translation_unit_diff): Add comments. (class corpus_diff): New type. (compute_diff): New overload for corpus_diff. * include/abg-corpus.h (corpus::{functions, variables}): New typedefs. (corpus::{operator==, get_functions, get_variables}): New members. * include/abg-diff-utils.h (struct deep_ptr_eq_functor): New functor. * include/abg-ir.h (translation_unit::operator==): New member equality operator. * src/abg-comparison.cc (struct corpus_diff::priv): New private struct holding the private members of corpus_diff. (corpus_diff::priv::{lookup_tables_empty, clear_lookup_tables, ensure_lookup_tables_populated}): Define new private member functions. (corpus_diff::{corpus_diff, first_corpus, second_corpus, function_changes, variable_changes, length, report}): New public members. (struct noop_deleter): New struct. (compute_diff): New implementation for corpus_diff. * src/abg-corpus.cc (struct corpus::priv): Renamed corpus::impl into this. Add new fns, vars and is_symbol_table_built data members. (corpus::priv::build_symbol_table): New member function. (class symtab_build_visitor_type): New visitor type to build the symbol table. (struct func_comp, struct var_comp): New comparison functors. (corpus::priv::build_symbol_table): Define new member function. (corpus::{corpus, add, get_translation_units, operator==, get_functions, get_variables}): Define new members. * src/abg-ir.cc (translation_unit::operator==): Define new member equality operator. (operator==(translation_unit_sptr l, translation_unit_sptr r)): Define new equality operator. * tools/abg-tools-utils.h (enum file_type): New enum. (guess_file_type): Declare new function. * tools/abg-tools-utils.cc (guess_file_type): define new function. * tools/bidiff.cc (main): Guess the type of the files given in input and support elf files reading and diffing. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-23 13:05:19 +00:00
const variables&
get_variables() const;
Add --drop/--keep options to bidiff * include/abg-sptr-utils.h: New file. * include/Makefile.am: Add abg-sptr-utils. to the build system. * include/abg-libxml-utils.h (reader_sptr, xml_char_sptr): Remove these typedefs as there are now in abg-sptr-utils. (build_sptr): Likewise for this template and its specializations declarations. * src/abg-libxml-utils.cc (sptr_utils::build_sptr): Mode the definition of the specializations for xmlTextReader and xmlChar into the sptr_utils namespace. * include/abg-corpus.h (corpus::{get_regex_patterns_of_fns_to_suppress, get_regex_patterns_of_vars_to_suppress, get_regex_patterns_of_fns_to_keep, get_regex_patterns_of_vars_to_keep}): Declare new member functions. * src/abg-comparison.cc (sptr_utils::regex_t_deleter): Define new functor. (build_sptr) Define new specialization for regex_t. (struct array_deleter): Remove unused functor. (corpus::priv::regex_patterns_{fns,vars}_to_{suppress,keep}): New data members. (symtab_build_visitor_type::regex_patterns_{fns,vars}_to_{suppress,keep}): Likewise. (symtab_build_visitor_type::r_{fns,vars}_{suppress,keep})): Likewise. (symtab_build_visitor_type::symtab_build_visitor_type): Update the signature of this constructor to take regex patterns for functions and variables to suppress and to keep. Also, initialize the data members from these new parameters. (symtab_build_visitor_type::regex_{fns,vars}_{suppress,keep}): New member functions. (symtab_build_visitor_type::{add_fn_to_wip_fns, add_var_to_wip_vars}): Likewise. (symtab_build_visitor_type::visit) Use either add_fn_to_wip_fns or add_var_to_wip_vars depending on the overload of the visit() member. (corpus::priv::build_symbol_table): Update for the change of the symtab_build_visitor_type constructor signature. (corpus::get_regex_patterns_of_{fns,vars}_to_{suppress,keep}): Define new member functions. * tools/bidiff.cc (options::{drop,keep}_{fn,var}_regex_patterns}): New data member. (display_usage): Add help strings for --drop, --drop-fn, --drop-var, --keep, --keep-fn, --keep-var (parse_command_line): Parse the command lines above. (set_corpus_keep_drop_regex_patterns): Define new static function. (main): Use the new set_corpus_keep_drop_regex_patterns. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 16:26:18 +00:00
Build the set of exported decls directly during DWARF loading Until now, after the ABI corpus was built from DWARF, the translation units of the corpus were walked and each function was considered for addition into the set of exported decls. During that walking, a first version of the set was put into a std::list and then, a set of filters (user-provided tunables like a list of regular expressions to keep or remove some functions from the exported decls) is applied to that list and the final set of exported decls is put in a std::vector. Profiling has shown that this process of building the set of exported decls is a hot spot and also that the current use of std::list was a big memory consumer especially on binaries with large exported symbol tables. So this patch builds the set of exported decls "on the fly", during DWARF reading, as opposed to waiting after the DWARF is read and having to walk the corpus again. The corpus defines a policy object that encapsulates the methods for determining if a function or variable ought to be part of the set of exported decls. The DWARF reader uses that policy object to determine which functions and variables among those built during the reading ought be part of the exported decls; the policy object also has a reference to the final vector (managed by the corpus) that must hold the exported decls, so the decls are put in that vector directly without unnecessary copying. Profiling also showed that the string copying done by {var_decl,function_decl}::get_id() was a hot spot. So the patch returns a reference there. With this patch applied, the peak memory consumption of abidiff on libabigail.so itself (abidiff libabigail.so libabigail.so) is 54MB of resident and takes 2 minutes and 16s (on my slow system). Without the patch the peak consumption was more than 300MB and it was taking slightly longer. For the test of bug https://sourceware.org/bugzilla/show_bug.cgi?id=17948, memory consumtion and wall clock time spent is down from 3.4GB and 1m59s to 760MB and 0m43s. * include/abg-ir.h ({var,function}_decl::get_id): Return a reference. * src/abg-ir.cc ({var,function}_decl::get_id): Return a reference to the string rather than copying it over. * include/abg-corpus.h (class corpus::exported_decls_builder): Declare new type. (corpus::{sort_functions, sort_variables, maybe_drop_some_exported_decls, get_exported_decls_builder}): Declare new methods. * src/abg-corpus.h (corpus::exported_decls_builder::priv): Define new type. (class symtab_build_visitor_type): Remove this type that is useless now. (corpus::exported_decls_builder::{exported_decls_builder, exported_functions, exported_variables, maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}): Define new functions. (corpus::priv::is_public_decl_table_built): Remove this data member. It's now useless. (corpus::priv::priv): Adjust. (corpus::priv::build_public_decl_table): Remove this member function. It's now useless. (corpus::{priv::build_unreferenced_symbols_tables, get_functions, get_variables}): No need to build the public decls table here. It's already built by the time the corpus is read from DWARF now. (corpus::{sort_functions, sort_variables, maybe_drop_some_exported_decls, get_exported_decls_builder}): Define new member functions. * src/abg-dwarf-reader.cc (read_context::exported_decls_builder): New data member. (read_context::read_context): Initialize it. (read_context::{exported_decls_builder, maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}): Define new member functions. (read_debug_info_into_corpus): Get the the new 'exported_decls_builder' object from the corpus and stick it into the read context so the DWARF reading code can use it to build the exported decls set. When the DWARF reading is done, sort the set of exported functions and variables that was built. (build_ir_node_from_die): When a function or variable is built, consider putting it into the set of exported decls. * tools/abicompat.cc (main): Now that the exported decls is built *before* we had a chance to stick the list of symbol IDs to keep, call corpus::maybe_drop_some_exported_decls() to update the set of exported decls we should consider for the corpus. was applied to that list and the final Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-23 19:39:32 +00:00
void
sort_variables();
Support comparing symbols not referenced by debug info * doc/manuals/abidiff.rst: Adjust intro to mention that w/o debug info, abidiff now works but just report about added/removed symbols. Add documentation about the new --no-unreferenced-symbols option. * include/abg-comparison.h (string_elf_symbol_map): New typedef. (diff_context::show_symbols_unreferenced_by_debug_info): Declare new accessors. * src/abg-comparison.cc (diff_context::priv::show_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_symbols_unreferenced_by_debug_info): Implement these accessors. (corpus_diff::priv::{unrefed_fn_syms_edit_script_, unrefed_var_syms_edit_script_, added_unrefed_fn_syms_, deleted_unrefed_fn_syms_, added_unrefed_var_syms_, deleted_unrefed_var_syms_}): New data members. (corpus_diff::priv::diff_stats::{num_func_syms_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): New data members. (corpus_diff::priv::diff_stats::diff_stats): Adjust. (corpus_diff::ensure_lookup_tables_populated): Populate lookup tables for added/removed symbols that are not referenced by any debug info. (corpus_diff::priv::apply_filters_and_compute_diff_stats): Compute stats for the added/removed symbols not referenced by any debug info. (corpus_diff::priv::emit_diff_stats): Emit stats about added/removed symbols that are not referenced by any debug info. (corpus_diff::length): Adjust to take in account added/removed symbols not referenced by any debug info. (show_linkage_name_and_aliases): New static function. (corpus_diff::report): When emitting a symbol name, emit its version too, and tell if it aliases other symbols. Avoid emitted extra new lines. Report added/removed symbols not referenced by any debug info. (compute_diff): In the overload for corpus_sptr, compute the diffs for symbols not referenced by debug info. * include/abg-corpus.h (corpus::get_unreferenced_{function,variable}_symbols): Declare new member functions. * src/abg-corpus.cc (corpus_priv::{unrefed_fun_symbols, unrefed_var_symbols}): New data members. (corpus_priv::build_unreferenced_symbols_tables): Define new member function. (struct comp_elf_symbols_functor): New functor. (corpus::is_empty): Adjust to take in account added/removed symbols not referenced by debug info. (corpus::{get_unreferenced_function_symbols, corpus::get_unreferenced_variable_symbols}): Define these accessors. * include/abg-dwarf-reader.h (enum status): Transform this into bitfields. Add a STATUS_UNKNOWN value that has the value 0. (operator|(status, status), operator&(status, status)) (operator|=(status&, status), operator&=(status, status)): New bit-wise operators to manipulate instances of the status bit-field. * src/abg-dwarf-reader.cc (get_version_for_symbol): Fix this to avoid returning garbage version sometimes. (read_debug_info_into_corpus): Fix this to return a non-null but empty corpus_sptr when there is no debug info available. (operator|(status, status), operator&(status, status)) (operator|=(status&, status), operator&=(status, status)): Define these new bitwise operators to manipulate instances of the status bit-field. (read_corpus_from_elf): Now that the abigail::dwarf_reader::status is a bit-field, set it to reflect if debug info and/or symbol tables have been found. Do not bail out if debug info hasn't been found. Rather, keep going, and go look for symbols-only; this is a kind of operating in degraded mode. * include/abg-ir.h (elf_symbol::get_aliases_id_string): Add a flag that says if the current instance of elf_symbol should be included in the list of aliases or not. * src/abg-ir.cc (elf_symbol::get_aliases_id_string): Define it. * tests/data/test-diff-dwarf/test16-syms-only-v{0,1}.o: New test input. * tools/abidiff.cc (options::show_symbols_not_referenced_by_debug_info): New data member. (options:options): Adjust. (display_usage): Add an info string for the new --no-unreferenced-symbols command line option. (parse_command_line): Parse the new --no-unreferenced-symbols command line. (set_diff_context_from_opts): Set the diff_context according to the presence of --no-unreferenced-symbols. (main): Adjust for the fact that abigail::dwarf_reader::status is now a bit-field. * tools/abilint.cc (main): Adjust for the fact that abigail::dwarf_reader::status is now a bit-field.. (): * tests/data/test-diff-dwarf/test16-syms-only-report.txt: New test reference output. * tests/data/test-diff-dwarf/test16-syms-only-v{0,1}.cc: Source code for new test input. * tests/data/test-diff-dwarf/test17-non-refed-syms-v{0,1}.o: New test input. * tests/data/test-diff-dwarf/test17-non-refed-syms-v{0,1}.cc: New source code for test input. * tests/data/test-diff-dwarf/libtest18-alias-sym-v{0,1}.so: New test input. * tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Reference output for new test input. * tests/data/test-diff-dwarf/test18-alias-sym-v{0,1}.cc: Source code for new test input. * tests/data/test-diff-dwarf/test18-alias-sym-version-script: Source code for new test input. * tests/Makefile.am: Add the new test materials to the source distribution. * tests/test-diff-dwarf.cc(in_out_specs): Add the new input tests above to the array of tests to run by this harness. (main): Emit empty reports for empty resulting diffs. * tests/data/test-diff-dwarf/test{0,8,9,12,14-inline-report,}-report.txt: Adjust. * tests/data/test-diff-filter/test{0,01,2,4,5,7,8,9,10,12,13,15-0,15-1}-report.txt: Likewise. * tests/data/test-diff-filter/test{19-enum,20-inline,}-report-0.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-{1,2}.txt: Likewise. * tests/data/test-diff-suppr/test{1,2}-typedef-suppr-report-1.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-22 16:05:31 +00:00
const elf_symbols&
get_unreferenced_function_symbols() const;
const elf_symbols&
get_unreferenced_variable_symbols() const;
Add --drop/--keep options to bidiff * include/abg-sptr-utils.h: New file. * include/Makefile.am: Add abg-sptr-utils. to the build system. * include/abg-libxml-utils.h (reader_sptr, xml_char_sptr): Remove these typedefs as there are now in abg-sptr-utils. (build_sptr): Likewise for this template and its specializations declarations. * src/abg-libxml-utils.cc (sptr_utils::build_sptr): Mode the definition of the specializations for xmlTextReader and xmlChar into the sptr_utils namespace. * include/abg-corpus.h (corpus::{get_regex_patterns_of_fns_to_suppress, get_regex_patterns_of_vars_to_suppress, get_regex_patterns_of_fns_to_keep, get_regex_patterns_of_vars_to_keep}): Declare new member functions. * src/abg-comparison.cc (sptr_utils::regex_t_deleter): Define new functor. (build_sptr) Define new specialization for regex_t. (struct array_deleter): Remove unused functor. (corpus::priv::regex_patterns_{fns,vars}_to_{suppress,keep}): New data members. (symtab_build_visitor_type::regex_patterns_{fns,vars}_to_{suppress,keep}): Likewise. (symtab_build_visitor_type::r_{fns,vars}_{suppress,keep})): Likewise. (symtab_build_visitor_type::symtab_build_visitor_type): Update the signature of this constructor to take regex patterns for functions and variables to suppress and to keep. Also, initialize the data members from these new parameters. (symtab_build_visitor_type::regex_{fns,vars}_{suppress,keep}): New member functions. (symtab_build_visitor_type::{add_fn_to_wip_fns, add_var_to_wip_vars}): Likewise. (symtab_build_visitor_type::visit) Use either add_fn_to_wip_fns or add_var_to_wip_vars depending on the overload of the visit() member. (corpus::priv::build_symbol_table): Update for the change of the symtab_build_visitor_type constructor signature. (corpus::get_regex_patterns_of_{fns,vars}_to_{suppress,keep}): Define new member functions. * tools/bidiff.cc (options::{drop,keep}_{fn,var}_regex_patterns}): New data member. (display_usage): Add help strings for --drop, --drop-fn, --drop-var, --keep, --keep-fn, --keep-var (parse_command_line): Parse the command lines above. (set_corpus_keep_drop_regex_patterns): Define new static function. (main): Use the new set_corpus_keep_drop_regex_patterns. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 16:26:18 +00:00
vector<string>&
get_regex_patterns_of_fns_to_suppress();
const vector<string>&
get_regex_patterns_of_fns_to_suppress() const;
vector<string>&
get_regex_patterns_of_vars_to_suppress();
const vector<string>&
get_regex_patterns_of_vars_to_suppress() const;
vector<string>&
get_regex_patterns_of_fns_to_keep();
const vector<string>&
get_regex_patterns_of_fns_to_keep() const;
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
vector<string>&
get_sym_ids_of_fns_to_keep();
const vector<string>&
get_sym_ids_of_fns_to_keep() const;
Add --drop/--keep options to bidiff * include/abg-sptr-utils.h: New file. * include/Makefile.am: Add abg-sptr-utils. to the build system. * include/abg-libxml-utils.h (reader_sptr, xml_char_sptr): Remove these typedefs as there are now in abg-sptr-utils. (build_sptr): Likewise for this template and its specializations declarations. * src/abg-libxml-utils.cc (sptr_utils::build_sptr): Mode the definition of the specializations for xmlTextReader and xmlChar into the sptr_utils namespace. * include/abg-corpus.h (corpus::{get_regex_patterns_of_fns_to_suppress, get_regex_patterns_of_vars_to_suppress, get_regex_patterns_of_fns_to_keep, get_regex_patterns_of_vars_to_keep}): Declare new member functions. * src/abg-comparison.cc (sptr_utils::regex_t_deleter): Define new functor. (build_sptr) Define new specialization for regex_t. (struct array_deleter): Remove unused functor. (corpus::priv::regex_patterns_{fns,vars}_to_{suppress,keep}): New data members. (symtab_build_visitor_type::regex_patterns_{fns,vars}_to_{suppress,keep}): Likewise. (symtab_build_visitor_type::r_{fns,vars}_{suppress,keep})): Likewise. (symtab_build_visitor_type::symtab_build_visitor_type): Update the signature of this constructor to take regex patterns for functions and variables to suppress and to keep. Also, initialize the data members from these new parameters. (symtab_build_visitor_type::regex_{fns,vars}_{suppress,keep}): New member functions. (symtab_build_visitor_type::{add_fn_to_wip_fns, add_var_to_wip_vars}): Likewise. (symtab_build_visitor_type::visit) Use either add_fn_to_wip_fns or add_var_to_wip_vars depending on the overload of the visit() member. (corpus::priv::build_symbol_table): Update for the change of the symtab_build_visitor_type constructor signature. (corpus::get_regex_patterns_of_{fns,vars}_to_{suppress,keep}): Define new member functions. * tools/bidiff.cc (options::{drop,keep}_{fn,var}_regex_patterns}): New data member. (display_usage): Add help strings for --drop, --drop-fn, --drop-var, --keep, --keep-fn, --keep-var (parse_command_line): Parse the command lines above. (set_corpus_keep_drop_regex_patterns): Define new static function. (main): Use the new set_corpus_keep_drop_regex_patterns. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 16:26:18 +00:00
vector<string>&
get_regex_patterns_of_vars_to_keep();
const vector<string>&
get_regex_patterns_of_vars_to_keep() const;
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
vector<string>&
get_sym_ids_of_vars_to_keep();
const vector<string>&
get_sym_ids_of_vars_to_keep() const;
Build the set of exported decls directly during DWARF loading Until now, after the ABI corpus was built from DWARF, the translation units of the corpus were walked and each function was considered for addition into the set of exported decls. During that walking, a first version of the set was put into a std::list and then, a set of filters (user-provided tunables like a list of regular expressions to keep or remove some functions from the exported decls) is applied to that list and the final set of exported decls is put in a std::vector. Profiling has shown that this process of building the set of exported decls is a hot spot and also that the current use of std::list was a big memory consumer especially on binaries with large exported symbol tables. So this patch builds the set of exported decls "on the fly", during DWARF reading, as opposed to waiting after the DWARF is read and having to walk the corpus again. The corpus defines a policy object that encapsulates the methods for determining if a function or variable ought to be part of the set of exported decls. The DWARF reader uses that policy object to determine which functions and variables among those built during the reading ought be part of the exported decls; the policy object also has a reference to the final vector (managed by the corpus) that must hold the exported decls, so the decls are put in that vector directly without unnecessary copying. Profiling also showed that the string copying done by {var_decl,function_decl}::get_id() was a hot spot. So the patch returns a reference there. With this patch applied, the peak memory consumption of abidiff on libabigail.so itself (abidiff libabigail.so libabigail.so) is 54MB of resident and takes 2 minutes and 16s (on my slow system). Without the patch the peak consumption was more than 300MB and it was taking slightly longer. For the test of bug https://sourceware.org/bugzilla/show_bug.cgi?id=17948, memory consumtion and wall clock time spent is down from 3.4GB and 1m59s to 760MB and 0m43s. * include/abg-ir.h ({var,function}_decl::get_id): Return a reference. * src/abg-ir.cc ({var,function}_decl::get_id): Return a reference to the string rather than copying it over. * include/abg-corpus.h (class corpus::exported_decls_builder): Declare new type. (corpus::{sort_functions, sort_variables, maybe_drop_some_exported_decls, get_exported_decls_builder}): Declare new methods. * src/abg-corpus.h (corpus::exported_decls_builder::priv): Define new type. (class symtab_build_visitor_type): Remove this type that is useless now. (corpus::exported_decls_builder::{exported_decls_builder, exported_functions, exported_variables, maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}): Define new functions. (corpus::priv::is_public_decl_table_built): Remove this data member. It's now useless. (corpus::priv::priv): Adjust. (corpus::priv::build_public_decl_table): Remove this member function. It's now useless. (corpus::{priv::build_unreferenced_symbols_tables, get_functions, get_variables}): No need to build the public decls table here. It's already built by the time the corpus is read from DWARF now. (corpus::{sort_functions, sort_variables, maybe_drop_some_exported_decls, get_exported_decls_builder}): Define new member functions. * src/abg-dwarf-reader.cc (read_context::exported_decls_builder): New data member. (read_context::read_context): Initialize it. (read_context::{exported_decls_builder, maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}): Define new member functions. (read_debug_info_into_corpus): Get the the new 'exported_decls_builder' object from the corpus and stick it into the read context so the DWARF reading code can use it to build the exported decls set. When the DWARF reading is done, sort the set of exported functions and variables that was built. (build_ir_node_from_die): When a function or variable is built, consider putting it into the set of exported decls. * tools/abicompat.cc (main): Now that the exported decls is built *before* we had a chance to stick the list of symbol IDs to keep, call corpus::maybe_drop_some_exported_decls() to update the set of exported decls we should consider for the corpus. was applied to that list and the final Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-23 19:39:32 +00:00
void
maybe_drop_some_exported_decls();
exported_decls_builder_sptr
get_exported_decls_builder() const;
Prepare serialization API for multiple backends * include/abg-reader.h: New file with abigail::xml_reader APIs. * include/abg-writer.h: New file with abigail::xml_writer APIs. * include/Makefile.am: Add the new files above to the source distribution. * src/abg-reader.cc: Update top-file comments. (namespace xml_reader): Rename namespace reader into this. (read_to_translation_unit, read_corpus_from_archive): New static functions. (read_translation_unit_from_file) (read_translation_unit_from_file, read_corpus_from_file): New entry points. (struct array_deleter): New functor. (translation_unit::read): Remove this. * src/abg-writer.cc: Update top file comments. (namespace xml_writer): Rename namespace writer into this. (struct archive_write_ctxt): New internal type. (create_archive_write_context, write_translation_unit_to_archive) (write_translation_unit, write_corpus_to_archive): New low level static functions overloads. (write_corpus_to_archive, write_translation_unit): Public higher level overloads. (translation_unit::write): Remove. (dump): Update for new xml_writer namespace. * include/abg-ir.h (translation_unit::{read, write}): Remove these serialization methods. * include/abg-corpus.h (corpus_sptr): New convenience typedef. (corpus::{read, write}): Remove these methods. * src/abg-corpus.cc (corpus::{read, write}) (corpus::impl::{serialized_tus, archive}): Remove these members. (corpus::impl::{get_archive, close_archive, write_tu_to_archive, read_to_translation_unit}): Remove these methods. * tests/test-bidiff.cc (main): Update for usage of the new xml_reader API. * tests/test-read-write.cc (main): Likewise. Update for the usage of the new xml_writer API, too. * tests/test-walker.cc (main): Update for the usage of the new xml_reader API. * tests/test-write-read-archive.cc (main): Likewise. And for the xml_writer API, too. * tools/biar.cc (add_tus_to_archive, extract_tus_from_archive): Likewise. * tools/bidiff.cc (main): Likewise, for xml_reader APIs. * tools/bilint.cc (main): Likewise, for xml_writer APIs, too. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-04 08:44:20 +00:00
};// end class corpus.
Initial writing/reading of an ABI corpus to an archive * configure.ac: Support detection of libzip dependency. Define new DEPS_CFLAGS and DEPS_LIBS variables for use in Makefile.am to refer to the dependency headers and libraries. * doc/website/mainpage.txt: Update this to talk about the new libzip dependency. * include/Makefile.am: Add abg-libzip-utils.h to the build system. * include/abg-corpus.h (corps): Hide abigail::corpus's private behind a pimpl idiom. (corpus::{drop_translation_units, get_file_path, set_file_path, write, read}): New methods. * include/abg-libxml-utils.h (new_reader_from_buffer): Declare new function. * include/abg-libzip-utils.h: New file. * src/Makefile.am: Add abg-corpus.cc and abg-libzip-utils.cc to the build system. Refer to the library and headers dependencies via the new DEPS_LIBS and DEPS_CFLAGS variables. * src/abg-corpus.cc: New file. * src/abg-ir.cc (translation::set_path): New method. * src/abg-libxml-utils.cc (new_reader_from_buffer): Define new function. * src/abg-libzip-utils.cc: New file. * src/abg-reader.cc (translation_unit::read): New overload. * src/abg-writer.cc: Inject the names from the std namespace into the abigail namespace, rather than into abigail::writer. (abigail::translation_unit::write): New overload. This can now use ofstream and the other stuff from std that are injected in the abigail:: namespace. * tests/Makefile.am: Add tests/test-write-read-archive.cc to the build system; use that to build runtestwritereadarchive. Also add the input test data from tests/data/test-write-read-archive/test[0-4].xml. * /tests/data/test-write-read-archive/test[0-4].xml: New test input data files. * tests/test-write-read-archive.cc: New test for this archive write/read support. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 13:18:59 +00:00
Build the set of exported decls directly during DWARF loading Until now, after the ABI corpus was built from DWARF, the translation units of the corpus were walked and each function was considered for addition into the set of exported decls. During that walking, a first version of the set was put into a std::list and then, a set of filters (user-provided tunables like a list of regular expressions to keep or remove some functions from the exported decls) is applied to that list and the final set of exported decls is put in a std::vector. Profiling has shown that this process of building the set of exported decls is a hot spot and also that the current use of std::list was a big memory consumer especially on binaries with large exported symbol tables. So this patch builds the set of exported decls "on the fly", during DWARF reading, as opposed to waiting after the DWARF is read and having to walk the corpus again. The corpus defines a policy object that encapsulates the methods for determining if a function or variable ought to be part of the set of exported decls. The DWARF reader uses that policy object to determine which functions and variables among those built during the reading ought be part of the exported decls; the policy object also has a reference to the final vector (managed by the corpus) that must hold the exported decls, so the decls are put in that vector directly without unnecessary copying. Profiling also showed that the string copying done by {var_decl,function_decl}::get_id() was a hot spot. So the patch returns a reference there. With this patch applied, the peak memory consumption of abidiff on libabigail.so itself (abidiff libabigail.so libabigail.so) is 54MB of resident and takes 2 minutes and 16s (on my slow system). Without the patch the peak consumption was more than 300MB and it was taking slightly longer. For the test of bug https://sourceware.org/bugzilla/show_bug.cgi?id=17948, memory consumtion and wall clock time spent is down from 3.4GB and 1m59s to 760MB and 0m43s. * include/abg-ir.h ({var,function}_decl::get_id): Return a reference. * src/abg-ir.cc ({var,function}_decl::get_id): Return a reference to the string rather than copying it over. * include/abg-corpus.h (class corpus::exported_decls_builder): Declare new type. (corpus::{sort_functions, sort_variables, maybe_drop_some_exported_decls, get_exported_decls_builder}): Declare new methods. * src/abg-corpus.h (corpus::exported_decls_builder::priv): Define new type. (class symtab_build_visitor_type): Remove this type that is useless now. (corpus::exported_decls_builder::{exported_decls_builder, exported_functions, exported_variables, maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}): Define new functions. (corpus::priv::is_public_decl_table_built): Remove this data member. It's now useless. (corpus::priv::priv): Adjust. (corpus::priv::build_public_decl_table): Remove this member function. It's now useless. (corpus::{priv::build_unreferenced_symbols_tables, get_functions, get_variables}): No need to build the public decls table here. It's already built by the time the corpus is read from DWARF now. (corpus::{sort_functions, sort_variables, maybe_drop_some_exported_decls, get_exported_decls_builder}): Define new member functions. * src/abg-dwarf-reader.cc (read_context::exported_decls_builder): New data member. (read_context::read_context): Initialize it. (read_context::{exported_decls_builder, maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}): Define new member functions. (read_debug_info_into_corpus): Get the the new 'exported_decls_builder' object from the corpus and stick it into the read context so the DWARF reading code can use it to build the exported decls set. When the DWARF reading is done, sort the set of exported functions and variables that was built. (build_ir_node_from_die): When a function or variable is built, consider putting it into the set of exported decls. * tools/abicompat.cc (main): Now that the exported decls is built *before* we had a chance to stick the list of symbol IDs to keep, call corpus::maybe_drop_some_exported_decls() to update the set of exported decls we should consider for the corpus. was applied to that list and the final Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-23 19:39:32 +00:00
/// Abstracts the building of the set of exported variables and
/// functions.
///
/// Given a function or variable, this type can decide if it belongs
/// to the list of exported functions and variables based on all the
/// parameters needed.
class corpus::exported_decls_builder
{
public:
class priv;
/// Convenience typedef for shared_ptr<priv>
typedef shared_ptr<priv> priv_sptr;
friend class corpus;
private:
priv_sptr priv_;
// Forbid default construction.
exported_decls_builder();
public:
exported_decls_builder(functions& fns,
variables& vars,
strings_type& fns_suppress_regexps,
strings_type& vars_suppress_regexps,
strings_type& fns_keep_regexps,
strings_type& vars_keep_regexps,
strings_type& sym_id_of_fns_to_keep,
strings_type& sym_id_of_vars_to_keep);
const functions&
exported_functions() const;
functions&
exported_functions();
const variables&
exported_variables() const;
variables&
exported_variables();
void
maybe_add_fn_to_exported_fns(function_decl*);
void
maybe_add_var_to_exported_vars(var_decl*);
}; //corpus::exported_decls_builder
}// end namespace ir
}//end namespace abigail
#endif //__ABG_CORPUS_H__