]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
libctf: create: struct/union addition
authorNick Alcock <nick.alcock@oracle.com>
Thu, 24 Apr 2025 15:28:26 +0000 (16:28 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Mon, 3 Nov 2025 15:49:20 +0000 (15:49 +0000)
commitca16f2778db2cf3dc23fbe5451400f2f62a080af
tree548af51badff33d1e1c22794ea196c3e5e8e0cc8
parent62f20b1040a176dec4421bcc19dda0cf8ddfd7eb
libctf: create: struct/union addition

There's one API addition here: the existing CTF_ADD_ROOT / CTF_ADD_NONROOT
flags can have a new flag ORed with them, CTF_ADD_STRUCT_BITFIELDS,
indicating that the newly-added struct/union is capable of having bitfields
added to it via the new ctf_add_member_bitfield function (see a later
commit).

Without this, you can only add bitfields via the deprecated slice or base
type encoding representations (the former will force CTF output).

Implementation notes: structs and unions are always added with a CTF_K_BIG
prefix: if promoting from a forward, one is added.  These are elided at
serialization time if they are not needed to encode this size of struct /
this number of members.  (This means you don't have to figure out in advance
if your struct will be too big for BTF: you can just add members to it,
and libctf will figure it out and upgrade the dict as needed, or tell you
it can't if you've forbidden such things.)

We take advantage of this to merge a couple of very similar functions,
saving a bit of code.
include/ctf-api.h
libctf/ctf-create.c