Commit | Line | Data |
---|---|---|
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 | ||
30 | #include <lttng/ust-abi.h> | |
31 | ||
32 | /* | |
33 | * offsets are absolute from start of bytecode. | |
34 | */ | |
35 | ||
cd54f6d9 MD |
36 | struct field_ref { |
37 | /* Initially, symbol offset. After link, field offset. */ | |
38 | uint16_t offset; | |
cd54f6d9 MD |
39 | } __attribute__((packed)); |
40 | ||
41 | struct literal_numeric { | |
42 | int64_t v; | |
43 | } __attribute__((packed)); | |
44 | ||
da6eed25 MD |
45 | struct literal_double { |
46 | double v; | |
47 | } __attribute__((packed)); | |
48 | ||
cd54f6d9 MD |
49 | struct literal_string { |
50 | char string[0]; | |
51 | } __attribute__((packed)); | |
52 | ||
53 | enum filter_op { | |
3151a51d | 54 | FILTER_OP_UNKNOWN = 0, |
cd54f6d9 | 55 | |
3151a51d | 56 | FILTER_OP_RETURN = 1, |
cd54f6d9 MD |
57 | |
58 | /* binary */ | |
3151a51d PP |
59 | FILTER_OP_MUL = 2, |
60 | FILTER_OP_DIV = 3, | |
61 | FILTER_OP_MOD = 4, | |
62 | FILTER_OP_PLUS = 5, | |
63 | FILTER_OP_MINUS = 6, | |
64 | FILTER_OP_RSHIFT = 7, | |
65 | FILTER_OP_LSHIFT = 8, | |
66 | FILTER_OP_BIN_AND = 9, | |
67 | FILTER_OP_BIN_OR = 10, | |
68 | FILTER_OP_BIN_XOR = 11, | |
226106c0 MD |
69 | |
70 | /* binary comparators */ | |
3151a51d PP |
71 | FILTER_OP_EQ = 12, |
72 | FILTER_OP_NE = 13, | |
73 | FILTER_OP_GT = 14, | |
74 | FILTER_OP_LT = 15, | |
75 | FILTER_OP_GE = 16, | |
76 | FILTER_OP_LE = 17, | |
77 | ||
78 | /* string binary comparator: apply to */ | |
79 | FILTER_OP_EQ_STRING = 18, | |
80 | FILTER_OP_NE_STRING = 19, | |
81 | FILTER_OP_GT_STRING = 20, | |
82 | FILTER_OP_LT_STRING = 21, | |
83 | FILTER_OP_GE_STRING = 22, | |
84 | FILTER_OP_LE_STRING = 23, | |
226106c0 MD |
85 | |
86 | /* s64 binary comparator */ | |
3151a51d PP |
87 | FILTER_OP_EQ_S64 = 24, |
88 | FILTER_OP_NE_S64 = 25, | |
89 | FILTER_OP_GT_S64 = 26, | |
90 | FILTER_OP_LT_S64 = 27, | |
91 | FILTER_OP_GE_S64 = 28, | |
92 | FILTER_OP_LE_S64 = 29, | |
226106c0 MD |
93 | |
94 | /* double binary comparator */ | |
3151a51d PP |
95 | FILTER_OP_EQ_DOUBLE = 30, |
96 | FILTER_OP_NE_DOUBLE = 31, | |
97 | FILTER_OP_GT_DOUBLE = 32, | |
98 | FILTER_OP_LT_DOUBLE = 33, | |
99 | FILTER_OP_GE_DOUBLE = 34, | |
100 | FILTER_OP_LE_DOUBLE = 35, | |
226106c0 | 101 | |
dbea82ec | 102 | /* Mixed S64-double binary comparators */ |
3151a51d PP |
103 | FILTER_OP_EQ_DOUBLE_S64 = 36, |
104 | FILTER_OP_NE_DOUBLE_S64 = 37, | |
105 | FILTER_OP_GT_DOUBLE_S64 = 38, | |
106 | FILTER_OP_LT_DOUBLE_S64 = 39, | |
107 | FILTER_OP_GE_DOUBLE_S64 = 40, | |
108 | FILTER_OP_LE_DOUBLE_S64 = 41, | |
109 | ||
110 | FILTER_OP_EQ_S64_DOUBLE = 42, | |
111 | FILTER_OP_NE_S64_DOUBLE = 43, | |
112 | FILTER_OP_GT_S64_DOUBLE = 44, | |
113 | FILTER_OP_LT_S64_DOUBLE = 45, | |
114 | FILTER_OP_GE_S64_DOUBLE = 46, | |
115 | FILTER_OP_LE_S64_DOUBLE = 47, | |
dbea82ec | 116 | |
cd54f6d9 | 117 | /* unary */ |
3151a51d PP |
118 | FILTER_OP_UNARY_PLUS = 48, |
119 | FILTER_OP_UNARY_MINUS = 49, | |
120 | FILTER_OP_UNARY_NOT = 50, | |
121 | FILTER_OP_UNARY_PLUS_S64 = 51, | |
122 | FILTER_OP_UNARY_MINUS_S64 = 52, | |
123 | FILTER_OP_UNARY_NOT_S64 = 53, | |
124 | FILTER_OP_UNARY_PLUS_DOUBLE = 54, | |
125 | FILTER_OP_UNARY_MINUS_DOUBLE = 55, | |
126 | FILTER_OP_UNARY_NOT_DOUBLE = 56, | |
cd54f6d9 MD |
127 | |
128 | /* logical */ | |
3151a51d PP |
129 | FILTER_OP_AND = 57, |
130 | FILTER_OP_OR = 58, | |
cd54f6d9 | 131 | |
77aa5901 | 132 | /* load field ref */ |
3151a51d PP |
133 | FILTER_OP_LOAD_FIELD_REF = 59, |
134 | FILTER_OP_LOAD_FIELD_REF_STRING = 60, | |
135 | FILTER_OP_LOAD_FIELD_REF_SEQUENCE = 61, | |
136 | FILTER_OP_LOAD_FIELD_REF_S64 = 62, | |
137 | FILTER_OP_LOAD_FIELD_REF_DOUBLE = 63, | |
2f0145d1 | 138 | |
77aa5901 | 139 | /* load immediate from operand */ |
3151a51d PP |
140 | FILTER_OP_LOAD_STRING = 64, |
141 | FILTER_OP_LOAD_S64 = 65, | |
142 | FILTER_OP_LOAD_DOUBLE = 66, | |
cd54f6d9 | 143 | |
49905038 | 144 | /* cast */ |
3151a51d PP |
145 | FILTER_OP_CAST_TO_S64 = 67, |
146 | FILTER_OP_CAST_DOUBLE_TO_S64 = 68, | |
147 | FILTER_OP_CAST_NOP = 69, | |
49905038 | 148 | |
77aa5901 | 149 | /* get context ref */ |
3151a51d PP |
150 | FILTER_OP_GET_CONTEXT_REF = 70, |
151 | FILTER_OP_GET_CONTEXT_REF_STRING = 71, | |
152 | FILTER_OP_GET_CONTEXT_REF_S64 = 72, | |
153 | FILTER_OP_GET_CONTEXT_REF_DOUBLE = 73, | |
154 | ||
155 | /* load userspace field ref */ | |
156 | FILTER_OP_LOAD_FIELD_REF_USER_STRING = 74, | |
157 | FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE = 75, | |
158 | ||
159 | /* | |
160 | * load immediate star globbing pattern (literal string) | |
161 | * from immediate | |
162 | */ | |
163 | FILTER_OP_LOAD_STAR_GLOB_STRING = 76, | |
164 | ||
165 | /* globbing pattern binary operator: apply to */ | |
166 | FILTER_OP_EQ_STAR_GLOB_STRING = 77, | |
167 | FILTER_OP_NE_STAR_GLOB_STRING = 78, | |
77aa5901 | 168 | |
cd54f6d9 MD |
169 | NR_FILTER_OPS, |
170 | }; | |
171 | ||
172 | typedef uint8_t filter_opcode_t; | |
173 | ||
174 | struct load_op { | |
175 | filter_opcode_t op; | |
cd54f6d9 MD |
176 | char data[0]; |
177 | /* data to load. Size known by enum filter_opcode and null-term char. */ | |
178 | } __attribute__((packed)); | |
179 | ||
180 | struct binary_op { | |
181 | filter_opcode_t op; | |
182 | } __attribute__((packed)); | |
183 | ||
184 | struct unary_op { | |
185 | filter_opcode_t op; | |
cd54f6d9 MD |
186 | } __attribute__((packed)); |
187 | ||
188 | /* skip_offset is absolute from start of bytecode */ | |
189 | struct logical_op { | |
190 | filter_opcode_t op; | |
191 | uint16_t skip_offset; /* bytecode insn, if skip second test */ | |
192 | } __attribute__((packed)); | |
193 | ||
49905038 MD |
194 | struct cast_op { |
195 | filter_opcode_t op; | |
49905038 MD |
196 | } __attribute__((packed)); |
197 | ||
cd54f6d9 MD |
198 | struct return_op { |
199 | filter_opcode_t op; | |
200 | } __attribute__((packed)); | |
201 | ||
202 | #endif /* _FILTER_BYTECODE_H */ |