Commit Graph

1177 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
1bb3461d1d Bug 19638 - DWARF reader fails to link clone function to its declaration
There are three mains issues that cause the reported problem.  Let's
look at them closely.

Suppose there is a DIE of a member function Klass::clone_of_foo, which
is a clone of the DIE of the function Klass_foo, which is the concrete
instance of the DIE of the declaration of Klass::foo.

When libabigail's DWARF reader sees the DIE for Klass::clone_of_foo,
it fails to get the context of the declaration of Klass::clone_of_foo
-- which is Klass::foo.

So, in the model built by libabigail, the symbol of
Klass::clone_of_foo never gets associated to Klass::foo.  It thus
looks like Klass::clone is never defined.  It also looks like that
symbol is unreferenced.  From there, a number of bad things happen.
This is the first root cause of the reported problem.  I call it issue
1/.

2/ While looking at this, I noticed that libabigail uses the
underlying symbol name of a given function as the linkage name of that
function, rather than using the value of the DW_AT_linkage_name DWARF
property.  This usually works, until the the function has a symbol
which has several aliases.  In that case, depending on the symbol
alias that is used, a given function can have different linkage names.
This causes problems later at comparison time.  This is issue 2/.

3/ I also noticed that in the libabigail model, even if type Klass
does have all its member functions (including Klass::foo) defined in
in a particular translation unit TU1 , the same Klass in another
translation unit TU2 might not have that Klass::foo defined, just
because that function is not used in TU2.  So after type
canonicalization, if the version of Klass that is kept is the one from
TU2, we end up with a type Klass *NOT* having Klass::foo defined.
Sometimes, it's just that one member function in the canonical type
doesn't have any underlying symbol, whereas the same member function
in another type of the same class of equivalence as the canonical type
does have that an underlying symbol.  This is issue 3/.

To address issue 1/ the patch fixes build_ir_node_from_die, in the
case where a DW_TAG_subprogram DIE is being handled.  It fixes the
case of finding the root interface of the clone of a function
definition.  The patch also fixes a bug in build_function_decl that
prevents it to update the linkage name of a function, *if* that
function already had one.  This was preventing build_function_decl to
adjust the linkage name of a function which is a clone of an original
function which already had a non-empty linkage name.

To address 2/ the patch makes function_decl::get_id return the linkage
name of the function, *if* it exists (rather than primarily returning
the ID of the underlying symbol).

To address 3/ the patch implements the copying of member functions or
underlying function symbols missing from the canonical type -- but
otherwise present in the type that has just been canonicalized.

	* include/abg-ir.h (decl_base::set_linkage_name): Make this member
	function virtual.
	(class_decl::string_mem_fn_ptr_map_type): Define new member type.
	(class_decl::find_member_function): Declare new member function.
	(copy_member_function): Declare new function.  Declare it as
	friend of class_decl.
	(method_decl::set_linkage_name): Declare an overload for this
	virtual function.
	* src/abg-dwarf-reader.cc (build_function_decl): Allow updating of
	linkage_name even if the linkage_name was already defined.
	(build_ir_node_from_die): In the case DW_TAG_subprogram, make the
	lookup of scope of the DIE work even if it has both an abstract
	origin and a specification (DW_AT_abstract_origin and
	DW_AT_specification).
	* src/abg-ir.cc (maybe_adjust_canonical_type): Define new
	function.
	(canonicalize): Use it.
	(function_decl::get_id): Return the linkage name first, if it
	exist.
	(class_decl::priv::mem_fns_map_): New data member.
	(class_decl::find_member_function): Define new member function.
	(class_decl::method_decl::set_linkage_name): Likewise.
	(class_decl::add_member_function): Update the new data member
	class_decl::priv::mem_fns_map_.
	(copy_member_function): Define new static function.
	* tests/data/test-abidiff/test-PR18791-report0.txt: Adjust.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Adjust.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Adjust.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Adjust.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Adjust.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Adjust.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-17 16:30:01 +01:00
Dodji Seketeli
f8761a48af Add function lookup by linkage name to libabigail::corpus
Until now, it was not possible to lookup a function declaration from a
corpus, using a symbol name for the function.  This patch adds that
functionnality, which is useful, at least for debugging purposes.

	* include/abg-corpus.h (corpus::lookup_functions): Declare new
	member function.
	* src/abg-corpus.cc (class corpus::exported_decls_builder::priv):
	Make class corpus be a friend of this type.
	(corpus::exported_decls_builder::priv::add_fn_to_id_fns_map): Fix
	a thinko that was preventing the fn_id -> functions map from ever
	being filled.  Fix this function to make it associate each aliases
	of a given function to the function, in the hash table.
	(corpus::lookup_functions): Define new member function.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-17 14:20:43 +01:00
Dodji Seketeli
421aa4ab5f Fix style cleanups
* include/abg-ir.h (method_type::{method_type, set_class_type,
	get_type, set_type}): Use type_base_sptr and class_decl_sptr
	instead of the full non-typedefed name.
	(method_type):Do some cleanups in the definition of the
	convenience typedefs.
	* src/abg-ir.cc (method_type::{method_type, set_class_type,
	get_type, set_type}): Use type_base_sptr and class_decl_sptr
	instead of the full non-typedefed name.
	* src/abg-writer.cc (write_class_decl): Add a comment.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-17 13:08:24 +01:00
Dodji Seketeli
1eecd89ee1 Bug 19619 - failing to suppress added aliased function reports for C++
Libabigail is designed to avoid suppressing a change report about an
added (or removed) function if that function has aliases.  For the
change report to be suppressed, the condition of the suppression
specification must match all the aliases of the symbol of the
function.  This is to avoid suppressing change reports about aliases
by error.

If the binary results from a C program, the name of the function is
the same as the name of its underlying symbol.  So if the condition of
the suppression specification is the property "name_regexp", the value
of the condition can be made to match the names of all the aliases of
the underlying symbol of the function.  In that case, if value of the
property name_regexp does *NOT* match all the aliases, then it's OK
for the "change report suppression sub-system" to avoid suppressing
the change report.

But if the binary results from a C++ program, the name of the function
is *different* from the name of its underlying symbol.  If the
condition of the suppression specification is the property
"name_regexp", there is *NO* way for the user to provide a value which
matches *ANY* of the names of the underlying function symbols while
also matching the name of the function.  So in this case, the "change
report suppression sub-system" should assume that the user wants to
suppress the change reports about all the aliases of the function.

In this problem report, the issue is that in the case of a C++ program
for which the user provided the "name_regexp" property, Libabigail is
expecting the "name_regexp" to match all the aliased symbol
names. Which is not possible.  So the suppression specification is not
suppressing the change report about the added function, just because
the function has an alias.

This patch fixes the issue by taking into account the difference
between languages where the name of the function is the same as the
name of their underlying symbol and languages where it is not.

	* src/abg-comparison.cc
	(function_suppression::suppresses_function): Make the evaluation
	of the "name" and "name_regexp" consider the cases of languages in
	which the function name is the same as the symbol name and the
	case of languages in which it is not.  In the former case, all
	symbol alias names must be matched.  In the latter case, if "name"
	and "name_regexp" match the function name, the suppression
	specification is considered to match the report about the function
	change.  Also, use the elf_symbol::is_main_symbol() predicate to
	test for the symbol being a main symbol, rather than using
	error-prone pointer equality.
	* tests/data/test-diff-suppr/test27-add-aliased-function-0.suppr:
	New test input.
	* tests/data/test-diff-suppr/test27-add-aliased-function-1.suppr: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-2.suppr: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-3.suppr: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-4.suppr: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-report-4.txt: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-report-5.txt: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-v0.cc: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-v0.o: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-v1.cc: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-v1.o: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-0.suppr: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-1.suppr: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-2.suppr: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-3.suppr: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-4.suppr: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-5.suppr: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-report-4.txt: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-report-5.txt: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-report-6.txt: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-v0.c: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-v0.o: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-v1.c: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-v1.o: Likewise.
	* tests/data/Makefile.am: Add the new test material above to the
	source distribution.
	* tests/test-diff-suppr.cc: Add the new test inputs above to this
	test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-13 08:47:41 +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
5a80db04f4 Add a comment about libabigail needing elfutils 0.159 at least.
* configure.ac: Add a comment saying that we require at least
	elfutils 0.159.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-11 12:37:03 +01:00
Dodji Seketeli
0cb928083d Talk about mandatory properties in suppress_* directives
The documentation doesn't talk about the mandatory properties in the
suppress_type, suppress_function and suppress_variable sections.

Fixed thus.

	* doc/manuals/libabigail-concepts.rst: Talk about the mandatory
	properties for suppress_type, suppress_function and
	suppress_variable directives.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-11 11:41:42 +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
ef2211831f Use proper WIFEXITED and WEXITSTATUS macros to get exit code
It turns out we were wrongly getting the exit code of some processes
being executed by the "system()" invocation.  The patch uses the
WIFEXITED and WEXITSTATUS macro as documented in the man page for
"system".

	* tests/test-diff-dwarf-abixml.cc (main): Use WIFEXITED and
	WEXITSTATUS macros to get the return code of the abidiff program.
	* tests/test-diff-filter.cc (test_task::perform): Likewise.
	* tests/test-diff-pkg.cc (main): Likewise.
	* tests/test-diff-suppr.cc (main): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-10 22:06:01 +01:00
Dodji Seketeli
4b7e295b20 Bug 19596 - Incorrect exit status for incompatible ABI change
The comparison engine doesn't take virtual offset changes into account
when deciding if a diff node carries an incompatible change.  This is
obviously an oversight.

Fixed thus.

	* include/abg-comparison.h (enum diff_category): Adjust the
	comment for enumerator VIRTUAL_MEMBER_CHANGE_CATEGORY; changes of
	this category are incompatible ABI changes.
	(corpus_diff::diff_stats::num_func_with_virtual_offset_changes):
	Declare new accessors.
	* src/abg-comparison.cc
	(corpus_diff::diff_stats::priv::num_func_with_virt_offset_changes):
	New data member.
	(corpus_diff::diff_stats::priv::priv): Initialize the new data
	member.
	(corpus_diff::diff_stats::num_func_with_virtual_offset_changes):
	Define new accessors.
	(corpus_diff::priv::apply_filters_and_compute_diff_stats): Use the
	new accessor to set the number of functions with virtual offset
	changes onto the stats data structure.
	(corpus_diff::has_incompatible_changes): Take functions with
	virtual offset changes into account.
 	* tests/test-abidiff-exit.cc: New test harness to test for exit
	codes of abidiff.
	* tests/Makefile.am: Build the new test harness runtestabidiff
	from the test-abidiff-exit.cc source file.
	* tests/data/test-abidiff-exit/test1-voffset-change-report0.txt:
	New reference test output.
	* tests/data/test-abidiff-exit/test1-voffset-change-v0.cc: New
	test input source code.
	* tests/data/test-abidiff-exit/test1-voffset-change-v0.o: New test input.
	* tests/data/test-abidiff-exit/test1-voffset-change-v1.cc: New
	test input source code.
	* tests/data/test-abidiff-exit/test1-voffset-change-v1.o: New test input.
	* tests/data/Makefile.am: tests/data/Makefile.am: Add the new test
	inputs above to the source distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-10 21:31:53 +01:00
Dodji Seketeli
31aef952c8 Fix synthesizing of reference type
Libabigail fails to synthesize a non-existing reference type to an
existing type.

This is similar to the previous commit "2f88edd Fix synthesizing of
pointer type" which, obviously dealt with pointer types.

This patch adds support for synthesizing a reference type to an
existing type.

	* src/abg-ir.cc (synthesize_type_from_translation_unit): Support
	synthesizing reference types.
	* tests/data/test-abicompat/libtest9-fn-changed-v0.so: Add new
	test input.
	* tests/data/test-abicompat/libtest9-fn-changed-v1.so: Likewise.
	* tests/data/test-abicompat/test9-fn-changed-app: Likewise.
	* tests/data/test-abicompat/test9-fn-changed-app.cc: : Likewise.
	* tests/data/test-abicompat/test9-fn-changed-report-0.txt: Likewise.
	* tests/data/test-abicompat/test9-fn-changed-v0.cc: Likewise.
	* tests/data/test-abicompat/test9-fn-changed-v0.h: Likewise.
	* tests/data/test-abicompat/test9-fn-changed-v1.cc: Likewise.
	* tests/data/test-abicompat/test9-fn-changed-v1.h: Likewise.
	* tests/data/Makefile.am: Add the new material to source
	distribution.
	* tests/test-abicompat.cc (in_out_specs): Add the new test inputs
	to the test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-04 11:26:22 +01:00
Dodji Seketeli
2f88edd3b3 Fix synthesizing of pointer type
Libabigail fails to to synthesize a non-existing pointer type to an
existing type.

This makes abicompat fail in weak mode when trying to detect changes
to a function type where the parameter is a pointer to a structure
which changed.  In the application, the function is invoked and a
pointer to the structure is passed to it.  It appears that the type of
structure is defined in the debug info of the application, but not the
pointer to that structure.  So abicompat needs to synthesize that
pointer to struct in order to synthesize the type of the function, and
so, compare it to the type of the function coming from the library.

It appears that synthesizing a pointer type (to an existing type) is
not supported.  Only synthesizing qualified type was supported.

This patch adds support for that and thus fixes the abicompat test
case that is attached.

	* include/abg-ir.h: Update copyright.
	* src/abg-ir.cc (synthesize_type_from_translation_unit): Support
	synthesizing pointer types.

	* tests/data/test-abicompat/libtest8-fn-changed-libapp-v0.so: New
	test input.
	* tests/data/test-abicompat/libtest8-fn-changed-libapp-v1.so: Likewise.
	* tests/data/test-abicompat/test8-fn-changed-app: Likewise.
	* tests/data/test-abicompat/test8-fn-changed-app.c: Likewise.
	* tests/data/test-abicompat/test8-fn-changed-libapp-v0.c: Likewise.
	* tests/data/test-abicompat/test8-fn-changed-libapp-v0.h: Likewise.
	* tests/data/test-abicompat/test8-fn-changed-libapp-v1.c: Likewise.
	* tests/data/test-abicompat/test8-fn-changed-libapp-v1.h: Likewise.
	* tests/data/test-abicompat/test8-fn-changed-report-0.txt: Likewise.
	* tests/data/Makefile.am: Add the new test input files to source
	distribution.
	* tests/test-abicompat.cc (in_out_specs): Add the new test inputs
	above to the test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-03 13:00:51 +01:00
Mark Wielaard
d01c536a5e Remove defined but not used functions pointed out by GCC6.
abg-ir.cc:6041:1: warning: ‘abigail::ir::decl_base_sptr abigail::ir::convert_node_to_decl(std::tr1::shared_ptr<_Tp>) [with NodeKind = abigail::ir::decl_base]’ defined but not used [-Wunused-function]
 convert_node_to_decl(decl_base_sptr node)
 ^~~~~~~~~~~~~~~~~~~~

abg-ir.cc:5990:1: warning: ‘const string& abigail::ir::get_node_name(std::tr1::shared_ptr<_Tp>) [with NodeKind = abigail::ir::decl_base]’ defined but not used -Wunused-function]
 get_node_name(decl_base_sptr node)
 ^~~~~~~~~~~~~

	* src/abg-ir.cc (convert_node_to_decl(decl_base_sptr)): Remove
	definition.
	(get_node_name(decl_base_sptr)): Likewise.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2016-01-28 09:33:15 +01:00
Mark Wielaard
eea4bf067b Make make more silent.
Silent rules already are the default, but automake and make both still
tell which directory is being entered/build. Disable printing from make.

	* Makefile.am (AM_MAKEFLAGS): Set --no-print-directory.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2016-01-28 09:18:05 +01:00
Mark Wielaard
6b0b68fbf7 Fix GCC6 -Wmisleading-indentation warnings.
These two issues pointed out by GCC6 are harmless, but might confuse
a reader of the code. Just properly indent the code.

	* src/abg-dwarf-reader.cc (find_import_unit_point_before_die):
	Properly indent code after if clause.
	* src/abg-ini.cc (write_property_value): Properly indent return
	statement after else clause.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2016-01-28 09:00:46 +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
35b7a928ef Do not crash when looking up a type from global scope
* src/abg-ir.cc (lookup_type_in_scope): Gently Handle empty access
	path.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-27 13:44:01 +01:00
Dodji Seketeli
8c1acaeb08 Comparing aliases of the same symbol must be done by pointer
Different aliases of the same symbol are considered equal.  This is at
least how the elf_symbol::operator== is intended to work.

What makes the different aliases be different is their pointer value.
This patch fixes several spots where these assumptions are not
respected.

	* src/abg-ir.cc (elf_symbol::operator==): Fix thinko and
	indentation.  What was I thinking ...
	(elf_symbol::add_alias)
	(compute_aliases_for_elf_symbol): Do not compare aliases using the
	equality operator, because it considers all aliases of a given
	symbol as equal.  Rather, use elf_symbol::is_main_symbol() to test
	if an alias is the main symbol alias.
	* src/abg-comp-filter.cc (function_name_changed_but_not_symbol):
	Likewise.
	* src/abg-corpus.cc
	(corpus::priv::build_unreferenced_symbols_tables): Likewise.
	* src/abg-writer.cc (write_elf_symbol_aliases): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-25 17:02:52 +01:00
Dodji Seketeli
066ebbdf0e Bug 19204 - libabigail aborts on DWARF referencing non-existing DIE
In this bug the DWARF reader tries to get the parent of a DIE
(referred-to by its offset) which is not defined in the debug info.
The DIE is not defined, but it's referred-to by another DIE of the
debug info.  This definitely looks like a faulty DWARF.

The DWARF reader aborts because, obviously, it cannot get the parent
DIE of a DIE that is not defined.

This patch changes the behaviour of the DWARF reader in this case.
Rather than aborting, the DWARF reader just drops the DIE (which
refers to a non-existing DIE) on the floor.  It thus do not abort on
such faulty DWARF anymore.

	* src/abg-dwarf-reader.cc (get_parent_die): If we couldn't find
	the parent of a given DIE, return false, do not abort.  Also,
	assert that if we don't find the parent of a DIE in the main debug
	info, we don't find it in the alternate debug info either (and
	vice versa).  This is because I'd like to abort on cases where we
	look for a DIE in the wrong debug info; those cases are likely to
	be hint that the DWARF reader is doing something wrong which ought
	to be investigated and fixed.
	(get_scope_for_die): If we couldn't get the parent of the DIE,
	then return a nil scope.
	* tests/data/test-types-stability/pr19204-libtcmalloc.so.4.2.6-xlc:
	New test binary input.
	* tests/data/Makefile.am: Add the new binary test input to the
	source distribution.
	* tests/test-types-stability.cc (elf_paths): Account for the new
	binary input.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-21 10:48:32 +01:00
Dodji Seketeli
11c89cad3e Pass parm of elf_symbol::add_alias by reference
* include/abg-ir.h (elf_symbol::add_alias): Pass parameter by
	reference.
	* src/abg-ir.cc (elf_symbol::add_alias): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-20 14:02:04 +01:00
Dodji Seketeli
640b3a2f59 Bug 19141 - Libabigail doesn't support common ELF symbols
Libabigail's internal representation of elf symbols fails to account
for common symbols in relocatable files.  There can be several common
symbols of the same name (defined in a section of SHN_COMMON kind).
In that case, Libabigail wrongly considers these multiple instances of
the same common symbol as being alias, and that breaks some
basic assumptions about aliases.  Oops.

This patch adds support for the common symbols (and the fact that
relocatable files can have several instances of the same common
symbol) and amends the ELF reader to make it properly represent those.
	* include/abg-ir.h (elf_symbol::elf_symbol): Take a new flag to
	say if the symbol is common.
	(elf_symbol::{is_common_symbol, has_other_common_instances,
	get_next_common_instance, add_common_instance}): New member functions.
	* src/abg-ir.cc (elf_symbol::priv::{is_common_,
	next_common_instance_): New data members.
	(elf_symbol::priv::priv): Adjust.
	(elf_symbol::{elf_symbol, create}): Take a new flag to say if the
	symbol is common.
	(textually_equals): Adjust to account for symbol common-ness.
	(elf_symbol::{is_common_symbol, has_other_common_instances,
	get_next_common_instance, add_common_instance}): Define new member
	functions.
	(elf_symbol::add_alias): Drive-by fix; compare symbols using
	pointer value.  Value comparison is not necessary.
	* src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab)
	(lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_symtab)
	(read_context::lookup_elf_symbol_from_index): Adjust the creation
	of the symbol to account for common-ness.
	(read_context::load_symbol_maps): Recognize instances of a given
	common symbol and represent them as such.  Do not mistake this
	with symbol aliases.
	* src/abg-reader.cc (build_elf_symbol): Adjust the creation of the
	symbol to account for common-ness.
	* src/abg-writer.cc (write_elf_symbol): Adjust symbol
	serialization to account common-ness.
	* tests/data/test-types-stability/pr19141-get5d.o: Add new test
	binary input.
	* tests/data/test-types-stability/pr19142-topo.o: Likewise.
	* tests/data/Makefile.am: Add the new test inputs to source distribution.
	* tests/test-types-stability.cc (elf_paths): The the new test
	inputs into account.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-20 13:37:52 +01:00
Dodji Seketeli
c3869ecc7b Bug 19434 - invalid character in attribute value
* include/abg-tools-utils.h (string_is_ascii_identifier): Declare
	new function.
	* src/abg-tools-utils.cc (string_is_ascii_identifier): Define new function.
	* src/abg-dwarf-reader.cc (build_function_type): Discard parameter
	name if it's made of non-identifier ascii characters.
	* tests/data/test-types-stability/pr19434-elf0: New test binary input file.
	* tests/data/Makefile.am: Add the new test input to source distribution.
	* tests/test-types-stability.cc: Test the new test input into account.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-18 18:23:19 +01:00
Dodji Seketeli
5e171c530c Sort the tests run in tests/ by running the slowest ones first
This speeds up the tests when they are run in parallel.

	* tests/Makefile.am: Sort the tests  by running the slowest ones
	first.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-18 18:23:18 +01:00
Dodji Seketeli
f275939df2 Use worker threads pattern to speed up some tests
We are going to need to speed up more and more tests, and coding directly
with libpthread for that can be tedious and bug-prone.  So I devised an
implementation for the worker threads design pattern instead, and used
it to speed up some tests.

	* include/Makefile.am: Add the new abg-workers.h to source
	distribution.
	* include/abg-workers.h: New file.
	* src/Makefile.am: Add the new abg-worker.cc to source
	distribution.
	* src/abg-workers.cc: New file.
	* tests/test-utils.cc: Update copyright.  Make get_src_dir() and
	get_build_dir() return a const char*, as opposed to returning a
	string.  Make that const char reside in thread local storage, so
	that two concurrent threads can safely call these functions in
	parallel, without any race.
	* tests/test-utils.h: Make get_src_dir() and get_build_dir()
	return a const char*, as opposed to returning a string.
	* tests/test-abicompat.cc: Update copyright.  Adjust for
	get_src_dir() and get_build_dir() change.
	* tests/test-abidiff.cc: Likewise.
	* tests/test-alt-dwarf-file.cc: Likewise.
	* tests/test-core-diff.cc: Likewise.
	* tests/test-diff-dwarf-abixml.cc: Likewise.
	* tests/test-diff-dwarf.cc: Likewise.
	* tests/test-diff-pkg.cc: Likewise.
	* tests/test-diff-suppr.cc: Likewise.
	* tests/test-lookup-syms.cc: Likewise.
	* tests/test-read-dwarf.cc: Likewise.
	* tests/test-read-write.cc: Likewise.
	* tests/test-types-stability.cc: Likewise.  Use the new task queue
	type to run these tests in parallel.
	* tests/test-diff-filter.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-18 18:23:18 +01:00
Ondrej Oprala
c8c7a3b5e7 Escape the value of the filepath attribute.
* src/abg-writer.cc (write_location): Sanitize the filepath with
	xml::escape_xml_string().
	(write_translation_unit): Likewise.
	(write_corpus_to_native_xml): Likewise.
	* tests/data/test-types-stability/pr19433-custom0: Add a new test file.
	* tests/test-types-stability.cc: Add the test file to the test harness.
	* tests/data/Makefile.am: Add the new test file to the list.

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2016-01-18 12:18:19 +01:00
Dodji Seketeli
64375c64d3 Make enum values take 64 bits on all platforms
The is still some changes in the way values of enumerators are
represented in 32 and 64 bits systems.  This is because the type of
enumerators is size_t which 32 bits on 32 bits systems and 64 bits on
64 bits systems.  The problem is, the output of, abidw can thus be
different on 32 and 64 bits, making some tests output be different on
these platforms.

This patch thus uses uint64_t to represent enumerator values on all
platforms.

	* include/abg-ir.h: Include stdint.h for int64_t.
	(enumerator::enumerator): Take an int64_t value for the value of
	the enumerator.
	(enumerator::{s,g}et_value): Take/return an int64_t value.
	* src/abg-ir.cc (enum_type_decl::enumerator::priv): Store the
	value in an int64_t.
	(enumerator::priv::priv): Take a int64_t for the value.
	(enum_type_decl::enumerator::enumerator): Likewise.
	(enum_type_decl::enumerator::{s,g}et_value): Take/returnan int64_t
	value.
	* src/abg-dwarf-reader.cc (die_unsigned_constant_attribute): Take
	an uint64_t value.
	(die_signed_constant_attribute): Take an int64_t value.
	(die_location, die_size_in_bits, die_access_specifier)
	(die_virtuality, die_is_virtual, die_is_declared_inline)
	(build_translation_unit_and_add_to_ir, build_type_decl)
	(build_enum_type, build_pointer_type_def, build_array_type):
	Adjust.
	* src/abg-reader.cc (build_enum_type_decl): Adjust.
	* src/abg-writer.cc (write_enum_type_decl): Do not cast the result
	of enumerator::get_value() anymore, it's value is now a int64_t.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-11 11:22:39 +01:00
Dodji Seketeli
3422aaf1c6 Include missing <algorithm> to abg-dwarf-reader.cc
Turns out without this include the file won't compile on el6/g++
4.4.7, because std::lower_bound won't be found.  Woops.

Fixed thus.

	* src/abg-dwarf-reader.cc: Add missing <algorithm> include file.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-08 23:54:46 +01:00
Dodji Seketeli
5c8c049e70 Bug 19138 - Failure to relate variables address from DWARF and ELF
In this problem report libabigail's DWARF reader wrongly looks up the
address of variables (that it got from DWARF) in the .bss section of
the ELF file.  But then, in these files (generated by the Intel C++
compiler) the variables we are looking at have their addresses in the
.data1 section.

This patch changes the DWARF/ELF reader to make it look for variable
addresses in .data, .data1, .rodata and .bss sections, as it should
be.

	* include/abg-dwarf-reader.h (elf_type::ELF_TYPE_RELOCATABLE): New
	enumerator.
	* src/abg-dwarf-reader.cc (find_section): Factorize this from ...
	(find_text_section, find_bss_section): ... these.
	(find_rodata_section, find_data_section, find_data1_section):
	Define new static functions.
	(elf_file_type): Move this static function definition up.
	(read_context::{get_elf_file_type, address_is_in_section,
	get_data_section_for_variable_address}): New member functions.
	(read_context::maybe_adjust_fn_sym_address): Adjust comment.
	Adjust to use the new
	read_context::get_data_section_for_variable_address().
	* tests/data/test-types-stability/pr19138-elf0: New test input
	binary.
	* tests/data/Makefile.am: Add the new test input binary to the
	test suite.
	* tests/test-types-stability.cc (elf_paths): Take it into account.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-08 22:38:58 +01:00
Dodji Seketeli
5728d928c4 Bump version revision to 1.0.rc3
* configure.ac: Change version_revision to rc3

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-08 12:18:18 +01:00
Dodji Seketeli
a619a8dcff Add a release announcement text pattern
* release-text-template.txt: New file.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-08 12:15:30 +01:00
Dodji Seketeli
b618da3869 Upate build instructions on the website
Now that we release tarballs, this patch updates the website for
instructions about how to compile them.

	* doc/website/mainpage.txt: Add instruction about how to build
	tarballs.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-08 10:02:51 +01:00
Dodji Seketeli
c573e59372 Update website link for 1.0.rc2
* doc/website/mainpage.txt: Update tarball link for 1.0.rc2

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-07 16:25:29 +01:00
Dodji Seketeli
c918d5a533 Update ChangeLog before 1.0.rc2
* ChangeLog: Update with make update-changelog

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-07 13:05:44 +01:00
Dodji Seketeli
8475633554 Update NEWS for 1.0.rc2
* NEWS: Update.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-07 13:05:44 +01:00
Dodji Seketeli
068a974774 Fix tests/data/Makefile.am glitch
* tests/data/Makefile.am: Fix a faulty file path.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-07 13:02:04 +01:00
Dodji Seketeli
03808c483a Lexicographically sort added/removed base classes in change report
Until now, added and removed base classes were not sorted in class
change reports. This causes differences change reports when running
the tests on different platorms.  This patch fixes that.

	* src/abg-comparison.cc (sort_string_base_diff_sptr_map): Define
	new static function.
	(struct base_spec_comp): Define new type.
	(class_diff::priv::sorted_{deleted,inserted}_bases_): New data
	members.
	(class_diff::ensure_lookup_tables_populated): Sort the deleted and
	inserted base classes.
	(class_diff::report): Use the sorted set of deleted/inserted base
	classes in the report.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-07 12:50:46 +01:00
Dodji Seketeli
6f00afe353 Fix regression on the support for alternate debug info files
My commit "5a8c000 Bug 19355 - Libabigail slow on r300_dri.so"
introduced a faster way of getting the logical parent of a DIE, when
one of its ancestor DIEs has been imported into a the current
translation unit.

But then that commit broke the support for alternate debug info
files.  Oops.

This commit brings back the support for alternate debug info files.

	* src/abg-dwarf-reader.cc
	(imported_unit_point::imported_unit_from_alt_di): New data member.
	(imported_unit_point::imported_unit_point): Adjust.
	(read_context::alt_tu_die_imported_unit_points_map_): New data
	member.
	(read_context::alt_tu_die_imported_unit_points_map): New accessor.
	(die_die_attribute): Remove the overload which doesn't say if the
	resulting DIE comes from alternate debug info.
	(build_die_parent_relations_under): Take a new flag which says if
	we are building the relations about DIEs in the alternate debug
	info section or not.  Use that flag to know if the imported unit
	trace we are building is for an alternate debug info file or not.
	(build_die_parent_maps): Build two different imported unit point
	trace vectors: one for the main debug info file, and another one
	for the alternate debug info file.
	(find_import_unit_point_between_dies): Take a flag that says if
	the beginning of the search is a DIE in the alternate debug info
	file or not.  Use it to know if we should use the import point
	trace vectors from alternate debug info or from the main debug
	info file.  When the import point trace vector is empty, return
	immediatly.
	(get_parent_die): If the parent DIE is a DW_TAG_partial_unit which
	hasn't been imported into this TU, then assume the logical parent
	is the DIE for the current translation unit.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt:
	Reference test output.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64.rpm: New
	input test rpm.
	* tests/data/test-diff-pkg/tbb-4.3-3.20141204.fc23.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/tbb-debuginfo-4.1-9.20130314.fc22.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/tbb-debuginfo-4.3-3.20141204.fc23.x86_64.rpm:
	Likewise.
	* tests/data/Makefile.am: Add the new test materials to the source
	distribution.
	* tests/test-diff-pkg.cc (int_out_specs): Add the new rpms to the
	list of rpms to test against.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-06 19:50:28 +01:00
Dodji Seketeli
7c05acfc45 Bump revision number to 1.0.rc2
* configure.ac: Bump revision number to 1.0.rc2

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-06 08:10:59 +01:00
Dodji Seketeli
79c1e30855 Update link to the 1.0.rc1 tarball
* doc/website/mainpage.txt: Update the "Getting source code"
	section.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-05 16:48:34 +01:00
Dodji Seketeli
8a2cc3ceb7 Update ChangeLog before 1.0.rc1
* ChangeLog: Update automatically with make update-changelog

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-05 15:32:22 +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
Dodji Seketeli
211ada1ee9 Add a NEWS file
* NEWS: New file.
	* Makefile.am: Add NEWS file to source distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-05 12:35:57 +01:00
Dodji Seketeli
5a8c000a87 Bug 19355 - Libabigail slow on r300_dri.so
Profiling abidw --abidiff r300_dri.so, with a r30_dri.so that was run
through dwz shows that a great deal of the time is spent in trying to
get the logical parent of a DIE which has been imported.

To do that, we need to walk the translation unit DIEs again to know
where the DIE we are looking at has been imported.  And doing that
walking again and again, following the accessors of the DIE data
structure from elfutils takes time.

This patch reduces that time by constructing a "trace" of where units
have been imported.  So that looking for the logical parent of a given
DIE doesn't involve walking the DIE tree itself, but rather, walking
the trace, which is a vector.  This proves to be much faster.

In practice, the overall time spent is now less than 12 minutes.  It
was more than 50 minutes before.

	* src/abg-dwarf-reader.cc (struct imported_unit_point): Define new
	type.
	(operator<(const imported_unit_point&, const
	imported_unit_point&)): Define less-than operator for new
	imported_unit_point& type.
	(imported_unit_points_type, tu_die_imported_unit_points_map_type):
	New typedefs.
	(find_lower_bound_in_imported_unit_points): Define new static function.
	(read_context::tu_die_imported_unit_points_map_): New data member.
	(read_context::tu_die_imported_unit_points_map): New getter.
	(die_die_attribute): Define new overload.
	(build_die_parent_relations_under): Take imported_unit_points_type
	output parameter and populate it along the way. Remove the
	overload that takes a read_context as a parameter.
	(build_primary_die_parent_relations_under)
	(build_alternate_die_parent_relations_under): Remove.
	(build_die_parent_maps): Pass an instance of
	imported_unit_points_type to build_die_parent_relations_under.
	(find_import_unit_point_between_dies): Rename one overload of
	find_last_import_unit_point_before_die into this.  Adjust to make
	it find the import point between two offsets.
	(find_import_unit_point_before_die): Rename the other overload of
	find_last_import_unit_point_before_die into this. Adjust to use
	find_import_unit_point_between_dies.
	(get_parent_die): Adjust to use find_import_unit_point_before_die.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-04 19:58:02 +01:00
Dodji Seketeli
658430b921 Support two different variables having the same underlying symbol
Sometimes, two different variables A and B can have the same underlying
symbol, when for instance A is a reference that is initialized with
the address of B.

Until now, that was not supported by libabigail's ABI corpus.  Only
one (either A or B) variable is kept.  This is because the ID of the
variable, as returned by abigail::var_decl::get_id() is made of the
symbol name of the variable only.

This patch fixes the issue by including the name of the variable in
the ID.

	* src/abg-ir.cc (var_decl::get_id()): Include the name of the
	variable in the ID.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-04 19:58:02 +01:00
Dodji Seketeli
f0520db5ed Avoid adding the same base class twice
When looking at bug
https://sourceware.org/bugzilla/show_bug.cgi?id=19355, it appears that
some class have the same base class more than once.

Here is why.

Sometime in the DWARF, a given class is declared briefly, and then
later, it's amended.  Sometimes, when the class is updated, the debug
info contains redundant information, like base classes that were
previously expressed, and which are expressed again in the updated
version of the class.  The DWARF reader needs to not add that
duplicated information.

It appears the DWARF reader fails to recognize redundant base class
specifiers.  The native xml reader which is supposed to recognize
those, has some logic error that prevents it from working correctly.

This patch fixes both the DWARF and native xml readers.

The patch has no test because the r300_dri.so binary is really big and
still takes too much time to process, for it to be a practical
candidate for the regression test suite.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-01-04 19:58:02 +01:00