binutils-gdb/libctf
Nick Alcock 26503e2f5e libctf, create: fix ctf_type_add of structs with unnamed members
Our recent commit to support unnamed structure members better ditched
the old ctf_member_iter iterator body in favour of ctf_member_next.
However, these functions treat unnamed structure members differently:
ctf_member_iter just returned whatever the internal representation
contained, while ctf_member_next took care to always return "" rather
than sometimes returning "" and sometimes NULL depending on whether the
dict was dynamic (a product of ctf_create) or not (a product of
ctf_open).  After this commit, ctf_member_iter did the same.

It was always a bug for external callers not to treat a "" return from
these functions as if it were NULL, so only buggy callers could be
affected -- but one of those buggy callers was ctf_add_type, which
assumed that it could just take whatever name was returned from
ctf_member_iter and slam it directly into the internal representation of
a dynamic dict -- which expects NULL for unnamed members, not "".  The
net effect of all of this is that taking a struct containing unnamed
members and ctf_add_type'ing it into a dynamic dict produced a dict
whose unnamed members were inaccessible to ctf_member_info (though if
you wrote that dict out and then ctf_open'ed it, they would magically
reappear again).

Compensate for this by suitably transforming a "" name into NULL in the
internal representation, as should have been done all along.

libctf/ChangeLog
2021-01-19  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-create.c (membadd): Transform ""-named members into
	NULL-named ones.
	* testsuite/libctf-regression/type-add-unnamed-struct*: New test.
2021-01-19 12:45:20 +00:00
..
testsuite libctf, create: fix ctf_type_add of structs with unnamed members 2021-01-19 12:45:20 +00:00
.gitignore
aclocal.m4 Implement a workaround for GNU mak jobserver 2021-01-12 05:45:44 -08:00
ChangeLog libctf, create: fix ctf_type_add of structs with unnamed members 2021-01-19 12:45:20 +00:00
ChangeLog-2020 libctf: fix old ChangeLog typo 2021-01-05 14:53:40 +00:00
config.h.in
configure Implement a workaround for GNU mak jobserver 2021-01-12 05:45:44 -08:00
configure.ac Implement a workaround for GNU mak jobserver 2021-01-12 05:45:44 -08:00
ctf-archive.c libctf: remove outdated comment about parent dict importing 2021-01-05 14:53:40 +00:00
ctf-create.c libctf, create: fix ctf_type_add of structs with unnamed members 2021-01-19 12:45:20 +00:00
ctf-decl.c
ctf-decls.h
ctf-dedup.c libctf, include: support unnamed structure members better 2021-01-05 14:53:40 +00:00
ctf-dump.c
ctf-endian.h
ctf-error.c
ctf-hash.c
ctf-impl.h libctf: fix lookups of pointers by name in parent dicts 2021-01-05 14:53:40 +00:00
ctf-inlines.h
ctf-intl.h
ctf-labels.c
ctf-link.c
ctf-lookup.c libctf: lookup_by_name: do not return success for nonexistent pointer types 2021-01-19 12:45:19 +00:00
ctf-open-bfd.c
ctf-open.c libctf: fix lookups of pointers by name in parent dicts 2021-01-05 14:53:40 +00:00
ctf-qsort_r.c
ctf-sha1.c
ctf-sha1.h
ctf-string.c
ctf-subr.c
ctf-types.c libctf, ld: fix formatting of forwards to unions and enums 2021-01-05 14:53:40 +00:00
ctf-util.c libctf, include: support unnamed structure members better 2021-01-05 14:53:40 +00:00
elf.h
libctf.ver
Makefile.am libctf, testsuite: don't run without a suitable compiler 2021-01-05 17:11:20 +00:00
Makefile.in Regen Makefile.in for jobserver.m4 aclocal.m4 dependency 2021-01-13 22:06:02 +10:30
swap.h