Commit Graph

6 Commits

Author SHA1 Message Date
Dodji Seketeli
23046152e0 Bump ABIXML format version to 2.0
After fixing the interpretation of the DW_AT_bit_offset attribute for
offset of bit field data members, serialized abixml might now be
incompatible with versions of Libabigail that use the previous
interpretation.

That means that comparing an abixml file generated with previous
versions of Libabigail against a corpus resulting from an analysis
performed with the current version of libabigail might yield spurious
changes due to the differences in the way we now interpret the
DW_AT_bit_offset.

Hence, this patch bumps the version of abixml files emitted from now
on to "2.0".  This version is deemed incompatible with the previous
"1.0" version.

Subsequently, an abixml file of the "1.0" format cannot be compared
against an abixml file of the "2.0" format, or against a binary
analyzed with a current version of Libabigail.

It's thus advised that abixml files of the "1.0" format version should
be re-generated with a current version of Libabigail, bumping their
format version number to the new "2.0".

	* include/abg-corpus.h (corpus::init_format_version): Declare new
	private method.
	(corpus::set_environment): Make this non-const.
	(corpus::{get,set}_format_{major,minor}_version_number): Declare
	new accessors.
	* src/abg-corpus.cc (corpus::init_format_version): Define new
	method.
	(corpus::set_environment): By default, initialize the format
	version number of the corpus to the one supported by Libabigail.
	(corpus::{get,set}_format_{major,minor}_version_number): Define
	new accessors.
	* include/abg-ir.h: Include abg-config.h to use the
	abigail::config.
	(environment::get_config): Declare new accessor.
	* src/abg-ir.cc (environment::priv::config_): Add new data member.
	(environment::get_config): Define new accessor.
	* src/abg-config.cc (config::config): Bump the format
	version number to "2.0".
	* src/abg-corpus-priv.h
	(corpus::priv::format_{major,minor}_version_number_): Add new data members.
	* src/abg-reader.cc (handle_version_attribute): Define new static
	function.
	(read_corpus_from_input, read_corpus_group_from_input): Use it to
	read the value of the "version" attribute and set the format
	version number of the corpus and corpus group accordingly.
	* src/abg-writer.cc (write_context::m_config): Remove the config
	object because we can now get it from the environment.
	(write_context::get_config): Get the config object from the
	environment.
	(write_translation_unit): Do not emit the version attribute on the
	translation unit element anymore.
	(write_version_info): Define static function.
	(write_corpus, write_corpus_group): Use it to emit version
	attribute on both the corpus and corpus group elements.
	* tools/abidiff.cc
	(emit_incomptatible_format_version_error_message): Define new
	static function.
	(main): Ensure that corpora and corpus groups being compared have
	the same major version number.
	* tests/update-test-output.py: Adjust syntax for python3.
	* tests/data/test-annotate/libtest23.so.abi: Adjust.
	* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Likewise.
	* tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-annotate/test-anonymous-members-0.o.abi:
	Likewise.
	* tests/data/test-annotate/test0.abi: Likewise.
	* tests/data/test-annotate/test1.abi: Likewise.
	* tests/data/test-annotate/test13-pr18894.so.abi: Likewise.
	* tests/data/test-annotate/test14-pr18893.so.abi: Likewise.
	* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
	* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-annotate/test2.so.abi: Likewise.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
	* tests/data/test-annotate/test3.so.abi: Likewise.
	* tests/data/test-annotate/test4.so.abi: Likewise.
	* tests/data/test-annotate/test5.o.abi: Likewise.
	* tests/data/test-annotate/test6.so.abi: Likewise.
	* tests/data/test-annotate/test7.so.abi: Likewise.
	* tests/data/test-annotate/test8-qualified-this-pointer.so.abi:
	Likewise.
	* tests/data/test-diff-dwarf-abixml/PR25409-librte_bus_dpaa.so.20.0.abi:
	Likewise.
	* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1-report-0.txt:
	Likewise.
	* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi:
	Likewise.
	* tests/data/test-diff-suppr/libtest48-soname-abixml-v0.so.abi:
	Likewise.
	* tests/data/test-diff-suppr/libtest48-soname-abixml-v1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR24378-fn-is-not-scope.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise.
	* tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: Likewise.
	* tests/data/test-read-dwarf/libtest23.so.abi: Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-PR26568-1.o.abi: Likewise.
	* tests/data/test-read-dwarf/test-PR26568-2.o.abi: Likewise.
	* tests/data/test-read-dwarf/test0.abi: Likewise.
	* tests/data/test-read-dwarf/test0.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test1.abi: Likewise.
	* tests/data/test-read-dwarf/test1.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test2.so.abi: Likewise.
	* tests/data/test-read-dwarf/test2.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test3.so.abi: Likewise.
	* tests/data/test-read-dwarf/test3.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test4.so.abi: Likewise.
	* tests/data/test-read-dwarf/test4.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test5.o.abi: Likewise.
	* tests/data/test-read-dwarf/test5.o.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test6.so.abi: Likewise.
	* tests/data/test-read-dwarf/test6.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test7.so.abi: Likewise.
	* tests/data/test-read-dwarf/test7.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.hash.abi:
	Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
	* tests/data/test-read-write/test0.xml: Likewise.
	* tests/data/test-read-write/test1.xml: Likewise.
	* tests/data/test-read-write/test10.xml: Likewise.
	* tests/data/test-read-write/test11.xml: Likewise.
	* tests/data/test-read-write/test12.xml: Likewise.
	* tests/data/test-read-write/test13.xml: Likewise.
	* tests/data/test-read-write/test14.xml: Likewise.
	* tests/data/test-read-write/test15.xml: Likewise.
	* tests/data/test-read-write/test16.xml: Likewise.
	* tests/data/test-read-write/test17.xml: Likewise.
	* tests/data/test-read-write/test18.xml: Likewise.
	* tests/data/test-read-write/test19.xml: Likewise.
	* tests/data/test-read-write/test2.xml: Likewise.
	* tests/data/test-read-write/test20.xml: Likewise.
	* tests/data/test-read-write/test21.xml: Likewise.
	* tests/data/test-read-write/test22.xml: Likewise.
	* tests/data/test-read-write/test23.xml: Likewise.
	* tests/data/test-read-write/test24.xml: Likewise.
	* tests/data/test-read-write/test25.xml: Likewise.
	* tests/data/test-read-write/test26.xml: Likewise.
	* tests/data/test-read-write/test27.xml: Likewise.
	* tests/data/test-read-write/test28-without-std-fns-ref.xml:
	Likewise.
	* tests/data/test-read-write/test28-without-std-vars-ref.xml:
	Likewise.
	* tests/data/test-read-write/test3.xml: Likewise.
	* tests/data/test-read-write/test4.xml: Likewise.
	* tests/data/test-read-write/test5.xml: Likewise.
	* tests/data/test-read-write/test6.xml: Likewise.
	* tests/data/test-read-write/test7.xml: Likewise.
	* tests/data/test-read-write/test8.xml: Likewise.
	* tests/data/test-read-write/test9.xml: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-02-01 14:09:29 +01:00
Dodji Seketeli
d3b188f859 Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
	(template_decl_wptr): Declare new typedefs.
	(class template_decl): Make this virtually inherit decl_base and
	pimpl-ify it.
	(class template_parameter): Pimpl-ify this.  Make the constructor
	take the enclosing template parameter.
	(struct template_decl::hash): Declare this here, rather than in
	src/abg-hash.cc
	(class type_tparameter, non_type_tparameter, template_tparameter)
	(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
	this.
	* src/abg-hash.cc (template_parameter:#️⃣:operator()): Hash the
	enclosing template parameter.  Avoid infinite recursion due to the
	loop hash parameter -> hash template -> hash parameter.
	(template_decl:#️⃣:operator()) Define this here, now that it's
	declared in abg-ir.h.  Also, avoid infinite recursion here; this
	is complementary to what is done in the hashing for
	template_parameter.
	({type_tparameter, template_tparameter, }:#️⃣:operator()):
	Cache the calculated hash just as what is done for other types
	hashed.
	(template_decl::priv): Define this new type.
	(template_decl::{add_template_parameter, get_template_parameters,
	~template_decl}): Define these here to pimpl-ify template_decl.
	(template_parameter::priv): Define this new type.
	(template_parameter::template_parameter): Define this here to
	pimpl-ify template_parameter.  Note also that this now takes the
	enclosing template decl.
	(template_parameter::{get_index, get_enclosing_template_decl,
	get_hashing_has_started, set_hashing_has_started, operator::==}):
	Define these here to pimpl-ify template_parameter.
	(type_tparameter::priv): Define this new type.
	(type_tparameter::type_tparameter): Define this here to pimpl-ify
	type_tparameter.   Also, not that this constructor now takes the
	enclosing template decl.
	(class non_type_tparameter::priv): Define new type.
	(non_type_tparameter::{non_type_tparameter, get_type}): Define
	these here to pimpl-ify non_type_tparameter.  The constructor now
	takes the enclosing template.
	(template_tparameter::priv): Define new type.
	(template_tparameter::template_tparameter): Define this here to
	pimpl-ify template_tparameter.  This constructor now takes the
	enclosing template.
	(class type_composition::priv): New type.
	(type_composition::{type_composition, get_composed_type,
	set_composed_type}): Define these here to pimpl-ify
	type_composition.  The constructor now takes the enclosing
	template decl.
	(class function_tdecl::priv): Define new type.
	(function_tdecl::{function_tdecl, set_pattern, get_pattern,
	get_binding}): Define this here to pimpl-ify function_tdecl.
	(class class_tdecl::priv): Define this new type.
	(class_tdecl::class_tdecl): Define this here to pimpl-ify
	class_tdecl.
	(class_tdecl::set_pattern): Adjust to pimpl-ify.
	(class_tdecl::get_pattern): Define new pimpl-ified getter.
	* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
	Cleanup.  Pass the enclosing template to the template parameters
	that are built.
	(build_type_tparameter, build_type_composition)
	(build_non_type_tparameter, build_template_tparameter)
	(build_template_parameter): Take the enclosing template
	declaration and pass it to the template parameter being created.
	* tests/data/test-read-write/test12.xml: Fix and Adjust.
	* tests/data/test-read-write/test13.xml: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 12:16:34 +01:00
Dodji Seketeli
2c9fb3e70d Support new 'abi-corpus' native XML format (.abi)
* include/abg-reader.h (read_corpus_from_native_xml)
	(read_corpus_from_native_xml_file): Declare new entry points.
	* include/abg-writer.h (write_corpus_to_native_xml)
	(write_corpus_to_native_xml_file): Likewise.
	* src/abg-reader.cc (read_translation_unit_from_input): Renamed
	read_input into this.  Support new 'path' attribute for
	'abi-instr' XML element.
	(read_corpus_from_input): New static function.
	(read_translation_unit_from_file)
	(read_translation_unit_from_buffer)
	(read_translation_unit_from_istream): Update wrt read_input ->
	read_translation_unit_from_input.
	(read_corpus_from_native_xml, read_corpus_from_native_xml)
	(read_corpus_from_native_xml_file): Define new entry points.
	* src/abg-writer.cc (write_translation_unit): Write 'path'
	attribute into the 'abi-instr' xml element.
	(write_corpus_to_native_xml, write_corpus_to_native_xml_file):
	Define new entry points.
	* tools/abg-tools-utils.h (file_type::{FILE_TYPE_XML_CORPUS,
	FILE_TYPE_ZIP_CORPUS}): New enumerators.
	* tools/abg-tools-utils.cc (guess_file_type): Support detection of
	the new xml file format containing a document root 'abi-corpus'
	root element.
	* tools/bidiff.cc (main): Support diffing xml corpus-es and zip
	corpus-es.
	* tools/bidw.cc (main): Recognize elf files before reading them.
	* tools/bilint.cc (main): Support reading xml/zip corpus-es too.
	* tests/data/test-read-write/test[0-23].xml: Update 'path'
	attribute.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-07 14:12:26 +01:00
Dodji Seketeli
ee2d8c9196 Fix IR node comparison bugs
* include/abg-ir.h (type_shared_ptr_equal::operator()): Fix thinko
	in checking for the boolean value of the pointers to types.
	* src/abg-ir.cc (type_decl::operator==(const decl_base&)): Do not
	forget to compare the decl_base part of the type too.
	(type_decl::operator==(const type_base&)): To ease maintenance,
	re-use the equality operator that takes a decl_base.
	(scope_type_decl::operator==(const type_base&)): Likewise.
	(qualified_type_def::operator==(const type_base&)): Likewise.
	(compare_function_types): New sub-routine to compare function
	types.  It fixes an infinite recursion when comparing two methods
	of the same class.
	(function_type::operator==(const type_base&)): Use the new
	compare_function_types function.
	(class_decl::operator==(const decl_base&)): Fix a thinko in the
	first test of the function.  Use a dedicated scope for each class
	section comparison; that way, there won't be any chance to misuse
	the variables pertaining to a different section.  Fix the member
	function sections; we were mistakenly using the variables for the
	*data* section there.
	(class_decl::operator==(const type_base&)): Re-use the operator
	that takes a decl_base.
	(class_decl::operator==(const class_decl&)): Don't remove
	const-ness during the static cast.
	(class_decl::member_function::operator==(const member_function&)):
	Do not remove the reference from the static cast.
	(class_decl::member_class_template::operator==(const
	member_base&)): Likewise.
	(type_tparameter::operator==(const template_parameter&)):
	Likewise.
	(template_tparameter::operator==(const template_parameter&)):
	Likewise.
	(function_tdecl::operator==(const template_decl&)): Likewise.
	(class_tdecl::operator==(const template_decl&)): Likewise.
	(class_tdecl::operator==(const class_tdecl&)): Likewise.
	* tests/data/test-read-write/test12.xml: Update this because the
	test now correctly considers two type template parameters at the
	same index as being equivalent.
	* tests/data/test-read-write/test13.xml: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:25:09 +01:00
Dodji Seketeli
0c65215330 Support function_type and adapt a function_decl to use it
* src/abg-ir.h (class function_type): Forward decl prior to class
	function_decl.
	(function_decl::parameter): Pass string by const reference.  Add a
	variadic marker member and initialize it.
	(function_decl::parameter::get_type): Add a non-const overload.
	(function_decl::parameter::get_variadic_marker): New getter.
	(function_decl::function_decl) Take a const reference to a vector
	for parameters, type size/alignment.  Add two overloads that takes a
	pointer to function_type.
	(function_decl::get_parameters): Move this out-of-line.
	(function_decl::append_parameter(s)): Renamed
	function_decl::add_parameter(s) into these.  Move it out-of-line.
	Add an overload.
	(function_decl::{get_type, set_type}): New declaration.
	(function_decl::get_return_type): Move this out-of-line.
	(function_decl::is_variadic): New in-line function.
	(function_decl::m_type): New data member.
	(function_decl::{m_parms, m_return_type}): Remove.  This are now
	carried by function_decl::m_type.
	(class function_type, struct function_type_hash): New
	declarations.
	(member_function::member_function): Take a vector of pointers to
	parameters.  Take size/align of the type of the member function.
	Adjust initialization.
	* src/abg-ir.cc (dynamic_type_hash): Hash instance of
	function_type accessed through a pointer.
	(function_type::{operator==, ~function_type})
	(function_type_hash::operaror(), function_decl::{get_return_type,
	}, function_decl::parameter:#️⃣:operator()): New definitions.
	(function_decl::function_decl): The out-of-line definitions of the
	declarations above.
	(function_decl::append_parameter): Moved this out-of-line from
	inline function_decl::add_parameter.  Make this rely on the
	underlying m_type.
	(function_decl::operator==): Adjust for use of vector for the
	parameters.  Also, there is no need anymore to compare the
	parameters or the return types as they are compared by the
	comparison of the function types.
	* src/abg-reader.cc (build_function_decl): Read the new size/alignment
	attributes on the function-decl element.  Build a function_type
	and use it to build the function_decl.  Parameters and return type
	are now hung off of the function_type.
	(handle_function_decl): use build_function_decl.
	* src/abg-writer.cc (write_function_decl): Write the new
	size/alignment properties of the function-decl element.  Adjust
	for the use of vectors for function parameters now.
	* tests/data/test-read-write/test10.xml: Adjust for the presence
	of size/alignment properties in the function-decl element now.
	* tests/data/test-read-write/test11.xml: Likewise.
	* tests/data/test-read-write/test12.xml: Likewise.
	* tests/data/test-read-write/test13.xml: Likewise.
	* tests/data/test-read-write/test14.xml: Likewise.
	* tests/data/test-read-write/test9.xml: Likewise.
2013-07-23 23:13:53 +02:00
Dodji Seketeli
ace9af4568 Fix depth management during the parsing
* src/abg-ir.cc (decl_base_hash::operator()):  Don't hash the
	context for decls in general.
	* src/abg-reader.cc (read_context::push_decl_to_current_scope)
	(read_context::push_and_key_type_decl): Add an overload that takes
	a node and update_depth_info boolean.
	(build_var_decl, build_type_decl, build_qualified_type_decl)
	(build_pointer_type_def, build_reference_type_def)
	(build_enum_type_decl, build_type_decl)
	(build_template_type_parameter, build_template_non_type_parameter)
	(build_template_template_parameter, build_template_parameter)
	(build_type): Make these functions take an update_depth_info
	parameter.  Pass it do read_context::push_and_key_type_decl or
	read_context::push_decl_to_current_scope rather than call
	update_read_context.
	(build_function_decl, build_class_decl)
	(build_function_template_decl): Change the seen_by_reader
	parameter into update_depth_info.  Pass the update_depth_info bool
	to read_context::push_decl_to_current_scope rather than call
	update_depth_info here.
	(handle_class, handle_function_template_decl): Adjust.
	* tests/data/test-read-write/test12.xml: Add new test input.
	* tests/test-read-write.cc (InOutSpec in_out_specs): Add it to the
	list of input to de-serialize, serialize back and compare the two.
	* tests/Makefile.am: Add the new test input to the distribution.
2013-07-23 23:13:50 +02:00