We were using the unsafe tmpnam function in abilint. This patch
creates a helper type abigail::tools_utils::temp_file that does away
with the use tmpnam in abilint.
* include/abg-tools-utils.h (abigail::tools_utils::temp_file):
Declare new type.
(abigail::tools_utils::temp_file_sptr): New typedef.
* src/abg-tools-utils.cc (temp_file::priv): Define new type.
(temp_file::{temp_file, is_good, get_path, get_stream, create}):
Define new member functions.
* tools/abilint.cc (main): Do not use tmpnam anymore. Use the new
abigail::tools_utils::temp_file type instead.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
abipkgdiff extracts the content of the first package in a directory
named <tmpdir>/package1 and the content second package in
<tmpdir>/package2. If two independant instances of abipkgdiff are
launched at the same time, they are going to walk on each others'
toes, to say the least.
This patch extracts the content of each package in directory named
<tmpdir>/<randomname>/package1, where randomname is supposed to be a
random number, and so should be unique, most of the time.
I guess we should try harder to generate a randomname that is unique
when we see that the directory <tmpdir>/<randomname> exists already,
but for now, what we have is good enough, or at least better than what
we have had so far.
* include/abg-tools-utils.h (get_random_number)
(get_random_number_as_string): Declare new functions.
* src/abg-tools-utils.cc (get_random_number)
(get_random_number_as_string): Define them.
* tools/abipkgdiff.cc
(package::extracted_package_parent_dir_path): New data member.
(package::package): Initialize
package::extracted_package_parent_dir_path to
<tmpdir>/<randomname>, with randomname being a random number
represented as a string.
(extract_rpm): Make sure to create a hierarchy of directories, not
just a directory.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tools/abipkgdiff.cc (options::suppressions): New data member.
(set_diff_context_from_opts): Set the suppression specifications
provided by the user to the diff context.
(parse_command_line): Parse the --suppressions and --suppr command
line options.
* doc/manuals/abipkgdiff.rst: Document the --suppressions and
--suppr options.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When a binary cannot be analyzed by abipkgdiff, silently skip it
unless --verbose is used, in which case, display a message saying
that it couldn't be analyzed.
* tools/abipkgdiff.cc (compare): In the elf_file overload, do not
emit an error message when a binary could not be analyzed unless
--verbose was provided.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tools/abipkgdiff.cc (compare): In the overload for packages,
indent the content of the "Removed binaries" and "Added binaries"
paragraphs.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Just like what abidiff does, this patch avoids emitting redundant diff
report messages unless the user provides the --redundant switch.
* tools/abipkgdiff.cc (options::show_redundant_changes): New data
member.
(options::options): Initialize it.
(display_usage): Add a help string for the --redundant command
Line option.
(set_diff_context_from_opts): New static function.
(compare): Take the options variable. Set the diff context from
the options, especially if we should show redundant changes or
not. Use that diff context when comparing ABIs.
(parse_command_line): Parse the new --redundant command line
switch.
* doc/manuals/abipkgdiff.rst: Document the new --redundant option.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
It turned out on some packages we are interested on comparing shared
libraries only. This patch adds that functionality by adding a new
--dso-only command line option to abipkgdiff.
* tools/abipkgdiff.cc (options::compare_dso_only): New data
member.
(options::options): Initialize it.
(display_usage): Display a little help string for it.
(create_maps_of_package_content): Take the option variable. Do
not compare non-dso files if the --dso-only option was provided.
(extract_package_and_map_its_content, prepare_packages, compare):
Take the option variable.
(parse_command_line): Parse the new --dso-only option.
* doc/manuals/abipkgdiff.rst: Add documentation for the new
--dso-only option.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (get_soname_of_elf_file): Better wording
of the apidoc of this function.
* tools/abipkgdiff.cc (verbose, elf_file_paths): Add apidoc for
these global variables.
(struct options, ): Add apidoc for these types.
(options::{erase_extraction_directory,
erase_extraction_directories}, display_usage, extract_rpm)
(erase_created_temporary_directories, extract_package)
(file_tree_walker_callback_fn, compare)
(create_maps_of_package_content)
(extract_package_and_map_its_content, prepare_packages, compare)
(parse_command_line): Add apidoc for these functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (get_soname_of_elf_file): Better wording
of the apidoc of this function.
* tools/abipkgdiff.cc (verbose, elf_file_paths): Add apidoc for
these global variables.
(struct options, ): Add apidoc for these types.
(options::{erase_extraction_directory,
erase_extraction_directories}, display_usage, extract_rpm)
(erase_created_temporary_directories, extract_package)
(file_tree_walker_callback_fn, compare)
(create_maps_of_package_content)
(extract_package_and_map_its_content, prepare_packages, compare)
(parse_command_line): Add apidoc for these functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* abipkgdiff.cc (get_soname_of_elf_file): Fix spacing.
* tools/abipkgdiff.cc (elf_file_paths): Make this global variable
static.
(extract_rpm): Rename parameter pkg_path name into package_path.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Directly using elfutils from abipkgdiff.cc feels like a taping into
the wrong abstraction layer from this level. So this patch moves the
determination of the type of elf file into abg-dwarf-reader.cc and
uses it from there. The patch also simplifies the instantiation of
types elf_file and package, from abipkgdiff.cc.
* abg-dwarf-reader.h (enum elf_type): Move this declaration here
from abipkgdiff.cc to here.
(get_type_of_elf_file): Declare this new function.
(get_soname_from_elf): Change this to take a path to the elf file
rather than a Elf* handler. So now to use this, the user doesn't
have to get her hand dirty with elfutils.
* src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to
take a path to the elf file rather than a Elf* handler.
(elf_file_type): Move this static function here, from
abipkgdiff.cc.
(get_type_of_elf_file): New function. This has been factorized
out of create_maps_of_package_content() in abipkgdiff.cc.
* tools/abipkgdiff.cc (class elf_file): Changed struct elf_file
into this. Make the default constructor private.
(elf_file::elf_file): Change the constructor to just take the path
to the elf_file. The base name, soname and elf file type are now
computed from the path file, in the constructor. This makes
instantiation much much easier from the point of view of the user
of the type.
(struct abi_diff): Renamed struct abi_changes into this.
(abi_diff::has_changes): Define new member function.
(abi_diffs): Remove this global variable.
(package::package): Remove the elf file type from the set of
parameters of this constructor. Rather, compute that elf file
type from the path to the elf file, in the constructor. Again,
this eases the use of the type.
(elf_file_type): Remove this from here, as it got moved to
abg-dwarf-reader.cc.
(compare): In the elf_file overload, return true if the comparison
yields ABI changes.
(create_maps_of_package_content): Do not fiddle with elfutils
stuff here. Rather, just instantiate elf_file and the analyzing
of the file magically happens.
(compare): Make the package overload take an abi_diff as output
parameter, rather than populating a global variable in return.
(compare): Add an other overload for package that doesn't take the
abi_diff as output parameter and write it in terms of the previous
one.
(main): Adjust as the instantiation of package is now simpler.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
It turned out it's important to be able to see what abipkgdiff is
actually doing. This patch adds a --verbose option that emits many
useful information about the tool's progress.
* tools/abipkgdiff.cc (verbose): Add a new global variable.
(package::erase_extraction_directory, extract_rpm, compare)
(create_maps_of_package_content): Emit verbose information.
(parse_command_line): Parse the --verbose option.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Until now, abipkgdiff was spawning a process running the 'abidiff'
command line tool to perform ABI comparison on binaries. This helped
in sketching what was possible with this tool. However, it's
sub-optimal in a final setup so this patch uses the libabigail library
to perform that comparison.
* tools/abipkgdiff.cc (compare): In the overload for elf_file, use
abigail::comparison::compute_diff() to compare the ABI of two
corpora. The corpora themselves is read using
abigail::dwarf_reader::read_corpus_from_elf(). This cleans up the
output of the tool because nothing is emitted to standard output
if the two ABI corpora compares equal.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
A number of functions have string parameters passed by value. Ooops.
They must be passed by reference.
Fixed thus.
* tools/abipkgdiff.cc (elf_file::elf_file): Pass the strings by
reference. Also, change the order of the parameters; all the
strings are passed first, then the elf_type is passed last.
(package::package): Likewise, pass the strings by reference, not
by value.
(create_maps_of_package_content): Adjust for the change in
parameters order of elf_file::elf_file.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tools/abipkgdiff.cc (compare): In the overload for packages,
only compare binaries that are DSO or executable.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Initially, fetching SONAME from a given DSO file was done in
abipkgdiff.cc. But, this function fits better when defined in
abg-dwarf-reader.cc in order to make it usable by other tools if
needed. For consistancy, get_soname() function has been renamed to
get_soname_from_elf().
* include/abg-dwarf-reader.h (get_soname_from_elf): Declare
new function
* src/abg-dwarf-reader.cc (get_soname_from_elf): Define new
function
* tools/abipkgdiff.cc (get_soname): Remove function
(pkg_diff): Call get_soname_from_elf() instead of get_soname()
Signed-off-by: Sinny Kumari <sinny@redhat.com>
This patch introduces many changes that should hopefully improve
legibility and ease of maintenance. Here is a list of the topic of
the changes:
* Avoid using shortened names when the line is not too long.
* Use shared_ptr when possible.
* When a function parameter is not meant to be nil, do not pass it
as a pointer; rather, pass it as a reference.
* Avoid doing things that can "fail" in a destructor; e.g, spawning
a process. Also, it's not common practise to cleanup a resource in a
type destructor, when that resource has not been created in one of the
member functions of the type. It eases maintenance when resource
creation and cleanup is performed at the same logical level.
* tools/abipkgdiff.cc (option::package{1,2}): Rename
option::pkg{1,2} into this, to increase legibility.
(option::debug_package{1,2}): Likewise, rename
option::debug_pkg{1,2} into this.
(elf_file::~elf_file): Do not "delete this" in a destructor. This
leads to double free. It's when someone invokes the "delete"
operator on a pointer to the object that the destructor of the
object is executed automatically; so if in the destructor the
delete operator is called again, bad things are going to happen.
As the destructor is now empty, remove it altogether.
(elf_file_sptr): New typedef for shared_ptr<elf_file>.
(package::path): Rename package::pkg_path into this, for better
legibility.
(package::extracted_package_dir_path): Rename
package::extracted_pkg_dir_path into this.
(package::type): Rename package::pkg_type into this.
(package::is_debug_info): Rename package::is_debuginfo_pkg into
this.
(package::path_elf_file_sptr_map): Rename
package::dir_elf_files_map into this because this is a map of
path -> elf_file_sptr. Also, now the value of the map element is
a elf_file_sptr, no more an elf_file*.
(package::debug_info_package): Rename package::debuginfo_pkg into
this.
(package::package): Adjust for the changes above.
(package::{erase_extraction_directory,
erase_extraction_directories}): New member functions.
(elf_file_paths): Renamed dir_elf_files_path into this.
(erase_created_temporary_directories)
(create_maps_of_package_content)
(extract_package_and_map_its_content, prepare_packages): New
static functions.
(get_soname, elf_file_type, extract_rpm): Make this static.
(extract_package): Take a const package& rather than a
package_sptr to express that the function really expects a non-nil
object by reference (not by copy) and that the object won't be
modified. Using a reference removes the possibility that the
pointer could be nil, causing crashes in the code where
parameter->something was used. Now only parameter.something can
be used, so no crash possible there. This is more solid code.
(file_tree_walker_callback_fn): Rename callback() into this. It
makes the code more legible and kind of 'self-documented'. At
least you get the hint that this is a callback function for some
file tree walking (ftw) function. Adjust for the relevant names
renaming above.
(compare): Rename compute_abidiff into this; again, this increases
legibility; at least at the point of use of this function. Rename
compare_package() into a an overload of compare() as well.
compare_package() used to take a vector of packages. It was hard
to guess by reading the signature of the function, which element
of the vector is expected to be the first vector of the
comparison, which one is to be the second, etc. Now, this
function takes two packages, named first_package and
second_package. That is more "typed"; that is, the signature is
more meaningful. Greater legibility, hopefully. And in the body
of the function, the debug information packages are now accessed
using the package::debug_info_package data member. Again, this is
less surprising, I believe. Also, explicitly erase the temporary
files that were created during this comparison. All this
simplifies the logic of this function, hopefully.
(parse_command_line): Make this static. Add new --d1 and --d2
command line switches that are shortcuts of --debug-info-pkg1 and
--debug-info-pkg2. Adjust this function for the relevant name
changes above. Make lines be shorter than 80 characters.
(main): Do not create any vector of parameters anymore as the
compare_packages() function don't take any vector of parameter
anymore. Just instantiate first_package and second_package now.
Adjust for the relevant name changes above. This hopefully
simplifies the logic of this function.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Through the libabigail project, we try to:
1/ make function names start with a verb
2/ avoid shortening function names, *unless* longer names make the
current line exceed 80 characters per line.
We believe these rules improve legibility for people reading the code.
This patch slightly changes abipkgdiff.cc file to comply with the
above.
* tools/abipkgdiff.cc (extract_package): Renamed extract_pkg into
this because shortening 'package' into 'pkg' provides no
legibility improvement.
(compare_packages): Renamed pkg_diff() into this, so that the name
of the function starts with a verb, and the shortened 'pkg' word
is renamed back to the 'package' word. This way, the code almost
reads like normal English sentences with verbs and complement,
thus enhancing legibility and easing latter maintenance.
(main): Adjust for the changes above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
While reading the source code, I realized parts of it where not yet
following the GNU-style indentation of the rest of the project files.
So I thought I'd do this early now, so that other changes happen on
top of the properly indented file.
Fixed thus.
* tools/abipkgdiff.cc: Re-indent the file properly and fix some
white spacing here and there.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tools/abipkgdiff.cc (display_usage): Fixed the typo in
'bi-pacakge.' Also, refer to 'package', not to 'bi-package' that
is surprising to the user at first.
(compute_abidiff): Shorten the size of the introductory line.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The compiler complains that in function callback(), parameters st and
flag are unused. In that case, C++ allows the name of the parameter
to be omitted; that makes the compiler complaint go away.
* tools/abipkgdiff.cc (callback): Remove the name of parameters st
and flag.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
In this declaration:
const bool
extract_rpm(const string& pkg_path, const string &extracted_pkg_dir_path)
the compiler rightfully complains that the const qualifier on the
return type is useless. This is because the value is returned by copy
so the const-ness is not relevant.
Fixed thus.
* tools/abipkgdiff.cc (extract_rpm): Remove useless const qualifier.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The compiler complains that there are some branches in the
get_soname() function that don't end up with a return statement. For
instance, there is no return statement right before the end of the
function, in case the outermost for loop is not taken.
This patch fixes that by having just one return statement at the end
of the function.
* tools/abipkgdiff.cc (get_soname): Have just one return statement
at the end of this function.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The compiler rightfully complains that data members should be
initialized in the other in which they are declared.
Fixed thus.
* tools/abipkgdiff.cc (elf_file::elf_file): Initialize data member
in the same order as they were declared.
(package::package): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Removed binaries can also lead to ABI breakage if an applicating was using
it previously. So, display it in ABI change report. Also, looking for
ABI change in symbolic link files doesn't make sense. Now, we are not
looking into ABI changes in symlink binaries.
* tools/abipkgdiff.cc (abi_changes): Declare new struct
(callback): Exclude symbloic link file for durther processing
(compute_abidiff): Consider SONAME if exists as key in map instead
of binary name, else binary as key. Also, print if removed/added
binaries exist between packages
Now, abipkgdiff can take two rpm packages and optional corresponding
debug-info pacakges. It look for same binary in both rpm directory and
if found calls abdiff along with debug-info options to get ABI changes
between them.
* tools/abipkgdiff.cc (compute_abidiff): New function
tools/abipkgdiff.cc (pkg_diff): Iterate through list of binaries
in both package directory and call compute_diff function if
same binary found in both file.
tools/abipkgdiff.cc (main): Also consider debug-info directories
avilable in debu-info packages.
Signed-off-by: Sinny Kumari <sinny@redhat.com>
An RPM package may conatins binaries, source/header files, config files,
etc. For abi check we are interested only in ELF binary files. This commit
stores binary files from extracted RPM in a map whose key is
binary file basename and value is struct elf_file with memeber variable
name, path, soname, type
* tools/abipkgdiff.cc (elf_type): Declare new enum
(elf_file): Declare new struct
(package): Add member variable dir_elf_files_map
(get_soname): Define new function
(elf_file_type): Define new function
(extract_rpm): Iterate over extracted directory files
and filter ELF binary files along with their information
like name, soname, elf_type and save in dir_elf_files_map
Input pacakges need to extracted for further processing which includes
fecthing all files in extracted rpms and look for ELF files aginst
which abi diff is required. Pacakges will be extracted in system tmp
directory.
* tools/abipkgdiff.cc (struct package): Declare new struct
(package_sptr): Declare shared_ptr for struct package
(extract_rpm): Define new fuction to extract rpm package
(extract_pkg): Define new function to extract pacakge
(pkg_diff): Define new function to get ABI diff between
two packages
(main): Create new object of type pacakge for each binary
and debuginfo pacakge passed in commandline options
Signed-off-by: Sinny Kumari <sinny@redhat.com>
To run abipkgdiff between two pacakges, it should know whether
input files are valid pacakge file or not. This patch detects RPM and SRPM
pacakge file type. abipkgdiff uses it to know whether input files are
valid RPM pacakge file or not.
* include/abg-tools-utils.h (file_type): Added member
FILE_TYPE_RPM and FILE_TYPE_SRPM
(operator<<): New function declaration.
* src/abg-tools-utils.cc (file_type): Detect RPM and
SRPM file type
(operator<<): New function definition
* tools/abidiff.cc (main): Check for RPM and SRPM
file type as well.
* tools/abilint.cci (main): Check for RPM and SRPM file
type as well.
* tools/abipkgdiff.cc (main): Check whether input files
to abipkgdiff are valid RPM files or not.
Signed-off-by: Sinny Kumari <sinny@redhat.com>
Motive of abipkgdiff tool is to provide abi changes between two
pacakges. Packages can be .rpm, .deb or archives. It also takes
optional debug-info package to support pacakges shipping separate
debug-info.
This commit set-up initial skeleton of abipkgdif tool consisting of
help and usage otions. It ensures pkgdiff tool compiles and run when
libabigail gets compiled as whole. Initially, we will add support for
ABI changes for two rpm packages. Further, support for other pacakging
format can be added.
* tools/Makefile.am: Include abipkgdiff.cc in compilation and
generate abipkgdiff binary.
* tools/abipkgdiff.cc: New file
Signed-off-by: Sinny Kumari <sinny@redhat.com>
While working on something else, it turned out that we need to cleanup
(de-allocate) the map of canonical types when all the translation
units that own types are de-allocated. Otherwise, when new
translation units are created later, the types in the canonical types
map become unrelated to the types in these new translation units,
leading to memory management issues.
This patch introduces a "usage watchdog" which detects when no
translation unit uses the type system anymore. That usage watchdog is
then used in the destructor of the translation_unit type to
de-allocate the global data that is logically owned by by the type
system.
The patch also changes the API to read translation units and corpora
in a way that forces users to get a handle on the resulting shared
pointer.
* include/abg-ir.h (type_base::canonical_types_map_type): Move
this typedef into abg-ir.cc and out of the type_base namespace.
(type_base::get_canonical_types_map): Likewise.
* src/abg-ir.cc (canonical_types_map_type): New typedef that got
moved here from type_base::canonical_types_map_type.
(get_canonical_types_map): Likewise got moved here from
type_base::get_canonical_types_map. Made static in the process.
(class usage_watchdog): New type.
(usage_watchdog_sptr, usage_watchdog_wptr): New typedefs.
(get_usage_watchdog, get_usage_watchdog_wptr, ref_usage_watchdog)
(maybe_cleanup_type_system_data): New static functions.
(translation_unit::priv::usage_watchdog_): Add new data member.
(translation_unit::priv::priv): Get a reference on the usage
watchdog.
(translation_unit::priv::~priv): If the usage watchdog says that
the type system is not used, then cleanup the global data
logically owned by the type system.
* include/abg-dwarf-reader.h (read_corpus_from_elf): Make this
return a corpus and set the status by reference using a parameter.
* src/abg-dwarf-reader.cc (read_corpus_from_elf): Implement the
above.
* include/abg-reader.h (read_translation_unit_from_file)
(read_translation_unit_from_buffer)
(read_translation_unit_from_istream): Remove the overloads that do
not return a translation_unit_sptr and that pass it as a
parameter. Only keep the overloads that return a
translation_unit_sptr, forcing users of the API to own a proper
reference on the resulting translation_unit pointer. That is
important to handle the life time of the global data of the type
system that need to be cleared when the last translation unit is
de-allocated.
* src/abg-reader.cc (read_translation_unit_from_input): Make this
return a translation_unit_sptr.
(read_translation_unit_from_file)
(read_translation_unit_from_buffer)
(read_translation_unit_from_istream): Remove the overloads that do
not return a translation_unit_sptr and that pass it as a
parameter. Only keep the overloads that return a
translation_unit_sptr.
(read_to_translation_unit): Make this return a
translation_unit_sptr.
* tests/print-diff-tree.cc (main): Adjust.
* tests/test-diff-dwarf.cc (main): Likewise.
* tests/test-ir-walker.cc (main): Likewise.
* tests/test-read-dwarf.cc (main): Likewise.
* tests/test-read-write.cc (main): Likewise.
* tools/abicompat.cc (main): Likewise.
* tools/abidiff.cc (main): Likewise.
* tools/abidw.cc (main): Likewise.
* tools/abilint.cc (main): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
It turned out typing --debug-info-dir{1,2} is a tad cumbersome. So this
patch adds --d1 and --d2 shortcut for these options.
* tools/abidiff.cc (display_usage): Add the --d{1,2} to the help
strings.
(parse_command_line): Parse the new --d1 and --d2 options.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
In abg-comparison.h, there is no function to test if a given
corpus_diff carries incompatible or subtype (after having applied
suppression specifications) ABI changes. So this patch factorizes the
code of abidiff.cc to provide these features to corpus_diff.
* include/abg-comparison.h (corpus_diff::{has_incompatible_changes,
has_net_subtype_changes}): Declare new member functions.
* src/abg-comparison.cc (corpus_diff::{has_incompatible_changes,
has_net_subtype_changes}): Define them.
* abidiff.cc (main): Use the new member functions above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tools/abidiff.cc (display_usage): Add a help string for the new
--suppr option.
(parse_command_line): Support the --suppr option which is an alias
for --suppressions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
So I forgot to finish the implementation of the --out-file option.
This patchlet addresses that.
* tools/abidw.cc (main): Take the argument of --out-file into
account when emitting the serialized form of the ABI.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
It turned out the hardened Rawhide build is failing if I don't this.
* tools/Makefile.am: Compile the binaries here with -fPIC. Note
that the library libabigail.la is built with libtool which already
takes care of this, so no need to worry about this for
libabigail.la.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
While working on something else, I noticed that the code for handling
copying symbols (and their aliases) was broken, and so comparing two
symbols which main name were different by which had aliases that were
equal was wrongly resulting in the two symbol being different. I think
we shouldn't actually copy symbols and their aliases. Once a symbol
is allocated, interested code should just manipulate that symbol by
address rather than by value an thus do away with the copying.
The patch does that, essentially. In the implementation of a symbol,
the aliases as well as the main symbol are now weak pointers, rather
than naked pointers. Numerous API entry points that were taking
containers of elf_symbol (and were copying elf_symbols over) are not
taking containers of smart pointers to elf_symbol. Copying of
instances of elf_symbol is now thus disabled.
As a result many tests that were exercising elf_symbols (with alias)
comparison have been updated.
As a result, many empty sub-result of PR libabigail/PR17948 are now
fixed.
* include/abg-ir.h (elf_symbol_wptr): New typedef.
(elf_symbol): Make the constructors and assignment operator
private. The type can neither be copied nor created with the new
operator.
(elf_symbol::create): New static member function.
(elf_symbol::{get_main_symbol, get_next_alias, add_alias}):
Adjust.
( compute_aliases_for_elf_symbol): Likewise.
(elf_symbol::operator=): Make this private.
(elf_symbol::get_alias_which_equals): Declare new member function.
* src/abg-comp-filter.cc (function_name_changed_but_not_symbol):
Adjust.
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): Adjust.
* src/abg-corpus.cc
(corpus::priv::build_unreferenced_symbols_tables): Likewise.
* include/abg-dwarf-reader.h (lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf): Adjust.
* src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(read_context::lookup_elf_symbol_from_index): Likewise.
(read_context::lookup_elf_fn_symbol_from_address): Likewise.
(read_context::lookup_elf_var_symbol_from_address): Likewise.
(read_context::lookup_public_function_symbol_from_elf): Likewise.
(read_context::lookup_public_variable_symbol_from_elf): Likewise.
(read_context::load_symbol_maps): Likewise.
(build_var_decl, build_function_decl): Likewise.
* src/abg-ir.cc (elf_symbol::priv::{main_symbol_, next_alias_}):
Change the type of these from elf_symbol* to elf_symbol_wptr.
(elf_symbol::priv::priv): Adjust.
(elf_symbol::{create, get_alias_which_equals}): Define new functions.
(textually_equals): Likewise.
(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
add_alias}): Adjust to return or take elf_symbol_sptr type, rather
than a elf_symbol* one.
(elf_symbol::{get_aliases_id_string, does_alias}): Adjust.
(compute_alias_for_elf_symbol): Likewise.
(elf_symbol::operator==): Two symbols A and B are now equal if A
has at least one alias that is textually equal to B.
(equals): In the overload for function_decls, in the part where we
compare the decl_base part of the functions without considering
their decl names, we now also omit considering their linkage
names, because we compared they symbols before.
* tools/abisym.cc (main): Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Adjust.
* tests/data/test-diff-dwarf/test8-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test13-report.txt: Adjust.
* tests/data/test-diff-filter/test2-report.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
As per https://sourceware.org/bugzilla/show_bug.cgi?id=18146, abidiff
the exit code of abidiff and abicompat is now a bit field that can be
inspected to know if the ABI change reported is incompatible for sure,
or if it needs user review of the output to decide.
This patch also updates the documentation.
* doc/manuals/abicompat.rst: Update documentation for abicompat
exit codes.
* doc/manuals/abidiff.rst: Likewise for abidiff exit codes.
* include/abg-tools-utils.h (enum abidiff_status): Declare new
enum.
(operator{|,&,|=}): Declare new operators for the new enum
abidiff_status.
(abidiff_status_has_error, abidiff_status_has_abi_change)
(abidiff_status_has_incompatible_abi_change): Declare new
functions.
* src/abg-tools-utils.cc (operator{|,&,|=}): Define these new
operators.
(abidiff_status_has_error, abidiff_status_has_abi_change)
(abidiff_status_has_incompatible_abi_change): Define new
functions.
* tests/test-diff-filter.cc (main): Adjust for the new exit code
of abidiff.
* tests/test-diff-suppr.cc (main): Likewise.
* tests/test-abicompat.cc (main): Likewise.
* tools/abicompat.cc (enum abicompat_status): Remove.
(operator{|,&,|=}): Remove these operators for enum
abicompat_status.
(perform_compat_check_in_normal_mode)
(perform_compat_check_in_weak_mode): Return abidiff_status instead
of abicompat_status. Adjust therefore.
(main): Adjust to return abidiff_status now, instead of a just
zero for all non-error cases.
* tools/abidiff.cc (main): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This patch implements the weak mode of abicompat. In this mode, just
the application and the new version of the library are provided. The
types of functions and variables of the library that are consumed by
the application are compared to the types of the functions and
variables expected by the application. The goal is to check if the
types of the declarations consumed by the application and provided by
the library are compatible with what the application expects.
The abicompat first gets the set of symbols undefined in the
application and exported by the library. It then builds the set of
declarations exported by the library that have those symbols. We call
these the set of declarations of the library that are consumed by the
application.
Note that the debug information for the application does not contain
the declarations of the functions/variables whose symbols are
undefined. So we can not just read them to compare them to
declarations exported by the library.
But the *types* of the variables and the *sub-types* of the functions
whose symbols are undefined in the application are present in the
debug information of the application.
So in the weak mode, abicompat compare the *types* of the declarations
consumed by the application as expected by the application (described
by the debug information of the application) with the types of the
declarations exported by the library.
To do this a number of changes were necessary.
The patch builds a representation of all the types found in the
application's debug info. Before that, only the types that are
reachable from exported declarations were represented.
The abidw tool got a new --load-all-types to test this new ability of
loading all types.
The patch also adds support for looking a type, not by name, but by
its internal representation.
In the comparison engine, function_type_diff is introduced to
represent changes between two function types. For this, a new class
type_or_decl_base has been introduced in the IR. It's now the base
class for both decl_base and type_base. And abigail::comparison::diff
now takes two pointers of type_or_decl, not decl_base anymore. So
function_type_diff can take two function_type now; not that a
function_type has no declaration so it doesn't inherit decl_base. A
bunch of changes got made just to adjust to this modification.
A number of fixes were made too, to make this work, like adding
missing comparison operators, removing asserts that too strong, etc..
The patch also adjust the test suite as well as the documentation.
* include/abg-fwd.h (class type_or_decl_base): Forward declare
this.
(is_decl, is_type, is_function_type, get_name, get_type_name)
(get_function_type_name, get_pretty_representation)
(lookup_function_type_in_corpus, lookup_type_in_translation_unit)
(lookup_function_type_in_translation_unit)
(synthesize_function_type_from_translation_unit)
(hash_type_or_decl): New function declarations.
* src/abg-corpus.cc (lookup_type_in_corpus)
(lookup_function_type_in_corpus): Define new functions.
* include/abg-ir.h
(translation_unit::lookup_function_type_in_translation_unit):
Declare new friend function.
(class type_or_decl_base): Declare this.
(operator==(const type_or_decl_base&, const type_or_decl_base&)):
Declare new operator.
(operator==(const type_or_decl_base_sptr&, const
type_or_decl_base_sptr&)): Likewise.
(class {decl_base, type_base}): Make these class inherit
type_or_decl_base.
(decl_base::get_member_scopes): New const overload.
(bool operator==(const function_decl::parameter_sptr&,
const function_decl::parameter_sptr&)): New operator.
(function_type::get_parameters): Remove the non-const overload.
(function_type::get_pretty_representation): Declare new member
function.
(method_type::get_pretty_representation): Likewise.
* src/abg-ir.cc (bool operator==(const type_or_decl_base&, const
type_or_decl_base&)): Define new equality operator.
(bool operator==(const type_or_decl_base_sptr&, const
type_or_decl_base_sptr&)): Likewise.
(strip_typedef): Do not expect canonicalized types anymore. Now
the system accepts (and expects) canonicalized types in certain
cases. For instance, non-complete types and aggregated types that
contain non-complete sub-types.
(get_name, get_function_type_name, get_type_name)
(get_pretty_representation, is_decl, is_type, is_function_type)
(lookup_function_type_in_translation_unit)
(synthesize_function_type_from_translation_unit)
(lookup_type_in_scope, lookup_type_in_translation_unit): Define
new functions or new overloads.
(bool operator==(const function_decl::parameter_sptr&,
const function_decl::parameter_sptr& r)): Define
new operator.
(function_type::get_parameters): Remove non-const overload.
(function_type::get_pretty_representation): Define new function.
(function_type::traverse): Adjust.
(method_type::get_pretty_representation): Likewise.
(function_decl::get_pretty_representation): Avoid emitting the
type of cdtors.
(hash_type_or_decl): Define new function.
* include/abg-dwarf-reader.h (create_read_context)
(read_corpus_from_elf): Take a new 'read_all_types' flag.
* src/abg-dwarf-reader.cc (read_context::load_all_types_): New
flag.
(read_context::read_context): Initialize it.
(read_context::canonical_types_scheduled): If some types still
have non-canonicalized sub-types, then do not canonicalize them.
(read_context::load_all_types): New member functions.
(build_function_decl): Do not represent void return type like
empty type anymore, rather, represent it like a void type node.
(build_ir_node_from_die): When asked, load all types
including those that are not reachable from an exported
declaration.
(create_read_context, read_corpus_from_elf): Take a new
'load_all_types' flag and honour it.
* src/abg-reader.cc (read_context::type_is_from_translation_unit):
Support looking up function types in the current translation unit,
now that we now how to lookup function types.
* include/abg-comparison.h (diff_context::{has_diff_for, add_diff,
set_canonical_diff_for, set_or_get_canonical_diff_for,
get_canonical_diff_for}): Make these take instances of
type_or_decl_base_sptr, instead of decl_base_sptr.
(diff::diff): Likewise.
(diff::{first_subject, second_subject}): Make these return
type_or_decl_base_sptr instead of decl_base_sptr.
(type_diff_base::type_diff_base): Make these take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::distinct_diff): Likewise.
(distinct_diff::{first, second}): Make these return
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::entities_are_of_distinct_kinds): Make these take
instances of type_or_decl_base_sptr instead of decl_base_sptr.
(class function_type_diff): Create this new type. It's a
factorization of the function_decl_diff type.
* src/abg-comparison.cc ():
* src/abg-comp-filter.cc ({harmless, harmful}_filter::visit):
Adjust as diff::{first,second}_subject() now returns a
type_or_decl_base_sptr, no more a decl_base_sptr.
(decls_type, decls_diff_map_type): Remove these typedefs and replace it with ...
(types_or_decls_type, types_or_decls_diff_map_type): ... these.
(struct {decls_hash, decls_equals): Remove these type sand replace them with ...
(struct {types_or_decls_hash, types_or_decls_equals}): ... these.
({type_suppression, variable_suppression}::suppresses_diff):
Adjust.
(diff_context::priv::decls_diff_map): Replace this with ...
(diff_context::priv::types_or_decls_diff_map): ... this.
(diff_context::{has_diff_for, add_diff, get_canonical_diff_for,
set_canonical_diff_for, set_or_get_canonical_diff_for}): Take
type_or_decl_base_sptr instead of decl_base_sptr.
(diff::priv::{first, second}_subject): Make the type of these be
type_or_decl_base_sptr, no more decl_base_sptr.
(diff::priv::priv): Adjust for the subjects of the diff being of
type type_or_decl_sptr now, no more decl_base_sptr.
(diff_less_than_functor::operator()(const diff_sptr, const
diff_sptr) const): Adjust.
(diff::diff): djust for the subjects of the diff being of type
type_or_decl_sptr now, no more decl_base_sptr.
(diff::{first,second}_subject): Make the type of these be
type_or_decl_base_sptr, no more decl_base_sptr.
(report_size_and_alignment_changes): Likewise.
(type_diff_base::type_diff_base): Make the type of this be
type_or_decl_base_sptr instead of type_base_sptr.
(distinct_diff::distinct_diff): Make this take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::{first, second, entities_are_of_distinct_kinds}):
Likewise.
(distinct_diff::has_changes): Simplify logic.
(distinct_diff::report): Adjust.
(compute_diff_for_types): Add an additional case to support the
new function_type.
(report_size_and_alignment_changes): Make this take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(class_diff::priv::member_type_has_changed): Return an instance of
type_or_decl_base_sptr rather than a decl_base_sptr.
(class_diff::report): Adjust.
(diff_comp::operator()(const diff&, diff&) const): Adjust.
(enum function_decl_diff::priv::Flags): Remove.
(function_decl_diff::priv::{first_fn_flags_, second_fn_flags_,
fn_flags_changes_}): Remove.
(function_decl_diff::priv::{fn_is_declared_inline_to_flag,
fn_binding_to_flag}): Remove.
(function_decl_diff::{deleted_parameter_at,
inserted_parameter_at}): Remove.
(function_decl_diff::ensure_lookup_tables_populated): Empty this.
(function_decl_diff::chain_into_hierarchy): Adjust.
(function_decl_diff::function_decl_diff): This now only takes the
subjects. It's body is now empty.
(function_decl_diff::{return_type_diff, subtype_changed_parms,
removed_parms, added_parms, type_diff}): Remove these member
functions.
(function_decl_diff::type_diff): Define new member function.
(function_decl_diff::report): Simplify logic by using the
reporting of the child type diff node.
(compute_diff): Likewise, in the overload for function_decl_sptr
simplify logic by using the child type diff object.
(function_type_diff::priv): Define new type.
(function_type_diff::{function_type_diff,
ensure_lookup_tables_populated, deleted_parameter_at,
inserted_parameter_at, finish_diff_type, first_function_type,
second_function_type, return_type_diff, subtype_changed_parms,
removed_parms, added_parms, get_pretty_representation,
has_changes, has_local_changes, report, chain_into_hierarchy}):
Define new functions.
(compute_diff): Define new overload for function_type_sptr.
* tools/abicompat.cc (options::weak_mode): New data member.
(options::options): Initialize it.
(enum abicompat_status): New enum
(abicompat_status operator|(abicompat_status, abicompat_status))
(abicompat_status& operator|=(abicompat_status &, abicompat_status))
(abicompat_status operator&(abicompat_status, abicompat_status)):
New operators to manipulate the abicompat_status enum.
(display_usage): Add help string for the new --weak-mode option.
(parse_command_line): Add the new --weak-mode command line
argument. If the tool is called with just the application and one
library then assume that we are in the weak mode.
(perform_compat_check_in_normal_mode): Define new function, factorized
from what was in the main function.
(perform_compat_check_in_weak_mode): Define new function.
(struct {fn,var}_change): Define new types.
(main): Use perform_compat_check_in_weak_mode() and
perform_compat_check_in_normal_mode().
* tools/abidiff.cc (main): Adjust.
* tools/abidw.cc: (options::load_all_types): Add new data member.
(options::options): Initialize it.
(display_usage): New help string for --load-all-types.
(parse_command_line): Support the new --load-all-types option.
(main): Adjust and honour the --load-all-types option.
* tools/abilint.cc (main): Adjust.
* doc/manuals/abicompat.rst: Update documentation for the new weak
mode. Also provide stuff that was missing from the examples
provided.
* doc/manuals/abidw.rst: Update documentation for the new
--load-all-types option.
* tests/print-diff-tree.cc (main): Adjust.
* tests/test-diff-dwarf.cc (main): Likewise.
* tests/test-read-dwarf.cc (main): Likewise.
* tests/data/test-abicompat/test0-fn-changed-app: Recompile this.
* tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so:
New new test input binaries
* tests/data/test-abicompat/test5-fn-changed-app: Likewise.
* tests/data/test-abicompat/test6-var-changed-app: Likewise.
* tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so:
Likewise.
* tests/data/test-abicompat/test5-fn-changed-report-0.txt:
Reference output for one test above.
* tests/data/test-abicompat/test6-var-changed-report-0.txt:
Likewise.
* tests/data/test-abicompat/test5-fn-changed-app.cc: Source file
for a binary above.
* tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}:
Likewise.
* tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}:
Likewise.
* tests/data/test-abicompat/test6-var-changed-app.cc: Likewise.
* tests/data/Makefile.am: Add the test related files above to the
source distribution.
* tests/test-abicompat.cc (in_out_spec): Add the new test input
above to the list of inputs to feed to this test harness.
(main): Support taking just the app and one library.
* tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o,
8-qualified-this-pointer.so,}.abi: Adjust for void type being
really emitted now, as opposed to just being an empty type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
For portability of the regression tests of libabigail, we need abidw
to avoid emitting information about the architecture of the ELF file
it's looking at. This patch thus adds a new --no-architecture option
to abidw for that purpose.
* tools/abidw.cc (options::write_architecture): New flag.
(options::options): Initialize it.
(display_usage): Add usage string for the new --no-architecture
option.
(parse_command): Parse the new --no-architecture command line
option.
(main): Ignore the architecture name if required by the user.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Until now, after the ABI corpus was built from DWARF, the translation
units of the corpus were walked and each function was considered for
addition into the set of exported decls. During that walking, a first
version of the set was put into a std::list and then, a set of filters
(user-provided tunables like a list of regular expressions to keep or
remove some functions from the exported decls) is applied to that list
and the final set of exported decls is put in a std::vector.
Profiling has shown that this process of building the set of exported
decls is a hot spot and also that the current use of std::list was a
big memory consumer especially on binaries with large exported symbol
tables.
So this patch builds the set of exported decls "on the fly", during
DWARF reading, as opposed to waiting after the DWARF is read and
having to walk the corpus again. The corpus defines a policy object
that encapsulates the methods for determining if a function or
variable ought to be part of the set of exported decls. The DWARF
reader uses that policy object to determine which functions and
variables among those built during the reading ought be part of the
exported decls; the policy object also has a reference to the final
vector (managed by the corpus) that must hold the exported decls, so
the decls are put in that vector directly without unnecessary copying.
Profiling also showed that the string copying done by
{var_decl,function_decl}::get_id() was a hot spot. So the patch
returns a reference there.
With this patch applied, the peak memory consumption of abidiff on
libabigail.so itself (abidiff libabigail.so libabigail.so) is 54MB of
resident and takes 2 minutes and 16s (on my slow system). Without the
patch the peak consumption was more than 300MB and it was taking
slightly longer.
For the test of bug
https://sourceware.org/bugzilla/show_bug.cgi?id=17948, memory
consumtion and wall clock time spent is down from 3.4GB and 1m59s to
760MB and 0m43s.
* include/abg-ir.h ({var,function}_decl::get_id): Return a
reference.
* src/abg-ir.cc ({var,function}_decl::get_id): Return a reference
to the string rather than copying it over.
* include/abg-corpus.h (class corpus::exported_decls_builder):
Declare new type.
(corpus::{sort_functions, sort_variables,
maybe_drop_some_exported_decls, get_exported_decls_builder}):
Declare new methods.
* src/abg-corpus.h (corpus::exported_decls_builder::priv): Define
new type.
(class symtab_build_visitor_type): Remove this type that is
useless now.
(corpus::exported_decls_builder::{exported_decls_builder,
exported_functions, exported_variables,
maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}):
Define new functions.
(corpus::priv::is_public_decl_table_built): Remove this data
member. It's now useless.
(corpus::priv::priv): Adjust.
(corpus::priv::build_public_decl_table): Remove this member
function. It's now useless.
(corpus::{priv::build_unreferenced_symbols_tables, get_functions,
get_variables}): No need to build the public decls table here.
It's already built by the time the corpus is read from DWARF now.
(corpus::{sort_functions, sort_variables,
maybe_drop_some_exported_decls, get_exported_decls_builder}):
Define new member functions.
* src/abg-dwarf-reader.cc (read_context::exported_decls_builder):
New data member.
(read_context::read_context): Initialize it.
(read_context::{exported_decls_builder,
maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}):
Define new member functions.
(read_debug_info_into_corpus): Get the the new
'exported_decls_builder' object from the corpus and stick it into
the read context so the DWARF reading code can use it to build the
exported decls set. When the DWARF reading is done, sort the set
of exported functions and variables that was built.
(build_ir_node_from_die): When a function or variable is built,
consider putting it into the set of exported decls.
* tools/abicompat.cc (main): Now that the exported decls is built
*before* we had a chance to stick the list of symbol IDs to keep,
call corpus::maybe_drop_some_exported_decls() to update the set of
exported decls we should consider for the corpus.
was applied to that list and the final
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Since it turned out that the length of the changes carried by a diff
node has never been used in the algorithms of the comparison engine,
the diff::length() feels wrong. What we want is rather a name like
diff::has_changes() so this is what this patch does.
* include/abg-comparison.h (*::has_changes): Rename the ::length()
method of all the diff types that inherit the diff class into
this, in the class declarations.
* src/abg-comparison.cc (*::has_changes): Do the same as in the
declarations, in the definitions.
(diff::to_be_reported, distinct_diff::has_local_changes)
(distinct_diff::report, distinct_diff::, array_diff::has_changes)
(reference_diff::has_changes, qualified_type_diff::has_changes)
(enum_diff::has_changes, translation_unit_diff::has_changes)
(suppression_categorization_visitor::visit_end)
(redundancy_marking_visitor::visit_begin): Adjust.
* tests/test-diff-dwarf.cc (main): Adjust.
* tools/abidiff.cc (main): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This program is meant to be used by libabigail developers to debug its
ini file parsing facilities. So there is no need to install.
* tools/Makefile.am: Add abinilint to the noinst_PROGRAMS primary.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
What was in the abigail::tools namespace got recently moved in the
abigail::tools_unit namespace. I forgot to adjust the client code
related to the archive support because that code is now compiled by
default on my main hacking box. This patch fixes that.
* tests/Makefile.am: tools/libtoolsutils.la is no more.
* tests/test-write-read-archive.cc (main): Adjust.
* tools/abiar.cc (extract_tus_from_archive): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The utilities present in this namespace were previously living in
tools/abg-tools-utils.h and tools/abg-tools-utils.cc. They were not
exported and were meant to be useful to the tools writting in the
tools/ directory. I realized that these utilities might be useful to
clients of the libabigail library in general so I am making them
available generally. Note that the initial name of the namespace was
libabigail::tools; so renaming it to libabigail::tools_utils required
that I adjust some client code. I have also cleaned up the code,
interfaces and their apidoc a little bit.
* include/abg-tools-utils.h: Moved tools/abg-tools-utils.h in
here. Renamed the namespace tools into tools_utils. Inject
std::ostream, std::istream, std::ifstream, and std::string types
into the tools_utils namespace. Adjust the function declarations
accordingly. Remove the useless dirname() function declaration.
* include/Makefile.am: Add abg-tools-utils.h to the list of
exported headers.
* src/abg-tools-utils.cc: Moved tools/abg-tools-utils.cc in here.
Renamed the namespace tools into tools_utils.
(get_stat): Add apidoc.
(is_dir): Cleanup apidoc.
(dir_name); Cleanup parameter name.
(guess_file_type): Cleanup parameter type.
* src/Makefile.am: Add abg-tools-utils.cc to the list of exported
headers.
* tools/Makefile.am: Do not build the temporary library
libtoolsutils.la anymore as abg-tools-utils.{h,cc} have moved out
of this directory.
* tools/abicompat.cc (parse_command_line, main): Adjust for tools
-> tools_utils namespace change.
* tools/abidiff.cc (parse_command_line, main): Likewise.
* tools/abidw.cc (parse_command_line, main): Likewise.
* tools/abilint.cc (parse_command_line, main): Likewise.
* tests/test-abicompat.cc (main): Adjust for tools -> tools_utils
namespace change.
* tests/test-abidiff.cc (main): Likewise.
* tests/test-alt-dwarf-file.cc (main): Likewise.
* tests/test-core-diff.cc (main): Likewise.
* tests/test-diff-dwarf.cc (main): Likewise.
* tests/test-diff-filter.cc (main): Likewise.
* tests/test-diff-suppr.cc (main): Likewise.
* tests/test-lookup-syms.cc (main): Likewise.
* tests/test-read-dwarf.cc (main): Likewise.
* tests/test-read-write.cc (main): Likewise.
* tests/Makefile.am: Do not reference the libtoolsutils.la private
library anymore.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
I have felt the need to emit a textual representation of the diff
nodes tree maintained by the comparison engine for changed functions
and variables. This patch adds that functionality.
* include/abg-comparison.h (enum visiting_kind): Add new
DO_NOT_MARK_VISITED_NODES_AS_TRAVERSED enumerator.
(diff_context::{default_output_stream, error_output_stream,
dump_diff_tree}): Declare new accessors.
(diff::end_traversing): Take a new boolean flag.
(print_diff_tree): Add new overload for diff_sptr.
* src/abg-comparison.cc
(diff_context::priv::{default_output_stream_,
error_output_stream_, dump_diff_tree_}): New data members.
(priv::priv): Initialize them.
(diff_context::{default_output_stream_, error_output_stream_,
dump_diff_tree, dump_diff_tree}): Define new accessors.
(diff::end_traversing): Take a new flag that control whether or
not to mark the current diff node as having been traversed.
(diff::traverse): Take in account the visiting kind carried by the
visitor to determine if the visited node should be marked as being
traversed.
(corpus_diff::priv::maybe_dump_diff_tree): Define new member
function.
(corpus_diff::report): Call it.
(diff_node_printer::visit): Pretty print the diff node just once.
(print_diff_tree): Define a new overload for diff_sptr.
* tools/abidiff.cc (options::dump_diff_tree): New data member.
(options::options): Initialize it.
(display_usage): Add a help string for the new --dump-diff-tree
command line switch.
(parse_command_line): Parse the new --dump-diff-tree command line
switch.
(set_diff_context_from_opts): Set the diff context according to
the --dump-diff-tree presence.
* doc/manuals/abidiff.rst: Add a bullet point for the new
--dump-diff-tree command line switch.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Now that we are handling redundant diff node marking (and reporting)
with more finesse, I guess we can enable redundant diff reporting
elision by default again.
* tools/abidiff.cc (options::options): Initialize
options::show_redundant_changes to false.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>