binutils-gdb/libctf
Nick Alcock 99dc3ebdff libctf: properly handle ctf_add_type of forwards and self-reffing structs
The code to handle structures (and unions) that refer to themselves in
ctf_add_type is extremely dodgy.  It works by looking through the list
of not-yet-committed types for a structure with the same name as the
structure in question and assuming, if it finds it, that this must be a
reference to the same type.  This is a linear search that gets ever
slower as the dictionary grows, requiring you to call ctf_update at
intervals to keep performance tolerable: but if you do that, you run
into the problem that if a forward declared before the ctf_update is
changed to a structure afterwards, ctf_update explodes.

The last commit fixed most of this: this commit can use it, adding a new
ctf_add_processing hash that tracks source type IDs that are currently
being processed and uses it to avoid infinite recursion rather than the
dynamic type list: we split ctf_add_type into a ctf_add_type_internal,
so that ctf_add_type itself can become a wrapper that empties out this
being-processed hash once the entire recursive type addition is over.
Structure additions themselves avoid adding their dependent types
quite so much by checking the type mapping and avoiding re-adding types
we already know we have added.

We also add support for adding forwards to dictionaries that already
contain the thing they are a forward to: we just silently return the
original type.

v4: return existing struct/union/enum types properly, rather than using
    an uninitialized variable: shrinks sizes of CTF sections back down
    to roughly where they were in v1/v2 of this patch series.
v5: fix tabdamage.

libctf/
	* ctf-impl.h (ctf_file_t) <ctf_add_processing>: New.
	* ctf-open.c (ctf_file_close): Free it.
	* ctf-create.c (ctf_serialize): Adjust.
	(membcmp): When reporting a conflict due to an error, report the
	error.
	(ctf_add_type): Turn into a ctf_add_processing wrapper.  Rename to...
	(ctf_add_type_internal): ... this.  Hand back types we are already
	in the middle of adding immediately.  Hand back structs/unions with
	the same number of members immediately.  Do not walk the dynamic
	list.  Call ctf_add_type_internal, not ctf_add_type.  Handle
	forwards promoted to other types and the inverse case identically.
	Add structs to the mapping as soon as we intern them, before they
	gain any members.
2019-10-03 17:04:56 +01:00
..
ChangeLog libctf: properly handle ctf_add_type of forwards and self-reffing structs 2019-10-03 17:04:56 +01:00
Makefile.am libctf: installable libctf as a shared library 2019-10-03 17:04:56 +01:00
Makefile.in libctf: installable libctf as a shared library 2019-10-03 17:04:56 +01:00
aclocal.m4 libctf: installable libctf as a shared library 2019-10-03 17:04:56 +01:00
config.h.in libctf: installable libctf as a shared library 2019-10-03 17:04:56 +01:00
configure libctf: installable libctf as a shared library 2019-10-03 17:04:56 +01:00
configure.ac libctf: installable libctf as a shared library 2019-10-03 17:04:56 +01:00
ctf-archive.c libctf: avoid the need to ever use ctf_update 2019-10-03 17:04:56 +01:00
ctf-create.c libctf: properly handle ctf_add_type of forwards and self-reffing structs 2019-10-03 17:04:56 +01:00
ctf-decl.c libctf: core type lookup 2019-05-28 17:08:14 +01:00
ctf-decls.h libctf: avoid strndup 2019-06-07 13:46:39 +01:00
ctf-dump.c libctf: handle nonrepresentable types at link time 2019-10-03 17:04:56 +01:00
ctf-endian.h libctf: make it compile for old glibc 2019-10-03 17:04:55 +01:00
ctf-error.c libctf: handle nonrepresentable types at link time 2019-10-03 17:04:56 +01:00
ctf-hash.c libctf: don't leak hash keys or values on value replacement 2019-10-03 17:04:55 +01:00
ctf-impl.h libctf: properly handle ctf_add_type of forwards and self-reffing structs 2019-10-03 17:04:56 +01:00
ctf-labels.c libctf: fix a number of build problems found on Solaris and NetBSD 2019-05-31 11:10:51 +02:00
ctf-link.c libctf: avoid the need to ever use ctf_update 2019-10-03 17:04:56 +01:00
ctf-lookup.c libctf: avoid the need to ever use ctf_update 2019-10-03 17:04:56 +01:00
ctf-open-bfd.c libctf: actually close bfds we have opened 2019-10-03 17:04:55 +01:00
ctf-open.c libctf: properly handle ctf_add_type of forwards and self-reffing structs 2019-10-03 17:04:56 +01:00
ctf-qsort_r.c libctf: look for BSD versus GNU qsort_r signatures 2019-06-04 17:05:08 +01:00
ctf-string.c libctf: avoid the need to ever use ctf_update 2019-10-03 17:04:56 +01:00
ctf-subr.c libctf: drop mmap()-based CTF data allocator 2019-06-21 13:04:02 +01:00
ctf-types.c libctf: avoid the need to ever use ctf_update 2019-10-03 17:04:56 +01:00
ctf-util.c libctf: avoid the need to ever use ctf_update 2019-10-03 17:04:56 +01:00
elf.h libctf: low-level list manipulation and helper utilities 2019-05-28 17:07:19 +01:00
libctf.ver libctf: installable libctf as a shared library 2019-10-03 17:04:56 +01:00
swap.h libctf: fix a number of build problems found on Solaris and NetBSD 2019-05-31 11:10:51 +02:00