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 [ FILTER_OP_RETURN_S64
] = &&LABEL_FILTER_OP_RETURN_S64
,
748 #endif /* #ifndef INTERPRETER_USE_SWITCH */
752 OP(FILTER_OP_UNKNOWN
):
753 OP(FILTER_OP_LOAD_FIELD_REF
):
754 #ifdef INTERPRETER_USE_SWITCH
756 #endif /* INTERPRETER_USE_SWITCH */
757 ERR("unknown bytecode op %u",
758 (unsigned int) *(filter_opcode_t
*) pc
);
762 OP(FILTER_OP_RETURN
):
763 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
764 /* Handle dynamic typing. */
765 switch (estack_ax_t
) {
767 retval
= !!estack_ax_v
;
771 case REG_STAR_GLOB_STRING
:
779 OP(FILTER_OP_RETURN_S64
):
780 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
781 retval
= !!estack_ax_v
;
791 ERR("unsupported bytecode op %u",
792 (unsigned int) *(filter_opcode_t
*) pc
);
798 /* Dynamic typing. */
799 switch (estack_ax_t
) {
801 switch (estack_bx_t
) {
803 JUMP_TO(FILTER_OP_EQ_S64
);
805 JUMP_TO(FILTER_OP_EQ_DOUBLE_S64
);
806 case REG_STRING
: /* Fall-through */
807 case REG_STAR_GLOB_STRING
:
811 ERR("Unknown filter register type (%d)",
818 switch (estack_bx_t
) {
820 JUMP_TO(FILTER_OP_EQ_S64_DOUBLE
);
822 JUMP_TO(FILTER_OP_EQ_DOUBLE
);
823 case REG_STRING
: /* Fall-through */
824 case REG_STAR_GLOB_STRING
:
828 ERR("Unknown filter register type (%d)",
835 switch (estack_bx_t
) {
836 case REG_S64
: /* Fall-through */
841 JUMP_TO(FILTER_OP_EQ_STRING
);
842 case REG_STAR_GLOB_STRING
:
843 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
845 ERR("Unknown filter register type (%d)",
851 case REG_STAR_GLOB_STRING
:
852 switch (estack_bx_t
) {
853 case REG_S64
: /* Fall-through */
858 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
859 case REG_STAR_GLOB_STRING
:
863 ERR("Unknown filter register type (%d)",
870 ERR("Unknown filter register type (%d)",
878 /* Dynamic typing. */
879 switch (estack_ax_t
) {
881 switch (estack_bx_t
) {
883 JUMP_TO(FILTER_OP_NE_S64
);
885 JUMP_TO(FILTER_OP_NE_DOUBLE_S64
);
886 case REG_STRING
: /* Fall-through */
887 case REG_STAR_GLOB_STRING
:
891 ERR("Unknown filter register type (%d)",
898 switch (estack_bx_t
) {
900 JUMP_TO(FILTER_OP_NE_S64_DOUBLE
);
902 JUMP_TO(FILTER_OP_NE_DOUBLE
);
903 case REG_STRING
: /* Fall-through */
904 case REG_STAR_GLOB_STRING
:
908 ERR("Unknown filter register type (%d)",
915 switch (estack_bx_t
) {
916 case REG_S64
: /* Fall-through */
921 JUMP_TO(FILTER_OP_NE_STRING
);
922 case REG_STAR_GLOB_STRING
:
923 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
925 ERR("Unknown filter register type (%d)",
931 case REG_STAR_GLOB_STRING
:
932 switch (estack_bx_t
) {
933 case REG_S64
: /* Fall-through */
938 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
939 case REG_STAR_GLOB_STRING
:
943 ERR("Unknown filter register type (%d)",
950 ERR("Unknown filter register type (%d)",
958 /* Dynamic typing. */
959 switch (estack_ax_t
) {
961 switch (estack_bx_t
) {
963 JUMP_TO(FILTER_OP_GT_S64
);
965 JUMP_TO(FILTER_OP_GT_DOUBLE_S64
);
966 case REG_STRING
: /* Fall-through */
967 case REG_STAR_GLOB_STRING
:
971 ERR("Unknown filter register type (%d)",
978 switch (estack_bx_t
) {
980 JUMP_TO(FILTER_OP_GT_S64_DOUBLE
);
982 JUMP_TO(FILTER_OP_GT_DOUBLE
);
983 case REG_STRING
: /* Fall-through */
984 case REG_STAR_GLOB_STRING
:
988 ERR("Unknown filter register type (%d)",
995 switch (estack_bx_t
) {
996 case REG_S64
: /* Fall-through */
997 case REG_DOUBLE
: /* Fall-through */
998 case REG_STAR_GLOB_STRING
:
1002 JUMP_TO(FILTER_OP_GT_STRING
);
1004 ERR("Unknown filter register type (%d)",
1011 ERR("Unknown filter register type (%d)",
1019 /* Dynamic typing. */
1020 switch (estack_ax_t
) {
1022 switch (estack_bx_t
) {
1024 JUMP_TO(FILTER_OP_LT_S64
);
1026 JUMP_TO(FILTER_OP_LT_DOUBLE_S64
);
1027 case REG_STRING
: /* Fall-through */
1028 case REG_STAR_GLOB_STRING
:
1032 ERR("Unknown filter register type (%d)",
1039 switch (estack_bx_t
) {
1041 JUMP_TO(FILTER_OP_LT_S64_DOUBLE
);
1043 JUMP_TO(FILTER_OP_LT_DOUBLE
);
1044 case REG_STRING
: /* Fall-through */
1045 case REG_STAR_GLOB_STRING
:
1049 ERR("Unknown filter register type (%d)",
1056 switch (estack_bx_t
) {
1057 case REG_S64
: /* Fall-through */
1058 case REG_DOUBLE
: /* Fall-through */
1059 case REG_STAR_GLOB_STRING
:
1063 JUMP_TO(FILTER_OP_LT_STRING
);
1065 ERR("Unknown filter register type (%d)",
1072 ERR("Unknown filter register type (%d)",
1080 /* Dynamic typing. */
1081 switch (estack_ax_t
) {
1083 switch (estack_bx_t
) {
1085 JUMP_TO(FILTER_OP_GE_S64
);
1087 JUMP_TO(FILTER_OP_GE_DOUBLE_S64
);
1088 case REG_STRING
: /* Fall-through */
1089 case REG_STAR_GLOB_STRING
:
1093 ERR("Unknown filter register type (%d)",
1100 switch (estack_bx_t
) {
1102 JUMP_TO(FILTER_OP_GE_S64_DOUBLE
);
1104 JUMP_TO(FILTER_OP_GE_DOUBLE
);
1105 case REG_STRING
: /* Fall-through */
1106 case REG_STAR_GLOB_STRING
:
1110 ERR("Unknown filter register type (%d)",
1117 switch (estack_bx_t
) {
1118 case REG_S64
: /* Fall-through */
1119 case REG_DOUBLE
: /* Fall-through */
1120 case REG_STAR_GLOB_STRING
:
1124 JUMP_TO(FILTER_OP_GE_STRING
);
1126 ERR("Unknown filter register type (%d)",
1133 ERR("Unknown filter register type (%d)",
1141 /* Dynamic typing. */
1142 switch (estack_ax_t
) {
1144 switch (estack_bx_t
) {
1146 JUMP_TO(FILTER_OP_LE_S64
);
1148 JUMP_TO(FILTER_OP_LE_DOUBLE_S64
);
1149 case REG_STRING
: /* Fall-through */
1150 case REG_STAR_GLOB_STRING
:
1154 ERR("Unknown filter register type (%d)",
1161 switch (estack_bx_t
) {
1163 JUMP_TO(FILTER_OP_LE_S64_DOUBLE
);
1165 JUMP_TO(FILTER_OP_LE_DOUBLE
);
1166 case REG_STRING
: /* Fall-through */
1167 case REG_STAR_GLOB_STRING
:
1171 ERR("Unknown filter register type (%d)",
1178 switch (estack_bx_t
) {
1179 case REG_S64
: /* Fall-through */
1180 case REG_DOUBLE
: /* Fall-through */
1181 case REG_STAR_GLOB_STRING
:
1185 JUMP_TO(FILTER_OP_LE_STRING
);
1187 ERR("Unknown filter register type (%d)",
1194 ERR("Unknown filter register type (%d)",
1201 OP(FILTER_OP_EQ_STRING
):
1205 res
= (stack_strcmp(stack
, top
, "==") == 0);
1206 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1208 estack_ax_t
= REG_S64
;
1209 next_pc
+= sizeof(struct binary_op
);
1212 OP(FILTER_OP_NE_STRING
):
1216 res
= (stack_strcmp(stack
, top
, "!=") != 0);
1217 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1219 estack_ax_t
= REG_S64
;
1220 next_pc
+= sizeof(struct binary_op
);
1223 OP(FILTER_OP_GT_STRING
):
1227 res
= (stack_strcmp(stack
, top
, ">") > 0);
1228 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1230 estack_ax_t
= REG_S64
;
1231 next_pc
+= sizeof(struct binary_op
);
1234 OP(FILTER_OP_LT_STRING
):
1238 res
= (stack_strcmp(stack
, top
, "<") < 0);
1239 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1241 estack_ax_t
= REG_S64
;
1242 next_pc
+= sizeof(struct binary_op
);
1245 OP(FILTER_OP_GE_STRING
):
1249 res
= (stack_strcmp(stack
, top
, ">=") >= 0);
1250 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1252 estack_ax_t
= REG_S64
;
1253 next_pc
+= sizeof(struct binary_op
);
1256 OP(FILTER_OP_LE_STRING
):
1260 res
= (stack_strcmp(stack
, top
, "<=") <= 0);
1261 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1263 estack_ax_t
= REG_S64
;
1264 next_pc
+= sizeof(struct binary_op
);
1268 OP(FILTER_OP_EQ_STAR_GLOB_STRING
):
1272 res
= (stack_star_glob_match(stack
, top
, "==") == 0);
1273 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1275 estack_ax_t
= REG_S64
;
1276 next_pc
+= sizeof(struct binary_op
);
1279 OP(FILTER_OP_NE_STAR_GLOB_STRING
):
1283 res
= (stack_star_glob_match(stack
, top
, "!=") != 0);
1284 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1286 estack_ax_t
= REG_S64
;
1287 next_pc
+= sizeof(struct binary_op
);
1291 OP(FILTER_OP_EQ_S64
):
1295 res
= (estack_bx_v
== estack_ax_v
);
1296 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1298 estack_ax_t
= REG_S64
;
1299 next_pc
+= sizeof(struct binary_op
);
1302 OP(FILTER_OP_NE_S64
):
1306 res
= (estack_bx_v
!= estack_ax_v
);
1307 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1309 estack_ax_t
= REG_S64
;
1310 next_pc
+= sizeof(struct binary_op
);
1313 OP(FILTER_OP_GT_S64
):
1317 res
= (estack_bx_v
> estack_ax_v
);
1318 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1320 estack_ax_t
= REG_S64
;
1321 next_pc
+= sizeof(struct binary_op
);
1324 OP(FILTER_OP_LT_S64
):
1328 res
= (estack_bx_v
< estack_ax_v
);
1329 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1331 estack_ax_t
= REG_S64
;
1332 next_pc
+= sizeof(struct binary_op
);
1335 OP(FILTER_OP_GE_S64
):
1339 res
= (estack_bx_v
>= estack_ax_v
);
1340 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1342 estack_ax_t
= REG_S64
;
1343 next_pc
+= sizeof(struct binary_op
);
1346 OP(FILTER_OP_LE_S64
):
1350 res
= (estack_bx_v
<= estack_ax_v
);
1351 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1353 estack_ax_t
= REG_S64
;
1354 next_pc
+= sizeof(struct binary_op
);
1358 OP(FILTER_OP_EQ_DOUBLE
):
1362 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax(stack
, top
)->u
.d
);
1363 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1365 estack_ax_t
= REG_S64
;
1366 next_pc
+= sizeof(struct binary_op
);
1369 OP(FILTER_OP_NE_DOUBLE
):
1373 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax(stack
, top
)->u
.d
);
1374 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1376 estack_ax_t
= REG_S64
;
1377 next_pc
+= sizeof(struct binary_op
);
1380 OP(FILTER_OP_GT_DOUBLE
):
1384 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax(stack
, top
)->u
.d
);
1385 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1387 estack_ax_t
= REG_S64
;
1388 next_pc
+= sizeof(struct binary_op
);
1391 OP(FILTER_OP_LT_DOUBLE
):
1395 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax(stack
, top
)->u
.d
);
1396 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1398 estack_ax_t
= REG_S64
;
1399 next_pc
+= sizeof(struct binary_op
);
1402 OP(FILTER_OP_GE_DOUBLE
):
1406 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax(stack
, top
)->u
.d
);
1407 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1409 estack_ax_t
= REG_S64
;
1410 next_pc
+= sizeof(struct binary_op
);
1413 OP(FILTER_OP_LE_DOUBLE
):
1417 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax(stack
, top
)->u
.d
);
1418 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1420 estack_ax_t
= REG_S64
;
1421 next_pc
+= sizeof(struct binary_op
);
1425 /* Mixed S64-double binary comparators */
1426 OP(FILTER_OP_EQ_DOUBLE_S64
):
1430 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax_v
);
1431 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1433 estack_ax_t
= REG_S64
;
1434 next_pc
+= sizeof(struct binary_op
);
1437 OP(FILTER_OP_NE_DOUBLE_S64
):
1441 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax_v
);
1442 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1444 estack_ax_t
= REG_S64
;
1445 next_pc
+= sizeof(struct binary_op
);
1448 OP(FILTER_OP_GT_DOUBLE_S64
):
1452 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax_v
);
1453 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1455 estack_ax_t
= REG_S64
;
1456 next_pc
+= sizeof(struct binary_op
);
1459 OP(FILTER_OP_LT_DOUBLE_S64
):
1463 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax_v
);
1464 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1466 estack_ax_t
= REG_S64
;
1467 next_pc
+= sizeof(struct binary_op
);
1470 OP(FILTER_OP_GE_DOUBLE_S64
):
1474 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax_v
);
1475 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1477 estack_ax_t
= REG_S64
;
1478 next_pc
+= sizeof(struct binary_op
);
1481 OP(FILTER_OP_LE_DOUBLE_S64
):
1485 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax_v
);
1486 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1488 estack_ax_t
= REG_S64
;
1489 next_pc
+= sizeof(struct binary_op
);
1493 OP(FILTER_OP_EQ_S64_DOUBLE
):
1497 res
= (estack_bx_v
== estack_ax(stack
, top
)->u
.d
);
1498 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1500 estack_ax_t
= REG_S64
;
1501 next_pc
+= sizeof(struct binary_op
);
1504 OP(FILTER_OP_NE_S64_DOUBLE
):
1508 res
= (estack_bx_v
!= estack_ax(stack
, top
)->u
.d
);
1509 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1511 estack_ax_t
= REG_S64
;
1512 next_pc
+= sizeof(struct binary_op
);
1515 OP(FILTER_OP_GT_S64_DOUBLE
):
1519 res
= (estack_bx_v
> estack_ax(stack
, top
)->u
.d
);
1520 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1522 estack_ax_t
= REG_S64
;
1523 next_pc
+= sizeof(struct binary_op
);
1526 OP(FILTER_OP_LT_S64_DOUBLE
):
1530 res
= (estack_bx_v
< estack_ax(stack
, top
)->u
.d
);
1531 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1533 estack_ax_t
= REG_S64
;
1534 next_pc
+= sizeof(struct binary_op
);
1537 OP(FILTER_OP_GE_S64_DOUBLE
):
1541 res
= (estack_bx_v
>= estack_ax(stack
, top
)->u
.d
);
1542 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1544 estack_ax_t
= REG_S64
;
1545 next_pc
+= sizeof(struct binary_op
);
1548 OP(FILTER_OP_LE_S64_DOUBLE
):
1552 res
= (estack_bx_v
<= estack_ax(stack
, top
)->u
.d
);
1553 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1555 estack_ax_t
= REG_S64
;
1556 next_pc
+= sizeof(struct binary_op
);
1559 OP(FILTER_OP_BIT_RSHIFT
):
1563 /* Dynamic typing. */
1564 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1568 /* Catch undefined behavior. */
1569 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1573 res
= ((uint64_t) estack_bx_v
>> (uint32_t) estack_ax_v
);
1574 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1576 estack_ax_t
= REG_S64
;
1577 next_pc
+= sizeof(struct binary_op
);
1580 OP(FILTER_OP_BIT_LSHIFT
):
1584 /* Dynamic typing. */
1585 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1589 /* Catch undefined behavior. */
1590 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1594 res
= ((uint64_t) estack_bx_v
<< (uint32_t) estack_ax_v
);
1595 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1597 estack_ax_t
= REG_S64
;
1598 next_pc
+= sizeof(struct binary_op
);
1601 OP(FILTER_OP_BIT_AND
):
1605 /* Dynamic typing. */
1606 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1611 res
= ((uint64_t) estack_bx_v
& (uint64_t) estack_ax_v
);
1612 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1614 estack_ax_t
= REG_S64
;
1615 next_pc
+= sizeof(struct binary_op
);
1618 OP(FILTER_OP_BIT_OR
):
1622 /* Dynamic typing. */
1623 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1628 res
= ((uint64_t) estack_bx_v
| (uint64_t) estack_ax_v
);
1629 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1631 estack_ax_t
= REG_S64
;
1632 next_pc
+= sizeof(struct binary_op
);
1635 OP(FILTER_OP_BIT_XOR
):
1639 /* Dynamic typing. */
1640 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1645 res
= ((uint64_t) estack_bx_v
^ (uint64_t) estack_ax_v
);
1646 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1648 estack_ax_t
= REG_S64
;
1649 next_pc
+= sizeof(struct binary_op
);
1654 OP(FILTER_OP_UNARY_PLUS
):
1656 /* Dynamic typing. */
1657 switch (estack_ax_t
) {
1658 case REG_S64
: /* Fall-through. */
1659 JUMP_TO(FILTER_OP_UNARY_PLUS_S64
);
1661 JUMP_TO(FILTER_OP_UNARY_PLUS_DOUBLE
);
1662 case REG_STRING
: /* Fall-through */
1663 case REG_STAR_GLOB_STRING
:
1667 ERR("Unknown filter register type (%d)",
1673 OP(FILTER_OP_UNARY_MINUS
):
1675 /* Dynamic typing. */
1676 switch (estack_ax_t
) {
1678 JUMP_TO(FILTER_OP_UNARY_MINUS_S64
);
1680 JUMP_TO(FILTER_OP_UNARY_MINUS_DOUBLE
);
1681 case REG_STRING
: /* Fall-through */
1682 case REG_STAR_GLOB_STRING
:
1686 ERR("Unknown filter register type (%d)",
1692 OP(FILTER_OP_UNARY_NOT
):
1694 /* Dynamic typing. */
1695 switch (estack_ax_t
) {
1697 JUMP_TO(FILTER_OP_UNARY_NOT_S64
);
1699 JUMP_TO(FILTER_OP_UNARY_NOT_DOUBLE
);
1700 case REG_STRING
: /* Fall-through */
1701 case REG_STAR_GLOB_STRING
:
1705 ERR("Unknown filter register type (%d)",
1710 next_pc
+= sizeof(struct unary_op
);
1714 OP(FILTER_OP_UNARY_BIT_NOT
):
1716 /* Dynamic typing. */
1717 if (estack_ax_t
!= REG_S64
) {
1722 estack_ax_v
= ~(uint64_t) estack_ax_v
;
1723 next_pc
+= sizeof(struct unary_op
);
1727 OP(FILTER_OP_UNARY_PLUS_S64
):
1728 OP(FILTER_OP_UNARY_PLUS_DOUBLE
):
1730 next_pc
+= sizeof(struct unary_op
);
1733 OP(FILTER_OP_UNARY_MINUS_S64
):
1735 estack_ax_v
= -estack_ax_v
;
1736 next_pc
+= sizeof(struct unary_op
);
1739 OP(FILTER_OP_UNARY_MINUS_DOUBLE
):
1741 estack_ax(stack
, top
)->u
.d
= -estack_ax(stack
, top
)->u
.d
;
1742 next_pc
+= sizeof(struct unary_op
);
1745 OP(FILTER_OP_UNARY_NOT_S64
):
1747 estack_ax_v
= !estack_ax_v
;
1748 next_pc
+= sizeof(struct unary_op
);
1751 OP(FILTER_OP_UNARY_NOT_DOUBLE
):
1753 estack_ax_v
= !estack_ax(stack
, top
)->u
.d
;
1754 estack_ax_t
= REG_S64
;
1755 next_pc
+= sizeof(struct unary_op
);
1762 struct logical_op
*insn
= (struct logical_op
*) pc
;
1764 if (estack_ax_t
!= REG_S64
) {
1768 /* If AX is 0, skip and evaluate to 0 */
1769 if (unlikely(estack_ax_v
== 0)) {
1770 dbg_printf("Jumping to bytecode offset %u\n",
1771 (unsigned int) insn
->skip_offset
);
1772 next_pc
= start_pc
+ insn
->skip_offset
;
1774 /* Pop 1 when jump not taken */
1775 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1776 next_pc
+= sizeof(struct logical_op
);
1782 struct logical_op
*insn
= (struct logical_op
*) pc
;
1784 if (estack_ax_t
!= REG_S64
) {
1788 /* If AX is nonzero, skip and evaluate to 1 */
1789 if (unlikely(estack_ax_v
!= 0)) {
1791 dbg_printf("Jumping to bytecode offset %u\n",
1792 (unsigned int) insn
->skip_offset
);
1793 next_pc
= start_pc
+ insn
->skip_offset
;
1795 /* Pop 1 when jump not taken */
1796 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1797 next_pc
+= sizeof(struct logical_op
);
1803 /* load field ref */
1804 OP(FILTER_OP_LOAD_FIELD_REF_STRING
):
1806 struct load_op
*insn
= (struct load_op
*) pc
;
1807 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1809 dbg_printf("load field ref offset %u type string\n",
1811 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1812 estack_ax(stack
, top
)->u
.s
.str
=
1813 *(const char * const *) &filter_stack_data
[ref
->offset
];
1814 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1815 dbg_printf("Filter warning: loading a NULL string.\n");
1819 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1820 estack_ax(stack
, top
)->u
.s
.literal_type
=
1821 ESTACK_STRING_LITERAL_TYPE_NONE
;
1822 estack_ax_t
= REG_STRING
;
1823 dbg_printf("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1824 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1828 OP(FILTER_OP_LOAD_FIELD_REF_SEQUENCE
):
1830 struct load_op
*insn
= (struct load_op
*) pc
;
1831 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1833 dbg_printf("load field ref offset %u type sequence\n",
1835 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1836 estack_ax(stack
, top
)->u
.s
.seq_len
=
1837 *(unsigned long *) &filter_stack_data
[ref
->offset
];
1838 estack_ax(stack
, top
)->u
.s
.str
=
1839 *(const char **) (&filter_stack_data
[ref
->offset
1840 + sizeof(unsigned long)]);
1841 estack_ax_t
= REG_STRING
;
1842 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1843 dbg_printf("Filter warning: loading a NULL sequence.\n");
1847 estack_ax(stack
, top
)->u
.s
.literal_type
=
1848 ESTACK_STRING_LITERAL_TYPE_NONE
;
1849 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1853 OP(FILTER_OP_LOAD_FIELD_REF_S64
):
1855 struct load_op
*insn
= (struct load_op
*) pc
;
1856 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1858 dbg_printf("load field ref offset %u type s64\n",
1860 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1862 ((struct literal_numeric
*) &filter_stack_data
[ref
->offset
])->v
;
1863 estack_ax_t
= REG_S64
;
1864 dbg_printf("ref load s64 %" PRIi64
"\n", estack_ax_v
);
1865 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1869 OP(FILTER_OP_LOAD_FIELD_REF_DOUBLE
):
1871 struct load_op
*insn
= (struct load_op
*) pc
;
1872 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1874 dbg_printf("load field ref offset %u type double\n",
1876 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1877 memcpy(&estack_ax(stack
, top
)->u
.d
, &filter_stack_data
[ref
->offset
],
1878 sizeof(struct literal_double
));
1879 estack_ax_t
= REG_DOUBLE
;
1880 dbg_printf("ref load double %g\n", estack_ax(stack
, top
)->u
.d
);
1881 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1885 /* load from immediate operand */
1886 OP(FILTER_OP_LOAD_STRING
):
1888 struct load_op
*insn
= (struct load_op
*) pc
;
1890 dbg_printf("load string %s\n", insn
->data
);
1891 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1892 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1893 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1894 estack_ax(stack
, top
)->u
.s
.literal_type
=
1895 ESTACK_STRING_LITERAL_TYPE_PLAIN
;
1896 estack_ax_t
= REG_STRING
;
1897 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1901 OP(FILTER_OP_LOAD_STAR_GLOB_STRING
):
1903 struct load_op
*insn
= (struct load_op
*) pc
;
1905 dbg_printf("load globbing pattern %s\n", insn
->data
);
1906 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1907 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1908 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1909 estack_ax(stack
, top
)->u
.s
.literal_type
=
1910 ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
;
1911 estack_ax_t
= REG_STAR_GLOB_STRING
;
1912 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1916 OP(FILTER_OP_LOAD_S64
):
1918 struct load_op
*insn
= (struct load_op
*) pc
;
1920 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1921 estack_ax_v
= ((struct literal_numeric
*) insn
->data
)->v
;
1922 estack_ax_t
= REG_S64
;
1923 dbg_printf("load s64 %" PRIi64
"\n", estack_ax_v
);
1924 next_pc
+= sizeof(struct load_op
)
1925 + sizeof(struct literal_numeric
);
1929 OP(FILTER_OP_LOAD_DOUBLE
):
1931 struct load_op
*insn
= (struct load_op
*) pc
;
1933 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1934 memcpy(&estack_ax(stack
, top
)->u
.d
, insn
->data
,
1935 sizeof(struct literal_double
));
1936 estack_ax_t
= REG_DOUBLE
;
1937 dbg_printf("load double %g\n", estack_ax(stack
, top
)->u
.d
);
1938 next_pc
+= sizeof(struct load_op
)
1939 + sizeof(struct literal_double
);
1944 OP(FILTER_OP_CAST_TO_S64
):
1946 /* Dynamic typing. */
1947 switch (estack_ax_t
) {
1949 JUMP_TO(FILTER_OP_CAST_NOP
);
1951 JUMP_TO(FILTER_OP_CAST_DOUBLE_TO_S64
);
1952 case REG_STRING
: /* Fall-through */
1953 case REG_STAR_GLOB_STRING
:
1957 ERR("Unknown filter register type (%d)",
1964 OP(FILTER_OP_CAST_DOUBLE_TO_S64
):
1966 estack_ax_v
= (int64_t) estack_ax(stack
, top
)->u
.d
;
1967 estack_ax_t
= REG_S64
;
1968 next_pc
+= sizeof(struct cast_op
);
1972 OP(FILTER_OP_CAST_NOP
):
1974 next_pc
+= sizeof(struct cast_op
);
1978 /* get context ref */
1979 OP(FILTER_OP_GET_CONTEXT_REF
):
1981 struct load_op
*insn
= (struct load_op
*) pc
;
1982 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1983 struct lttng_ctx
*ctx
;
1984 struct lttng_ctx_field
*ctx_field
;
1985 struct lttng_ctx_value v
;
1987 dbg_printf("get context ref offset %u type dynamic\n",
1989 ctx
= rcu_dereference(session
->ctx
);
1990 ctx_field
= &ctx
->fields
[ref
->offset
];
1991 ctx_field
->get_value(ctx_field
, &v
);
1992 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1994 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
1997 case LTTNG_UST_DYNAMIC_TYPE_S64
:
1998 estack_ax_v
= v
.u
.s64
;
1999 estack_ax_t
= REG_S64
;
2000 dbg_printf("ref get context dynamic s64 %" PRIi64
"\n", estack_ax_v
);
2002 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
2003 estack_ax(stack
, top
)->u
.d
= v
.u
.d
;
2004 estack_ax_t
= REG_DOUBLE
;
2005 dbg_printf("ref get context dynamic double %g\n", estack_ax(stack
, top
)->u
.d
);
2007 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
2008 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2009 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2010 dbg_printf("Filter warning: loading a NULL string.\n");
2014 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2015 estack_ax(stack
, top
)->u
.s
.literal_type
=
2016 ESTACK_STRING_LITERAL_TYPE_NONE
;
2017 dbg_printf("ref get context dynamic string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2018 estack_ax_t
= REG_STRING
;
2021 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
2025 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2029 OP(FILTER_OP_GET_CONTEXT_REF_STRING
):
2031 struct load_op
*insn
= (struct load_op
*) pc
;
2032 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2033 struct lttng_ctx
*ctx
;
2034 struct lttng_ctx_field
*ctx_field
;
2035 struct lttng_ctx_value v
;
2037 dbg_printf("get context ref offset %u type string\n",
2039 ctx
= rcu_dereference(session
->ctx
);
2040 ctx_field
= &ctx
->fields
[ref
->offset
];
2041 ctx_field
->get_value(ctx_field
, &v
);
2042 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2043 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2044 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2045 dbg_printf("Filter warning: loading a NULL string.\n");
2049 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2050 estack_ax(stack
, top
)->u
.s
.literal_type
=
2051 ESTACK_STRING_LITERAL_TYPE_NONE
;
2052 estack_ax_t
= REG_STRING
;
2053 dbg_printf("ref get context string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2054 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2058 OP(FILTER_OP_GET_CONTEXT_REF_S64
):
2060 struct load_op
*insn
= (struct load_op
*) pc
;
2061 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2062 struct lttng_ctx
*ctx
;
2063 struct lttng_ctx_field
*ctx_field
;
2064 struct lttng_ctx_value v
;
2066 dbg_printf("get context ref offset %u type s64\n",
2068 ctx
= rcu_dereference(session
->ctx
);
2069 ctx_field
= &ctx
->fields
[ref
->offset
];
2070 ctx_field
->get_value(ctx_field
, &v
);
2071 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2072 estack_ax_v
= v
.u
.s64
;
2073 estack_ax_t
= REG_S64
;
2074 dbg_printf("ref get context s64 %" PRIi64
"\n", estack_ax_v
);
2075 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2079 OP(FILTER_OP_GET_CONTEXT_REF_DOUBLE
):
2081 struct load_op
*insn
= (struct load_op
*) pc
;
2082 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2083 struct lttng_ctx
*ctx
;
2084 struct lttng_ctx_field
*ctx_field
;
2085 struct lttng_ctx_value v
;
2087 dbg_printf("get context ref offset %u type double\n",
2089 ctx
= rcu_dereference(session
->ctx
);
2090 ctx_field
= &ctx
->fields
[ref
->offset
];
2091 ctx_field
->get_value(ctx_field
, &v
);
2092 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2093 memcpy(&estack_ax(stack
, top
)->u
.d
, &v
.u
.d
, sizeof(struct literal_double
));
2094 estack_ax_t
= REG_DOUBLE
;
2095 dbg_printf("ref get context double %g\n", estack_ax(stack
, top
)->u
.d
);
2096 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2100 OP(FILTER_OP_GET_CONTEXT_ROOT
):
2102 dbg_printf("op get context root\n");
2103 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2104 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_CONTEXT
;
2105 /* "field" only needed for variants. */
2106 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2107 estack_ax_t
= REG_PTR
;
2108 next_pc
+= sizeof(struct load_op
);
2112 OP(FILTER_OP_GET_APP_CONTEXT_ROOT
):
2114 dbg_printf("op get app context root\n");
2115 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2116 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_APP_CONTEXT
;
2117 /* "field" only needed for variants. */
2118 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2119 estack_ax_t
= REG_PTR
;
2120 next_pc
+= sizeof(struct load_op
);
2124 OP(FILTER_OP_GET_PAYLOAD_ROOT
):
2126 dbg_printf("op get app payload root\n");
2127 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2128 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_PAYLOAD
;
2129 estack_ax(stack
, top
)->u
.ptr
.ptr
= filter_stack_data
;
2130 /* "field" only needed for variants. */
2131 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2132 estack_ax_t
= REG_PTR
;
2133 next_pc
+= sizeof(struct load_op
);
2137 OP(FILTER_OP_GET_SYMBOL
):
2139 dbg_printf("op get symbol\n");
2140 switch (estack_ax(stack
, top
)->u
.ptr
.type
) {
2142 ERR("Nested fields not implemented yet.");
2145 case LOAD_ROOT_CONTEXT
:
2146 case LOAD_ROOT_APP_CONTEXT
:
2147 case LOAD_ROOT_PAYLOAD
:
2149 * symbol lookup is performed by
2155 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_symbol
);
2159 OP(FILTER_OP_GET_SYMBOL_FIELD
):
2162 * Used for first variant encountered in a
2163 * traversal. Variants are not implemented yet.
2169 OP(FILTER_OP_GET_INDEX_U16
):
2171 struct load_op
*insn
= (struct load_op
*) pc
;
2172 struct get_index_u16
*index
= (struct get_index_u16
*) insn
->data
;
2174 dbg_printf("op get index u16\n");
2175 ret
= dynamic_get_index(session
, bytecode
, index
->index
, estack_ax(stack
, top
));
2178 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2179 estack_ax_t
= estack_ax(stack
, top
)->type
;
2180 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u16
);
2184 OP(FILTER_OP_GET_INDEX_U64
):
2186 struct load_op
*insn
= (struct load_op
*) pc
;
2187 struct get_index_u64
*index
= (struct get_index_u64
*) insn
->data
;
2189 dbg_printf("op get index u64\n");
2190 ret
= dynamic_get_index(session
, bytecode
, index
->index
, estack_ax(stack
, top
));
2193 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2194 estack_ax_t
= estack_ax(stack
, top
)->type
;
2195 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u64
);
2199 OP(FILTER_OP_LOAD_FIELD
):
2201 dbg_printf("op load field\n");
2202 ret
= dynamic_load_field(estack_ax(stack
, top
));
2205 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2206 estack_ax_t
= estack_ax(stack
, top
)->type
;
2207 next_pc
+= sizeof(struct load_op
);
2211 OP(FILTER_OP_LOAD_FIELD_S8
):
2213 dbg_printf("op load field s8\n");
2215 estack_ax_v
= *(int8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2216 estack_ax_t
= REG_S64
;
2217 next_pc
+= sizeof(struct load_op
);
2220 OP(FILTER_OP_LOAD_FIELD_S16
):
2222 dbg_printf("op load field s16\n");
2224 estack_ax_v
= *(int16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2225 estack_ax_t
= REG_S64
;
2226 next_pc
+= sizeof(struct load_op
);
2229 OP(FILTER_OP_LOAD_FIELD_S32
):
2231 dbg_printf("op load field s32\n");
2233 estack_ax_v
= *(int32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2234 estack_ax_t
= REG_S64
;
2235 next_pc
+= sizeof(struct load_op
);
2238 OP(FILTER_OP_LOAD_FIELD_S64
):
2240 dbg_printf("op load field s64\n");
2242 estack_ax_v
= *(int64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2243 estack_ax_t
= REG_S64
;
2244 next_pc
+= sizeof(struct load_op
);
2247 OP(FILTER_OP_LOAD_FIELD_U8
):
2249 dbg_printf("op load field u8\n");
2251 estack_ax_v
= *(uint8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2252 estack_ax_t
= REG_S64
;
2253 next_pc
+= sizeof(struct load_op
);
2256 OP(FILTER_OP_LOAD_FIELD_U16
):
2258 dbg_printf("op load field u16\n");
2260 estack_ax_v
= *(uint16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2261 estack_ax_t
= REG_S64
;
2262 next_pc
+= sizeof(struct load_op
);
2265 OP(FILTER_OP_LOAD_FIELD_U32
):
2267 dbg_printf("op load field u32\n");
2269 estack_ax_v
= *(uint32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2270 estack_ax_t
= REG_S64
;
2271 next_pc
+= sizeof(struct load_op
);
2274 OP(FILTER_OP_LOAD_FIELD_U64
):
2276 dbg_printf("op load field u64\n");
2278 estack_ax_v
= *(uint64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2279 estack_ax_t
= REG_S64
;
2280 next_pc
+= sizeof(struct load_op
);
2283 OP(FILTER_OP_LOAD_FIELD_DOUBLE
):
2285 dbg_printf("op load field double\n");
2287 memcpy(&estack_ax(stack
, top
)->u
.d
,
2288 estack_ax(stack
, top
)->u
.ptr
.ptr
,
2289 sizeof(struct literal_double
));
2290 estack_ax(stack
, top
)->type
= REG_DOUBLE
;
2291 next_pc
+= sizeof(struct load_op
);
2295 OP(FILTER_OP_LOAD_FIELD_STRING
):
2299 dbg_printf("op load field string\n");
2300 str
= (const char *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2301 estack_ax(stack
, top
)->u
.s
.str
= str
;
2302 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2303 dbg_printf("Filter warning: loading a NULL string.\n");
2307 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2308 estack_ax(stack
, top
)->u
.s
.literal_type
=
2309 ESTACK_STRING_LITERAL_TYPE_NONE
;
2310 estack_ax(stack
, top
)->type
= REG_STRING
;
2311 next_pc
+= sizeof(struct load_op
);
2315 OP(FILTER_OP_LOAD_FIELD_SEQUENCE
):
2319 dbg_printf("op load field string sequence\n");
2320 ptr
= estack_ax(stack
, top
)->u
.ptr
.ptr
;
2321 estack_ax(stack
, top
)->u
.s
.seq_len
= *(unsigned long *) ptr
;
2322 estack_ax(stack
, top
)->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
2323 estack_ax(stack
, top
)->type
= REG_STRING
;
2324 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2325 dbg_printf("Filter warning: loading a NULL sequence.\n");
2329 estack_ax(stack
, top
)->u
.s
.literal_type
=
2330 ESTACK_STRING_LITERAL_TYPE_NONE
;
2331 next_pc
+= sizeof(struct load_op
);
2337 /* return 0 (discard) on error */