2 * lttng-filter-interpreter.c
4 * LTTng UST filter interpreter.
6 * Copyright (C) 2010-2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 #include <urcu-pointer.h>
31 #include "lttng-filter.h"
32 #include "string-utils.h"
36 * -2: unknown escape char.
41 int parse_char(const char **p
)
61 * Returns SIZE_MAX if the string is null-terminated, or the number of
65 size_t get_str_or_seq_len(const struct estack_entry
*entry
)
67 return entry
->u
.s
.seq_len
;
71 int stack_star_glob_match(struct estack
*stack
, int top
, const char *cmp_type
)
74 const char *candidate
;
78 /* Find out which side is the pattern vs. the candidate. */
79 if (estack_ax(stack
, top
)->u
.s
.literal_type
== ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
) {
80 pattern
= estack_ax(stack
, top
)->u
.s
.str
;
81 pattern_len
= get_str_or_seq_len(estack_ax(stack
, top
));
82 candidate
= estack_bx(stack
, top
)->u
.s
.str
;
83 candidate_len
= get_str_or_seq_len(estack_bx(stack
, top
));
85 pattern
= estack_bx(stack
, top
)->u
.s
.str
;
86 pattern_len
= get_str_or_seq_len(estack_bx(stack
, top
));
87 candidate
= estack_ax(stack
, top
)->u
.s
.str
;
88 candidate_len
= get_str_or_seq_len(estack_ax(stack
, top
));
91 /* Perform the match. Returns 0 when the result is true. */
92 return !strutils_star_glob_match(pattern
, pattern_len
, candidate
,
97 int stack_strcmp(struct estack
*stack
, int top
, const char *cmp_type
)
99 const char *p
= estack_bx(stack
, top
)->u
.s
.str
, *q
= estack_ax(stack
, top
)->u
.s
.str
;
106 if (unlikely(p
- estack_bx(stack
, top
)->u
.s
.str
>= estack_bx(stack
, top
)->u
.s
.seq_len
|| *p
== '\0')) {
107 if (q
- estack_ax(stack
, top
)->u
.s
.str
>= estack_ax(stack
, top
)->u
.s
.seq_len
|| *q
== '\0') {
110 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
111 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
112 ret
= parse_char(&q
);
119 if (unlikely(q
- estack_ax(stack
, top
)->u
.s
.str
>= estack_ax(stack
, top
)->u
.s
.seq_len
|| *q
== '\0')) {
120 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
121 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
122 ret
= parse_char(&p
);
128 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
129 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
130 ret
= parse_char(&p
);
133 } else if (ret
== -2) {
136 /* else compare both char */
138 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
139 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
140 ret
= parse_char(&q
);
143 } else if (ret
== -2) {
163 uint64_t lttng_filter_false(void *filter_data
,
164 const char *filter_stack_data
)
169 #ifdef INTERPRETER_USE_SWITCH
172 * Fallback for compilers that do not support taking address of labels.
176 start_pc = &bytecode->data[0]; \
177 for (pc = next_pc = start_pc; pc - start_pc < bytecode->len; \
179 dbg_printf("Executing op %s (%u)\n", \
180 print_op((unsigned int) *(filter_opcode_t *) pc), \
181 (unsigned int) *(filter_opcode_t *) pc); \
182 switch (*(filter_opcode_t *) pc) {
184 #define OP(name) jump_target_##name: __attribute__((unused)); \
192 #define JUMP_TO(name) \
193 goto jump_target_##name
198 * Dispatch-table based interpreter.
202 start_pc = &bytecode->code[0]; \
203 pc = next_pc = start_pc; \
204 if (unlikely(pc - start_pc >= bytecode->len)) \
206 goto *dispatch[*(filter_opcode_t *) pc];
213 goto *dispatch[*(filter_opcode_t *) pc];
217 #define JUMP_TO(name) \
222 static int context_get_index(struct lttng_ctx
*ctx
,
223 struct load_ptr
*ptr
,
227 struct lttng_ctx_field
*ctx_field
;
228 struct lttng_event_field
*field
;
229 struct lttng_ctx_value v
;
231 ctx_field
= &ctx
->fields
[idx
];
232 field
= &ctx_field
->event_field
;
233 ptr
->type
= LOAD_OBJECT
;
234 /* field is only used for types nested within variants. */
237 switch (field
->type
.atype
) {
239 ctx_field
->get_value(ctx_field
, &v
);
240 if (field
->type
.u
.basic
.integer
.signedness
) {
241 ptr
->object_type
= OBJECT_TYPE_S64
;
242 ptr
->u
.s64
= v
.u
.s64
;
243 ptr
->ptr
= &ptr
->u
.s64
;
245 ptr
->object_type
= OBJECT_TYPE_U64
;
246 ptr
->u
.u64
= v
.u
.s64
; /* Cast. */
247 ptr
->ptr
= &ptr
->u
.u64
;
252 const struct lttng_integer_type
*itype
=
253 &field
->type
.u
.basic
.enumeration
.container_type
;
255 ctx_field
->get_value(ctx_field
, &v
);
256 if (itype
->signedness
) {
257 ptr
->object_type
= OBJECT_TYPE_S64
;
258 ptr
->u
.s64
= v
.u
.s64
;
259 ptr
->ptr
= &ptr
->u
.s64
;
261 ptr
->object_type
= OBJECT_TYPE_U64
;
262 ptr
->u
.u64
= v
.u
.s64
; /* Cast. */
263 ptr
->ptr
= &ptr
->u
.u64
;
268 if (field
->type
.u
.array
.elem_type
.atype
!= atype_integer
) {
269 ERR("Array nesting only supports integer types.");
272 if (field
->type
.u
.array
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
273 ERR("Only string arrays are supported for contexts.");
276 ptr
->object_type
= OBJECT_TYPE_STRING
;
277 ctx_field
->get_value(ctx_field
, &v
);
281 if (field
->type
.u
.sequence
.elem_type
.atype
!= atype_integer
) {
282 ERR("Sequence nesting only supports integer types.");
285 if (field
->type
.u
.sequence
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
286 ERR("Only string sequences are supported for contexts.");
289 ptr
->object_type
= OBJECT_TYPE_STRING
;
290 ctx_field
->get_value(ctx_field
, &v
);
294 ptr
->object_type
= OBJECT_TYPE_STRING
;
295 ctx_field
->get_value(ctx_field
, &v
);
299 ptr
->object_type
= OBJECT_TYPE_DOUBLE
;
301 ptr
->ptr
= &ptr
->u
.d
;
304 ctx_field
->get_value(ctx_field
, &v
);
306 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
308 case LTTNG_UST_DYNAMIC_TYPE_S64
:
309 ptr
->object_type
= OBJECT_TYPE_S64
;
310 ptr
->u
.s64
= v
.u
.s64
;
311 ptr
->ptr
= &ptr
->u
.s64
;
312 dbg_printf("context get index dynamic s64 %" PRIi64
"\n", ptr
->u
.s64
);
314 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
315 ptr
->object_type
= OBJECT_TYPE_DOUBLE
;
317 ptr
->ptr
= &ptr
->u
.d
;
318 dbg_printf("context get index dynamic double %g\n", ptr
->u
.d
);
320 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
321 ptr
->object_type
= OBJECT_TYPE_STRING
;
323 dbg_printf("context get index dynamic string %s\n", (const char *) ptr
->ptr
);
326 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
331 ERR("Structure type cannot be loaded.");
334 ERR("Unknown type: %d", (int) field
->type
.atype
);
340 static int dynamic_get_index(struct lttng_session
*session
,
341 struct bytecode_runtime
*runtime
,
342 uint64_t index
, struct estack_entry
*stack_top
)
345 const struct filter_get_index_data
*gid
;
348 * Types nested within variants need to perform dynamic lookup
349 * based on the field descriptions. LTTng-UST does not implement
352 if (stack_top
->u
.ptr
.field
)
354 gid
= (const struct filter_get_index_data
*) &runtime
->data
[index
];
355 switch (stack_top
->u
.ptr
.type
) {
357 switch (stack_top
->u
.ptr
.object_type
) {
358 case OBJECT_TYPE_ARRAY
:
362 assert(gid
->offset
< gid
->array_len
);
363 /* Skip count (unsigned long) */
364 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
365 ptr
= ptr
+ gid
->offset
;
366 stack_top
->u
.ptr
.ptr
= ptr
;
367 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
368 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
369 /* field is only used for types nested within variants. */
370 stack_top
->u
.ptr
.field
= NULL
;
373 case OBJECT_TYPE_SEQUENCE
:
378 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
379 ptr_seq_len
= *(unsigned long *) stack_top
->u
.ptr
.ptr
;
380 if (gid
->offset
>= gid
->elem
.len
* ptr_seq_len
) {
384 ptr
= ptr
+ gid
->offset
;
385 stack_top
->u
.ptr
.ptr
= ptr
;
386 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
387 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
388 /* field is only used for types nested within variants. */
389 stack_top
->u
.ptr
.field
= NULL
;
392 case OBJECT_TYPE_STRUCT
:
393 ERR("Nested structures are not supported yet.");
396 case OBJECT_TYPE_VARIANT
:
398 ERR("Unexpected get index type %d",
399 (int) stack_top
->u
.ptr
.object_type
);
404 case LOAD_ROOT_CONTEXT
:
405 case LOAD_ROOT_APP_CONTEXT
: /* Fall-through */
407 struct lttng_ctx
*ctx
;
409 ctx
= rcu_dereference(session
->ctx
);
410 ret
= context_get_index(ctx
,
418 case LOAD_ROOT_PAYLOAD
:
419 stack_top
->u
.ptr
.ptr
+= gid
->offset
;
420 if (gid
->elem
.type
== OBJECT_TYPE_STRING
)
421 stack_top
->u
.ptr
.ptr
= *(const char * const *) stack_top
->u
.ptr
.ptr
;
422 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
423 stack_top
->u
.ptr
.type
= LOAD_OBJECT
;
424 /* field is only used for types nested within variants. */
425 stack_top
->u
.ptr
.field
= NULL
;
434 static int dynamic_load_field(struct estack_entry
*stack_top
)
438 switch (stack_top
->u
.ptr
.type
) {
441 case LOAD_ROOT_CONTEXT
:
442 case LOAD_ROOT_APP_CONTEXT
:
443 case LOAD_ROOT_PAYLOAD
:
445 dbg_printf("Filter warning: cannot load root, missing field name.\n");
449 switch (stack_top
->u
.ptr
.object_type
) {
451 dbg_printf("op load field s8\n");
452 stack_top
->u
.v
= *(int8_t *) stack_top
->u
.ptr
.ptr
;
453 stack_top
->type
= REG_S64
;
455 case OBJECT_TYPE_S16
:
459 dbg_printf("op load field s16\n");
460 tmp
= *(int16_t *) stack_top
->u
.ptr
.ptr
;
461 if (stack_top
->u
.ptr
.rev_bo
)
463 stack_top
->u
.v
= tmp
;
464 stack_top
->type
= REG_S64
;
467 case OBJECT_TYPE_S32
:
471 dbg_printf("op load field s32\n");
472 tmp
= *(int32_t *) stack_top
->u
.ptr
.ptr
;
473 if (stack_top
->u
.ptr
.rev_bo
)
475 stack_top
->u
.v
= tmp
;
476 stack_top
->type
= REG_S64
;
479 case OBJECT_TYPE_S64
:
483 dbg_printf("op load field s64\n");
484 tmp
= *(int64_t *) stack_top
->u
.ptr
.ptr
;
485 if (stack_top
->u
.ptr
.rev_bo
)
487 stack_top
->u
.v
= tmp
;
488 stack_top
->type
= REG_S64
;
492 dbg_printf("op load field u8\n");
493 stack_top
->u
.v
= *(uint8_t *) stack_top
->u
.ptr
.ptr
;
494 stack_top
->type
= REG_S64
;
496 case OBJECT_TYPE_U16
:
500 dbg_printf("op load field s16\n");
501 tmp
= *(uint16_t *) stack_top
->u
.ptr
.ptr
;
502 if (stack_top
->u
.ptr
.rev_bo
)
504 stack_top
->u
.v
= tmp
;
505 stack_top
->type
= REG_S64
;
508 case OBJECT_TYPE_U32
:
512 dbg_printf("op load field u32\n");
513 tmp
= *(uint32_t *) stack_top
->u
.ptr
.ptr
;
514 if (stack_top
->u
.ptr
.rev_bo
)
516 stack_top
->u
.v
= tmp
;
517 stack_top
->type
= REG_S64
;
520 case OBJECT_TYPE_U64
:
524 dbg_printf("op load field u64\n");
525 tmp
= *(uint64_t *) stack_top
->u
.ptr
.ptr
;
526 if (stack_top
->u
.ptr
.rev_bo
)
528 stack_top
->u
.v
= tmp
;
529 stack_top
->type
= REG_S64
;
532 case OBJECT_TYPE_DOUBLE
:
533 memcpy(&stack_top
->u
.d
,
534 stack_top
->u
.ptr
.ptr
,
535 sizeof(struct literal_double
));
536 stack_top
->type
= REG_DOUBLE
;
538 case OBJECT_TYPE_STRING
:
542 dbg_printf("op load field string\n");
543 str
= (const char *) stack_top
->u
.ptr
.ptr
;
544 stack_top
->u
.s
.str
= str
;
545 if (unlikely(!stack_top
->u
.s
.str
)) {
546 dbg_printf("Filter warning: loading a NULL string.\n");
550 stack_top
->u
.s
.seq_len
= SIZE_MAX
;
551 stack_top
->u
.s
.literal_type
=
552 ESTACK_STRING_LITERAL_TYPE_NONE
;
553 stack_top
->type
= REG_STRING
;
556 case OBJECT_TYPE_STRING_SEQUENCE
:
560 dbg_printf("op load field string sequence\n");
561 ptr
= stack_top
->u
.ptr
.ptr
;
562 stack_top
->u
.s
.seq_len
= *(unsigned long *) ptr
;
563 stack_top
->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
564 stack_top
->type
= REG_STRING
;
565 if (unlikely(!stack_top
->u
.s
.str
)) {
566 dbg_printf("Filter warning: loading a NULL sequence.\n");
570 stack_top
->u
.s
.literal_type
=
571 ESTACK_STRING_LITERAL_TYPE_NONE
;
574 case OBJECT_TYPE_DYNAMIC
:
576 * Dynamic types in context are looked up
577 * by context get index.
581 case OBJECT_TYPE_SEQUENCE
:
582 case OBJECT_TYPE_ARRAY
:
583 case OBJECT_TYPE_STRUCT
:
584 case OBJECT_TYPE_VARIANT
:
585 ERR("Sequences, arrays, struct and variant cannot be loaded (nested types).");
596 * Return 0 (discard), or raise the 0x1 flag (log event).
597 * Currently, other flags are kept for future extensions and have no
600 uint64_t lttng_filter_interpret_bytecode(void *filter_data
,
601 const char *filter_stack_data
)
603 struct bytecode_runtime
*bytecode
= filter_data
;
604 struct lttng_session
*session
= bytecode
->p
.session
;
605 void *pc
, *next_pc
, *start_pc
;
608 struct estack _stack
;
609 struct estack
*stack
= &_stack
;
610 register int64_t ax
= 0, bx
= 0;
611 register enum entry_type ax_t
= REG_UNKNOWN
, bx_t
= REG_UNKNOWN
;
612 register int top
= FILTER_STACK_EMPTY
;
613 #ifndef INTERPRETER_USE_SWITCH
614 static void *dispatch
[NR_FILTER_OPS
] = {
615 [ FILTER_OP_UNKNOWN
] = &&LABEL_FILTER_OP_UNKNOWN
,
617 [ FILTER_OP_RETURN
] = &&LABEL_FILTER_OP_RETURN
,
620 [ FILTER_OP_MUL
] = &&LABEL_FILTER_OP_MUL
,
621 [ FILTER_OP_DIV
] = &&LABEL_FILTER_OP_DIV
,
622 [ FILTER_OP_MOD
] = &&LABEL_FILTER_OP_MOD
,
623 [ FILTER_OP_PLUS
] = &&LABEL_FILTER_OP_PLUS
,
624 [ FILTER_OP_MINUS
] = &&LABEL_FILTER_OP_MINUS
,
625 [ FILTER_OP_BIT_RSHIFT
] = &&LABEL_FILTER_OP_BIT_RSHIFT
,
626 [ FILTER_OP_BIT_LSHIFT
] = &&LABEL_FILTER_OP_BIT_LSHIFT
,
627 [ FILTER_OP_BIT_AND
] = &&LABEL_FILTER_OP_BIT_AND
,
628 [ FILTER_OP_BIT_OR
] = &&LABEL_FILTER_OP_BIT_OR
,
629 [ FILTER_OP_BIT_XOR
] = &&LABEL_FILTER_OP_BIT_XOR
,
631 /* binary comparators */
632 [ FILTER_OP_EQ
] = &&LABEL_FILTER_OP_EQ
,
633 [ FILTER_OP_NE
] = &&LABEL_FILTER_OP_NE
,
634 [ FILTER_OP_GT
] = &&LABEL_FILTER_OP_GT
,
635 [ FILTER_OP_LT
] = &&LABEL_FILTER_OP_LT
,
636 [ FILTER_OP_GE
] = &&LABEL_FILTER_OP_GE
,
637 [ FILTER_OP_LE
] = &&LABEL_FILTER_OP_LE
,
639 /* string binary comparator */
640 [ FILTER_OP_EQ_STRING
] = &&LABEL_FILTER_OP_EQ_STRING
,
641 [ FILTER_OP_NE_STRING
] = &&LABEL_FILTER_OP_NE_STRING
,
642 [ FILTER_OP_GT_STRING
] = &&LABEL_FILTER_OP_GT_STRING
,
643 [ FILTER_OP_LT_STRING
] = &&LABEL_FILTER_OP_LT_STRING
,
644 [ FILTER_OP_GE_STRING
] = &&LABEL_FILTER_OP_GE_STRING
,
645 [ FILTER_OP_LE_STRING
] = &&LABEL_FILTER_OP_LE_STRING
,
647 /* globbing pattern binary comparator */
648 [ FILTER_OP_EQ_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_EQ_STAR_GLOB_STRING
,
649 [ FILTER_OP_NE_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_NE_STAR_GLOB_STRING
,
651 /* s64 binary comparator */
652 [ FILTER_OP_EQ_S64
] = &&LABEL_FILTER_OP_EQ_S64
,
653 [ FILTER_OP_NE_S64
] = &&LABEL_FILTER_OP_NE_S64
,
654 [ FILTER_OP_GT_S64
] = &&LABEL_FILTER_OP_GT_S64
,
655 [ FILTER_OP_LT_S64
] = &&LABEL_FILTER_OP_LT_S64
,
656 [ FILTER_OP_GE_S64
] = &&LABEL_FILTER_OP_GE_S64
,
657 [ FILTER_OP_LE_S64
] = &&LABEL_FILTER_OP_LE_S64
,
659 /* double binary comparator */
660 [ FILTER_OP_EQ_DOUBLE
] = &&LABEL_FILTER_OP_EQ_DOUBLE
,
661 [ FILTER_OP_NE_DOUBLE
] = &&LABEL_FILTER_OP_NE_DOUBLE
,
662 [ FILTER_OP_GT_DOUBLE
] = &&LABEL_FILTER_OP_GT_DOUBLE
,
663 [ FILTER_OP_LT_DOUBLE
] = &&LABEL_FILTER_OP_LT_DOUBLE
,
664 [ FILTER_OP_GE_DOUBLE
] = &&LABEL_FILTER_OP_GE_DOUBLE
,
665 [ FILTER_OP_LE_DOUBLE
] = &&LABEL_FILTER_OP_LE_DOUBLE
,
667 /* Mixed S64-double binary comparators */
668 [ FILTER_OP_EQ_DOUBLE_S64
] = &&LABEL_FILTER_OP_EQ_DOUBLE_S64
,
669 [ FILTER_OP_NE_DOUBLE_S64
] = &&LABEL_FILTER_OP_NE_DOUBLE_S64
,
670 [ FILTER_OP_GT_DOUBLE_S64
] = &&LABEL_FILTER_OP_GT_DOUBLE_S64
,
671 [ FILTER_OP_LT_DOUBLE_S64
] = &&LABEL_FILTER_OP_LT_DOUBLE_S64
,
672 [ FILTER_OP_GE_DOUBLE_S64
] = &&LABEL_FILTER_OP_GE_DOUBLE_S64
,
673 [ FILTER_OP_LE_DOUBLE_S64
] = &&LABEL_FILTER_OP_LE_DOUBLE_S64
,
675 [ FILTER_OP_EQ_S64_DOUBLE
] = &&LABEL_FILTER_OP_EQ_S64_DOUBLE
,
676 [ FILTER_OP_NE_S64_DOUBLE
] = &&LABEL_FILTER_OP_NE_S64_DOUBLE
,
677 [ FILTER_OP_GT_S64_DOUBLE
] = &&LABEL_FILTER_OP_GT_S64_DOUBLE
,
678 [ FILTER_OP_LT_S64_DOUBLE
] = &&LABEL_FILTER_OP_LT_S64_DOUBLE
,
679 [ FILTER_OP_GE_S64_DOUBLE
] = &&LABEL_FILTER_OP_GE_S64_DOUBLE
,
680 [ FILTER_OP_LE_S64_DOUBLE
] = &&LABEL_FILTER_OP_LE_S64_DOUBLE
,
683 [ FILTER_OP_UNARY_PLUS
] = &&LABEL_FILTER_OP_UNARY_PLUS
,
684 [ FILTER_OP_UNARY_MINUS
] = &&LABEL_FILTER_OP_UNARY_MINUS
,
685 [ FILTER_OP_UNARY_NOT
] = &&LABEL_FILTER_OP_UNARY_NOT
,
686 [ FILTER_OP_UNARY_PLUS_S64
] = &&LABEL_FILTER_OP_UNARY_PLUS_S64
,
687 [ FILTER_OP_UNARY_MINUS_S64
] = &&LABEL_FILTER_OP_UNARY_MINUS_S64
,
688 [ FILTER_OP_UNARY_NOT_S64
] = &&LABEL_FILTER_OP_UNARY_NOT_S64
,
689 [ FILTER_OP_UNARY_PLUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_PLUS_DOUBLE
,
690 [ FILTER_OP_UNARY_MINUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_MINUS_DOUBLE
,
691 [ FILTER_OP_UNARY_NOT_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_NOT_DOUBLE
,
694 [ FILTER_OP_AND
] = &&LABEL_FILTER_OP_AND
,
695 [ FILTER_OP_OR
] = &&LABEL_FILTER_OP_OR
,
698 [ FILTER_OP_LOAD_FIELD_REF
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF
,
699 [ FILTER_OP_LOAD_FIELD_REF_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_STRING
,
700 [ FILTER_OP_LOAD_FIELD_REF_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_SEQUENCE
,
701 [ FILTER_OP_LOAD_FIELD_REF_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_S64
,
702 [ FILTER_OP_LOAD_FIELD_REF_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_DOUBLE
,
704 /* load from immediate operand */
705 [ FILTER_OP_LOAD_STRING
] = &&LABEL_FILTER_OP_LOAD_STRING
,
706 [ FILTER_OP_LOAD_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_LOAD_STAR_GLOB_STRING
,
707 [ FILTER_OP_LOAD_S64
] = &&LABEL_FILTER_OP_LOAD_S64
,
708 [ FILTER_OP_LOAD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_DOUBLE
,
711 [ FILTER_OP_CAST_TO_S64
] = &&LABEL_FILTER_OP_CAST_TO_S64
,
712 [ FILTER_OP_CAST_DOUBLE_TO_S64
] = &&LABEL_FILTER_OP_CAST_DOUBLE_TO_S64
,
713 [ FILTER_OP_CAST_NOP
] = &&LABEL_FILTER_OP_CAST_NOP
,
715 /* get context ref */
716 [ FILTER_OP_GET_CONTEXT_REF
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF
,
717 [ FILTER_OP_GET_CONTEXT_REF_STRING
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_STRING
,
718 [ FILTER_OP_GET_CONTEXT_REF_S64
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_S64
,
719 [ FILTER_OP_GET_CONTEXT_REF_DOUBLE
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_DOUBLE
,
721 /* Instructions for recursive traversal through composed types. */
722 [ FILTER_OP_GET_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_CONTEXT_ROOT
,
723 [ FILTER_OP_GET_APP_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_APP_CONTEXT_ROOT
,
724 [ FILTER_OP_GET_PAYLOAD_ROOT
] = &&LABEL_FILTER_OP_GET_PAYLOAD_ROOT
,
726 [ FILTER_OP_GET_SYMBOL
] = &&LABEL_FILTER_OP_GET_SYMBOL
,
727 [ FILTER_OP_GET_SYMBOL_FIELD
] = &&LABEL_FILTER_OP_GET_SYMBOL_FIELD
,
728 [ FILTER_OP_GET_INDEX_U16
] = &&LABEL_FILTER_OP_GET_INDEX_U16
,
729 [ FILTER_OP_GET_INDEX_U64
] = &&LABEL_FILTER_OP_GET_INDEX_U64
,
731 [ FILTER_OP_LOAD_FIELD
] = &&LABEL_FILTER_OP_LOAD_FIELD
,
732 [ FILTER_OP_LOAD_FIELD_S8
] = &&LABEL_FILTER_OP_LOAD_FIELD_S8
,
733 [ FILTER_OP_LOAD_FIELD_S16
] = &&LABEL_FILTER_OP_LOAD_FIELD_S16
,
734 [ FILTER_OP_LOAD_FIELD_S32
] = &&LABEL_FILTER_OP_LOAD_FIELD_S32
,
735 [ FILTER_OP_LOAD_FIELD_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_S64
,
736 [ FILTER_OP_LOAD_FIELD_U8
] = &&LABEL_FILTER_OP_LOAD_FIELD_U8
,
737 [ FILTER_OP_LOAD_FIELD_U16
] = &&LABEL_FILTER_OP_LOAD_FIELD_U16
,
738 [ FILTER_OP_LOAD_FIELD_U32
] = &&LABEL_FILTER_OP_LOAD_FIELD_U32
,
739 [ FILTER_OP_LOAD_FIELD_U64
] = &&LABEL_FILTER_OP_LOAD_FIELD_U64
,
740 [ FILTER_OP_LOAD_FIELD_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_STRING
,
741 [ FILTER_OP_LOAD_FIELD_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_SEQUENCE
,
742 [ FILTER_OP_LOAD_FIELD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_DOUBLE
,
744 [ FILTER_OP_UNARY_BIT_NOT
] = &&LABEL_FILTER_OP_UNARY_BIT_NOT
,
746 #endif /* #ifndef INTERPRETER_USE_SWITCH */
750 OP(FILTER_OP_UNKNOWN
):
751 OP(FILTER_OP_LOAD_FIELD_REF
):
752 #ifdef INTERPRETER_USE_SWITCH
754 #endif /* INTERPRETER_USE_SWITCH */
755 ERR("unknown bytecode op %u",
756 (unsigned int) *(filter_opcode_t
*) pc
);
760 OP(FILTER_OP_RETURN
):
761 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
762 /* Handle dynamic typing. */
763 switch (estack_ax_t
) {
765 retval
= !!estack_ax_v
;
769 case REG_STAR_GLOB_STRING
:
783 ERR("unsupported bytecode op %u",
784 (unsigned int) *(filter_opcode_t
*) pc
);
790 /* Dynamic typing. */
791 switch (estack_ax_t
) {
793 switch (estack_bx_t
) {
795 JUMP_TO(FILTER_OP_EQ_S64
);
797 JUMP_TO(FILTER_OP_EQ_DOUBLE_S64
);
798 case REG_STRING
: /* Fall-through */
799 case REG_STAR_GLOB_STRING
:
803 ERR("Unknown filter register type (%d)",
810 switch (estack_bx_t
) {
812 JUMP_TO(FILTER_OP_EQ_S64_DOUBLE
);
814 JUMP_TO(FILTER_OP_EQ_DOUBLE
);
815 case REG_STRING
: /* Fall-through */
816 case REG_STAR_GLOB_STRING
:
820 ERR("Unknown filter register type (%d)",
827 switch (estack_bx_t
) {
828 case REG_S64
: /* Fall-through */
833 JUMP_TO(FILTER_OP_EQ_STRING
);
834 case REG_STAR_GLOB_STRING
:
835 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
837 ERR("Unknown filter register type (%d)",
843 case REG_STAR_GLOB_STRING
:
844 switch (estack_bx_t
) {
845 case REG_S64
: /* Fall-through */
850 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
851 case REG_STAR_GLOB_STRING
:
855 ERR("Unknown filter register type (%d)",
862 ERR("Unknown filter register type (%d)",
870 /* Dynamic typing. */
871 switch (estack_ax_t
) {
873 switch (estack_bx_t
) {
875 JUMP_TO(FILTER_OP_NE_S64
);
877 JUMP_TO(FILTER_OP_NE_DOUBLE_S64
);
878 case REG_STRING
: /* Fall-through */
879 case REG_STAR_GLOB_STRING
:
883 ERR("Unknown filter register type (%d)",
890 switch (estack_bx_t
) {
892 JUMP_TO(FILTER_OP_NE_S64_DOUBLE
);
894 JUMP_TO(FILTER_OP_NE_DOUBLE
);
895 case REG_STRING
: /* Fall-through */
896 case REG_STAR_GLOB_STRING
:
900 ERR("Unknown filter register type (%d)",
907 switch (estack_bx_t
) {
908 case REG_S64
: /* Fall-through */
913 JUMP_TO(FILTER_OP_NE_STRING
);
914 case REG_STAR_GLOB_STRING
:
915 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
917 ERR("Unknown filter register type (%d)",
923 case REG_STAR_GLOB_STRING
:
924 switch (estack_bx_t
) {
925 case REG_S64
: /* Fall-through */
930 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
931 case REG_STAR_GLOB_STRING
:
935 ERR("Unknown filter register type (%d)",
942 ERR("Unknown filter register type (%d)",
950 /* Dynamic typing. */
951 switch (estack_ax_t
) {
953 switch (estack_bx_t
) {
955 JUMP_TO(FILTER_OP_GT_S64
);
957 JUMP_TO(FILTER_OP_GT_DOUBLE_S64
);
958 case REG_STRING
: /* Fall-through */
959 case REG_STAR_GLOB_STRING
:
963 ERR("Unknown filter register type (%d)",
970 switch (estack_bx_t
) {
972 JUMP_TO(FILTER_OP_GT_S64_DOUBLE
);
974 JUMP_TO(FILTER_OP_GT_DOUBLE
);
975 case REG_STRING
: /* Fall-through */
976 case REG_STAR_GLOB_STRING
:
980 ERR("Unknown filter register type (%d)",
987 switch (estack_bx_t
) {
988 case REG_S64
: /* Fall-through */
989 case REG_DOUBLE
: /* Fall-through */
990 case REG_STAR_GLOB_STRING
:
994 JUMP_TO(FILTER_OP_GT_STRING
);
996 ERR("Unknown filter register type (%d)",
1003 ERR("Unknown filter register type (%d)",
1011 /* Dynamic typing. */
1012 switch (estack_ax_t
) {
1014 switch (estack_bx_t
) {
1016 JUMP_TO(FILTER_OP_LT_S64
);
1018 JUMP_TO(FILTER_OP_LT_DOUBLE_S64
);
1019 case REG_STRING
: /* Fall-through */
1020 case REG_STAR_GLOB_STRING
:
1024 ERR("Unknown filter register type (%d)",
1031 switch (estack_bx_t
) {
1033 JUMP_TO(FILTER_OP_LT_S64_DOUBLE
);
1035 JUMP_TO(FILTER_OP_LT_DOUBLE
);
1036 case REG_STRING
: /* Fall-through */
1037 case REG_STAR_GLOB_STRING
:
1041 ERR("Unknown filter register type (%d)",
1048 switch (estack_bx_t
) {
1049 case REG_S64
: /* Fall-through */
1050 case REG_DOUBLE
: /* Fall-through */
1051 case REG_STAR_GLOB_STRING
:
1055 JUMP_TO(FILTER_OP_LT_STRING
);
1057 ERR("Unknown filter register type (%d)",
1064 ERR("Unknown filter register type (%d)",
1072 /* Dynamic typing. */
1073 switch (estack_ax_t
) {
1075 switch (estack_bx_t
) {
1077 JUMP_TO(FILTER_OP_GE_S64
);
1079 JUMP_TO(FILTER_OP_GE_DOUBLE_S64
);
1080 case REG_STRING
: /* Fall-through */
1081 case REG_STAR_GLOB_STRING
:
1085 ERR("Unknown filter register type (%d)",
1092 switch (estack_bx_t
) {
1094 JUMP_TO(FILTER_OP_GE_S64_DOUBLE
);
1096 JUMP_TO(FILTER_OP_GE_DOUBLE
);
1097 case REG_STRING
: /* Fall-through */
1098 case REG_STAR_GLOB_STRING
:
1102 ERR("Unknown filter register type (%d)",
1109 switch (estack_bx_t
) {
1110 case REG_S64
: /* Fall-through */
1111 case REG_DOUBLE
: /* Fall-through */
1112 case REG_STAR_GLOB_STRING
:
1116 JUMP_TO(FILTER_OP_GE_STRING
);
1118 ERR("Unknown filter register type (%d)",
1125 ERR("Unknown filter register type (%d)",
1133 /* Dynamic typing. */
1134 switch (estack_ax_t
) {
1136 switch (estack_bx_t
) {
1138 JUMP_TO(FILTER_OP_LE_S64
);
1140 JUMP_TO(FILTER_OP_LE_DOUBLE_S64
);
1141 case REG_STRING
: /* Fall-through */
1142 case REG_STAR_GLOB_STRING
:
1146 ERR("Unknown filter register type (%d)",
1153 switch (estack_bx_t
) {
1155 JUMP_TO(FILTER_OP_LE_S64_DOUBLE
);
1157 JUMP_TO(FILTER_OP_LE_DOUBLE
);
1158 case REG_STRING
: /* Fall-through */
1159 case REG_STAR_GLOB_STRING
:
1163 ERR("Unknown filter register type (%d)",
1170 switch (estack_bx_t
) {
1171 case REG_S64
: /* Fall-through */
1172 case REG_DOUBLE
: /* Fall-through */
1173 case REG_STAR_GLOB_STRING
:
1177 JUMP_TO(FILTER_OP_LE_STRING
);
1179 ERR("Unknown filter register type (%d)",
1186 ERR("Unknown filter register type (%d)",
1193 OP(FILTER_OP_EQ_STRING
):
1197 res
= (stack_strcmp(stack
, top
, "==") == 0);
1198 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1200 estack_ax_t
= REG_S64
;
1201 next_pc
+= sizeof(struct binary_op
);
1204 OP(FILTER_OP_NE_STRING
):
1208 res
= (stack_strcmp(stack
, top
, "!=") != 0);
1209 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1211 estack_ax_t
= REG_S64
;
1212 next_pc
+= sizeof(struct binary_op
);
1215 OP(FILTER_OP_GT_STRING
):
1219 res
= (stack_strcmp(stack
, top
, ">") > 0);
1220 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1222 estack_ax_t
= REG_S64
;
1223 next_pc
+= sizeof(struct binary_op
);
1226 OP(FILTER_OP_LT_STRING
):
1230 res
= (stack_strcmp(stack
, top
, "<") < 0);
1231 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1233 estack_ax_t
= REG_S64
;
1234 next_pc
+= sizeof(struct binary_op
);
1237 OP(FILTER_OP_GE_STRING
):
1241 res
= (stack_strcmp(stack
, top
, ">=") >= 0);
1242 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1244 estack_ax_t
= REG_S64
;
1245 next_pc
+= sizeof(struct binary_op
);
1248 OP(FILTER_OP_LE_STRING
):
1252 res
= (stack_strcmp(stack
, top
, "<=") <= 0);
1253 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1255 estack_ax_t
= REG_S64
;
1256 next_pc
+= sizeof(struct binary_op
);
1260 OP(FILTER_OP_EQ_STAR_GLOB_STRING
):
1264 res
= (stack_star_glob_match(stack
, top
, "==") == 0);
1265 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1267 estack_ax_t
= REG_S64
;
1268 next_pc
+= sizeof(struct binary_op
);
1271 OP(FILTER_OP_NE_STAR_GLOB_STRING
):
1275 res
= (stack_star_glob_match(stack
, top
, "!=") != 0);
1276 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1278 estack_ax_t
= REG_S64
;
1279 next_pc
+= sizeof(struct binary_op
);
1283 OP(FILTER_OP_EQ_S64
):
1287 res
= (estack_bx_v
== estack_ax_v
);
1288 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1290 estack_ax_t
= REG_S64
;
1291 next_pc
+= sizeof(struct binary_op
);
1294 OP(FILTER_OP_NE_S64
):
1298 res
= (estack_bx_v
!= estack_ax_v
);
1299 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1301 estack_ax_t
= REG_S64
;
1302 next_pc
+= sizeof(struct binary_op
);
1305 OP(FILTER_OP_GT_S64
):
1309 res
= (estack_bx_v
> estack_ax_v
);
1310 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1312 estack_ax_t
= REG_S64
;
1313 next_pc
+= sizeof(struct binary_op
);
1316 OP(FILTER_OP_LT_S64
):
1320 res
= (estack_bx_v
< estack_ax_v
);
1321 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1323 estack_ax_t
= REG_S64
;
1324 next_pc
+= sizeof(struct binary_op
);
1327 OP(FILTER_OP_GE_S64
):
1331 res
= (estack_bx_v
>= estack_ax_v
);
1332 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1334 estack_ax_t
= REG_S64
;
1335 next_pc
+= sizeof(struct binary_op
);
1338 OP(FILTER_OP_LE_S64
):
1342 res
= (estack_bx_v
<= estack_ax_v
);
1343 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1345 estack_ax_t
= REG_S64
;
1346 next_pc
+= sizeof(struct binary_op
);
1350 OP(FILTER_OP_EQ_DOUBLE
):
1354 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax(stack
, top
)->u
.d
);
1355 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1357 estack_ax_t
= REG_S64
;
1358 next_pc
+= sizeof(struct binary_op
);
1361 OP(FILTER_OP_NE_DOUBLE
):
1365 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax(stack
, top
)->u
.d
);
1366 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1368 estack_ax_t
= REG_S64
;
1369 next_pc
+= sizeof(struct binary_op
);
1372 OP(FILTER_OP_GT_DOUBLE
):
1376 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax(stack
, top
)->u
.d
);
1377 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1379 estack_ax_t
= REG_S64
;
1380 next_pc
+= sizeof(struct binary_op
);
1383 OP(FILTER_OP_LT_DOUBLE
):
1387 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax(stack
, top
)->u
.d
);
1388 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1390 estack_ax_t
= REG_S64
;
1391 next_pc
+= sizeof(struct binary_op
);
1394 OP(FILTER_OP_GE_DOUBLE
):
1398 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax(stack
, top
)->u
.d
);
1399 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1401 estack_ax_t
= REG_S64
;
1402 next_pc
+= sizeof(struct binary_op
);
1405 OP(FILTER_OP_LE_DOUBLE
):
1409 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax(stack
, top
)->u
.d
);
1410 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1412 estack_ax_t
= REG_S64
;
1413 next_pc
+= sizeof(struct binary_op
);
1417 /* Mixed S64-double binary comparators */
1418 OP(FILTER_OP_EQ_DOUBLE_S64
):
1422 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax_v
);
1423 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1425 estack_ax_t
= REG_S64
;
1426 next_pc
+= sizeof(struct binary_op
);
1429 OP(FILTER_OP_NE_DOUBLE_S64
):
1433 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax_v
);
1434 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1436 estack_ax_t
= REG_S64
;
1437 next_pc
+= sizeof(struct binary_op
);
1440 OP(FILTER_OP_GT_DOUBLE_S64
):
1444 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax_v
);
1445 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1447 estack_ax_t
= REG_S64
;
1448 next_pc
+= sizeof(struct binary_op
);
1451 OP(FILTER_OP_LT_DOUBLE_S64
):
1455 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax_v
);
1456 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1458 estack_ax_t
= REG_S64
;
1459 next_pc
+= sizeof(struct binary_op
);
1462 OP(FILTER_OP_GE_DOUBLE_S64
):
1466 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax_v
);
1467 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1469 estack_ax_t
= REG_S64
;
1470 next_pc
+= sizeof(struct binary_op
);
1473 OP(FILTER_OP_LE_DOUBLE_S64
):
1477 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax_v
);
1478 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1480 estack_ax_t
= REG_S64
;
1481 next_pc
+= sizeof(struct binary_op
);
1485 OP(FILTER_OP_EQ_S64_DOUBLE
):
1489 res
= (estack_bx_v
== estack_ax(stack
, top
)->u
.d
);
1490 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1492 estack_ax_t
= REG_S64
;
1493 next_pc
+= sizeof(struct binary_op
);
1496 OP(FILTER_OP_NE_S64_DOUBLE
):
1500 res
= (estack_bx_v
!= estack_ax(stack
, top
)->u
.d
);
1501 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1503 estack_ax_t
= REG_S64
;
1504 next_pc
+= sizeof(struct binary_op
);
1507 OP(FILTER_OP_GT_S64_DOUBLE
):
1511 res
= (estack_bx_v
> estack_ax(stack
, top
)->u
.d
);
1512 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1514 estack_ax_t
= REG_S64
;
1515 next_pc
+= sizeof(struct binary_op
);
1518 OP(FILTER_OP_LT_S64_DOUBLE
):
1522 res
= (estack_bx_v
< estack_ax(stack
, top
)->u
.d
);
1523 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1525 estack_ax_t
= REG_S64
;
1526 next_pc
+= sizeof(struct binary_op
);
1529 OP(FILTER_OP_GE_S64_DOUBLE
):
1533 res
= (estack_bx_v
>= estack_ax(stack
, top
)->u
.d
);
1534 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1536 estack_ax_t
= REG_S64
;
1537 next_pc
+= sizeof(struct binary_op
);
1540 OP(FILTER_OP_LE_S64_DOUBLE
):
1544 res
= (estack_bx_v
<= estack_ax(stack
, top
)->u
.d
);
1545 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1547 estack_ax_t
= REG_S64
;
1548 next_pc
+= sizeof(struct binary_op
);
1551 OP(FILTER_OP_BIT_RSHIFT
):
1555 /* Dynamic typing. */
1556 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1561 res
= (estack_bx_v
>> estack_ax_v
);
1562 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1564 estack_ax_t
= REG_S64
;
1565 next_pc
+= sizeof(struct binary_op
);
1568 OP(FILTER_OP_BIT_LSHIFT
):
1572 /* Dynamic typing. */
1573 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1578 res
= (estack_bx_v
<< estack_ax_v
);
1579 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1581 estack_ax_t
= REG_S64
;
1582 next_pc
+= sizeof(struct binary_op
);
1585 OP(FILTER_OP_BIT_AND
):
1589 /* Dynamic typing. */
1590 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1595 res
= (estack_bx_v
& 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_OR
):
1606 /* Dynamic typing. */
1607 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1612 res
= (estack_bx_v
| 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_XOR
):
1623 /* Dynamic typing. */
1624 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1629 res
= (estack_bx_v
^ 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
);
1638 OP(FILTER_OP_UNARY_PLUS
):
1640 /* Dynamic typing. */
1641 switch (estack_ax_t
) {
1642 case REG_S64
: /* Fall-through. */
1643 JUMP_TO(FILTER_OP_UNARY_PLUS_S64
);
1645 JUMP_TO(FILTER_OP_UNARY_PLUS_DOUBLE
);
1646 case REG_STRING
: /* Fall-through */
1647 case REG_STAR_GLOB_STRING
:
1651 ERR("Unknown filter register type (%d)",
1657 OP(FILTER_OP_UNARY_MINUS
):
1659 /* Dynamic typing. */
1660 switch (estack_ax_t
) {
1662 JUMP_TO(FILTER_OP_UNARY_MINUS_S64
);
1664 JUMP_TO(FILTER_OP_UNARY_MINUS_DOUBLE
);
1665 case REG_STRING
: /* Fall-through */
1666 case REG_STAR_GLOB_STRING
:
1670 ERR("Unknown filter register type (%d)",
1676 OP(FILTER_OP_UNARY_NOT
):
1678 /* Dynamic typing. */
1679 switch (estack_ax_t
) {
1681 JUMP_TO(FILTER_OP_UNARY_NOT_S64
);
1683 JUMP_TO(FILTER_OP_UNARY_NOT_DOUBLE
);
1684 case REG_STRING
: /* Fall-through */
1685 case REG_STAR_GLOB_STRING
:
1689 ERR("Unknown filter register type (%d)",
1694 next_pc
+= sizeof(struct unary_op
);
1698 OP(FILTER_OP_UNARY_BIT_NOT
):
1700 /* Dynamic typing. */
1701 if (estack_ax_t
!= REG_S64
) {
1706 estack_ax_v
= ~estack_ax_v
;
1707 next_pc
+= sizeof(struct unary_op
);
1711 OP(FILTER_OP_UNARY_PLUS_S64
):
1712 OP(FILTER_OP_UNARY_PLUS_DOUBLE
):
1714 next_pc
+= sizeof(struct unary_op
);
1717 OP(FILTER_OP_UNARY_MINUS_S64
):
1719 estack_ax_v
= -estack_ax_v
;
1720 next_pc
+= sizeof(struct unary_op
);
1723 OP(FILTER_OP_UNARY_MINUS_DOUBLE
):
1725 estack_ax(stack
, top
)->u
.d
= -estack_ax(stack
, top
)->u
.d
;
1726 next_pc
+= sizeof(struct unary_op
);
1729 OP(FILTER_OP_UNARY_NOT_S64
):
1731 estack_ax_v
= !estack_ax_v
;
1732 next_pc
+= sizeof(struct unary_op
);
1735 OP(FILTER_OP_UNARY_NOT_DOUBLE
):
1737 estack_ax_v
= !estack_ax(stack
, top
)->u
.d
;
1738 estack_ax_t
= REG_S64
;
1739 next_pc
+= sizeof(struct unary_op
);
1746 struct logical_op
*insn
= (struct logical_op
*) pc
;
1748 if (estack_ax_t
!= REG_S64
) {
1752 /* If AX is 0, skip and evaluate to 0 */
1753 if (unlikely(estack_ax_v
== 0)) {
1754 dbg_printf("Jumping to bytecode offset %u\n",
1755 (unsigned int) insn
->skip_offset
);
1756 next_pc
= start_pc
+ insn
->skip_offset
;
1758 /* Pop 1 when jump not taken */
1759 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1760 next_pc
+= sizeof(struct logical_op
);
1766 struct logical_op
*insn
= (struct logical_op
*) pc
;
1768 if (estack_ax_t
!= REG_S64
) {
1772 /* If AX is nonzero, skip and evaluate to 1 */
1773 if (unlikely(estack_ax_v
!= 0)) {
1775 dbg_printf("Jumping to bytecode offset %u\n",
1776 (unsigned int) insn
->skip_offset
);
1777 next_pc
= start_pc
+ insn
->skip_offset
;
1779 /* Pop 1 when jump not taken */
1780 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1781 next_pc
+= sizeof(struct logical_op
);
1787 /* load field ref */
1788 OP(FILTER_OP_LOAD_FIELD_REF_STRING
):
1790 struct load_op
*insn
= (struct load_op
*) pc
;
1791 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1793 dbg_printf("load field ref offset %u type string\n",
1795 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1796 estack_ax(stack
, top
)->u
.s
.str
=
1797 *(const char * const *) &filter_stack_data
[ref
->offset
];
1798 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1799 dbg_printf("Filter warning: loading a NULL string.\n");
1803 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1804 estack_ax(stack
, top
)->u
.s
.literal_type
=
1805 ESTACK_STRING_LITERAL_TYPE_NONE
;
1806 estack_ax_t
= REG_STRING
;
1807 dbg_printf("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1808 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1812 OP(FILTER_OP_LOAD_FIELD_REF_SEQUENCE
):
1814 struct load_op
*insn
= (struct load_op
*) pc
;
1815 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1817 dbg_printf("load field ref offset %u type sequence\n",
1819 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1820 estack_ax(stack
, top
)->u
.s
.seq_len
=
1821 *(unsigned long *) &filter_stack_data
[ref
->offset
];
1822 estack_ax(stack
, top
)->u
.s
.str
=
1823 *(const char **) (&filter_stack_data
[ref
->offset
1824 + sizeof(unsigned long)]);
1825 estack_ax_t
= REG_STRING
;
1826 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1827 dbg_printf("Filter warning: loading a NULL sequence.\n");
1831 estack_ax(stack
, top
)->u
.s
.literal_type
=
1832 ESTACK_STRING_LITERAL_TYPE_NONE
;
1833 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1837 OP(FILTER_OP_LOAD_FIELD_REF_S64
):
1839 struct load_op
*insn
= (struct load_op
*) pc
;
1840 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1842 dbg_printf("load field ref offset %u type s64\n",
1844 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1846 ((struct literal_numeric
*) &filter_stack_data
[ref
->offset
])->v
;
1847 estack_ax_t
= REG_S64
;
1848 dbg_printf("ref load s64 %" PRIi64
"\n", estack_ax_v
);
1849 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1853 OP(FILTER_OP_LOAD_FIELD_REF_DOUBLE
):
1855 struct load_op
*insn
= (struct load_op
*) pc
;
1856 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1858 dbg_printf("load field ref offset %u type double\n",
1860 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1861 memcpy(&estack_ax(stack
, top
)->u
.d
, &filter_stack_data
[ref
->offset
],
1862 sizeof(struct literal_double
));
1863 estack_ax_t
= REG_DOUBLE
;
1864 dbg_printf("ref load double %g\n", estack_ax(stack
, top
)->u
.d
);
1865 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1869 /* load from immediate operand */
1870 OP(FILTER_OP_LOAD_STRING
):
1872 struct load_op
*insn
= (struct load_op
*) pc
;
1874 dbg_printf("load string %s\n", insn
->data
);
1875 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1876 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1877 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1878 estack_ax(stack
, top
)->u
.s
.literal_type
=
1879 ESTACK_STRING_LITERAL_TYPE_PLAIN
;
1880 estack_ax_t
= REG_STRING
;
1881 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1885 OP(FILTER_OP_LOAD_STAR_GLOB_STRING
):
1887 struct load_op
*insn
= (struct load_op
*) pc
;
1889 dbg_printf("load globbing pattern %s\n", insn
->data
);
1890 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1891 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1892 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1893 estack_ax(stack
, top
)->u
.s
.literal_type
=
1894 ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
;
1895 estack_ax_t
= REG_STAR_GLOB_STRING
;
1896 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1900 OP(FILTER_OP_LOAD_S64
):
1902 struct load_op
*insn
= (struct load_op
*) pc
;
1904 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1905 estack_ax_v
= ((struct literal_numeric
*) insn
->data
)->v
;
1906 estack_ax_t
= REG_S64
;
1907 dbg_printf("load s64 %" PRIi64
"\n", estack_ax_v
);
1908 next_pc
+= sizeof(struct load_op
)
1909 + sizeof(struct literal_numeric
);
1913 OP(FILTER_OP_LOAD_DOUBLE
):
1915 struct load_op
*insn
= (struct load_op
*) pc
;
1917 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1918 memcpy(&estack_ax(stack
, top
)->u
.d
, insn
->data
,
1919 sizeof(struct literal_double
));
1920 estack_ax_t
= REG_DOUBLE
;
1921 dbg_printf("load double %g\n", estack_ax(stack
, top
)->u
.d
);
1922 next_pc
+= sizeof(struct load_op
)
1923 + sizeof(struct literal_double
);
1928 OP(FILTER_OP_CAST_TO_S64
):
1930 /* Dynamic typing. */
1931 switch (estack_ax_t
) {
1933 JUMP_TO(FILTER_OP_CAST_NOP
);
1935 JUMP_TO(FILTER_OP_CAST_DOUBLE_TO_S64
);
1936 case REG_STRING
: /* Fall-through */
1937 case REG_STAR_GLOB_STRING
:
1941 ERR("Unknown filter register type (%d)",
1948 OP(FILTER_OP_CAST_DOUBLE_TO_S64
):
1950 estack_ax_v
= (int64_t) estack_ax(stack
, top
)->u
.d
;
1951 estack_ax_t
= REG_S64
;
1952 next_pc
+= sizeof(struct cast_op
);
1956 OP(FILTER_OP_CAST_NOP
):
1958 next_pc
+= sizeof(struct cast_op
);
1962 /* get context ref */
1963 OP(FILTER_OP_GET_CONTEXT_REF
):
1965 struct load_op
*insn
= (struct load_op
*) pc
;
1966 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1967 struct lttng_ctx
*ctx
;
1968 struct lttng_ctx_field
*ctx_field
;
1969 struct lttng_ctx_value v
;
1971 dbg_printf("get context ref offset %u type dynamic\n",
1973 ctx
= rcu_dereference(session
->ctx
);
1974 ctx_field
= &ctx
->fields
[ref
->offset
];
1975 ctx_field
->get_value(ctx_field
, &v
);
1976 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1978 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
1981 case LTTNG_UST_DYNAMIC_TYPE_S64
:
1982 estack_ax_v
= v
.u
.s64
;
1983 estack_ax_t
= REG_S64
;
1984 dbg_printf("ref get context dynamic s64 %" PRIi64
"\n", estack_ax_v
);
1986 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
1987 estack_ax(stack
, top
)->u
.d
= v
.u
.d
;
1988 estack_ax_t
= REG_DOUBLE
;
1989 dbg_printf("ref get context dynamic double %g\n", estack_ax(stack
, top
)->u
.d
);
1991 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
1992 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
1993 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1994 dbg_printf("Filter warning: loading a NULL string.\n");
1998 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1999 estack_ax(stack
, top
)->u
.s
.literal_type
=
2000 ESTACK_STRING_LITERAL_TYPE_NONE
;
2001 dbg_printf("ref get context dynamic string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2002 estack_ax_t
= REG_STRING
;
2005 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
2009 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2013 OP(FILTER_OP_GET_CONTEXT_REF_STRING
):
2015 struct load_op
*insn
= (struct load_op
*) pc
;
2016 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2017 struct lttng_ctx
*ctx
;
2018 struct lttng_ctx_field
*ctx_field
;
2019 struct lttng_ctx_value v
;
2021 dbg_printf("get context ref offset %u type string\n",
2023 ctx
= rcu_dereference(session
->ctx
);
2024 ctx_field
= &ctx
->fields
[ref
->offset
];
2025 ctx_field
->get_value(ctx_field
, &v
);
2026 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2027 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2028 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2029 dbg_printf("Filter warning: loading a NULL string.\n");
2033 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2034 estack_ax(stack
, top
)->u
.s
.literal_type
=
2035 ESTACK_STRING_LITERAL_TYPE_NONE
;
2036 estack_ax_t
= REG_STRING
;
2037 dbg_printf("ref get context string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2038 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2042 OP(FILTER_OP_GET_CONTEXT_REF_S64
):
2044 struct load_op
*insn
= (struct load_op
*) pc
;
2045 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2046 struct lttng_ctx
*ctx
;
2047 struct lttng_ctx_field
*ctx_field
;
2048 struct lttng_ctx_value v
;
2050 dbg_printf("get context ref offset %u type s64\n",
2052 ctx
= rcu_dereference(session
->ctx
);
2053 ctx_field
= &ctx
->fields
[ref
->offset
];
2054 ctx_field
->get_value(ctx_field
, &v
);
2055 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2056 estack_ax_v
= v
.u
.s64
;
2057 estack_ax_t
= REG_S64
;
2058 dbg_printf("ref get context s64 %" PRIi64
"\n", estack_ax_v
);
2059 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2063 OP(FILTER_OP_GET_CONTEXT_REF_DOUBLE
):
2065 struct load_op
*insn
= (struct load_op
*) pc
;
2066 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2067 struct lttng_ctx
*ctx
;
2068 struct lttng_ctx_field
*ctx_field
;
2069 struct lttng_ctx_value v
;
2071 dbg_printf("get context ref offset %u type double\n",
2073 ctx
= rcu_dereference(session
->ctx
);
2074 ctx_field
= &ctx
->fields
[ref
->offset
];
2075 ctx_field
->get_value(ctx_field
, &v
);
2076 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2077 memcpy(&estack_ax(stack
, top
)->u
.d
, &v
.u
.d
, sizeof(struct literal_double
));
2078 estack_ax_t
= REG_DOUBLE
;
2079 dbg_printf("ref get context double %g\n", estack_ax(stack
, top
)->u
.d
);
2080 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2084 OP(FILTER_OP_GET_CONTEXT_ROOT
):
2086 dbg_printf("op get context root\n");
2087 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2088 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_CONTEXT
;
2089 /* "field" only needed for variants. */
2090 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2091 estack_ax_t
= REG_PTR
;
2092 next_pc
+= sizeof(struct load_op
);
2096 OP(FILTER_OP_GET_APP_CONTEXT_ROOT
):
2098 dbg_printf("op get app context root\n");
2099 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2100 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_APP_CONTEXT
;
2101 /* "field" only needed for variants. */
2102 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2103 estack_ax_t
= REG_PTR
;
2104 next_pc
+= sizeof(struct load_op
);
2108 OP(FILTER_OP_GET_PAYLOAD_ROOT
):
2110 dbg_printf("op get app payload root\n");
2111 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2112 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_PAYLOAD
;
2113 estack_ax(stack
, top
)->u
.ptr
.ptr
= filter_stack_data
;
2114 /* "field" only needed for variants. */
2115 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2116 estack_ax_t
= REG_PTR
;
2117 next_pc
+= sizeof(struct load_op
);
2121 OP(FILTER_OP_GET_SYMBOL
):
2123 dbg_printf("op get symbol\n");
2124 switch (estack_ax(stack
, top
)->u
.ptr
.type
) {
2126 ERR("Nested fields not implemented yet.");
2129 case LOAD_ROOT_CONTEXT
:
2130 case LOAD_ROOT_APP_CONTEXT
:
2131 case LOAD_ROOT_PAYLOAD
:
2133 * symbol lookup is performed by
2139 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_symbol
);
2143 OP(FILTER_OP_GET_SYMBOL_FIELD
):
2146 * Used for first variant encountered in a
2147 * traversal. Variants are not implemented yet.
2153 OP(FILTER_OP_GET_INDEX_U16
):
2155 struct load_op
*insn
= (struct load_op
*) pc
;
2156 struct get_index_u16
*index
= (struct get_index_u16
*) insn
->data
;
2158 dbg_printf("op get index u16\n");
2159 ret
= dynamic_get_index(session
, bytecode
, index
->index
, estack_ax(stack
, top
));
2162 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2163 estack_ax_t
= estack_ax(stack
, top
)->type
;
2164 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u16
);
2168 OP(FILTER_OP_GET_INDEX_U64
):
2170 struct load_op
*insn
= (struct load_op
*) pc
;
2171 struct get_index_u64
*index
= (struct get_index_u64
*) insn
->data
;
2173 dbg_printf("op get index u64\n");
2174 ret
= dynamic_get_index(session
, bytecode
, index
->index
, estack_ax(stack
, top
));
2177 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2178 estack_ax_t
= estack_ax(stack
, top
)->type
;
2179 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u64
);
2183 OP(FILTER_OP_LOAD_FIELD
):
2185 dbg_printf("op load field\n");
2186 ret
= dynamic_load_field(estack_ax(stack
, top
));
2189 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2190 estack_ax_t
= estack_ax(stack
, top
)->type
;
2191 next_pc
+= sizeof(struct load_op
);
2195 OP(FILTER_OP_LOAD_FIELD_S8
):
2197 dbg_printf("op load field s8\n");
2199 estack_ax_v
= *(int8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2200 estack_ax_t
= REG_S64
;
2201 next_pc
+= sizeof(struct load_op
);
2204 OP(FILTER_OP_LOAD_FIELD_S16
):
2206 dbg_printf("op load field s16\n");
2208 estack_ax_v
= *(int16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2209 estack_ax_t
= REG_S64
;
2210 next_pc
+= sizeof(struct load_op
);
2213 OP(FILTER_OP_LOAD_FIELD_S32
):
2215 dbg_printf("op load field s32\n");
2217 estack_ax_v
= *(int32_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_S64
):
2224 dbg_printf("op load field s64\n");
2226 estack_ax_v
= *(int64_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_U8
):
2233 dbg_printf("op load field u8\n");
2235 estack_ax_v
= *(uint8_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_U16
):
2242 dbg_printf("op load field u16\n");
2244 estack_ax_v
= *(uint16_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_U32
):
2251 dbg_printf("op load field u32\n");
2253 estack_ax_v
= *(uint32_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_U64
):
2260 dbg_printf("op load field u64\n");
2262 estack_ax_v
= *(uint64_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_DOUBLE
):
2269 dbg_printf("op load field double\n");
2271 memcpy(&estack_ax(stack
, top
)->u
.d
,
2272 estack_ax(stack
, top
)->u
.ptr
.ptr
,
2273 sizeof(struct literal_double
));
2274 estack_ax(stack
, top
)->type
= REG_DOUBLE
;
2275 next_pc
+= sizeof(struct load_op
);
2279 OP(FILTER_OP_LOAD_FIELD_STRING
):
2283 dbg_printf("op load field string\n");
2284 str
= (const char *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2285 estack_ax(stack
, top
)->u
.s
.str
= str
;
2286 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2287 dbg_printf("Filter warning: loading a NULL string.\n");
2291 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2292 estack_ax(stack
, top
)->u
.s
.literal_type
=
2293 ESTACK_STRING_LITERAL_TYPE_NONE
;
2294 estack_ax(stack
, top
)->type
= REG_STRING
;
2295 next_pc
+= sizeof(struct load_op
);
2299 OP(FILTER_OP_LOAD_FIELD_SEQUENCE
):
2303 dbg_printf("op load field string sequence\n");
2304 ptr
= estack_ax(stack
, top
)->u
.ptr
.ptr
;
2305 estack_ax(stack
, top
)->u
.s
.seq_len
= *(unsigned long *) ptr
;
2306 estack_ax(stack
, top
)->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
2307 estack_ax(stack
, top
)->type
= REG_STRING
;
2308 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2309 dbg_printf("Filter warning: loading a NULL sequence.\n");
2313 estack_ax(stack
, top
)->u
.s
.literal_type
=
2314 ESTACK_STRING_LITERAL_TYPE_NONE
;
2315 next_pc
+= sizeof(struct load_op
);
2321 /* return 0 (discard) on error */