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