Cleanup: apply `include-what-you-use` guideline for `uint*_t`
[lttng-ust.git] / liblttng-ust / filter-bytecode.h
CommitLineData
cd54f6d9
MD
1#ifndef _FILTER_BYTECODE_H
2#define _FILTER_BYTECODE_H
3
4/*
5 * filter-bytecode.h
6 *
7 * LTTng filter bytecode
8 *
7e50015d 9 * Copyright 2012-2016 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
cd54f6d9 10 *
7e50015d
MD
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
cd54f6d9 17 *
7e50015d
MD
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
cd54f6d9 20 *
7e50015d
MD
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * SOFTWARE.
cd54f6d9
MD
28 */
29
fb31eb73 30#include <stdint.h>
cd54f6d9
MD
31#include <lttng/ust-abi.h>
32
db56acaf
MD
33#ifndef LTTNG_PACKED
34#error "LTTNG_PACKED should be defined"
35#endif
36
cd54f6d9
MD
37/*
38 * offsets are absolute from start of bytecode.
39 */
40
cd54f6d9
MD
41struct field_ref {
42 /* Initially, symbol offset. After link, field offset. */
43 uint16_t offset;
cd54f6d9
MD
44} __attribute__((packed));
45
47e5f13e
MD
46struct get_symbol {
47 /* Symbol offset. */
48 uint16_t offset;
49} LTTNG_PACKED;
50
51struct get_index_u16 {
52 uint16_t index;
53} LTTNG_PACKED;
54
55struct get_index_u64 {
56 uint64_t index;
57} LTTNG_PACKED;
58
cd54f6d9
MD
59struct literal_numeric {
60 int64_t v;
61} __attribute__((packed));
62
da6eed25
MD
63struct literal_double {
64 double v;
65} __attribute__((packed));
66
cd54f6d9
MD
67struct literal_string {
68 char string[0];
69} __attribute__((packed));
70
71enum filter_op {
3151a51d 72 FILTER_OP_UNKNOWN = 0,
cd54f6d9 73
3151a51d 74 FILTER_OP_RETURN = 1,
cd54f6d9
MD
75
76 /* binary */
3151a51d
PP
77 FILTER_OP_MUL = 2,
78 FILTER_OP_DIV = 3,
79 FILTER_OP_MOD = 4,
80 FILTER_OP_PLUS = 5,
81 FILTER_OP_MINUS = 6,
0039e2d8
MD
82 FILTER_OP_BIT_RSHIFT = 7,
83 FILTER_OP_BIT_LSHIFT = 8,
47e5f13e
MD
84 FILTER_OP_BIT_AND = 9,
85 FILTER_OP_BIT_OR = 10,
86 FILTER_OP_BIT_XOR = 11,
226106c0
MD
87
88 /* binary comparators */
3151a51d
PP
89 FILTER_OP_EQ = 12,
90 FILTER_OP_NE = 13,
91 FILTER_OP_GT = 14,
92 FILTER_OP_LT = 15,
93 FILTER_OP_GE = 16,
94 FILTER_OP_LE = 17,
95
96 /* string binary comparator: apply to */
97 FILTER_OP_EQ_STRING = 18,
98 FILTER_OP_NE_STRING = 19,
99 FILTER_OP_GT_STRING = 20,
100 FILTER_OP_LT_STRING = 21,
101 FILTER_OP_GE_STRING = 22,
102 FILTER_OP_LE_STRING = 23,
226106c0
MD
103
104 /* s64 binary comparator */
3151a51d
PP
105 FILTER_OP_EQ_S64 = 24,
106 FILTER_OP_NE_S64 = 25,
107 FILTER_OP_GT_S64 = 26,
108 FILTER_OP_LT_S64 = 27,
109 FILTER_OP_GE_S64 = 28,
110 FILTER_OP_LE_S64 = 29,
226106c0
MD
111
112 /* double binary comparator */
3151a51d
PP
113 FILTER_OP_EQ_DOUBLE = 30,
114 FILTER_OP_NE_DOUBLE = 31,
115 FILTER_OP_GT_DOUBLE = 32,
116 FILTER_OP_LT_DOUBLE = 33,
117 FILTER_OP_GE_DOUBLE = 34,
118 FILTER_OP_LE_DOUBLE = 35,
226106c0 119
dbea82ec 120 /* Mixed S64-double binary comparators */
3151a51d
PP
121 FILTER_OP_EQ_DOUBLE_S64 = 36,
122 FILTER_OP_NE_DOUBLE_S64 = 37,
123 FILTER_OP_GT_DOUBLE_S64 = 38,
124 FILTER_OP_LT_DOUBLE_S64 = 39,
125 FILTER_OP_GE_DOUBLE_S64 = 40,
126 FILTER_OP_LE_DOUBLE_S64 = 41,
127
128 FILTER_OP_EQ_S64_DOUBLE = 42,
129 FILTER_OP_NE_S64_DOUBLE = 43,
130 FILTER_OP_GT_S64_DOUBLE = 44,
131 FILTER_OP_LT_S64_DOUBLE = 45,
132 FILTER_OP_GE_S64_DOUBLE = 46,
133 FILTER_OP_LE_S64_DOUBLE = 47,
dbea82ec 134
cd54f6d9 135 /* unary */
3151a51d
PP
136 FILTER_OP_UNARY_PLUS = 48,
137 FILTER_OP_UNARY_MINUS = 49,
138 FILTER_OP_UNARY_NOT = 50,
139 FILTER_OP_UNARY_PLUS_S64 = 51,
140 FILTER_OP_UNARY_MINUS_S64 = 52,
141 FILTER_OP_UNARY_NOT_S64 = 53,
142 FILTER_OP_UNARY_PLUS_DOUBLE = 54,
143 FILTER_OP_UNARY_MINUS_DOUBLE = 55,
144 FILTER_OP_UNARY_NOT_DOUBLE = 56,
cd54f6d9
MD
145
146 /* logical */
3151a51d
PP
147 FILTER_OP_AND = 57,
148 FILTER_OP_OR = 58,
cd54f6d9 149
77aa5901 150 /* load field ref */
3151a51d
PP
151 FILTER_OP_LOAD_FIELD_REF = 59,
152 FILTER_OP_LOAD_FIELD_REF_STRING = 60,
153 FILTER_OP_LOAD_FIELD_REF_SEQUENCE = 61,
154 FILTER_OP_LOAD_FIELD_REF_S64 = 62,
155 FILTER_OP_LOAD_FIELD_REF_DOUBLE = 63,
2f0145d1 156
77aa5901 157 /* load immediate from operand */
3151a51d
PP
158 FILTER_OP_LOAD_STRING = 64,
159 FILTER_OP_LOAD_S64 = 65,
160 FILTER_OP_LOAD_DOUBLE = 66,
cd54f6d9 161
49905038 162 /* cast */
3151a51d
PP
163 FILTER_OP_CAST_TO_S64 = 67,
164 FILTER_OP_CAST_DOUBLE_TO_S64 = 68,
165 FILTER_OP_CAST_NOP = 69,
49905038 166
77aa5901 167 /* get context ref */
3151a51d
PP
168 FILTER_OP_GET_CONTEXT_REF = 70,
169 FILTER_OP_GET_CONTEXT_REF_STRING = 71,
170 FILTER_OP_GET_CONTEXT_REF_S64 = 72,
171 FILTER_OP_GET_CONTEXT_REF_DOUBLE = 73,
172
173 /* load userspace field ref */
174 FILTER_OP_LOAD_FIELD_REF_USER_STRING = 74,
175 FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE = 75,
176
177 /*
178 * load immediate star globbing pattern (literal string)
179 * from immediate
180 */
181 FILTER_OP_LOAD_STAR_GLOB_STRING = 76,
182
183 /* globbing pattern binary operator: apply to */
184 FILTER_OP_EQ_STAR_GLOB_STRING = 77,
185 FILTER_OP_NE_STAR_GLOB_STRING = 78,
77aa5901 186
47e5f13e
MD
187 /*
188 * Instructions for recursive traversal through composed types.
189 */
190 FILTER_OP_GET_CONTEXT_ROOT = 79,
191 FILTER_OP_GET_APP_CONTEXT_ROOT = 80,
192 FILTER_OP_GET_PAYLOAD_ROOT = 81,
193
194 FILTER_OP_GET_SYMBOL = 82,
195 FILTER_OP_GET_SYMBOL_FIELD = 83,
196 FILTER_OP_GET_INDEX_U16 = 84,
197 FILTER_OP_GET_INDEX_U64 = 85,
198
199 FILTER_OP_LOAD_FIELD = 86,
200 FILTER_OP_LOAD_FIELD_S8 = 87,
201 FILTER_OP_LOAD_FIELD_S16 = 88,
202 FILTER_OP_LOAD_FIELD_S32 = 89,
203 FILTER_OP_LOAD_FIELD_S64 = 90,
204 FILTER_OP_LOAD_FIELD_U8 = 91,
205 FILTER_OP_LOAD_FIELD_U16 = 92,
206 FILTER_OP_LOAD_FIELD_U32 = 93,
207 FILTER_OP_LOAD_FIELD_U64 = 94,
208 FILTER_OP_LOAD_FIELD_STRING = 95,
209 FILTER_OP_LOAD_FIELD_SEQUENCE = 96,
210 FILTER_OP_LOAD_FIELD_DOUBLE = 97,
211
0039e2d8
MD
212 FILTER_OP_UNARY_BIT_NOT = 98,
213
93c591bb
MD
214 FILTER_OP_RETURN_S64 = 99,
215
cd54f6d9
MD
216 NR_FILTER_OPS,
217};
218
219typedef uint8_t filter_opcode_t;
220
221struct load_op {
222 filter_opcode_t op;
cd54f6d9
MD
223 char data[0];
224 /* data to load. Size known by enum filter_opcode and null-term char. */
225} __attribute__((packed));
226
227struct binary_op {
228 filter_opcode_t op;
229} __attribute__((packed));
230
231struct unary_op {
232 filter_opcode_t op;
cd54f6d9
MD
233} __attribute__((packed));
234
235/* skip_offset is absolute from start of bytecode */
236struct logical_op {
237 filter_opcode_t op;
238 uint16_t skip_offset; /* bytecode insn, if skip second test */
239} __attribute__((packed));
240
49905038
MD
241struct cast_op {
242 filter_opcode_t op;
49905038
MD
243} __attribute__((packed));
244
cd54f6d9
MD
245struct return_op {
246 filter_opcode_t op;
247} __attribute__((packed));
248
249#endif /* _FILTER_BYTECODE_H */
This page took 0.039416 seconds and 4 git commands to generate.