libabigail/tests
Dodji Seketeli 5b09ea77e2 Handle the life time of the map of canonical types
While working on something else, it turned out that we need to cleanup
(de-allocate) the map of canonical types when all the translation
units that own types are de-allocated.  Otherwise, when new
translation units are created later, the types in the canonical types
map become unrelated to the types in these new translation units,
leading to memory management issues.

This patch introduces a "usage watchdog" which detects when no
translation unit uses the type system anymore.  That usage watchdog is
then used in the destructor of the translation_unit type to
de-allocate the global data that is logically owned by by the type
system.

The patch also changes the API to read translation units and corpora
in a way that forces users to get a handle on the resulting shared
pointer.

	* include/abg-ir.h (type_base::canonical_types_map_type): Move
	this typedef into abg-ir.cc and out of the type_base namespace.
	(type_base::get_canonical_types_map): Likewise.
	* src/abg-ir.cc (canonical_types_map_type): New typedef that got
	moved here from type_base::canonical_types_map_type.
	(get_canonical_types_map): Likewise got moved here from
	type_base::get_canonical_types_map.  Made static in the process.
	(class usage_watchdog): New type.
	(usage_watchdog_sptr, usage_watchdog_wptr): New typedefs.
	(get_usage_watchdog, get_usage_watchdog_wptr, ref_usage_watchdog)
	(maybe_cleanup_type_system_data): New static functions.
	(translation_unit::priv::usage_watchdog_): Add new data member.
	(translation_unit::priv::priv): Get a reference on the usage
	watchdog.
	(translation_unit::priv::~priv): If the usage watchdog says that
	the type system is not used, then cleanup the global data
	logically owned by the type system.

	* include/abg-dwarf-reader.h (read_corpus_from_elf): Make this
	return a corpus and set the status by reference using a parameter.
	* src/abg-dwarf-reader.cc (read_corpus_from_elf): Implement the
	above.
	* include/abg-reader.h (read_translation_unit_from_file)
	(read_translation_unit_from_buffer)
	(read_translation_unit_from_istream): Remove the overloads that do
	not return a translation_unit_sptr and that pass it as a
	parameter.  Only keep the overloads that return a
	translation_unit_sptr, forcing users of the API to own a proper
	reference on the resulting translation_unit pointer.  That is
	important to handle the life time of the global data of the type
	system that need to be cleared when the last translation unit is
	de-allocated.
	* src/abg-reader.cc (read_translation_unit_from_input): Make this
	return a translation_unit_sptr.
	(read_translation_unit_from_file)
	(read_translation_unit_from_buffer)
	(read_translation_unit_from_istream): Remove the overloads that do
	not return a translation_unit_sptr and that pass it as a
	parameter.  Only keep the overloads that return a
	translation_unit_sptr.
	(read_to_translation_unit): Make this return a
	translation_unit_sptr.
	* tests/print-diff-tree.cc (main): Adjust.
	* tests/test-diff-dwarf.cc (main): Likewise.
	* tests/test-ir-walker.cc (main): Likewise.
	* tests/test-read-dwarf.cc (main): Likewise.
	* tests/test-read-write.cc (main): Likewise.
	* tools/abicompat.cc (main): Likewise.
	* tools/abidiff.cc (main): Likewise.
	* tools/abidw.cc (main): Likewise.
	* tools/abilint.cc (main): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-09 11:12:40 +02:00
..
data Adjust some tests for output changes 2015-07-09 00:10:33 +02:00
Makefile.am Build libabigail tests with position-independent code 2015-06-07 17:01:52 +02:00
print-diff-tree.cc Handle the life time of the map of canonical types 2015-07-09 11:12:40 +02:00
runtestcanonicalizetypes.sh.in
test-abicompat.cc Make abidiff and abicompat return meaningful exit codes 2015-04-10 16:26:36 +02:00
test-abidiff.cc 18166 - Abidiff fails with internal on Libtirpc ABI in XML format 2015-03-30 09:50:44 +02:00
test-alt-dwarf-file.cc
test-core-diff.cc
test-diff2.cc
test-diff-dwarf.cc Handle the life time of the map of canonical types 2015-07-09 11:12:40 +02:00
test-diff-filter.cc Fix redundancy marking for change of types used directly 2015-06-03 12:13:54 +02:00
test-diff-suppr.cc Support filtering out just one alias of a function 2015-07-02 17:15:35 +02:00
test-dot.cc
test-ir-walker.cc Handle the life time of the map of canonical types 2015-07-09 11:12:40 +02:00
test-lookup-syms.cc
test-read-dwarf.cc Handle the life time of the map of canonical types 2015-07-09 11:12:40 +02:00
test-read-write.cc Handle the life time of the map of canonical types 2015-07-09 11:12:40 +02:00
test-svg.cc
test-utils.cc
test-utils.h
test-write-read-archive.cc Fix archive writing support 2015-04-24 19:59:19 +02:00