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
;
460 stack_top
->type
= REG_PTR
;
468 static int dynamic_load_field(struct estack_entry
*stack_top
)
472 switch (stack_top
->u
.ptr
.type
) {
475 case LOAD_ROOT_CONTEXT
:
476 case LOAD_ROOT_APP_CONTEXT
:
477 case LOAD_ROOT_PAYLOAD
:
479 dbg_printf("Filter warning: cannot load root, missing field name.\n");
483 switch (stack_top
->u
.ptr
.object_type
) {
485 dbg_printf("op load field s8\n");
486 stack_top
->u
.v
= *(int8_t *) stack_top
->u
.ptr
.ptr
;
487 stack_top
->type
= REG_S64
;
489 case OBJECT_TYPE_S16
:
493 dbg_printf("op load field s16\n");
494 tmp
= *(int16_t *) stack_top
->u
.ptr
.ptr
;
495 if (stack_top
->u
.ptr
.rev_bo
)
497 stack_top
->u
.v
= tmp
;
498 stack_top
->type
= REG_S64
;
501 case OBJECT_TYPE_S32
:
505 dbg_printf("op load field s32\n");
506 tmp
= *(int32_t *) stack_top
->u
.ptr
.ptr
;
507 if (stack_top
->u
.ptr
.rev_bo
)
509 stack_top
->u
.v
= tmp
;
510 stack_top
->type
= REG_S64
;
513 case OBJECT_TYPE_S64
:
517 dbg_printf("op load field s64\n");
518 tmp
= *(int64_t *) stack_top
->u
.ptr
.ptr
;
519 if (stack_top
->u
.ptr
.rev_bo
)
521 stack_top
->u
.v
= tmp
;
522 stack_top
->type
= REG_S64
;
526 dbg_printf("op load field u8\n");
527 stack_top
->u
.v
= *(uint8_t *) stack_top
->u
.ptr
.ptr
;
528 stack_top
->type
= REG_U64
;
530 case OBJECT_TYPE_U16
:
534 dbg_printf("op load field u16\n");
535 tmp
= *(uint16_t *) stack_top
->u
.ptr
.ptr
;
536 if (stack_top
->u
.ptr
.rev_bo
)
538 stack_top
->u
.v
= tmp
;
539 stack_top
->type
= REG_U64
;
542 case OBJECT_TYPE_U32
:
546 dbg_printf("op load field u32\n");
547 tmp
= *(uint32_t *) stack_top
->u
.ptr
.ptr
;
548 if (stack_top
->u
.ptr
.rev_bo
)
550 stack_top
->u
.v
= tmp
;
551 stack_top
->type
= REG_U64
;
554 case OBJECT_TYPE_U64
:
558 dbg_printf("op load field u64\n");
559 tmp
= *(uint64_t *) stack_top
->u
.ptr
.ptr
;
560 if (stack_top
->u
.ptr
.rev_bo
)
562 stack_top
->u
.v
= tmp
;
563 stack_top
->type
= REG_U64
;
566 case OBJECT_TYPE_DOUBLE
:
567 memcpy(&stack_top
->u
.d
,
568 stack_top
->u
.ptr
.ptr
,
569 sizeof(struct literal_double
));
570 stack_top
->type
= REG_DOUBLE
;
572 case OBJECT_TYPE_STRING
:
576 dbg_printf("op load field string\n");
577 str
= (const char *) stack_top
->u
.ptr
.ptr
;
578 stack_top
->u
.s
.str
= str
;
579 if (unlikely(!stack_top
->u
.s
.str
)) {
580 dbg_printf("Filter warning: loading a NULL string.\n");
584 stack_top
->u
.s
.seq_len
= SIZE_MAX
;
585 stack_top
->u
.s
.literal_type
=
586 ESTACK_STRING_LITERAL_TYPE_NONE
;
587 stack_top
->type
= REG_STRING
;
590 case OBJECT_TYPE_STRING_SEQUENCE
:
594 dbg_printf("op load field string sequence\n");
595 ptr
= stack_top
->u
.ptr
.ptr
;
596 stack_top
->u
.s
.seq_len
= *(unsigned long *) ptr
;
597 stack_top
->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
598 stack_top
->type
= REG_STRING
;
599 if (unlikely(!stack_top
->u
.s
.str
)) {
600 dbg_printf("Filter warning: loading a NULL sequence.\n");
604 stack_top
->u
.s
.literal_type
=
605 ESTACK_STRING_LITERAL_TYPE_NONE
;
608 case OBJECT_TYPE_DYNAMIC
:
610 * Dynamic types in context are looked up
611 * by context get index.
615 case OBJECT_TYPE_SEQUENCE
:
616 case OBJECT_TYPE_ARRAY
:
617 case OBJECT_TYPE_STRUCT
:
618 case OBJECT_TYPE_VARIANT
:
619 ERR("Sequences, arrays, struct and variant cannot be loaded (nested types).");
630 int lttng_bytecode_interpret_format_output(struct estack_entry
*ax
,
631 struct lttng_interpreter_output
*output
)
638 output
->type
= LTTNG_INTERPRETER_TYPE_S64
;
639 output
->u
.s
= ax
->u
.v
;
642 output
->type
= LTTNG_INTERPRETER_TYPE_U64
;
643 output
->u
.u
= (uint64_t) ax
->u
.v
;
646 output
->type
= LTTNG_INTERPRETER_TYPE_DOUBLE
;
647 output
->u
.d
= ax
->u
.d
;
650 output
->type
= LTTNG_INTERPRETER_TYPE_STRING
;
651 output
->u
.str
.str
= ax
->u
.s
.str
;
652 output
->u
.str
.len
= ax
->u
.s
.seq_len
;
655 switch (ax
->u
.ptr
.object_type
) {
657 case OBJECT_TYPE_S16
:
658 case OBJECT_TYPE_S32
:
659 case OBJECT_TYPE_S64
:
661 case OBJECT_TYPE_U16
:
662 case OBJECT_TYPE_U32
:
663 case OBJECT_TYPE_U64
:
664 case OBJECT_TYPE_DOUBLE
:
665 case OBJECT_TYPE_STRING
:
666 case OBJECT_TYPE_STRING_SEQUENCE
:
667 ret
= dynamic_load_field(ax
);
670 /* Retry after loading ptr into stack top. */
672 case OBJECT_TYPE_SEQUENCE
:
673 output
->type
= LTTNG_INTERPRETER_TYPE_SEQUENCE
;
674 output
->u
.sequence
.ptr
= *(const char **) (ax
->u
.ptr
.ptr
+ sizeof(unsigned long));
675 output
->u
.sequence
.nr_elem
= *(unsigned long *) ax
->u
.ptr
.ptr
;
676 output
->u
.sequence
.nested_type
= ax
->u
.ptr
.field
->type
.u
.sequence_nestable
.elem_type
;
678 case OBJECT_TYPE_ARRAY
:
679 /* Skip count (unsigned long) */
680 output
->type
= LTTNG_INTERPRETER_TYPE_SEQUENCE
;
681 output
->u
.sequence
.ptr
= *(const char **) (ax
->u
.ptr
.ptr
+ sizeof(unsigned long));
682 output
->u
.sequence
.nr_elem
= ax
->u
.ptr
.field
->type
.u
.array_nestable
.length
;
683 output
->u
.sequence
.nested_type
= ax
->u
.ptr
.field
->type
.u
.array_nestable
.elem_type
;
685 case OBJECT_TYPE_STRUCT
:
686 case OBJECT_TYPE_VARIANT
:
692 case REG_STAR_GLOB_STRING
:
698 return LTTNG_FILTER_RECORD_FLAG
;
702 * Return 0 (discard), or raise the 0x1 flag (log event).
703 * Currently, other flags are kept for future extensions and have no
707 uint64_t bytecode_interpret(void *interpreter_data
,
708 const char *interpreter_stack_data
,
709 struct lttng_interpreter_output
*output
)
711 struct bytecode_runtime
*bytecode
= interpreter_data
;
712 struct lttng_ctx
*ctx
= rcu_dereference(*bytecode
->p
.pctx
);
713 void *pc
, *next_pc
, *start_pc
;
716 struct estack _stack
;
717 struct estack
*stack
= &_stack
;
718 register int64_t ax
= 0, bx
= 0;
719 register enum entry_type ax_t
= REG_UNKNOWN
, bx_t
= REG_UNKNOWN
;
720 register int top
= FILTER_STACK_EMPTY
;
721 #ifndef INTERPRETER_USE_SWITCH
722 static void *dispatch
[NR_FILTER_OPS
] = {
723 [ FILTER_OP_UNKNOWN
] = &&LABEL_FILTER_OP_UNKNOWN
,
725 [ FILTER_OP_RETURN
] = &&LABEL_FILTER_OP_RETURN
,
728 [ FILTER_OP_MUL
] = &&LABEL_FILTER_OP_MUL
,
729 [ FILTER_OP_DIV
] = &&LABEL_FILTER_OP_DIV
,
730 [ FILTER_OP_MOD
] = &&LABEL_FILTER_OP_MOD
,
731 [ FILTER_OP_PLUS
] = &&LABEL_FILTER_OP_PLUS
,
732 [ FILTER_OP_MINUS
] = &&LABEL_FILTER_OP_MINUS
,
733 [ FILTER_OP_BIT_RSHIFT
] = &&LABEL_FILTER_OP_BIT_RSHIFT
,
734 [ FILTER_OP_BIT_LSHIFT
] = &&LABEL_FILTER_OP_BIT_LSHIFT
,
735 [ FILTER_OP_BIT_AND
] = &&LABEL_FILTER_OP_BIT_AND
,
736 [ FILTER_OP_BIT_OR
] = &&LABEL_FILTER_OP_BIT_OR
,
737 [ FILTER_OP_BIT_XOR
] = &&LABEL_FILTER_OP_BIT_XOR
,
739 /* binary comparators */
740 [ FILTER_OP_EQ
] = &&LABEL_FILTER_OP_EQ
,
741 [ FILTER_OP_NE
] = &&LABEL_FILTER_OP_NE
,
742 [ FILTER_OP_GT
] = &&LABEL_FILTER_OP_GT
,
743 [ FILTER_OP_LT
] = &&LABEL_FILTER_OP_LT
,
744 [ FILTER_OP_GE
] = &&LABEL_FILTER_OP_GE
,
745 [ FILTER_OP_LE
] = &&LABEL_FILTER_OP_LE
,
747 /* string binary comparator */
748 [ FILTER_OP_EQ_STRING
] = &&LABEL_FILTER_OP_EQ_STRING
,
749 [ FILTER_OP_NE_STRING
] = &&LABEL_FILTER_OP_NE_STRING
,
750 [ FILTER_OP_GT_STRING
] = &&LABEL_FILTER_OP_GT_STRING
,
751 [ FILTER_OP_LT_STRING
] = &&LABEL_FILTER_OP_LT_STRING
,
752 [ FILTER_OP_GE_STRING
] = &&LABEL_FILTER_OP_GE_STRING
,
753 [ FILTER_OP_LE_STRING
] = &&LABEL_FILTER_OP_LE_STRING
,
755 /* globbing pattern binary comparator */
756 [ FILTER_OP_EQ_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_EQ_STAR_GLOB_STRING
,
757 [ FILTER_OP_NE_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_NE_STAR_GLOB_STRING
,
759 /* s64 binary comparator */
760 [ FILTER_OP_EQ_S64
] = &&LABEL_FILTER_OP_EQ_S64
,
761 [ FILTER_OP_NE_S64
] = &&LABEL_FILTER_OP_NE_S64
,
762 [ FILTER_OP_GT_S64
] = &&LABEL_FILTER_OP_GT_S64
,
763 [ FILTER_OP_LT_S64
] = &&LABEL_FILTER_OP_LT_S64
,
764 [ FILTER_OP_GE_S64
] = &&LABEL_FILTER_OP_GE_S64
,
765 [ FILTER_OP_LE_S64
] = &&LABEL_FILTER_OP_LE_S64
,
767 /* double binary comparator */
768 [ FILTER_OP_EQ_DOUBLE
] = &&LABEL_FILTER_OP_EQ_DOUBLE
,
769 [ FILTER_OP_NE_DOUBLE
] = &&LABEL_FILTER_OP_NE_DOUBLE
,
770 [ FILTER_OP_GT_DOUBLE
] = &&LABEL_FILTER_OP_GT_DOUBLE
,
771 [ FILTER_OP_LT_DOUBLE
] = &&LABEL_FILTER_OP_LT_DOUBLE
,
772 [ FILTER_OP_GE_DOUBLE
] = &&LABEL_FILTER_OP_GE_DOUBLE
,
773 [ FILTER_OP_LE_DOUBLE
] = &&LABEL_FILTER_OP_LE_DOUBLE
,
775 /* Mixed S64-double binary comparators */
776 [ FILTER_OP_EQ_DOUBLE_S64
] = &&LABEL_FILTER_OP_EQ_DOUBLE_S64
,
777 [ FILTER_OP_NE_DOUBLE_S64
] = &&LABEL_FILTER_OP_NE_DOUBLE_S64
,
778 [ FILTER_OP_GT_DOUBLE_S64
] = &&LABEL_FILTER_OP_GT_DOUBLE_S64
,
779 [ FILTER_OP_LT_DOUBLE_S64
] = &&LABEL_FILTER_OP_LT_DOUBLE_S64
,
780 [ FILTER_OP_GE_DOUBLE_S64
] = &&LABEL_FILTER_OP_GE_DOUBLE_S64
,
781 [ FILTER_OP_LE_DOUBLE_S64
] = &&LABEL_FILTER_OP_LE_DOUBLE_S64
,
783 [ FILTER_OP_EQ_S64_DOUBLE
] = &&LABEL_FILTER_OP_EQ_S64_DOUBLE
,
784 [ FILTER_OP_NE_S64_DOUBLE
] = &&LABEL_FILTER_OP_NE_S64_DOUBLE
,
785 [ FILTER_OP_GT_S64_DOUBLE
] = &&LABEL_FILTER_OP_GT_S64_DOUBLE
,
786 [ FILTER_OP_LT_S64_DOUBLE
] = &&LABEL_FILTER_OP_LT_S64_DOUBLE
,
787 [ FILTER_OP_GE_S64_DOUBLE
] = &&LABEL_FILTER_OP_GE_S64_DOUBLE
,
788 [ FILTER_OP_LE_S64_DOUBLE
] = &&LABEL_FILTER_OP_LE_S64_DOUBLE
,
791 [ FILTER_OP_UNARY_PLUS
] = &&LABEL_FILTER_OP_UNARY_PLUS
,
792 [ FILTER_OP_UNARY_MINUS
] = &&LABEL_FILTER_OP_UNARY_MINUS
,
793 [ FILTER_OP_UNARY_NOT
] = &&LABEL_FILTER_OP_UNARY_NOT
,
794 [ FILTER_OP_UNARY_PLUS_S64
] = &&LABEL_FILTER_OP_UNARY_PLUS_S64
,
795 [ FILTER_OP_UNARY_MINUS_S64
] = &&LABEL_FILTER_OP_UNARY_MINUS_S64
,
796 [ FILTER_OP_UNARY_NOT_S64
] = &&LABEL_FILTER_OP_UNARY_NOT_S64
,
797 [ FILTER_OP_UNARY_PLUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_PLUS_DOUBLE
,
798 [ FILTER_OP_UNARY_MINUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_MINUS_DOUBLE
,
799 [ FILTER_OP_UNARY_NOT_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_NOT_DOUBLE
,
802 [ FILTER_OP_AND
] = &&LABEL_FILTER_OP_AND
,
803 [ FILTER_OP_OR
] = &&LABEL_FILTER_OP_OR
,
806 [ FILTER_OP_LOAD_FIELD_REF
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF
,
807 [ FILTER_OP_LOAD_FIELD_REF_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_STRING
,
808 [ FILTER_OP_LOAD_FIELD_REF_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_SEQUENCE
,
809 [ FILTER_OP_LOAD_FIELD_REF_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_S64
,
810 [ FILTER_OP_LOAD_FIELD_REF_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_DOUBLE
,
812 /* load from immediate operand */
813 [ FILTER_OP_LOAD_STRING
] = &&LABEL_FILTER_OP_LOAD_STRING
,
814 [ FILTER_OP_LOAD_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_LOAD_STAR_GLOB_STRING
,
815 [ FILTER_OP_LOAD_S64
] = &&LABEL_FILTER_OP_LOAD_S64
,
816 [ FILTER_OP_LOAD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_DOUBLE
,
819 [ FILTER_OP_CAST_TO_S64
] = &&LABEL_FILTER_OP_CAST_TO_S64
,
820 [ FILTER_OP_CAST_DOUBLE_TO_S64
] = &&LABEL_FILTER_OP_CAST_DOUBLE_TO_S64
,
821 [ FILTER_OP_CAST_NOP
] = &&LABEL_FILTER_OP_CAST_NOP
,
823 /* get context ref */
824 [ FILTER_OP_GET_CONTEXT_REF
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF
,
825 [ FILTER_OP_GET_CONTEXT_REF_STRING
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_STRING
,
826 [ FILTER_OP_GET_CONTEXT_REF_S64
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_S64
,
827 [ FILTER_OP_GET_CONTEXT_REF_DOUBLE
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_DOUBLE
,
829 /* Instructions for recursive traversal through composed types. */
830 [ FILTER_OP_GET_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_CONTEXT_ROOT
,
831 [ FILTER_OP_GET_APP_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_APP_CONTEXT_ROOT
,
832 [ FILTER_OP_GET_PAYLOAD_ROOT
] = &&LABEL_FILTER_OP_GET_PAYLOAD_ROOT
,
834 [ FILTER_OP_GET_SYMBOL
] = &&LABEL_FILTER_OP_GET_SYMBOL
,
835 [ FILTER_OP_GET_SYMBOL_FIELD
] = &&LABEL_FILTER_OP_GET_SYMBOL_FIELD
,
836 [ FILTER_OP_GET_INDEX_U16
] = &&LABEL_FILTER_OP_GET_INDEX_U16
,
837 [ FILTER_OP_GET_INDEX_U64
] = &&LABEL_FILTER_OP_GET_INDEX_U64
,
839 [ FILTER_OP_LOAD_FIELD
] = &&LABEL_FILTER_OP_LOAD_FIELD
,
840 [ FILTER_OP_LOAD_FIELD_S8
] = &&LABEL_FILTER_OP_LOAD_FIELD_S8
,
841 [ FILTER_OP_LOAD_FIELD_S16
] = &&LABEL_FILTER_OP_LOAD_FIELD_S16
,
842 [ FILTER_OP_LOAD_FIELD_S32
] = &&LABEL_FILTER_OP_LOAD_FIELD_S32
,
843 [ FILTER_OP_LOAD_FIELD_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_S64
,
844 [ FILTER_OP_LOAD_FIELD_U8
] = &&LABEL_FILTER_OP_LOAD_FIELD_U8
,
845 [ FILTER_OP_LOAD_FIELD_U16
] = &&LABEL_FILTER_OP_LOAD_FIELD_U16
,
846 [ FILTER_OP_LOAD_FIELD_U32
] = &&LABEL_FILTER_OP_LOAD_FIELD_U32
,
847 [ FILTER_OP_LOAD_FIELD_U64
] = &&LABEL_FILTER_OP_LOAD_FIELD_U64
,
848 [ FILTER_OP_LOAD_FIELD_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_STRING
,
849 [ FILTER_OP_LOAD_FIELD_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_SEQUENCE
,
850 [ FILTER_OP_LOAD_FIELD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_DOUBLE
,
852 [ FILTER_OP_UNARY_BIT_NOT
] = &&LABEL_FILTER_OP_UNARY_BIT_NOT
,
854 [ FILTER_OP_RETURN_S64
] = &&LABEL_FILTER_OP_RETURN_S64
,
856 #endif /* #ifndef INTERPRETER_USE_SWITCH */
860 OP(FILTER_OP_UNKNOWN
):
861 OP(FILTER_OP_LOAD_FIELD_REF
):
862 #ifdef INTERPRETER_USE_SWITCH
864 #endif /* INTERPRETER_USE_SWITCH */
865 ERR("unknown bytecode op %u",
866 (unsigned int) *(filter_opcode_t
*) pc
);
870 OP(FILTER_OP_RETURN
):
871 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
872 /* Handle dynamic typing. */
873 switch (estack_ax_t
) {
876 retval
= !!estack_ax_v
;
887 case REG_STAR_GLOB_STRING
:
896 OP(FILTER_OP_RETURN_S64
):
897 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
898 retval
= !!estack_ax_v
;
908 ERR("unsupported bytecode op %u",
909 (unsigned int) *(filter_opcode_t
*) pc
);
915 /* Dynamic typing. */
916 switch (estack_ax_t
) {
917 case REG_S64
: /* Fall-through */
919 switch (estack_bx_t
) {
920 case REG_S64
: /* Fall-through */
922 JUMP_TO(FILTER_OP_EQ_S64
);
924 JUMP_TO(FILTER_OP_EQ_DOUBLE_S64
);
925 case REG_STRING
: /* Fall-through */
926 case REG_STAR_GLOB_STRING
:
930 ERR("Unknown filter register type (%d)",
937 switch (estack_bx_t
) {
938 case REG_S64
: /* Fall-through */
940 JUMP_TO(FILTER_OP_EQ_S64_DOUBLE
);
942 JUMP_TO(FILTER_OP_EQ_DOUBLE
);
943 case REG_STRING
: /* Fall-through */
944 case REG_STAR_GLOB_STRING
:
948 ERR("Unknown filter register type (%d)",
955 switch (estack_bx_t
) {
956 case REG_S64
: /* Fall-through */
957 case REG_U64
: /* Fall-through */
962 JUMP_TO(FILTER_OP_EQ_STRING
);
963 case REG_STAR_GLOB_STRING
:
964 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
966 ERR("Unknown filter register type (%d)",
972 case REG_STAR_GLOB_STRING
:
973 switch (estack_bx_t
) {
974 case REG_S64
: /* Fall-through */
975 case REG_U64
: /* Fall-through */
980 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
981 case REG_STAR_GLOB_STRING
:
985 ERR("Unknown filter register type (%d)",
992 ERR("Unknown filter register type (%d)",
1000 /* Dynamic typing. */
1001 switch (estack_ax_t
) {
1002 case REG_S64
: /* Fall-through */
1004 switch (estack_bx_t
) {
1005 case REG_S64
: /* Fall-through */
1007 JUMP_TO(FILTER_OP_NE_S64
);
1009 JUMP_TO(FILTER_OP_NE_DOUBLE_S64
);
1010 case REG_STRING
: /* Fall-through */
1011 case REG_STAR_GLOB_STRING
:
1015 ERR("Unknown filter register type (%d)",
1022 switch (estack_bx_t
) {
1023 case REG_S64
: /* Fall-through */
1025 JUMP_TO(FILTER_OP_NE_S64_DOUBLE
);
1027 JUMP_TO(FILTER_OP_NE_DOUBLE
);
1028 case REG_STRING
: /* Fall-through */
1029 case REG_STAR_GLOB_STRING
:
1033 ERR("Unknown filter register type (%d)",
1040 switch (estack_bx_t
) {
1041 case REG_S64
: /* Fall-through */
1047 JUMP_TO(FILTER_OP_NE_STRING
);
1048 case REG_STAR_GLOB_STRING
:
1049 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
1051 ERR("Unknown filter register type (%d)",
1057 case REG_STAR_GLOB_STRING
:
1058 switch (estack_bx_t
) {
1059 case REG_S64
: /* Fall-through */
1065 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
1066 case REG_STAR_GLOB_STRING
:
1070 ERR("Unknown filter register type (%d)",
1077 ERR("Unknown filter register type (%d)",
1085 /* Dynamic typing. */
1086 switch (estack_ax_t
) {
1087 case REG_S64
: /* Fall-through */
1089 switch (estack_bx_t
) {
1090 case REG_S64
: /* Fall-through */
1092 JUMP_TO(FILTER_OP_GT_S64
);
1094 JUMP_TO(FILTER_OP_GT_DOUBLE_S64
);
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 */
1110 JUMP_TO(FILTER_OP_GT_S64_DOUBLE
);
1112 JUMP_TO(FILTER_OP_GT_DOUBLE
);
1113 case REG_STRING
: /* Fall-through */
1114 case REG_STAR_GLOB_STRING
:
1118 ERR("Unknown filter register type (%d)",
1125 switch (estack_bx_t
) {
1126 case REG_S64
: /* Fall-through */
1127 case REG_U64
: /* Fall-through */
1128 case REG_DOUBLE
: /* Fall-through */
1129 case REG_STAR_GLOB_STRING
:
1133 JUMP_TO(FILTER_OP_GT_STRING
);
1135 ERR("Unknown filter register type (%d)",
1142 ERR("Unknown filter register type (%d)",
1150 /* Dynamic typing. */
1151 switch (estack_ax_t
) {
1152 case REG_S64
: /* Fall-through */
1154 switch (estack_bx_t
) {
1155 case REG_S64
: /* Fall-through */
1157 JUMP_TO(FILTER_OP_LT_S64
);
1159 JUMP_TO(FILTER_OP_LT_DOUBLE_S64
);
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 */
1175 JUMP_TO(FILTER_OP_LT_S64_DOUBLE
);
1177 JUMP_TO(FILTER_OP_LT_DOUBLE
);
1178 case REG_STRING
: /* Fall-through */
1179 case REG_STAR_GLOB_STRING
:
1183 ERR("Unknown filter register type (%d)",
1190 switch (estack_bx_t
) {
1191 case REG_S64
: /* Fall-through */
1192 case REG_U64
: /* Fall-through */
1193 case REG_DOUBLE
: /* Fall-through */
1194 case REG_STAR_GLOB_STRING
:
1198 JUMP_TO(FILTER_OP_LT_STRING
);
1200 ERR("Unknown filter register type (%d)",
1207 ERR("Unknown filter register type (%d)",
1215 /* Dynamic typing. */
1216 switch (estack_ax_t
) {
1217 case REG_S64
: /* Fall-through */
1219 switch (estack_bx_t
) {
1220 case REG_S64
: /* Fall-through */
1222 JUMP_TO(FILTER_OP_GE_S64
);
1224 JUMP_TO(FILTER_OP_GE_DOUBLE_S64
);
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 */
1240 JUMP_TO(FILTER_OP_GE_S64_DOUBLE
);
1242 JUMP_TO(FILTER_OP_GE_DOUBLE
);
1243 case REG_STRING
: /* Fall-through */
1244 case REG_STAR_GLOB_STRING
:
1248 ERR("Unknown filter register type (%d)",
1255 switch (estack_bx_t
) {
1256 case REG_S64
: /* Fall-through */
1257 case REG_U64
: /* Fall-through */
1258 case REG_DOUBLE
: /* Fall-through */
1259 case REG_STAR_GLOB_STRING
:
1263 JUMP_TO(FILTER_OP_GE_STRING
);
1265 ERR("Unknown filter register type (%d)",
1272 ERR("Unknown filter register type (%d)",
1280 /* Dynamic typing. */
1281 switch (estack_ax_t
) {
1282 case REG_S64
: /* Fall-through */
1284 switch (estack_bx_t
) {
1285 case REG_S64
: /* Fall-through */
1287 JUMP_TO(FILTER_OP_LE_S64
);
1289 JUMP_TO(FILTER_OP_LE_DOUBLE_S64
);
1290 case REG_STRING
: /* Fall-through */
1291 case REG_STAR_GLOB_STRING
:
1295 ERR("Unknown filter register type (%d)",
1302 switch (estack_bx_t
) {
1303 case REG_S64
: /* Fall-through */
1305 JUMP_TO(FILTER_OP_LE_S64_DOUBLE
);
1307 JUMP_TO(FILTER_OP_LE_DOUBLE
);
1308 case REG_STRING
: /* Fall-through */
1309 case REG_STAR_GLOB_STRING
:
1313 ERR("Unknown filter register type (%d)",
1320 switch (estack_bx_t
) {
1321 case REG_S64
: /* Fall-through */
1322 case REG_U64
: /* Fall-through */
1323 case REG_DOUBLE
: /* Fall-through */
1324 case REG_STAR_GLOB_STRING
:
1328 JUMP_TO(FILTER_OP_LE_STRING
);
1330 ERR("Unknown filter register type (%d)",
1337 ERR("Unknown filter register type (%d)",
1344 OP(FILTER_OP_EQ_STRING
):
1348 res
= (stack_strcmp(stack
, top
, "==") == 0);
1349 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1351 estack_ax_t
= REG_S64
;
1352 next_pc
+= sizeof(struct binary_op
);
1355 OP(FILTER_OP_NE_STRING
):
1359 res
= (stack_strcmp(stack
, top
, "!=") != 0);
1360 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1362 estack_ax_t
= REG_S64
;
1363 next_pc
+= sizeof(struct binary_op
);
1366 OP(FILTER_OP_GT_STRING
):
1370 res
= (stack_strcmp(stack
, top
, ">") > 0);
1371 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1373 estack_ax_t
= REG_S64
;
1374 next_pc
+= sizeof(struct binary_op
);
1377 OP(FILTER_OP_LT_STRING
):
1381 res
= (stack_strcmp(stack
, top
, "<") < 0);
1382 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1384 estack_ax_t
= REG_S64
;
1385 next_pc
+= sizeof(struct binary_op
);
1388 OP(FILTER_OP_GE_STRING
):
1392 res
= (stack_strcmp(stack
, top
, ">=") >= 0);
1393 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1395 estack_ax_t
= REG_S64
;
1396 next_pc
+= sizeof(struct binary_op
);
1399 OP(FILTER_OP_LE_STRING
):
1403 res
= (stack_strcmp(stack
, top
, "<=") <= 0);
1404 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1406 estack_ax_t
= REG_S64
;
1407 next_pc
+= sizeof(struct binary_op
);
1411 OP(FILTER_OP_EQ_STAR_GLOB_STRING
):
1415 res
= (stack_star_glob_match(stack
, top
, "==") == 0);
1416 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1418 estack_ax_t
= REG_S64
;
1419 next_pc
+= sizeof(struct binary_op
);
1422 OP(FILTER_OP_NE_STAR_GLOB_STRING
):
1426 res
= (stack_star_glob_match(stack
, top
, "!=") != 0);
1427 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1429 estack_ax_t
= REG_S64
;
1430 next_pc
+= sizeof(struct binary_op
);
1434 OP(FILTER_OP_EQ_S64
):
1438 res
= (estack_bx_v
== estack_ax_v
);
1439 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1441 estack_ax_t
= REG_S64
;
1442 next_pc
+= sizeof(struct binary_op
);
1445 OP(FILTER_OP_NE_S64
):
1449 res
= (estack_bx_v
!= estack_ax_v
);
1450 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1452 estack_ax_t
= REG_S64
;
1453 next_pc
+= sizeof(struct binary_op
);
1456 OP(FILTER_OP_GT_S64
):
1460 res
= (estack_bx_v
> estack_ax_v
);
1461 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1463 estack_ax_t
= REG_S64
;
1464 next_pc
+= sizeof(struct binary_op
);
1467 OP(FILTER_OP_LT_S64
):
1471 res
= (estack_bx_v
< estack_ax_v
);
1472 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1474 estack_ax_t
= REG_S64
;
1475 next_pc
+= sizeof(struct binary_op
);
1478 OP(FILTER_OP_GE_S64
):
1482 res
= (estack_bx_v
>= estack_ax_v
);
1483 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1485 estack_ax_t
= REG_S64
;
1486 next_pc
+= sizeof(struct binary_op
);
1489 OP(FILTER_OP_LE_S64
):
1493 res
= (estack_bx_v
<= estack_ax_v
);
1494 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1496 estack_ax_t
= REG_S64
;
1497 next_pc
+= sizeof(struct binary_op
);
1501 OP(FILTER_OP_EQ_DOUBLE
):
1505 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax(stack
, top
)->u
.d
);
1506 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1508 estack_ax_t
= REG_S64
;
1509 next_pc
+= sizeof(struct binary_op
);
1512 OP(FILTER_OP_NE_DOUBLE
):
1516 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax(stack
, top
)->u
.d
);
1517 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1519 estack_ax_t
= REG_S64
;
1520 next_pc
+= sizeof(struct binary_op
);
1523 OP(FILTER_OP_GT_DOUBLE
):
1527 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax(stack
, top
)->u
.d
);
1528 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1530 estack_ax_t
= REG_S64
;
1531 next_pc
+= sizeof(struct binary_op
);
1534 OP(FILTER_OP_LT_DOUBLE
):
1538 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax(stack
, top
)->u
.d
);
1539 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1541 estack_ax_t
= REG_S64
;
1542 next_pc
+= sizeof(struct binary_op
);
1545 OP(FILTER_OP_GE_DOUBLE
):
1549 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax(stack
, top
)->u
.d
);
1550 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1552 estack_ax_t
= REG_S64
;
1553 next_pc
+= sizeof(struct binary_op
);
1556 OP(FILTER_OP_LE_DOUBLE
):
1560 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax(stack
, top
)->u
.d
);
1561 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1563 estack_ax_t
= REG_S64
;
1564 next_pc
+= sizeof(struct binary_op
);
1568 /* Mixed S64-double binary comparators */
1569 OP(FILTER_OP_EQ_DOUBLE_S64
):
1573 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax_v
);
1574 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1576 estack_ax_t
= REG_S64
;
1577 next_pc
+= sizeof(struct binary_op
);
1580 OP(FILTER_OP_NE_DOUBLE_S64
):
1584 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax_v
);
1585 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1587 estack_ax_t
= REG_S64
;
1588 next_pc
+= sizeof(struct binary_op
);
1591 OP(FILTER_OP_GT_DOUBLE_S64
):
1595 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax_v
);
1596 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1598 estack_ax_t
= REG_S64
;
1599 next_pc
+= sizeof(struct binary_op
);
1602 OP(FILTER_OP_LT_DOUBLE_S64
):
1606 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax_v
);
1607 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1609 estack_ax_t
= REG_S64
;
1610 next_pc
+= sizeof(struct binary_op
);
1613 OP(FILTER_OP_GE_DOUBLE_S64
):
1617 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax_v
);
1618 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1620 estack_ax_t
= REG_S64
;
1621 next_pc
+= sizeof(struct binary_op
);
1624 OP(FILTER_OP_LE_DOUBLE_S64
):
1628 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax_v
);
1629 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1631 estack_ax_t
= REG_S64
;
1632 next_pc
+= sizeof(struct binary_op
);
1636 OP(FILTER_OP_EQ_S64_DOUBLE
):
1640 res
= (estack_bx_v
== estack_ax(stack
, top
)->u
.d
);
1641 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1643 estack_ax_t
= REG_S64
;
1644 next_pc
+= sizeof(struct binary_op
);
1647 OP(FILTER_OP_NE_S64_DOUBLE
):
1651 res
= (estack_bx_v
!= estack_ax(stack
, top
)->u
.d
);
1652 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1654 estack_ax_t
= REG_S64
;
1655 next_pc
+= sizeof(struct binary_op
);
1658 OP(FILTER_OP_GT_S64_DOUBLE
):
1662 res
= (estack_bx_v
> estack_ax(stack
, top
)->u
.d
);
1663 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1665 estack_ax_t
= REG_S64
;
1666 next_pc
+= sizeof(struct binary_op
);
1669 OP(FILTER_OP_LT_S64_DOUBLE
):
1673 res
= (estack_bx_v
< estack_ax(stack
, top
)->u
.d
);
1674 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1676 estack_ax_t
= REG_S64
;
1677 next_pc
+= sizeof(struct binary_op
);
1680 OP(FILTER_OP_GE_S64_DOUBLE
):
1684 res
= (estack_bx_v
>= estack_ax(stack
, top
)->u
.d
);
1685 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1687 estack_ax_t
= REG_S64
;
1688 next_pc
+= sizeof(struct binary_op
);
1691 OP(FILTER_OP_LE_S64_DOUBLE
):
1695 res
= (estack_bx_v
<= estack_ax(stack
, top
)->u
.d
);
1696 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1698 estack_ax_t
= REG_S64
;
1699 next_pc
+= sizeof(struct binary_op
);
1702 OP(FILTER_OP_BIT_RSHIFT
):
1706 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1711 /* Catch undefined behavior. */
1712 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1716 res
= ((uint64_t) estack_bx_v
>> (uint32_t) estack_ax_v
);
1717 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1719 estack_ax_t
= REG_U64
;
1720 next_pc
+= sizeof(struct binary_op
);
1723 OP(FILTER_OP_BIT_LSHIFT
):
1727 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1732 /* Catch undefined behavior. */
1733 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1737 res
= ((uint64_t) estack_bx_v
<< (uint32_t) estack_ax_v
);
1738 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1740 estack_ax_t
= REG_U64
;
1741 next_pc
+= sizeof(struct binary_op
);
1744 OP(FILTER_OP_BIT_AND
):
1748 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1753 res
= ((uint64_t) estack_bx_v
& (uint64_t) estack_ax_v
);
1754 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1756 estack_ax_t
= REG_U64
;
1757 next_pc
+= sizeof(struct binary_op
);
1760 OP(FILTER_OP_BIT_OR
):
1764 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1769 res
= ((uint64_t) estack_bx_v
| (uint64_t) estack_ax_v
);
1770 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1772 estack_ax_t
= REG_U64
;
1773 next_pc
+= sizeof(struct binary_op
);
1776 OP(FILTER_OP_BIT_XOR
):
1780 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1785 res
= ((uint64_t) estack_bx_v
^ (uint64_t) estack_ax_v
);
1786 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1788 estack_ax_t
= REG_U64
;
1789 next_pc
+= sizeof(struct binary_op
);
1794 OP(FILTER_OP_UNARY_PLUS
):
1796 /* Dynamic typing. */
1797 switch (estack_ax_t
) {
1798 case REG_S64
: /* Fall-through. */
1800 JUMP_TO(FILTER_OP_UNARY_PLUS_S64
);
1802 JUMP_TO(FILTER_OP_UNARY_PLUS_DOUBLE
);
1803 case REG_STRING
: /* Fall-through */
1804 case REG_STAR_GLOB_STRING
:
1808 ERR("Unknown filter register type (%d)",
1814 OP(FILTER_OP_UNARY_MINUS
):
1816 /* Dynamic typing. */
1817 switch (estack_ax_t
) {
1818 case REG_S64
: /* Fall-through. */
1820 JUMP_TO(FILTER_OP_UNARY_MINUS_S64
);
1822 JUMP_TO(FILTER_OP_UNARY_MINUS_DOUBLE
);
1823 case REG_STRING
: /* Fall-through */
1824 case REG_STAR_GLOB_STRING
:
1828 ERR("Unknown filter register type (%d)",
1834 OP(FILTER_OP_UNARY_NOT
):
1836 /* Dynamic typing. */
1837 switch (estack_ax_t
) {
1838 case REG_S64
: /* Fall-through. */
1840 JUMP_TO(FILTER_OP_UNARY_NOT_S64
);
1842 JUMP_TO(FILTER_OP_UNARY_NOT_DOUBLE
);
1843 case REG_STRING
: /* Fall-through */
1844 case REG_STAR_GLOB_STRING
:
1848 ERR("Unknown filter register type (%d)",
1853 next_pc
+= sizeof(struct unary_op
);
1857 OP(FILTER_OP_UNARY_BIT_NOT
):
1859 /* Dynamic typing. */
1860 if (!IS_INTEGER_REGISTER(estack_ax_t
)) {
1865 estack_ax_v
= ~(uint64_t) estack_ax_v
;
1866 estack_ax_t
= REG_U64
;
1867 next_pc
+= sizeof(struct unary_op
);
1871 OP(FILTER_OP_UNARY_PLUS_S64
):
1872 OP(FILTER_OP_UNARY_PLUS_DOUBLE
):
1874 next_pc
+= sizeof(struct unary_op
);
1877 OP(FILTER_OP_UNARY_MINUS_S64
):
1879 estack_ax_v
= -estack_ax_v
;
1880 next_pc
+= sizeof(struct unary_op
);
1883 OP(FILTER_OP_UNARY_MINUS_DOUBLE
):
1885 estack_ax(stack
, top
)->u
.d
= -estack_ax(stack
, top
)->u
.d
;
1886 next_pc
+= sizeof(struct unary_op
);
1889 OP(FILTER_OP_UNARY_NOT_S64
):
1891 estack_ax_v
= !estack_ax_v
;
1892 estack_ax_t
= REG_S64
;
1893 next_pc
+= sizeof(struct unary_op
);
1896 OP(FILTER_OP_UNARY_NOT_DOUBLE
):
1898 estack_ax_v
= !estack_ax(stack
, top
)->u
.d
;
1899 estack_ax_t
= REG_S64
;
1900 next_pc
+= sizeof(struct unary_op
);
1907 struct logical_op
*insn
= (struct logical_op
*) pc
;
1909 if (estack_ax_t
!= REG_S64
&& estack_ax_t
!= REG_U64
) {
1913 /* If AX is 0, skip and evaluate to 0 */
1914 if (unlikely(estack_ax_v
== 0)) {
1915 dbg_printf("Jumping to bytecode offset %u\n",
1916 (unsigned int) insn
->skip_offset
);
1917 next_pc
= start_pc
+ insn
->skip_offset
;
1919 /* Pop 1 when jump not taken */
1920 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1921 next_pc
+= sizeof(struct logical_op
);
1927 struct logical_op
*insn
= (struct logical_op
*) pc
;
1929 if (estack_ax_t
!= REG_S64
&& estack_ax_t
!= REG_U64
) {
1933 /* If AX is nonzero, skip and evaluate to 1 */
1934 if (unlikely(estack_ax_v
!= 0)) {
1936 dbg_printf("Jumping to bytecode offset %u\n",
1937 (unsigned int) insn
->skip_offset
);
1938 next_pc
= start_pc
+ insn
->skip_offset
;
1940 /* Pop 1 when jump not taken */
1941 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1942 next_pc
+= sizeof(struct logical_op
);
1948 /* load field ref */
1949 OP(FILTER_OP_LOAD_FIELD_REF_STRING
):
1951 struct load_op
*insn
= (struct load_op
*) pc
;
1952 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1954 dbg_printf("load field ref offset %u type string\n",
1956 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1957 estack_ax(stack
, top
)->u
.s
.str
=
1958 *(const char * const *) &interpreter_stack_data
[ref
->offset
];
1959 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1960 dbg_printf("Filter warning: loading a NULL string.\n");
1964 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1965 estack_ax(stack
, top
)->u
.s
.literal_type
=
1966 ESTACK_STRING_LITERAL_TYPE_NONE
;
1967 estack_ax_t
= REG_STRING
;
1968 dbg_printf("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1969 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1973 OP(FILTER_OP_LOAD_FIELD_REF_SEQUENCE
):
1975 struct load_op
*insn
= (struct load_op
*) pc
;
1976 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1978 dbg_printf("load field ref offset %u type sequence\n",
1980 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1981 estack_ax(stack
, top
)->u
.s
.seq_len
=
1982 *(unsigned long *) &interpreter_stack_data
[ref
->offset
];
1983 estack_ax(stack
, top
)->u
.s
.str
=
1984 *(const char **) (&interpreter_stack_data
[ref
->offset
1985 + sizeof(unsigned long)]);
1986 estack_ax_t
= REG_STRING
;
1987 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1988 dbg_printf("Filter warning: loading a NULL sequence.\n");
1992 estack_ax(stack
, top
)->u
.s
.literal_type
=
1993 ESTACK_STRING_LITERAL_TYPE_NONE
;
1994 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1998 OP(FILTER_OP_LOAD_FIELD_REF_S64
):
2000 struct load_op
*insn
= (struct load_op
*) pc
;
2001 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2003 dbg_printf("load field ref offset %u type s64\n",
2005 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2007 ((struct literal_numeric
*) &interpreter_stack_data
[ref
->offset
])->v
;
2008 estack_ax_t
= REG_S64
;
2009 dbg_printf("ref load s64 %" PRIi64
"\n", estack_ax_v
);
2010 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2014 OP(FILTER_OP_LOAD_FIELD_REF_DOUBLE
):
2016 struct load_op
*insn
= (struct load_op
*) pc
;
2017 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2019 dbg_printf("load field ref offset %u type double\n",
2021 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2022 memcpy(&estack_ax(stack
, top
)->u
.d
, &interpreter_stack_data
[ref
->offset
],
2023 sizeof(struct literal_double
));
2024 estack_ax_t
= REG_DOUBLE
;
2025 dbg_printf("ref load double %g\n", estack_ax(stack
, top
)->u
.d
);
2026 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2030 /* load from immediate operand */
2031 OP(FILTER_OP_LOAD_STRING
):
2033 struct load_op
*insn
= (struct load_op
*) pc
;
2035 dbg_printf("load string %s\n", insn
->data
);
2036 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2037 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
2038 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2039 estack_ax(stack
, top
)->u
.s
.literal_type
=
2040 ESTACK_STRING_LITERAL_TYPE_PLAIN
;
2041 estack_ax_t
= REG_STRING
;
2042 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
2046 OP(FILTER_OP_LOAD_STAR_GLOB_STRING
):
2048 struct load_op
*insn
= (struct load_op
*) pc
;
2050 dbg_printf("load globbing pattern %s\n", insn
->data
);
2051 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2052 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
2053 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2054 estack_ax(stack
, top
)->u
.s
.literal_type
=
2055 ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
;
2056 estack_ax_t
= REG_STAR_GLOB_STRING
;
2057 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
2061 OP(FILTER_OP_LOAD_S64
):
2063 struct load_op
*insn
= (struct load_op
*) pc
;
2065 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2066 estack_ax_v
= ((struct literal_numeric
*) insn
->data
)->v
;
2067 estack_ax_t
= REG_S64
;
2068 dbg_printf("load s64 %" PRIi64
"\n", estack_ax_v
);
2069 next_pc
+= sizeof(struct load_op
)
2070 + sizeof(struct literal_numeric
);
2074 OP(FILTER_OP_LOAD_DOUBLE
):
2076 struct load_op
*insn
= (struct load_op
*) pc
;
2078 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2079 memcpy(&estack_ax(stack
, top
)->u
.d
, insn
->data
,
2080 sizeof(struct literal_double
));
2081 estack_ax_t
= REG_DOUBLE
;
2082 dbg_printf("load double %g\n", estack_ax(stack
, top
)->u
.d
);
2083 next_pc
+= sizeof(struct load_op
)
2084 + sizeof(struct literal_double
);
2089 OP(FILTER_OP_CAST_TO_S64
):
2091 /* Dynamic typing. */
2092 switch (estack_ax_t
) {
2094 JUMP_TO(FILTER_OP_CAST_NOP
);
2096 JUMP_TO(FILTER_OP_CAST_DOUBLE_TO_S64
);
2098 estack_ax_t
= REG_S64
;
2099 next_pc
+= sizeof(struct cast_op
);
2100 case REG_STRING
: /* Fall-through */
2101 case REG_STAR_GLOB_STRING
:
2105 ERR("Unknown filter register type (%d)",
2112 OP(FILTER_OP_CAST_DOUBLE_TO_S64
):
2114 estack_ax_v
= (int64_t) estack_ax(stack
, top
)->u
.d
;
2115 estack_ax_t
= REG_S64
;
2116 next_pc
+= sizeof(struct cast_op
);
2120 OP(FILTER_OP_CAST_NOP
):
2122 next_pc
+= sizeof(struct cast_op
);
2126 /* get context ref */
2127 OP(FILTER_OP_GET_CONTEXT_REF
):
2129 struct load_op
*insn
= (struct load_op
*) pc
;
2130 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2131 struct lttng_ctx_field
*ctx_field
;
2132 struct lttng_ctx_value v
;
2134 dbg_printf("get context ref offset %u type dynamic\n",
2136 ctx_field
= &ctx
->fields
[ref
->offset
];
2137 ctx_field
->get_value(ctx_field
, &v
);
2138 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2140 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
2143 case LTTNG_UST_DYNAMIC_TYPE_S64
:
2144 estack_ax_v
= v
.u
.s64
;
2145 estack_ax_t
= REG_S64
;
2146 dbg_printf("ref get context dynamic s64 %" PRIi64
"\n", estack_ax_v
);
2148 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
2149 estack_ax(stack
, top
)->u
.d
= v
.u
.d
;
2150 estack_ax_t
= REG_DOUBLE
;
2151 dbg_printf("ref get context dynamic double %g\n", estack_ax(stack
, top
)->u
.d
);
2153 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
2154 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2155 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2156 dbg_printf("Filter warning: loading a NULL string.\n");
2160 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2161 estack_ax(stack
, top
)->u
.s
.literal_type
=
2162 ESTACK_STRING_LITERAL_TYPE_NONE
;
2163 dbg_printf("ref get context dynamic string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2164 estack_ax_t
= REG_STRING
;
2167 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
2171 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2175 OP(FILTER_OP_GET_CONTEXT_REF_STRING
):
2177 struct load_op
*insn
= (struct load_op
*) pc
;
2178 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2179 struct lttng_ctx_field
*ctx_field
;
2180 struct lttng_ctx_value v
;
2182 dbg_printf("get context ref offset %u type string\n",
2184 ctx_field
= &ctx
->fields
[ref
->offset
];
2185 ctx_field
->get_value(ctx_field
, &v
);
2186 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2187 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2188 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2189 dbg_printf("Filter warning: loading a NULL string.\n");
2193 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2194 estack_ax(stack
, top
)->u
.s
.literal_type
=
2195 ESTACK_STRING_LITERAL_TYPE_NONE
;
2196 estack_ax_t
= REG_STRING
;
2197 dbg_printf("ref get context string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2198 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2202 OP(FILTER_OP_GET_CONTEXT_REF_S64
):
2204 struct load_op
*insn
= (struct load_op
*) pc
;
2205 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2206 struct lttng_ctx_field
*ctx_field
;
2207 struct lttng_ctx_value v
;
2209 dbg_printf("get context ref offset %u type s64\n",
2211 ctx_field
= &ctx
->fields
[ref
->offset
];
2212 ctx_field
->get_value(ctx_field
, &v
);
2213 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2214 estack_ax_v
= v
.u
.s64
;
2215 estack_ax_t
= REG_S64
;
2216 dbg_printf("ref get context s64 %" PRIi64
"\n", estack_ax_v
);
2217 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2221 OP(FILTER_OP_GET_CONTEXT_REF_DOUBLE
):
2223 struct load_op
*insn
= (struct load_op
*) pc
;
2224 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2225 struct lttng_ctx_field
*ctx_field
;
2226 struct lttng_ctx_value v
;
2228 dbg_printf("get context ref offset %u type double\n",
2230 ctx_field
= &ctx
->fields
[ref
->offset
];
2231 ctx_field
->get_value(ctx_field
, &v
);
2232 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2233 memcpy(&estack_ax(stack
, top
)->u
.d
, &v
.u
.d
, sizeof(struct literal_double
));
2234 estack_ax_t
= REG_DOUBLE
;
2235 dbg_printf("ref get context double %g\n", estack_ax(stack
, top
)->u
.d
);
2236 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2240 OP(FILTER_OP_GET_CONTEXT_ROOT
):
2242 dbg_printf("op get context root\n");
2243 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2244 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_CONTEXT
;
2245 /* "field" only needed for variants. */
2246 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2247 estack_ax_t
= REG_PTR
;
2248 next_pc
+= sizeof(struct load_op
);
2252 OP(FILTER_OP_GET_APP_CONTEXT_ROOT
):
2254 dbg_printf("op get app context root\n");
2255 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2256 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_APP_CONTEXT
;
2257 /* "field" only needed for variants. */
2258 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2259 estack_ax_t
= REG_PTR
;
2260 next_pc
+= sizeof(struct load_op
);
2264 OP(FILTER_OP_GET_PAYLOAD_ROOT
):
2266 dbg_printf("op get app payload root\n");
2267 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2268 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_PAYLOAD
;
2269 estack_ax(stack
, top
)->u
.ptr
.ptr
= interpreter_stack_data
;
2270 /* "field" only needed for variants. */
2271 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2272 estack_ax_t
= REG_PTR
;
2273 next_pc
+= sizeof(struct load_op
);
2277 OP(FILTER_OP_GET_SYMBOL
):
2279 dbg_printf("op get symbol\n");
2280 switch (estack_ax(stack
, top
)->u
.ptr
.type
) {
2282 ERR("Nested fields not implemented yet.");
2285 case LOAD_ROOT_CONTEXT
:
2286 case LOAD_ROOT_APP_CONTEXT
:
2287 case LOAD_ROOT_PAYLOAD
:
2289 * symbol lookup is performed by
2295 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_symbol
);
2299 OP(FILTER_OP_GET_SYMBOL_FIELD
):
2302 * Used for first variant encountered in a
2303 * traversal. Variants are not implemented yet.
2309 OP(FILTER_OP_GET_INDEX_U16
):
2311 struct load_op
*insn
= (struct load_op
*) pc
;
2312 struct get_index_u16
*index
= (struct get_index_u16
*) insn
->data
;
2314 dbg_printf("op get index u16\n");
2315 ret
= dynamic_get_index(ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
2318 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2319 estack_ax_t
= estack_ax(stack
, top
)->type
;
2320 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u16
);
2324 OP(FILTER_OP_GET_INDEX_U64
):
2326 struct load_op
*insn
= (struct load_op
*) pc
;
2327 struct get_index_u64
*index
= (struct get_index_u64
*) insn
->data
;
2329 dbg_printf("op get index u64\n");
2330 ret
= dynamic_get_index(ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
2333 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2334 estack_ax_t
= estack_ax(stack
, top
)->type
;
2335 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u64
);
2339 OP(FILTER_OP_LOAD_FIELD
):
2341 dbg_printf("op load field\n");
2342 ret
= dynamic_load_field(estack_ax(stack
, top
));
2345 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2346 estack_ax_t
= estack_ax(stack
, top
)->type
;
2347 next_pc
+= sizeof(struct load_op
);
2351 OP(FILTER_OP_LOAD_FIELD_S8
):
2353 dbg_printf("op load field s8\n");
2355 estack_ax_v
= *(int8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2356 estack_ax_t
= REG_S64
;
2357 next_pc
+= sizeof(struct load_op
);
2360 OP(FILTER_OP_LOAD_FIELD_S16
):
2362 dbg_printf("op load field s16\n");
2364 estack_ax_v
= *(int16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2365 estack_ax_t
= REG_S64
;
2366 next_pc
+= sizeof(struct load_op
);
2369 OP(FILTER_OP_LOAD_FIELD_S32
):
2371 dbg_printf("op load field s32\n");
2373 estack_ax_v
= *(int32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2374 estack_ax_t
= REG_S64
;
2375 next_pc
+= sizeof(struct load_op
);
2378 OP(FILTER_OP_LOAD_FIELD_S64
):
2380 dbg_printf("op load field s64\n");
2382 estack_ax_v
= *(int64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2383 estack_ax_t
= REG_S64
;
2384 next_pc
+= sizeof(struct load_op
);
2387 OP(FILTER_OP_LOAD_FIELD_U8
):
2389 dbg_printf("op load field u8\n");
2391 estack_ax_v
= *(uint8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2392 estack_ax_t
= REG_U64
;
2393 next_pc
+= sizeof(struct load_op
);
2396 OP(FILTER_OP_LOAD_FIELD_U16
):
2398 dbg_printf("op load field u16\n");
2400 estack_ax_v
= *(uint16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2401 estack_ax_t
= REG_U64
;
2402 next_pc
+= sizeof(struct load_op
);
2405 OP(FILTER_OP_LOAD_FIELD_U32
):
2407 dbg_printf("op load field u32\n");
2409 estack_ax_v
= *(uint32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2410 estack_ax_t
= REG_U64
;
2411 next_pc
+= sizeof(struct load_op
);
2414 OP(FILTER_OP_LOAD_FIELD_U64
):
2416 dbg_printf("op load field u64\n");
2418 estack_ax_v
= *(uint64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2419 estack_ax_t
= REG_U64
;
2420 next_pc
+= sizeof(struct load_op
);
2423 OP(FILTER_OP_LOAD_FIELD_DOUBLE
):
2425 dbg_printf("op load field double\n");
2427 memcpy(&estack_ax(stack
, top
)->u
.d
,
2428 estack_ax(stack
, top
)->u
.ptr
.ptr
,
2429 sizeof(struct literal_double
));
2430 estack_ax(stack
, top
)->type
= REG_DOUBLE
;
2431 next_pc
+= sizeof(struct load_op
);
2435 OP(FILTER_OP_LOAD_FIELD_STRING
):
2439 dbg_printf("op load field string\n");
2440 str
= (const char *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2441 estack_ax(stack
, top
)->u
.s
.str
= str
;
2442 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2443 dbg_printf("Filter warning: loading a NULL string.\n");
2447 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2448 estack_ax(stack
, top
)->u
.s
.literal_type
=
2449 ESTACK_STRING_LITERAL_TYPE_NONE
;
2450 estack_ax(stack
, top
)->type
= REG_STRING
;
2451 next_pc
+= sizeof(struct load_op
);
2455 OP(FILTER_OP_LOAD_FIELD_SEQUENCE
):
2459 dbg_printf("op load field string sequence\n");
2460 ptr
= estack_ax(stack
, top
)->u
.ptr
.ptr
;
2461 estack_ax(stack
, top
)->u
.s
.seq_len
= *(unsigned long *) ptr
;
2462 estack_ax(stack
, top
)->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
2463 estack_ax(stack
, top
)->type
= REG_STRING
;
2464 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2465 dbg_printf("Filter warning: loading a NULL sequence.\n");
2469 estack_ax(stack
, top
)->u
.s
.literal_type
=
2470 ESTACK_STRING_LITERAL_TYPE_NONE
;
2471 next_pc
+= sizeof(struct load_op
);
2477 /* Return _DISCARD on error. */
2479 return LTTNG_FILTER_DISCARD
;
2482 return lttng_bytecode_interpret_format_output(estack_ax(stack
, top
),
2489 uint64_t lttng_filter_interpret_bytecode(void *filter_data
,
2490 const char *filter_stack_data
)
2492 return bytecode_interpret(filter_data
, filter_stack_data
, NULL
);