mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-26 22:07:58 +08:00
bfd
binutils
config
contrib
cpu
elfcpp
etc
gas
gdb
gdbserver
gdbsupport
gnulib
gold
gprof
gprofng
include
intl
ld
libbacktrace
libctf
doc
testsuite
config
lib
libctf-lookup
ambiguous-struct-A.c
ambiguous-struct-B.c
ambiguous-struct.c
ambiguous-struct.lk
conflicting-type-syms-a.c
conflicting-type-syms-b.c
conflicting-type-syms.c
conflicting-type-syms.lk
enum-ctf.c
enum-many-ctf.c
enum-many.lk
enum-symbol-ctf.c
enum-symbol-obj.lk
enum-symbol.c
enum-symbol.lk
enum.c
enum.lk
lookup.exp
struct-iteration-ctf.c
struct-iteration.c
struct-iteration.lk
struct-lookup.c
struct-lookup.lk
libctf-regression
libctf-writable
.gitignore
ChangeLog
ChangeLog-2020
Makefile.am
Makefile.in
NEWS
aclocal.m4
config.h.in
configure
configure.ac
ctf-archive.c
ctf-create.c
ctf-decl.c
ctf-decls.h
ctf-dedup.c
ctf-dump.c
ctf-endian.h
ctf-error.c
ctf-hash.c
ctf-impl.h
ctf-inlines.h
ctf-intl.h
ctf-labels.c
ctf-link.c
ctf-lookup.c
ctf-open-bfd.c
ctf-open.c
ctf-qsort_r.c
ctf-serialize.c
ctf-sha1.c
ctf-sha1.h
ctf-string.c
ctf-subr.c
ctf-types.c
ctf-util.c
elf.h
libctf.ver
swap.h
libdecnumber
libiberty
opcodes
readline
sim
texinfo
zlib
.cvsignore
.editorconfig
.gitattributes
.gitignore
COPYING
COPYING.LIB
COPYING.LIBGLOSS
COPYING.NEWLIB
COPYING3
COPYING3.LIB
ChangeLog
MAINTAINERS
Makefile.def
Makefile.in
Makefile.tpl
README
README-maintainer-mode
ar-lib
compile
config-ml.in
config.guess
config.rpath
config.sub
configure
configure.ac
depcomp
djunpack.bat
install-sh
libtool.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
makefile.vms
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
setup.com
src-release.sh
symlink-tree
test-driver
ylwrap

libctf has no intrinsic support for the GCC unnamed structure member extension. This principally means that you can't look up named members inside unnamed struct or union members via ctf_member_info: you have to tiresomely find out the type ID of the unnamed members via iteration, then look in each of these. This is ridiculous. Fix it by extending ctf_member_info so that it recurses into unnamed members for you: this is still unambiguous because GCC won't let you create ambiguously-named members even in the presence of this extension. For consistency, and because the release hasn't happened and we can still do this, break the ctf_member_next API and add flags: we specify one flag, CTF_MN_RECURSE, which if set causes ctf_member_next to automatically recurse into unnamed members for you, returning not only the members themselves but all their contained members, so that you can use ctf_member_next to identify every member that it would be valid to call ctf_member_info with. New lookup tests are added for all of this. include/ChangeLog 2021-01-05 Nick Alcock <nick.alcock@oracle.com> * ctf-api.h (CTF_MN_RECURSE): New. (ctf_member_next): Add flags argument. libctf/ChangeLog 2021-01-05 Nick Alcock <nick.alcock@oracle.com> * ctf-impl.h (struct ctf_next) <u.ctn_next>: Move to... <ctn_next>: ... here. * ctf-util.c (ctf_next_destroy): Unconditionally destroy it. * ctf-lookup.c (ctf_symbol_next): Adjust accordingly. * ctf-types.c (ctf_member_iter): Reimplement in terms of... (ctf_member_next): ... this. Support recursive unnamed member iteration (off by default). (ctf_member_info): Look up members in unnamed sub-structs. * ctf-dedup.c (ctf_dedup_rhash_type): Adjust ctf_member_next call. (ctf_dedup_emit_struct_members): Likewise. * testsuite/libctf-lookup/struct-iteration-ctf.c: Test empty unnamed members, and a normal member after the end. * testsuite/libctf-lookup/struct-iteration.c: Verify that ctf_member_count is consistent with the number of successful returns from a non-recursive ctf_member_next. * testsuite/libctf-lookup/struct-iteration-*: New, test iteration over struct members. * testsuite/libctf-lookup/struct-lookup.c: New test. * testsuite/libctf-lookup/struct-lookup.lk: New test.
29 lines
400 B
C
29 lines
400 B
C
#include <unistd.h>
|
|
|
|
struct foo_t
|
|
{
|
|
int foo;
|
|
size_t bar;
|
|
const char *baz;
|
|
struct foo_t *self;
|
|
union
|
|
{
|
|
double should_not_appear;
|
|
char *nor_should_this;
|
|
} named;
|
|
struct
|
|
{
|
|
long unnamed_sub_member;
|
|
union
|
|
{
|
|
double one_more_level;
|
|
long yes_really_one_more;
|
|
};
|
|
};
|
|
struct {}; /* Empty ones */
|
|
union {};
|
|
int after_the_end;
|
|
};
|
|
|
|
struct foo_t used;
|