Tests: ns_contexts: discarded events result in test failure
[lttng-tools.git] / src / common / filter / filter-bytecode.h
CommitLineData
953192ba
MD
1#ifndef _FILTER_BYTECODE_H
2#define _FILTER_BYTECODE_H
3
4/*
5 * filter-bytecode.h
6 *
7 * LTTng filter bytecode
8 *
ab5be9fa 9 * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
953192ba 10 *
ab5be9fa 11 * SPDX-License-Identifier: LGPL-2.1-only
953192ba 12 *
953192ba
MD
13 */
14
d00c599e 15#include <common/sessiond-comm/sessiond-comm.h>
aa52c986 16#include <common/macros.h>
d00c599e 17
953192ba
MD
18#include "filter-ast.h"
19
20/*
21 * offsets are absolute from start of bytecode.
22 */
23
953192ba
MD
24struct field_ref {
25 /* Initially, symbol offset. After link, field offset. */
26 uint16_t offset;
6f30f9b8 27} LTTNG_PACKED;
953192ba 28
bff988fa
MD
29struct get_symbol {
30 /* Symbol offset. */
661dfdd1 31 uint16_t offset;
bff988fa
MD
32} LTTNG_PACKED;
33
34struct get_index_u16 {
35 uint16_t index;
36} LTTNG_PACKED;
37
38struct get_index_u64 {
39 uint64_t index;
661dfdd1
MD
40} LTTNG_PACKED;
41
953192ba
MD
42struct literal_numeric {
43 int64_t v;
6f30f9b8 44} LTTNG_PACKED;
953192ba 45
e90d8561
MD
46struct literal_double {
47 double v;
6f30f9b8 48} LTTNG_PACKED;
e90d8561 49
953192ba
MD
50struct literal_string {
51 char string[0];
6f30f9b8 52} LTTNG_PACKED;
953192ba
MD
53
54enum filter_op {
7e6831d1 55 FILTER_OP_UNKNOWN = 0,
953192ba 56
7e6831d1 57 FILTER_OP_RETURN = 1,
953192ba
MD
58
59 /* binary */
7e6831d1
MD
60 FILTER_OP_MUL = 2,
61 FILTER_OP_DIV = 3,
62 FILTER_OP_MOD = 4,
63 FILTER_OP_PLUS = 5,
64 FILTER_OP_MINUS = 6,
116d3c01
MD
65 FILTER_OP_BIT_RSHIFT = 7,
66 FILTER_OP_BIT_LSHIFT = 8,
bff988fa
MD
67 FILTER_OP_BIT_AND = 9,
68 FILTER_OP_BIT_OR = 10,
69 FILTER_OP_BIT_XOR = 11,
78228322
MD
70
71 /* binary comparators */
7e6831d1
MD
72 FILTER_OP_EQ = 12,
73 FILTER_OP_NE = 13,
74 FILTER_OP_GT = 14,
75 FILTER_OP_LT = 15,
76 FILTER_OP_GE = 16,
77 FILTER_OP_LE = 17,
953192ba 78
9f449915 79 /* string binary comparator: apply to */
7e6831d1
MD
80 FILTER_OP_EQ_STRING = 18,
81 FILTER_OP_NE_STRING = 19,
82 FILTER_OP_GT_STRING = 20,
83 FILTER_OP_LT_STRING = 21,
84 FILTER_OP_GE_STRING = 22,
85 FILTER_OP_LE_STRING = 23,
78228322
MD
86
87 /* s64 binary comparator */
7e6831d1
MD
88 FILTER_OP_EQ_S64 = 24,
89 FILTER_OP_NE_S64 = 25,
90 FILTER_OP_GT_S64 = 26,
91 FILTER_OP_LT_S64 = 27,
92 FILTER_OP_GE_S64 = 28,
93 FILTER_OP_LE_S64 = 29,
78228322
MD
94
95 /* double binary comparator */
7e6831d1
MD
96 FILTER_OP_EQ_DOUBLE = 30,
97 FILTER_OP_NE_DOUBLE = 31,
98 FILTER_OP_GT_DOUBLE = 32,
99 FILTER_OP_LT_DOUBLE = 33,
100 FILTER_OP_GE_DOUBLE = 34,
101 FILTER_OP_LE_DOUBLE = 35,
78228322 102
78370c0c 103 /* Mixed S64-double binary comparators */
7e6831d1
MD
104 FILTER_OP_EQ_DOUBLE_S64 = 36,
105 FILTER_OP_NE_DOUBLE_S64 = 37,
106 FILTER_OP_GT_DOUBLE_S64 = 38,
107 FILTER_OP_LT_DOUBLE_S64 = 39,
108 FILTER_OP_GE_DOUBLE_S64 = 40,
109 FILTER_OP_LE_DOUBLE_S64 = 41,
110
111 FILTER_OP_EQ_S64_DOUBLE = 42,
112 FILTER_OP_NE_S64_DOUBLE = 43,
113 FILTER_OP_GT_S64_DOUBLE = 44,
114 FILTER_OP_LT_S64_DOUBLE = 45,
115 FILTER_OP_GE_S64_DOUBLE = 46,
116 FILTER_OP_LE_S64_DOUBLE = 47,
78370c0c 117
953192ba 118 /* unary */
7e6831d1
MD
119 FILTER_OP_UNARY_PLUS = 48,
120 FILTER_OP_UNARY_MINUS = 49,
121 FILTER_OP_UNARY_NOT = 50,
122 FILTER_OP_UNARY_PLUS_S64 = 51,
123 FILTER_OP_UNARY_MINUS_S64 = 52,
124 FILTER_OP_UNARY_NOT_S64 = 53,
125 FILTER_OP_UNARY_PLUS_DOUBLE = 54,
126 FILTER_OP_UNARY_MINUS_DOUBLE = 55,
127 FILTER_OP_UNARY_NOT_DOUBLE = 56,
953192ba
MD
128
129 /* logical */
7e6831d1
MD
130 FILTER_OP_AND = 57,
131 FILTER_OP_OR = 58,
953192ba 132
586dc72f 133 /* load field ref */
7e6831d1
MD
134 FILTER_OP_LOAD_FIELD_REF = 59,
135 FILTER_OP_LOAD_FIELD_REF_STRING = 60,
136 FILTER_OP_LOAD_FIELD_REF_SEQUENCE = 61,
137 FILTER_OP_LOAD_FIELD_REF_S64 = 62,
138 FILTER_OP_LOAD_FIELD_REF_DOUBLE = 63,
65775683 139
586dc72f 140 /* load immediate from operand */
7e6831d1
MD
141 FILTER_OP_LOAD_STRING = 64,
142 FILTER_OP_LOAD_S64 = 65,
143 FILTER_OP_LOAD_DOUBLE = 66,
953192ba 144
8cf9540a 145 /* cast */
7e6831d1
MD
146 FILTER_OP_CAST_TO_S64 = 67,
147 FILTER_OP_CAST_DOUBLE_TO_S64 = 68,
148 FILTER_OP_CAST_NOP = 69,
8cf9540a 149
586dc72f
MD
150 /* get context ref */
151 FILTER_OP_GET_CONTEXT_REF = 70,
152 FILTER_OP_GET_CONTEXT_REF_STRING = 71,
153 FILTER_OP_GET_CONTEXT_REF_S64 = 72,
154 FILTER_OP_GET_CONTEXT_REF_DOUBLE = 73,
155
00a62084
MD
156 /* load userspace field ref */
157 FILTER_OP_LOAD_FIELD_REF_USER_STRING = 74,
158 FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE = 75,
159
9f449915
PP
160 /*
161 * load immediate star globbing pattern (literal string)
162 * from immediate
163 */
164 FILTER_OP_LOAD_STAR_GLOB_STRING = 76,
165
166 /* globbing pattern binary operator: apply to */
167 FILTER_OP_EQ_STAR_GLOB_STRING = 77,
168 FILTER_OP_NE_STAR_GLOB_STRING = 78,
169
bff988fa
MD
170 /*
171 * Instructions for recursive traversal through composed types.
172 */
173 FILTER_OP_GET_CONTEXT_ROOT = 79,
174 FILTER_OP_GET_APP_CONTEXT_ROOT = 80,
175 FILTER_OP_GET_PAYLOAD_ROOT = 81,
176
177 FILTER_OP_GET_SYMBOL = 82,
178 FILTER_OP_GET_SYMBOL_FIELD = 83,
179 FILTER_OP_GET_INDEX_U16 = 84,
180 FILTER_OP_GET_INDEX_U64 = 85,
181
182 FILTER_OP_LOAD_FIELD = 86,
183 FILTER_OP_LOAD_FIELD_S8 = 87,
184 FILTER_OP_LOAD_FIELD_S16 = 88,
185 FILTER_OP_LOAD_FIELD_S32 = 89,
186 FILTER_OP_LOAD_FIELD_S64 = 90,
187 FILTER_OP_LOAD_FIELD_U8 = 91,
188 FILTER_OP_LOAD_FIELD_U16 = 92,
189 FILTER_OP_LOAD_FIELD_U32 = 93,
190 FILTER_OP_LOAD_FIELD_U64 = 94,
191 FILTER_OP_LOAD_FIELD_STRING = 95,
192 FILTER_OP_LOAD_FIELD_SEQUENCE = 96,
193 FILTER_OP_LOAD_FIELD_DOUBLE = 97,
661dfdd1 194
116d3c01
MD
195 FILTER_OP_UNARY_BIT_NOT = 98,
196
ba8f6b16
MD
197 FILTER_OP_RETURN_S64 = 99,
198
953192ba
MD
199 NR_FILTER_OPS,
200};
201
202typedef uint8_t filter_opcode_t;
203
204struct load_op {
205 filter_opcode_t op;
953192ba
MD
206 char data[0];
207 /* data to load. Size known by enum filter_opcode and null-term char. */
6f30f9b8 208} LTTNG_PACKED;
953192ba
MD
209
210struct binary_op {
211 filter_opcode_t op;
6f30f9b8 212} LTTNG_PACKED;
953192ba
MD
213
214struct unary_op {
215 filter_opcode_t op;
6f30f9b8 216} LTTNG_PACKED;
953192ba
MD
217
218/* skip_offset is absolute from start of bytecode */
219struct logical_op {
220 filter_opcode_t op;
221 uint16_t skip_offset; /* bytecode insn, if skip second test */
6f30f9b8 222} LTTNG_PACKED;
953192ba 223
8cf9540a
MD
224struct cast_op {
225 filter_opcode_t op;
6f30f9b8 226} LTTNG_PACKED;
8cf9540a 227
953192ba
MD
228struct return_op {
229 filter_opcode_t op;
6f30f9b8 230} LTTNG_PACKED;
953192ba 231
53a80697 232struct lttng_filter_bytecode_alloc {
5ddb0a08 233 uint32_t alloc_len;
53a80697 234 struct lttng_filter_bytecode b;
953192ba
MD
235};
236
237static inline
53a80697 238unsigned int bytecode_get_len(struct lttng_filter_bytecode *bytecode)
953192ba
MD
239{
240 return bytecode->len;
241}
242
243#endif /* _FILTER_BYTECODE_H */
This page took 0.11368 seconds and 5 git commands to generate.