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
30 #include <urcu-pointer.h>
32 #include "lttng-filter.h"
33 #include "string-utils.h"
37 * -2: unknown escape char.
42 int parse_char(const char **p
)
62 * Returns SIZE_MAX if the string is null-terminated, or the number of
66 size_t get_str_or_seq_len(const struct estack_entry
*entry
)
68 return entry
->u
.s
.seq_len
;
72 int stack_star_glob_match(struct estack
*stack
, int top
, const char *cmp_type
)
75 const char *candidate
;
79 /* Find out which side is the pattern vs. the candidate. */
80 if (estack_ax(stack
, top
)->u
.s
.literal_type
== ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
) {
81 pattern
= estack_ax(stack
, top
)->u
.s
.str
;
82 pattern_len
= get_str_or_seq_len(estack_ax(stack
, top
));
83 candidate
= estack_bx(stack
, top
)->u
.s
.str
;
84 candidate_len
= get_str_or_seq_len(estack_bx(stack
, top
));
86 pattern
= estack_bx(stack
, top
)->u
.s
.str
;
87 pattern_len
= get_str_or_seq_len(estack_bx(stack
, top
));
88 candidate
= estack_ax(stack
, top
)->u
.s
.str
;
89 candidate_len
= get_str_or_seq_len(estack_ax(stack
, top
));
92 /* Perform the match. Returns 0 when the result is true. */
93 return !strutils_star_glob_match(pattern
, pattern_len
, candidate
,
98 int stack_strcmp(struct estack
*stack
, int top
, const char *cmp_type
)
100 const char *p
= estack_bx(stack
, top
)->u
.s
.str
, *q
= estack_ax(stack
, top
)->u
.s
.str
;
107 if (unlikely(p
- estack_bx(stack
, top
)->u
.s
.str
>= estack_bx(stack
, top
)->u
.s
.seq_len
|| *p
== '\0')) {
108 if (q
- estack_ax(stack
, top
)->u
.s
.str
>= estack_ax(stack
, top
)->u
.s
.seq_len
|| *q
== '\0') {
111 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
112 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
113 ret
= parse_char(&q
);
120 if (unlikely(q
- estack_ax(stack
, top
)->u
.s
.str
>= estack_ax(stack
, top
)->u
.s
.seq_len
|| *q
== '\0')) {
121 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
122 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
123 ret
= parse_char(&p
);
129 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
130 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
131 ret
= parse_char(&p
);
134 } else if (ret
== -2) {
137 /* else compare both char */
139 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
140 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
141 ret
= parse_char(&q
);
144 } else if (ret
== -2) {
164 uint64_t lttng_filter_false(void *filter_data
,
165 const char *filter_stack_data
)
170 #ifdef INTERPRETER_USE_SWITCH
173 * Fallback for compilers that do not support taking address of labels.
177 start_pc = &bytecode->data[0]; \
178 for (pc = next_pc = start_pc; pc - start_pc < bytecode->len; \
180 dbg_printf("Executing op %s (%u)\n", \
181 print_op((unsigned int) *(filter_opcode_t *) pc), \
182 (unsigned int) *(filter_opcode_t *) pc); \
183 switch (*(filter_opcode_t *) pc) {
185 #define OP(name) jump_target_##name: __attribute__((unused)); \
193 #define JUMP_TO(name) \
194 goto jump_target_##name
199 * Dispatch-table based interpreter.
203 start_pc = &bytecode->code[0]; \
204 pc = next_pc = start_pc; \
205 if (unlikely(pc - start_pc >= bytecode->len)) \
207 goto *dispatch[*(filter_opcode_t *) pc];
214 goto *dispatch[*(filter_opcode_t *) pc];
218 #define JUMP_TO(name) \
223 static int context_get_index(struct lttng_ctx
*ctx
,
224 struct load_ptr
*ptr
,
228 struct lttng_ctx_field
*ctx_field
;
229 struct lttng_event_field
*field
;
230 struct lttng_ctx_value v
;
232 ctx_field
= &ctx
->fields
[idx
];
233 field
= &ctx_field
->event_field
;
234 ptr
->type
= LOAD_OBJECT
;
235 /* field is only used for types nested within variants. */
238 switch (field
->type
.atype
) {
240 ctx_field
->get_value(ctx_field
, &v
);
241 if (field
->type
.u
.basic
.integer
.signedness
) {
242 ptr
->object_type
= OBJECT_TYPE_S64
;
243 ptr
->u
.s64
= v
.u
.s64
;
244 ptr
->ptr
= &ptr
->u
.s64
;
246 ptr
->object_type
= OBJECT_TYPE_U64
;
247 ptr
->u
.u64
= v
.u
.s64
; /* Cast. */
248 ptr
->ptr
= &ptr
->u
.u64
;
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
;
269 if (field
->type
.u
.array
.elem_type
.atype
!= atype_integer
) {
270 ERR("Array nesting only supports integer types.");
273 if (field
->type
.u
.array
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
274 ERR("Only string arrays are supported for contexts.");
277 ptr
->object_type
= OBJECT_TYPE_STRING
;
278 ctx_field
->get_value(ctx_field
, &v
);
282 if (field
->type
.u
.sequence
.elem_type
.atype
!= atype_integer
) {
283 ERR("Sequence nesting only supports integer types.");
286 if (field
->type
.u
.sequence
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
287 ERR("Only string sequences are supported for contexts.");
290 ptr
->object_type
= OBJECT_TYPE_STRING
;
291 ctx_field
->get_value(ctx_field
, &v
);
295 ptr
->object_type
= OBJECT_TYPE_STRING
;
296 ctx_field
->get_value(ctx_field
, &v
);
300 ptr
->object_type
= OBJECT_TYPE_DOUBLE
;
302 ptr
->ptr
= &ptr
->u
.d
;
305 ctx_field
->get_value(ctx_field
, &v
);
307 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
309 case LTTNG_UST_DYNAMIC_TYPE_S64
:
310 ptr
->object_type
= OBJECT_TYPE_S64
;
311 ptr
->u
.s64
= v
.u
.s64
;
312 ptr
->ptr
= &ptr
->u
.s64
;
313 dbg_printf("context get index dynamic s64 %" PRIi64
"\n", ptr
->u
.s64
);
315 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
316 ptr
->object_type
= OBJECT_TYPE_DOUBLE
;
318 ptr
->ptr
= &ptr
->u
.d
;
319 dbg_printf("context get index dynamic double %g\n", ptr
->u
.d
);
321 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
322 ptr
->object_type
= OBJECT_TYPE_STRING
;
324 dbg_printf("context get index dynamic string %s\n", (const char *) ptr
->ptr
);
327 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
332 ERR("Structure type cannot be loaded.");
335 ERR("Unknown type: %d", (int) field
->type
.atype
);
341 static int dynamic_get_index(struct lttng_ctx
*ctx
,
342 struct bytecode_runtime
*runtime
,
343 uint64_t index
, struct estack_entry
*stack_top
)
346 const struct filter_get_index_data
*gid
;
349 * Types nested within variants need to perform dynamic lookup
350 * based on the field descriptions. LTTng-UST does not implement
353 if (stack_top
->u
.ptr
.field
)
355 gid
= (const struct filter_get_index_data
*) &runtime
->data
[index
];
356 switch (stack_top
->u
.ptr
.type
) {
358 switch (stack_top
->u
.ptr
.object_type
) {
359 case OBJECT_TYPE_ARRAY
:
363 assert(gid
->offset
< gid
->array_len
);
364 /* Skip count (unsigned long) */
365 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
366 ptr
= ptr
+ gid
->offset
;
367 stack_top
->u
.ptr
.ptr
= ptr
;
368 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
369 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
370 /* field is only used for types nested within variants. */
371 stack_top
->u
.ptr
.field
= NULL
;
374 case OBJECT_TYPE_SEQUENCE
:
379 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
380 ptr_seq_len
= *(unsigned long *) stack_top
->u
.ptr
.ptr
;
381 if (gid
->offset
>= gid
->elem
.len
* ptr_seq_len
) {
385 ptr
= ptr
+ gid
->offset
;
386 stack_top
->u
.ptr
.ptr
= ptr
;
387 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
388 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
389 /* field is only used for types nested within variants. */
390 stack_top
->u
.ptr
.field
= NULL
;
393 case OBJECT_TYPE_STRUCT
:
394 ERR("Nested structures are not supported yet.");
397 case OBJECT_TYPE_VARIANT
:
399 ERR("Unexpected get index type %d",
400 (int) stack_top
->u
.ptr
.object_type
);
405 case LOAD_ROOT_CONTEXT
:
406 case LOAD_ROOT_APP_CONTEXT
: /* Fall-through */
408 ret
= context_get_index(ctx
,
416 case LOAD_ROOT_PAYLOAD
:
417 stack_top
->u
.ptr
.ptr
+= gid
->offset
;
418 if (gid
->elem
.type
== OBJECT_TYPE_STRING
)
419 stack_top
->u
.ptr
.ptr
= *(const char * const *) stack_top
->u
.ptr
.ptr
;
420 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
421 stack_top
->u
.ptr
.type
= LOAD_OBJECT
;
422 /* field is only used for types nested within variants. */
423 stack_top
->u
.ptr
.field
= NULL
;
432 static int dynamic_load_field(struct estack_entry
*stack_top
)
436 switch (stack_top
->u
.ptr
.type
) {
439 case LOAD_ROOT_CONTEXT
:
440 case LOAD_ROOT_APP_CONTEXT
:
441 case LOAD_ROOT_PAYLOAD
:
443 dbg_printf("Filter warning: cannot load root, missing field name.\n");
447 switch (stack_top
->u
.ptr
.object_type
) {
449 dbg_printf("op load field s8\n");
450 stack_top
->u
.v
= *(int8_t *) stack_top
->u
.ptr
.ptr
;
451 stack_top
->type
= REG_S64
;
453 case OBJECT_TYPE_S16
:
457 dbg_printf("op load field s16\n");
458 tmp
= *(int16_t *) stack_top
->u
.ptr
.ptr
;
459 if (stack_top
->u
.ptr
.rev_bo
)
461 stack_top
->u
.v
= tmp
;
462 stack_top
->type
= REG_S64
;
465 case OBJECT_TYPE_S32
:
469 dbg_printf("op load field s32\n");
470 tmp
= *(int32_t *) stack_top
->u
.ptr
.ptr
;
471 if (stack_top
->u
.ptr
.rev_bo
)
473 stack_top
->u
.v
= tmp
;
474 stack_top
->type
= REG_S64
;
477 case OBJECT_TYPE_S64
:
481 dbg_printf("op load field s64\n");
482 tmp
= *(int64_t *) stack_top
->u
.ptr
.ptr
;
483 if (stack_top
->u
.ptr
.rev_bo
)
485 stack_top
->u
.v
= tmp
;
486 stack_top
->type
= REG_S64
;
490 dbg_printf("op load field u8\n");
491 stack_top
->u
.v
= *(uint8_t *) stack_top
->u
.ptr
.ptr
;
492 stack_top
->type
= REG_S64
;
494 case OBJECT_TYPE_U16
:
498 dbg_printf("op load field s16\n");
499 tmp
= *(uint16_t *) stack_top
->u
.ptr
.ptr
;
500 if (stack_top
->u
.ptr
.rev_bo
)
502 stack_top
->u
.v
= tmp
;
503 stack_top
->type
= REG_S64
;
506 case OBJECT_TYPE_U32
:
510 dbg_printf("op load field u32\n");
511 tmp
= *(uint32_t *) stack_top
->u
.ptr
.ptr
;
512 if (stack_top
->u
.ptr
.rev_bo
)
514 stack_top
->u
.v
= tmp
;
515 stack_top
->type
= REG_S64
;
518 case OBJECT_TYPE_U64
:
522 dbg_printf("op load field u64\n");
523 tmp
= *(uint64_t *) stack_top
->u
.ptr
.ptr
;
524 if (stack_top
->u
.ptr
.rev_bo
)
526 stack_top
->u
.v
= tmp
;
527 stack_top
->type
= REG_S64
;
530 case OBJECT_TYPE_DOUBLE
:
531 memcpy(&stack_top
->u
.d
,
532 stack_top
->u
.ptr
.ptr
,
533 sizeof(struct literal_double
));
534 stack_top
->type
= REG_DOUBLE
;
536 case OBJECT_TYPE_STRING
:
540 dbg_printf("op load field string\n");
541 str
= (const char *) stack_top
->u
.ptr
.ptr
;
542 stack_top
->u
.s
.str
= str
;
543 if (unlikely(!stack_top
->u
.s
.str
)) {
544 dbg_printf("Filter warning: loading a NULL string.\n");
548 stack_top
->u
.s
.seq_len
= SIZE_MAX
;
549 stack_top
->u
.s
.literal_type
=
550 ESTACK_STRING_LITERAL_TYPE_NONE
;
551 stack_top
->type
= REG_STRING
;
554 case OBJECT_TYPE_STRING_SEQUENCE
:
558 dbg_printf("op load field string sequence\n");
559 ptr
= stack_top
->u
.ptr
.ptr
;
560 stack_top
->u
.s
.seq_len
= *(unsigned long *) ptr
;
561 stack_top
->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
562 stack_top
->type
= REG_STRING
;
563 if (unlikely(!stack_top
->u
.s
.str
)) {
564 dbg_printf("Filter warning: loading a NULL sequence.\n");
568 stack_top
->u
.s
.literal_type
=
569 ESTACK_STRING_LITERAL_TYPE_NONE
;
572 case OBJECT_TYPE_DYNAMIC
:
574 * Dynamic types in context are looked up
575 * by context get index.
579 case OBJECT_TYPE_SEQUENCE
:
580 case OBJECT_TYPE_ARRAY
:
581 case OBJECT_TYPE_STRUCT
:
582 case OBJECT_TYPE_VARIANT
:
583 ERR("Sequences, arrays, struct and variant cannot be loaded (nested types).");
594 * Return 0 (discard), or raise the 0x1 flag (log event).
595 * Currently, other flags are kept for future extensions and have no
598 uint64_t lttng_filter_interpret_bytecode(void *filter_data
,
599 const char *filter_stack_data
)
601 struct bytecode_runtime
*bytecode
= filter_data
;
602 struct lttng_ctx
*ctx
= rcu_dereference(*bytecode
->p
.ctx
);
603 void *pc
, *next_pc
, *start_pc
;
606 struct estack _stack
;
607 struct estack
*stack
= &_stack
;
608 register int64_t ax
= 0, bx
= 0;
609 register enum entry_type ax_t
= REG_UNKNOWN
, bx_t
= REG_UNKNOWN
;
610 register int top
= FILTER_STACK_EMPTY
;
611 #ifndef INTERPRETER_USE_SWITCH
612 static void *dispatch
[NR_FILTER_OPS
] = {
613 [ FILTER_OP_UNKNOWN
] = &&LABEL_FILTER_OP_UNKNOWN
,
615 [ FILTER_OP_RETURN
] = &&LABEL_FILTER_OP_RETURN
,
618 [ FILTER_OP_MUL
] = &&LABEL_FILTER_OP_MUL
,
619 [ FILTER_OP_DIV
] = &&LABEL_FILTER_OP_DIV
,
620 [ FILTER_OP_MOD
] = &&LABEL_FILTER_OP_MOD
,
621 [ FILTER_OP_PLUS
] = &&LABEL_FILTER_OP_PLUS
,
622 [ FILTER_OP_MINUS
] = &&LABEL_FILTER_OP_MINUS
,
623 [ FILTER_OP_BIT_RSHIFT
] = &&LABEL_FILTER_OP_BIT_RSHIFT
,
624 [ FILTER_OP_BIT_LSHIFT
] = &&LABEL_FILTER_OP_BIT_LSHIFT
,
625 [ FILTER_OP_BIT_AND
] = &&LABEL_FILTER_OP_BIT_AND
,
626 [ FILTER_OP_BIT_OR
] = &&LABEL_FILTER_OP_BIT_OR
,
627 [ FILTER_OP_BIT_XOR
] = &&LABEL_FILTER_OP_BIT_XOR
,
629 /* binary comparators */
630 [ FILTER_OP_EQ
] = &&LABEL_FILTER_OP_EQ
,
631 [ FILTER_OP_NE
] = &&LABEL_FILTER_OP_NE
,
632 [ FILTER_OP_GT
] = &&LABEL_FILTER_OP_GT
,
633 [ FILTER_OP_LT
] = &&LABEL_FILTER_OP_LT
,
634 [ FILTER_OP_GE
] = &&LABEL_FILTER_OP_GE
,
635 [ FILTER_OP_LE
] = &&LABEL_FILTER_OP_LE
,
637 /* string binary comparator */
638 [ FILTER_OP_EQ_STRING
] = &&LABEL_FILTER_OP_EQ_STRING
,
639 [ FILTER_OP_NE_STRING
] = &&LABEL_FILTER_OP_NE_STRING
,
640 [ FILTER_OP_GT_STRING
] = &&LABEL_FILTER_OP_GT_STRING
,
641 [ FILTER_OP_LT_STRING
] = &&LABEL_FILTER_OP_LT_STRING
,
642 [ FILTER_OP_GE_STRING
] = &&LABEL_FILTER_OP_GE_STRING
,
643 [ FILTER_OP_LE_STRING
] = &&LABEL_FILTER_OP_LE_STRING
,
645 /* globbing pattern binary comparator */
646 [ FILTER_OP_EQ_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_EQ_STAR_GLOB_STRING
,
647 [ FILTER_OP_NE_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_NE_STAR_GLOB_STRING
,
649 /* s64 binary comparator */
650 [ FILTER_OP_EQ_S64
] = &&LABEL_FILTER_OP_EQ_S64
,
651 [ FILTER_OP_NE_S64
] = &&LABEL_FILTER_OP_NE_S64
,
652 [ FILTER_OP_GT_S64
] = &&LABEL_FILTER_OP_GT_S64
,
653 [ FILTER_OP_LT_S64
] = &&LABEL_FILTER_OP_LT_S64
,
654 [ FILTER_OP_GE_S64
] = &&LABEL_FILTER_OP_GE_S64
,
655 [ FILTER_OP_LE_S64
] = &&LABEL_FILTER_OP_LE_S64
,
657 /* double binary comparator */
658 [ FILTER_OP_EQ_DOUBLE
] = &&LABEL_FILTER_OP_EQ_DOUBLE
,
659 [ FILTER_OP_NE_DOUBLE
] = &&LABEL_FILTER_OP_NE_DOUBLE
,
660 [ FILTER_OP_GT_DOUBLE
] = &&LABEL_FILTER_OP_GT_DOUBLE
,
661 [ FILTER_OP_LT_DOUBLE
] = &&LABEL_FILTER_OP_LT_DOUBLE
,
662 [ FILTER_OP_GE_DOUBLE
] = &&LABEL_FILTER_OP_GE_DOUBLE
,
663 [ FILTER_OP_LE_DOUBLE
] = &&LABEL_FILTER_OP_LE_DOUBLE
,
665 /* Mixed S64-double binary comparators */
666 [ FILTER_OP_EQ_DOUBLE_S64
] = &&LABEL_FILTER_OP_EQ_DOUBLE_S64
,
667 [ FILTER_OP_NE_DOUBLE_S64
] = &&LABEL_FILTER_OP_NE_DOUBLE_S64
,
668 [ FILTER_OP_GT_DOUBLE_S64
] = &&LABEL_FILTER_OP_GT_DOUBLE_S64
,
669 [ FILTER_OP_LT_DOUBLE_S64
] = &&LABEL_FILTER_OP_LT_DOUBLE_S64
,
670 [ FILTER_OP_GE_DOUBLE_S64
] = &&LABEL_FILTER_OP_GE_DOUBLE_S64
,
671 [ FILTER_OP_LE_DOUBLE_S64
] = &&LABEL_FILTER_OP_LE_DOUBLE_S64
,
673 [ FILTER_OP_EQ_S64_DOUBLE
] = &&LABEL_FILTER_OP_EQ_S64_DOUBLE
,
674 [ FILTER_OP_NE_S64_DOUBLE
] = &&LABEL_FILTER_OP_NE_S64_DOUBLE
,
675 [ FILTER_OP_GT_S64_DOUBLE
] = &&LABEL_FILTER_OP_GT_S64_DOUBLE
,
676 [ FILTER_OP_LT_S64_DOUBLE
] = &&LABEL_FILTER_OP_LT_S64_DOUBLE
,
677 [ FILTER_OP_GE_S64_DOUBLE
] = &&LABEL_FILTER_OP_GE_S64_DOUBLE
,
678 [ FILTER_OP_LE_S64_DOUBLE
] = &&LABEL_FILTER_OP_LE_S64_DOUBLE
,
681 [ FILTER_OP_UNARY_PLUS
] = &&LABEL_FILTER_OP_UNARY_PLUS
,
682 [ FILTER_OP_UNARY_MINUS
] = &&LABEL_FILTER_OP_UNARY_MINUS
,
683 [ FILTER_OP_UNARY_NOT
] = &&LABEL_FILTER_OP_UNARY_NOT
,
684 [ FILTER_OP_UNARY_PLUS_S64
] = &&LABEL_FILTER_OP_UNARY_PLUS_S64
,
685 [ FILTER_OP_UNARY_MINUS_S64
] = &&LABEL_FILTER_OP_UNARY_MINUS_S64
,
686 [ FILTER_OP_UNARY_NOT_S64
] = &&LABEL_FILTER_OP_UNARY_NOT_S64
,
687 [ FILTER_OP_UNARY_PLUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_PLUS_DOUBLE
,
688 [ FILTER_OP_UNARY_MINUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_MINUS_DOUBLE
,
689 [ FILTER_OP_UNARY_NOT_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_NOT_DOUBLE
,
692 [ FILTER_OP_AND
] = &&LABEL_FILTER_OP_AND
,
693 [ FILTER_OP_OR
] = &&LABEL_FILTER_OP_OR
,
696 [ FILTER_OP_LOAD_FIELD_REF
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF
,
697 [ FILTER_OP_LOAD_FIELD_REF_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_STRING
,
698 [ FILTER_OP_LOAD_FIELD_REF_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_SEQUENCE
,
699 [ FILTER_OP_LOAD_FIELD_REF_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_S64
,
700 [ FILTER_OP_LOAD_FIELD_REF_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_DOUBLE
,
702 /* load from immediate operand */
703 [ FILTER_OP_LOAD_STRING
] = &&LABEL_FILTER_OP_LOAD_STRING
,
704 [ FILTER_OP_LOAD_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_LOAD_STAR_GLOB_STRING
,
705 [ FILTER_OP_LOAD_S64
] = &&LABEL_FILTER_OP_LOAD_S64
,
706 [ FILTER_OP_LOAD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_DOUBLE
,
709 [ FILTER_OP_CAST_TO_S64
] = &&LABEL_FILTER_OP_CAST_TO_S64
,
710 [ FILTER_OP_CAST_DOUBLE_TO_S64
] = &&LABEL_FILTER_OP_CAST_DOUBLE_TO_S64
,
711 [ FILTER_OP_CAST_NOP
] = &&LABEL_FILTER_OP_CAST_NOP
,
713 /* get context ref */
714 [ FILTER_OP_GET_CONTEXT_REF
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF
,
715 [ FILTER_OP_GET_CONTEXT_REF_STRING
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_STRING
,
716 [ FILTER_OP_GET_CONTEXT_REF_S64
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_S64
,
717 [ FILTER_OP_GET_CONTEXT_REF_DOUBLE
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_DOUBLE
,
719 /* Instructions for recursive traversal through composed types. */
720 [ FILTER_OP_GET_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_CONTEXT_ROOT
,
721 [ FILTER_OP_GET_APP_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_APP_CONTEXT_ROOT
,
722 [ FILTER_OP_GET_PAYLOAD_ROOT
] = &&LABEL_FILTER_OP_GET_PAYLOAD_ROOT
,
724 [ FILTER_OP_GET_SYMBOL
] = &&LABEL_FILTER_OP_GET_SYMBOL
,
725 [ FILTER_OP_GET_SYMBOL_FIELD
] = &&LABEL_FILTER_OP_GET_SYMBOL_FIELD
,
726 [ FILTER_OP_GET_INDEX_U16
] = &&LABEL_FILTER_OP_GET_INDEX_U16
,
727 [ FILTER_OP_GET_INDEX_U64
] = &&LABEL_FILTER_OP_GET_INDEX_U64
,
729 [ FILTER_OP_LOAD_FIELD
] = &&LABEL_FILTER_OP_LOAD_FIELD
,
730 [ FILTER_OP_LOAD_FIELD_S8
] = &&LABEL_FILTER_OP_LOAD_FIELD_S8
,
731 [ FILTER_OP_LOAD_FIELD_S16
] = &&LABEL_FILTER_OP_LOAD_FIELD_S16
,
732 [ FILTER_OP_LOAD_FIELD_S32
] = &&LABEL_FILTER_OP_LOAD_FIELD_S32
,
733 [ FILTER_OP_LOAD_FIELD_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_S64
,
734 [ FILTER_OP_LOAD_FIELD_U8
] = &&LABEL_FILTER_OP_LOAD_FIELD_U8
,
735 [ FILTER_OP_LOAD_FIELD_U16
] = &&LABEL_FILTER_OP_LOAD_FIELD_U16
,
736 [ FILTER_OP_LOAD_FIELD_U32
] = &&LABEL_FILTER_OP_LOAD_FIELD_U32
,
737 [ FILTER_OP_LOAD_FIELD_U64
] = &&LABEL_FILTER_OP_LOAD_FIELD_U64
,
738 [ FILTER_OP_LOAD_FIELD_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_STRING
,
739 [ FILTER_OP_LOAD_FIELD_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_SEQUENCE
,
740 [ FILTER_OP_LOAD_FIELD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_DOUBLE
,
742 [ FILTER_OP_UNARY_BIT_NOT
] = &&LABEL_FILTER_OP_UNARY_BIT_NOT
,
744 [ FILTER_OP_RETURN_S64
] = &&LABEL_FILTER_OP_RETURN_S64
,
746 #endif /* #ifndef INTERPRETER_USE_SWITCH */
750 OP(FILTER_OP_UNKNOWN
):
751 OP(FILTER_OP_LOAD_FIELD_REF
):
752 #ifdef INTERPRETER_USE_SWITCH
754 #endif /* INTERPRETER_USE_SWITCH */
755 ERR("unknown bytecode op %u",
756 (unsigned int) *(filter_opcode_t
*) pc
);
760 OP(FILTER_OP_RETURN
):
761 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
762 /* Handle dynamic typing. */
763 switch (estack_ax_t
) {
765 retval
= !!estack_ax_v
;
769 case REG_STAR_GLOB_STRING
:
777 OP(FILTER_OP_RETURN_S64
):
778 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
779 retval
= !!estack_ax_v
;
789 ERR("unsupported bytecode op %u",
790 (unsigned int) *(filter_opcode_t
*) pc
);
796 /* Dynamic typing. */
797 switch (estack_ax_t
) {
799 switch (estack_bx_t
) {
801 JUMP_TO(FILTER_OP_EQ_S64
);
803 JUMP_TO(FILTER_OP_EQ_DOUBLE_S64
);
804 case REG_STRING
: /* Fall-through */
805 case REG_STAR_GLOB_STRING
:
809 ERR("Unknown filter register type (%d)",
816 switch (estack_bx_t
) {
818 JUMP_TO(FILTER_OP_EQ_S64_DOUBLE
);
820 JUMP_TO(FILTER_OP_EQ_DOUBLE
);
821 case REG_STRING
: /* Fall-through */
822 case REG_STAR_GLOB_STRING
:
826 ERR("Unknown filter register type (%d)",
833 switch (estack_bx_t
) {
834 case REG_S64
: /* Fall-through */
839 JUMP_TO(FILTER_OP_EQ_STRING
);
840 case REG_STAR_GLOB_STRING
:
841 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
843 ERR("Unknown filter register type (%d)",
849 case REG_STAR_GLOB_STRING
:
850 switch (estack_bx_t
) {
851 case REG_S64
: /* Fall-through */
856 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
857 case REG_STAR_GLOB_STRING
:
861 ERR("Unknown filter register type (%d)",
868 ERR("Unknown filter register type (%d)",
876 /* Dynamic typing. */
877 switch (estack_ax_t
) {
879 switch (estack_bx_t
) {
881 JUMP_TO(FILTER_OP_NE_S64
);
883 JUMP_TO(FILTER_OP_NE_DOUBLE_S64
);
884 case REG_STRING
: /* Fall-through */
885 case REG_STAR_GLOB_STRING
:
889 ERR("Unknown filter register type (%d)",
896 switch (estack_bx_t
) {
898 JUMP_TO(FILTER_OP_NE_S64_DOUBLE
);
900 JUMP_TO(FILTER_OP_NE_DOUBLE
);
901 case REG_STRING
: /* Fall-through */
902 case REG_STAR_GLOB_STRING
:
906 ERR("Unknown filter register type (%d)",
913 switch (estack_bx_t
) {
914 case REG_S64
: /* Fall-through */
919 JUMP_TO(FILTER_OP_NE_STRING
);
920 case REG_STAR_GLOB_STRING
:
921 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
923 ERR("Unknown filter register type (%d)",
929 case REG_STAR_GLOB_STRING
:
930 switch (estack_bx_t
) {
931 case REG_S64
: /* Fall-through */
936 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
937 case REG_STAR_GLOB_STRING
:
941 ERR("Unknown filter register type (%d)",
948 ERR("Unknown filter register type (%d)",
956 /* Dynamic typing. */
957 switch (estack_ax_t
) {
959 switch (estack_bx_t
) {
961 JUMP_TO(FILTER_OP_GT_S64
);
963 JUMP_TO(FILTER_OP_GT_DOUBLE_S64
);
964 case REG_STRING
: /* Fall-through */
965 case REG_STAR_GLOB_STRING
:
969 ERR("Unknown filter register type (%d)",
976 switch (estack_bx_t
) {
978 JUMP_TO(FILTER_OP_GT_S64_DOUBLE
);
980 JUMP_TO(FILTER_OP_GT_DOUBLE
);
981 case REG_STRING
: /* Fall-through */
982 case REG_STAR_GLOB_STRING
:
986 ERR("Unknown filter register type (%d)",
993 switch (estack_bx_t
) {
994 case REG_S64
: /* Fall-through */
995 case REG_DOUBLE
: /* Fall-through */
996 case REG_STAR_GLOB_STRING
:
1000 JUMP_TO(FILTER_OP_GT_STRING
);
1002 ERR("Unknown filter register type (%d)",
1009 ERR("Unknown filter register type (%d)",
1017 /* Dynamic typing. */
1018 switch (estack_ax_t
) {
1020 switch (estack_bx_t
) {
1022 JUMP_TO(FILTER_OP_LT_S64
);
1024 JUMP_TO(FILTER_OP_LT_DOUBLE_S64
);
1025 case REG_STRING
: /* Fall-through */
1026 case REG_STAR_GLOB_STRING
:
1030 ERR("Unknown filter register type (%d)",
1037 switch (estack_bx_t
) {
1039 JUMP_TO(FILTER_OP_LT_S64_DOUBLE
);
1041 JUMP_TO(FILTER_OP_LT_DOUBLE
);
1042 case REG_STRING
: /* Fall-through */
1043 case REG_STAR_GLOB_STRING
:
1047 ERR("Unknown filter register type (%d)",
1054 switch (estack_bx_t
) {
1055 case REG_S64
: /* Fall-through */
1056 case REG_DOUBLE
: /* Fall-through */
1057 case REG_STAR_GLOB_STRING
:
1061 JUMP_TO(FILTER_OP_LT_STRING
);
1063 ERR("Unknown filter register type (%d)",
1070 ERR("Unknown filter register type (%d)",
1078 /* Dynamic typing. */
1079 switch (estack_ax_t
) {
1081 switch (estack_bx_t
) {
1083 JUMP_TO(FILTER_OP_GE_S64
);
1085 JUMP_TO(FILTER_OP_GE_DOUBLE_S64
);
1086 case REG_STRING
: /* Fall-through */
1087 case REG_STAR_GLOB_STRING
:
1091 ERR("Unknown filter register type (%d)",
1098 switch (estack_bx_t
) {
1100 JUMP_TO(FILTER_OP_GE_S64_DOUBLE
);
1102 JUMP_TO(FILTER_OP_GE_DOUBLE
);
1103 case REG_STRING
: /* Fall-through */
1104 case REG_STAR_GLOB_STRING
:
1108 ERR("Unknown filter register type (%d)",
1115 switch (estack_bx_t
) {
1116 case REG_S64
: /* Fall-through */
1117 case REG_DOUBLE
: /* Fall-through */
1118 case REG_STAR_GLOB_STRING
:
1122 JUMP_TO(FILTER_OP_GE_STRING
);
1124 ERR("Unknown filter register type (%d)",
1131 ERR("Unknown filter register type (%d)",
1139 /* Dynamic typing. */
1140 switch (estack_ax_t
) {
1142 switch (estack_bx_t
) {
1144 JUMP_TO(FILTER_OP_LE_S64
);
1146 JUMP_TO(FILTER_OP_LE_DOUBLE_S64
);
1147 case REG_STRING
: /* Fall-through */
1148 case REG_STAR_GLOB_STRING
:
1152 ERR("Unknown filter register type (%d)",
1159 switch (estack_bx_t
) {
1161 JUMP_TO(FILTER_OP_LE_S64_DOUBLE
);
1163 JUMP_TO(FILTER_OP_LE_DOUBLE
);
1164 case REG_STRING
: /* Fall-through */
1165 case REG_STAR_GLOB_STRING
:
1169 ERR("Unknown filter register type (%d)",
1176 switch (estack_bx_t
) {
1177 case REG_S64
: /* Fall-through */
1178 case REG_DOUBLE
: /* Fall-through */
1179 case REG_STAR_GLOB_STRING
:
1183 JUMP_TO(FILTER_OP_LE_STRING
);
1185 ERR("Unknown filter register type (%d)",
1192 ERR("Unknown filter register type (%d)",
1199 OP(FILTER_OP_EQ_STRING
):
1203 res
= (stack_strcmp(stack
, top
, "==") == 0);
1204 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1206 estack_ax_t
= REG_S64
;
1207 next_pc
+= sizeof(struct binary_op
);
1210 OP(FILTER_OP_NE_STRING
):
1214 res
= (stack_strcmp(stack
, top
, "!=") != 0);
1215 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1217 estack_ax_t
= REG_S64
;
1218 next_pc
+= sizeof(struct binary_op
);
1221 OP(FILTER_OP_GT_STRING
):
1225 res
= (stack_strcmp(stack
, top
, ">") > 0);
1226 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1228 estack_ax_t
= REG_S64
;
1229 next_pc
+= sizeof(struct binary_op
);
1232 OP(FILTER_OP_LT_STRING
):
1236 res
= (stack_strcmp(stack
, top
, "<") < 0);
1237 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1239 estack_ax_t
= REG_S64
;
1240 next_pc
+= sizeof(struct binary_op
);
1243 OP(FILTER_OP_GE_STRING
):
1247 res
= (stack_strcmp(stack
, top
, ">=") >= 0);
1248 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1250 estack_ax_t
= REG_S64
;
1251 next_pc
+= sizeof(struct binary_op
);
1254 OP(FILTER_OP_LE_STRING
):
1258 res
= (stack_strcmp(stack
, top
, "<=") <= 0);
1259 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1261 estack_ax_t
= REG_S64
;
1262 next_pc
+= sizeof(struct binary_op
);
1266 OP(FILTER_OP_EQ_STAR_GLOB_STRING
):
1270 res
= (stack_star_glob_match(stack
, top
, "==") == 0);
1271 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1273 estack_ax_t
= REG_S64
;
1274 next_pc
+= sizeof(struct binary_op
);
1277 OP(FILTER_OP_NE_STAR_GLOB_STRING
):
1281 res
= (stack_star_glob_match(stack
, top
, "!=") != 0);
1282 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1284 estack_ax_t
= REG_S64
;
1285 next_pc
+= sizeof(struct binary_op
);
1289 OP(FILTER_OP_EQ_S64
):
1293 res
= (estack_bx_v
== estack_ax_v
);
1294 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1296 estack_ax_t
= REG_S64
;
1297 next_pc
+= sizeof(struct binary_op
);
1300 OP(FILTER_OP_NE_S64
):
1304 res
= (estack_bx_v
!= estack_ax_v
);
1305 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1307 estack_ax_t
= REG_S64
;
1308 next_pc
+= sizeof(struct binary_op
);
1311 OP(FILTER_OP_GT_S64
):
1315 res
= (estack_bx_v
> estack_ax_v
);
1316 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1318 estack_ax_t
= REG_S64
;
1319 next_pc
+= sizeof(struct binary_op
);
1322 OP(FILTER_OP_LT_S64
):
1326 res
= (estack_bx_v
< estack_ax_v
);
1327 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1329 estack_ax_t
= REG_S64
;
1330 next_pc
+= sizeof(struct binary_op
);
1333 OP(FILTER_OP_GE_S64
):
1337 res
= (estack_bx_v
>= estack_ax_v
);
1338 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1340 estack_ax_t
= REG_S64
;
1341 next_pc
+= sizeof(struct binary_op
);
1344 OP(FILTER_OP_LE_S64
):
1348 res
= (estack_bx_v
<= estack_ax_v
);
1349 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1351 estack_ax_t
= REG_S64
;
1352 next_pc
+= sizeof(struct binary_op
);
1356 OP(FILTER_OP_EQ_DOUBLE
):
1360 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax(stack
, top
)->u
.d
);
1361 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1363 estack_ax_t
= REG_S64
;
1364 next_pc
+= sizeof(struct binary_op
);
1367 OP(FILTER_OP_NE_DOUBLE
):
1371 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax(stack
, top
)->u
.d
);
1372 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1374 estack_ax_t
= REG_S64
;
1375 next_pc
+= sizeof(struct binary_op
);
1378 OP(FILTER_OP_GT_DOUBLE
):
1382 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax(stack
, top
)->u
.d
);
1383 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1385 estack_ax_t
= REG_S64
;
1386 next_pc
+= sizeof(struct binary_op
);
1389 OP(FILTER_OP_LT_DOUBLE
):
1393 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax(stack
, top
)->u
.d
);
1394 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1396 estack_ax_t
= REG_S64
;
1397 next_pc
+= sizeof(struct binary_op
);
1400 OP(FILTER_OP_GE_DOUBLE
):
1404 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax(stack
, top
)->u
.d
);
1405 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1407 estack_ax_t
= REG_S64
;
1408 next_pc
+= sizeof(struct binary_op
);
1411 OP(FILTER_OP_LE_DOUBLE
):
1415 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax(stack
, top
)->u
.d
);
1416 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1418 estack_ax_t
= REG_S64
;
1419 next_pc
+= sizeof(struct binary_op
);
1423 /* Mixed S64-double binary comparators */
1424 OP(FILTER_OP_EQ_DOUBLE_S64
):
1428 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax_v
);
1429 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1431 estack_ax_t
= REG_S64
;
1432 next_pc
+= sizeof(struct binary_op
);
1435 OP(FILTER_OP_NE_DOUBLE_S64
):
1439 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax_v
);
1440 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1442 estack_ax_t
= REG_S64
;
1443 next_pc
+= sizeof(struct binary_op
);
1446 OP(FILTER_OP_GT_DOUBLE_S64
):
1450 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax_v
);
1451 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1453 estack_ax_t
= REG_S64
;
1454 next_pc
+= sizeof(struct binary_op
);
1457 OP(FILTER_OP_LT_DOUBLE_S64
):
1461 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax_v
);
1462 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1464 estack_ax_t
= REG_S64
;
1465 next_pc
+= sizeof(struct binary_op
);
1468 OP(FILTER_OP_GE_DOUBLE_S64
):
1472 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax_v
);
1473 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1475 estack_ax_t
= REG_S64
;
1476 next_pc
+= sizeof(struct binary_op
);
1479 OP(FILTER_OP_LE_DOUBLE_S64
):
1483 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax_v
);
1484 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1486 estack_ax_t
= REG_S64
;
1487 next_pc
+= sizeof(struct binary_op
);
1491 OP(FILTER_OP_EQ_S64_DOUBLE
):
1495 res
= (estack_bx_v
== estack_ax(stack
, top
)->u
.d
);
1496 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1498 estack_ax_t
= REG_S64
;
1499 next_pc
+= sizeof(struct binary_op
);
1502 OP(FILTER_OP_NE_S64_DOUBLE
):
1506 res
= (estack_bx_v
!= estack_ax(stack
, top
)->u
.d
);
1507 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1509 estack_ax_t
= REG_S64
;
1510 next_pc
+= sizeof(struct binary_op
);
1513 OP(FILTER_OP_GT_S64_DOUBLE
):
1517 res
= (estack_bx_v
> estack_ax(stack
, top
)->u
.d
);
1518 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1520 estack_ax_t
= REG_S64
;
1521 next_pc
+= sizeof(struct binary_op
);
1524 OP(FILTER_OP_LT_S64_DOUBLE
):
1528 res
= (estack_bx_v
< estack_ax(stack
, top
)->u
.d
);
1529 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1531 estack_ax_t
= REG_S64
;
1532 next_pc
+= sizeof(struct binary_op
);
1535 OP(FILTER_OP_GE_S64_DOUBLE
):
1539 res
= (estack_bx_v
>= estack_ax(stack
, top
)->u
.d
);
1540 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1542 estack_ax_t
= REG_S64
;
1543 next_pc
+= sizeof(struct binary_op
);
1546 OP(FILTER_OP_LE_S64_DOUBLE
):
1550 res
= (estack_bx_v
<= estack_ax(stack
, top
)->u
.d
);
1551 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1553 estack_ax_t
= REG_S64
;
1554 next_pc
+= sizeof(struct binary_op
);
1557 OP(FILTER_OP_BIT_RSHIFT
):
1561 /* Dynamic typing. */
1562 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1566 /* Catch undefined behavior. */
1567 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1571 res
= ((uint64_t) estack_bx_v
>> (uint32_t) estack_ax_v
);
1572 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1574 estack_ax_t
= REG_S64
;
1575 next_pc
+= sizeof(struct binary_op
);
1578 OP(FILTER_OP_BIT_LSHIFT
):
1582 /* Dynamic typing. */
1583 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1587 /* Catch undefined behavior. */
1588 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1592 res
= ((uint64_t) estack_bx_v
<< (uint32_t) estack_ax_v
);
1593 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1595 estack_ax_t
= REG_S64
;
1596 next_pc
+= sizeof(struct binary_op
);
1599 OP(FILTER_OP_BIT_AND
):
1603 /* Dynamic typing. */
1604 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1609 res
= ((uint64_t) estack_bx_v
& (uint64_t) estack_ax_v
);
1610 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1612 estack_ax_t
= REG_S64
;
1613 next_pc
+= sizeof(struct binary_op
);
1616 OP(FILTER_OP_BIT_OR
):
1620 /* Dynamic typing. */
1621 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1626 res
= ((uint64_t) estack_bx_v
| (uint64_t) estack_ax_v
);
1627 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1629 estack_ax_t
= REG_S64
;
1630 next_pc
+= sizeof(struct binary_op
);
1633 OP(FILTER_OP_BIT_XOR
):
1637 /* Dynamic typing. */
1638 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1643 res
= ((uint64_t) estack_bx_v
^ (uint64_t) estack_ax_v
);
1644 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1646 estack_ax_t
= REG_S64
;
1647 next_pc
+= sizeof(struct binary_op
);
1652 OP(FILTER_OP_UNARY_PLUS
):
1654 /* Dynamic typing. */
1655 switch (estack_ax_t
) {
1656 case REG_S64
: /* Fall-through. */
1657 JUMP_TO(FILTER_OP_UNARY_PLUS_S64
);
1659 JUMP_TO(FILTER_OP_UNARY_PLUS_DOUBLE
);
1660 case REG_STRING
: /* Fall-through */
1661 case REG_STAR_GLOB_STRING
:
1665 ERR("Unknown filter register type (%d)",
1671 OP(FILTER_OP_UNARY_MINUS
):
1673 /* Dynamic typing. */
1674 switch (estack_ax_t
) {
1676 JUMP_TO(FILTER_OP_UNARY_MINUS_S64
);
1678 JUMP_TO(FILTER_OP_UNARY_MINUS_DOUBLE
);
1679 case REG_STRING
: /* Fall-through */
1680 case REG_STAR_GLOB_STRING
:
1684 ERR("Unknown filter register type (%d)",
1690 OP(FILTER_OP_UNARY_NOT
):
1692 /* Dynamic typing. */
1693 switch (estack_ax_t
) {
1695 JUMP_TO(FILTER_OP_UNARY_NOT_S64
);
1697 JUMP_TO(FILTER_OP_UNARY_NOT_DOUBLE
);
1698 case REG_STRING
: /* Fall-through */
1699 case REG_STAR_GLOB_STRING
:
1703 ERR("Unknown filter register type (%d)",
1708 next_pc
+= sizeof(struct unary_op
);
1712 OP(FILTER_OP_UNARY_BIT_NOT
):
1714 /* Dynamic typing. */
1715 if (estack_ax_t
!= REG_S64
) {
1720 estack_ax_v
= ~(uint64_t) estack_ax_v
;
1721 next_pc
+= sizeof(struct unary_op
);
1725 OP(FILTER_OP_UNARY_PLUS_S64
):
1726 OP(FILTER_OP_UNARY_PLUS_DOUBLE
):
1728 next_pc
+= sizeof(struct unary_op
);
1731 OP(FILTER_OP_UNARY_MINUS_S64
):
1733 estack_ax_v
= -estack_ax_v
;
1734 next_pc
+= sizeof(struct unary_op
);
1737 OP(FILTER_OP_UNARY_MINUS_DOUBLE
):
1739 estack_ax(stack
, top
)->u
.d
= -estack_ax(stack
, top
)->u
.d
;
1740 next_pc
+= sizeof(struct unary_op
);
1743 OP(FILTER_OP_UNARY_NOT_S64
):
1745 estack_ax_v
= !estack_ax_v
;
1746 next_pc
+= sizeof(struct unary_op
);
1749 OP(FILTER_OP_UNARY_NOT_DOUBLE
):
1751 estack_ax_v
= !estack_ax(stack
, top
)->u
.d
;
1752 estack_ax_t
= REG_S64
;
1753 next_pc
+= sizeof(struct unary_op
);
1760 struct logical_op
*insn
= (struct logical_op
*) pc
;
1762 if (estack_ax_t
!= REG_S64
) {
1766 /* If AX is 0, skip and evaluate to 0 */
1767 if (unlikely(estack_ax_v
== 0)) {
1768 dbg_printf("Jumping to bytecode offset %u\n",
1769 (unsigned int) insn
->skip_offset
);
1770 next_pc
= start_pc
+ insn
->skip_offset
;
1772 /* Pop 1 when jump not taken */
1773 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1774 next_pc
+= sizeof(struct logical_op
);
1780 struct logical_op
*insn
= (struct logical_op
*) pc
;
1782 if (estack_ax_t
!= REG_S64
) {
1786 /* If AX is nonzero, skip and evaluate to 1 */
1787 if (unlikely(estack_ax_v
!= 0)) {
1789 dbg_printf("Jumping to bytecode offset %u\n",
1790 (unsigned int) insn
->skip_offset
);
1791 next_pc
= start_pc
+ insn
->skip_offset
;
1793 /* Pop 1 when jump not taken */
1794 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1795 next_pc
+= sizeof(struct logical_op
);
1801 /* load field ref */
1802 OP(FILTER_OP_LOAD_FIELD_REF_STRING
):
1804 struct load_op
*insn
= (struct load_op
*) pc
;
1805 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1807 dbg_printf("load field ref offset %u type string\n",
1809 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1810 estack_ax(stack
, top
)->u
.s
.str
=
1811 *(const char * const *) &filter_stack_data
[ref
->offset
];
1812 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1813 dbg_printf("Filter warning: loading a NULL string.\n");
1817 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1818 estack_ax(stack
, top
)->u
.s
.literal_type
=
1819 ESTACK_STRING_LITERAL_TYPE_NONE
;
1820 estack_ax_t
= REG_STRING
;
1821 dbg_printf("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1822 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1826 OP(FILTER_OP_LOAD_FIELD_REF_SEQUENCE
):
1828 struct load_op
*insn
= (struct load_op
*) pc
;
1829 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1831 dbg_printf("load field ref offset %u type sequence\n",
1833 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1834 estack_ax(stack
, top
)->u
.s
.seq_len
=
1835 *(unsigned long *) &filter_stack_data
[ref
->offset
];
1836 estack_ax(stack
, top
)->u
.s
.str
=
1837 *(const char **) (&filter_stack_data
[ref
->offset
1838 + sizeof(unsigned long)]);
1839 estack_ax_t
= REG_STRING
;
1840 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1841 dbg_printf("Filter warning: loading a NULL sequence.\n");
1845 estack_ax(stack
, top
)->u
.s
.literal_type
=
1846 ESTACK_STRING_LITERAL_TYPE_NONE
;
1847 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1851 OP(FILTER_OP_LOAD_FIELD_REF_S64
):
1853 struct load_op
*insn
= (struct load_op
*) pc
;
1854 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1856 dbg_printf("load field ref offset %u type s64\n",
1858 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1860 ((struct literal_numeric
*) &filter_stack_data
[ref
->offset
])->v
;
1861 estack_ax_t
= REG_S64
;
1862 dbg_printf("ref load s64 %" PRIi64
"\n", estack_ax_v
);
1863 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1867 OP(FILTER_OP_LOAD_FIELD_REF_DOUBLE
):
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 double\n",
1874 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1875 memcpy(&estack_ax(stack
, top
)->u
.d
, &filter_stack_data
[ref
->offset
],
1876 sizeof(struct literal_double
));
1877 estack_ax_t
= REG_DOUBLE
;
1878 dbg_printf("ref load double %g\n", estack_ax(stack
, top
)->u
.d
);
1879 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1883 /* load from immediate operand */
1884 OP(FILTER_OP_LOAD_STRING
):
1886 struct load_op
*insn
= (struct load_op
*) pc
;
1888 dbg_printf("load string %s\n", insn
->data
);
1889 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1890 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1891 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1892 estack_ax(stack
, top
)->u
.s
.literal_type
=
1893 ESTACK_STRING_LITERAL_TYPE_PLAIN
;
1894 estack_ax_t
= REG_STRING
;
1895 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1899 OP(FILTER_OP_LOAD_STAR_GLOB_STRING
):
1901 struct load_op
*insn
= (struct load_op
*) pc
;
1903 dbg_printf("load globbing pattern %s\n", insn
->data
);
1904 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1905 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1906 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1907 estack_ax(stack
, top
)->u
.s
.literal_type
=
1908 ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
;
1909 estack_ax_t
= REG_STAR_GLOB_STRING
;
1910 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1914 OP(FILTER_OP_LOAD_S64
):
1916 struct load_op
*insn
= (struct load_op
*) pc
;
1918 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1919 estack_ax_v
= ((struct literal_numeric
*) insn
->data
)->v
;
1920 estack_ax_t
= REG_S64
;
1921 dbg_printf("load s64 %" PRIi64
"\n", estack_ax_v
);
1922 next_pc
+= sizeof(struct load_op
)
1923 + sizeof(struct literal_numeric
);
1927 OP(FILTER_OP_LOAD_DOUBLE
):
1929 struct load_op
*insn
= (struct load_op
*) pc
;
1931 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1932 memcpy(&estack_ax(stack
, top
)->u
.d
, insn
->data
,
1933 sizeof(struct literal_double
));
1934 estack_ax_t
= REG_DOUBLE
;
1935 dbg_printf("load double %g\n", estack_ax(stack
, top
)->u
.d
);
1936 next_pc
+= sizeof(struct load_op
)
1937 + sizeof(struct literal_double
);
1942 OP(FILTER_OP_CAST_TO_S64
):
1944 /* Dynamic typing. */
1945 switch (estack_ax_t
) {
1947 JUMP_TO(FILTER_OP_CAST_NOP
);
1949 JUMP_TO(FILTER_OP_CAST_DOUBLE_TO_S64
);
1950 case REG_STRING
: /* Fall-through */
1951 case REG_STAR_GLOB_STRING
:
1955 ERR("Unknown filter register type (%d)",
1962 OP(FILTER_OP_CAST_DOUBLE_TO_S64
):
1964 estack_ax_v
= (int64_t) estack_ax(stack
, top
)->u
.d
;
1965 estack_ax_t
= REG_S64
;
1966 next_pc
+= sizeof(struct cast_op
);
1970 OP(FILTER_OP_CAST_NOP
):
1972 next_pc
+= sizeof(struct cast_op
);
1976 /* get context ref */
1977 OP(FILTER_OP_GET_CONTEXT_REF
):
1979 struct load_op
*insn
= (struct load_op
*) pc
;
1980 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1981 struct lttng_ctx_field
*ctx_field
;
1982 struct lttng_ctx_value v
;
1984 dbg_printf("get context ref offset %u type dynamic\n",
1986 ctx_field
= &ctx
->fields
[ref
->offset
];
1987 ctx_field
->get_value(ctx_field
, &v
);
1988 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1990 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
1993 case LTTNG_UST_DYNAMIC_TYPE_S64
:
1994 estack_ax_v
= v
.u
.s64
;
1995 estack_ax_t
= REG_S64
;
1996 dbg_printf("ref get context dynamic s64 %" PRIi64
"\n", estack_ax_v
);
1998 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
1999 estack_ax(stack
, top
)->u
.d
= v
.u
.d
;
2000 estack_ax_t
= REG_DOUBLE
;
2001 dbg_printf("ref get context dynamic double %g\n", estack_ax(stack
, top
)->u
.d
);
2003 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
2004 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2005 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2006 dbg_printf("Filter warning: loading a NULL string.\n");
2010 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2011 estack_ax(stack
, top
)->u
.s
.literal_type
=
2012 ESTACK_STRING_LITERAL_TYPE_NONE
;
2013 dbg_printf("ref get context dynamic string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2014 estack_ax_t
= REG_STRING
;
2017 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
2021 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2025 OP(FILTER_OP_GET_CONTEXT_REF_STRING
):
2027 struct load_op
*insn
= (struct load_op
*) pc
;
2028 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2029 struct lttng_ctx_field
*ctx_field
;
2030 struct lttng_ctx_value v
;
2032 dbg_printf("get context ref offset %u type string\n",
2034 ctx_field
= &ctx
->fields
[ref
->offset
];
2035 ctx_field
->get_value(ctx_field
, &v
);
2036 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2037 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2038 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2039 dbg_printf("Filter warning: loading a NULL string.\n");
2043 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2044 estack_ax(stack
, top
)->u
.s
.literal_type
=
2045 ESTACK_STRING_LITERAL_TYPE_NONE
;
2046 estack_ax_t
= REG_STRING
;
2047 dbg_printf("ref get context string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2048 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2052 OP(FILTER_OP_GET_CONTEXT_REF_S64
):
2054 struct load_op
*insn
= (struct load_op
*) pc
;
2055 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2056 struct lttng_ctx_field
*ctx_field
;
2057 struct lttng_ctx_value v
;
2059 dbg_printf("get context ref offset %u type s64\n",
2061 ctx_field
= &ctx
->fields
[ref
->offset
];
2062 ctx_field
->get_value(ctx_field
, &v
);
2063 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2064 estack_ax_v
= v
.u
.s64
;
2065 estack_ax_t
= REG_S64
;
2066 dbg_printf("ref get context s64 %" PRIi64
"\n", estack_ax_v
);
2067 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2071 OP(FILTER_OP_GET_CONTEXT_REF_DOUBLE
):
2073 struct load_op
*insn
= (struct load_op
*) pc
;
2074 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2075 struct lttng_ctx_field
*ctx_field
;
2076 struct lttng_ctx_value v
;
2078 dbg_printf("get context ref offset %u type double\n",
2080 ctx_field
= &ctx
->fields
[ref
->offset
];
2081 ctx_field
->get_value(ctx_field
, &v
);
2082 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2083 memcpy(&estack_ax(stack
, top
)->u
.d
, &v
.u
.d
, sizeof(struct literal_double
));
2084 estack_ax_t
= REG_DOUBLE
;
2085 dbg_printf("ref get context double %g\n", estack_ax(stack
, top
)->u
.d
);
2086 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2090 OP(FILTER_OP_GET_CONTEXT_ROOT
):
2092 dbg_printf("op get context root\n");
2093 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2094 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_CONTEXT
;
2095 /* "field" only needed for variants. */
2096 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2097 estack_ax_t
= REG_PTR
;
2098 next_pc
+= sizeof(struct load_op
);
2102 OP(FILTER_OP_GET_APP_CONTEXT_ROOT
):
2104 dbg_printf("op get app context root\n");
2105 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2106 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_APP_CONTEXT
;
2107 /* "field" only needed for variants. */
2108 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2109 estack_ax_t
= REG_PTR
;
2110 next_pc
+= sizeof(struct load_op
);
2114 OP(FILTER_OP_GET_PAYLOAD_ROOT
):
2116 dbg_printf("op get app payload root\n");
2117 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2118 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_PAYLOAD
;
2119 estack_ax(stack
, top
)->u
.ptr
.ptr
= filter_stack_data
;
2120 /* "field" only needed for variants. */
2121 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2122 estack_ax_t
= REG_PTR
;
2123 next_pc
+= sizeof(struct load_op
);
2127 OP(FILTER_OP_GET_SYMBOL
):
2129 dbg_printf("op get symbol\n");
2130 switch (estack_ax(stack
, top
)->u
.ptr
.type
) {
2132 ERR("Nested fields not implemented yet.");
2135 case LOAD_ROOT_CONTEXT
:
2136 case LOAD_ROOT_APP_CONTEXT
:
2137 case LOAD_ROOT_PAYLOAD
:
2139 * symbol lookup is performed by
2145 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_symbol
);
2149 OP(FILTER_OP_GET_SYMBOL_FIELD
):
2152 * Used for first variant encountered in a
2153 * traversal. Variants are not implemented yet.
2159 OP(FILTER_OP_GET_INDEX_U16
):
2161 struct load_op
*insn
= (struct load_op
*) pc
;
2162 struct get_index_u16
*index
= (struct get_index_u16
*) insn
->data
;
2164 dbg_printf("op get index u16\n");
2165 ret
= dynamic_get_index(ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
2168 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2169 estack_ax_t
= estack_ax(stack
, top
)->type
;
2170 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u16
);
2174 OP(FILTER_OP_GET_INDEX_U64
):
2176 struct load_op
*insn
= (struct load_op
*) pc
;
2177 struct get_index_u64
*index
= (struct get_index_u64
*) insn
->data
;
2179 dbg_printf("op get index u64\n");
2180 ret
= dynamic_get_index(ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
2183 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2184 estack_ax_t
= estack_ax(stack
, top
)->type
;
2185 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u64
);
2189 OP(FILTER_OP_LOAD_FIELD
):
2191 dbg_printf("op load field\n");
2192 ret
= dynamic_load_field(estack_ax(stack
, top
));
2195 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2196 estack_ax_t
= estack_ax(stack
, top
)->type
;
2197 next_pc
+= sizeof(struct load_op
);
2201 OP(FILTER_OP_LOAD_FIELD_S8
):
2203 dbg_printf("op load field s8\n");
2205 estack_ax_v
= *(int8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2206 estack_ax_t
= REG_S64
;
2207 next_pc
+= sizeof(struct load_op
);
2210 OP(FILTER_OP_LOAD_FIELD_S16
):
2212 dbg_printf("op load field s16\n");
2214 estack_ax_v
= *(int16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2215 estack_ax_t
= REG_S64
;
2216 next_pc
+= sizeof(struct load_op
);
2219 OP(FILTER_OP_LOAD_FIELD_S32
):
2221 dbg_printf("op load field s32\n");
2223 estack_ax_v
= *(int32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2224 estack_ax_t
= REG_S64
;
2225 next_pc
+= sizeof(struct load_op
);
2228 OP(FILTER_OP_LOAD_FIELD_S64
):
2230 dbg_printf("op load field s64\n");
2232 estack_ax_v
= *(int64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2233 estack_ax_t
= REG_S64
;
2234 next_pc
+= sizeof(struct load_op
);
2237 OP(FILTER_OP_LOAD_FIELD_U8
):
2239 dbg_printf("op load field u8\n");
2241 estack_ax_v
= *(uint8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2242 estack_ax_t
= REG_S64
;
2243 next_pc
+= sizeof(struct load_op
);
2246 OP(FILTER_OP_LOAD_FIELD_U16
):
2248 dbg_printf("op load field u16\n");
2250 estack_ax_v
= *(uint16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2251 estack_ax_t
= REG_S64
;
2252 next_pc
+= sizeof(struct load_op
);
2255 OP(FILTER_OP_LOAD_FIELD_U32
):
2257 dbg_printf("op load field u32\n");
2259 estack_ax_v
= *(uint32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2260 estack_ax_t
= REG_S64
;
2261 next_pc
+= sizeof(struct load_op
);
2264 OP(FILTER_OP_LOAD_FIELD_U64
):
2266 dbg_printf("op load field u64\n");
2268 estack_ax_v
= *(uint64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2269 estack_ax_t
= REG_S64
;
2270 next_pc
+= sizeof(struct load_op
);
2273 OP(FILTER_OP_LOAD_FIELD_DOUBLE
):
2275 dbg_printf("op load field double\n");
2277 memcpy(&estack_ax(stack
, top
)->u
.d
,
2278 estack_ax(stack
, top
)->u
.ptr
.ptr
,
2279 sizeof(struct literal_double
));
2280 estack_ax(stack
, top
)->type
= REG_DOUBLE
;
2281 next_pc
+= sizeof(struct load_op
);
2285 OP(FILTER_OP_LOAD_FIELD_STRING
):
2289 dbg_printf("op load field string\n");
2290 str
= (const char *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2291 estack_ax(stack
, top
)->u
.s
.str
= str
;
2292 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2293 dbg_printf("Filter warning: loading a NULL string.\n");
2297 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2298 estack_ax(stack
, top
)->u
.s
.literal_type
=
2299 ESTACK_STRING_LITERAL_TYPE_NONE
;
2300 estack_ax(stack
, top
)->type
= REG_STRING
;
2301 next_pc
+= sizeof(struct load_op
);
2305 OP(FILTER_OP_LOAD_FIELD_SEQUENCE
):
2309 dbg_printf("op load field string sequence\n");
2310 ptr
= estack_ax(stack
, top
)->u
.ptr
.ptr
;
2311 estack_ax(stack
, top
)->u
.s
.seq_len
= *(unsigned long *) ptr
;
2312 estack_ax(stack
, top
)->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
2313 estack_ax(stack
, top
)->type
= REG_STRING
;
2314 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2315 dbg_printf("Filter warning: loading a NULL sequence.\n");
2319 estack_ax(stack
, top
)->u
.s
.literal_type
=
2320 ESTACK_STRING_LITERAL_TYPE_NONE
;
2321 next_pc
+= sizeof(struct load_op
);
2327 /* return 0 (discard) on error */