pahole: Describe expected use of 'default' in the man page
[dwarves.git] / ctf.h
blob25b79892bde37acf9a3ce2923e517e7e86c25f74
1 #ifndef _CTF_H
2 #define _CTF_H
3 /*
4 SPDX-License-Identifier: GPL-2.0-only
6 Copyright (C) 2019 Arnaldo Carvalho de Melo <acme@redhat.com>
7 */
9 #include <stdint.h>
11 struct ctf_header {
12 uint16_t ctf_magic; /* Header magic value */
13 #define CTF_MAGIC 0xcff1
14 #define CTF_MAGIC_SWAP 0xf1cf
16 uint8_t ctf_version; /* Header version */
17 #define CTF_VERSION 2
19 uint8_t ctf_flags; /* Header flags */
20 #define CTF_FLAGS_COMPR 0x01
22 uint32_t ctf_parent_label; /* Label of parent CTF object */
23 uint32_t ctf_parent_name; /* Name of parent CTF object */
25 /* All offsets are in bytes are relative to the end of
26 * this header.
28 uint32_t ctf_label_off; /* Offset of label section */
29 uint32_t ctf_object_off; /* Offset of data object section */
30 uint32_t ctf_func_off; /* Offset of function section */
31 uint32_t ctf_type_off; /* Offset of type section */
32 uint32_t ctf_str_off; /* Offset of string section */
33 uint32_t ctf_str_len; /* Length of string section */
36 #define CTF_REF_OFFSET(REF) ((REF) & 0x7fffffff)
37 #define CTF_REF_TBL_ID(REF) (((REF) >> 31) & 0x1)
38 #define CTF_STR_TBL_ID_0 0
39 #define CTF_STR_TBL_ID_1 1
41 #define CTF_REF_ENCODE(TBL, OFF) (((TBL) << 31) | (OFF))
43 struct ctf_label_ent {
44 uint32_t ctf_label_ref;
45 uint32_t ctf_type_index;
48 /* Types are encoded with ctf_short_type so long as the ctf_size
49 * field can be fully represented in a uint16_t. If not, then
50 * the ctf_size is given the value 0xffff and ctf_full_type is
51 * used.
53 struct ctf_short_type {
54 uint32_t ctf_name;
55 uint16_t ctf_info;
56 union {
57 uint16_t ctf_size;
58 uint16_t ctf_type;
62 struct ctf_full_type {
63 struct ctf_short_type base;
64 uint32_t ctf_size_high;
65 uint32_t ctf_size_low;
68 #define CTF_GET_KIND(VAL) (((VAL) >> 11) & 0x1f)
69 #define CTF_GET_VLEN(VAL) ((VAL) & 0x3ff)
70 #define CTF_ISROOT(VAL) (((VAL) & 0x400) != 0)
72 #define CTF_INFO_ENCODE(KIND, VLEN, ISROOT) \
73 (((ISROOT) ? 0x400 : 0) | ((KIND) << 11) | (VLEN))
75 #define CTF_TYPE_KIND_UNKN 0 /* Unknown */
76 #define CTF_TYPE_KIND_INT 1 /* Integer */
77 #define CTF_TYPE_KIND_FLT 2 /* Float */
78 #define CTF_TYPE_KIND_PTR 3 /* Pointer */
79 #define CTF_TYPE_KIND_ARR 4 /* Array */
80 #define CTF_TYPE_KIND_FUNC 5 /* Function */
81 #define CTF_TYPE_KIND_STR 6 /* Struct */
82 #define CTF_TYPE_KIND_UNION 7 /* Union */
83 #define CTF_TYPE_KIND_ENUM 8 /* Enumeration */
84 #define CTF_TYPE_KIND_FWD 9 /* Forward */
85 #define CTF_TYPE_KIND_TYPDEF 10 /* Typedef */
86 #define CTF_TYPE_KIND_VOLATILE 11 /* Volatile */
87 #define CTF_TYPE_KIND_CONST 12 /* Const */
88 #define CTF_TYPE_KIND_RESTRICT 13 /* Restrict */
89 #define CTF_TYPE_KIND_MAX 31
91 #define CTF_TYPE_INT_ATTRS(VAL) ((VAL) >> 24)
92 #define CTF_TYPE_INT_OFFSET(VAL) (((VAL) >> 16) & 0xff)
93 #define CTF_TYPE_INT_BITS(VAL) ((VAL) & 0xffff)
95 #define CTF_TYPE_INT_ENCODE(ATTRS, OFF, BITS) \
96 (((ATTRS) << 24) | ((OFF) << 16) | (BITS))
98 /* Integer type attributes */
99 #define CTF_TYPE_INT_SIGNED 0x1
100 #define CTF_TYPE_INT_CHAR 0x2
101 #define CTF_TYPE_INT_BOOL 0x4
102 #define CTF_TYPE_INT_VARARGS 0x8
104 #define CTF_TYPE_FP_ATTRS(VAL) ((VAL) >> 24)
105 #define CTF_TYPE_FP_OFFSET(VAL) (((VAL) >> 16) & 0xff)
106 #define CTF_TYPE_FP_BITS(VAL) ((VAL) & 0xffff)
108 #define CTF_TYPE_FP_ENCODE(ATTRS, OFF, BITS) \
109 (((ATTRS) << 24) | ((OFF) << 16) | (BITS))
111 /* Possible values for the float type attribute field */
112 #define CTF_TYPE_FP_SINGLE 1
113 #define CTF_TYPE_FP_DOUBLE 2
114 #define CTF_TYPE_FP_CMPLX 3
115 #define CTF_TYPE_FP_CMPLX_DBL 4
116 #define CTF_TYPE_FP_CMPLX_LDBL 5
117 #define CTF_TYPE_FP_LDBL 6
118 #define CTF_TYPE_FP_INTVL 7
119 #define CTF_TYPE_FP_INTVL_DBL 8
120 #define CTF_TYPE_FP_INTVL_LDBL 9
121 #define CTF_TYPE_FP_IMGRY 10
122 #define CTF_TYPE_FP_IMGRY_DBL 11
123 #define CTF_TYPE_FP_IMGRY_LDBL 12
124 #define CTF_TYPE_FP_MAX 12
126 struct ctf_enum {
127 uint32_t ctf_enum_name;
128 uint32_t ctf_enum_val;
131 struct ctf_array {
132 uint16_t ctf_array_type;
133 uint16_t ctf_array_index_type;
134 uint32_t ctf_array_nelems;
137 /* Struct members are encoded with either ctf_short_member or
138 * ctf_full_member, depending upon the 'size' of the struct or
139 * union being defined. If it is less than CTF_SHORT_MEMBER_LIMIT
140 * then ctf_short_member objects are used to encode, else
141 * ctf_full_member is used.
143 #define CTF_SHORT_MEMBER_LIMIT 8192
145 struct ctf_short_member {
146 uint32_t ctf_member_name;
147 uint16_t ctf_member_type;
148 uint16_t ctf_member_offset;
151 struct ctf_full_member {
152 uint32_t ctf_member_name;
153 uint16_t ctf_member_type;
154 uint16_t ctf_member_unused;
155 uint32_t ctf_member_offset_high;
156 uint32_t ctf_member_offset_low;
159 #endif /* _CTF_H */