Next: , Up: The type section   [Contents][Index]


2.3.1 The info word, ctt_info

The info word is a bitfield split into three parts. From MSB to LSB:

Bit offsetNameDescription
26–31kindType kind: see section Type kinds.
25isroot1 if this type is visible to name lookup
0–24vlenLength of variable-length data for this type (some kinds only). The variable-length data directly follows the ctf_type_t or ctf_stype_t. This is a kind-dependent array length value, not a length in bytes. Some kinds have no variable-length data, or fixed-size variable-length data, and do not use this value.

The most mysterious of these is undoubtedly isroot. This indicates whether types with names (nonzero ctt_name) are visible to name lookup: if zero, this type is considered a non-root type and you can’t look it up by name at all. Multiple types with the same name in the same C namespace (struct, union, enum, other) can exist in a single dictionary, but only one of them may have a nonzero value for isroot. libctf validates this at open time and refuses to open dictionaries that violate this constraint.

Historically, this feature was introduced for the encoding of bitfields (see section Integer types): for instance, int bitfields will all be named int with different widths or offsets, but only the full-width one at offset zero is wanted when you look up the type named int. With the introduction of slices (see section Slices) as a more general bitfield encoding mechanism, this is less important, but we still use non-root types to handle conflicts if the linker API is used to fuse multiple translation units into one dictionary and those translation units contain types with the same name and conflicting definitions. (We do not discuss this further here, because the linker never does this: only specialized type mergers do, like that used for the Linux kernel. The libctf documentation will describe this in more detail.)

The CTF_TYPE_INFO macro can be used to compose an info word from a kind, isroot, and vlen; CTF_V2_INFO_KIND, CTF_V2_INFO_ISROOT and CTF_V2_INFO_VLEN pick it apart again.


Next: , Up: The type section   [Contents][Index]