2 * lttng-filter-interpreter.c
4 * LTTng UST filter interpreter.
6 * Copyright (C) 2010-2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 #include <urcu-pointer.h>
32 #include "lttng-filter.h"
33 #include "string-utils.h"
37 * -2: unknown escape char.
42 int parse_char(const char **p
)
62 * Returns SIZE_MAX if the string is null-terminated, or the number of
66 size_t get_str_or_seq_len(const struct estack_entry
*entry
)
68 return entry
->u
.s
.seq_len
;
72 int stack_star_glob_match(struct estack
*stack
, int top
, const char *cmp_type
)
75 const char *candidate
;
79 /* Find out which side is the pattern vs. the candidate. */
80 if (estack_ax(stack
, top
)->u
.s
.literal_type
== ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
) {
81 pattern
= estack_ax(stack
, top
)->u
.s
.str
;
82 pattern_len
= get_str_or_seq_len(estack_ax(stack
, top
));
83 candidate
= estack_bx(stack
, top
)->u
.s
.str
;
84 candidate_len
= get_str_or_seq_len(estack_bx(stack
, top
));
86 pattern
= estack_bx(stack
, top
)->u
.s
.str
;
87 pattern_len
= get_str_or_seq_len(estack_bx(stack
, top
));
88 candidate
= estack_ax(stack
, top
)->u
.s
.str
;
89 candidate_len
= get_str_or_seq_len(estack_ax(stack
, top
));
92 /* Perform the match. Returns 0 when the result is true. */
93 return !strutils_star_glob_match(pattern
, pattern_len
, candidate
,
98 int stack_strcmp(struct estack
*stack
, int top
, const char *cmp_type
)
100 const char *p
= estack_bx(stack
, top
)->u
.s
.str
, *q
= estack_ax(stack
, top
)->u
.s
.str
;
107 if (unlikely(p
- estack_bx(stack
, top
)->u
.s
.str
>= estack_bx(stack
, top
)->u
.s
.seq_len
|| *p
== '\0')) {
108 if (q
- estack_ax(stack
, top
)->u
.s
.str
>= estack_ax(stack
, top
)->u
.s
.seq_len
|| *q
== '\0') {
111 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
112 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
113 ret
= parse_char(&q
);
120 if (unlikely(q
- estack_ax(stack
, top
)->u
.s
.str
>= estack_ax(stack
, top
)->u
.s
.seq_len
|| *q
== '\0')) {
121 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
122 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
123 ret
= parse_char(&p
);
129 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
130 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
131 ret
= parse_char(&p
);
134 } else if (ret
== -2) {
137 /* else compare both char */
139 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
140 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
141 ret
= parse_char(&q
);
144 } else if (ret
== -2) {
164 uint64_t lttng_filter_false(void *filter_data
,
165 const char *filter_stack_data
)
170 #ifdef INTERPRETER_USE_SWITCH
173 * Fallback for compilers that do not support taking address of labels.
177 start_pc = &bytecode->data[0]; \
178 for (pc = next_pc = start_pc; pc - start_pc < bytecode->len; \
180 dbg_printf("Executing op %s (%u)\n", \
181 print_op((unsigned int) *(filter_opcode_t *) pc), \
182 (unsigned int) *(filter_opcode_t *) pc); \
183 switch (*(filter_opcode_t *) pc) {
185 #define OP(name) jump_target_##name: __attribute__((unused)); \
193 #define JUMP_TO(name) \
194 goto jump_target_##name
199 * Dispatch-table based interpreter.
203 start_pc = &bytecode->code[0]; \
204 pc = next_pc = start_pc; \
205 if (unlikely(pc - start_pc >= bytecode->len)) \
207 goto *dispatch[*(filter_opcode_t *) pc];
214 goto *dispatch[*(filter_opcode_t *) pc];
218 #define JUMP_TO(name) \
223 static int context_get_index(struct lttng_ctx
*ctx
,
224 struct load_ptr
*ptr
,
228 struct lttng_ctx_field
*ctx_field
;
229 struct lttng_event_field
*field
;
230 struct lttng_ctx_value v
;
232 ctx_field
= &ctx
->fields
[idx
];
233 field
= &ctx_field
->event_field
;
234 ptr
->type
= LOAD_OBJECT
;
235 /* field is only used for types nested within variants. */
238 switch (field
->type
.atype
) {
240 ctx_field
->get_value(ctx_field
, &v
);
241 if (field
->type
.u
.basic
.integer
.signedness
) {
242 ptr
->object_type
= OBJECT_TYPE_S64
;
243 ptr
->u
.s64
= v
.u
.s64
;
244 ptr
->ptr
= &ptr
->u
.s64
;
246 ptr
->object_type
= OBJECT_TYPE_U64
;
247 ptr
->u
.u64
= v
.u
.s64
; /* Cast. */
248 ptr
->ptr
= &ptr
->u
.u64
;
253 const struct lttng_integer_type
*itype
=
254 &field
->type
.u
.basic
.enumeration
.container_type
;
256 ctx_field
->get_value(ctx_field
, &v
);
257 if (itype
->signedness
) {
258 ptr
->object_type
= OBJECT_TYPE_S64
;
259 ptr
->u
.s64
= v
.u
.s64
;
260 ptr
->ptr
= &ptr
->u
.s64
;
262 ptr
->object_type
= OBJECT_TYPE_U64
;
263 ptr
->u
.u64
= v
.u
.s64
; /* Cast. */
264 ptr
->ptr
= &ptr
->u
.u64
;
269 if (field
->type
.u
.array
.elem_type
.atype
!= atype_integer
) {
270 ERR("Array nesting only supports integer types.");
273 if (field
->type
.u
.array
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
274 ERR("Only string arrays are supported for contexts.");
277 ptr
->object_type
= OBJECT_TYPE_STRING
;
278 ctx_field
->get_value(ctx_field
, &v
);
282 if (field
->type
.u
.sequence
.elem_type
.atype
!= atype_integer
) {
283 ERR("Sequence nesting only supports integer types.");
286 if (field
->type
.u
.sequence
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
287 ERR("Only string sequences are supported for contexts.");
290 ptr
->object_type
= OBJECT_TYPE_STRING
;
291 ctx_field
->get_value(ctx_field
, &v
);
295 ptr
->object_type
= OBJECT_TYPE_STRING
;
296 ctx_field
->get_value(ctx_field
, &v
);
300 ptr
->object_type
= OBJECT_TYPE_DOUBLE
;
302 ptr
->ptr
= &ptr
->u
.d
;
305 ctx_field
->get_value(ctx_field
, &v
);
307 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
309 case LTTNG_UST_DYNAMIC_TYPE_S64
:
310 ptr
->object_type
= OBJECT_TYPE_S64
;
311 ptr
->u
.s64
= v
.u
.s64
;
312 ptr
->ptr
= &ptr
->u
.s64
;
313 dbg_printf("context get index dynamic s64 %" PRIi64
"\n", ptr
->u
.s64
);
315 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
316 ptr
->object_type
= OBJECT_TYPE_DOUBLE
;
318 ptr
->ptr
= &ptr
->u
.d
;
319 dbg_printf("context get index dynamic double %g\n", ptr
->u
.d
);
321 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
322 ptr
->object_type
= OBJECT_TYPE_STRING
;
324 dbg_printf("context get index dynamic string %s\n", (const char *) ptr
->ptr
);
327 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
332 ERR("Structure type cannot be loaded.");
335 ERR("Unknown type: %d", (int) field
->type
.atype
);
341 static int dynamic_get_index(struct lttng_session
*session
,
342 struct bytecode_runtime
*runtime
,
343 uint64_t index
, struct estack_entry
*stack_top
)
346 const struct filter_get_index_data
*gid
;
349 * Types nested within variants need to perform dynamic lookup
350 * based on the field descriptions. LTTng-UST does not implement
353 if (stack_top
->u
.ptr
.field
)
355 gid
= (const struct filter_get_index_data
*) &runtime
->data
[index
];
356 switch (stack_top
->u
.ptr
.type
) {
358 switch (stack_top
->u
.ptr
.object_type
) {
359 case OBJECT_TYPE_ARRAY
:
363 assert(gid
->offset
< gid
->array_len
);
364 /* Skip count (unsigned long) */
365 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
366 ptr
= ptr
+ gid
->offset
;
367 stack_top
->u
.ptr
.ptr
= ptr
;
368 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
369 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
370 /* field is only used for types nested within variants. */
371 stack_top
->u
.ptr
.field
= NULL
;
374 case OBJECT_TYPE_SEQUENCE
:
379 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
380 ptr_seq_len
= *(unsigned long *) stack_top
->u
.ptr
.ptr
;
381 if (gid
->offset
>= gid
->elem
.len
* ptr_seq_len
) {
385 ptr
= ptr
+ gid
->offset
;
386 stack_top
->u
.ptr
.ptr
= ptr
;
387 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
388 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
389 /* field is only used for types nested within variants. */
390 stack_top
->u
.ptr
.field
= NULL
;
393 case OBJECT_TYPE_STRUCT
:
394 ERR("Nested structures are not supported yet.");
397 case OBJECT_TYPE_VARIANT
:
399 ERR("Unexpected get index type %d",
400 (int) stack_top
->u
.ptr
.object_type
);
405 case LOAD_ROOT_CONTEXT
:
406 case LOAD_ROOT_APP_CONTEXT
: /* Fall-through */
408 struct lttng_ctx
*ctx
;
410 ctx
= rcu_dereference(session
->ctx
);
411 ret
= context_get_index(ctx
,
419 case LOAD_ROOT_PAYLOAD
:
420 stack_top
->u
.ptr
.ptr
+= gid
->offset
;
421 if (gid
->elem
.type
== OBJECT_TYPE_STRING
)
422 stack_top
->u
.ptr
.ptr
= *(const char * const *) stack_top
->u
.ptr
.ptr
;
423 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
424 stack_top
->u
.ptr
.type
= LOAD_OBJECT
;
425 /* field is only used for types nested within variants. */
426 stack_top
->u
.ptr
.field
= NULL
;
435 static int dynamic_load_field(struct estack_entry
*stack_top
)
439 switch (stack_top
->u
.ptr
.type
) {
442 case LOAD_ROOT_CONTEXT
:
443 case LOAD_ROOT_APP_CONTEXT
:
444 case LOAD_ROOT_PAYLOAD
:
446 dbg_printf("Filter warning: cannot load root, missing field name.\n");
450 switch (stack_top
->u
.ptr
.object_type
) {
452 dbg_printf("op load field s8\n");
453 stack_top
->u
.v
= *(int8_t *) stack_top
->u
.ptr
.ptr
;
454 stack_top
->type
= REG_S64
;
456 case OBJECT_TYPE_S16
:
460 dbg_printf("op load field s16\n");
461 tmp
= *(int16_t *) stack_top
->u
.ptr
.ptr
;
462 if (stack_top
->u
.ptr
.rev_bo
)
464 stack_top
->u
.v
= tmp
;
465 stack_top
->type
= REG_S64
;
468 case OBJECT_TYPE_S32
:
472 dbg_printf("op load field s32\n");
473 tmp
= *(int32_t *) stack_top
->u
.ptr
.ptr
;
474 if (stack_top
->u
.ptr
.rev_bo
)
476 stack_top
->u
.v
= tmp
;
477 stack_top
->type
= REG_S64
;
480 case OBJECT_TYPE_S64
:
484 dbg_printf("op load field s64\n");
485 tmp
= *(int64_t *) stack_top
->u
.ptr
.ptr
;
486 if (stack_top
->u
.ptr
.rev_bo
)
488 stack_top
->u
.v
= tmp
;
489 stack_top
->type
= REG_S64
;
493 dbg_printf("op load field u8\n");
494 stack_top
->u
.v
= *(uint8_t *) stack_top
->u
.ptr
.ptr
;
495 stack_top
->type
= REG_S64
;
497 case OBJECT_TYPE_U16
:
501 dbg_printf("op load field s16\n");
502 tmp
= *(uint16_t *) stack_top
->u
.ptr
.ptr
;
503 if (stack_top
->u
.ptr
.rev_bo
)
505 stack_top
->u
.v
= tmp
;
506 stack_top
->type
= REG_S64
;
509 case OBJECT_TYPE_U32
:
513 dbg_printf("op load field u32\n");
514 tmp
= *(uint32_t *) stack_top
->u
.ptr
.ptr
;
515 if (stack_top
->u
.ptr
.rev_bo
)
517 stack_top
->u
.v
= tmp
;
518 stack_top
->type
= REG_S64
;
521 case OBJECT_TYPE_U64
:
525 dbg_printf("op load field u64\n");
526 tmp
= *(uint64_t *) stack_top
->u
.ptr
.ptr
;
527 if (stack_top
->u
.ptr
.rev_bo
)
529 stack_top
->u
.v
= tmp
;
530 stack_top
->type
= REG_S64
;
533 case OBJECT_TYPE_DOUBLE
:
534 memcpy(&stack_top
->u
.d
,
535 stack_top
->u
.ptr
.ptr
,
536 sizeof(struct literal_double
));
537 stack_top
->type
= REG_DOUBLE
;
539 case OBJECT_TYPE_STRING
:
543 dbg_printf("op load field string\n");
544 str
= (const char *) stack_top
->u
.ptr
.ptr
;
545 stack_top
->u
.s
.str
= str
;
546 if (unlikely(!stack_top
->u
.s
.str
)) {
547 dbg_printf("Filter warning: loading a NULL string.\n");
551 stack_top
->u
.s
.seq_len
= SIZE_MAX
;
552 stack_top
->u
.s
.literal_type
=
553 ESTACK_STRING_LITERAL_TYPE_NONE
;
554 stack_top
->type
= REG_STRING
;
557 case OBJECT_TYPE_STRING_SEQUENCE
:
561 dbg_printf("op load field string sequence\n");
562 ptr
= stack_top
->u
.ptr
.ptr
;
563 stack_top
->u
.s
.seq_len
= *(unsigned long *) ptr
;
564 stack_top
->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
565 stack_top
->type
= REG_STRING
;
566 if (unlikely(!stack_top
->u
.s
.str
)) {
567 dbg_printf("Filter warning: loading a NULL sequence.\n");
571 stack_top
->u
.s
.literal_type
=
572 ESTACK_STRING_LITERAL_TYPE_NONE
;
575 case OBJECT_TYPE_DYNAMIC
:
577 * Dynamic types in context are looked up
578 * by context get index.
582 case OBJECT_TYPE_SEQUENCE
:
583 case OBJECT_TYPE_ARRAY
:
584 case OBJECT_TYPE_STRUCT
:
585 case OBJECT_TYPE_VARIANT
:
586 ERR("Sequences, arrays, struct and variant cannot be loaded (nested types).");
597 * Return 0 (discard), or raise the 0x1 flag (log event).
598 * Currently, other flags are kept for future extensions and have no
601 uint64_t lttng_filter_interpret_bytecode(void *filter_data
,
602 const char *filter_stack_data
)
604 struct bytecode_runtime
*bytecode
= filter_data
;
605 struct lttng_session
*session
= bytecode
->p
.session
;
606 void *pc
, *next_pc
, *start_pc
;
609 struct estack _stack
;
610 struct estack
*stack
= &_stack
;
611 register int64_t ax
= 0, bx
= 0;
612 register enum entry_type ax_t
= REG_UNKNOWN
, bx_t
= REG_UNKNOWN
;
613 register int top
= FILTER_STACK_EMPTY
;
614 #ifndef INTERPRETER_USE_SWITCH
615 static void *dispatch
[NR_FILTER_OPS
] = {
616 [ FILTER_OP_UNKNOWN
] = &&LABEL_FILTER_OP_UNKNOWN
,
618 [ FILTER_OP_RETURN
] = &&LABEL_FILTER_OP_RETURN
,
621 [ FILTER_OP_MUL
] = &&LABEL_FILTER_OP_MUL
,
622 [ FILTER_OP_DIV
] = &&LABEL_FILTER_OP_DIV
,
623 [ FILTER_OP_MOD
] = &&LABEL_FILTER_OP_MOD
,
624 [ FILTER_OP_PLUS
] = &&LABEL_FILTER_OP_PLUS
,
625 [ FILTER_OP_MINUS
] = &&LABEL_FILTER_OP_MINUS
,
626 [ FILTER_OP_BIT_RSHIFT
] = &&LABEL_FILTER_OP_BIT_RSHIFT
,
627 [ FILTER_OP_BIT_LSHIFT
] = &&LABEL_FILTER_OP_BIT_LSHIFT
,
628 [ FILTER_OP_BIT_AND
] = &&LABEL_FILTER_OP_BIT_AND
,
629 [ FILTER_OP_BIT_OR
] = &&LABEL_FILTER_OP_BIT_OR
,
630 [ FILTER_OP_BIT_XOR
] = &&LABEL_FILTER_OP_BIT_XOR
,
632 /* binary comparators */
633 [ FILTER_OP_EQ
] = &&LABEL_FILTER_OP_EQ
,
634 [ FILTER_OP_NE
] = &&LABEL_FILTER_OP_NE
,
635 [ FILTER_OP_GT
] = &&LABEL_FILTER_OP_GT
,
636 [ FILTER_OP_LT
] = &&LABEL_FILTER_OP_LT
,
637 [ FILTER_OP_GE
] = &&LABEL_FILTER_OP_GE
,
638 [ FILTER_OP_LE
] = &&LABEL_FILTER_OP_LE
,
640 /* string binary comparator */
641 [ FILTER_OP_EQ_STRING
] = &&LABEL_FILTER_OP_EQ_STRING
,
642 [ FILTER_OP_NE_STRING
] = &&LABEL_FILTER_OP_NE_STRING
,
643 [ FILTER_OP_GT_STRING
] = &&LABEL_FILTER_OP_GT_STRING
,
644 [ FILTER_OP_LT_STRING
] = &&LABEL_FILTER_OP_LT_STRING
,
645 [ FILTER_OP_GE_STRING
] = &&LABEL_FILTER_OP_GE_STRING
,
646 [ FILTER_OP_LE_STRING
] = &&LABEL_FILTER_OP_LE_STRING
,
648 /* globbing pattern binary comparator */
649 [ FILTER_OP_EQ_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_EQ_STAR_GLOB_STRING
,
650 [ FILTER_OP_NE_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_NE_STAR_GLOB_STRING
,
652 /* s64 binary comparator */
653 [ FILTER_OP_EQ_S64
] = &&LABEL_FILTER_OP_EQ_S64
,
654 [ FILTER_OP_NE_S64
] = &&LABEL_FILTER_OP_NE_S64
,
655 [ FILTER_OP_GT_S64
] = &&LABEL_FILTER_OP_GT_S64
,
656 [ FILTER_OP_LT_S64
] = &&LABEL_FILTER_OP_LT_S64
,
657 [ FILTER_OP_GE_S64
] = &&LABEL_FILTER_OP_GE_S64
,
658 [ FILTER_OP_LE_S64
] = &&LABEL_FILTER_OP_LE_S64
,
660 /* double binary comparator */
661 [ FILTER_OP_EQ_DOUBLE
] = &&LABEL_FILTER_OP_EQ_DOUBLE
,
662 [ FILTER_OP_NE_DOUBLE
] = &&LABEL_FILTER_OP_NE_DOUBLE
,
663 [ FILTER_OP_GT_DOUBLE
] = &&LABEL_FILTER_OP_GT_DOUBLE
,
664 [ FILTER_OP_LT_DOUBLE
] = &&LABEL_FILTER_OP_LT_DOUBLE
,
665 [ FILTER_OP_GE_DOUBLE
] = &&LABEL_FILTER_OP_GE_DOUBLE
,
666 [ FILTER_OP_LE_DOUBLE
] = &&LABEL_FILTER_OP_LE_DOUBLE
,
668 /* Mixed S64-double binary comparators */
669 [ FILTER_OP_EQ_DOUBLE_S64
] = &&LABEL_FILTER_OP_EQ_DOUBLE_S64
,
670 [ FILTER_OP_NE_DOUBLE_S64
] = &&LABEL_FILTER_OP_NE_DOUBLE_S64
,
671 [ FILTER_OP_GT_DOUBLE_S64
] = &&LABEL_FILTER_OP_GT_DOUBLE_S64
,
672 [ FILTER_OP_LT_DOUBLE_S64
] = &&LABEL_FILTER_OP_LT_DOUBLE_S64
,
673 [ FILTER_OP_GE_DOUBLE_S64
] = &&LABEL_FILTER_OP_GE_DOUBLE_S64
,
674 [ FILTER_OP_LE_DOUBLE_S64
] = &&LABEL_FILTER_OP_LE_DOUBLE_S64
,
676 [ FILTER_OP_EQ_S64_DOUBLE
] = &&LABEL_FILTER_OP_EQ_S64_DOUBLE
,
677 [ FILTER_OP_NE_S64_DOUBLE
] = &&LABEL_FILTER_OP_NE_S64_DOUBLE
,
678 [ FILTER_OP_GT_S64_DOUBLE
] = &&LABEL_FILTER_OP_GT_S64_DOUBLE
,
679 [ FILTER_OP_LT_S64_DOUBLE
] = &&LABEL_FILTER_OP_LT_S64_DOUBLE
,
680 [ FILTER_OP_GE_S64_DOUBLE
] = &&LABEL_FILTER_OP_GE_S64_DOUBLE
,
681 [ FILTER_OP_LE_S64_DOUBLE
] = &&LABEL_FILTER_OP_LE_S64_DOUBLE
,
684 [ FILTER_OP_UNARY_PLUS
] = &&LABEL_FILTER_OP_UNARY_PLUS
,
685 [ FILTER_OP_UNARY_MINUS
] = &&LABEL_FILTER_OP_UNARY_MINUS
,
686 [ FILTER_OP_UNARY_NOT
] = &&LABEL_FILTER_OP_UNARY_NOT
,
687 [ FILTER_OP_UNARY_PLUS_S64
] = &&LABEL_FILTER_OP_UNARY_PLUS_S64
,
688 [ FILTER_OP_UNARY_MINUS_S64
] = &&LABEL_FILTER_OP_UNARY_MINUS_S64
,
689 [ FILTER_OP_UNARY_NOT_S64
] = &&LABEL_FILTER_OP_UNARY_NOT_S64
,
690 [ FILTER_OP_UNARY_PLUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_PLUS_DOUBLE
,
691 [ FILTER_OP_UNARY_MINUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_MINUS_DOUBLE
,
692 [ FILTER_OP_UNARY_NOT_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_NOT_DOUBLE
,
695 [ FILTER_OP_AND
] = &&LABEL_FILTER_OP_AND
,
696 [ FILTER_OP_OR
] = &&LABEL_FILTER_OP_OR
,
699 [ FILTER_OP_LOAD_FIELD_REF
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF
,
700 [ FILTER_OP_LOAD_FIELD_REF_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_STRING
,
701 [ FILTER_OP_LOAD_FIELD_REF_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_SEQUENCE
,
702 [ FILTER_OP_LOAD_FIELD_REF_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_S64
,
703 [ FILTER_OP_LOAD_FIELD_REF_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_DOUBLE
,
705 /* load from immediate operand */
706 [ FILTER_OP_LOAD_STRING
] = &&LABEL_FILTER_OP_LOAD_STRING
,
707 [ FILTER_OP_LOAD_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_LOAD_STAR_GLOB_STRING
,
708 [ FILTER_OP_LOAD_S64
] = &&LABEL_FILTER_OP_LOAD_S64
,
709 [ FILTER_OP_LOAD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_DOUBLE
,
712 [ FILTER_OP_CAST_TO_S64
] = &&LABEL_FILTER_OP_CAST_TO_S64
,
713 [ FILTER_OP_CAST_DOUBLE_TO_S64
] = &&LABEL_FILTER_OP_CAST_DOUBLE_TO_S64
,
714 [ FILTER_OP_CAST_NOP
] = &&LABEL_FILTER_OP_CAST_NOP
,
716 /* get context ref */
717 [ FILTER_OP_GET_CONTEXT_REF
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF
,
718 [ FILTER_OP_GET_CONTEXT_REF_STRING
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_STRING
,
719 [ FILTER_OP_GET_CONTEXT_REF_S64
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_S64
,
720 [ FILTER_OP_GET_CONTEXT_REF_DOUBLE
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_DOUBLE
,
722 /* Instructions for recursive traversal through composed types. */
723 [ FILTER_OP_GET_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_CONTEXT_ROOT
,
724 [ FILTER_OP_GET_APP_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_APP_CONTEXT_ROOT
,
725 [ FILTER_OP_GET_PAYLOAD_ROOT
] = &&LABEL_FILTER_OP_GET_PAYLOAD_ROOT
,
727 [ FILTER_OP_GET_SYMBOL
] = &&LABEL_FILTER_OP_GET_SYMBOL
,
728 [ FILTER_OP_GET_SYMBOL_FIELD
] = &&LABEL_FILTER_OP_GET_SYMBOL_FIELD
,
729 [ FILTER_OP_GET_INDEX_U16
] = &&LABEL_FILTER_OP_GET_INDEX_U16
,
730 [ FILTER_OP_GET_INDEX_U64
] = &&LABEL_FILTER_OP_GET_INDEX_U64
,
732 [ FILTER_OP_LOAD_FIELD
] = &&LABEL_FILTER_OP_LOAD_FIELD
,
733 [ FILTER_OP_LOAD_FIELD_S8
] = &&LABEL_FILTER_OP_LOAD_FIELD_S8
,
734 [ FILTER_OP_LOAD_FIELD_S16
] = &&LABEL_FILTER_OP_LOAD_FIELD_S16
,
735 [ FILTER_OP_LOAD_FIELD_S32
] = &&LABEL_FILTER_OP_LOAD_FIELD_S32
,
736 [ FILTER_OP_LOAD_FIELD_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_S64
,
737 [ FILTER_OP_LOAD_FIELD_U8
] = &&LABEL_FILTER_OP_LOAD_FIELD_U8
,
738 [ FILTER_OP_LOAD_FIELD_U16
] = &&LABEL_FILTER_OP_LOAD_FIELD_U16
,
739 [ FILTER_OP_LOAD_FIELD_U32
] = &&LABEL_FILTER_OP_LOAD_FIELD_U32
,
740 [ FILTER_OP_LOAD_FIELD_U64
] = &&LABEL_FILTER_OP_LOAD_FIELD_U64
,
741 [ FILTER_OP_LOAD_FIELD_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_STRING
,
742 [ FILTER_OP_LOAD_FIELD_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_SEQUENCE
,
743 [ FILTER_OP_LOAD_FIELD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_DOUBLE
,
745 [ FILTER_OP_UNARY_BIT_NOT
] = &&LABEL_FILTER_OP_UNARY_BIT_NOT
,
747 [ FILTER_OP_RETURN_S64
] = &&LABEL_FILTER_OP_RETURN_S64
,
749 #endif /* #ifndef INTERPRETER_USE_SWITCH */
753 OP(FILTER_OP_UNKNOWN
):
754 OP(FILTER_OP_LOAD_FIELD_REF
):
755 #ifdef INTERPRETER_USE_SWITCH
757 #endif /* INTERPRETER_USE_SWITCH */
758 ERR("unknown bytecode op %u",
759 (unsigned int) *(filter_opcode_t
*) pc
);
763 OP(FILTER_OP_RETURN
):
764 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
765 /* Handle dynamic typing. */
766 switch (estack_ax_t
) {
768 retval
= !!estack_ax_v
;
772 case REG_STAR_GLOB_STRING
:
780 OP(FILTER_OP_RETURN_S64
):
781 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
782 retval
= !!estack_ax_v
;
792 ERR("unsupported bytecode op %u",
793 (unsigned int) *(filter_opcode_t
*) pc
);
799 /* Dynamic typing. */
800 switch (estack_ax_t
) {
802 switch (estack_bx_t
) {
804 JUMP_TO(FILTER_OP_EQ_S64
);
806 JUMP_TO(FILTER_OP_EQ_DOUBLE_S64
);
807 case REG_STRING
: /* Fall-through */
808 case REG_STAR_GLOB_STRING
:
812 ERR("Unknown filter register type (%d)",
819 switch (estack_bx_t
) {
821 JUMP_TO(FILTER_OP_EQ_S64_DOUBLE
);
823 JUMP_TO(FILTER_OP_EQ_DOUBLE
);
824 case REG_STRING
: /* Fall-through */
825 case REG_STAR_GLOB_STRING
:
829 ERR("Unknown filter register type (%d)",
836 switch (estack_bx_t
) {
837 case REG_S64
: /* Fall-through */
842 JUMP_TO(FILTER_OP_EQ_STRING
);
843 case REG_STAR_GLOB_STRING
:
844 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
846 ERR("Unknown filter register type (%d)",
852 case REG_STAR_GLOB_STRING
:
853 switch (estack_bx_t
) {
854 case REG_S64
: /* Fall-through */
859 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
860 case REG_STAR_GLOB_STRING
:
864 ERR("Unknown filter register type (%d)",
871 ERR("Unknown filter register type (%d)",
879 /* Dynamic typing. */
880 switch (estack_ax_t
) {
882 switch (estack_bx_t
) {
884 JUMP_TO(FILTER_OP_NE_S64
);
886 JUMP_TO(FILTER_OP_NE_DOUBLE_S64
);
887 case REG_STRING
: /* Fall-through */
888 case REG_STAR_GLOB_STRING
:
892 ERR("Unknown filter register type (%d)",
899 switch (estack_bx_t
) {
901 JUMP_TO(FILTER_OP_NE_S64_DOUBLE
);
903 JUMP_TO(FILTER_OP_NE_DOUBLE
);
904 case REG_STRING
: /* Fall-through */
905 case REG_STAR_GLOB_STRING
:
909 ERR("Unknown filter register type (%d)",
916 switch (estack_bx_t
) {
917 case REG_S64
: /* Fall-through */
922 JUMP_TO(FILTER_OP_NE_STRING
);
923 case REG_STAR_GLOB_STRING
:
924 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
926 ERR("Unknown filter register type (%d)",
932 case REG_STAR_GLOB_STRING
:
933 switch (estack_bx_t
) {
934 case REG_S64
: /* Fall-through */
939 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
940 case REG_STAR_GLOB_STRING
:
944 ERR("Unknown filter register type (%d)",
951 ERR("Unknown filter register type (%d)",
959 /* Dynamic typing. */
960 switch (estack_ax_t
) {
962 switch (estack_bx_t
) {
964 JUMP_TO(FILTER_OP_GT_S64
);
966 JUMP_TO(FILTER_OP_GT_DOUBLE_S64
);
967 case REG_STRING
: /* Fall-through */
968 case REG_STAR_GLOB_STRING
:
972 ERR("Unknown filter register type (%d)",
979 switch (estack_bx_t
) {
981 JUMP_TO(FILTER_OP_GT_S64_DOUBLE
);
983 JUMP_TO(FILTER_OP_GT_DOUBLE
);
984 case REG_STRING
: /* Fall-through */
985 case REG_STAR_GLOB_STRING
:
989 ERR("Unknown filter register type (%d)",
996 switch (estack_bx_t
) {
997 case REG_S64
: /* Fall-through */
998 case REG_DOUBLE
: /* Fall-through */
999 case REG_STAR_GLOB_STRING
:
1003 JUMP_TO(FILTER_OP_GT_STRING
);
1005 ERR("Unknown filter register type (%d)",
1012 ERR("Unknown filter register type (%d)",
1020 /* Dynamic typing. */
1021 switch (estack_ax_t
) {
1023 switch (estack_bx_t
) {
1025 JUMP_TO(FILTER_OP_LT_S64
);
1027 JUMP_TO(FILTER_OP_LT_DOUBLE_S64
);
1028 case REG_STRING
: /* Fall-through */
1029 case REG_STAR_GLOB_STRING
:
1033 ERR("Unknown filter register type (%d)",
1040 switch (estack_bx_t
) {
1042 JUMP_TO(FILTER_OP_LT_S64_DOUBLE
);
1044 JUMP_TO(FILTER_OP_LT_DOUBLE
);
1045 case REG_STRING
: /* Fall-through */
1046 case REG_STAR_GLOB_STRING
:
1050 ERR("Unknown filter register type (%d)",
1057 switch (estack_bx_t
) {
1058 case REG_S64
: /* Fall-through */
1059 case REG_DOUBLE
: /* Fall-through */
1060 case REG_STAR_GLOB_STRING
:
1064 JUMP_TO(FILTER_OP_LT_STRING
);
1066 ERR("Unknown filter register type (%d)",
1073 ERR("Unknown filter register type (%d)",
1081 /* Dynamic typing. */
1082 switch (estack_ax_t
) {
1084 switch (estack_bx_t
) {
1086 JUMP_TO(FILTER_OP_GE_S64
);
1088 JUMP_TO(FILTER_OP_GE_DOUBLE_S64
);
1089 case REG_STRING
: /* Fall-through */
1090 case REG_STAR_GLOB_STRING
:
1094 ERR("Unknown filter register type (%d)",
1101 switch (estack_bx_t
) {
1103 JUMP_TO(FILTER_OP_GE_S64_DOUBLE
);
1105 JUMP_TO(FILTER_OP_GE_DOUBLE
);
1106 case REG_STRING
: /* Fall-through */
1107 case REG_STAR_GLOB_STRING
:
1111 ERR("Unknown filter register type (%d)",
1118 switch (estack_bx_t
) {
1119 case REG_S64
: /* Fall-through */
1120 case REG_DOUBLE
: /* Fall-through */
1121 case REG_STAR_GLOB_STRING
:
1125 JUMP_TO(FILTER_OP_GE_STRING
);
1127 ERR("Unknown filter register type (%d)",
1134 ERR("Unknown filter register type (%d)",
1142 /* Dynamic typing. */
1143 switch (estack_ax_t
) {
1145 switch (estack_bx_t
) {
1147 JUMP_TO(FILTER_OP_LE_S64
);
1149 JUMP_TO(FILTER_OP_LE_DOUBLE_S64
);
1150 case REG_STRING
: /* Fall-through */
1151 case REG_STAR_GLOB_STRING
:
1155 ERR("Unknown filter register type (%d)",
1162 switch (estack_bx_t
) {
1164 JUMP_TO(FILTER_OP_LE_S64_DOUBLE
);
1166 JUMP_TO(FILTER_OP_LE_DOUBLE
);
1167 case REG_STRING
: /* Fall-through */
1168 case REG_STAR_GLOB_STRING
:
1172 ERR("Unknown filter register type (%d)",
1179 switch (estack_bx_t
) {
1180 case REG_S64
: /* Fall-through */
1181 case REG_DOUBLE
: /* Fall-through */
1182 case REG_STAR_GLOB_STRING
:
1186 JUMP_TO(FILTER_OP_LE_STRING
);
1188 ERR("Unknown filter register type (%d)",
1195 ERR("Unknown filter register type (%d)",
1202 OP(FILTER_OP_EQ_STRING
):
1206 res
= (stack_strcmp(stack
, top
, "==") == 0);
1207 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1209 estack_ax_t
= REG_S64
;
1210 next_pc
+= sizeof(struct binary_op
);
1213 OP(FILTER_OP_NE_STRING
):
1217 res
= (stack_strcmp(stack
, top
, "!=") != 0);
1218 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1220 estack_ax_t
= REG_S64
;
1221 next_pc
+= sizeof(struct binary_op
);
1224 OP(FILTER_OP_GT_STRING
):
1228 res
= (stack_strcmp(stack
, top
, ">") > 0);
1229 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1231 estack_ax_t
= REG_S64
;
1232 next_pc
+= sizeof(struct binary_op
);
1235 OP(FILTER_OP_LT_STRING
):
1239 res
= (stack_strcmp(stack
, top
, "<") < 0);
1240 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1242 estack_ax_t
= REG_S64
;
1243 next_pc
+= sizeof(struct binary_op
);
1246 OP(FILTER_OP_GE_STRING
):
1250 res
= (stack_strcmp(stack
, top
, ">=") >= 0);
1251 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1253 estack_ax_t
= REG_S64
;
1254 next_pc
+= sizeof(struct binary_op
);
1257 OP(FILTER_OP_LE_STRING
):
1261 res
= (stack_strcmp(stack
, top
, "<=") <= 0);
1262 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1264 estack_ax_t
= REG_S64
;
1265 next_pc
+= sizeof(struct binary_op
);
1269 OP(FILTER_OP_EQ_STAR_GLOB_STRING
):
1273 res
= (stack_star_glob_match(stack
, top
, "==") == 0);
1274 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1276 estack_ax_t
= REG_S64
;
1277 next_pc
+= sizeof(struct binary_op
);
1280 OP(FILTER_OP_NE_STAR_GLOB_STRING
):
1284 res
= (stack_star_glob_match(stack
, top
, "!=") != 0);
1285 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1287 estack_ax_t
= REG_S64
;
1288 next_pc
+= sizeof(struct binary_op
);
1292 OP(FILTER_OP_EQ_S64
):
1296 res
= (estack_bx_v
== estack_ax_v
);
1297 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1299 estack_ax_t
= REG_S64
;
1300 next_pc
+= sizeof(struct binary_op
);
1303 OP(FILTER_OP_NE_S64
):
1307 res
= (estack_bx_v
!= estack_ax_v
);
1308 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1310 estack_ax_t
= REG_S64
;
1311 next_pc
+= sizeof(struct binary_op
);
1314 OP(FILTER_OP_GT_S64
):
1318 res
= (estack_bx_v
> estack_ax_v
);
1319 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1321 estack_ax_t
= REG_S64
;
1322 next_pc
+= sizeof(struct binary_op
);
1325 OP(FILTER_OP_LT_S64
):
1329 res
= (estack_bx_v
< estack_ax_v
);
1330 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1332 estack_ax_t
= REG_S64
;
1333 next_pc
+= sizeof(struct binary_op
);
1336 OP(FILTER_OP_GE_S64
):
1340 res
= (estack_bx_v
>= estack_ax_v
);
1341 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1343 estack_ax_t
= REG_S64
;
1344 next_pc
+= sizeof(struct binary_op
);
1347 OP(FILTER_OP_LE_S64
):
1351 res
= (estack_bx_v
<= estack_ax_v
);
1352 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1354 estack_ax_t
= REG_S64
;
1355 next_pc
+= sizeof(struct binary_op
);
1359 OP(FILTER_OP_EQ_DOUBLE
):
1363 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax(stack
, top
)->u
.d
);
1364 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1366 estack_ax_t
= REG_S64
;
1367 next_pc
+= sizeof(struct binary_op
);
1370 OP(FILTER_OP_NE_DOUBLE
):
1374 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax(stack
, top
)->u
.d
);
1375 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1377 estack_ax_t
= REG_S64
;
1378 next_pc
+= sizeof(struct binary_op
);
1381 OP(FILTER_OP_GT_DOUBLE
):
1385 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax(stack
, top
)->u
.d
);
1386 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1388 estack_ax_t
= REG_S64
;
1389 next_pc
+= sizeof(struct binary_op
);
1392 OP(FILTER_OP_LT_DOUBLE
):
1396 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax(stack
, top
)->u
.d
);
1397 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1399 estack_ax_t
= REG_S64
;
1400 next_pc
+= sizeof(struct binary_op
);
1403 OP(FILTER_OP_GE_DOUBLE
):
1407 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax(stack
, top
)->u
.d
);
1408 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1410 estack_ax_t
= REG_S64
;
1411 next_pc
+= sizeof(struct binary_op
);
1414 OP(FILTER_OP_LE_DOUBLE
):
1418 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax(stack
, top
)->u
.d
);
1419 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1421 estack_ax_t
= REG_S64
;
1422 next_pc
+= sizeof(struct binary_op
);
1426 /* Mixed S64-double binary comparators */
1427 OP(FILTER_OP_EQ_DOUBLE_S64
):
1431 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax_v
);
1432 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1434 estack_ax_t
= REG_S64
;
1435 next_pc
+= sizeof(struct binary_op
);
1438 OP(FILTER_OP_NE_DOUBLE_S64
):
1442 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax_v
);
1443 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1445 estack_ax_t
= REG_S64
;
1446 next_pc
+= sizeof(struct binary_op
);
1449 OP(FILTER_OP_GT_DOUBLE_S64
):
1453 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax_v
);
1454 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1456 estack_ax_t
= REG_S64
;
1457 next_pc
+= sizeof(struct binary_op
);
1460 OP(FILTER_OP_LT_DOUBLE_S64
):
1464 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax_v
);
1465 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1467 estack_ax_t
= REG_S64
;
1468 next_pc
+= sizeof(struct binary_op
);
1471 OP(FILTER_OP_GE_DOUBLE_S64
):
1475 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax_v
);
1476 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1478 estack_ax_t
= REG_S64
;
1479 next_pc
+= sizeof(struct binary_op
);
1482 OP(FILTER_OP_LE_DOUBLE_S64
):
1486 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax_v
);
1487 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1489 estack_ax_t
= REG_S64
;
1490 next_pc
+= sizeof(struct binary_op
);
1494 OP(FILTER_OP_EQ_S64_DOUBLE
):
1498 res
= (estack_bx_v
== estack_ax(stack
, top
)->u
.d
);
1499 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1501 estack_ax_t
= REG_S64
;
1502 next_pc
+= sizeof(struct binary_op
);
1505 OP(FILTER_OP_NE_S64_DOUBLE
):
1509 res
= (estack_bx_v
!= estack_ax(stack
, top
)->u
.d
);
1510 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1512 estack_ax_t
= REG_S64
;
1513 next_pc
+= sizeof(struct binary_op
);
1516 OP(FILTER_OP_GT_S64_DOUBLE
):
1520 res
= (estack_bx_v
> estack_ax(stack
, top
)->u
.d
);
1521 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1523 estack_ax_t
= REG_S64
;
1524 next_pc
+= sizeof(struct binary_op
);
1527 OP(FILTER_OP_LT_S64_DOUBLE
):
1531 res
= (estack_bx_v
< estack_ax(stack
, top
)->u
.d
);
1532 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1534 estack_ax_t
= REG_S64
;
1535 next_pc
+= sizeof(struct binary_op
);
1538 OP(FILTER_OP_GE_S64_DOUBLE
):
1542 res
= (estack_bx_v
>= estack_ax(stack
, top
)->u
.d
);
1543 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1545 estack_ax_t
= REG_S64
;
1546 next_pc
+= sizeof(struct binary_op
);
1549 OP(FILTER_OP_LE_S64_DOUBLE
):
1553 res
= (estack_bx_v
<= estack_ax(stack
, top
)->u
.d
);
1554 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1556 estack_ax_t
= REG_S64
;
1557 next_pc
+= sizeof(struct binary_op
);
1560 OP(FILTER_OP_BIT_RSHIFT
):
1564 /* Dynamic typing. */
1565 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1569 /* Catch undefined behavior. */
1570 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1574 res
= ((uint64_t) estack_bx_v
>> (uint32_t) estack_ax_v
);
1575 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1577 estack_ax_t
= REG_S64
;
1578 next_pc
+= sizeof(struct binary_op
);
1581 OP(FILTER_OP_BIT_LSHIFT
):
1585 /* Dynamic typing. */
1586 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1590 /* Catch undefined behavior. */
1591 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1595 res
= ((uint64_t) estack_bx_v
<< (uint32_t) estack_ax_v
);
1596 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1598 estack_ax_t
= REG_S64
;
1599 next_pc
+= sizeof(struct binary_op
);
1602 OP(FILTER_OP_BIT_AND
):
1606 /* Dynamic typing. */
1607 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1612 res
= ((uint64_t) estack_bx_v
& (uint64_t) estack_ax_v
);
1613 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1615 estack_ax_t
= REG_S64
;
1616 next_pc
+= sizeof(struct binary_op
);
1619 OP(FILTER_OP_BIT_OR
):
1623 /* Dynamic typing. */
1624 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1629 res
= ((uint64_t) estack_bx_v
| (uint64_t) estack_ax_v
);
1630 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1632 estack_ax_t
= REG_S64
;
1633 next_pc
+= sizeof(struct binary_op
);
1636 OP(FILTER_OP_BIT_XOR
):
1640 /* Dynamic typing. */
1641 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1646 res
= ((uint64_t) estack_bx_v
^ (uint64_t) estack_ax_v
);
1647 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1649 estack_ax_t
= REG_S64
;
1650 next_pc
+= sizeof(struct binary_op
);
1655 OP(FILTER_OP_UNARY_PLUS
):
1657 /* Dynamic typing. */
1658 switch (estack_ax_t
) {
1659 case REG_S64
: /* Fall-through. */
1660 JUMP_TO(FILTER_OP_UNARY_PLUS_S64
);
1662 JUMP_TO(FILTER_OP_UNARY_PLUS_DOUBLE
);
1663 case REG_STRING
: /* Fall-through */
1664 case REG_STAR_GLOB_STRING
:
1668 ERR("Unknown filter register type (%d)",
1674 OP(FILTER_OP_UNARY_MINUS
):
1676 /* Dynamic typing. */
1677 switch (estack_ax_t
) {
1679 JUMP_TO(FILTER_OP_UNARY_MINUS_S64
);
1681 JUMP_TO(FILTER_OP_UNARY_MINUS_DOUBLE
);
1682 case REG_STRING
: /* Fall-through */
1683 case REG_STAR_GLOB_STRING
:
1687 ERR("Unknown filter register type (%d)",
1693 OP(FILTER_OP_UNARY_NOT
):
1695 /* Dynamic typing. */
1696 switch (estack_ax_t
) {
1698 JUMP_TO(FILTER_OP_UNARY_NOT_S64
);
1700 JUMP_TO(FILTER_OP_UNARY_NOT_DOUBLE
);
1701 case REG_STRING
: /* Fall-through */
1702 case REG_STAR_GLOB_STRING
:
1706 ERR("Unknown filter register type (%d)",
1711 next_pc
+= sizeof(struct unary_op
);
1715 OP(FILTER_OP_UNARY_BIT_NOT
):
1717 /* Dynamic typing. */
1718 if (estack_ax_t
!= REG_S64
) {
1723 estack_ax_v
= ~(uint64_t) estack_ax_v
;
1724 next_pc
+= sizeof(struct unary_op
);
1728 OP(FILTER_OP_UNARY_PLUS_S64
):
1729 OP(FILTER_OP_UNARY_PLUS_DOUBLE
):
1731 next_pc
+= sizeof(struct unary_op
);
1734 OP(FILTER_OP_UNARY_MINUS_S64
):
1736 estack_ax_v
= -estack_ax_v
;
1737 next_pc
+= sizeof(struct unary_op
);
1740 OP(FILTER_OP_UNARY_MINUS_DOUBLE
):
1742 estack_ax(stack
, top
)->u
.d
= -estack_ax(stack
, top
)->u
.d
;
1743 next_pc
+= sizeof(struct unary_op
);
1746 OP(FILTER_OP_UNARY_NOT_S64
):
1748 estack_ax_v
= !estack_ax_v
;
1749 next_pc
+= sizeof(struct unary_op
);
1752 OP(FILTER_OP_UNARY_NOT_DOUBLE
):
1754 estack_ax_v
= !estack_ax(stack
, top
)->u
.d
;
1755 estack_ax_t
= REG_S64
;
1756 next_pc
+= sizeof(struct unary_op
);
1763 struct logical_op
*insn
= (struct logical_op
*) pc
;
1765 if (estack_ax_t
!= REG_S64
) {
1769 /* If AX is 0, skip and evaluate to 0 */
1770 if (unlikely(estack_ax_v
== 0)) {
1771 dbg_printf("Jumping to bytecode offset %u\n",
1772 (unsigned int) insn
->skip_offset
);
1773 next_pc
= start_pc
+ insn
->skip_offset
;
1775 /* Pop 1 when jump not taken */
1776 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1777 next_pc
+= sizeof(struct logical_op
);
1783 struct logical_op
*insn
= (struct logical_op
*) pc
;
1785 if (estack_ax_t
!= REG_S64
) {
1789 /* If AX is nonzero, skip and evaluate to 1 */
1790 if (unlikely(estack_ax_v
!= 0)) {
1792 dbg_printf("Jumping to bytecode offset %u\n",
1793 (unsigned int) insn
->skip_offset
);
1794 next_pc
= start_pc
+ insn
->skip_offset
;
1796 /* Pop 1 when jump not taken */
1797 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1798 next_pc
+= sizeof(struct logical_op
);
1804 /* load field ref */
1805 OP(FILTER_OP_LOAD_FIELD_REF_STRING
):
1807 struct load_op
*insn
= (struct load_op
*) pc
;
1808 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1810 dbg_printf("load field ref offset %u type string\n",
1812 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1813 estack_ax(stack
, top
)->u
.s
.str
=
1814 *(const char * const *) &filter_stack_data
[ref
->offset
];
1815 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1816 dbg_printf("Filter warning: loading a NULL string.\n");
1820 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1821 estack_ax(stack
, top
)->u
.s
.literal_type
=
1822 ESTACK_STRING_LITERAL_TYPE_NONE
;
1823 estack_ax_t
= REG_STRING
;
1824 dbg_printf("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1825 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1829 OP(FILTER_OP_LOAD_FIELD_REF_SEQUENCE
):
1831 struct load_op
*insn
= (struct load_op
*) pc
;
1832 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1834 dbg_printf("load field ref offset %u type sequence\n",
1836 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1837 estack_ax(stack
, top
)->u
.s
.seq_len
=
1838 *(unsigned long *) &filter_stack_data
[ref
->offset
];
1839 estack_ax(stack
, top
)->u
.s
.str
=
1840 *(const char **) (&filter_stack_data
[ref
->offset
1841 + sizeof(unsigned long)]);
1842 estack_ax_t
= REG_STRING
;
1843 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1844 dbg_printf("Filter warning: loading a NULL sequence.\n");
1848 estack_ax(stack
, top
)->u
.s
.literal_type
=
1849 ESTACK_STRING_LITERAL_TYPE_NONE
;
1850 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1854 OP(FILTER_OP_LOAD_FIELD_REF_S64
):
1856 struct load_op
*insn
= (struct load_op
*) pc
;
1857 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1859 dbg_printf("load field ref offset %u type s64\n",
1861 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1863 ((struct literal_numeric
*) &filter_stack_data
[ref
->offset
])->v
;
1864 estack_ax_t
= REG_S64
;
1865 dbg_printf("ref load s64 %" PRIi64
"\n", estack_ax_v
);
1866 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1870 OP(FILTER_OP_LOAD_FIELD_REF_DOUBLE
):
1872 struct load_op
*insn
= (struct load_op
*) pc
;
1873 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1875 dbg_printf("load field ref offset %u type double\n",
1877 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1878 memcpy(&estack_ax(stack
, top
)->u
.d
, &filter_stack_data
[ref
->offset
],
1879 sizeof(struct literal_double
));
1880 estack_ax_t
= REG_DOUBLE
;
1881 dbg_printf("ref load double %g\n", estack_ax(stack
, top
)->u
.d
);
1882 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1886 /* load from immediate operand */
1887 OP(FILTER_OP_LOAD_STRING
):
1889 struct load_op
*insn
= (struct load_op
*) pc
;
1891 dbg_printf("load string %s\n", insn
->data
);
1892 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1893 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1894 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1895 estack_ax(stack
, top
)->u
.s
.literal_type
=
1896 ESTACK_STRING_LITERAL_TYPE_PLAIN
;
1897 estack_ax_t
= REG_STRING
;
1898 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1902 OP(FILTER_OP_LOAD_STAR_GLOB_STRING
):
1904 struct load_op
*insn
= (struct load_op
*) pc
;
1906 dbg_printf("load globbing pattern %s\n", insn
->data
);
1907 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1908 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1909 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1910 estack_ax(stack
, top
)->u
.s
.literal_type
=
1911 ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
;
1912 estack_ax_t
= REG_STAR_GLOB_STRING
;
1913 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1917 OP(FILTER_OP_LOAD_S64
):
1919 struct load_op
*insn
= (struct load_op
*) pc
;
1921 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1922 estack_ax_v
= ((struct literal_numeric
*) insn
->data
)->v
;
1923 estack_ax_t
= REG_S64
;
1924 dbg_printf("load s64 %" PRIi64
"\n", estack_ax_v
);
1925 next_pc
+= sizeof(struct load_op
)
1926 + sizeof(struct literal_numeric
);
1930 OP(FILTER_OP_LOAD_DOUBLE
):
1932 struct load_op
*insn
= (struct load_op
*) pc
;
1934 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1935 memcpy(&estack_ax(stack
, top
)->u
.d
, insn
->data
,
1936 sizeof(struct literal_double
));
1937 estack_ax_t
= REG_DOUBLE
;
1938 dbg_printf("load double %g\n", estack_ax(stack
, top
)->u
.d
);
1939 next_pc
+= sizeof(struct load_op
)
1940 + sizeof(struct literal_double
);
1945 OP(FILTER_OP_CAST_TO_S64
):
1947 /* Dynamic typing. */
1948 switch (estack_ax_t
) {
1950 JUMP_TO(FILTER_OP_CAST_NOP
);
1952 JUMP_TO(FILTER_OP_CAST_DOUBLE_TO_S64
);
1953 case REG_STRING
: /* Fall-through */
1954 case REG_STAR_GLOB_STRING
:
1958 ERR("Unknown filter register type (%d)",
1965 OP(FILTER_OP_CAST_DOUBLE_TO_S64
):
1967 estack_ax_v
= (int64_t) estack_ax(stack
, top
)->u
.d
;
1968 estack_ax_t
= REG_S64
;
1969 next_pc
+= sizeof(struct cast_op
);
1973 OP(FILTER_OP_CAST_NOP
):
1975 next_pc
+= sizeof(struct cast_op
);
1979 /* get context ref */
1980 OP(FILTER_OP_GET_CONTEXT_REF
):
1982 struct load_op
*insn
= (struct load_op
*) pc
;
1983 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1984 struct lttng_ctx
*ctx
;
1985 struct lttng_ctx_field
*ctx_field
;
1986 struct lttng_ctx_value v
;
1988 dbg_printf("get context ref offset %u type dynamic\n",
1990 ctx
= rcu_dereference(session
->ctx
);
1991 ctx_field
= &ctx
->fields
[ref
->offset
];
1992 ctx_field
->get_value(ctx_field
, &v
);
1993 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1995 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
1998 case LTTNG_UST_DYNAMIC_TYPE_S64
:
1999 estack_ax_v
= v
.u
.s64
;
2000 estack_ax_t
= REG_S64
;
2001 dbg_printf("ref get context dynamic s64 %" PRIi64
"\n", estack_ax_v
);
2003 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
2004 estack_ax(stack
, top
)->u
.d
= v
.u
.d
;
2005 estack_ax_t
= REG_DOUBLE
;
2006 dbg_printf("ref get context dynamic double %g\n", estack_ax(stack
, top
)->u
.d
);
2008 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
2009 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2010 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2011 dbg_printf("Filter warning: loading a NULL string.\n");
2015 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2016 estack_ax(stack
, top
)->u
.s
.literal_type
=
2017 ESTACK_STRING_LITERAL_TYPE_NONE
;
2018 dbg_printf("ref get context dynamic string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2019 estack_ax_t
= REG_STRING
;
2022 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
2026 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2030 OP(FILTER_OP_GET_CONTEXT_REF_STRING
):
2032 struct load_op
*insn
= (struct load_op
*) pc
;
2033 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2034 struct lttng_ctx
*ctx
;
2035 struct lttng_ctx_field
*ctx_field
;
2036 struct lttng_ctx_value v
;
2038 dbg_printf("get context ref offset %u type string\n",
2040 ctx
= rcu_dereference(session
->ctx
);
2041 ctx_field
= &ctx
->fields
[ref
->offset
];
2042 ctx_field
->get_value(ctx_field
, &v
);
2043 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2044 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2045 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2046 dbg_printf("Filter warning: loading a NULL string.\n");
2050 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2051 estack_ax(stack
, top
)->u
.s
.literal_type
=
2052 ESTACK_STRING_LITERAL_TYPE_NONE
;
2053 estack_ax_t
= REG_STRING
;
2054 dbg_printf("ref get context string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2055 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2059 OP(FILTER_OP_GET_CONTEXT_REF_S64
):
2061 struct load_op
*insn
= (struct load_op
*) pc
;
2062 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2063 struct lttng_ctx
*ctx
;
2064 struct lttng_ctx_field
*ctx_field
;
2065 struct lttng_ctx_value v
;
2067 dbg_printf("get context ref offset %u type s64\n",
2069 ctx
= rcu_dereference(session
->ctx
);
2070 ctx_field
= &ctx
->fields
[ref
->offset
];
2071 ctx_field
->get_value(ctx_field
, &v
);
2072 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2073 estack_ax_v
= v
.u
.s64
;
2074 estack_ax_t
= REG_S64
;
2075 dbg_printf("ref get context s64 %" PRIi64
"\n", estack_ax_v
);
2076 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2080 OP(FILTER_OP_GET_CONTEXT_REF_DOUBLE
):
2082 struct load_op
*insn
= (struct load_op
*) pc
;
2083 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2084 struct lttng_ctx
*ctx
;
2085 struct lttng_ctx_field
*ctx_field
;
2086 struct lttng_ctx_value v
;
2088 dbg_printf("get context ref offset %u type double\n",
2090 ctx
= rcu_dereference(session
->ctx
);
2091 ctx_field
= &ctx
->fields
[ref
->offset
];
2092 ctx_field
->get_value(ctx_field
, &v
);
2093 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2094 memcpy(&estack_ax(stack
, top
)->u
.d
, &v
.u
.d
, sizeof(struct literal_double
));
2095 estack_ax_t
= REG_DOUBLE
;
2096 dbg_printf("ref get context double %g\n", estack_ax(stack
, top
)->u
.d
);
2097 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2101 OP(FILTER_OP_GET_CONTEXT_ROOT
):
2103 dbg_printf("op get context root\n");
2104 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2105 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_CONTEXT
;
2106 /* "field" only needed for variants. */
2107 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2108 estack_ax_t
= REG_PTR
;
2109 next_pc
+= sizeof(struct load_op
);
2113 OP(FILTER_OP_GET_APP_CONTEXT_ROOT
):
2115 dbg_printf("op get app context root\n");
2116 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2117 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_APP_CONTEXT
;
2118 /* "field" only needed for variants. */
2119 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2120 estack_ax_t
= REG_PTR
;
2121 next_pc
+= sizeof(struct load_op
);
2125 OP(FILTER_OP_GET_PAYLOAD_ROOT
):
2127 dbg_printf("op get app payload root\n");
2128 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2129 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_PAYLOAD
;
2130 estack_ax(stack
, top
)->u
.ptr
.ptr
= filter_stack_data
;
2131 /* "field" only needed for variants. */
2132 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2133 estack_ax_t
= REG_PTR
;
2134 next_pc
+= sizeof(struct load_op
);
2138 OP(FILTER_OP_GET_SYMBOL
):
2140 dbg_printf("op get symbol\n");
2141 switch (estack_ax(stack
, top
)->u
.ptr
.type
) {
2143 ERR("Nested fields not implemented yet.");
2146 case LOAD_ROOT_CONTEXT
:
2147 case LOAD_ROOT_APP_CONTEXT
:
2148 case LOAD_ROOT_PAYLOAD
:
2150 * symbol lookup is performed by
2156 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_symbol
);
2160 OP(FILTER_OP_GET_SYMBOL_FIELD
):
2163 * Used for first variant encountered in a
2164 * traversal. Variants are not implemented yet.
2170 OP(FILTER_OP_GET_INDEX_U16
):
2172 struct load_op
*insn
= (struct load_op
*) pc
;
2173 struct get_index_u16
*index
= (struct get_index_u16
*) insn
->data
;
2175 dbg_printf("op get index u16\n");
2176 ret
= dynamic_get_index(session
, bytecode
, index
->index
, estack_ax(stack
, top
));
2179 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2180 estack_ax_t
= estack_ax(stack
, top
)->type
;
2181 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u16
);
2185 OP(FILTER_OP_GET_INDEX_U64
):
2187 struct load_op
*insn
= (struct load_op
*) pc
;
2188 struct get_index_u64
*index
= (struct get_index_u64
*) insn
->data
;
2190 dbg_printf("op get index u64\n");
2191 ret
= dynamic_get_index(session
, bytecode
, index
->index
, estack_ax(stack
, top
));
2194 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2195 estack_ax_t
= estack_ax(stack
, top
)->type
;
2196 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u64
);
2200 OP(FILTER_OP_LOAD_FIELD
):
2202 dbg_printf("op load field\n");
2203 ret
= dynamic_load_field(estack_ax(stack
, top
));
2206 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2207 estack_ax_t
= estack_ax(stack
, top
)->type
;
2208 next_pc
+= sizeof(struct load_op
);
2212 OP(FILTER_OP_LOAD_FIELD_S8
):
2214 dbg_printf("op load field s8\n");
2216 estack_ax_v
= *(int8_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_S16
):
2223 dbg_printf("op load field s16\n");
2225 estack_ax_v
= *(int16_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_S32
):
2232 dbg_printf("op load field s32\n");
2234 estack_ax_v
= *(int32_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_S64
):
2241 dbg_printf("op load field s64\n");
2243 estack_ax_v
= *(int64_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_U8
):
2250 dbg_printf("op load field u8\n");
2252 estack_ax_v
= *(uint8_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_U16
):
2259 dbg_printf("op load field u16\n");
2261 estack_ax_v
= *(uint16_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_U32
):
2268 dbg_printf("op load field u32\n");
2270 estack_ax_v
= *(uint32_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_U64
):
2277 dbg_printf("op load field u64\n");
2279 estack_ax_v
= *(uint64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2280 estack_ax_t
= REG_S64
;
2281 next_pc
+= sizeof(struct load_op
);
2284 OP(FILTER_OP_LOAD_FIELD_DOUBLE
):
2286 dbg_printf("op load field double\n");
2288 memcpy(&estack_ax(stack
, top
)->u
.d
,
2289 estack_ax(stack
, top
)->u
.ptr
.ptr
,
2290 sizeof(struct literal_double
));
2291 estack_ax(stack
, top
)->type
= REG_DOUBLE
;
2292 next_pc
+= sizeof(struct load_op
);
2296 OP(FILTER_OP_LOAD_FIELD_STRING
):
2300 dbg_printf("op load field string\n");
2301 str
= (const char *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2302 estack_ax(stack
, top
)->u
.s
.str
= str
;
2303 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2304 dbg_printf("Filter warning: loading a NULL string.\n");
2308 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2309 estack_ax(stack
, top
)->u
.s
.literal_type
=
2310 ESTACK_STRING_LITERAL_TYPE_NONE
;
2311 estack_ax(stack
, top
)->type
= REG_STRING
;
2312 next_pc
+= sizeof(struct load_op
);
2316 OP(FILTER_OP_LOAD_FIELD_SEQUENCE
):
2320 dbg_printf("op load field string sequence\n");
2321 ptr
= estack_ax(stack
, top
)->u
.ptr
.ptr
;
2322 estack_ax(stack
, top
)->u
.s
.seq_len
= *(unsigned long *) ptr
;
2323 estack_ax(stack
, top
)->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
2324 estack_ax(stack
, top
)->type
= REG_STRING
;
2325 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2326 dbg_printf("Filter warning: loading a NULL sequence.\n");
2330 estack_ax(stack
, top
)->u
.s
.literal_type
=
2331 ESTACK_STRING_LITERAL_TYPE_NONE
;
2332 next_pc
+= sizeof(struct load_op
);
2338 /* return 0 (discard) on error */