Commit Graph

170 Commits

Author SHA1 Message Date
Dodji Seketeli
ec9a667f39 Fix indentation
* tools/abipkgdiff.cc (parse_command_line): Fix a wrong indentation.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-18 16:06:13 +01:00
Dodji Seketeli
c2d32394b9 Emit more informational messages on unrecognized options
This is like what was done for abififf, but for abicompat, abidw,
abipkgdiff and abilint.

	* tools/abicompat.cc (options::prog_name): New data member.
	(display_help, perform_compat_check_in_normal_mode)
	(perform_compat_check_in_weak_mode, main): Prefix error messages
	with the name of the program.
	* tools/abidw.cc (options::wrong_option): New data member.
	(display_help): Prefix error messages with the name of the
	program.n
	(parse_command_line): Record the name of the unrecognized option.
	(main): Tell the name of the unrecognized option.  Prefix error
	messages with the name of the program.
	* tools/abilint.cc (optionqs::wrong_option): New data member
	(display_usage): Prefix error messages with the name of the
	program.
	(parse_command_line): Record the name of the unrecognized option.
	(main): Tell the name of the unrecognized option.  Prefix error
	messages with the name of the program.
	* tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New
	data members.
	(package::erase_extraction_directory, display_usage, extract_rpm)
	(extract_deb, extract_tar)
	(erase_created_temporary_directories_parent, extract_package)
	(compare, create_maps_of_package_content): Prefix error messages
	with the name of the program.
	(maybe_check_suppression_files): Adjust.
	(parse_command_line): Record the name of the unrecognized option,
	and the name of option which lacks an operand.
	(main): Give the name of the unrecognized option.  Prefix error
	messages with the name of the program.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 12:37:04 +01:00
Dodji Seketeli
b0335a42d5 Prefix abidiff error message with the 'abidiff' program name
* include/abg-tools-utils.h (emit_prefix): Declare new function.
	(check_file): Add a new parameter with a default value, so that
	existing code keeps compiling.
	* src/abg-tools-utils.cc (emit_prefix): Define new function.
	(check_file): Use the emit_prefix function and give it the program
	name passed as a new parameter.
	* tools/abidiff.cc (display_usage, main): Use the new emit_prefix
	to prefix error messages.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 10:12:38 +01:00
Dodji Seketeli
5c07fdcc2e Bug 19606 - Need better error message for invalid options
This patch instructs abidiff to mentions the wrong option when it
encounters an unknown option.

It also instructs it to mention the option when reporting about
a missing option argument.

	* tools/abidiff.cc (options::wrong_option): New data member.
	(parse_command_line): Record the name of the unknown option and of
	the option which value is missing.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-11 16:07:34 +01:00
Dodji Seketeli
21a85fbbdf Make abipkgdiff check for the presence of suppression spec files
* tools/abipkgdiff.cc (maybe_check_suppression_files): Define new
	static function.
	(main): Use it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-11 09:40:41 +01:00
Dodji Seketeli
ff408a3d07 Make abipkgdiff return correct exit code on usage error
* tools/abipkgdiff.cc (main): Return the correct error code on
	usage error.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-11 09:40:41 +01:00
Dodji Seketeli
2c4efc0c3e Bug 19604 - abidiff --suppressions doesn't complain about invalid file name
* tools/abidiff.cc (maybe_check_suppression_files): Define new
	static function.
	(main): Use it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-11 09:39:10 +01:00
Dodji Seketeli
2dc323b972 Fix abicompat's handling of library types not used by the application
When abicompat sees a type defined by the library but not used by the
application, it behaves as if the application has that type defined as
"void".  So it compares both types (void and the library type) and
report the difference.  Hugh.

This patch fixes that by avoiding comparison when the application
doesn't use a particular library type.

	* tools/abicompat.cc (perform_compat_check_in_weak_mode): If the
	application doesn't use a given type defined and exported by the
	library, then skip it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-27 14:18:47 +01:00
Dodji Seketeli
097a5c46ff Fix abidw -v
abidw -v was failing to work until now.  This patch fixes that.

	* tools/abidw.cc (parse_command_line): Simplify logic.
	(main): Fix logic.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-05 12:35:57 +01:00
Ondrej Oprala
6a7566d513 Add the option of printing the file, line and column information about a type being reported.
* bash-completion/abicompat: Complete the new "--no-show-locs" option.
	* bash-completion/abidiff: Likewise.
	* bash-completion/abidw: Likewise.
	* bash-completion/abipkgdiff: Likewise.
	* doc/manuals/abicompat.rst: Mention the new "--no-show-locs" option.
	* doc/manuals/abidiff.rst: Likewise.
	* doc/manuals/abidw.rst: Likewise.
	* doc/manuals/abipkgdiff.rst: Likewise.
	* include/abg-comparison.h (show_locs): Add declarations.
	* src/abg-comparison.cc: (diff_context::priv): Add a new switch
	called "show_locs_" and set its default value to false.
	(report_loc_info): New function. Outputting the extra information
	is conditionalized based on the associated diff contexts settings.
	(show_locs): define a getter/setter for
	diff_context::priv::show_locs_.
	({distinct,pointer,reference,qualified_type,enum,class,scope,fn_parm,
	typedef,corpus}_diff::report): Call report_loc_info when
	appropriate.
	(maybe_report_diff_for_member): Likewise.
	(represent): Accept a const reference to a diff_context_sptr as a first
	argument and call report_loc_info on its second argument.
	* src/abg-dwarf-reader.cc:
	* tests/data/Makefile.am: Add the new test reference files.
	* tests/data/test-abicompat/test0-fn-changed-report-2.txt: New test
	reference output.
	* tests/data/test-abicompat/test5-fn-changed-report-1.txt: Likewise.
	* tests/data/test-abicompat/test6-var-changed-report-1.txt: Likewise.
	* tests/data/test-abicompat/test7-fn-changed-report-2.txt: Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt:
	Likewise.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt:
	Likewise.
	* tests/data/test-diff-pkg/dirpkg-3-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise.
	* tests/test-abidiff.cc: Explicitly create a diff context and turn off
	location emitting.
	* tests/test-diff-dwarf.cc: Likewise.
	* tests/test-abicompat.cc: Add --no-show-locs to all existing test
	arguments. Run a few of the existing tests again, but without this
	option.
	* tests/test-diff-filter.cc: Likewise.
	* tests/test-diff-pkg.cc: Likewise.
	* tests/test-diff-suppr.cc: Likewise.
	* tools/abicompat.cc: Handle the new "--no-show-locs" option.
	* tools/abidiff.cc: Likewise.
	* tools/abidw.cc: Likewise.
	* tools/abipkgdiff.cc: Likewise.

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-12-15 12:32:55 +01:00
Dodji Seketeli
43c908ed15 Bug 19336 - Better handle redundantly qualified reference types
Sometimes we can see const references in DWARF.  But then, a reference
is always const, so that qualified reference is redundant.
Furthermore, having that construct make its way into the internal
representation can cause awkward diagnostics.

The DWARF reader was thus eliding such redundant qualifiers in the
function "maybe_strip_qualification".  It was doing so by stripping
the qualifier from the qualified type. So const reference, for
instance, becomes a (non-qualified) reference.  In that case, we are
turning a qualified type into a non-qualified one.

But as the accompanying problem report suggests, this can cause issues
during the DWARF parsing.  This is because a given Debug Information
Entry (DIE) of qualified type kind can be referenced elsewhere, by
another type.  That other type expects that DIE to be a qualified
type.  And libabigail's DWARF reader code enforces that.  So the
internal representation of a type resulting from a qualified type DIE
must be a qualified type itself.

So the way the function "maybe_strip_qualification" was doing the
redundancy elision was wrong.  This patch fixes that by keeping the
type qualified, but introducing a "no-op" qualifier.  Actually, the IR
already has that "no-op" qualifier: abigail::ir::qualified_type_def::CV_NONE.

So now "maybe_strip_qualification" just turns the CV_CONST qualifier
into a CV_NONE one when the former is redundant.

Now that the libabigail type system actually *has* types qualified
with this no-op qualifier, we need to handle things like printing the
name of such qualified types.  When we are printing the name of the
type for internal reasons (i.e, for type canonicalization purposes) we
need to make a difference between the name of a no-op qualified type
and the name of the underlying type of the qualified type, otherwise,
the canonicalizer wrongly considers the two types as being equal.  But
then when we are printing the name of the no-op qualified type for
diagnostics reasons, then the name is the same as the name of its
underlying unqualified type.

	* src/abg-dwarf-reader.cc (maybe_strip_qualification): Do not nuke
	the qualified type.  Rather, just turn the redundant const
	qualifier into a no-op one.
	* src/abg-comparison.cc (compute_diff_for_types): Look through
	no-op qualified types.
	* include/abg-ir.h
	(decl_base::{peek,set}_temporary_qualified_name): Declare new
	accessors.
	* src/abg-ir.cc (decl_base::priv::temporary_qualified_name_): New
	data member.
	(decl_base::{peek,set}_temporary_qualified_name): Define new
	accessors.
	(qualified_type_def::priv::{temporary_internal_name_,
	internal_name}): New data members.
	(qualified_type_def::build_name): For a no-op qualified type, the
	internal name (which contains the 'none' qualifier) is different
	from the non-internal name.
	(qualified_type_def::get_qualified_name): Handle temporary names
	and non-temporary names in two different caches.  Also handle
	internal and non-internal names in two different caches.  This
	makes four different caches.
	(qualified_name_setter::do_update): Do not touch the non-internal,
	non-temporary qualified name cache if the qualified parent name is
	empty.
	* tools/abidw.cc (main): change --check-alternate-debug-info to
	make it *not* display the name/path to the alternate debug info,
	when it's found.  Rather, only
	--check-alternate-debug-info-base-name keeps displaying the base
	name of the alternate debug info.
	* tests/data/test-alt-dwarf-file/test1-libgromacs-debug-dir/*: New
	test material.
	* tests/data/Makefile.am: Add the new test material to the build
	system.
	* tests/test-alt-dwarf-file.cc (in_out_specs): Take the new test
	input into account.
	* tests/data/test-read-dwarf/test1.abi: Adjust.
	* tests/data/test-read-dwarf/test7.so.abi: Likewise.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-12-08 14:11:22 +01:00
Dodji Seketeli
04bcd328b6 Add missing new line to abidiff help message
* tools/abidiff.cc (display_usage): Add missing new line.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-11-28 10:09:37 +01:00
Dodji Seketeli
7722e27a89 Do not abort when there is no binary to compare in a package
When given a package which has no binary to compare, abipkgdiff
aborts.  This patch fixes that.

	* tests/data/test-diff-pkg/empty-pkg-libvirt-0.9.11.3-1.el7.ppc64.rpm:
	New input test package.
	* tests/data/test-diff-pkg/empty-pkg-libvirt-1.2.17-13.el7_2.2.ppc64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/empty-pkg-report-0.txt: New test
	reference output.
	* data/Makefile.am: Add the new test material above to the build system.
	* tests/test-diff-pkg.cc (int_out_specs): Add the new test inputs
	to the set of tests.
	* tools/abipkgdiff.cc (compare): Do not abort if there is no
	binary to compare.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-11-26 11:59:42 +01:00
Ondrej Oprala
814a88cdfc Abidiff: Remove doubled line in help.
* tools/abidiff.cc (display_usage): Remove a doubled help message.

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-23 09:57:12 +01:00
Dodji Seketeli
47f7ef1a38 Do not use designated initializers in abipkgdiff.cc
g++ 4.4.7 of el6 does not support designated initializers, so
libabigail fails to build on el6 for that reason.

	* tools/abipkgdiff.cc (prepare_packages): Do not use designated
	initializers syntax.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-11-17 13:41:38 +01:00
Dodji Seketeli
266fa9288e Add --version option to several libabigail tools
This patch changed the revision number of the libabigail library to
make it reflect the fact that we are not in "release candidate" mode,
before the first 1.0 release.  So the revision number is now "rc0".

The configuration manager has been updated to support version numbers
that are strings, so that it can supports things like "rc0".

Then, several libabigail tools have been modified to support the
--version option to display their version number.

	* configure.ac: Set the version revision to "rc0".
	* doc/manuals/abicompat.rst: Adjust manual for new --version
	option.
	* doc/manuals/abidiff.rst: Likewise.
	* doc/manuals/abidw.rst: Likewise.
	* doc/manuals/abilint.rst: Likewise.
	* doc/manuals/abipkgdiff.rst: Likewise.
	* include/abg-config.h (config::{m_format_minor, m_format_major}):
	Make these be strings.
	(config::{get,set}_format_minor_version_number): Make these return
	strings.
	(config::{get,set}_format_major_version_number): Make these return
	or take strings.
	(abigail_get_library_version): Make this take strings.
	* src/abg-config.cc (config::config): Adjust.
	(config::{get,set}_format_major_version_number): Make these return
	or take strings.
	(config::{get,set}_format_minor_version_number): Make these return
	strings.
	(abigail_get_library_version): Make this take strings.
	* include/abg-version.h.in: Make the version variables be strings.
	* src/abg-writer.cc (write_translation_unit): The version numbers
	are now strings so adjust.
	* tools/{abicompat,abidiff,abidw,abilint,abipkgdiff,abisym}.cc
	(options::display_version): New data member.
	(options::options): Initialize it.
	(display_usage): Add documentation for new --version option.
	(parse_command_line): Parse new --version option.
	(main): Support --version.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-11-16 12:54:10 +01:00
Ondrej Oprala
17b04f2e04 Bug 19081 - abipkgdiff parallelization
Abipkgdiff now attempts to extract packages and compare the resulting
ELF pairs in parallel. First off, a thread is spawned to extract each
package and each debuginfo package. After the ELF files are extracted,
mapped and the threads are successfully collected, the resulting
ELF vectors are traversed to identify existing pairs and a list of
arguments for future comparison is made. This list is then sorted
by size from largest to smallest. Unless --no-parallel is
specified on the command line, MIN(pairs,active_processors) threads
are spawned, sharing a single list of arguments. This list is
processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile,
the main thread checks this same map for results in the original order
of the ELF pairs, ensuring sequential output. After all the diffing
and reporting is done, the threads are collected again.

	* doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option.
	* tools/Makefile.am: Add -pthread to abipkgdiffs link options.
	* tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the
	thread-local vector of ELF filepaths.
	(reports_map): A map of the path of the first ELF of a compared pair
	and a corpus representing the difference.
	(env_map): A map of the corpus difference and a corresponding
	environment needed to be kept alive until the diff is reported.
	({arg,map}_lock): mutexes to control access to the comparison argument
	list and the {reports,env}_map respectively.
	(options): Add a new member "parallel" and set it to true in the ctor.
	(elf_file): Add a new "size" member and set it in the ctor.
	(package descriptor): Arguments passed to extract_package_set.
	(compare_args): Arguments passed to the ELF comparison function.
	(display_usage): Mention the new "--no-parallel" option.
	(pthread_routine_extract_package): A wrapper function around
	extract_package to be used in a multi-threaded environment.
	({first_second}_package_tree_walker_callback_fn): Add the new ELF file
	paths to a thread-specific vector.
	(compare): In an overload of compare, verbose output is updated to
	always mention the ELF files being compared for each reported stage.
	Reporting is no longer done in this function, the resulting difference
	is instead passed back to the calling function for reporting in the
	main thread, along with a corresponding environment.
	(pthread_routine_compare): Accept a pointer to a vector of comparison
	arguments. This function is to be called NTHREAD times and share the
	vector passed to it with its other invocations. Create the environment
	for compare() and store its output in a map if there is a difference.
	(create_maps_of_package_content): Allocate memory for a thread local
	vector of ELF paths and dispose of it before returning.
	(pthread_routine_extract_pkg_and_map_its_content): Renamed from
	extract_package_and_map_its_content. Extract the debuginfo as well as
	the regular package in this function. Spawn a separate thread for the
	extraction of the debug package.
	(pthread_join): A function handling thread joining throughout package
	extractions.
	(prepare_packages): Spawn a thread to extract each set of packages.
	(elf_size_is_greater): New comparison function used to order ELF pairs
	by size.
	(compare): In the overload of compare, pass through the ELF path
	vectors and identify pairs to be diffed. Put them in a vector and sort
	it by the summed ELF pair size. Spawn comparison threads and safely
	check for results in the proper order of the ELF pairs. Report any
	differences ASAP and collect the threads after all the reporting is
	done, checking their return status.
	(parse_command_line): Check for the "--no-parallel" option.

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-10 16:04:39 +01:00
Ondrej Oprala
c05a02573f Document abipkgdiff's option --no-abignore
* doc/manuals/abipkgdiff.rst: Mention the new option.
	* tools/abipkgdiff.cc: Likewise.

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-10 09:50:45 +01:00
Dodji Seketeli
6d4472066b Make abidw --abidiff not show definitely harmless changes
When comparing the ABI of the input ELF binary with that same ABI
saved to abixml and read back again, there can be some minor and
harmless changes that are seen, because libabigail makes some
approximations for performance reasons.  For instance, if there are
two types that are equivalent, but have different names (because of
typedefs) then libabigail will consider that they are the same type,
and might save them (to abixml) and read them back (from abixml) in
different order.

That can lead to subtle changes that are reported (and filtered out)
by the command "abidw --abixml".

This patch arranges for abidw --abixml to avoid emitting a report
saying that a filtered out change was detected, as those cases are
considered OK.

The patch also fixes a little issue where abidw would abort because
the user forgot to provide the binary to analyze, on the command line.

	* tools/abidw.cc (set_diff_context): New function.
	(main): Use that new function.  Do not show any output for
	--abidiff if only compatible changes were detected.  Also, do not
	abort if no input binary was giving.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-10-15 13:50:49 +02:00
Ondrej Oprala
b2a5bf6389 Bug 19082 - Recognize suppression spec files
When abipkgdiff is invoked on a set of packages, the newer (second) one is also
inspected for files matching the pattern '*.abignore', whose contents are read
and interpreted as suppression specifications.

	* tests/data/Makefile.am: Add new test material to the build system.
	* tests/data/test-diff-pkg/dirpkg-{0-dir1,{1,2}-dir2}/dir.abignore:
	A test suppression specification.
	* tests/data/test-diff-pkg/dirpkg-{2,3}-dir2/.abignore: Likewise.
	* tests/data/test-diff-pkg/dirpkg-3.suppr: Likewise.
	* tests/data/test-diff-pkg/dirpkg-{1,2,3}-dir{1,2}/libobj-v0.so: New
	binary test inputs.
	* tests/data/test-diff-pkg/dirpkg-{1,2,3}-dir{1,2}/obj-v0.cc: New test
	source files
	* tests/data/test-diff-pkg/dirpkg-{1,2,3}-report-{0,1}.txt: New
	reference outputs
	* tests/test-diff-pkg.cc: Adjust to run the new tests.
	* tools/abipkgdiff.cc (prog_options): New static pointer to struct
	opts.
	(file_tree_walker_callback_fn): Rename to
	first_package_tree_walker_callback_fn.
	(second_package_tree_walker_callback_fn): Check for ELF files just
	like the previous function but additionally check for files
	ending with ".abignore", unless disabled from the command line.
	({create_maps_of_package,extract_package_and_map_its}_content):
	Add a callback as a new argument.
	(main) handle the new "--no-abignore" option, which turns off
	the search for suppression files within the new package.

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-10-13 09:19:47 +02:00
Dodji Seketeli
133d0e491d Remove some dead code in abilint
* tools/abilint.cc (options::bidiff): Remove.
	(options::options): Adjust.
	(display_usage): Remove usage string for --bidiff
	(parse_command_line): Remove parsing of un-implemented option
	--bidiff.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-09-21 15:20:10 +02:00
Dodji Seketeli
bd0926a2b5 Add a new --abidiff option to abidw
This is a debugging and sanity check option.  It saves the abi of the
ELF binary to a temporary file, reads it back and compares the abis of
the temporary file against the abi of the input ELF binary.

	* tools/abidw.cc (options::abidiff): New data member.
	(options::options): Initialize it.
	(display_usage): Add a usage string for the new --abidiff option.
	(parse_command): Parse the new --abidiff options.
	(main): Save the abi of the input elf in a temporary abixml file;
	read it back and compare both.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-09-21 15:14:26 +02:00
Dodji Seketeli
04167e5c66 Fix compilation warnings in abipkgdiff.cc
* tools/abipkgdiff.cc (package::erase_extraction_directory)
	(extract_rpm, extract_deb, extract_tar)
	(erase_created_temporary_directories_parent): Check the return
	value of the system() function.
	(extract_package): Add necessary white space.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-09-09 14:20:43 +02:00
Dodji Seketeli
a717ca6faf Adjust {s,g}et_show_stats() to use a reference
* include/abg-dwarf-reader.h ({s,g}et_show_stats): Use a reference
	to the reader.
	* tools/abidiff.cc (main): Adjust.
	* tools/abidw.cc (main): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-09-07 23:42:17 +02:00
Dodji Seketeli
b2e5366d3f Introduce the concept of environment
There are resources needed by the type system and other artifacts of
libabigail.  Today, when the life time of those resources need to be
greater than all of artifacts of Abigail, then said resources are made
global.

But then global resources are not great, if anything because they
complicate the future use of the library in concurrent computing
setups.

As I was in the need to add one resource to be used by the type
system, I decided to sit down and first overhaul how these long lived
resources needed to be handled.

And here comes the concept of "environment".  An environment is a
place where one can put resources that need to live longer than all
the other artifacts of the Abigail system.  And so, the code that
creates Abigail artifacts needs and environment of for said artifacts
to use.  In other words, artifacts now use an environment.

This has interesting and strong implications.  We can only compare two
artifacts if they use the same environment.  This is quite a strong
requirement.

But then when this requirement is fulfilled, comparing two types
amounts to just comparing two pointer values; hash values for types
can also be cached.  Now *that* is great for speed of comparison, is
it not?

This patch introduce the concept environment (which is basically a new
abigail::ir::environment type), removes the global variables and uses
the environment instead.  Each ABI artifact (either type or decl) now
has a ::get_environment() member function to get its environment.

This patch also disables the caching of hash values because the
caching must happen only *after* all types have been canonicalized.
We were not respecting that requirement until now, and that introduces
wrong hash values.  A subsequent patch is going to re-introduce hash
value caching again, once the infrastructure is in place to set a flag
in the environment (hah!) once type canonicalization is done, and then
later read that flag when some client code requests a hash value, to
know if we should look in the hash value cache or not.

The patch obviously changes the output of numerous regression tests
(if anything b/c it disables hash value caching) so 'make check'
yields regressions.  But then, it's only the subsequent patch that
updates the tests.

	* include/abg-ir.h: Adjust note about memory management.
	(class environment): Declare new class.
	(translation_unit::translation_unit): Take an environment in
	parameter.
	(translation_unit::{g,s}et_environment): Declare new member
	functions.
	(type_or_decl_base::{g,s}et_environment): Likewise.
	(type_or_decl_base::{get_cached_hash_value,
	set_cached_hash_value}): Change the name of
	decl_base::peek_hash_value() and decl_base::set_hash() here into
	these and move them here.
	(type_or_decl_base::hashing_started): Move
	decl_base::hashing_started() here.
	({g,s}et_environment_for_artifact): Declare new functions.
	(class decl_base): Move member functions hashing_started(),
	peek_hash_value() and set_hash() on to the type_or_decl_base base
	class.
	(scope_decl::scope_decl): Initialize the virtual member
	type_or_decl_base().
	(type_decl::{get_void_type_decl,
	get_variadic_parameter_type_decl}): Remove these static member
	functions.  They are now non-static member functions of the new
	environment type.
	* src/abg-ir.cc (class environment_setter): New internal class.
	(get_canonical_types_map): Remove.  This now becomes a member
	function of the environment type.
	(class usage_watchdog): Remove.
	(usage_watchdog_{s,w}ptr): Remove these typedefs.
	(get_usage_watchdog_wptr, ref_usage_watchdog)
	(maybe_cleanup_type_system_data): Remove these functions.
	(translation_unit::priv::usage_watchdog_): Remove data member.
	(translation_unit::priv::env_): New data member.
	(translation_unit::priv::priv): Take an environment and initialize
	the new env_ data member.  Do not initialize the removed
	usage_watchdog_.
	(translation_unit::translation_unit): Take an environment
	parameter.
	(translation_unit::get_global_scope): Set the environment of a new
	global scope.
	(translation_unit::{g,s}et_environment): New accessors.
	(translation_unit::bind_function_type_life_time): Set the
	environment of the function type.
	(struct environment::priv): New class.
	(environment::{environment, ~environment, get_canonical_types_map,
	get_variadic_parameter_type_decl, canonicalization_is_done}): New
	member functions.
	(struct type_or_decl_base::priv): New class.
	(type_or_decl_base::{type_or_decl_base, hashing_started,
	get_cached_hash_value, set_cached_hash_value, set_environment,
	get_environment, traverse}): New member functions.
	({s,g}get_environment_for_artifact): New functions.
	(decl_base::priv::{hash_, hashing_started}): Remove.
	(decl_base::priv::priv): Adjust.
	(decl_base::decl_base): In the copy constructor, initialize the
	virtual base type_or_decl_base.  Do not initialize hash_ and
	hashing_started data member that got removed.
	(decl_base::{hashing_started, peek_hash_value, set_hash}): Remove
	member functions.
	(strip_typedef): Set the environment of the new type which has its
	typedefs stripped off.  Adjust the call to type_or_void().
	(scope_decl::{add, insert}_member_decl): Set the environment of
	the new member decl to the environment of its scope.
	(synthesize_type_from_translation_unit)
	(synthesize_function_type_from_translation_unit): Set the
	environment for the newly synthesized type. Adjust calls to
	type_or_void().
	(type_or_void): Take an environment in parameter.  Get the void
	type from the environment.
	(get_canonical_types_map): Remove.
	(type_base::get_canonical_type_for): Get the canonical types map
	from the environment, not from a global variable.
	(type_decl::{get_void_type_decl,
	get_variadic_parameter_type_decl}): Remove.
	(pointer_type_def::pointer_type_def): Adjust call to type_or_void.
	(reference_type_def::reference_type_def): Likewise.
	(function_decl::parameter::get_pretty_representation): Get the
	variadic parameter type decl from the environment.
	(class_decl::priv::classes_being_compared_): Remove static data
	member.
	(class_decl::priv::{mark_as_being_compared,
	unmark_as_being_compared, comparison_started): Use the "classes
	being compared" map from the environment.
	(class_decl::base_spec::get_hash): Adjust.
	(keep_type_alive): Get the alive types array from the environment)
	not from a global variable anymore.
	(get_next_string): Put the counter in thread-local storage.
	* src/abg-hash.cc (scope_decl:#️⃣:operator())
	(function_decl:#️⃣:operator()): Do not handle caching (here).
	* include/abg-corpus.h (corpus::{g,s}et_environment): Declare new
	accessors.
	* src/abg-corpus.cc (corpus::priv::env): New data member.
	(corpus::priv::priv): Initialize it.
	(corpus::corpus):  Take an environment in parameter.
	(corpus::{g,s}et_environment): Define new member functions
	(corpus::add): Set the environment of the newly added translation
	unit, if it's not set already set.  In any case, assert that the
	translation unit must use the same environment as the corpus.
	* include/abg-dwarf-reader.h (create_read_context)
	(read_corpus_from_elf): Take an environment parameter.
	({s,g}et_debug_info_root_path, {s,g}et_environment): Declare new
	functions.
	* src/abg-dwarf-reader.cc (read_context::{env_,
	offline_callbacks_}): New data members.
	(read_context::read_context): Initialize them.
	(read_context::clear_per_translation_unit_data): Do not touch the
	void type declaration, it doesn't belong to the translation unit.
	(read_context::{env, offline_callbacks}): New accessors.
	(read_context::{create_default_dwfl}): New member function.
	(read_context::dwfl_handle): Add a setter overload.
	({s,g}et_debug_info_root_path): Define new accessors.
	(create_default_dwfl, create_dwfl_sptr, create_default_dwfl_sptr):
	Remove these.
	(build_translation_unit_and_add_to_ir): Adjust to pass the
	environment to the newly created translation unit.
	(build_function_decl): Adjust to pass the environment to the
	created function and parameter types.  Get variadic parameter type
	node from the current environment, not from a global variable.
	And do not try to canonicalize function types here.
	(read_debug_info_into_corpus): Set the environment of the newly
	created corpus.
	(build_ir_node_for_void_type): Get the void type node from the
	current environment, rather than from a global variable.
	(create_read_context): Take the environment in parameter.
	Create the default dwarf front end library handle using the new
	member function of the read context.  Set the current environment
	used by the reader.
	(read_corpus_from_elf): Take an environment in
	parameter. Overhaul.  This is now simpler.
	(has_alt_debug_info): Adjust the call to create_read_context() to
	make it pass an empty environment.
	* include/abg-fwd.h (class environment): Forward declare.
	* include/abg-reader.h (read_translation_unit_from_file)
	(read_translation_unit_from_buffer)
	(read_translation_unit_from_istream)
	(read_corpus_from_native_xml): Take an environment in parameter.
	* src/abg-reader.cc (read_context::m_env): New data member.
	(read_context::read_context): Initialize it.
	(read_context::{get_environment, set_environment}): New data
	member.
	(read_translation_unit): Set environment of the new translation
	unit.
	(read_corpus_from_input): Set the environment of the new corpus.
	(read_translation_unit_from_file)
	(read_translation_unit_from_buffer)
	(read_translation_unit_from_istream, read_corpus_from_native_xml):
	Take an environment in parameter.
	(build_function_parameter): Get variadic parameter type from the environment.
	* src/abg-comparison.cc (compute_diff): Add asserts in all the
	overloads to ensure that the artifact being compared come from the
	same environment.
	* tests/print-diff-tree.cc (main): Create an env for the ABI
	artifacts to use.
	* tests/test-abidiff.cc (main): Likewise.
	* 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.
	* tools/abipkgdiff.cc (main): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-09-07 23:35:29 +02:00
Dodji Seketeli
277e524392 Add a new --noout option to abidw
* tools/abidw.cc (options::noout): New data member.
	(options::options): Initialize it.
	(display_usage): Add a usage string for the new option.
	(parse_command_line): Parse the new option.
	(main): If --noout is provided, do not emit the XML form.
 	* doc/manuals/abidw.rst: Document the new option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-29 16:23:15 +02:00
Dodji Seketeli
e61afa7291 Add a --no-architecture option to abidiff
This new option omits architectures when comparing ABIs.

	* tools/abidiff.cc (options::no_arch): New data member.
	(options::options): Initialize it.
	(display_usage): Display a help string for the new options.
	(parse_command_line): Parse the new options.
	(main): If --no-architecture is provided, set the corpus
	architecture to "".
	* doc/manuals/abidiff.rst: Document the new options.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-29 16:23:15 +02:00
Dodji Seketeli
72b42c3090 Misc style cleanups
* configure.ac: Fix some spelling typos.
	* src/abg-tools-utils.cc (guess_file_type): Fix indentation.
	* tests/test-diff-pkg.cc (int_out_specs): Add some vertical spaces
	for better legibility.
	* tools/abidiff.cc (main): Add a missing space.
	* tools/abipkgdiff.cc (extract_deb): Fix a typo in the comment.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-22 14:32:20 +02:00
Dodji Seketeli
585fc4c33c Make abipkgdiff compare tar archives containing binaries
This patch adds support for comparing the ABI of binaries contained in
a tar archive.

If the archive is compressed with gzip, bzip2, lzip, lzma or xz, then
abipkgdiff recognizes the usual relevant file extensions and lets the
GNU tar program handle the decompression.

If the archive is not compressed, abipkgdiff recognizes the UStar
(Uniform Standard Tape ARchive) format, even if the archive file name
doesn't end with the .tar extension, and lets the GNU tar program
handle the extraction.  If the file ends up with the .tar extension
anyway (even if it's not in the UStar format, abipkgdiff lets the GNU
tar program handle its extraction.

	* config.h.in (WITH_TAR): New configuration preprocessor macro.
	* configure.ac: Add a new --enable-tar option.  It's turned on
	automatically if the tar program is found in the PATH.  Adjust the
	build configuration report to add the tar archive support.
	* include/abg-tools-utils.h (string_ends_with): Declare new
	function.
	(enum file_type): Add a new FILE_TYPE_TAR enumerator.
	* src/abg-tools-utils.cc (string_ends_with): Define new function.
	(operator<<(ostream&, file_type)): Serialize the new FILE_TYPE_TAR
	enumerator.
	(guess_file_type): Detect UStar format file by reading its magic
	number.  Detect compressed tar files based on the file path
	extension.
	* tools/abipkgdiff.cc (extract_tar): Define new function.
	(extract_package): Handle tar packages.
	(main): Handle tar archives.
	* tools/abidiff.cc (main): Handle the new FILE_TYPE_TAR
	enumerator.
	* tools/abilint.cc (main): Likewise.
	* tests/data/test-diff-pkg/tarpkg-0-dir{1,2}.ta{,r,.bz2, gz}: New
	test input tarballs.
	* tests/data/test-diff-pkg/tarpkg-0-report-0.txt: New test output
	reference.
	* tests/data/Makefile.am: Add the new test data file above to
	source distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Add new tests cases.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-22 14:32:20 +02:00
Dodji Seketeli
fca8506ab9 Misc style fixes in abipkgdiff
* include/abg-tools-utils.h (enum file_type): Fix the comment for
	for the FILE_TYPE_DEB enumerator.
	* tools/abipkgdiff.cc (main): Fix the style of the conditions.
	Also, fix the text emitted.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-22 12:19:27 +02:00
Dodji Seketeli
d7dbbf0d50 Make abipkgdiff compare directories containing binaries
abipkgdiff knows how to compare the ABI of binaries contained in .deb
and .rpm files.  This patch adds support for comparing the ABI of
binaries contained in two directories.

	* include/abg-tools-utils.h (enum file_type): Add a new
	FILE_TYPE_DIR enumerator.
	* src/abg-tools-utils.cc (operator<<(ostream&, file_type)):
	Support serialization of the new FILE_TYPE_DIR enumerator.
	(guess_file_type): Detect that the path given is a directory.
	* tools/abipkgdiff.cc (package::package): If the package is a
	directory, then set its extracted directory path to the path of
	the directory.
	(package::erase_extraction_directory): Do not erase the extraction
	directory if the package is a directory provided by the user.
	(extract_package): If the package is a directory provided by the
	user, then there is nothing to extract.
	(main): If the first package is a directory, then the second one
	should be a directory as well.
	* tools/abidiff.cc (main): Support directories as input.
	* tools/abilint.cc (main): Likewise.
	* tests/data/test-diff-pkg/dirpkg-0-dir{1,2}/libobj-v0.so: New
	binary test inputs.
	* test/data/test-diff-pkg/dirpkg-0-report-0.txt: New input test
	file.
	* tests/data/test-diff-pkg/dirpkg-1-dir{1,2}/obj-v0.cc: Source
	code of the binary test inputs above.
	* tests/data/Makefile.am: Add the new files above to the source
	distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Add the new test input
	files above to the set of tests this harness has to run over.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-22 12:19:27 +02:00
Dodji Seketeli
d1c6ef0cb5 make abipkgdiff compile with GCC 4.4.7
GCC 4.4.7 won't let us declare an instance of string with __thread.
So for now, package::extracted_packages_parent_dir() juststores its string
globally.  We are single-threaded for now anyway.

	* tools/abipkgdiff.cc (package::extracted_packages_parent_dir):
	The string holding the dir name is no more __thread, as this won't
	compile with GCC 4.4.7

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-21 13:08:38 +02:00
Dodji Seketeli
7bcaf67504 Add a --stats to abidiff and abidw
For now, this new --stats emits diagnostics about the number of types
canonicalized at the very end of building the ABI corpus as well as
the number of types that were scheduled for late canonicalizing and
that couldn't be canonicalized.

	* include/abg-dwarf-reader.h (get_show_stats)
	(set_show_stats): New accessors for a new "show_stats" property of
	the dwarf reader context.
	* src/abg-dwarf-reader.cc: Include iostream to use std::cerr.
	(dwarf_reader::show_stats_): New data member.
	(dwarf_reader::dwarf_reader): Initialize it.
	(dwarf_reader::show_stats)
	(get_show_stats)
	(set_show_stats): Define new accessors.
	(dwarf_reader::die_type_map): Add const overload to this accessor.
	(dwarf_reader::lookup_type_from_die_offset): Make this accessor
	const.
	(dwarf_reader::add_late_canonicalized_types_stats): New member
	function.
	(dwarf_reader::perform_late_type_canonicalizing): Emit the
	statistics about late-canonicalized types if the user asked for
	it.
	* tools/abidiff.cc (options::show_stats): New data member.
	(options::options): Initialize it.
	(display_usage): Document it.
	(parse_command_line): Parse the new --stats option.
	(main): Create a dwarf reader context, set the show_stats to it
	and then use that context to read the corpora before diffing them.
	* tools/abidw.cc (options::show_stats): New data member.
	(options::options): Initialize it.
	(display_usage): Document it.
	(parse_command_line): Parse the new --stats option.
	(main): Set the show_stats to the dwarf reader context before
	using it.
	* doc/manuals/abidiff.rst: Update the manual.
	* doc/manuals/abidw.rst: Update the manual.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-20 13:25:42 +02:00
Dodji Seketeli
dd15667e8e Fix typos in abipkgdiff
* tools/abipkgdiff.cc (display_usage): s/pompare/compare.  Give a
	better help message for --help.
	(extract_rpm): Insert a space after the path of the package being
	extracted, when emitting a verbose message.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 16:50:18 +02:00
Dodji Seketeli
57e2cb9e07 Update comment about the supported formats in abipkgdiff
* tools/abipkgdiff.cc: Now that .deb packages are supported, say
	it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 15:24:12 +02:00
Dodji Seketeli
28090bad1b Make the support of RPM and DEB package formats conditional
If at configure time the libabigail source tarball detects that
rpm2cpio and cpio are present then it enables the support for rpm
files.  Users can explicitly enable or disable that support by passing
--enable-rpm or --disable-rpm to configure.

Similarly if it detects that dpkg is present at configure time then it
enables the support for deb files.  Users can explicitly enable or
disable that support by passing --enable-deb or --disable-deb to
configure.

	* config.h.in: Define WITH_DEB and WITH_RPM pre-processor macros.
	* configure.ac: Add --enable-{rpm,deb} switches.  Check for
	rpm2cpio and cpio programs, unless --disable-rpm was provided.  If
	they are found and if --enable-rpm=auto was provided, then
	consider that --enable-rpm=yes was provided.  In that case, set
	the WITH_RPM macro to 1.  Otherwise, undefine that macro.
	Similarly, check for dpkg unless --disable-deb was provided.  If
	it's found and if --enable-deb=auto was provided, consider that
	--enable-deb=yes was provided.  In that case, set the WITH_DEB
	macro to 1.  Otherwise, undefine that macro.  Define the
	ENABLE_RPM and ENABLE_DEB conditional automake variables, if the
	rpm resp. deb support is enabled.  Emit a notice about the rpm and
	deb features being enabled or not, at the end of the configure
	process.
	* tests/test-diff-pkg.cc: Include the config.h header.
	(in_out_spec): Guard rpm tests by the WITH_RPM macro.  Similarly,
	guard deb tests by the WITH_DEB macro.
	* tools/abipkgdiff.cc: Include the config.h header.
	(extract_rpm): Guard this function definition with the WITH_RPM
	macro.
	(extract_deb): Guard this function definition with the WITH_DEB
	macro.
	(extract_package): Guard the handling of rpm packages with the
	WITH_RPM macro and the handling of deb package with the WITH_DEB
	macro.  If a package not-support package format is encountered,
	emit an appropriate error message and error out.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 13:40:32 +02:00
Matthias Klose
4df0a4d952 Add support for .deb files to abipkgdiff
This lets abipkgdiff compare debian binary packages.

The patch contains test cases for debian package with split debug info
that is referenced by the build-id scheme.  These test cases come from
the bug report https://sourceware.org/bugzilla/show_bug.cgi?id=18792,
more particularly from the attachment
https://sourceware.org/bugzilla/attachment.cgi?id=8516.

	* include/abg-tools-utils.h (file_type): Add FILE_TYPE_DEB.
	* tools/abipkgdiff.cc (extract_deb): New.
	(extract_package, main): Handle FILE_TYPE_DEB.
	* src/abg-tools-utils.cc (operator<<): Handle FILE_TYPE_DEB.
	(guess_file_type): Detect FILE_TYPE_DEB.
	* tools/abidiff.cc (main): Handle FILE_TYPE_DEB.
	* tools/abilint.cc (main): Handle FILE_TYPE_DEB.
	* tests/data/test-diff-pkg/libsigc++-2.0-0c2a-dbgsym_2.4.0-1_amd64.ddeb:
	Input debian debug info package; to be compared by the test
	harness runtestdiffpkg.
	* tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64.deb:
	Input debian package; to be compared by the test harness
	runtestdiffpkg.
	* tests/data/test-diff-pkg/libsigc++-2.0-0v5-dbgsym_2.4.1-1ubuntu2_amd64.ddeb:
	Input debug info package
	* tests/data/test-diff-pkg/libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64.deb:
	Input debian package; to be compared by the test harness
	runtestdiffpkg.
	* tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt:
	Reference output for the comparison of the packages above.
	* tests/data/Makefile.am: Add the new files above to the source distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Add the input packages
	above to the set of files to be compared by this test harness.

Signed-off-by: Matthias Klose <doko@debian.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 13:36:23 +02:00
Dodji Seketeli
56112bae3b Add an abipkgdiff --fail-no-dbg command line option
* tools/abipkgdiff.cc (options::fail_if_no_debug_info): New data
	member.
	(options::options): Initialize it.
	(display_usage): Document it.
	(compare): If the user asked for it, fail if the we couldn't file
	the debug info for the corpus files being compared.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-13 23:26:53 +02:00
Dodji Seketeli
c09bb53ab1 Add -h and -d option shortcuts to abidw
Added a -h option shortcut for the --help option and a -d option
shortcut for the --debug-info-dir option, to the abidw program.

	* tools/abidw.cc (display_usage): Added a documentation string.
	(parse_command_line): Parse the new -h and -d shortcuts.
	* doc/manuals/abidw.rst: Update the manual.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-13 23:26:53 +02:00
Dodji Seketeli
71acc72064 Add a -h option shortcut to abidiff
Added a -h shortcut for --help to the abidiff program.n

	* tools/abidiff.cc (display_usage): Add documentation for the new
	switch.
	(parse_command_line): Parse the -h option.
	* doc/manuals/abidiff.rst: Update the manual.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-13 23:26:53 +02:00
Dodji Seketeli
da870f3598 Add a -h shortcup to abipkgdiff --help
* tools/abipkgdiff.cc (display_usage): Document the -h shortcut.
	(parse_command_line): Parse the -h shortcut to --help.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-13 23:26:52 +02:00
Dodji Seketeli
9f7c07460d Add --no-added-syms to abipkgdiff
With this new option the tool ignores added functions, variables and
their symbols.

	* tools/abipkgdiff.cc (options::show_added_syms): New data member.
	(options::options): Initialize it.
	(parse_command_line): Parse the new --no-added-syms option and set
	the options::show_added_syms flag accordingly.
	(display_usage): Add a help string for the new option.
	(set_diff_context_from_opts): Set the diff context according to
	the state of the new options::show_added_syms flag.
	* doc/manuals/abipkgdiff.rst: Add manual entry for the new
	--no-added-syms options.
	* tests/data/test-diff-pkg/test-rpm-report-5.txt: New test
	reference input file.
	* tests/data/Makefile.am: Add the new file above to source
	distribution.
	* tests/test-diff-pkg.cc (InOutSpec::prog_options): New data
	member.
	(in_out_specs): Adjust.  Add a new input to run the test again
	with --no-added-syms.
	(main): Adjust to pass the program options contained in
	InOutSpec::prog_options to abipkgdiff.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>

fixup! Add --no-added-syms to abipkgdiff

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-06 15:22:38 +02:00
Dodji Seketeli
f0d319ab42 Make abipkgdiff erase the *parent* directory of temporary files
abipkgdiff was erasing the temporary files created by it wasn't
erasing the parent directory containing them.  Fixed thus.

	* tools/abipkgdiff.cc
	(erase_created_temporary_directories_parent): New static function.
	(compare): After comparison, erase the temporary parent directory
	as well.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-24 14:09:55 +02:00
Dodji Seketeli
b8ae34192f Extract all packages for a given run of abipkgdiff under the same temp dir
This patch extracts all packages for a given run of abipkgdiff under
the same temporary directory, cluttering /tmp less.

To do this, the patch makes accesses of data members of the 'package'
type go through accessor functions only.  Then the accessor for the
parent directory of all extracted package does the job of computing
the path to that parent directory in a way that makes it unique, per
thread.

	* tools/abipkgdiff.cc (package::{<all data members>}): Make the
	data members be private.  Make their names end with an underscore.
	(package::extracted_package_parent_dir_path): Remove.
	(package::extracted_package_dir_path): Rename into
	package::extracted_dir_path_.
	(package::extracted_packages_parent_dir): New static member
	function, accessor.
	(package::package): Adjust to the new names of the data members.
	Call the new package::extracted_package_parent_dir() static member
	function to initial the package::extracted_dir_path_ data member.
	(package::{path, extracted_dir_path, type, is_debug,
	path_elf_file_sptr_map, debug_info_package}): New accessors for
	the data members.
	(package::{erase_extraction_directory,
	erase_extraction_directories}): Adjust.
	(erase_created_temporary_directories)
	(create_maps_of_package_content)
	(extract_package_and_map_its_content, prepare_packages, compare)
	(main): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-22 16:05:11 +02:00
Dodji Seketeli
decf33e847 Add a --keep-tmp-files option to abipkgidff
Sometimes, for debugging purposes it can be very handy to inspect the
content of the packages as seen by the tool.  This patch thus adds a
new --keep-tmp-files options so that users can inspect the content of
packages that were extracted.

	* tools/abipkgdiff.cc (options::keep_tmp_files): New data member.
	(options::options): Initialize it.
	(display_usage): Display a usage string for the new
	--keep-tmp-files option.
	(parse_command_line): Parse the new --keep-tmp-files option.
	(compare): Do not erase temporary directories if the users asked so.
	* doc/manuals/abipkgdiff.rst: Document the new --keep-tmp-files
	options.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-22 15:36:16 +02:00
Dodji Seketeli
819f8941cf Show linkage names in abipkgdiff output
With this patch abipkgdiff now shows the linkage names of
added/removed functions and variables.  In addition, there now is a
--no-linkage-name option to avoid seeing linkage names.

	* doc/manuals/abipkgdiff.rst: Document the new --no-linkage-name
	options.
	* tools/abipkgdiff.cc (options::show_linkage_names): New data
	member.
	(options::options): Initialize it.
	(display_usage): Display a usage string for --no-linkage-name.
	(parse_command_line): Parse the --no-linkage-name option.
	(set_diff_context_from_opts): Set the diff context accordingly.
	* tests/data/test-diff-pkg/test-rpm-report-0.txt: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-21 16:09:53 +02:00
Dodji Seketeli
b638309e48 Add --no-added-binaries to abipkgdiff
* tools/abipkgdiff.cc (options::show_added_binaries): New data
	member.
	(options::options): Initialize it.
	(display_usage): Add a help string for --no-added-binaries.
	(parse_command_line): Parse the new --no-added-binaries option.
	(compare): Do not show added binaries if the user doesn't want to.
	* doc/manuals/abipkgdiff.rst: Document the new --no-added-binaries
	option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-21 14:15:33 +02:00
Dodji Seketeli
96af1baf13 make abipkgdiff return a proper exit code
With this patch, abipkgdiff returns the same exit code as abidiff.
It's zero if there is no ABI change, and non-zero if there are ABI
changes.  The exact value depends on the kind of changes that is
detected.

	* tools/abipkgdiff.cc (compare): Return an instance
	abigail::tools_utils::abidiff_status, just like what we do in
	abidiff.
	* doc/manuals/abipkgdiff.rst: Document the new exit code.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-21 14:11:53 +02:00
Dodji Seketeli
6d4c194c04 Fix logic of determining if changes happened in abidiff
Now that we can easily check if the diff between two corpora carries
net changes (i.e, changes after applying suppression specifications)
we can simplify the logic of determining if the corpora have
"worthwhile" changes, in abidiff.

	* tools/abidiff.cc (main): Simplify the logic when determining if
	the comparison between two corpora yields worthwhile changes.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-21 12:54:57 +02:00
Dodji Seketeli
92b821034a Clean up the output of abicompat weak mode
Remove ugly vertical spaces from the output of abicompat in weak
mode and adjust regression tests accordingly.

	* tools/abicompat.cc (perform_compat_check_in_weak_mode): Remove
	disgracious vertical spaces in the wording.
	* tests/data/test-abicompat/test5-fn-changed-report-0.txt: Adjust.
	* tests/data/test-abicompat/test6-var-changed-report-0.txt: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-20 16:01:27 +02:00