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 libctf: restructure error handling to reduce relocations 2020-07-22 17:57:20 +01:00
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 libctf, dedup: add deduplicator 2020-07-22 18:02:19 +01:00
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 libctf, ld: dump enums: generally improve dump formatting 2021-01-05 14:53:39 +00:00
ctf-decls.h Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-dedup.c libctf, include: support unnamed structure members better 2021-01-05 14:53:40 +00:00
ctf-dump.c libctf, ld: dump enums: generally improve dump formatting 2021-01-05 14:53:39 +00:00
ctf-endian.h Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-error.c Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-hash.c Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-impl.h libctf: fix lookups of pointers by name in parent dicts 2021-01-05 14:53:40 +00:00
ctf-inlines.h Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-intl.h Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-labels.c Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-link.c libctf: warn about information loss because of unreleased format changes 2021-01-05 14:53:40 +00:00
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 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
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 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-sha1.c Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-sha1.h Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-string.c Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ctf-subr.c Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
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 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
libctf.ver Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
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 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30