libabigail
|
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_file > | temp_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_status & | operator|= (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... | |
Namespace for a set of utility function used by tools based on libabigail.
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.
enum 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.
Definition at line 243 of file abg-tools-utils.h.
enum file_type |
The different types of files understood the bi* suite of tools.
Definition at line 209 of file abg-tools-utils.h.
bool abidiff_status_has_abi_change | ( | abidiff_status | s | ) |
Test if an instance of.
abidiff_status | bits mask represents an abi change. |
This functions tests if the ABIDIFF_ABI_CHANGE bit is set in the given bits mask.
s | the bit mask to consider. |
s
has its ABIDIFF_ABI_CHANGE bit set. Definition at line 173 of file abg-tools-utils.cc.
bool abidiff_status_has_error | ( | abidiff_status | s | ) |
Test if an instance of.
abidiff_status | bits mask represents an error. |
This functions tests if the ABIDIFF_ERROR bit is set in the given bits mask.
s | the bit mask to consider. |
s
has its ABIDIFF_ERROR bit set. Definition at line 160 of file abg-tools-utils.cc.
bool abidiff_status_has_incompatible_abi_change | ( | abidiff_status | s | ) |
Test if an instance of.
abidiff_status | bits 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.
s | the bit mask to consider. |
s
has its ABIDIFF_INCOMPATIBLE ABI_CHANGE set. Definition at line 188 of file abg-tools-utils.cc.
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.
reader | the reader used to read the binaries into an ABI corpus. |
binaries | the vector of binaries to read and add to a corpus group. |
deps_dirs | the vector of directories where to look for the binaries in binaries . |
group | the corpus group to add the corpus. |
Definition at line 2515 of file abg-tools-utils.cc.
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.
reader | the reader used to read the binaries into an ABI corpus. |
korpus | the corpus to consider. |
deps_dirs | the vector of directories where to look for the dependencies of korpus . |
group | the corpus group to add the corpus. |
Definition at line 2555 of file abg-tools-utils.cc.
bool base_name | ( | string const & | path, |
string & | file_name | ||
) |
Return the file name part of a file part.
path | the file path to consider. |
file_name | the name part of the file to consider. |
Definition at line 778 of file abg-tools-utils.cc.
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.
root | the 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_root | the directory under which debug info is to be found for binaries under director root . |
vmlinux_path | the 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_paths | the paths to the suppression specifications to apply while loading the binaries. |
kabi_wl_path | the paths to the kabi whitelist files to take into account while loading the binaries. |
supprs | the suppressions resulting from parsing the suppression specifications at suppr_paths . This is set by this function. |
verbose | true if the function has to emit some verbose messages. |
env | the environment to create the corpus_group in. |
requested_fe_kind | the kind of front-end requested by the user. |
Definition at line 3106 of file abg-tools-utils.cc.
bool check_dir | ( | const string & | path, |
ostream & | out, | ||
const string & | prog_name | ||
) |
Check if a given path exists, is readable and is a directory.
path | the path to consider. |
out | the out stream to report errors to. |
prog_name | the program name on behalf of which to report the error, if any. |
path
exists and is for a directory. Definition at line 924 of file abg-tools-utils.cc.
bool check_file | ( | const string & | path, |
ostream & | out, | ||
const string & | prog_name | ||
) |
Check if a given path exists and is readable.
path | the path to consider. |
out | the out stream to report errors to. |
Definition at line 896 of file abg-tools-utils.cc.
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**>.
char_stars | the input vector. |
char_star_stars | the output vector. |
Definition at line 1382 of file abg-tools-utils.cc.
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.
elf_file_path | a path to the ELF file to consider |
debug_info_root_paths | a vector of the paths where to look for debug info, if applicable. |
env | the environment to use for the front-end. |
requested_fe_kind | the 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_types | option to be passed to elf based readers. |
linux_kernel_mode | option to bed passed to elf based readers, |
elf_file_path
. Definition at line 3208 of file abg-tools-utils.cc.
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.
l | the name of the first (left hand side) decl to consider. |
r | the name of the second (right hand side) decl to consider. |
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.
bool abigail::tools_utils::dir_contains_ctf_archive | ( | const string & | directory, |
const string & | archive_prefix | ||
) |
Test if a directory contains a CTF archive.
directory | the directory to consider. |
archive_prefix | the prefix of the archive file. |
directory
contains a CTF archive file. Definition at line 434 of file abg-tools-utils.cc.
bool dir_exists | ( | const string & | path | ) |
Test that a given directory exists.
path | the path of the directory to consider. |
path
Definition at line 376 of file abg-tools-utils.cc.
bool dir_is_empty | ( | const string & | path | ) |
Test if a given directory exists and is empty.
path | the path of the directory to consider |
Definition at line 383 of file abg-tools-utils.cc.
bool dir_name | ( | string const & | path, |
string & | dir_name, | ||
bool | keep_separator_at_end | ||
) |
Return the directory part of a file path.
path | the file path to consider |
dirnam | the 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_end | if true, then keep the separator at the end of the resulting dir name. |
Definition at line 749 of file abg-tools-utils.cc.
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> : "
prog_name | the name of the program to use in the prefix. |
out | the output stream where to emit the prefix. |
Definition at line 881 of file abg-tools-utils.cc.
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.
Definition at line 825 of file abg-tools-utils.cc.
bool ensure_parent_dir_created | ( | const string & | path | ) |
Ensures that the parent directory of #path is created.
Definition at line 855 of file abg-tools-utils.cc.
bool execute_command_and_get_output | ( | const string & | cmd, |
vector< string > & | lines | ||
) |
Execute a shell command and returns its output.
cmd | the shell command to execute. |
lines | output parameter. This is set with the lines that constitute the output of the process that executed the command cmd . |
Definition at line 1227 of file abg-tools-utils.cc.
bool file_exists | ( | const string & | path | ) |
Tests whether a path exists;.
path | the path to test for. |
path
exist. Definition at line 363 of file abg-tools-utils.cc.
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.
elf_file_path | the path to the ELF file to consider. |
debug_info_root | a 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. |
Definition at line 538 of file abg-tools-utils.cc.
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".
elf_file_path | the path to the ELF file to consider. |
debug_info_root | a 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. |
Definition at line 494 of file abg-tools-utils.cc.
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.
elf_file_path | the path to the ELF file to consider. |
debug_info_root | a 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. |
Definition at line 458 of file abg-tools-utils.cc.
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.
file_name | the file name to consider. |
file_type | the type of the file file_name . |
file_name
of kind file_type
designates a kernel debuginfo package. Definition at line 1893 of file abg-tools-utils.cc.
bool file_is_kernel_package | ( | const string & | file_path, |
file_type | file_type | ||
) |
Tests if a given file name designates a kernel package.
file_path | the path to the file to consider. |
file_type | the type of the file file_name . |
file_name
of kind file_type
designates a kernel package. Definition at line 1833 of file abg-tools-utils.cc.
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.
root_dir | the root directory under which to look for. |
file_path_to_look_for | the file to look for under the directory root_dir . |
result | the 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.
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.
root_dirs | the vector of root directories under which to look for. |
file_path_to_look_for | the file to look for under the directory root_dir . |
result | the 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.
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.
headers_root_dir | ABI changes in types defined in files *NOT* found in this directory tree are going be suppressed. |
headers_root_dir
. Definition at line 2154 of file abg-tools-utils.cc.
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.
headers_root_dir | ABI changes in types defined in files *NOT* found in this directory tree are going be suppressed. |
header_files | a set of additional header files that define types that are to be kept (not supressed) by the returned type suppression. |
headers_root_dir
. Definition at line 2132 of file abg-tools-utils.cc.
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.
headers_root_dirs | ABI changes in types defined in files *NOT* found in these directory trees are going be suppressed. |
header_files | a set of additional header files that define types that are to be kept (not supressed) by the returned type suppression. |
headers_root_dir
. Definition at line 2100 of file abg-tools-utils.cc.
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.
abi_whitelist_paths | a vector of KMI whitelist paths |
Definition at line 2187 of file abg-tools-utils.cc.
string get_abixml_version_string | ( | ) |
Return the version string for the ABIXML format.
Definition at line 1208 of file abg-tools-utils.cc.
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.
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.
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.
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.
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.
dist_root | the directory under which to look for. |
debug_info_root_path | the path to the directory under which debug info is going to be found for binaries under dist_root . |
vmlinux_path | output parameter. The path of the vmlinux binary that was found. |
module_paths | output parameter. The paths of the kernel module binaries that were found, sorted to impose a deterministic ordering. |
Definition at line 2842 of file abg-tools-utils.cc.
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.
dist_root | the directory under which to look for. |
vmlinux_path | output parameter. The path of the vmlinux binary that was found. |
module_paths | output parameter. The paths of the kernel module binaries that were found. |
Definition at line 2938 of file abg-tools-utils.cc.
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.
input_str | the input string containing the comma-separated list of arguments The input string has the form "option=arg1,arg2,arg3,arg4". |
option | if the content of the input string input_str is "option=arg1,arg2,arg3", then this parameter should be "option". |
arguments | this 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.
bool get_deb_name | ( | const string & | str, |
string & | name | ||
) |
Get the package name of a .deb package.
str | the string containing the .deb NVR. |
name | output parameter. This is set with the package name of the .deb package iff the function returns true. |
Definition at line 1716 of file abg-tools-utils.cc.
string get_default_system_suppression_file_path | ( | ) |
Get the path to the default system suppression file.
Definition at line 2276 of file abg-tools-utils.cc.
string get_default_user_suppression_file_path | ( | ) |
Get the path to the default user suppression file.
Definition at line 2295 of file abg-tools-utils.cc.
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.
korpus | the ABI corpus to consider. |
deps_dirs | the list of directories where to look for the dependencies. |
dependencies | output 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. |
korpus
were found in directories deps_dirs
. Definition at line 2478 of file abg-tools-utils.cc.
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.
rpm_path | the path to the RPM to consider. |
provided_dsos | output parameter. This is set to the set of SONAMEs of the DSOs advertised as being provided by the RPM designated by rpm_path . |
Definition at line 1302 of file abg-tools-utils.cc.
string get_library_version_string | ( | ) |
Return the version string of the library.
Definition at line 1196 of file abg-tools-utils.cc.
size_t get_random_number | ( | ) |
Get a pseudo random number.
Definition at line 1489 of file abg-tools-utils.cc.
string get_random_number_as_string | ( | ) |
Get a pseudo random number as string.
Definition at line 1506 of file abg-tools-utils.cc.
bool get_rpm_arch | ( | const string & | str, |
string & | arch | ||
) |
Get the architecture string from the NVR of an rpm.
str | the NVR to consider. |
arch | output parameter. Is set to the resulting archirecture string iff the function returns true. |
Definition at line 1780 of file abg-tools-utils.cc.
bool get_rpm_name | ( | const string & | str, |
string & | name | ||
) |
Get the package name of an rpm package.
str | the string containing the NVR of the rpm. |
name | output parameter. This is set with the package name of the rpm package iff the function returns true. |
Definition at line 1746 of file abg-tools-utils.cc.
const char * get_system_libdir | ( | ) |
Get the value of $libdir variable of the autotools build system. This is where shared libraries are usually installed.
Definition at line 101 of file abg-tools-utils.cc.
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.
from | the directory under which to look for. |
vmlinux_path | output parameter. The path of the vmlinux binary that was found. |
Definition at line 2902 of file abg-tools-utils.cc.
file_type guess_file_type | ( | const string & | file_path | ) |
Guess the type of the content of an file.
file_path | the path to the file to consider. |
Definition at line 1678 of file abg-tools-utils.cc.
file_type guess_file_type | ( | istream & | in | ) |
Guess the type of the content of an input stream.
in | the input stream to guess the content type for. |
Definition at line 1567 of file abg-tools-utils.cc.
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.
bool is_dir | ( | const string & | path | ) |
Tests if a given path is a directory or a symbolic link to a directory.
path | the path to test for. |
path
is a directory. Definition at line 560 of file abg-tools-utils.cc.
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.
path | the path to consider. |
Definition at line 409 of file abg-tools-utils.cc.
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.
supprs | the vector to add the suppression specifications read from the file to. |
Definition at line 2325 of file abg-tools-utils.cc.
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.
supprs | the vector to add the suppression specifications read from the file to. |
Definition at line 2341 of file abg-tools-utils.cc.
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.
p | the path to turn into an absolute path. |
Definition at line 1937 of file abg-tools-utils.cc.
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.
p | the path to turn into an absolute path. |
Definition at line 1968 of file abg-tools-utils.cc.
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.
file_path | the path to the file to consider. |
target_path | this 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. |
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.
abidiff_status operator& | ( | abidiff_status | l, |
abidiff_status | r | ||
) |
The bitwise 'AND' operator for abidiff_status bit masks.
l | the left hand side operand of the AND operator. |
r | the right hand side operand of the AND operator. |
Definition at line 131 of file abg-tools-utils.cc.
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.
o | the output stream to emit the elapsed time string to. |
t | the timer to consider. |
Definition at line 336 of file abg-tools-utils.cc.
abidiff_status operator| | ( | abidiff_status | l, |
abidiff_status | r | ||
) |
The bitwise 'OR' operator for abidiff_status bit masks.
l | the left hand side operand of the OR operator. |
r | the right hand side operand of the OR operator. |
Definition at line 119 of file abg-tools-utils.cc.
abidiff_status & operator|= | ( | abidiff_status & | l, |
abidiff_status | r | ||
) |
The |= operator.
l | the left hand side operand of the operator. |
r | the right hand side operand of the operator. |
the | resulting bit mask. |
Definition at line 143 of file abg-tools-utils.cc.
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.
path | the path to consider. |
result | the computed real_path; |
Definition at line 803 of file abg-tools-utils.cc.
bool rpm_contains_file | ( | const string & | rpm_path, |
const string & | file_name | ||
) |
Test if an RPM package contains a given file.
rpm_path | the path to the RPM package. |
file_name | the file name to test the presence for in the rpm. |
Definition at line 1863 of file abg-tools-utils.cc.
bool sorted_strings_common_prefix | ( | vector< string > & | input_strings, |
string & | prefix | ||
) |
Find the prefix common to a *SORTED* vector of strings.
input_strings | a 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. |
prefix | output parameter. This is set by this function with the prefix common to the strings found in input_strings , iff the function returns true. |
input_strings
. Definition at line 1149 of file abg-tools-utils.cc.
bool split_string | ( | const string & | input_string, |
const string & | delims, | ||
vector< string > & | result | ||
) |
Split a given string into substrings, given some delimiters.
input_string | the input string to split. |
delims | a string containing the delimiters to consider. |
result | a vector of strings containing the splitted result. |
Definition at line 1040 of file abg-tools-utils.cc.
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.
reader | the reader to use to read the binaries. |
korpus | the ABI corpus to add to the corpus group. |
binaries | the set of binaries to add to the corpus group, if they are present one of the directories denoted by the vector deps_dirs . |
bins_dirs | the directories where the binaries listed in binaries are to be found. |
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.
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.
reader | the reader to use to read the binaries. |
korpus | the ABI corpus to add to the corpus group along with its dependencies that can be found in a subset of directories. |
deps_dirs | the directories where the dependencies of the ABI corpus denoted by korpus binaries are to be found. |
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.
bool string_begins_with | ( | const string & | str, |
const string & | prefix | ||
) |
Test if a given string begins with a particular prefix.
str | the string consider. |
prefix | the prefix to look for. |
str
begins with prefix prefix
. Definition at line 966 of file abg-tools-utils.cc.
bool string_ends_with | ( | const string & | str, |
const string & | suffix | ||
) |
Test if a given string ends with a particular suffix.
str | the string to consider. |
suffix | the suffix to test for. |
str
ends with suffix suffix
. Definition at line 949 of file abg-tools-utils.cc.
bool string_is_ascii | ( | const string & | str | ) |
Test if a string is made of ascii characters.
str | the string to consider. |
str
is made of ascii characters. Definition at line 987 of file abg-tools-utils.cc.
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."
str | the string to consider. |
str
is made of ascii characters, and is an identifier. Definition at line 1012 of file abg-tools-utils.cc.
bool string_suffix | ( | const string & | input_string, |
const string & | prefix, | ||
string & | suffix | ||
) |
Get the suffix of a string, given a prefix to consider.
input_string | the input string to consider. |
prefix | the prefix of the input string to consider. |
suffix | output parameter. This is set by the function to the the computed suffix iff a suffix was found for prefix prefix . |
suffix
in the input string input_string
. Definition at line 1090 of file abg-tools-utils.cc.
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".
from | the string to trim the leading repetition of pattern from. |
to_trim | the pattern to consider (and to trim). |
to_trim
has been removed from. Definition at line 1367 of file abg-tools-utils.cc.
string trim_white_space | ( | const string & | str | ) |
Remove spaces at the beginning and at the end of a given string.
str | the input string to consider. |
str
string with leading and trailing white spaces removed. Definition at line 1331 of file abg-tools-utils.cc.