mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-16 15:04:46 +00:00
c80f79271a
Thanks to the previous work done, changing the license is just a matter of changing the SPDX identifer from "LGPL-3.0-or-later" to "Apache-2.0 WITH LLVM-exception". Note that for the abigail.m4, tests/test-dot.cc and tests/test-svg.cc the change was from "GPL-3.0-or-later WITH GCC-exception-3.1" to "Apache-2.0 WITH LLVM-exception". include/abg-cxx-compat.h was changed from "LGPL-2.0-or-later" to "Apache-2.0 WITH LLVM-exception". Source code of programs (as opposed to source code of the library) where generally licensed under GPL-3.0-or-later; they are also now licensed "Apache-2.0 WITH LLVM-exception". This is what this patch does. * abigail.m4: Change the SPDX identifier from "GPL-3.0-or-later WITH GCC-exception-3.1" to "Apache-2.0 WITH LLVM-exception" * include/abg-cxx-compat.h: Change the SPDX identifier from "LGPL-2.0-or-later" to "Apache-2.0 WITH LLVM-exception". * .clang-format: Change the SPDX identifier from "LGPL-3.0-or-later" to "Apache-2.0 WITH LLVM-exception". * Makefile.am: Likewise. * bash-completion/Makefile.am: Likewise. * bash-completion/abicompat: Likewise. * bash-completion/abidiff: Likewise. * bash-completion/abidw: Likewise. * bash-completion/abilint: Likewise. * bash-completion/abinilint: Likewise. * bash-completion/abipkgdiff: Likewise. * bash-completion/abisym: Likewise. * bash-completion/fedabipkgdiff: Likewise. * configure.ac: Likewise. * default.abignore: Likewise. * doc/Makefile.am: Likewise. * doc/api/libabigail.doxy: Likewise. * doc/manuals/Makefile.am: Likewise. * doc/website/libabigail-website.doxy: Likewise. * include/Makefile.am: Likewise. * include/abg-comp-filter.h: Likewise. * include/abg-comparison.h: Likewise. * include/abg-config.h: Likewise. * include/abg-corpus.h: Likewise. * include/abg-diff-utils.h: Likewise. * include/abg-dwarf-reader.h: Likewise. * include/abg-fwd.h: Likewise. * include/abg-hash.h: Likewise. * include/abg-ini.h: Likewise. * include/abg-interned-str.h: Likewise. * include/abg-ir.h: Likewise. * include/abg-libxml-utils.h: Likewise. * include/abg-libzip-utils.h: Likewise. * include/abg-reader.h: Likewise. * include/abg-regex.h: Likewise. * include/abg-reporter.h: Likewise. * include/abg-sptr-utils.h: Likewise. * include/abg-suppression.h: Likewise. * include/abg-tools-utils.h: Likewise. * include/abg-traverse.h: Likewise. * include/abg-version.h.in: Likewise. * include/abg-viz-common.h: Likewise. * include/abg-viz-dot.h: Likewise. * include/abg-viz-svg.h: Likewise. * include/abg-workers.h: Likewise. * include/abg-writer.h: Likewise. * scripts/dot_to_png.sh: Likewise. * scripts/dot_to_svg.sh: Likewise. * scripts/make-verbose.sh: Likewise. * scripts/svg_to_plain_svg.sh: Likewise. * scripts/svg_to_png_and_pdf.sh: Likewise. * src/Makefile.am: Likewise. * src/abg-comp-filter.cc: Likewise. * src/abg-comparison-priv.h: Likewise. * src/abg-comparison.cc: Likewise. * src/abg-config.cc: Likewise. * src/abg-corpus-priv.h: Likewise. * src/abg-corpus.cc: Likewise. * src/abg-default-reporter.cc: Likewise. * src/abg-diff-utils.cc: Likewise. * src/abg-dwarf-reader.cc: Likewise. * src/abg-elf-helpers.cc: Likewise. * src/abg-elf-helpers.h: Likewise. * src/abg-hash.cc: Likewise. * src/abg-ini.cc: Likewise. * src/abg-internal.h: Likewise. * src/abg-ir-priv.h: Likewise. * src/abg-ir.cc: Likewise. * src/abg-leaf-reporter.cc: Likewise. * src/abg-libxml-utils.cc: Likewise. * src/abg-libzip-utils.cc: Likewise. * src/abg-reader.cc: Likewise. * src/abg-regex.cc: Likewise. * src/abg-reporter-priv.cc: Likewise. * src/abg-reporter-priv.h: Likewise. * src/abg-suppression-priv.h: Likewise. * src/abg-suppression.cc: Likewise. * src/abg-tools-utils.cc: Likewise. * src/abg-traverse.cc: Likewise. * src/abg-viz-common.cc: Likewise. * src/abg-viz-dot.cc: Likewise. * src/abg-viz-svg.cc: Likewise. * src/abg-workers.cc: Likewise. * src/abg-writer.cc: Likewise. * tests/Makefile.am: Likewise. * tests/data/Makefile.am: Likewise. * tests/lib/catch.cc: Likewise. * tests/mockfedabipkgdiff.in: Likewise. * tests/print-diff-tree.cc: Likewise. * tests/runtestcanonicalizetypes.sh.in: Likewise. * tests/runtestdefaultsupprs.py.in: Likewise. * tests/runtestdefaultsupprspy3.sh.in: Likewise. * tests/runtestfedabipkgdiff.py.in: Likewise. * tests/runtestfedabipkgdiffpy3.sh.in: Likewise. * tests/test-abicompat.cc: Likewise. * tests/test-abidiff-exit.cc: Likewise. * tests/test-abidiff.cc: Likewise. * tests/test-alt-dwarf-file.cc: Likewise. * tests/test-annotate.cc: Likewise. * tests/test-core-diff.cc: Likewise. * tests/test-cxx-compat.cc: Likewise. * tests/test-diff-dwarf-abixml.cc: Likewise. * tests/test-diff-dwarf.cc: Likewise. * tests/test-diff-filter.cc: Likewise. * tests/test-diff-pkg.cc: Likewise. * tests/test-diff-suppr.cc: Likewise. * tests/test-diff2.cc: Likewise. * tests/test-dot.cc: Change the SPDX identifier from "GPL-3.0-or-later WITH GCC-exception-3.1" to "Apache-2.0 WITH LLVM-exception" * tests/test-elf-helpers.cc: Change the SPDX identifier from "LGPL-3.0-or-later" to "Apache-2.0 WITH LLVM-exception" * tests/test-ini.cc: Likewise. * tests/test-ir-walker.cc: Likewise. * tests/test-kmi-whitelist.cc: Likewise. * tests/test-lookup-syms.cc: Likewise. * tests/test-read-dwarf.cc: Likewise. * tests/test-read-write.cc: Likewise. * tests/test-svg.cc: Change the SPDX identifier from "GPL-3.0-or-later WITH GCC-exception-3.1" to "Apache-2.0 WITH LLVM-exception". * tests/test-symtab.cc: Change the SPDX identifier from "LGPL-3.0-or-later" to "Apache-2.0 WITH LLVM-exception" * tests/test-tools-utils.cc: Likewise. * tests/test-types-stability.cc: Likewise. * tests/test-utils.cc: Likewise. * tests/test-utils.h: Likewise. * tests/test-write-read-archive.cc: Likewise. * tests/update-test-output.py: Likewise. * tools/Makefile.am: Likewise. * tools/abiar.cc: Likewise. * tools/abicompat.cc: Likewise. * tools/abidiff.cc: Likewise. * tools/abidw.cc: Likewise. * tools/abilint.cc: Likewise. * tools/abipkgdiff.cc: Likewise. * tools/abisym.cc: Likewise. * tools/binilint.cc: Likewise. * tools/fedabipkgdiff: Likewise. * tools/kmidiff.cc: Likewise. * update-copyright.sh: Likewise. Signed-off-by: Benjamin De Kosnik <bkoz@gnu.org> Signed-off-by: Ben Woodard <woodard@redhat.com> Signed-off-by: Chenxiong Qi <cqi@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Jan Engelhardt <jengelh@inai.de> Signed-off-by: Jessica Yu <jeyu@kernel.org> Signed-off-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Mark Wielaard <mark@klomp.org> Signed-off-by: Matthias Klose <doko@ubuntu.com> Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com> Signed-off-by: Roland McGrath <roland@hack.frob.com> Signed-off-by: Sinny Kumari <ksinny@gmail.com> Signed-off-by: Slava Barinov <v.barinov@samsung.com>
337 lines
8.6 KiB
C++
337 lines
8.6 KiB
C++
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
// -*- Mode: C++ -*-
|
|
//
|
|
// Copyright (C) 2013-2020 Red Hat, Inc.
|
|
|
|
///@file
|
|
|
|
#ifndef __ABG_TOOLS_UTILS_H
|
|
#define __ABG_TOOLS_UTILS_H
|
|
|
|
#include <string>
|
|
#include <set>
|
|
#include <ostream>
|
|
#include <istream>
|
|
#include <iostream>
|
|
#include "abg-cxx-compat.h"
|
|
#include "abg-suppression.h"
|
|
|
|
namespace abigail
|
|
{
|
|
|
|
namespace tools_utils
|
|
{
|
|
|
|
using std::ostream;
|
|
using std::istream;
|
|
using std::ifstream;
|
|
using std::string;
|
|
using std::set;
|
|
using abg_compat::shared_ptr;
|
|
|
|
const char* get_system_libdir();
|
|
const char* get_anonymous_struct_internal_name_prefix();
|
|
const char* get_anonymous_union_internal_name_prefix();
|
|
const char* get_anonymous_enum_internal_name_prefix();
|
|
|
|
bool file_exists(const string&);
|
|
bool is_regular_file(const string&);
|
|
bool is_dir(const string&);
|
|
bool dir_exists(const string&);
|
|
bool dir_is_empty(const string &);
|
|
bool decl_names_equal(const string&, const string&);
|
|
bool maybe_get_symlink_target_file_path(const string& file_path,
|
|
string& target_path);
|
|
bool base_name(string const& path,
|
|
string& file_name);
|
|
bool dir_name(string const &path,
|
|
string& path_dir_name,
|
|
bool keep_separator_at_end=false);
|
|
void real_path(const string&path, string& realpath);
|
|
bool ensure_dir_path_created(const string&);
|
|
bool ensure_parent_dir_created(const string&);
|
|
ostream& emit_prefix(const string& prog_name, ostream& out);
|
|
bool check_file(const string& path, ostream& out, const string& prog_name = "");
|
|
bool check_dir(const string& path, ostream& out, const string& prog_name="");
|
|
bool string_ends_with(const string&, const string&);
|
|
bool string_begins_with(const string&, const string&);
|
|
bool string_is_ascii(const string&);
|
|
bool string_is_ascii_identifier(const string&);
|
|
bool split_string(const string&, const string&, vector<string>&);
|
|
bool string_suffix(const string&, const string&, string&);
|
|
bool sorted_strings_common_prefix(vector<string>&, string&);
|
|
string get_library_version_string();
|
|
bool execute_command_and_get_output(const string&, vector<string>&);
|
|
bool get_dsos_provided_by_rpm(const string& rpm_path,
|
|
set<string>& provided_dsos);
|
|
string trim_white_space(const string&);
|
|
string trim_leading_string(const string& from, const string& to_trim);
|
|
void convert_char_stars_to_char_star_stars(const vector<char*>&,
|
|
vector<char**>&);
|
|
|
|
suppr::type_suppression_sptr
|
|
gen_suppr_spec_from_headers(const string& hdrs_root_dir);
|
|
|
|
suppr::type_suppression_sptr
|
|
gen_suppr_spec_from_headers(const string& hdrs_root_dir,
|
|
const vector<string>& hdr_files);
|
|
|
|
suppr::type_suppression_sptr
|
|
gen_suppr_spec_from_headers(const vector<string>& headers_root_dirs,
|
|
const vector<string>& header_files);
|
|
|
|
suppr::suppressions_type
|
|
gen_suppr_spec_from_kernel_abi_whitelists
|
|
(const vector<string>& abi_whitelist_paths);
|
|
|
|
bool
|
|
get_vmlinux_path_from_kernel_dist(const string& from,
|
|
string& vmlinux_path);
|
|
|
|
bool
|
|
get_binary_paths_from_kernel_dist(const string& dist_root,
|
|
const string& debug_info_root_path,
|
|
string& vmlinux_path,
|
|
vector<string>& module_paths);
|
|
|
|
bool
|
|
get_binary_paths_from_kernel_dist(const string& dist_root,
|
|
string& vmlinux_path,
|
|
vector<string>& module_paths);
|
|
|
|
string
|
|
get_default_system_suppression_file_path();
|
|
|
|
string
|
|
get_default_user_suppression_file_path();
|
|
|
|
void
|
|
load_default_system_suppressions(suppr::suppressions_type&);
|
|
|
|
void
|
|
load_default_user_suppressions(suppr::suppressions_type&);
|
|
|
|
bool
|
|
find_file_under_dir(const string& root_dir,
|
|
const string& file_path_to_look_for,
|
|
string& result);
|
|
|
|
class temp_file;
|
|
|
|
/// Convenience typedef for a shared_ptr to @ref temp_file.
|
|
typedef shared_ptr<temp_file> temp_file_sptr;
|
|
|
|
/// A temporary file.
|
|
///
|
|
/// This is a helper file around the mkstemp API.
|
|
///
|
|
/// Once the temporary file is created, users can interact with it
|
|
/// using an fstream. They can also get the path to the newly
|
|
/// created temporary file.
|
|
///
|
|
/// When the instance of @ref temp_file is destroyed, the underlying
|
|
/// resources are de-allocated, the underlying temporary file is
|
|
/// closed and removed.
|
|
class temp_file
|
|
{
|
|
struct priv;
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
priv_sptr priv_;
|
|
|
|
temp_file();
|
|
|
|
public:
|
|
|
|
bool
|
|
is_good() const;
|
|
|
|
const char*
|
|
get_path() const;
|
|
|
|
std::fstream&
|
|
get_stream();
|
|
|
|
static temp_file_sptr
|
|
create();
|
|
}; // end class temp_file
|
|
|
|
size_t
|
|
get_random_number();
|
|
|
|
string
|
|
get_random_number_as_string();
|
|
|
|
/// 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,
|
|
/// An archive (AR) file.
|
|
FILE_TYPE_AR,
|
|
// A native abixml file format representing a corpus of one or
|
|
// several translation units.
|
|
FILE_TYPE_XML_CORPUS,
|
|
// A native abixml file format representing a corpus group of one or
|
|
// several corpora.
|
|
FILE_TYPE_XML_CORPUS_GROUP,
|
|
// A zip file, possibly containing a corpus of one of several
|
|
// translation units.
|
|
FILE_TYPE_ZIP_CORPUS,
|
|
/// An RPM (.rpm) binary file
|
|
FILE_TYPE_RPM,
|
|
/// An SRPM (.src.rpm) file
|
|
FILE_TYPE_SRPM,
|
|
/// A DEB (.deb) binary file
|
|
FILE_TYPE_DEB,
|
|
/// A plain directory
|
|
FILE_TYPE_DIR,
|
|
/// A tar archive. The archive can be compressed with the popular
|
|
/// compression schemes recognized by GNU tar.
|
|
FILE_TYPE_TAR
|
|
};
|
|
|
|
/// Exit status for abidiff and abicompat tools.
|
|
///
|
|
/// It's actually a bit mask. The value of each enumerator is a power
|
|
/// of two.
|
|
enum abidiff_status
|
|
{
|
|
/// This is for when the compared ABIs are equal.
|
|
///
|
|
/// Its numerical value is 0.
|
|
ABIDIFF_OK = 0,
|
|
|
|
/// This bit is set if there is an application error.
|
|
///
|
|
/// Its numerical value is 1.
|
|
ABIDIFF_ERROR = 1,
|
|
|
|
/// This bit is set if the tool is invoked in an non appropriate
|
|
/// manner.
|
|
///
|
|
/// Its numerical value is 2.
|
|
ABIDIFF_USAGE_ERROR = 1 << 1,
|
|
|
|
/// This bit is set if the ABIs being compared are different.
|
|
///
|
|
/// Its numerical value is 4.
|
|
ABIDIFF_ABI_CHANGE = 1 << 2,
|
|
|
|
/// This bit is set if the ABIs being compared are different *and*
|
|
/// are incompatible.
|
|
///
|
|
/// Its numerical value is 8.
|
|
ABIDIFF_ABI_INCOMPATIBLE_CHANGE = 1 << 3
|
|
};
|
|
|
|
abidiff_status
|
|
operator|(abidiff_status, abidiff_status);
|
|
|
|
abidiff_status
|
|
operator&(abidiff_status, abidiff_status);
|
|
|
|
abidiff_status&
|
|
operator|=(abidiff_status&l, abidiff_status r);
|
|
|
|
bool
|
|
abidiff_status_has_error(abidiff_status s);
|
|
|
|
bool
|
|
abidiff_status_has_abi_change(abidiff_status s);
|
|
|
|
bool
|
|
abidiff_status_has_incompatible_abi_change(abidiff_status s);
|
|
|
|
/// A type used to time various part of the libabigail system.
|
|
class timer
|
|
{
|
|
struct priv;
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
priv_sptr priv_;
|
|
|
|
public:
|
|
enum kind
|
|
{
|
|
/// Default timer kind.
|
|
DEFAULT_TIMER_KIND = 0,
|
|
/// This kind of timer starts upon instantiation.
|
|
START_ON_INSTANTIATION_TIMER_KIND = 1,
|
|
};
|
|
|
|
timer (kind k = DEFAULT_TIMER_KIND);
|
|
bool start();
|
|
bool stop();
|
|
time_t value_in_seconds() const;
|
|
bool value(time_t& hours,
|
|
time_t& minutes,
|
|
time_t& seconds,
|
|
time_t& milliseconds) const;
|
|
string value_as_string() const;
|
|
~timer();
|
|
}; //end class timer
|
|
|
|
ostream& operator<<(ostream&, const timer&);
|
|
|
|
ostream&
|
|
operator<<(ostream& output, file_type r);
|
|
|
|
file_type guess_file_type(istream& in);
|
|
|
|
file_type guess_file_type(const string& file_path);
|
|
|
|
bool
|
|
get_rpm_name(const string& str, string& name);
|
|
|
|
bool
|
|
get_rpm_arch(const string& str, string& arch);
|
|
|
|
bool
|
|
get_deb_name(const string& str, string& name);
|
|
|
|
bool
|
|
file_is_kernel_package(const string& file_path,
|
|
file_type file_type);
|
|
|
|
bool
|
|
file_is_kernel_debuginfo_package(const string& file_path,
|
|
file_type file_type);
|
|
|
|
abg_compat::shared_ptr<char>
|
|
make_path_absolute(const char*p);
|
|
|
|
char*
|
|
make_path_absolute_to_be_freed(const char*p);
|
|
|
|
corpus_group_sptr
|
|
build_corpus_group_from_kernel_dist_under(const string& root,
|
|
const string debug_info_root,
|
|
const string& vmlinux_path,
|
|
vector<string>& suppr_paths,
|
|
vector<string>& kabi_wl_paths,
|
|
suppr::suppressions_type& supprs,
|
|
bool verbose,
|
|
environment_sptr& env);
|
|
}// end namespace tools_utils
|
|
|
|
/// A macro that expands to aborting the program when executed.
|
|
///
|
|
/// Before aborting, the macro emits informatin about the source
|
|
/// location where it was expanded.
|
|
#define ABG_ASSERT_NOT_REACHED \
|
|
do { \
|
|
std::cerr << "in " << __FUNCTION__ \
|
|
<< " at: " << __FILE__ << ":" << __LINE__ \
|
|
<< ": execution should not have reached this point!\n"; \
|
|
abort(); \
|
|
} while (false)
|
|
}//end namespace abigail
|
|
|
|
#endif //__ABG_TOOLS_UTILS_H
|