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


2.3.6 Slices

Slices, with kind CTF_K_SLICE, are an unusual CTF construct: they do not directly correspond to any C type, but are a way to model other types in a more convenient fashion for CTF generators.

A slice is like a pointer or other reference type in that they are always represented by ctf_stype_t: but unlike pointers and other reference types, they populate the ctt_size field just like integral types do, and come with an attached encoding and transform the encoding of the underlying type. The underlying type is described in the variable-length data, similarly to structure and union fields: see below. Requests for the type size should also chase down to the referenced type.

Slices are always nameless: ctt_name is always zero for them.

(The libctf API behaviour is unusual as well, and justifies the existence of slices: ctf_type_kind never returns CTF_K_SLICE but always the underlying type kind, so that consumers never need to know about slices: they can tell if an apparent integer is actually a slice if they need to by calling ctf_type_reference, which will uniquely return the underlying integral type rather than erroring out with ECTF_NOTREF if this is actually a slice. So slices act just like an integer with an encoding, but more closely mirror DWARF and other debugging information formats by allowing CTF file creators to represent a bitfield as a slice of an underlying integral type.)

The vlen in the info word for a slice should be ignored and is always zero. The variable-length data for a slice is a single ctf_slice_t:

typedef struct ctf_slice
{
  uint32_t cts_type;
  unsigned short cts_offset;
  unsigned short cts_bits;
} ctf_slice_t;
OffsetNameDescription
0x0uint32_t cts_type The type this slice is a slice of. Must be an integral type (or a floating-point type, but this nonsensical option will go away in v4.)
0x4unsigned short cts_offset The offset of this integral type in bits from the start of its enclosing structure field, adjusted for endianness: see section Structs and unions. Identical semantics to the CTF_INT_OFFSET field: see section Integer types. This field is much too long, because the maximum possible offset of an integral type would easily fit in a char: this field is bigger just for the sake of alignment. This will change in v4.
0x6unsigned short cts_bits The bit-width of this integral type. Identical semantics to the CTF_INT_BITS field: see section Integer types. As above, this field is really too large and will shrink in v4.

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