Commit Graph

872 Commits

Author SHA1 Message Date
Dodji Seketeli
2afa86fec1 Fix redundancy in abidiff manual
* doc/manuals/abidiff.rst: Remove the redundant bullet point about
	the --drop-fn command line switch.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-27 10:18:42 +01:00
Dodji Seketeli
90a77f40c0 Fix the doc string of the CanonicalDiff section of the apidoc
* src/abg-comparison.cc: The summary of the CanonicalDiff should
	not be a @par directive, otherwise it won't show up in the summary
	field on the html-genereated page.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-26 19:24:31 +01:00
Dodji Seketeli
9418ad46de Update doc string for new --no-redundant option of abidiff
* doc/manuals/abidiff.rst: Update the documentation string for the
	--no-redundant option of abidiff.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-26 19:03:16 +01:00
Dodji Seketeli
c887ad69ba Make abidiff *NOT* show redundant changes by default
Now that we are handling redundant diff node marking (and reporting)
with more finesse, I guess we can enable redundant diff reporting
elision by default again.

	* tools/abidiff.cc (options::options): Initialize
	options::show_redundant_changes to false.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-26 18:45:07 +01:00
Dodji Seketeli
3ca026b0ee Try harder to handle pointer/reference to void
When a pointer_type_def or reference_type_def is initialized with an
empty pointed-to type, we want consider that as a pointer/reference to
void.

This patch does that.  That helps to avoids to later crash because the
pointed-to-type is empty.  Also, this patch fixes spots where the
pointed-to-type seems nonetheless empty.

I have used the two different versions of libstdc++ from RHEL 6.5 and RHEL
7 to spot and fix these issues.

	* include/abg-fwd.h (type_or_void): Declare new function.
	* src/abg-ir.cc (type_or_void): Define it.
	(pointer_type_def::pointer_type_def)
	(reference_type_def::reference_type_def)
	(reference_type_def::get_qualified_name, strip_typedef): Use it to
	ensure that empty pointed-to-type is considered as a void type.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-26 18:45:06 +01:00
Dodji Seketeli
1e82b98af2 Do not mark sibling structurally identical nodes as redundant
Consider the C code below:

    int
    foo(int a, int b)
    {
    }

that is changed as:

    float
    foo(float a, float b)
    {
    }

In this case, we want the 'abidiff' tool to report the three
occurrences of the 'int' -> 'float' change (in the return type and in
the two parameter changes of the function foo).

In the current code, the comparison engine only reports the first
occurrence of the change and consider the two other occurrences as
being redundant.  So, by default, it only reports the first occurrence
of the change.

This patch modifies the comparison engine to make it *NOT* mark the
two later occurrences of change as redundant because the three
occurrences of changes happen at the same logical level: they are all
children of the function diff node in the diff tree.

	* include/abg-comparison.h (diff::parent_node): Declare new
	accessor.
	* src/abg-comparison.cc (diff::priv::parent_): New data member.
	(diff::priv::priv): Initialize it.
	(diff::parent_node): Define new accessor.
	(diff::append_child_node): Set the diff::priv::parent_ data member
	of the added child node.
	(redundancy_marking_visitor::visit_begin): If two (logical)
	sibbling nodes are structurally equivalent, do not mark them as
	being redundant.
	* tests/data/test-diff-suppr/libtest10-changed-parm-c-v0.so: New
	test input binary.
	* tests/data/test-diff-suppr/libtest10-changed-parm-c-v1.so:
	Likewise.
	* tests/data/test-diff-suppr/test10-changed-parm-c-report-0.txt:
	New test input data.
	* tests/data/test-diff-suppr/test10-changed-parm-c-v0.c: Source
	code for the binary input above.
	* tests/data/test-diff-suppr/test10-changed-parm-c-v1.c: Likewise.
	* tests/data/Makefile.am: Add the new test files to source
	distribution.
	* tests/test-diff-suppr.cc (in_out_specs): Add the new test input
	to the vector of test inputs to run this harness over.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-26 18:45:06 +01:00
Dodji Seketeli
817aa5555e Un-share diff nodes in the comparison IR
Until now, the diff nodes of the comparison IR were shared.  That is,
two diffs about the same subjects were represented by the same diff
node that would appear twice in the tree.

This was preventing us from spotting e.g, the first occurrence of a
diff node that would later (in the tree) turn to be redundant because
all redundant diff nodes are represented by the same diff node
pointer.

This patch now makes each diff node be different, as far of pointer
comparison is concerned.  But it introduces the concept of canonical
diff node to ease the comparison between two diff nodes.  Two diff
nodes that are equal have the same canonical diff node.

With this facility, it's now possible to tell the difference between
diff nodes that are (structurally) equal.  It's not possible to say
things like "this is the first or second occurrence of the redundant
diff node foo'.

	* include/abg-ir.h: Prefix the doc string with "///", rather than
	writing it inside a /**/ comment.
	* include/abg-comparison.h (function_decl_diff)
	(function_decl_diff_sptr, fn_parm_diff, fn_parm_diff_sptr)
	(var_diff_sptr, base_diff, class_diff, class_diff_sptr): Move
	these class & typedef decls to the top of the file.
	(string_changed_base_map, string_changed_parm_map)
	(unsigned_changed_parm_map, changed_function_ptr)
	(string_changed_function_ptr_map): Remove these typedefs.
	(string_base_diff_sptr_map, string_fn_parm_diff_sptr_map)
	(unsigned_fn_parm_diff_sptr_map, string_var_diff_sptr_map)
	(unsigned_var_diff_sptr_map, string_function_decl_diff_sptr_map)
	(string_var_diff_ptr_map): New typedefs.
	(diff_context::{has_diff_for,add_diff}): Make these member
	functions private.
	(diff_context::{set_canonical_diff_for,
	set_or_get_canonical_diff_for}): Declare new private member
	functions.
	(diff_context::{get_canonical_diff_for,
	initialize_canonical_diff}): New public member functions.
	(diff_context::maybe_apply_filters): Set the default value of the
	'traverse_nodes_once' parameter to false.
	(compute_diff): Make the overload for class_decl_sptr friend of
	the diff_context class.
	(class diff): Make the diff_context class a friend of this one.
	(diff::set_canonical_diff): Declare new private member function.
	(diff::get_canonical_diff): Declare new public member function.
	(diff::children_nodes): Make this return a vector<diff_sptr>, rather
	than a vector<diff*>.
	(diff::append_child_node): Make this take a diff_sptr rather than
	a diff*.
	(class fn_parm_diff): Declare new type.
	(compute_diff): Declare new overload for the new
	function_decl::parameter_sptr.
	(function_decl_diff::subtype_changed_parms): Return a
	string_fn_parm_diff_sptr_map rather than a string_changed_parm.
	(function_decl_diff::children_nodes): Return a vector<diff_sptr>.
	(function_decl_diff::append_child_node): Take a diff_sptr.
	(function_decl_diff::changed_functions): Return a
	string_function_decl_diff_sptr_map.
	(function_decl_diff::changed_variables): Return a
	string_var_diff_sptr.
	(class function_decl::parameter): Make this a pimpled class.
	Also, make it inherit decl_base.
	(equals): New overload for function_decl::parameter.
	(struct function_decl::parameter::hash): Declare this.
	(ir_node_visitor::visit): Declare new overload for
	function_decl::parameter.
	* src/abg-comparison.cc: Add doc-string about the internal
	representation of the comparison engine and also about the concept
	of canonical diff of the comparison engine.
	(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER)
	(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER2)
	(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER3): Consider the
	canonical diff when trying to know if the current node was
	reported earlier.
	(diff_context::priv::canonical_diffs): New data member.
	(diff_context::{get_canonical_diff_for, set_canonical_diff_for,
	set_or_get_canonical_diff_for, initialize_canonical_diff}): Define
	new member functions.
	(diff_context::{diff_has_been_traversed, mark_diff_as_traversed):
	Consider canonical diff for these tests and actions.
	(diff::priv::children_): Change the type of this to
	vector<diff_sptr>.
	(diff::canonical_diff_): New data member.
	(diff::diff): Initialize the diff::canonical_diff_ data member.
	(diff::begin_traversing): Mark the canonical diff node too.
	(diff::is_traversing): Consider the canonical diff node in this
	test.
	(diff::end_traversing): Make the canonical diff node too.  Also
	mark the current node as having been traversed.
	(diff::children_nodes): Return a vector<diff_sptr> type.
	(diff::{get_canonical_diff, set_canonical_diff}): Define new
	member functions.
	(diff::append_child_node): Take a diff_sptr type parameter.
	(diff::{reported_once, currently_reporting}): Flag the canonical
	diff node too.  And consider the canonical diff node when checking
	the flag.
	(diff::traverse): No need to mark the node as being traversed
	because the diff::end_traversing() function does it now.  Adjust
	the code because diff::children_nodes() now returns
	vector<diff_sptr>.
	({distinct_diff, var_diff, pointer_diff, array_diff,
	reference_diff, qualified_type_diff, enum_diff, class_diff,
	base_diff, scope_diff, function_decl_diff, typedef_diff,
	corpus_diff}::chain_into_hierarchy): Adjust to the new type that
	diff::append_child_node() takes.  Also, take into account that the
	diff nodes are now un-shared.
	(compute_diff_for_distinct_kinds, compute_diff_for_types)
	(compute_diff): Do not share diff nodes anymore.  Initialize the
	canonical diff node for the new created node.
	(represent): Take a var_diff_sptr rather than two var_decl_sptr.
	Adjust.  Also take in account the fact that diff nodes are not
	shared anymore, and that they do have canonical diffs.
	(var_diff::type_diff): Make the computation of the type_diff of
	the var_diff be lazy.  This avoids infinite (recursive) creation
	of diff nodes when a class diff node has a sub-type of data member
	that is a class diff node too.
	(var_diff::report): Detect redundant reporting of this kind of
	diff node.
	(class_diff::priv::changed_bases_): Change the type of this to
	string_base_diff_sptr_map.
	(class_diff::priv::subtype_changed_dm_): Change the type of this
	to string_var_diff_sptr_map.
	(class_diff::priv::changed_dm_): Change the type of this to
	unsigned_var_diff_sptr_map.
	(class_diff::priv::{count_filtered_subtype_changed_dm,
	count_filtered_bases}): Do not take a diff_context_sptr anymore.
	(class_diff::ensure_lookup_tables_populated): changed_bases_
	subtype_changed_dm_ and changed_dm_ are now *NOT* shared diff
	nodes anymore.
	(class_diff::priv::base_has_changed): Adjust.
	(class_diff::priv::subtype_changed_dm): Adjust.
	(class_diff::priv::count_filtered_bases): Adjust as changed_bases_
	is now a map of un-shared diff nodes.
	(class_diff::priv::count_filtered_subtype_changed_dm): Adjust as
	subtype_changed_dm_ is now a map of un-shared diff nodes.
	(class_diff::priv::{count_filtered_changed_mem_fns,
	count_filtered_inserted_mem_fns, count_filtered_deleted_mem_fns,
	}): Adjust for change of the default parameter value of
	diff_context::maybe_apply_filters().
	(class_diff::~class_diff): New destructor.
	(class_diff::changed_bases): Return a string_base_diff_sptr_map&
	type.
	(class_diff::{inserted_data_members, deleted_data_members,
	changed_member_fns}): Add doc strings.
	(struct changed_data_member_comp): Remove.
	(struct var_diff_comp): New comparison functor.
	(sort_changed_data_members): Remove.
	(sort_var_diffs): Define new sorting function.
	(class_diff::report): Adjust.
	(fn_parm_diff::*): Define member types and functions of the new
	fn_parm_diff type.
	(function_decl_diff::priv::{subtype_changed_parms_,
	changed_parms_by_id_}): Make these take a map of fn_parm_diff_sptr
	nodes.
	(function_decl_diff::ensure_lookup_tables_populated): Adjust to
	the fact that priv_->subtype_changed_parms_ and
	priv_->priv_->changed_parms_by_id_ now are maps of un-shared
	fn_parm_diff_sptr nodes.
	(function_decl_diff::subtype_changed_parms): Adjust.
	(struct changed_parm_comp): Remove.
	(struct fn_parm_diff_comp): New comparison functor.
	(sort_changed_parm_map): Remove.
	(sort_string_fn_parm_diff_sptr_map): New sorting function.
	(function_decl_diff::report): Adjust.
	(corpus_diff::priv::children_): Change the type of this to
	vector<diff_sptr>.
	(corpus_diff::priv::changed_fns_): Changed the type of this to
	string_function_decl_diff_sptr_map.
	(corpus_diff::priv::changed_vars_): Changed the type of this to
	string_var_diff_sptr_map.
	(corpus_diff::priv::ensure_lookup_tables_populated): Adjust.
	(corpus_diff::priv::apply_filters_and_compute_diff_stats}):
	Adjust.  Do not need to clear redundancy categorization anymore
	because the diff nodes are not shared anymore.
	(corpus_diff::priv::categorize_redundant_changed_sub_nodes):
	Adjust.
	(corpus_diff::priv::clear_redundancy_categorization): Adjust.
	(corpus_diff::changed_variables): Adjust.
	(struct changed_function_ptr_comp): Remove.
	(struct function_decl_diff_comp): New comparison functor.
	(sort_string_changed_function_ptr_map): Remove.
	(sort_string_function_decl_diff_sptr_map): Define new sorting
	function.
	(struct changed_vars_comp): Remove.
	(struct var_diff_sptr_comp): New comparison functor.
	(sort_changed_vars): Remove.
	(sort_string_var_diff_sptr_map): Define new sorting function.
	(corpus_diff::report): Adjust.
	(corpus_diff::traverse): Adjust.
	({category_propagation_visitor,
	suppression_categorization_visitor}::visit_end): Adjust.
	(clear_redundancy_categorization): Adjust.
	* src/abg-hash.cc (function_decl::parameter:#️⃣:operator):
	Adjust.
	* src/abg-ir.cc (struct function_decl::parameter::priv): Define
	here as part of pimpl-ifying the function_decl::parameter type.
	(function_decl::parameter::*): Define here the member functions as
	part of pimpl-ifying the function_decl::parameter type.
	(equals): Define the overload for function_decl::parameter here
	too.
	(ir_node_visitor::visit(function_decl::parameter*)): Define this.
	* tests/data/test-abicompat/test0-fn-changed-report-0.txt: Adjust.
	* tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Adjust.
	* tests/data/test-diff-dwarf/libtest21-redundant-fn-v0.so: New
	test input data.
	* tests/data/test-diff-dwarf/libtest21-redundant-fn-v1.so:
	Likewise.
	* tests/data/test-diff-dwarf/test21-redundant-fn-v0.cc: Source
	code for test input binary above.
	* tests/data/test-diff-dwarf/test21-redundant-fn-v1.cc: Likewise.
	* tests/data/test-diff-dwarf/test21-redundant-fn-report-0.txt: New
	test input data.
	* tests/data/test-diff-dwarf/libtest22-changed-parm-c-v0.so: New
	test input data.
	* tests/data/test-diff-dwarf/libtest22-changed-parm-c-v1.so:
	Likewise.
	* tests/data/test-diff-dwarf/test22-changed-parm-c-v0.c: Source
	code for test input binary above.
	* tests/data/test-diff-dwarf/test22-changed-parm-c-v1.c: Likewise.
	* tests/test-diff-dwarf.cc (in_out_spec): Add the new test input
	data to the vector the test inputs to run this harness over.
	* tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt: New
	test input data.
	* tests/data/test-diff-suppr/test8-redundant-fn-report-1.txt:
	Likewise.
	* tests/data/test-diff-suppr/libtest8-redundant-fn-v0.so: New test
	input binary.
	* tests/data/test-diff-suppr/libtest8-redundant-fn-v1.so: Likewise.
	* tests/data/test-diff-suppr/test8-redundant-fn-v0.cc: Source code
	code for binary test input above.
	* tests/data/test-diff-suppr/test8-redundant-fn-v1.cc: Likewise.
	* tests/data/test-diff-suppr/test9-changed-parm-c-report-0.txt:
	New test input data.
	* tests/data/test-diff-suppr/test9-changed-parm-c-report-1.txt:
	Likewise.
	* tests/data/test-diff-suppr/libtest9-changed-parm-c-v0.so: New
	test input binary.
	* tests/data/test-diff-suppr/libtest9-changed-parm-c-v1.so: New
	test input binary.
	* tests/data/test-diff-suppr/test9-changed-parm-c-v0.c: Source
	code for binary test input above.
	* tests/data/test-diff-suppr/test9-changed-parm-c-v1.c: Likewise.
	* tests/test-diff-suppr.cc (in_out_specs): Add the new test input
	data to the vector the test inputs to run this harness over.
	* tests/data/Makefile.am: Add the new files to the source
	distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-26 18:45:06 +01:00
Dodji Seketeli
a1a87c204e Style fix
Make reference_type_def::get_pointed_to_type() return a type_base_sptr
rather than a shared_ptr<type_base>.

	* src/abg-ir.cc (reference_type_def::get_pointed_to_type): Return
	a type_base_sptr.
	* src/abg-comparison.cc (diff::is_filtered_out): Fix a comment.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-26 18:42:20 +01:00
Dodji Seketeli
1fe4b2d473 Fix pretty printing of pointer_diff node
While working on un-sharing diff nodes, I observed that the pretty
printed representation of pointer_diff nodes  was lacking an opening
square bracket.  Fixed thus.

	* src/abg-comparison.cc (pointer_diff::get_pretty_representation):
	Add the missing opening square bracket.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-26 14:59:49 +01:00
Sinny Kumari
a6897b0fea Add new methods in corpus_diff class
Functions added_unrefed_function_symbols() and
added_unrefed_variable_symbols() are required in order to access
added functions and variables obtained while calculating abi diff
between libraries with no debug information available

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

Signed-off-by: Sinny Kumari <skumari@redhat.com>
2014-12-18 15:27:39 +01:00
Sinny Kumari
a95af1c160 Add new corpus_diff::added_variables() method
Function added_variables() is required in order to access the list of
added variables obtained while calculating abi diff between two
libraries outside libabigail

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

Signed-off-by: Sinny Kumari <skumari@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-15 09:23:52 +01:00
Dodji Seketeli
8879d00538 Extend detection of compatible types to arrays
* include/abg-fwd.h (is_array_type): Renamed is_array_type_def()
	into this for consistency.
	* src/abg-comparison.cc (type_suppression::suppresses_diff):
	Adjust.
	* src/abg-dwarf-reader.cc (build_array_type): Remove useless code
	that was trying to read a DW_AT_byte_size attribute from the DIE
	of the array, but then wasn't doing anything with the value.  But
	then if the attribute was not present, the array type wouldn't be
	built.
	* src/abg-ir.cc (strip_typedef): Strip typedefs from sub-types of
	array types too.
	(is_array_type): Rename is_array_def() to this, for consistency.
	(var_decl::get_pretty_representation): Adjust.
	* tests/data/test-diff-filter/libtest24-compatible-vars-v0.so: New
	test input data.
	* tests/data/test-diff-filter/libtest24-compatible-vars-v1.so: Likewise.
	* tests/data/test-diff-filter/test24-compatible-vars-report-0.txt:
	Likewise.
	* tests/data/test-diff-filter/test24-compatible-vars-v0.c: Source
	code for the first binary above.
	* tests/data/test-diff-filter/test24-compatible-vars-v1.c: Source
	code for the second binary above.
	* tests/data/Makefile.am: Add the new test input data to source
	distribution.
	* tests/test-diff-filter.cc (in_out_specs): Add the new test input
	data to the list of input to run this test harness over.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-12 14:44:24 +01:00
Dodji Seketeli
501d5ab502 Improve the doc string for the elf_symbol::get_id_string() method
* src/abg-ir.cc (elf_symbol::get_id_string): Improve doc string.
	Talk about the content of the id string of an elf symbol.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-12 11:10:02 +01:00
Dodji Seketeli
99b31c92ff Better handle pointer-to-void in various places of the pipeline
This is the last patch that should fix the issue
https://sourceware.org/bugzilla/show_bug.cgi?id=17655

A pointer to void can be represented as an instance of
abigail::ir::pointer_type_def which has a NULL pointed-to attribute.

Unfortunately, there are various places in the code that assume that
abigail::ir::pointer_type_def::get_pointed_to_type() returns a
non-null value.  This patch is an attempt at fixing those spots.

	* src/abg-comparison.cc (pointer_diff::report): Handle the case of
	pointer to void.
	* src/abg-dwarf-reader.cc (build_pointer_type_def): Assert that
	the underlying pointer is non-null.
	* src/abg-ir.cc (pointer_type_def::pointer_type_def): Handle the
	case of pointer to void.
	(equals): Likewise in the overload for const pointer_type_def.
	(pointer_type_def::get_qualified_name): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-11 16:01:07 +01:00
Dodji Seketeli
1176c1c4ed Try harder to detect a DWARF attribute pointing into alternate DWARF section
This is bug https://sourceware.org/bugzilla/show_bug.cgi?id=17655.
There are several issues conflated into that one problem report.  This
patch addresses one of them.

The value of a DW_AT_type attribute on a DW_TAG_subprogram DIE can be
a type that lies in an alternate DWARF section.  The link from the
DW_TAG_subprogram die to the attribute value can be very much
indirect; for instance, the DW_TAG_subprogram might be linked to an
abstract origin function through a DW_AT_abstract_origin, which itself
can be linked to a function specification that lies in the alternate
DWARF section through a DW_AT_specification attribute.  It's that last
function specification (in the alternate DWARF section) that would
have the DW_AT_type that points to the return type of the function,
defined in the alternate DWARF section.  In this specific case, we
were failing to detect that the DW_AT_type was inside the alternate
debug info section; note that detecting that is not obvious because
the elfutils function dwarf_attr_integrate that we use to get the
value of the DW_AT_type magically does the walking through all the
hops, but doesn't tell us if the resulting type is in the alternate
debug info section or not.  So we do have our own function that does
the detection.

This patch makes the detection work in this case.

	* src/abg-dwarf-reader.cc
	(is_die_attribute_resolved_through_gnu_ref_alt): Support the case
	of the origin function itself having a specification function
	link.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-11 13:48:43 +01:00
Dodji Seketeli
04abbd1d44 Fix accidentally removing the scope of variables when fixing them up
This is about bug
https://sourceware.org/bugzilla/show_bug.cgi?id=17652.  Some old DWARF
producers emit incomplete debug info for static data members.  We
currently detect this and fix the resulting constructed variables up.
During this fix up, it appears that we sometimes accidentally remove
the scope of some variables.  Fixed thus.

	* src/abg-dwarf-reader.cc (build_translation_unit_and_add_to_ir):
	During var decl fixup, remove the scope of a variable only when we
	are sure that we want to re-scope it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-11 11:39:31 +01:00
Dodji Seketeli
e8a0fbaeee Fix several aborts while diffing libdw.so
Several crashes were spotted when running abidiff on the libdw.so from
elfutils versions 0.158 and 0.160.  This is the problem report
https://sourceware.org/bugzilla/show_bug.cgi?id=17650 and the patch
below addresses that.

	* src/abg-corpus.cc
	(corpus::priv::build_unreferenced_symbols_tables): Fix wrong
	guestimation of the size of the map of unreferenced symbol table.
	* src/abg-dwarf-reader.cc (get_version_needed_for_versym): Honour
	the conditions of breaking out from walking the verneed table.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-11 09:28:55 +01:00
Dodji Seketeli
8f994b5e29 Temporarily disable redundant diff report elimination
So, this is all about problem report
https://sourceware.org/bugzilla/show_bug.cgi?id=17693.

When redundant diff node reporting is enabled and when a diff node
appears twice in a diff tree, we detect that and the second occurrence
of the diff node is flagged as being redundant.  Later at diff tree
node reporting time, the redundant diff node is not reported.

The problem is that diff nodes are canonicalized.  That is, when the
same change is present twice in a diff, the same diff node is going to
be present twice.  So flagging the second occurrence as being
redundant amounts as flagging the first occurrence as being redundant
too!  So at reporting time, the diff tree visitor that walks the diff
tree nodes will avoid reporting the two occurrences of diff tree nodes
altogether.  This is what happens in the example of the bug above.  I
am reproducing the example here for convenience:

So suppose we have a first version of a library named lib-v0.so which
is made of this C code:

    int add(int a, int b)
    {
    }

Then suppose that code was changed in a subsequent version of the
library named lib-v1.so, leading to the following code:

    int add(float a, float b)
    {
    }

So, the diff tree node for the 'add' function is going to have several
child diff tree nodes, among which, one that carries the change for
the first parameter (int a becoming float a) and the one carrying the
change for the second parameter (int b becoming float b).

The diff tree node for the second parameter is going to be same diff
tree node as the one for the first parameter because what counts is
the change in the *type* of the parameter.  Thus, the diff tree node
for the second parameter is going to be marked as being redundant; and
so is the first parameter.

So abidiff lib-v0.so lib-v1.so yields:

    Functions changes summary: 0 Removed, 0 Changed (1 filtered out), 0 Added
    function
    Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

You can see that even the function 'add' is not mentioned in the
report.  This is because it has also been considered as being
redundant because of a phenomenon named 'propagation'.  The
redundant-ness of the children nodes of the diff tree node of the
'add' function is propagated to the diff tree node of the add function
itself because that add function diff tree node has no child but
redundant diff children nodes.  This categorization behaviour is
correct.

What is not correct is that only the second child node of the add
function diff tree node should have been marked redundant.

I am going to tackle this issue a bit later.  For now, I am
temporarily disabling redundancy categorization for diff tree nodes by
default.  Hence this patch.

With this patch, abidiff lib-v0.so lib-v1.so yields:

    Functions changes summary: 0 Removed, 1 Changed, 0 Added function
    Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

    1 function with some indirect sub-type change:

      [C]'function int add(int, int)' has some indirect sub-type changes:
	parameter 0 of type 'int' changed:
	  name changed from 'int' to 'float'
	parameter 1 of type 'int' changed:
	  name changed from 'int' to 'float'

Note how the change on the second parameter appears equal to the
change on the first.

	* src/abg-comparison.cc
	(diff_context::priv::priv): Show redundant changes by default.
	(categorize_redundancy): Do not categorize redundancy if the
	diff_context says that we shouldn't.
	* tools/abicompat.cc (options::show_redundant): New data member.
	(options::options): Initialize to true.
	(display_usage): Add new help string for new --no-redundant and
	--redundant options.
	(parse_command_line): Parse new --no-redundant and --redundant
	command line options.
	(main): Initialize the diff context with respect to the
	options::show_redundant property.
	* tools/abidiff.cc (options::options): Initialize the
	show_redundant_changes data member to true.
	(display_usage): Show new help string for the new --no-redundant
	command line option.
	(parse_command_line): Parse the new --no-redundant command line
	option.
	* tests/data/test-diff-filter/libtest23-redundant-fn-parm-change-v0.so:
	New test data input.
	* tests/data/test-diff-filter/libtest23-redundant-fn-parm-change-v1.so:
	Likewise.
	* tests/data/test-diff-filter/test23-redundant-fn-parm-change-report-0.txt:
	Likewise.
	* tests/data/test-diff-filter/test23-redundant-fn-parm-change-v0.c:
	Source code for the first binary above.
	* tests/data/test-diff-filter/test23-redundant-fn-parm-change-v1.c:
	Source code for the second binary above.
	* tests/data/Makefile.am: Add the new test data input to source
	distribution.
	* tests/test-abicompat.cc (in_out_specs): Add --no-redundant to
	abicompat when we don't want it to show redundant diff reports.
	* test-diff-filter.cc (in_out_specs): Likewise for abidiff.
	* test-diff-suppr.cc (in_out_specs): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-10 19:19:57 +01:00
Jan Engelhardt
112432bbd2 Fix conditional build wrt zip archives and cx11
Revert 1b4e3844e9. Automake does support
nested conditionals just fine.  One just has to use the += operator.

This also fixes the problem:

	./configure: line 15878: ENABLE_ZIP_ARCHIVE_AND_CXX11:
	command not found

caused by bad syntax:

	ENABLE_ZIP_ARCHIVE_AND_CXX11 = yes

(Variable assignments must not use spaces around '=').

	* configure.ac: remove (broken) assignment to the
	ENABLE_ZIP_ARCHIVE_AND_CXX11 variable
	* Makefile.am: replace variable assignments to
	ZIP_ARCHIVE_TESTS_FIRST_PART, ZIP_ARCHIVE_TESTS_SECOND_PART
	by ZIP_ARCHIVE_TESTS using the "+=" automake operator.
	Likewise for CXX11_TESTS.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-10 14:35:55 +01:00
Dodji Seketeli
1b75fd3eac Make determining of compatible types complete
Until now, two types that are different were considered compatible if
one type is a typedef of the other.  This is useful because two
different types, if compatible, are not ABI-incompatible.  This patch
extends the concept of compatible types to types which might have
sub-types that are typedefs of each others, including function types.

Note implementing this required that I fixed various other things left
and right.  Like style fixes, crash avoiding fixes, etc.

	* include/abg-fwd.h (is_reference_type, is_function_type)
	(is_method_type): Declare new predicates.
	* include/abg-ir.h (class qualified_type_def): Pimpl this class.
	(qualified_type_def::qualified_type_def): Use the convenience
	type_base_sptr typedef.
	(qualified_type_def::{get_cv_quals, set_cv_quals}): Use the
	qualified_type_def::CV type rather than char.
	(qualified_type_def::get_underlying_type): Use the convenience
	type_base_sptr typedef.
	(pointer_type_def::pointer_type_def): Likewise.
	(function_decl::parameter::parameter): Add a new constructor.
	* src/abg-ir.cc (is_reference_type, is_function_type)
	(is_method_type): Define new predicates.
	(class qualified_type_def::priv): Define this new private type,
	for the purpose of Pimpl-ifying the qualified_type_def class.
	(qualified_type_def::{qualified_type_def, build_name,
	get_cv_quals_string_prefix, get_underlying_type}): Adjust for the
	purpose of Pimpl-ifying the qualified_type_def class.
	(equals): In the qualified_type_def, reference_type_def overloads,
	trust the fact that we have operator== overload for the
	type_base_sptr.  This avoids crashes for when the (possible)
	underlying type is null.
	(pointer_type_def::operator==): Likewise.
	(strip_typedef): Make this recursively strip
	typedefs from sub-types.
	(types_are_compatible): Handle null types.
	(qualified_type_def::{get_cv_quals, set_cv_quals}): Handle
	qualified_type_def::CV rather than char.
	(pointer_type_def::pointer_type_def): Use the convenience
	type_base_sptr typedef.
	* include/abg-comparison.h (distinct_diff::compatible_child_diff):
	Declare new member function.
	* src/abg-comparison.cc (distinct_diff::compatible_child_diff):
	Define new member function.
	(distinct_diff::chain_into_hierarchy):
	Chain the compatible child diff node that might be present.
	(distinct_diff::report): Now when a distinct diff carries a
	compatible change, mention it in the report.
	* src/abg-comp-filter.cc (is_compatible_change): A compatible
	change can now involve types that are not typedefs.  Only their
	sub-types need to be involved with typedef-ness.
	* tests/data/test-diff-dwarf/test{2,4,5}-report.txt: Adjust.
	* tests/data/test-diff-filter/libtest21-compatible-vars-v0.so: New
	test data input.
	* tests/data/test-diff-filter/libtest21-compatible-vars-v1.so: Likewise.
	* tests/data/test-diff-filter/test21-compatible-vars-report-0.txt Likewise.
	* tests/data/test-diff-filter/test21-compatible-vars-report-1.txt Likewise.
	* tests/data/test-diff-filter/test21-compatible-vars-v0.cc: Source
	code for the first data input binary above.
	* tests/data/test-diff-filter/test21-compatible-vars-v1.cc: Source
	code for the second data input binary above.
	* tests/data/test-diff-filter/libtest22-compatible-fns-v0.so: New
	test data input.
	* tests/data/test-diff-filter/libtest22-compatible-fns-v1.so Likewise.
	* tests/data/test-diff-filter/test22-compatible-fns-report-0.txt:
	New test data input.
	* tests/data/test-diff-filter/test22-compatible-fns-report-1.txt: Likewise.
	* tests/data/test-diff-filter/test22-compatible-fns-v0.c: Source
	code for the first test data input binary above.
	* tests/data/test-diff-filter/test22-compatible-fns-v1.c: Source
	code for the second test data input binary above.
	* tests/data/Makefile.am: Add the new test input data to source
	distribution.
	* tests/test-diff-filter.cc (in_out_specs): Add the new test data
	input above to the list of test data this harness has to be run
	over.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-10 08:02:32 +01:00
Dodji Seketeli
eecf5f87df Fix classification of parameter addition in C
The comparison engine classifies an addition or removal of parameter
from a C function as harmless.  This is a mistake that impacts abidiff
and abicompat.  Fixed thus.

	* src/abg-comp-filter.cc (function_name_changed_but_not_symbol):
	Compare the fully qualified name of the functions; not their
	pretty representation.
	* tests/data/test-diff-dwarf/libtest20-add-fn-parm-v0.so: New test
	data intput.
	* tests/data/test-diff-dwarf/libtest20-add-fn-parm-v1.so:
	Likewise.
	* tests/data/test-diff-dwarf/test20-add-fn-parm-report-0.txt:
	Likewise.
	* tests/data/test-diff-dwarf/test20-add-fn-parm-v0.c: Source code
	for the first shared library above.
	* tests/data/test-diff-dwarf/test20-add-fn-parm-v1.c: Source code
	for the second shared library above.
	* tests/test-diff-dwarf.cc (in_out_specs): Add the test input data
	above to the list of test input the harness must run over.
	* Makefile.am: Add the new files above to source distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-09 13:10:58 +01:00
Dodji Seketeli
775cfcde0c Wire the soname check into abicompat
Now that the comparison engine knows how to take SONAMEs into account
during ABI abi comparison, it's feasible to make abicompat leverage
that capability.  This patch does just that.

	* include/abg-comparison.h (corpus_diff::soname_changed): Declare
	new member function.
	* src/abg-comparison.cc (corpus_diff::soname_changed): Define new
	member function.
	(corpus_diff::length): Use the new corpus_diff::soname_changed()
	method.
	* tests/data/test-abicompat/libtest4-soname-changed-v0.so: New
	test input data.
	* tests/data/test-abicompat/libtest4-soname-changed-v1.so:
	Likewise.
	* tests/data/test-abicompat/test4-soname-changed-app: Likewise.
	* tests/data/test-abicompat/test4-soname-changed-report-0.txt:
	Likewise.
	* tests/data/test-abicompat/test4-soname-changed-app.cc: Source
	code for one of the binaries above.
	* tests/data/test-abicompat/test4-soname-changed-v0.cc: Likewise.
	* tests/data/test-abicompat/test4-soname-changed-v1.cc: Likewise.
	* tests/test-abicompat.cc (in_out_specs): Add the new test input
	data to the list of input data to run this harness over.
	(main): Take the soname change in account to determine if the
	change is ABI incompatible.
	* tests/data/Makefile.am: Add the new test input data above to source
	distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-08 13:47:00 +01:00
Dodji Seketeli
ae98acdb90 Fixup messed up old runtestdiffdwarf input tests
While working on supporting the comparison of sonames I realized that
the runtestdiffdwarf test harness was missing some input data.  This
patch addresses that.

	* tests/data/test-diff-dwarf/test17-non-refed-syms-report-0.txt:
	Add this missing reference test output.
	* tests/data/Makefile.am: Add the new reference test output to
	source distribution.
	* tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Fix
	this output to avoid emitting symbol alias information in it.
	* tests/test-diff-dwarf.cc (in_out_specs): Add two missing test
	input data to the list of input data this harness is supposed to
	run over.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-07 23:42:26 +01:00
Dodji Seketeli
721728e7de Support reading and comparing soname from ELF files
Libabigail's DWARF reader doesn't read the DT_SONAME tag from the
.dynamic section.  The abigail::corpus type doesn't have a property
for that tag either.  And the comparison engine doesn't take that tag
in when comparing corpora.

This patch modifies the DWARF reader to read the DT_SONAME and
DT_NEEDED tags from the .dynamic section.  The value of DT_SONAME tag
is then saved in the new corpus property accessed by the new
abigail::corpus::get_soname() accessor.  The comparison engine has
also been modified to compare the sonames of two corpora being
compared.  Note that the value of the DT_NEEDED elf tag is saved in a
new corpus property that is accessed via the new
abigail::corpus::get_needed() getter.  This property is not used yet.

This patch also adds a unit test for this new feature.

	* include/abg-corpus.h (corpus::{get_needed, set_needed,
	get_soname, set_soname}): Declare new accessors.
	* src/abg-corpus.cc (corpus::priv::{needed, soname}): New data
	members.
	(corpus::{get_needed, set_needed, get_soname, set_soname}): Define
	new accessors.
	(corpus::is_empty): Take dt_needed and dt_soname in account in
	computing empty-ness.
	* src/abg-dwarf-reader.cc (read_context::{dt_needed_,
	dt_soname_}): New data members.
	(read_context::{dt_needed, dt_soname}): New accessors.
	(read_context::load_dt_soname_and_needed): New member function.
	(read_corpus_from_elf): Call the new
	read_context::load_dt_soname_and_needed() to read the dt_soname
	and dt_needed tags.  Set them to the corpus.
	* include/abg-comparison.h (diff_context::show_soname_change):
	Declare new accessors.
	* src/abg-comparison.cc (diff_context::priv::show_soname_change_):
	New data member.
	(diff_context::priv::priv): Initialize the new data member
	diff_context::priv::show_soname_change_.
	(diff_context::show_soname_change): Define new accessors.
	(corpus_diff::priv::sonames_equal_): New data member.
	(corpus_diff::priv::priv): Initialize the new data member
	corpus_diff::priv::sonames_equal_.
	(corpus_diff::length): Take the new priv_->sonames_equals_ data
	member in account.
	(corpus_diff::{report, priv::emit_diff_stats}): If the sonames
	changed and we are allowed to report it, then report it.
	(compute_diff): In the variant for corpus_diff, do not forget to
	compare the sonames.
	* src/abg-reader.cc (build_needed, read_elf_needed_from_input):
	Define new static functions.
	(read_corpus_from_input): Read the 'soname' attribute from the
	'abi-corpus' xml element node.
	* src/abg-writer.cc (write_elf_needed): Define new static
	function.
	(write_corpus_to_native_xml): Write a new 'elf-needed' xml element
	node that contains one xml 'dependency' element node per
	dependency to emit.  This uses the new write_elf_needed() function
	above.
	* tests/data/test-diff-dwarf/libtest19-soname-v0.so: New test
	input data.
	* tests/data/test-diff-dwarf/libtest19-soname-v1.so: Likewise.
	* tests/data/test-diff-dwarf/test19-soname-report-0.txt: Likewise.
	* tests/data/test-diff-dwarf/test19-soname-v0.c: Source code of
	the first binary above.
	* tests/data/test-diff-dwarf/test19-soname-v1.c: Source code of
	the second binary above.
	* tests/test-diff-dwarf.cc (in_out_specs): Add the test input
	above to the list of test input to run this harness on.
	* tests/data/Makefile.am: Add the new test input data above.
	* tests/data/test-read-dwarf/test{0,1}.abi: Adjust.
	* tests/data/test-read-dwarf/test{2,3,4,6,}.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-07 23:42:26 +01:00
Dodji Seketeli
e518336d8a Fix some style nits in the native reader and writer
While working on the soname comparison support I stumbled across some
small style issues.  Fixed thus.

	* src/abg-reader.cc (read_symbol_db_from_input): Align parameter
	names.  Fix indentation of the first line of the function.
	* src/abg-writer.cc (write_elf_symbols_table): Align parameter names.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-07 23:42:26 +01:00
Dodji Seketeli
c0a31b48c7 Fix a crash while writing symbol information
While working on something else, I noticed that the abilint tool would
crash when trying to write information relative to some symbol
information.  It turned out that invoking corpus::get_fun_symbol_map()
or corpus::get_var_symbol_map() on a corpus that has an empty function
(or variable) symbol map yields a crash.  This patch fixes that.

To test the fix I had to extend the test-read-write.cc test harness to
teach it to load corpus files too; up to now it was only loading
simple translation unit files (named Binary Instrumentation files).  I
then created a native xml corpus file using the abidw tool on a simple
shared library I created.  That corpus file does have an empty
variable symbol section which triggers the crash on a non-fixed tree.

	* src/abg-corpus.cc (corpus::{get_fun_symbol_map_sptr,
	get_var_symbol_map_sptr}): Make sure the symbol map is always
	constructed, even if it's empty.
	* tests/data/test-read-write/test26.xml: New test input data.
	* tests/test-read-write.cc (in_out_spec): Add this new test input
	data to the list of input data to run the harness on.
	(main): Support reading and writing corpus files alongside
	translation unit files that we were handling already.
	* tests/data/Makefile.am: Add the new test input data to source
	distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-07 17:25:26 +01:00
Dodji Seketeli
8e9dbc9cf1 Avoid showing ugly version info in the libabigail online manual
* doc/manuals/conf.py: Update copyright mention.  Do not show ugly
	version information.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-05 15:43:31 +01:00
Dodji Seketeli
ef7e71febf Initial implementation of the abicompat tool
Given an application A that links to a shared library L of version V
denoted L(V) and a subsequent version of that library denoted L(V+P),
the 'abicompat' tool tells the user if L(V+P) is still ABI compatible
with L(V+P).  And if it is not, abicompat gives a reports that shows
the differences between L(V) and L(V+P) that makes L(V+P)
ABI-incompatible with A.

The source code of this tool is in the tools/abicompat.cc source
file.  To support this new tool, this commit changes the comparison
engine to optionally avoid showing added symbols that were not
referenced by any debug info.  It changes the ABI corpus type to allow
the specification of a list of variables and functions symbols to keep
(and drop all other functions and variables which have other symbols
on the floor even before starting to compare the two libraries).

This is how the abicompat tool itself works.  It basically compares
L(V) and L(V+P) but it only looks at their exported functions and
variables which symbols are undefined in application A.  If the list
of exported and defined variables and functions of L(V) whose symbols
are undefined in A equals that of L(V+P) (including the sub-types of
these variables and functions) A is still compatible with L(V+P).
Otherwise, they might not be compatible depending on the kind of
differences that are found.

	* include/abg-comparison.h
	(diff_context::show_added_symbols_unreferenced_by_debug_info):
	Declare new accessors.
	(corpus_diff::{deleted_variables,
	deleted_unrefed_function_symbols,
	deleted_unrefed_variable_symbols,
	apply_filters_and_suppressions_before_reporting}): Declare new
	methods.
	(corpus_diff::diff_stats): Declare this new type.  Actually this
	was previously corpus_diff::priv::diff_stats, which was a hidden
	internal type..  We are moving it here, in the external API so
	that client code can have more information about changes
	statistics.  Change all the previously publicly accessible data
	members into accessor functions.
	* src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New
	type.
	(diff_context::priv::show_added_syms_unreferenced_by_di_): New
	data member.
	(diff_context::priv::priv): Adjust.
	(diff_context::show_added_symbols_unreferenced_by_debug_info):
	Define this new method.
	(corpus_diff::priv::emit_diff_stats):  Do not show the diff stat
	if the only changes is added function or variables symbols and if
	we were instructed to not show added symbols.
	(corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}):
	New data members.
	(corpus_diff::priv::priv): Initialize the
	filters_and_suppr_applied_ data member.
	(corpus_diff::priv::diff_stats): Move this type to
	corpus_diff::diff_stats.
	(corpus_diff::priv::{apply_filters_and_compute_diff_stats,
	emit_diff_stats}): Adjust.
	(corpus_diff::apply_filters_and_suppressions_before_reporting):
	Define new member function.
	(corpus_diff::report): Use the new
	apply_filters_and_suppressions_before_reporting() function, rather
	than applying the filters and suppressions by ourselves.  Also
	adjust to the use the accessors of the new corpus_diff::diff_stats
	type.
	(corpus_diff::{deleted_variables,
	deleted_unrefed_function_symbols,
	deleted_unrefed_variable_symbols}): Define new accessors.
	(corpus_diff::diff_stats::{diff_stats, num_func_removed,
	num_func_added, num_func_changed, num_func_filtered_out,
	net_num_func_changed, num_vars_removed, num_vars_added,
	num_vars_changed, num_vars_filtered_out, net_num_vars_changed,
	num_func_sym_removed, num_func_syms_added, num_var_syms_removed,
	num_var_syms_added}): Define new member functions.
	* include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep,
	get_sym_ids_of_vars_to_keep}): Declare new methods.
	* src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep,
	sym_id_vars_to_keep}): Added data members.
	(symtab_build_visitor_type::{unrefed_fun_symbols,
	unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}):
	Added new data members.
	(symtab_build_visitor_type::symtab_build_visitor_type): Take two
	additional parameters for the function and variable symbol ids to
	keep.
	(symtab_build_visitor_type::add_fn_to_wip_fns): Take the function
	symbols to keep in account when building the exported symbol
	table.
	(symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take
	the variable symbols to keep in account when building the exported
	symbol table.
	(corpus::priv::build_public_decl_table): Adjust the initialization
	of the visitor that walks the ABI artifacts to build the exported
	symbol table to know take a list of function/variable symbols to
	keep.
	(corpus::priv::build_unreferenced_symbols_tables): Ensure that the
	public table of functions/variables is built before doing the work
	of this function.  Also, if a list of variable/function symbols to
	keep is given, drop all symbols that are not in that list on the
	floor.
	(corpus::{get_sym_ids_of_fns_to_keep,
	get_sym_ids_of_vars_to_keep}): Define new accessors.
	* tools/abicompat.cc: New abicompat tool.
	* doc/manuals/abicompat.rst: New documentation source for
	abicompat.
	* doc/manuals/libabigail-tools.rst: Add an entry for the abicompat
	doc.
	* tests/test-abicompat.cc: New test harness for the 'abicompat'
	tool.
	* tests/Makefile.am: Build the runtestabicompat test harness and
	add it to the list of tests harnesses that are run by make check.
	* tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New
	test input.
	* tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise.
	* tests/data/test-abicompat/test0-fn-changed-app: Likewise.
	* tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise
	* tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise.
	* tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise.
	* tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise.
	* tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise.
	* tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise.
	* tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise.
	* tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise.
	* tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise.
	* tests/data/test-abicompat/test1-fn-removed-app: Likewise.
	* tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise.
	* tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise.
	* tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise.
	* tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise.
	* tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise.
	* tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise.
	* tests/data/test-abicompat/test2-var-removed-app: Likewise.
	* tests/data/test-abicompat/test2-var-removed-app.cc: Likewise.
	* tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise.
	* tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise.
	* tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise.
	* tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise.
	* tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise.
	* tests/data/test-abicompat/test3-fn-removed-app: Likewise.
	* tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise.
	* tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise.
	* tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise.
	* tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise.
	* tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.:
	* tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise.
	* tests/data/Makefile.am: Add the new test inputs above to the
	source distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-05 15:43:31 +01:00
Dodji Seketeli
06279598c8 Support reading undefined symbols from an ELF file
In preparation to support the upcoming 'abicompat' tool, we need the
ABI corpus type to capture the symbols that are undefined in a given
ELF file.

This patch changes the ELF reader to capture the undefined symbols as
well as the symbol versions they need to be satisfied.  These
undefined symbols are then stored in the instance ABI corpus build as
a result of the reading of the ELF file.

At the moment, these undefined symbols are not serialized to the
native XML format of libabigail yet.  I guess I'll do that in a
subsequent patch.

	* include/abg-corpus.h (corpus::{set_undefined_fun_symbol_map,
	set_undefined_var_symbol_map, get_undefined_fun_symbol_map_sptr,
	get_undefined_fun_symbol_map, get_sorted_undefined_fun_symbols,
	get_undefined_var_symbol_map_sptr, get_undefined_var_symbol_map,
	get_sorted_undefined_var_symbols}): Declare new methods ...
	* src/abg-corpus.cc (corpus::{set_undefined_fun_symbol_map,
	set_undefined_var_symbol_map, get_undefined_fun_symbol_map_sptr,
	get_undefined_fun_symbol_map, get_sorted_undefined_fun_symbols,
	get_undefined_var_symbol_map_sptr, get_undefined_var_symbol_map,
	get_sorted_undefined_var_symbols}): ... and define them.
	(struct corpus::priv::{undefined_var_symbol_map,
	sorted_undefined_var_symbols, undefined_fun_symbol_map,
	sorted_undefined_fun_symbols}): New data members.
	* src/abg-dwarf-reader.cc (get_symbol_versionning_sections): Also
	return the SHT_GNU_verneed section.
	(get_version_needed_for_versym): New static function.
	(get_version_definition_for_versym): Factorize this function out
	of ..
	(get_version_for_symbol): ... this one.  Take a flag that says if
	we want the definition version or the needed version of a symbol.
	Extend the implementation using the two new function
	get_version_needed_for_versym() and
	get_version_definition_for_versym() above.  This function now
	returns the version either for a defined & exported symbol, or for
	an undefined symbol.
	(lookup_symbol_from_sysv_hash_tab)
	(lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_symtab):
	Adjust for the change of signature of get_version_for_symbol().
	(read_context::{undefined_fun_syms_, undefined_var_syms_}): New
	data members.
	(read_context::lookup_elf_symbol_from_index): Adjust for
	invocation of the new signature of get_version_for_symbol().
	(read_context::{undefined_fun_syms_sptr, undefined_fun_syms,
	undefined_var_syms_sptr, undefined_var_syms}): Define new methods.
	(read_context::load_symbol_maps): Add support for loading
	undefined symbols and their versions.
	(read_context::maybe_load_symbol_maps):  Take in account the need
	to load undefined symbols as well.
	(read_corpus_from_elf): Once the undefined symbols have been read
	from the ELF file, stuff them into the resulting ABI corpus that
	has been built.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 19:57:05 +01:00
Dodji Seketeli
0b5edf13d7 Show the pretty representation of deleted variables in the diff output
While working on the 'abicompat' tool, it appeared that only the names
of deleted variables where printed in the diff report; what we want is
the full pretty representation of the variables, that is, we want
their type too.

This patch changes the reporting code of the corpus_diff to show the
full pretty representation of deleted variables.

	* src/abg-comparison.cc (corpus_diff::report): Show the pretty
	representation of deleted variables in all cases.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 19:57:05 +01:00
Dodji Seketeli
f091ff1ac2 Fix status checking in abidw
Now that the status is a bit field, one needs to check the OK bit in
the status for successful operation state.  Oops.

	* tools/abidw.cc (main): Fix successful status checking.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 19:57:04 +01:00
Dodji Seketeli
6be1218195 Rename elf_symbol::get_is_defined() to elf_symbol::is_defined()
It's let's awkward to type if (elf_symbol->is_defined()); than
...->get_is_defined().  So I am going to the former.  A chance we
still can change ABI here ;-)

	* include/abg-ir.h (elf_symbol::get_is_defined): Rename into
	elf_symbol::is_defined.
	(elf_symbol::set_is_defined): Rename into elf_symbol::is_defined.
	* src/abg-ir.cc (elf_symbol::get_is_defined): Likewise, rename
	this into elf_symbol::is_defined.
	(elf_symbol::set_is_defined): Likewise, rename this into
	elf_symbol::is_defined.
	(elf_symbol::{elf_symbol, is_public}): Adjust.
	* src/abg-writer.cc (write_elf_symbol): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 19:57:04 +01:00
Dodji Seketeli
d6bba81ac0 Update the copyright years of include/abg-corpus.h
* include/abg-corpus.h: Update the copyright years of this file.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 19:57:04 +01:00
Dodji Seketeli
5c19aa1061 Make tests/data directory have its own Makefile
On RHEL 6, make distcheck was trying to compile the C++ files that are
in tests/data.  Having a dedicated tests/data Makefile.am which only
put the data files into an EXTRA_DIST variable fixes that.

	* configure.ac(AC_CONFIG_FILE): Generate a new tests/data/Makefile
	file.
	* tests/Makefile.am: Link the data/ sub-directory from here.  Move
	the EXTRA_DIST definition to ...
	* tests/data/Makefile.am: ... this new file here.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-20 11:26:30 +01:00
Dodji Seketeli
d259f37ca3 Hmh, finally EXTRA_DIST was just fine
* tests/Makefile.am: Put EXTRA_DIST back.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-20 10:53:58 +01:00
Dodji Seketeli
a6422da0a2 Make sure we don't try to build test data
* tests/Makefile.am: Replace EXTRA_DIST with noinst_DATA.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-19 21:20:27 +01:00
Dodji Seketeli
27e958dbba Fix manual documentation generation
The manual building was failing in make distcheck because it was being
built using the standard 'html' target.  That target needs the output
to not be rebuilt each time make install-html is called.  Which is not
easily possible for us.  So for now, the apidoc is being generated
using the html-doc target.  Also fix some other issues in the Makefile.

	* doc/manuals/Makefile.am: Trigger the manual generation from the
	html-doc target.  Add the source files to the distribution.  Fix
	the clean target.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-19 21:00:50 +01:00
Dodji Seketeli
42474ecf70 Fix apidoc building
The apidoc building was failing in make distcheck because it was being
built using the standard 'html' target.  That target needs the output
to not be rebuilt each time make install-html is called.  Which is not
easily possible for us.  So for now, the apidoc is being generated
using the html-doc target.

	* doc/Makefile.am: Trigger the building frm the html-doc target.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-19 21:00:16 +01:00
Dodji Seketeli
c5ac6e828b Cleanup of configure.ac
* configure.ac: Remove useless variables and fix a typo.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-19 17:38:38 +01:00
Dodji Seketeli
d09799377a Add loads of forgotten test data files to source distribution
* tests/Makefile.am: Add lots of test data file that were
	forgotten and then revealed by running make distcheck.  Also fix
	some wrong paths to test data files.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-19 17:31:34 +01:00
Dodji Seketeli
7e59bcc657 Use DESTDIR in doc/manuals/Makefile.am when creating the manuals
* doc/manuals/Makefile.am: Use the DESTDIR variable when
	addressing the destination directory of the created manuals.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-19 17:30:12 +01:00
Dodji Seketeli
bbcc2165d2 Fix a thinko in doc/Makefile.am
* apidoc-install-html-doxygen: Make sure that the directory
	$(DESTDIR)$(docdir) does not exist, before trying to create it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-19 17:28:21 +01:00
Dodji Seketeli
1cdb8456c8 Add doc/api/libabigail.doxy to source distribution
Make distcheck revealed that the file doc/api/libabigail.doxy was
missing from the source distribution.  This patch adds it.

	* doc/Makefile.am: Add the file api/libabigail.doxy to source
	distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-19 17:25:54 +01:00
Dodji Seketeli
52a33575b3 Make the install-html target of apidoc/manual be conditional
When running 'make distcheck', make install is automatically run,
which runs 'make install-html', especially in the apidoc and manual
sub-directories.  That triggers the building of the documentation,
using doxygen and python-sphinx even when these two packages are not
installed; in this case, install-html fails because doxygen or or the
python-sphinx binary is not found.  So this patch conditionnaly make the
install-html target run.  To run them, one must enable the building of
the apidoc or the manuals.  Note that just installing doxygen or
python-sphinx enables the building of the apidoc and the manuals.

	* configure.ac: add --enable-apidoc and --enable-manual.  Add the
	two ENABLE_APIDOC and ENABLE_MANUAL automake conditional
	variables.  Add the activation of the apidoc and manual into the
	final package configuration report.
	* doc/Makefile.am: Make the install-html, install-data-local and
	uninstall-local targets conditional on the ENABLE_APIDOC
	conditional variable.
	* doc/manuals/Makefile.am: Likewise, make the install-html,
	install-data-local and uninstall-data-local conditional on the
	ENABLE_MANUAL conditional variable.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-19 17:08:10 +01:00
Dodji Seketeli
1e55a1245e Make the alt dwarf debug file *not* be a symlink
* tests/data/test-alt-dwarf-file/test0-debug-dir/.build-id/16/7088580c513b439c9ed95fe6a8b29496495f26.debug:
	Make this be a real file, no more a symlink to
	../../../test0-common-dwz.debug.
	* tests/data/test-alt-dwarf-file/test0-report.txt: Now that the
	file above is no more a symlink the message emitted by the test
	changes.  It now says that the file found is the base name of the
	real file.  So change the reference report accordingly.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-19 16:50:48 +01:00
Dodji Seketeli
479d8fa6d8 Use the POSIX 1003.1-1988 tar format for dist tar
* configure.ac: For the tar invocation made by make dist, make
	sure to use the POSIX 1003.1-1988 tar format that can support file
	names of more than 99 characters.  This is useful for the
	test-alt-dwarf-file test that has data made of a file which patch
	has more than 99 characters.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-19 15:38:51 +01:00
Dodji Seketeli
1b4e3844e9 Nested automake conditionals don't work
* configure.ac (ENABLE_ZIP_ARCHIVE_AND_CXX11): Define this
	automake condition variable that is true if both the zip archive
	and c++11 features are enabled.  This is important to know if the
	test runtestdot is going to be compiled.  That test needs both
	c++11 and the zip archive features.
	* tests/Makefile.am: Do not nest automake conditional statements.
	It does not work.  Rather, use the new
	ENABLE_ZIP_ARCHIVE_AND_CXX11 condition variable.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-19 10:23:41 +01:00
Dodji Seketeli
8a886caad9 INSTALL file is not yet in the distribution
* Makefile.am: Do not say that INSTALL file is in the distribution
	while it is not.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-19 10:21:06 +01:00
Dodji Seketeli
c134ed84c7 If c++11 is disable do not execute the runtestdot test
* tests/Makefile.am: runtestdot should not be executed if c++11 is
	disabled.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-19 09:17:13 +01:00
Dodji Seketeli
03e57be0d1 make html now generates the apidoc, manual and web site
* doc/Makefile.am (html-local): Make the html file generation be
	triggered by the html-local target, not the html target.  The html
	target is a recursive target that calls the the html-local targets
	under each directory.
	(apidoc-html-doxygen): Rename the doc-html-doxygen target into
	(apidoc-install-html-doxygen): Rename doc-install-html-doxygen
	into this.  this.
	(DO_HTML, DO_INSTALL_HTML): Adjust.
	(install-data-local): New target.
	* doc/manuals/Makefile.am (install-html, install-data-local): New
	targets.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-18 23:54:16 +01:00