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. */
38 struct field_ref_index
{
39 /* Initially, symbol offset. After link, field offset. */
41 uint64_t index
; /* array index */
44 struct literal_numeric
{
48 struct literal_double
{
52 struct literal_string
{
57 FILTER_OP_UNKNOWN
= 0,
69 FILTER_OP_BIN_AND
= 9,
70 FILTER_OP_BIN_OR
= 10,
71 FILTER_OP_BIN_XOR
= 11,
73 /* binary comparators */
81 /* string binary comparator: apply to */
82 FILTER_OP_EQ_STRING
= 18,
83 FILTER_OP_NE_STRING
= 19,
84 FILTER_OP_GT_STRING
= 20,
85 FILTER_OP_LT_STRING
= 21,
86 FILTER_OP_GE_STRING
= 22,
87 FILTER_OP_LE_STRING
= 23,
89 /* s64 binary comparator */
90 FILTER_OP_EQ_S64
= 24,
91 FILTER_OP_NE_S64
= 25,
92 FILTER_OP_GT_S64
= 26,
93 FILTER_OP_LT_S64
= 27,
94 FILTER_OP_GE_S64
= 28,
95 FILTER_OP_LE_S64
= 29,
97 /* double binary comparator */
98 FILTER_OP_EQ_DOUBLE
= 30,
99 FILTER_OP_NE_DOUBLE
= 31,
100 FILTER_OP_GT_DOUBLE
= 32,
101 FILTER_OP_LT_DOUBLE
= 33,
102 FILTER_OP_GE_DOUBLE
= 34,
103 FILTER_OP_LE_DOUBLE
= 35,
105 /* Mixed S64-double binary comparators */
106 FILTER_OP_EQ_DOUBLE_S64
= 36,
107 FILTER_OP_NE_DOUBLE_S64
= 37,
108 FILTER_OP_GT_DOUBLE_S64
= 38,
109 FILTER_OP_LT_DOUBLE_S64
= 39,
110 FILTER_OP_GE_DOUBLE_S64
= 40,
111 FILTER_OP_LE_DOUBLE_S64
= 41,
113 FILTER_OP_EQ_S64_DOUBLE
= 42,
114 FILTER_OP_NE_S64_DOUBLE
= 43,
115 FILTER_OP_GT_S64_DOUBLE
= 44,
116 FILTER_OP_LT_S64_DOUBLE
= 45,
117 FILTER_OP_GE_S64_DOUBLE
= 46,
118 FILTER_OP_LE_S64_DOUBLE
= 47,
121 FILTER_OP_UNARY_PLUS
= 48,
122 FILTER_OP_UNARY_MINUS
= 49,
123 FILTER_OP_UNARY_NOT
= 50,
124 FILTER_OP_UNARY_PLUS_S64
= 51,
125 FILTER_OP_UNARY_MINUS_S64
= 52,
126 FILTER_OP_UNARY_NOT_S64
= 53,
127 FILTER_OP_UNARY_PLUS_DOUBLE
= 54,
128 FILTER_OP_UNARY_MINUS_DOUBLE
= 55,
129 FILTER_OP_UNARY_NOT_DOUBLE
= 56,
136 FILTER_OP_LOAD_FIELD_REF
= 59,
137 FILTER_OP_LOAD_FIELD_REF_STRING
= 60,
138 FILTER_OP_LOAD_FIELD_REF_SEQUENCE
= 61,
139 FILTER_OP_LOAD_FIELD_REF_S64
= 62,
140 FILTER_OP_LOAD_FIELD_REF_DOUBLE
= 63,
142 /* load immediate from operand */
143 FILTER_OP_LOAD_STRING
= 64,
144 FILTER_OP_LOAD_S64
= 65,
145 FILTER_OP_LOAD_DOUBLE
= 66,
148 FILTER_OP_CAST_TO_S64
= 67,
149 FILTER_OP_CAST_DOUBLE_TO_S64
= 68,
150 FILTER_OP_CAST_NOP
= 69,
152 /* get context ref */
153 FILTER_OP_GET_CONTEXT_REF
= 70,
154 FILTER_OP_GET_CONTEXT_REF_STRING
= 71,
155 FILTER_OP_GET_CONTEXT_REF_S64
= 72,
156 FILTER_OP_GET_CONTEXT_REF_DOUBLE
= 73,
158 /* load userspace field ref */
159 FILTER_OP_LOAD_FIELD_REF_USER_STRING
= 74,
160 FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE
= 75,
163 * load immediate star globbing pattern (literal string)
166 FILTER_OP_LOAD_STAR_GLOB_STRING
= 76,
168 /* globbing pattern binary operator: apply to */
169 FILTER_OP_EQ_STAR_GLOB_STRING
= 77,
170 FILTER_OP_NE_STAR_GLOB_STRING
= 78,
172 /* load field ref with index */
173 FILTER_OP_LOAD_FIELD_REF_INDEX
= 79,
174 FILTER_OP_LOAD_FIELD_REF_INDEX_S64
= 80,
176 /* get context ref with index */
177 FILTER_OP_GET_CONTEXT_REF_INDEX
= 81,
178 FILTER_OP_GET_CONTEXT_REF_INDEX_S64
= 82,
183 typedef uint8_t filter_opcode_t
;
188 /* data to load. Size known by enum filter_opcode and null-term char. */
199 /* skip_offset is absolute from start of bytecode */
202 uint16_t skip_offset
; /* bytecode insn, if skip second test */
213 struct lttng_filter_bytecode_alloc
{
215 struct lttng_filter_bytecode b
;
219 unsigned int bytecode_get_len(struct lttng_filter_bytecode
*bytecode
)
221 return bytecode
->len
;
224 #endif /* _FILTER_BYTECODE_H */