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
;
301 ctx_field
->get_value(ctx_field
, &v
);
303 ptr
->ptr
= &ptr
->u
.d
;
306 ctx_field
->get_value(ctx_field
, &v
);
308 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
310 case LTTNG_UST_DYNAMIC_TYPE_S64
:
311 ptr
->object_type
= OBJECT_TYPE_S64
;
312 ptr
->u
.s64
= v
.u
.s64
;
313 ptr
->ptr
= &ptr
->u
.s64
;
314 dbg_printf("context get index dynamic s64 %" PRIi64
"\n", ptr
->u
.s64
);
316 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
317 ptr
->object_type
= OBJECT_TYPE_DOUBLE
;
319 ptr
->ptr
= &ptr
->u
.d
;
320 dbg_printf("context get index dynamic double %g\n", ptr
->u
.d
);
322 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
323 ptr
->object_type
= OBJECT_TYPE_STRING
;
325 dbg_printf("context get index dynamic string %s\n", (const char *) ptr
->ptr
);
328 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
333 ERR("Structure type cannot be loaded.");
336 ERR("Unknown type: %d", (int) field
->type
.atype
);
342 static int dynamic_get_index(struct lttng_session
*session
,
343 struct bytecode_runtime
*runtime
,
344 uint64_t index
, struct estack_entry
*stack_top
)
347 const struct filter_get_index_data
*gid
;
350 * Types nested within variants need to perform dynamic lookup
351 * based on the field descriptions. LTTng-UST does not implement
354 if (stack_top
->u
.ptr
.field
)
356 gid
= (const struct filter_get_index_data
*) &runtime
->data
[index
];
357 switch (stack_top
->u
.ptr
.type
) {
359 switch (stack_top
->u
.ptr
.object_type
) {
360 case OBJECT_TYPE_ARRAY
:
364 assert(gid
->offset
< gid
->array_len
);
365 /* Skip count (unsigned long) */
366 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
367 ptr
= ptr
+ gid
->offset
;
368 stack_top
->u
.ptr
.ptr
= ptr
;
369 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
370 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
371 /* field is only used for types nested within variants. */
372 stack_top
->u
.ptr
.field
= NULL
;
375 case OBJECT_TYPE_SEQUENCE
:
380 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
381 ptr_seq_len
= *(unsigned long *) stack_top
->u
.ptr
.ptr
;
382 if (gid
->offset
>= gid
->elem
.len
* ptr_seq_len
) {
386 ptr
= ptr
+ gid
->offset
;
387 stack_top
->u
.ptr
.ptr
= ptr
;
388 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
389 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
390 /* field is only used for types nested within variants. */
391 stack_top
->u
.ptr
.field
= NULL
;
394 case OBJECT_TYPE_STRUCT
:
395 ERR("Nested structures are not supported yet.");
398 case OBJECT_TYPE_VARIANT
:
400 ERR("Unexpected get index type %d",
401 (int) stack_top
->u
.ptr
.object_type
);
406 case LOAD_ROOT_CONTEXT
:
407 case LOAD_ROOT_APP_CONTEXT
: /* Fall-through */
409 struct lttng_ctx
*ctx
;
411 ctx
= rcu_dereference(session
->ctx
);
412 ret
= context_get_index(ctx
,
420 case LOAD_ROOT_PAYLOAD
:
421 stack_top
->u
.ptr
.ptr
+= gid
->offset
;
422 if (gid
->elem
.type
== OBJECT_TYPE_STRING
)
423 stack_top
->u
.ptr
.ptr
= *(const char * const *) stack_top
->u
.ptr
.ptr
;
424 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
425 stack_top
->u
.ptr
.type
= LOAD_OBJECT
;
426 /* field is only used for types nested within variants. */
427 stack_top
->u
.ptr
.field
= NULL
;
436 static int dynamic_load_field(struct estack_entry
*stack_top
)
440 switch (stack_top
->u
.ptr
.type
) {
443 case LOAD_ROOT_CONTEXT
:
444 case LOAD_ROOT_APP_CONTEXT
:
445 case LOAD_ROOT_PAYLOAD
:
447 dbg_printf("Filter warning: cannot load root, missing field name.\n");
451 switch (stack_top
->u
.ptr
.object_type
) {
453 dbg_printf("op load field s8\n");
454 stack_top
->u
.v
= *(int8_t *) stack_top
->u
.ptr
.ptr
;
455 stack_top
->type
= REG_S64
;
457 case OBJECT_TYPE_S16
:
461 dbg_printf("op load field s16\n");
462 tmp
= *(int16_t *) stack_top
->u
.ptr
.ptr
;
463 if (stack_top
->u
.ptr
.rev_bo
)
465 stack_top
->u
.v
= tmp
;
466 stack_top
->type
= REG_S64
;
469 case OBJECT_TYPE_S32
:
473 dbg_printf("op load field s32\n");
474 tmp
= *(int32_t *) stack_top
->u
.ptr
.ptr
;
475 if (stack_top
->u
.ptr
.rev_bo
)
477 stack_top
->u
.v
= tmp
;
478 stack_top
->type
= REG_S64
;
481 case OBJECT_TYPE_S64
:
485 dbg_printf("op load field s64\n");
486 tmp
= *(int64_t *) stack_top
->u
.ptr
.ptr
;
487 if (stack_top
->u
.ptr
.rev_bo
)
489 stack_top
->u
.v
= tmp
;
490 stack_top
->type
= REG_S64
;
494 dbg_printf("op load field u8\n");
495 stack_top
->u
.v
= *(uint8_t *) stack_top
->u
.ptr
.ptr
;
496 stack_top
->type
= REG_S64
;
498 case OBJECT_TYPE_U16
:
502 dbg_printf("op load field s16\n");
503 tmp
= *(uint16_t *) stack_top
->u
.ptr
.ptr
;
504 if (stack_top
->u
.ptr
.rev_bo
)
506 stack_top
->u
.v
= tmp
;
507 stack_top
->type
= REG_S64
;
510 case OBJECT_TYPE_U32
:
514 dbg_printf("op load field u32\n");
515 tmp
= *(uint32_t *) stack_top
->u
.ptr
.ptr
;
516 if (stack_top
->u
.ptr
.rev_bo
)
518 stack_top
->u
.v
= tmp
;
519 stack_top
->type
= REG_S64
;
522 case OBJECT_TYPE_U64
:
526 dbg_printf("op load field u64\n");
527 tmp
= *(uint64_t *) stack_top
->u
.ptr
.ptr
;
528 if (stack_top
->u
.ptr
.rev_bo
)
530 stack_top
->u
.v
= tmp
;
531 stack_top
->type
= REG_S64
;
534 case OBJECT_TYPE_DOUBLE
:
535 memcpy(&stack_top
->u
.d
,
536 stack_top
->u
.ptr
.ptr
,
537 sizeof(struct literal_double
));
538 stack_top
->type
= REG_DOUBLE
;
540 case OBJECT_TYPE_STRING
:
544 dbg_printf("op load field string\n");
545 str
= (const char *) stack_top
->u
.ptr
.ptr
;
546 stack_top
->u
.s
.str
= str
;
547 if (unlikely(!stack_top
->u
.s
.str
)) {
548 dbg_printf("Filter warning: loading a NULL string.\n");
552 stack_top
->u
.s
.seq_len
= SIZE_MAX
;
553 stack_top
->u
.s
.literal_type
=
554 ESTACK_STRING_LITERAL_TYPE_NONE
;
555 stack_top
->type
= REG_STRING
;
558 case OBJECT_TYPE_STRING_SEQUENCE
:
562 dbg_printf("op load field string sequence\n");
563 ptr
= stack_top
->u
.ptr
.ptr
;
564 stack_top
->u
.s
.seq_len
= *(unsigned long *) ptr
;
565 stack_top
->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
566 stack_top
->type
= REG_STRING
;
567 if (unlikely(!stack_top
->u
.s
.str
)) {
568 dbg_printf("Filter warning: loading a NULL sequence.\n");
572 stack_top
->u
.s
.literal_type
=
573 ESTACK_STRING_LITERAL_TYPE_NONE
;
576 case OBJECT_TYPE_DYNAMIC
:
578 * Dynamic types in context are looked up
579 * by context get index.
583 case OBJECT_TYPE_SEQUENCE
:
584 case OBJECT_TYPE_ARRAY
:
585 case OBJECT_TYPE_STRUCT
:
586 case OBJECT_TYPE_VARIANT
:
587 ERR("Sequences, arrays, struct and variant cannot be loaded (nested types).");
598 * Return 0 (discard), or raise the 0x1 flag (log event).
599 * Currently, other flags are kept for future extensions and have no
602 uint64_t lttng_filter_interpret_bytecode(void *filter_data
,
603 const char *filter_stack_data
)
605 struct bytecode_runtime
*bytecode
= filter_data
;
606 struct lttng_session
*session
= bytecode
->p
.session
;
607 void *pc
, *next_pc
, *start_pc
;
610 struct estack _stack
;
611 struct estack
*stack
= &_stack
;
612 register int64_t ax
= 0, bx
= 0;
613 register enum entry_type ax_t
= REG_UNKNOWN
, bx_t
= REG_UNKNOWN
;
614 register int top
= FILTER_STACK_EMPTY
;
615 #ifndef INTERPRETER_USE_SWITCH
616 static void *dispatch
[NR_FILTER_OPS
] = {
617 [ FILTER_OP_UNKNOWN
] = &&LABEL_FILTER_OP_UNKNOWN
,
619 [ FILTER_OP_RETURN
] = &&LABEL_FILTER_OP_RETURN
,
622 [ FILTER_OP_MUL
] = &&LABEL_FILTER_OP_MUL
,
623 [ FILTER_OP_DIV
] = &&LABEL_FILTER_OP_DIV
,
624 [ FILTER_OP_MOD
] = &&LABEL_FILTER_OP_MOD
,
625 [ FILTER_OP_PLUS
] = &&LABEL_FILTER_OP_PLUS
,
626 [ FILTER_OP_MINUS
] = &&LABEL_FILTER_OP_MINUS
,
627 [ FILTER_OP_BIT_RSHIFT
] = &&LABEL_FILTER_OP_BIT_RSHIFT
,
628 [ FILTER_OP_BIT_LSHIFT
] = &&LABEL_FILTER_OP_BIT_LSHIFT
,
629 [ FILTER_OP_BIT_AND
] = &&LABEL_FILTER_OP_BIT_AND
,
630 [ FILTER_OP_BIT_OR
] = &&LABEL_FILTER_OP_BIT_OR
,
631 [ FILTER_OP_BIT_XOR
] = &&LABEL_FILTER_OP_BIT_XOR
,
633 /* binary comparators */
634 [ FILTER_OP_EQ
] = &&LABEL_FILTER_OP_EQ
,
635 [ FILTER_OP_NE
] = &&LABEL_FILTER_OP_NE
,
636 [ FILTER_OP_GT
] = &&LABEL_FILTER_OP_GT
,
637 [ FILTER_OP_LT
] = &&LABEL_FILTER_OP_LT
,
638 [ FILTER_OP_GE
] = &&LABEL_FILTER_OP_GE
,
639 [ FILTER_OP_LE
] = &&LABEL_FILTER_OP_LE
,
641 /* string binary comparator */
642 [ FILTER_OP_EQ_STRING
] = &&LABEL_FILTER_OP_EQ_STRING
,
643 [ FILTER_OP_NE_STRING
] = &&LABEL_FILTER_OP_NE_STRING
,
644 [ FILTER_OP_GT_STRING
] = &&LABEL_FILTER_OP_GT_STRING
,
645 [ FILTER_OP_LT_STRING
] = &&LABEL_FILTER_OP_LT_STRING
,
646 [ FILTER_OP_GE_STRING
] = &&LABEL_FILTER_OP_GE_STRING
,
647 [ FILTER_OP_LE_STRING
] = &&LABEL_FILTER_OP_LE_STRING
,
649 /* globbing pattern binary comparator */
650 [ FILTER_OP_EQ_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_EQ_STAR_GLOB_STRING
,
651 [ FILTER_OP_NE_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_NE_STAR_GLOB_STRING
,
653 /* s64 binary comparator */
654 [ FILTER_OP_EQ_S64
] = &&LABEL_FILTER_OP_EQ_S64
,
655 [ FILTER_OP_NE_S64
] = &&LABEL_FILTER_OP_NE_S64
,
656 [ FILTER_OP_GT_S64
] = &&LABEL_FILTER_OP_GT_S64
,
657 [ FILTER_OP_LT_S64
] = &&LABEL_FILTER_OP_LT_S64
,
658 [ FILTER_OP_GE_S64
] = &&LABEL_FILTER_OP_GE_S64
,
659 [ FILTER_OP_LE_S64
] = &&LABEL_FILTER_OP_LE_S64
,
661 /* double binary comparator */
662 [ FILTER_OP_EQ_DOUBLE
] = &&LABEL_FILTER_OP_EQ_DOUBLE
,
663 [ FILTER_OP_NE_DOUBLE
] = &&LABEL_FILTER_OP_NE_DOUBLE
,
664 [ FILTER_OP_GT_DOUBLE
] = &&LABEL_FILTER_OP_GT_DOUBLE
,
665 [ FILTER_OP_LT_DOUBLE
] = &&LABEL_FILTER_OP_LT_DOUBLE
,
666 [ FILTER_OP_GE_DOUBLE
] = &&LABEL_FILTER_OP_GE_DOUBLE
,
667 [ FILTER_OP_LE_DOUBLE
] = &&LABEL_FILTER_OP_LE_DOUBLE
,
669 /* Mixed S64-double binary comparators */
670 [ FILTER_OP_EQ_DOUBLE_S64
] = &&LABEL_FILTER_OP_EQ_DOUBLE_S64
,
671 [ FILTER_OP_NE_DOUBLE_S64
] = &&LABEL_FILTER_OP_NE_DOUBLE_S64
,
672 [ FILTER_OP_GT_DOUBLE_S64
] = &&LABEL_FILTER_OP_GT_DOUBLE_S64
,
673 [ FILTER_OP_LT_DOUBLE_S64
] = &&LABEL_FILTER_OP_LT_DOUBLE_S64
,
674 [ FILTER_OP_GE_DOUBLE_S64
] = &&LABEL_FILTER_OP_GE_DOUBLE_S64
,
675 [ FILTER_OP_LE_DOUBLE_S64
] = &&LABEL_FILTER_OP_LE_DOUBLE_S64
,
677 [ FILTER_OP_EQ_S64_DOUBLE
] = &&LABEL_FILTER_OP_EQ_S64_DOUBLE
,
678 [ FILTER_OP_NE_S64_DOUBLE
] = &&LABEL_FILTER_OP_NE_S64_DOUBLE
,
679 [ FILTER_OP_GT_S64_DOUBLE
] = &&LABEL_FILTER_OP_GT_S64_DOUBLE
,
680 [ FILTER_OP_LT_S64_DOUBLE
] = &&LABEL_FILTER_OP_LT_S64_DOUBLE
,
681 [ FILTER_OP_GE_S64_DOUBLE
] = &&LABEL_FILTER_OP_GE_S64_DOUBLE
,
682 [ FILTER_OP_LE_S64_DOUBLE
] = &&LABEL_FILTER_OP_LE_S64_DOUBLE
,
685 [ FILTER_OP_UNARY_PLUS
] = &&LABEL_FILTER_OP_UNARY_PLUS
,
686 [ FILTER_OP_UNARY_MINUS
] = &&LABEL_FILTER_OP_UNARY_MINUS
,
687 [ FILTER_OP_UNARY_NOT
] = &&LABEL_FILTER_OP_UNARY_NOT
,
688 [ FILTER_OP_UNARY_PLUS_S64
] = &&LABEL_FILTER_OP_UNARY_PLUS_S64
,
689 [ FILTER_OP_UNARY_MINUS_S64
] = &&LABEL_FILTER_OP_UNARY_MINUS_S64
,
690 [ FILTER_OP_UNARY_NOT_S64
] = &&LABEL_FILTER_OP_UNARY_NOT_S64
,
691 [ FILTER_OP_UNARY_PLUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_PLUS_DOUBLE
,
692 [ FILTER_OP_UNARY_MINUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_MINUS_DOUBLE
,
693 [ FILTER_OP_UNARY_NOT_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_NOT_DOUBLE
,
696 [ FILTER_OP_AND
] = &&LABEL_FILTER_OP_AND
,
697 [ FILTER_OP_OR
] = &&LABEL_FILTER_OP_OR
,
700 [ FILTER_OP_LOAD_FIELD_REF
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF
,
701 [ FILTER_OP_LOAD_FIELD_REF_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_STRING
,
702 [ FILTER_OP_LOAD_FIELD_REF_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_SEQUENCE
,
703 [ FILTER_OP_LOAD_FIELD_REF_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_S64
,
704 [ FILTER_OP_LOAD_FIELD_REF_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_DOUBLE
,
706 /* load from immediate operand */
707 [ FILTER_OP_LOAD_STRING
] = &&LABEL_FILTER_OP_LOAD_STRING
,
708 [ FILTER_OP_LOAD_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_LOAD_STAR_GLOB_STRING
,
709 [ FILTER_OP_LOAD_S64
] = &&LABEL_FILTER_OP_LOAD_S64
,
710 [ FILTER_OP_LOAD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_DOUBLE
,
713 [ FILTER_OP_CAST_TO_S64
] = &&LABEL_FILTER_OP_CAST_TO_S64
,
714 [ FILTER_OP_CAST_DOUBLE_TO_S64
] = &&LABEL_FILTER_OP_CAST_DOUBLE_TO_S64
,
715 [ FILTER_OP_CAST_NOP
] = &&LABEL_FILTER_OP_CAST_NOP
,
717 /* get context ref */
718 [ FILTER_OP_GET_CONTEXT_REF
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF
,
719 [ FILTER_OP_GET_CONTEXT_REF_STRING
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_STRING
,
720 [ FILTER_OP_GET_CONTEXT_REF_S64
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_S64
,
721 [ FILTER_OP_GET_CONTEXT_REF_DOUBLE
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_DOUBLE
,
723 /* Instructions for recursive traversal through composed types. */
724 [ FILTER_OP_GET_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_CONTEXT_ROOT
,
725 [ FILTER_OP_GET_APP_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_APP_CONTEXT_ROOT
,
726 [ FILTER_OP_GET_PAYLOAD_ROOT
] = &&LABEL_FILTER_OP_GET_PAYLOAD_ROOT
,
728 [ FILTER_OP_GET_SYMBOL
] = &&LABEL_FILTER_OP_GET_SYMBOL
,
729 [ FILTER_OP_GET_SYMBOL_FIELD
] = &&LABEL_FILTER_OP_GET_SYMBOL_FIELD
,
730 [ FILTER_OP_GET_INDEX_U16
] = &&LABEL_FILTER_OP_GET_INDEX_U16
,
731 [ FILTER_OP_GET_INDEX_U64
] = &&LABEL_FILTER_OP_GET_INDEX_U64
,
733 [ FILTER_OP_LOAD_FIELD
] = &&LABEL_FILTER_OP_LOAD_FIELD
,
734 [ FILTER_OP_LOAD_FIELD_S8
] = &&LABEL_FILTER_OP_LOAD_FIELD_S8
,
735 [ FILTER_OP_LOAD_FIELD_S16
] = &&LABEL_FILTER_OP_LOAD_FIELD_S16
,
736 [ FILTER_OP_LOAD_FIELD_S32
] = &&LABEL_FILTER_OP_LOAD_FIELD_S32
,
737 [ FILTER_OP_LOAD_FIELD_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_S64
,
738 [ FILTER_OP_LOAD_FIELD_U8
] = &&LABEL_FILTER_OP_LOAD_FIELD_U8
,
739 [ FILTER_OP_LOAD_FIELD_U16
] = &&LABEL_FILTER_OP_LOAD_FIELD_U16
,
740 [ FILTER_OP_LOAD_FIELD_U32
] = &&LABEL_FILTER_OP_LOAD_FIELD_U32
,
741 [ FILTER_OP_LOAD_FIELD_U64
] = &&LABEL_FILTER_OP_LOAD_FIELD_U64
,
742 [ FILTER_OP_LOAD_FIELD_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_STRING
,
743 [ FILTER_OP_LOAD_FIELD_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_SEQUENCE
,
744 [ FILTER_OP_LOAD_FIELD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_DOUBLE
,
746 [ FILTER_OP_UNARY_BIT_NOT
] = &&LABEL_FILTER_OP_UNARY_BIT_NOT
,
748 [ FILTER_OP_RETURN_S64
] = &&LABEL_FILTER_OP_RETURN_S64
,
750 #endif /* #ifndef INTERPRETER_USE_SWITCH */
754 OP(FILTER_OP_UNKNOWN
):
755 OP(FILTER_OP_LOAD_FIELD_REF
):
756 #ifdef INTERPRETER_USE_SWITCH
758 #endif /* INTERPRETER_USE_SWITCH */
759 ERR("unknown bytecode op %u",
760 (unsigned int) *(filter_opcode_t
*) pc
);
764 OP(FILTER_OP_RETURN
):
765 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
766 /* Handle dynamic typing. */
767 switch (estack_ax_t
) {
769 retval
= !!estack_ax_v
;
773 case REG_STAR_GLOB_STRING
:
781 OP(FILTER_OP_RETURN_S64
):
782 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
783 retval
= !!estack_ax_v
;
793 ERR("unsupported bytecode op %u",
794 (unsigned int) *(filter_opcode_t
*) pc
);
800 /* Dynamic typing. */
801 switch (estack_ax_t
) {
803 switch (estack_bx_t
) {
805 JUMP_TO(FILTER_OP_EQ_S64
);
807 JUMP_TO(FILTER_OP_EQ_DOUBLE_S64
);
808 case REG_STRING
: /* Fall-through */
809 case REG_STAR_GLOB_STRING
:
813 ERR("Unknown filter register type (%d)",
820 switch (estack_bx_t
) {
822 JUMP_TO(FILTER_OP_EQ_S64_DOUBLE
);
824 JUMP_TO(FILTER_OP_EQ_DOUBLE
);
825 case REG_STRING
: /* Fall-through */
826 case REG_STAR_GLOB_STRING
:
830 ERR("Unknown filter register type (%d)",
837 switch (estack_bx_t
) {
838 case REG_S64
: /* Fall-through */
843 JUMP_TO(FILTER_OP_EQ_STRING
);
844 case REG_STAR_GLOB_STRING
:
845 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
847 ERR("Unknown filter register type (%d)",
853 case REG_STAR_GLOB_STRING
:
854 switch (estack_bx_t
) {
855 case REG_S64
: /* Fall-through */
860 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
861 case REG_STAR_GLOB_STRING
:
865 ERR("Unknown filter register type (%d)",
872 ERR("Unknown filter register type (%d)",
880 /* Dynamic typing. */
881 switch (estack_ax_t
) {
883 switch (estack_bx_t
) {
885 JUMP_TO(FILTER_OP_NE_S64
);
887 JUMP_TO(FILTER_OP_NE_DOUBLE_S64
);
888 case REG_STRING
: /* Fall-through */
889 case REG_STAR_GLOB_STRING
:
893 ERR("Unknown filter register type (%d)",
900 switch (estack_bx_t
) {
902 JUMP_TO(FILTER_OP_NE_S64_DOUBLE
);
904 JUMP_TO(FILTER_OP_NE_DOUBLE
);
905 case REG_STRING
: /* Fall-through */
906 case REG_STAR_GLOB_STRING
:
910 ERR("Unknown filter register type (%d)",
917 switch (estack_bx_t
) {
918 case REG_S64
: /* Fall-through */
923 JUMP_TO(FILTER_OP_NE_STRING
);
924 case REG_STAR_GLOB_STRING
:
925 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
927 ERR("Unknown filter register type (%d)",
933 case REG_STAR_GLOB_STRING
:
934 switch (estack_bx_t
) {
935 case REG_S64
: /* Fall-through */
940 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
941 case REG_STAR_GLOB_STRING
:
945 ERR("Unknown filter register type (%d)",
952 ERR("Unknown filter register type (%d)",
960 /* Dynamic typing. */
961 switch (estack_ax_t
) {
963 switch (estack_bx_t
) {
965 JUMP_TO(FILTER_OP_GT_S64
);
967 JUMP_TO(FILTER_OP_GT_DOUBLE_S64
);
968 case REG_STRING
: /* Fall-through */
969 case REG_STAR_GLOB_STRING
:
973 ERR("Unknown filter register type (%d)",
980 switch (estack_bx_t
) {
982 JUMP_TO(FILTER_OP_GT_S64_DOUBLE
);
984 JUMP_TO(FILTER_OP_GT_DOUBLE
);
985 case REG_STRING
: /* Fall-through */
986 case REG_STAR_GLOB_STRING
:
990 ERR("Unknown filter register type (%d)",
997 switch (estack_bx_t
) {
998 case REG_S64
: /* Fall-through */
999 case REG_DOUBLE
: /* Fall-through */
1000 case REG_STAR_GLOB_STRING
:
1004 JUMP_TO(FILTER_OP_GT_STRING
);
1006 ERR("Unknown filter register type (%d)",
1013 ERR("Unknown filter register type (%d)",
1021 /* Dynamic typing. */
1022 switch (estack_ax_t
) {
1024 switch (estack_bx_t
) {
1026 JUMP_TO(FILTER_OP_LT_S64
);
1028 JUMP_TO(FILTER_OP_LT_DOUBLE_S64
);
1029 case REG_STRING
: /* Fall-through */
1030 case REG_STAR_GLOB_STRING
:
1034 ERR("Unknown filter register type (%d)",
1041 switch (estack_bx_t
) {
1043 JUMP_TO(FILTER_OP_LT_S64_DOUBLE
);
1045 JUMP_TO(FILTER_OP_LT_DOUBLE
);
1046 case REG_STRING
: /* Fall-through */
1047 case REG_STAR_GLOB_STRING
:
1051 ERR("Unknown filter register type (%d)",
1058 switch (estack_bx_t
) {
1059 case REG_S64
: /* Fall-through */
1060 case REG_DOUBLE
: /* Fall-through */
1061 case REG_STAR_GLOB_STRING
:
1065 JUMP_TO(FILTER_OP_LT_STRING
);
1067 ERR("Unknown filter register type (%d)",
1074 ERR("Unknown filter register type (%d)",
1082 /* Dynamic typing. */
1083 switch (estack_ax_t
) {
1085 switch (estack_bx_t
) {
1087 JUMP_TO(FILTER_OP_GE_S64
);
1089 JUMP_TO(FILTER_OP_GE_DOUBLE_S64
);
1090 case REG_STRING
: /* Fall-through */
1091 case REG_STAR_GLOB_STRING
:
1095 ERR("Unknown filter register type (%d)",
1102 switch (estack_bx_t
) {
1104 JUMP_TO(FILTER_OP_GE_S64_DOUBLE
);
1106 JUMP_TO(FILTER_OP_GE_DOUBLE
);
1107 case REG_STRING
: /* Fall-through */
1108 case REG_STAR_GLOB_STRING
:
1112 ERR("Unknown filter register type (%d)",
1119 switch (estack_bx_t
) {
1120 case REG_S64
: /* Fall-through */
1121 case REG_DOUBLE
: /* Fall-through */
1122 case REG_STAR_GLOB_STRING
:
1126 JUMP_TO(FILTER_OP_GE_STRING
);
1128 ERR("Unknown filter register type (%d)",
1135 ERR("Unknown filter register type (%d)",
1143 /* Dynamic typing. */
1144 switch (estack_ax_t
) {
1146 switch (estack_bx_t
) {
1148 JUMP_TO(FILTER_OP_LE_S64
);
1150 JUMP_TO(FILTER_OP_LE_DOUBLE_S64
);
1151 case REG_STRING
: /* Fall-through */
1152 case REG_STAR_GLOB_STRING
:
1156 ERR("Unknown filter register type (%d)",
1163 switch (estack_bx_t
) {
1165 JUMP_TO(FILTER_OP_LE_S64_DOUBLE
);
1167 JUMP_TO(FILTER_OP_LE_DOUBLE
);
1168 case REG_STRING
: /* Fall-through */
1169 case REG_STAR_GLOB_STRING
:
1173 ERR("Unknown filter register type (%d)",
1180 switch (estack_bx_t
) {
1181 case REG_S64
: /* Fall-through */
1182 case REG_DOUBLE
: /* Fall-through */
1183 case REG_STAR_GLOB_STRING
:
1187 JUMP_TO(FILTER_OP_LE_STRING
);
1189 ERR("Unknown filter register type (%d)",
1196 ERR("Unknown filter register type (%d)",
1203 OP(FILTER_OP_EQ_STRING
):
1207 res
= (stack_strcmp(stack
, top
, "==") == 0);
1208 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1210 estack_ax_t
= REG_S64
;
1211 next_pc
+= sizeof(struct binary_op
);
1214 OP(FILTER_OP_NE_STRING
):
1218 res
= (stack_strcmp(stack
, top
, "!=") != 0);
1219 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1221 estack_ax_t
= REG_S64
;
1222 next_pc
+= sizeof(struct binary_op
);
1225 OP(FILTER_OP_GT_STRING
):
1229 res
= (stack_strcmp(stack
, top
, ">") > 0);
1230 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1232 estack_ax_t
= REG_S64
;
1233 next_pc
+= sizeof(struct binary_op
);
1236 OP(FILTER_OP_LT_STRING
):
1240 res
= (stack_strcmp(stack
, top
, "<") < 0);
1241 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1243 estack_ax_t
= REG_S64
;
1244 next_pc
+= sizeof(struct binary_op
);
1247 OP(FILTER_OP_GE_STRING
):
1251 res
= (stack_strcmp(stack
, top
, ">=") >= 0);
1252 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1254 estack_ax_t
= REG_S64
;
1255 next_pc
+= sizeof(struct binary_op
);
1258 OP(FILTER_OP_LE_STRING
):
1262 res
= (stack_strcmp(stack
, top
, "<=") <= 0);
1263 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1265 estack_ax_t
= REG_S64
;
1266 next_pc
+= sizeof(struct binary_op
);
1270 OP(FILTER_OP_EQ_STAR_GLOB_STRING
):
1274 res
= (stack_star_glob_match(stack
, top
, "==") == 0);
1275 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1277 estack_ax_t
= REG_S64
;
1278 next_pc
+= sizeof(struct binary_op
);
1281 OP(FILTER_OP_NE_STAR_GLOB_STRING
):
1285 res
= (stack_star_glob_match(stack
, top
, "!=") != 0);
1286 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1288 estack_ax_t
= REG_S64
;
1289 next_pc
+= sizeof(struct binary_op
);
1293 OP(FILTER_OP_EQ_S64
):
1297 res
= (estack_bx_v
== estack_ax_v
);
1298 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1300 estack_ax_t
= REG_S64
;
1301 next_pc
+= sizeof(struct binary_op
);
1304 OP(FILTER_OP_NE_S64
):
1308 res
= (estack_bx_v
!= estack_ax_v
);
1309 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1311 estack_ax_t
= REG_S64
;
1312 next_pc
+= sizeof(struct binary_op
);
1315 OP(FILTER_OP_GT_S64
):
1319 res
= (estack_bx_v
> estack_ax_v
);
1320 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1322 estack_ax_t
= REG_S64
;
1323 next_pc
+= sizeof(struct binary_op
);
1326 OP(FILTER_OP_LT_S64
):
1330 res
= (estack_bx_v
< estack_ax_v
);
1331 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1333 estack_ax_t
= REG_S64
;
1334 next_pc
+= sizeof(struct binary_op
);
1337 OP(FILTER_OP_GE_S64
):
1341 res
= (estack_bx_v
>= estack_ax_v
);
1342 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1344 estack_ax_t
= REG_S64
;
1345 next_pc
+= sizeof(struct binary_op
);
1348 OP(FILTER_OP_LE_S64
):
1352 res
= (estack_bx_v
<= estack_ax_v
);
1353 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1355 estack_ax_t
= REG_S64
;
1356 next_pc
+= sizeof(struct binary_op
);
1360 OP(FILTER_OP_EQ_DOUBLE
):
1364 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax(stack
, top
)->u
.d
);
1365 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1367 estack_ax_t
= REG_S64
;
1368 next_pc
+= sizeof(struct binary_op
);
1371 OP(FILTER_OP_NE_DOUBLE
):
1375 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax(stack
, top
)->u
.d
);
1376 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1378 estack_ax_t
= REG_S64
;
1379 next_pc
+= sizeof(struct binary_op
);
1382 OP(FILTER_OP_GT_DOUBLE
):
1386 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax(stack
, top
)->u
.d
);
1387 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1389 estack_ax_t
= REG_S64
;
1390 next_pc
+= sizeof(struct binary_op
);
1393 OP(FILTER_OP_LT_DOUBLE
):
1397 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax(stack
, top
)->u
.d
);
1398 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1400 estack_ax_t
= REG_S64
;
1401 next_pc
+= sizeof(struct binary_op
);
1404 OP(FILTER_OP_GE_DOUBLE
):
1408 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax(stack
, top
)->u
.d
);
1409 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1411 estack_ax_t
= REG_S64
;
1412 next_pc
+= sizeof(struct binary_op
);
1415 OP(FILTER_OP_LE_DOUBLE
):
1419 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax(stack
, top
)->u
.d
);
1420 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1422 estack_ax_t
= REG_S64
;
1423 next_pc
+= sizeof(struct binary_op
);
1427 /* Mixed S64-double binary comparators */
1428 OP(FILTER_OP_EQ_DOUBLE_S64
):
1432 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax_v
);
1433 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1435 estack_ax_t
= REG_S64
;
1436 next_pc
+= sizeof(struct binary_op
);
1439 OP(FILTER_OP_NE_DOUBLE_S64
):
1443 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax_v
);
1444 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1446 estack_ax_t
= REG_S64
;
1447 next_pc
+= sizeof(struct binary_op
);
1450 OP(FILTER_OP_GT_DOUBLE_S64
):
1454 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax_v
);
1455 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1457 estack_ax_t
= REG_S64
;
1458 next_pc
+= sizeof(struct binary_op
);
1461 OP(FILTER_OP_LT_DOUBLE_S64
):
1465 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax_v
);
1466 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1468 estack_ax_t
= REG_S64
;
1469 next_pc
+= sizeof(struct binary_op
);
1472 OP(FILTER_OP_GE_DOUBLE_S64
):
1476 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax_v
);
1477 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1479 estack_ax_t
= REG_S64
;
1480 next_pc
+= sizeof(struct binary_op
);
1483 OP(FILTER_OP_LE_DOUBLE_S64
):
1487 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax_v
);
1488 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1490 estack_ax_t
= REG_S64
;
1491 next_pc
+= sizeof(struct binary_op
);
1495 OP(FILTER_OP_EQ_S64_DOUBLE
):
1499 res
= (estack_bx_v
== estack_ax(stack
, top
)->u
.d
);
1500 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1502 estack_ax_t
= REG_S64
;
1503 next_pc
+= sizeof(struct binary_op
);
1506 OP(FILTER_OP_NE_S64_DOUBLE
):
1510 res
= (estack_bx_v
!= estack_ax(stack
, top
)->u
.d
);
1511 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1513 estack_ax_t
= REG_S64
;
1514 next_pc
+= sizeof(struct binary_op
);
1517 OP(FILTER_OP_GT_S64_DOUBLE
):
1521 res
= (estack_bx_v
> estack_ax(stack
, top
)->u
.d
);
1522 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1524 estack_ax_t
= REG_S64
;
1525 next_pc
+= sizeof(struct binary_op
);
1528 OP(FILTER_OP_LT_S64_DOUBLE
):
1532 res
= (estack_bx_v
< estack_ax(stack
, top
)->u
.d
);
1533 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1535 estack_ax_t
= REG_S64
;
1536 next_pc
+= sizeof(struct binary_op
);
1539 OP(FILTER_OP_GE_S64_DOUBLE
):
1543 res
= (estack_bx_v
>= estack_ax(stack
, top
)->u
.d
);
1544 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1546 estack_ax_t
= REG_S64
;
1547 next_pc
+= sizeof(struct binary_op
);
1550 OP(FILTER_OP_LE_S64_DOUBLE
):
1554 res
= (estack_bx_v
<= estack_ax(stack
, top
)->u
.d
);
1555 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1557 estack_ax_t
= REG_S64
;
1558 next_pc
+= sizeof(struct binary_op
);
1561 OP(FILTER_OP_BIT_RSHIFT
):
1565 /* Dynamic typing. */
1566 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1570 /* Catch undefined behavior. */
1571 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1575 res
= ((uint64_t) estack_bx_v
>> (uint32_t) estack_ax_v
);
1576 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1578 estack_ax_t
= REG_S64
;
1579 next_pc
+= sizeof(struct binary_op
);
1582 OP(FILTER_OP_BIT_LSHIFT
):
1586 /* Dynamic typing. */
1587 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1591 /* Catch undefined behavior. */
1592 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1596 res
= ((uint64_t) estack_bx_v
<< (uint32_t) estack_ax_v
);
1597 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1599 estack_ax_t
= REG_S64
;
1600 next_pc
+= sizeof(struct binary_op
);
1603 OP(FILTER_OP_BIT_AND
):
1607 /* Dynamic typing. */
1608 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1613 res
= ((uint64_t) estack_bx_v
& (uint64_t) estack_ax_v
);
1614 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1616 estack_ax_t
= REG_S64
;
1617 next_pc
+= sizeof(struct binary_op
);
1620 OP(FILTER_OP_BIT_OR
):
1624 /* Dynamic typing. */
1625 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1630 res
= ((uint64_t) estack_bx_v
| (uint64_t) estack_ax_v
);
1631 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1633 estack_ax_t
= REG_S64
;
1634 next_pc
+= sizeof(struct binary_op
);
1637 OP(FILTER_OP_BIT_XOR
):
1641 /* Dynamic typing. */
1642 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1647 res
= ((uint64_t) estack_bx_v
^ (uint64_t) estack_ax_v
);
1648 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1650 estack_ax_t
= REG_S64
;
1651 next_pc
+= sizeof(struct binary_op
);
1656 OP(FILTER_OP_UNARY_PLUS
):
1658 /* Dynamic typing. */
1659 switch (estack_ax_t
) {
1660 case REG_S64
: /* Fall-through. */
1661 JUMP_TO(FILTER_OP_UNARY_PLUS_S64
);
1663 JUMP_TO(FILTER_OP_UNARY_PLUS_DOUBLE
);
1664 case REG_STRING
: /* Fall-through */
1665 case REG_STAR_GLOB_STRING
:
1669 ERR("Unknown filter register type (%d)",
1675 OP(FILTER_OP_UNARY_MINUS
):
1677 /* Dynamic typing. */
1678 switch (estack_ax_t
) {
1680 JUMP_TO(FILTER_OP_UNARY_MINUS_S64
);
1682 JUMP_TO(FILTER_OP_UNARY_MINUS_DOUBLE
);
1683 case REG_STRING
: /* Fall-through */
1684 case REG_STAR_GLOB_STRING
:
1688 ERR("Unknown filter register type (%d)",
1694 OP(FILTER_OP_UNARY_NOT
):
1696 /* Dynamic typing. */
1697 switch (estack_ax_t
) {
1699 JUMP_TO(FILTER_OP_UNARY_NOT_S64
);
1701 JUMP_TO(FILTER_OP_UNARY_NOT_DOUBLE
);
1702 case REG_STRING
: /* Fall-through */
1703 case REG_STAR_GLOB_STRING
:
1707 ERR("Unknown filter register type (%d)",
1712 next_pc
+= sizeof(struct unary_op
);
1716 OP(FILTER_OP_UNARY_BIT_NOT
):
1718 /* Dynamic typing. */
1719 if (estack_ax_t
!= REG_S64
) {
1724 estack_ax_v
= ~(uint64_t) estack_ax_v
;
1725 next_pc
+= sizeof(struct unary_op
);
1729 OP(FILTER_OP_UNARY_PLUS_S64
):
1730 OP(FILTER_OP_UNARY_PLUS_DOUBLE
):
1732 next_pc
+= sizeof(struct unary_op
);
1735 OP(FILTER_OP_UNARY_MINUS_S64
):
1737 estack_ax_v
= -estack_ax_v
;
1738 next_pc
+= sizeof(struct unary_op
);
1741 OP(FILTER_OP_UNARY_MINUS_DOUBLE
):
1743 estack_ax(stack
, top
)->u
.d
= -estack_ax(stack
, top
)->u
.d
;
1744 next_pc
+= sizeof(struct unary_op
);
1747 OP(FILTER_OP_UNARY_NOT_S64
):
1749 estack_ax_v
= !estack_ax_v
;
1750 next_pc
+= sizeof(struct unary_op
);
1753 OP(FILTER_OP_UNARY_NOT_DOUBLE
):
1755 estack_ax_v
= !estack_ax(stack
, top
)->u
.d
;
1756 estack_ax_t
= REG_S64
;
1757 next_pc
+= sizeof(struct unary_op
);
1764 struct logical_op
*insn
= (struct logical_op
*) pc
;
1766 if (estack_ax_t
!= REG_S64
) {
1770 /* If AX is 0, skip and evaluate to 0 */
1771 if (unlikely(estack_ax_v
== 0)) {
1772 dbg_printf("Jumping to bytecode offset %u\n",
1773 (unsigned int) insn
->skip_offset
);
1774 next_pc
= start_pc
+ insn
->skip_offset
;
1776 /* Pop 1 when jump not taken */
1777 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1778 next_pc
+= sizeof(struct logical_op
);
1784 struct logical_op
*insn
= (struct logical_op
*) pc
;
1786 if (estack_ax_t
!= REG_S64
) {
1790 /* If AX is nonzero, skip and evaluate to 1 */
1791 if (unlikely(estack_ax_v
!= 0)) {
1793 dbg_printf("Jumping to bytecode offset %u\n",
1794 (unsigned int) insn
->skip_offset
);
1795 next_pc
= start_pc
+ insn
->skip_offset
;
1797 /* Pop 1 when jump not taken */
1798 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1799 next_pc
+= sizeof(struct logical_op
);
1805 /* load field ref */
1806 OP(FILTER_OP_LOAD_FIELD_REF_STRING
):
1808 struct load_op
*insn
= (struct load_op
*) pc
;
1809 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1811 dbg_printf("load field ref offset %u type string\n",
1813 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1814 estack_ax(stack
, top
)->u
.s
.str
=
1815 *(const char * const *) &filter_stack_data
[ref
->offset
];
1816 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1817 dbg_printf("Filter warning: loading a NULL string.\n");
1821 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1822 estack_ax(stack
, top
)->u
.s
.literal_type
=
1823 ESTACK_STRING_LITERAL_TYPE_NONE
;
1824 estack_ax_t
= REG_STRING
;
1825 dbg_printf("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1826 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1830 OP(FILTER_OP_LOAD_FIELD_REF_SEQUENCE
):
1832 struct load_op
*insn
= (struct load_op
*) pc
;
1833 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1835 dbg_printf("load field ref offset %u type sequence\n",
1837 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1838 estack_ax(stack
, top
)->u
.s
.seq_len
=
1839 *(unsigned long *) &filter_stack_data
[ref
->offset
];
1840 estack_ax(stack
, top
)->u
.s
.str
=
1841 *(const char **) (&filter_stack_data
[ref
->offset
1842 + sizeof(unsigned long)]);
1843 estack_ax_t
= REG_STRING
;
1844 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1845 dbg_printf("Filter warning: loading a NULL sequence.\n");
1849 estack_ax(stack
, top
)->u
.s
.literal_type
=
1850 ESTACK_STRING_LITERAL_TYPE_NONE
;
1851 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1855 OP(FILTER_OP_LOAD_FIELD_REF_S64
):
1857 struct load_op
*insn
= (struct load_op
*) pc
;
1858 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1860 dbg_printf("load field ref offset %u type s64\n",
1862 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1864 ((struct literal_numeric
*) &filter_stack_data
[ref
->offset
])->v
;
1865 estack_ax_t
= REG_S64
;
1866 dbg_printf("ref load s64 %" PRIi64
"\n", estack_ax_v
);
1867 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1871 OP(FILTER_OP_LOAD_FIELD_REF_DOUBLE
):
1873 struct load_op
*insn
= (struct load_op
*) pc
;
1874 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1876 dbg_printf("load field ref offset %u type double\n",
1878 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1879 memcpy(&estack_ax(stack
, top
)->u
.d
, &filter_stack_data
[ref
->offset
],
1880 sizeof(struct literal_double
));
1881 estack_ax_t
= REG_DOUBLE
;
1882 dbg_printf("ref load double %g\n", estack_ax(stack
, top
)->u
.d
);
1883 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1887 /* load from immediate operand */
1888 OP(FILTER_OP_LOAD_STRING
):
1890 struct load_op
*insn
= (struct load_op
*) pc
;
1892 dbg_printf("load string %s\n", insn
->data
);
1893 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1894 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1895 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1896 estack_ax(stack
, top
)->u
.s
.literal_type
=
1897 ESTACK_STRING_LITERAL_TYPE_PLAIN
;
1898 estack_ax_t
= REG_STRING
;
1899 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1903 OP(FILTER_OP_LOAD_STAR_GLOB_STRING
):
1905 struct load_op
*insn
= (struct load_op
*) pc
;
1907 dbg_printf("load globbing pattern %s\n", insn
->data
);
1908 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1909 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1910 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1911 estack_ax(stack
, top
)->u
.s
.literal_type
=
1912 ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
;
1913 estack_ax_t
= REG_STAR_GLOB_STRING
;
1914 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1918 OP(FILTER_OP_LOAD_S64
):
1920 struct load_op
*insn
= (struct load_op
*) pc
;
1922 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1923 estack_ax_v
= ((struct literal_numeric
*) insn
->data
)->v
;
1924 estack_ax_t
= REG_S64
;
1925 dbg_printf("load s64 %" PRIi64
"\n", estack_ax_v
);
1926 next_pc
+= sizeof(struct load_op
)
1927 + sizeof(struct literal_numeric
);
1931 OP(FILTER_OP_LOAD_DOUBLE
):
1933 struct load_op
*insn
= (struct load_op
*) pc
;
1935 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1936 memcpy(&estack_ax(stack
, top
)->u
.d
, insn
->data
,
1937 sizeof(struct literal_double
));
1938 estack_ax_t
= REG_DOUBLE
;
1939 dbg_printf("load double %g\n", estack_ax(stack
, top
)->u
.d
);
1940 next_pc
+= sizeof(struct load_op
)
1941 + sizeof(struct literal_double
);
1946 OP(FILTER_OP_CAST_TO_S64
):
1948 /* Dynamic typing. */
1949 switch (estack_ax_t
) {
1951 JUMP_TO(FILTER_OP_CAST_NOP
);
1953 JUMP_TO(FILTER_OP_CAST_DOUBLE_TO_S64
);
1954 case REG_STRING
: /* Fall-through */
1955 case REG_STAR_GLOB_STRING
:
1959 ERR("Unknown filter register type (%d)",
1966 OP(FILTER_OP_CAST_DOUBLE_TO_S64
):
1968 estack_ax_v
= (int64_t) estack_ax(stack
, top
)->u
.d
;
1969 estack_ax_t
= REG_S64
;
1970 next_pc
+= sizeof(struct cast_op
);
1974 OP(FILTER_OP_CAST_NOP
):
1976 next_pc
+= sizeof(struct cast_op
);
1980 /* get context ref */
1981 OP(FILTER_OP_GET_CONTEXT_REF
):
1983 struct load_op
*insn
= (struct load_op
*) pc
;
1984 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1985 struct lttng_ctx
*ctx
;
1986 struct lttng_ctx_field
*ctx_field
;
1987 struct lttng_ctx_value v
;
1989 dbg_printf("get context ref offset %u type dynamic\n",
1991 ctx
= rcu_dereference(session
->ctx
);
1992 ctx_field
= &ctx
->fields
[ref
->offset
];
1993 ctx_field
->get_value(ctx_field
, &v
);
1994 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1996 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
1999 case LTTNG_UST_DYNAMIC_TYPE_S64
:
2000 estack_ax_v
= v
.u
.s64
;
2001 estack_ax_t
= REG_S64
;
2002 dbg_printf("ref get context dynamic s64 %" PRIi64
"\n", estack_ax_v
);
2004 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
2005 estack_ax(stack
, top
)->u
.d
= v
.u
.d
;
2006 estack_ax_t
= REG_DOUBLE
;
2007 dbg_printf("ref get context dynamic double %g\n", estack_ax(stack
, top
)->u
.d
);
2009 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
2010 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2011 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2012 dbg_printf("Filter warning: loading a NULL string.\n");
2016 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2017 estack_ax(stack
, top
)->u
.s
.literal_type
=
2018 ESTACK_STRING_LITERAL_TYPE_NONE
;
2019 dbg_printf("ref get context dynamic string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2020 estack_ax_t
= REG_STRING
;
2023 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
2027 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2031 OP(FILTER_OP_GET_CONTEXT_REF_STRING
):
2033 struct load_op
*insn
= (struct load_op
*) pc
;
2034 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2035 struct lttng_ctx
*ctx
;
2036 struct lttng_ctx_field
*ctx_field
;
2037 struct lttng_ctx_value v
;
2039 dbg_printf("get context ref offset %u type string\n",
2041 ctx
= rcu_dereference(session
->ctx
);
2042 ctx_field
= &ctx
->fields
[ref
->offset
];
2043 ctx_field
->get_value(ctx_field
, &v
);
2044 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2045 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2046 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2047 dbg_printf("Filter warning: loading a NULL string.\n");
2051 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2052 estack_ax(stack
, top
)->u
.s
.literal_type
=
2053 ESTACK_STRING_LITERAL_TYPE_NONE
;
2054 estack_ax_t
= REG_STRING
;
2055 dbg_printf("ref get context string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2056 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2060 OP(FILTER_OP_GET_CONTEXT_REF_S64
):
2062 struct load_op
*insn
= (struct load_op
*) pc
;
2063 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2064 struct lttng_ctx
*ctx
;
2065 struct lttng_ctx_field
*ctx_field
;
2066 struct lttng_ctx_value v
;
2068 dbg_printf("get context ref offset %u type s64\n",
2070 ctx
= rcu_dereference(session
->ctx
);
2071 ctx_field
= &ctx
->fields
[ref
->offset
];
2072 ctx_field
->get_value(ctx_field
, &v
);
2073 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2074 estack_ax_v
= v
.u
.s64
;
2075 estack_ax_t
= REG_S64
;
2076 dbg_printf("ref get context s64 %" PRIi64
"\n", estack_ax_v
);
2077 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2081 OP(FILTER_OP_GET_CONTEXT_REF_DOUBLE
):
2083 struct load_op
*insn
= (struct load_op
*) pc
;
2084 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2085 struct lttng_ctx
*ctx
;
2086 struct lttng_ctx_field
*ctx_field
;
2087 struct lttng_ctx_value v
;
2089 dbg_printf("get context ref offset %u type double\n",
2091 ctx
= rcu_dereference(session
->ctx
);
2092 ctx_field
= &ctx
->fields
[ref
->offset
];
2093 ctx_field
->get_value(ctx_field
, &v
);
2094 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2095 memcpy(&estack_ax(stack
, top
)->u
.d
, &v
.u
.d
, sizeof(struct literal_double
));
2096 estack_ax_t
= REG_DOUBLE
;
2097 dbg_printf("ref get context double %g\n", estack_ax(stack
, top
)->u
.d
);
2098 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2102 OP(FILTER_OP_GET_CONTEXT_ROOT
):
2104 dbg_printf("op get context root\n");
2105 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2106 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_CONTEXT
;
2107 /* "field" only needed for variants. */
2108 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2109 estack_ax_t
= REG_PTR
;
2110 next_pc
+= sizeof(struct load_op
);
2114 OP(FILTER_OP_GET_APP_CONTEXT_ROOT
):
2116 dbg_printf("op get app context root\n");
2117 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2118 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_APP_CONTEXT
;
2119 /* "field" only needed for variants. */
2120 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2121 estack_ax_t
= REG_PTR
;
2122 next_pc
+= sizeof(struct load_op
);
2126 OP(FILTER_OP_GET_PAYLOAD_ROOT
):
2128 dbg_printf("op get app payload root\n");
2129 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2130 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_PAYLOAD
;
2131 estack_ax(stack
, top
)->u
.ptr
.ptr
= filter_stack_data
;
2132 /* "field" only needed for variants. */
2133 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2134 estack_ax_t
= REG_PTR
;
2135 next_pc
+= sizeof(struct load_op
);
2139 OP(FILTER_OP_GET_SYMBOL
):
2141 dbg_printf("op get symbol\n");
2142 switch (estack_ax(stack
, top
)->u
.ptr
.type
) {
2144 ERR("Nested fields not implemented yet.");
2147 case LOAD_ROOT_CONTEXT
:
2148 case LOAD_ROOT_APP_CONTEXT
:
2149 case LOAD_ROOT_PAYLOAD
:
2151 * symbol lookup is performed by
2157 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_symbol
);
2161 OP(FILTER_OP_GET_SYMBOL_FIELD
):
2164 * Used for first variant encountered in a
2165 * traversal. Variants are not implemented yet.
2171 OP(FILTER_OP_GET_INDEX_U16
):
2173 struct load_op
*insn
= (struct load_op
*) pc
;
2174 struct get_index_u16
*index
= (struct get_index_u16
*) insn
->data
;
2176 dbg_printf("op get index u16\n");
2177 ret
= dynamic_get_index(session
, bytecode
, index
->index
, estack_ax(stack
, top
));
2180 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2181 estack_ax_t
= estack_ax(stack
, top
)->type
;
2182 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u16
);
2186 OP(FILTER_OP_GET_INDEX_U64
):
2188 struct load_op
*insn
= (struct load_op
*) pc
;
2189 struct get_index_u64
*index
= (struct get_index_u64
*) insn
->data
;
2191 dbg_printf("op get index u64\n");
2192 ret
= dynamic_get_index(session
, bytecode
, index
->index
, estack_ax(stack
, top
));
2195 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2196 estack_ax_t
= estack_ax(stack
, top
)->type
;
2197 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u64
);
2201 OP(FILTER_OP_LOAD_FIELD
):
2203 dbg_printf("op load field\n");
2204 ret
= dynamic_load_field(estack_ax(stack
, top
));
2207 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2208 estack_ax_t
= estack_ax(stack
, top
)->type
;
2209 next_pc
+= sizeof(struct load_op
);
2213 OP(FILTER_OP_LOAD_FIELD_S8
):
2215 dbg_printf("op load field s8\n");
2217 estack_ax_v
= *(int8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2218 estack_ax_t
= REG_S64
;
2219 next_pc
+= sizeof(struct load_op
);
2222 OP(FILTER_OP_LOAD_FIELD_S16
):
2224 dbg_printf("op load field s16\n");
2226 estack_ax_v
= *(int16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2227 estack_ax_t
= REG_S64
;
2228 next_pc
+= sizeof(struct load_op
);
2231 OP(FILTER_OP_LOAD_FIELD_S32
):
2233 dbg_printf("op load field s32\n");
2235 estack_ax_v
= *(int32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2236 estack_ax_t
= REG_S64
;
2237 next_pc
+= sizeof(struct load_op
);
2240 OP(FILTER_OP_LOAD_FIELD_S64
):
2242 dbg_printf("op load field s64\n");
2244 estack_ax_v
= *(int64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2245 estack_ax_t
= REG_S64
;
2246 next_pc
+= sizeof(struct load_op
);
2249 OP(FILTER_OP_LOAD_FIELD_U8
):
2251 dbg_printf("op load field u8\n");
2253 estack_ax_v
= *(uint8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2254 estack_ax_t
= REG_S64
;
2255 next_pc
+= sizeof(struct load_op
);
2258 OP(FILTER_OP_LOAD_FIELD_U16
):
2260 dbg_printf("op load field u16\n");
2262 estack_ax_v
= *(uint16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2263 estack_ax_t
= REG_S64
;
2264 next_pc
+= sizeof(struct load_op
);
2267 OP(FILTER_OP_LOAD_FIELD_U32
):
2269 dbg_printf("op load field u32\n");
2271 estack_ax_v
= *(uint32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2272 estack_ax_t
= REG_S64
;
2273 next_pc
+= sizeof(struct load_op
);
2276 OP(FILTER_OP_LOAD_FIELD_U64
):
2278 dbg_printf("op load field u64\n");
2280 estack_ax_v
= *(uint64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2281 estack_ax_t
= REG_S64
;
2282 next_pc
+= sizeof(struct load_op
);
2285 OP(FILTER_OP_LOAD_FIELD_DOUBLE
):
2287 dbg_printf("op load field double\n");
2289 memcpy(&estack_ax(stack
, top
)->u
.d
,
2290 estack_ax(stack
, top
)->u
.ptr
.ptr
,
2291 sizeof(struct literal_double
));
2292 estack_ax(stack
, top
)->type
= REG_DOUBLE
;
2293 next_pc
+= sizeof(struct load_op
);
2297 OP(FILTER_OP_LOAD_FIELD_STRING
):
2301 dbg_printf("op load field string\n");
2302 str
= (const char *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2303 estack_ax(stack
, top
)->u
.s
.str
= str
;
2304 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2305 dbg_printf("Filter warning: loading a NULL string.\n");
2309 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2310 estack_ax(stack
, top
)->u
.s
.literal_type
=
2311 ESTACK_STRING_LITERAL_TYPE_NONE
;
2312 estack_ax(stack
, top
)->type
= REG_STRING
;
2313 next_pc
+= sizeof(struct load_op
);
2317 OP(FILTER_OP_LOAD_FIELD_SEQUENCE
):
2321 dbg_printf("op load field string sequence\n");
2322 ptr
= estack_ax(stack
, top
)->u
.ptr
.ptr
;
2323 estack_ax(stack
, top
)->u
.s
.seq_len
= *(unsigned long *) ptr
;
2324 estack_ax(stack
, top
)->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
2325 estack_ax(stack
, top
)->type
= REG_STRING
;
2326 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2327 dbg_printf("Filter warning: loading a NULL sequence.\n");
2331 estack_ax(stack
, top
)->u
.s
.literal_type
=
2332 ESTACK_STRING_LITERAL_TYPE_NONE
;
2333 next_pc
+= sizeof(struct load_op
);
2339 /* return 0 (discard) on error */