libabigail
Classes | Typedefs | Enumerations | Functions
abigail::tools_utils Namespace Reference

Namespace for a set of utility function used by tools based on libabigail. More...

Classes

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

Typedefs

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

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. More...
 
bool abidiff_status_has_error (abidiff_status s)
 Test if an instance of. More...
 
bool abidiff_status_has_incompatible_abi_change (abidiff_status s)
 Test if an instance of. More...
 
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. More...
 
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. More...
 
bool base_name (string const &path, string &file_name)
 Return the file name part of a file part. More...
 
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. More...
 
bool check_dir (const string &path, ostream &out, const string &prog_name)
 Check if a given path exists, is readable and is a directory. More...
 
bool check_file (const string &path, ostream &out, const string &prog_name)
 Check if a given path exists and is readable. More...
 
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**>. More...
 
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. More...
 
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. More...
 
bool dir_contains_ctf_archive (const string &directory, const string &archive_prefix)
 Test if a directory contains a CTF archive. More...
 
bool dir_exists (const string &path)
 Test that a given directory exists. More...
 
bool dir_is_empty (const string &path)
 Test if a given directory exists and is empty. More...
 
bool dir_name (string const &path, string &dir_name, bool keep_separator_at_end)
 Return the directory part of a file path. More...
 
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. More...
 
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. More...
 
bool ensure_parent_dir_created (const string &path)
 Ensures that the parent directory of #path is created. More...
 
bool execute_command_and_get_output (const string &cmd, vector< string > &lines)
 Execute a shell command and returns its output. More...
 
bool file_exists (const string &path)
 Tests whether a path exists;. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
bool file_is_kernel_package (const string &file_path, file_type file_type)
 Tests if a given file name designates a kernel package. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
suppressions_type gen_suppr_spec_from_kernel_abi_whitelists (const std::vector< std::string > &abi_whitelist_paths)
 Generate a suppression specification from kernel abi whitelist files. More...
 
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. More...
 
const char * get_anonymous_enum_internal_name_prefix ()
 Getter of the prefix for the name of anonymous enums. More...
 
const char * get_anonymous_struct_internal_name_prefix ()
 Getter of the prefix for the name of anonymous structs. More...
 
const char * get_anonymous_subrange_internal_name_prefix ()
 Getter of the prefix for the name of anonymous range. More...
 
const char * get_anonymous_union_internal_name_prefix ()
 Getter of the prefix for the name of anonymous unions. More...
 
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. More...
 
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. More...
 
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. More...
 
bool get_deb_name (const string &str, string &name)
 Get the package name of a .deb package. More...
 
string get_default_system_suppression_file_path ()
 Get the path to the default system suppression file. More...
 
string get_default_user_suppression_file_path ()
 Get the path to the default user suppression file. More...
 
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. More...
 
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. More...
 
string get_library_version_string ()
 Return the version string of the library. More...
 
size_t get_random_number ()
 Get a pseudo random number. More...
 
string get_random_number_as_string ()
 Get a pseudo random number as string. More...
 
bool get_rpm_arch (const string &str, string &arch)
 Get the architecture string from the NVR of an rpm. More...
 
bool get_rpm_name (const string &str, string &name)
 Get the package name of an rpm package. More...
 
const char * get_system_libdir ()
 Get the value of $libdir variable of the autotools build system. This is where shared libraries are usually installed. More...
 
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. More...
 
file_type guess_file_type (const string &file_path)
 Guess the type of the content of an file. More...
 
file_type guess_file_type (istream &in)
 Guess the type of the content of an input stream. More...
 
void initialize ()
 This function needs to be called before any libabigail function. More...
 
bool is_dir (const string &path)
 Tests if a given path is a directory or a symbolic link to a directory. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
abidiff_status operator& (abidiff_status l, abidiff_status r)
 The bitwise 'AND' operator for abidiff_status bit masks. More...
 
ostream & operator<< (ostream &o, const timer &t)
 Streaming operator for the timer type. More...
 
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. More...
 
abidiff_statusoperator|= (abidiff_status &l, abidiff_status r)
 The |= operator. More...
 
void real_path (const string &path, string &result)
 Return the real path of a given path. More...
 
bool rpm_contains_file (const string &rpm_path, const string &file_name)
 Test if an RPM package contains a given file. More...
 
bool sorted_strings_common_prefix (vector< string > &input_strings, string &prefix)
 Find the prefix common to a *SORTED* vector of strings. More...
 
bool split_string (const string &input_string, const string &delims, vector< string > &result)
 Split a given string into substrings, given some delimiters. More...
 
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. More...
 
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. More...
 
bool string_begins_with (const string &str, const string &prefix)
 Test if a given string begins with a particular prefix. More...
 
bool string_ends_with (const string &str, const string &suffix)
 Test if a given string ends with a particular suffix. More...
 
bool string_is_ascii (const string &str)
 Test if a string is made of ascii characters. More...
 
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. More...
 
bool string_suffix (const string &input_string, const string &prefix, string &suffix)
 Get the suffix of a string, given a prefix to consider. More...
 
string trim_leading_string (const string &from, const string &to_trim)
 Remove a string of pattern in front of a given string. More...
 
string trim_white_space (const string &str)
 Remove spaces at the beginning and at the end of a given string. More...
 

Detailed Description

Namespace for a set of utility function used by tools based on libabigail.

Typedef Documentation

◆ temp_file_sptr

typedef shared_ptr<temp_file> temp_file_sptr

Convenience typedef for a shared_ptr to temp_file.

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

Enumeration Type Documentation

◆ abidiff_status

Exit status for abidiff and abicompat tools.

It's actually a bit mask. The value of each enumerator is a power of two.

Enumerator
ABIDIFF_OK 

This is for when the compared ABIs are equal.

Its numerical value is 0.

ABIDIFF_ERROR 

This bit is set if there is an application error.

Its numerical value is 1.

ABIDIFF_USAGE_ERROR 

This bit is set if the tool is invoked in an non appropriate manner.

Its numerical value is 2.

ABIDIFF_ABI_CHANGE 

This bit is set if the ABIs being compared are different.

Its numerical value is 4.

ABIDIFF_ABI_INCOMPATIBLE_CHANGE 

This bit is set if the ABIs being compared are different *and* are incompatible.

Its numerical value is 8.

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

◆ file_type

enum file_type

The different types of files understood the bi* suite of tools.

Enumerator
FILE_TYPE_UNKNOWN 

A file type we don't know about.

FILE_TYPE_NATIVE_BI 

The native xml file format representing a translation unit.

FILE_TYPE_ELF 

An elf file. Read this kind of file should yield an abigail::corpus type.

FILE_TYPE_AR 

An archive (AR) file.

FILE_TYPE_RPM 

An RPM (.rpm) binary file.

FILE_TYPE_SRPM 

An SRPM (.src.rpm) file.

FILE_TYPE_DEB 

A DEB (.deb) binary file.

FILE_TYPE_DIR 

A plain directory.

FILE_TYPE_TAR 

A tar archive. The archive can be compressed with the popular compression schemes recognized by GNU tar.

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

Function Documentation

◆ abidiff_status_has_abi_change()

bool abidiff_status_has_abi_change ( abidiff_status  s)

Test if an instance of.

Parameters
abidiff_statusbits mask represents an abi change.

This functions tests if the ABIDIFF_ABI_CHANGE bit is set in the given bits mask.

Parameters
sthe bit mask to consider.
Returns
true iff s has its ABIDIFF_ABI_CHANGE bit set.

Definition at line 173 of file abg-tools-utils.cc.

◆ abidiff_status_has_error()

bool abidiff_status_has_error ( abidiff_status  s)

Test if an instance of.

Parameters
abidiff_statusbits mask represents an error.

This functions tests if the ABIDIFF_ERROR bit is set in the given bits mask.

Parameters
sthe bit mask to consider.
Returns
true iff s has its ABIDIFF_ERROR bit set.

Definition at line 160 of file abg-tools-utils.cc.

◆ abidiff_status_has_incompatible_abi_change()

bool abidiff_status_has_incompatible_abi_change ( abidiff_status  s)

Test if an instance of.

Parameters
abidiff_statusbits mask represents an incompatible abi change.

This functions tests if the ABIDIFF_INCOMPATIBLE_ABI_CHANGE bit is set in the given bits mask. Note that the this bit is set then the bit ABIDIFF_ABI_CHANGE must be set as well.

Parameters
sthe bit mask to consider.
Returns
true iff s has its ABIDIFF_INCOMPATIBLE ABI_CHANGE set.

Definition at line 188 of file abg-tools-utils.cc.

◆ add_binaries_into_corpus_group()

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.

Parameters
readerthe reader used to read the binaries into an ABI corpus.
binariesthe vector of binaries to read and add to a corpus group.
deps_dirsthe vector of directories where to look for the binaries in binaries.
groupthe corpus group to add the corpus.

Definition at line 2515 of file abg-tools-utils.cc.

◆ add_dependencies_into_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.

Parameters
readerthe reader used to read the binaries into an ABI corpus.
korpusthe corpus to consider.
deps_dirsthe vector of directories where to look for the dependencies of korpus.
groupthe corpus group to add the corpus.

Definition at line 2555 of file abg-tools-utils.cc.

◆ base_name()

bool base_name ( string const &  path,
string &  file_name 
)

Return the file name part of a file part.

Parameters
paththe file path to consider.
file_namethe name part of the file to consider.
Returns
true upon successful completion, false otherwise (okay it always return true for now, but that might change in the future).

Definition at line 778 of file abg-tools-utils.cc.

◆ build_corpus_group_from_kernel_dist_under()

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.

The main corpus of the corpus_group is made of the vmlinux binary. The other corpora are made of the linux kernel binaries.

Parameters
rootthe path of the directory under which the kernel kernel modules are to be found. The vmlinux can also be found somewhere under that directory, but if it's not in there, its path can be set to the vmlinux_path parameter.
debug_info_rootthe directory under which debug info is to be found for binaries under director root.
vmlinux_paththe path to the vmlinux binary, if that binary is not under the root directory. If this is empty, then it means the vmlinux binary is to be found under the root directory.
suppr_pathsthe paths to the suppression specifications to apply while loading the binaries.
kabi_wl_paththe paths to the kabi whitelist files to take into account while loading the binaries.
supprsthe suppressions resulting from parsing the suppression specifications at suppr_paths. This is set by this function.
verbosetrue if the function has to emit some verbose messages.
envthe environment to create the corpus_group in.
requested_fe_kindthe kind of front-end requested by the user.

Definition at line 3106 of file abg-tools-utils.cc.

◆ check_dir()

bool check_dir ( const string &  path,
ostream &  out,
const string &  prog_name 
)

Check if a given path exists, is readable and is a directory.

Parameters
paththe path to consider.
outthe out stream to report errors to.
prog_namethe program name on behalf of which to report the error, if any.
Returns
true iff path exists and is for a directory.

Definition at line 924 of file abg-tools-utils.cc.

◆ check_file()

bool check_file ( const string &  path,
ostream &  out,
const string &  prog_name 
)

Check if a given path exists and is readable.

Parameters
paththe path to consider.
outthe out stream to report errors to.
Returns
true iff path exists and is readable.

Definition at line 896 of file abg-tools-utils.cc.

◆ convert_char_stars_to_char_star_stars()

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**>.

Parameters
char_starsthe input vector.
char_star_starsthe output vector.

Definition at line 1382 of file abg-tools-utils.cc.

◆ create_best_elf_based_reader()

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.

This function looks into the ELF file; depending on the kind of debug info it contains and on the request of the user, the "best" front-end is created.

If the user requested the use of the CTF front-end, then, if the file contains CTF debug info, the CTF front-end is created, assuming libabigail is built with CTF support.

If the binary ONLY has CTF debug info, then CTF front-end is created, even if the user hasn't explicitly requested the creation of the CTF front-end.

Otherwise, by default, the DWARF front-end is created.

Parameters
elf_file_patha path to the ELF file to consider
debug_info_root_pathsa vector of the paths where to look for debug info, if applicable.
envthe environment to use for the front-end.
requested_fe_kindthe kind of front-end specifically requested by the user. At the moment, only the CTF front-end can be requested, using the "--ctf" command line option on some tools using the library.
show_all_typesoption to be passed to elf based readers.
linux_kernel_modeoption to bed passed to elf based readers,
Returns
the ELF based Reader that is better adapted for the binary designated by elf_file_path.

Definition at line 3208 of file abg-tools-utils.cc.

◆ decl_names_equal()

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.

For instance:

__anonymous_struct__1::foo and __anonymous_struct__2::foo are considered being equivalent qualified names because both are data members that belong to anonymous structs. The anonymous structs are numbered so that we can tell them appart (and look them up) where there are several of them in the same scope. But during comparison, for various purposes, we want to consider them as equivalent.

Similarly, __anonymous_struct__1::foo::__anonymous_struct__2::bar and __anonymous_struct__10::foo::__anonymous_struct__11::bar are equivalent.

But __anonymous_struct__1::foo::__anonymous_struct__2::bar and __anonymous_struct__10::foo::__anonymous_union__11::bar are not equivalent because the former designates a member of an anonymous struct and the latter designates a member of an anonymous union.

So this function handles those cases.

Parameters
lthe name of the first (left hand side) decl to consider.
rthe name of the second (right hand side) decl to consider.
Returns
true iff l is equivalent to r when taking into account the anonymous scopes that both might have and if they might be anonymous themselves.

Definition at line 662 of file abg-tools-utils.cc.

◆ dir_contains_ctf_archive()

bool abigail::tools_utils::dir_contains_ctf_archive ( const string &  directory,
const string &  archive_prefix 
)

Test if a directory contains a CTF archive.

Parameters
directorythe directory to consider.
archive_prefixthe prefix of the archive file.
Returns
true iff directory contains a CTF archive file.

Definition at line 434 of file abg-tools-utils.cc.

◆ dir_exists()

bool dir_exists ( const string &  path)

Test that a given directory exists.

Parameters
paththe path of the directory to consider.
Returns
true iff a directory exists with the name path

Definition at line 376 of file abg-tools-utils.cc.

◆ dir_is_empty()

bool dir_is_empty ( const string &  path)

Test if a given directory exists and is empty.

Parameters
paththe path of the directory to consider

Definition at line 383 of file abg-tools-utils.cc.

◆ dir_name()

bool dir_name ( string const &  path,
string &  dir_name,
bool  keep_separator_at_end 
)

Return the directory part of a file path.

Parameters
paththe file path to consider
dirnamthe resulting directory part, or "." if the couldn't figure out anything better (for now; maybe we should do something better than this later ...).
keep_separator_at_endif true, then keep the separator at the end of the resulting dir name.
Returns
true upon successful completion, false otherwise (okay, for now it always return true, but that might change in the future).

Definition at line 749 of file abg-tools-utils.cc.

◆ emit_prefix()

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.

The prefix is a string which looks like:

"<program-name> : "

Parameters
prog_namethe name of the program to use in the prefix.
outthe output stream where to emit the prefix.
Returns
the output stream where the prefix was emitted.

Definition at line 881 of file abg-tools-utils.cc.

◆ ensure_dir_path_created()

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.

Returns
true if #dir_path is a directory that is already present, of if the function has successfuly created it.

Definition at line 825 of file abg-tools-utils.cc.

◆ ensure_parent_dir_created()

bool ensure_parent_dir_created ( const string &  path)

Ensures that the parent directory of #path is created.

Returns
true if the parent directory of #path is already present, or if this function has successfuly created it.

Definition at line 855 of file abg-tools-utils.cc.

◆ execute_command_and_get_output()

bool execute_command_and_get_output ( const string &  cmd,
vector< string > &  lines 
)

Execute a shell command and returns its output.

Parameters
cmdthe shell command to execute.
linesoutput parameter. This is set with the lines that constitute the output of the process that executed the command cmd.
Returns
true iff the command was executed properly and no error was encountered.

Definition at line 1227 of file abg-tools-utils.cc.

◆ file_exists()

bool file_exists ( const string &  path)

Tests whether a path exists;.

Parameters
paththe path to test for.
Returns
true iff the path at path exist.

Definition at line 363 of file abg-tools-utils.cc.

◆ file_has_btf_debug_info()

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.

Parameters
elf_file_paththe path to the ELF file to consider.
debug_info_roota vector of pointer to directory to look for debug info, in case the file is associated to split debug info. If there is no split debug info then this vector can be empty. Note that convert_char_stars_to_char_star_stars() can be used to ease the construction of this vector.
Returns
true iff the ELF file at @elf_file_path is an ELF file that contains debug info.

Definition at line 538 of file abg-tools-utils.cc.

◆ file_has_ctf_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.

This function supports split debug info files as well. Linux Kernel with CTF debug information generates a CTF archive: a special file containing debug information for vmlinux and its modules (*.ko) files it is located by default in the Kernel build directory as "vmlinux.ctfa".

Parameters
elf_file_paththe path to the ELF file to consider.
debug_info_roota vector of pointer to directory to look for debug info, in case the file is associated to split debug info. If there is no split debug info then this vector can be empty. Note that convert_char_stars_to_char_star_stars() can be used to ease the construction of this vector.
Returns
true iff the ELF file at @elf_file_path is an ELF file that contains debug info.

Definition at line 494 of file abg-tools-utils.cc.

◆ file_has_dwarf_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.

This function supports split debug info files as well.

Parameters
elf_file_paththe path to the ELF file to consider.
debug_info_roota vector of pointer to directory to look for debug info, in case the file is associated to split debug info. If there is no split debug info then this vector can be empty. Note that convert_char_stars_to_char_star_stars() can be used to ease the construction of this vector.
Returns
true iff the ELF file at @elf_file_path is an ELF file that contains debug info.

Definition at line 458 of file abg-tools-utils.cc.

◆ file_is_kernel_debuginfo_package()

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.

Parameters
file_namethe file name to consider.
file_typethe type of the file file_name.
Returns
true iff file_name of kind file_type designates a kernel debuginfo package.

Definition at line 1893 of file abg-tools-utils.cc.

◆ file_is_kernel_package()

bool file_is_kernel_package ( const string &  file_path,
file_type  file_type 
)

Tests if a given file name designates a kernel package.

Parameters
file_paththe path to the file to consider.
file_typethe type of the file file_name.
Returns
true iff file_name of kind file_type designates a kernel package.

Definition at line 1833 of file abg-tools-utils.cc.

◆ find_file_under_dir()

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.

Parameters
root_dirthe root directory under which to look for.
file_path_to_look_forthe file to look for under the directory root_dir.
resultthe resulting path to file_path_to_look_for. This is set iff the file has been found.

Definition at line 2396 of file abg-tools-utils.cc.

◆ find_file_under_dirs()

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.

Parameters
root_dirsthe vector of root directories under which to look for.
file_path_to_look_forthe file to look for under the directory root_dir.
resultthe resulting path to file_path_to_look_for. This is set iff the file has been found.

Definition at line 2443 of file abg-tools-utils.cc.

◆ gen_suppr_spec_from_headers() [1/3]

suppr::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.

Parameters
headers_root_dirABI changes in types defined in files *NOT* found in this directory tree are going be suppressed.
Returns
the resulting type suppression generated, if any file was found in the directory tree headers_root_dir.

Definition at line 2154 of file abg-tools-utils.cc.

◆ gen_suppr_spec_from_headers() [2/3]

suppr::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.

Parameters
headers_root_dirABI changes in types defined in files *NOT* found in this directory tree are going be suppressed.
header_filesa set of additional header files that define types that are to be kept (not supressed) by the returned type suppression.
Returns
the resulting type suppression generated, if any file was found in the directory tree headers_root_dir.

Definition at line 2132 of file abg-tools-utils.cc.

◆ gen_suppr_spec_from_headers() [3/3]

suppr::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.

Parameters
headers_root_dirsABI changes in types defined in files *NOT* found in these directory trees are going be suppressed.
header_filesa set of additional header files that define types that are to be kept (not supressed) by the returned type suppression.
Returns
the resulting type suppression generated, if any file was found in the directory tree headers_root_dir.

Definition at line 2100 of file abg-tools-utils.cc.

◆ gen_suppr_spec_from_kernel_abi_whitelists()

suppressions_type abigail::tools_utils::gen_suppr_spec_from_kernel_abi_whitelists ( const std::vector< std::string > &  abi_whitelist_paths)

Generate a suppression specification from kernel abi whitelist files.

A kernel ABI whitelist file is an INI file that usually has only one section. The name of the section is a string that ends up with the sub-string "whitelist". For instance RHEL7_x86_64_whitelist.

Then the content of the section is a set of function or variable names, one name per line. Each function or variable name is the name of a function or a variable whose changes are to be keept.

A whitelist file can have multiple sections (adhering to the naming conventions and multiple files can be passed. The suppression that is created takes all whitelist sections from all files into account. Symbols (or expression of such) are deduplicated in the final suppression expression.

This function reads the white lists and generates a function_suppression_sptr and variable_suppression_sptr and returns a vector containing those.

Parameters
abi_whitelist_pathsa vector of KMI whitelist paths
Returns
a vector or suppressions

Definition at line 2187 of file abg-tools-utils.cc.

◆ get_abixml_version_string()

string get_abixml_version_string ( )

Return the version string for the ABIXML format.

Returns
the version string of the ABIXML format.

Definition at line 1208 of file abg-tools-utils.cc.

◆ get_anonymous_enum_internal_name_prefix()

const char * get_anonymous_enum_internal_name_prefix ( )

Getter of the prefix for the name of anonymous enums.

@reaturn the prefix for the name of anonymous enums.

Definition at line 620 of file abg-tools-utils.cc.

◆ get_anonymous_struct_internal_name_prefix()

const char * get_anonymous_struct_internal_name_prefix ( )

Getter of the prefix for the name of anonymous structs.

@reaturn the prefix for the name of anonymous structs.

Definition at line 603 of file abg-tools-utils.cc.

◆ get_anonymous_subrange_internal_name_prefix()

const char * get_anonymous_subrange_internal_name_prefix ( )

Getter of the prefix for the name of anonymous range.

@reaturn the prefix for the name of anonymous range.

Definition at line 627 of file abg-tools-utils.cc.

◆ get_anonymous_union_internal_name_prefix()

const char * get_anonymous_union_internal_name_prefix ( )

Getter of the prefix for the name of anonymous unions.

@reaturn the prefix for the name of anonymous unions.

Definition at line 610 of file abg-tools-utils.cc.

◆ get_binary_paths_from_kernel_dist() [1/2]

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.

Parameters
dist_rootthe directory under which to look for.
debug_info_root_paththe path to the directory under which debug info is going to be found for binaries under dist_root.
vmlinux_pathoutput parameter. The path of the vmlinux binary that was found.
module_pathsoutput parameter. The paths of the kernel module binaries that were found, sorted to impose a deterministic ordering.
Returns
true if at least the path to the vmlinux binary was found.

Definition at line 2842 of file abg-tools-utils.cc.

◆ get_binary_paths_from_kernel_dist() [2/2]

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.

Parameters
dist_rootthe directory under which to look for.
vmlinux_pathoutput parameter. The path of the vmlinux binary that was found.
module_pathsoutput parameter. The paths of the kernel module binaries that were found.
Returns
true if at least the path to the vmlinux binary was found.

Definition at line 2938 of file abg-tools-utils.cc.

◆ get_comma_separated_args_of_option()

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.

Parameters
input_strthe input string containing the comma-separated list of arguments The input string has the form "option=arg1,arg2,arg3,arg4".
optionif the content of the input string input_str is "option=arg1,arg2,arg3", then this parameter should be "option".
argumentsthis is set by the fonction the the arguments that were a comma-separated list of arguments on the right hand side of the '=' sign in the string input_str.

Definition at line 1272 of file abg-tools-utils.cc.

◆ get_deb_name()

bool get_deb_name ( const string &  str,
string &  name 
)

Get the package name of a .deb package.

Parameters
strthe string containing the .deb NVR.
nameoutput parameter. This is set with the package name of the .deb package iff the function returns true.
Returns
true iff the function successfully finds the .deb package name.

Definition at line 1716 of file abg-tools-utils.cc.

◆ get_default_system_suppression_file_path()

string get_default_system_suppression_file_path ( )

Get the path to the default system suppression file.

Returns
a copy of the default system suppression file.

Definition at line 2276 of file abg-tools-utils.cc.

◆ get_default_user_suppression_file_path()

string get_default_user_suppression_file_path ( )

Get the path to the default user suppression file.

Returns
a copy of the default user suppression file.

Definition at line 2295 of file abg-tools-utils.cc.

◆ get_dependencies()

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.

If the corpus has a dependency that is not found under any of the given directories, then the dependency is ignored and not returned.

Parameters
korpusthe ABI corpus to consider.
deps_dirsthe list of directories where to look for the dependencies.
dependenciesoutput parameter that is set the dependencies of the corpus denoted by korpus which are found in the directories deps_dirs. This is set iff the function returns true.
Returns
true iff some dependencies of the corpus korpus were found in directories deps_dirs.

Definition at line 2478 of file abg-tools-utils.cc.

◆ get_dsos_provided_by_rpm()

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.

This runs the command "rpm -qp --provides <rpm> | grep .so" and filters its result.

Parameters
rpm_paththe path to the RPM to consider.
provided_dsosoutput parameter. This is set to the set of SONAMEs of the DSOs advertised as being provided by the RPM designated by rpm_path.
Returns
true iff we could successfully query the RPM to see what DSOs it provides.

Definition at line 1302 of file abg-tools-utils.cc.

◆ get_library_version_string()

string get_library_version_string ( )

Return the version string of the library.

Returns
the version string of the library.

Definition at line 1196 of file abg-tools-utils.cc.

◆ get_random_number()

size_t get_random_number ( )

Get a pseudo random number.

Returns
a pseudo random number.

Definition at line 1489 of file abg-tools-utils.cc.

◆ get_random_number_as_string()

string get_random_number_as_string ( )

Get a pseudo random number as string.

Returns
a pseudo random number as string.

Definition at line 1506 of file abg-tools-utils.cc.

◆ get_rpm_arch()

bool get_rpm_arch ( const string &  str,
string &  arch 
)

Get the architecture string from the NVR of an rpm.

Parameters
strthe NVR to consider.
archoutput parameter. Is set to the resulting archirecture string iff the function returns true.
Returns
true iff the function could find the architecture string from the NVR.

Definition at line 1780 of file abg-tools-utils.cc.

◆ get_rpm_name()

bool get_rpm_name ( const string &  str,
string &  name 
)

Get the package name of an rpm package.

Parameters
strthe string containing the NVR of the rpm.
nameoutput parameter. This is set with the package name of the rpm package iff the function returns true.
Returns
true iff the function successfully finds the rpm package name.

Definition at line 1746 of file abg-tools-utils.cc.

◆ get_system_libdir()

const char * get_system_libdir ( )

Get the value of $libdir variable of the autotools build system. This is where shared libraries are usually installed.

Returns
a constant string (doesn't have to be free-ed by the caller) that represent the value of the $libdir variable in the autotools build system, or NULL if it's not set.

Definition at line 101 of file abg-tools-utils.cc.

◆ get_vmlinux_path_from_kernel_dist()

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.

Parameters
fromthe directory under which to look for.
vmlinux_pathoutput parameter. The path of the vmlinux binary that was found.
Returns
true if the path to the vmlinux binary was found.

Definition at line 2902 of file abg-tools-utils.cc.

◆ guess_file_type() [1/2]

file_type guess_file_type ( const string &  file_path)

Guess the type of the content of an file.

Parameters
file_paththe path to the file to consider.
Returns
the type of content guessed.

Definition at line 1678 of file abg-tools-utils.cc.

◆ guess_file_type() [2/2]

file_type guess_file_type ( istream &  in)

Guess the type of the content of an input stream.

Parameters
inthe input stream to guess the content type for.
Returns
the type of content guessed.

Definition at line 1567 of file abg-tools-utils.cc.

◆ initialize()

void initialize ( )

This function needs to be called before any libabigail function.

Users of libabigail must call it prior to using any of the functions of the library.

It intends to initialize the underlying libraries that might need initialization, especially, libxml2, in multi-threaded environments.

Definition at line 88 of file abg-tools-utils.cc.

◆ is_dir()

bool is_dir ( const string &  path)

Tests if a given path is a directory or a symbolic link to a directory.

Parameters
paththe path to test for.
Returns
true iff path is a directory.

Definition at line 560 of file abg-tools-utils.cc.

◆ is_regular_file()

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.

Parameters
paththe path to consider.
Returns
true iff path is a regular path.

Definition at line 409 of file abg-tools-utils.cc.

◆ load_default_system_suppressions()

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.

The default system suppression file is located at $libdir/libabigail/default-libabigail.abignore.

Parameters
supprsthe vector to add the suppression specifications read from the file to.

Definition at line 2325 of file abg-tools-utils.cc.

◆ load_default_user_suppressions()

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.

The default user suppression file is located at $HOME~/.abignore.

Parameters
supprsthe vector to add the suppression specifications read from the file to.

Definition at line 2341 of file abg-tools-utils.cc.

◆ make_path_absolute()

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.

The result being an shared_ptr to char*, it should manage its memory by itself and the user shouldn't need to wory too much for that.

Parameters
pthe path to turn into an absolute path.
Returns
a shared pointer to the resulting absolute path.

Definition at line 1937 of file abg-tools-utils.cc.

◆ make_path_absolute_to_be_freed()

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.

The result being a pointer to an allocated memory region, it must be freed by the caller.

Parameters
pthe path to turn into an absolute path.
Returns
a pointer to the resulting absolute path. It must be freed by the caller.

Definition at line 1968 of file abg-tools-utils.cc.

◆ maybe_get_symlink_target_file_path()

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.

Parameters
file_paththe path to the file to consider.
target_paththis parameter is set by the function to the canonicalized path to the target file, if file_path is a symbolic link. In that case, the function returns true.
Returns
true iff file_path is a symbolic link. In that case, the function sets target_path to the canonicalized absolute path of the target file.

Definition at line 718 of file abg-tools-utils.cc.

◆ operator&()

abidiff_status operator& ( abidiff_status  l,
abidiff_status  r 
)

The bitwise 'AND' operator for abidiff_status bit masks.

Parameters
lthe left hand side operand of the AND operator.
rthe right hand side operand of the AND operator.
Returns
the result of the AND expression.

Definition at line 131 of file abg-tools-utils.cc.

◆ operator<<()

ostream & operator<< ( ostream &  o,
const timer t 
)

Streaming operator for the timer type.

Emit a string representing the elapsed time (in a human-readable manner) to an output stream.

Parameters
othe output stream to emit the elapsed time string to.
tthe timer to consider.
Returns
the output stream considered.

Definition at line 336 of file abg-tools-utils.cc.

◆ operator|()

abidiff_status operator| ( abidiff_status  l,
abidiff_status  r 
)

The bitwise 'OR' operator for abidiff_status bit masks.

Parameters
lthe left hand side operand of the OR operator.
rthe right hand side operand of the OR operator.
Returns
the result of the OR expression.

Definition at line 119 of file abg-tools-utils.cc.

◆ operator|=()

abidiff_status & operator|= ( abidiff_status l,
abidiff_status  r 
)

The |= operator.

Parameters
lthe left hand side operand of the operator.
rthe right hand side operand of the operator.
theresulting bit mask.

Definition at line 143 of file abg-tools-utils.cc.

◆ real_path()

void real_path ( const string &  path,
string &  result 
)

Return the real path of a given path.

The real path of path 'foo_path' is the same path as foo_path, but with symlinks and relative paths resolved.

Parameters
paththe path to consider.
resultthe computed real_path;

Definition at line 803 of file abg-tools-utils.cc.

◆ rpm_contains_file()

bool rpm_contains_file ( const string &  rpm_path,
const string &  file_name 
)

Test if an RPM package contains a given file.

Parameters
rpm_paththe path to the RPM package.
file_namethe file name to test the presence for in the rpm.
Returns
true iff the file named @file_name is present in the RPM.

Definition at line 1863 of file abg-tools-utils.cc.

◆ sorted_strings_common_prefix()

bool sorted_strings_common_prefix ( vector< string > &  input_strings,
string &  prefix 
)

Find the prefix common to a *SORTED* vector of strings.

Parameters
input_stringsa lexycographically sorted vector of strings. Please note that this vector absolutely needs to be sorted for the function to work correctly. Otherwise the results are going to be wrong.
prefixoutput parameter. This is set by this function with the prefix common to the strings found in input_strings, iff the function returns true.
Returns
true iff the function could find a common prefix to the strings in input_strings.

Definition at line 1149 of file abg-tools-utils.cc.

◆ split_string()

bool split_string ( const string &  input_string,
const string &  delims,
vector< string > &  result 
)

Split a given string into substrings, given some delimiters.

Parameters
input_stringthe input string to split.
delimsa string containing the delimiters to consider.
resulta vector of strings containing the splitted result.
Returns
true iff the function found delimiters in the input string and did split it as a result. Note that if no delimiter was found in the input string, then the input string is added at the end of the output vector of strings.

Definition at line 1040 of file abg-tools-utils.cc.

◆ stick_corpus_and_binaries_into_corpus_group()

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.

Parameters
readerthe reader to use to read the binaries.
korpusthe ABI corpus to add to the corpus group.
binariesthe set of binaries to add to the corpus group, if they are present one of the directories denoted by the vector deps_dirs.
bins_dirsthe directories where the binaries listed in binaries are to be found.
Returns
a corpus group made of korpus and the binaries listed in binaries and found in at least one of the directories found in bins_dirs.

Definition at line 2599 of file abg-tools-utils.cc.

◆ stick_corpus_and_dependencies_into_corpus_group()

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.

Parameters
readerthe reader to use to read the binaries.
korpusthe ABI corpus to add to the corpus group along with its dependencies that can be found in a subset of directories.
deps_dirsthe directories where the dependencies of the ABI corpus denoted by korpus binaries are to be found.
Returns
a corpus group made of korpus and the subset of its dependencies found in at least one of the directories denoted by deps_dirs.

Definition at line 2628 of file abg-tools-utils.cc.

◆ string_begins_with()

bool string_begins_with ( const string &  str,
const string &  prefix 
)

Test if a given string begins with a particular prefix.

Parameters
strthe string consider.
prefixthe prefix to look for.
Returns
true iff string str begins with prefix prefix.

Definition at line 966 of file abg-tools-utils.cc.

◆ string_ends_with()

bool string_ends_with ( const string &  str,
const string &  suffix 
)

Test if a given string ends with a particular suffix.

Parameters
strthe string to consider.
suffixthe suffix to test for.
Returns
true iff string str ends with suffix suffix.

Definition at line 949 of file abg-tools-utils.cc.

◆ string_is_ascii()

bool string_is_ascii ( const string &  str)

Test if a string is made of ascii characters.

Parameters
strthe string to consider.
Returns
true iff str is made of ascii characters.

Definition at line 987 of file abg-tools-utils.cc.

◆ string_is_ascii_identifier()

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.

In the C++ spec, [lex.charset]/2, we can read:

"if the hexadecimal value for a universal-character-name [...] or string literal corresponds to a control character (in either of the ranges 0x00-0x1F or 0x7F-0x9F, both inclusive) [...] the program is ill-formed."

Parameters
strthe string to consider.
Returns
true iff str is made of ascii characters, and is an identifier.

Definition at line 1012 of file abg-tools-utils.cc.

◆ string_suffix()

bool string_suffix ( const string &  input_string,
const string &  prefix,
string &  suffix 
)

Get the suffix of a string, given a prefix to consider.

Parameters
input_stringthe input string to consider.
prefixthe prefix of the input string to consider.
suffixoutput parameter. This is set by the function to the the computed suffix iff a suffix was found for prefix prefix.
Returns
true iff the function could find a prefix for the suffix suffix in the input string input_string.

Definition at line 1090 of file abg-tools-utils.cc.

◆ trim_leading_string()

string trim_leading_string ( const string &  from,
const string &  to_trim 
)

Remove a string of pattern in front of a given string.

For instance, consider this string: "../../../foo"

The pattern "../" is repeated three times in front of the sub-string "foo". Thus, the call: trim_leading_string("../../../foo", "../") will return the string "foo".

Parameters
fromthe string to trim the leading repetition of pattern from.
to_trimthe pattern to consider (and to trim).
Returns
the resulting string where the leading patter to_trim has been removed from.

Definition at line 1367 of file abg-tools-utils.cc.

◆ trim_white_space()

string trim_white_space ( const string &  str)

Remove spaces at the beginning and at the end of a given string.

Parameters
strthe input string to consider.
Returns
the str string with leading and trailing white spaces removed.

Definition at line 1331 of file abg-tools-utils.cc.