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
|
|
|
// -*- Mode: C++ -*-
|
|
|
|
//
|
2019-01-07 13:54:47 +00:00
|
|
|
// Copyright (C) 2013-2019 Red Hat, Inc.
|
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
|
|
|
//
|
|
|
|
// This file is part of the GNU Application Binary Interface Generic
|
|
|
|
// Analysis and Instrumentation Library (libabigail). This library is
|
|
|
|
// free software; you can redistribute it and/or modify it under the
|
|
|
|
// terms of the GNU Lesser General Public License as published by the
|
|
|
|
// Free Software Foundation; either version 3, or (at your option) any
|
|
|
|
// later version.
|
|
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Lesser Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this program; see the file COPYING-LGPLV3. If
|
|
|
|
// not, see <http://www.gnu.org/licenses/>.
|
|
|
|
//
|
|
|
|
// Author: Dodji Seketeli
|
|
|
|
|
|
|
|
/// @file
|
|
|
|
///
|
|
|
|
/// This file contains the declarations of the entry points to
|
2014-01-17 14:42:47 +00:00
|
|
|
/// de-serialize an instance of @ref abigail::translation_unit from an
|
|
|
|
/// ABI Instrumentation file in libabigail native XML format.
|
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
|
|
|
|
|
|
|
#ifndef __ABG_READER_H__
|
|
|
|
#define __ABG_READER_H__
|
|
|
|
|
2013-12-11 14:20:42 +00:00
|
|
|
#include <istream>
|
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
|
|
|
#include "abg-corpus.h"
|
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
|
|
|
#include "abg-suppression.h"
|
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
|
|
|
|
|
|
|
namespace abigail
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace xml_reader
|
|
|
|
{
|
|
|
|
|
2014-10-11 09:27:59 +00:00
|
|
|
using namespace abigail::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
|
|
|
translation_unit_sptr
|
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
|
|
|
read_translation_unit_from_file(const std::string& file_path,
|
|
|
|
environment* env);
|
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
|
|
|
|
|
|
|
translation_unit_sptr
|
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
|
|
|
read_translation_unit_from_buffer(const std::string& file_path,
|
|
|
|
environment* env);
|
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
|
|
|
|
2013-12-11 14:20:42 +00:00
|
|
|
translation_unit_sptr
|
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
|
|
|
read_translation_unit_from_istream(std::istream* in,
|
|
|
|
environment* env);
|
2013-12-11 14:20:42 +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
|
|
|
class read_context;
|
|
|
|
|
|
|
|
/// A convenience typedef for a shared pointer to read_context.
|
|
|
|
typedef shared_ptr<read_context> read_context_sptr;
|
|
|
|
|
|
|
|
read_context_sptr
|
|
|
|
create_native_xml_read_context(const string& path, environment *env);
|
|
|
|
|
|
|
|
read_context_sptr
|
|
|
|
create_native_xml_read_context(std::istream* in, environment* env);
|
|
|
|
|
Separate public types of first binary from those of the second
In abidiff when the user uses --headers-dir{1,2}, she implicitly
indicates the public types of the first and the second binary. That
means that any type that is defined in a file that is not located
under the directory tree designated by --headers-dir{1,2} is
considered private and any change involving those private types will
be suppressed.
In practice, what happens is that libabigail constructs a suppression
specification which suppress all types that are defined in files that
are not under the directories located by --headers-dir{1,2}.
abidiff has a problem, though. It uses the same private type
suppressions (derived from --headers-dir1 and --headers-dir2) when
looking at the first binary *and* the second binary. It should rather
only use the private type suppression specifications derived from
--headers-dir1 when looking at the first binary, and use the private
type suppression specifications derived from --headers-dir2 when
looking at the second binary.
This problem leads to some false positives like the one reported at
https://gitlab.gnome.org/GNOME/pango/issues/343#note_397761.
This patch fixes this issue by using the private type suppression
specifications derived from --headers-dir1 only when looking at the
first binary, and using the private type suppression specifications
derived from --headers-dir2 only when looking at the second binary.
* include/abg-dwarf-reader.h (read_context_get_path): Declare new
function.
* include/abg-reader.h (read_context_get_path): Likewise.
* src/abg-dwarf-reader.cc (read_context_get_path): Define new function.
* src/abg-reader.cc (read_context_get_path): Likewise.
* tools/abidiff.cc (set_suppressions): Set the suppression
specification derived from the --headers-dir1 option only for the first
binary, and similarly, from the --headers-dir2 option only for the
second binary.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-01-15 17:33:12 +00:00
|
|
|
const string&
|
|
|
|
read_context_get_path(const read_context&);
|
|
|
|
|
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
|
|
|
abigail::corpus_sptr
|
|
|
|
read_corpus_from_file(const string& path);
|
|
|
|
|
|
|
|
int
|
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
|
|
|
read_corpus_from_file(corpus_sptr& corp,
|
|
|
|
const string& path);
|
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
|
|
|
|
|
|
|
int
|
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
|
|
|
read_corpus_from_file(corpus_sptr& corp);
|
2014-01-07 13:12:26 +00:00
|
|
|
|
|
|
|
corpus_sptr
|
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
|
|
|
read_corpus_from_native_xml(std::istream* in,
|
|
|
|
environment* env);
|
2014-01-07 13:12:26 +00:00
|
|
|
|
|
|
|
corpus_sptr
|
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
|
|
|
read_corpus_from_native_xml_file(const string& path,
|
|
|
|
environment* env);
|
2014-01-07 13:12:26 +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_sptr
|
|
|
|
read_corpus_from_input(read_context& ctxt);
|
|
|
|
|
Initial support of de-serializing the KMI of a Linux Kernel Tree
With this patch, kmidiff knows how to compare a serialized
corpus_group that represents a Kernel Module Interface (a .kmi file)
against either another serialized .kmi file, or against a kernel tree.
The patch extends the abixml reader to make it parse an
'abi-corpus-group' element. To do that, the patch modifies
read_corpus_from_input to make it be capable of parsing several
'abi-corpus' in a row. That modified function is then used by a new
read_corpus_group_from_input, which is itself used by the new public
entry points read_corpus_group_from_native_xml_file and
read_corpus_group_from_native_xml.
With that read_corpus_group_from_native_xml_file building block
function, the kmidiff program is modified so that it can take either
two directory trees, two .kmi files or one directory tree and one .kmi
file.
* include/abg-libxml-utils.h (advance_to_next_sibling_element):
Declare new function.
* src/abg-libxml-utils.cc (go_to_next_sibling_element_or_stay)
(advance_to_next_sibling_element): Define new functions.
* include/abg-reader.h (read_corpus_group_from_input)
(read_corpus_group_from_native_xml)
(read_corpus_group_from_native_xml_file): Declare new functions.
* src/abg-reader.cc (read_context::m_corpus_group): New data
member.
(read_context::{get_corpus_group, set_corpus_group}): Define new
member functions.
(read_translation_unit_from_input): Cleanup logic.
(read_corpus_from_input): Don't assume that the document is
starting with an 'abi-corpus' element. Support the mode where a
caller called the xmlTextReaderExpand function (and so we are
given an expanded xmlNodePtr) and the mode where we need to use
the xmlTextReader API to walk through the 'abi-corpus' element.
Also, if we are building a corpus group, do not clear what used to
be 'per-corpus' data. That data must be shared by all the corpora
of a given abi-corpus-group.
(read_corpus_group_from_input, read_corpus_group_from_native_xml)
(read_corpus_group_from_native_xml_file): Define new functions.
* include/abg-tools-utils.h (FILE_TYPE_XML_CORPUS_GROUP): New
enumerator of the file_type enum.
* src/abg-tools-utils.cc (operator<<): In the overload for
file_type, add a case for the new FILE_TYPE_XML_CORPUS_GROUP.
(guess_file_type): Dectect abi-corpus-group xml element.
* tools/abidiff.cc (adjust_diff_context_for_kmidiff): Define new
static function.
(main): Adjust to handle the new FILE_TYPE_XML_CORPUS_GROUP. That
is, compare two FILE_TYPE_XML_CORPUS_GROUP if they are present.
* tools/abilint.cc (main): Likewise.
* tools/kmidiff.cc (main): Detect that one of two .kmi files are
passed. In that case, load the .kmi file(s), build a corpus_group
of it and use it in the comparison.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-07 21:06:14 +00:00
|
|
|
corpus_group_sptr
|
|
|
|
read_corpus_group_from_input(read_context& ctxt);
|
|
|
|
|
|
|
|
corpus_group_sptr
|
|
|
|
read_corpus_group_from_native_xml(std::istream* in,
|
|
|
|
environment* env);
|
|
|
|
|
|
|
|
corpus_group_sptr
|
|
|
|
read_corpus_group_from_native_xml_file(const string& path,
|
|
|
|
environment* env);
|
|
|
|
|
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
|
|
|
void
|
|
|
|
add_read_context_suppressions(read_context& ctxt,
|
|
|
|
const suppr::suppressions_type& supprs);
|
|
|
|
|
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 xml_reader
|
|
|
|
}//end namespace abigail
|
|
|
|
|
|
|
|
#endif // __ABG_READER_H__
|