2 * lttng-filter-interpreter.c
4 * LTTng UST filter interpreter.
6 * Copyright (C) 2010-2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 #include <urcu-pointer.h>
31 #include <lttng/ust-endian.h>
32 #include "lttng-filter.h"
33 #include "string-utils.h"
37 * -2: unknown escape char.
42 int parse_char(const char **p
)
62 * Returns SIZE_MAX if the string is null-terminated, or the number of
66 size_t get_str_or_seq_len(const struct estack_entry
*entry
)
68 return entry
->u
.s
.seq_len
;
72 int stack_star_glob_match(struct estack
*stack
, int top
, const char *cmp_type
)
75 const char *candidate
;
79 /* Find out which side is the pattern vs. the candidate. */
80 if (estack_ax(stack
, top
)->u
.s
.literal_type
== ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
) {
81 pattern
= estack_ax(stack
, top
)->u
.s
.str
;
82 pattern_len
= get_str_or_seq_len(estack_ax(stack
, top
));
83 candidate
= estack_bx(stack
, top
)->u
.s
.str
;
84 candidate_len
= get_str_or_seq_len(estack_bx(stack
, top
));
86 pattern
= estack_bx(stack
, top
)->u
.s
.str
;
87 pattern_len
= get_str_or_seq_len(estack_bx(stack
, top
));
88 candidate
= estack_ax(stack
, top
)->u
.s
.str
;
89 candidate_len
= get_str_or_seq_len(estack_ax(stack
, top
));
92 /* Perform the match. Returns 0 when the result is true. */
93 return !strutils_star_glob_match(pattern
, pattern_len
, candidate
,
98 int stack_strcmp(struct estack
*stack
, int top
, const char *cmp_type
)
100 const char *p
= estack_bx(stack
, top
)->u
.s
.str
, *q
= estack_ax(stack
, top
)->u
.s
.str
;
107 if (unlikely(p
- estack_bx(stack
, top
)->u
.s
.str
>= estack_bx(stack
, top
)->u
.s
.seq_len
|| *p
== '\0')) {
108 if (q
- estack_ax(stack
, top
)->u
.s
.str
>= estack_ax(stack
, top
)->u
.s
.seq_len
|| *q
== '\0') {
111 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
112 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
113 ret
= parse_char(&q
);
120 if (unlikely(q
- estack_ax(stack
, top
)->u
.s
.str
>= estack_ax(stack
, top
)->u
.s
.seq_len
|| *q
== '\0')) {
121 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
122 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
123 ret
= parse_char(&p
);
129 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
130 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
131 ret
= parse_char(&p
);
134 } else if (ret
== -2) {
137 /* else compare both char */
139 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
140 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
141 ret
= parse_char(&q
);
144 } else if (ret
== -2) {
164 uint64_t lttng_filter_false(void *filter_data
,
165 const char *filter_stack_data
)
167 return LTTNG_FILTER_DISCARD
;
170 #ifdef INTERPRETER_USE_SWITCH
173 * Fallback for compilers that do not support taking address of labels.
177 start_pc = &bytecode->data[0]; \
178 for (pc = next_pc = start_pc; pc - start_pc < bytecode->len; \
180 dbg_printf("Executing op %s (%u)\n", \
181 print_op((unsigned int) *(filter_opcode_t *) pc), \
182 (unsigned int) *(filter_opcode_t *) pc); \
183 switch (*(filter_opcode_t *) pc) {
185 #define OP(name) jump_target_##name: __attribute__((unused)); \
193 #define JUMP_TO(name) \
194 goto jump_target_##name
199 * Dispatch-table based interpreter.
203 start_pc = &bytecode->code[0]; \
204 pc = next_pc = start_pc; \
205 if (unlikely(pc - start_pc >= bytecode->len)) \
207 goto *dispatch[*(filter_opcode_t *) pc];
214 goto *dispatch[*(filter_opcode_t *) pc];
218 #define JUMP_TO(name) \
223 static int context_get_index(struct lttng_ctx
*ctx
,
224 struct load_ptr
*ptr
,
228 struct lttng_ctx_field
*ctx_field
;
229 struct lttng_event_field
*field
;
230 struct lttng_ctx_value v
;
232 ctx_field
= &ctx
->fields
[idx
];
233 field
= &ctx_field
->event_field
;
234 ptr
->type
= LOAD_OBJECT
;
235 /* field is only used for types nested within variants. */
238 switch (field
->type
.atype
) {
240 ctx_field
->get_value(ctx_field
, &v
);
241 if (field
->type
.u
.integer
.signedness
) {
242 ptr
->object_type
= OBJECT_TYPE_S64
;
243 ptr
->u
.s64
= v
.u
.s64
;
244 ptr
->ptr
= &ptr
->u
.s64
;
246 ptr
->object_type
= OBJECT_TYPE_U64
;
247 ptr
->u
.u64
= v
.u
.s64
; /* Cast. */
248 ptr
->ptr
= &ptr
->u
.u64
;
251 case atype_enum
: /* Fall-through */
252 case atype_enum_nestable
:
254 const struct lttng_integer_type
*itype
;
256 if (field
->type
.atype
== atype_enum
) {
257 itype
= &field
->type
.u
.legacy
.basic
.enumeration
.container_type
;
259 itype
= &field
->type
.u
.enum_nestable
.container_type
->u
.integer
;
261 ctx_field
->get_value(ctx_field
, &v
);
262 if (itype
->signedness
) {
263 ptr
->object_type
= OBJECT_TYPE_S64
;
264 ptr
->u
.s64
= v
.u
.s64
;
265 ptr
->ptr
= &ptr
->u
.s64
;
267 ptr
->object_type
= OBJECT_TYPE_U64
;
268 ptr
->u
.u64
= v
.u
.s64
; /* Cast. */
269 ptr
->ptr
= &ptr
->u
.u64
;
274 if (field
->type
.u
.legacy
.array
.elem_type
.atype
!= atype_integer
) {
275 ERR("Array nesting only supports integer types.");
278 if (field
->type
.u
.legacy
.array
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
279 ERR("Only string arrays are supported for contexts.");
282 ptr
->object_type
= OBJECT_TYPE_STRING
;
283 ctx_field
->get_value(ctx_field
, &v
);
286 case atype_array_nestable
:
287 if (field
->type
.u
.array_nestable
.elem_type
->atype
!= atype_integer
) {
288 ERR("Array nesting only supports integer types.");
291 if (field
->type
.u
.array_nestable
.elem_type
->u
.integer
.encoding
== lttng_encode_none
) {
292 ERR("Only string arrays are supported for contexts.");
295 ptr
->object_type
= OBJECT_TYPE_STRING
;
296 ctx_field
->get_value(ctx_field
, &v
);
300 if (field
->type
.u
.legacy
.sequence
.elem_type
.atype
!= atype_integer
) {
301 ERR("Sequence nesting only supports integer types.");
304 if (field
->type
.u
.legacy
.sequence
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
305 ERR("Only string sequences are supported for contexts.");
308 ptr
->object_type
= OBJECT_TYPE_STRING
;
309 ctx_field
->get_value(ctx_field
, &v
);
312 case atype_sequence_nestable
:
313 if (field
->type
.u
.sequence_nestable
.elem_type
->atype
!= atype_integer
) {
314 ERR("Sequence nesting only supports integer types.");
317 if (field
->type
.u
.sequence_nestable
.elem_type
->u
.integer
.encoding
== lttng_encode_none
) {
318 ERR("Only string sequences are supported for contexts.");
321 ptr
->object_type
= OBJECT_TYPE_STRING
;
322 ctx_field
->get_value(ctx_field
, &v
);
326 ptr
->object_type
= OBJECT_TYPE_STRING
;
327 ctx_field
->get_value(ctx_field
, &v
);
331 ptr
->object_type
= OBJECT_TYPE_DOUBLE
;
332 ctx_field
->get_value(ctx_field
, &v
);
334 ptr
->ptr
= &ptr
->u
.d
;
337 ctx_field
->get_value(ctx_field
, &v
);
339 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
341 case LTTNG_UST_DYNAMIC_TYPE_S64
:
342 ptr
->object_type
= OBJECT_TYPE_S64
;
343 ptr
->u
.s64
= v
.u
.s64
;
344 ptr
->ptr
= &ptr
->u
.s64
;
345 dbg_printf("context get index dynamic s64 %" PRIi64
"\n", ptr
->u
.s64
);
347 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
348 ptr
->object_type
= OBJECT_TYPE_DOUBLE
;
350 ptr
->ptr
= &ptr
->u
.d
;
351 dbg_printf("context get index dynamic double %g\n", ptr
->u
.d
);
353 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
354 ptr
->object_type
= OBJECT_TYPE_STRING
;
356 dbg_printf("context get index dynamic string %s\n", (const char *) ptr
->ptr
);
359 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
364 ERR("Structure type cannot be loaded.");
367 ERR("Unknown type: %d", (int) field
->type
.atype
);
373 static int dynamic_get_index(struct lttng_ctx
*ctx
,
374 struct bytecode_runtime
*runtime
,
375 uint64_t index
, struct estack_entry
*stack_top
)
378 const struct filter_get_index_data
*gid
;
381 * Types nested within variants need to perform dynamic lookup
382 * based on the field descriptions. LTTng-UST does not implement
385 if (stack_top
->u
.ptr
.field
)
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 /* field is only used for types nested within variants. */
403 stack_top
->u
.ptr
.field
= NULL
;
406 case OBJECT_TYPE_SEQUENCE
:
411 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
412 ptr_seq_len
= *(unsigned long *) stack_top
->u
.ptr
.ptr
;
413 if (gid
->offset
>= gid
->elem
.len
* ptr_seq_len
) {
417 ptr
= ptr
+ gid
->offset
;
418 stack_top
->u
.ptr
.ptr
= ptr
;
419 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
420 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
421 /* field is only used for types nested within variants. */
422 stack_top
->u
.ptr
.field
= NULL
;
425 case OBJECT_TYPE_STRUCT
:
426 ERR("Nested structures are not supported yet.");
429 case OBJECT_TYPE_VARIANT
:
431 ERR("Unexpected get index type %d",
432 (int) stack_top
->u
.ptr
.object_type
);
437 case LOAD_ROOT_CONTEXT
:
438 case LOAD_ROOT_APP_CONTEXT
: /* Fall-through */
440 ret
= context_get_index(ctx
,
448 case LOAD_ROOT_PAYLOAD
:
449 stack_top
->u
.ptr
.ptr
+= gid
->offset
;
450 if (gid
->elem
.type
== OBJECT_TYPE_STRING
)
451 stack_top
->u
.ptr
.ptr
= *(const char * const *) stack_top
->u
.ptr
.ptr
;
452 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
453 stack_top
->u
.ptr
.type
= LOAD_OBJECT
;
454 /* field is only used for types nested within variants. */
455 stack_top
->u
.ptr
.field
= NULL
;
464 static int dynamic_load_field(struct estack_entry
*stack_top
)
468 switch (stack_top
->u
.ptr
.type
) {
471 case LOAD_ROOT_CONTEXT
:
472 case LOAD_ROOT_APP_CONTEXT
:
473 case LOAD_ROOT_PAYLOAD
:
475 dbg_printf("Filter warning: cannot load root, missing field name.\n");
479 switch (stack_top
->u
.ptr
.object_type
) {
481 dbg_printf("op load field s8\n");
482 stack_top
->u
.v
= *(int8_t *) stack_top
->u
.ptr
.ptr
;
483 stack_top
->type
= REG_S64
;
485 case OBJECT_TYPE_S16
:
489 dbg_printf("op load field s16\n");
490 tmp
= *(int16_t *) stack_top
->u
.ptr
.ptr
;
491 if (stack_top
->u
.ptr
.rev_bo
)
493 stack_top
->u
.v
= tmp
;
494 stack_top
->type
= REG_S64
;
497 case OBJECT_TYPE_S32
:
501 dbg_printf("op load field s32\n");
502 tmp
= *(int32_t *) stack_top
->u
.ptr
.ptr
;
503 if (stack_top
->u
.ptr
.rev_bo
)
505 stack_top
->u
.v
= tmp
;
506 stack_top
->type
= REG_S64
;
509 case OBJECT_TYPE_S64
:
513 dbg_printf("op load field s64\n");
514 tmp
= *(int64_t *) stack_top
->u
.ptr
.ptr
;
515 if (stack_top
->u
.ptr
.rev_bo
)
517 stack_top
->u
.v
= tmp
;
518 stack_top
->type
= REG_S64
;
522 dbg_printf("op load field u8\n");
523 stack_top
->u
.v
= *(uint8_t *) stack_top
->u
.ptr
.ptr
;
524 stack_top
->type
= REG_S64
;
526 case OBJECT_TYPE_U16
:
530 dbg_printf("op load field u16\n");
531 tmp
= *(uint16_t *) stack_top
->u
.ptr
.ptr
;
532 if (stack_top
->u
.ptr
.rev_bo
)
534 stack_top
->u
.v
= tmp
;
535 stack_top
->type
= REG_S64
;
538 case OBJECT_TYPE_U32
:
542 dbg_printf("op load field u32\n");
543 tmp
= *(uint32_t *) stack_top
->u
.ptr
.ptr
;
544 if (stack_top
->u
.ptr
.rev_bo
)
546 stack_top
->u
.v
= tmp
;
547 stack_top
->type
= REG_S64
;
550 case OBJECT_TYPE_U64
:
554 dbg_printf("op load field u64\n");
555 tmp
= *(uint64_t *) stack_top
->u
.ptr
.ptr
;
556 if (stack_top
->u
.ptr
.rev_bo
)
558 stack_top
->u
.v
= tmp
;
559 stack_top
->type
= REG_S64
;
562 case OBJECT_TYPE_DOUBLE
:
563 memcpy(&stack_top
->u
.d
,
564 stack_top
->u
.ptr
.ptr
,
565 sizeof(struct literal_double
));
566 stack_top
->type
= REG_DOUBLE
;
568 case OBJECT_TYPE_STRING
:
572 dbg_printf("op load field string\n");
573 str
= (const char *) stack_top
->u
.ptr
.ptr
;
574 stack_top
->u
.s
.str
= str
;
575 if (unlikely(!stack_top
->u
.s
.str
)) {
576 dbg_printf("Filter warning: loading a NULL string.\n");
580 stack_top
->u
.s
.seq_len
= SIZE_MAX
;
581 stack_top
->u
.s
.literal_type
=
582 ESTACK_STRING_LITERAL_TYPE_NONE
;
583 stack_top
->type
= REG_STRING
;
586 case OBJECT_TYPE_STRING_SEQUENCE
:
590 dbg_printf("op load field string sequence\n");
591 ptr
= stack_top
->u
.ptr
.ptr
;
592 stack_top
->u
.s
.seq_len
= *(unsigned long *) ptr
;
593 stack_top
->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
594 stack_top
->type
= REG_STRING
;
595 if (unlikely(!stack_top
->u
.s
.str
)) {
596 dbg_printf("Filter warning: loading a NULL sequence.\n");
600 stack_top
->u
.s
.literal_type
=
601 ESTACK_STRING_LITERAL_TYPE_NONE
;
604 case OBJECT_TYPE_DYNAMIC
:
606 * Dynamic types in context are looked up
607 * by context get index.
611 case OBJECT_TYPE_SEQUENCE
:
612 case OBJECT_TYPE_ARRAY
:
613 case OBJECT_TYPE_STRUCT
:
614 case OBJECT_TYPE_VARIANT
:
615 ERR("Sequences, arrays, struct and variant cannot be loaded (nested types).");
626 * Return 0 (discard), or raise the 0x1 flag (log event).
627 * Currently, other flags are kept for future extensions and have no
630 uint64_t lttng_filter_interpret_bytecode(void *filter_data
,
631 const char *filter_stack_data
)
633 struct bytecode_runtime
*bytecode
= filter_data
;
634 struct lttng_ctx
*ctx
= rcu_dereference(*bytecode
->p
.pctx
);
635 void *pc
, *next_pc
, *start_pc
;
638 struct estack _stack
;
639 struct estack
*stack
= &_stack
;
640 register int64_t ax
= 0, bx
= 0;
641 register enum entry_type ax_t
= REG_UNKNOWN
, bx_t
= REG_UNKNOWN
;
642 register int top
= FILTER_STACK_EMPTY
;
643 #ifndef INTERPRETER_USE_SWITCH
644 static void *dispatch
[NR_FILTER_OPS
] = {
645 [ FILTER_OP_UNKNOWN
] = &&LABEL_FILTER_OP_UNKNOWN
,
647 [ FILTER_OP_RETURN
] = &&LABEL_FILTER_OP_RETURN
,
650 [ FILTER_OP_MUL
] = &&LABEL_FILTER_OP_MUL
,
651 [ FILTER_OP_DIV
] = &&LABEL_FILTER_OP_DIV
,
652 [ FILTER_OP_MOD
] = &&LABEL_FILTER_OP_MOD
,
653 [ FILTER_OP_PLUS
] = &&LABEL_FILTER_OP_PLUS
,
654 [ FILTER_OP_MINUS
] = &&LABEL_FILTER_OP_MINUS
,
655 [ FILTER_OP_BIT_RSHIFT
] = &&LABEL_FILTER_OP_BIT_RSHIFT
,
656 [ FILTER_OP_BIT_LSHIFT
] = &&LABEL_FILTER_OP_BIT_LSHIFT
,
657 [ FILTER_OP_BIT_AND
] = &&LABEL_FILTER_OP_BIT_AND
,
658 [ FILTER_OP_BIT_OR
] = &&LABEL_FILTER_OP_BIT_OR
,
659 [ FILTER_OP_BIT_XOR
] = &&LABEL_FILTER_OP_BIT_XOR
,
661 /* binary comparators */
662 [ FILTER_OP_EQ
] = &&LABEL_FILTER_OP_EQ
,
663 [ FILTER_OP_NE
] = &&LABEL_FILTER_OP_NE
,
664 [ FILTER_OP_GT
] = &&LABEL_FILTER_OP_GT
,
665 [ FILTER_OP_LT
] = &&LABEL_FILTER_OP_LT
,
666 [ FILTER_OP_GE
] = &&LABEL_FILTER_OP_GE
,
667 [ FILTER_OP_LE
] = &&LABEL_FILTER_OP_LE
,
669 /* string binary comparator */
670 [ FILTER_OP_EQ_STRING
] = &&LABEL_FILTER_OP_EQ_STRING
,
671 [ FILTER_OP_NE_STRING
] = &&LABEL_FILTER_OP_NE_STRING
,
672 [ FILTER_OP_GT_STRING
] = &&LABEL_FILTER_OP_GT_STRING
,
673 [ FILTER_OP_LT_STRING
] = &&LABEL_FILTER_OP_LT_STRING
,
674 [ FILTER_OP_GE_STRING
] = &&LABEL_FILTER_OP_GE_STRING
,
675 [ FILTER_OP_LE_STRING
] = &&LABEL_FILTER_OP_LE_STRING
,
677 /* globbing pattern binary comparator */
678 [ FILTER_OP_EQ_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_EQ_STAR_GLOB_STRING
,
679 [ FILTER_OP_NE_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_NE_STAR_GLOB_STRING
,
681 /* s64 binary comparator */
682 [ FILTER_OP_EQ_S64
] = &&LABEL_FILTER_OP_EQ_S64
,
683 [ FILTER_OP_NE_S64
] = &&LABEL_FILTER_OP_NE_S64
,
684 [ FILTER_OP_GT_S64
] = &&LABEL_FILTER_OP_GT_S64
,
685 [ FILTER_OP_LT_S64
] = &&LABEL_FILTER_OP_LT_S64
,
686 [ FILTER_OP_GE_S64
] = &&LABEL_FILTER_OP_GE_S64
,
687 [ FILTER_OP_LE_S64
] = &&LABEL_FILTER_OP_LE_S64
,
689 /* double binary comparator */
690 [ FILTER_OP_EQ_DOUBLE
] = &&LABEL_FILTER_OP_EQ_DOUBLE
,
691 [ FILTER_OP_NE_DOUBLE
] = &&LABEL_FILTER_OP_NE_DOUBLE
,
692 [ FILTER_OP_GT_DOUBLE
] = &&LABEL_FILTER_OP_GT_DOUBLE
,
693 [ FILTER_OP_LT_DOUBLE
] = &&LABEL_FILTER_OP_LT_DOUBLE
,
694 [ FILTER_OP_GE_DOUBLE
] = &&LABEL_FILTER_OP_GE_DOUBLE
,
695 [ FILTER_OP_LE_DOUBLE
] = &&LABEL_FILTER_OP_LE_DOUBLE
,
697 /* Mixed S64-double binary comparators */
698 [ FILTER_OP_EQ_DOUBLE_S64
] = &&LABEL_FILTER_OP_EQ_DOUBLE_S64
,
699 [ FILTER_OP_NE_DOUBLE_S64
] = &&LABEL_FILTER_OP_NE_DOUBLE_S64
,
700 [ FILTER_OP_GT_DOUBLE_S64
] = &&LABEL_FILTER_OP_GT_DOUBLE_S64
,
701 [ FILTER_OP_LT_DOUBLE_S64
] = &&LABEL_FILTER_OP_LT_DOUBLE_S64
,
702 [ FILTER_OP_GE_DOUBLE_S64
] = &&LABEL_FILTER_OP_GE_DOUBLE_S64
,
703 [ FILTER_OP_LE_DOUBLE_S64
] = &&LABEL_FILTER_OP_LE_DOUBLE_S64
,
705 [ FILTER_OP_EQ_S64_DOUBLE
] = &&LABEL_FILTER_OP_EQ_S64_DOUBLE
,
706 [ FILTER_OP_NE_S64_DOUBLE
] = &&LABEL_FILTER_OP_NE_S64_DOUBLE
,
707 [ FILTER_OP_GT_S64_DOUBLE
] = &&LABEL_FILTER_OP_GT_S64_DOUBLE
,
708 [ FILTER_OP_LT_S64_DOUBLE
] = &&LABEL_FILTER_OP_LT_S64_DOUBLE
,
709 [ FILTER_OP_GE_S64_DOUBLE
] = &&LABEL_FILTER_OP_GE_S64_DOUBLE
,
710 [ FILTER_OP_LE_S64_DOUBLE
] = &&LABEL_FILTER_OP_LE_S64_DOUBLE
,
713 [ FILTER_OP_UNARY_PLUS
] = &&LABEL_FILTER_OP_UNARY_PLUS
,
714 [ FILTER_OP_UNARY_MINUS
] = &&LABEL_FILTER_OP_UNARY_MINUS
,
715 [ FILTER_OP_UNARY_NOT
] = &&LABEL_FILTER_OP_UNARY_NOT
,
716 [ FILTER_OP_UNARY_PLUS_S64
] = &&LABEL_FILTER_OP_UNARY_PLUS_S64
,
717 [ FILTER_OP_UNARY_MINUS_S64
] = &&LABEL_FILTER_OP_UNARY_MINUS_S64
,
718 [ FILTER_OP_UNARY_NOT_S64
] = &&LABEL_FILTER_OP_UNARY_NOT_S64
,
719 [ FILTER_OP_UNARY_PLUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_PLUS_DOUBLE
,
720 [ FILTER_OP_UNARY_MINUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_MINUS_DOUBLE
,
721 [ FILTER_OP_UNARY_NOT_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_NOT_DOUBLE
,
724 [ FILTER_OP_AND
] = &&LABEL_FILTER_OP_AND
,
725 [ FILTER_OP_OR
] = &&LABEL_FILTER_OP_OR
,
728 [ FILTER_OP_LOAD_FIELD_REF
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF
,
729 [ FILTER_OP_LOAD_FIELD_REF_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_STRING
,
730 [ FILTER_OP_LOAD_FIELD_REF_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_SEQUENCE
,
731 [ FILTER_OP_LOAD_FIELD_REF_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_S64
,
732 [ FILTER_OP_LOAD_FIELD_REF_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_DOUBLE
,
734 /* load from immediate operand */
735 [ FILTER_OP_LOAD_STRING
] = &&LABEL_FILTER_OP_LOAD_STRING
,
736 [ FILTER_OP_LOAD_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_LOAD_STAR_GLOB_STRING
,
737 [ FILTER_OP_LOAD_S64
] = &&LABEL_FILTER_OP_LOAD_S64
,
738 [ FILTER_OP_LOAD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_DOUBLE
,
741 [ FILTER_OP_CAST_TO_S64
] = &&LABEL_FILTER_OP_CAST_TO_S64
,
742 [ FILTER_OP_CAST_DOUBLE_TO_S64
] = &&LABEL_FILTER_OP_CAST_DOUBLE_TO_S64
,
743 [ FILTER_OP_CAST_NOP
] = &&LABEL_FILTER_OP_CAST_NOP
,
745 /* get context ref */
746 [ FILTER_OP_GET_CONTEXT_REF
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF
,
747 [ FILTER_OP_GET_CONTEXT_REF_STRING
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_STRING
,
748 [ FILTER_OP_GET_CONTEXT_REF_S64
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_S64
,
749 [ FILTER_OP_GET_CONTEXT_REF_DOUBLE
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_DOUBLE
,
751 /* Instructions for recursive traversal through composed types. */
752 [ FILTER_OP_GET_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_CONTEXT_ROOT
,
753 [ FILTER_OP_GET_APP_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_APP_CONTEXT_ROOT
,
754 [ FILTER_OP_GET_PAYLOAD_ROOT
] = &&LABEL_FILTER_OP_GET_PAYLOAD_ROOT
,
756 [ FILTER_OP_GET_SYMBOL
] = &&LABEL_FILTER_OP_GET_SYMBOL
,
757 [ FILTER_OP_GET_SYMBOL_FIELD
] = &&LABEL_FILTER_OP_GET_SYMBOL_FIELD
,
758 [ FILTER_OP_GET_INDEX_U16
] = &&LABEL_FILTER_OP_GET_INDEX_U16
,
759 [ FILTER_OP_GET_INDEX_U64
] = &&LABEL_FILTER_OP_GET_INDEX_U64
,
761 [ FILTER_OP_LOAD_FIELD
] = &&LABEL_FILTER_OP_LOAD_FIELD
,
762 [ FILTER_OP_LOAD_FIELD_S8
] = &&LABEL_FILTER_OP_LOAD_FIELD_S8
,
763 [ FILTER_OP_LOAD_FIELD_S16
] = &&LABEL_FILTER_OP_LOAD_FIELD_S16
,
764 [ FILTER_OP_LOAD_FIELD_S32
] = &&LABEL_FILTER_OP_LOAD_FIELD_S32
,
765 [ FILTER_OP_LOAD_FIELD_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_S64
,
766 [ FILTER_OP_LOAD_FIELD_U8
] = &&LABEL_FILTER_OP_LOAD_FIELD_U8
,
767 [ FILTER_OP_LOAD_FIELD_U16
] = &&LABEL_FILTER_OP_LOAD_FIELD_U16
,
768 [ FILTER_OP_LOAD_FIELD_U32
] = &&LABEL_FILTER_OP_LOAD_FIELD_U32
,
769 [ FILTER_OP_LOAD_FIELD_U64
] = &&LABEL_FILTER_OP_LOAD_FIELD_U64
,
770 [ FILTER_OP_LOAD_FIELD_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_STRING
,
771 [ FILTER_OP_LOAD_FIELD_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_SEQUENCE
,
772 [ FILTER_OP_LOAD_FIELD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_DOUBLE
,
774 [ FILTER_OP_UNARY_BIT_NOT
] = &&LABEL_FILTER_OP_UNARY_BIT_NOT
,
776 [ FILTER_OP_RETURN_S64
] = &&LABEL_FILTER_OP_RETURN_S64
,
778 #endif /* #ifndef INTERPRETER_USE_SWITCH */
782 OP(FILTER_OP_UNKNOWN
):
783 OP(FILTER_OP_LOAD_FIELD_REF
):
784 #ifdef INTERPRETER_USE_SWITCH
786 #endif /* INTERPRETER_USE_SWITCH */
787 ERR("unknown bytecode op %u",
788 (unsigned int) *(filter_opcode_t
*) pc
);
792 OP(FILTER_OP_RETURN
):
793 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
794 /* Handle dynamic typing. */
795 switch (estack_ax_t
) {
797 retval
= !!estack_ax_v
;
801 case REG_STAR_GLOB_STRING
:
809 OP(FILTER_OP_RETURN_S64
):
810 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
811 retval
= !!estack_ax_v
;
821 ERR("unsupported bytecode op %u",
822 (unsigned int) *(filter_opcode_t
*) pc
);
828 /* Dynamic typing. */
829 switch (estack_ax_t
) {
831 switch (estack_bx_t
) {
833 JUMP_TO(FILTER_OP_EQ_S64
);
835 JUMP_TO(FILTER_OP_EQ_DOUBLE_S64
);
836 case REG_STRING
: /* Fall-through */
837 case REG_STAR_GLOB_STRING
:
841 ERR("Unknown filter register type (%d)",
848 switch (estack_bx_t
) {
850 JUMP_TO(FILTER_OP_EQ_S64_DOUBLE
);
852 JUMP_TO(FILTER_OP_EQ_DOUBLE
);
853 case REG_STRING
: /* Fall-through */
854 case REG_STAR_GLOB_STRING
:
858 ERR("Unknown filter register type (%d)",
865 switch (estack_bx_t
) {
866 case REG_S64
: /* Fall-through */
871 JUMP_TO(FILTER_OP_EQ_STRING
);
872 case REG_STAR_GLOB_STRING
:
873 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
875 ERR("Unknown filter register type (%d)",
881 case REG_STAR_GLOB_STRING
:
882 switch (estack_bx_t
) {
883 case REG_S64
: /* Fall-through */
888 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
889 case REG_STAR_GLOB_STRING
:
893 ERR("Unknown filter register type (%d)",
900 ERR("Unknown filter register type (%d)",
908 /* Dynamic typing. */
909 switch (estack_ax_t
) {
911 switch (estack_bx_t
) {
913 JUMP_TO(FILTER_OP_NE_S64
);
915 JUMP_TO(FILTER_OP_NE_DOUBLE_S64
);
916 case REG_STRING
: /* Fall-through */
917 case REG_STAR_GLOB_STRING
:
921 ERR("Unknown filter register type (%d)",
928 switch (estack_bx_t
) {
930 JUMP_TO(FILTER_OP_NE_S64_DOUBLE
);
932 JUMP_TO(FILTER_OP_NE_DOUBLE
);
933 case REG_STRING
: /* Fall-through */
934 case REG_STAR_GLOB_STRING
:
938 ERR("Unknown filter register type (%d)",
945 switch (estack_bx_t
) {
946 case REG_S64
: /* Fall-through */
951 JUMP_TO(FILTER_OP_NE_STRING
);
952 case REG_STAR_GLOB_STRING
:
953 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
955 ERR("Unknown filter register type (%d)",
961 case REG_STAR_GLOB_STRING
:
962 switch (estack_bx_t
) {
963 case REG_S64
: /* Fall-through */
968 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
969 case REG_STAR_GLOB_STRING
:
973 ERR("Unknown filter register type (%d)",
980 ERR("Unknown filter register type (%d)",
988 /* Dynamic typing. */
989 switch (estack_ax_t
) {
991 switch (estack_bx_t
) {
993 JUMP_TO(FILTER_OP_GT_S64
);
995 JUMP_TO(FILTER_OP_GT_DOUBLE_S64
);
996 case REG_STRING
: /* Fall-through */
997 case REG_STAR_GLOB_STRING
:
1001 ERR("Unknown filter register type (%d)",
1008 switch (estack_bx_t
) {
1010 JUMP_TO(FILTER_OP_GT_S64_DOUBLE
);
1012 JUMP_TO(FILTER_OP_GT_DOUBLE
);
1013 case REG_STRING
: /* Fall-through */
1014 case REG_STAR_GLOB_STRING
:
1018 ERR("Unknown filter register type (%d)",
1025 switch (estack_bx_t
) {
1026 case REG_S64
: /* Fall-through */
1027 case REG_DOUBLE
: /* Fall-through */
1028 case REG_STAR_GLOB_STRING
:
1032 JUMP_TO(FILTER_OP_GT_STRING
);
1034 ERR("Unknown filter register type (%d)",
1041 ERR("Unknown filter register type (%d)",
1049 /* Dynamic typing. */
1050 switch (estack_ax_t
) {
1052 switch (estack_bx_t
) {
1054 JUMP_TO(FILTER_OP_LT_S64
);
1056 JUMP_TO(FILTER_OP_LT_DOUBLE_S64
);
1057 case REG_STRING
: /* Fall-through */
1058 case REG_STAR_GLOB_STRING
:
1062 ERR("Unknown filter register type (%d)",
1069 switch (estack_bx_t
) {
1071 JUMP_TO(FILTER_OP_LT_S64_DOUBLE
);
1073 JUMP_TO(FILTER_OP_LT_DOUBLE
);
1074 case REG_STRING
: /* Fall-through */
1075 case REG_STAR_GLOB_STRING
:
1079 ERR("Unknown filter register type (%d)",
1086 switch (estack_bx_t
) {
1087 case REG_S64
: /* Fall-through */
1088 case REG_DOUBLE
: /* Fall-through */
1089 case REG_STAR_GLOB_STRING
:
1093 JUMP_TO(FILTER_OP_LT_STRING
);
1095 ERR("Unknown filter register type (%d)",
1102 ERR("Unknown filter register type (%d)",
1110 /* Dynamic typing. */
1111 switch (estack_ax_t
) {
1113 switch (estack_bx_t
) {
1115 JUMP_TO(FILTER_OP_GE_S64
);
1117 JUMP_TO(FILTER_OP_GE_DOUBLE_S64
);
1118 case REG_STRING
: /* Fall-through */
1119 case REG_STAR_GLOB_STRING
:
1123 ERR("Unknown filter register type (%d)",
1130 switch (estack_bx_t
) {
1132 JUMP_TO(FILTER_OP_GE_S64_DOUBLE
);
1134 JUMP_TO(FILTER_OP_GE_DOUBLE
);
1135 case REG_STRING
: /* Fall-through */
1136 case REG_STAR_GLOB_STRING
:
1140 ERR("Unknown filter register type (%d)",
1147 switch (estack_bx_t
) {
1148 case REG_S64
: /* Fall-through */
1149 case REG_DOUBLE
: /* Fall-through */
1150 case REG_STAR_GLOB_STRING
:
1154 JUMP_TO(FILTER_OP_GE_STRING
);
1156 ERR("Unknown filter register type (%d)",
1163 ERR("Unknown filter register type (%d)",
1171 /* Dynamic typing. */
1172 switch (estack_ax_t
) {
1174 switch (estack_bx_t
) {
1176 JUMP_TO(FILTER_OP_LE_S64
);
1178 JUMP_TO(FILTER_OP_LE_DOUBLE_S64
);
1179 case REG_STRING
: /* Fall-through */
1180 case REG_STAR_GLOB_STRING
:
1184 ERR("Unknown filter register type (%d)",
1191 switch (estack_bx_t
) {
1193 JUMP_TO(FILTER_OP_LE_S64_DOUBLE
);
1195 JUMP_TO(FILTER_OP_LE_DOUBLE
);
1196 case REG_STRING
: /* Fall-through */
1197 case REG_STAR_GLOB_STRING
:
1201 ERR("Unknown filter register type (%d)",
1208 switch (estack_bx_t
) {
1209 case REG_S64
: /* Fall-through */
1210 case REG_DOUBLE
: /* Fall-through */
1211 case REG_STAR_GLOB_STRING
:
1215 JUMP_TO(FILTER_OP_LE_STRING
);
1217 ERR("Unknown filter register type (%d)",
1224 ERR("Unknown filter register type (%d)",
1231 OP(FILTER_OP_EQ_STRING
):
1235 res
= (stack_strcmp(stack
, top
, "==") == 0);
1236 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1238 estack_ax_t
= REG_S64
;
1239 next_pc
+= sizeof(struct binary_op
);
1242 OP(FILTER_OP_NE_STRING
):
1246 res
= (stack_strcmp(stack
, top
, "!=") != 0);
1247 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1249 estack_ax_t
= REG_S64
;
1250 next_pc
+= sizeof(struct binary_op
);
1253 OP(FILTER_OP_GT_STRING
):
1257 res
= (stack_strcmp(stack
, top
, ">") > 0);
1258 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1260 estack_ax_t
= REG_S64
;
1261 next_pc
+= sizeof(struct binary_op
);
1264 OP(FILTER_OP_LT_STRING
):
1268 res
= (stack_strcmp(stack
, top
, "<") < 0);
1269 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1271 estack_ax_t
= REG_S64
;
1272 next_pc
+= sizeof(struct binary_op
);
1275 OP(FILTER_OP_GE_STRING
):
1279 res
= (stack_strcmp(stack
, top
, ">=") >= 0);
1280 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1282 estack_ax_t
= REG_S64
;
1283 next_pc
+= sizeof(struct binary_op
);
1286 OP(FILTER_OP_LE_STRING
):
1290 res
= (stack_strcmp(stack
, top
, "<=") <= 0);
1291 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1293 estack_ax_t
= REG_S64
;
1294 next_pc
+= sizeof(struct binary_op
);
1298 OP(FILTER_OP_EQ_STAR_GLOB_STRING
):
1302 res
= (stack_star_glob_match(stack
, top
, "==") == 0);
1303 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1305 estack_ax_t
= REG_S64
;
1306 next_pc
+= sizeof(struct binary_op
);
1309 OP(FILTER_OP_NE_STAR_GLOB_STRING
):
1313 res
= (stack_star_glob_match(stack
, top
, "!=") != 0);
1314 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1316 estack_ax_t
= REG_S64
;
1317 next_pc
+= sizeof(struct binary_op
);
1321 OP(FILTER_OP_EQ_S64
):
1325 res
= (estack_bx_v
== estack_ax_v
);
1326 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1328 estack_ax_t
= REG_S64
;
1329 next_pc
+= sizeof(struct binary_op
);
1332 OP(FILTER_OP_NE_S64
):
1336 res
= (estack_bx_v
!= estack_ax_v
);
1337 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1339 estack_ax_t
= REG_S64
;
1340 next_pc
+= sizeof(struct binary_op
);
1343 OP(FILTER_OP_GT_S64
):
1347 res
= (estack_bx_v
> estack_ax_v
);
1348 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1350 estack_ax_t
= REG_S64
;
1351 next_pc
+= sizeof(struct binary_op
);
1354 OP(FILTER_OP_LT_S64
):
1358 res
= (estack_bx_v
< estack_ax_v
);
1359 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1361 estack_ax_t
= REG_S64
;
1362 next_pc
+= sizeof(struct binary_op
);
1365 OP(FILTER_OP_GE_S64
):
1369 res
= (estack_bx_v
>= estack_ax_v
);
1370 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1372 estack_ax_t
= REG_S64
;
1373 next_pc
+= sizeof(struct binary_op
);
1376 OP(FILTER_OP_LE_S64
):
1380 res
= (estack_bx_v
<= estack_ax_v
);
1381 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1383 estack_ax_t
= REG_S64
;
1384 next_pc
+= sizeof(struct binary_op
);
1388 OP(FILTER_OP_EQ_DOUBLE
):
1392 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax(stack
, top
)->u
.d
);
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_NE_DOUBLE
):
1403 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax(stack
, top
)->u
.d
);
1404 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1406 estack_ax_t
= REG_S64
;
1407 next_pc
+= sizeof(struct binary_op
);
1410 OP(FILTER_OP_GT_DOUBLE
):
1414 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax(stack
, top
)->u
.d
);
1415 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1417 estack_ax_t
= REG_S64
;
1418 next_pc
+= sizeof(struct binary_op
);
1421 OP(FILTER_OP_LT_DOUBLE
):
1425 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax(stack
, top
)->u
.d
);
1426 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1428 estack_ax_t
= REG_S64
;
1429 next_pc
+= sizeof(struct binary_op
);
1432 OP(FILTER_OP_GE_DOUBLE
):
1436 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax(stack
, top
)->u
.d
);
1437 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1439 estack_ax_t
= REG_S64
;
1440 next_pc
+= sizeof(struct binary_op
);
1443 OP(FILTER_OP_LE_DOUBLE
):
1447 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax(stack
, top
)->u
.d
);
1448 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1450 estack_ax_t
= REG_S64
;
1451 next_pc
+= sizeof(struct binary_op
);
1455 /* Mixed S64-double binary comparators */
1456 OP(FILTER_OP_EQ_DOUBLE_S64
):
1460 res
= (estack_bx(stack
, top
)->u
.d
== 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_NE_DOUBLE_S64
):
1471 res
= (estack_bx(stack
, top
)->u
.d
!= 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_GT_DOUBLE_S64
):
1482 res
= (estack_bx(stack
, top
)->u
.d
> 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_LT_DOUBLE_S64
):
1493 res
= (estack_bx(stack
, top
)->u
.d
< 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
);
1500 OP(FILTER_OP_GE_DOUBLE_S64
):
1504 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax_v
);
1505 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1507 estack_ax_t
= REG_S64
;
1508 next_pc
+= sizeof(struct binary_op
);
1511 OP(FILTER_OP_LE_DOUBLE_S64
):
1515 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax_v
);
1516 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1518 estack_ax_t
= REG_S64
;
1519 next_pc
+= sizeof(struct binary_op
);
1523 OP(FILTER_OP_EQ_S64_DOUBLE
):
1527 res
= (estack_bx_v
== 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_NE_S64_DOUBLE
):
1538 res
= (estack_bx_v
!= 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_GT_S64_DOUBLE
):
1549 res
= (estack_bx_v
> 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_LT_S64_DOUBLE
):
1560 res
= (estack_bx_v
< 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
);
1567 OP(FILTER_OP_GE_S64_DOUBLE
):
1571 res
= (estack_bx_v
>= estack_ax(stack
, top
)->u
.d
);
1572 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1574 estack_ax_t
= REG_S64
;
1575 next_pc
+= sizeof(struct binary_op
);
1578 OP(FILTER_OP_LE_S64_DOUBLE
):
1582 res
= (estack_bx_v
<= estack_ax(stack
, top
)->u
.d
);
1583 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1585 estack_ax_t
= REG_S64
;
1586 next_pc
+= sizeof(struct binary_op
);
1589 OP(FILTER_OP_BIT_RSHIFT
):
1593 /* Dynamic typing. */
1594 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1598 /* Catch undefined behavior. */
1599 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1603 res
= ((uint64_t) estack_bx_v
>> (uint32_t) 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_BIT_LSHIFT
):
1614 /* Dynamic typing. */
1615 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1619 /* Catch undefined behavior. */
1620 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1624 res
= ((uint64_t) estack_bx_v
<< (uint32_t) estack_ax_v
);
1625 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1627 estack_ax_t
= REG_S64
;
1628 next_pc
+= sizeof(struct binary_op
);
1631 OP(FILTER_OP_BIT_AND
):
1635 /* Dynamic typing. */
1636 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1641 res
= ((uint64_t) estack_bx_v
& (uint64_t) estack_ax_v
);
1642 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1644 estack_ax_t
= REG_S64
;
1645 next_pc
+= sizeof(struct binary_op
);
1648 OP(FILTER_OP_BIT_OR
):
1652 /* Dynamic typing. */
1653 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1658 res
= ((uint64_t) estack_bx_v
| (uint64_t) estack_ax_v
);
1659 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1661 estack_ax_t
= REG_S64
;
1662 next_pc
+= sizeof(struct binary_op
);
1665 OP(FILTER_OP_BIT_XOR
):
1669 /* Dynamic typing. */
1670 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1675 res
= ((uint64_t) estack_bx_v
^ (uint64_t) estack_ax_v
);
1676 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1678 estack_ax_t
= REG_S64
;
1679 next_pc
+= sizeof(struct binary_op
);
1684 OP(FILTER_OP_UNARY_PLUS
):
1686 /* Dynamic typing. */
1687 switch (estack_ax_t
) {
1688 case REG_S64
: /* Fall-through. */
1689 JUMP_TO(FILTER_OP_UNARY_PLUS_S64
);
1691 JUMP_TO(FILTER_OP_UNARY_PLUS_DOUBLE
);
1692 case REG_STRING
: /* Fall-through */
1693 case REG_STAR_GLOB_STRING
:
1697 ERR("Unknown filter register type (%d)",
1703 OP(FILTER_OP_UNARY_MINUS
):
1705 /* Dynamic typing. */
1706 switch (estack_ax_t
) {
1708 JUMP_TO(FILTER_OP_UNARY_MINUS_S64
);
1710 JUMP_TO(FILTER_OP_UNARY_MINUS_DOUBLE
);
1711 case REG_STRING
: /* Fall-through */
1712 case REG_STAR_GLOB_STRING
:
1716 ERR("Unknown filter register type (%d)",
1722 OP(FILTER_OP_UNARY_NOT
):
1724 /* Dynamic typing. */
1725 switch (estack_ax_t
) {
1727 JUMP_TO(FILTER_OP_UNARY_NOT_S64
);
1729 JUMP_TO(FILTER_OP_UNARY_NOT_DOUBLE
);
1730 case REG_STRING
: /* Fall-through */
1731 case REG_STAR_GLOB_STRING
:
1735 ERR("Unknown filter register type (%d)",
1740 next_pc
+= sizeof(struct unary_op
);
1744 OP(FILTER_OP_UNARY_BIT_NOT
):
1746 /* Dynamic typing. */
1747 if (estack_ax_t
!= REG_S64
) {
1752 estack_ax_v
= ~(uint64_t) estack_ax_v
;
1753 next_pc
+= sizeof(struct unary_op
);
1757 OP(FILTER_OP_UNARY_PLUS_S64
):
1758 OP(FILTER_OP_UNARY_PLUS_DOUBLE
):
1760 next_pc
+= sizeof(struct unary_op
);
1763 OP(FILTER_OP_UNARY_MINUS_S64
):
1765 estack_ax_v
= -estack_ax_v
;
1766 next_pc
+= sizeof(struct unary_op
);
1769 OP(FILTER_OP_UNARY_MINUS_DOUBLE
):
1771 estack_ax(stack
, top
)->u
.d
= -estack_ax(stack
, top
)->u
.d
;
1772 next_pc
+= sizeof(struct unary_op
);
1775 OP(FILTER_OP_UNARY_NOT_S64
):
1777 estack_ax_v
= !estack_ax_v
;
1778 next_pc
+= sizeof(struct unary_op
);
1781 OP(FILTER_OP_UNARY_NOT_DOUBLE
):
1783 estack_ax_v
= !estack_ax(stack
, top
)->u
.d
;
1784 estack_ax_t
= REG_S64
;
1785 next_pc
+= sizeof(struct unary_op
);
1792 struct logical_op
*insn
= (struct logical_op
*) pc
;
1794 if (estack_ax_t
!= REG_S64
) {
1798 /* If AX is 0, skip and evaluate to 0 */
1799 if (unlikely(estack_ax_v
== 0)) {
1800 dbg_printf("Jumping to bytecode offset %u\n",
1801 (unsigned int) insn
->skip_offset
);
1802 next_pc
= start_pc
+ insn
->skip_offset
;
1804 /* Pop 1 when jump not taken */
1805 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1806 next_pc
+= sizeof(struct logical_op
);
1812 struct logical_op
*insn
= (struct logical_op
*) pc
;
1814 if (estack_ax_t
!= REG_S64
) {
1818 /* If AX is nonzero, skip and evaluate to 1 */
1819 if (unlikely(estack_ax_v
!= 0)) {
1821 dbg_printf("Jumping to bytecode offset %u\n",
1822 (unsigned int) insn
->skip_offset
);
1823 next_pc
= start_pc
+ insn
->skip_offset
;
1825 /* Pop 1 when jump not taken */
1826 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1827 next_pc
+= sizeof(struct logical_op
);
1833 /* load field ref */
1834 OP(FILTER_OP_LOAD_FIELD_REF_STRING
):
1836 struct load_op
*insn
= (struct load_op
*) pc
;
1837 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1839 dbg_printf("load field ref offset %u type string\n",
1841 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1842 estack_ax(stack
, top
)->u
.s
.str
=
1843 *(const char * const *) &filter_stack_data
[ref
->offset
];
1844 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1845 dbg_printf("Filter warning: loading a NULL string.\n");
1849 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1850 estack_ax(stack
, top
)->u
.s
.literal_type
=
1851 ESTACK_STRING_LITERAL_TYPE_NONE
;
1852 estack_ax_t
= REG_STRING
;
1853 dbg_printf("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1854 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1858 OP(FILTER_OP_LOAD_FIELD_REF_SEQUENCE
):
1860 struct load_op
*insn
= (struct load_op
*) pc
;
1861 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1863 dbg_printf("load field ref offset %u type sequence\n",
1865 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1866 estack_ax(stack
, top
)->u
.s
.seq_len
=
1867 *(unsigned long *) &filter_stack_data
[ref
->offset
];
1868 estack_ax(stack
, top
)->u
.s
.str
=
1869 *(const char **) (&filter_stack_data
[ref
->offset
1870 + sizeof(unsigned long)]);
1871 estack_ax_t
= REG_STRING
;
1872 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1873 dbg_printf("Filter warning: loading a NULL sequence.\n");
1877 estack_ax(stack
, top
)->u
.s
.literal_type
=
1878 ESTACK_STRING_LITERAL_TYPE_NONE
;
1879 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1883 OP(FILTER_OP_LOAD_FIELD_REF_S64
):
1885 struct load_op
*insn
= (struct load_op
*) pc
;
1886 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1888 dbg_printf("load field ref offset %u type s64\n",
1890 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1892 ((struct literal_numeric
*) &filter_stack_data
[ref
->offset
])->v
;
1893 estack_ax_t
= REG_S64
;
1894 dbg_printf("ref load s64 %" PRIi64
"\n", estack_ax_v
);
1895 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1899 OP(FILTER_OP_LOAD_FIELD_REF_DOUBLE
):
1901 struct load_op
*insn
= (struct load_op
*) pc
;
1902 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1904 dbg_printf("load field ref offset %u type double\n",
1906 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1907 memcpy(&estack_ax(stack
, top
)->u
.d
, &filter_stack_data
[ref
->offset
],
1908 sizeof(struct literal_double
));
1909 estack_ax_t
= REG_DOUBLE
;
1910 dbg_printf("ref load double %g\n", estack_ax(stack
, top
)->u
.d
);
1911 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1915 /* load from immediate operand */
1916 OP(FILTER_OP_LOAD_STRING
):
1918 struct load_op
*insn
= (struct load_op
*) pc
;
1920 dbg_printf("load string %s\n", insn
->data
);
1921 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1922 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1923 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1924 estack_ax(stack
, top
)->u
.s
.literal_type
=
1925 ESTACK_STRING_LITERAL_TYPE_PLAIN
;
1926 estack_ax_t
= REG_STRING
;
1927 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1931 OP(FILTER_OP_LOAD_STAR_GLOB_STRING
):
1933 struct load_op
*insn
= (struct load_op
*) pc
;
1935 dbg_printf("load globbing pattern %s\n", insn
->data
);
1936 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1937 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1938 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1939 estack_ax(stack
, top
)->u
.s
.literal_type
=
1940 ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
;
1941 estack_ax_t
= REG_STAR_GLOB_STRING
;
1942 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1946 OP(FILTER_OP_LOAD_S64
):
1948 struct load_op
*insn
= (struct load_op
*) pc
;
1950 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1951 estack_ax_v
= ((struct literal_numeric
*) insn
->data
)->v
;
1952 estack_ax_t
= REG_S64
;
1953 dbg_printf("load s64 %" PRIi64
"\n", estack_ax_v
);
1954 next_pc
+= sizeof(struct load_op
)
1955 + sizeof(struct literal_numeric
);
1959 OP(FILTER_OP_LOAD_DOUBLE
):
1961 struct load_op
*insn
= (struct load_op
*) pc
;
1963 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1964 memcpy(&estack_ax(stack
, top
)->u
.d
, insn
->data
,
1965 sizeof(struct literal_double
));
1966 estack_ax_t
= REG_DOUBLE
;
1967 dbg_printf("load double %g\n", estack_ax(stack
, top
)->u
.d
);
1968 next_pc
+= sizeof(struct load_op
)
1969 + sizeof(struct literal_double
);
1974 OP(FILTER_OP_CAST_TO_S64
):
1976 /* Dynamic typing. */
1977 switch (estack_ax_t
) {
1979 JUMP_TO(FILTER_OP_CAST_NOP
);
1981 JUMP_TO(FILTER_OP_CAST_DOUBLE_TO_S64
);
1982 case REG_STRING
: /* Fall-through */
1983 case REG_STAR_GLOB_STRING
:
1987 ERR("Unknown filter register type (%d)",
1994 OP(FILTER_OP_CAST_DOUBLE_TO_S64
):
1996 estack_ax_v
= (int64_t) estack_ax(stack
, top
)->u
.d
;
1997 estack_ax_t
= REG_S64
;
1998 next_pc
+= sizeof(struct cast_op
);
2002 OP(FILTER_OP_CAST_NOP
):
2004 next_pc
+= sizeof(struct cast_op
);
2008 /* get context ref */
2009 OP(FILTER_OP_GET_CONTEXT_REF
):
2011 struct load_op
*insn
= (struct load_op
*) pc
;
2012 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2013 struct lttng_ctx_field
*ctx_field
;
2014 struct lttng_ctx_value v
;
2016 dbg_printf("get context ref offset %u type dynamic\n",
2018 ctx_field
= &ctx
->fields
[ref
->offset
];
2019 ctx_field
->get_value(ctx_field
, &v
);
2020 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2022 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
2025 case LTTNG_UST_DYNAMIC_TYPE_S64
:
2026 estack_ax_v
= v
.u
.s64
;
2027 estack_ax_t
= REG_S64
;
2028 dbg_printf("ref get context dynamic s64 %" PRIi64
"\n", estack_ax_v
);
2030 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
2031 estack_ax(stack
, top
)->u
.d
= v
.u
.d
;
2032 estack_ax_t
= REG_DOUBLE
;
2033 dbg_printf("ref get context dynamic double %g\n", estack_ax(stack
, top
)->u
.d
);
2035 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
2036 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2037 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2038 dbg_printf("Filter warning: loading a NULL string.\n");
2042 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2043 estack_ax(stack
, top
)->u
.s
.literal_type
=
2044 ESTACK_STRING_LITERAL_TYPE_NONE
;
2045 dbg_printf("ref get context dynamic string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2046 estack_ax_t
= REG_STRING
;
2049 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
2053 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2057 OP(FILTER_OP_GET_CONTEXT_REF_STRING
):
2059 struct load_op
*insn
= (struct load_op
*) pc
;
2060 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2061 struct lttng_ctx_field
*ctx_field
;
2062 struct lttng_ctx_value v
;
2064 dbg_printf("get context ref offset %u type string\n",
2066 ctx_field
= &ctx
->fields
[ref
->offset
];
2067 ctx_field
->get_value(ctx_field
, &v
);
2068 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2069 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2070 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2071 dbg_printf("Filter warning: loading a NULL string.\n");
2075 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2076 estack_ax(stack
, top
)->u
.s
.literal_type
=
2077 ESTACK_STRING_LITERAL_TYPE_NONE
;
2078 estack_ax_t
= REG_STRING
;
2079 dbg_printf("ref get context string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2080 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2084 OP(FILTER_OP_GET_CONTEXT_REF_S64
):
2086 struct load_op
*insn
= (struct load_op
*) pc
;
2087 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2088 struct lttng_ctx_field
*ctx_field
;
2089 struct lttng_ctx_value v
;
2091 dbg_printf("get context ref offset %u type s64\n",
2093 ctx_field
= &ctx
->fields
[ref
->offset
];
2094 ctx_field
->get_value(ctx_field
, &v
);
2095 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2096 estack_ax_v
= v
.u
.s64
;
2097 estack_ax_t
= REG_S64
;
2098 dbg_printf("ref get context s64 %" PRIi64
"\n", estack_ax_v
);
2099 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2103 OP(FILTER_OP_GET_CONTEXT_REF_DOUBLE
):
2105 struct load_op
*insn
= (struct load_op
*) pc
;
2106 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2107 struct lttng_ctx_field
*ctx_field
;
2108 struct lttng_ctx_value v
;
2110 dbg_printf("get context ref offset %u type double\n",
2112 ctx_field
= &ctx
->fields
[ref
->offset
];
2113 ctx_field
->get_value(ctx_field
, &v
);
2114 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2115 memcpy(&estack_ax(stack
, top
)->u
.d
, &v
.u
.d
, sizeof(struct literal_double
));
2116 estack_ax_t
= REG_DOUBLE
;
2117 dbg_printf("ref get context double %g\n", estack_ax(stack
, top
)->u
.d
);
2118 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2122 OP(FILTER_OP_GET_CONTEXT_ROOT
):
2124 dbg_printf("op get context root\n");
2125 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2126 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_CONTEXT
;
2127 /* "field" only needed for variants. */
2128 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2129 estack_ax_t
= REG_PTR
;
2130 next_pc
+= sizeof(struct load_op
);
2134 OP(FILTER_OP_GET_APP_CONTEXT_ROOT
):
2136 dbg_printf("op get app context root\n");
2137 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2138 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_APP_CONTEXT
;
2139 /* "field" only needed for variants. */
2140 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2141 estack_ax_t
= REG_PTR
;
2142 next_pc
+= sizeof(struct load_op
);
2146 OP(FILTER_OP_GET_PAYLOAD_ROOT
):
2148 dbg_printf("op get app payload root\n");
2149 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2150 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_PAYLOAD
;
2151 estack_ax(stack
, top
)->u
.ptr
.ptr
= filter_stack_data
;
2152 /* "field" only needed for variants. */
2153 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2154 estack_ax_t
= REG_PTR
;
2155 next_pc
+= sizeof(struct load_op
);
2159 OP(FILTER_OP_GET_SYMBOL
):
2161 dbg_printf("op get symbol\n");
2162 switch (estack_ax(stack
, top
)->u
.ptr
.type
) {
2164 ERR("Nested fields not implemented yet.");
2167 case LOAD_ROOT_CONTEXT
:
2168 case LOAD_ROOT_APP_CONTEXT
:
2169 case LOAD_ROOT_PAYLOAD
:
2171 * symbol lookup is performed by
2177 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_symbol
);
2181 OP(FILTER_OP_GET_SYMBOL_FIELD
):
2184 * Used for first variant encountered in a
2185 * traversal. Variants are not implemented yet.
2191 OP(FILTER_OP_GET_INDEX_U16
):
2193 struct load_op
*insn
= (struct load_op
*) pc
;
2194 struct get_index_u16
*index
= (struct get_index_u16
*) insn
->data
;
2196 dbg_printf("op get index u16\n");
2197 ret
= dynamic_get_index(ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
2200 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2201 estack_ax_t
= estack_ax(stack
, top
)->type
;
2202 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u16
);
2206 OP(FILTER_OP_GET_INDEX_U64
):
2208 struct load_op
*insn
= (struct load_op
*) pc
;
2209 struct get_index_u64
*index
= (struct get_index_u64
*) insn
->data
;
2211 dbg_printf("op get index u64\n");
2212 ret
= dynamic_get_index(ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
2215 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2216 estack_ax_t
= estack_ax(stack
, top
)->type
;
2217 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u64
);
2221 OP(FILTER_OP_LOAD_FIELD
):
2223 dbg_printf("op load field\n");
2224 ret
= dynamic_load_field(estack_ax(stack
, top
));
2227 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2228 estack_ax_t
= estack_ax(stack
, top
)->type
;
2229 next_pc
+= sizeof(struct load_op
);
2233 OP(FILTER_OP_LOAD_FIELD_S8
):
2235 dbg_printf("op load field s8\n");
2237 estack_ax_v
= *(int8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2238 estack_ax_t
= REG_S64
;
2239 next_pc
+= sizeof(struct load_op
);
2242 OP(FILTER_OP_LOAD_FIELD_S16
):
2244 dbg_printf("op load field s16\n");
2246 estack_ax_v
= *(int16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2247 estack_ax_t
= REG_S64
;
2248 next_pc
+= sizeof(struct load_op
);
2251 OP(FILTER_OP_LOAD_FIELD_S32
):
2253 dbg_printf("op load field s32\n");
2255 estack_ax_v
= *(int32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2256 estack_ax_t
= REG_S64
;
2257 next_pc
+= sizeof(struct load_op
);
2260 OP(FILTER_OP_LOAD_FIELD_S64
):
2262 dbg_printf("op load field s64\n");
2264 estack_ax_v
= *(int64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2265 estack_ax_t
= REG_S64
;
2266 next_pc
+= sizeof(struct load_op
);
2269 OP(FILTER_OP_LOAD_FIELD_U8
):
2271 dbg_printf("op load field u8\n");
2273 estack_ax_v
= *(uint8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2274 estack_ax_t
= REG_S64
;
2275 next_pc
+= sizeof(struct load_op
);
2278 OP(FILTER_OP_LOAD_FIELD_U16
):
2280 dbg_printf("op load field u16\n");
2282 estack_ax_v
= *(uint16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2283 estack_ax_t
= REG_S64
;
2284 next_pc
+= sizeof(struct load_op
);
2287 OP(FILTER_OP_LOAD_FIELD_U32
):
2289 dbg_printf("op load field u32\n");
2291 estack_ax_v
= *(uint32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2292 estack_ax_t
= REG_S64
;
2293 next_pc
+= sizeof(struct load_op
);
2296 OP(FILTER_OP_LOAD_FIELD_U64
):
2298 dbg_printf("op load field u64\n");
2300 estack_ax_v
= *(uint64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2301 estack_ax_t
= REG_S64
;
2302 next_pc
+= sizeof(struct load_op
);
2305 OP(FILTER_OP_LOAD_FIELD_DOUBLE
):
2307 dbg_printf("op load field double\n");
2309 memcpy(&estack_ax(stack
, top
)->u
.d
,
2310 estack_ax(stack
, top
)->u
.ptr
.ptr
,
2311 sizeof(struct literal_double
));
2312 estack_ax(stack
, top
)->type
= REG_DOUBLE
;
2313 next_pc
+= sizeof(struct load_op
);
2317 OP(FILTER_OP_LOAD_FIELD_STRING
):
2321 dbg_printf("op load field string\n");
2322 str
= (const char *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2323 estack_ax(stack
, top
)->u
.s
.str
= str
;
2324 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2325 dbg_printf("Filter warning: loading a NULL string.\n");
2329 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2330 estack_ax(stack
, top
)->u
.s
.literal_type
=
2331 ESTACK_STRING_LITERAL_TYPE_NONE
;
2332 estack_ax(stack
, top
)->type
= REG_STRING
;
2333 next_pc
+= sizeof(struct load_op
);
2337 OP(FILTER_OP_LOAD_FIELD_SEQUENCE
):
2341 dbg_printf("op load field string sequence\n");
2342 ptr
= estack_ax(stack
, top
)->u
.ptr
.ptr
;
2343 estack_ax(stack
, top
)->u
.s
.seq_len
= *(unsigned long *) ptr
;
2344 estack_ax(stack
, top
)->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
2345 estack_ax(stack
, top
)->type
= REG_STRING
;
2346 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2347 dbg_printf("Filter warning: loading a NULL sequence.\n");
2351 estack_ax(stack
, top
)->u
.s
.literal_type
=
2352 ESTACK_STRING_LITERAL_TYPE_NONE
;
2353 next_pc
+= sizeof(struct load_op
);
2359 /* Return _DISCARD on error. */
2361 return LTTNG_FILTER_DISCARD
;