1 #ifndef _FILTER_BYTECODE_H
2 #define _FILTER_BYTECODE_H
7 * LTTng filter bytecode
9 * Copyright 2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 * This library is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License, version 2.1 only,
13 * as published by the Free Software Foundation.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this library; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 #include <common/sessiond-comm/sessiond-comm.h>
27 #include "filter-ast.h"
30 * offsets are absolute from start of bytecode.
34 /* Initially, symbol offset. After link, field offset. */
43 struct get_index_u16
{
47 struct get_index_u64
{
51 struct literal_numeric
{
55 struct literal_double
{
59 struct literal_string
{
64 FILTER_OP_UNKNOWN
= 0,
74 FILTER_OP_BIT_RSHIFT
= 7,
75 FILTER_OP_BIT_LSHIFT
= 8,
76 FILTER_OP_BIT_AND
= 9,
77 FILTER_OP_BIT_OR
= 10,
78 FILTER_OP_BIT_XOR
= 11,
80 /* binary comparators */
88 /* string binary comparator: apply to */
89 FILTER_OP_EQ_STRING
= 18,
90 FILTER_OP_NE_STRING
= 19,
91 FILTER_OP_GT_STRING
= 20,
92 FILTER_OP_LT_STRING
= 21,
93 FILTER_OP_GE_STRING
= 22,
94 FILTER_OP_LE_STRING
= 23,
96 /* s64 binary comparator */
97 FILTER_OP_EQ_S64
= 24,
98 FILTER_OP_NE_S64
= 25,
99 FILTER_OP_GT_S64
= 26,
100 FILTER_OP_LT_S64
= 27,
101 FILTER_OP_GE_S64
= 28,
102 FILTER_OP_LE_S64
= 29,
104 /* double binary comparator */
105 FILTER_OP_EQ_DOUBLE
= 30,
106 FILTER_OP_NE_DOUBLE
= 31,
107 FILTER_OP_GT_DOUBLE
= 32,
108 FILTER_OP_LT_DOUBLE
= 33,
109 FILTER_OP_GE_DOUBLE
= 34,
110 FILTER_OP_LE_DOUBLE
= 35,
112 /* Mixed S64-double binary comparators */
113 FILTER_OP_EQ_DOUBLE_S64
= 36,
114 FILTER_OP_NE_DOUBLE_S64
= 37,
115 FILTER_OP_GT_DOUBLE_S64
= 38,
116 FILTER_OP_LT_DOUBLE_S64
= 39,
117 FILTER_OP_GE_DOUBLE_S64
= 40,
118 FILTER_OP_LE_DOUBLE_S64
= 41,
120 FILTER_OP_EQ_S64_DOUBLE
= 42,
121 FILTER_OP_NE_S64_DOUBLE
= 43,
122 FILTER_OP_GT_S64_DOUBLE
= 44,
123 FILTER_OP_LT_S64_DOUBLE
= 45,
124 FILTER_OP_GE_S64_DOUBLE
= 46,
125 FILTER_OP_LE_S64_DOUBLE
= 47,
128 FILTER_OP_UNARY_PLUS
= 48,
129 FILTER_OP_UNARY_MINUS
= 49,
130 FILTER_OP_UNARY_NOT
= 50,
131 FILTER_OP_UNARY_PLUS_S64
= 51,
132 FILTER_OP_UNARY_MINUS_S64
= 52,
133 FILTER_OP_UNARY_NOT_S64
= 53,
134 FILTER_OP_UNARY_PLUS_DOUBLE
= 54,
135 FILTER_OP_UNARY_MINUS_DOUBLE
= 55,
136 FILTER_OP_UNARY_NOT_DOUBLE
= 56,
143 FILTER_OP_LOAD_FIELD_REF
= 59,
144 FILTER_OP_LOAD_FIELD_REF_STRING
= 60,
145 FILTER_OP_LOAD_FIELD_REF_SEQUENCE
= 61,
146 FILTER_OP_LOAD_FIELD_REF_S64
= 62,
147 FILTER_OP_LOAD_FIELD_REF_DOUBLE
= 63,
149 /* load immediate from operand */
150 FILTER_OP_LOAD_STRING
= 64,
151 FILTER_OP_LOAD_S64
= 65,
152 FILTER_OP_LOAD_DOUBLE
= 66,
155 FILTER_OP_CAST_TO_S64
= 67,
156 FILTER_OP_CAST_DOUBLE_TO_S64
= 68,
157 FILTER_OP_CAST_NOP
= 69,
159 /* get context ref */
160 FILTER_OP_GET_CONTEXT_REF
= 70,
161 FILTER_OP_GET_CONTEXT_REF_STRING
= 71,
162 FILTER_OP_GET_CONTEXT_REF_S64
= 72,
163 FILTER_OP_GET_CONTEXT_REF_DOUBLE
= 73,
165 /* load userspace field ref */
166 FILTER_OP_LOAD_FIELD_REF_USER_STRING
= 74,
167 FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE
= 75,
170 * load immediate star globbing pattern (literal string)
173 FILTER_OP_LOAD_STAR_GLOB_STRING
= 76,
175 /* globbing pattern binary operator: apply to */
176 FILTER_OP_EQ_STAR_GLOB_STRING
= 77,
177 FILTER_OP_NE_STAR_GLOB_STRING
= 78,
180 * Instructions for recursive traversal through composed types.
182 FILTER_OP_GET_CONTEXT_ROOT
= 79,
183 FILTER_OP_GET_APP_CONTEXT_ROOT
= 80,
184 FILTER_OP_GET_PAYLOAD_ROOT
= 81,
186 FILTER_OP_GET_SYMBOL
= 82,
187 FILTER_OP_GET_SYMBOL_FIELD
= 83,
188 FILTER_OP_GET_INDEX_U16
= 84,
189 FILTER_OP_GET_INDEX_U64
= 85,
191 FILTER_OP_LOAD_FIELD
= 86,
192 FILTER_OP_LOAD_FIELD_S8
= 87,
193 FILTER_OP_LOAD_FIELD_S16
= 88,
194 FILTER_OP_LOAD_FIELD_S32
= 89,
195 FILTER_OP_LOAD_FIELD_S64
= 90,
196 FILTER_OP_LOAD_FIELD_U8
= 91,
197 FILTER_OP_LOAD_FIELD_U16
= 92,
198 FILTER_OP_LOAD_FIELD_U32
= 93,
199 FILTER_OP_LOAD_FIELD_U64
= 94,
200 FILTER_OP_LOAD_FIELD_STRING
= 95,
201 FILTER_OP_LOAD_FIELD_SEQUENCE
= 96,
202 FILTER_OP_LOAD_FIELD_DOUBLE
= 97,
204 FILTER_OP_UNARY_BIT_NOT
= 98,
209 typedef uint8_t filter_opcode_t
;
214 /* data to load. Size known by enum filter_opcode and null-term char. */
225 /* skip_offset is absolute from start of bytecode */
228 uint16_t skip_offset
; /* bytecode insn, if skip second test */
239 struct lttng_filter_bytecode_alloc
{
241 struct lttng_filter_bytecode b
;
245 unsigned int bytecode_get_len(struct lttng_filter_bytecode
*bytecode
)
247 return bytecode
->len
;
250 #endif /* _FILTER_BYTECODE_H */