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->data[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
;
252 const struct lttng_integer_type
*itype
=
253 &field
->type
.u
.basic
.enumeration
.container_type
;
255 ctx_field
->get_value(ctx_field
, &v
);
256 if (itype
->signedness
) {
257 ptr
->object_type
= OBJECT_TYPE_S64
;
258 ptr
->u
.s64
= v
.u
.s64
;
259 ptr
->ptr
= &ptr
->u
.s64
;
261 ptr
->object_type
= OBJECT_TYPE_U64
;
262 ptr
->u
.u64
= v
.u
.s64
; /* Cast. */
263 ptr
->ptr
= &ptr
->u
.u64
;
268 if (field
->type
.u
.array
.elem_type
.atype
!= atype_integer
) {
269 ERR("Array nesting only supports integer types.");
272 if (field
->type
.u
.array
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
273 ERR("Only string arrays are supported for contexts.");
276 ptr
->object_type
= OBJECT_TYPE_STRING
;
277 ctx_field
->get_value(ctx_field
, &v
);
281 if (field
->type
.u
.sequence
.elem_type
.atype
!= atype_integer
) {
282 ERR("Sequence nesting only supports integer types.");
285 if (field
->type
.u
.sequence
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
286 ERR("Only string sequences are supported for contexts.");
289 ptr
->object_type
= OBJECT_TYPE_STRING
;
290 ctx_field
->get_value(ctx_field
, &v
);
294 ptr
->object_type
= OBJECT_TYPE_STRING
;
295 ctx_field
->get_value(ctx_field
, &v
);
299 ptr
->object_type
= OBJECT_TYPE_DOUBLE
;
301 ptr
->ptr
= &ptr
->u
.d
;
304 ctx_field
->get_value(ctx_field
, &v
);
306 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
308 case LTTNG_UST_DYNAMIC_TYPE_S64
:
309 ptr
->object_type
= OBJECT_TYPE_S64
;
310 ptr
->u
.s64
= v
.u
.s64
;
311 ptr
->ptr
= &ptr
->u
.s64
;
312 dbg_printf("context get index dynamic s64 %" PRIi64
"\n", ptr
->u
.s64
);
314 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
315 ptr
->object_type
= OBJECT_TYPE_DOUBLE
;
317 ptr
->ptr
= &ptr
->u
.d
;
318 dbg_printf("context get index dynamic double %g\n", ptr
->u
.d
);
320 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
321 ptr
->object_type
= OBJECT_TYPE_STRING
;
323 dbg_printf("context get index dynamic string %s\n", (const char *) ptr
->ptr
);
326 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
331 ERR("Structure type cannot be loaded.");
334 ERR("Unknown type: %d", (int) field
->type
.atype
);
340 static int dynamic_get_index(struct lttng_session
*session
,
341 struct bytecode_runtime
*runtime
,
342 uint64_t index
, struct estack_entry
*stack_top
)
345 const struct filter_get_index_data
*gid
;
348 * Types nested within variants need to perform dynamic lookup
349 * based on the field descriptions. LTTng-UST does not implement
352 if (stack_top
->u
.ptr
.field
)
354 gid
= (const struct filter_get_index_data
*) &runtime
->data
[index
];
355 switch (stack_top
->u
.ptr
.type
) {
357 switch (stack_top
->u
.ptr
.object_type
) {
358 case OBJECT_TYPE_ARRAY
:
362 assert(gid
->offset
< gid
->array_len
);
363 /* Skip count (unsigned long) */
364 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
365 ptr
= ptr
+ gid
->offset
;
366 stack_top
->u
.ptr
.ptr
= ptr
;
367 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
368 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
369 /* field is only used for types nested within variants. */
370 stack_top
->u
.ptr
.field
= NULL
;
373 case OBJECT_TYPE_SEQUENCE
:
378 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
379 ptr_seq_len
= *(unsigned long *) stack_top
->u
.ptr
.ptr
;
380 if (gid
->offset
>= gid
->elem
.len
* ptr_seq_len
) {
384 ptr
= ptr
+ gid
->offset
;
385 stack_top
->u
.ptr
.ptr
= ptr
;
386 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
387 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
388 /* field is only used for types nested within variants. */
389 stack_top
->u
.ptr
.field
= NULL
;
392 case OBJECT_TYPE_STRUCT
:
393 ERR("Nested structures are not supported yet.");
396 case OBJECT_TYPE_VARIANT
:
398 ERR("Unexpected get index type %d",
399 (int) stack_top
->u
.ptr
.object_type
);
404 case LOAD_ROOT_CONTEXT
:
405 case LOAD_ROOT_APP_CONTEXT
: /* Fall-through */
407 struct lttng_ctx
*ctx
;
409 ctx
= rcu_dereference(session
->ctx
);
410 ret
= context_get_index(ctx
,
418 case LOAD_ROOT_PAYLOAD
:
419 stack_top
->u
.ptr
.ptr
+= gid
->offset
;
420 if (gid
->elem
.type
== OBJECT_TYPE_STRING
)
421 stack_top
->u
.ptr
.ptr
= *(const char * const *) stack_top
->u
.ptr
.ptr
;
422 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
423 stack_top
->u
.ptr
.type
= LOAD_OBJECT
;
424 /* field is only used for types nested within variants. */
425 stack_top
->u
.ptr
.field
= NULL
;
434 static int dynamic_load_field(struct estack_entry
*stack_top
)
438 switch (stack_top
->u
.ptr
.type
) {
441 case LOAD_ROOT_CONTEXT
:
442 case LOAD_ROOT_APP_CONTEXT
:
443 case LOAD_ROOT_PAYLOAD
:
445 dbg_printf("Filter warning: cannot load root, missing field name.\n");
449 switch (stack_top
->u
.ptr
.object_type
) {
451 dbg_printf("op load field s8\n");
452 stack_top
->u
.v
= *(int8_t *) stack_top
->u
.ptr
.ptr
;
453 stack_top
->type
= REG_S64
;
455 case OBJECT_TYPE_S16
:
459 dbg_printf("op load field s16\n");
460 tmp
= *(int16_t *) stack_top
->u
.ptr
.ptr
;
461 if (stack_top
->u
.ptr
.rev_bo
)
463 stack_top
->u
.v
= tmp
;
464 stack_top
->type
= REG_S64
;
467 case OBJECT_TYPE_S32
:
471 dbg_printf("op load field s32\n");
472 tmp
= *(int32_t *) stack_top
->u
.ptr
.ptr
;
473 if (stack_top
->u
.ptr
.rev_bo
)
475 stack_top
->u
.v
= tmp
;
476 stack_top
->type
= REG_S64
;
479 case OBJECT_TYPE_S64
:
483 dbg_printf("op load field s64\n");
484 tmp
= *(int64_t *) stack_top
->u
.ptr
.ptr
;
485 if (stack_top
->u
.ptr
.rev_bo
)
487 stack_top
->u
.v
= tmp
;
488 stack_top
->type
= REG_S64
;
492 dbg_printf("op load field u8\n");
493 stack_top
->u
.v
= *(uint8_t *) stack_top
->u
.ptr
.ptr
;
494 stack_top
->type
= REG_S64
;
496 case OBJECT_TYPE_U16
:
500 dbg_printf("op load field s16\n");
501 tmp
= *(uint16_t *) stack_top
->u
.ptr
.ptr
;
502 if (stack_top
->u
.ptr
.rev_bo
)
504 stack_top
->u
.v
= tmp
;
505 stack_top
->type
= REG_S64
;
508 case OBJECT_TYPE_U32
:
512 dbg_printf("op load field u32\n");
513 tmp
= *(uint32_t *) stack_top
->u
.ptr
.ptr
;
514 if (stack_top
->u
.ptr
.rev_bo
)
516 stack_top
->u
.v
= tmp
;
517 stack_top
->type
= REG_S64
;
520 case OBJECT_TYPE_U64
:
524 dbg_printf("op load field u64\n");
525 tmp
= *(uint64_t *) stack_top
->u
.ptr
.ptr
;
526 if (stack_top
->u
.ptr
.rev_bo
)
528 stack_top
->u
.v
= tmp
;
529 stack_top
->type
= REG_S64
;
532 case OBJECT_TYPE_DOUBLE
:
533 memcpy(&stack_top
->u
.d
,
534 stack_top
->u
.ptr
.ptr
,
535 sizeof(struct literal_double
));
536 stack_top
->type
= REG_DOUBLE
;
538 case OBJECT_TYPE_STRING
:
542 dbg_printf("op load field string\n");
543 str
= (const char *) stack_top
->u
.ptr
.ptr
;
544 stack_top
->u
.s
.str
= str
;
545 if (unlikely(!stack_top
->u
.s
.str
)) {
546 dbg_printf("Filter warning: loading a NULL string.\n");
550 stack_top
->u
.s
.seq_len
= SIZE_MAX
;
551 stack_top
->u
.s
.literal_type
=
552 ESTACK_STRING_LITERAL_TYPE_NONE
;
553 stack_top
->type
= REG_STRING
;
556 case OBJECT_TYPE_STRING_SEQUENCE
:
560 dbg_printf("op load field string sequence\n");
561 ptr
= stack_top
->u
.ptr
.ptr
;
562 stack_top
->u
.s
.seq_len
= *(unsigned long *) ptr
;
563 stack_top
->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
564 stack_top
->type
= REG_STRING
;
565 if (unlikely(!stack_top
->u
.s
.str
)) {
566 dbg_printf("Filter warning: loading a NULL sequence.\n");
570 stack_top
->u
.s
.literal_type
=
571 ESTACK_STRING_LITERAL_TYPE_NONE
;
574 case OBJECT_TYPE_DYNAMIC
:
576 * Dynamic types in context are looked up
577 * by context get index.
581 case OBJECT_TYPE_SEQUENCE
:
582 case OBJECT_TYPE_ARRAY
:
583 case OBJECT_TYPE_STRUCT
:
584 case OBJECT_TYPE_VARIANT
:
585 ERR("Sequences, arrays, struct and variant cannot be loaded (nested types).");
596 * Return 0 (discard), or raise the 0x1 flag (log event).
597 * Currently, other flags are kept for future extensions and have no
600 uint64_t lttng_filter_interpret_bytecode(void *filter_data
,
601 const char *filter_stack_data
)
603 struct bytecode_runtime
*bytecode
= filter_data
;
604 struct lttng_session
*session
= bytecode
->p
.session
;
605 void *pc
, *next_pc
, *start_pc
;
608 struct estack _stack
;
609 struct estack
*stack
= &_stack
;
610 register int64_t ax
= 0, bx
= 0;
611 register enum entry_type ax_t
= REG_UNKNOWN
, bx_t
= REG_UNKNOWN
;
612 register int top
= FILTER_STACK_EMPTY
;
613 #ifndef INTERPRETER_USE_SWITCH
614 static void *dispatch
[NR_FILTER_OPS
] = {
615 [ FILTER_OP_UNKNOWN
] = &&LABEL_FILTER_OP_UNKNOWN
,
617 [ FILTER_OP_RETURN
] = &&LABEL_FILTER_OP_RETURN
,
620 [ FILTER_OP_MUL
] = &&LABEL_FILTER_OP_MUL
,
621 [ FILTER_OP_DIV
] = &&LABEL_FILTER_OP_DIV
,
622 [ FILTER_OP_MOD
] = &&LABEL_FILTER_OP_MOD
,
623 [ FILTER_OP_PLUS
] = &&LABEL_FILTER_OP_PLUS
,
624 [ FILTER_OP_MINUS
] = &&LABEL_FILTER_OP_MINUS
,
625 [ FILTER_OP_BIT_RSHIFT
] = &&LABEL_FILTER_OP_BIT_RSHIFT
,
626 [ FILTER_OP_BIT_LSHIFT
] = &&LABEL_FILTER_OP_BIT_LSHIFT
,
627 [ FILTER_OP_BIT_AND
] = &&LABEL_FILTER_OP_BIT_AND
,
628 [ FILTER_OP_BIT_OR
] = &&LABEL_FILTER_OP_BIT_OR
,
629 [ FILTER_OP_BIT_XOR
] = &&LABEL_FILTER_OP_BIT_XOR
,
631 /* binary comparators */
632 [ FILTER_OP_EQ
] = &&LABEL_FILTER_OP_EQ
,
633 [ FILTER_OP_NE
] = &&LABEL_FILTER_OP_NE
,
634 [ FILTER_OP_GT
] = &&LABEL_FILTER_OP_GT
,
635 [ FILTER_OP_LT
] = &&LABEL_FILTER_OP_LT
,
636 [ FILTER_OP_GE
] = &&LABEL_FILTER_OP_GE
,
637 [ FILTER_OP_LE
] = &&LABEL_FILTER_OP_LE
,
639 /* string binary comparator */
640 [ FILTER_OP_EQ_STRING
] = &&LABEL_FILTER_OP_EQ_STRING
,
641 [ FILTER_OP_NE_STRING
] = &&LABEL_FILTER_OP_NE_STRING
,
642 [ FILTER_OP_GT_STRING
] = &&LABEL_FILTER_OP_GT_STRING
,
643 [ FILTER_OP_LT_STRING
] = &&LABEL_FILTER_OP_LT_STRING
,
644 [ FILTER_OP_GE_STRING
] = &&LABEL_FILTER_OP_GE_STRING
,
645 [ FILTER_OP_LE_STRING
] = &&LABEL_FILTER_OP_LE_STRING
,
647 /* globbing pattern binary comparator */
648 [ FILTER_OP_EQ_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_EQ_STAR_GLOB_STRING
,
649 [ FILTER_OP_NE_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_NE_STAR_GLOB_STRING
,
651 /* s64 binary comparator */
652 [ FILTER_OP_EQ_S64
] = &&LABEL_FILTER_OP_EQ_S64
,
653 [ FILTER_OP_NE_S64
] = &&LABEL_FILTER_OP_NE_S64
,
654 [ FILTER_OP_GT_S64
] = &&LABEL_FILTER_OP_GT_S64
,
655 [ FILTER_OP_LT_S64
] = &&LABEL_FILTER_OP_LT_S64
,
656 [ FILTER_OP_GE_S64
] = &&LABEL_FILTER_OP_GE_S64
,
657 [ FILTER_OP_LE_S64
] = &&LABEL_FILTER_OP_LE_S64
,
659 /* double binary comparator */
660 [ FILTER_OP_EQ_DOUBLE
] = &&LABEL_FILTER_OP_EQ_DOUBLE
,
661 [ FILTER_OP_NE_DOUBLE
] = &&LABEL_FILTER_OP_NE_DOUBLE
,
662 [ FILTER_OP_GT_DOUBLE
] = &&LABEL_FILTER_OP_GT_DOUBLE
,
663 [ FILTER_OP_LT_DOUBLE
] = &&LABEL_FILTER_OP_LT_DOUBLE
,
664 [ FILTER_OP_GE_DOUBLE
] = &&LABEL_FILTER_OP_GE_DOUBLE
,
665 [ FILTER_OP_LE_DOUBLE
] = &&LABEL_FILTER_OP_LE_DOUBLE
,
667 /* Mixed S64-double binary comparators */
668 [ FILTER_OP_EQ_DOUBLE_S64
] = &&LABEL_FILTER_OP_EQ_DOUBLE_S64
,
669 [ FILTER_OP_NE_DOUBLE_S64
] = &&LABEL_FILTER_OP_NE_DOUBLE_S64
,
670 [ FILTER_OP_GT_DOUBLE_S64
] = &&LABEL_FILTER_OP_GT_DOUBLE_S64
,
671 [ FILTER_OP_LT_DOUBLE_S64
] = &&LABEL_FILTER_OP_LT_DOUBLE_S64
,
672 [ FILTER_OP_GE_DOUBLE_S64
] = &&LABEL_FILTER_OP_GE_DOUBLE_S64
,
673 [ FILTER_OP_LE_DOUBLE_S64
] = &&LABEL_FILTER_OP_LE_DOUBLE_S64
,
675 [ FILTER_OP_EQ_S64_DOUBLE
] = &&LABEL_FILTER_OP_EQ_S64_DOUBLE
,
676 [ FILTER_OP_NE_S64_DOUBLE
] = &&LABEL_FILTER_OP_NE_S64_DOUBLE
,
677 [ FILTER_OP_GT_S64_DOUBLE
] = &&LABEL_FILTER_OP_GT_S64_DOUBLE
,
678 [ FILTER_OP_LT_S64_DOUBLE
] = &&LABEL_FILTER_OP_LT_S64_DOUBLE
,
679 [ FILTER_OP_GE_S64_DOUBLE
] = &&LABEL_FILTER_OP_GE_S64_DOUBLE
,
680 [ FILTER_OP_LE_S64_DOUBLE
] = &&LABEL_FILTER_OP_LE_S64_DOUBLE
,
683 [ FILTER_OP_UNARY_PLUS
] = &&LABEL_FILTER_OP_UNARY_PLUS
,
684 [ FILTER_OP_UNARY_MINUS
] = &&LABEL_FILTER_OP_UNARY_MINUS
,
685 [ FILTER_OP_UNARY_NOT
] = &&LABEL_FILTER_OP_UNARY_NOT
,
686 [ FILTER_OP_UNARY_PLUS_S64
] = &&LABEL_FILTER_OP_UNARY_PLUS_S64
,
687 [ FILTER_OP_UNARY_MINUS_S64
] = &&LABEL_FILTER_OP_UNARY_MINUS_S64
,
688 [ FILTER_OP_UNARY_NOT_S64
] = &&LABEL_FILTER_OP_UNARY_NOT_S64
,
689 [ FILTER_OP_UNARY_PLUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_PLUS_DOUBLE
,
690 [ FILTER_OP_UNARY_MINUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_MINUS_DOUBLE
,
691 [ FILTER_OP_UNARY_NOT_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_NOT_DOUBLE
,
694 [ FILTER_OP_AND
] = &&LABEL_FILTER_OP_AND
,
695 [ FILTER_OP_OR
] = &&LABEL_FILTER_OP_OR
,
698 [ FILTER_OP_LOAD_FIELD_REF
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF
,
699 [ FILTER_OP_LOAD_FIELD_REF_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_STRING
,
700 [ FILTER_OP_LOAD_FIELD_REF_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_SEQUENCE
,
701 [ FILTER_OP_LOAD_FIELD_REF_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_S64
,
702 [ FILTER_OP_LOAD_FIELD_REF_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_DOUBLE
,
704 /* load from immediate operand */
705 [ FILTER_OP_LOAD_STRING
] = &&LABEL_FILTER_OP_LOAD_STRING
,
706 [ FILTER_OP_LOAD_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_LOAD_STAR_GLOB_STRING
,
707 [ FILTER_OP_LOAD_S64
] = &&LABEL_FILTER_OP_LOAD_S64
,
708 [ FILTER_OP_LOAD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_DOUBLE
,
711 [ FILTER_OP_CAST_TO_S64
] = &&LABEL_FILTER_OP_CAST_TO_S64
,
712 [ FILTER_OP_CAST_DOUBLE_TO_S64
] = &&LABEL_FILTER_OP_CAST_DOUBLE_TO_S64
,
713 [ FILTER_OP_CAST_NOP
] = &&LABEL_FILTER_OP_CAST_NOP
,
715 /* get context ref */
716 [ FILTER_OP_GET_CONTEXT_REF
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF
,
717 [ FILTER_OP_GET_CONTEXT_REF_STRING
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_STRING
,
718 [ FILTER_OP_GET_CONTEXT_REF_S64
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_S64
,
719 [ FILTER_OP_GET_CONTEXT_REF_DOUBLE
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_DOUBLE
,
721 /* Instructions for recursive traversal through composed types. */
722 [ FILTER_OP_GET_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_CONTEXT_ROOT
,
723 [ FILTER_OP_GET_APP_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_APP_CONTEXT_ROOT
,
724 [ FILTER_OP_GET_PAYLOAD_ROOT
] = &&LABEL_FILTER_OP_GET_PAYLOAD_ROOT
,
726 [ FILTER_OP_GET_SYMBOL
] = &&LABEL_FILTER_OP_GET_SYMBOL
,
727 [ FILTER_OP_GET_SYMBOL_FIELD
] = &&LABEL_FILTER_OP_GET_SYMBOL_FIELD
,
728 [ FILTER_OP_GET_INDEX_U16
] = &&LABEL_FILTER_OP_GET_INDEX_U16
,
729 [ FILTER_OP_GET_INDEX_U64
] = &&LABEL_FILTER_OP_GET_INDEX_U64
,
731 [ FILTER_OP_LOAD_FIELD
] = &&LABEL_FILTER_OP_LOAD_FIELD
,
732 [ FILTER_OP_LOAD_FIELD_S8
] = &&LABEL_FILTER_OP_LOAD_FIELD_S8
,
733 [ FILTER_OP_LOAD_FIELD_S16
] = &&LABEL_FILTER_OP_LOAD_FIELD_S16
,
734 [ FILTER_OP_LOAD_FIELD_S32
] = &&LABEL_FILTER_OP_LOAD_FIELD_S32
,
735 [ FILTER_OP_LOAD_FIELD_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_S64
,
736 [ FILTER_OP_LOAD_FIELD_U8
] = &&LABEL_FILTER_OP_LOAD_FIELD_U8
,
737 [ FILTER_OP_LOAD_FIELD_U16
] = &&LABEL_FILTER_OP_LOAD_FIELD_U16
,
738 [ FILTER_OP_LOAD_FIELD_U32
] = &&LABEL_FILTER_OP_LOAD_FIELD_U32
,
739 [ FILTER_OP_LOAD_FIELD_U64
] = &&LABEL_FILTER_OP_LOAD_FIELD_U64
,
740 [ FILTER_OP_LOAD_FIELD_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_STRING
,
741 [ FILTER_OP_LOAD_FIELD_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_SEQUENCE
,
742 [ FILTER_OP_LOAD_FIELD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_DOUBLE
,
744 [ FILTER_OP_UNARY_BIT_NOT
] = &&LABEL_FILTER_OP_UNARY_BIT_NOT
,
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
:
783 ERR("unsupported bytecode op %u",
784 (unsigned int) *(filter_opcode_t
*) pc
);
790 /* Dynamic typing. */
791 switch (estack_ax_t
) {
793 switch (estack_bx_t
) {
795 JUMP_TO(FILTER_OP_EQ_S64
);
797 JUMP_TO(FILTER_OP_EQ_DOUBLE_S64
);
798 case REG_STRING
: /* Fall-through */
799 case REG_STAR_GLOB_STRING
:
803 ERR("Unknown filter register type (%d)",
810 switch (estack_bx_t
) {
812 JUMP_TO(FILTER_OP_EQ_S64_DOUBLE
);
814 JUMP_TO(FILTER_OP_EQ_DOUBLE
);
815 case REG_STRING
: /* Fall-through */
816 case REG_STAR_GLOB_STRING
:
820 ERR("Unknown filter register type (%d)",
827 switch (estack_bx_t
) {
828 case REG_S64
: /* Fall-through */
833 JUMP_TO(FILTER_OP_EQ_STRING
);
834 case REG_STAR_GLOB_STRING
:
835 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
837 ERR("Unknown filter register type (%d)",
843 case REG_STAR_GLOB_STRING
:
844 switch (estack_bx_t
) {
845 case REG_S64
: /* Fall-through */
850 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
851 case REG_STAR_GLOB_STRING
:
855 ERR("Unknown filter register type (%d)",
862 ERR("Unknown filter register type (%d)",
870 /* Dynamic typing. */
871 switch (estack_ax_t
) {
873 switch (estack_bx_t
) {
875 JUMP_TO(FILTER_OP_NE_S64
);
877 JUMP_TO(FILTER_OP_NE_DOUBLE_S64
);
878 case REG_STRING
: /* Fall-through */
879 case REG_STAR_GLOB_STRING
:
883 ERR("Unknown filter register type (%d)",
890 switch (estack_bx_t
) {
892 JUMP_TO(FILTER_OP_NE_S64_DOUBLE
);
894 JUMP_TO(FILTER_OP_NE_DOUBLE
);
895 case REG_STRING
: /* Fall-through */
896 case REG_STAR_GLOB_STRING
:
900 ERR("Unknown filter register type (%d)",
907 switch (estack_bx_t
) {
908 case REG_S64
: /* Fall-through */
913 JUMP_TO(FILTER_OP_NE_STRING
);
914 case REG_STAR_GLOB_STRING
:
915 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
917 ERR("Unknown filter register type (%d)",
923 case REG_STAR_GLOB_STRING
:
924 switch (estack_bx_t
) {
925 case REG_S64
: /* Fall-through */
930 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
931 case REG_STAR_GLOB_STRING
:
935 ERR("Unknown filter register type (%d)",
942 ERR("Unknown filter register type (%d)",
950 /* Dynamic typing. */
951 switch (estack_ax_t
) {
953 switch (estack_bx_t
) {
955 JUMP_TO(FILTER_OP_GT_S64
);
957 JUMP_TO(FILTER_OP_GT_DOUBLE_S64
);
958 case REG_STRING
: /* Fall-through */
959 case REG_STAR_GLOB_STRING
:
963 ERR("Unknown filter register type (%d)",
970 switch (estack_bx_t
) {
972 JUMP_TO(FILTER_OP_GT_S64_DOUBLE
);
974 JUMP_TO(FILTER_OP_GT_DOUBLE
);
975 case REG_STRING
: /* Fall-through */
976 case REG_STAR_GLOB_STRING
:
980 ERR("Unknown filter register type (%d)",
987 switch (estack_bx_t
) {
988 case REG_S64
: /* Fall-through */
989 case REG_DOUBLE
: /* Fall-through */
990 case REG_STAR_GLOB_STRING
:
994 JUMP_TO(FILTER_OP_GT_STRING
);
996 ERR("Unknown filter register type (%d)",
1003 ERR("Unknown filter register type (%d)",
1011 /* Dynamic typing. */
1012 switch (estack_ax_t
) {
1014 switch (estack_bx_t
) {
1016 JUMP_TO(FILTER_OP_LT_S64
);
1018 JUMP_TO(FILTER_OP_LT_DOUBLE_S64
);
1019 case REG_STRING
: /* Fall-through */
1020 case REG_STAR_GLOB_STRING
:
1024 ERR("Unknown filter register type (%d)",
1031 switch (estack_bx_t
) {
1033 JUMP_TO(FILTER_OP_LT_S64_DOUBLE
);
1035 JUMP_TO(FILTER_OP_LT_DOUBLE
);
1036 case REG_STRING
: /* Fall-through */
1037 case REG_STAR_GLOB_STRING
:
1041 ERR("Unknown filter register type (%d)",
1048 switch (estack_bx_t
) {
1049 case REG_S64
: /* Fall-through */
1050 case REG_DOUBLE
: /* Fall-through */
1051 case REG_STAR_GLOB_STRING
:
1055 JUMP_TO(FILTER_OP_LT_STRING
);
1057 ERR("Unknown filter register type (%d)",
1064 ERR("Unknown filter register type (%d)",
1072 /* Dynamic typing. */
1073 switch (estack_ax_t
) {
1075 switch (estack_bx_t
) {
1077 JUMP_TO(FILTER_OP_GE_S64
);
1079 JUMP_TO(FILTER_OP_GE_DOUBLE_S64
);
1080 case REG_STRING
: /* Fall-through */
1081 case REG_STAR_GLOB_STRING
:
1085 ERR("Unknown filter register type (%d)",
1092 switch (estack_bx_t
) {
1094 JUMP_TO(FILTER_OP_GE_S64_DOUBLE
);
1096 JUMP_TO(FILTER_OP_GE_DOUBLE
);
1097 case REG_STRING
: /* Fall-through */
1098 case REG_STAR_GLOB_STRING
:
1102 ERR("Unknown filter register type (%d)",
1109 switch (estack_bx_t
) {
1110 case REG_S64
: /* Fall-through */
1111 case REG_DOUBLE
: /* Fall-through */
1112 case REG_STAR_GLOB_STRING
:
1116 JUMP_TO(FILTER_OP_GE_STRING
);
1118 ERR("Unknown filter register type (%d)",
1125 ERR("Unknown filter register type (%d)",
1133 /* Dynamic typing. */
1134 switch (estack_ax_t
) {
1136 switch (estack_bx_t
) {
1138 JUMP_TO(FILTER_OP_LE_S64
);
1140 JUMP_TO(FILTER_OP_LE_DOUBLE_S64
);
1141 case REG_STRING
: /* Fall-through */
1142 case REG_STAR_GLOB_STRING
:
1146 ERR("Unknown filter register type (%d)",
1153 switch (estack_bx_t
) {
1155 JUMP_TO(FILTER_OP_LE_S64_DOUBLE
);
1157 JUMP_TO(FILTER_OP_LE_DOUBLE
);
1158 case REG_STRING
: /* Fall-through */
1159 case REG_STAR_GLOB_STRING
:
1163 ERR("Unknown filter register type (%d)",
1170 switch (estack_bx_t
) {
1171 case REG_S64
: /* Fall-through */
1172 case REG_DOUBLE
: /* Fall-through */
1173 case REG_STAR_GLOB_STRING
:
1177 JUMP_TO(FILTER_OP_LE_STRING
);
1179 ERR("Unknown filter register type (%d)",
1186 ERR("Unknown filter register type (%d)",
1193 OP(FILTER_OP_EQ_STRING
):
1197 res
= (stack_strcmp(stack
, top
, "==") == 0);
1198 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1200 estack_ax_t
= REG_S64
;
1201 next_pc
+= sizeof(struct binary_op
);
1204 OP(FILTER_OP_NE_STRING
):
1208 res
= (stack_strcmp(stack
, top
, "!=") != 0);
1209 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1211 estack_ax_t
= REG_S64
;
1212 next_pc
+= sizeof(struct binary_op
);
1215 OP(FILTER_OP_GT_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_LT_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_GE_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_LE_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
);
1260 OP(FILTER_OP_EQ_STAR_GLOB_STRING
):
1264 res
= (stack_star_glob_match(stack
, top
, "==") == 0);
1265 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1267 estack_ax_t
= REG_S64
;
1268 next_pc
+= sizeof(struct binary_op
);
1271 OP(FILTER_OP_NE_STAR_GLOB_STRING
):
1275 res
= (stack_star_glob_match(stack
, top
, "!=") != 0);
1276 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1278 estack_ax_t
= REG_S64
;
1279 next_pc
+= sizeof(struct binary_op
);
1283 OP(FILTER_OP_EQ_S64
):
1287 res
= (estack_bx_v
== estack_ax_v
);
1288 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1290 estack_ax_t
= REG_S64
;
1291 next_pc
+= sizeof(struct binary_op
);
1294 OP(FILTER_OP_NE_S64
):
1298 res
= (estack_bx_v
!= estack_ax_v
);
1299 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1301 estack_ax_t
= REG_S64
;
1302 next_pc
+= sizeof(struct binary_op
);
1305 OP(FILTER_OP_GT_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_LT_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_GE_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_LE_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
);
1350 OP(FILTER_OP_EQ_DOUBLE
):
1354 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax(stack
, top
)->u
.d
);
1355 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1357 estack_ax_t
= REG_S64
;
1358 next_pc
+= sizeof(struct binary_op
);
1361 OP(FILTER_OP_NE_DOUBLE
):
1365 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax(stack
, top
)->u
.d
);
1366 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1368 estack_ax_t
= REG_S64
;
1369 next_pc
+= sizeof(struct binary_op
);
1372 OP(FILTER_OP_GT_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_LT_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_GE_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_LE_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
);
1417 /* Mixed S64-double binary comparators */
1418 OP(FILTER_OP_EQ_DOUBLE_S64
):
1422 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax_v
);
1423 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1425 estack_ax_t
= REG_S64
;
1426 next_pc
+= sizeof(struct binary_op
);
1429 OP(FILTER_OP_NE_DOUBLE_S64
):
1433 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax_v
);
1434 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1436 estack_ax_t
= REG_S64
;
1437 next_pc
+= sizeof(struct binary_op
);
1440 OP(FILTER_OP_GT_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_LT_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_GE_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_LE_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
);
1485 OP(FILTER_OP_EQ_S64_DOUBLE
):
1489 res
= (estack_bx_v
== estack_ax(stack
, top
)->u
.d
);
1490 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1492 estack_ax_t
= REG_S64
;
1493 next_pc
+= sizeof(struct binary_op
);
1496 OP(FILTER_OP_NE_S64_DOUBLE
):
1500 res
= (estack_bx_v
!= estack_ax(stack
, top
)->u
.d
);
1501 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1503 estack_ax_t
= REG_S64
;
1504 next_pc
+= sizeof(struct binary_op
);
1507 OP(FILTER_OP_GT_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_LT_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_GE_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_LE_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_BIT_RSHIFT
):
1555 /* Dynamic typing. */
1556 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1560 /* Catch undefined behavior. */
1561 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1565 res
= (estack_bx_v
>> estack_ax_v
);
1566 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1568 estack_ax_t
= REG_S64
;
1569 next_pc
+= sizeof(struct binary_op
);
1572 OP(FILTER_OP_BIT_LSHIFT
):
1576 /* Dynamic typing. */
1577 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1581 /* Catch undefined behavior. */
1582 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1586 res
= (estack_bx_v
<< estack_ax_v
);
1587 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1589 estack_ax_t
= REG_S64
;
1590 next_pc
+= sizeof(struct binary_op
);
1593 OP(FILTER_OP_BIT_AND
):
1597 /* Dynamic typing. */
1598 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1603 res
= (estack_bx_v
& estack_ax_v
);
1604 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1606 estack_ax_t
= REG_S64
;
1607 next_pc
+= sizeof(struct binary_op
);
1610 OP(FILTER_OP_BIT_OR
):
1614 /* Dynamic typing. */
1615 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1620 res
= (estack_bx_v
| estack_ax_v
);
1621 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1623 estack_ax_t
= REG_S64
;
1624 next_pc
+= sizeof(struct binary_op
);
1627 OP(FILTER_OP_BIT_XOR
):
1631 /* Dynamic typing. */
1632 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1637 res
= (estack_bx_v
^ estack_ax_v
);
1638 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1640 estack_ax_t
= REG_S64
;
1641 next_pc
+= sizeof(struct binary_op
);
1646 OP(FILTER_OP_UNARY_PLUS
):
1648 /* Dynamic typing. */
1649 switch (estack_ax_t
) {
1650 case REG_S64
: /* Fall-through. */
1651 JUMP_TO(FILTER_OP_UNARY_PLUS_S64
);
1653 JUMP_TO(FILTER_OP_UNARY_PLUS_DOUBLE
);
1654 case REG_STRING
: /* Fall-through */
1655 case REG_STAR_GLOB_STRING
:
1659 ERR("Unknown filter register type (%d)",
1665 OP(FILTER_OP_UNARY_MINUS
):
1667 /* Dynamic typing. */
1668 switch (estack_ax_t
) {
1670 JUMP_TO(FILTER_OP_UNARY_MINUS_S64
);
1672 JUMP_TO(FILTER_OP_UNARY_MINUS_DOUBLE
);
1673 case REG_STRING
: /* Fall-through */
1674 case REG_STAR_GLOB_STRING
:
1678 ERR("Unknown filter register type (%d)",
1684 OP(FILTER_OP_UNARY_NOT
):
1686 /* Dynamic typing. */
1687 switch (estack_ax_t
) {
1689 JUMP_TO(FILTER_OP_UNARY_NOT_S64
);
1691 JUMP_TO(FILTER_OP_UNARY_NOT_DOUBLE
);
1692 case REG_STRING
: /* Fall-through */
1693 case REG_STAR_GLOB_STRING
:
1697 ERR("Unknown filter register type (%d)",
1702 next_pc
+= sizeof(struct unary_op
);
1706 OP(FILTER_OP_UNARY_BIT_NOT
):
1708 /* Dynamic typing. */
1709 if (estack_ax_t
!= REG_S64
) {
1714 estack_ax_v
= ~estack_ax_v
;
1715 next_pc
+= sizeof(struct unary_op
);
1719 OP(FILTER_OP_UNARY_PLUS_S64
):
1720 OP(FILTER_OP_UNARY_PLUS_DOUBLE
):
1722 next_pc
+= sizeof(struct unary_op
);
1725 OP(FILTER_OP_UNARY_MINUS_S64
):
1727 estack_ax_v
= -estack_ax_v
;
1728 next_pc
+= sizeof(struct unary_op
);
1731 OP(FILTER_OP_UNARY_MINUS_DOUBLE
):
1733 estack_ax(stack
, top
)->u
.d
= -estack_ax(stack
, top
)->u
.d
;
1734 next_pc
+= sizeof(struct unary_op
);
1737 OP(FILTER_OP_UNARY_NOT_S64
):
1739 estack_ax_v
= !estack_ax_v
;
1740 next_pc
+= sizeof(struct unary_op
);
1743 OP(FILTER_OP_UNARY_NOT_DOUBLE
):
1745 estack_ax_v
= !estack_ax(stack
, top
)->u
.d
;
1746 estack_ax_t
= REG_S64
;
1747 next_pc
+= sizeof(struct unary_op
);
1754 struct logical_op
*insn
= (struct logical_op
*) pc
;
1756 if (estack_ax_t
!= REG_S64
) {
1760 /* If AX is 0, skip and evaluate to 0 */
1761 if (unlikely(estack_ax_v
== 0)) {
1762 dbg_printf("Jumping to bytecode offset %u\n",
1763 (unsigned int) insn
->skip_offset
);
1764 next_pc
= start_pc
+ insn
->skip_offset
;
1766 /* Pop 1 when jump not taken */
1767 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1768 next_pc
+= sizeof(struct logical_op
);
1774 struct logical_op
*insn
= (struct logical_op
*) pc
;
1776 if (estack_ax_t
!= REG_S64
) {
1780 /* If AX is nonzero, skip and evaluate to 1 */
1781 if (unlikely(estack_ax_v
!= 0)) {
1783 dbg_printf("Jumping to bytecode offset %u\n",
1784 (unsigned int) insn
->skip_offset
);
1785 next_pc
= start_pc
+ insn
->skip_offset
;
1787 /* Pop 1 when jump not taken */
1788 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1789 next_pc
+= sizeof(struct logical_op
);
1795 /* load field ref */
1796 OP(FILTER_OP_LOAD_FIELD_REF_STRING
):
1798 struct load_op
*insn
= (struct load_op
*) pc
;
1799 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1801 dbg_printf("load field ref offset %u type string\n",
1803 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1804 estack_ax(stack
, top
)->u
.s
.str
=
1805 *(const char * const *) &filter_stack_data
[ref
->offset
];
1806 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1807 dbg_printf("Filter warning: loading a NULL string.\n");
1811 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1812 estack_ax(stack
, top
)->u
.s
.literal_type
=
1813 ESTACK_STRING_LITERAL_TYPE_NONE
;
1814 estack_ax_t
= REG_STRING
;
1815 dbg_printf("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1816 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1820 OP(FILTER_OP_LOAD_FIELD_REF_SEQUENCE
):
1822 struct load_op
*insn
= (struct load_op
*) pc
;
1823 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1825 dbg_printf("load field ref offset %u type sequence\n",
1827 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1828 estack_ax(stack
, top
)->u
.s
.seq_len
=
1829 *(unsigned long *) &filter_stack_data
[ref
->offset
];
1830 estack_ax(stack
, top
)->u
.s
.str
=
1831 *(const char **) (&filter_stack_data
[ref
->offset
1832 + sizeof(unsigned long)]);
1833 estack_ax_t
= REG_STRING
;
1834 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1835 dbg_printf("Filter warning: loading a NULL sequence.\n");
1839 estack_ax(stack
, top
)->u
.s
.literal_type
=
1840 ESTACK_STRING_LITERAL_TYPE_NONE
;
1841 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1845 OP(FILTER_OP_LOAD_FIELD_REF_S64
):
1847 struct load_op
*insn
= (struct load_op
*) pc
;
1848 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1850 dbg_printf("load field ref offset %u type s64\n",
1852 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1854 ((struct literal_numeric
*) &filter_stack_data
[ref
->offset
])->v
;
1855 estack_ax_t
= REG_S64
;
1856 dbg_printf("ref load s64 %" PRIi64
"\n", estack_ax_v
);
1857 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1861 OP(FILTER_OP_LOAD_FIELD_REF_DOUBLE
):
1863 struct load_op
*insn
= (struct load_op
*) pc
;
1864 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1866 dbg_printf("load field ref offset %u type double\n",
1868 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1869 memcpy(&estack_ax(stack
, top
)->u
.d
, &filter_stack_data
[ref
->offset
],
1870 sizeof(struct literal_double
));
1871 estack_ax_t
= REG_DOUBLE
;
1872 dbg_printf("ref load double %g\n", estack_ax(stack
, top
)->u
.d
);
1873 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1877 /* load from immediate operand */
1878 OP(FILTER_OP_LOAD_STRING
):
1880 struct load_op
*insn
= (struct load_op
*) pc
;
1882 dbg_printf("load string %s\n", insn
->data
);
1883 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1884 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1885 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1886 estack_ax(stack
, top
)->u
.s
.literal_type
=
1887 ESTACK_STRING_LITERAL_TYPE_PLAIN
;
1888 estack_ax_t
= REG_STRING
;
1889 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1893 OP(FILTER_OP_LOAD_STAR_GLOB_STRING
):
1895 struct load_op
*insn
= (struct load_op
*) pc
;
1897 dbg_printf("load globbing pattern %s\n", insn
->data
);
1898 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1899 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1900 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1901 estack_ax(stack
, top
)->u
.s
.literal_type
=
1902 ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
;
1903 estack_ax_t
= REG_STAR_GLOB_STRING
;
1904 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1908 OP(FILTER_OP_LOAD_S64
):
1910 struct load_op
*insn
= (struct load_op
*) pc
;
1912 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1913 estack_ax_v
= ((struct literal_numeric
*) insn
->data
)->v
;
1914 estack_ax_t
= REG_S64
;
1915 dbg_printf("load s64 %" PRIi64
"\n", estack_ax_v
);
1916 next_pc
+= sizeof(struct load_op
)
1917 + sizeof(struct literal_numeric
);
1921 OP(FILTER_OP_LOAD_DOUBLE
):
1923 struct load_op
*insn
= (struct load_op
*) pc
;
1925 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1926 memcpy(&estack_ax(stack
, top
)->u
.d
, insn
->data
,
1927 sizeof(struct literal_double
));
1928 estack_ax_t
= REG_DOUBLE
;
1929 dbg_printf("load double %g\n", estack_ax(stack
, top
)->u
.d
);
1930 next_pc
+= sizeof(struct load_op
)
1931 + sizeof(struct literal_double
);
1936 OP(FILTER_OP_CAST_TO_S64
):
1938 /* Dynamic typing. */
1939 switch (estack_ax_t
) {
1941 JUMP_TO(FILTER_OP_CAST_NOP
);
1943 JUMP_TO(FILTER_OP_CAST_DOUBLE_TO_S64
);
1944 case REG_STRING
: /* Fall-through */
1945 case REG_STAR_GLOB_STRING
:
1949 ERR("Unknown filter register type (%d)",
1956 OP(FILTER_OP_CAST_DOUBLE_TO_S64
):
1958 estack_ax_v
= (int64_t) estack_ax(stack
, top
)->u
.d
;
1959 estack_ax_t
= REG_S64
;
1960 next_pc
+= sizeof(struct cast_op
);
1964 OP(FILTER_OP_CAST_NOP
):
1966 next_pc
+= sizeof(struct cast_op
);
1970 /* get context ref */
1971 OP(FILTER_OP_GET_CONTEXT_REF
):
1973 struct load_op
*insn
= (struct load_op
*) pc
;
1974 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1975 struct lttng_ctx
*ctx
;
1976 struct lttng_ctx_field
*ctx_field
;
1977 struct lttng_ctx_value v
;
1979 dbg_printf("get context ref offset %u type dynamic\n",
1981 ctx
= rcu_dereference(session
->ctx
);
1982 ctx_field
= &ctx
->fields
[ref
->offset
];
1983 ctx_field
->get_value(ctx_field
, &v
);
1984 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1986 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
1989 case LTTNG_UST_DYNAMIC_TYPE_S64
:
1990 estack_ax_v
= v
.u
.s64
;
1991 estack_ax_t
= REG_S64
;
1992 dbg_printf("ref get context dynamic s64 %" PRIi64
"\n", estack_ax_v
);
1994 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
1995 estack_ax(stack
, top
)->u
.d
= v
.u
.d
;
1996 estack_ax_t
= REG_DOUBLE
;
1997 dbg_printf("ref get context dynamic double %g\n", estack_ax(stack
, top
)->u
.d
);
1999 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
2000 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2001 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2002 dbg_printf("Filter warning: loading a NULL string.\n");
2006 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2007 estack_ax(stack
, top
)->u
.s
.literal_type
=
2008 ESTACK_STRING_LITERAL_TYPE_NONE
;
2009 dbg_printf("ref get context dynamic string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2010 estack_ax_t
= REG_STRING
;
2013 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
2017 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2021 OP(FILTER_OP_GET_CONTEXT_REF_STRING
):
2023 struct load_op
*insn
= (struct load_op
*) pc
;
2024 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2025 struct lttng_ctx
*ctx
;
2026 struct lttng_ctx_field
*ctx_field
;
2027 struct lttng_ctx_value v
;
2029 dbg_printf("get context ref offset %u type string\n",
2031 ctx
= rcu_dereference(session
->ctx
);
2032 ctx_field
= &ctx
->fields
[ref
->offset
];
2033 ctx_field
->get_value(ctx_field
, &v
);
2034 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2035 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2036 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2037 dbg_printf("Filter warning: loading a NULL string.\n");
2041 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2042 estack_ax(stack
, top
)->u
.s
.literal_type
=
2043 ESTACK_STRING_LITERAL_TYPE_NONE
;
2044 estack_ax_t
= REG_STRING
;
2045 dbg_printf("ref get context string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2046 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2050 OP(FILTER_OP_GET_CONTEXT_REF_S64
):
2052 struct load_op
*insn
= (struct load_op
*) pc
;
2053 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2054 struct lttng_ctx
*ctx
;
2055 struct lttng_ctx_field
*ctx_field
;
2056 struct lttng_ctx_value v
;
2058 dbg_printf("get context ref offset %u type s64\n",
2060 ctx
= rcu_dereference(session
->ctx
);
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
*ctx
;
2076 struct lttng_ctx_field
*ctx_field
;
2077 struct lttng_ctx_value v
;
2079 dbg_printf("get context ref offset %u type double\n",
2081 ctx
= rcu_dereference(session
->ctx
);
2082 ctx_field
= &ctx
->fields
[ref
->offset
];
2083 ctx_field
->get_value(ctx_field
, &v
);
2084 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2085 memcpy(&estack_ax(stack
, top
)->u
.d
, &v
.u
.d
, sizeof(struct literal_double
));
2086 estack_ax_t
= REG_DOUBLE
;
2087 dbg_printf("ref get context double %g\n", estack_ax(stack
, top
)->u
.d
);
2088 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2092 OP(FILTER_OP_GET_CONTEXT_ROOT
):
2094 dbg_printf("op get context root\n");
2095 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2096 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_CONTEXT
;
2097 /* "field" only needed for variants. */
2098 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2099 estack_ax_t
= REG_PTR
;
2100 next_pc
+= sizeof(struct load_op
);
2104 OP(FILTER_OP_GET_APP_CONTEXT_ROOT
):
2106 dbg_printf("op get app context root\n");
2107 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2108 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_APP_CONTEXT
;
2109 /* "field" only needed for variants. */
2110 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2111 estack_ax_t
= REG_PTR
;
2112 next_pc
+= sizeof(struct load_op
);
2116 OP(FILTER_OP_GET_PAYLOAD_ROOT
):
2118 dbg_printf("op get app payload root\n");
2119 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2120 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_PAYLOAD
;
2121 estack_ax(stack
, top
)->u
.ptr
.ptr
= filter_stack_data
;
2122 /* "field" only needed for variants. */
2123 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2124 estack_ax_t
= REG_PTR
;
2125 next_pc
+= sizeof(struct load_op
);
2129 OP(FILTER_OP_GET_SYMBOL
):
2131 dbg_printf("op get symbol\n");
2132 switch (estack_ax(stack
, top
)->u
.ptr
.type
) {
2134 ERR("Nested fields not implemented yet.");
2137 case LOAD_ROOT_CONTEXT
:
2138 case LOAD_ROOT_APP_CONTEXT
:
2139 case LOAD_ROOT_PAYLOAD
:
2141 * symbol lookup is performed by
2147 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_symbol
);
2151 OP(FILTER_OP_GET_SYMBOL_FIELD
):
2154 * Used for first variant encountered in a
2155 * traversal. Variants are not implemented yet.
2161 OP(FILTER_OP_GET_INDEX_U16
):
2163 struct load_op
*insn
= (struct load_op
*) pc
;
2164 struct get_index_u16
*index
= (struct get_index_u16
*) insn
->data
;
2166 dbg_printf("op get index u16\n");
2167 ret
= dynamic_get_index(session
, bytecode
, index
->index
, estack_ax(stack
, top
));
2170 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2171 estack_ax_t
= estack_ax(stack
, top
)->type
;
2172 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u16
);
2176 OP(FILTER_OP_GET_INDEX_U64
):
2178 struct load_op
*insn
= (struct load_op
*) pc
;
2179 struct get_index_u64
*index
= (struct get_index_u64
*) insn
->data
;
2181 dbg_printf("op get index u64\n");
2182 ret
= dynamic_get_index(session
, bytecode
, index
->index
, estack_ax(stack
, top
));
2185 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2186 estack_ax_t
= estack_ax(stack
, top
)->type
;
2187 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u64
);
2191 OP(FILTER_OP_LOAD_FIELD
):
2193 dbg_printf("op load field\n");
2194 ret
= dynamic_load_field(estack_ax(stack
, top
));
2197 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2198 estack_ax_t
= estack_ax(stack
, top
)->type
;
2199 next_pc
+= sizeof(struct load_op
);
2203 OP(FILTER_OP_LOAD_FIELD_S8
):
2205 dbg_printf("op load field s8\n");
2207 estack_ax_v
= *(int8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2208 estack_ax_t
= REG_S64
;
2209 next_pc
+= sizeof(struct load_op
);
2212 OP(FILTER_OP_LOAD_FIELD_S16
):
2214 dbg_printf("op load field s16\n");
2216 estack_ax_v
= *(int16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2217 estack_ax_t
= REG_S64
;
2218 next_pc
+= sizeof(struct load_op
);
2221 OP(FILTER_OP_LOAD_FIELD_S32
):
2223 dbg_printf("op load field s32\n");
2225 estack_ax_v
= *(int32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2226 estack_ax_t
= REG_S64
;
2227 next_pc
+= sizeof(struct load_op
);
2230 OP(FILTER_OP_LOAD_FIELD_S64
):
2232 dbg_printf("op load field s64\n");
2234 estack_ax_v
= *(int64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2235 estack_ax_t
= REG_S64
;
2236 next_pc
+= sizeof(struct load_op
);
2239 OP(FILTER_OP_LOAD_FIELD_U8
):
2241 dbg_printf("op load field u8\n");
2243 estack_ax_v
= *(uint8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2244 estack_ax_t
= REG_S64
;
2245 next_pc
+= sizeof(struct load_op
);
2248 OP(FILTER_OP_LOAD_FIELD_U16
):
2250 dbg_printf("op load field u16\n");
2252 estack_ax_v
= *(uint16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2253 estack_ax_t
= REG_S64
;
2254 next_pc
+= sizeof(struct load_op
);
2257 OP(FILTER_OP_LOAD_FIELD_U32
):
2259 dbg_printf("op load field u32\n");
2261 estack_ax_v
= *(uint32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2262 estack_ax_t
= REG_S64
;
2263 next_pc
+= sizeof(struct load_op
);
2266 OP(FILTER_OP_LOAD_FIELD_U64
):
2268 dbg_printf("op load field u64\n");
2270 estack_ax_v
= *(uint64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2271 estack_ax_t
= REG_S64
;
2272 next_pc
+= sizeof(struct load_op
);
2275 OP(FILTER_OP_LOAD_FIELD_DOUBLE
):
2277 dbg_printf("op load field double\n");
2279 memcpy(&estack_ax(stack
, top
)->u
.d
,
2280 estack_ax(stack
, top
)->u
.ptr
.ptr
,
2281 sizeof(struct literal_double
));
2282 estack_ax(stack
, top
)->type
= REG_DOUBLE
;
2283 next_pc
+= sizeof(struct load_op
);
2287 OP(FILTER_OP_LOAD_FIELD_STRING
):
2291 dbg_printf("op load field string\n");
2292 str
= (const char *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2293 estack_ax(stack
, top
)->u
.s
.str
= str
;
2294 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2295 dbg_printf("Filter warning: loading a NULL string.\n");
2299 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2300 estack_ax(stack
, top
)->u
.s
.literal_type
=
2301 ESTACK_STRING_LITERAL_TYPE_NONE
;
2302 estack_ax(stack
, top
)->type
= REG_STRING
;
2303 next_pc
+= sizeof(struct load_op
);
2307 OP(FILTER_OP_LOAD_FIELD_SEQUENCE
):
2311 dbg_printf("op load field string sequence\n");
2312 ptr
= estack_ax(stack
, top
)->u
.ptr
.ptr
;
2313 estack_ax(stack
, top
)->u
.s
.seq_len
= *(unsigned long *) ptr
;
2314 estack_ax(stack
, top
)->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
2315 estack_ax(stack
, top
)->type
= REG_STRING
;
2316 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2317 dbg_printf("Filter warning: loading a NULL sequence.\n");
2321 estack_ax(stack
, top
)->u
.s
.literal_type
=
2322 ESTACK_STRING_LITERAL_TYPE_NONE
;
2323 next_pc
+= sizeof(struct load_op
);
2329 /* return 0 (discard) on error */