Commit Graph

948 Commits

Author SHA1 Message Date
Dodji Seketeli
8798649dbe Do not remove api and website source files by accident
When the root source dir is used as root build dir, make clean can
remove the content of ${abs_builddir}/api which is then equal to
${abs_srcdir}/api.  Oops.  This patch fixes this.

	* doc/Makefile.am: Do not remove the entirety of the build dir of
	doxygen for the apidoc and the website as these can be also the
	source dirs.  Rather, remove that is under the html/ sub-directory
	of the build dir, as this is always generated by doxygen.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 13:31:30 +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
242e49a321 Bug 18791 - libabigail fails to read the output of abidw
The reader fails to set the access specifier for a member type.  Fixed
thus.

	* src/abg-reader.cc (read_context::get_scope_for_node): Take an
	access_specifier output parameter to set the access specifier of
	the current node in its scope.  Update the function to set the
	access_specifier.
	(read_context::build_or_get_type_decl): Adjust to set the access
	specifier of the type we are building, in case it's a member type.
	* tests/data/test-abidiff/test-PR18791-v{0,1}.so.abi: New test input files.
	* tests/data/test-abidiff/test-PR18791-report0.txt: New test
	output reference.
	* tests/data/Makefile.am: Add the new test material to the source
	distribution.
	* tests/test-abidiff.cc (specs): Add the new test inputs to the set of
	input files this test harness has to run over.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-09 02:11:17 +02:00
Dodji Seketeli
11b536e4fc Fix a thinko in language support de-serialization
A thinko was preventing us from reading the value of the "language"
property in the XML format.  Fixed thus.

	* src/abg-ir.cc (string_to_translation_unit_language): Fix
	thinko.  What was I thinking ...

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-09 02:10:09 +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
465b25e0d8 Update diff stats when added symbols are removed from change report
Until now, when added symbols were removed from the diff output, the
diff stat was not properly updated.  This patch fixes that.

	* include/abg-comparison.h (diff_context_wptr)
	(corpus_diff::diff_stats_sptr): New typedefs.
	(corpus_diff::diff_stats::diff_stats): Make this constructor take
	a diff_context_sptr.  Make the default constructor private.
	* src/abg-comparison.cc (corpus_diff::diff_stats::priv::ctxt_):
	New data member.  This is a weak pointer to a diff_context.
	(corpus_diff::diff_stats::priv::priv): Take a diff_context_sptr
	and initialize the weak pointer ctxt_ to it.
	(corpus_diff::diff_stats::priv::ctxt): New accessor to the
	diff_context hold by the diff_stats.
	(corpus_diff::diff_stats::{num_removed_func_filtered_out,
	num_added_func_filtered_out, num_removed_vars_filtered_out,
	num_added_vars_filtered_out, num_removed_func_syms_filtered_out,
	num_added_func_syms_filtered_out,
	num_removed_var_syms_filtered_out,
	num_added_var_syms_filtered_out}): If the user asked for the added
	[or removed] variables/functions/symbols to be ignored, the
	accessors for the number of filtered added/removed variables/functions/symbols
	return the total number of added/removed
	variables/functions/symbols; that is, say that *all* added/removed
	variables/functions/symbols got filtered out.
	(corpus_diff::priv::diff_stats_): Turn this data member into a
	[shared] pointer to diff_stats.
	(corpus_diff::priv::filters_and_suppr_applied_): Remove this data
	member.  Now that diff_stats_ is a pointer, we don't need this
	boolean anymore.
	(corpus_diff::apply_filters_and_suppressions_before_reporting):
	Adjust to the fact that filters_and_suppr_applied_ is gone, and
	that diff_stats_ is now a pointer.
	(corpus_diff::report): Control un-referenced added symbols
	reporting with
	diff_context::show_added_symbols_unreferenced_by_debug_info()

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-06 15:15:41 +02:00
Dodji Seketeli
a746f4afee Make applying supp specs through pointer access look through typedefs
Consider the declaration of the exported function bar() below:

    struct _OpaqueType {int member;};

    typedef struct _OpaqueType Type;

    void bar(Type*);

Once the *definition of struct _OpaqueType and bar() are compiled into
a shared library, if a layout change happens to struct _OpaqueType,
then abidiff rightfully reports that bar() is impacted by the layout
change to struct _OpaqueType.

But then, the following suppression specification won't silence the
ABI change report:

    [suppress_type]
      name = _OpaqueType
      type_kind = struct
      accessed_through = pointer

This is because strictly speaking, it's not struct _OpaqueType that is
accessed through a pointer, from function bar(); it's the type 'Type',
(which is a typedef of struct _OpaqueType) that is accessed though a
pointer.

But then, as 'Type' and 'struct _OpaqueType' are the same type (modulo
the typedef), this behaviour is not super useful.  It would be more
interesting if the suppression specification could silence the ABI
change report.

And this is what this patch does.

	* include/abg-comparison.h (type_suppression::suppresses_type):
	Declare new member function.
	(get_typedef_diff_underlying_type_diff): Declare new function.
	* include/abg-fwd.h (get_typedef_underlying_type): Likewise.
	* src/abg-comparison.cc (type_suppression::suppresses_type):
	Define new member function.
	(get_typedef_diff_underlying_type_diff): Define new function.
	(type_suppression::suppresses_diff): After looking through the
	different kind of access methods, use the new
	type_suppression::suppresses_type(), rather than doing lots of
	stuff ourselves here.  But then, if the suppression doesn't apply
	to the subjects of the diff, look through typedefs and try to
	apply the suppression again.
	* src/abg-ir.cc (get_typedef_underlying_type): Define new
	function.
	* tests/data/test-diff-suppr/libtest25-typedef-v{0,1}.so: New
	binary test input files.
	* tests/data/test-diff-suppr/test25-typedef-v{0,1}.c: Source code
	for the binary test input files above.
	* tests/data/test-diff-suppr/test25-typedef-report-{0, 1}.txt: New test
	input files.
	* tests/data/test-diff-suppr/test25-typedef-suppr-0.txt: New test
	input file.
	* tests/data/Makefile.am: Add the new test material to the source
	distribution.
	* tests/test-diff-suppr.cc (in_out_specs): Add the test inputs
	above to the set of test inputs this harness has to run over.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-01 14:34:46 +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
88a1e8d6a0 Make the name of the removed variable section be consistent
The removed functions section is introduced by the string "Removed
functions", whereas the removed variables section is introduced by the
string "Deleted variables".  This patch makes the latter be "Removed
variables" just like for the functions.

	* src/abg-comparison.cc (corpus_diff::report): Introduce the
	section of removed variables with the string "Removed variable",
	rather than with the string "Deleted variable".
	* tests/data/test-abicompat/test2-var-removed-report-0.txt: Adjust.
	* tests/data/test-diff-suppr/test18-suppr-removed-var-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test18-suppr-removed-var-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test18-suppr-removed-var-report-5.txt: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-24 14:06:29 +02:00
Dodji Seketeli
e5cf9d1f60 Consider default symbol versions when computing added/removed fns/vars
When computing the set of added function or variable symbols, if a
symbol S with no version symbol was present in a given corpus and that
symbol gained a *DEFAULT* version V in the second corpus, we should
not consider that a new symbol S was added (and that the former S was
removed) because:

  1/ S was already present in the first corpus
  2/ applications linked to the first corpus and that were using S
  (with no version) there, will automatically use the S with version V
  in the second corpus, without needing any re-linking; the
  power of symbol versioning!

Rather, it's just that S gained a default symbol version.

This patch implements that.

	* include/abg-corpus.h (corpus::{lookup_function_symbol,
	lookup_variable_symbol}): Take a elf_symbol::version object,
	rather than a string representing the version.  Add an overload
	that takes an elf_symbol.
	* src/abg-corpus.cc (find_symbol_by_version): New static function.
	(corpus::{lookup_function_symbol, lookup_variable_symbol}): Take a
	elf_symbol::version object, rather than a string representing the
	version.  Add an overload that takes an elf_symbol.  If the looked
	up symbol has no version and if the corpus contains a symbol with
	the same name and with a default version, then return that latter
	symbol if the corpus doesn't contain a symbol with the same name
	and empty version.
	* src/abg-comparison.cc
	(class_diff::ensure_lookup_tables_populated): Adjust.
	(corpus_diff::priv::ensure_lookup_tables_populated): Before
	deciding that a symbol has been added, if the symbol has a default
	version, make sure no symbol with the same name and without
	version was present in the former corpus.  Similarly, before
	deciding that a symbol has been removed, if the symbol has no
	version, make sure the latter corpus has no symbol with the same
	name and with a default version.
	* tests/data/test-diff-dwarf/test12-report.txt: Adjust.  The
	function should not be considered as added, because its symbol
	(and version) was already present in the former DSO.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-24 14:04:11 +02:00
Dodji Seketeli
bf6b1924c4 Fix a thinko in removed variables detection
It appears the comparison engine was counting more deleted variables
than necessary, due to a thinko.  Fixed thus.

	* src/abg-comparison.cc
	(corpus_diff::priv::ensure_lookup_tables_populated): Once we have
	computed a set of potentially deleted variables that turned out to
	contain variables that were actually *NOT* deleted, really take
	these into account by removing these false positives from the set
	of deleted *variables*.  We were trying to delete these from the
	set deleted *functions*; woops, I guess this was a copy & paste
	error.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-24 11:23:56 +02:00
Dodji Seketeli
47bdb5f6d3 Fix logic of type_has_non_canonicalized_subtype()
* src/abg-ir.cc (type_has_non_canonicalized_subtype): Once the
	type has been traversed, just test if the visitor has accumulated
	the 'has_non_canonical_type' property.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-24 00:52:28 +02:00
Dodji Seketeli
636202c833 Fix style issues
* include/abg-ir.h (struct ir_node_visitor): Fix the wording of
	the comment of this type.
	* src/abg-dwarf-reader.cc (build_ir_node_from_die): Fix the
	filling of the text of the comment of the code that chooses to
	perform early canonicalizing.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-24 00:45:03 +02:00
Dodji Seketeli
38a46fd0b0 Adding member type doesn't reset declaration-only-ness of a class
When reading DWARF, a declaration-only class was loosing its
declaration-only-ness just because a member type was being added.  Bad
things was then happening next because that (normally
declaration-only) class was then considered as being suitable for
early canonicalizing, while it wasn't (yet), in reality.  Its
canonicalizing should have been deferred.

This issue was spotted when comparing
kdebase-workspace-4.3.4-29.el6_6.x86_64.rpm and,
kdebase-workspace-4.3.4-30.el6_6.x86_64.rpm, using their associated
debug info.  The issue was happening precisely when comparing their
usr/lib64/kde4/kwin4_effect_builtins.so DSOs, precisely; it was
leading to a crash.

	* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir):
          Adding a new member type shouldn't remove the
          declaration-only-ness of the class.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-24 00:32:09 +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
915bf047fb Add a new corpus_diff::has_net_changes() entry point
This entry point is to test if there are still ABI changes between two
corpora after applying suppression specifications.

	* include/abg-comparison.h (corpus_diff::has_net_changes): Declare
	new member function.
	* src/abg-comparison.cc (corpus_diff::has_net_changes): Define it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-21 12:48:19 +02:00
Dodji Seketeli
0cf1828a90 Fix type synthesis to fix abicompat weak mode
While looking further in the issue Sinny Kumari reported, I realized
that the weak mode wasn't working in that example either.

It turned out that synthesizing qualified types was not working
because we were just looking them up in the binary, rather than
looking up the un-qualified underlying type and then synthezing the
resulting qualified type.

This patch just does that.

	* include/abg-fwd.h
	(synthesize_type_from_translation_unit): Declare new function.
	(synthesize_function_type_from_translation_unit): Make the
	translation_unit parameter non-const because the function needs to
	bind the life time of the synthesized function to the life time of
	the translation unit.  Make this function be a friend of
	abigail::ir::translation_unit.
	(synthesize_function_type_from_translation_unit):
	* src/abg-ir.cc (translation_unit::priv::synthesized_types_): New
	data member.
	(synthesize_type_from_translation_unit): Define new function.
	(synthesize_function_type_from_translation_unit): Make the
	translation_unit parameter non-const.  If the return is void, then
	take that in account carefuly.  Rather than just looking up the
	type of parameters and return value, synthesize them too,
	especially when they are qualified types.  Bind the life time of
	the synthesized function type to the lifetime of the translation
	unit.
	* tests/data/test-abicompat/test7-fn-changed-report-1.txt: New
	test reference output.
	* tests/test-abicompat.cc (in_out_spec): Run the harness on the
	exisiting test7-fn-changed-app and libtest7-fn-changed-libapp-v1
	but in weak mode this time.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-20 17:11:32 +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
Sinny Kumari
ab1316bcbc Display --suppressions|--suppr option in help usage
* tools/abipkgdiff.cc (display_usage): Print
	 --suppressions|--suppr <path> option in help usage

Signed-off-by: Sinny Kumari <sinny@redhat.com>
2015-07-20 12:47:07 +02:00
Dodji Seketeli
af2a94defa Fix computing the set of exported functions and varible symbols
Sinny Kumari reported that abicompat is failing to report ABI changes
on a library linked to a small test program.  It turned out that the
code that compute if a given exported function is to be kept by
looking at the white list of symbols to keep has a bug in which the
versions of the symbols of the white list were not being reset as they
should.  Fixed thus.

	* src/abg-ir.cc (elf_symbol::get_name_and_version_from_id): Always
	set the version and name of the symbol.
	*  src/abg-corpus.cc
	(corpus::exported_decls_builder::{keep_wrt_id_of_fns_to_keep,
	keep_wrt_id_of_vars_to_keep}): Reset the symbol name *and* version
	before passing it.  This is redundant with the fix in
	elf_symbol::get_name_and_version_from_id() that always set the
	symbol name and version now, but I felt it makes it easier to
	understand the fix overall.
	* tests/data/test-abicompat/libtest7-fn-changed-libapp-v{0,1}.so:
	New test input binaries.
	* tests/data/test-abicompat/test7-fn-changed-app: Likewise.
	* tests/data/test-abicompat/test7-fn-changed-{app, libapp-v0,
	libapp-v1}.c: Source code of the binary test inputs above.
	* * tests/data/test-abicompat/test7-fn-changed-{libapp-v0,
	libapp-v1}.h: Likewise.
	* tests/data/test-abicompat/test7-fn-changed-report-0.txt: Test
	input.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-abicompat.cc (int_out_specs): Add the test inputs
	above to the set of inputs this test harness has to run over.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-20 12:46:21 +02:00
Dodji Seketeli
78e7890b20 Fix the wording of description of abipkgdiff.cc again
* tools/abipkgdiff.cc: Fix the wording again.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-20 10:15:00 +02:00
Dodji Seketeli
f681c33970 Remove use of tmpnam from abilint
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>
2015-07-20 10:06:17 +02:00
Dodji Seketeli
1ddde3d9d0 Try to avoid a race condition when abipkgdiff extracts packages.
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>
2015-07-20 00:02:00 +02:00
Dodji Seketeli
77fa0621e4 Fix the wording of the description of the abipkgdiff.cc file
* tools/abipkgdiff.cc: Fix the wording of the description.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-19 19:54:57 +02:00
Dodji Seketeli
78293108f2 Fix the --suppressions manual doc for abidiff
* doc/manuals/abidiff.rst: Talk about the --suppr shortcut of the
	--suppressions option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-19 19:54:57 +02:00
Dodji Seketeli
7cae79e0d8 On changed fn, show symbol info when name is different from linkage name in C
In change reports for function sub-type changes, for the C language,
when the name of the function is different from its linkage name, even
when the function symbol has no aliases, show the symbol information
of the function.

	* include/abg-ir.h (translation_unit::language): New enum type.
	(translation_unit::{get_language, set_language}): Declare new
	accessors.
	(translation_unit_language_to_string)
	(string_to_translation_unit_language, is_c_language)
	(is_cplus_plus_language): Declare new functions.
	* src/abg-ir.cc (translation_unit::priv::language_): New data
	member.
	(translation_unit::priv::language_): Initialize it.
	(translation_unit::{set_language, get_language}): Define new
	member functions.
	(translation_unit_language_to_string)
	(string_to_translation_unit_language, is_c_language)
	(is_cplus_plus_language): Define new functions.
	* src/abg-dwarf-reader.cc (dwarf_language_to_tu_language): New
	static function.
	(build_translation_unit_and_add_to_ir): Read the language of the
	translation unit.
	* src/abg-comparison.cc (corpus_diff::report): When reporting a
	change in a function sub-type, if we are in C language translation
	unit, if the function name is different from its linkage name,
	even if the symbol doesn't have any alias, show symbol
	information.
	* src/abg-reader.cc (read_translation_unit_from_input): Read the
	'language' property of the translation unit, if present.
	* src/abg-writer.cc (write_translation_unit): Write the 'language'
	property to the translation unit, if present.
	* tests/data/test-read-dwarf/test0.abi: Adjust for the new
	'language' property of the 'abi-instr' element.
	* tests/data/test-read-dwarf/test1.abi: Likewise.
	* tests/data/test-read-dwarf/test2.so.abi: Likewise.
	* tests/data/test-read-dwarf/test3.so.abi: Likewise.
	* tests/data/test-read-dwarf/test4.so.abi: Likewise.
	* tests/data/test-read-dwarf/test5.o.abi: Likewise.
	* tests/data/test-read-dwarf/test6.so.abi: Likewise.
	* tests/data/test-read-dwarf/test7.so.abi: Likewise.
	* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi:
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-19 19:52:01 +02:00
Dodji Seketeli
80dc31f540 Add --suppressions to abipkgdiff
* 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>
2015-07-19 19:52:01 +02:00
Dodji Seketeli
f3ed9dfa92 Support file_name_regexp and soname_regexp in supp-specs
With this patch it's now possible to express the soname or name of the binary
file that contains the ABI artifacts the suppression specifications
should apply to.

	* include/abg-comparison.h (suppression_base::priv_): Make this
	pimpl member protected.
	(suppression_base::set_file_name_regex_str)
	(get_file_name_regex_str, get_soname_regex_str)
	(set_soname_regex_str): Declare new accessors.
	(function_suppression::{suppresses_function,
	suppresses_function_symbol}): Take a diff_context_sptr.
	(variable_suppression::{suppresses_variable,
	suppresses_variable_symbol}): Take a diff_context_sptr.
	* src/abg-comparison.cc
	(suppression_base::priv::{file_name_regex_str_, file_name_regex_,
	soname_regex_str_, soname_regex_}): Define new data members.
	(suppression_base::priv::get_file_name_regex_str)
	(get_soname_regex_str): Define new member functions.
	(suppression_base::set_file_name_regex_str)
	(get_file_name_regex_str, get_soname_regex_str)
	(set_soname_regex_str): Define new accessors.
	(type_suppression::suppresses_diff): Evaluate file_name_regexp and
	soname_regexp.
	(read_type_suppression): Fix the reading of the "label" property.
	Read the file_name_regexp and soname_regexp properties.
	(function_suppression::{suppresses_function,
	suppresses_function_symbol): Take a diff_context_sptr parameter.
	Evaluate file_name_regexp and soname_regexp properties.
	(function_suppression::suppresses_diff): Adjust for the api change
	of function_suppression::suppresses_function().
	(read_function_suppression): Read the file_name_regexp and
	soname_regexp properties.
	(variable_suppression::suppresses_variable): Take a
	diff_context_sptr parameter and evaluate file_name_regexp and
	soname_regexp properties.
	(variable_suppression::suppresses_variable_symbol): Likewise.
	(variable_suppression::suppresses_diff): Adjust for the api change
	of variable_suppression::suppresses_variable().
	(read_variable_suppression): Read the file_name_regexp and
	soname_regexp properties.
	(function_is_suppressed, variable_is_suppressed): Take a
	diff_context_sptr parameter.
	(corpus_diff::priv::apply_suppressions_to_added_removed_fns_vars):
	Adjust.
	* doc/manuals/libabigail-concepts.rst: Document file_name_regexp
	and soname_regexp in the manual.
	* tests/data/test-diff-suppr/libtest24-soname-v{0,1}.so: New test
	binary input files.
	* tests/data/test-diff-suppr/test24-soname-report-{0,4}.txt: New
	test input files.
	* tests/data/test-diff-suppr/test24-soname-suppr-{0,4}.txt:
	Likewise.
	* tests/data/test-diff-suppr/test24-soname-v{0,1}.cc: Source code
	of the binary test input files above.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-diff-suppr.cc (in_out_spec): Add the new test inputs
	to the set of tests this harness has to run over.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-19 19:48:51 +02:00
Dodji Seketeli
c599f90fea Fix possible crash in suppression evaluation
When evaluating the way the diff node has been reached, do not crash
on diff nodes that are pointer_diff to something else but a type diff,
because there can be pointers to distinct_diff nodes, for instance.

	* src/abg-comparison.cc (type_suppression::suppresses_diff): When
	evaluating the reach_kind property, do not crash on diff nodes
	that are pointer_diff or reference_diff to something else but a
	type diff.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-18 10:28:54 +02:00
Dodji Seketeli
018a9345d6 Fix '--' being rendered as '-' in html manuals
* doc/manuals/abicompat.rst: Quote options as verbatim.
	* doc/manuals/abidiff.rst: Likewise.
	* doc/manuals/abidw.rst: Likewise.
	* doc/manuals/abilint.rst: Likewise.
	* doc/manuals/abipkgdiff.rst: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-17 11:14:46 +02:00
Dodji Seketeli
7f67f2573d Fix the --verbose option
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>
2015-07-17 10:11:36 +02:00
Dodji Seketeli
317f4e1ff3 Cleanup the output for added/removed binaries
* 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>
2015-07-17 10:11:24 +02:00
Dodji Seketeli
3b85f2864d Avoid redundant diff report messages by default.
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>
2015-07-17 10:11:20 +02:00
Dodji Seketeli
71a5e0762e Support comparing only shared libraries
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>
2015-07-17 10:11:15 +02:00
Dodji Seketeli
2da9825c59 Comment functions and types of abipkgdiff
* 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>
2015-07-17 10:11:08 +02:00
Sinny Kumari
260b92f5df Add regression tests for abipkgdiff tool
Add tests for the abipkgdiff tool.  The tests runs abipkgdiff on RPM
packages. RPMs for test data are taken from Fedora koji build with
build id - 106158 and 648058

	* tests/Makefile.am: Build new runtestdiffpkg regression test
	* tests/data/Makefile.am: Add new test files to source
	* tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64.rpm:
	Test data for abipkgdiff tool
	* tests/data/test-diff-pkg/dbus-glib-0.80-3.fc12.x86_64.rpm: Likewise
	* tests/data/test-diff-pkg/dbus-glib-debuginfo-0.104-3.fc23.x86_64.rpm:
	Likewise
	* tests/data/test-diff-pkg/dbus-glib-debuginfo-0.80-3.fc12.x86_64.rpm:
	Likewise
	* tests/data/test-diff-pkg/test-rpm-report-0.txt: Expected test output
	* tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise
	* tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise
	* tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise
	* tests/data/test-diff-pkg/test-rpm-report-4.txt: Likewise
	* tests/test-diff-pkg.cc: New file

Signed-off-by: Sinny Kumari <sinny@redhat.com>
2015-07-17 10:10:21 +02:00
Dodji Seketeli
dea76e9f5f Add a manual for abipkgidiff
* doc/manuals/abipkgdiff.rst: New manual file.
	* doc/manuals/libabigail-tools.rst: Refer to the manual for
	abipkgdiff.
	* doc/manuals/Makefile.am: Add the new manual file to source
	distribution.
	* doc/manuals/conf.py: Add the manual for abipkgdiff to section 1.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-17 10:10:17 +02:00
Dodji Seketeli
21bf2a87d8 Comment functions and types of abipkgdiff
* 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>
2015-07-17 10:10:07 +02:00
Dodji Seketeli
080218e6a1 Various style fixes
* 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>
2015-07-17 10:10:03 +02:00
Dodji Seketeli
5df40e91ce Remove the last direct fiddling with ELF from abipkgdiff.cc
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>
2015-07-17 10:09:57 +02:00
Dodji Seketeli
e96f9f3690 Add a --verbose option to abipkgdiff
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>
2015-07-17 10:09:53 +02:00
Dodji Seketeli
3aa51dac47 Use the library to implement ABI comparison in abipkgdiff
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>
2015-07-17 10:09:43 +02:00