libabigail
Loading...
Searching...
No Matches
abg-tools-utils.h File Reference
#include <iostream>
#include <istream>
#include <memory>
#include <ostream>
#include <set>
#include <string>
#include "abg-suppression.h"
#include "abg-elf-based-reader.h"
Include dependency graph for abg-tools-utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  temp_file
 A temporary file. More...
 
class  timer
 A type used to time various part of the libabigail system. More...
 

Namespaces

namespace  abigail
 Toplevel namespace for libabigail.
 
namespace  abigail::tools_utils
 Namespace for a set of utility function used by tools based on libabigail.
 

Macros

#define ABG_ASSERT_NOT_REACHED
 A macro that expands to aborting the program when executed.
 

Typedefs

typedef shared_ptr< temp_filetemp_file_sptr
 Convenience typedef for a shared_ptr to temp_file.
 

Enumerations

enum  abidiff_status {
  ABIDIFF_OK , ABIDIFF_ERROR , ABIDIFF_USAGE_ERROR , ABIDIFF_ABI_CHANGE ,
  ABIDIFF_ABI_INCOMPATIBLE_CHANGE
}
 Exit status for abidiff and abicompat tools. More...
 
enum  file_type {
  FILE_TYPE_UNKNOWN , FILE_TYPE_NATIVE_BI , FILE_TYPE_ELF , FILE_TYPE_AR ,
  FILE_TYPE_XML_CORPUS , FILE_TYPE_XML_CORPUS_GROUP , FILE_TYPE_RPM , FILE_TYPE_SRPM ,
  FILE_TYPE_DEB , FILE_TYPE_DIR , FILE_TYPE_TAR
}
 The different types of files understood the bi* suite of tools. More...
 

Functions

bool abidiff_status_has_abi_change (abidiff_status s)
 Test if an instance of.
 
bool abidiff_status_has_error (abidiff_status s)
 Test if an instance of.
 
bool abidiff_status_has_incompatible_abi_change (abidiff_status s)
 Test if an instance of.
 
void add_binaries_into_corpus_group (const fe_iface_sptr &reader, const vector< string > &binaries, const vector< string > &deps_dirs, corpus_group &group)
 For each binary of a vector of binaries, if the binary is present in at least one of the directories listed in a given vector, construct a corpus and add it to a corpus group.
 
void add_dependencies_into_corpus_group (const fe_iface_sptr &reader, const corpus &korpus, const vector< string > &deps_dirs, corpus_group &group)
 For each dependency of a given corpus, if it is present in at least one of the directories listed in a given vector, construct a corpus and add it to a corpus group.
 
bool base_name (string const &path, string &file_name)
 Return the file name part of a file part.
 
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, suppressions_type &supprs, bool verbose, environment &env, corpus::origin requested_fe_kind)
 Walk a given directory and build an instance of corpus_group from the vmlinux kernel binary and the linux kernel modules found under that directory and under its sub-directories, recursively.
 
bool check_dir (const string &path, ostream &out, const string &prog_name)
 Check if a given path exists, is readable and is a directory.
 
bool check_file (const string &path, ostream &out, const string &prog_name)
 Check if a given path exists and is readable.
 
void convert_char_stars_to_char_star_stars (const vector< char * > &char_stars, vector< char ** > &char_star_stars)
 Convert a vector<char*> into a vector<char**>.
 
elf_based_reader_sptr create_best_elf_based_reader (const string &elf_file_path, const vector< char ** > &debug_info_root_paths, environment &env, corpus::origin requested_fe_kind, bool show_all_types, bool linux_kernel_mode)
 Create the best elf based reader (or front-end), given an ELF file.
 
bool decl_names_equal (const string &l, const string &r)
 Compare two fully qualified decl names by taking into account that they might have compontents that are anonymous types/namespace names.
 
bool dir_exists (const string &path)
 Test that a given directory exists.
 
bool dir_is_empty (const string &path)
 Test if a given directory exists and is empty.
 
bool dir_name (string const &path, string &dir_name, bool keep_separator_at_end)
 Return the directory part of a file path.
 
ostream & emit_prefix (const string &prog_name, ostream &out)
 Emit a prefix made of the name of the program which is emitting a message to an output stream.
 
bool ensure_dir_path_created (const string &dir_path)
 Ensures #dir_path is a directory and is created. If #dir_path is not created, this function creates it.
 
bool ensure_parent_dir_created (const string &path)
 Ensures that the parent directory of #path is created.
 
bool execute_command_and_get_output (const string &cmd, vector< string > &lines)
 Execute a shell command and returns its output.
 
bool file_exists (const string &path)
 Tests whether a path exists;.
 
bool file_has_btf_debug_info (const string &elf_file_path, const vector< char ** > &debug_info_root_paths)
 Test if an ELF file has BTFG debug info.
 
bool file_has_ctf_debug_info (const string &elf_file_path, const vector< char ** > &debug_info_root_paths)
 Test if an ELF file has CTF debug info.
 
bool file_has_dwarf_debug_info (const string &elf_file_path, const vector< char ** > &debug_info_root_paths)
 Test if an ELF file has DWARF debug info.
 
bool file_is_kernel_debuginfo_package (const string &file_name, file_type file_type)
 Tests if a given file name designates a kernel debuginfo package.
 
bool file_is_kernel_package (const string &file_path, file_type file_type)
 Tests if a given file name designates a kernel package.
 
bool find_file_under_dir (const string &root_dir, const string &file_path_to_look_for, string &result)
 Find a given file under a root directory and return its absolute path.
 
bool find_file_under_dirs (const vector< string > &root_dirs, const string &file_path_to_look_for, string &result)
 Find a given file possibly under a set of directories and return its absolute path.
 
type_suppression_sptr gen_suppr_spec_from_headers (const string &headers_root_dir)
 Generate a type suppression specification that suppresses ABI changes for types defined in source files that are not in a given header root dir.
 
type_suppression_sptr gen_suppr_spec_from_headers (const string &headers_root_dir, const vector< string > &header_files)
 Generate a type suppression specification that suppresses ABI changes for types defined in source files that are neither in a given header root dir, not in a set of header files.
 
type_suppression_sptr gen_suppr_spec_from_headers (const vector< string > &headers_root_dirs, const vector< string > &header_files)
 Generate a type suppression specification that suppresses ABI changes for types defined in source files that are neither in a given set of header root directories nor in a set of header files.
 
suppr::suppressions_type gen_suppr_spec_from_kernel_abi_whitelists (const vector< string > &abi_whitelist_paths)
 
string get_abixml_version_string ()
 Return the version string for the ABIXML format.
 
const char * get_anonymous_enum_internal_name_prefix ()
 Getter of the prefix for the name of anonymous enums.
 
const char * get_anonymous_struct_internal_name_prefix ()
 Getter of the prefix for the name of anonymous structs.
 
const char * get_anonymous_subrange_internal_name_prefix ()
 Getter of the prefix for the name of anonymous range.
 
const char * get_anonymous_union_internal_name_prefix ()
 Getter of the prefix for the name of anonymous unions.
 
bool get_binary_paths_from_kernel_dist (const string &dist_root, const string &debug_info_root_path, string &vmlinux_path, vector< string > &module_paths)
 Get the paths of the vmlinux and kernel module binaries under given directory.
 
bool get_binary_paths_from_kernel_dist (const string &dist_root, string &vmlinux_path, vector< string > &module_paths)
 Get the paths of the vmlinux and kernel module binaries under given directory.
 
void get_comma_separated_args_of_option (const string &input_str, const string &option, vector< string > &arguments)
 Get a vector of arguments from a string containing a comma-separated list of those arguments.
 
bool get_deb_name (const string &str, string &name)
 Get the package name of a .deb package.
 
string get_default_system_suppression_file_path ()
 Get the path to the default system suppression file.
 
string get_default_user_suppression_file_path ()
 Get the path to the default user suppression file.
 
bool get_dependencies (const corpus &korpus, const vector< string > &deps_dirs, set< string > &dependencies)
 Get the dependencies of an ABI corpus, which are found in a set of directories. Note that the dependencies are listed as properties of the ABI corpus.
 
bool get_dsos_provided_by_rpm (const string &rpm_path, set< string > &provided_dsos)
 Get the SONAMEs of the DSOs advertised as being "provided" by a given RPM. That set can be considered as being the set of "public" DSOs of the RPM.
 
string get_library_version_string ()
 Return the version string of the library.
 
size_t get_random_number ()
 Get a pseudo random number.
 
string get_random_number_as_string ()
 Get a pseudo random number as string.
 
bool get_rpm_arch (const string &str, string &arch)
 Get the architecture string from the NVR of an rpm.
 
bool get_rpm_name (const string &str, string &name)
 Get the package name of an rpm package.
 
const char * get_system_libdir ()
 Get the value of $libdir variable of the autotools build system. This is where shared libraries are usually installed.
 
bool get_vmlinux_path_from_kernel_dist (const string &from, string &vmlinux_path)
 Get the path of the vmlinux binary under the given directory, that must have been generated either from extracting a package.
 
file_type guess_file_type (const string &file_path)
 Guess the type of the content of an file.
 
file_type guess_file_type (istream &in)
 Guess the type of the content of an input stream.
 
void initialize ()
 This function needs to be called before any libabigail function.
 
bool is_dir (const string &path)
 Tests if a given path is a directory or a symbolic link to a directory.
 
bool is_regular_file (const string &path)
 Test if path is a path to a regular file or a symbolic link to a regular file.
 
void load_default_system_suppressions (suppr::suppressions_type &supprs)
 Load the default system suppression specification file and populate a vector of suppression_sptr with its content.
 
void load_default_user_suppressions (suppr::suppressions_type &supprs)
 Load the default user suppression specification file and populate a vector of suppression_sptr with its content.
 
std::shared_ptr< char > make_path_absolute (const char *p)
 Return a copy of the path given in argument, turning it into an absolute path by prefixing it with the concatenation of the result of get_current_dir_name() and the '/' character.
 
char * make_path_absolute_to_be_freed (const char *p)
 Return a copy of the path given in argument, turning it into an absolute path by prefixing it with the concatenation of the result of get_current_dir_name() and the '/' character.
 
bool maybe_get_symlink_target_file_path (const string &file_path, string &target_path)
 If a given file is a symbolic link, get the canonicalized absolute path to the target file.
 
abidiff_status operator& (abidiff_status l, abidiff_status r)
 The bitwise 'AND' operator for abidiff_status bit masks.
 
ostream & operator<< (ostream &o, const timer &t)
 Streaming operator for the timer type.
 
ostream & operator<< (ostream &output, file_type r)
 
abidiff_status operator| (abidiff_status l, abidiff_status r)
 The bitwise 'OR' operator for abidiff_status bit masks.
 
abidiff_statusoperator|= (abidiff_status &l, abidiff_status r)
 The |= operator.
 
void real_path (const string &path, string &result)
 Return the real path of a given path.
 
bool rpm_contains_file (const string &rpm_path, const string &file_name)
 Test if an RPM package contains a given file.
 
bool sorted_strings_common_prefix (vector< string > &input_strings, string &prefix)
 Find the prefix common to a *SORTED* vector of strings.
 
bool split_string (const string &input_string, const string &delims, vector< string > &result)
 Split a given string into substrings, given some delimiters.
 
corpus_group_sptr stick_corpus_and_binaries_into_corpus_group (const fe_iface_sptr &reader, const corpus_sptr &korpus, const vector< string > &binaries, const vector< string > &bins_dirs)
 Create a corpus group made of a given korpus and a set of binaries found in a set of directories.
 
corpus_group_sptr stick_corpus_and_dependencies_into_corpus_group (const fe_iface_sptr &reader, const corpus_sptr &korpus, const vector< string > &deps_dirs)
 Create a corpus group made of a given korpus and the subset of its dependencies that can be found found in a set of directories.
 
bool string_begins_with (const string &str, const string &prefix)
 Test if a given string begins with a particular prefix.
 
bool string_ends_with (const string &str, const string &suffix)
 Test if a given string ends with a particular suffix.
 
bool string_is_ascii (const string &str)
 Test if a string is made of ascii characters.
 
bool string_is_ascii_identifier (const string &str)
 Test if a string is made of ascii characters which are identifiers acceptable in C or C++ programs.
 
bool string_suffix (const string &input_string, const string &prefix, string &suffix)
 Get the suffix of a string, given a prefix to consider.
 
string trim_leading_string (const string &from, const string &to_trim)
 Remove a string of pattern in front of a given string.
 
string trim_white_space (const string &str)
 Remove spaces at the beginning and at the end of a given string.
 

Macro Definition Documentation

◆ ABG_ASSERT_NOT_REACHED

#define ABG_ASSERT_NOT_REACHED

A macro that expands to aborting the program when executed.

Before aborting, the macro emits informatin about the source location where it was expanded.

Definition at line 379 of file abg-tools-utils.h.