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>
33 #include <lttng/ust-endian.h>
34 #include <lttng/ust-events.h>
36 #include "lttng-filter.h"
37 #include "string-utils.h"
42 * -2: unknown escape char.
47 int parse_char(const char **p
)
67 * Returns SIZE_MAX if the string is null-terminated, or the number of
71 size_t get_str_or_seq_len(const struct estack_entry
*entry
)
73 return entry
->u
.s
.seq_len
;
77 int stack_star_glob_match(struct estack
*stack
, int top
, const char *cmp_type
)
80 const char *candidate
;
84 /* Find out which side is the pattern vs. the candidate. */
85 if (estack_ax(stack
, top
)->u
.s
.literal_type
== ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
) {
86 pattern
= estack_ax(stack
, top
)->u
.s
.str
;
87 pattern_len
= get_str_or_seq_len(estack_ax(stack
, top
));
88 candidate
= estack_bx(stack
, top
)->u
.s
.str
;
89 candidate_len
= get_str_or_seq_len(estack_bx(stack
, top
));
91 pattern
= estack_bx(stack
, top
)->u
.s
.str
;
92 pattern_len
= get_str_or_seq_len(estack_bx(stack
, top
));
93 candidate
= estack_ax(stack
, top
)->u
.s
.str
;
94 candidate_len
= get_str_or_seq_len(estack_ax(stack
, top
));
97 /* Perform the match. Returns 0 when the result is true. */
98 return !strutils_star_glob_match(pattern
, pattern_len
, candidate
,
103 int stack_strcmp(struct estack
*stack
, int top
, const char *cmp_type
)
105 const char *p
= estack_bx(stack
, top
)->u
.s
.str
, *q
= estack_ax(stack
, top
)->u
.s
.str
;
112 if (unlikely(p
- estack_bx(stack
, top
)->u
.s
.str
>= estack_bx(stack
, top
)->u
.s
.seq_len
|| *p
== '\0')) {
113 if (q
- estack_ax(stack
, top
)->u
.s
.str
>= estack_ax(stack
, top
)->u
.s
.seq_len
|| *q
== '\0') {
116 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
117 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
118 ret
= parse_char(&q
);
125 if (unlikely(q
- estack_ax(stack
, top
)->u
.s
.str
>= estack_ax(stack
, top
)->u
.s
.seq_len
|| *q
== '\0')) {
126 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
127 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
128 ret
= parse_char(&p
);
134 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
135 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
136 ret
= parse_char(&p
);
139 } else if (ret
== -2) {
142 /* else compare both char */
144 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
145 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
146 ret
= parse_char(&q
);
149 } else if (ret
== -2) {
169 uint64_t lttng_filter_interpret_bytecode_false(void *filter_data
,
170 const char *filter_stack_data
)
172 return LTTNG_FILTER_DISCARD
;
175 #ifdef INTERPRETER_USE_SWITCH
178 * Fallback for compilers that do not support taking address of labels.
182 start_pc = &bytecode->data[0]; \
183 for (pc = next_pc = start_pc; pc - start_pc < bytecode->len; \
185 dbg_printf("Executing op %s (%u)\n", \
186 print_op((unsigned int) *(filter_opcode_t *) pc), \
187 (unsigned int) *(filter_opcode_t *) pc); \
188 switch (*(filter_opcode_t *) pc) {
190 #define OP(name) jump_target_##name: __attribute__((unused)); \
198 #define JUMP_TO(name) \
199 goto jump_target_##name
204 * Dispatch-table based interpreter.
208 start_pc = &bytecode->code[0]; \
209 pc = next_pc = start_pc; \
210 if (unlikely(pc - start_pc >= bytecode->len)) \
212 goto *dispatch[*(filter_opcode_t *) pc];
219 goto *dispatch[*(filter_opcode_t *) pc];
223 #define JUMP_TO(name) \
228 #define IS_INTEGER_REGISTER(reg_type) \
229 (reg_type == REG_U64 || reg_type == REG_S64)
231 static int context_get_index(struct lttng_ctx
*ctx
,
232 struct load_ptr
*ptr
,
236 struct lttng_ctx_field
*ctx_field
;
237 struct lttng_event_field
*field
;
238 struct lttng_ctx_value v
;
240 ctx_field
= &ctx
->fields
[idx
];
241 field
= &ctx_field
->event_field
;
242 ptr
->type
= LOAD_OBJECT
;
245 switch (field
->type
.atype
) {
247 ctx_field
->get_value(ctx_field
, &v
);
248 if (field
->type
.u
.integer
.signedness
) {
249 ptr
->object_type
= OBJECT_TYPE_S64
;
250 ptr
->u
.s64
= v
.u
.s64
;
251 ptr
->ptr
= &ptr
->u
.s64
;
253 ptr
->object_type
= OBJECT_TYPE_U64
;
254 ptr
->u
.u64
= v
.u
.s64
; /* Cast. */
255 ptr
->ptr
= &ptr
->u
.u64
;
258 case atype_enum
: /* Fall-through */
259 case atype_enum_nestable
:
261 const struct lttng_integer_type
*itype
;
263 if (field
->type
.atype
== atype_enum
) {
264 itype
= &field
->type
.u
.legacy
.basic
.enumeration
.container_type
;
266 itype
= &field
->type
.u
.enum_nestable
.container_type
->u
.integer
;
268 ctx_field
->get_value(ctx_field
, &v
);
269 if (itype
->signedness
) {
270 ptr
->object_type
= OBJECT_TYPE_S64
;
271 ptr
->u
.s64
= v
.u
.s64
;
272 ptr
->ptr
= &ptr
->u
.s64
;
274 ptr
->object_type
= OBJECT_TYPE_U64
;
275 ptr
->u
.u64
= v
.u
.s64
; /* Cast. */
276 ptr
->ptr
= &ptr
->u
.u64
;
281 if (field
->type
.u
.legacy
.array
.elem_type
.atype
!= atype_integer
) {
282 ERR("Array nesting only supports integer types.");
285 if (field
->type
.u
.legacy
.array
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
286 ERR("Only string arrays are supported for contexts.");
289 ptr
->object_type
= OBJECT_TYPE_STRING
;
290 ctx_field
->get_value(ctx_field
, &v
);
293 case atype_array_nestable
:
294 if (field
->type
.u
.array_nestable
.elem_type
->atype
!= atype_integer
) {
295 ERR("Array nesting only supports integer types.");
298 if (field
->type
.u
.array_nestable
.elem_type
->u
.integer
.encoding
== lttng_encode_none
) {
299 ERR("Only string arrays are supported for contexts.");
302 ptr
->object_type
= OBJECT_TYPE_STRING
;
303 ctx_field
->get_value(ctx_field
, &v
);
307 if (field
->type
.u
.legacy
.sequence
.elem_type
.atype
!= atype_integer
) {
308 ERR("Sequence nesting only supports integer types.");
311 if (field
->type
.u
.legacy
.sequence
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
312 ERR("Only string sequences are supported for contexts.");
315 ptr
->object_type
= OBJECT_TYPE_STRING
;
316 ctx_field
->get_value(ctx_field
, &v
);
319 case atype_sequence_nestable
:
320 if (field
->type
.u
.sequence_nestable
.elem_type
->atype
!= atype_integer
) {
321 ERR("Sequence nesting only supports integer types.");
324 if (field
->type
.u
.sequence_nestable
.elem_type
->u
.integer
.encoding
== lttng_encode_none
) {
325 ERR("Only string sequences are supported for contexts.");
328 ptr
->object_type
= OBJECT_TYPE_STRING
;
329 ctx_field
->get_value(ctx_field
, &v
);
333 ptr
->object_type
= OBJECT_TYPE_STRING
;
334 ctx_field
->get_value(ctx_field
, &v
);
338 ptr
->object_type
= OBJECT_TYPE_DOUBLE
;
339 ctx_field
->get_value(ctx_field
, &v
);
341 ptr
->ptr
= &ptr
->u
.d
;
344 ctx_field
->get_value(ctx_field
, &v
);
346 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
348 case LTTNG_UST_DYNAMIC_TYPE_S64
:
349 ptr
->object_type
= OBJECT_TYPE_S64
;
350 ptr
->u
.s64
= v
.u
.s64
;
351 ptr
->ptr
= &ptr
->u
.s64
;
352 dbg_printf("context get index dynamic s64 %" PRIi64
"\n", ptr
->u
.s64
);
354 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
355 ptr
->object_type
= OBJECT_TYPE_DOUBLE
;
357 ptr
->ptr
= &ptr
->u
.d
;
358 dbg_printf("context get index dynamic double %g\n", ptr
->u
.d
);
360 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
361 ptr
->object_type
= OBJECT_TYPE_STRING
;
363 dbg_printf("context get index dynamic string %s\n", (const char *) ptr
->ptr
);
366 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
371 ERR("Structure type cannot be loaded.");
374 ERR("Unknown type: %d", (int) field
->type
.atype
);
380 static int dynamic_get_index(struct lttng_ctx
*ctx
,
381 struct bytecode_runtime
*runtime
,
382 uint64_t index
, struct estack_entry
*stack_top
)
385 const struct filter_get_index_data
*gid
;
387 gid
= (const struct filter_get_index_data
*) &runtime
->data
[index
];
388 switch (stack_top
->u
.ptr
.type
) {
390 switch (stack_top
->u
.ptr
.object_type
) {
391 case OBJECT_TYPE_ARRAY
:
395 assert(gid
->offset
< gid
->array_len
);
396 /* Skip count (unsigned long) */
397 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
398 ptr
= ptr
+ gid
->offset
;
399 stack_top
->u
.ptr
.ptr
= ptr
;
400 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
401 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
402 assert(stack_top
->u
.ptr
.field
->type
.atype
== atype_array
||
403 stack_top
->u
.ptr
.field
->type
.atype
== atype_array_nestable
);
404 stack_top
->u
.ptr
.field
= NULL
;
407 case OBJECT_TYPE_SEQUENCE
:
412 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
413 ptr_seq_len
= *(unsigned long *) stack_top
->u
.ptr
.ptr
;
414 if (gid
->offset
>= gid
->elem
.len
* ptr_seq_len
) {
418 ptr
= ptr
+ gid
->offset
;
419 stack_top
->u
.ptr
.ptr
= ptr
;
420 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
421 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
422 assert(stack_top
->u
.ptr
.field
->type
.atype
== atype_sequence
||
423 stack_top
->u
.ptr
.field
->type
.atype
== atype_sequence_nestable
);
424 stack_top
->u
.ptr
.field
= NULL
;
427 case OBJECT_TYPE_STRUCT
:
428 ERR("Nested structures are not supported yet.");
431 case OBJECT_TYPE_VARIANT
:
433 ERR("Unexpected get index type %d",
434 (int) stack_top
->u
.ptr
.object_type
);
439 case LOAD_ROOT_CONTEXT
:
440 case LOAD_ROOT_APP_CONTEXT
: /* Fall-through */
442 ret
= context_get_index(ctx
,
450 case LOAD_ROOT_PAYLOAD
:
451 stack_top
->u
.ptr
.ptr
+= gid
->offset
;
452 if (gid
->elem
.type
== OBJECT_TYPE_STRING
)
453 stack_top
->u
.ptr
.ptr
= *(const char * const *) stack_top
->u
.ptr
.ptr
;
454 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
455 stack_top
->u
.ptr
.type
= LOAD_OBJECT
;
456 stack_top
->u
.ptr
.field
= gid
->field
;
465 static int dynamic_load_field(struct estack_entry
*stack_top
)
469 switch (stack_top
->u
.ptr
.type
) {
472 case LOAD_ROOT_CONTEXT
:
473 case LOAD_ROOT_APP_CONTEXT
:
474 case LOAD_ROOT_PAYLOAD
:
476 dbg_printf("Filter warning: cannot load root, missing field name.\n");
480 switch (stack_top
->u
.ptr
.object_type
) {
482 dbg_printf("op load field s8\n");
483 stack_top
->u
.v
= *(int8_t *) stack_top
->u
.ptr
.ptr
;
484 stack_top
->type
= REG_S64
;
486 case OBJECT_TYPE_S16
:
490 dbg_printf("op load field s16\n");
491 tmp
= *(int16_t *) stack_top
->u
.ptr
.ptr
;
492 if (stack_top
->u
.ptr
.rev_bo
)
494 stack_top
->u
.v
= tmp
;
495 stack_top
->type
= REG_S64
;
498 case OBJECT_TYPE_S32
:
502 dbg_printf("op load field s32\n");
503 tmp
= *(int32_t *) stack_top
->u
.ptr
.ptr
;
504 if (stack_top
->u
.ptr
.rev_bo
)
506 stack_top
->u
.v
= tmp
;
507 stack_top
->type
= REG_S64
;
510 case OBJECT_TYPE_S64
:
514 dbg_printf("op load field s64\n");
515 tmp
= *(int64_t *) stack_top
->u
.ptr
.ptr
;
516 if (stack_top
->u
.ptr
.rev_bo
)
518 stack_top
->u
.v
= tmp
;
519 stack_top
->type
= REG_S64
;
523 dbg_printf("op load field u8\n");
524 stack_top
->u
.v
= *(uint8_t *) stack_top
->u
.ptr
.ptr
;
525 stack_top
->type
= REG_U64
;
527 case OBJECT_TYPE_U16
:
531 dbg_printf("op load field u16\n");
532 tmp
= *(uint16_t *) stack_top
->u
.ptr
.ptr
;
533 if (stack_top
->u
.ptr
.rev_bo
)
535 stack_top
->u
.v
= tmp
;
536 stack_top
->type
= REG_U64
;
539 case OBJECT_TYPE_U32
:
543 dbg_printf("op load field u32\n");
544 tmp
= *(uint32_t *) stack_top
->u
.ptr
.ptr
;
545 if (stack_top
->u
.ptr
.rev_bo
)
547 stack_top
->u
.v
= tmp
;
548 stack_top
->type
= REG_U64
;
551 case OBJECT_TYPE_U64
:
555 dbg_printf("op load field u64\n");
556 tmp
= *(uint64_t *) stack_top
->u
.ptr
.ptr
;
557 if (stack_top
->u
.ptr
.rev_bo
)
559 stack_top
->u
.v
= tmp
;
560 stack_top
->type
= REG_U64
;
563 case OBJECT_TYPE_DOUBLE
:
564 memcpy(&stack_top
->u
.d
,
565 stack_top
->u
.ptr
.ptr
,
566 sizeof(struct literal_double
));
567 stack_top
->type
= REG_DOUBLE
;
569 case OBJECT_TYPE_STRING
:
573 dbg_printf("op load field string\n");
574 str
= (const char *) stack_top
->u
.ptr
.ptr
;
575 stack_top
->u
.s
.str
= str
;
576 if (unlikely(!stack_top
->u
.s
.str
)) {
577 dbg_printf("Filter warning: loading a NULL string.\n");
581 stack_top
->u
.s
.seq_len
= SIZE_MAX
;
582 stack_top
->u
.s
.literal_type
=
583 ESTACK_STRING_LITERAL_TYPE_NONE
;
584 stack_top
->type
= REG_STRING
;
587 case OBJECT_TYPE_STRING_SEQUENCE
:
591 dbg_printf("op load field string sequence\n");
592 ptr
= stack_top
->u
.ptr
.ptr
;
593 stack_top
->u
.s
.seq_len
= *(unsigned long *) ptr
;
594 stack_top
->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
595 stack_top
->type
= REG_STRING
;
596 if (unlikely(!stack_top
->u
.s
.str
)) {
597 dbg_printf("Filter warning: loading a NULL sequence.\n");
601 stack_top
->u
.s
.literal_type
=
602 ESTACK_STRING_LITERAL_TYPE_NONE
;
605 case OBJECT_TYPE_DYNAMIC
:
607 * Dynamic types in context are looked up
608 * by context get index.
612 case OBJECT_TYPE_SEQUENCE
:
613 case OBJECT_TYPE_ARRAY
:
614 case OBJECT_TYPE_STRUCT
:
615 case OBJECT_TYPE_VARIANT
:
616 ERR("Sequences, arrays, struct and variant cannot be loaded (nested types).");
627 int lttng_bytecode_interpret_format_output(struct estack_entry
*ax
,
628 struct lttng_interpreter_output
*output
)
635 output
->type
= LTTNG_INTERPRETER_TYPE_S64
;
636 output
->u
.s
= ax
->u
.v
;
639 output
->type
= LTTNG_INTERPRETER_TYPE_U64
;
640 output
->u
.u
= (uint64_t) ax
->u
.v
;
643 output
->type
= LTTNG_INTERPRETER_TYPE_DOUBLE
;
644 output
->u
.d
= ax
->u
.d
;
647 output
->type
= LTTNG_INTERPRETER_TYPE_STRING
;
648 output
->u
.str
.str
= ax
->u
.s
.str
;
649 output
->u
.str
.len
= ax
->u
.s
.seq_len
;
652 switch (ax
->u
.ptr
.object_type
) {
654 case OBJECT_TYPE_S16
:
655 case OBJECT_TYPE_S32
:
656 case OBJECT_TYPE_S64
:
658 case OBJECT_TYPE_U16
:
659 case OBJECT_TYPE_U32
:
660 case OBJECT_TYPE_U64
:
661 case OBJECT_TYPE_DOUBLE
:
662 case OBJECT_TYPE_STRING
:
663 case OBJECT_TYPE_STRING_SEQUENCE
:
664 ret
= dynamic_load_field(ax
);
667 /* Retry after loading ptr into stack top. */
669 case OBJECT_TYPE_SEQUENCE
:
670 output
->type
= LTTNG_INTERPRETER_TYPE_SEQUENCE
;
671 output
->u
.sequence
.ptr
= *(const char **) (ax
->u
.ptr
.ptr
+ sizeof(unsigned long));
672 output
->u
.sequence
.nr_elem
= *(unsigned long *) ax
->u
.ptr
.ptr
;
673 output
->u
.sequence
.nested_type
= ax
->u
.ptr
.field
->type
.u
.sequence_nestable
.elem_type
;
675 case OBJECT_TYPE_ARRAY
:
676 /* Skip count (unsigned long) */
677 output
->type
= LTTNG_INTERPRETER_TYPE_SEQUENCE
;
678 output
->u
.sequence
.ptr
= *(const char **) (ax
->u
.ptr
.ptr
+ sizeof(unsigned long));
679 output
->u
.sequence
.nr_elem
= ax
->u
.ptr
.field
->type
.u
.array_nestable
.length
;
680 output
->u
.sequence
.nested_type
= ax
->u
.ptr
.field
->type
.u
.array_nestable
.elem_type
;
682 case OBJECT_TYPE_STRUCT
:
683 case OBJECT_TYPE_VARIANT
:
689 case REG_STAR_GLOB_STRING
:
695 return LTTNG_FILTER_RECORD_FLAG
;
699 * Return 0 (discard), or raise the 0x1 flag (log event).
700 * Currently, other flags are kept for future extensions and have no
704 uint64_t bytecode_interpret(void *interpreter_data
,
705 const char *interpreter_stack_data
,
706 struct lttng_interpreter_output
*output
)
708 struct bytecode_runtime
*bytecode
= interpreter_data
;
709 struct lttng_ctx
*ctx
= rcu_dereference(*bytecode
->p
.pctx
);
710 void *pc
, *next_pc
, *start_pc
;
713 struct estack _stack
;
714 struct estack
*stack
= &_stack
;
715 register int64_t ax
= 0, bx
= 0;
716 register enum entry_type ax_t
= REG_UNKNOWN
, bx_t
= REG_UNKNOWN
;
717 register int top
= FILTER_STACK_EMPTY
;
718 #ifndef INTERPRETER_USE_SWITCH
719 static void *dispatch
[NR_FILTER_OPS
] = {
720 [ FILTER_OP_UNKNOWN
] = &&LABEL_FILTER_OP_UNKNOWN
,
722 [ FILTER_OP_RETURN
] = &&LABEL_FILTER_OP_RETURN
,
725 [ FILTER_OP_MUL
] = &&LABEL_FILTER_OP_MUL
,
726 [ FILTER_OP_DIV
] = &&LABEL_FILTER_OP_DIV
,
727 [ FILTER_OP_MOD
] = &&LABEL_FILTER_OP_MOD
,
728 [ FILTER_OP_PLUS
] = &&LABEL_FILTER_OP_PLUS
,
729 [ FILTER_OP_MINUS
] = &&LABEL_FILTER_OP_MINUS
,
730 [ FILTER_OP_BIT_RSHIFT
] = &&LABEL_FILTER_OP_BIT_RSHIFT
,
731 [ FILTER_OP_BIT_LSHIFT
] = &&LABEL_FILTER_OP_BIT_LSHIFT
,
732 [ FILTER_OP_BIT_AND
] = &&LABEL_FILTER_OP_BIT_AND
,
733 [ FILTER_OP_BIT_OR
] = &&LABEL_FILTER_OP_BIT_OR
,
734 [ FILTER_OP_BIT_XOR
] = &&LABEL_FILTER_OP_BIT_XOR
,
736 /* binary comparators */
737 [ FILTER_OP_EQ
] = &&LABEL_FILTER_OP_EQ
,
738 [ FILTER_OP_NE
] = &&LABEL_FILTER_OP_NE
,
739 [ FILTER_OP_GT
] = &&LABEL_FILTER_OP_GT
,
740 [ FILTER_OP_LT
] = &&LABEL_FILTER_OP_LT
,
741 [ FILTER_OP_GE
] = &&LABEL_FILTER_OP_GE
,
742 [ FILTER_OP_LE
] = &&LABEL_FILTER_OP_LE
,
744 /* string binary comparator */
745 [ FILTER_OP_EQ_STRING
] = &&LABEL_FILTER_OP_EQ_STRING
,
746 [ FILTER_OP_NE_STRING
] = &&LABEL_FILTER_OP_NE_STRING
,
747 [ FILTER_OP_GT_STRING
] = &&LABEL_FILTER_OP_GT_STRING
,
748 [ FILTER_OP_LT_STRING
] = &&LABEL_FILTER_OP_LT_STRING
,
749 [ FILTER_OP_GE_STRING
] = &&LABEL_FILTER_OP_GE_STRING
,
750 [ FILTER_OP_LE_STRING
] = &&LABEL_FILTER_OP_LE_STRING
,
752 /* globbing pattern binary comparator */
753 [ FILTER_OP_EQ_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_EQ_STAR_GLOB_STRING
,
754 [ FILTER_OP_NE_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_NE_STAR_GLOB_STRING
,
756 /* s64 binary comparator */
757 [ FILTER_OP_EQ_S64
] = &&LABEL_FILTER_OP_EQ_S64
,
758 [ FILTER_OP_NE_S64
] = &&LABEL_FILTER_OP_NE_S64
,
759 [ FILTER_OP_GT_S64
] = &&LABEL_FILTER_OP_GT_S64
,
760 [ FILTER_OP_LT_S64
] = &&LABEL_FILTER_OP_LT_S64
,
761 [ FILTER_OP_GE_S64
] = &&LABEL_FILTER_OP_GE_S64
,
762 [ FILTER_OP_LE_S64
] = &&LABEL_FILTER_OP_LE_S64
,
764 /* double binary comparator */
765 [ FILTER_OP_EQ_DOUBLE
] = &&LABEL_FILTER_OP_EQ_DOUBLE
,
766 [ FILTER_OP_NE_DOUBLE
] = &&LABEL_FILTER_OP_NE_DOUBLE
,
767 [ FILTER_OP_GT_DOUBLE
] = &&LABEL_FILTER_OP_GT_DOUBLE
,
768 [ FILTER_OP_LT_DOUBLE
] = &&LABEL_FILTER_OP_LT_DOUBLE
,
769 [ FILTER_OP_GE_DOUBLE
] = &&LABEL_FILTER_OP_GE_DOUBLE
,
770 [ FILTER_OP_LE_DOUBLE
] = &&LABEL_FILTER_OP_LE_DOUBLE
,
772 /* Mixed S64-double binary comparators */
773 [ FILTER_OP_EQ_DOUBLE_S64
] = &&LABEL_FILTER_OP_EQ_DOUBLE_S64
,
774 [ FILTER_OP_NE_DOUBLE_S64
] = &&LABEL_FILTER_OP_NE_DOUBLE_S64
,
775 [ FILTER_OP_GT_DOUBLE_S64
] = &&LABEL_FILTER_OP_GT_DOUBLE_S64
,
776 [ FILTER_OP_LT_DOUBLE_S64
] = &&LABEL_FILTER_OP_LT_DOUBLE_S64
,
777 [ FILTER_OP_GE_DOUBLE_S64
] = &&LABEL_FILTER_OP_GE_DOUBLE_S64
,
778 [ FILTER_OP_LE_DOUBLE_S64
] = &&LABEL_FILTER_OP_LE_DOUBLE_S64
,
780 [ FILTER_OP_EQ_S64_DOUBLE
] = &&LABEL_FILTER_OP_EQ_S64_DOUBLE
,
781 [ FILTER_OP_NE_S64_DOUBLE
] = &&LABEL_FILTER_OP_NE_S64_DOUBLE
,
782 [ FILTER_OP_GT_S64_DOUBLE
] = &&LABEL_FILTER_OP_GT_S64_DOUBLE
,
783 [ FILTER_OP_LT_S64_DOUBLE
] = &&LABEL_FILTER_OP_LT_S64_DOUBLE
,
784 [ FILTER_OP_GE_S64_DOUBLE
] = &&LABEL_FILTER_OP_GE_S64_DOUBLE
,
785 [ FILTER_OP_LE_S64_DOUBLE
] = &&LABEL_FILTER_OP_LE_S64_DOUBLE
,
788 [ FILTER_OP_UNARY_PLUS
] = &&LABEL_FILTER_OP_UNARY_PLUS
,
789 [ FILTER_OP_UNARY_MINUS
] = &&LABEL_FILTER_OP_UNARY_MINUS
,
790 [ FILTER_OP_UNARY_NOT
] = &&LABEL_FILTER_OP_UNARY_NOT
,
791 [ FILTER_OP_UNARY_PLUS_S64
] = &&LABEL_FILTER_OP_UNARY_PLUS_S64
,
792 [ FILTER_OP_UNARY_MINUS_S64
] = &&LABEL_FILTER_OP_UNARY_MINUS_S64
,
793 [ FILTER_OP_UNARY_NOT_S64
] = &&LABEL_FILTER_OP_UNARY_NOT_S64
,
794 [ FILTER_OP_UNARY_PLUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_PLUS_DOUBLE
,
795 [ FILTER_OP_UNARY_MINUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_MINUS_DOUBLE
,
796 [ FILTER_OP_UNARY_NOT_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_NOT_DOUBLE
,
799 [ FILTER_OP_AND
] = &&LABEL_FILTER_OP_AND
,
800 [ FILTER_OP_OR
] = &&LABEL_FILTER_OP_OR
,
803 [ FILTER_OP_LOAD_FIELD_REF
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF
,
804 [ FILTER_OP_LOAD_FIELD_REF_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_STRING
,
805 [ FILTER_OP_LOAD_FIELD_REF_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_SEQUENCE
,
806 [ FILTER_OP_LOAD_FIELD_REF_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_S64
,
807 [ FILTER_OP_LOAD_FIELD_REF_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_DOUBLE
,
809 /* load from immediate operand */
810 [ FILTER_OP_LOAD_STRING
] = &&LABEL_FILTER_OP_LOAD_STRING
,
811 [ FILTER_OP_LOAD_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_LOAD_STAR_GLOB_STRING
,
812 [ FILTER_OP_LOAD_S64
] = &&LABEL_FILTER_OP_LOAD_S64
,
813 [ FILTER_OP_LOAD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_DOUBLE
,
816 [ FILTER_OP_CAST_TO_S64
] = &&LABEL_FILTER_OP_CAST_TO_S64
,
817 [ FILTER_OP_CAST_DOUBLE_TO_S64
] = &&LABEL_FILTER_OP_CAST_DOUBLE_TO_S64
,
818 [ FILTER_OP_CAST_NOP
] = &&LABEL_FILTER_OP_CAST_NOP
,
820 /* get context ref */
821 [ FILTER_OP_GET_CONTEXT_REF
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF
,
822 [ FILTER_OP_GET_CONTEXT_REF_STRING
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_STRING
,
823 [ FILTER_OP_GET_CONTEXT_REF_S64
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_S64
,
824 [ FILTER_OP_GET_CONTEXT_REF_DOUBLE
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_DOUBLE
,
826 /* Instructions for recursive traversal through composed types. */
827 [ FILTER_OP_GET_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_CONTEXT_ROOT
,
828 [ FILTER_OP_GET_APP_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_APP_CONTEXT_ROOT
,
829 [ FILTER_OP_GET_PAYLOAD_ROOT
] = &&LABEL_FILTER_OP_GET_PAYLOAD_ROOT
,
831 [ FILTER_OP_GET_SYMBOL
] = &&LABEL_FILTER_OP_GET_SYMBOL
,
832 [ FILTER_OP_GET_SYMBOL_FIELD
] = &&LABEL_FILTER_OP_GET_SYMBOL_FIELD
,
833 [ FILTER_OP_GET_INDEX_U16
] = &&LABEL_FILTER_OP_GET_INDEX_U16
,
834 [ FILTER_OP_GET_INDEX_U64
] = &&LABEL_FILTER_OP_GET_INDEX_U64
,
836 [ FILTER_OP_LOAD_FIELD
] = &&LABEL_FILTER_OP_LOAD_FIELD
,
837 [ FILTER_OP_LOAD_FIELD_S8
] = &&LABEL_FILTER_OP_LOAD_FIELD_S8
,
838 [ FILTER_OP_LOAD_FIELD_S16
] = &&LABEL_FILTER_OP_LOAD_FIELD_S16
,
839 [ FILTER_OP_LOAD_FIELD_S32
] = &&LABEL_FILTER_OP_LOAD_FIELD_S32
,
840 [ FILTER_OP_LOAD_FIELD_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_S64
,
841 [ FILTER_OP_LOAD_FIELD_U8
] = &&LABEL_FILTER_OP_LOAD_FIELD_U8
,
842 [ FILTER_OP_LOAD_FIELD_U16
] = &&LABEL_FILTER_OP_LOAD_FIELD_U16
,
843 [ FILTER_OP_LOAD_FIELD_U32
] = &&LABEL_FILTER_OP_LOAD_FIELD_U32
,
844 [ FILTER_OP_LOAD_FIELD_U64
] = &&LABEL_FILTER_OP_LOAD_FIELD_U64
,
845 [ FILTER_OP_LOAD_FIELD_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_STRING
,
846 [ FILTER_OP_LOAD_FIELD_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_SEQUENCE
,
847 [ FILTER_OP_LOAD_FIELD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_DOUBLE
,
849 [ FILTER_OP_UNARY_BIT_NOT
] = &&LABEL_FILTER_OP_UNARY_BIT_NOT
,
851 [ FILTER_OP_RETURN_S64
] = &&LABEL_FILTER_OP_RETURN_S64
,
853 #endif /* #ifndef INTERPRETER_USE_SWITCH */
857 OP(FILTER_OP_UNKNOWN
):
858 OP(FILTER_OP_LOAD_FIELD_REF
):
859 #ifdef INTERPRETER_USE_SWITCH
861 #endif /* INTERPRETER_USE_SWITCH */
862 ERR("unknown bytecode op %u",
863 (unsigned int) *(filter_opcode_t
*) pc
);
867 OP(FILTER_OP_RETURN
):
868 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
869 /* Handle dynamic typing. */
870 switch (estack_ax_t
) {
873 retval
= !!estack_ax_v
;
884 case REG_STAR_GLOB_STRING
:
893 OP(FILTER_OP_RETURN_S64
):
894 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
895 retval
= !!estack_ax_v
;
905 ERR("unsupported bytecode op %u",
906 (unsigned int) *(filter_opcode_t
*) pc
);
912 /* Dynamic typing. */
913 switch (estack_ax_t
) {
914 case REG_S64
: /* Fall-through */
916 switch (estack_bx_t
) {
917 case REG_S64
: /* Fall-through */
919 JUMP_TO(FILTER_OP_EQ_S64
);
921 JUMP_TO(FILTER_OP_EQ_DOUBLE_S64
);
922 case REG_STRING
: /* Fall-through */
923 case REG_STAR_GLOB_STRING
:
927 ERR("Unknown filter register type (%d)",
934 switch (estack_bx_t
) {
935 case REG_S64
: /* Fall-through */
937 JUMP_TO(FILTER_OP_EQ_S64_DOUBLE
);
939 JUMP_TO(FILTER_OP_EQ_DOUBLE
);
940 case REG_STRING
: /* Fall-through */
941 case REG_STAR_GLOB_STRING
:
945 ERR("Unknown filter register type (%d)",
952 switch (estack_bx_t
) {
953 case REG_S64
: /* Fall-through */
954 case REG_U64
: /* Fall-through */
959 JUMP_TO(FILTER_OP_EQ_STRING
);
960 case REG_STAR_GLOB_STRING
:
961 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
963 ERR("Unknown filter register type (%d)",
969 case REG_STAR_GLOB_STRING
:
970 switch (estack_bx_t
) {
971 case REG_S64
: /* Fall-through */
972 case REG_U64
: /* Fall-through */
977 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
978 case REG_STAR_GLOB_STRING
:
982 ERR("Unknown filter register type (%d)",
989 ERR("Unknown filter register type (%d)",
997 /* Dynamic typing. */
998 switch (estack_ax_t
) {
999 case REG_S64
: /* Fall-through */
1001 switch (estack_bx_t
) {
1002 case REG_S64
: /* Fall-through */
1004 JUMP_TO(FILTER_OP_NE_S64
);
1006 JUMP_TO(FILTER_OP_NE_DOUBLE_S64
);
1007 case REG_STRING
: /* Fall-through */
1008 case REG_STAR_GLOB_STRING
:
1012 ERR("Unknown filter register type (%d)",
1019 switch (estack_bx_t
) {
1020 case REG_S64
: /* Fall-through */
1022 JUMP_TO(FILTER_OP_NE_S64_DOUBLE
);
1024 JUMP_TO(FILTER_OP_NE_DOUBLE
);
1025 case REG_STRING
: /* Fall-through */
1026 case REG_STAR_GLOB_STRING
:
1030 ERR("Unknown filter register type (%d)",
1037 switch (estack_bx_t
) {
1038 case REG_S64
: /* Fall-through */
1044 JUMP_TO(FILTER_OP_NE_STRING
);
1045 case REG_STAR_GLOB_STRING
:
1046 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
1048 ERR("Unknown filter register type (%d)",
1054 case REG_STAR_GLOB_STRING
:
1055 switch (estack_bx_t
) {
1056 case REG_S64
: /* Fall-through */
1062 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
1063 case REG_STAR_GLOB_STRING
:
1067 ERR("Unknown filter register type (%d)",
1074 ERR("Unknown filter register type (%d)",
1082 /* Dynamic typing. */
1083 switch (estack_ax_t
) {
1084 case REG_S64
: /* Fall-through */
1086 switch (estack_bx_t
) {
1087 case REG_S64
: /* Fall-through */
1089 JUMP_TO(FILTER_OP_GT_S64
);
1091 JUMP_TO(FILTER_OP_GT_DOUBLE_S64
);
1092 case REG_STRING
: /* Fall-through */
1093 case REG_STAR_GLOB_STRING
:
1097 ERR("Unknown filter register type (%d)",
1104 switch (estack_bx_t
) {
1105 case REG_S64
: /* Fall-through */
1107 JUMP_TO(FILTER_OP_GT_S64_DOUBLE
);
1109 JUMP_TO(FILTER_OP_GT_DOUBLE
);
1110 case REG_STRING
: /* Fall-through */
1111 case REG_STAR_GLOB_STRING
:
1115 ERR("Unknown filter register type (%d)",
1122 switch (estack_bx_t
) {
1123 case REG_S64
: /* Fall-through */
1124 case REG_U64
: /* Fall-through */
1125 case REG_DOUBLE
: /* Fall-through */
1126 case REG_STAR_GLOB_STRING
:
1130 JUMP_TO(FILTER_OP_GT_STRING
);
1132 ERR("Unknown filter register type (%d)",
1139 ERR("Unknown filter register type (%d)",
1147 /* Dynamic typing. */
1148 switch (estack_ax_t
) {
1149 case REG_S64
: /* Fall-through */
1151 switch (estack_bx_t
) {
1152 case REG_S64
: /* Fall-through */
1154 JUMP_TO(FILTER_OP_LT_S64
);
1156 JUMP_TO(FILTER_OP_LT_DOUBLE_S64
);
1157 case REG_STRING
: /* Fall-through */
1158 case REG_STAR_GLOB_STRING
:
1162 ERR("Unknown filter register type (%d)",
1169 switch (estack_bx_t
) {
1170 case REG_S64
: /* Fall-through */
1172 JUMP_TO(FILTER_OP_LT_S64_DOUBLE
);
1174 JUMP_TO(FILTER_OP_LT_DOUBLE
);
1175 case REG_STRING
: /* Fall-through */
1176 case REG_STAR_GLOB_STRING
:
1180 ERR("Unknown filter register type (%d)",
1187 switch (estack_bx_t
) {
1188 case REG_S64
: /* Fall-through */
1189 case REG_U64
: /* Fall-through */
1190 case REG_DOUBLE
: /* Fall-through */
1191 case REG_STAR_GLOB_STRING
:
1195 JUMP_TO(FILTER_OP_LT_STRING
);
1197 ERR("Unknown filter register type (%d)",
1204 ERR("Unknown filter register type (%d)",
1212 /* Dynamic typing. */
1213 switch (estack_ax_t
) {
1214 case REG_S64
: /* Fall-through */
1216 switch (estack_bx_t
) {
1217 case REG_S64
: /* Fall-through */
1219 JUMP_TO(FILTER_OP_GE_S64
);
1221 JUMP_TO(FILTER_OP_GE_DOUBLE_S64
);
1222 case REG_STRING
: /* Fall-through */
1223 case REG_STAR_GLOB_STRING
:
1227 ERR("Unknown filter register type (%d)",
1234 switch (estack_bx_t
) {
1235 case REG_S64
: /* Fall-through */
1237 JUMP_TO(FILTER_OP_GE_S64_DOUBLE
);
1239 JUMP_TO(FILTER_OP_GE_DOUBLE
);
1240 case REG_STRING
: /* Fall-through */
1241 case REG_STAR_GLOB_STRING
:
1245 ERR("Unknown filter register type (%d)",
1252 switch (estack_bx_t
) {
1253 case REG_S64
: /* Fall-through */
1254 case REG_U64
: /* Fall-through */
1255 case REG_DOUBLE
: /* Fall-through */
1256 case REG_STAR_GLOB_STRING
:
1260 JUMP_TO(FILTER_OP_GE_STRING
);
1262 ERR("Unknown filter register type (%d)",
1269 ERR("Unknown filter register type (%d)",
1277 /* Dynamic typing. */
1278 switch (estack_ax_t
) {
1279 case REG_S64
: /* Fall-through */
1281 switch (estack_bx_t
) {
1282 case REG_S64
: /* Fall-through */
1284 JUMP_TO(FILTER_OP_LE_S64
);
1286 JUMP_TO(FILTER_OP_LE_DOUBLE_S64
);
1287 case REG_STRING
: /* Fall-through */
1288 case REG_STAR_GLOB_STRING
:
1292 ERR("Unknown filter register type (%d)",
1299 switch (estack_bx_t
) {
1300 case REG_S64
: /* Fall-through */
1302 JUMP_TO(FILTER_OP_LE_S64_DOUBLE
);
1304 JUMP_TO(FILTER_OP_LE_DOUBLE
);
1305 case REG_STRING
: /* Fall-through */
1306 case REG_STAR_GLOB_STRING
:
1310 ERR("Unknown filter register type (%d)",
1317 switch (estack_bx_t
) {
1318 case REG_S64
: /* Fall-through */
1319 case REG_U64
: /* Fall-through */
1320 case REG_DOUBLE
: /* Fall-through */
1321 case REG_STAR_GLOB_STRING
:
1325 JUMP_TO(FILTER_OP_LE_STRING
);
1327 ERR("Unknown filter register type (%d)",
1334 ERR("Unknown filter register type (%d)",
1341 OP(FILTER_OP_EQ_STRING
):
1345 res
= (stack_strcmp(stack
, top
, "==") == 0);
1346 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1348 estack_ax_t
= REG_S64
;
1349 next_pc
+= sizeof(struct binary_op
);
1352 OP(FILTER_OP_NE_STRING
):
1356 res
= (stack_strcmp(stack
, top
, "!=") != 0);
1357 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1359 estack_ax_t
= REG_S64
;
1360 next_pc
+= sizeof(struct binary_op
);
1363 OP(FILTER_OP_GT_STRING
):
1367 res
= (stack_strcmp(stack
, top
, ">") > 0);
1368 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1370 estack_ax_t
= REG_S64
;
1371 next_pc
+= sizeof(struct binary_op
);
1374 OP(FILTER_OP_LT_STRING
):
1378 res
= (stack_strcmp(stack
, top
, "<") < 0);
1379 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1381 estack_ax_t
= REG_S64
;
1382 next_pc
+= sizeof(struct binary_op
);
1385 OP(FILTER_OP_GE_STRING
):
1389 res
= (stack_strcmp(stack
, top
, ">=") >= 0);
1390 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1392 estack_ax_t
= REG_S64
;
1393 next_pc
+= sizeof(struct binary_op
);
1396 OP(FILTER_OP_LE_STRING
):
1400 res
= (stack_strcmp(stack
, top
, "<=") <= 0);
1401 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1403 estack_ax_t
= REG_S64
;
1404 next_pc
+= sizeof(struct binary_op
);
1408 OP(FILTER_OP_EQ_STAR_GLOB_STRING
):
1412 res
= (stack_star_glob_match(stack
, top
, "==") == 0);
1413 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1415 estack_ax_t
= REG_S64
;
1416 next_pc
+= sizeof(struct binary_op
);
1419 OP(FILTER_OP_NE_STAR_GLOB_STRING
):
1423 res
= (stack_star_glob_match(stack
, top
, "!=") != 0);
1424 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1426 estack_ax_t
= REG_S64
;
1427 next_pc
+= sizeof(struct binary_op
);
1431 OP(FILTER_OP_EQ_S64
):
1435 res
= (estack_bx_v
== estack_ax_v
);
1436 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1438 estack_ax_t
= REG_S64
;
1439 next_pc
+= sizeof(struct binary_op
);
1442 OP(FILTER_OP_NE_S64
):
1446 res
= (estack_bx_v
!= estack_ax_v
);
1447 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1449 estack_ax_t
= REG_S64
;
1450 next_pc
+= sizeof(struct binary_op
);
1453 OP(FILTER_OP_GT_S64
):
1457 res
= (estack_bx_v
> estack_ax_v
);
1458 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1460 estack_ax_t
= REG_S64
;
1461 next_pc
+= sizeof(struct binary_op
);
1464 OP(FILTER_OP_LT_S64
):
1468 res
= (estack_bx_v
< estack_ax_v
);
1469 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1471 estack_ax_t
= REG_S64
;
1472 next_pc
+= sizeof(struct binary_op
);
1475 OP(FILTER_OP_GE_S64
):
1479 res
= (estack_bx_v
>= estack_ax_v
);
1480 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1482 estack_ax_t
= REG_S64
;
1483 next_pc
+= sizeof(struct binary_op
);
1486 OP(FILTER_OP_LE_S64
):
1490 res
= (estack_bx_v
<= 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
);
1498 OP(FILTER_OP_EQ_DOUBLE
):
1502 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax(stack
, top
)->u
.d
);
1503 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1505 estack_ax_t
= REG_S64
;
1506 next_pc
+= sizeof(struct binary_op
);
1509 OP(FILTER_OP_NE_DOUBLE
):
1513 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax(stack
, top
)->u
.d
);
1514 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1516 estack_ax_t
= REG_S64
;
1517 next_pc
+= sizeof(struct binary_op
);
1520 OP(FILTER_OP_GT_DOUBLE
):
1524 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax(stack
, top
)->u
.d
);
1525 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1527 estack_ax_t
= REG_S64
;
1528 next_pc
+= sizeof(struct binary_op
);
1531 OP(FILTER_OP_LT_DOUBLE
):
1535 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax(stack
, top
)->u
.d
);
1536 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1538 estack_ax_t
= REG_S64
;
1539 next_pc
+= sizeof(struct binary_op
);
1542 OP(FILTER_OP_GE_DOUBLE
):
1546 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax(stack
, top
)->u
.d
);
1547 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1549 estack_ax_t
= REG_S64
;
1550 next_pc
+= sizeof(struct binary_op
);
1553 OP(FILTER_OP_LE_DOUBLE
):
1557 res
= (estack_bx(stack
, top
)->u
.d
<= 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
);
1565 /* Mixed S64-double binary comparators */
1566 OP(FILTER_OP_EQ_DOUBLE_S64
):
1570 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax_v
);
1571 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1573 estack_ax_t
= REG_S64
;
1574 next_pc
+= sizeof(struct binary_op
);
1577 OP(FILTER_OP_NE_DOUBLE_S64
):
1581 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax_v
);
1582 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1584 estack_ax_t
= REG_S64
;
1585 next_pc
+= sizeof(struct binary_op
);
1588 OP(FILTER_OP_GT_DOUBLE_S64
):
1592 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax_v
);
1593 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1595 estack_ax_t
= REG_S64
;
1596 next_pc
+= sizeof(struct binary_op
);
1599 OP(FILTER_OP_LT_DOUBLE_S64
):
1603 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax_v
);
1604 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1606 estack_ax_t
= REG_S64
;
1607 next_pc
+= sizeof(struct binary_op
);
1610 OP(FILTER_OP_GE_DOUBLE_S64
):
1614 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax_v
);
1615 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1617 estack_ax_t
= REG_S64
;
1618 next_pc
+= sizeof(struct binary_op
);
1621 OP(FILTER_OP_LE_DOUBLE_S64
):
1625 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax_v
);
1626 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1628 estack_ax_t
= REG_S64
;
1629 next_pc
+= sizeof(struct binary_op
);
1633 OP(FILTER_OP_EQ_S64_DOUBLE
):
1637 res
= (estack_bx_v
== estack_ax(stack
, top
)->u
.d
);
1638 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1640 estack_ax_t
= REG_S64
;
1641 next_pc
+= sizeof(struct binary_op
);
1644 OP(FILTER_OP_NE_S64_DOUBLE
):
1648 res
= (estack_bx_v
!= estack_ax(stack
, top
)->u
.d
);
1649 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1651 estack_ax_t
= REG_S64
;
1652 next_pc
+= sizeof(struct binary_op
);
1655 OP(FILTER_OP_GT_S64_DOUBLE
):
1659 res
= (estack_bx_v
> estack_ax(stack
, top
)->u
.d
);
1660 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1662 estack_ax_t
= REG_S64
;
1663 next_pc
+= sizeof(struct binary_op
);
1666 OP(FILTER_OP_LT_S64_DOUBLE
):
1670 res
= (estack_bx_v
< estack_ax(stack
, top
)->u
.d
);
1671 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1673 estack_ax_t
= REG_S64
;
1674 next_pc
+= sizeof(struct binary_op
);
1677 OP(FILTER_OP_GE_S64_DOUBLE
):
1681 res
= (estack_bx_v
>= estack_ax(stack
, top
)->u
.d
);
1682 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1684 estack_ax_t
= REG_S64
;
1685 next_pc
+= sizeof(struct binary_op
);
1688 OP(FILTER_OP_LE_S64_DOUBLE
):
1692 res
= (estack_bx_v
<= estack_ax(stack
, top
)->u
.d
);
1693 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1695 estack_ax_t
= REG_S64
;
1696 next_pc
+= sizeof(struct binary_op
);
1699 OP(FILTER_OP_BIT_RSHIFT
):
1703 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1708 /* Catch undefined behavior. */
1709 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1713 res
= ((uint64_t) estack_bx_v
>> (uint32_t) estack_ax_v
);
1714 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1716 estack_ax_t
= REG_U64
;
1717 next_pc
+= sizeof(struct binary_op
);
1720 OP(FILTER_OP_BIT_LSHIFT
):
1724 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1729 /* Catch undefined behavior. */
1730 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1734 res
= ((uint64_t) estack_bx_v
<< (uint32_t) estack_ax_v
);
1735 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1737 estack_ax_t
= REG_U64
;
1738 next_pc
+= sizeof(struct binary_op
);
1741 OP(FILTER_OP_BIT_AND
):
1745 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1750 res
= ((uint64_t) estack_bx_v
& (uint64_t) estack_ax_v
);
1751 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1753 estack_ax_t
= REG_U64
;
1754 next_pc
+= sizeof(struct binary_op
);
1757 OP(FILTER_OP_BIT_OR
):
1761 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1766 res
= ((uint64_t) estack_bx_v
| (uint64_t) estack_ax_v
);
1767 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1769 estack_ax_t
= REG_U64
;
1770 next_pc
+= sizeof(struct binary_op
);
1773 OP(FILTER_OP_BIT_XOR
):
1777 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1782 res
= ((uint64_t) estack_bx_v
^ (uint64_t) estack_ax_v
);
1783 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1785 estack_ax_t
= REG_U64
;
1786 next_pc
+= sizeof(struct binary_op
);
1791 OP(FILTER_OP_UNARY_PLUS
):
1793 /* Dynamic typing. */
1794 switch (estack_ax_t
) {
1795 case REG_S64
: /* Fall-through. */
1797 JUMP_TO(FILTER_OP_UNARY_PLUS_S64
);
1799 JUMP_TO(FILTER_OP_UNARY_PLUS_DOUBLE
);
1800 case REG_STRING
: /* Fall-through */
1801 case REG_STAR_GLOB_STRING
:
1805 ERR("Unknown filter register type (%d)",
1811 OP(FILTER_OP_UNARY_MINUS
):
1813 /* Dynamic typing. */
1814 switch (estack_ax_t
) {
1815 case REG_S64
: /* Fall-through. */
1817 JUMP_TO(FILTER_OP_UNARY_MINUS_S64
);
1819 JUMP_TO(FILTER_OP_UNARY_MINUS_DOUBLE
);
1820 case REG_STRING
: /* Fall-through */
1821 case REG_STAR_GLOB_STRING
:
1825 ERR("Unknown filter register type (%d)",
1831 OP(FILTER_OP_UNARY_NOT
):
1833 /* Dynamic typing. */
1834 switch (estack_ax_t
) {
1835 case REG_S64
: /* Fall-through. */
1837 JUMP_TO(FILTER_OP_UNARY_NOT_S64
);
1839 JUMP_TO(FILTER_OP_UNARY_NOT_DOUBLE
);
1840 case REG_STRING
: /* Fall-through */
1841 case REG_STAR_GLOB_STRING
:
1845 ERR("Unknown filter register type (%d)",
1850 next_pc
+= sizeof(struct unary_op
);
1854 OP(FILTER_OP_UNARY_BIT_NOT
):
1856 /* Dynamic typing. */
1857 if (!IS_INTEGER_REGISTER(estack_ax_t
)) {
1862 estack_ax_v
= ~(uint64_t) estack_ax_v
;
1863 estack_ax_t
= REG_U64
;
1864 next_pc
+= sizeof(struct unary_op
);
1868 OP(FILTER_OP_UNARY_PLUS_S64
):
1869 OP(FILTER_OP_UNARY_PLUS_DOUBLE
):
1871 next_pc
+= sizeof(struct unary_op
);
1874 OP(FILTER_OP_UNARY_MINUS_S64
):
1876 estack_ax_v
= -estack_ax_v
;
1877 next_pc
+= sizeof(struct unary_op
);
1880 OP(FILTER_OP_UNARY_MINUS_DOUBLE
):
1882 estack_ax(stack
, top
)->u
.d
= -estack_ax(stack
, top
)->u
.d
;
1883 next_pc
+= sizeof(struct unary_op
);
1886 OP(FILTER_OP_UNARY_NOT_S64
):
1888 estack_ax_v
= !estack_ax_v
;
1889 estack_ax_t
= REG_S64
;
1890 next_pc
+= sizeof(struct unary_op
);
1893 OP(FILTER_OP_UNARY_NOT_DOUBLE
):
1895 estack_ax_v
= !estack_ax(stack
, top
)->u
.d
;
1896 estack_ax_t
= REG_S64
;
1897 next_pc
+= sizeof(struct unary_op
);
1904 struct logical_op
*insn
= (struct logical_op
*) pc
;
1906 if (estack_ax_t
!= REG_S64
&& estack_ax_t
!= REG_U64
) {
1910 /* If AX is 0, skip and evaluate to 0 */
1911 if (unlikely(estack_ax_v
== 0)) {
1912 dbg_printf("Jumping to bytecode offset %u\n",
1913 (unsigned int) insn
->skip_offset
);
1914 next_pc
= start_pc
+ insn
->skip_offset
;
1916 /* Pop 1 when jump not taken */
1917 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1918 next_pc
+= sizeof(struct logical_op
);
1924 struct logical_op
*insn
= (struct logical_op
*) pc
;
1926 if (estack_ax_t
!= REG_S64
&& estack_ax_t
!= REG_U64
) {
1930 /* If AX is nonzero, skip and evaluate to 1 */
1931 if (unlikely(estack_ax_v
!= 0)) {
1933 dbg_printf("Jumping to bytecode offset %u\n",
1934 (unsigned int) insn
->skip_offset
);
1935 next_pc
= start_pc
+ insn
->skip_offset
;
1937 /* Pop 1 when jump not taken */
1938 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1939 next_pc
+= sizeof(struct logical_op
);
1945 /* load field ref */
1946 OP(FILTER_OP_LOAD_FIELD_REF_STRING
):
1948 struct load_op
*insn
= (struct load_op
*) pc
;
1949 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1951 dbg_printf("load field ref offset %u type string\n",
1953 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1954 estack_ax(stack
, top
)->u
.s
.str
=
1955 *(const char * const *) &interpreter_stack_data
[ref
->offset
];
1956 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1957 dbg_printf("Filter warning: loading a NULL string.\n");
1961 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1962 estack_ax(stack
, top
)->u
.s
.literal_type
=
1963 ESTACK_STRING_LITERAL_TYPE_NONE
;
1964 estack_ax_t
= REG_STRING
;
1965 dbg_printf("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1966 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1970 OP(FILTER_OP_LOAD_FIELD_REF_SEQUENCE
):
1972 struct load_op
*insn
= (struct load_op
*) pc
;
1973 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1975 dbg_printf("load field ref offset %u type sequence\n",
1977 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1978 estack_ax(stack
, top
)->u
.s
.seq_len
=
1979 *(unsigned long *) &interpreter_stack_data
[ref
->offset
];
1980 estack_ax(stack
, top
)->u
.s
.str
=
1981 *(const char **) (&interpreter_stack_data
[ref
->offset
1982 + sizeof(unsigned long)]);
1983 estack_ax_t
= REG_STRING
;
1984 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1985 dbg_printf("Filter warning: loading a NULL sequence.\n");
1989 estack_ax(stack
, top
)->u
.s
.literal_type
=
1990 ESTACK_STRING_LITERAL_TYPE_NONE
;
1991 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1995 OP(FILTER_OP_LOAD_FIELD_REF_S64
):
1997 struct load_op
*insn
= (struct load_op
*) pc
;
1998 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2000 dbg_printf("load field ref offset %u type s64\n",
2002 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2004 ((struct literal_numeric
*) &interpreter_stack_data
[ref
->offset
])->v
;
2005 estack_ax_t
= REG_S64
;
2006 dbg_printf("ref load s64 %" PRIi64
"\n", estack_ax_v
);
2007 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2011 OP(FILTER_OP_LOAD_FIELD_REF_DOUBLE
):
2013 struct load_op
*insn
= (struct load_op
*) pc
;
2014 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2016 dbg_printf("load field ref offset %u type double\n",
2018 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2019 memcpy(&estack_ax(stack
, top
)->u
.d
, &interpreter_stack_data
[ref
->offset
],
2020 sizeof(struct literal_double
));
2021 estack_ax_t
= REG_DOUBLE
;
2022 dbg_printf("ref load double %g\n", estack_ax(stack
, top
)->u
.d
);
2023 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2027 /* load from immediate operand */
2028 OP(FILTER_OP_LOAD_STRING
):
2030 struct load_op
*insn
= (struct load_op
*) pc
;
2032 dbg_printf("load string %s\n", insn
->data
);
2033 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2034 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
2035 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2036 estack_ax(stack
, top
)->u
.s
.literal_type
=
2037 ESTACK_STRING_LITERAL_TYPE_PLAIN
;
2038 estack_ax_t
= REG_STRING
;
2039 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
2043 OP(FILTER_OP_LOAD_STAR_GLOB_STRING
):
2045 struct load_op
*insn
= (struct load_op
*) pc
;
2047 dbg_printf("load globbing pattern %s\n", insn
->data
);
2048 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2049 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
2050 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2051 estack_ax(stack
, top
)->u
.s
.literal_type
=
2052 ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
;
2053 estack_ax_t
= REG_STAR_GLOB_STRING
;
2054 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
2058 OP(FILTER_OP_LOAD_S64
):
2060 struct load_op
*insn
= (struct load_op
*) pc
;
2062 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2063 estack_ax_v
= ((struct literal_numeric
*) insn
->data
)->v
;
2064 estack_ax_t
= REG_S64
;
2065 dbg_printf("load s64 %" PRIi64
"\n", estack_ax_v
);
2066 next_pc
+= sizeof(struct load_op
)
2067 + sizeof(struct literal_numeric
);
2071 OP(FILTER_OP_LOAD_DOUBLE
):
2073 struct load_op
*insn
= (struct load_op
*) pc
;
2075 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2076 memcpy(&estack_ax(stack
, top
)->u
.d
, insn
->data
,
2077 sizeof(struct literal_double
));
2078 estack_ax_t
= REG_DOUBLE
;
2079 dbg_printf("load double %g\n", estack_ax(stack
, top
)->u
.d
);
2080 next_pc
+= sizeof(struct load_op
)
2081 + sizeof(struct literal_double
);
2086 OP(FILTER_OP_CAST_TO_S64
):
2088 /* Dynamic typing. */
2089 switch (estack_ax_t
) {
2091 JUMP_TO(FILTER_OP_CAST_NOP
);
2093 JUMP_TO(FILTER_OP_CAST_DOUBLE_TO_S64
);
2095 estack_ax_t
= REG_S64
;
2096 next_pc
+= sizeof(struct cast_op
);
2097 case REG_STRING
: /* Fall-through */
2098 case REG_STAR_GLOB_STRING
:
2102 ERR("Unknown filter register type (%d)",
2109 OP(FILTER_OP_CAST_DOUBLE_TO_S64
):
2111 estack_ax_v
= (int64_t) estack_ax(stack
, top
)->u
.d
;
2112 estack_ax_t
= REG_S64
;
2113 next_pc
+= sizeof(struct cast_op
);
2117 OP(FILTER_OP_CAST_NOP
):
2119 next_pc
+= sizeof(struct cast_op
);
2123 /* get context ref */
2124 OP(FILTER_OP_GET_CONTEXT_REF
):
2126 struct load_op
*insn
= (struct load_op
*) pc
;
2127 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2128 struct lttng_ctx_field
*ctx_field
;
2129 struct lttng_ctx_value v
;
2131 dbg_printf("get context ref offset %u type dynamic\n",
2133 ctx_field
= &ctx
->fields
[ref
->offset
];
2134 ctx_field
->get_value(ctx_field
, &v
);
2135 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2137 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
2140 case LTTNG_UST_DYNAMIC_TYPE_S64
:
2141 estack_ax_v
= v
.u
.s64
;
2142 estack_ax_t
= REG_S64
;
2143 dbg_printf("ref get context dynamic s64 %" PRIi64
"\n", estack_ax_v
);
2145 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
2146 estack_ax(stack
, top
)->u
.d
= v
.u
.d
;
2147 estack_ax_t
= REG_DOUBLE
;
2148 dbg_printf("ref get context dynamic double %g\n", estack_ax(stack
, top
)->u
.d
);
2150 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
2151 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2152 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2153 dbg_printf("Filter warning: loading a NULL string.\n");
2157 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2158 estack_ax(stack
, top
)->u
.s
.literal_type
=
2159 ESTACK_STRING_LITERAL_TYPE_NONE
;
2160 dbg_printf("ref get context dynamic string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2161 estack_ax_t
= REG_STRING
;
2164 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
2168 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2172 OP(FILTER_OP_GET_CONTEXT_REF_STRING
):
2174 struct load_op
*insn
= (struct load_op
*) pc
;
2175 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2176 struct lttng_ctx_field
*ctx_field
;
2177 struct lttng_ctx_value v
;
2179 dbg_printf("get context ref offset %u type string\n",
2181 ctx_field
= &ctx
->fields
[ref
->offset
];
2182 ctx_field
->get_value(ctx_field
, &v
);
2183 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2184 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2185 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2186 dbg_printf("Filter warning: loading a NULL string.\n");
2190 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2191 estack_ax(stack
, top
)->u
.s
.literal_type
=
2192 ESTACK_STRING_LITERAL_TYPE_NONE
;
2193 estack_ax_t
= REG_STRING
;
2194 dbg_printf("ref get context string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2195 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2199 OP(FILTER_OP_GET_CONTEXT_REF_S64
):
2201 struct load_op
*insn
= (struct load_op
*) pc
;
2202 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2203 struct lttng_ctx_field
*ctx_field
;
2204 struct lttng_ctx_value v
;
2206 dbg_printf("get context ref offset %u type s64\n",
2208 ctx_field
= &ctx
->fields
[ref
->offset
];
2209 ctx_field
->get_value(ctx_field
, &v
);
2210 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2211 estack_ax_v
= v
.u
.s64
;
2212 estack_ax_t
= REG_S64
;
2213 dbg_printf("ref get context s64 %" PRIi64
"\n", estack_ax_v
);
2214 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2218 OP(FILTER_OP_GET_CONTEXT_REF_DOUBLE
):
2220 struct load_op
*insn
= (struct load_op
*) pc
;
2221 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2222 struct lttng_ctx_field
*ctx_field
;
2223 struct lttng_ctx_value v
;
2225 dbg_printf("get context ref offset %u type double\n",
2227 ctx_field
= &ctx
->fields
[ref
->offset
];
2228 ctx_field
->get_value(ctx_field
, &v
);
2229 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2230 memcpy(&estack_ax(stack
, top
)->u
.d
, &v
.u
.d
, sizeof(struct literal_double
));
2231 estack_ax_t
= REG_DOUBLE
;
2232 dbg_printf("ref get context double %g\n", estack_ax(stack
, top
)->u
.d
);
2233 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2237 OP(FILTER_OP_GET_CONTEXT_ROOT
):
2239 dbg_printf("op get context root\n");
2240 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2241 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_CONTEXT
;
2242 /* "field" only needed for variants. */
2243 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2244 estack_ax_t
= REG_PTR
;
2245 next_pc
+= sizeof(struct load_op
);
2249 OP(FILTER_OP_GET_APP_CONTEXT_ROOT
):
2251 dbg_printf("op get app context root\n");
2252 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2253 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_APP_CONTEXT
;
2254 /* "field" only needed for variants. */
2255 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2256 estack_ax_t
= REG_PTR
;
2257 next_pc
+= sizeof(struct load_op
);
2261 OP(FILTER_OP_GET_PAYLOAD_ROOT
):
2263 dbg_printf("op get app payload root\n");
2264 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2265 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_PAYLOAD
;
2266 estack_ax(stack
, top
)->u
.ptr
.ptr
= interpreter_stack_data
;
2267 /* "field" only needed for variants. */
2268 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2269 estack_ax_t
= REG_PTR
;
2270 next_pc
+= sizeof(struct load_op
);
2274 OP(FILTER_OP_GET_SYMBOL
):
2276 dbg_printf("op get symbol\n");
2277 switch (estack_ax(stack
, top
)->u
.ptr
.type
) {
2279 ERR("Nested fields not implemented yet.");
2282 case LOAD_ROOT_CONTEXT
:
2283 case LOAD_ROOT_APP_CONTEXT
:
2284 case LOAD_ROOT_PAYLOAD
:
2286 * symbol lookup is performed by
2292 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_symbol
);
2296 OP(FILTER_OP_GET_SYMBOL_FIELD
):
2299 * Used for first variant encountered in a
2300 * traversal. Variants are not implemented yet.
2306 OP(FILTER_OP_GET_INDEX_U16
):
2308 struct load_op
*insn
= (struct load_op
*) pc
;
2309 struct get_index_u16
*index
= (struct get_index_u16
*) insn
->data
;
2311 dbg_printf("op get index u16\n");
2312 ret
= dynamic_get_index(ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
2315 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2316 estack_ax_t
= estack_ax(stack
, top
)->type
;
2317 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u16
);
2321 OP(FILTER_OP_GET_INDEX_U64
):
2323 struct load_op
*insn
= (struct load_op
*) pc
;
2324 struct get_index_u64
*index
= (struct get_index_u64
*) insn
->data
;
2326 dbg_printf("op get index u64\n");
2327 ret
= dynamic_get_index(ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
2330 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2331 estack_ax_t
= estack_ax(stack
, top
)->type
;
2332 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u64
);
2336 OP(FILTER_OP_LOAD_FIELD
):
2338 dbg_printf("op load field\n");
2339 ret
= dynamic_load_field(estack_ax(stack
, top
));
2342 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2343 estack_ax_t
= estack_ax(stack
, top
)->type
;
2344 next_pc
+= sizeof(struct load_op
);
2348 OP(FILTER_OP_LOAD_FIELD_S8
):
2350 dbg_printf("op load field s8\n");
2352 estack_ax_v
= *(int8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2353 estack_ax_t
= REG_S64
;
2354 next_pc
+= sizeof(struct load_op
);
2357 OP(FILTER_OP_LOAD_FIELD_S16
):
2359 dbg_printf("op load field s16\n");
2361 estack_ax_v
= *(int16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2362 estack_ax_t
= REG_S64
;
2363 next_pc
+= sizeof(struct load_op
);
2366 OP(FILTER_OP_LOAD_FIELD_S32
):
2368 dbg_printf("op load field s32\n");
2370 estack_ax_v
= *(int32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2371 estack_ax_t
= REG_S64
;
2372 next_pc
+= sizeof(struct load_op
);
2375 OP(FILTER_OP_LOAD_FIELD_S64
):
2377 dbg_printf("op load field s64\n");
2379 estack_ax_v
= *(int64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2380 estack_ax_t
= REG_S64
;
2381 next_pc
+= sizeof(struct load_op
);
2384 OP(FILTER_OP_LOAD_FIELD_U8
):
2386 dbg_printf("op load field u8\n");
2388 estack_ax_v
= *(uint8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2389 estack_ax_t
= REG_U64
;
2390 next_pc
+= sizeof(struct load_op
);
2393 OP(FILTER_OP_LOAD_FIELD_U16
):
2395 dbg_printf("op load field u16\n");
2397 estack_ax_v
= *(uint16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2398 estack_ax_t
= REG_U64
;
2399 next_pc
+= sizeof(struct load_op
);
2402 OP(FILTER_OP_LOAD_FIELD_U32
):
2404 dbg_printf("op load field u32\n");
2406 estack_ax_v
= *(uint32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2407 estack_ax_t
= REG_U64
;
2408 next_pc
+= sizeof(struct load_op
);
2411 OP(FILTER_OP_LOAD_FIELD_U64
):
2413 dbg_printf("op load field u64\n");
2415 estack_ax_v
= *(uint64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2416 estack_ax_t
= REG_U64
;
2417 next_pc
+= sizeof(struct load_op
);
2420 OP(FILTER_OP_LOAD_FIELD_DOUBLE
):
2422 dbg_printf("op load field double\n");
2424 memcpy(&estack_ax(stack
, top
)->u
.d
,
2425 estack_ax(stack
, top
)->u
.ptr
.ptr
,
2426 sizeof(struct literal_double
));
2427 estack_ax(stack
, top
)->type
= REG_DOUBLE
;
2428 next_pc
+= sizeof(struct load_op
);
2432 OP(FILTER_OP_LOAD_FIELD_STRING
):
2436 dbg_printf("op load field string\n");
2437 str
= (const char *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2438 estack_ax(stack
, top
)->u
.s
.str
= str
;
2439 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2440 dbg_printf("Filter warning: loading a NULL string.\n");
2444 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2445 estack_ax(stack
, top
)->u
.s
.literal_type
=
2446 ESTACK_STRING_LITERAL_TYPE_NONE
;
2447 estack_ax(stack
, top
)->type
= REG_STRING
;
2448 next_pc
+= sizeof(struct load_op
);
2452 OP(FILTER_OP_LOAD_FIELD_SEQUENCE
):
2456 dbg_printf("op load field string sequence\n");
2457 ptr
= estack_ax(stack
, top
)->u
.ptr
.ptr
;
2458 estack_ax(stack
, top
)->u
.s
.seq_len
= *(unsigned long *) ptr
;
2459 estack_ax(stack
, top
)->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
2460 estack_ax(stack
, top
)->type
= REG_STRING
;
2461 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2462 dbg_printf("Filter warning: loading a NULL sequence.\n");
2466 estack_ax(stack
, top
)->u
.s
.literal_type
=
2467 ESTACK_STRING_LITERAL_TYPE_NONE
;
2468 next_pc
+= sizeof(struct load_op
);
2474 /* Return _DISCARD on error. */
2476 return LTTNG_FILTER_DISCARD
;
2479 return lttng_bytecode_interpret_format_output(estack_ax(stack
, top
),
2486 uint64_t lttng_filter_interpret_bytecode(void *filter_data
,
2487 const char *filter_stack_data
)
2489 return bytecode_interpret(filter_data
, filter_stack_data
, NULL
);