libabigail/tools/abg-tools-utils.h

67 lines
2.1 KiB
C
Raw Normal View History

Initial version of an archive manipulation program: biar * tests/test-utils.h (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): Move these directories manipulation utilities from here to ... * tools/abg-tools-utils.h (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): ... here in this new file. (dir_name, base_name): Declare these new functions. * tests/test-utils.cc (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): Likewise, move these to ... * tools/abg-tools-utils.cc (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): ... here in this new file. (dir_name, base_name): Define these. * tools/Makefile.am: New file. Create a new libtoolsutils.la static library with stuff from tools/abg-tools-utils.cc in it. Also create a new 'biar' program with the stuff from the new tools/biar.cc in it. * tools/biar.cc: New file. Contains the code for the new "biar" archive manipulation command line utility. * tests/test-read-write.cc (main): Adjust for the change about ensure_parent_dir_created above. * tests/test-write-read-archive.cc (main): Likewise. * Makefile.am (SUBDIRS): Add the new tools/ sub-directory to the build system. * configure.ac (AC_CONFIG_FILES): Generate tools/Makefile. * tests/Makefile.am: Make libtestutils.la link with the new libtoolsutils.la. Make sure to express the dependencies between libtestutils.la and the binaries that depend on it. Otherwise parallel builds can go awry. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-29 15:08:47 +00:00
// -*- Mode: C++ -*-
//
// Copyright (C) 2013 Red Hat, Inc.
//
// This file is part of the GNU Application Binary Interface Generic
// Analysis and Instrumentation Library (libabigail). This library is
// free software; you can redistribute it and/or modify it under the
// terms of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 3, or (at your option) any
// later version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this program; see the file COPYING-LGPLV3. If
// not, see <http://www.gnu.org/licenses/>.
///@file
#include <string>
#include <ostream>
Initial support for diffing ABI corpus files * include/abg-comparison.h (string_function_ptr_map) (changed_function_ptr, string_changed_function_ptr_map) (corpus_diff_sptr): New convenience typedefs. (translation_unit_diff): Add comments. (class corpus_diff): New type. (compute_diff): New overload for corpus_diff. * include/abg-corpus.h (corpus::{functions, variables}): New typedefs. (corpus::{operator==, get_functions, get_variables}): New members. * include/abg-diff-utils.h (struct deep_ptr_eq_functor): New functor. * include/abg-ir.h (translation_unit::operator==): New member equality operator. * src/abg-comparison.cc (struct corpus_diff::priv): New private struct holding the private members of corpus_diff. (corpus_diff::priv::{lookup_tables_empty, clear_lookup_tables, ensure_lookup_tables_populated}): Define new private member functions. (corpus_diff::{corpus_diff, first_corpus, second_corpus, function_changes, variable_changes, length, report}): New public members. (struct noop_deleter): New struct. (compute_diff): New implementation for corpus_diff. * src/abg-corpus.cc (struct corpus::priv): Renamed corpus::impl into this. Add new fns, vars and is_symbol_table_built data members. (corpus::priv::build_symbol_table): New member function. (class symtab_build_visitor_type): New visitor type to build the symbol table. (struct func_comp, struct var_comp): New comparison functors. (corpus::priv::build_symbol_table): Define new member function. (corpus::{corpus, add, get_translation_units, operator==, get_functions, get_variables}): Define new members. * src/abg-ir.cc (translation_unit::operator==): Define new member equality operator. (operator==(translation_unit_sptr l, translation_unit_sptr r)): Define new equality operator. * tools/abg-tools-utils.h (enum file_type): New enum. (guess_file_type): Declare new function. * tools/abg-tools-utils.cc (guess_file_type): define new function. * tools/bidiff.cc (main): Guess the type of the files given in input and support elf files reading and diffing. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-23 13:05:19 +00:00
#include <istream>
Initial version of an archive manipulation program: biar * tests/test-utils.h (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): Move these directories manipulation utilities from here to ... * tools/abg-tools-utils.h (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): ... here in this new file. (dir_name, base_name): Declare these new functions. * tests/test-utils.cc (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): Likewise, move these to ... * tools/abg-tools-utils.cc (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): ... here in this new file. (dir_name, base_name): Define these. * tools/Makefile.am: New file. Create a new libtoolsutils.la static library with stuff from tools/abg-tools-utils.cc in it. Also create a new 'biar' program with the stuff from the new tools/biar.cc in it. * tools/biar.cc: New file. Contains the code for the new "biar" archive manipulation command line utility. * tests/test-read-write.cc (main): Adjust for the change about ensure_parent_dir_created above. * tests/test-write-read-archive.cc (main): Likewise. * Makefile.am (SUBDIRS): Add the new tools/ sub-directory to the build system. * configure.ac (AC_CONFIG_FILES): Generate tools/Makefile. * tests/Makefile.am: Make libtestutils.la link with the new libtoolsutils.la. Make sure to express the dependencies between libtestutils.la and the binaries that depend on it. Otherwise parallel builds can go awry. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-29 15:08:47 +00:00
namespace abigail
{
namespace tools
{
bool file_exists(const std::string&);
bool is_regular_file(const std::string&);
Initial version of an archive manipulation program: biar * tests/test-utils.h (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): Move these directories manipulation utilities from here to ... * tools/abg-tools-utils.h (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): ... here in this new file. (dir_name, base_name): Declare these new functions. * tests/test-utils.cc (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): Likewise, move these to ... * tools/abg-tools-utils.cc (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): ... here in this new file. (dir_name, base_name): Define these. * tools/Makefile.am: New file. Create a new libtoolsutils.la static library with stuff from tools/abg-tools-utils.cc in it. Also create a new 'biar' program with the stuff from the new tools/biar.cc in it. * tools/biar.cc: New file. Contains the code for the new "biar" archive manipulation command line utility. * tests/test-read-write.cc (main): Adjust for the change about ensure_parent_dir_created above. * tests/test-write-read-archive.cc (main): Likewise. * Makefile.am (SUBDIRS): Add the new tools/ sub-directory to the build system. * configure.ac (AC_CONFIG_FILES): Generate tools/Makefile. * tests/Makefile.am: Make libtestutils.la link with the new libtoolsutils.la. Make sure to express the dependencies between libtestutils.la and the binaries that depend on it. Otherwise parallel builds can go awry. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-29 15:08:47 +00:00
bool is_dir(const std::string&);
bool dirname(std::string const& path,
std::string& dir_name);
bool base_name(std::string const& path,
std::string& file_name);
bool ensure_dir_path_created(const std::string&);
bool ensure_parent_dir_created(const std::string&);
bool check_file(const std::string& path, std::ostream& out);
Initial version of an archive manipulation program: biar * tests/test-utils.h (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): Move these directories manipulation utilities from here to ... * tools/abg-tools-utils.h (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): ... here in this new file. (dir_name, base_name): Declare these new functions. * tests/test-utils.cc (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): Likewise, move these to ... * tools/abg-tools-utils.cc (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): ... here in this new file. (dir_name, base_name): Define these. * tools/Makefile.am: New file. Create a new libtoolsutils.la static library with stuff from tools/abg-tools-utils.cc in it. Also create a new 'biar' program with the stuff from the new tools/biar.cc in it. * tools/biar.cc: New file. Contains the code for the new "biar" archive manipulation command line utility. * tests/test-read-write.cc (main): Adjust for the change about ensure_parent_dir_created above. * tests/test-write-read-archive.cc (main): Likewise. * Makefile.am (SUBDIRS): Add the new tools/ sub-directory to the build system. * configure.ac (AC_CONFIG_FILES): Generate tools/Makefile. * tests/Makefile.am: Make libtestutils.la link with the new libtoolsutils.la. Make sure to express the dependencies between libtestutils.la and the binaries that depend on it. Otherwise parallel builds can go awry. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-29 15:08:47 +00:00
Initial support for diffing ABI corpus files * include/abg-comparison.h (string_function_ptr_map) (changed_function_ptr, string_changed_function_ptr_map) (corpus_diff_sptr): New convenience typedefs. (translation_unit_diff): Add comments. (class corpus_diff): New type. (compute_diff): New overload for corpus_diff. * include/abg-corpus.h (corpus::{functions, variables}): New typedefs. (corpus::{operator==, get_functions, get_variables}): New members. * include/abg-diff-utils.h (struct deep_ptr_eq_functor): New functor. * include/abg-ir.h (translation_unit::operator==): New member equality operator. * src/abg-comparison.cc (struct corpus_diff::priv): New private struct holding the private members of corpus_diff. (corpus_diff::priv::{lookup_tables_empty, clear_lookup_tables, ensure_lookup_tables_populated}): Define new private member functions. (corpus_diff::{corpus_diff, first_corpus, second_corpus, function_changes, variable_changes, length, report}): New public members. (struct noop_deleter): New struct. (compute_diff): New implementation for corpus_diff. * src/abg-corpus.cc (struct corpus::priv): Renamed corpus::impl into this. Add new fns, vars and is_symbol_table_built data members. (corpus::priv::build_symbol_table): New member function. (class symtab_build_visitor_type): New visitor type to build the symbol table. (struct func_comp, struct var_comp): New comparison functors. (corpus::priv::build_symbol_table): Define new member function. (corpus::{corpus, add, get_translation_units, operator==, get_functions, get_variables}): Define new members. * src/abg-ir.cc (translation_unit::operator==): Define new member equality operator. (operator==(translation_unit_sptr l, translation_unit_sptr r)): Define new equality operator. * tools/abg-tools-utils.h (enum file_type): New enum. (guess_file_type): Declare new function. * tools/abg-tools-utils.cc (guess_file_type): define new function. * tools/bidiff.cc (main): Guess the type of the files given in input and support elf files reading and diffing. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-23 13:05:19 +00:00
/// The different types of files understood the bi* suite of tools.
enum file_type
{
/// A file type we don't know about.
FILE_TYPE_UNKNOWN,
/// The native xml file format representing a translation unit.
FILE_TYPE_NATIVE_BI,
/// An elf file. Read this kind of file should yield an
/// abigail::corpus type.
FILE_TYPE_ELF,
Support new 'abi-corpus' native XML format (.abi) * include/abg-reader.h (read_corpus_from_native_xml) (read_corpus_from_native_xml_file): Declare new entry points. * include/abg-writer.h (write_corpus_to_native_xml) (write_corpus_to_native_xml_file): Likewise. * src/abg-reader.cc (read_translation_unit_from_input): Renamed read_input into this. Support new 'path' attribute for 'abi-instr' XML element. (read_corpus_from_input): New static function. (read_translation_unit_from_file) (read_translation_unit_from_buffer) (read_translation_unit_from_istream): Update wrt read_input -> read_translation_unit_from_input. (read_corpus_from_native_xml, read_corpus_from_native_xml) (read_corpus_from_native_xml_file): Define new entry points. * src/abg-writer.cc (write_translation_unit): Write 'path' attribute into the 'abi-instr' xml element. (write_corpus_to_native_xml, write_corpus_to_native_xml_file): Define new entry points. * tools/abg-tools-utils.h (file_type::{FILE_TYPE_XML_CORPUS, FILE_TYPE_ZIP_CORPUS}): New enumerators. * tools/abg-tools-utils.cc (guess_file_type): Support detection of the new xml file format containing a document root 'abi-corpus' root element. * tools/bidiff.cc (main): Support diffing xml corpus-es and zip corpus-es. * tools/bidw.cc (main): Recognize elf files before reading them. * tools/bilint.cc (main): Support reading xml/zip corpus-es too. * tests/data/test-read-write/test[0-23].xml: Update 'path' attribute. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-07 13:12:26 +00:00
// A native xml file format representing a corpus of one or several
// translation units.
FILE_TYPE_XML_CORPUS,
// A zip file, possibly containing a corpus of one of several
// translation units.
FILE_TYPE_ZIP_CORPUS,
Initial support for diffing ABI corpus files * include/abg-comparison.h (string_function_ptr_map) (changed_function_ptr, string_changed_function_ptr_map) (corpus_diff_sptr): New convenience typedefs. (translation_unit_diff): Add comments. (class corpus_diff): New type. (compute_diff): New overload for corpus_diff. * include/abg-corpus.h (corpus::{functions, variables}): New typedefs. (corpus::{operator==, get_functions, get_variables}): New members. * include/abg-diff-utils.h (struct deep_ptr_eq_functor): New functor. * include/abg-ir.h (translation_unit::operator==): New member equality operator. * src/abg-comparison.cc (struct corpus_diff::priv): New private struct holding the private members of corpus_diff. (corpus_diff::priv::{lookup_tables_empty, clear_lookup_tables, ensure_lookup_tables_populated}): Define new private member functions. (corpus_diff::{corpus_diff, first_corpus, second_corpus, function_changes, variable_changes, length, report}): New public members. (struct noop_deleter): New struct. (compute_diff): New implementation for corpus_diff. * src/abg-corpus.cc (struct corpus::priv): Renamed corpus::impl into this. Add new fns, vars and is_symbol_table_built data members. (corpus::priv::build_symbol_table): New member function. (class symtab_build_visitor_type): New visitor type to build the symbol table. (struct func_comp, struct var_comp): New comparison functors. (corpus::priv::build_symbol_table): Define new member function. (corpus::{corpus, add, get_translation_units, operator==, get_functions, get_variables}): Define new members. * src/abg-ir.cc (translation_unit::operator==): Define new member equality operator. (operator==(translation_unit_sptr l, translation_unit_sptr r)): Define new equality operator. * tools/abg-tools-utils.h (enum file_type): New enum. (guess_file_type): Declare new function. * tools/abg-tools-utils.cc (guess_file_type): define new function. * tools/bidiff.cc (main): Guess the type of the files given in input and support elf files reading and diffing. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-23 13:05:19 +00:00
};
file_type guess_file_type(std::istream& in);
file_type guess_file_type(const std::string& file_path);
Initial version of an archive manipulation program: biar * tests/test-utils.h (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): Move these directories manipulation utilities from here to ... * tools/abg-tools-utils.h (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): ... here in this new file. (dir_name, base_name): Declare these new functions. * tests/test-utils.cc (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): Likewise, move these to ... * tools/abg-tools-utils.cc (is_dir, ensure_dir_path_created) (ensure_parent_dir_created): ... here in this new file. (dir_name, base_name): Define these. * tools/Makefile.am: New file. Create a new libtoolsutils.la static library with stuff from tools/abg-tools-utils.cc in it. Also create a new 'biar' program with the stuff from the new tools/biar.cc in it. * tools/biar.cc: New file. Contains the code for the new "biar" archive manipulation command line utility. * tests/test-read-write.cc (main): Adjust for the change about ensure_parent_dir_created above. * tests/test-write-read-archive.cc (main): Likewise. * Makefile.am (SUBDIRS): Add the new tools/ sub-directory to the build system. * configure.ac (AC_CONFIG_FILES): Generate tools/Makefile. * tests/Makefile.am: Make libtestutils.la link with the new libtoolsutils.la. Make sure to express the dependencies between libtestutils.la and the binaries that depend on it. Otherwise parallel builds can go awry. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-29 15:08:47 +00:00
}// end namespace tools
}//end namespace abigail