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>
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_session
*session
,
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 struct lttng_ctx
*ctx
;
442 ctx
= rcu_dereference(session
->ctx
);
443 ret
= context_get_index(ctx
,
451 case LOAD_ROOT_PAYLOAD
:
452 stack_top
->u
.ptr
.ptr
+= gid
->offset
;
453 if (gid
->elem
.type
== OBJECT_TYPE_STRING
)
454 stack_top
->u
.ptr
.ptr
= *(const char * const *) stack_top
->u
.ptr
.ptr
;
455 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
456 stack_top
->u
.ptr
.type
= LOAD_OBJECT
;
457 /* field is only used for types nested within variants. */
458 stack_top
->u
.ptr
.field
= NULL
;
467 static int dynamic_load_field(struct estack_entry
*stack_top
)
471 switch (stack_top
->u
.ptr
.type
) {
474 case LOAD_ROOT_CONTEXT
:
475 case LOAD_ROOT_APP_CONTEXT
:
476 case LOAD_ROOT_PAYLOAD
:
478 dbg_printf("Filter warning: cannot load root, missing field name.\n");
482 switch (stack_top
->u
.ptr
.object_type
) {
484 dbg_printf("op load field s8\n");
485 stack_top
->u
.v
= *(int8_t *) stack_top
->u
.ptr
.ptr
;
486 stack_top
->type
= REG_S64
;
488 case OBJECT_TYPE_S16
:
492 dbg_printf("op load field s16\n");
493 tmp
= *(int16_t *) stack_top
->u
.ptr
.ptr
;
494 if (stack_top
->u
.ptr
.rev_bo
)
496 stack_top
->u
.v
= tmp
;
497 stack_top
->type
= REG_S64
;
500 case OBJECT_TYPE_S32
:
504 dbg_printf("op load field s32\n");
505 tmp
= *(int32_t *) stack_top
->u
.ptr
.ptr
;
506 if (stack_top
->u
.ptr
.rev_bo
)
508 stack_top
->u
.v
= tmp
;
509 stack_top
->type
= REG_S64
;
512 case OBJECT_TYPE_S64
:
516 dbg_printf("op load field s64\n");
517 tmp
= *(int64_t *) stack_top
->u
.ptr
.ptr
;
518 if (stack_top
->u
.ptr
.rev_bo
)
520 stack_top
->u
.v
= tmp
;
521 stack_top
->type
= REG_S64
;
525 dbg_printf("op load field u8\n");
526 stack_top
->u
.v
= *(uint8_t *) stack_top
->u
.ptr
.ptr
;
527 stack_top
->type
= REG_S64
;
529 case OBJECT_TYPE_U16
:
533 dbg_printf("op load field u16\n");
534 tmp
= *(uint16_t *) stack_top
->u
.ptr
.ptr
;
535 if (stack_top
->u
.ptr
.rev_bo
)
537 stack_top
->u
.v
= tmp
;
538 stack_top
->type
= REG_S64
;
541 case OBJECT_TYPE_U32
:
545 dbg_printf("op load field u32\n");
546 tmp
= *(uint32_t *) stack_top
->u
.ptr
.ptr
;
547 if (stack_top
->u
.ptr
.rev_bo
)
549 stack_top
->u
.v
= tmp
;
550 stack_top
->type
= REG_S64
;
553 case OBJECT_TYPE_U64
:
557 dbg_printf("op load field u64\n");
558 tmp
= *(uint64_t *) stack_top
->u
.ptr
.ptr
;
559 if (stack_top
->u
.ptr
.rev_bo
)
561 stack_top
->u
.v
= tmp
;
562 stack_top
->type
= REG_S64
;
565 case OBJECT_TYPE_DOUBLE
:
566 memcpy(&stack_top
->u
.d
,
567 stack_top
->u
.ptr
.ptr
,
568 sizeof(struct literal_double
));
569 stack_top
->type
= REG_DOUBLE
;
571 case OBJECT_TYPE_STRING
:
575 dbg_printf("op load field string\n");
576 str
= (const char *) stack_top
->u
.ptr
.ptr
;
577 stack_top
->u
.s
.str
= str
;
578 if (unlikely(!stack_top
->u
.s
.str
)) {
579 dbg_printf("Filter warning: loading a NULL string.\n");
583 stack_top
->u
.s
.seq_len
= SIZE_MAX
;
584 stack_top
->u
.s
.literal_type
=
585 ESTACK_STRING_LITERAL_TYPE_NONE
;
586 stack_top
->type
= REG_STRING
;
589 case OBJECT_TYPE_STRING_SEQUENCE
:
593 dbg_printf("op load field string sequence\n");
594 ptr
= stack_top
->u
.ptr
.ptr
;
595 stack_top
->u
.s
.seq_len
= *(unsigned long *) ptr
;
596 stack_top
->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
597 stack_top
->type
= REG_STRING
;
598 if (unlikely(!stack_top
->u
.s
.str
)) {
599 dbg_printf("Filter warning: loading a NULL sequence.\n");
603 stack_top
->u
.s
.literal_type
=
604 ESTACK_STRING_LITERAL_TYPE_NONE
;
607 case OBJECT_TYPE_DYNAMIC
:
609 * Dynamic types in context are looked up
610 * by context get index.
614 case OBJECT_TYPE_SEQUENCE
:
615 case OBJECT_TYPE_ARRAY
:
616 case OBJECT_TYPE_STRUCT
:
617 case OBJECT_TYPE_VARIANT
:
618 ERR("Sequences, arrays, struct and variant cannot be loaded (nested types).");
629 * Return 0 (discard), or raise the 0x1 flag (log event).
630 * Currently, other flags are kept for future extensions and have no
633 uint64_t lttng_filter_interpret_bytecode(void *filter_data
,
634 const char *filter_stack_data
)
636 struct bytecode_runtime
*bytecode
= filter_data
;
637 struct lttng_session
*session
= bytecode
->p
.session
;
638 void *pc
, *next_pc
, *start_pc
;
641 struct estack _stack
;
642 struct estack
*stack
= &_stack
;
643 register int64_t ax
= 0, bx
= 0;
644 register enum entry_type ax_t
= REG_UNKNOWN
, bx_t
= REG_UNKNOWN
;
645 register int top
= FILTER_STACK_EMPTY
;
646 #ifndef INTERPRETER_USE_SWITCH
647 static void *dispatch
[NR_FILTER_OPS
] = {
648 [ FILTER_OP_UNKNOWN
] = &&LABEL_FILTER_OP_UNKNOWN
,
650 [ FILTER_OP_RETURN
] = &&LABEL_FILTER_OP_RETURN
,
653 [ FILTER_OP_MUL
] = &&LABEL_FILTER_OP_MUL
,
654 [ FILTER_OP_DIV
] = &&LABEL_FILTER_OP_DIV
,
655 [ FILTER_OP_MOD
] = &&LABEL_FILTER_OP_MOD
,
656 [ FILTER_OP_PLUS
] = &&LABEL_FILTER_OP_PLUS
,
657 [ FILTER_OP_MINUS
] = &&LABEL_FILTER_OP_MINUS
,
658 [ FILTER_OP_BIT_RSHIFT
] = &&LABEL_FILTER_OP_BIT_RSHIFT
,
659 [ FILTER_OP_BIT_LSHIFT
] = &&LABEL_FILTER_OP_BIT_LSHIFT
,
660 [ FILTER_OP_BIT_AND
] = &&LABEL_FILTER_OP_BIT_AND
,
661 [ FILTER_OP_BIT_OR
] = &&LABEL_FILTER_OP_BIT_OR
,
662 [ FILTER_OP_BIT_XOR
] = &&LABEL_FILTER_OP_BIT_XOR
,
664 /* binary comparators */
665 [ FILTER_OP_EQ
] = &&LABEL_FILTER_OP_EQ
,
666 [ FILTER_OP_NE
] = &&LABEL_FILTER_OP_NE
,
667 [ FILTER_OP_GT
] = &&LABEL_FILTER_OP_GT
,
668 [ FILTER_OP_LT
] = &&LABEL_FILTER_OP_LT
,
669 [ FILTER_OP_GE
] = &&LABEL_FILTER_OP_GE
,
670 [ FILTER_OP_LE
] = &&LABEL_FILTER_OP_LE
,
672 /* string binary comparator */
673 [ FILTER_OP_EQ_STRING
] = &&LABEL_FILTER_OP_EQ_STRING
,
674 [ FILTER_OP_NE_STRING
] = &&LABEL_FILTER_OP_NE_STRING
,
675 [ FILTER_OP_GT_STRING
] = &&LABEL_FILTER_OP_GT_STRING
,
676 [ FILTER_OP_LT_STRING
] = &&LABEL_FILTER_OP_LT_STRING
,
677 [ FILTER_OP_GE_STRING
] = &&LABEL_FILTER_OP_GE_STRING
,
678 [ FILTER_OP_LE_STRING
] = &&LABEL_FILTER_OP_LE_STRING
,
680 /* globbing pattern binary comparator */
681 [ FILTER_OP_EQ_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_EQ_STAR_GLOB_STRING
,
682 [ FILTER_OP_NE_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_NE_STAR_GLOB_STRING
,
684 /* s64 binary comparator */
685 [ FILTER_OP_EQ_S64
] = &&LABEL_FILTER_OP_EQ_S64
,
686 [ FILTER_OP_NE_S64
] = &&LABEL_FILTER_OP_NE_S64
,
687 [ FILTER_OP_GT_S64
] = &&LABEL_FILTER_OP_GT_S64
,
688 [ FILTER_OP_LT_S64
] = &&LABEL_FILTER_OP_LT_S64
,
689 [ FILTER_OP_GE_S64
] = &&LABEL_FILTER_OP_GE_S64
,
690 [ FILTER_OP_LE_S64
] = &&LABEL_FILTER_OP_LE_S64
,
692 /* double binary comparator */
693 [ FILTER_OP_EQ_DOUBLE
] = &&LABEL_FILTER_OP_EQ_DOUBLE
,
694 [ FILTER_OP_NE_DOUBLE
] = &&LABEL_FILTER_OP_NE_DOUBLE
,
695 [ FILTER_OP_GT_DOUBLE
] = &&LABEL_FILTER_OP_GT_DOUBLE
,
696 [ FILTER_OP_LT_DOUBLE
] = &&LABEL_FILTER_OP_LT_DOUBLE
,
697 [ FILTER_OP_GE_DOUBLE
] = &&LABEL_FILTER_OP_GE_DOUBLE
,
698 [ FILTER_OP_LE_DOUBLE
] = &&LABEL_FILTER_OP_LE_DOUBLE
,
700 /* Mixed S64-double binary comparators */
701 [ FILTER_OP_EQ_DOUBLE_S64
] = &&LABEL_FILTER_OP_EQ_DOUBLE_S64
,
702 [ FILTER_OP_NE_DOUBLE_S64
] = &&LABEL_FILTER_OP_NE_DOUBLE_S64
,
703 [ FILTER_OP_GT_DOUBLE_S64
] = &&LABEL_FILTER_OP_GT_DOUBLE_S64
,
704 [ FILTER_OP_LT_DOUBLE_S64
] = &&LABEL_FILTER_OP_LT_DOUBLE_S64
,
705 [ FILTER_OP_GE_DOUBLE_S64
] = &&LABEL_FILTER_OP_GE_DOUBLE_S64
,
706 [ FILTER_OP_LE_DOUBLE_S64
] = &&LABEL_FILTER_OP_LE_DOUBLE_S64
,
708 [ FILTER_OP_EQ_S64_DOUBLE
] = &&LABEL_FILTER_OP_EQ_S64_DOUBLE
,
709 [ FILTER_OP_NE_S64_DOUBLE
] = &&LABEL_FILTER_OP_NE_S64_DOUBLE
,
710 [ FILTER_OP_GT_S64_DOUBLE
] = &&LABEL_FILTER_OP_GT_S64_DOUBLE
,
711 [ FILTER_OP_LT_S64_DOUBLE
] = &&LABEL_FILTER_OP_LT_S64_DOUBLE
,
712 [ FILTER_OP_GE_S64_DOUBLE
] = &&LABEL_FILTER_OP_GE_S64_DOUBLE
,
713 [ FILTER_OP_LE_S64_DOUBLE
] = &&LABEL_FILTER_OP_LE_S64_DOUBLE
,
716 [ FILTER_OP_UNARY_PLUS
] = &&LABEL_FILTER_OP_UNARY_PLUS
,
717 [ FILTER_OP_UNARY_MINUS
] = &&LABEL_FILTER_OP_UNARY_MINUS
,
718 [ FILTER_OP_UNARY_NOT
] = &&LABEL_FILTER_OP_UNARY_NOT
,
719 [ FILTER_OP_UNARY_PLUS_S64
] = &&LABEL_FILTER_OP_UNARY_PLUS_S64
,
720 [ FILTER_OP_UNARY_MINUS_S64
] = &&LABEL_FILTER_OP_UNARY_MINUS_S64
,
721 [ FILTER_OP_UNARY_NOT_S64
] = &&LABEL_FILTER_OP_UNARY_NOT_S64
,
722 [ FILTER_OP_UNARY_PLUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_PLUS_DOUBLE
,
723 [ FILTER_OP_UNARY_MINUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_MINUS_DOUBLE
,
724 [ FILTER_OP_UNARY_NOT_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_NOT_DOUBLE
,
727 [ FILTER_OP_AND
] = &&LABEL_FILTER_OP_AND
,
728 [ FILTER_OP_OR
] = &&LABEL_FILTER_OP_OR
,
731 [ FILTER_OP_LOAD_FIELD_REF
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF
,
732 [ FILTER_OP_LOAD_FIELD_REF_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_STRING
,
733 [ FILTER_OP_LOAD_FIELD_REF_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_SEQUENCE
,
734 [ FILTER_OP_LOAD_FIELD_REF_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_S64
,
735 [ FILTER_OP_LOAD_FIELD_REF_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_DOUBLE
,
737 /* load from immediate operand */
738 [ FILTER_OP_LOAD_STRING
] = &&LABEL_FILTER_OP_LOAD_STRING
,
739 [ FILTER_OP_LOAD_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_LOAD_STAR_GLOB_STRING
,
740 [ FILTER_OP_LOAD_S64
] = &&LABEL_FILTER_OP_LOAD_S64
,
741 [ FILTER_OP_LOAD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_DOUBLE
,
744 [ FILTER_OP_CAST_TO_S64
] = &&LABEL_FILTER_OP_CAST_TO_S64
,
745 [ FILTER_OP_CAST_DOUBLE_TO_S64
] = &&LABEL_FILTER_OP_CAST_DOUBLE_TO_S64
,
746 [ FILTER_OP_CAST_NOP
] = &&LABEL_FILTER_OP_CAST_NOP
,
748 /* get context ref */
749 [ FILTER_OP_GET_CONTEXT_REF
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF
,
750 [ FILTER_OP_GET_CONTEXT_REF_STRING
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_STRING
,
751 [ FILTER_OP_GET_CONTEXT_REF_S64
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_S64
,
752 [ FILTER_OP_GET_CONTEXT_REF_DOUBLE
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_DOUBLE
,
754 /* Instructions for recursive traversal through composed types. */
755 [ FILTER_OP_GET_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_CONTEXT_ROOT
,
756 [ FILTER_OP_GET_APP_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_APP_CONTEXT_ROOT
,
757 [ FILTER_OP_GET_PAYLOAD_ROOT
] = &&LABEL_FILTER_OP_GET_PAYLOAD_ROOT
,
759 [ FILTER_OP_GET_SYMBOL
] = &&LABEL_FILTER_OP_GET_SYMBOL
,
760 [ FILTER_OP_GET_SYMBOL_FIELD
] = &&LABEL_FILTER_OP_GET_SYMBOL_FIELD
,
761 [ FILTER_OP_GET_INDEX_U16
] = &&LABEL_FILTER_OP_GET_INDEX_U16
,
762 [ FILTER_OP_GET_INDEX_U64
] = &&LABEL_FILTER_OP_GET_INDEX_U64
,
764 [ FILTER_OP_LOAD_FIELD
] = &&LABEL_FILTER_OP_LOAD_FIELD
,
765 [ FILTER_OP_LOAD_FIELD_S8
] = &&LABEL_FILTER_OP_LOAD_FIELD_S8
,
766 [ FILTER_OP_LOAD_FIELD_S16
] = &&LABEL_FILTER_OP_LOAD_FIELD_S16
,
767 [ FILTER_OP_LOAD_FIELD_S32
] = &&LABEL_FILTER_OP_LOAD_FIELD_S32
,
768 [ FILTER_OP_LOAD_FIELD_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_S64
,
769 [ FILTER_OP_LOAD_FIELD_U8
] = &&LABEL_FILTER_OP_LOAD_FIELD_U8
,
770 [ FILTER_OP_LOAD_FIELD_U16
] = &&LABEL_FILTER_OP_LOAD_FIELD_U16
,
771 [ FILTER_OP_LOAD_FIELD_U32
] = &&LABEL_FILTER_OP_LOAD_FIELD_U32
,
772 [ FILTER_OP_LOAD_FIELD_U64
] = &&LABEL_FILTER_OP_LOAD_FIELD_U64
,
773 [ FILTER_OP_LOAD_FIELD_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_STRING
,
774 [ FILTER_OP_LOAD_FIELD_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_SEQUENCE
,
775 [ FILTER_OP_LOAD_FIELD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_DOUBLE
,
777 [ FILTER_OP_UNARY_BIT_NOT
] = &&LABEL_FILTER_OP_UNARY_BIT_NOT
,
779 [ FILTER_OP_RETURN_S64
] = &&LABEL_FILTER_OP_RETURN_S64
,
781 #endif /* #ifndef INTERPRETER_USE_SWITCH */
785 OP(FILTER_OP_UNKNOWN
):
786 OP(FILTER_OP_LOAD_FIELD_REF
):
787 #ifdef INTERPRETER_USE_SWITCH
789 #endif /* INTERPRETER_USE_SWITCH */
790 ERR("unknown bytecode op %u",
791 (unsigned int) *(filter_opcode_t
*) pc
);
795 OP(FILTER_OP_RETURN
):
796 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
797 /* Handle dynamic typing. */
798 switch (estack_ax_t
) {
800 retval
= !!estack_ax_v
;
804 case REG_STAR_GLOB_STRING
:
812 OP(FILTER_OP_RETURN_S64
):
813 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
814 retval
= !!estack_ax_v
;
824 ERR("unsupported bytecode op %u",
825 (unsigned int) *(filter_opcode_t
*) pc
);
831 /* Dynamic typing. */
832 switch (estack_ax_t
) {
834 switch (estack_bx_t
) {
836 JUMP_TO(FILTER_OP_EQ_S64
);
838 JUMP_TO(FILTER_OP_EQ_DOUBLE_S64
);
839 case REG_STRING
: /* Fall-through */
840 case REG_STAR_GLOB_STRING
:
844 ERR("Unknown filter register type (%d)",
851 switch (estack_bx_t
) {
853 JUMP_TO(FILTER_OP_EQ_S64_DOUBLE
);
855 JUMP_TO(FILTER_OP_EQ_DOUBLE
);
856 case REG_STRING
: /* Fall-through */
857 case REG_STAR_GLOB_STRING
:
861 ERR("Unknown filter register type (%d)",
868 switch (estack_bx_t
) {
869 case REG_S64
: /* Fall-through */
874 JUMP_TO(FILTER_OP_EQ_STRING
);
875 case REG_STAR_GLOB_STRING
:
876 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
878 ERR("Unknown filter register type (%d)",
884 case REG_STAR_GLOB_STRING
:
885 switch (estack_bx_t
) {
886 case REG_S64
: /* Fall-through */
891 JUMP_TO(FILTER_OP_EQ_STAR_GLOB_STRING
);
892 case REG_STAR_GLOB_STRING
:
896 ERR("Unknown filter register type (%d)",
903 ERR("Unknown filter register type (%d)",
911 /* Dynamic typing. */
912 switch (estack_ax_t
) {
914 switch (estack_bx_t
) {
916 JUMP_TO(FILTER_OP_NE_S64
);
918 JUMP_TO(FILTER_OP_NE_DOUBLE_S64
);
919 case REG_STRING
: /* Fall-through */
920 case REG_STAR_GLOB_STRING
:
924 ERR("Unknown filter register type (%d)",
931 switch (estack_bx_t
) {
933 JUMP_TO(FILTER_OP_NE_S64_DOUBLE
);
935 JUMP_TO(FILTER_OP_NE_DOUBLE
);
936 case REG_STRING
: /* Fall-through */
937 case REG_STAR_GLOB_STRING
:
941 ERR("Unknown filter register type (%d)",
948 switch (estack_bx_t
) {
949 case REG_S64
: /* Fall-through */
954 JUMP_TO(FILTER_OP_NE_STRING
);
955 case REG_STAR_GLOB_STRING
:
956 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
958 ERR("Unknown filter register type (%d)",
964 case REG_STAR_GLOB_STRING
:
965 switch (estack_bx_t
) {
966 case REG_S64
: /* Fall-through */
971 JUMP_TO(FILTER_OP_NE_STAR_GLOB_STRING
);
972 case REG_STAR_GLOB_STRING
:
976 ERR("Unknown filter register type (%d)",
983 ERR("Unknown filter register type (%d)",
991 /* Dynamic typing. */
992 switch (estack_ax_t
) {
994 switch (estack_bx_t
) {
996 JUMP_TO(FILTER_OP_GT_S64
);
998 JUMP_TO(FILTER_OP_GT_DOUBLE_S64
);
999 case REG_STRING
: /* Fall-through */
1000 case REG_STAR_GLOB_STRING
:
1004 ERR("Unknown filter register type (%d)",
1011 switch (estack_bx_t
) {
1013 JUMP_TO(FILTER_OP_GT_S64_DOUBLE
);
1015 JUMP_TO(FILTER_OP_GT_DOUBLE
);
1016 case REG_STRING
: /* Fall-through */
1017 case REG_STAR_GLOB_STRING
:
1021 ERR("Unknown filter register type (%d)",
1028 switch (estack_bx_t
) {
1029 case REG_S64
: /* Fall-through */
1030 case REG_DOUBLE
: /* Fall-through */
1031 case REG_STAR_GLOB_STRING
:
1035 JUMP_TO(FILTER_OP_GT_STRING
);
1037 ERR("Unknown filter register type (%d)",
1044 ERR("Unknown filter register type (%d)",
1052 /* Dynamic typing. */
1053 switch (estack_ax_t
) {
1055 switch (estack_bx_t
) {
1057 JUMP_TO(FILTER_OP_LT_S64
);
1059 JUMP_TO(FILTER_OP_LT_DOUBLE_S64
);
1060 case REG_STRING
: /* Fall-through */
1061 case REG_STAR_GLOB_STRING
:
1065 ERR("Unknown filter register type (%d)",
1072 switch (estack_bx_t
) {
1074 JUMP_TO(FILTER_OP_LT_S64_DOUBLE
);
1076 JUMP_TO(FILTER_OP_LT_DOUBLE
);
1077 case REG_STRING
: /* Fall-through */
1078 case REG_STAR_GLOB_STRING
:
1082 ERR("Unknown filter register type (%d)",
1089 switch (estack_bx_t
) {
1090 case REG_S64
: /* Fall-through */
1091 case REG_DOUBLE
: /* Fall-through */
1092 case REG_STAR_GLOB_STRING
:
1096 JUMP_TO(FILTER_OP_LT_STRING
);
1098 ERR("Unknown filter register type (%d)",
1105 ERR("Unknown filter register type (%d)",
1113 /* Dynamic typing. */
1114 switch (estack_ax_t
) {
1116 switch (estack_bx_t
) {
1118 JUMP_TO(FILTER_OP_GE_S64
);
1120 JUMP_TO(FILTER_OP_GE_DOUBLE_S64
);
1121 case REG_STRING
: /* Fall-through */
1122 case REG_STAR_GLOB_STRING
:
1126 ERR("Unknown filter register type (%d)",
1133 switch (estack_bx_t
) {
1135 JUMP_TO(FILTER_OP_GE_S64_DOUBLE
);
1137 JUMP_TO(FILTER_OP_GE_DOUBLE
);
1138 case REG_STRING
: /* Fall-through */
1139 case REG_STAR_GLOB_STRING
:
1143 ERR("Unknown filter register type (%d)",
1150 switch (estack_bx_t
) {
1151 case REG_S64
: /* Fall-through */
1152 case REG_DOUBLE
: /* Fall-through */
1153 case REG_STAR_GLOB_STRING
:
1157 JUMP_TO(FILTER_OP_GE_STRING
);
1159 ERR("Unknown filter register type (%d)",
1166 ERR("Unknown filter register type (%d)",
1174 /* Dynamic typing. */
1175 switch (estack_ax_t
) {
1177 switch (estack_bx_t
) {
1179 JUMP_TO(FILTER_OP_LE_S64
);
1181 JUMP_TO(FILTER_OP_LE_DOUBLE_S64
);
1182 case REG_STRING
: /* Fall-through */
1183 case REG_STAR_GLOB_STRING
:
1187 ERR("Unknown filter register type (%d)",
1194 switch (estack_bx_t
) {
1196 JUMP_TO(FILTER_OP_LE_S64_DOUBLE
);
1198 JUMP_TO(FILTER_OP_LE_DOUBLE
);
1199 case REG_STRING
: /* Fall-through */
1200 case REG_STAR_GLOB_STRING
:
1204 ERR("Unknown filter register type (%d)",
1211 switch (estack_bx_t
) {
1212 case REG_S64
: /* Fall-through */
1213 case REG_DOUBLE
: /* Fall-through */
1214 case REG_STAR_GLOB_STRING
:
1218 JUMP_TO(FILTER_OP_LE_STRING
);
1220 ERR("Unknown filter register type (%d)",
1227 ERR("Unknown filter register type (%d)",
1234 OP(FILTER_OP_EQ_STRING
):
1238 res
= (stack_strcmp(stack
, top
, "==") == 0);
1239 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1241 estack_ax_t
= REG_S64
;
1242 next_pc
+= sizeof(struct binary_op
);
1245 OP(FILTER_OP_NE_STRING
):
1249 res
= (stack_strcmp(stack
, top
, "!=") != 0);
1250 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1252 estack_ax_t
= REG_S64
;
1253 next_pc
+= sizeof(struct binary_op
);
1256 OP(FILTER_OP_GT_STRING
):
1260 res
= (stack_strcmp(stack
, top
, ">") > 0);
1261 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1263 estack_ax_t
= REG_S64
;
1264 next_pc
+= sizeof(struct binary_op
);
1267 OP(FILTER_OP_LT_STRING
):
1271 res
= (stack_strcmp(stack
, top
, "<") < 0);
1272 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1274 estack_ax_t
= REG_S64
;
1275 next_pc
+= sizeof(struct binary_op
);
1278 OP(FILTER_OP_GE_STRING
):
1282 res
= (stack_strcmp(stack
, top
, ">=") >= 0);
1283 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1285 estack_ax_t
= REG_S64
;
1286 next_pc
+= sizeof(struct binary_op
);
1289 OP(FILTER_OP_LE_STRING
):
1293 res
= (stack_strcmp(stack
, top
, "<=") <= 0);
1294 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1296 estack_ax_t
= REG_S64
;
1297 next_pc
+= sizeof(struct binary_op
);
1301 OP(FILTER_OP_EQ_STAR_GLOB_STRING
):
1305 res
= (stack_star_glob_match(stack
, top
, "==") == 0);
1306 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1308 estack_ax_t
= REG_S64
;
1309 next_pc
+= sizeof(struct binary_op
);
1312 OP(FILTER_OP_NE_STAR_GLOB_STRING
):
1316 res
= (stack_star_glob_match(stack
, top
, "!=") != 0);
1317 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1319 estack_ax_t
= REG_S64
;
1320 next_pc
+= sizeof(struct binary_op
);
1324 OP(FILTER_OP_EQ_S64
):
1328 res
= (estack_bx_v
== estack_ax_v
);
1329 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1331 estack_ax_t
= REG_S64
;
1332 next_pc
+= sizeof(struct binary_op
);
1335 OP(FILTER_OP_NE_S64
):
1339 res
= (estack_bx_v
!= estack_ax_v
);
1340 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1342 estack_ax_t
= REG_S64
;
1343 next_pc
+= sizeof(struct binary_op
);
1346 OP(FILTER_OP_GT_S64
):
1350 res
= (estack_bx_v
> estack_ax_v
);
1351 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1353 estack_ax_t
= REG_S64
;
1354 next_pc
+= sizeof(struct binary_op
);
1357 OP(FILTER_OP_LT_S64
):
1361 res
= (estack_bx_v
< estack_ax_v
);
1362 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1364 estack_ax_t
= REG_S64
;
1365 next_pc
+= sizeof(struct binary_op
);
1368 OP(FILTER_OP_GE_S64
):
1372 res
= (estack_bx_v
>= estack_ax_v
);
1373 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1375 estack_ax_t
= REG_S64
;
1376 next_pc
+= sizeof(struct binary_op
);
1379 OP(FILTER_OP_LE_S64
):
1383 res
= (estack_bx_v
<= estack_ax_v
);
1384 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1386 estack_ax_t
= REG_S64
;
1387 next_pc
+= sizeof(struct binary_op
);
1391 OP(FILTER_OP_EQ_DOUBLE
):
1395 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax(stack
, top
)->u
.d
);
1396 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1398 estack_ax_t
= REG_S64
;
1399 next_pc
+= sizeof(struct binary_op
);
1402 OP(FILTER_OP_NE_DOUBLE
):
1406 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax(stack
, top
)->u
.d
);
1407 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1409 estack_ax_t
= REG_S64
;
1410 next_pc
+= sizeof(struct binary_op
);
1413 OP(FILTER_OP_GT_DOUBLE
):
1417 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax(stack
, top
)->u
.d
);
1418 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1420 estack_ax_t
= REG_S64
;
1421 next_pc
+= sizeof(struct binary_op
);
1424 OP(FILTER_OP_LT_DOUBLE
):
1428 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax(stack
, top
)->u
.d
);
1429 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1431 estack_ax_t
= REG_S64
;
1432 next_pc
+= sizeof(struct binary_op
);
1435 OP(FILTER_OP_GE_DOUBLE
):
1439 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax(stack
, top
)->u
.d
);
1440 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1442 estack_ax_t
= REG_S64
;
1443 next_pc
+= sizeof(struct binary_op
);
1446 OP(FILTER_OP_LE_DOUBLE
):
1450 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax(stack
, top
)->u
.d
);
1451 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1453 estack_ax_t
= REG_S64
;
1454 next_pc
+= sizeof(struct binary_op
);
1458 /* Mixed S64-double binary comparators */
1459 OP(FILTER_OP_EQ_DOUBLE_S64
):
1463 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax_v
);
1464 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1466 estack_ax_t
= REG_S64
;
1467 next_pc
+= sizeof(struct binary_op
);
1470 OP(FILTER_OP_NE_DOUBLE_S64
):
1474 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax_v
);
1475 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1477 estack_ax_t
= REG_S64
;
1478 next_pc
+= sizeof(struct binary_op
);
1481 OP(FILTER_OP_GT_DOUBLE_S64
):
1485 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax_v
);
1486 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1488 estack_ax_t
= REG_S64
;
1489 next_pc
+= sizeof(struct binary_op
);
1492 OP(FILTER_OP_LT_DOUBLE_S64
):
1496 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax_v
);
1497 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1499 estack_ax_t
= REG_S64
;
1500 next_pc
+= sizeof(struct binary_op
);
1503 OP(FILTER_OP_GE_DOUBLE_S64
):
1507 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax_v
);
1508 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1510 estack_ax_t
= REG_S64
;
1511 next_pc
+= sizeof(struct binary_op
);
1514 OP(FILTER_OP_LE_DOUBLE_S64
):
1518 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax_v
);
1519 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1521 estack_ax_t
= REG_S64
;
1522 next_pc
+= sizeof(struct binary_op
);
1526 OP(FILTER_OP_EQ_S64_DOUBLE
):
1530 res
= (estack_bx_v
== estack_ax(stack
, top
)->u
.d
);
1531 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1533 estack_ax_t
= REG_S64
;
1534 next_pc
+= sizeof(struct binary_op
);
1537 OP(FILTER_OP_NE_S64_DOUBLE
):
1541 res
= (estack_bx_v
!= estack_ax(stack
, top
)->u
.d
);
1542 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1544 estack_ax_t
= REG_S64
;
1545 next_pc
+= sizeof(struct binary_op
);
1548 OP(FILTER_OP_GT_S64_DOUBLE
):
1552 res
= (estack_bx_v
> estack_ax(stack
, top
)->u
.d
);
1553 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1555 estack_ax_t
= REG_S64
;
1556 next_pc
+= sizeof(struct binary_op
);
1559 OP(FILTER_OP_LT_S64_DOUBLE
):
1563 res
= (estack_bx_v
< estack_ax(stack
, top
)->u
.d
);
1564 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1566 estack_ax_t
= REG_S64
;
1567 next_pc
+= sizeof(struct binary_op
);
1570 OP(FILTER_OP_GE_S64_DOUBLE
):
1574 res
= (estack_bx_v
>= estack_ax(stack
, top
)->u
.d
);
1575 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1577 estack_ax_t
= REG_S64
;
1578 next_pc
+= sizeof(struct binary_op
);
1581 OP(FILTER_OP_LE_S64_DOUBLE
):
1585 res
= (estack_bx_v
<= estack_ax(stack
, top
)->u
.d
);
1586 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1588 estack_ax_t
= REG_S64
;
1589 next_pc
+= sizeof(struct binary_op
);
1592 OP(FILTER_OP_BIT_RSHIFT
):
1596 /* Dynamic typing. */
1597 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1601 /* Catch undefined behavior. */
1602 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1606 res
= ((uint64_t) estack_bx_v
>> (uint32_t) 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_BIT_LSHIFT
):
1617 /* Dynamic typing. */
1618 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1622 /* Catch undefined behavior. */
1623 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1627 res
= ((uint64_t) estack_bx_v
<< (uint32_t) estack_ax_v
);
1628 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1630 estack_ax_t
= REG_S64
;
1631 next_pc
+= sizeof(struct binary_op
);
1634 OP(FILTER_OP_BIT_AND
):
1638 /* Dynamic typing. */
1639 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1644 res
= ((uint64_t) estack_bx_v
& (uint64_t) estack_ax_v
);
1645 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1647 estack_ax_t
= REG_S64
;
1648 next_pc
+= sizeof(struct binary_op
);
1651 OP(FILTER_OP_BIT_OR
):
1655 /* Dynamic typing. */
1656 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1661 res
= ((uint64_t) estack_bx_v
| (uint64_t) estack_ax_v
);
1662 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1664 estack_ax_t
= REG_S64
;
1665 next_pc
+= sizeof(struct binary_op
);
1668 OP(FILTER_OP_BIT_XOR
):
1672 /* Dynamic typing. */
1673 if (estack_ax_t
!= REG_S64
|| estack_bx_t
!= REG_S64
) {
1678 res
= ((uint64_t) estack_bx_v
^ (uint64_t) estack_ax_v
);
1679 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1681 estack_ax_t
= REG_S64
;
1682 next_pc
+= sizeof(struct binary_op
);
1687 OP(FILTER_OP_UNARY_PLUS
):
1689 /* Dynamic typing. */
1690 switch (estack_ax_t
) {
1691 case REG_S64
: /* Fall-through. */
1692 JUMP_TO(FILTER_OP_UNARY_PLUS_S64
);
1694 JUMP_TO(FILTER_OP_UNARY_PLUS_DOUBLE
);
1695 case REG_STRING
: /* Fall-through */
1696 case REG_STAR_GLOB_STRING
:
1700 ERR("Unknown filter register type (%d)",
1706 OP(FILTER_OP_UNARY_MINUS
):
1708 /* Dynamic typing. */
1709 switch (estack_ax_t
) {
1711 JUMP_TO(FILTER_OP_UNARY_MINUS_S64
);
1713 JUMP_TO(FILTER_OP_UNARY_MINUS_DOUBLE
);
1714 case REG_STRING
: /* Fall-through */
1715 case REG_STAR_GLOB_STRING
:
1719 ERR("Unknown filter register type (%d)",
1725 OP(FILTER_OP_UNARY_NOT
):
1727 /* Dynamic typing. */
1728 switch (estack_ax_t
) {
1730 JUMP_TO(FILTER_OP_UNARY_NOT_S64
);
1732 JUMP_TO(FILTER_OP_UNARY_NOT_DOUBLE
);
1733 case REG_STRING
: /* Fall-through */
1734 case REG_STAR_GLOB_STRING
:
1738 ERR("Unknown filter register type (%d)",
1743 next_pc
+= sizeof(struct unary_op
);
1747 OP(FILTER_OP_UNARY_BIT_NOT
):
1749 /* Dynamic typing. */
1750 if (estack_ax_t
!= REG_S64
) {
1755 estack_ax_v
= ~(uint64_t) estack_ax_v
;
1756 next_pc
+= sizeof(struct unary_op
);
1760 OP(FILTER_OP_UNARY_PLUS_S64
):
1761 OP(FILTER_OP_UNARY_PLUS_DOUBLE
):
1763 next_pc
+= sizeof(struct unary_op
);
1766 OP(FILTER_OP_UNARY_MINUS_S64
):
1768 estack_ax_v
= -estack_ax_v
;
1769 next_pc
+= sizeof(struct unary_op
);
1772 OP(FILTER_OP_UNARY_MINUS_DOUBLE
):
1774 estack_ax(stack
, top
)->u
.d
= -estack_ax(stack
, top
)->u
.d
;
1775 next_pc
+= sizeof(struct unary_op
);
1778 OP(FILTER_OP_UNARY_NOT_S64
):
1780 estack_ax_v
= !estack_ax_v
;
1781 next_pc
+= sizeof(struct unary_op
);
1784 OP(FILTER_OP_UNARY_NOT_DOUBLE
):
1786 estack_ax_v
= !estack_ax(stack
, top
)->u
.d
;
1787 estack_ax_t
= REG_S64
;
1788 next_pc
+= sizeof(struct unary_op
);
1795 struct logical_op
*insn
= (struct logical_op
*) pc
;
1797 if (estack_ax_t
!= REG_S64
) {
1801 /* If AX is 0, skip and evaluate to 0 */
1802 if (unlikely(estack_ax_v
== 0)) {
1803 dbg_printf("Jumping to bytecode offset %u\n",
1804 (unsigned int) insn
->skip_offset
);
1805 next_pc
= start_pc
+ insn
->skip_offset
;
1807 /* Pop 1 when jump not taken */
1808 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1809 next_pc
+= sizeof(struct logical_op
);
1815 struct logical_op
*insn
= (struct logical_op
*) pc
;
1817 if (estack_ax_t
!= REG_S64
) {
1821 /* If AX is nonzero, skip and evaluate to 1 */
1822 if (unlikely(estack_ax_v
!= 0)) {
1824 dbg_printf("Jumping to bytecode offset %u\n",
1825 (unsigned int) insn
->skip_offset
);
1826 next_pc
= start_pc
+ insn
->skip_offset
;
1828 /* Pop 1 when jump not taken */
1829 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1830 next_pc
+= sizeof(struct logical_op
);
1836 /* load field ref */
1837 OP(FILTER_OP_LOAD_FIELD_REF_STRING
):
1839 struct load_op
*insn
= (struct load_op
*) pc
;
1840 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1842 dbg_printf("load field ref offset %u type string\n",
1844 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1845 estack_ax(stack
, top
)->u
.s
.str
=
1846 *(const char * const *) &filter_stack_data
[ref
->offset
];
1847 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1848 dbg_printf("Filter warning: loading a NULL string.\n");
1852 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1853 estack_ax(stack
, top
)->u
.s
.literal_type
=
1854 ESTACK_STRING_LITERAL_TYPE_NONE
;
1855 estack_ax_t
= REG_STRING
;
1856 dbg_printf("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1857 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1861 OP(FILTER_OP_LOAD_FIELD_REF_SEQUENCE
):
1863 struct load_op
*insn
= (struct load_op
*) pc
;
1864 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1866 dbg_printf("load field ref offset %u type sequence\n",
1868 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1869 estack_ax(stack
, top
)->u
.s
.seq_len
=
1870 *(unsigned long *) &filter_stack_data
[ref
->offset
];
1871 estack_ax(stack
, top
)->u
.s
.str
=
1872 *(const char **) (&filter_stack_data
[ref
->offset
1873 + sizeof(unsigned long)]);
1874 estack_ax_t
= REG_STRING
;
1875 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1876 dbg_printf("Filter warning: loading a NULL sequence.\n");
1880 estack_ax(stack
, top
)->u
.s
.literal_type
=
1881 ESTACK_STRING_LITERAL_TYPE_NONE
;
1882 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1886 OP(FILTER_OP_LOAD_FIELD_REF_S64
):
1888 struct load_op
*insn
= (struct load_op
*) pc
;
1889 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1891 dbg_printf("load field ref offset %u type s64\n",
1893 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1895 ((struct literal_numeric
*) &filter_stack_data
[ref
->offset
])->v
;
1896 estack_ax_t
= REG_S64
;
1897 dbg_printf("ref load s64 %" PRIi64
"\n", estack_ax_v
);
1898 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1902 OP(FILTER_OP_LOAD_FIELD_REF_DOUBLE
):
1904 struct load_op
*insn
= (struct load_op
*) pc
;
1905 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1907 dbg_printf("load field ref offset %u type double\n",
1909 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1910 memcpy(&estack_ax(stack
, top
)->u
.d
, &filter_stack_data
[ref
->offset
],
1911 sizeof(struct literal_double
));
1912 estack_ax_t
= REG_DOUBLE
;
1913 dbg_printf("ref load double %g\n", estack_ax(stack
, top
)->u
.d
);
1914 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1918 /* load from immediate operand */
1919 OP(FILTER_OP_LOAD_STRING
):
1921 struct load_op
*insn
= (struct load_op
*) pc
;
1923 dbg_printf("load string %s\n", insn
->data
);
1924 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1925 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1926 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1927 estack_ax(stack
, top
)->u
.s
.literal_type
=
1928 ESTACK_STRING_LITERAL_TYPE_PLAIN
;
1929 estack_ax_t
= REG_STRING
;
1930 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1934 OP(FILTER_OP_LOAD_STAR_GLOB_STRING
):
1936 struct load_op
*insn
= (struct load_op
*) pc
;
1938 dbg_printf("load globbing pattern %s\n", insn
->data
);
1939 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1940 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1941 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1942 estack_ax(stack
, top
)->u
.s
.literal_type
=
1943 ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
;
1944 estack_ax_t
= REG_STAR_GLOB_STRING
;
1945 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1949 OP(FILTER_OP_LOAD_S64
):
1951 struct load_op
*insn
= (struct load_op
*) pc
;
1953 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1954 estack_ax_v
= ((struct literal_numeric
*) insn
->data
)->v
;
1955 estack_ax_t
= REG_S64
;
1956 dbg_printf("load s64 %" PRIi64
"\n", estack_ax_v
);
1957 next_pc
+= sizeof(struct load_op
)
1958 + sizeof(struct literal_numeric
);
1962 OP(FILTER_OP_LOAD_DOUBLE
):
1964 struct load_op
*insn
= (struct load_op
*) pc
;
1966 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1967 memcpy(&estack_ax(stack
, top
)->u
.d
, insn
->data
,
1968 sizeof(struct literal_double
));
1969 estack_ax_t
= REG_DOUBLE
;
1970 dbg_printf("load double %g\n", estack_ax(stack
, top
)->u
.d
);
1971 next_pc
+= sizeof(struct load_op
)
1972 + sizeof(struct literal_double
);
1977 OP(FILTER_OP_CAST_TO_S64
):
1979 /* Dynamic typing. */
1980 switch (estack_ax_t
) {
1982 JUMP_TO(FILTER_OP_CAST_NOP
);
1984 JUMP_TO(FILTER_OP_CAST_DOUBLE_TO_S64
);
1985 case REG_STRING
: /* Fall-through */
1986 case REG_STAR_GLOB_STRING
:
1990 ERR("Unknown filter register type (%d)",
1997 OP(FILTER_OP_CAST_DOUBLE_TO_S64
):
1999 estack_ax_v
= (int64_t) estack_ax(stack
, top
)->u
.d
;
2000 estack_ax_t
= REG_S64
;
2001 next_pc
+= sizeof(struct cast_op
);
2005 OP(FILTER_OP_CAST_NOP
):
2007 next_pc
+= sizeof(struct cast_op
);
2011 /* get context ref */
2012 OP(FILTER_OP_GET_CONTEXT_REF
):
2014 struct load_op
*insn
= (struct load_op
*) pc
;
2015 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2016 struct lttng_ctx
*ctx
;
2017 struct lttng_ctx_field
*ctx_field
;
2018 struct lttng_ctx_value v
;
2020 dbg_printf("get context ref offset %u type dynamic\n",
2022 ctx
= rcu_dereference(session
->ctx
);
2023 ctx_field
= &ctx
->fields
[ref
->offset
];
2024 ctx_field
->get_value(ctx_field
, &v
);
2025 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2027 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
2030 case LTTNG_UST_DYNAMIC_TYPE_S64
:
2031 estack_ax_v
= v
.u
.s64
;
2032 estack_ax_t
= REG_S64
;
2033 dbg_printf("ref get context dynamic s64 %" PRIi64
"\n", estack_ax_v
);
2035 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
2036 estack_ax(stack
, top
)->u
.d
= v
.u
.d
;
2037 estack_ax_t
= REG_DOUBLE
;
2038 dbg_printf("ref get context dynamic double %g\n", estack_ax(stack
, top
)->u
.d
);
2040 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
2041 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2042 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2043 dbg_printf("Filter warning: loading a NULL string.\n");
2047 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2048 estack_ax(stack
, top
)->u
.s
.literal_type
=
2049 ESTACK_STRING_LITERAL_TYPE_NONE
;
2050 dbg_printf("ref get context dynamic string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2051 estack_ax_t
= REG_STRING
;
2054 dbg_printf("Filter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
2058 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2062 OP(FILTER_OP_GET_CONTEXT_REF_STRING
):
2064 struct load_op
*insn
= (struct load_op
*) pc
;
2065 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2066 struct lttng_ctx
*ctx
;
2067 struct lttng_ctx_field
*ctx_field
;
2068 struct lttng_ctx_value v
;
2070 dbg_printf("get context ref offset %u type string\n",
2072 ctx
= rcu_dereference(session
->ctx
);
2073 ctx_field
= &ctx
->fields
[ref
->offset
];
2074 ctx_field
->get_value(ctx_field
, &v
);
2075 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2076 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2077 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2078 dbg_printf("Filter warning: loading a NULL string.\n");
2082 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2083 estack_ax(stack
, top
)->u
.s
.literal_type
=
2084 ESTACK_STRING_LITERAL_TYPE_NONE
;
2085 estack_ax_t
= REG_STRING
;
2086 dbg_printf("ref get context string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2087 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2091 OP(FILTER_OP_GET_CONTEXT_REF_S64
):
2093 struct load_op
*insn
= (struct load_op
*) pc
;
2094 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2095 struct lttng_ctx
*ctx
;
2096 struct lttng_ctx_field
*ctx_field
;
2097 struct lttng_ctx_value v
;
2099 dbg_printf("get context ref offset %u type s64\n",
2101 ctx
= rcu_dereference(session
->ctx
);
2102 ctx_field
= &ctx
->fields
[ref
->offset
];
2103 ctx_field
->get_value(ctx_field
, &v
);
2104 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2105 estack_ax_v
= v
.u
.s64
;
2106 estack_ax_t
= REG_S64
;
2107 dbg_printf("ref get context s64 %" PRIi64
"\n", estack_ax_v
);
2108 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2112 OP(FILTER_OP_GET_CONTEXT_REF_DOUBLE
):
2114 struct load_op
*insn
= (struct load_op
*) pc
;
2115 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2116 struct lttng_ctx
*ctx
;
2117 struct lttng_ctx_field
*ctx_field
;
2118 struct lttng_ctx_value v
;
2120 dbg_printf("get context ref offset %u type double\n",
2122 ctx
= rcu_dereference(session
->ctx
);
2123 ctx_field
= &ctx
->fields
[ref
->offset
];
2124 ctx_field
->get_value(ctx_field
, &v
);
2125 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2126 memcpy(&estack_ax(stack
, top
)->u
.d
, &v
.u
.d
, sizeof(struct literal_double
));
2127 estack_ax_t
= REG_DOUBLE
;
2128 dbg_printf("ref get context double %g\n", estack_ax(stack
, top
)->u
.d
);
2129 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2133 OP(FILTER_OP_GET_CONTEXT_ROOT
):
2135 dbg_printf("op get context root\n");
2136 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2137 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_CONTEXT
;
2138 /* "field" only needed for variants. */
2139 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2140 estack_ax_t
= REG_PTR
;
2141 next_pc
+= sizeof(struct load_op
);
2145 OP(FILTER_OP_GET_APP_CONTEXT_ROOT
):
2147 dbg_printf("op get app context root\n");
2148 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2149 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_APP_CONTEXT
;
2150 /* "field" only needed for variants. */
2151 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2152 estack_ax_t
= REG_PTR
;
2153 next_pc
+= sizeof(struct load_op
);
2157 OP(FILTER_OP_GET_PAYLOAD_ROOT
):
2159 dbg_printf("op get app payload root\n");
2160 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2161 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_PAYLOAD
;
2162 estack_ax(stack
, top
)->u
.ptr
.ptr
= filter_stack_data
;
2163 /* "field" only needed for variants. */
2164 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2165 estack_ax_t
= REG_PTR
;
2166 next_pc
+= sizeof(struct load_op
);
2170 OP(FILTER_OP_GET_SYMBOL
):
2172 dbg_printf("op get symbol\n");
2173 switch (estack_ax(stack
, top
)->u
.ptr
.type
) {
2175 ERR("Nested fields not implemented yet.");
2178 case LOAD_ROOT_CONTEXT
:
2179 case LOAD_ROOT_APP_CONTEXT
:
2180 case LOAD_ROOT_PAYLOAD
:
2182 * symbol lookup is performed by
2188 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_symbol
);
2192 OP(FILTER_OP_GET_SYMBOL_FIELD
):
2195 * Used for first variant encountered in a
2196 * traversal. Variants are not implemented yet.
2202 OP(FILTER_OP_GET_INDEX_U16
):
2204 struct load_op
*insn
= (struct load_op
*) pc
;
2205 struct get_index_u16
*index
= (struct get_index_u16
*) insn
->data
;
2207 dbg_printf("op get index u16\n");
2208 ret
= dynamic_get_index(session
, bytecode
, index
->index
, estack_ax(stack
, top
));
2211 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2212 estack_ax_t
= estack_ax(stack
, top
)->type
;
2213 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u16
);
2217 OP(FILTER_OP_GET_INDEX_U64
):
2219 struct load_op
*insn
= (struct load_op
*) pc
;
2220 struct get_index_u64
*index
= (struct get_index_u64
*) insn
->data
;
2222 dbg_printf("op get index u64\n");
2223 ret
= dynamic_get_index(session
, bytecode
, index
->index
, estack_ax(stack
, top
));
2226 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2227 estack_ax_t
= estack_ax(stack
, top
)->type
;
2228 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u64
);
2232 OP(FILTER_OP_LOAD_FIELD
):
2234 dbg_printf("op load field\n");
2235 ret
= dynamic_load_field(estack_ax(stack
, top
));
2238 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2239 estack_ax_t
= estack_ax(stack
, top
)->type
;
2240 next_pc
+= sizeof(struct load_op
);
2244 OP(FILTER_OP_LOAD_FIELD_S8
):
2246 dbg_printf("op load field s8\n");
2248 estack_ax_v
= *(int8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2249 estack_ax_t
= REG_S64
;
2250 next_pc
+= sizeof(struct load_op
);
2253 OP(FILTER_OP_LOAD_FIELD_S16
):
2255 dbg_printf("op load field s16\n");
2257 estack_ax_v
= *(int16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2258 estack_ax_t
= REG_S64
;
2259 next_pc
+= sizeof(struct load_op
);
2262 OP(FILTER_OP_LOAD_FIELD_S32
):
2264 dbg_printf("op load field s32\n");
2266 estack_ax_v
= *(int32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2267 estack_ax_t
= REG_S64
;
2268 next_pc
+= sizeof(struct load_op
);
2271 OP(FILTER_OP_LOAD_FIELD_S64
):
2273 dbg_printf("op load field s64\n");
2275 estack_ax_v
= *(int64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2276 estack_ax_t
= REG_S64
;
2277 next_pc
+= sizeof(struct load_op
);
2280 OP(FILTER_OP_LOAD_FIELD_U8
):
2282 dbg_printf("op load field u8\n");
2284 estack_ax_v
= *(uint8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2285 estack_ax_t
= REG_S64
;
2286 next_pc
+= sizeof(struct load_op
);
2289 OP(FILTER_OP_LOAD_FIELD_U16
):
2291 dbg_printf("op load field u16\n");
2293 estack_ax_v
= *(uint16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2294 estack_ax_t
= REG_S64
;
2295 next_pc
+= sizeof(struct load_op
);
2298 OP(FILTER_OP_LOAD_FIELD_U32
):
2300 dbg_printf("op load field u32\n");
2302 estack_ax_v
= *(uint32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2303 estack_ax_t
= REG_S64
;
2304 next_pc
+= sizeof(struct load_op
);
2307 OP(FILTER_OP_LOAD_FIELD_U64
):
2309 dbg_printf("op load field u64\n");
2311 estack_ax_v
= *(uint64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2312 estack_ax_t
= REG_S64
;
2313 next_pc
+= sizeof(struct load_op
);
2316 OP(FILTER_OP_LOAD_FIELD_DOUBLE
):
2318 dbg_printf("op load field double\n");
2320 memcpy(&estack_ax(stack
, top
)->u
.d
,
2321 estack_ax(stack
, top
)->u
.ptr
.ptr
,
2322 sizeof(struct literal_double
));
2323 estack_ax(stack
, top
)->type
= REG_DOUBLE
;
2324 next_pc
+= sizeof(struct load_op
);
2328 OP(FILTER_OP_LOAD_FIELD_STRING
):
2332 dbg_printf("op load field string\n");
2333 str
= (const char *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2334 estack_ax(stack
, top
)->u
.s
.str
= str
;
2335 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2336 dbg_printf("Filter warning: loading a NULL string.\n");
2340 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2341 estack_ax(stack
, top
)->u
.s
.literal_type
=
2342 ESTACK_STRING_LITERAL_TYPE_NONE
;
2343 estack_ax(stack
, top
)->type
= REG_STRING
;
2344 next_pc
+= sizeof(struct load_op
);
2348 OP(FILTER_OP_LOAD_FIELD_SEQUENCE
):
2352 dbg_printf("op load field string sequence\n");
2353 ptr
= estack_ax(stack
, top
)->u
.ptr
.ptr
;
2354 estack_ax(stack
, top
)->u
.s
.seq_len
= *(unsigned long *) ptr
;
2355 estack_ax(stack
, top
)->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
2356 estack_ax(stack
, top
)->type
= REG_STRING
;
2357 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2358 dbg_printf("Filter warning: loading a NULL sequence.\n");
2362 estack_ax(stack
, top
)->u
.s
.literal_type
=
2363 ESTACK_STRING_LITERAL_TYPE_NONE
;
2364 next_pc
+= sizeof(struct load_op
);
2370 /* Return _DISCARD on error. */
2372 return LTTNG_FILTER_DISCARD
;