2 * lttng-filter-interpreter.c
4 * LTTng UST filter interpreter.
6 * Copyright (C) 2010-2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 #include <urcu-pointer.h>
31 #include "lttng-filter.h"
32 #include "string-utils.h"
36 * -2: unknown escape char.
41 int parse_char(const char **p
)
61 * Returns SIZE_MAX if the string is null-terminated, or the number of
65 size_t get_str_or_seq_len(const struct estack_entry
*entry
)
67 return entry
->u
.s
.seq_len
;
71 int stack_star_glob_match(struct estack
*stack
, int top
, const char *cmp_type
)
74 const char *candidate
;
78 /* Find out which side is the pattern vs. the candidate. */
79 if (estack_ax(stack
, top
)->u
.s
.literal_type
== ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
) {
80 pattern
= estack_ax(stack
, top
)->u
.s
.str
;
81 pattern_len
= get_str_or_seq_len(estack_ax(stack
, top
));
82 candidate
= estack_bx(stack
, top
)->u
.s
.str
;
83 candidate_len
= get_str_or_seq_len(estack_bx(stack
, top
));
85 pattern
= estack_bx(stack
, top
)->u
.s
.str
;
86 pattern_len
= get_str_or_seq_len(estack_bx(stack
, top
));
87 candidate
= estack_ax(stack
, top
)->u
.s
.str
;
88 candidate_len
= get_str_or_seq_len(estack_ax(stack
, top
));
91 /* Perform the match. Returns 0 when the result is true. */
92 return !strutils_star_glob_match(pattern
, pattern_len
, candidate
,
97 int stack_strcmp(struct estack
*stack
, int top
, const char *cmp_type
)
99 const char *p
= estack_bx(stack
, top
)->u
.s
.str
, *q
= estack_ax(stack
, top
)->u
.s
.str
;
106 if (unlikely(p
- estack_bx(stack
, top
)->u
.s
.str
>= estack_bx(stack
, top
)->u
.s
.seq_len
|| *p
== '\0')) {
107 if (q
- estack_ax(stack
, top
)->u
.s
.str
>= estack_ax(stack
, top
)->u
.s
.seq_len
|| *q
== '\0') {
110 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
111 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
112 ret
= parse_char(&q
);
119 if (unlikely(q
- estack_ax(stack
, top
)->u
.s
.str
>= estack_ax(stack
, top
)->u
.s
.seq_len
|| *q
== '\0')) {
120 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
121 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
122 ret
= parse_char(&p
);
128 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
129 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
130 ret
= parse_char(&p
);
133 } else if (ret
== -2) {
136 /* else compare both char */
138 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
139 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
140 ret
= parse_char(&q
);
143 } else if (ret
== -2) {
163 uint64_t lttng_filter_false(void *filter_data
,
164 const char *filter_stack_data
)
169 #ifdef INTERPRETER_USE_SWITCH
172 * Fallback for compilers that do not support taking address of labels.
176 start_pc = &bytecode->code[0]; \
177 for (pc = next_pc = start_pc; pc - start_pc < bytecode->len; \
179 dbg_printf("Executing op %s (%u)\n", \
180 print_op((unsigned int) *(filter_opcode_t *) pc), \
181 (unsigned int) *(filter_opcode_t *) pc); \
182 switch (*(filter_opcode_t *) pc) {
184 #define OP(name) jump_target_##name: __attribute__((unused)); \
192 #define JUMP_TO(name) \
193 goto jump_target_##name
198 * Dispatch-table based interpreter.
202 start_pc = &bytecode->code[0]; \
203 pc = next_pc = start_pc; \
204 if (unlikely(pc - start_pc >= bytecode->len)) \
206 goto *dispatch[*(filter_opcode_t *) pc];
213 goto *dispatch[*(filter_opcode_t *) pc];
217 #define JUMP_TO(name) \
222 static int context_get_index(struct lttng_ctx
*ctx
,
223 struct load_ptr
*ptr
,
227 struct lttng_ctx_field
*ctx_field
;
228 struct lttng_event_field
*field
;
229 struct lttng_ctx_value v
;
231 ctx_field
= &ctx
->fields
[idx
];
232 field
= &ctx_field
->event_field
;
233 ptr
->type
= LOAD_OBJECT
;
234 /* field is only used for types nested within variants. */
237 switch (field
->type
.atype
) {
239 ctx_field
->get_value(ctx_field
, &v
);
240 if (field
->type
.u
.basic
.integer
.signedness
) {
241 ptr
->object_type
= OBJECT_TYPE_S64
;
242 ptr
->u
.s64
= v
.u
.s64
;
243 ptr
->ptr
= &ptr
->u
.s64
;
245 ptr
->object_type
= OBJECT_TYPE_U64
;
246 ptr
->u
.u64
= v
.u
.s64
; /* Cast. */
247 ptr
->ptr
= &ptr
->u
.u64
;
249 ptr
->rev_bo
= field
->type
.u
.basic
.integer
.reverse_byte_order
;
253 const struct lttng_integer_type
*itype
=
254 &field
->type
.u
.basic
.enumeration
.container_type
;
256 ctx_field
->get_value(ctx_field
, &v
);
257 if (itype
->signedness
) {
258 ptr
->object_type
= OBJECT_TYPE_S64
;
259 ptr
->u
.s64
= v
.u
.s64
;
260 ptr
->ptr
= &ptr
->u
.s64
;
262 ptr
->object_type
= OBJECT_TYPE_U64
;
263 ptr
->u
.u64
= v
.u
.s64
; /* Cast. */
264 ptr
->ptr
= &ptr
->u
.u64
;
266 ptr
->rev_bo
= itype
->reverse_byte_order
;
270 if (field
->type
.u
.array
.elem_type
.atype
!= atype_integer
) {
271 ERR("Array nesting only supports integer types.");
274 if (field
->type
.u
.array
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
275 ERR("Only string arrays are supported for contexts.");
278 ptr
->object_type
= OBJECT_TYPE_STRING
;
279 ctx_field
->get_value(ctx_field
, &v
);
283 if (field
->type
.u
.sequence
.elem_type
.atype
!= atype_integer
) {
284 ERR("Sequence nesting only supports integer types.");
287 if (field
->type
.u
.sequence
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
288 ERR("Only string sequences are supported for contexts.");
291 ptr
->object_type
= OBJECT_TYPE_STRING
;
292 ctx_field
->get_value(ctx_field
, &v
);
296 ptr
->object_type
= OBJECT_TYPE_STRING
;
297 ctx_field
->get_value(ctx_field
, &v
);
301 ptr
->object_type
= OBJECT_TYPE_DOUBLE
;
302 ctx_field
->get_value(ctx_field
, &v
);
304 ptr
->ptr
= &ptr
->u
.d
;
305 ptr
->rev_bo
= field
->type
.u
.basic
._float
.reverse_byte_order
;
308 ctx_field
->get_value(ctx_field
, &v
);
310 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
312 case LTTNG_UST_DYNAMIC_TYPE_S64
:
313 ptr
->object_type
= OBJECT_TYPE_S64
;
314 ptr
->u
.s64
= v
.u
.s64
;
315 ptr
->ptr
= &ptr
->u
.s64
;
317 * struct lttng_ctx_value does not currently
318 * feature a byte order field.
321 dbg_printf("context get index dynamic s64 %" PRIi64
"\n", ptr
->u
.s64
);
323 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
324 ptr
->object_type
= OBJECT_TYPE_DOUBLE
;
326 ptr
->ptr
= &ptr
->u
.d
;
328 * struct lttng_ctx_value does not currently
329 * feature a byte order field.
332 dbg_printf("context get index dynamic double %g\n", ptr
->u
.d
);
334 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
335 ptr
->object_type
= OBJECT_TYPE_STRING
;
337 dbg_printf("context get index dynamic string %s\n", (const char *) ptr
->ptr
);
340 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
345 ERR("Structure type cannot be loaded.");
348 ERR("Unknown type: %d", (int) field
->type
.atype
);
354 static int dynamic_get_index(struct lttng_session
*session
,
355 struct bytecode_runtime
*runtime
,
356 uint64_t index
, struct estack_entry
*stack_top
)
359 const struct filter_get_index_data
*gid
;
362 * Types nested within variants need to perform dynamic lookup
363 * based on the field descriptions. LTTng-UST does not implement
366 if (stack_top
->u
.ptr
.field
)
368 gid
= (const struct filter_get_index_data
*) &runtime
->data
[index
];
369 switch (stack_top
->u
.ptr
.type
) {
371 switch (stack_top
->u
.ptr
.object_type
) {
372 case OBJECT_TYPE_ARRAY
:
376 assert(gid
->offset
< gid
->array_len
);
377 /* Skip count (unsigned long) */
378 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
379 ptr
= ptr
+ gid
->offset
;
380 stack_top
->u
.ptr
.ptr
= ptr
;
381 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
382 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
383 /* field is only used for types nested within variants. */
384 stack_top
->u
.ptr
.field
= NULL
;
387 case OBJECT_TYPE_SEQUENCE
:
392 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
393 ptr_seq_len
= *(unsigned long *) stack_top
->u
.ptr
.ptr
;
394 if (gid
->offset
>= gid
->elem
.len
* ptr_seq_len
) {
398 ptr
= ptr
+ gid
->offset
;
399 stack_top
->u
.ptr
.ptr
= ptr
;
400 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
401 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
402 /* field is only used for types nested within variants. */
403 stack_top
->u
.ptr
.field
= NULL
;
406 case OBJECT_TYPE_STRUCT
:
407 ERR("Nested structures are not supported yet.");
410 case OBJECT_TYPE_VARIANT
:
412 ERR("Unexpected get index type %d",
413 (int) stack_top
->u
.ptr
.object_type
);
418 case LOAD_ROOT_CONTEXT
:
419 case LOAD_ROOT_APP_CONTEXT
: /* Fall-through */
421 struct lttng_ctx
*ctx
;
423 ctx
= rcu_dereference(session
->ctx
);
424 ret
= context_get_index(ctx
,
432 case LOAD_ROOT_PAYLOAD
:
433 stack_top
->u
.ptr
.ptr
+= gid
->offset
;
434 if (gid
->elem
.type
== OBJECT_TYPE_STRING
)
435 stack_top
->u
.ptr
.ptr
= *(const char * const *) stack_top
->u
.ptr
.ptr
;
436 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
437 stack_top
->u
.ptr
.type
= LOAD_OBJECT
;
438 /* field is only used for types nested within variants. */
439 stack_top
->u
.ptr
.field
= NULL
;
448 static int dynamic_load_field(struct estack_entry
*stack_top
)
452 switch (stack_top
->u
.ptr
.type
) {
455 case LOAD_ROOT_CONTEXT
:
456 case LOAD_ROOT_APP_CONTEXT
:
457 case LOAD_ROOT_PAYLOAD
:
459 dbg_printf("Filter warning: cannot load root, missing field name.\n");
463 switch (stack_top
->u
.ptr
.object_type
) {
465 dbg_printf("op load field s8\n");
466 stack_top
->u
.v
= *(int8_t *) stack_top
->u
.ptr
.ptr
;
467 stack_top
->type
= REG_S64
;
469 case OBJECT_TYPE_S16
:
473 dbg_printf("op load field s16\n");
474 tmp
= *(int16_t *) stack_top
->u
.ptr
.ptr
;
475 if (stack_top
->u
.ptr
.rev_bo
)
477 stack_top
->u
.v
= tmp
;
478 stack_top
->type
= REG_S64
;
481 case OBJECT_TYPE_S32
:
485 dbg_printf("op load field s32\n");
486 tmp
= *(int32_t *) stack_top
->u
.ptr
.ptr
;
487 if (stack_top
->u
.ptr
.rev_bo
)
489 stack_top
->u
.v
= tmp
;
490 stack_top
->type
= REG_S64
;
493 case OBJECT_TYPE_S64
:
497 dbg_printf("op load field s64\n");
498 tmp
= *(int64_t *) stack_top
->u
.ptr
.ptr
;
499 if (stack_top
->u
.ptr
.rev_bo
)
501 stack_top
->u
.v
= tmp
;
502 stack_top
->type
= REG_S64
;
506 dbg_printf("op load field u8\n");
507 stack_top
->u
.v
= *(uint8_t *) stack_top
->u
.ptr
.ptr
;
508 stack_top
->type
= REG_S64
;
510 case OBJECT_TYPE_U16
:
514 dbg_printf("op load field s16\n");
515 tmp
= *(uint16_t *) stack_top
->u
.ptr
.ptr
;
516 if (stack_top
->u
.ptr
.rev_bo
)
518 stack_top
->u
.v
= tmp
;
519 stack_top
->type
= REG_S64
;
522 case OBJECT_TYPE_U32
:
526 dbg_printf("op load field u32\n");
527 tmp
= *(uint32_t *) stack_top
->u
.ptr
.ptr
;
528 if (stack_top
->u
.ptr
.rev_bo
)
530 stack_top
->u
.v
= tmp
;
531 stack_top
->type
= REG_S64
;
534 case OBJECT_TYPE_U64
:
538 dbg_printf("op load field u64\n");
539 tmp
= *(uint64_t *) stack_top
->u
.ptr
.ptr
;
540 if (stack_top
->u
.ptr
.rev_bo
)
542 stack_top
->u
.v
= tmp
;
543 stack_top
->type
= REG_S64
;
546 case OBJECT_TYPE_DOUBLE
:
547 memcpy(&stack_top
->u
.d
,
548 stack_top
->u
.ptr
.ptr
,
549 sizeof(struct literal_double
));
550 stack_top
->type
= REG_DOUBLE
;
552 case OBJECT_TYPE_STRING
:
556 dbg_printf("op load field string\n");
557 str
= (const char *) stack_top
->u
.ptr
.ptr
;
558 stack_top
->u
.s
.str
= str
;
559 if (unlikely(!stack_top
->u
.s
.str
)) {
560 dbg_printf("Filter warning: loading a NULL string.\n");
564 stack_top
->u
.s
.seq_len
= SIZE_MAX
;
565 stack_top
->u
.s
.literal_type
=
566 ESTACK_STRING_LITERAL_TYPE_NONE
;
567 stack_top
->type
= REG_STRING
;
570 case OBJECT_TYPE_STRING_SEQUENCE
:
574 dbg_printf("op load field string sequence\n");
575 ptr
= stack_top
->u
.ptr
.ptr
;
576 stack_top
->u
.s
.seq_len
= *(unsigned long *) ptr
;
577 stack_top
->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
578 stack_top
->type
= REG_STRING
;
579 if (unlikely(!stack_top
->u
.s
.str
)) {
580 dbg_printf("Filter warning: loading a NULL sequence.\n");
584 stack_top
->u
.s
.literal_type
=
585 ESTACK_STRING_LITERAL_TYPE_NONE
;
588 case OBJECT_TYPE_DYNAMIC
:
590 * Dynamic types in context are looked up
591 * by context get index.
595 case OBJECT_TYPE_SEQUENCE
:
596 case OBJECT_TYPE_ARRAY
:
597 case OBJECT_TYPE_STRUCT
:
598 case OBJECT_TYPE_VARIANT
:
599 ERR("Sequences, arrays, struct and variant cannot be loaded (nested types).");
610 * Return 0 (discard), or raise the 0x1 flag (log event).
611 * Currently, other flags are kept for future extensions and have no
614 uint64_t lttng_filter_interpret_bytecode(void *filter_data
,
615 const char *filter_stack_data
)
617 struct bytecode_runtime
*bytecode
= filter_data
;
618 struct lttng_session
*session
= bytecode
->p
.session
;
619 void *pc
, *next_pc
, *start_pc
;
622 struct estack _stack
;
623 struct estack
*stack
= &_stack
;
624 register int64_t ax
= 0, bx
= 0;
625 register enum entry_type ax_t
= REG_UNKNOWN
, bx_t
= REG_UNKNOWN
;
626 register int top
= FILTER_STACK_EMPTY
;
627 #ifndef INTERPRETER_USE_SWITCH
628 static void *dispatch
[NR_FILTER_OPS
] = {
629 [ FILTER_OP_UNKNOWN
] = &&LABEL_FILTER_OP_UNKNOWN
,
631 [ FILTER_OP_RETURN
] = &&LABEL_FILTER_OP_RETURN
,
634 [ FILTER_OP_MUL
] = &&LABEL_FILTER_OP_MUL
,
635 [ FILTER_OP_DIV
] = &&LABEL_FILTER_OP_DIV
,
636 [ FILTER_OP_MOD
] = &&LABEL_FILTER_OP_MOD
,
637 [ FILTER_OP_PLUS
] = &&LABEL_FILTER_OP_PLUS
,
638 [ FILTER_OP_MINUS
] = &&LABEL_FILTER_OP_MINUS
,
639 [ FILTER_OP_BIT_RSHIFT
] = &&LABEL_FILTER_OP_BIT_RSHIFT
,
640 [ FILTER_OP_BIT_LSHIFT
] = &&LABEL_FILTER_OP_BIT_LSHIFT
,
641 [ FILTER_OP_BIT_AND
] = &&LABEL_FILTER_OP_BIT_AND
,
642 [ FILTER_OP_BIT_OR
] = &&LABEL_FILTER_OP_BIT_OR
,
643 [ FILTER_OP_BIT_XOR
] = &&LABEL_FILTER_OP_BIT_XOR
,
645 /* binary comparators */
646 [ FILTER_OP_EQ
] = &&LABEL_FILTER_OP_EQ
,
647 [ FILTER_OP_NE
] = &&LABEL_FILTER_OP_NE
,
648 [ FILTER_OP_GT
] = &&LABEL_FILTER_OP_GT
,
649 [ FILTER_OP_LT
] = &&LABEL_FILTER_OP_LT
,
650 [ FILTER_OP_GE
] = &&LABEL_FILTER_OP_GE
,
651 [ FILTER_OP_LE
] = &&LABEL_FILTER_OP_LE
,
653 /* string binary comparator */
654 [ FILTER_OP_EQ_STRING
] = &&LABEL_FILTER_OP_EQ_STRING
,
655 [ FILTER_OP_NE_STRING
] = &&LABEL_FILTER_OP_NE_STRING
,
656 [ FILTER_OP_GT_STRING
] = &&LABEL_FILTER_OP_GT_STRING
,
657 [ FILTER_OP_LT_STRING
] = &&LABEL_FILTER_OP_LT_STRING
,
658 [ FILTER_OP_GE_STRING
] = &&LABEL_FILTER_OP_GE_STRING
,
659 [ FILTER_OP_LE_STRING
] = &&LABEL_FILTER_OP_LE_STRING
,
661 /* globbing pattern binary comparator */
662 [ FILTER_OP_EQ_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_EQ_STAR_GLOB_STRING
,
663 [ FILTER_OP_NE_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_NE_STAR_GLOB_STRING
,
665 /* s64 binary comparator */
666 [ FILTER_OP_EQ_S64
] = &&LABEL_FILTER_OP_EQ_S64
,
667 [ FILTER_OP_NE_S64
] = &&LABEL_FILTER_OP_NE_S64
,
668 [ FILTER_OP_GT_S64
] = &&LABEL_FILTER_OP_GT_S64
,
669 [ FILTER_OP_LT_S64
] = &&LABEL_FILTER_OP_LT_S64
,
670 [ FILTER_OP_GE_S64
] = &&LABEL_FILTER_OP_GE_S64
,
671 [ FILTER_OP_LE_S64
] = &&LABEL_FILTER_OP_LE_S64
,
673 /* double binary comparator */
674 [ FILTER_OP_EQ_DOUBLE
] = &&LABEL_FILTER_OP_EQ_DOUBLE
,
675 [ FILTER_OP_NE_DOUBLE
] = &&LABEL_FILTER_OP_NE_DOUBLE
,
676 [ FILTER_OP_GT_DOUBLE
] = &&LABEL_FILTER_OP_GT_DOUBLE
,
677 [ FILTER_OP_LT_DOUBLE
] = &&LABEL_FILTER_OP_LT_DOUBLE
,
678 [ FILTER_OP_GE_DOUBLE
] = &&LABEL_FILTER_OP_GE_DOUBLE
,
679 [ FILTER_OP_LE_DOUBLE
] = &&LABEL_FILTER_OP_LE_DOUBLE
,
681 /* Mixed S64-double binary comparators */
682 [ FILTER_OP_EQ_DOUBLE_S64
] = &&LABEL_FILTER_OP_EQ_DOUBLE_S64
,
683 [ FILTER_OP_NE_DOUBLE_S64
] = &&LABEL_FILTER_OP_NE_DOUBLE_S64
,
684 [ FILTER_OP_GT_DOUBLE_S64
] = &&LABEL_FILTER_OP_GT_DOUBLE_S64
,
685 [ FILTER_OP_LT_DOUBLE_S64
] = &&LABEL_FILTER_OP_LT_DOUBLE_S64
,
686 [ FILTER_OP_GE_DOUBLE_S64
] = &&LABEL_FILTER_OP_GE_DOUBLE_S64
,
687 [ FILTER_OP_LE_DOUBLE_S64
] = &&LABEL_FILTER_OP_LE_DOUBLE_S64
,
689 [ FILTER_OP_EQ_S64_DOUBLE
] = &&LABEL_FILTER_OP_EQ_S64_DOUBLE
,
690 [ FILTER_OP_NE_S64_DOUBLE
] = &&LABEL_FILTER_OP_NE_S64_DOUBLE
,
691 [ FILTER_OP_GT_S64_DOUBLE
] = &&LABEL_FILTER_OP_GT_S64_DOUBLE
,
692 [ FILTER_OP_LT_S64_DOUBLE
] = &&LABEL_FILTER_OP_LT_S64_DOUBLE
,
693 [ FILTER_OP_GE_S64_DOUBLE
] = &&LABEL_FILTER_OP_GE_S64_DOUBLE
,
694 [ FILTER_OP_LE_S64_DOUBLE
] = &&LABEL_FILTER_OP_LE_S64_DOUBLE
,
697 [ FILTER_OP_UNARY_PLUS
] = &&LABEL_FILTER_OP_UNARY_PLUS
,
698 [ FILTER_OP_UNARY_MINUS
] = &&LABEL_FILTER_OP_UNARY_MINUS
,
699 [ FILTER_OP_UNARY_NOT
] = &&LABEL_FILTER_OP_UNARY_NOT
,
700 [ FILTER_OP_UNARY_PLUS_S64
] = &&LABEL_FILTER_OP_UNARY_PLUS_S64
,
701 [ FILTER_OP_UNARY_MINUS_S64
] = &&LABEL_FILTER_OP_UNARY_MINUS_S64
,
702 [ FILTER_OP_UNARY_NOT_S64
] = &&LABEL_FILTER_OP_UNARY_NOT_S64
,
703 [ FILTER_OP_UNARY_PLUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_PLUS_DOUBLE
,
704 [ FILTER_OP_UNARY_MINUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_MINUS_DOUBLE
,
705 [ FILTER_OP_UNARY_NOT_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_NOT_DOUBLE
,
708 [ FILTER_OP_AND
] = &&LABEL_FILTER_OP_AND
,
709 [ FILTER_OP_OR
] = &&LABEL_FILTER_OP_OR
,
712 [ FILTER_OP_LOAD_FIELD_REF
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF
,
713 [ FILTER_OP_LOAD_FIELD_REF_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_STRING
,
714 [ FILTER_OP_LOAD_FIELD_REF_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_SEQUENCE
,
715 [ FILTER_OP_LOAD_FIELD_REF_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_S64
,
716 [ FILTER_OP_LOAD_FIELD_REF_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_DOUBLE
,
718 /* load from immediate operand */
719 [ FILTER_OP_LOAD_STRING
] = &&LABEL_FILTER_OP_LOAD_STRING
,
720 [ FILTER_OP_LOAD_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_LOAD_STAR_GLOB_STRING
,
721 [ FILTER_OP_LOAD_S64
] = &&LABEL_FILTER_OP_LOAD_S64
,
722 [ FILTER_OP_LOAD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_DOUBLE
,
725 [ FILTER_OP_CAST_TO_S64
] = &&LABEL_FILTER_OP_CAST_TO_S64
,
726 [ FILTER_OP_CAST_DOUBLE_TO_S64
] = &&LABEL_FILTER_OP_CAST_DOUBLE_TO_S64
,
727 [ FILTER_OP_CAST_NOP
] = &&LABEL_FILTER_OP_CAST_NOP
,
729 /* get context ref */
730 [ FILTER_OP_GET_CONTEXT_REF
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF
,
731 [ FILTER_OP_GET_CONTEXT_REF_STRING
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_STRING
,
732 [ FILTER_OP_GET_CONTEXT_REF_S64
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_S64
,
733 [ FILTER_OP_GET_CONTEXT_REF_DOUBLE
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_DOUBLE
,
735 /* Instructions for recursive traversal through composed types. */
736 [ FILTER_OP_GET_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_CONTEXT_ROOT
,
737 [ FILTER_OP_GET_APP_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_APP_CONTEXT_ROOT
,
738 [ FILTER_OP_GET_PAYLOAD_ROOT
] = &&LABEL_FILTER_OP_GET_PAYLOAD_ROOT
,
740 [ FILTER_OP_GET_SYMBOL
] = &&LABEL_FILTER_OP_GET_SYMBOL
,
741 [ FILTER_OP_GET_SYMBOL_FIELD
] = &&LABEL_FILTER_OP_GET_SYMBOL_FIELD
,
742 [ FILTER_OP_GET_INDEX_U16
] = &&LABEL_FILTER_OP_GET_INDEX_U16
,
743 [ FILTER_OP_GET_INDEX_U64
] = &&LABEL_FILTER_OP_GET_INDEX_U64
,
745 [ FILTER_OP_LOAD_FIELD
] = &&LABEL_FILTER_OP_LOAD_FIELD
,
746 [ FILTER_OP_LOAD_FIELD_S8
] = &&LABEL_FILTER_OP_LOAD_FIELD_S8
,
747 [ FILTER_OP_LOAD_FIELD_S16
] = &&LABEL_FILTER_OP_LOAD_FIELD_S16
,
748 [ FILTER_OP_LOAD_FIELD_S32
] = &&LABEL_FILTER_OP_LOAD_FIELD_S32
,
749 [ FILTER_OP_LOAD_FIELD_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_S64
,
750 [ FILTER_OP_LOAD_FIELD_U8
] = &&LABEL_FILTER_OP_LOAD_FIELD_U8
,
751 [ FILTER_OP_LOAD_FIELD_U16
] = &&LABEL_FILTER_OP_LOAD_FIELD_U16
,
752 [ FILTER_OP_LOAD_FIELD_U32
] = &&LABEL_FILTER_OP_LOAD_FIELD_U32
,
753 [ FILTER_OP_LOAD_FIELD_U64
] = &&LABEL_FILTER_OP_LOAD_FIELD_U64
,
754 [ FILTER_OP_LOAD_FIELD_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_STRING
,
755 [ FILTER_OP_LOAD_FIELD_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_SEQUENCE
,
756 [ FILTER_OP_LOAD_FIELD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_DOUBLE
,
758 [ FILTER_OP_UNARY_BIT_NOT
] = &&LABEL_FILTER_OP_UNARY_BIT_NOT
,
760 [ FILTER_OP_RETURN_S64
] = &&LABEL_FILTER_OP_RETURN_S64
,
762 #endif /* #ifndef INTERPRETER_USE_SWITCH */
766 OP(FILTER_OP_UNKNOWN
):
767 OP(FILTER_OP_LOAD_FIELD_REF
):
768 #ifdef INTERPRETER_USE_SWITCH
770 #endif /* INTERPRETER_USE_SWITCH */
771 ERR("unknown bytecode op %u",
772 (unsigned int) *(filter_opcode_t
*) pc
);
776 OP(FILTER_OP_RETURN
):
777 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
778 /* Handle dynamic typing. */
779 switch (estack_ax_t
) {
781 retval
= !!estack_ax_v
;
785 case REG_STAR_GLOB_STRING
:
793 OP(FILTER_OP_RETURN_S64
):
794 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
795 retval
= !!estack_ax_v
;
805 ERR("unsupported bytecode op %u",
806 (unsigned int) *(filter_opcode_t
*) pc
);
812 /* Dynamic typing. */
813 switch (estack_ax_t
) {
815 switch (estack_bx_t
) {
817 JUMP_TO(FILTER_OP_EQ_S64
);
819 JUMP_TO(FILTER_OP_EQ_DOUBLE_S64
);
820 case REG_STRING
: /* Fall-through */
821 case REG_STAR_GLOB_STRING
:
825 ERR("Unknown filter register type (%d)",
832 switch (estack_bx_t
) {
834 JUMP_TO(FILTER_OP_EQ_S64_DOUBLE
);
836 JUMP_TO(FILTER_OP_EQ_DOUBLE
);
837 case REG_STRING
: /* Fall-through */
838 case REG_STAR_GLOB_STRING
:
842 ERR("Unknown filter register type (%d)",
849 switch (estack_bx_t
) {
850 case REG_S64
: /* Fall-through */
855 JUMP_TO(FILTER_OP_EQ_STRING
);
856 case REG_STAR_GLOB_STRING
:
857 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
859 ERR("Unknown filter register type (%d)",
865 case REG_STAR_GLOB_STRING
:
866 switch (estack_bx_t
) {
867 case REG_S64
: /* Fall-through */
872 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
873 case REG_STAR_GLOB_STRING
:
877 ERR("Unknown filter register type (%d)",
884 ERR("Unknown filter register type (%d)",
892 /* Dynamic typing. */
893 switch (estack_ax_t
) {
895 switch (estack_bx_t
) {
897 JUMP_TO(FILTER_OP_NE_S64
);
899 JUMP_TO(FILTER_OP_NE_DOUBLE_S64
);
900 case REG_STRING
: /* Fall-through */
901 case REG_STAR_GLOB_STRING
:
905 ERR("Unknown filter register type (%d)",
912 switch (estack_bx_t
) {
914 JUMP_TO(FILTER_OP_NE_S64_DOUBLE
);
916 JUMP_TO(FILTER_OP_NE_DOUBLE
);
917 case REG_STRING
: /* Fall-through */
918 case REG_STAR_GLOB_STRING
:
922 ERR("Unknown filter register type (%d)",
929 switch (estack_bx_t
) {
930 case REG_S64
: /* Fall-through */
935 JUMP_TO(FILTER_OP_NE_STRING
);
936 case REG_STAR_GLOB_STRING
:
937 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
939 ERR("Unknown filter register type (%d)",
945 case REG_STAR_GLOB_STRING
:
946 switch (estack_bx_t
) {
947 case REG_S64
: /* Fall-through */
952 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
953 case REG_STAR_GLOB_STRING
:
957 ERR("Unknown filter register type (%d)",
964 ERR("Unknown filter register type (%d)",
972 /* Dynamic typing. */
973 switch (estack_ax_t
) {
975 switch (estack_bx_t
) {
977 JUMP_TO(FILTER_OP_GT_S64
);
979 JUMP_TO(FILTER_OP_GT_DOUBLE_S64
);
980 case REG_STRING
: /* Fall-through */
981 case REG_STAR_GLOB_STRING
:
985 ERR("Unknown filter register type (%d)",
992 switch (estack_bx_t
) {
994 JUMP_TO(FILTER_OP_GT_S64_DOUBLE
);
996 JUMP_TO(FILTER_OP_GT_DOUBLE
);
997 case REG_STRING
: /* Fall-through */
998 case REG_STAR_GLOB_STRING
:
1002 ERR("Unknown filter register type (%d)",
1009 switch (estack_bx_t
) {
1010 case REG_S64
: /* Fall-through */
1011 case REG_DOUBLE
: /* Fall-through */
1012 case REG_STAR_GLOB_STRING
:
1016 JUMP_TO(FILTER_OP_GT_STRING
);
1018 ERR("Unknown filter register type (%d)",
1025 ERR("Unknown filter register type (%d)",
1033 /* Dynamic typing. */
1034 switch (estack_ax_t
) {
1036 switch (estack_bx_t
) {
1038 JUMP_TO(FILTER_OP_LT_S64
);
1040 JUMP_TO(FILTER_OP_LT_DOUBLE_S64
);
1041 case REG_STRING
: /* Fall-through */
1042 case REG_STAR_GLOB_STRING
:
1046 ERR("Unknown filter register type (%d)",
1053 switch (estack_bx_t
) {
1055 JUMP_TO(FILTER_OP_LT_S64_DOUBLE
);
1057 JUMP_TO(FILTER_OP_LT_DOUBLE
);
1058 case REG_STRING
: /* Fall-through */
1059 case REG_STAR_GLOB_STRING
:
1063 ERR("Unknown filter register type (%d)",
1070 switch (estack_bx_t
) {
1071 case REG_S64
: /* Fall-through */
1072 case REG_DOUBLE
: /* Fall-through */
1073 case REG_STAR_GLOB_STRING
:
1077 JUMP_TO(FILTER_OP_LT_STRING
);
1079 ERR("Unknown filter register type (%d)",
1086 ERR("Unknown filter register type (%d)",
1094 /* Dynamic typing. */
1095 switch (estack_ax_t
) {
1097 switch (estack_bx_t
) {
1099 JUMP_TO(FILTER_OP_GE_S64
);
1101 JUMP_TO(FILTER_OP_GE_DOUBLE_S64
);
1102 case REG_STRING
: /* Fall-through */
1103 case REG_STAR_GLOB_STRING
:
1107 ERR("Unknown filter register type (%d)",
1114 switch (estack_bx_t
) {
1116 JUMP_TO(FILTER_OP_GE_S64_DOUBLE
);
1118 JUMP_TO(FILTER_OP_GE_DOUBLE
);
1119 case REG_STRING
: /* Fall-through */
1120 case REG_STAR_GLOB_STRING
:
1124 ERR("Unknown filter register type (%d)",
1131 switch (estack_bx_t
) {
1132 case REG_S64
: /* Fall-through */
1133 case REG_DOUBLE
: /* Fall-through */
1134 case REG_STAR_GLOB_STRING
:
1138 JUMP_TO(FILTER_OP_GE_STRING
);
1140 ERR("Unknown filter register type (%d)",
1147 ERR("Unknown filter register type (%d)",
1155 /* Dynamic typing. */
1156 switch (estack_ax_t
) {
1158 switch (estack_bx_t
) {
1160 JUMP_TO(FILTER_OP_LE_S64
);
1162 JUMP_TO(FILTER_OP_LE_DOUBLE_S64
);
1163 case REG_STRING
: /* Fall-through */
1164 case REG_STAR_GLOB_STRING
:
1168 ERR("Unknown filter register type (%d)",
1175 switch (estack_bx_t
) {
1177 JUMP_TO(FILTER_OP_LE_S64_DOUBLE
);
1179 JUMP_TO(FILTER_OP_LE_DOUBLE
);
1180 case REG_STRING
: /* Fall-through */
1181 case REG_STAR_GLOB_STRING
:
1185 ERR("Unknown filter register type (%d)",
1192 switch (estack_bx_t
) {
1193 case REG_S64
: /* Fall-through */
1194 case REG_DOUBLE
: /* Fall-through */
1195 case REG_STAR_GLOB_STRING
:
1199 JUMP_TO(FILTER_OP_LE_STRING
);
1201 ERR("Unknown filter register type (%d)",
1208 ERR("Unknown filter register type (%d)",
1215 OP(FILTER_OP_EQ_STRING
):
1219 res
= (stack_strcmp(stack
, top
, "==") == 0);
1220 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1222 estack_ax_t
= REG_S64
;
1223 next_pc
+= sizeof(struct binary_op
);
1226 OP(FILTER_OP_NE_STRING
):
1230 res
= (stack_strcmp(stack
, top
, "!=") != 0);
1231 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1233 estack_ax_t
= REG_S64
;
1234 next_pc
+= sizeof(struct binary_op
);
1237 OP(FILTER_OP_GT_STRING
):
1241 res
= (stack_strcmp(stack
, top
, ">") > 0);
1242 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1244 estack_ax_t
= REG_S64
;
1245 next_pc
+= sizeof(struct binary_op
);
1248 OP(FILTER_OP_LT_STRING
):
1252 res
= (stack_strcmp(stack
, top
, "<") < 0);
1253 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1255 estack_ax_t
= REG_S64
;
1256 next_pc
+= sizeof(struct binary_op
);
1259 OP(FILTER_OP_GE_STRING
):
1263 res
= (stack_strcmp(stack
, top
, ">=") >= 0);
1264 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1266 estack_ax_t
= REG_S64
;
1267 next_pc
+= sizeof(struct binary_op
);
1270 OP(FILTER_OP_LE_STRING
):
1274 res
= (stack_strcmp(stack
, top
, "<=") <= 0);
1275 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1277 estack_ax_t
= REG_S64
;
1278 next_pc
+= sizeof(struct binary_op
);
1282 OP(FILTER_OP_EQ_STAR_GLOB_STRING
):
1286 res
= (stack_star_glob_match(stack
, top
, "==") == 0);
1287 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1289 estack_ax_t
= REG_S64
;
1290 next_pc
+= sizeof(struct binary_op
);
1293 OP(FILTER_OP_NE_STAR_GLOB_STRING
):
1297 res
= (stack_star_glob_match(stack
, top
, "!=") != 0);
1298 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1300 estack_ax_t
= REG_S64
;
1301 next_pc
+= sizeof(struct binary_op
);
1305 OP(FILTER_OP_EQ_S64
):
1309 res
= (estack_bx_v
== estack_ax_v
);
1310 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1312 estack_ax_t
= REG_S64
;
1313 next_pc
+= sizeof(struct binary_op
);
1316 OP(FILTER_OP_NE_S64
):
1320 res
= (estack_bx_v
!= estack_ax_v
);
1321 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1323 estack_ax_t
= REG_S64
;
1324 next_pc
+= sizeof(struct binary_op
);
1327 OP(FILTER_OP_GT_S64
):
1331 res
= (estack_bx_v
> estack_ax_v
);
1332 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1334 estack_ax_t
= REG_S64
;
1335 next_pc
+= sizeof(struct binary_op
);
1338 OP(FILTER_OP_LT_S64
):
1342 res
= (estack_bx_v
< estack_ax_v
);
1343 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1345 estack_ax_t
= REG_S64
;
1346 next_pc
+= sizeof(struct binary_op
);
1349 OP(FILTER_OP_GE_S64
):
1353 res
= (estack_bx_v
>= estack_ax_v
);
1354 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1356 estack_ax_t
= REG_S64
;
1357 next_pc
+= sizeof(struct binary_op
);
1360 OP(FILTER_OP_LE_S64
):
1364 res
= (estack_bx_v
<= estack_ax_v
);
1365 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1367 estack_ax_t
= REG_S64
;
1368 next_pc
+= sizeof(struct binary_op
);
1372 OP(FILTER_OP_EQ_DOUBLE
):
1376 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax(stack
, top
)->u
.d
);
1377 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1379 estack_ax_t
= REG_S64
;
1380 next_pc
+= sizeof(struct binary_op
);
1383 OP(FILTER_OP_NE_DOUBLE
):
1387 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax(stack
, top
)->u
.d
);
1388 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1390 estack_ax_t
= REG_S64
;
1391 next_pc
+= sizeof(struct binary_op
);
1394 OP(FILTER_OP_GT_DOUBLE
):
1398 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax(stack
, top
)->u
.d
);
1399 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1401 estack_ax_t
= REG_S64
;
1402 next_pc
+= sizeof(struct binary_op
);
1405 OP(FILTER_OP_LT_DOUBLE
):
1409 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax(stack
, top
)->u
.d
);
1410 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1412 estack_ax_t
= REG_S64
;
1413 next_pc
+= sizeof(struct binary_op
);
1416 OP(FILTER_OP_GE_DOUBLE
):
1420 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax(stack
, top
)->u
.d
);
1421 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1423 estack_ax_t
= REG_S64
;
1424 next_pc
+= sizeof(struct binary_op
);
1427 OP(FILTER_OP_LE_DOUBLE
):
1431 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax(stack
, top
)->u
.d
);
1432 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1434 estack_ax_t
= REG_S64
;
1435 next_pc
+= sizeof(struct binary_op
);
1439 /* Mixed S64-double binary comparators */
1440 OP(FILTER_OP_EQ_DOUBLE_S64
):
1444 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax_v
);
1445 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1447 estack_ax_t
= REG_S64
;
1448 next_pc
+= sizeof(struct binary_op
);
1451 OP(FILTER_OP_NE_DOUBLE_S64
):
1455 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax_v
);
1456 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1458 estack_ax_t
= REG_S64
;
1459 next_pc
+= sizeof(struct binary_op
);
1462 OP(FILTER_OP_GT_DOUBLE_S64
):
1466 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax_v
);
1467 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1469 estack_ax_t
= REG_S64
;
1470 next_pc
+= sizeof(struct binary_op
);
1473 OP(FILTER_OP_LT_DOUBLE_S64
):
1477 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax_v
);
1478 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1480 estack_ax_t
= REG_S64
;
1481 next_pc
+= sizeof(struct binary_op
);
1484 OP(FILTER_OP_GE_DOUBLE_S64
):
1488 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax_v
);
1489 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1491 estack_ax_t
= REG_S64
;
1492 next_pc
+= sizeof(struct binary_op
);
1495 OP(FILTER_OP_LE_DOUBLE_S64
):
1499 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax_v
);
1500 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1502 estack_ax_t
= REG_S64
;
1503 next_pc
+= sizeof(struct binary_op
);
1507 OP(FILTER_OP_EQ_S64_DOUBLE
):
1511 res
= (estack_bx_v
== estack_ax(stack
, top
)->u
.d
);
1512 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1514 estack_ax_t
= REG_S64
;
1515 next_pc
+= sizeof(struct binary_op
);
1518 OP(FILTER_OP_NE_S64_DOUBLE
):
1522 res
= (estack_bx_v
!= estack_ax(stack
, top
)->u
.d
);
1523 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1525 estack_ax_t
= REG_S64
;
1526 next_pc
+= sizeof(struct binary_op
);
1529 OP(FILTER_OP_GT_S64_DOUBLE
):
1533 res
= (estack_bx_v
> estack_ax(stack
, top
)->u
.d
);
1534 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1536 estack_ax_t
= REG_S64
;
1537 next_pc
+= sizeof(struct binary_op
);
1540 OP(FILTER_OP_LT_S64_DOUBLE
):
1544 res
= (estack_bx_v
< estack_ax(stack
, top
)->u
.d
);
1545 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1547 estack_ax_t
= REG_S64
;
1548 next_pc
+= sizeof(struct binary_op
);
1551 OP(FILTER_OP_GE_S64_DOUBLE
):
1555 res
= (estack_bx_v
>= estack_ax(stack
, top
)->u
.d
);
1556 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1558 estack_ax_t
= REG_S64
;
1559 next_pc
+= sizeof(struct binary_op
);
1562 OP(FILTER_OP_LE_S64_DOUBLE
):
1566 res
= (estack_bx_v
<= estack_ax(stack
, top
)->u
.d
);
1567 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1569 estack_ax_t
= REG_S64
;
1570 next_pc
+= sizeof(struct binary_op
);
1573 OP(FILTER_OP_BIT_RSHIFT
):
1577 /* Dynamic typing. */
1578 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1582 /* Catch undefined behavior. */
1583 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1587 res
= ((uint64_t) estack_bx_v
>> (uint32_t) estack_ax_v
);
1588 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1590 estack_ax_t
= REG_S64
;
1591 next_pc
+= sizeof(struct binary_op
);
1594 OP(FILTER_OP_BIT_LSHIFT
):
1598 /* Dynamic typing. */
1599 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1603 /* Catch undefined behavior. */
1604 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1608 res
= ((uint64_t) estack_bx_v
<< (uint32_t) estack_ax_v
);
1609 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1611 estack_ax_t
= REG_S64
;
1612 next_pc
+= sizeof(struct binary_op
);
1615 OP(FILTER_OP_BIT_AND
):
1619 /* Dynamic typing. */
1620 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1625 res
= ((uint64_t) estack_bx_v
& (uint64_t) estack_ax_v
);
1626 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1628 estack_ax_t
= REG_S64
;
1629 next_pc
+= sizeof(struct binary_op
);
1632 OP(FILTER_OP_BIT_OR
):
1636 /* Dynamic typing. */
1637 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1642 res
= ((uint64_t) estack_bx_v
| (uint64_t) estack_ax_v
);
1643 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1645 estack_ax_t
= REG_S64
;
1646 next_pc
+= sizeof(struct binary_op
);
1649 OP(FILTER_OP_BIT_XOR
):
1653 /* Dynamic typing. */
1654 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1659 res
= ((uint64_t) estack_bx_v
^ (uint64_t) estack_ax_v
);
1660 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1662 estack_ax_t
= REG_S64
;
1663 next_pc
+= sizeof(struct binary_op
);
1668 OP(FILTER_OP_UNARY_PLUS
):
1670 /* Dynamic typing. */
1671 switch (estack_ax_t
) {
1672 case REG_S64
: /* Fall-through. */
1673 JUMP_TO(FILTER_OP_UNARY_PLUS_S64
);
1675 JUMP_TO(FILTER_OP_UNARY_PLUS_DOUBLE
);
1676 case REG_STRING
: /* Fall-through */
1677 case REG_STAR_GLOB_STRING
:
1681 ERR("Unknown filter register type (%d)",
1687 OP(FILTER_OP_UNARY_MINUS
):
1689 /* Dynamic typing. */
1690 switch (estack_ax_t
) {
1692 JUMP_TO(FILTER_OP_UNARY_MINUS_S64
);
1694 JUMP_TO(FILTER_OP_UNARY_MINUS_DOUBLE
);
1695 case REG_STRING
: /* Fall-through */
1696 case REG_STAR_GLOB_STRING
:
1700 ERR("Unknown filter register type (%d)",
1706 OP(FILTER_OP_UNARY_NOT
):
1708 /* Dynamic typing. */
1709 switch (estack_ax_t
) {
1711 JUMP_TO(FILTER_OP_UNARY_NOT_S64
);
1713 JUMP_TO(FILTER_OP_UNARY_NOT_DOUBLE
);
1714 case REG_STRING
: /* Fall-through */
1715 case REG_STAR_GLOB_STRING
:
1719 ERR("Unknown filter register type (%d)",
1724 next_pc
+= sizeof(struct unary_op
);
1728 OP(FILTER_OP_UNARY_BIT_NOT
):
1730 /* Dynamic typing. */
1731 if (estack_ax_t
!= REG_S64
) {
1736 estack_ax_v
= ~(uint64_t) estack_ax_v
;
1737 next_pc
+= sizeof(struct unary_op
);
1741 OP(FILTER_OP_UNARY_PLUS_S64
):
1742 OP(FILTER_OP_UNARY_PLUS_DOUBLE
):
1744 next_pc
+= sizeof(struct unary_op
);
1747 OP(FILTER_OP_UNARY_MINUS_S64
):
1749 estack_ax_v
= -estack_ax_v
;
1750 next_pc
+= sizeof(struct unary_op
);
1753 OP(FILTER_OP_UNARY_MINUS_DOUBLE
):
1755 estack_ax(stack
, top
)->u
.d
= -estack_ax(stack
, top
)->u
.d
;
1756 next_pc
+= sizeof(struct unary_op
);
1759 OP(FILTER_OP_UNARY_NOT_S64
):
1761 estack_ax_v
= !estack_ax_v
;
1762 next_pc
+= sizeof(struct unary_op
);
1765 OP(FILTER_OP_UNARY_NOT_DOUBLE
):
1767 estack_ax_v
= !estack_ax(stack
, top
)->u
.d
;
1768 estack_ax_t
= REG_S64
;
1769 next_pc
+= sizeof(struct unary_op
);
1776 struct logical_op
*insn
= (struct logical_op
*) pc
;
1778 if (estack_ax_t
!= REG_S64
) {
1782 /* If AX is 0, skip and evaluate to 0 */
1783 if (unlikely(estack_ax_v
== 0)) {
1784 dbg_printf("Jumping to bytecode offset %u\n",
1785 (unsigned int) insn
->skip_offset
);
1786 next_pc
= start_pc
+ insn
->skip_offset
;
1788 /* Pop 1 when jump not taken */
1789 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1790 next_pc
+= sizeof(struct logical_op
);
1796 struct logical_op
*insn
= (struct logical_op
*) pc
;
1798 if (estack_ax_t
!= REG_S64
) {
1802 /* If AX is nonzero, skip and evaluate to 1 */
1803 if (unlikely(estack_ax_v
!= 0)) {
1805 dbg_printf("Jumping to bytecode offset %u\n",
1806 (unsigned int) insn
->skip_offset
);
1807 next_pc
= start_pc
+ insn
->skip_offset
;
1809 /* Pop 1 when jump not taken */
1810 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1811 next_pc
+= sizeof(struct logical_op
);
1817 /* load field ref */
1818 OP(FILTER_OP_LOAD_FIELD_REF_STRING
):
1820 struct load_op
*insn
= (struct load_op
*) pc
;
1821 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1823 dbg_printf("load field ref offset %u type string\n",
1825 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1826 estack_ax(stack
, top
)->u
.s
.str
=
1827 *(const char * const *) &filter_stack_data
[ref
->offset
];
1828 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1829 dbg_printf("Filter warning: loading a NULL string.\n");
1833 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1834 estack_ax(stack
, top
)->u
.s
.literal_type
=
1835 ESTACK_STRING_LITERAL_TYPE_NONE
;
1836 estack_ax_t
= REG_STRING
;
1837 dbg_printf("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1838 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1842 OP(FILTER_OP_LOAD_FIELD_REF_SEQUENCE
):
1844 struct load_op
*insn
= (struct load_op
*) pc
;
1845 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1847 dbg_printf("load field ref offset %u type sequence\n",
1849 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1850 estack_ax(stack
, top
)->u
.s
.seq_len
=
1851 *(unsigned long *) &filter_stack_data
[ref
->offset
];
1852 estack_ax(stack
, top
)->u
.s
.str
=
1853 *(const char **) (&filter_stack_data
[ref
->offset
1854 + sizeof(unsigned long)]);
1855 estack_ax_t
= REG_STRING
;
1856 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1857 dbg_printf("Filter warning: loading a NULL sequence.\n");
1861 estack_ax(stack
, top
)->u
.s
.literal_type
=
1862 ESTACK_STRING_LITERAL_TYPE_NONE
;
1863 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1867 OP(FILTER_OP_LOAD_FIELD_REF_S64
):
1869 struct load_op
*insn
= (struct load_op
*) pc
;
1870 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1872 dbg_printf("load field ref offset %u type s64\n",
1874 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1876 ((struct literal_numeric
*) &filter_stack_data
[ref
->offset
])->v
;
1877 estack_ax_t
= REG_S64
;
1878 dbg_printf("ref load s64 %" PRIi64
"\n", estack_ax_v
);
1879 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1883 OP(FILTER_OP_LOAD_FIELD_REF_DOUBLE
):
1885 struct load_op
*insn
= (struct load_op
*) pc
;
1886 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1888 dbg_printf("load field ref offset %u type double\n",
1890 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1891 memcpy(&estack_ax(stack
, top
)->u
.d
, &filter_stack_data
[ref
->offset
],
1892 sizeof(struct literal_double
));
1893 estack_ax_t
= REG_DOUBLE
;
1894 dbg_printf("ref load double %g\n", estack_ax(stack
, top
)->u
.d
);
1895 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1899 /* load from immediate operand */
1900 OP(FILTER_OP_LOAD_STRING
):
1902 struct load_op
*insn
= (struct load_op
*) pc
;
1904 dbg_printf("load string %s\n", insn
->data
);
1905 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1906 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1907 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1908 estack_ax(stack
, top
)->u
.s
.literal_type
=
1909 ESTACK_STRING_LITERAL_TYPE_PLAIN
;
1910 estack_ax_t
= REG_STRING
;
1911 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1915 OP(FILTER_OP_LOAD_STAR_GLOB_STRING
):
1917 struct load_op
*insn
= (struct load_op
*) pc
;
1919 dbg_printf("load globbing pattern %s\n", insn
->data
);
1920 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1921 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1922 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1923 estack_ax(stack
, top
)->u
.s
.literal_type
=
1924 ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
;
1925 estack_ax_t
= REG_STAR_GLOB_STRING
;
1926 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1930 OP(FILTER_OP_LOAD_S64
):
1932 struct load_op
*insn
= (struct load_op
*) pc
;
1934 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1935 estack_ax_v
= ((struct literal_numeric
*) insn
->data
)->v
;
1936 estack_ax_t
= REG_S64
;
1937 dbg_printf("load s64 %" PRIi64
"\n", estack_ax_v
);
1938 next_pc
+= sizeof(struct load_op
)
1939 + sizeof(struct literal_numeric
);
1943 OP(FILTER_OP_LOAD_DOUBLE
):
1945 struct load_op
*insn
= (struct load_op
*) pc
;
1947 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1948 memcpy(&estack_ax(stack
, top
)->u
.d
, insn
->data
,
1949 sizeof(struct literal_double
));
1950 estack_ax_t
= REG_DOUBLE
;
1951 dbg_printf("load double %g\n", estack_ax(stack
, top
)->u
.d
);
1952 next_pc
+= sizeof(struct load_op
)
1953 + sizeof(struct literal_double
);
1958 OP(FILTER_OP_CAST_TO_S64
):
1960 /* Dynamic typing. */
1961 switch (estack_ax_t
) {
1963 JUMP_TO(FILTER_OP_CAST_NOP
);
1965 JUMP_TO(FILTER_OP_CAST_DOUBLE_TO_S64
);
1966 case REG_STRING
: /* Fall-through */
1967 case REG_STAR_GLOB_STRING
:
1971 ERR("Unknown filter register type (%d)",
1978 OP(FILTER_OP_CAST_DOUBLE_TO_S64
):
1980 estack_ax_v
= (int64_t) estack_ax(stack
, top
)->u
.d
;
1981 estack_ax_t
= REG_S64
;
1982 next_pc
+= sizeof(struct cast_op
);
1986 OP(FILTER_OP_CAST_NOP
):
1988 next_pc
+= sizeof(struct cast_op
);
1992 /* get context ref */
1993 OP(FILTER_OP_GET_CONTEXT_REF
):
1995 struct load_op
*insn
= (struct load_op
*) pc
;
1996 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1997 struct lttng_ctx
*ctx
;
1998 struct lttng_ctx_field
*ctx_field
;
1999 struct lttng_ctx_value v
;
2001 dbg_printf("get context ref offset %u type dynamic\n",
2003 ctx
= rcu_dereference(session
->ctx
);
2004 ctx_field
= &ctx
->fields
[ref
->offset
];
2005 ctx_field
->get_value(ctx_field
, &v
);
2006 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2008 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
2011 case LTTNG_UST_DYNAMIC_TYPE_S64
:
2012 estack_ax_v
= v
.u
.s64
;
2013 estack_ax_t
= REG_S64
;
2014 dbg_printf("ref get context dynamic s64 %" PRIi64
"\n", estack_ax_v
);
2016 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
2017 estack_ax(stack
, top
)->u
.d
= v
.u
.d
;
2018 estack_ax_t
= REG_DOUBLE
;
2019 dbg_printf("ref get context dynamic double %g\n", estack_ax(stack
, top
)->u
.d
);
2021 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
2022 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2023 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2024 dbg_printf("Filter warning: loading a NULL string.\n");
2028 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2029 estack_ax(stack
, top
)->u
.s
.literal_type
=
2030 ESTACK_STRING_LITERAL_TYPE_NONE
;
2031 dbg_printf("ref get context dynamic string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2032 estack_ax_t
= REG_STRING
;
2035 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
2039 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2043 OP(FILTER_OP_GET_CONTEXT_REF_STRING
):
2045 struct load_op
*insn
= (struct load_op
*) pc
;
2046 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2047 struct lttng_ctx
*ctx
;
2048 struct lttng_ctx_field
*ctx_field
;
2049 struct lttng_ctx_value v
;
2051 dbg_printf("get context ref offset %u type string\n",
2053 ctx
= rcu_dereference(session
->ctx
);
2054 ctx_field
= &ctx
->fields
[ref
->offset
];
2055 ctx_field
->get_value(ctx_field
, &v
);
2056 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2057 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2058 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2059 dbg_printf("Filter warning: loading a NULL string.\n");
2063 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2064 estack_ax(stack
, top
)->u
.s
.literal_type
=
2065 ESTACK_STRING_LITERAL_TYPE_NONE
;
2066 estack_ax_t
= REG_STRING
;
2067 dbg_printf("ref get context string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2068 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2072 OP(FILTER_OP_GET_CONTEXT_REF_S64
):
2074 struct load_op
*insn
= (struct load_op
*) pc
;
2075 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2076 struct lttng_ctx
*ctx
;
2077 struct lttng_ctx_field
*ctx_field
;
2078 struct lttng_ctx_value v
;
2080 dbg_printf("get context ref offset %u type s64\n",
2082 ctx
= rcu_dereference(session
->ctx
);
2083 ctx_field
= &ctx
->fields
[ref
->offset
];
2084 ctx_field
->get_value(ctx_field
, &v
);
2085 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2086 estack_ax_v
= v
.u
.s64
;
2087 estack_ax_t
= REG_S64
;
2088 dbg_printf("ref get context s64 %" PRIi64
"\n", estack_ax_v
);
2089 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2093 OP(FILTER_OP_GET_CONTEXT_REF_DOUBLE
):
2095 struct load_op
*insn
= (struct load_op
*) pc
;
2096 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2097 struct lttng_ctx
*ctx
;
2098 struct lttng_ctx_field
*ctx_field
;
2099 struct lttng_ctx_value v
;
2101 dbg_printf("get context ref offset %u type double\n",
2103 ctx
= rcu_dereference(session
->ctx
);
2104 ctx_field
= &ctx
->fields
[ref
->offset
];
2105 ctx_field
->get_value(ctx_field
, &v
);
2106 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2107 memcpy(&estack_ax(stack
, top
)->u
.d
, &v
.u
.d
, sizeof(struct literal_double
));
2108 estack_ax_t
= REG_DOUBLE
;
2109 dbg_printf("ref get context double %g\n", estack_ax(stack
, top
)->u
.d
);
2110 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2114 OP(FILTER_OP_GET_CONTEXT_ROOT
):
2116 dbg_printf("op get context root\n");
2117 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2118 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_CONTEXT
;
2119 /* "field" only needed for variants. */
2120 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2121 estack_ax_t
= REG_PTR
;
2122 next_pc
+= sizeof(struct load_op
);
2126 OP(FILTER_OP_GET_APP_CONTEXT_ROOT
):
2128 dbg_printf("op get app context root\n");
2129 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2130 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_APP_CONTEXT
;
2131 /* "field" only needed for variants. */
2132 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2133 estack_ax_t
= REG_PTR
;
2134 next_pc
+= sizeof(struct load_op
);
2138 OP(FILTER_OP_GET_PAYLOAD_ROOT
):
2140 dbg_printf("op get app payload root\n");
2141 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2142 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_PAYLOAD
;
2143 estack_ax(stack
, top
)->u
.ptr
.ptr
= filter_stack_data
;
2144 /* "field" only needed for variants. */
2145 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2146 estack_ax_t
= REG_PTR
;
2147 next_pc
+= sizeof(struct load_op
);
2151 OP(FILTER_OP_GET_SYMBOL
):
2153 dbg_printf("op get symbol\n");
2154 switch (estack_ax(stack
, top
)->u
.ptr
.type
) {
2156 ERR("Nested fields not implemented yet.");
2159 case LOAD_ROOT_CONTEXT
:
2160 case LOAD_ROOT_APP_CONTEXT
:
2161 case LOAD_ROOT_PAYLOAD
:
2163 * symbol lookup is performed by
2169 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_symbol
);
2173 OP(FILTER_OP_GET_SYMBOL_FIELD
):
2176 * Used for first variant encountered in a
2177 * traversal. Variants are not implemented yet.
2183 OP(FILTER_OP_GET_INDEX_U16
):
2185 struct load_op
*insn
= (struct load_op
*) pc
;
2186 struct get_index_u16
*index
= (struct get_index_u16
*) insn
->data
;
2188 dbg_printf("op get index u16\n");
2189 ret
= dynamic_get_index(session
, bytecode
, index
->index
, estack_ax(stack
, top
));
2192 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2193 estack_ax_t
= estack_ax(stack
, top
)->type
;
2194 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u16
);
2198 OP(FILTER_OP_GET_INDEX_U64
):
2200 struct load_op
*insn
= (struct load_op
*) pc
;
2201 struct get_index_u64
*index
= (struct get_index_u64
*) insn
->data
;
2203 dbg_printf("op get index u64\n");
2204 ret
= dynamic_get_index(session
, bytecode
, index
->index
, estack_ax(stack
, top
));
2207 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2208 estack_ax_t
= estack_ax(stack
, top
)->type
;
2209 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u64
);
2213 OP(FILTER_OP_LOAD_FIELD
):
2215 dbg_printf("op load field\n");
2216 ret
= dynamic_load_field(estack_ax(stack
, top
));
2219 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2220 estack_ax_t
= estack_ax(stack
, top
)->type
;
2221 next_pc
+= sizeof(struct load_op
);
2225 OP(FILTER_OP_LOAD_FIELD_S8
):
2227 dbg_printf("op load field s8\n");
2229 estack_ax_v
= *(int8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2230 estack_ax_t
= REG_S64
;
2231 next_pc
+= sizeof(struct load_op
);
2234 OP(FILTER_OP_LOAD_FIELD_S16
):
2236 dbg_printf("op load field s16\n");
2238 estack_ax_v
= *(int16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2239 estack_ax_t
= REG_S64
;
2240 next_pc
+= sizeof(struct load_op
);
2243 OP(FILTER_OP_LOAD_FIELD_S32
):
2245 dbg_printf("op load field s32\n");
2247 estack_ax_v
= *(int32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2248 estack_ax_t
= REG_S64
;
2249 next_pc
+= sizeof(struct load_op
);
2252 OP(FILTER_OP_LOAD_FIELD_S64
):
2254 dbg_printf("op load field s64\n");
2256 estack_ax_v
= *(int64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2257 estack_ax_t
= REG_S64
;
2258 next_pc
+= sizeof(struct load_op
);
2261 OP(FILTER_OP_LOAD_FIELD_U8
):
2263 dbg_printf("op load field u8\n");
2265 estack_ax_v
= *(uint8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2266 estack_ax_t
= REG_S64
;
2267 next_pc
+= sizeof(struct load_op
);
2270 OP(FILTER_OP_LOAD_FIELD_U16
):
2272 dbg_printf("op load field u16\n");
2274 estack_ax_v
= *(uint16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2275 estack_ax_t
= REG_S64
;
2276 next_pc
+= sizeof(struct load_op
);
2279 OP(FILTER_OP_LOAD_FIELD_U32
):
2281 dbg_printf("op load field u32\n");
2283 estack_ax_v
= *(uint32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2284 estack_ax_t
= REG_S64
;
2285 next_pc
+= sizeof(struct load_op
);
2288 OP(FILTER_OP_LOAD_FIELD_U64
):
2290 dbg_printf("op load field u64\n");
2292 estack_ax_v
= *(uint64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2293 estack_ax_t
= REG_S64
;
2294 next_pc
+= sizeof(struct load_op
);
2297 OP(FILTER_OP_LOAD_FIELD_DOUBLE
):
2299 dbg_printf("op load field double\n");
2301 memcpy(&estack_ax(stack
, top
)->u
.d
,
2302 estack_ax(stack
, top
)->u
.ptr
.ptr
,
2303 sizeof(struct literal_double
));
2304 estack_ax(stack
, top
)->type
= REG_DOUBLE
;
2305 next_pc
+= sizeof(struct load_op
);
2309 OP(FILTER_OP_LOAD_FIELD_STRING
):
2313 dbg_printf("op load field string\n");
2314 str
= (const char *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2315 estack_ax(stack
, top
)->u
.s
.str
= str
;
2316 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2317 dbg_printf("Filter warning: loading a NULL string.\n");
2321 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2322 estack_ax(stack
, top
)->u
.s
.literal_type
=
2323 ESTACK_STRING_LITERAL_TYPE_NONE
;
2324 estack_ax(stack
, top
)->type
= REG_STRING
;
2325 next_pc
+= sizeof(struct load_op
);
2329 OP(FILTER_OP_LOAD_FIELD_SEQUENCE
):
2333 dbg_printf("op load field string sequence\n");
2334 ptr
= estack_ax(stack
, top
)->u
.ptr
.ptr
;
2335 estack_ax(stack
, top
)->u
.s
.seq_len
= *(unsigned long *) ptr
;
2336 estack_ax(stack
, top
)->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
2337 estack_ax(stack
, top
)->type
= REG_STRING
;
2338 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2339 dbg_printf("Filter warning: loading a NULL sequence.\n");
2343 estack_ax(stack
, top
)->u
.s
.literal_type
=
2344 ESTACK_STRING_LITERAL_TYPE_NONE
;
2345 next_pc
+= sizeof(struct load_op
);
2351 /* return 0 (discard) on error */