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>
31 #include <lttng/ust-endian.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
)
167 return LTTNG_FILTER_DISCARD
;
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 #define IS_INTEGER_REGISTER(reg_type) \
224 (reg_type == REG_U64 || reg_type == REG_S64)
226 static int context_get_index(struct lttng_ctx
*ctx
,
227 struct load_ptr
*ptr
,
231 struct lttng_ctx_field
*ctx_field
;
232 struct lttng_event_field
*field
;
233 struct lttng_ctx_value v
;
235 ctx_field
= &ctx
->fields
[idx
];
236 field
= &ctx_field
->event_field
;
237 ptr
->type
= LOAD_OBJECT
;
238 /* field is only used for types nested within variants. */
241 switch (field
->type
.atype
) {
243 ctx_field
->get_value(ctx_field
, &v
);
244 if (field
->type
.u
.integer
.signedness
) {
245 ptr
->object_type
= OBJECT_TYPE_S64
;
246 ptr
->u
.s64
= v
.u
.s64
;
247 ptr
->ptr
= &ptr
->u
.s64
;
249 ptr
->object_type
= OBJECT_TYPE_U64
;
250 ptr
->u
.u64
= v
.u
.s64
; /* Cast. */
251 ptr
->ptr
= &ptr
->u
.u64
;
254 case atype_enum
: /* Fall-through */
255 case atype_enum_nestable
:
257 const struct lttng_integer_type
*itype
;
259 if (field
->type
.atype
== atype_enum
) {
260 itype
= &field
->type
.u
.legacy
.basic
.enumeration
.container_type
;
262 itype
= &field
->type
.u
.enum_nestable
.container_type
->u
.integer
;
264 ctx_field
->get_value(ctx_field
, &v
);
265 if (itype
->signedness
) {
266 ptr
->object_type
= OBJECT_TYPE_S64
;
267 ptr
->u
.s64
= v
.u
.s64
;
268 ptr
->ptr
= &ptr
->u
.s64
;
270 ptr
->object_type
= OBJECT_TYPE_U64
;
271 ptr
->u
.u64
= v
.u
.s64
; /* Cast. */
272 ptr
->ptr
= &ptr
->u
.u64
;
277 if (field
->type
.u
.legacy
.array
.elem_type
.atype
!= atype_integer
) {
278 ERR("Array nesting only supports integer types.");
281 if (field
->type
.u
.legacy
.array
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
282 ERR("Only string arrays are supported for contexts.");
285 ptr
->object_type
= OBJECT_TYPE_STRING
;
286 ctx_field
->get_value(ctx_field
, &v
);
289 case atype_array_nestable
:
290 if (field
->type
.u
.array_nestable
.elem_type
->atype
!= atype_integer
) {
291 ERR("Array nesting only supports integer types.");
294 if (field
->type
.u
.array_nestable
.elem_type
->u
.integer
.encoding
== lttng_encode_none
) {
295 ERR("Only string arrays are supported for contexts.");
298 ptr
->object_type
= OBJECT_TYPE_STRING
;
299 ctx_field
->get_value(ctx_field
, &v
);
303 if (field
->type
.u
.legacy
.sequence
.elem_type
.atype
!= atype_integer
) {
304 ERR("Sequence nesting only supports integer types.");
307 if (field
->type
.u
.legacy
.sequence
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
308 ERR("Only string sequences are supported for contexts.");
311 ptr
->object_type
= OBJECT_TYPE_STRING
;
312 ctx_field
->get_value(ctx_field
, &v
);
315 case atype_sequence_nestable
:
316 if (field
->type
.u
.sequence_nestable
.elem_type
->atype
!= atype_integer
) {
317 ERR("Sequence nesting only supports integer types.");
320 if (field
->type
.u
.sequence_nestable
.elem_type
->u
.integer
.encoding
== lttng_encode_none
) {
321 ERR("Only string sequences are supported for contexts.");
324 ptr
->object_type
= OBJECT_TYPE_STRING
;
325 ctx_field
->get_value(ctx_field
, &v
);
329 ptr
->object_type
= OBJECT_TYPE_STRING
;
330 ctx_field
->get_value(ctx_field
, &v
);
334 ptr
->object_type
= OBJECT_TYPE_DOUBLE
;
335 ctx_field
->get_value(ctx_field
, &v
);
337 ptr
->ptr
= &ptr
->u
.d
;
340 ctx_field
->get_value(ctx_field
, &v
);
342 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
344 case LTTNG_UST_DYNAMIC_TYPE_S64
:
345 ptr
->object_type
= OBJECT_TYPE_S64
;
346 ptr
->u
.s64
= v
.u
.s64
;
347 ptr
->ptr
= &ptr
->u
.s64
;
348 dbg_printf("context get index dynamic s64 %" PRIi64
"\n", ptr
->u
.s64
);
350 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
351 ptr
->object_type
= OBJECT_TYPE_DOUBLE
;
353 ptr
->ptr
= &ptr
->u
.d
;
354 dbg_printf("context get index dynamic double %g\n", ptr
->u
.d
);
356 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
357 ptr
->object_type
= OBJECT_TYPE_STRING
;
359 dbg_printf("context get index dynamic string %s\n", (const char *) ptr
->ptr
);
362 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
367 ERR("Structure type cannot be loaded.");
370 ERR("Unknown type: %d", (int) field
->type
.atype
);
376 static int dynamic_get_index(struct lttng_ctx
*ctx
,
377 struct bytecode_runtime
*runtime
,
378 uint64_t index
, struct estack_entry
*stack_top
)
381 const struct filter_get_index_data
*gid
;
384 * Types nested within variants need to perform dynamic lookup
385 * based on the field descriptions. LTTng-UST does not implement
388 if (stack_top
->u
.ptr
.field
)
390 gid
= (const struct filter_get_index_data
*) &runtime
->data
[index
];
391 switch (stack_top
->u
.ptr
.type
) {
393 switch (stack_top
->u
.ptr
.object_type
) {
394 case OBJECT_TYPE_ARRAY
:
398 assert(gid
->offset
< gid
->array_len
);
399 /* Skip count (unsigned long) */
400 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
401 ptr
= ptr
+ gid
->offset
;
402 stack_top
->u
.ptr
.ptr
= ptr
;
403 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
404 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
405 /* field is only used for types nested within variants. */
406 stack_top
->u
.ptr
.field
= NULL
;
409 case OBJECT_TYPE_SEQUENCE
:
414 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
415 ptr_seq_len
= *(unsigned long *) stack_top
->u
.ptr
.ptr
;
416 if (gid
->offset
>= gid
->elem
.len
* ptr_seq_len
) {
420 ptr
= ptr
+ gid
->offset
;
421 stack_top
->u
.ptr
.ptr
= ptr
;
422 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
423 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
424 /* field is only used for types nested within variants. */
425 stack_top
->u
.ptr
.field
= NULL
;
428 case OBJECT_TYPE_STRUCT
:
429 ERR("Nested structures are not supported yet.");
432 case OBJECT_TYPE_VARIANT
:
434 ERR("Unexpected get index type %d",
435 (int) stack_top
->u
.ptr
.object_type
);
440 case LOAD_ROOT_CONTEXT
:
441 case LOAD_ROOT_APP_CONTEXT
: /* Fall-through */
443 ret
= context_get_index(ctx
,
451 case LOAD_ROOT_PAYLOAD
:
452 stack_top
->u
.ptr
.ptr
+= gid
->offset
;
453 if (gid
->elem
.type
== OBJECT_TYPE_STRING
)
454 stack_top
->u
.ptr
.ptr
= *(const char * const *) stack_top
->u
.ptr
.ptr
;
455 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
456 stack_top
->u
.ptr
.type
= LOAD_OBJECT
;
457 /* field is only used for types nested within variants. */
458 stack_top
->u
.ptr
.field
= NULL
;
467 static int dynamic_load_field(struct estack_entry
*stack_top
)
471 switch (stack_top
->u
.ptr
.type
) {
474 case LOAD_ROOT_CONTEXT
:
475 case LOAD_ROOT_APP_CONTEXT
:
476 case LOAD_ROOT_PAYLOAD
:
478 dbg_printf("Filter warning: cannot load root, missing field name.\n");
482 switch (stack_top
->u
.ptr
.object_type
) {
484 dbg_printf("op load field s8\n");
485 stack_top
->u
.v
= *(int8_t *) stack_top
->u
.ptr
.ptr
;
486 stack_top
->type
= REG_S64
;
488 case OBJECT_TYPE_S16
:
492 dbg_printf("op load field s16\n");
493 tmp
= *(int16_t *) stack_top
->u
.ptr
.ptr
;
494 if (stack_top
->u
.ptr
.rev_bo
)
496 stack_top
->u
.v
= tmp
;
497 stack_top
->type
= REG_S64
;
500 case OBJECT_TYPE_S32
:
504 dbg_printf("op load field s32\n");
505 tmp
= *(int32_t *) stack_top
->u
.ptr
.ptr
;
506 if (stack_top
->u
.ptr
.rev_bo
)
508 stack_top
->u
.v
= tmp
;
509 stack_top
->type
= REG_S64
;
512 case OBJECT_TYPE_S64
:
516 dbg_printf("op load field s64\n");
517 tmp
= *(int64_t *) stack_top
->u
.ptr
.ptr
;
518 if (stack_top
->u
.ptr
.rev_bo
)
520 stack_top
->u
.v
= tmp
;
521 stack_top
->type
= REG_S64
;
525 dbg_printf("op load field u8\n");
526 stack_top
->u
.v
= *(uint8_t *) stack_top
->u
.ptr
.ptr
;
527 stack_top
->type
= REG_U64
;
529 case OBJECT_TYPE_U16
:
533 dbg_printf("op load field u16\n");
534 tmp
= *(uint16_t *) stack_top
->u
.ptr
.ptr
;
535 if (stack_top
->u
.ptr
.rev_bo
)
537 stack_top
->u
.v
= tmp
;
538 stack_top
->type
= REG_U64
;
541 case OBJECT_TYPE_U32
:
545 dbg_printf("op load field u32\n");
546 tmp
= *(uint32_t *) stack_top
->u
.ptr
.ptr
;
547 if (stack_top
->u
.ptr
.rev_bo
)
549 stack_top
->u
.v
= tmp
;
550 stack_top
->type
= REG_U64
;
553 case OBJECT_TYPE_U64
:
557 dbg_printf("op load field u64\n");
558 tmp
= *(uint64_t *) stack_top
->u
.ptr
.ptr
;
559 if (stack_top
->u
.ptr
.rev_bo
)
561 stack_top
->u
.v
= tmp
;
562 stack_top
->type
= REG_U64
;
565 case OBJECT_TYPE_DOUBLE
:
566 memcpy(&stack_top
->u
.d
,
567 stack_top
->u
.ptr
.ptr
,
568 sizeof(struct literal_double
));
569 stack_top
->type
= REG_DOUBLE
;
571 case OBJECT_TYPE_STRING
:
575 dbg_printf("op load field string\n");
576 str
= (const char *) stack_top
->u
.ptr
.ptr
;
577 stack_top
->u
.s
.str
= str
;
578 if (unlikely(!stack_top
->u
.s
.str
)) {
579 dbg_printf("Filter warning: loading a NULL string.\n");
583 stack_top
->u
.s
.seq_len
= SIZE_MAX
;
584 stack_top
->u
.s
.literal_type
=
585 ESTACK_STRING_LITERAL_TYPE_NONE
;
586 stack_top
->type
= REG_STRING
;
589 case OBJECT_TYPE_STRING_SEQUENCE
:
593 dbg_printf("op load field string sequence\n");
594 ptr
= stack_top
->u
.ptr
.ptr
;
595 stack_top
->u
.s
.seq_len
= *(unsigned long *) ptr
;
596 stack_top
->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
597 stack_top
->type
= REG_STRING
;
598 if (unlikely(!stack_top
->u
.s
.str
)) {
599 dbg_printf("Filter warning: loading a NULL sequence.\n");
603 stack_top
->u
.s
.literal_type
=
604 ESTACK_STRING_LITERAL_TYPE_NONE
;
607 case OBJECT_TYPE_DYNAMIC
:
609 * Dynamic types in context are looked up
610 * by context get index.
614 case OBJECT_TYPE_SEQUENCE
:
615 case OBJECT_TYPE_ARRAY
:
616 case OBJECT_TYPE_STRUCT
:
617 case OBJECT_TYPE_VARIANT
:
618 ERR("Sequences, arrays, struct and variant cannot be loaded (nested types).");
629 * Return 0 (discard), or raise the 0x1 flag (log event).
630 * Currently, other flags are kept for future extensions and have no
633 uint64_t lttng_filter_interpret_bytecode(void *filter_data
,
634 const char *filter_stack_data
)
636 struct bytecode_runtime
*bytecode
= filter_data
;
637 struct lttng_ctx
*ctx
= rcu_dereference(*bytecode
->p
.pctx
);
638 void *pc
, *next_pc
, *start_pc
;
641 struct estack _stack
;
642 struct estack
*stack
= &_stack
;
643 register int64_t ax
= 0, bx
= 0;
644 register enum entry_type ax_t
= REG_UNKNOWN
, bx_t
= REG_UNKNOWN
;
645 register int top
= FILTER_STACK_EMPTY
;
646 #ifndef INTERPRETER_USE_SWITCH
647 static void *dispatch
[NR_FILTER_OPS
] = {
648 [ FILTER_OP_UNKNOWN
] = &&LABEL_FILTER_OP_UNKNOWN
,
650 [ FILTER_OP_RETURN
] = &&LABEL_FILTER_OP_RETURN
,
653 [ FILTER_OP_MUL
] = &&LABEL_FILTER_OP_MUL
,
654 [ FILTER_OP_DIV
] = &&LABEL_FILTER_OP_DIV
,
655 [ FILTER_OP_MOD
] = &&LABEL_FILTER_OP_MOD
,
656 [ FILTER_OP_PLUS
] = &&LABEL_FILTER_OP_PLUS
,
657 [ FILTER_OP_MINUS
] = &&LABEL_FILTER_OP_MINUS
,
658 [ FILTER_OP_BIT_RSHIFT
] = &&LABEL_FILTER_OP_BIT_RSHIFT
,
659 [ FILTER_OP_BIT_LSHIFT
] = &&LABEL_FILTER_OP_BIT_LSHIFT
,
660 [ FILTER_OP_BIT_AND
] = &&LABEL_FILTER_OP_BIT_AND
,
661 [ FILTER_OP_BIT_OR
] = &&LABEL_FILTER_OP_BIT_OR
,
662 [ FILTER_OP_BIT_XOR
] = &&LABEL_FILTER_OP_BIT_XOR
,
664 /* binary comparators */
665 [ FILTER_OP_EQ
] = &&LABEL_FILTER_OP_EQ
,
666 [ FILTER_OP_NE
] = &&LABEL_FILTER_OP_NE
,
667 [ FILTER_OP_GT
] = &&LABEL_FILTER_OP_GT
,
668 [ FILTER_OP_LT
] = &&LABEL_FILTER_OP_LT
,
669 [ FILTER_OP_GE
] = &&LABEL_FILTER_OP_GE
,
670 [ FILTER_OP_LE
] = &&LABEL_FILTER_OP_LE
,
672 /* string binary comparator */
673 [ FILTER_OP_EQ_STRING
] = &&LABEL_FILTER_OP_EQ_STRING
,
674 [ FILTER_OP_NE_STRING
] = &&LABEL_FILTER_OP_NE_STRING
,
675 [ FILTER_OP_GT_STRING
] = &&LABEL_FILTER_OP_GT_STRING
,
676 [ FILTER_OP_LT_STRING
] = &&LABEL_FILTER_OP_LT_STRING
,
677 [ FILTER_OP_GE_STRING
] = &&LABEL_FILTER_OP_GE_STRING
,
678 [ FILTER_OP_LE_STRING
] = &&LABEL_FILTER_OP_LE_STRING
,
680 /* globbing pattern binary comparator */
681 [ FILTER_OP_EQ_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_EQ_STAR_GLOB_STRING
,
682 [ FILTER_OP_NE_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_NE_STAR_GLOB_STRING
,
684 /* s64 binary comparator */
685 [ FILTER_OP_EQ_S64
] = &&LABEL_FILTER_OP_EQ_S64
,
686 [ FILTER_OP_NE_S64
] = &&LABEL_FILTER_OP_NE_S64
,
687 [ FILTER_OP_GT_S64
] = &&LABEL_FILTER_OP_GT_S64
,
688 [ FILTER_OP_LT_S64
] = &&LABEL_FILTER_OP_LT_S64
,
689 [ FILTER_OP_GE_S64
] = &&LABEL_FILTER_OP_GE_S64
,
690 [ FILTER_OP_LE_S64
] = &&LABEL_FILTER_OP_LE_S64
,
692 /* double binary comparator */
693 [ FILTER_OP_EQ_DOUBLE
] = &&LABEL_FILTER_OP_EQ_DOUBLE
,
694 [ FILTER_OP_NE_DOUBLE
] = &&LABEL_FILTER_OP_NE_DOUBLE
,
695 [ FILTER_OP_GT_DOUBLE
] = &&LABEL_FILTER_OP_GT_DOUBLE
,
696 [ FILTER_OP_LT_DOUBLE
] = &&LABEL_FILTER_OP_LT_DOUBLE
,
697 [ FILTER_OP_GE_DOUBLE
] = &&LABEL_FILTER_OP_GE_DOUBLE
,
698 [ FILTER_OP_LE_DOUBLE
] = &&LABEL_FILTER_OP_LE_DOUBLE
,
700 /* Mixed S64-double binary comparators */
701 [ FILTER_OP_EQ_DOUBLE_S64
] = &&LABEL_FILTER_OP_EQ_DOUBLE_S64
,
702 [ FILTER_OP_NE_DOUBLE_S64
] = &&LABEL_FILTER_OP_NE_DOUBLE_S64
,
703 [ FILTER_OP_GT_DOUBLE_S64
] = &&LABEL_FILTER_OP_GT_DOUBLE_S64
,
704 [ FILTER_OP_LT_DOUBLE_S64
] = &&LABEL_FILTER_OP_LT_DOUBLE_S64
,
705 [ FILTER_OP_GE_DOUBLE_S64
] = &&LABEL_FILTER_OP_GE_DOUBLE_S64
,
706 [ FILTER_OP_LE_DOUBLE_S64
] = &&LABEL_FILTER_OP_LE_DOUBLE_S64
,
708 [ FILTER_OP_EQ_S64_DOUBLE
] = &&LABEL_FILTER_OP_EQ_S64_DOUBLE
,
709 [ FILTER_OP_NE_S64_DOUBLE
] = &&LABEL_FILTER_OP_NE_S64_DOUBLE
,
710 [ FILTER_OP_GT_S64_DOUBLE
] = &&LABEL_FILTER_OP_GT_S64_DOUBLE
,
711 [ FILTER_OP_LT_S64_DOUBLE
] = &&LABEL_FILTER_OP_LT_S64_DOUBLE
,
712 [ FILTER_OP_GE_S64_DOUBLE
] = &&LABEL_FILTER_OP_GE_S64_DOUBLE
,
713 [ FILTER_OP_LE_S64_DOUBLE
] = &&LABEL_FILTER_OP_LE_S64_DOUBLE
,
716 [ FILTER_OP_UNARY_PLUS
] = &&LABEL_FILTER_OP_UNARY_PLUS
,
717 [ FILTER_OP_UNARY_MINUS
] = &&LABEL_FILTER_OP_UNARY_MINUS
,
718 [ FILTER_OP_UNARY_NOT
] = &&LABEL_FILTER_OP_UNARY_NOT
,
719 [ FILTER_OP_UNARY_PLUS_S64
] = &&LABEL_FILTER_OP_UNARY_PLUS_S64
,
720 [ FILTER_OP_UNARY_MINUS_S64
] = &&LABEL_FILTER_OP_UNARY_MINUS_S64
,
721 [ FILTER_OP_UNARY_NOT_S64
] = &&LABEL_FILTER_OP_UNARY_NOT_S64
,
722 [ FILTER_OP_UNARY_PLUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_PLUS_DOUBLE
,
723 [ FILTER_OP_UNARY_MINUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_MINUS_DOUBLE
,
724 [ FILTER_OP_UNARY_NOT_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_NOT_DOUBLE
,
727 [ FILTER_OP_AND
] = &&LABEL_FILTER_OP_AND
,
728 [ FILTER_OP_OR
] = &&LABEL_FILTER_OP_OR
,
731 [ FILTER_OP_LOAD_FIELD_REF
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF
,
732 [ FILTER_OP_LOAD_FIELD_REF_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_STRING
,
733 [ FILTER_OP_LOAD_FIELD_REF_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_SEQUENCE
,
734 [ FILTER_OP_LOAD_FIELD_REF_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_S64
,
735 [ FILTER_OP_LOAD_FIELD_REF_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_DOUBLE
,
737 /* load from immediate operand */
738 [ FILTER_OP_LOAD_STRING
] = &&LABEL_FILTER_OP_LOAD_STRING
,
739 [ FILTER_OP_LOAD_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_LOAD_STAR_GLOB_STRING
,
740 [ FILTER_OP_LOAD_S64
] = &&LABEL_FILTER_OP_LOAD_S64
,
741 [ FILTER_OP_LOAD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_DOUBLE
,
744 [ FILTER_OP_CAST_TO_S64
] = &&LABEL_FILTER_OP_CAST_TO_S64
,
745 [ FILTER_OP_CAST_DOUBLE_TO_S64
] = &&LABEL_FILTER_OP_CAST_DOUBLE_TO_S64
,
746 [ FILTER_OP_CAST_NOP
] = &&LABEL_FILTER_OP_CAST_NOP
,
748 /* get context ref */
749 [ FILTER_OP_GET_CONTEXT_REF
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF
,
750 [ FILTER_OP_GET_CONTEXT_REF_STRING
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_STRING
,
751 [ FILTER_OP_GET_CONTEXT_REF_S64
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_S64
,
752 [ FILTER_OP_GET_CONTEXT_REF_DOUBLE
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_DOUBLE
,
754 /* Instructions for recursive traversal through composed types. */
755 [ FILTER_OP_GET_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_CONTEXT_ROOT
,
756 [ FILTER_OP_GET_APP_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_APP_CONTEXT_ROOT
,
757 [ FILTER_OP_GET_PAYLOAD_ROOT
] = &&LABEL_FILTER_OP_GET_PAYLOAD_ROOT
,
759 [ FILTER_OP_GET_SYMBOL
] = &&LABEL_FILTER_OP_GET_SYMBOL
,
760 [ FILTER_OP_GET_SYMBOL_FIELD
] = &&LABEL_FILTER_OP_GET_SYMBOL_FIELD
,
761 [ FILTER_OP_GET_INDEX_U16
] = &&LABEL_FILTER_OP_GET_INDEX_U16
,
762 [ FILTER_OP_GET_INDEX_U64
] = &&LABEL_FILTER_OP_GET_INDEX_U64
,
764 [ FILTER_OP_LOAD_FIELD
] = &&LABEL_FILTER_OP_LOAD_FIELD
,
765 [ FILTER_OP_LOAD_FIELD_S8
] = &&LABEL_FILTER_OP_LOAD_FIELD_S8
,
766 [ FILTER_OP_LOAD_FIELD_S16
] = &&LABEL_FILTER_OP_LOAD_FIELD_S16
,
767 [ FILTER_OP_LOAD_FIELD_S32
] = &&LABEL_FILTER_OP_LOAD_FIELD_S32
,
768 [ FILTER_OP_LOAD_FIELD_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_S64
,
769 [ FILTER_OP_LOAD_FIELD_U8
] = &&LABEL_FILTER_OP_LOAD_FIELD_U8
,
770 [ FILTER_OP_LOAD_FIELD_U16
] = &&LABEL_FILTER_OP_LOAD_FIELD_U16
,
771 [ FILTER_OP_LOAD_FIELD_U32
] = &&LABEL_FILTER_OP_LOAD_FIELD_U32
,
772 [ FILTER_OP_LOAD_FIELD_U64
] = &&LABEL_FILTER_OP_LOAD_FIELD_U64
,
773 [ FILTER_OP_LOAD_FIELD_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_STRING
,
774 [ FILTER_OP_LOAD_FIELD_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_SEQUENCE
,
775 [ FILTER_OP_LOAD_FIELD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_DOUBLE
,
777 [ FILTER_OP_UNARY_BIT_NOT
] = &&LABEL_FILTER_OP_UNARY_BIT_NOT
,
779 [ FILTER_OP_RETURN_S64
] = &&LABEL_FILTER_OP_RETURN_S64
,
781 #endif /* #ifndef INTERPRETER_USE_SWITCH */
785 OP(FILTER_OP_UNKNOWN
):
786 OP(FILTER_OP_LOAD_FIELD_REF
):
787 #ifdef INTERPRETER_USE_SWITCH
789 #endif /* INTERPRETER_USE_SWITCH */
790 ERR("unknown bytecode op %u",
791 (unsigned int) *(filter_opcode_t
*) pc
);
795 OP(FILTER_OP_RETURN
):
796 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
797 /* Handle dynamic typing. */
798 switch (estack_ax_t
) {
801 retval
= !!estack_ax_v
;
805 case REG_STAR_GLOB_STRING
:
813 OP(FILTER_OP_RETURN_S64
):
814 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
815 retval
= !!estack_ax_v
;
825 ERR("unsupported bytecode op %u",
826 (unsigned int) *(filter_opcode_t
*) pc
);
832 /* Dynamic typing. */
833 switch (estack_ax_t
) {
834 case REG_S64
: /* Fall-through */
836 switch (estack_bx_t
) {
837 case REG_S64
: /* Fall-through */
839 JUMP_TO(FILTER_OP_EQ_S64
);
841 JUMP_TO(FILTER_OP_EQ_DOUBLE_S64
);
842 case REG_STRING
: /* Fall-through */
843 case REG_STAR_GLOB_STRING
:
847 ERR("Unknown filter register type (%d)",
854 switch (estack_bx_t
) {
855 case REG_S64
: /* Fall-through */
857 JUMP_TO(FILTER_OP_EQ_S64_DOUBLE
);
859 JUMP_TO(FILTER_OP_EQ_DOUBLE
);
860 case REG_STRING
: /* Fall-through */
861 case REG_STAR_GLOB_STRING
:
865 ERR("Unknown filter register type (%d)",
872 switch (estack_bx_t
) {
873 case REG_S64
: /* Fall-through */
874 case REG_U64
: /* Fall-through */
879 JUMP_TO(FILTER_OP_EQ_STRING
);
880 case REG_STAR_GLOB_STRING
:
881 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
883 ERR("Unknown filter register type (%d)",
889 case REG_STAR_GLOB_STRING
:
890 switch (estack_bx_t
) {
891 case REG_S64
: /* Fall-through */
892 case REG_U64
: /* Fall-through */
897 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
898 case REG_STAR_GLOB_STRING
:
902 ERR("Unknown filter register type (%d)",
909 ERR("Unknown filter register type (%d)",
917 /* Dynamic typing. */
918 switch (estack_ax_t
) {
919 case REG_S64
: /* Fall-through */
921 switch (estack_bx_t
) {
922 case REG_S64
: /* Fall-through */
924 JUMP_TO(FILTER_OP_NE_S64
);
926 JUMP_TO(FILTER_OP_NE_DOUBLE_S64
);
927 case REG_STRING
: /* Fall-through */
928 case REG_STAR_GLOB_STRING
:
932 ERR("Unknown filter register type (%d)",
939 switch (estack_bx_t
) {
940 case REG_S64
: /* Fall-through */
942 JUMP_TO(FILTER_OP_NE_S64_DOUBLE
);
944 JUMP_TO(FILTER_OP_NE_DOUBLE
);
945 case REG_STRING
: /* Fall-through */
946 case REG_STAR_GLOB_STRING
:
950 ERR("Unknown filter register type (%d)",
957 switch (estack_bx_t
) {
958 case REG_S64
: /* Fall-through */
964 JUMP_TO(FILTER_OP_NE_STRING
);
965 case REG_STAR_GLOB_STRING
:
966 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
968 ERR("Unknown filter register type (%d)",
974 case REG_STAR_GLOB_STRING
:
975 switch (estack_bx_t
) {
976 case REG_S64
: /* Fall-through */
982 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
983 case REG_STAR_GLOB_STRING
:
987 ERR("Unknown filter register type (%d)",
994 ERR("Unknown filter register type (%d)",
1002 /* Dynamic typing. */
1003 switch (estack_ax_t
) {
1004 case REG_S64
: /* Fall-through */
1006 switch (estack_bx_t
) {
1007 case REG_S64
: /* Fall-through */
1009 JUMP_TO(FILTER_OP_GT_S64
);
1011 JUMP_TO(FILTER_OP_GT_DOUBLE_S64
);
1012 case REG_STRING
: /* Fall-through */
1013 case REG_STAR_GLOB_STRING
:
1017 ERR("Unknown filter register type (%d)",
1024 switch (estack_bx_t
) {
1025 case REG_S64
: /* Fall-through */
1027 JUMP_TO(FILTER_OP_GT_S64_DOUBLE
);
1029 JUMP_TO(FILTER_OP_GT_DOUBLE
);
1030 case REG_STRING
: /* Fall-through */
1031 case REG_STAR_GLOB_STRING
:
1035 ERR("Unknown filter register type (%d)",
1042 switch (estack_bx_t
) {
1043 case REG_S64
: /* Fall-through */
1044 case REG_U64
: /* Fall-through */
1045 case REG_DOUBLE
: /* Fall-through */
1046 case REG_STAR_GLOB_STRING
:
1050 JUMP_TO(FILTER_OP_GT_STRING
);
1052 ERR("Unknown filter register type (%d)",
1059 ERR("Unknown filter register type (%d)",
1067 /* Dynamic typing. */
1068 switch (estack_ax_t
) {
1069 case REG_S64
: /* Fall-through */
1071 switch (estack_bx_t
) {
1072 case REG_S64
: /* Fall-through */
1074 JUMP_TO(FILTER_OP_LT_S64
);
1076 JUMP_TO(FILTER_OP_LT_DOUBLE_S64
);
1077 case REG_STRING
: /* Fall-through */
1078 case REG_STAR_GLOB_STRING
:
1082 ERR("Unknown filter register type (%d)",
1089 switch (estack_bx_t
) {
1090 case REG_S64
: /* Fall-through */
1092 JUMP_TO(FILTER_OP_LT_S64_DOUBLE
);
1094 JUMP_TO(FILTER_OP_LT_DOUBLE
);
1095 case REG_STRING
: /* Fall-through */
1096 case REG_STAR_GLOB_STRING
:
1100 ERR("Unknown filter register type (%d)",
1107 switch (estack_bx_t
) {
1108 case REG_S64
: /* Fall-through */
1109 case REG_U64
: /* Fall-through */
1110 case REG_DOUBLE
: /* Fall-through */
1111 case REG_STAR_GLOB_STRING
:
1115 JUMP_TO(FILTER_OP_LT_STRING
);
1117 ERR("Unknown filter register type (%d)",
1124 ERR("Unknown filter register type (%d)",
1132 /* Dynamic typing. */
1133 switch (estack_ax_t
) {
1134 case REG_S64
: /* Fall-through */
1136 switch (estack_bx_t
) {
1137 case REG_S64
: /* Fall-through */
1139 JUMP_TO(FILTER_OP_GE_S64
);
1141 JUMP_TO(FILTER_OP_GE_DOUBLE_S64
);
1142 case REG_STRING
: /* Fall-through */
1143 case REG_STAR_GLOB_STRING
:
1147 ERR("Unknown filter register type (%d)",
1154 switch (estack_bx_t
) {
1155 case REG_S64
: /* Fall-through */
1157 JUMP_TO(FILTER_OP_GE_S64_DOUBLE
);
1159 JUMP_TO(FILTER_OP_GE_DOUBLE
);
1160 case REG_STRING
: /* Fall-through */
1161 case REG_STAR_GLOB_STRING
:
1165 ERR("Unknown filter register type (%d)",
1172 switch (estack_bx_t
) {
1173 case REG_S64
: /* Fall-through */
1174 case REG_U64
: /* Fall-through */
1175 case REG_DOUBLE
: /* Fall-through */
1176 case REG_STAR_GLOB_STRING
:
1180 JUMP_TO(FILTER_OP_GE_STRING
);
1182 ERR("Unknown filter register type (%d)",
1189 ERR("Unknown filter register type (%d)",
1197 /* Dynamic typing. */
1198 switch (estack_ax_t
) {
1199 case REG_S64
: /* Fall-through */
1201 switch (estack_bx_t
) {
1202 case REG_S64
: /* Fall-through */
1204 JUMP_TO(FILTER_OP_LE_S64
);
1206 JUMP_TO(FILTER_OP_LE_DOUBLE_S64
);
1207 case REG_STRING
: /* Fall-through */
1208 case REG_STAR_GLOB_STRING
:
1212 ERR("Unknown filter register type (%d)",
1219 switch (estack_bx_t
) {
1220 case REG_S64
: /* Fall-through */
1222 JUMP_TO(FILTER_OP_LE_S64_DOUBLE
);
1224 JUMP_TO(FILTER_OP_LE_DOUBLE
);
1225 case REG_STRING
: /* Fall-through */
1226 case REG_STAR_GLOB_STRING
:
1230 ERR("Unknown filter register type (%d)",
1237 switch (estack_bx_t
) {
1238 case REG_S64
: /* Fall-through */
1239 case REG_U64
: /* Fall-through */
1240 case REG_DOUBLE
: /* Fall-through */
1241 case REG_STAR_GLOB_STRING
:
1245 JUMP_TO(FILTER_OP_LE_STRING
);
1247 ERR("Unknown filter register type (%d)",
1254 ERR("Unknown filter register type (%d)",
1261 OP(FILTER_OP_EQ_STRING
):
1265 res
= (stack_strcmp(stack
, top
, "==") == 0);
1266 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1268 estack_ax_t
= REG_S64
;
1269 next_pc
+= sizeof(struct binary_op
);
1272 OP(FILTER_OP_NE_STRING
):
1276 res
= (stack_strcmp(stack
, top
, "!=") != 0);
1277 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1279 estack_ax_t
= REG_S64
;
1280 next_pc
+= sizeof(struct binary_op
);
1283 OP(FILTER_OP_GT_STRING
):
1287 res
= (stack_strcmp(stack
, top
, ">") > 0);
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_LT_STRING
):
1298 res
= (stack_strcmp(stack
, top
, "<") < 0);
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_GE_STRING
):
1309 res
= (stack_strcmp(stack
, top
, ">=") >= 0);
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_LE_STRING
):
1320 res
= (stack_strcmp(stack
, top
, "<=") <= 0);
1321 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1323 estack_ax_t
= REG_S64
;
1324 next_pc
+= sizeof(struct binary_op
);
1328 OP(FILTER_OP_EQ_STAR_GLOB_STRING
):
1332 res
= (stack_star_glob_match(stack
, top
, "==") == 0);
1333 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1335 estack_ax_t
= REG_S64
;
1336 next_pc
+= sizeof(struct binary_op
);
1339 OP(FILTER_OP_NE_STAR_GLOB_STRING
):
1343 res
= (stack_star_glob_match(stack
, top
, "!=") != 0);
1344 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1346 estack_ax_t
= REG_S64
;
1347 next_pc
+= sizeof(struct binary_op
);
1351 OP(FILTER_OP_EQ_S64
):
1355 res
= (estack_bx_v
== estack_ax_v
);
1356 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1358 estack_ax_t
= REG_S64
;
1359 next_pc
+= sizeof(struct binary_op
);
1362 OP(FILTER_OP_NE_S64
):
1366 res
= (estack_bx_v
!= estack_ax_v
);
1367 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1369 estack_ax_t
= REG_S64
;
1370 next_pc
+= sizeof(struct binary_op
);
1373 OP(FILTER_OP_GT_S64
):
1377 res
= (estack_bx_v
> estack_ax_v
);
1378 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1380 estack_ax_t
= REG_S64
;
1381 next_pc
+= sizeof(struct binary_op
);
1384 OP(FILTER_OP_LT_S64
):
1388 res
= (estack_bx_v
< estack_ax_v
);
1389 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1391 estack_ax_t
= REG_S64
;
1392 next_pc
+= sizeof(struct binary_op
);
1395 OP(FILTER_OP_GE_S64
):
1399 res
= (estack_bx_v
>= estack_ax_v
);
1400 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1402 estack_ax_t
= REG_S64
;
1403 next_pc
+= sizeof(struct binary_op
);
1406 OP(FILTER_OP_LE_S64
):
1410 res
= (estack_bx_v
<= estack_ax_v
);
1411 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1413 estack_ax_t
= REG_S64
;
1414 next_pc
+= sizeof(struct binary_op
);
1418 OP(FILTER_OP_EQ_DOUBLE
):
1422 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax(stack
, top
)->u
.d
);
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
):
1433 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax(stack
, top
)->u
.d
);
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
):
1444 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax(stack
, top
)->u
.d
);
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
):
1455 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax(stack
, top
)->u
.d
);
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
):
1466 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax(stack
, top
)->u
.d
);
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
):
1477 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax(stack
, top
)->u
.d
);
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 /* Mixed S64-double binary comparators */
1486 OP(FILTER_OP_EQ_DOUBLE_S64
):
1490 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax_v
);
1491 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1493 estack_ax_t
= REG_S64
;
1494 next_pc
+= sizeof(struct binary_op
);
1497 OP(FILTER_OP_NE_DOUBLE_S64
):
1501 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax_v
);
1502 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1504 estack_ax_t
= REG_S64
;
1505 next_pc
+= sizeof(struct binary_op
);
1508 OP(FILTER_OP_GT_DOUBLE_S64
):
1512 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax_v
);
1513 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1515 estack_ax_t
= REG_S64
;
1516 next_pc
+= sizeof(struct binary_op
);
1519 OP(FILTER_OP_LT_DOUBLE_S64
):
1523 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax_v
);
1524 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1526 estack_ax_t
= REG_S64
;
1527 next_pc
+= sizeof(struct binary_op
);
1530 OP(FILTER_OP_GE_DOUBLE_S64
):
1534 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax_v
);
1535 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1537 estack_ax_t
= REG_S64
;
1538 next_pc
+= sizeof(struct binary_op
);
1541 OP(FILTER_OP_LE_DOUBLE_S64
):
1545 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax_v
);
1546 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1548 estack_ax_t
= REG_S64
;
1549 next_pc
+= sizeof(struct binary_op
);
1553 OP(FILTER_OP_EQ_S64_DOUBLE
):
1557 res
= (estack_bx_v
== estack_ax(stack
, top
)->u
.d
);
1558 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1560 estack_ax_t
= REG_S64
;
1561 next_pc
+= sizeof(struct binary_op
);
1564 OP(FILTER_OP_NE_S64_DOUBLE
):
1568 res
= (estack_bx_v
!= estack_ax(stack
, top
)->u
.d
);
1569 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1571 estack_ax_t
= REG_S64
;
1572 next_pc
+= sizeof(struct binary_op
);
1575 OP(FILTER_OP_GT_S64_DOUBLE
):
1579 res
= (estack_bx_v
> estack_ax(stack
, top
)->u
.d
);
1580 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1582 estack_ax_t
= REG_S64
;
1583 next_pc
+= sizeof(struct binary_op
);
1586 OP(FILTER_OP_LT_S64_DOUBLE
):
1590 res
= (estack_bx_v
< estack_ax(stack
, top
)->u
.d
);
1591 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1593 estack_ax_t
= REG_S64
;
1594 next_pc
+= sizeof(struct binary_op
);
1597 OP(FILTER_OP_GE_S64_DOUBLE
):
1601 res
= (estack_bx_v
>= estack_ax(stack
, top
)->u
.d
);
1602 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1604 estack_ax_t
= REG_S64
;
1605 next_pc
+= sizeof(struct binary_op
);
1608 OP(FILTER_OP_LE_S64_DOUBLE
):
1612 res
= (estack_bx_v
<= estack_ax(stack
, top
)->u
.d
);
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_RSHIFT
):
1623 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1628 /* Catch undefined behavior. */
1629 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1633 res
= ((uint64_t) estack_bx_v
>> (uint32_t) estack_ax_v
);
1634 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1636 estack_ax_t
= REG_U64
;
1637 next_pc
+= sizeof(struct binary_op
);
1640 OP(FILTER_OP_BIT_LSHIFT
):
1644 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1649 /* Catch undefined behavior. */
1650 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1654 res
= ((uint64_t) estack_bx_v
<< (uint32_t) estack_ax_v
);
1655 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1657 estack_ax_t
= REG_U64
;
1658 next_pc
+= sizeof(struct binary_op
);
1661 OP(FILTER_OP_BIT_AND
):
1665 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1670 res
= ((uint64_t) estack_bx_v
& (uint64_t) estack_ax_v
);
1671 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1673 estack_ax_t
= REG_U64
;
1674 next_pc
+= sizeof(struct binary_op
);
1677 OP(FILTER_OP_BIT_OR
):
1681 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1686 res
= ((uint64_t) estack_bx_v
| (uint64_t) estack_ax_v
);
1687 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1689 estack_ax_t
= REG_U64
;
1690 next_pc
+= sizeof(struct binary_op
);
1693 OP(FILTER_OP_BIT_XOR
):
1697 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1702 res
= ((uint64_t) estack_bx_v
^ (uint64_t) estack_ax_v
);
1703 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1705 estack_ax_t
= REG_U64
;
1706 next_pc
+= sizeof(struct binary_op
);
1711 OP(FILTER_OP_UNARY_PLUS
):
1713 /* Dynamic typing. */
1714 switch (estack_ax_t
) {
1715 case REG_S64
: /* Fall-through. */
1717 JUMP_TO(FILTER_OP_UNARY_PLUS_S64
);
1719 JUMP_TO(FILTER_OP_UNARY_PLUS_DOUBLE
);
1720 case REG_STRING
: /* Fall-through */
1721 case REG_STAR_GLOB_STRING
:
1725 ERR("Unknown filter register type (%d)",
1731 OP(FILTER_OP_UNARY_MINUS
):
1733 /* Dynamic typing. */
1734 switch (estack_ax_t
) {
1735 case REG_S64
: /* Fall-through. */
1737 JUMP_TO(FILTER_OP_UNARY_MINUS_S64
);
1739 JUMP_TO(FILTER_OP_UNARY_MINUS_DOUBLE
);
1740 case REG_STRING
: /* Fall-through */
1741 case REG_STAR_GLOB_STRING
:
1745 ERR("Unknown filter register type (%d)",
1751 OP(FILTER_OP_UNARY_NOT
):
1753 /* Dynamic typing. */
1754 switch (estack_ax_t
) {
1755 case REG_S64
: /* Fall-through. */
1757 JUMP_TO(FILTER_OP_UNARY_NOT_S64
);
1759 JUMP_TO(FILTER_OP_UNARY_NOT_DOUBLE
);
1760 case REG_STRING
: /* Fall-through */
1761 case REG_STAR_GLOB_STRING
:
1765 ERR("Unknown filter register type (%d)",
1770 next_pc
+= sizeof(struct unary_op
);
1774 OP(FILTER_OP_UNARY_BIT_NOT
):
1776 /* Dynamic typing. */
1777 if (!IS_INTEGER_REGISTER(estack_ax_t
)) {
1782 estack_ax_v
= ~(uint64_t) estack_ax_v
;
1783 estack_ax_t
= REG_U64
;
1784 next_pc
+= sizeof(struct unary_op
);
1788 OP(FILTER_OP_UNARY_PLUS_S64
):
1789 OP(FILTER_OP_UNARY_PLUS_DOUBLE
):
1791 next_pc
+= sizeof(struct unary_op
);
1794 OP(FILTER_OP_UNARY_MINUS_S64
):
1796 estack_ax_v
= -estack_ax_v
;
1797 next_pc
+= sizeof(struct unary_op
);
1800 OP(FILTER_OP_UNARY_MINUS_DOUBLE
):
1802 estack_ax(stack
, top
)->u
.d
= -estack_ax(stack
, top
)->u
.d
;
1803 next_pc
+= sizeof(struct unary_op
);
1806 OP(FILTER_OP_UNARY_NOT_S64
):
1808 estack_ax_v
= !estack_ax_v
;
1809 estack_ax_t
= REG_S64
;
1810 next_pc
+= sizeof(struct unary_op
);
1813 OP(FILTER_OP_UNARY_NOT_DOUBLE
):
1815 estack_ax_v
= !estack_ax(stack
, top
)->u
.d
;
1816 estack_ax_t
= REG_S64
;
1817 next_pc
+= sizeof(struct unary_op
);
1824 struct logical_op
*insn
= (struct logical_op
*) pc
;
1826 if (estack_ax_t
!= REG_S64
&& estack_ax_t
!= REG_U64
) {
1830 /* If AX is 0, skip and evaluate to 0 */
1831 if (unlikely(estack_ax_v
== 0)) {
1832 dbg_printf("Jumping to bytecode offset %u\n",
1833 (unsigned int) insn
->skip_offset
);
1834 next_pc
= start_pc
+ insn
->skip_offset
;
1836 /* Pop 1 when jump not taken */
1837 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1838 next_pc
+= sizeof(struct logical_op
);
1844 struct logical_op
*insn
= (struct logical_op
*) pc
;
1846 if (estack_ax_t
!= REG_S64
&& estack_ax_t
!= REG_U64
) {
1850 /* If AX is nonzero, skip and evaluate to 1 */
1851 if (unlikely(estack_ax_v
!= 0)) {
1853 dbg_printf("Jumping to bytecode offset %u\n",
1854 (unsigned int) insn
->skip_offset
);
1855 next_pc
= start_pc
+ insn
->skip_offset
;
1857 /* Pop 1 when jump not taken */
1858 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1859 next_pc
+= sizeof(struct logical_op
);
1865 /* load field ref */
1866 OP(FILTER_OP_LOAD_FIELD_REF_STRING
):
1868 struct load_op
*insn
= (struct load_op
*) pc
;
1869 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1871 dbg_printf("load field ref offset %u type string\n",
1873 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1874 estack_ax(stack
, top
)->u
.s
.str
=
1875 *(const char * const *) &filter_stack_data
[ref
->offset
];
1876 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1877 dbg_printf("Filter warning: loading a NULL string.\n");
1881 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1882 estack_ax(stack
, top
)->u
.s
.literal_type
=
1883 ESTACK_STRING_LITERAL_TYPE_NONE
;
1884 estack_ax_t
= REG_STRING
;
1885 dbg_printf("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1886 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1890 OP(FILTER_OP_LOAD_FIELD_REF_SEQUENCE
):
1892 struct load_op
*insn
= (struct load_op
*) pc
;
1893 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1895 dbg_printf("load field ref offset %u type sequence\n",
1897 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1898 estack_ax(stack
, top
)->u
.s
.seq_len
=
1899 *(unsigned long *) &filter_stack_data
[ref
->offset
];
1900 estack_ax(stack
, top
)->u
.s
.str
=
1901 *(const char **) (&filter_stack_data
[ref
->offset
1902 + sizeof(unsigned long)]);
1903 estack_ax_t
= REG_STRING
;
1904 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1905 dbg_printf("Filter warning: loading a NULL sequence.\n");
1909 estack_ax(stack
, top
)->u
.s
.literal_type
=
1910 ESTACK_STRING_LITERAL_TYPE_NONE
;
1911 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1915 OP(FILTER_OP_LOAD_FIELD_REF_S64
):
1917 struct load_op
*insn
= (struct load_op
*) pc
;
1918 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1920 dbg_printf("load field ref offset %u type s64\n",
1922 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1924 ((struct literal_numeric
*) &filter_stack_data
[ref
->offset
])->v
;
1925 estack_ax_t
= REG_S64
;
1926 dbg_printf("ref load s64 %" PRIi64
"\n", estack_ax_v
);
1927 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1931 OP(FILTER_OP_LOAD_FIELD_REF_DOUBLE
):
1933 struct load_op
*insn
= (struct load_op
*) pc
;
1934 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1936 dbg_printf("load field ref offset %u type double\n",
1938 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1939 memcpy(&estack_ax(stack
, top
)->u
.d
, &filter_stack_data
[ref
->offset
],
1940 sizeof(struct literal_double
));
1941 estack_ax_t
= REG_DOUBLE
;
1942 dbg_printf("ref load double %g\n", estack_ax(stack
, top
)->u
.d
);
1943 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1947 /* load from immediate operand */
1948 OP(FILTER_OP_LOAD_STRING
):
1950 struct load_op
*insn
= (struct load_op
*) pc
;
1952 dbg_printf("load string %s\n", insn
->data
);
1953 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1954 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1955 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1956 estack_ax(stack
, top
)->u
.s
.literal_type
=
1957 ESTACK_STRING_LITERAL_TYPE_PLAIN
;
1958 estack_ax_t
= REG_STRING
;
1959 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1963 OP(FILTER_OP_LOAD_STAR_GLOB_STRING
):
1965 struct load_op
*insn
= (struct load_op
*) pc
;
1967 dbg_printf("load globbing pattern %s\n", insn
->data
);
1968 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1969 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1970 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1971 estack_ax(stack
, top
)->u
.s
.literal_type
=
1972 ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
;
1973 estack_ax_t
= REG_STAR_GLOB_STRING
;
1974 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1978 OP(FILTER_OP_LOAD_S64
):
1980 struct load_op
*insn
= (struct load_op
*) pc
;
1982 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1983 estack_ax_v
= ((struct literal_numeric
*) insn
->data
)->v
;
1984 estack_ax_t
= REG_S64
;
1985 dbg_printf("load s64 %" PRIi64
"\n", estack_ax_v
);
1986 next_pc
+= sizeof(struct load_op
)
1987 + sizeof(struct literal_numeric
);
1991 OP(FILTER_OP_LOAD_DOUBLE
):
1993 struct load_op
*insn
= (struct load_op
*) pc
;
1995 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1996 memcpy(&estack_ax(stack
, top
)->u
.d
, insn
->data
,
1997 sizeof(struct literal_double
));
1998 estack_ax_t
= REG_DOUBLE
;
1999 dbg_printf("load double %g\n", estack_ax(stack
, top
)->u
.d
);
2000 next_pc
+= sizeof(struct load_op
)
2001 + sizeof(struct literal_double
);
2006 OP(FILTER_OP_CAST_TO_S64
):
2008 /* Dynamic typing. */
2009 switch (estack_ax_t
) {
2011 JUMP_TO(FILTER_OP_CAST_NOP
);
2013 JUMP_TO(FILTER_OP_CAST_DOUBLE_TO_S64
);
2015 estack_ax_t
= REG_S64
;
2016 next_pc
+= sizeof(struct cast_op
);
2017 case REG_STRING
: /* Fall-through */
2018 case REG_STAR_GLOB_STRING
:
2022 ERR("Unknown filter register type (%d)",
2029 OP(FILTER_OP_CAST_DOUBLE_TO_S64
):
2031 estack_ax_v
= (int64_t) estack_ax(stack
, top
)->u
.d
;
2032 estack_ax_t
= REG_S64
;
2033 next_pc
+= sizeof(struct cast_op
);
2037 OP(FILTER_OP_CAST_NOP
):
2039 next_pc
+= sizeof(struct cast_op
);
2043 /* get context ref */
2044 OP(FILTER_OP_GET_CONTEXT_REF
):
2046 struct load_op
*insn
= (struct load_op
*) pc
;
2047 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2048 struct lttng_ctx_field
*ctx_field
;
2049 struct lttng_ctx_value v
;
2051 dbg_printf("get context ref offset %u type dynamic\n",
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
);
2057 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
2060 case LTTNG_UST_DYNAMIC_TYPE_S64
:
2061 estack_ax_v
= v
.u
.s64
;
2062 estack_ax_t
= REG_S64
;
2063 dbg_printf("ref get context dynamic s64 %" PRIi64
"\n", estack_ax_v
);
2065 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
2066 estack_ax(stack
, top
)->u
.d
= v
.u
.d
;
2067 estack_ax_t
= REG_DOUBLE
;
2068 dbg_printf("ref get context dynamic double %g\n", estack_ax(stack
, top
)->u
.d
);
2070 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
2071 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2072 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2073 dbg_printf("Filter warning: loading a NULL string.\n");
2077 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2078 estack_ax(stack
, top
)->u
.s
.literal_type
=
2079 ESTACK_STRING_LITERAL_TYPE_NONE
;
2080 dbg_printf("ref get context dynamic string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2081 estack_ax_t
= REG_STRING
;
2084 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
2088 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2092 OP(FILTER_OP_GET_CONTEXT_REF_STRING
):
2094 struct load_op
*insn
= (struct load_op
*) pc
;
2095 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2096 struct lttng_ctx_field
*ctx_field
;
2097 struct lttng_ctx_value v
;
2099 dbg_printf("get context ref offset %u type string\n",
2101 ctx_field
= &ctx
->fields
[ref
->offset
];
2102 ctx_field
->get_value(ctx_field
, &v
);
2103 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2104 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2105 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2106 dbg_printf("Filter warning: loading a NULL string.\n");
2110 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2111 estack_ax(stack
, top
)->u
.s
.literal_type
=
2112 ESTACK_STRING_LITERAL_TYPE_NONE
;
2113 estack_ax_t
= REG_STRING
;
2114 dbg_printf("ref get context string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2115 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2119 OP(FILTER_OP_GET_CONTEXT_REF_S64
):
2121 struct load_op
*insn
= (struct load_op
*) pc
;
2122 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2123 struct lttng_ctx_field
*ctx_field
;
2124 struct lttng_ctx_value v
;
2126 dbg_printf("get context ref offset %u type s64\n",
2128 ctx_field
= &ctx
->fields
[ref
->offset
];
2129 ctx_field
->get_value(ctx_field
, &v
);
2130 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2131 estack_ax_v
= v
.u
.s64
;
2132 estack_ax_t
= REG_S64
;
2133 dbg_printf("ref get context s64 %" PRIi64
"\n", estack_ax_v
);
2134 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2138 OP(FILTER_OP_GET_CONTEXT_REF_DOUBLE
):
2140 struct load_op
*insn
= (struct load_op
*) pc
;
2141 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2142 struct lttng_ctx_field
*ctx_field
;
2143 struct lttng_ctx_value v
;
2145 dbg_printf("get context ref offset %u type double\n",
2147 ctx_field
= &ctx
->fields
[ref
->offset
];
2148 ctx_field
->get_value(ctx_field
, &v
);
2149 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2150 memcpy(&estack_ax(stack
, top
)->u
.d
, &v
.u
.d
, sizeof(struct literal_double
));
2151 estack_ax_t
= REG_DOUBLE
;
2152 dbg_printf("ref get context double %g\n", estack_ax(stack
, top
)->u
.d
);
2153 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2157 OP(FILTER_OP_GET_CONTEXT_ROOT
):
2159 dbg_printf("op get context root\n");
2160 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2161 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_CONTEXT
;
2162 /* "field" only needed for variants. */
2163 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2164 estack_ax_t
= REG_PTR
;
2165 next_pc
+= sizeof(struct load_op
);
2169 OP(FILTER_OP_GET_APP_CONTEXT_ROOT
):
2171 dbg_printf("op get app context root\n");
2172 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2173 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_APP_CONTEXT
;
2174 /* "field" only needed for variants. */
2175 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2176 estack_ax_t
= REG_PTR
;
2177 next_pc
+= sizeof(struct load_op
);
2181 OP(FILTER_OP_GET_PAYLOAD_ROOT
):
2183 dbg_printf("op get app payload root\n");
2184 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2185 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_PAYLOAD
;
2186 estack_ax(stack
, top
)->u
.ptr
.ptr
= filter_stack_data
;
2187 /* "field" only needed for variants. */
2188 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2189 estack_ax_t
= REG_PTR
;
2190 next_pc
+= sizeof(struct load_op
);
2194 OP(FILTER_OP_GET_SYMBOL
):
2196 dbg_printf("op get symbol\n");
2197 switch (estack_ax(stack
, top
)->u
.ptr
.type
) {
2199 ERR("Nested fields not implemented yet.");
2202 case LOAD_ROOT_CONTEXT
:
2203 case LOAD_ROOT_APP_CONTEXT
:
2204 case LOAD_ROOT_PAYLOAD
:
2206 * symbol lookup is performed by
2212 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_symbol
);
2216 OP(FILTER_OP_GET_SYMBOL_FIELD
):
2219 * Used for first variant encountered in a
2220 * traversal. Variants are not implemented yet.
2226 OP(FILTER_OP_GET_INDEX_U16
):
2228 struct load_op
*insn
= (struct load_op
*) pc
;
2229 struct get_index_u16
*index
= (struct get_index_u16
*) insn
->data
;
2231 dbg_printf("op get index u16\n");
2232 ret
= dynamic_get_index(ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
2235 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2236 estack_ax_t
= estack_ax(stack
, top
)->type
;
2237 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u16
);
2241 OP(FILTER_OP_GET_INDEX_U64
):
2243 struct load_op
*insn
= (struct load_op
*) pc
;
2244 struct get_index_u64
*index
= (struct get_index_u64
*) insn
->data
;
2246 dbg_printf("op get index u64\n");
2247 ret
= dynamic_get_index(ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
2250 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2251 estack_ax_t
= estack_ax(stack
, top
)->type
;
2252 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u64
);
2256 OP(FILTER_OP_LOAD_FIELD
):
2258 dbg_printf("op load field\n");
2259 ret
= dynamic_load_field(estack_ax(stack
, top
));
2262 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2263 estack_ax_t
= estack_ax(stack
, top
)->type
;
2264 next_pc
+= sizeof(struct load_op
);
2268 OP(FILTER_OP_LOAD_FIELD_S8
):
2270 dbg_printf("op load field s8\n");
2272 estack_ax_v
= *(int8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2273 estack_ax_t
= REG_S64
;
2274 next_pc
+= sizeof(struct load_op
);
2277 OP(FILTER_OP_LOAD_FIELD_S16
):
2279 dbg_printf("op load field s16\n");
2281 estack_ax_v
= *(int16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2282 estack_ax_t
= REG_S64
;
2283 next_pc
+= sizeof(struct load_op
);
2286 OP(FILTER_OP_LOAD_FIELD_S32
):
2288 dbg_printf("op load field s32\n");
2290 estack_ax_v
= *(int32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2291 estack_ax_t
= REG_S64
;
2292 next_pc
+= sizeof(struct load_op
);
2295 OP(FILTER_OP_LOAD_FIELD_S64
):
2297 dbg_printf("op load field s64\n");
2299 estack_ax_v
= *(int64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2300 estack_ax_t
= REG_S64
;
2301 next_pc
+= sizeof(struct load_op
);
2304 OP(FILTER_OP_LOAD_FIELD_U8
):
2306 dbg_printf("op load field u8\n");
2308 estack_ax_v
= *(uint8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2309 estack_ax_t
= REG_U64
;
2310 next_pc
+= sizeof(struct load_op
);
2313 OP(FILTER_OP_LOAD_FIELD_U16
):
2315 dbg_printf("op load field u16\n");
2317 estack_ax_v
= *(uint16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2318 estack_ax_t
= REG_U64
;
2319 next_pc
+= sizeof(struct load_op
);
2322 OP(FILTER_OP_LOAD_FIELD_U32
):
2324 dbg_printf("op load field u32\n");
2326 estack_ax_v
= *(uint32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2327 estack_ax_t
= REG_U64
;
2328 next_pc
+= sizeof(struct load_op
);
2331 OP(FILTER_OP_LOAD_FIELD_U64
):
2333 dbg_printf("op load field u64\n");
2335 estack_ax_v
= *(uint64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2336 estack_ax_t
= REG_U64
;
2337 next_pc
+= sizeof(struct load_op
);
2340 OP(FILTER_OP_LOAD_FIELD_DOUBLE
):
2342 dbg_printf("op load field double\n");
2344 memcpy(&estack_ax(stack
, top
)->u
.d
,
2345 estack_ax(stack
, top
)->u
.ptr
.ptr
,
2346 sizeof(struct literal_double
));
2347 estack_ax(stack
, top
)->type
= REG_DOUBLE
;
2348 next_pc
+= sizeof(struct load_op
);
2352 OP(FILTER_OP_LOAD_FIELD_STRING
):
2356 dbg_printf("op load field string\n");
2357 str
= (const char *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2358 estack_ax(stack
, top
)->u
.s
.str
= str
;
2359 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2360 dbg_printf("Filter warning: loading a NULL string.\n");
2364 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2365 estack_ax(stack
, top
)->u
.s
.literal_type
=
2366 ESTACK_STRING_LITERAL_TYPE_NONE
;
2367 estack_ax(stack
, top
)->type
= REG_STRING
;
2368 next_pc
+= sizeof(struct load_op
);
2372 OP(FILTER_OP_LOAD_FIELD_SEQUENCE
):
2376 dbg_printf("op load field string sequence\n");
2377 ptr
= estack_ax(stack
, top
)->u
.ptr
.ptr
;
2378 estack_ax(stack
, top
)->u
.s
.seq_len
= *(unsigned long *) ptr
;
2379 estack_ax(stack
, top
)->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
2380 estack_ax(stack
, top
)->type
= REG_STRING
;
2381 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2382 dbg_printf("Filter warning: loading a NULL sequence.\n");
2386 estack_ax(stack
, top
)->u
.s
.literal_type
=
2387 ESTACK_STRING_LITERAL_TYPE_NONE
;
2388 next_pc
+= sizeof(struct load_op
);
2394 /* Return _DISCARD on error. */
2396 return LTTNG_FILTER_DISCARD
;