Commit Graph

29 Commits

Author SHA1 Message Date
Frank Ch. Eigler
09338a2590 abidb: Introduce a tool to manage the ABI of a Linux distribution
This patch introduces a new tool named abidb.  It manages a Git
repository of the Application Binary Interfaces of a set of shared
libraries.  Those ABIs are stored in the Git repository in the form of
ABIXML files.

The tool then supports the verification of the ABI compatibility of a
given binary against the stored ABIs of shared libraries.

	* configure.ac: Condition building abidb on the presence of python
	and the required modules.
	* doc/manuals/Makefile.am: Add the abidb.rst documentation to
	source distribution.  Distribute the abidb.1 manpage file as well.
	* doc/manuals/abidb.rst: New documentation file.
	* doc/manuals/conf.py: Configure the generation of the abidb.1
	manage from the abidb.rst file above.
	* doc/manuals/libabigail-tools.rst: Add a reference to the new
	abidb tool.
	* tests/Makefile.am: Register runabidb1.sh and runabidb2.sh as
	tests for abidb.  Register runabidb1.sh.in and runabidb2.sh.in as
	input files for autoconf generated runabidb1.sh and runabidb2.sh.
	* tests/data/Makefile.am: Add abidb2client.c, abidb2so.c and
	abidb2soBAD.c to source distribution.
	* tests/data/abidb2client.c: New source file for test input binaries.
	* tests/data/abidb2so.c: Likewise.
	* tests/data/abidb2soBAD.c: Likewise.
	* tests/runtestabidb1.sh.in: New test script input for autoconf generation.
	* tests/runtestabidb2.sh.in: Likewise.
	* tools/Makefile.am: Add the new abidb tool to the set of tools.
	* tools/abidb: The New Tool, ladies and gentlemen!

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2024-03-22 17:18:17 +01:00
Dodji Seketeli
7bd6983052 Make Front Ends first class citizens
This patch is a reorganization of the code to better support the need
for having several different front-ends.

In the libabigail pipeline of operation, a front-end is the part of
the pipeline that analyses the input file.  For instance, to analyse
an ELF file, there is going to be one front-end.  To analyse an ABIXML
file, there is going to be another front-end.

The middle-end is the part of the pipeline that interacts with the
internal representation of ABIs.  The middle-end knows how to analyse,
compare ABI corpora provide an internal representation of the
comparison result and analyse it as well.

The back-end would be the part of the front-end that knows how to
serialize internal representations of ABIs and ABI comparison results.

One could thus imagine a front-end that understands the DWARF debug
info format embedded in an ELF file.  Another front-end would be
dedicated to the CTF debug info format, and so on.

Front-ends can share capabilities.  For instance, DWARF and CTF
front-ends are ELF based front end.  As such, they share capabilities
to understand the ELF format.  They don't share much with the ABIXML
front-end, however, as it's based on XML, which has almost nothing in
common with ELF.

To support this organization of concepts, this patch introduces a new
hierarchy of types in the form of C++ classes.

All front-ends implements the "Front End Interface".  As such, they
all inherit the abigail::fe_iface class.

That class provides properties and behaviours that are shared by all
front-ends that libabigail supports today.  Namely, that class
provides access to some of the options that are relevant to operating
the front-end, to the ABI corpus or corpus group being constructed and
to the suppression specifications that are considered.  It also
provides an abstract interface to perform the actual loading of the
ABI corpus.  That abstract interface has to be implemented by every
single concrete front-end that is provided in libabigail.

Then, there is the "ELF Reader" front-end.  Its class name is
abigail:🧝:reader.  It inherits the abigail::fe_iface class and
implements the fe_iface::load_corpus() so that the ELF properties of
the ELF file be loaded and exposed in the ABI corpus as returned by
the fe_iface::corpus() accessor.  This ELF reader front-end also
provides lots of capabilities that are specific to accessing ELF
content.

Then, there is a common base class for ELF-based front-ends to come,
named abigail::elf_based_reader, which inherits the abigail:🧝:reader
class.  The purpose of this base class is to provide common properties
and behaviours that are necessary to implement things like a DWARF or
a CTF front-end, or any other front-end to support an ELF-based debug
info format.

Then, there is a CTF front-end which class is named
abigail::ctf::reader.  It inherits the abigail::elf_based_reader class
and implements the fe_iface::load_corpus() interface to load and
analyse the CTF-specific properties of the ELF file.  To do this,
abigail::ctf::reader::load_corpus() re-uses the abigail:🧝:load_corpus() member
function to load the generic ELF parts of the ABI corpus.  This reader
then constructs the internal representation of the ABI corpus and
passes it to the middle-end for further analysis.

Then, there is a DWARF front-end which class is named
abigail::dwarf::reader.  It inherits the abigail::elf_based_reader
class and implements the fe_iface::load_corpus() interface to load and
analyse the DWARF-specific properties of the ELF file.  To do this,
abigail::dwarf::reader re-uses the abigail:🧝:load_corpus() member
function to load the generic ELF parts of the ABI corpus, just like
what the CTF front-end does.  And then, just like the CTF front-end,
this reader then constructs the internal representation of the ABI
corpus and passes it to the middle-end for further analysis.

Lastly, there is an ABIXML front-end which class is named
abigail::abixml::reader.  It inherits the abigail::fe_iface class
directly.  Note that unlike the two previous front-ends, this one
doesn't inherit the elf_based_reader base class, for reasons that
should be obvious to the astute reader by now.  So, this front-end
implements the abigail::fe_iface::load_corpus() abstract interface to
load the properties for the ABI corpus represented in the ABIXML
format, construct the internal representation and pass it to the
middle-end for further analysis.

The code of the tools got adapted to use these front-ends.

The support of CTF is still guarded by #ifdef WITH_CTF pre-processor
macros, but the one cool side effect is that the amount of guarded
code is reduced.  Basically, it's only the creation of the CTF
front-end that is guarded.  After its creation, what is returned is an
instance of abigail::elf_based_reader::reader, exactly like what is
returned by the creation of a DWARF front-end.  Thus, the rest of the
code is exactly the same, regardless of the kind of front-end.  I
believe this results in a more elegant and maintainable code.

As a proof-of-concept, this patch also provides the
create_best_elf_based_reader function.  This function analyses the ELF
file and depending on the kind of debug info it provides, returns the
right front-end for it.  Maybe at some point, all the #ifdef WITH_CTF
guard pre-processing macros will be constrained in a single function
like this one that will take the decision of instantiating the right
front-end.  The rest of the code will be as generic as it gets.

The patch adjusts the reference abixml files produced by the CTF
front-end because it now emits the <elf-needed> XML element which was
not emitted before.  This is done because the CTF front-end inherits
the elf-reader which reads the "elf-needed" property from the binary,
without explicit intervention from the CTF front-end.

The patch passes 'make distcheck' on all the supported platforms.

	* include/abg-fwd.h (build_internal_underlying_enum_type_name):
	Move this here from src/abg-dwarf-reader.cc.
	* include/abg-elf-reader-common.h: Delete this file.  Its content
	is going to be put in the new include/abg-elf-reader.h.
	* src/abg-elf-reader-common.cc: Likewise.
	* include/abg-{elf-based-reader, elf-reader, fe-iface}.h: Add new
	files.
	* src/abg-fe-iface.cc: Likewise.
	* include/Makefile.am: Add the new file abg-fe-iface.h,
	abg-elf-based-reader.h and abg-elf-reader.h to source distribution
	and remove include/abg-elf-reader-common.h from source
	distribution.
	* src/abg-ir.cc (build_internal_underlying_enum_type_name): Move
	this here from abg-dwarf-reader.cc so that it can be used by other
	readers.
	* include/abg-reader.h (abigail::abixml::reader): Rename the
	namespace abigail::xml_reader into this one.
	(read_context, create_native_xml_read_context)
	(read_context_get_path, read_corpus_from_native_xml)
	(read_corpus_from_native_xml_file)
	(read_corpus_group_from_native_xml)
	(read_corpus_group_from_native_xml_file): Remove.
	(read_translation_unit_from_file)
	(read_translation_unit_from_buffer)
	(read_translation_unit_from_istream)
	(read_translation_unit)
	(consider_types_not_reachable_from_public_interfaces)
	(get_types_from_type_id, get_artifact_used_by_relation_map)
	(load_canonical_type_ids): Take an fe_iface&, not a read_context.
	(create_reader): Declare new function that returns a
	fe_iface_sptr.
	(read_corpus_from_abixml, read_corpus_from_abixml_file)
	(read_corpus_group_from_abixml)
	(read_corpus_group_from_abixml_file): Declare new functions.
	* src/abg-reader.cc (namespace abixml): Rename the
	xml_reader namespace into this.
	(abixml::reader_sptr): New typedef.
	(abixml::reader): Rename read_context into this.  Make it
	inherit the fe_iface interface.
	(abixml::reader::{m_path, m_env, m_corpus, m_corpus_group,
	m_exported_decls_builder, m_supprs}): Remove these data members
	that are now part of the fe_iface parent type.
	(abixml::reader::{set_environment, get_corpus, set_corpus,
	set_corpus_group, maybe_add_fn_to_exported_decls,
	maybe_add_var_to_exported_decls,
	maybe_check_abixml_canonical_type_stability,
	suppression_matches_function_sym_name,
	suppression_matches_variable_name,
	suppression_matches_variable_sym_name}): Remove.
	(read_corpus_from_input): Remove.  Actually the code of this went
	into abixml::reader::read_context().
	(abixml::reader::get_libxml_reader): Rename the get_reader
	member function into this.
	(abixml::add_reader_suppressions): Rename
	add_read_context_suppressions into this.
	(abixml::reader::read_corpus): Implement this virtual
	member function if the fe_iface parent interface.
	(maybe_set_naming_typedef, advance_cursor)
	(handle_version_attribute, walk_xml_node_to_map_type_ids)
	(read_elf_needed_from_input, read_symbol_db_from_input)
	(get_or_read_and_add_translation_unit, build_needed)
	(read_elf_needed_from_input, add_read_context_suppressions)
	(maybe_set_artificial_location, maybe_set_naming_typedef)
	(build_namespace_decl, build_elf_symbol)
	(build_elf_symbol_from_reference, build_elf_symbol_db)
	(build_function_parameter, build_function_decl)
	(build_function_decl_if_not_suppressed, function_is_suppressed)
	(type_is_suppressed, build_var_decl_if_not_suppressed)
	(variable_is_suppressed, variable_is_suppressed, build_var_decl)
	(build_type_decl, build_qualified_type_decl)
	(build_pointer_type_def, build_reference_type_def)
	(build_function_type, build_subrange_type, build_array_type_def)
	(build_enum_type_decl_if_not_suppressed, build_enum_type_decl)
	(build_typedef_decl, build_class_decl_if_not_suppressed)
	(build_union_decl_if_not_suppressed, build_class_decl)
	(build_union_decl, build_function_tdecl, build_class_tdecl)
	(build_type_tparameter, build_type_composition)
	(build_non_type_tparameter, build_non_type_tparameter)
	(build_template_tparameter, build_template_parameter, build_type)
	(handle_type_decl, handle_namespace_decl)
	(handle_qualified_type_decl, handle_pointer_type_def)
	(handle_reference_type_def, handle_function_type)
	(handle_array_type_def, handle_enum_type_decl)
	(handle_typedef_decl, handle_var_decl, handle_function_decl)
	(handle_class_decl, handle_union_decl, handle_function_tdecl)
	(read_translation_unit_from_istream): Take or use an
	abixml::reader rather than a read_context.
	(read_translation_unit, read_translation_unit_from_input)
	(consider_types_not_reachable_from_public_interfaces)
	(get_types_from_type_id, get_artifact_used_by_relation_map)
	(read_corpus_group_from_input, read_translation_unit)
	(handle_element_node, read_location, read_artificial_location)
	(load_canonical_type_ids) : Take an fe_iface&, not a read_context.
	(create_abixml_reader): Rename create_native_xml_read_context
	into this.  Make it return a fe_iface_sptr.
	(read_corpus_from_abixml): Rename read_corpus_from_abixml into
	this.
	(read_corpus_from_abixml_file): Rename
	read_corpus_from_native_xml_file into this.
	(read_context_get_path): Remove.
	* include/abg-tools-utils.h
	(abigail::tools_utils::{file_has_dwarf_debug_info,
	file_has_ctf_debug_info}): Declare new functions.
	(create_best_elf_based_reader): Declare new function.
	* include/abg-corpus.h (corpus::add): Pass the translation unit by
	reference.
	(corpus::exported_decls_builder::maybe_add_{fn,var}_to_exported_fns):
	Take a const parameter.
	* src/abg-corpus-priv.h
	(corpus::exported_decls_builder::priv::add_{fn,var}_to_exported):
	Take a const parameter and adjust.
	* src/abg-corpus.cc
	(corpus::exported_decls_builder::maybe_add_{fn,var}_to_exported_fns):
	Take a const parameter.
	(corpus::add): Take a reference to translation_unit_sptr.
	* include/abg-suppression.h (abigail::fe_iface): Forward-declare
	this.
	(abigail::{suppression_sptr, suppressions_type}): Declare these
	types here.
	(abigail::suppr::{suppression_can_match,
	suppression_matches_function_name,
	suppression_matches_function_sym_name,
	suppression_matches_variable_name,
	suppression_matches_variable_sym_name,
	suppression_matches_type_name_or_location,
	is_elf_symbol_suppressed, is_elf_symbol_suppressed,
	is_function_suppressed, is_variable_suppressed,
	is_type_suppressed}): Declare these functions here.
	* src/abg-suppression-priv.h (function_is_suppressed)
	(variable_is_suppressed, type_is_suppressed)
	(is_elf_symbol_suppressed): Remove these template functions.
	* src/abg-suppression.cc (suppression_matches_function_name)
	(suppression_matches_function_sym_name): Remove.
	(variable_is_suppressed, suppression_can_match)
	(suppression_matches_function_name)
	(suppression_matches_function_sym_name)
	(suppression_matches_variable_name)
	(suppression_matches_variable_sym_name)
	(suppression_matches_type_name_or_location)
	(is_elf_symbol_suppressed, is_elf_symbol_suppressed)
	(is_function_suppressed, is_variable_suppressed)
	(is_type_suppressed): New functions.
	* include/abg-ctf-reader.h (abigail::ctf::{read_context,
	create_read_context, read_corpus,
	read_and_add_corpus_to_group_from_elf,
	set_read_context_corpus_group, reset_read_context, dic_type_key}):
	Remove.
	(ctf::{create_reader, reset_reader}): Declare new
	functions.
	* src/abg-ctf-reader.cc (read_context): Remove.
	(process_ctf_typedef, process_ctf_base_type)
	(build_ir_node_for_variadic_parameter_type)
	(process_ctf_function_type, process_ctf_sou_members)
	(process_ctf_forward_type, process_ctf_struct_type)
	(process_ctf_union_type, process_ctf_array_type)
	(process_ctf_qualified_type, process_ctf_pointer_type)
	(process_ctf_enum_type, fill_ctf_section)
	(lookup_symbol_in_ctf_archive, dic_type_key): Forward-declare
	these static functions.
	(ctf::reader): New class that is the abstraction
	of the CTF reader.  It extends the abigail::elf_based_reader
	class.  This is a renaming of the
	abigail::ctf::read_context class.
	(ctf::reader::{elf_handler, elf_fd,
	elf_handler_dbg, elf_fd_dbg, symtab, debug_info_root_paths_,
	debug_info_root_paths_}): Remove these data members as they are
	now properties of the abigail::elf_reader class, which is a parent
	class of this abigail::ctf::reader class.
	(ctf::reader::{exported_decls_builder,
	maybe_add_fn_to_exported_decls, current_corpus_group,
	has_corpus_group, main_corpus_from_current_group,
	current_corpus_is_main_corpus_from_current_group,
	should_reuse_type_from_corpus_group}): Remove these accessors
	that can now be used from the parent classes abigail::{elf_reader,
	elf_based_reader}.
	(ctf::reader::reader): This now delegates to the constructor of
	elf_based_reader.  It doesn't pass any argument to initialize()
	anymore.
	(ctf::reader::initialize): Add an overload with no
	parameter.  In the other overload, do not take a pointer to an
	environment as no new environment can be passed to the instance of
	reader that is being reset.  Adjust the code of the initializer to
	reflect all the data members that got removed.
	(ctf::{env, find_ctfa_file, slurp_elf_info,
	process_ctf_archive, process_ctf_type, lookup_type, read_corpus,
	~reader}): New member functions.  Most of these were free-form
	functions that took ctf::read_context as first parameter.
	In read_corpus, do not set the corpus::LINUX_KERNEL_BINARY_ORIGIN
	origin as that is now done by elf::reader when it reads the
	binary.
	(lookup_type): Remove.  These are now member functions of the
	ctf::reader class.
	(process_ctf_typedef, process_ctf_base_type)
	(build_ir_node_for_variadic_parameter_type)
	(process_ctf_function_type, process_ctf_sou_members)
	(process_ctf_forward_type, process_ctf_struct_type)
	(process_ctf_union_type, process_ctf_array_type)
	(process_ctf_qualified_type, process_ctf_pointer_type): Take a
	ctf::reader rather an ctf::read_context.  Adjust the
	content of the functions.
	(process_ctf_type, lookup_type, process_ctf_archive): Remove these
	and turn them into member functions of ctf::reader.
	(open_elf_handler, close_elf_handler, find_alt_debuginfo): Remove
	these ELF handling functions as ELF handling is now done by the
	elf_reader parent class.
	(fill_ctf_section): Take a const pointer to Elf_Scn.
	(slurp_elf_info, find_ctfa_file): Remove this and make it be a
	member of ctf::reader.  Also, make it handle only CTF
	reader specific pieces.  slurp_elf_info now delegates the reading
	of generic ELF properties to elf::reader by calling
	elf::reader::read_corpus().
	(create_read_context, read_corpus, set_read_context_corpus_group)
	(read_and_add_corpus_to_group_from_elf): Remove these functions.
	(create_reader, reset_reader): Create new functions
	(dic_type_key): Make this static.
	* include/abg-dwarf-reader.h (abigail::dwarf::elf_type):
	Move this enum into the namespace abigail::elf_reader in the file
	include/abg-elf-reader.h.
	(abigail::dwarf::{read_context, read_context_sptr,
	create_read_context, read_context_get_path, reset_read_context,
	add_read_context_suppressions, set_read_context_corpus_group,
	read_corpus_from_elf, read_and_add_corpus_to_group_from_elf,
	read_and_add_corpus_to_group_from_elf,
	add_read_context_suppressions, refers_to_alt_debug_info,
	has_alt_debug_info, get_soname_of_elf_file, get_type_of_elf_file,
	set_debug_info_root_path, get_debug_info_root_path,
	get_show_stats, set_show_stats, set_drop_undefined_syms,
	set_do_log, set_environment, get_environment}): Remove.
	* src/abg-dwarf-reader.cc (struct dwfl_deleter, dwfl_sptr)
	(addr_elf_symbol_sptr_map_type, address_set_type)
	(address_set_sptr): Delete these types.
	(read_context::options_type): Remove.  The data members of this
	type got moved to struct fe_iface::options_type.
	(find_alt_debug_info_link, find_alt_debug_info_path)
	(find_alt_debug_info, lookup_data_tag_from_dynamic_segment)
	(elf_file_type, refers_to_alt_debug_info, has_alt_debug_info)
	(get_soname_of_elf_file, get_type_of_elf_file) : Remove these ELF
	specific functions from here; move them to the elf_reader
	namespace.
	(dwarf::reader): Create new class that extends
	elf_based_reader.  dwarf::read_context is renamed into this
	type, actually.
	(dwarf::reader::die_source_dependant_container_set::get_container):
	Adjust.
	(dwarf::reader::{supprs_, dwarf_version_,
	offline_callbacks_, debug_info_root_paths_, handle_, dwarf_,
	alt_fd_, alt_dwarf_, alt_debug_info_path_, elf_module_,
	elf_handle_, elf_path_, symtab_section_, cur_corpus_group_,
	cur_corpus_, dt_needed_, dt_soname_, elf_architecture_,
	exported_decls_builder_, options_, drop_undefined_syms_}): Remove
	these ELF-related data members to move them into the elf_reader
	namespace.
	(maybe_propagate_canonical_type)
	(build_translation_unit_and_add_to_ir, build_ir_node_from_die)
	(add_or_update_class_type, add_or_update_union_type)
	(build_ir_node_for_void_type)
	(build_ir_node_for_variadic_parameter_type, build_function_decl)
	(function_is_suppressed, build_or_get_fn_decl_if_not_suppressed)
	(build_var_decl, build_or_get_var_decl_if_not_suppressed)
	(variable_is_suppressed)
	(propagate_canonical_type)
	(get_parent_die, get_scope_die, die_is_at_class_scope)
	(die_location, die_qualified_type_name, die_qualified_name)
	(die_qualified_type_name_empty)
	(die_return_and_parm_names_from_fn_type_die)
	(die_function_signature, die_function_type_is_method_type)
	(die_pretty_print_type, die_pretty_print_decl, die_pretty_print)
	(maybe_canonicalize_type, build_subrange_type)
	(build_subranges_from_array_type_die, compare_dies, die_location)
	(die_loc_and_name, die_is_effectively_public_decl)
	(maybe_cache_type_comparison_result)
	(get_cached_type_comparison_result)
	(maybe_get_cached_type_comparison_result, die_is_at_class_scope)
	(die_function_type_is_method_type, die_member_offset)
	(die_qualified_type_name, die_qualified_decl_name)
	(die_qualified_name, die_qualified_type_name_empty)
	(die_return_and_parm_names_from_fn_type_die)
	(die_function_signature, die_pretty_print_type)
	(die_pretty_print_decl, die_pretty_print)
	(at_least_one_decl_only_among_odr_relevant_dies)
	(compare_as_type_dies, compare_as_decl_and_type_dies)
	(fn_die_equal_by_linkage_name, try_canonical_die_comparison)
	(maybe_propagate_canonical_type, propagate_canonical_type)
	(compare_dies, compare_dies_during_canonicalization)
	(find_import_unit_point_between_dies, get_parent_die)
	(get_scope_die, find_lower_bound_in_imported_unit_points)
	(build_translation_unit_and_add_to_ir)
	(build_namespace_decl_and_add_to_ir, build_type_decl)
	(build_enum_underlying_type, build_enum_type)
	(finish_member_function_reading)
	(maybe_finish_function_decl_reading)
	(lookup_class_or_typedef_from_corpus)
	(is_function_for_die_a_member_of_class)
	(add_or_update_member_function, add_or_update_class_type)
	(add_or_update_union_type, build_qualified_type)
	(schedule_array_tree_for_late_canonicalization)
	(maybe_strip_qualification, build_pointer_type_def)
	(build_reference_type, build_function_type, build_subrange_type)
	(build_subranges_from_array_type_die, build_array_type)
	(build_typedef_type, build_or_get_var_decl_if_not_suppressed)
	(build_var_decl, function_is_suppressed)
	(build_or_get_fn_decl_if_not_suppressed, variable_is_suppressed)
	(type_is_suppressed, type_is_suppressed)
	(get_opaque_version_of_type, create_default_fn_sym)
	(build_function_decl, maybe_canonicalize_type)
	(build_ir_node_from_die)
	(build_ir_node_for_variadic_parameter_type): Take a reference to
	the new dwarf::reader rather than to the previous
	read_context.  Adjust the function body.
	(return_comparison_result): Adjust.
	(dwarf::reader::reader): Adjust this from
	read_context::read_context.
	(dwarf::reader::initialize): Adjust from
	dwarf::read_context::initialize.
	(dwarf::reader::create): New factory static member
	function.
	(dwarf::reader::~reader): This doesn't have to clear
	anything for now.
	(dwarf::reader::read_corpus): New virtual member function
	which implements the fe_iface::read_corpus pure virtual interface.
	This now delegates the reading of the generic ELF properties to
	elf::reader by calling elf::reader::read_corpus().
	Newer front-ends will be able to do the same.
	(dwarf::reader::reset_corpus): New member function.
	(dwarf::reader::read_debug_info_into_corpus): Adjust.  This
	is now a member function.  Also, do not set the
	corpus::LINUX_KERNEL_BINARY_ORIGIN here as it's now set by the
	elf::reader when it loads the binary.
	(dwarf::reader::{env, drop_undefined_syms,
	drop_undefined_syms, dwarf_elf_handle, dwarf_per_die_source,
	elf_path, compute_canonical_die_offset, get_die_source,
	get_die_from_offset, get_die_qualified_name,
	get_die_pretty_type_representation, get_die_qualified_type_name,
	get_die_pretty_representation, odr_is_relevant,
	set_canonical_die_offset, get_canonical_die_offset,
	erase_canonical_die_offset, die_wip_classes_map,
	die_wip_function_types_map, compare_before_canonicalisation,
	resolve_declaration_only_classes, resolve_declaration_only_enums,
	symbol_already_belongs_to_a_function,
	fixup_functions_with_no_symbols, canonicalize_types_scheduled,
	tu_die_imported_unit_points_map, die_parent_map,
	find_symbol_table_section, get_variable_address,
	exported_decls_builder, load_all_types, load_in_linux_kernel_mode,
	show_stats, do_log, build_die_parent_maps): Adjust.
	(offset_pairs_stack_type::rdr_): Changed the ctxt_ into this.
	(offset_pairs_stack_type::offset_pairs_stack_type): Adjust.
	(offset_pairs_stack_type::{erase_redundant_type_pair_entry,
	cancel_canonical_propagated_type}): Adjust.
	(dwarf::reader::{get_suppressions, offline_callbacks,
	create_default_dwfl, dwfl_handle, elf_module, elf_handle,
	add_debug_info_root_paths, add_debug_info_root_path,
	find_alt_debug_info, dwarf, alt_dwarf, alt_debug_info_path,
	current_corpus, reset_current_corpus, current_corpus_group,
	has_corpus_group, main_corpus_from_current_group,
	current_corpus_is_main_corpus_from_current_group,
	should_reuse_type_from_corpus_group, function_symbol_is_exported,
	variable_symbol_is_exported, symtab, dt_needed, dt_soname,
	elf_architecture, is_elf_symbol_suppressed,
	load_dt_soname_and_needed, load_elf_architecture,
	load_elf_properties, maybe_add_fn_to_exported_decls,
	maybe_add_var_to_exported_decls}): Remove these member functions
	as they got moved into the elf_reader namespace or into the
	fe_iface class.
	(dwarf::read_context::{suppression_can_match,
	suppression_matches_function_sym_name,
	suppression_matches_function_name,
	suppression_matches_variable_name,
	suppression_matches_variable_sym_name,
	suppression_matches_type_name_or_location}): Move these into the
	suppr namespace.  Make it take an additional parameter that is
	reference fe_iface.
	(dwarf::reader::load_debug_info): Remove.  This became
	merged into dwarf::read_debug_info_into_corpus.
	(dwarf::{set_debug_info_root_path,
	get_debug_info_root_path, get_show_stats, set_drop_undefined_syms,
	set_do_log}): Remove.
	(add_read_context_suppressions)
	(set_read_context_corpus_group, read_corpus_from_elf): Remove.
	(read_debug_info_into_corpus): This became a member function of
	dwarf::reader.
	(create_reader): Renamed create_read_context into this.
	Make it return an elf_based_reader_sptr, like the other front-end
	factory functions.  Adjust.
	(reset_dwarf_reader): Renamed reset_read_context into this.
	Adjust.
	(read_corpus_from_elf): Adjust.
	* src/abg-elf-based-reader.cc: New file.
	* src/abg-elf-helpers.h (struct dwfl_deleter, dwfl_sptr)
	(addr_elf_symbol_sptr_map_type, address_set_sptr): Move these
	types here from abg-dwarf-reader.cc
	(initialize_dwfl_callbacks, lookup_data_tag_from_dynamic_segment):
	* src/abg-elf-helpers.cc (lookup_data_tag_from_dynamic_segment)
	(lookup_data_tag_from_dynamic_segment, initialize_dwfl_callbacks)
	(create_new_dwfl_handle, get_soname_of_elf_file): New functions
	that got moved here from the factorizing of abg-dwarf-reader.cc
	and abg-ctf-reader.cc.
	* src/abg-tools-utils.cc (file_has_dwarf_debug_info)
	(file_has_ctf_debug_info): New functions.
	(load_generate_apply_suppressions): Take an elf_based_reader, not
	a dwarf::read_context.
	(maybe_load_vmlinux_dwarf_corpus): Adjust the body to use the new
	front-end types.
	* src/Makefile.am: Add the new files src/abg-{fe-iface,
	elf-based-reader, elf-reader}.cc to source distribution. Remove
	src/abg-elf-reader-common.cc.
	* tools/Makefile.am: Factorize linking to libabigail.so by using
	LDADD.
	* tools/abicompat.cc (read_corpus, main): Adjust.
	* tools/abidiff.cc (set_suppressions)
	(set_native_xml_reader_options, handle_error, main): Adjust.
	* tools/abidw.cc (set_suppressions, load_corpus_and_write_abixml)
	(load_kernel_corpus_group_and_write_abixml): Adjust.
	* tools/abilint.cc (build_type_use_tree, show_how_type_is_used)
	(set_suppressions, main): Adjust.
	* tools/abipkgdiff.cc (elf_file::type, compare, compare_to_self)
	(create_maps_of_package_content)
	(compare_prepared_userspace_packages)
	(self_compare_prepared_userspace_package): Adjust.
	* tools/abisym.cc: Adjust invocation to
	abigail::dwarf::lookup_symbol_from_elf, from
	abigail::dwarf_reader::lookup_symbol_from_elf.
	* tools/kmidiff.cc (main): Adjust.
	* tests/print-diff-tree.cc (main): Adjust.
	* tests/test-abidiff.cc (main): Likewise.
	* tests/test-diff-dwarf.cc (main): Likewise.
	* tests/test-ir-walker.cc (main): Likewise.
	* tests/test-read-ctf.cc (test_task_ctf::perform): Likewise.
	* tests/test-read-dwarf.cc: Remove the useless "using" statements.
	* tests/test-read-write.cc: Likewise.
	* tests/test-symtab.cc (read_corpus, TEST_CASE)
	(assert_symbol_count): Adjust.
	* tests/data/test-read-ctf/test0.abi: Adjust.
	* tests/data/test-read-ctf/test0.hash.abi: Likewise.
	* tests/data/test-read-ctf/test1.so.abi: Likewise.
	* tests/data/test-read-ctf/test1.so.hash.abi: Likewise.
	* tests/data/test-read-ctf/test2.so.abi: Likewise.
	* tests/data/test-read-ctf/test2.so.hash.abi: Likewise.
	* tests/data/test-read-ctf/test3.so.abi: Likewise.
	* tests/data/test-read-ctf/test3.so.hash.abi: Likewise.
	* tests/data/test-read-ctf/test4.so.abi: Likewise.
	* tests/data/test-read-ctf/test4.so.hash.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-18 18:12:38 +01:00
David Seifert
1198798985 Find fts-standalone on musl
When using the musl C library fts is optional.  So we need to detect
its presence by looking at the fts-standalone pkgconfig module.

This patch does that.

This comes from Gentoo bug https://bugs.gentoo.org/831571

	* configure.ac: Invoke AC_CANONICAL_HOST to compute the host_cpu,
	host_vendor, host_os parts of the 'host" variable.  Then if the
	host_os ends up with "musl" then, check for the fts-standalone
	pkgconfig module and record the fts library into
	FTS_{LIBS,CFLAGS}.
	* src/Makefile.am: Link to $FTS_LIBS and use $FTS_CFLAGS for
	compilation.
	* tools/Makefile.am: Likewise.
	* tools/abisym.cc: Include libgen.h
	* tools/kmidiff.cc: Remove useless fts.h header file.

Signed-off-by: David Seifert <soap@gentoo.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-02-07 16:26:30 +01:00
Ben Woodard via Libabigail
05d33d607a Bug 27512 - Remove broken zip-archive support
The optional zip archive feature was broken when the concept of
environment was introduced by commit b2e5366d3 back in 2015. Since it
wouldn't even compile and nobody noticed, we are fairly sure nobody
uses that feature. Therefore, we decided to remove it rather than fix
it.

	* configure.ac: remove --enable-zip-archive option and logic
	associated with it.
	* include/abg-libzip-utils.h: Remove.
	* src/abg-libzip-utils.cc: Likewise.
	* include/Makefile.am: remove reference to include/abg-libzip-utils.h
	that no longer exists.
	* src/Makefile.am: remove reference to src/abg-libzip-utils.cc that no
	longer exists.
	* relicensing-scripts/file-licenses.orig.txt: remove references to
	files that no longer exist.
	* relicensing-scripts/files-with-lgplv3.txt: remove references to
	files that no longer exist.
	* tests/test-write-read-archive.cc: Remove because it tests code
	that no longer exists.
	* tests/Makefile.am: remove reference to tests that no longer exist.
	* include/abg-reader.h: remove conditionally compiled code for zip
	archives.
	* include/abg-tools-utils.h: remove conditionally compiled code for
	zip archives.
	* src/abg-corpus.cc: remove conditionally compiled code for zip
	archives.
	* src/abg-reader.cc: remove conditionally compiled code for zip
	archives.
	* src/abg-tools-utils.cc: remove conditionally compiled code for zip
	archives.
	* src/abg-writer.cc: remove conditionally compiled code for zip
	archives.
	* tools/abidiff.cc: remove conditionally compiled code for zip
	archives.
	* tools/abilint.cc: remove conditionally compiled code for zip
	archives.
	* tools/abiar.c: Remove.
	* tools/Makefile.am: remove references to abiar a utility that no
	longer has a reason for existing.

Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-03-19 10:52:57 +01:00
Dodji Seketeli
c80f79271a Re-license the project to Apache v2 With LLVM Exception
Thanks to the previous work done, changing the license is just a
matter of changing the SPDX identifer from "LGPL-3.0-or-later" to
"Apache-2.0 WITH LLVM-exception".  Note that for the abigail.m4,
tests/test-dot.cc and tests/test-svg.cc the change was from
"GPL-3.0-or-later WITH GCC-exception-3.1" to "Apache-2.0 WITH
LLVM-exception".  include/abg-cxx-compat.h was changed from
"LGPL-2.0-or-later" to "Apache-2.0 WITH LLVM-exception".  Source code
of programs (as opposed to source code of the library) where generally
licensed under GPL-3.0-or-later; they are also now licensed
"Apache-2.0 WITH LLVM-exception".

This is what this patch does.

	* abigail.m4: Change the SPDX identifier from "GPL-3.0-or-later
	WITH GCC-exception-3.1" to "Apache-2.0 WITH LLVM-exception"
	* include/abg-cxx-compat.h: Change the SPDX identifier from
	"LGPL-2.0-or-later" to "Apache-2.0 WITH LLVM-exception".
	* .clang-format: Change the SPDX identifier from
	  "LGPL-3.0-or-later" to "Apache-2.0 WITH LLVM-exception".
	* Makefile.am: Likewise.
	* bash-completion/Makefile.am: Likewise.
	* bash-completion/abicompat: Likewise.
	* bash-completion/abidiff: Likewise.
	* bash-completion/abidw: Likewise.
	* bash-completion/abilint: Likewise.
	* bash-completion/abinilint: Likewise.
	* bash-completion/abipkgdiff: Likewise.
	* bash-completion/abisym: Likewise.
	* bash-completion/fedabipkgdiff: Likewise.
	* configure.ac: Likewise.
	* default.abignore: Likewise.
	* doc/Makefile.am: Likewise.
	* doc/api/libabigail.doxy: Likewise.
	* doc/manuals/Makefile.am: Likewise.
	* doc/website/libabigail-website.doxy: Likewise.
	* include/Makefile.am: Likewise.
	* include/abg-comp-filter.h: Likewise.
	* include/abg-comparison.h: Likewise.
	* include/abg-config.h: Likewise.
	* include/abg-corpus.h: Likewise.
	* include/abg-diff-utils.h: Likewise.
	* include/abg-dwarf-reader.h: Likewise.
	* include/abg-fwd.h: Likewise.
	* include/abg-hash.h: Likewise.
	* include/abg-ini.h: Likewise.
	* include/abg-interned-str.h: Likewise.
	* include/abg-ir.h: Likewise.
	* include/abg-libxml-utils.h: Likewise.
	* include/abg-libzip-utils.h: Likewise.
	* include/abg-reader.h: Likewise.
	* include/abg-regex.h: Likewise.
	* include/abg-reporter.h: Likewise.
	* include/abg-sptr-utils.h: Likewise.
	* include/abg-suppression.h: Likewise.
	* include/abg-tools-utils.h: Likewise.
	* include/abg-traverse.h: Likewise.
	* include/abg-version.h.in: Likewise.
	* include/abg-viz-common.h: Likewise.
	* include/abg-viz-dot.h: Likewise.
	* include/abg-viz-svg.h: Likewise.
	* include/abg-workers.h: Likewise.
	* include/abg-writer.h: Likewise.
	* scripts/dot_to_png.sh: Likewise.
	* scripts/dot_to_svg.sh: Likewise.
	* scripts/make-verbose.sh: Likewise.
	* scripts/svg_to_plain_svg.sh: Likewise.
	* scripts/svg_to_png_and_pdf.sh: Likewise.
	* src/Makefile.am: Likewise.
	* src/abg-comp-filter.cc: Likewise.
	* src/abg-comparison-priv.h: Likewise.
	* src/abg-comparison.cc: Likewise.
	* src/abg-config.cc: Likewise.
	* src/abg-corpus-priv.h: Likewise.
	* src/abg-corpus.cc: Likewise.
	* src/abg-default-reporter.cc: Likewise.
	* src/abg-diff-utils.cc: Likewise.
	* src/abg-dwarf-reader.cc: Likewise.
	* src/abg-elf-helpers.cc: Likewise.
	* src/abg-elf-helpers.h: Likewise.
	* src/abg-hash.cc: Likewise.
	* src/abg-ini.cc: Likewise.
	* src/abg-internal.h: Likewise.
	* src/abg-ir-priv.h: Likewise.
	* src/abg-ir.cc: Likewise.
	* src/abg-leaf-reporter.cc: Likewise.
	* src/abg-libxml-utils.cc: Likewise.
	* src/abg-libzip-utils.cc: Likewise.
	* src/abg-reader.cc: Likewise.
	* src/abg-regex.cc: Likewise.
	* src/abg-reporter-priv.cc: Likewise.
	* src/abg-reporter-priv.h: Likewise.
	* src/abg-suppression-priv.h: Likewise.
	* src/abg-suppression.cc: Likewise.
	* src/abg-tools-utils.cc: Likewise.
	* src/abg-traverse.cc: Likewise.
	* src/abg-viz-common.cc: Likewise.
	* src/abg-viz-dot.cc: Likewise.
	* src/abg-viz-svg.cc: Likewise.
	* src/abg-workers.cc: Likewise.
	* src/abg-writer.cc: Likewise.
	* tests/Makefile.am: Likewise.
	* tests/data/Makefile.am: Likewise.
	* tests/lib/catch.cc: Likewise.
	* tests/mockfedabipkgdiff.in: Likewise.
	* tests/print-diff-tree.cc: Likewise.
	* tests/runtestcanonicalizetypes.sh.in: Likewise.
	* tests/runtestdefaultsupprs.py.in: Likewise.
	* tests/runtestdefaultsupprspy3.sh.in: Likewise.
	* tests/runtestfedabipkgdiff.py.in: Likewise.
	* tests/runtestfedabipkgdiffpy3.sh.in: Likewise.
	* tests/test-abicompat.cc: Likewise.
	* tests/test-abidiff-exit.cc: Likewise.
	* tests/test-abidiff.cc: Likewise.
	* tests/test-alt-dwarf-file.cc: Likewise.
	* tests/test-annotate.cc: Likewise.
	* tests/test-core-diff.cc: Likewise.
	* tests/test-cxx-compat.cc: Likewise.
	* tests/test-diff-dwarf-abixml.cc: Likewise.
	* tests/test-diff-dwarf.cc: Likewise.
	* tests/test-diff-filter.cc: Likewise.
	* tests/test-diff-pkg.cc: Likewise.
	* tests/test-diff-suppr.cc: Likewise.
	* tests/test-diff2.cc: Likewise.
	* tests/test-dot.cc: Change the SPDX identifier from
	"GPL-3.0-or-later WITH GCC-exception-3.1" to "Apache-2.0 WITH
	LLVM-exception"
	* tests/test-elf-helpers.cc: Change the SPDX identifier from
	"LGPL-3.0-or-later" to "Apache-2.0 WITH LLVM-exception"
	* tests/test-ini.cc: Likewise.
	* tests/test-ir-walker.cc: Likewise.
	* tests/test-kmi-whitelist.cc: Likewise.
	* tests/test-lookup-syms.cc: Likewise.
	* tests/test-read-dwarf.cc: Likewise.
	* tests/test-read-write.cc: Likewise.
	* tests/test-svg.cc: Change the SPDX identifier from
	"GPL-3.0-or-later WITH GCC-exception-3.1" to "Apache-2.0 WITH
	LLVM-exception".
	* tests/test-symtab.cc: Change the SPDX identifier from
	"LGPL-3.0-or-later" to "Apache-2.0 WITH LLVM-exception"
	* tests/test-tools-utils.cc: Likewise.
	* tests/test-types-stability.cc: Likewise.
	* tests/test-utils.cc: Likewise.
	* tests/test-utils.h: Likewise.
	* tests/test-write-read-archive.cc: Likewise.
	* tests/update-test-output.py: Likewise.
	* tools/Makefile.am: Likewise.
	* tools/abiar.cc: Likewise.
	* tools/abicompat.cc: Likewise.
	* tools/abidiff.cc: Likewise.
	* tools/abidw.cc: Likewise.
	* tools/abilint.cc: Likewise.
	* tools/abipkgdiff.cc: Likewise.
	* tools/abisym.cc: Likewise.
	* tools/binilint.cc: Likewise.
	* tools/fedabipkgdiff: Likewise.
	* tools/kmidiff.cc: Likewise.
	* update-copyright.sh: Likewise.

Signed-off-by: Benjamin De Kosnik <bkoz@gnu.org>
Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Matthias Klose <doko@ubuntu.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Roland McGrath <roland@hack.frob.com>
Signed-off-by: Sinny Kumari <ksinny@gmail.com>
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
2020-12-02 11:49:13 +01:00
Dodji Seketeli
be6bf58308 Add missing SPDX headers to source files not specifying any license
Default to the project's defautl - LGPLv3+ - for those.

	* Makefile.am: Add a LGPL-3.0-or-later SPDX header prefixed
	with '##' so that that the header doesn't get emitted in the
	resulting Makefile.in file.  Note that the license of Makefile.in
	files is "FSF All Permissible License", which virtually compatible
	with anything.
	* bash-completion/Makefile.am: Likewise.
	* doc/Makefile.am: Likewise
	* doc/manuals/Makefile.am: Likewise
	* include/Makefile.am: Likewise
	* src/Makefile.am: Likewise
	* tests/Makefile.am: Likewise
	* tests/data/Makefile.am: Likewise
	* tools/Makefile.am: Likewise
	* .clang-format: Add a LGPL-3.0-or-later SPDX header.
	* bash-completion/abicompat: Likewise.
	* bash-completion/abidiff: Likewise.
	* bash-completion/abidw: Likewise.
	* bash-completion/abilint: Likewise.
	* bash-completion/abinilint: Likewise.
	* bash-completion/abipkgdiff: Likewise.
	* bash-completion/abisym: Likewise.
	* bash-completion/fedabipkgdiff: Likewise.
	* configure.ac: Likewise.
	* default.abignore: Likewise.
	* doc/api/libabigail.doxy: Likewise.
	* doc/website/libabigail-website.doxy: Likewise.
	* include/abg-version.h.in: Likewise.
	* scripts/dot_to_png.sh: Likewise.
	* scripts/dot_to_svg.sh: Likewise.
	* scripts/make-verbose.sh: Likewise.
	* scripts/svg_to_plain_svg.sh: Likewise.
	* scripts/svg_to_png_and_pdf.sh: Likewise.
	* tests/runtestcanonicalizetypes.sh.in: Likewise.
	* tests/runtestdefaultsupprs.py.in: Likewise.
	* tests/runtestdefaultsupprspy3.sh.in: Likewise.
	* tests/runtestfedabipkgdiffpy3.sh.in: Likewise.
	* tests/update-test-output.py: Likewise.
	* update-copyright.sh: Likewise.

Signed-off-by: Benjamin De Kosnik <bkoz@gnu.org>
Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Matthias Klose <doko@ubuntu.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Roland McGrath <roland@hack.frob.com>
Signed-off-by: Sinny Kumari <ksinny@gmail.com>
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
2020-12-02 11:44:56 +01:00
Dodji Seketeli
8e8de9c3f5 Support loading and comparing two kernel trees
* include/abg-dwarf-reader.h (set_read_context_corpus_group)
	(read_and_add_corpus_to_group_from_elf, set_ignore_symbol_table)
	(get_ignore_symbol_table): Declare new functions.
	* abg-dwarf-reader.cc (read_context::options_type): Define new
	type.
	(die_dependant_container_set::clear): Define new member function.
	(read_context::{bss, tesxt, rodata, data, data1}_section_): Add
	new data members.
	(read_context::{symbol_versionning_sections_loaded_,
	symbol_versionning_sections_found_}): Likewise.
	(read_context::corpus_group_): Likewise.
	(read_context::{load_in_linux_kernel_mode, load_all_types,
	show_stats, do_log_}): Replace these options by ..
	(read_context::options_): ... this instance of the new
	read_context:options_type.
	(read_context::read_context): Adjust.
	(read_context::{clear_alt_debug_info_data, clear_per_corpus_data,
	env, get_data_section_for_variable_address, load_all_types,
	load_in_linux_kernel_mode, show_stats, do_log}): Adjust.
	(create_read_context): Adjust.
	(read_context::~read_context): Define destructor.
	(read_context::{options, bss_section, text_section,
	rodata_section, data_section, data1_section, current_corpus_group,
	has_corpus_group, main_corpus_from_current_group,
	main_corpus_from_current_group,
	current_corpus_is_main_corpus_from_current_group,
	should_reuse_type_from_corpus_group}): Define new member
	functions.
	(read_context::get_die_qualified_type_name): Handle the name of
	the current translation unit.
	(read_context::load_symbol_maps): Really don't load (linux kernel
	specific) symbol maps if we were told to ignore the ELF symbol
	table.
	(set_ignore_symbol_table, get_ignore_symbol_table)
	(create_default_var_sym, create_default_fn_sym, add_symbol_to_map)
	(set_read_context_corpus_group)
	(read_and_add_corpus_to_group_from_elf): Define new functions.
	(build_type_decl, build_typedef_type, build_enum_type)
	(add_or_update_class_type)
	(add_or_update_union_type): Reuse the type being built, from the
	main corpus of the corpus group.
	(build_qualified_type): Cleanup logic.
	(build_var_decl, build_function_decl): Create a default symbol for
	the variable or function if we are supposed to ignore the symbol
	table of the current binary.  Add that symbol to the symbol table
	that is created in the read context.
	(read_debug_info_into_corpus): Don't load the ELF symbol table
	information if we are asked to ignore the symbol table.  But set
	the symbol table that we built artificially while loading
	functions and variables, into the ABI corpus being built.
	(read_context::maybe_adjust_var_sym_address): Adjust.
	(build_ir_node_from_die): Add ir node to its logical scope.  For
	the C language, the scope of a type is the global scope.
	(read_corpus_from_elf): Don't load ELF properties if we were asked
	to avoid the ELF symbol table.
	* include/abg-comparison.h (compute_diff): Declare ...
	* src/abg-comparison.cc (compute_diff): ... an overload to compare
	corpus_group.
	* tools/kmidiff.cc: New tool.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:36 +02:00
Dodji Seketeli
103a6eb94f Control symbols exported from libabigail.so
Symbols of pretty much all member functions of types that are meant to
be "private" to translation units that contribute to libabigail.so
were exported because we didn't do much to prevent that.

This patch starts controlling the set of symbols that are exported.

By default, symbols of any entity declared in a translation unit that
contributes to libabigail.so are hidden by default.  Only symbols of
entities declared in public headers (headers in include/*.h) are
exported.

There are many ways to achieve that.  This patch chooses to avoid
cluttering declarations of entities in the public header by adding
__attribute__((visibility="default")) to every declared type of
function in there.

Rather, the patch uses "#pragma GCC visibility push(default)" before
entities declared on those headers.  By doing so, all those entities
have their symbol marked as "visible" by the compiler.  Once the
header are #included, the #pragma GCC visibility pop" is used, so that
anything else has its symbol be hidden from that point on.

Note that for ease of maintenance the patch uses the macros
ABG_BEGIN_EXPORT_DECLARATIONS and ABG_END_EXPORT_DECLARATIONS rather
than using the pragma directive directly.

I believe this is a more elegant way of handling visibility, compared
to cluttering every single declaration in public headers with a
"__attribute__((visibility=("default")))" or with a macro which
expands to it.

This reduces the the set of symbols exported by libabigail.so from
20000+ to less than 5000.

	* VISIBILITY: New documentation about this visiblity business.
	* CONTRIBUTING: Update the "contributing guide" to refer to symbol
	visibility issues.
	* configure.ac: Define a variable VISIBILITY_FLAGS that is set to
	the -fvisibility=hidden flag to pass to GCC, when its available.
	* src/Makefile.am: Add VISIBILITY to source distribution.  Also
	add COMPILING and COMMIT-LOG-GUIDELINES that were missing.
	* src/Makefile.am: Use the new $(VISIBILITY_FLAGS) when buiding
	the library.
	* tests/Makefile.am: Use the new $(VISIBILITY_FLAGS) when buiding
	tests.
	* tools/Makefile.am: Use the new $(VISIBILITY_FLAGS) when buiding
	tools.
	* src/abg-comp-filter.cc: Enclose inclusion of public headers in
	ABG_BEGIN_EXPORT_DECLARATIONS and ABG_END_EXPORT_DECLARATIONS to
	export the symbols of entities declared in there.
	* src/abg-comparison.cc: Likewise.
	* src/abg-config.cc: Likewise.
	* src/abg-corpus.cc: Likewise.
	* src/abg-diff-utils.cc: Likewise.
	* src/abg-dwarf-reader.cc: Likewise.
	* src/abg-hash.cc: Likewise.
	* src/abg-ini.cc: Likewise.
	* src/abg-ir.cc: Likewise.
	* src/abg-libxml-utils.cc: Likewise.
	* src/abg-libzip-utils.cc: Likewise.
	* src/abg-reader.cc: Likewise.
	* src/abg-suppression.cc: Likewise.
	* src/abg-tools-utils.cc: Likewise.
	* src/abg-traverse.cc: Likewise.
	* src/abg-viz-common.cc: Likewise.
	* src/abg-viz-dot.cc: Likewise.
	* src/abg-viz-svg.cc: Likewise.
	* src/abg-workers.cc: Likewise.
	* src/abg-writer.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-07-27 12:51:02 +02:00
Chenxiong Qi
57dcfb18f5 Bug 19428 - New fedabipkgdiff utility
fedabipkgdiff is a convenient way to compare the ABI of Fedora
packages easily.

The first version of fedabipkgdiff introduced by this patch lets users
perform operations like:

    fedabipkgdiff --from fc23 foo-0.1-1.fc23.x86_64.rpm
    fedabipkgdiff --from fc23 --to fc24 foo
    fedabipkgdiff foo-0.1-1.fc23 foo-0.1-1.fc24
    fedabipkgdiff foo-0.1-1.fc23.i686 foo-0.1-1.fc24.i686
    fedabipkgdiff --all-subpackages foo-0.1-1.fc23 foo-0.1-1.fc24

	* autoconf-archive/ax_compare_version.m4: New file copied from the
	autoconf-archive project.
	* autoconf-archive/ax_prog_python_version.m4: Likewise.
	* autoconf-archive/ax_python_module.m4: Likewise.
	* Makefile.am: Add the new files above to the source distribution.
	* configure.ac: Include the new m4 macros from the autoconf
	archive. Add a new --enable-fedabipkgdiff option. Update the
	report at the end of the configure process to show the status of
	the fedabipkgdiff feature. Add check for prerequisite python
	modules argparse, glob, logging, os, re, shlex, subprocess, sys,
	itertools, urlparse, itertools, shutil, unittest, xdg, koji and
	mock.  These are necessary for the unit test of
	fedabipkgdiff. Generate tests/runtestfedabipkgdiff.py into the
	build directory, from the tests/runtestfedabipkgdiff.py.in input
	file.
	* tools/Makefile.am: Include the fedabipkgdiff to the source
	distribution and install it if the "fedabipkgdiff" feature is
	enabled.
	* tests/Makefile.am: Rename runtestfedabipkgdiff.sh into
	runtestfedabipkgdiff.py.  Add the new runtestfedabipkgdiff.py.in
	autoconf template file in here.
	* tests/runtestfedabipkgdiff.py.in: New unit test file.
	* tools/fedabipkgdiff: New fedabipkgdiff tool.
	* doc/manuals/fedabipkgdiff.rst: New manual.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-13 00:42:36 +02:00
Dodji Seketeli
12d56c861b Make libabigail link with pthread
Since libabigail now uses pthreads via the abigail::workers namespace,
the libabigail shared library should link with pthreads.  Many to
Michi Henning for raising this.

	* src/Makefile.am: Add -pthread to libabigail_la_LDFLAGS.
	* tools/Makefile.am: Do not use abinilint_LDFLAGS when it should
	be abinilint_LDADD.  This one was fixed by Michi Henning.

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

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

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-10 16:04:39 +01:00
Sinny Kumari
411b60c30d Initial skeleton of abipkgdiff tool
Motive of abipkgdiff tool is to provide abi changes between two
pacakges. Packages can be .rpm, .deb or archives. It also takes
optional debug-info package to support pacakges shipping separate
debug-info.

This commit set-up initial skeleton of abipkgdif tool consisting of
help and usage otions. It ensures pkgdiff tool compiles and run when
libabigail gets compiled as whole. Initially, we will add support for
ABI changes for two rpm packages. Further, support for other pacakging
format can be added.

	* tools/Makefile.am: Include abipkgdiff.cc in compilation and
	generate abipkgdiff binary.
	* tools/abipkgdiff.cc: New file

Signed-off-by: Sinny Kumari <sinny@redhat.com>
2015-07-17 10:07:37 +02:00
Dodji Seketeli
96eb3a5698 Build libabigail tools as position-independent code
It turned out the hardened Rawhide build is failing if I don't this.

	* tools/Makefile.am: Compile the binaries here with -fPIC.  Note
	that the library libabigail.la is built with libtool which already
	takes care of this, so no need to worry about this for
	libabigail.la.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-06-07 16:55:29 +02:00
Dodji Seketeli
527d7ab218 Do not install the abinilint program
This program is meant to be used by libabigail developers to debug its
ini file parsing facilities.  So there is no need to install.

	* tools/Makefile.am: Add abinilint to the noinst_PROGRAMS primary.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-01-14 13:20:46 +01:00
Dodji Seketeli
322b0e7769 Expose a new libabigail::tools_utils namespace
The utilities present in this namespace were previously living in
tools/abg-tools-utils.h and tools/abg-tools-utils.cc.  They were not
exported and were meant to be useful to the tools writting in the
tools/ directory.  I realized that these utilities might be useful to
clients of the libabigail library in general so I am making them
available generally.  Note that the initial name of the namespace was
libabigail::tools; so renaming it to libabigail::tools_utils required
that I adjust some client code.  I have also cleaned up the code,
interfaces and their apidoc a little bit.

	* include/abg-tools-utils.h: Moved tools/abg-tools-utils.h in
	here.  Renamed the namespace tools into tools_utils.  Inject
	std::ostream, std::istream, std::ifstream, and std::string types
	into the tools_utils namespace.  Adjust the function declarations
	accordingly.  Remove the useless dirname() function declaration.
	* include/Makefile.am: Add abg-tools-utils.h to the list of
	exported headers.
	* src/abg-tools-utils.cc: Moved tools/abg-tools-utils.cc in here.
	Renamed the namespace tools into tools_utils.
	(get_stat): Add apidoc.
	(is_dir): Cleanup apidoc.
	(dir_name); Cleanup parameter name.
	(guess_file_type): Cleanup parameter type.
	* src/Makefile.am: Add abg-tools-utils.cc to the list of exported
	headers.
	* tools/Makefile.am: Do not build the temporary library
	libtoolsutils.la anymore as abg-tools-utils.{h,cc} have moved out
	of this directory.
	* tools/abicompat.cc (parse_command_line, main): Adjust for tools
	-> tools_utils namespace change.
	* tools/abidiff.cc (parse_command_line, main): Likewise.
	* tools/abidw.cc (parse_command_line, main): Likewise.
	* tools/abilint.cc (parse_command_line, main): Likewise.
	* tests/test-abicompat.cc (main): Adjust for tools -> tools_utils
	namespace change.
	* tests/test-abidiff.cc (main): Likewise.
	* tests/test-alt-dwarf-file.cc (main): Likewise.
	* tests/test-core-diff.cc (main): Likewise.
	* tests/test-diff-dwarf.cc (main): Likewise.
	* tests/test-diff-filter.cc (main): Likewise.
	* tests/test-diff-suppr.cc (main): Likewise.
	* tests/test-lookup-syms.cc (main): Likewise.
	* tests/test-read-dwarf.cc (main): Likewise.
	* tests/test-read-write.cc (main): Likewise.
	* tests/Makefile.am: Do not reference the libtoolsutils.la private
	library anymore.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-01-08 12:28:14 +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
26869d665c Make all type diff types extend new type_diff_base type
* include/abg-comparison.h (type_diff_base, decl_diff_base): New
	types.
	(type_diff_base_sptr): New typedef.
	(pointer_diff, reference_diff, array_diff, qualified_type_diff)
	(enum_diff, class_diff, type_decl_diff, typedef_diff): Make this
	extend the new type_diff_base.
	* src/abg-comparison.cc (type_diff_base::priv, type_diff_base):
	Define these new types and their methods.
	(pointer_diff::pointer_diff, array_diff::array_diff)
	(reference_diff::reference_diff)
	(qualified_type_diff::qualified_type_diff, enum_diff::enum_diff)
	(class_diff::class_diff, type_decl_diff::type_decl_diff)
	(typedef_diff::typedef_diff): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 17:44:43 +02:00
Dodji Seketeli
284c9e488f Initial support of ini-style file parsing
* include/abg-ini.h: New file.
	* include/Makefile.am: Add include/abg-ini.h to the source
	distribution.
	* src/abg-ini.cc: New file.
	* src/Makefile.am: Add src/abg-ini.cc to the source distribution.
	* tools/binilint.cc: New testing tool.
	* tools/Makefile.am: Add tools/binilint.cc to the source distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 17:44:43 +02:00
Dodji Seketeli
e807eb86e6 Do not install the abisym program
* tools/Makefile.am: Do not install abisym.  It's really there
	just for testing purposes and is of almost no use for generic
	users.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-26 16:14:18 +02:00
Dodji Seketeli
d041c1f5dd Rename bi* tools to abi* tools
* tests/data/test-bidiff: Rename this directory to
	tests/data/test-abidiff.
	* tests/test-bidiff.cc: Renamed this to tests/test-abidiff.cc.
	* tools/biar.cc: Renamed to tools/abiar.cc
	* tools/bidiff.cc: Renamed to tools/abidiff.cc
	* tools/bidw.cc: Renamed to tools/abidw.cc
	* tools/bilint.cc: Renamed to tools/abilint.cc
	* tools/bisym.cc: Renamed to tools/abisym.cc
	* tests/test-alt-dwarf-file.cc: Renamed references to bidw* to abidw*.
	* tests/test-diff-filter.cc: Renamed references to bidiff to abidiff.
	* tests/test-lookup-syms.cc: Renamed references to bisym to abisym.
	* tools/Makefile.am: Adjust.
	* tests/Makefile.am: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-26 10:58:16 +02:00
Jan Engelhardt
4e32504064 Place -L/-l flags into *_LIBADD/*_LDADD
* src/Makefile.am: -L and -l ought to be in LIBADD/LDADD because
	that is the only place guaranteed to be in the right spot.  So add
	Them to libabigail_la_LIBADD.
	* tools/Makefile.am: Likewise.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
2014-09-12 11:04:59 +02:00
Jan Engelhardt
aa7fc67119 Set automake options globally
* configure.ac(AM_INIT_AUTOMAKE): Set the subdir-object option
	here ..
	* src/Makefile.am: ... not here.
	* tests/Makefile.am: Likewise.
	* tools/Makefile.am: Likewise.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
2014-09-12 11:04:45 +02:00
Dodji Seketeli
36ed6e0583 Make zip archive support optional
* configure.ac: Support a new --enable-zip-archive option.  By
	default its value is set to the 'auto', meaning that if libzip is
	installed, that turns the option on -- just like if
	--enable-zip-archive was called with the value 'yes'; if libzip is
	not installed, that turns the option off -- just like if
	--enable-zip-archive was called with the value 'no'.  If libzip is
	detected, the pre-processor macro HAVE_LIBZIP is set to 1.  If
	--enable-zip-archive is turned on, the pre-processor macro
	WITH_ZIP_ARCHIVE is set to 1.
	* config.h.in (HAVE_LIBZIP, WITH_ZIP): New define.
	* src/abg-corpus.cc: Include config.h.  Guard the inclusion of
	abg-libzip-utils.h with the WITH_ZIP_ARCHIVE macro.  Likewise for
	the use of declarations coming from abg-libzip-utils.h.
	* src/abg-libzip-utils.cc: Include config.h.  Guard the file's
	content with the WITH_ZIP_ARCHIVE macro.
	* src/abg-reader.cc: Include config.h.  Guard the inclusion of
	abg-libzip-utils.h with the WITH_ZIP_ARCHIVE.  Likewise for the
	use of declarations coming from abg-libzip-utils.h.
	* src/abg-writer.cc: Likewise.
	* tests/Makefile.am: Build runtestwritereadarchive and runtestdot
	only if zip archives are supported.
	* tools/Makefile.am: The biar program is built only if
	zip archives are supported.
	* tools/bidiff.cc: Handle zip archives only if the
	WITH_ZIP_ARCHIVE macros is defined.
	* tools/bilint.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-31 11:28:42 +02:00
Dodji Seketeli
a8285b1f9c Add subdir-objects automake option where it is needed
* src/Makefile.am: Add the subdir-object automake option here.
	Do not specify absolute paths for the input files as Automake now
	takes care of that just fine.
	* tests/Makefile.am: Likewise.
	* tools/Makefile.am: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@seketeli.org>
2014-06-23 15:01:00 +02:00
Dodji Seketeli
12c777681d Support symbol lookups from ELF
* include/abg-dwarf-reader.h (symbol_type, symbol_binding): New
	enums.
	(operator<<): Declare new overloads for the new enums above.
	(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
	Declare new entry points.
	* src/abg-dwarf-reader.cc (lookup_symbol_from_elf)
	(lookup_public_function_symbol_from_elf)
	(lookup_public_variable_symbol_from_elf): Define new static
	functions.
	(read_context::elf_{module_, handle}_): New data members.
	(read_context::{elf_module, elf_handle}): New accessors.
	(read_context::load_debug_info): Store the elf module into
	read_context::_elf_module_.  Adjust.
	(read_context::{lookup_symbol_from_elf,
	lookup_public_function_symbol_from_elf,
	lookup_public_variable_symbol_from_elf}): New member functions.
	(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf)
	(operator<<): Define public entry points.
	* tools/bisym.cc: New tool to lookup a symbol in an elf file.
	* tools/Makefile.am: Add the bisym.cc source file to the
	distribution and arrange to compile it into a 'bisym' executable.
	* tests/test-lookup-syms.cc: New test harness.
	* tests/data/test-lookup-syms/test0-report.txt: New test input
	for the harness above.
	* tests/data/test-lookup-syms/test0.cc: Likewise.
	* tests/data/test-lookup-syms/test0.o: Likewise
	* tests/data/test-lookup-syms/test01-report.txt: Likewise.
	* tests/data/test-lookup-syms/test02-report.txt: Likewise.
	* tests/Makefile.am: Build the new runtestlookupsyms test and add
	the new files to the distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 17:56:40 +02:00
Dodji Seketeli
bd1af4cd52 Initial support of reading an ABI Corpus from DWARF
* configure.ac: Check the presence of libdw.so and
	elfutils/libdwfl.h headers from elfutils and define the necessary
	linking flags.
	* include/abg-dwarf-reader.h: New header file
	* include/Makefile.am: Add the new header file to the source
	distribution.
	* src/abg-dwarf-reader.cc:: New file.
	* src/Makefile.am: Add the new file to the source distribution.
	* include/abg-fwd.h (dump): Add declarations for several overloads
	to allow dumping to a given output stream.
	* include/abg-ir.h (class translation_unit): Use a pimpl idiom for
	this now.
	(translation_unit::canonicalize_type): Declare new method.
	* src/abg-ir.cc (struct translation_unit::priv): New private type
	for the pimpl idiom for translation_unit.
	(translation_unit::{translation_unit, get_global_scope, get_path,
	set_path, get_loc_mgr}): Adjust for pimpl idiom.
	(translation_unit::canonicalize_type): Define this new method and
	one overload.
	* src/abg-writer.cc (dump): Define several overloads to dump IR
	nodes to given output streams.
	* tools/bidw.cc: New file for the new bidw tool.
	* tools/Makefile.am: Define rules to build the new bidw tools.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-07 08:07:54 +01:00
Dodji Seketeli
80b753e85d Add bilint tool to validate bi files somewhat.
* tools/bilint.cc: New file.
	* tools/Makefile.am: Build and install the new file above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:28:04 +01:00
Dodji Seketeli
749611d2e8 Initial implementation of tu diffing & bidiff cmd line program
* include/abg-comparison.h (class translation_unit_diff): New type.
	(compute_diff): Make this take class_decl&, rather than
	class_decl_sptr.  Add new overloads for scope_decl& and
	translation_unit&.
	(report_changes): New overload for scope_diff& and
	translation_unit&.
	* src/abg-comparison.cc (struct class_decl_diff::priv): New type.
	(class class_decl_diff): Add comments to methods.
	(class translation_unit_diff): Implement methods.
	(compute_diff, report_changes): Implement the new overloads.
	(scope_diff::ensure_lookup_tables_populated): Fix a thinko here.
	* src/abg-ir.cc (is_var_decl): Add new predicate.
	* tools/abg-tools-utils.h (file_exists, is_regular_file)
	(check_file): Declare new functions.
	* tools/abg-tools-utils.cc (get_stat, file_exists, check_file)
	(is_regular_file): Define new functions.
	(is_dir): Use the new get_stat.
	* tools/bidiff.cc: New file.
	* tools/Makefile.am: Add tools/bidiff.cc to the build system; make it
	produce the bidiff tool.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:24:01 +01:00
Dodji Seketeli
0d738e2b95 Initial version of an archive manipulation program: biar
* tests/test-utils.h (is_dir, ensure_dir_path_created)
	(ensure_parent_dir_created): Move these directories manipulation
	utilities from here to ...
	* tools/abg-tools-utils.h (is_dir, ensure_dir_path_created)
	(ensure_parent_dir_created): ... here in this new file.
	(dir_name, base_name): Declare these new functions.
	* tests/test-utils.cc (is_dir, ensure_dir_path_created)
	(ensure_parent_dir_created): Likewise, move these to ...
	* tools/abg-tools-utils.cc (is_dir, ensure_dir_path_created)
	(ensure_parent_dir_created): ... here in this new file.
	(dir_name, base_name): Define these.
	* tools/Makefile.am: New file.  Create a new libtoolsutils.la
	static library with stuff from tools/abg-tools-utils.cc in it.
	Also create a new 'biar' program with the stuff from the new
	tools/biar.cc in it.
	* tools/biar.cc: New file.  Contains the code for the new "biar"
	archive manipulation command line utility.
	* tests/test-read-write.cc (main): Adjust for the change about
	ensure_parent_dir_created above.
	* tests/test-write-read-archive.cc (main): Likewise.
	* Makefile.am (SUBDIRS): Add the new tools/ sub-directory to the
	build system.
	* configure.ac (AC_CONFIG_FILES): Generate tools/Makefile.
	* tests/Makefile.am: Make libtestutils.la link with the new
	libtoolsutils.la.  Make sure to express the dependencies between
	libtestutils.la and the binaries that depend on it.  Otherwise
	parallel builds can go awry.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-29 17:08:47 +02:00