1 /* SPDX-License-Identifier: MIT
3 * lttng-bytecode-interpreter.c
5 * LTTng modules bytecode interpreter.
7 * Copyright (C) 2010-2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 #include <wrapper/compiler_attributes.h>
11 #include <wrapper/uaccess.h>
12 #include <wrapper/objtool.h>
13 #include <wrapper/types.h>
14 #include <linux/swab.h>
16 #include <lttng/lttng-bytecode.h>
17 #include <lttng/string-utils.h>
18 #include <lttng/events-internal.h>
19 #include <lttng/probe-user.h>
22 * get_char should be called with page fault handler disabled if it is expected
23 * to handle user-space read.
26 char get_char(const struct estack_entry
*reg
, size_t offset
)
28 if (unlikely(offset
>= reg
->u
.s
.seq_len
))
33 /* Handle invalid access as end of string. */
34 if (unlikely(!lttng_access_ok(VERIFY_READ
,
35 reg
->u
.s
.user_str
+ offset
,
38 /* Handle fault (nonzero return value) as end of string. */
39 if (unlikely(__copy_from_user_inatomic(&c
,
40 reg
->u
.s
.user_str
+ offset
,
45 return reg
->u
.s
.str
[offset
];
51 * -2: unknown escape char.
55 int parse_char(struct estack_entry
*reg
, char *c
, size_t *offset
)
60 *c
= get_char(reg
, *offset
);
76 char get_char_at_cb(size_t at
, void *data
)
78 return get_char(data
, at
);
82 int stack_star_glob_match(struct estack
*stack
, int top
, const char *cmp_type
)
84 bool has_user
= false;
86 struct estack_entry
*pattern_reg
;
87 struct estack_entry
*candidate_reg
;
89 /* Disable the page fault handler when reading from userspace. */
90 if (estack_bx(stack
, top
)->u
.s
.user
91 || estack_ax(stack
, top
)->u
.s
.user
) {
96 /* Find out which side is the pattern vs. the candidate. */
97 if (estack_ax(stack
, top
)->u
.s
.literal_type
== ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
) {
98 pattern_reg
= estack_ax(stack
, top
);
99 candidate_reg
= estack_bx(stack
, top
);
101 pattern_reg
= estack_bx(stack
, top
);
102 candidate_reg
= estack_ax(stack
, top
);
105 /* Perform the match operation. */
106 result
= !strutils_star_glob_match_char_cb(get_char_at_cb
,
107 pattern_reg
, get_char_at_cb
, candidate_reg
);
115 int stack_strcmp(struct estack
*stack
, int top
, const char *cmp_type
)
117 size_t offset_bx
= 0, offset_ax
= 0;
118 int diff
, has_user
= 0;
120 if (estack_bx(stack
, top
)->u
.s
.user
121 || estack_ax(stack
, top
)->u
.s
.user
) {
129 char char_bx
, char_ax
;
131 char_bx
= get_char(estack_bx(stack
, top
), offset_bx
);
132 char_ax
= get_char(estack_ax(stack
, top
), offset_ax
);
134 if (unlikely(char_bx
== '\0')) {
135 if (char_ax
== '\0') {
139 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
140 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
141 ret
= parse_char(estack_ax(stack
, top
),
142 &char_ax
, &offset_ax
);
152 if (unlikely(char_ax
== '\0')) {
153 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
154 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
155 ret
= parse_char(estack_bx(stack
, top
),
156 &char_bx
, &offset_bx
);
165 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
166 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
167 ret
= parse_char(estack_bx(stack
, top
),
168 &char_bx
, &offset_bx
);
172 } else if (ret
== -2) {
175 /* else compare both char */
177 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
178 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
179 ret
= parse_char(estack_ax(stack
, top
),
180 &char_ax
, &offset_ax
);
184 } else if (ret
== -2) {
201 diff
= char_bx
- char_ax
;
213 int lttng_bytecode_interpret_error(
214 struct lttng_kernel_bytecode_runtime
*bytecode_runtime
__attribute__((unused
)),
215 const char *stack_data
__attribute__((unused
)),
216 struct lttng_kernel_probe_ctx
*probe_ctx
__attribute__((unused
)),
217 void *ctx
__attribute__((unused
)))
219 return LTTNG_KERNEL_BYTECODE_INTERPRETER_ERROR
;
222 #ifdef INTERPRETER_USE_SWITCH
225 * Fallback for compilers that do not support taking address of labels.
229 start_pc = &bytecode->data[0]; \
230 for (pc = next_pc = start_pc; pc - start_pc < bytecode->len; \
232 dbg_printk("LTTng: Executing op %s (%u)\n", \
233 lttng_bytecode_print_op((unsigned int) *(bytecode_opcode_t *) pc), \
234 (unsigned int) *(bytecode_opcode_t *) pc); \
235 switch (*(bytecode_opcode_t *) pc) {
237 #define OP(name) case name
247 * Dispatch-table based interpreter.
251 start_pc = &bytecode->code[0]; \
252 pc = next_pc = start_pc; \
253 if (unlikely(pc - start_pc >= bytecode->len)) \
255 goto *dispatch[*(bytecode_opcode_t *) pc];
262 goto *dispatch[*(bytecode_opcode_t *) pc];
268 #define IS_INTEGER_REGISTER(reg_type) \
269 (reg_type == REG_S64 || reg_type == REG_U64)
271 static int context_get_index(struct lttng_kernel_probe_ctx
*lttng_probe_ctx
,
272 struct load_ptr
*ptr
,
276 struct lttng_kernel_ctx_field
*ctx_field
;
277 const struct lttng_kernel_event_field
*field
;
278 struct lttng_ctx_value v
;
280 ctx_field
= <tng_static_ctx
->fields
[idx
];
281 field
= ctx_field
->event_field
;
282 ptr
->type
= LOAD_OBJECT
;
283 /* field is only used for types nested within variants. */
286 switch (field
->type
->type
) {
287 case lttng_kernel_type_integer
:
289 const struct lttng_kernel_type_integer
*integer_type
= lttng_kernel_get_type_integer(field
->type
);
291 ctx_field
->get_value(ctx_field
->priv
, lttng_probe_ctx
, &v
);
292 if (lttng_kernel_get_type_integer(field
->type
)->signedness
) {
293 ptr
->object_type
= OBJECT_TYPE_S64
;
294 ptr
->u
.s64
= v
.u
.s64
;
295 ptr
->ptr
= &ptr
->u
.s64
;
297 ptr
->object_type
= OBJECT_TYPE_U64
;
298 ptr
->u
.u64
= v
.u
.s64
; /* Cast. */
299 ptr
->ptr
= &ptr
->u
.u64
;
301 ptr
->rev_bo
= integer_type
->reverse_byte_order
;
302 ptr
->user
= integer_type
->user
;
305 case lttng_kernel_type_enum
:
307 const struct lttng_kernel_type_enum
*enum_type
= lttng_kernel_get_type_enum(field
->type
);
308 const struct lttng_kernel_type_integer
*integer_type
= lttng_kernel_get_type_integer(enum_type
->container_type
);
310 ctx_field
->get_value(ctx_field
->priv
, lttng_probe_ctx
, &v
);
311 if (integer_type
->signedness
) {
312 ptr
->object_type
= OBJECT_TYPE_SIGNED_ENUM
;
313 ptr
->u
.s64
= v
.u
.s64
;
314 ptr
->ptr
= &ptr
->u
.s64
;
316 ptr
->object_type
= OBJECT_TYPE_UNSIGNED_ENUM
;
317 ptr
->u
.u64
= v
.u
.s64
; /* Cast. */
318 ptr
->ptr
= &ptr
->u
.u64
;
320 ptr
->rev_bo
= integer_type
->reverse_byte_order
;
321 ptr
->user
= integer_type
->user
;
324 case lttng_kernel_type_array
:
326 const struct lttng_kernel_type_array
*array_type
= lttng_kernel_get_type_array(field
->type
);
327 const struct lttng_kernel_type_integer
*integer_type
;
329 if (!lttng_kernel_type_is_bytewise_integer(array_type
->elem_type
)) {
330 printk(KERN_WARNING
"LTTng: bytecode: Array nesting only supports integer types.\n");
333 if (array_type
->encoding
== lttng_kernel_string_encoding_none
) {
334 printk(KERN_WARNING
"LTTng: bytecode: Only string arrays are supported for contexts.\n");
337 integer_type
= lttng_kernel_get_type_integer(array_type
->elem_type
);
338 ptr
->object_type
= OBJECT_TYPE_STRING
;
339 ptr
->user
= integer_type
->user
;
340 ctx_field
->get_value(ctx_field
->priv
, lttng_probe_ctx
, &v
);
344 case lttng_kernel_type_sequence
:
346 const struct lttng_kernel_type_sequence
*sequence_type
= lttng_kernel_get_type_sequence(field
->type
);
347 const struct lttng_kernel_type_integer
*integer_type
;
349 if (!lttng_kernel_type_is_bytewise_integer(sequence_type
->elem_type
)) {
350 printk(KERN_WARNING
"LTTng: bytecode: Sequence nesting only supports integer types.\n");
353 if (sequence_type
->encoding
== lttng_kernel_string_encoding_none
) {
354 printk(KERN_WARNING
"LTTng: bytecode: Only string sequences are supported for contexts.\n");
357 integer_type
= lttng_kernel_get_type_integer(sequence_type
->elem_type
);
358 ptr
->object_type
= OBJECT_TYPE_STRING
;
359 ptr
->user
= integer_type
->user
;
360 ctx_field
->get_value(ctx_field
->priv
, lttng_probe_ctx
, &v
);
364 case lttng_kernel_type_string
:
366 const struct lttng_kernel_type_string
*string_type
= lttng_kernel_get_type_string(field
->type
);
368 ptr
->object_type
= OBJECT_TYPE_STRING
;
369 ptr
->user
= string_type
->user
;
370 ctx_field
->get_value(ctx_field
->priv
, lttng_probe_ctx
, &v
);
374 case lttng_kernel_type_struct
:
375 printk(KERN_WARNING
"LTTng: bytecode: Structure type cannot be loaded.\n");
377 case lttng_kernel_type_variant
:
378 printk(KERN_WARNING
"LTTng: bytecode: Variant type cannot be loaded.\n");
381 printk(KERN_WARNING
"LTTng: bytecode: Unknown type: %d", (int) field
->type
->type
);
387 static int dynamic_get_index(struct lttng_kernel_probe_ctx
*lttng_probe_ctx
,
388 struct bytecode_runtime
*runtime
,
389 uint64_t index
, struct estack_entry
*stack_top
)
392 const struct bytecode_get_index_data
*gid
;
394 gid
= (const struct bytecode_get_index_data
*) &runtime
->data
[index
];
395 switch (stack_top
->u
.ptr
.type
) {
397 switch (stack_top
->u
.ptr
.object_type
) {
398 case OBJECT_TYPE_ARRAY
:
402 WARN_ON_ONCE(gid
->offset
>= gid
->array_len
);
403 /* Skip count (unsigned long) */
404 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
405 ptr
= ptr
+ gid
->offset
;
406 stack_top
->u
.ptr
.ptr
= ptr
;
407 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
408 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
409 stack_top
->u
.ptr
.user
= gid
->elem
.user
;
410 BUG_ON(stack_top
->u
.ptr
.field
->type
->type
!= lttng_kernel_type_array
);
411 stack_top
->u
.ptr
.field
= NULL
;
414 case OBJECT_TYPE_SEQUENCE
:
419 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
420 ptr_seq_len
= *(unsigned long *) stack_top
->u
.ptr
.ptr
;
421 if (gid
->offset
>= gid
->elem
.len
* ptr_seq_len
) {
425 ptr
= ptr
+ gid
->offset
;
426 stack_top
->u
.ptr
.ptr
= ptr
;
427 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
428 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
429 stack_top
->u
.ptr
.user
= gid
->elem
.user
;
430 BUG_ON(stack_top
->u
.ptr
.field
->type
->type
!= lttng_kernel_type_sequence
);
431 stack_top
->u
.ptr
.field
= NULL
;
434 case OBJECT_TYPE_STRUCT
:
435 printk(KERN_WARNING
"LTTng: bytecode: Nested structures are not supported yet.\n");
438 case OBJECT_TYPE_VARIANT
:
440 printk(KERN_WARNING
"LTTng: bytecode: Unexpected get index type %d",
441 (int) stack_top
->u
.ptr
.object_type
);
446 case LOAD_ROOT_CONTEXT
:
448 case LOAD_ROOT_APP_CONTEXT
:
450 ret
= context_get_index(lttng_probe_ctx
,
458 case LOAD_ROOT_PAYLOAD
:
459 stack_top
->u
.ptr
.ptr
+= gid
->offset
;
460 if (gid
->elem
.type
== OBJECT_TYPE_STRING
)
461 stack_top
->u
.ptr
.ptr
= *(const char * const *) stack_top
->u
.ptr
.ptr
;
462 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
463 stack_top
->u
.ptr
.type
= LOAD_OBJECT
;
464 stack_top
->u
.ptr
.field
= gid
->field
;
465 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
466 stack_top
->u
.ptr
.user
= gid
->elem
.user
;
470 stack_top
->type
= REG_PTR
;
478 static int dynamic_load_field(struct estack_entry
*stack_top
)
482 switch (stack_top
->u
.ptr
.type
) {
485 case LOAD_ROOT_CONTEXT
:
486 case LOAD_ROOT_APP_CONTEXT
:
487 case LOAD_ROOT_PAYLOAD
:
489 dbg_printk("Bytecode warning: cannot load root, missing field name.\n");
493 switch (stack_top
->u
.ptr
.object_type
) {
495 dbg_printk("op load field s8\n");
496 if (stack_top
->u
.ptr
.user
) {
497 if (lttng_copy_from_user_check_nofault(&stack_top
->u
.v
, (int8_t __user
*) stack_top
->u
.ptr
.ptr
, sizeof(int8_t)))
500 stack_top
->u
.v
= *(int8_t *) stack_top
->u
.ptr
.ptr
;
502 stack_top
->type
= REG_S64
;
504 case OBJECT_TYPE_S16
:
508 dbg_printk("op load field s16\n");
509 if (stack_top
->u
.ptr
.user
) {
510 if (lttng_copy_from_user_check_nofault(&tmp
, (int16_t __user
*) stack_top
->u
.ptr
.ptr
, sizeof(int16_t)))
513 tmp
= *(int16_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
;
521 case OBJECT_TYPE_S32
:
525 dbg_printk("op load field s32\n");
526 if (stack_top
->u
.ptr
.user
) {
527 if (lttng_copy_from_user_check_nofault(&tmp
, (int32_t __user
*) stack_top
->u
.ptr
.ptr
, sizeof(int32_t)))
530 tmp
= *(int32_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_S64
:
542 dbg_printk("op load field s64\n");
543 if (stack_top
->u
.ptr
.user
) {
544 if (lttng_copy_from_user_check_nofault(&tmp
, (int64_t __user
*) stack_top
->u
.ptr
.ptr
, sizeof(int64_t)))
547 tmp
= *(int64_t *) stack_top
->u
.ptr
.ptr
;
549 if (stack_top
->u
.ptr
.rev_bo
)
551 stack_top
->u
.v
= tmp
;
552 stack_top
->type
= REG_S64
;
555 case OBJECT_TYPE_SIGNED_ENUM
:
559 dbg_printk("op load field signed enumeration\n");
560 if (stack_top
->u
.ptr
.user
) {
561 dbg_printk("Bytecode warning: user enum unsupported.\n");
565 tmp
= *(int64_t *) stack_top
->u
.ptr
.ptr
;
566 if (stack_top
->u
.ptr
.rev_bo
)
568 stack_top
->u
.v
= tmp
;
569 stack_top
->type
= REG_S64
;
573 dbg_printk("op load field u8\n");
574 if (stack_top
->u
.ptr
.user
) {
575 if (lttng_copy_from_user_check_nofault(&stack_top
->u
.v
, (uint8_t __user
*) stack_top
->u
.ptr
.ptr
, sizeof(uint8_t)))
578 stack_top
->u
.v
= *(uint8_t *) stack_top
->u
.ptr
.ptr
;
580 stack_top
->type
= REG_U64
;
582 case OBJECT_TYPE_U16
:
586 dbg_printk("op load field u16\n");
587 if (stack_top
->u
.ptr
.user
) {
588 if (lttng_copy_from_user_check_nofault(&tmp
, (uint16_t __user
*) stack_top
->u
.ptr
.ptr
, sizeof(uint16_t)))
591 tmp
= *(uint16_t *) stack_top
->u
.ptr
.ptr
;
593 if (stack_top
->u
.ptr
.rev_bo
)
595 stack_top
->u
.v
= tmp
;
596 stack_top
->type
= REG_U64
;
599 case OBJECT_TYPE_U32
:
603 dbg_printk("op load field u32\n");
604 if (stack_top
->u
.ptr
.user
) {
605 if (lttng_copy_from_user_check_nofault(&tmp
, (uint32_t __user
*) stack_top
->u
.ptr
.ptr
, sizeof(uint32_t)))
608 tmp
= *(uint32_t *) stack_top
->u
.ptr
.ptr
;
610 if (stack_top
->u
.ptr
.rev_bo
)
612 stack_top
->u
.v
= tmp
;
613 stack_top
->type
= REG_U64
;
616 case OBJECT_TYPE_U64
:
620 dbg_printk("op load field u64\n");
621 if (stack_top
->u
.ptr
.user
) {
622 if (lttng_copy_from_user_check_nofault(&tmp
, (uint64_t __user
*) stack_top
->u
.ptr
.ptr
, sizeof(uint64_t)))
625 tmp
= *(uint64_t *) stack_top
->u
.ptr
.ptr
;
627 if (stack_top
->u
.ptr
.rev_bo
)
629 stack_top
->u
.v
= tmp
;
630 stack_top
->type
= REG_U64
;
633 case OBJECT_TYPE_UNSIGNED_ENUM
:
637 dbg_printk("op load field unsigned enumeration\n");
638 if (stack_top
->u
.ptr
.user
) {
639 dbg_printk("Bytecode warning: user enum unsupported.\n");
643 tmp
= *(uint64_t *) stack_top
->u
.ptr
.ptr
;
644 if (stack_top
->u
.ptr
.rev_bo
)
646 stack_top
->u
.v
= tmp
;
647 stack_top
->type
= REG_U64
;
650 case OBJECT_TYPE_STRING
:
652 dbg_printk("op load field string: user=%d\n", stack_top
->u
.ptr
.user
);
653 if (stack_top
->u
.ptr
.user
) {
654 const char __user
*user_str
= (const char __user
*) stack_top
->u
.ptr
.ptr
;
656 stack_top
->u
.s
.user_str
= user_str
;
657 if (unlikely(!stack_top
->u
.s
.user_str
)) {
658 dbg_printk("Bytecode warning: loading a NULL user string.\n");
662 stack_top
->u
.s
.user
= 1;
664 const char *str
= (const char *) stack_top
->u
.ptr
.ptr
;
666 stack_top
->u
.s
.str
= str
;
667 if (unlikely(!stack_top
->u
.s
.str
)) {
668 dbg_printk("Bytecode warning: loading a NULL string.\n");
672 stack_top
->u
.s
.user
= 0;
674 stack_top
->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
675 stack_top
->u
.s
.literal_type
= ESTACK_STRING_LITERAL_TYPE_NONE
;
676 stack_top
->type
= REG_STRING
;
679 case OBJECT_TYPE_STRING_SEQUENCE
:
683 dbg_printk("op load field string sequence: user=%d\n", stack_top
->u
.ptr
.user
);
684 ptr
= stack_top
->u
.ptr
.ptr
;
685 stack_top
->u
.s
.seq_len
= *(unsigned long *) ptr
;
686 if (stack_top
->u
.ptr
.user
) {
687 stack_top
->u
.s
.user_str
= *(const char __user
**) (ptr
+ sizeof(unsigned long));
688 if (unlikely(!stack_top
->u
.s
.user_str
)) {
689 dbg_printk("Bytecode warning: loading a NULL user sequence.\n");
693 stack_top
->u
.s
.user
= 1;
695 stack_top
->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
696 if (unlikely(!stack_top
->u
.s
.str
)) {
697 dbg_printk("Bytecode warning: loading a NULL sequence.\n");
701 stack_top
->u
.s
.user
= 0;
703 stack_top
->u
.s
.literal_type
= ESTACK_STRING_LITERAL_TYPE_NONE
;
704 stack_top
->type
= REG_STRING
;
707 case OBJECT_TYPE_DYNAMIC
:
709 * Dynamic types in context are looked up
710 * by context get index.
714 case OBJECT_TYPE_DOUBLE
:
717 case OBJECT_TYPE_SEQUENCE
:
718 case OBJECT_TYPE_ARRAY
:
719 case OBJECT_TYPE_STRUCT
:
720 case OBJECT_TYPE_VARIANT
:
721 printk(KERN_WARNING
"LTTng: bytecode: Sequences, arrays, struct and variant cannot be loaded (nested types).\n");
732 int lttng_bytecode_interpret_format_output(struct estack_entry
*ax
,
733 struct lttng_interpreter_output
*output
)
740 output
->type
= LTTNG_INTERPRETER_TYPE_S64
;
741 output
->u
.s
= ax
->u
.v
;
744 output
->type
= LTTNG_INTERPRETER_TYPE_U64
;
745 output
->u
.u
= (uint64_t) ax
->u
.v
;
748 output
->type
= LTTNG_INTERPRETER_TYPE_STRING
;
749 output
->u
.str
.len
= ax
->u
.s
.seq_len
;
750 output
->u
.str
.user
= ax
->u
.s
.user
;
752 output
->u
.str
.user_str
= ax
->u
.s
.user_str
;
754 output
->u
.str
.str
= ax
->u
.s
.str
;
758 switch (ax
->u
.ptr
.object_type
) {
760 case OBJECT_TYPE_S16
:
761 case OBJECT_TYPE_S32
:
762 case OBJECT_TYPE_S64
:
764 case OBJECT_TYPE_U16
:
765 case OBJECT_TYPE_U32
:
766 case OBJECT_TYPE_U64
:
767 case OBJECT_TYPE_DOUBLE
:
768 case OBJECT_TYPE_STRING
:
769 case OBJECT_TYPE_STRING_SEQUENCE
:
770 ret
= dynamic_load_field(ax
);
773 /* Retry after loading ptr into stack top. */
775 case OBJECT_TYPE_SEQUENCE
:
776 output
->type
= LTTNG_INTERPRETER_TYPE_SEQUENCE
;
777 output
->u
.sequence
.ptr
= *(const char **) (ax
->u
.ptr
.ptr
+ sizeof(unsigned long));
778 output
->u
.sequence
.nr_elem
= *(unsigned long *) ax
->u
.ptr
.ptr
;
779 output
->u
.sequence
.nested_type
= lttng_kernel_get_type_sequence(ax
->u
.ptr
.field
->type
)->elem_type
;
781 case OBJECT_TYPE_ARRAY
:
782 /* Skip count (unsigned long) */
783 output
->type
= LTTNG_INTERPRETER_TYPE_SEQUENCE
;
784 output
->u
.sequence
.ptr
= *(const char **) (ax
->u
.ptr
.ptr
+ sizeof(unsigned long));
785 output
->u
.sequence
.nr_elem
= lttng_kernel_get_type_array(ax
->u
.ptr
.field
->type
)->length
;
786 output
->u
.sequence
.nested_type
= lttng_kernel_get_type_array(ax
->u
.ptr
.field
->type
)->elem_type
;
788 case OBJECT_TYPE_SIGNED_ENUM
:
789 ret
= dynamic_load_field(ax
);
792 output
->type
= LTTNG_INTERPRETER_TYPE_SIGNED_ENUM
;
793 output
->u
.s
= ax
->u
.v
;
795 case OBJECT_TYPE_UNSIGNED_ENUM
:
796 ret
= dynamic_load_field(ax
);
799 output
->type
= LTTNG_INTERPRETER_TYPE_UNSIGNED_ENUM
;
800 output
->u
.u
= ax
->u
.v
;
802 case OBJECT_TYPE_STRUCT
:
803 case OBJECT_TYPE_VARIANT
:
809 case REG_STAR_GLOB_STRING
:
810 case REG_TYPE_UNKNOWN
:
820 #define DBG_USER_STR_CUTOFF 32
823 * In debug mode, print user string (truncated, if necessary).
826 void dbg_load_ref_user_str_printk(const struct estack_entry
*user_str_reg
)
830 char user_str
[DBG_USER_STR_CUTOFF
];
834 last_char
= get_char(user_str_reg
, pos
);
835 user_str
[pos
] = last_char
;
837 } while (last_char
!= '\0' && pos
< sizeof(user_str
));
840 user_str
[sizeof(user_str
) - 1] = '\0';
841 dbg_printk("load field ref user string: '%s%s'\n", user_str
,
842 last_char
!= '\0' ? "[...]" : "");
846 void dbg_load_ref_user_str_printk(const struct estack_entry
*user_str_reg
)
852 * Return LTTNG_KERNEL_BYTECODE_INTERPRETER_OK on success.
853 * Return LTTNG_KERNEL_BYTECODE_INTERPRETER_ERROR on error.
855 * For FILTER bytecode: expect a struct lttng_kernel_bytecode_filter_ctx *
857 * For CAPTURE bytecode: expect a struct lttng_interpreter_output *
860 int lttng_bytecode_interpret(struct lttng_kernel_bytecode_runtime
*kernel_bytecode
,
861 const char *interpreter_stack_data
,
862 struct lttng_kernel_probe_ctx
*lttng_probe_ctx
,
865 struct bytecode_runtime
*bytecode
= container_of(kernel_bytecode
, struct bytecode_runtime
, p
);
866 void *pc
, *next_pc
, *start_pc
;
869 struct estack _stack
;
870 struct estack
*stack
= &_stack
;
871 register int64_t ax
= 0, bx
= 0;
872 register enum entry_type ax_t
= REG_TYPE_UNKNOWN
, bx_t
= REG_TYPE_UNKNOWN
;
873 register int top
= INTERPRETER_STACK_EMPTY
;
874 #ifndef INTERPRETER_USE_SWITCH
875 static void *dispatch
[NR_BYTECODE_OPS
] = {
876 [ BYTECODE_OP_UNKNOWN
] = &&LABEL_BYTECODE_OP_UNKNOWN
,
878 [ BYTECODE_OP_RETURN
] = &&LABEL_BYTECODE_OP_RETURN
,
881 [ BYTECODE_OP_MUL
] = &&LABEL_BYTECODE_OP_MUL
,
882 [ BYTECODE_OP_DIV
] = &&LABEL_BYTECODE_OP_DIV
,
883 [ BYTECODE_OP_MOD
] = &&LABEL_BYTECODE_OP_MOD
,
884 [ BYTECODE_OP_PLUS
] = &&LABEL_BYTECODE_OP_PLUS
,
885 [ BYTECODE_OP_MINUS
] = &&LABEL_BYTECODE_OP_MINUS
,
886 [ BYTECODE_OP_BIT_RSHIFT
] = &&LABEL_BYTECODE_OP_BIT_RSHIFT
,
887 [ BYTECODE_OP_BIT_LSHIFT
] = &&LABEL_BYTECODE_OP_BIT_LSHIFT
,
888 [ BYTECODE_OP_BIT_AND
] = &&LABEL_BYTECODE_OP_BIT_AND
,
889 [ BYTECODE_OP_BIT_OR
] = &&LABEL_BYTECODE_OP_BIT_OR
,
890 [ BYTECODE_OP_BIT_XOR
] = &&LABEL_BYTECODE_OP_BIT_XOR
,
892 /* binary comparators */
893 [ BYTECODE_OP_EQ
] = &&LABEL_BYTECODE_OP_EQ
,
894 [ BYTECODE_OP_NE
] = &&LABEL_BYTECODE_OP_NE
,
895 [ BYTECODE_OP_GT
] = &&LABEL_BYTECODE_OP_GT
,
896 [ BYTECODE_OP_LT
] = &&LABEL_BYTECODE_OP_LT
,
897 [ BYTECODE_OP_GE
] = &&LABEL_BYTECODE_OP_GE
,
898 [ BYTECODE_OP_LE
] = &&LABEL_BYTECODE_OP_LE
,
900 /* string binary comparator */
901 [ BYTECODE_OP_EQ_STRING
] = &&LABEL_BYTECODE_OP_EQ_STRING
,
902 [ BYTECODE_OP_NE_STRING
] = &&LABEL_BYTECODE_OP_NE_STRING
,
903 [ BYTECODE_OP_GT_STRING
] = &&LABEL_BYTECODE_OP_GT_STRING
,
904 [ BYTECODE_OP_LT_STRING
] = &&LABEL_BYTECODE_OP_LT_STRING
,
905 [ BYTECODE_OP_GE_STRING
] = &&LABEL_BYTECODE_OP_GE_STRING
,
906 [ BYTECODE_OP_LE_STRING
] = &&LABEL_BYTECODE_OP_LE_STRING
,
908 /* globbing pattern binary comparator */
909 [ BYTECODE_OP_EQ_STAR_GLOB_STRING
] = &&LABEL_BYTECODE_OP_EQ_STAR_GLOB_STRING
,
910 [ BYTECODE_OP_NE_STAR_GLOB_STRING
] = &&LABEL_BYTECODE_OP_NE_STAR_GLOB_STRING
,
912 /* s64 binary comparator */
913 [ BYTECODE_OP_EQ_S64
] = &&LABEL_BYTECODE_OP_EQ_S64
,
914 [ BYTECODE_OP_NE_S64
] = &&LABEL_BYTECODE_OP_NE_S64
,
915 [ BYTECODE_OP_GT_S64
] = &&LABEL_BYTECODE_OP_GT_S64
,
916 [ BYTECODE_OP_LT_S64
] = &&LABEL_BYTECODE_OP_LT_S64
,
917 [ BYTECODE_OP_GE_S64
] = &&LABEL_BYTECODE_OP_GE_S64
,
918 [ BYTECODE_OP_LE_S64
] = &&LABEL_BYTECODE_OP_LE_S64
,
920 /* double binary comparator */
921 [ BYTECODE_OP_EQ_DOUBLE
] = &&LABEL_BYTECODE_OP_EQ_DOUBLE
,
922 [ BYTECODE_OP_NE_DOUBLE
] = &&LABEL_BYTECODE_OP_NE_DOUBLE
,
923 [ BYTECODE_OP_GT_DOUBLE
] = &&LABEL_BYTECODE_OP_GT_DOUBLE
,
924 [ BYTECODE_OP_LT_DOUBLE
] = &&LABEL_BYTECODE_OP_LT_DOUBLE
,
925 [ BYTECODE_OP_GE_DOUBLE
] = &&LABEL_BYTECODE_OP_GE_DOUBLE
,
926 [ BYTECODE_OP_LE_DOUBLE
] = &&LABEL_BYTECODE_OP_LE_DOUBLE
,
928 /* Mixed S64-double binary comparators */
929 [ BYTECODE_OP_EQ_DOUBLE_S64
] = &&LABEL_BYTECODE_OP_EQ_DOUBLE_S64
,
930 [ BYTECODE_OP_NE_DOUBLE_S64
] = &&LABEL_BYTECODE_OP_NE_DOUBLE_S64
,
931 [ BYTECODE_OP_GT_DOUBLE_S64
] = &&LABEL_BYTECODE_OP_GT_DOUBLE_S64
,
932 [ BYTECODE_OP_LT_DOUBLE_S64
] = &&LABEL_BYTECODE_OP_LT_DOUBLE_S64
,
933 [ BYTECODE_OP_GE_DOUBLE_S64
] = &&LABEL_BYTECODE_OP_GE_DOUBLE_S64
,
934 [ BYTECODE_OP_LE_DOUBLE_S64
] = &&LABEL_BYTECODE_OP_LE_DOUBLE_S64
,
936 [ BYTECODE_OP_EQ_S64_DOUBLE
] = &&LABEL_BYTECODE_OP_EQ_S64_DOUBLE
,
937 [ BYTECODE_OP_NE_S64_DOUBLE
] = &&LABEL_BYTECODE_OP_NE_S64_DOUBLE
,
938 [ BYTECODE_OP_GT_S64_DOUBLE
] = &&LABEL_BYTECODE_OP_GT_S64_DOUBLE
,
939 [ BYTECODE_OP_LT_S64_DOUBLE
] = &&LABEL_BYTECODE_OP_LT_S64_DOUBLE
,
940 [ BYTECODE_OP_GE_S64_DOUBLE
] = &&LABEL_BYTECODE_OP_GE_S64_DOUBLE
,
941 [ BYTECODE_OP_LE_S64_DOUBLE
] = &&LABEL_BYTECODE_OP_LE_S64_DOUBLE
,
944 [ BYTECODE_OP_UNARY_PLUS
] = &&LABEL_BYTECODE_OP_UNARY_PLUS
,
945 [ BYTECODE_OP_UNARY_MINUS
] = &&LABEL_BYTECODE_OP_UNARY_MINUS
,
946 [ BYTECODE_OP_UNARY_NOT
] = &&LABEL_BYTECODE_OP_UNARY_NOT
,
947 [ BYTECODE_OP_UNARY_PLUS_S64
] = &&LABEL_BYTECODE_OP_UNARY_PLUS_S64
,
948 [ BYTECODE_OP_UNARY_MINUS_S64
] = &&LABEL_BYTECODE_OP_UNARY_MINUS_S64
,
949 [ BYTECODE_OP_UNARY_NOT_S64
] = &&LABEL_BYTECODE_OP_UNARY_NOT_S64
,
950 [ BYTECODE_OP_UNARY_PLUS_DOUBLE
] = &&LABEL_BYTECODE_OP_UNARY_PLUS_DOUBLE
,
951 [ BYTECODE_OP_UNARY_MINUS_DOUBLE
] = &&LABEL_BYTECODE_OP_UNARY_MINUS_DOUBLE
,
952 [ BYTECODE_OP_UNARY_NOT_DOUBLE
] = &&LABEL_BYTECODE_OP_UNARY_NOT_DOUBLE
,
955 [ BYTECODE_OP_AND
] = &&LABEL_BYTECODE_OP_AND
,
956 [ BYTECODE_OP_OR
] = &&LABEL_BYTECODE_OP_OR
,
959 [ BYTECODE_OP_LOAD_FIELD_REF
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_REF
,
960 [ BYTECODE_OP_LOAD_FIELD_REF_STRING
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_REF_STRING
,
961 [ BYTECODE_OP_LOAD_FIELD_REF_SEQUENCE
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_REF_SEQUENCE
,
962 [ BYTECODE_OP_LOAD_FIELD_REF_S64
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_REF_S64
,
963 [ BYTECODE_OP_LOAD_FIELD_REF_DOUBLE
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_REF_DOUBLE
,
965 /* load from immediate operand */
966 [ BYTECODE_OP_LOAD_STRING
] = &&LABEL_BYTECODE_OP_LOAD_STRING
,
967 [ BYTECODE_OP_LOAD_STAR_GLOB_STRING
] = &&LABEL_BYTECODE_OP_LOAD_STAR_GLOB_STRING
,
968 [ BYTECODE_OP_LOAD_S64
] = &&LABEL_BYTECODE_OP_LOAD_S64
,
969 [ BYTECODE_OP_LOAD_DOUBLE
] = &&LABEL_BYTECODE_OP_LOAD_DOUBLE
,
972 [ BYTECODE_OP_CAST_TO_S64
] = &&LABEL_BYTECODE_OP_CAST_TO_S64
,
973 [ BYTECODE_OP_CAST_DOUBLE_TO_S64
] = &&LABEL_BYTECODE_OP_CAST_DOUBLE_TO_S64
,
974 [ BYTECODE_OP_CAST_NOP
] = &&LABEL_BYTECODE_OP_CAST_NOP
,
976 /* get context ref */
977 [ BYTECODE_OP_GET_CONTEXT_REF
] = &&LABEL_BYTECODE_OP_GET_CONTEXT_REF
,
978 [ BYTECODE_OP_GET_CONTEXT_REF_STRING
] = &&LABEL_BYTECODE_OP_GET_CONTEXT_REF_STRING
,
979 [ BYTECODE_OP_GET_CONTEXT_REF_S64
] = &&LABEL_BYTECODE_OP_GET_CONTEXT_REF_S64
,
980 [ BYTECODE_OP_GET_CONTEXT_REF_DOUBLE
] = &&LABEL_BYTECODE_OP_GET_CONTEXT_REF_DOUBLE
,
982 /* load userspace field ref */
983 [ BYTECODE_OP_LOAD_FIELD_REF_USER_STRING
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_REF_USER_STRING
,
984 [ BYTECODE_OP_LOAD_FIELD_REF_USER_SEQUENCE
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_REF_USER_SEQUENCE
,
986 /* Instructions for recursive traversal through composed types. */
987 [ BYTECODE_OP_GET_CONTEXT_ROOT
] = &&LABEL_BYTECODE_OP_GET_CONTEXT_ROOT
,
988 [ BYTECODE_OP_GET_APP_CONTEXT_ROOT
] = &&LABEL_BYTECODE_OP_GET_APP_CONTEXT_ROOT
,
989 [ BYTECODE_OP_GET_PAYLOAD_ROOT
] = &&LABEL_BYTECODE_OP_GET_PAYLOAD_ROOT
,
991 [ BYTECODE_OP_GET_SYMBOL
] = &&LABEL_BYTECODE_OP_GET_SYMBOL
,
992 [ BYTECODE_OP_GET_SYMBOL_FIELD
] = &&LABEL_BYTECODE_OP_GET_SYMBOL_FIELD
,
993 [ BYTECODE_OP_GET_INDEX_U16
] = &&LABEL_BYTECODE_OP_GET_INDEX_U16
,
994 [ BYTECODE_OP_GET_INDEX_U64
] = &&LABEL_BYTECODE_OP_GET_INDEX_U64
,
996 [ BYTECODE_OP_LOAD_FIELD
] = &&LABEL_BYTECODE_OP_LOAD_FIELD
,
997 [ BYTECODE_OP_LOAD_FIELD_S8
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_S8
,
998 [ BYTECODE_OP_LOAD_FIELD_S16
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_S16
,
999 [ BYTECODE_OP_LOAD_FIELD_S32
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_S32
,
1000 [ BYTECODE_OP_LOAD_FIELD_S64
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_S64
,
1001 [ BYTECODE_OP_LOAD_FIELD_U8
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_U8
,
1002 [ BYTECODE_OP_LOAD_FIELD_U16
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_U16
,
1003 [ BYTECODE_OP_LOAD_FIELD_U32
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_U32
,
1004 [ BYTECODE_OP_LOAD_FIELD_U64
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_U64
,
1005 [ BYTECODE_OP_LOAD_FIELD_STRING
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_STRING
,
1006 [ BYTECODE_OP_LOAD_FIELD_SEQUENCE
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_SEQUENCE
,
1007 [ BYTECODE_OP_LOAD_FIELD_DOUBLE
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_DOUBLE
,
1009 [ BYTECODE_OP_UNARY_BIT_NOT
] = &&LABEL_BYTECODE_OP_UNARY_BIT_NOT
,
1011 [ BYTECODE_OP_RETURN_S64
] = &&LABEL_BYTECODE_OP_RETURN_S64
,
1013 #endif /* #ifndef INTERPRETER_USE_SWITCH */
1017 OP(BYTECODE_OP_UNKNOWN
):
1018 OP(BYTECODE_OP_LOAD_FIELD_REF
):
1019 OP(BYTECODE_OP_GET_CONTEXT_REF
):
1020 #ifdef INTERPRETER_USE_SWITCH
1022 #endif /* INTERPRETER_USE_SWITCH */
1023 printk(KERN_WARNING
"LTTng: bytecode: unknown bytecode op %u\n",
1024 (unsigned int) *(bytecode_opcode_t
*) pc
);
1028 OP(BYTECODE_OP_RETURN
):
1029 /* LTTNG_KERNEL_BYTECODE_INTERPRETER_ERROR or LTTNG_KERNEL_BYTECODE_INTERPRETER_OK */
1030 switch (estack_ax_t
) {
1033 retval
= !!estack_ax_v
;
1038 if (kernel_bytecode
->type
!= LTTNG_KERNEL_BYTECODE_TYPE_CAPTURE
) {
1044 case REG_STAR_GLOB_STRING
:
1045 case REG_TYPE_UNKNOWN
:
1052 OP(BYTECODE_OP_RETURN_S64
):
1053 /* LTTNG_KERNEL_BYTECODE_INTERPRETER_ERROR or LTTNG_KERNEL_BYTECODE_INTERPRETER_OK */
1054 retval
= !!estack_ax_v
;
1059 OP(BYTECODE_OP_MUL
):
1060 OP(BYTECODE_OP_DIV
):
1061 OP(BYTECODE_OP_MOD
):
1062 OP(BYTECODE_OP_PLUS
):
1063 OP(BYTECODE_OP_MINUS
):
1064 printk(KERN_WARNING
"LTTng: bytecode: unsupported bytecode op %u\n",
1065 (unsigned int) *(bytecode_opcode_t
*) pc
);
1075 printk(KERN_WARNING
"LTTng: bytecode: unsupported non-specialized bytecode op %u\n",
1076 (unsigned int) *(bytecode_opcode_t
*) pc
);
1080 OP(BYTECODE_OP_EQ_STRING
):
1084 res
= (stack_strcmp(stack
, top
, "==") == 0);
1085 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1087 estack_ax_t
= REG_S64
;
1088 next_pc
+= sizeof(struct binary_op
);
1091 OP(BYTECODE_OP_NE_STRING
):
1095 res
= (stack_strcmp(stack
, top
, "!=") != 0);
1096 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1098 estack_ax_t
= REG_S64
;
1099 next_pc
+= sizeof(struct binary_op
);
1102 OP(BYTECODE_OP_GT_STRING
):
1106 res
= (stack_strcmp(stack
, top
, ">") > 0);
1107 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1109 estack_ax_t
= REG_S64
;
1110 next_pc
+= sizeof(struct binary_op
);
1113 OP(BYTECODE_OP_LT_STRING
):
1117 res
= (stack_strcmp(stack
, top
, "<") < 0);
1118 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1120 estack_ax_t
= REG_S64
;
1121 next_pc
+= sizeof(struct binary_op
);
1124 OP(BYTECODE_OP_GE_STRING
):
1128 res
= (stack_strcmp(stack
, top
, ">=") >= 0);
1129 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1131 estack_ax_t
= REG_S64
;
1132 next_pc
+= sizeof(struct binary_op
);
1135 OP(BYTECODE_OP_LE_STRING
):
1139 res
= (stack_strcmp(stack
, top
, "<=") <= 0);
1140 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1142 estack_ax_t
= REG_S64
;
1143 next_pc
+= sizeof(struct binary_op
);
1147 OP(BYTECODE_OP_EQ_STAR_GLOB_STRING
):
1151 res
= (stack_star_glob_match(stack
, top
, "==") == 0);
1152 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1154 estack_ax_t
= REG_S64
;
1155 next_pc
+= sizeof(struct binary_op
);
1158 OP(BYTECODE_OP_NE_STAR_GLOB_STRING
):
1162 res
= (stack_star_glob_match(stack
, top
, "!=") != 0);
1163 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1165 estack_ax_t
= REG_S64
;
1166 next_pc
+= sizeof(struct binary_op
);
1170 OP(BYTECODE_OP_EQ_S64
):
1174 res
= (estack_bx_v
== estack_ax_v
);
1175 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1177 estack_ax_t
= REG_S64
;
1178 next_pc
+= sizeof(struct binary_op
);
1181 OP(BYTECODE_OP_NE_S64
):
1185 res
= (estack_bx_v
!= estack_ax_v
);
1186 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1188 estack_ax_t
= REG_S64
;
1189 next_pc
+= sizeof(struct binary_op
);
1192 OP(BYTECODE_OP_GT_S64
):
1196 res
= (estack_bx_v
> estack_ax_v
);
1197 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1199 estack_ax_t
= REG_S64
;
1200 next_pc
+= sizeof(struct binary_op
);
1203 OP(BYTECODE_OP_LT_S64
):
1207 res
= (estack_bx_v
< estack_ax_v
);
1208 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1210 estack_ax_t
= REG_S64
;
1211 next_pc
+= sizeof(struct binary_op
);
1214 OP(BYTECODE_OP_GE_S64
):
1218 res
= (estack_bx_v
>= estack_ax_v
);
1219 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1221 estack_ax_t
= REG_S64
;
1222 next_pc
+= sizeof(struct binary_op
);
1225 OP(BYTECODE_OP_LE_S64
):
1229 res
= (estack_bx_v
<= estack_ax_v
);
1230 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1232 estack_ax_t
= REG_S64
;
1233 next_pc
+= sizeof(struct binary_op
);
1237 OP(BYTECODE_OP_EQ_DOUBLE
):
1238 OP(BYTECODE_OP_NE_DOUBLE
):
1239 OP(BYTECODE_OP_GT_DOUBLE
):
1240 OP(BYTECODE_OP_LT_DOUBLE
):
1241 OP(BYTECODE_OP_GE_DOUBLE
):
1242 OP(BYTECODE_OP_LE_DOUBLE
):
1248 /* Mixed S64-double binary comparators */
1249 OP(BYTECODE_OP_EQ_DOUBLE_S64
):
1250 OP(BYTECODE_OP_NE_DOUBLE_S64
):
1251 OP(BYTECODE_OP_GT_DOUBLE_S64
):
1252 OP(BYTECODE_OP_LT_DOUBLE_S64
):
1253 OP(BYTECODE_OP_GE_DOUBLE_S64
):
1254 OP(BYTECODE_OP_LE_DOUBLE_S64
):
1255 OP(BYTECODE_OP_EQ_S64_DOUBLE
):
1256 OP(BYTECODE_OP_NE_S64_DOUBLE
):
1257 OP(BYTECODE_OP_GT_S64_DOUBLE
):
1258 OP(BYTECODE_OP_LT_S64_DOUBLE
):
1259 OP(BYTECODE_OP_GE_S64_DOUBLE
):
1260 OP(BYTECODE_OP_LE_S64_DOUBLE
):
1265 OP(BYTECODE_OP_BIT_RSHIFT
):
1269 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1274 /* Catch undefined behavior. */
1275 if (unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1279 res
= ((uint64_t) estack_bx_v
>> (uint32_t) estack_ax_v
);
1280 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1282 estack_ax_t
= REG_U64
;
1283 next_pc
+= sizeof(struct binary_op
);
1286 OP(BYTECODE_OP_BIT_LSHIFT
):
1290 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1295 /* Catch undefined behavior. */
1296 if (unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1300 res
= ((uint64_t) estack_bx_v
<< (uint32_t) estack_ax_v
);
1301 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1303 estack_ax_t
= REG_U64
;
1304 next_pc
+= sizeof(struct binary_op
);
1307 OP(BYTECODE_OP_BIT_AND
):
1311 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1316 res
= ((uint64_t) estack_bx_v
& (uint64_t) estack_ax_v
);
1317 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1319 estack_ax_t
= REG_U64
;
1320 next_pc
+= sizeof(struct binary_op
);
1323 OP(BYTECODE_OP_BIT_OR
):
1327 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1332 res
= ((uint64_t) estack_bx_v
| (uint64_t) estack_ax_v
);
1333 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1335 estack_ax_t
= REG_U64
;
1336 next_pc
+= sizeof(struct binary_op
);
1339 OP(BYTECODE_OP_BIT_XOR
):
1343 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1348 res
= ((uint64_t) estack_bx_v
^ (uint64_t) estack_ax_v
);
1349 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1351 estack_ax_t
= REG_U64
;
1352 next_pc
+= sizeof(struct binary_op
);
1357 OP(BYTECODE_OP_UNARY_PLUS
):
1358 OP(BYTECODE_OP_UNARY_MINUS
):
1359 OP(BYTECODE_OP_UNARY_NOT
):
1360 printk(KERN_WARNING
"LTTng: bytecode: unsupported non-specialized bytecode op %u\n",
1361 (unsigned int) *(bytecode_opcode_t
*) pc
);
1366 OP(BYTECODE_OP_UNARY_BIT_NOT
):
1368 estack_ax_v
= ~(uint64_t) estack_ax_v
;
1369 estack_ax_t
= REG_S64
;
1370 next_pc
+= sizeof(struct unary_op
);
1374 OP(BYTECODE_OP_UNARY_PLUS_S64
):
1376 next_pc
+= sizeof(struct unary_op
);
1379 OP(BYTECODE_OP_UNARY_MINUS_S64
):
1381 estack_ax_v
= -estack_ax_v
;
1382 estack_ax_t
= REG_S64
;
1383 next_pc
+= sizeof(struct unary_op
);
1386 OP(BYTECODE_OP_UNARY_PLUS_DOUBLE
):
1387 OP(BYTECODE_OP_UNARY_MINUS_DOUBLE
):
1392 OP(BYTECODE_OP_UNARY_NOT_S64
):
1394 estack_ax_v
= !estack_ax_v
;
1395 estack_ax_t
= REG_S64
;
1396 next_pc
+= sizeof(struct unary_op
);
1399 OP(BYTECODE_OP_UNARY_NOT_DOUBLE
):
1406 OP(BYTECODE_OP_AND
):
1408 struct logical_op
*insn
= (struct logical_op
*) pc
;
1410 /* If AX is 0, skip and evaluate to 0 */
1411 if (unlikely(estack_ax_v
== 0)) {
1412 dbg_printk("Jumping to bytecode offset %u\n",
1413 (unsigned int) insn
->skip_offset
);
1414 next_pc
= start_pc
+ insn
->skip_offset
;
1416 /* Pop 1 when jump not taken */
1417 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1418 next_pc
+= sizeof(struct logical_op
);
1424 struct logical_op
*insn
= (struct logical_op
*) pc
;
1426 /* If AX is nonzero, skip and evaluate to 1 */
1428 if (unlikely(estack_ax_v
!= 0)) {
1430 dbg_printk("Jumping to bytecode offset %u\n",
1431 (unsigned int) insn
->skip_offset
);
1432 next_pc
= start_pc
+ insn
->skip_offset
;
1434 /* Pop 1 when jump not taken */
1435 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1436 next_pc
+= sizeof(struct logical_op
);
1442 /* load field ref */
1443 OP(BYTECODE_OP_LOAD_FIELD_REF_STRING
):
1445 struct load_op
*insn
= (struct load_op
*) pc
;
1446 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1448 dbg_printk("load field ref offset %u type string\n",
1450 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1451 estack_ax(stack
, top
)->u
.s
.str
=
1452 *(const char * const *) &interpreter_stack_data
[ref
->offset
];
1453 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1454 dbg_printk("Bytecode warning: loading a NULL string.\n");
1458 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1459 estack_ax(stack
, top
)->u
.s
.literal_type
=
1460 ESTACK_STRING_LITERAL_TYPE_NONE
;
1461 estack_ax(stack
, top
)->u
.s
.user
= 0;
1462 estack_ax(stack
, top
)->type
= REG_STRING
;
1463 dbg_printk("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1464 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1468 OP(BYTECODE_OP_LOAD_FIELD_REF_SEQUENCE
):
1470 struct load_op
*insn
= (struct load_op
*) pc
;
1471 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1473 dbg_printk("load field ref offset %u type sequence\n",
1475 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1476 estack_ax(stack
, top
)->u
.s
.seq_len
=
1477 *(unsigned long *) &interpreter_stack_data
[ref
->offset
];
1478 estack_ax(stack
, top
)->u
.s
.str
=
1479 *(const char **) (&interpreter_stack_data
[ref
->offset
1480 + sizeof(unsigned long)]);
1481 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1482 dbg_printk("Bytecode warning: loading a NULL sequence.\n");
1486 estack_ax(stack
, top
)->u
.s
.literal_type
=
1487 ESTACK_STRING_LITERAL_TYPE_NONE
;
1488 estack_ax(stack
, top
)->u
.s
.user
= 0;
1489 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1493 OP(BYTECODE_OP_LOAD_FIELD_REF_S64
):
1495 struct load_op
*insn
= (struct load_op
*) pc
;
1496 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1498 dbg_printk("load field ref offset %u type s64\n",
1500 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1502 ((struct literal_numeric
*) &interpreter_stack_data
[ref
->offset
])->v
;
1503 estack_ax_t
= REG_S64
;
1504 dbg_printk("ref load s64 %lld\n",
1505 (long long) estack_ax_v
);
1506 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1510 OP(BYTECODE_OP_LOAD_FIELD_REF_DOUBLE
):
1516 /* load from immediate operand */
1517 OP(BYTECODE_OP_LOAD_STRING
):
1519 struct load_op
*insn
= (struct load_op
*) pc
;
1521 dbg_printk("load string %s\n", insn
->data
);
1522 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1523 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1524 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1525 estack_ax(stack
, top
)->u
.s
.literal_type
=
1526 ESTACK_STRING_LITERAL_TYPE_PLAIN
;
1527 estack_ax(stack
, top
)->u
.s
.user
= 0;
1528 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1532 OP(BYTECODE_OP_LOAD_STAR_GLOB_STRING
):
1534 struct load_op
*insn
= (struct load_op
*) pc
;
1536 dbg_printk("load globbing pattern %s\n", insn
->data
);
1537 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1538 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1539 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1540 estack_ax(stack
, top
)->u
.s
.literal_type
=
1541 ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
;
1542 estack_ax(stack
, top
)->u
.s
.user
= 0;
1543 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1547 OP(BYTECODE_OP_LOAD_S64
):
1549 struct load_op
*insn
= (struct load_op
*) pc
;
1551 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1552 estack_ax_v
= ((struct literal_numeric
*) insn
->data
)->v
;
1553 estack_ax_t
= REG_S64
;
1554 dbg_printk("load s64 %lld\n",
1555 (long long) estack_ax_v
);
1556 next_pc
+= sizeof(struct load_op
)
1557 + sizeof(struct literal_numeric
);
1561 OP(BYTECODE_OP_LOAD_DOUBLE
):
1568 OP(BYTECODE_OP_CAST_TO_S64
):
1569 printk(KERN_WARNING
"LTTng: bytecode: unsupported non-specialized bytecode op %u\n",
1570 (unsigned int) *(bytecode_opcode_t
*) pc
);
1574 OP(BYTECODE_OP_CAST_DOUBLE_TO_S64
):
1580 OP(BYTECODE_OP_CAST_NOP
):
1582 next_pc
+= sizeof(struct cast_op
);
1586 /* get context ref */
1587 OP(BYTECODE_OP_GET_CONTEXT_REF_STRING
):
1589 struct load_op
*insn
= (struct load_op
*) pc
;
1590 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1591 struct lttng_kernel_ctx_field
*ctx_field
;
1592 struct lttng_ctx_value v
;
1594 dbg_printk("get context ref offset %u type string\n",
1596 ctx_field
= <tng_static_ctx
->fields
[ref
->offset
];
1597 ctx_field
->get_value(ctx_field
->priv
, lttng_probe_ctx
, &v
);
1598 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1599 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
1600 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1601 dbg_printk("Bytecode warning: loading a NULL string.\n");
1605 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1606 estack_ax(stack
, top
)->u
.s
.literal_type
=
1607 ESTACK_STRING_LITERAL_TYPE_NONE
;
1608 estack_ax(stack
, top
)->u
.s
.user
= 0;
1609 estack_ax(stack
, top
)->type
= REG_STRING
;
1610 dbg_printk("ref get context string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1611 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1615 OP(BYTECODE_OP_GET_CONTEXT_REF_S64
):
1617 struct load_op
*insn
= (struct load_op
*) pc
;
1618 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1619 struct lttng_kernel_ctx_field
*ctx_field
;
1620 struct lttng_ctx_value v
;
1622 dbg_printk("get context ref offset %u type s64\n",
1624 ctx_field
= <tng_static_ctx
->fields
[ref
->offset
];
1625 ctx_field
->get_value(ctx_field
->priv
, lttng_probe_ctx
, &v
);
1626 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1627 estack_ax_v
= v
.u
.s64
;
1628 estack_ax_t
= REG_S64
;
1629 dbg_printk("ref get context s64 %lld\n",
1630 (long long) estack_ax_v
);
1631 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1635 OP(BYTECODE_OP_GET_CONTEXT_REF_DOUBLE
):
1641 /* load userspace field ref */
1642 OP(BYTECODE_OP_LOAD_FIELD_REF_USER_STRING
):
1644 struct load_op
*insn
= (struct load_op
*) pc
;
1645 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1647 dbg_printk("load field ref offset %u type user string\n",
1649 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1650 estack_ax(stack
, top
)->u
.s
.user_str
=
1651 *(const char * const *) &interpreter_stack_data
[ref
->offset
];
1652 if (unlikely(!estack_ax(stack
, top
)->u
.s
.user_str
)) {
1653 dbg_printk("Bytecode warning: loading a NULL string.\n");
1657 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1658 estack_ax(stack
, top
)->u
.s
.literal_type
=
1659 ESTACK_STRING_LITERAL_TYPE_NONE
;
1660 estack_ax(stack
, top
)->u
.s
.user
= 1;
1661 estack_ax(stack
, top
)->type
= REG_STRING
;
1662 dbg_load_ref_user_str_printk(estack_ax(stack
, top
));
1663 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1667 OP(BYTECODE_OP_LOAD_FIELD_REF_USER_SEQUENCE
):
1669 struct load_op
*insn
= (struct load_op
*) pc
;
1670 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1672 dbg_printk("load field ref offset %u type user sequence\n",
1674 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1675 estack_ax(stack
, top
)->u
.s
.seq_len
=
1676 *(unsigned long *) &interpreter_stack_data
[ref
->offset
];
1677 estack_ax(stack
, top
)->u
.s
.user_str
=
1678 *(const char **) (&interpreter_stack_data
[ref
->offset
1679 + sizeof(unsigned long)]);
1680 if (unlikely(!estack_ax(stack
, top
)->u
.s
.user_str
)) {
1681 dbg_printk("Bytecode warning: loading a NULL sequence.\n");
1685 estack_ax(stack
, top
)->u
.s
.literal_type
=
1686 ESTACK_STRING_LITERAL_TYPE_NONE
;
1687 estack_ax(stack
, top
)->u
.s
.user
= 1;
1688 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1692 OP(BYTECODE_OP_GET_CONTEXT_ROOT
):
1694 dbg_printk("op get context root\n");
1695 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1696 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_CONTEXT
;
1697 /* "field" only needed for variants. */
1698 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
1699 estack_ax(stack
, top
)->type
= REG_PTR
;
1700 next_pc
+= sizeof(struct load_op
);
1704 OP(BYTECODE_OP_GET_APP_CONTEXT_ROOT
):
1710 OP(BYTECODE_OP_GET_PAYLOAD_ROOT
):
1712 dbg_printk("op get app payload root\n");
1713 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1714 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_PAYLOAD
;
1715 estack_ax(stack
, top
)->u
.ptr
.ptr
= interpreter_stack_data
;
1716 /* "field" only needed for variants. */
1717 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
1718 estack_ax(stack
, top
)->type
= REG_PTR
;
1719 next_pc
+= sizeof(struct load_op
);
1723 OP(BYTECODE_OP_GET_SYMBOL
):
1725 dbg_printk("op get symbol\n");
1726 switch (estack_ax(stack
, top
)->u
.ptr
.type
) {
1728 printk(KERN_WARNING
"LTTng: bytecode: Nested fields not implemented yet.\n");
1731 case LOAD_ROOT_CONTEXT
:
1732 case LOAD_ROOT_APP_CONTEXT
:
1733 case LOAD_ROOT_PAYLOAD
:
1735 * symbol lookup is performed by
1741 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_symbol
);
1745 OP(BYTECODE_OP_GET_SYMBOL_FIELD
):
1748 * Used for first variant encountered in a
1749 * traversal. Variants are not implemented yet.
1755 OP(BYTECODE_OP_GET_INDEX_U16
):
1757 struct load_op
*insn
= (struct load_op
*) pc
;
1758 struct get_index_u16
*index
= (struct get_index_u16
*) insn
->data
;
1760 dbg_printk("op get index u16\n");
1761 ret
= dynamic_get_index(lttng_probe_ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
1764 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
1765 estack_ax_t
= estack_ax(stack
, top
)->type
;
1766 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u16
);
1770 OP(BYTECODE_OP_GET_INDEX_U64
):
1772 struct load_op
*insn
= (struct load_op
*) pc
;
1773 struct get_index_u64
*index
= (struct get_index_u64
*) insn
->data
;
1775 dbg_printk("op get index u64\n");
1776 ret
= dynamic_get_index(lttng_probe_ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
1779 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
1780 estack_ax_t
= estack_ax(stack
, top
)->type
;
1781 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u64
);
1785 OP(BYTECODE_OP_LOAD_FIELD
):
1787 dbg_printk("op load field\n");
1788 ret
= dynamic_load_field(estack_ax(stack
, top
));
1791 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
1792 estack_ax_t
= estack_ax(stack
, top
)->type
;
1793 next_pc
+= sizeof(struct load_op
);
1797 OP(BYTECODE_OP_LOAD_FIELD_S8
):
1799 dbg_printk("op load field s8\n");
1801 estack_ax_v
= *(int8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1802 estack_ax_t
= REG_S64
;
1803 next_pc
+= sizeof(struct load_op
);
1806 OP(BYTECODE_OP_LOAD_FIELD_S16
):
1808 dbg_printk("op load field s16\n");
1810 estack_ax_v
= *(int16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1811 estack_ax_t
= REG_S64
;
1812 next_pc
+= sizeof(struct load_op
);
1815 OP(BYTECODE_OP_LOAD_FIELD_S32
):
1817 dbg_printk("op load field s32\n");
1819 estack_ax_v
= *(int32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1820 estack_ax_t
= REG_S64
;
1821 next_pc
+= sizeof(struct load_op
);
1824 OP(BYTECODE_OP_LOAD_FIELD_S64
):
1826 dbg_printk("op load field s64\n");
1828 estack_ax_v
= *(int64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1829 estack_ax_t
= REG_S64
;
1830 next_pc
+= sizeof(struct load_op
);
1833 OP(BYTECODE_OP_LOAD_FIELD_U8
):
1835 dbg_printk("op load field u8\n");
1837 estack_ax_v
= *(uint8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1838 estack_ax_t
= REG_S64
;
1839 next_pc
+= sizeof(struct load_op
);
1842 OP(BYTECODE_OP_LOAD_FIELD_U16
):
1844 dbg_printk("op load field u16\n");
1846 estack_ax_v
= *(uint16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1847 estack_ax_t
= REG_S64
;
1848 next_pc
+= sizeof(struct load_op
);
1851 OP(BYTECODE_OP_LOAD_FIELD_U32
):
1853 dbg_printk("op load field u32\n");
1855 estack_ax_v
= *(uint32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1856 estack_ax_t
= REG_S64
;
1857 next_pc
+= sizeof(struct load_op
);
1860 OP(BYTECODE_OP_LOAD_FIELD_U64
):
1862 dbg_printk("op load field u64\n");
1864 estack_ax_v
= *(uint64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1865 estack_ax_t
= REG_S64
;
1866 next_pc
+= sizeof(struct load_op
);
1869 OP(BYTECODE_OP_LOAD_FIELD_DOUBLE
):
1875 OP(BYTECODE_OP_LOAD_FIELD_STRING
):
1879 dbg_printk("op load field string\n");
1880 str
= (const char *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1881 estack_ax(stack
, top
)->u
.s
.str
= str
;
1882 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1883 dbg_printk("Bytecode warning: loading a NULL string.\n");
1887 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1888 estack_ax(stack
, top
)->u
.s
.literal_type
=
1889 ESTACK_STRING_LITERAL_TYPE_NONE
;
1890 estack_ax(stack
, top
)->type
= REG_STRING
;
1891 estack_ax(stack
, top
)->u
.s
.user
= 0;
1892 next_pc
+= sizeof(struct load_op
);
1896 OP(BYTECODE_OP_LOAD_FIELD_SEQUENCE
):
1900 dbg_printk("op load field string sequence\n");
1901 ptr
= estack_ax(stack
, top
)->u
.ptr
.ptr
;
1902 estack_ax(stack
, top
)->u
.s
.seq_len
= *(unsigned long *) ptr
;
1903 estack_ax(stack
, top
)->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
1904 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1905 dbg_printk("Bytecode warning: loading a NULL sequence.\n");
1909 estack_ax(stack
, top
)->u
.s
.literal_type
=
1910 ESTACK_STRING_LITERAL_TYPE_NONE
;
1911 estack_ax(stack
, top
)->type
= REG_STRING
;
1912 estack_ax(stack
, top
)->u
.s
.user
= 0;
1913 next_pc
+= sizeof(struct load_op
);
1919 /* No need to prepare output if an error occurred. */
1921 return LTTNG_KERNEL_BYTECODE_INTERPRETER_ERROR
;
1923 /* Prepare output. */
1924 switch (kernel_bytecode
->type
) {
1925 case LTTNG_KERNEL_BYTECODE_TYPE_FILTER
:
1927 struct lttng_kernel_bytecode_filter_ctx
*filter_ctx
=
1928 (struct lttng_kernel_bytecode_filter_ctx
*) caller_ctx
;
1930 filter_ctx
->result
= LTTNG_KERNEL_BYTECODE_FILTER_ACCEPT
;
1932 filter_ctx
->result
= LTTNG_KERNEL_BYTECODE_FILTER_REJECT
;
1935 case LTTNG_KERNEL_BYTECODE_TYPE_CAPTURE
:
1936 ret
= lttng_bytecode_interpret_format_output(estack_ax(stack
, top
),
1937 (struct lttng_interpreter_output
*) caller_ctx
);
1944 return LTTNG_KERNEL_BYTECODE_INTERPRETER_ERROR
;
1946 return LTTNG_KERNEL_BYTECODE_INTERPRETER_OK
;
1948 LTTNG_STACK_FRAME_NON_STANDARD(lttng_bytecode_interpret
);
1951 * Return LTTNG_KERNEL_EVENT_FILTER_ACCEPT or LTTNG_KERNEL_EVENT_FILTER_REJECT.
1953 int lttng_kernel_interpret_event_filter(const struct lttng_kernel_event_common
*event
,
1954 const char *interpreter_stack_data
,
1955 struct lttng_kernel_probe_ctx
*probe_ctx
,
1956 void *event_filter_ctx
__attribute__((unused
)))
1958 struct lttng_kernel_bytecode_runtime
*filter_bc_runtime
;
1959 struct list_head
*filter_bytecode_runtime_head
= &event
->priv
->filter_bytecode_runtime_head
;
1960 struct lttng_kernel_bytecode_filter_ctx bytecode_filter_ctx
;
1961 bool filter_record
= false;
1963 list_for_each_entry_rcu(filter_bc_runtime
, filter_bytecode_runtime_head
, node
) {
1964 if (likely(filter_bc_runtime
->interpreter_func(filter_bc_runtime
,
1965 interpreter_stack_data
, probe_ctx
, &bytecode_filter_ctx
) == LTTNG_KERNEL_BYTECODE_INTERPRETER_OK
)) {
1966 if (unlikely(bytecode_filter_ctx
.result
== LTTNG_KERNEL_BYTECODE_FILTER_ACCEPT
)) {
1967 filter_record
= true;
1973 return LTTNG_KERNEL_EVENT_FILTER_ACCEPT
;
1975 return LTTNG_KERNEL_EVENT_FILTER_REJECT
;