2013-04-03 06:23:33 +00:00
|
|
|
// -*- mode: C++ -*-
|
2013-07-17 21:39:24 +00:00
|
|
|
//
|
2016-02-24 13:53:57 +00:00
|
|
|
// Copyright (C) 2013-2016 Red Hat, Inc.
|
2013-07-16 19:58:43 +00:00
|
|
|
//
|
2013-07-17 21:39:24 +00:00
|
|
|
// This file is part of the GNU Application Binary Interface Generic
|
|
|
|
// Analysis and Instrumentation Library (libabigail). This library is
|
|
|
|
// free software; you can redistribute it and/or modify it under the
|
2013-07-16 19:58:43 +00:00
|
|
|
// terms of the GNU Lesser General Public License as published by the
|
|
|
|
// Free Software Foundation; either version 3, or (at your option) any
|
2013-07-17 21:39:24 +00:00
|
|
|
// 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
|
2013-07-16 19:58:43 +00:00
|
|
|
// General Lesser Public License for more details.
|
2013-07-17 21:39:24 +00:00
|
|
|
|
2013-07-16 19:58:43 +00:00
|
|
|
// 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/>.
|
2013-07-17 21:39:24 +00:00
|
|
|
|
2013-04-03 06:23:33 +00:00
|
|
|
/// @file
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
|
|
|
#ifndef __ABG_CORPUS_H__
|
|
|
|
#define __ABG_CORPUS_H__
|
|
|
|
|
2013-08-29 14:38:24 +00:00
|
|
|
#include <abg-ir.h>
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2014-10-11 09:27:59 +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.
|
2013-08-07 00:03:28 +00:00
|
|
|
class corpus
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
{
|
2013-08-02 03:16:22 +00:00
|
|
|
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;
|
2013-08-02 03:16:22 +00:00
|
|
|
|
2014-04-21 15:22:11 +00:00
|
|
|
/// 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
|
|
|
|
};
|
|
|
|
|
2013-08-02 03:16:22 +00:00
|
|
|
private:
|
2013-08-07 00:03:28 +00:00
|
|
|
corpus();
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
Bug 19658 - Type canonicalization slow for the 2nd binary loaded
When loading two binaries (e.g, when the library is used by abidiff),
and when the second one does have deep types (e.g, classes with
recursively deep hierarchies) with lots of duplicated types in lots of
translation units, canonicalizing the types of the second binaries can
take a *lot* of time, given the quadratic nature of the structural
type comparisons that take place and the cheer number of those type
comparisons (because of the duplication).
There is already an optimization based on the One Definition Rule in
the canonicalization code. That optimization avoids structural
comparison of types of the same corpus which have the same name. But
then, this optimization only works on types of the first corpus.
As soon as we are loading a second corpus, all types being
canonicalized are coming from a corpus that is different from the
first corpus, by definition. So a structural comparison is taking
place for *all* those types.
The patch extends the existing optimization to make it work on the
second corpus being loaded. Once a type from the second corpus is
canonicalized, the canonical type is cached inside the corpus. Then,
later, when a type with the same name has to be canonicalized, the
system looks inside the cache of that corpus to see if there is a
canonicalized type the same name.
I tested the patch on this command:
abipkgdiff --d1 nss-debuginfo-3.19.1-8.el6_7.i686.rpm \
--d2 nss-debuginfo-3.21.0-0.1.el6_7.i686.rpm \
nss-3.19.1-8.el6_7.i686.rpm \
nss-3.21.0-0.1.el6_7.i686.rpm
I whitnessed a x10 speedup, at least.
On binaries that don't have a lot of duplicated deep types, the patch
doesn't have any noticeable effect. At lesat It doesn't slow things
down in that case.
* include/abg-corpus.h (corpus::{record_canonical_type,
lookup_canonical_type}): Declare new member functions.
* src/abg-corpus.cc (corpus::priv::canonical_types_): New data
member.
(corpus::{record_canonical_type, lookup_canonical_type}): Define
new member functions.
* src/abg-ir.cc (type_base::get_canonical_type_for): Cache the
canonical type inside the corpus of the type being canonicalized.
Then later when canonicalizing another type, lookup in the cache
inside its corpus to see if there is a type with the same name.
* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt:
Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-18 14:40:09 +00:00
|
|
|
void record_canonical_type(const type_base_sptr&) const;
|
|
|
|
type_base_sptr lookup_canonical_type(const string& qualified_name) const;
|
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
public:
|
Setup per-corpus type maps indexed by type names
This patch creates per-corpus maps that associate, for a certain kind
of type, the fully qualified name of the type to the type.
So there is a map for class_decl, one for enum_type_decl, one for
type_decl, etc.
These maps are populated when a new type is added to its scope.
The patch defines overloads of the function
maybe_update_types_lookup_map() that update the right map, depending
on the kind of type we are looking at.
Note that there also is a map in each class that associates a
signature string to a member functions. This is so that member
functions of a given class can be looked up by signature.
This is so that looking up a type becomes now much faster than having
to walk all the translation units of a corpus to find one.
Note that this patch is specifically part of the series of patches
that implements types and declarations de-duplication while reading
DWARF information.
The patch might slightly change the output of abi serialization or
comparison so it needs some adjustments of some test reference files.
That adjustment is not done here. Rather, it's done at once in
another patch of the set.
* include/abg-corpus.h (corpus::priv_): Make this public so that
functions from outside of the class can access it. These
functions are meant to be used only by code that is *inside*
libabigail.so, though.
* src/abg-corpus-priv.h: New file.
* src/abg-corpus.cc: Include the new abg-corpus-priv.h file.
(struct regex_t_deleter): Move this to abg-sptr-utils.h.
(build_sptr<regex_t>): Move the declaration of this function
template specialization to abg-sptr-utils.h and its definition to
abg-sptr-utils.cc.
(typedef regex_t_sptrs_type, typedef str_var_ptr_map_type)
(struct corpus::exported_decls_builder::priv, struct
corpus::priv): Move these declarations to the new
abg-corpus-priv.h.
(maybe_update_types_lookup_map): Define overloads of this (one per
kind of type).
(lookup_{basic, class, enum, typedef, class_or_typedef,
class_typedef_or_enum, qualified, pointer, reference, array,
function}_type): Define new functions.
* include/abg-ir.h (typedef istring_type_base_wptr_map_type)
(typedef istring_type_or_decl_base_sptr_map_type): Declare new
typedefs.
(class_decl::find_member_function_from_signature): Declare new
member function.
* src/abg-ir.cc: Include the new abg-corpus-priv.h file.
(maybe_update_types_lookup_map): Remove this initial function.
There are now new overloads in abg-corpus.cc for it.
(scope_decl::{add_member_decl, insert_member_decl}): Adjust.
(class_decl::{set_is_declaration_only, find_member_function,
add_member_function}): Adjust.
(class_decl::find_member_function_from_signature): Define new
member function.
* include/abg-sptr-utils.h (struct regex_t_deleter): Declare new
type.
(build_sptr<regex_t>): New build function template
specializations.
* src/abg-sptr-utils.cc: New file.
* src/Makefile.am: Add src/abg-sptr-utils.cc and
src/abg-corpus-priv.h to the build system.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-01 13:05:45 +00:00
|
|
|
shared_ptr<priv> priv_;
|
2013-03-21 13:43:30 +00:00
|
|
|
|
Drop suppressed ABI artifacts from the IR
This patch allows dropping suppressed ABI artifacts from the in-memory
internal representation right during the DWARF or abixml reading.
In practise, this means that abidw and abilint now have a
--suppressions options to give them suppression specifications. If a
suppression specification that has the "drop" property matches an ABI
artifact (type, function or variable) then that artifact is dropped
from the internal representation. This also applies to abidiff.
Note that now, by default, ABI artifacts (types) that are suppressed
due to the --headers-dir{1,2} option of abidiff are now also dropped
from the IR as well. Incidentally, abidw and abilint tools now have a
--header-dir option too.
* doc/manuals/abidw.rst: Document the new --suppressions and
--headers-dir options off the abidw tool.
* doc/manuals/abilint.rst: Document the new --suppressions and
--headers-dir options on the abilint tool.
* doc/manuals/libabigail-concepts.rst: Document the new "drop" and
"name_not_regexp" properties on suppression directives.
* include/abg-corpus.h (corpus::corpus): Add a default argument to
the path parameter.
* src/abg-suppression-priv.h: New private header file.
* src/Makefile.am: Add the new abg-suppression-priv.h file to
source distribution.
* include/abg-suppression.h ({suppression_base, type_suppression,
function_suppression, variable_suppression}::priv): Make these
public.
(suppression_base::{g,s}et_drops_artifact_from_ir): Declare new
member functions.
(type_suppression::{suppressed_type}): Likewise.
(suppression_base::{names,sonames}_of_binaries_match): Remove
member functions.
(function_suppression::{get_name, set_name, get_name_regex_str,
set_name_regex_str}): Renamed get_function_name,
set_function_name, get_function_name_regex_str,
set_function_name_regex_str into these.
({variable,function}_suppression::{g,s}et_name_not_regex_str):
Declare new member functions.
* src/abg-suppression.cc: Include the new abg-suppression-priv.h
private header.
(class suppression_base::priv, class type_suppression::priv, class
function_suppression::parameter_spec::priv, class
function_suppression::priv, class variable_suppression::priv):
Move these types to that new private header.
(suppression_base::{g,s}et_drops_artifact_from_ir)
(function_suppression::{g,s}et_name_not_regex_str)
(variable_suppression::{g,s}et_name_not_regex_str): New member
functions.
(sonames_of_binaries_match): New static function, taken from
suppression_base::sonames_of_binaries_match.
(names_of_binaries_match): New static function, taken from
suppression_base::names_of_binaries_match.
(suppression_matches_type_no_name): New static function.
(type_suppression::suppresses_type): Adjust
(function_suppression::suppresses_function)
(variable_suppression::suppresses_variable): Adjust. Evaluate the
new "name_not_regexp" property.
(suppression_matches_type_name)
(suppression_matches_type_location)
(suppression_matches_type_name_or_location)
(suppression_matches_function_name)
(suppression_matches_function_sym_name)
(suppression_matches_variable_name)
(suppression_matches_variable_sym_name, suppression_matches_type):
New functions.
(read_type_suppression): Support the new "drop_artifacts" and
"drop" properties.
(read_function_suppression, read_variable_suppression): Support
the new "drop_artifacts", "drop", and "name_not_regexp"
properties.
(function_suppression::{g,s}et_name): Renamed
{g,s}et_function_name into these.
(function_suppression::set_name_not_regex_str): Renamed
{g,s}et_name_regex_str into this.
(function_suppression::suppresses_function_symbol): Adjust.
* include/abg-dwarf-reader.h (add_read_context_suppressions):
Declare new function.
* src/abg-dwarf-reader.cc: Use the new private
abg-suppression-priv.h header file.
(read_context::supprs_): New data member.
(read_context::get_suppressions): New member function.
(read_context::get_die_source): Make this const.
(read_context::tu_die_imported_unit_points_map): Add a const
overload.
(read_context::cur_transl_unit): Renamed current_translation_unit
unit into this;
(read_context::cur_tu): Remove or rename into cur_transl_unit.
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_enum_type, build_pointer_type_def, build_reference_type)
(build_function_type, build_array_type, build_function_decl):
Adjust.
(read_context::{suppression_can_match,
suppression_matches_function_sym_name,
suppression_matches_function_name,
suppression_matches_variable_sym_name,
suppression_matches_variable_name,
suppression_matches_type_name_or_location,
suppression_matches_type_name}): Add member functions.
(die_signed_constant_attribute): Remove this as dead code.
(die_location, die_loc_and_name)
(find_import_unit_point_between_dies)
(find_import_unit_point_before_die, get_parent_die): Make the
read_context& parameter be const and adjust as required.
(build_var_decl_if_not_suppressed, function_is_suppressed)
(variable_is_suppressed, type_is_suppressed): Define new static
functions.
(add_read_context_suppressions): Define new function.
(build_class_type_and_add_to_ir): Do not add suppressed static
data members to the IR.
(build_ir_node_from_die): Do not add suppressed enum types, class
types, variables or functions to the IR. Adjust for the
read_context::cur_tu -> read_context::cur_transl_unit rename.
* include/abg-reader.h (read_context_sptr): Declare new type.
(create_native_xml_read_context, read_corpus_from_input)
(add_read_context_suppressions): Declare new functions.
* src/abg-reader.cc: Include the new private
abg-suppression-priv.h header file.
(read_context::m_exported_decls_builder): Renamed
m_exported_decls_builder_ into this.
(read_context::get_exported_decls_builder): Adjust.
(read_context::get_cur_scope): Make this const.
(read_location): Take a const read_context and adjust.
(read_corpus_from_input): Make this non-static.
(build_namespace_decl): Don't abort if trying to add an artifact
to the IR doesn't succeed. It might be suppressed now.
(read_context::{m_path, m_supprs}): New data members.
(read_context::{g,s}et_path): New member functions.
(read_context::{get_suppressions,
suppression_matches_function_name, suppression_can_match,
suppression_matches_function_name,
suppression_matches_function_sym_name,
suppression_matches_variable_name,
suppression_matches_variable_sym_name,
suppression_matches_type_name_or_location}): Likewise.
(add_read_context_suppressions, create_native_xml_read_context)
(read_corpus_from_native_xml): New functions.
(build_function_decl_if_not_suppressed, function_is_suppressed)
(type_is_suppressed, build_var_decl_if_not_suppressed)
(variable_is_suppressed, build_enum_type_decl_if_not_suppressed)
(build_class_decl_if_not_suppressed): New static functions.
(build_class_decl): Add member types that are being built early,
so that their sub-types can be evaluated for suppression. Do not
add suppressed static data members or suppressed member functions
to the IR.
(build_type): Do not add an enum type or a class type to the IR if
they are suppressed.
(handle_enum_type_decl): Do not add an enum type to the IR if its
suppressed.
(handle_var_decl): Likewise for a variable decl.
(handle_function_decl): Likewise for a function decl.
(handle_class_decl): Likewise for a class decl.
* src/abg-tools-utils.cc (handle_fts_entry): Drop suppressed ABI
from the IR.
* tools/abidiff.cc (display_usage): Fix help strings for
--headers-dirs{1,2}.
(set_suppressions): New static function.
(main): Adjust. Release the memory used by read_context early.
* tools/abidw.cc (options::{headers_dir, suppression_paths}):
(display_usage): New help strings for the new --header-dir and
--suppressions options.
(parse_command_line): Parse the new --header-dir and
--suppressions options.
(maybe_check_suppression_files, set_suppressions): New static
functions.
(main): Use the two new functions above. Free the memory used by
the read context before working with the corpus.
* tools/abilint.cc (options::suppression_paths):
(display_usage): New help strings for the new --header-dir and
--suppressions options.
(parse_command_line): Parse the new --header-dir and
--suppressions options.
(maybe_check_suppression_files, set_suppressions): New static
functions.
(main): Use the two new functions above. Free the memory used by
the read context before working with the corpus.
* tests/data/test-diff-suppr/test24-soname-suppr-{2,3].txt:
Adjust.
* tests/data/test-diff-suppr/test29-suppr-6.txt: Likewise.
* tests/data/test-diff-suppr/test29-suppr-8.txt: Likewise.
* tests/data/test-diff-suppr/libtest31-v{0,1}.so: New test input.
* tests/data/test-diff-suppr/libtest31.suppr: Likewise
* tests/data/test-diff-suppr/libtest32-v{0,1}.so: Likewise.
* tests/data/test-diff-suppr/libtest32-0.suppr: Likewise.
* tests/data/test-diff-suppr/libtest33-v{0,1}.so: Likewise.
* tests/data/test-diff-suppr/test31-report-{0,1}.txt: Likewise.
* tests/data/test-diff-suppr/test31-v{0,1}.cc: Likewise.
* tests/data/test-diff-suppr/test32-report-{0,1}.txt: Likewise.
* tests/data/test-diff-suppr/test32-v{0,1}.c: Likewise.
* tests/data/test-diff-suppr/test33-suppr-1.txt: Likewise.
* tests/data/test-diff-suppr/test33-v{0,1}.cc: Likewise.
* tests/data/test-diff-suppr/test33-v{0,1}.h: Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns.so: Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
* tests/data/test-read-dwarf/test24-drop-fns-0.suppr: Likewise.
* tests/data/test-read-dwarf/test24-drop-fns.cc: Likewise.
* tests/data/test-read-write/test28-drop-std-fns.abignore:
Likewise.
* tests/data/test-read-write/test28-drop-std-vars.abignore:
Likewise.
* tests/data/test-read-write/test28-without-std-fns-ref.xml:
Likewise.
* tests/data/test-read-write/test28-without-std-fns.xml: Likewise.
* tests/data/test-read-write/test28-without-std-vars-ref.xml:
Likewise.
* tests/data/test-read-write/test28-without-std-vars.xml:
Likewise.
* tests/data/test-read-write/test28.xml: Likewise.
* tests/data/Makefile.am: Add the new test artifacts to source
distribution.
* tests/test-diff-suppr.cc (in_out_spec): Take the new test inputs
into account.
* tests/test-read-dwarf.cc (Inoutspec::in_suppr_spec_path): New
data member.
(in_out_spec): Adjust. The new test inputs into account.
(set_suppressions): New static function.
(handle_in_out_spec): Adjust.
* tests/test-read-write.cc (Inoutspec::{in_suppr_spec_path,
ref_out_path}): New data members.
(in_out_spec): Adjust. Take new test inputs into account.
(main): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-09-19 16:03:19 +00:00
|
|
|
corpus(ir::environment*, const string& path= "");
|
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
|
|
|
|
|
|
|
const environment*
|
|
|
|
get_environment() const;
|
|
|
|
|
Implement string interning for Libabigail
This patch implements string interning optimization. One can read
about the principles of this optimization at
https://en.wikipedia.org/wiki/String_interning.
The patch introduces an abigail::interned_string type, as well as an
abigail::interned_string_pool type. Each environment type owns a
string pool and strings are interned in that pool for all types and
decls of that environments. The interned_string has methods to
interact seemingly with std::string including a hashing function. Of
course hashing and comparing interned_string is faster than for
std::string.
To enable ABI artifacts to intern strings, each constructor of ABI
artifacts now takes the environment it's constructed in as parameter.
From the environment, it can thus use the interned string pool.
The patch then changes declaration names to be of type
interned_string, and performs the necessary adjustments. The hash
maps that hash strings coming from those declaration names are
adjusted to hash interned_string.
* include/Makefile.am: Add the new abg-interned-str.h file to
source distribution.
* include/abg-corpus.h (corpus::corpus): Re-arrange the order of
* src/abg-corpus.cc
(corpus::exported_decls_builder::priv::get_id): Return
interned_string rather than std::string.
(corpus::corpus): Re-arrange the order of parameters: take an
environment as first parameter. parameters: take an environment
as first parameter.
* include/abg-dwarf-reader.h (lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf): Likewise.
* src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab)
(lookup_symbol_from_elf_hash_tab, lookup_symbol_from_symtab)
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf, lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf): Take an environment as
first parameter and adjust.
(build_translation_unit_and_add_to_ir)
(build_namespace_decl_and_add_to_ir, build_type_decl)
(build_enum_type, finish_member_function_reading)
(build_class_type_and_add_to_ir, build_function_type)
(read_debug_info_into_corpus, read_corpus_from_elf): Adjust.
* include/abg-fwd.h: Include abg-interned-str.h
(get_type_name, get_function_type_name, get_method_type_name):
Return a interned_string, rather than a std::string.
* include/abg-interned-str.h: New declarations for interned strings
and their pool.
* include/abg-ir.h (environment::intern): Declare new method.
(elf_symbol::{g,s}et_environment): Likewise.
(type_or_decl_base::type_or_decl_base): Make the default
constructor private.
({translation, type_or_decl_base}::set_environment)
(set_environment_for_artifact): Take a const environment*.
(elf_symbol::elf_symbol)
(elf_symbol::create)
(type_or_decl_base::type_or_decl_base)
(translation::translation, decl_base::decl_base)
(scope_decl::scope_decl, type_base::type_base)
(type_decl::type_decl, scope_type_decl::scope_type_decl)
(namespace_decl::namespace_decl)
(enum_type_decl::enumerator::enumerator)
(function_type::function_type, method_type::method_type)
(template_decl::template_decl, function_tdecl::function_tdecl)
(class_tdecl::class_tdecl, class_decl::class_decl): Take an
environment.
(type_or_decl_base::operator=)
(enum_type_decl::enumerator::get_environment): Declare new method.
(decl_base::{peek_qualified_name, peek_temporary_qualified_name,
get_qualified_name, get_name, get_qualified_parent_name,
get_linkage_name}, qualified_type_def::get_qualified_name)
(reference_type_def::get_qualified_name)
(array_type_def::get_qualified_name)
(enum_type_decl::enumerator::{get_name, get_qualified_name})
({var,function}_decl::get_id)
(function_decl::parameter::{get_type_name, get_name_id}): Return
an interned_string, rather than a std::string.
(decl_base::{set_qualified_name, set_temporary_qualified_name,
get_qualified_name, set_linkage_name})
(qualified_type_def::get_qualified_name)
(reference_type_def::get_qualified_name)
(array_type_def::get_qualified_name)
(function_decl::parameter::get_qualified_name): Take an
interned_string, rather than a std::string.
(class_decl::member_{class,function}_template::member_{class,function}_template):
Adjust.
* src/abg-ir.cc (environment_setter::env_): Make this be a pointer
to const environment.
(environment_setter::visit_begin): Adjust.
(interned_string_pool::priv): Define new type.
(interned_string_pool::*): Define the method declared in
abg-interned-str. h.
(operator==, operator!=, operator+): Define operator for interned_string and
std::string
(operator<<): Define for interned_string.
(translation_unit::priv::env_): Make this be a pointer to const
environment.
(translation_unit::priv::priv): Take a pointer to const
environment.
(elf_symbol::priv::env_): New data member.
(elf_symbol::priv::priv): Adjust. Make an overoad take an
environment.
(translation_unit::{g,s}et_environment): Adjust.
(interned_string_bool_map_type): New typedef.
(environment::priv::classes_being_compared_): Make this hastable
of string be a hashtable of interned_string.
(environment::priv::string_pool_): New data member.
(environment::{get_void_type_decl,
get_variadic_parameter_type_decl}): Adjust.
(type_or_decl_base::priv::env_): Make this be a pointer to const
environment.
(type_or_decl::base::priv::priv): Adjust.
(type_or_decl_base::set_environment)
(set_environment_for_artifact): Take a pointer to const
environment.
(elf_symbol::{g,s}et_environment, environment::intern)
(type_or_decl_base::operator=): Define new methods.
(decl_base::priv::{name_, qualified_parent_name_,
temporary_qualified_name_, qualified_name_, linkage_name_}): Make
these data member be of tpe interned_string.
(decl_base::priv::priv): Make this take an environment. Adjust.
(decl_base::{peek_qualified_name, peek_temporary_qualified_name,
get_linkage_name, get_qualified_parent_name, get_name,
get_qualified_name}, get_type_name, get_function_type_name)
(get_method_type_name, get_node_name)
(qualified_type_def::get_qualified_name)
(pointer_type_def::get_qualified_name)
(array_type_def::get_qualified_name)
(enum_type_decl::enumerator::get_qualified_name)
(var_decl::get_id, function_decl::get_id)
(function_decl::parameter::get_{name_id, type_name}): Return an
interned_string.
(decl_base::{set_qualified_name, set_temporary_qualified_name})
(qualified_type_def::get_qualified_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name)
(array_type_def::get_qualified_name)
(function_decl::parameter::get_qualified_name): Take an
interned_string.
(decl_base::{set_name, set_linkage_name}): Intern the std::string
passed in parameter.
(equals): In the overload for decl_base, adjust for a little speed
optimization that is justified by profiling.
(pointer_type_def::priv::{internal_qualified_name_,
temp_internal_qualified_name_}): Make these data member be
interned_string.
(enum_type_decl::enumerator::priv::env_): New data member.
(enum_type_decl::enumerator::priv::{name_, qualified_name}): Make
these data member be of type interned_string.
(enum_type_decl::enumerator::get_environment): New method.
(enum_type_decl::enumerator::priv::priv) Adjust.
(typedef_decl::operator==): Implement a little speed optimization.
(var_decl::priv::nake_type_): New data member.
(var_decl::priv::id_): Make this data member be of type
interned_string.
(equals): In the overload for var_decl, function_type,
function_decl, adjust for the use of interned_string.
(function_decl::priv::id_): Make this be of type interned_string.
(scope_decl::{add_member_decl, insert_member_decl})
(lookup_function_type_in_translation_unit)
(synthesize_type_from_translation_unit, lookup_node_in_scope)
(lookup_type_in_scope, scope_decl::scope_decl)
(qualified_type_def::qualified_type_def)
(qualified_type_def::get_qualified_name)
(pointer_type_def::pointer_type_def)
(reference_type_def::reference_type_def)
(array_type_def::array_type_def, array_type_def::append_subrange)
(array_type_def::get_qualified_name)
(enum_type_decl::enum_type_decl)
(enum_type_decl::enumerator::get_qualified_name)
(enum_type_decl::enumerator::set_name)
(typedef_decl::typedef_decl, var_decl::var_decl)
(function_type::function_type, method_type::method_type)
(function_decl::function_decl)
(function_decl::parameter::parameter)
(class_decl::priv::comparison_started)
(class_decl::add_base_specifier)
(class_decl::base_spec::base_spec)
(class_decl::method_decl::method_decl)
(type_tparameter::type_tparameter)
(non_type_tparameter::non_type_tparameter)
(template_tparameter::template_tparameter)
(type_composition::type_composition)
(function_tdecl::function_tdecl, class_tdecl::class_tdecl)
(qualified_name_setter::do_update): Adjust.
(translation_unit::translation_unit, elf_symbol::elf_symbol)
(elf_symbol::create, type_or_decl_base::type_or_decl_base)
(decl_base::decl_base, type_base::type_base)
(type_decl::type_decl, scope_type_decl::scope_type_decl)
(namespace_decl::namespace_decl)
(enum_type_decl::enumerator::enumerator, class_decl::class_decl)
(template_decl::template_decl, function_tdecl::function_tdecl)
(class_tdecl::class_tdecl): Take an environment.
* src/abg-comparison.cc
(function_suppression::suppresses_function): Adjust.
* src/abg-reader.cc (read_translation_unit)
(read_corpus_from_input, build_namespace_decl, build_elf_symbol)
(build_function_parameter, build_function_decl, build_type_decl)
(build_function_type, build_enum_type_decl, build_enum_type_decl)
(build_class_decl, build_function_tdecl, build_class_tdecl)
(read_corpus_from_native_xml): Likewise.
* src/abg-writer.cc (id_manager::m_cur_id): Make this mutable.
(id_manager::m_env): New data member.
(id_manager::id_manager): Adjust.
(id_manager::get_environment): New method.
(id_manager::{get_id, get_id_with_prefix}): Return an
interned_string.
(type_ptr_map): Make this be a hash map of type_base* ->
interned_string, rather a type_base* -> string.
(write_context::m_env): New data member.
(write_context::m_type_id_map): Make this data member be mutable.
(write_context::m_emitted_type_id_map): Make this be a hash map of
interned_string -> bool, rather than string -> bool.
(write_context::write_context): Take an environment and adjust.
(write_context::get_environment): New method.
(write_context::get_id_manager): New const overload.
(write_context::get_id_for_type): Return an interned_string; adjust.
(write_context::{record_type_id_as_emitted,
record_type_as_referenced}): Adjust.
(write_context::type_id_is_emitted): Take an interned_string.
(write_context::{type_is_emitted,
record_decl_only_type_as_emitted}): Adjust.
(write_translation_unit, write_corpus_to_native_xml, dump):
Adjust.
* tools/abisym.cc (main): Adjust.
* tests/data/test-read-write/test22.xml: Adjust.
* tests/data/test-read-write/test23.xml: Adjust.
* tests/data/test-read-write/test26.xml: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-24 06:44:29 +00:00
|
|
|
environment*
|
|
|
|
get_environment();
|
|
|
|
|
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
|
|
|
void
|
|
|
|
set_environment(environment*) const;
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
2013-03-21 13:43:30 +00:00
|
|
|
void
|
2013-08-02 03:16:22 +00:00
|
|
|
add(const translation_unit_sptr);
|
2013-03-21 13:43:30 +00:00
|
|
|
|
2013-08-02 03:16:22 +00:00
|
|
|
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;
|
2013-03-21 13:43:30 +00:00
|
|
|
|
2013-08-27 13:18:59 +00:00
|
|
|
void
|
|
|
|
drop_translation_units();
|
|
|
|
|
2014-04-21 15:22:11 +00:00
|
|
|
origin
|
|
|
|
get_origin() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_origin(origin);
|
|
|
|
|
2013-08-27 13:18:59 +00:00
|
|
|
string&
|
2013-08-29 14:29:25 +00:00
|
|
|
get_path() const;
|
2013-08-27 13:18:59 +00:00
|
|
|
|
|
|
|
void
|
2013-08-29 14:29:25 +00:00
|
|
|
set_path(const string&);
|
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&);
|
|
|
|
|
2015-01-07 12:45:53 +00:00
|
|
|
const string&
|
|
|
|
get_architecture_name();
|
|
|
|
|
|
|
|
void
|
|
|
|
set_architecture_name(const string&);
|
|
|
|
|
2013-03-21 13:43:30 +00:00
|
|
|
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;
|
|
|
|
|
2014-11-08 10:22:43 +00:00
|
|
|
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;
|
|
|
|
|
2014-11-08 10:22:43 +00:00
|
|
|
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
|
2014-08-25 21:04:53 +00:00
|
|
|
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
|
|
|
|
2014-08-25 21:06:18 +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;
|
2014-08-25 21:06:18 +00:00
|
|
|
|
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
|
2014-08-25 21:04:53 +00:00
|
|
|
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
|
|
|
|
2014-08-25 21:06:18 +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;
|
2014-08-25 21:06:18 +00:00
|
|
|
|
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;
|
|
|
|
|
2016-02-17 13:20:43 +00:00
|
|
|
const vector<function_decl*>*
|
|
|
|
lookup_functions(const string& id) 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;
|
Bug 19658 - Type canonicalization slow for the 2nd binary loaded
When loading two binaries (e.g, when the library is used by abidiff),
and when the second one does have deep types (e.g, classes with
recursively deep hierarchies) with lots of duplicated types in lots of
translation units, canonicalizing the types of the second binaries can
take a *lot* of time, given the quadratic nature of the structural
type comparisons that take place and the cheer number of those type
comparisons (because of the duplication).
There is already an optimization based on the One Definition Rule in
the canonicalization code. That optimization avoids structural
comparison of types of the same corpus which have the same name. But
then, this optimization only works on types of the first corpus.
As soon as we are loading a second corpus, all types being
canonicalized are coming from a corpus that is different from the
first corpus, by definition. So a structural comparison is taking
place for *all* those types.
The patch extends the existing optimization to make it work on the
second corpus being loaded. Once a type from the second corpus is
canonicalized, the canonical type is cached inside the corpus. Then,
later, when a type with the same name has to be canonicalized, the
system looks inside the cache of that corpus to see if there is a
canonicalized type the same name.
I tested the patch on this command:
abipkgdiff --d1 nss-debuginfo-3.19.1-8.el6_7.i686.rpm \
--d2 nss-debuginfo-3.21.0-0.1.el6_7.i686.rpm \
nss-3.19.1-8.el6_7.i686.rpm \
nss-3.21.0-0.1.el6_7.i686.rpm
I whitnessed a x10 speedup, at least.
On binaries that don't have a lot of duplicated deep types, the patch
doesn't have any noticeable effect. At lesat It doesn't slow things
down in that case.
* include/abg-corpus.h (corpus::{record_canonical_type,
lookup_canonical_type}): Declare new member functions.
* src/abg-corpus.cc (corpus::priv::canonical_types_): New data
member.
(corpus::{record_canonical_type, lookup_canonical_type}): Define
new member functions.
* src/abg-ir.cc (type_base::get_canonical_type_for): Cache the
canonical type inside the corpus of the type being canonicalized.
Then later when canonicalizing another type, lookup in the cache
inside its corpus to see if there is a type with the same name.
* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt:
Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-18 14:40:09 +00:00
|
|
|
|
|
|
|
friend class type_base;
|
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.
|
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
|
|
|
|
|
2014-10-11 09:27:59 +00:00
|
|
|
}// end namespace ir
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
}//end namespace abigail
|
|
|
|
#endif //__ABG_CORPUS_H__
|