2 * SPDX-License-Identifier: MIT
4 * Copyright (C) 2010-2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 * LTTng UST bytecode interpreter.
13 #include <lttng/urcu/pointer.h>
14 #include <lttng/ust-endian.h>
15 #include <lttng/ust-events.h>
16 #include "ust-events-internal.h"
18 #include "lttng-bytecode.h"
19 #include "string-utils.h"
24 * -2: unknown escape char.
29 int parse_char(const char **p
)
49 * Returns SIZE_MAX if the string is null-terminated, or the number of
53 size_t get_str_or_seq_len(const struct estack_entry
*entry
)
55 return entry
->u
.s
.seq_len
;
59 int stack_star_glob_match(struct estack
*stack
, int top
, const char *cmp_type
)
62 const char *candidate
;
66 /* Find out which side is the pattern vs. the candidate. */
67 if (estack_ax(stack
, top
)->u
.s
.literal_type
== ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
) {
68 pattern
= estack_ax(stack
, top
)->u
.s
.str
;
69 pattern_len
= get_str_or_seq_len(estack_ax(stack
, top
));
70 candidate
= estack_bx(stack
, top
)->u
.s
.str
;
71 candidate_len
= get_str_or_seq_len(estack_bx(stack
, top
));
73 pattern
= estack_bx(stack
, top
)->u
.s
.str
;
74 pattern_len
= get_str_or_seq_len(estack_bx(stack
, top
));
75 candidate
= estack_ax(stack
, top
)->u
.s
.str
;
76 candidate_len
= get_str_or_seq_len(estack_ax(stack
, top
));
79 /* Perform the match. Returns 0 when the result is true. */
80 return !strutils_star_glob_match(pattern
, pattern_len
, candidate
,
85 int stack_strcmp(struct estack
*stack
, int top
, const char *cmp_type
)
87 const char *p
= estack_bx(stack
, top
)->u
.s
.str
, *q
= estack_ax(stack
, top
)->u
.s
.str
;
94 if (unlikely(p
- estack_bx(stack
, top
)->u
.s
.str
>= estack_bx(stack
, top
)->u
.s
.seq_len
|| *p
== '\0')) {
95 if (q
- estack_ax(stack
, top
)->u
.s
.str
>= estack_ax(stack
, top
)->u
.s
.seq_len
|| *q
== '\0') {
98 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
99 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
100 ret
= parse_char(&q
);
107 if (unlikely(q
- estack_ax(stack
, top
)->u
.s
.str
>= estack_ax(stack
, top
)->u
.s
.seq_len
|| *q
== '\0')) {
108 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
109 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
110 ret
= parse_char(&p
);
116 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
117 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
118 ret
= parse_char(&p
);
121 } else if (ret
== -2) {
124 /* else compare both char */
126 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
127 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
128 ret
= parse_char(&q
);
131 } else if (ret
== -2) {
151 uint64_t lttng_bytecode_filter_interpret_false(void *filter_data
,
152 const char *filter_stack_data
)
154 return LTTNG_UST_BYTECODE_INTERPRETER_DISCARD
;
157 uint64_t lttng_bytecode_capture_interpret_false(void *capture_data
,
158 const char *capture_stack_data
,
159 struct lttng_interpreter_output
*output
)
161 return LTTNG_UST_BYTECODE_INTERPRETER_DISCARD
;
164 #ifdef INTERPRETER_USE_SWITCH
167 * Fallback for compilers that do not support taking address of labels.
171 start_pc = &bytecode->data[0]; \
172 for (pc = next_pc = start_pc; pc - start_pc < bytecode->len; \
174 dbg_printf("Executing op %s (%u)\n", \
175 lttng_bytecode_print_op((unsigned int) *(bytecode_opcode_t *) pc), \
176 (unsigned int) *(bytecode_opcode_t *) pc); \
177 switch (*(bytecode_opcode_t *) pc) {
179 #define OP(name) jump_target_##name: __attribute__((unused)); \
187 #define JUMP_TO(name) \
188 goto jump_target_##name
193 * Dispatch-table based interpreter.
197 start_pc = &bytecode->code[0]; \
198 pc = next_pc = start_pc; \
199 if (unlikely(pc - start_pc >= bytecode->len)) \
201 goto *dispatch[*(bytecode_opcode_t *) pc];
208 goto *dispatch[*(bytecode_opcode_t *) pc];
212 #define JUMP_TO(name) \
217 #define IS_INTEGER_REGISTER(reg_type) \
218 (reg_type == REG_U64 || reg_type == REG_S64)
220 static int context_get_index(struct lttng_ust_ctx
*ctx
,
221 struct load_ptr
*ptr
,
225 struct lttng_ust_ctx_field
*ctx_field
;
226 struct lttng_ust_event_field
*field
;
227 struct lttng_ust_ctx_value v
;
229 ctx_field
= ctx
->fields
[idx
];
230 field
= ctx_field
->event_field
;
231 ptr
->type
= LOAD_OBJECT
;
234 switch (field
->type
->type
) {
235 case lttng_ust_type_integer
:
236 ctx_field
->get_value(ctx_field
, &v
);
237 if (lttng_ust_get_type_integer(field
->type
)->signedness
) {
238 ptr
->object_type
= OBJECT_TYPE_S64
;
239 ptr
->u
.s64
= v
.u
.s64
;
240 ptr
->ptr
= &ptr
->u
.s64
;
242 ptr
->object_type
= OBJECT_TYPE_U64
;
243 ptr
->u
.u64
= v
.u
.s64
; /* Cast. */
244 ptr
->ptr
= &ptr
->u
.u64
;
247 case lttng_ust_type_enum
:
249 const struct lttng_ust_type_integer
*itype
;
251 itype
= lttng_ust_get_type_integer(lttng_ust_get_type_enum(field
->type
)->container_type
);
252 ctx_field
->get_value(ctx_field
, &v
);
253 if (itype
->signedness
) {
254 ptr
->object_type
= OBJECT_TYPE_SIGNED_ENUM
;
255 ptr
->u
.s64
= v
.u
.s64
;
256 ptr
->ptr
= &ptr
->u
.s64
;
258 ptr
->object_type
= OBJECT_TYPE_UNSIGNED_ENUM
;
259 ptr
->u
.u64
= v
.u
.s64
; /* Cast. */
260 ptr
->ptr
= &ptr
->u
.u64
;
264 case lttng_ust_type_array
:
265 if (lttng_ust_get_type_array(field
->type
)->elem_type
->type
!= lttng_ust_type_integer
) {
266 ERR("Array nesting only supports integer types.");
269 if (lttng_ust_get_type_array(field
->type
)->encoding
== lttng_ust_string_encoding_none
) {
270 ERR("Only string arrays are supported for contexts.");
273 ptr
->object_type
= OBJECT_TYPE_STRING
;
274 ctx_field
->get_value(ctx_field
, &v
);
277 case lttng_ust_type_sequence
:
278 if (lttng_ust_get_type_sequence(field
->type
)->elem_type
->type
!= lttng_ust_type_integer
) {
279 ERR("Sequence nesting only supports integer types.");
282 if (lttng_ust_get_type_sequence(field
->type
)->encoding
== lttng_ust_string_encoding_none
) {
283 ERR("Only string sequences are supported for contexts.");
286 ptr
->object_type
= OBJECT_TYPE_STRING
;
287 ctx_field
->get_value(ctx_field
, &v
);
290 case lttng_ust_type_string
:
291 ptr
->object_type
= OBJECT_TYPE_STRING
;
292 ctx_field
->get_value(ctx_field
, &v
);
295 case lttng_ust_type_float
:
296 ptr
->object_type
= OBJECT_TYPE_DOUBLE
;
297 ctx_field
->get_value(ctx_field
, &v
);
299 ptr
->ptr
= &ptr
->u
.d
;
301 case lttng_ust_type_dynamic
:
302 ctx_field
->get_value(ctx_field
, &v
);
304 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
306 case LTTNG_UST_DYNAMIC_TYPE_U8
:
307 case LTTNG_UST_DYNAMIC_TYPE_U16
:
308 case LTTNG_UST_DYNAMIC_TYPE_U32
:
309 case LTTNG_UST_DYNAMIC_TYPE_U64
:
310 ptr
->object_type
= OBJECT_TYPE_U64
;
311 ptr
->u
.u64
= v
.u
.u64
;
312 ptr
->ptr
= &ptr
->u
.u64
;
313 dbg_printf("context get index dynamic u64 %" PRIi64
"\n", ptr
->u
.u64
);
315 case LTTNG_UST_DYNAMIC_TYPE_S8
:
316 case LTTNG_UST_DYNAMIC_TYPE_S16
:
317 case LTTNG_UST_DYNAMIC_TYPE_S32
:
318 case LTTNG_UST_DYNAMIC_TYPE_S64
:
319 ptr
->object_type
= OBJECT_TYPE_S64
;
320 ptr
->u
.s64
= v
.u
.s64
;
321 ptr
->ptr
= &ptr
->u
.s64
;
322 dbg_printf("context get index dynamic s64 %" PRIi64
"\n", ptr
->u
.s64
);
324 case LTTNG_UST_DYNAMIC_TYPE_FLOAT
:
325 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
326 ptr
->object_type
= OBJECT_TYPE_DOUBLE
;
328 ptr
->ptr
= &ptr
->u
.d
;
329 dbg_printf("context get index dynamic double %g\n", ptr
->u
.d
);
331 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
332 ptr
->object_type
= OBJECT_TYPE_STRING
;
334 dbg_printf("context get index dynamic string %s\n", (const char *) ptr
->ptr
);
337 dbg_printf("Interpreter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
342 ERR("Unknown type: %d", (int) field
->type
->type
);
348 static int dynamic_get_index(struct lttng_ust_ctx
*ctx
,
349 struct bytecode_runtime
*runtime
,
350 uint64_t index
, struct estack_entry
*stack_top
)
353 const struct bytecode_get_index_data
*gid
;
355 gid
= (const struct bytecode_get_index_data
*) &runtime
->data
[index
];
356 switch (stack_top
->u
.ptr
.type
) {
358 switch (stack_top
->u
.ptr
.object_type
) {
359 case OBJECT_TYPE_ARRAY
:
363 assert(gid
->offset
< gid
->array_len
);
364 /* Skip count (unsigned long) */
365 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
366 ptr
= ptr
+ gid
->offset
;
367 stack_top
->u
.ptr
.ptr
= ptr
;
368 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
369 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
370 assert(stack_top
->u
.ptr
.field
->type
->type
== lttng_ust_type_array
);
371 stack_top
->u
.ptr
.field
= NULL
;
374 case OBJECT_TYPE_SEQUENCE
:
379 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
380 ptr_seq_len
= *(unsigned long *) stack_top
->u
.ptr
.ptr
;
381 if (gid
->offset
>= gid
->elem
.len
* ptr_seq_len
) {
385 ptr
= ptr
+ gid
->offset
;
386 stack_top
->u
.ptr
.ptr
= ptr
;
387 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
388 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
389 assert(stack_top
->u
.ptr
.field
->type
->type
== lttng_ust_type_sequence
);
390 stack_top
->u
.ptr
.field
= NULL
;
393 case OBJECT_TYPE_STRUCT
:
394 ERR("Nested structures are not supported yet.");
397 case OBJECT_TYPE_VARIANT
:
399 ERR("Unexpected get index type %d",
400 (int) stack_top
->u
.ptr
.object_type
);
405 case LOAD_ROOT_CONTEXT
:
406 case LOAD_ROOT_APP_CONTEXT
: /* Fall-through */
408 ret
= context_get_index(ctx
,
416 case LOAD_ROOT_PAYLOAD
:
417 stack_top
->u
.ptr
.ptr
+= gid
->offset
;
418 if (gid
->elem
.type
== OBJECT_TYPE_STRING
)
419 stack_top
->u
.ptr
.ptr
= *(const char * const *) stack_top
->u
.ptr
.ptr
;
420 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
421 stack_top
->u
.ptr
.type
= LOAD_OBJECT
;
422 stack_top
->u
.ptr
.field
= gid
->field
;
423 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
427 stack_top
->type
= REG_PTR
;
435 static int dynamic_load_field(struct estack_entry
*stack_top
)
439 switch (stack_top
->u
.ptr
.type
) {
442 case LOAD_ROOT_CONTEXT
:
443 case LOAD_ROOT_APP_CONTEXT
:
444 case LOAD_ROOT_PAYLOAD
:
446 dbg_printf("Interpreter warning: cannot load root, missing field name.\n");
450 switch (stack_top
->u
.ptr
.object_type
) {
452 dbg_printf("op load field s8\n");
453 stack_top
->u
.v
= *(int8_t *) stack_top
->u
.ptr
.ptr
;
454 stack_top
->type
= REG_S64
;
456 case OBJECT_TYPE_S16
:
460 dbg_printf("op load field s16\n");
461 tmp
= *(int16_t *) stack_top
->u
.ptr
.ptr
;
462 if (stack_top
->u
.ptr
.rev_bo
)
464 stack_top
->u
.v
= tmp
;
465 stack_top
->type
= REG_S64
;
468 case OBJECT_TYPE_S32
:
472 dbg_printf("op load field s32\n");
473 tmp
= *(int32_t *) stack_top
->u
.ptr
.ptr
;
474 if (stack_top
->u
.ptr
.rev_bo
)
476 stack_top
->u
.v
= tmp
;
477 stack_top
->type
= REG_S64
;
480 case OBJECT_TYPE_S64
:
484 dbg_printf("op load field s64\n");
485 tmp
= *(int64_t *) stack_top
->u
.ptr
.ptr
;
486 if (stack_top
->u
.ptr
.rev_bo
)
488 stack_top
->u
.v
= tmp
;
489 stack_top
->type
= REG_S64
;
492 case OBJECT_TYPE_SIGNED_ENUM
:
496 dbg_printf("op load field signed enumeration\n");
497 tmp
= *(int64_t *) stack_top
->u
.ptr
.ptr
;
498 if (stack_top
->u
.ptr
.rev_bo
)
500 stack_top
->u
.v
= tmp
;
501 stack_top
->type
= REG_S64
;
505 dbg_printf("op load field u8\n");
506 stack_top
->u
.v
= *(uint8_t *) stack_top
->u
.ptr
.ptr
;
507 stack_top
->type
= REG_U64
;
509 case OBJECT_TYPE_U16
:
513 dbg_printf("op load field u16\n");
514 tmp
= *(uint16_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_U64
;
521 case OBJECT_TYPE_U32
:
525 dbg_printf("op load field u32\n");
526 tmp
= *(uint32_t *) stack_top
->u
.ptr
.ptr
;
527 if (stack_top
->u
.ptr
.rev_bo
)
529 stack_top
->u
.v
= tmp
;
530 stack_top
->type
= REG_U64
;
533 case OBJECT_TYPE_U64
:
537 dbg_printf("op load field u64\n");
538 tmp
= *(uint64_t *) stack_top
->u
.ptr
.ptr
;
539 if (stack_top
->u
.ptr
.rev_bo
)
541 stack_top
->u
.v
= tmp
;
542 stack_top
->type
= REG_U64
;
545 case OBJECT_TYPE_UNSIGNED_ENUM
:
549 dbg_printf("op load field unsigned enumeration\n");
550 tmp
= *(uint64_t *) stack_top
->u
.ptr
.ptr
;
551 if (stack_top
->u
.ptr
.rev_bo
)
553 stack_top
->u
.v
= tmp
;
554 stack_top
->type
= REG_U64
;
557 case OBJECT_TYPE_DOUBLE
:
558 memcpy(&stack_top
->u
.d
,
559 stack_top
->u
.ptr
.ptr
,
560 sizeof(struct literal_double
));
561 stack_top
->type
= REG_DOUBLE
;
563 case OBJECT_TYPE_STRING
:
567 dbg_printf("op load field string\n");
568 str
= (const char *) stack_top
->u
.ptr
.ptr
;
569 stack_top
->u
.s
.str
= str
;
570 if (unlikely(!stack_top
->u
.s
.str
)) {
571 dbg_printf("Interpreter warning: loading a NULL string.\n");
575 stack_top
->u
.s
.seq_len
= SIZE_MAX
;
576 stack_top
->u
.s
.literal_type
=
577 ESTACK_STRING_LITERAL_TYPE_NONE
;
578 stack_top
->type
= REG_STRING
;
581 case OBJECT_TYPE_STRING_SEQUENCE
:
585 dbg_printf("op load field string sequence\n");
586 ptr
= stack_top
->u
.ptr
.ptr
;
587 stack_top
->u
.s
.seq_len
= *(unsigned long *) ptr
;
588 stack_top
->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
589 stack_top
->type
= REG_STRING
;
590 if (unlikely(!stack_top
->u
.s
.str
)) {
591 dbg_printf("Interpreter warning: loading a NULL sequence.\n");
595 stack_top
->u
.s
.literal_type
=
596 ESTACK_STRING_LITERAL_TYPE_NONE
;
599 case OBJECT_TYPE_DYNAMIC
:
601 * Dynamic types in context are looked up
602 * by context get index.
606 case OBJECT_TYPE_SEQUENCE
:
607 case OBJECT_TYPE_ARRAY
:
608 case OBJECT_TYPE_STRUCT
:
609 case OBJECT_TYPE_VARIANT
:
610 ERR("Sequences, arrays, struct and variant cannot be loaded (nested types).");
621 int lttng_bytecode_interpret_format_output(struct estack_entry
*ax
,
622 struct lttng_interpreter_output
*output
)
629 output
->type
= LTTNG_INTERPRETER_TYPE_S64
;
630 output
->u
.s
= ax
->u
.v
;
633 output
->type
= LTTNG_INTERPRETER_TYPE_U64
;
634 output
->u
.u
= (uint64_t) ax
->u
.v
;
637 output
->type
= LTTNG_INTERPRETER_TYPE_DOUBLE
;
638 output
->u
.d
= ax
->u
.d
;
641 output
->type
= LTTNG_INTERPRETER_TYPE_STRING
;
642 output
->u
.str
.str
= ax
->u
.s
.str
;
643 output
->u
.str
.len
= ax
->u
.s
.seq_len
;
646 switch (ax
->u
.ptr
.object_type
) {
648 case OBJECT_TYPE_S16
:
649 case OBJECT_TYPE_S32
:
650 case OBJECT_TYPE_S64
:
652 case OBJECT_TYPE_U16
:
653 case OBJECT_TYPE_U32
:
654 case OBJECT_TYPE_U64
:
655 case OBJECT_TYPE_DOUBLE
:
656 case OBJECT_TYPE_STRING
:
657 case OBJECT_TYPE_STRING_SEQUENCE
:
658 ret
= dynamic_load_field(ax
);
661 /* Retry after loading ptr into stack top. */
663 case OBJECT_TYPE_SEQUENCE
:
664 output
->type
= LTTNG_INTERPRETER_TYPE_SEQUENCE
;
665 output
->u
.sequence
.ptr
= *(const char **) (ax
->u
.ptr
.ptr
+ sizeof(unsigned long));
666 output
->u
.sequence
.nr_elem
= *(unsigned long *) ax
->u
.ptr
.ptr
;
667 output
->u
.sequence
.nested_type
= lttng_ust_get_type_sequence(ax
->u
.ptr
.field
->type
)->elem_type
;
669 case OBJECT_TYPE_ARRAY
:
670 /* Skip count (unsigned long) */
671 output
->type
= LTTNG_INTERPRETER_TYPE_SEQUENCE
;
672 output
->u
.sequence
.ptr
= *(const char **) (ax
->u
.ptr
.ptr
+ sizeof(unsigned long));
673 output
->u
.sequence
.nr_elem
= lttng_ust_get_type_array(ax
->u
.ptr
.field
->type
)->length
;
674 output
->u
.sequence
.nested_type
= lttng_ust_get_type_array(ax
->u
.ptr
.field
->type
)->elem_type
;
676 case OBJECT_TYPE_SIGNED_ENUM
:
677 ret
= dynamic_load_field(ax
);
680 output
->type
= LTTNG_INTERPRETER_TYPE_SIGNED_ENUM
;
681 output
->u
.s
= ax
->u
.v
;
683 case OBJECT_TYPE_UNSIGNED_ENUM
:
684 ret
= dynamic_load_field(ax
);
687 output
->type
= LTTNG_INTERPRETER_TYPE_UNSIGNED_ENUM
;
688 output
->u
.u
= ax
->u
.v
;
690 case OBJECT_TYPE_STRUCT
:
691 case OBJECT_TYPE_VARIANT
:
697 case REG_STAR_GLOB_STRING
:
703 return LTTNG_UST_BYTECODE_INTERPRETER_RECORD_FLAG
;
707 * For `output` equal to NULL:
708 * Return 0 (discard), or raise the 0x1 flag (log event).
709 * Currently, other flags are kept for future extensions and have no
711 * For `output` not equal to NULL:
712 * Return 0 on success, negative error value on error.
715 uint64_t bytecode_interpret(void *interpreter_data
,
716 const char *interpreter_stack_data
,
717 struct lttng_interpreter_output
*output
)
719 struct bytecode_runtime
*bytecode
= interpreter_data
;
720 struct lttng_ust_ctx
*ctx
= lttng_ust_rcu_dereference(*bytecode
->p
.priv
->pctx
);
721 void *pc
, *next_pc
, *start_pc
;
724 struct estack _stack
;
725 struct estack
*stack
= &_stack
;
726 register int64_t ax
= 0, bx
= 0;
727 register enum entry_type ax_t
= REG_UNKNOWN
, bx_t
= REG_UNKNOWN
;
728 register int top
= INTERPRETER_STACK_EMPTY
;
729 #ifndef INTERPRETER_USE_SWITCH
730 static void *dispatch
[NR_BYTECODE_OPS
] = {
731 [ BYTECODE_OP_UNKNOWN
] = &&LABEL_BYTECODE_OP_UNKNOWN
,
733 [ BYTECODE_OP_RETURN
] = &&LABEL_BYTECODE_OP_RETURN
,
736 [ BYTECODE_OP_MUL
] = &&LABEL_BYTECODE_OP_MUL
,
737 [ BYTECODE_OP_DIV
] = &&LABEL_BYTECODE_OP_DIV
,
738 [ BYTECODE_OP_MOD
] = &&LABEL_BYTECODE_OP_MOD
,
739 [ BYTECODE_OP_PLUS
] = &&LABEL_BYTECODE_OP_PLUS
,
740 [ BYTECODE_OP_MINUS
] = &&LABEL_BYTECODE_OP_MINUS
,
741 [ BYTECODE_OP_BIT_RSHIFT
] = &&LABEL_BYTECODE_OP_BIT_RSHIFT
,
742 [ BYTECODE_OP_BIT_LSHIFT
] = &&LABEL_BYTECODE_OP_BIT_LSHIFT
,
743 [ BYTECODE_OP_BIT_AND
] = &&LABEL_BYTECODE_OP_BIT_AND
,
744 [ BYTECODE_OP_BIT_OR
] = &&LABEL_BYTECODE_OP_BIT_OR
,
745 [ BYTECODE_OP_BIT_XOR
] = &&LABEL_BYTECODE_OP_BIT_XOR
,
747 /* binary comparators */
748 [ BYTECODE_OP_EQ
] = &&LABEL_BYTECODE_OP_EQ
,
749 [ BYTECODE_OP_NE
] = &&LABEL_BYTECODE_OP_NE
,
750 [ BYTECODE_OP_GT
] = &&LABEL_BYTECODE_OP_GT
,
751 [ BYTECODE_OP_LT
] = &&LABEL_BYTECODE_OP_LT
,
752 [ BYTECODE_OP_GE
] = &&LABEL_BYTECODE_OP_GE
,
753 [ BYTECODE_OP_LE
] = &&LABEL_BYTECODE_OP_LE
,
755 /* string binary comparator */
756 [ BYTECODE_OP_EQ_STRING
] = &&LABEL_BYTECODE_OP_EQ_STRING
,
757 [ BYTECODE_OP_NE_STRING
] = &&LABEL_BYTECODE_OP_NE_STRING
,
758 [ BYTECODE_OP_GT_STRING
] = &&LABEL_BYTECODE_OP_GT_STRING
,
759 [ BYTECODE_OP_LT_STRING
] = &&LABEL_BYTECODE_OP_LT_STRING
,
760 [ BYTECODE_OP_GE_STRING
] = &&LABEL_BYTECODE_OP_GE_STRING
,
761 [ BYTECODE_OP_LE_STRING
] = &&LABEL_BYTECODE_OP_LE_STRING
,
763 /* globbing pattern binary comparator */
764 [ BYTECODE_OP_EQ_STAR_GLOB_STRING
] = &&LABEL_BYTECODE_OP_EQ_STAR_GLOB_STRING
,
765 [ BYTECODE_OP_NE_STAR_GLOB_STRING
] = &&LABEL_BYTECODE_OP_NE_STAR_GLOB_STRING
,
767 /* s64 binary comparator */
768 [ BYTECODE_OP_EQ_S64
] = &&LABEL_BYTECODE_OP_EQ_S64
,
769 [ BYTECODE_OP_NE_S64
] = &&LABEL_BYTECODE_OP_NE_S64
,
770 [ BYTECODE_OP_GT_S64
] = &&LABEL_BYTECODE_OP_GT_S64
,
771 [ BYTECODE_OP_LT_S64
] = &&LABEL_BYTECODE_OP_LT_S64
,
772 [ BYTECODE_OP_GE_S64
] = &&LABEL_BYTECODE_OP_GE_S64
,
773 [ BYTECODE_OP_LE_S64
] = &&LABEL_BYTECODE_OP_LE_S64
,
775 /* double binary comparator */
776 [ BYTECODE_OP_EQ_DOUBLE
] = &&LABEL_BYTECODE_OP_EQ_DOUBLE
,
777 [ BYTECODE_OP_NE_DOUBLE
] = &&LABEL_BYTECODE_OP_NE_DOUBLE
,
778 [ BYTECODE_OP_GT_DOUBLE
] = &&LABEL_BYTECODE_OP_GT_DOUBLE
,
779 [ BYTECODE_OP_LT_DOUBLE
] = &&LABEL_BYTECODE_OP_LT_DOUBLE
,
780 [ BYTECODE_OP_GE_DOUBLE
] = &&LABEL_BYTECODE_OP_GE_DOUBLE
,
781 [ BYTECODE_OP_LE_DOUBLE
] = &&LABEL_BYTECODE_OP_LE_DOUBLE
,
783 /* Mixed S64-double binary comparators */
784 [ BYTECODE_OP_EQ_DOUBLE_S64
] = &&LABEL_BYTECODE_OP_EQ_DOUBLE_S64
,
785 [ BYTECODE_OP_NE_DOUBLE_S64
] = &&LABEL_BYTECODE_OP_NE_DOUBLE_S64
,
786 [ BYTECODE_OP_GT_DOUBLE_S64
] = &&LABEL_BYTECODE_OP_GT_DOUBLE_S64
,
787 [ BYTECODE_OP_LT_DOUBLE_S64
] = &&LABEL_BYTECODE_OP_LT_DOUBLE_S64
,
788 [ BYTECODE_OP_GE_DOUBLE_S64
] = &&LABEL_BYTECODE_OP_GE_DOUBLE_S64
,
789 [ BYTECODE_OP_LE_DOUBLE_S64
] = &&LABEL_BYTECODE_OP_LE_DOUBLE_S64
,
791 [ BYTECODE_OP_EQ_S64_DOUBLE
] = &&LABEL_BYTECODE_OP_EQ_S64_DOUBLE
,
792 [ BYTECODE_OP_NE_S64_DOUBLE
] = &&LABEL_BYTECODE_OP_NE_S64_DOUBLE
,
793 [ BYTECODE_OP_GT_S64_DOUBLE
] = &&LABEL_BYTECODE_OP_GT_S64_DOUBLE
,
794 [ BYTECODE_OP_LT_S64_DOUBLE
] = &&LABEL_BYTECODE_OP_LT_S64_DOUBLE
,
795 [ BYTECODE_OP_GE_S64_DOUBLE
] = &&LABEL_BYTECODE_OP_GE_S64_DOUBLE
,
796 [ BYTECODE_OP_LE_S64_DOUBLE
] = &&LABEL_BYTECODE_OP_LE_S64_DOUBLE
,
799 [ BYTECODE_OP_UNARY_PLUS
] = &&LABEL_BYTECODE_OP_UNARY_PLUS
,
800 [ BYTECODE_OP_UNARY_MINUS
] = &&LABEL_BYTECODE_OP_UNARY_MINUS
,
801 [ BYTECODE_OP_UNARY_NOT
] = &&LABEL_BYTECODE_OP_UNARY_NOT
,
802 [ BYTECODE_OP_UNARY_PLUS_S64
] = &&LABEL_BYTECODE_OP_UNARY_PLUS_S64
,
803 [ BYTECODE_OP_UNARY_MINUS_S64
] = &&LABEL_BYTECODE_OP_UNARY_MINUS_S64
,
804 [ BYTECODE_OP_UNARY_NOT_S64
] = &&LABEL_BYTECODE_OP_UNARY_NOT_S64
,
805 [ BYTECODE_OP_UNARY_PLUS_DOUBLE
] = &&LABEL_BYTECODE_OP_UNARY_PLUS_DOUBLE
,
806 [ BYTECODE_OP_UNARY_MINUS_DOUBLE
] = &&LABEL_BYTECODE_OP_UNARY_MINUS_DOUBLE
,
807 [ BYTECODE_OP_UNARY_NOT_DOUBLE
] = &&LABEL_BYTECODE_OP_UNARY_NOT_DOUBLE
,
810 [ BYTECODE_OP_AND
] = &&LABEL_BYTECODE_OP_AND
,
811 [ BYTECODE_OP_OR
] = &&LABEL_BYTECODE_OP_OR
,
814 [ BYTECODE_OP_LOAD_FIELD_REF
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_REF
,
815 [ BYTECODE_OP_LOAD_FIELD_REF_STRING
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_REF_STRING
,
816 [ BYTECODE_OP_LOAD_FIELD_REF_SEQUENCE
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_REF_SEQUENCE
,
817 [ BYTECODE_OP_LOAD_FIELD_REF_S64
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_REF_S64
,
818 [ BYTECODE_OP_LOAD_FIELD_REF_DOUBLE
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_REF_DOUBLE
,
820 /* load from immediate operand */
821 [ BYTECODE_OP_LOAD_STRING
] = &&LABEL_BYTECODE_OP_LOAD_STRING
,
822 [ BYTECODE_OP_LOAD_STAR_GLOB_STRING
] = &&LABEL_BYTECODE_OP_LOAD_STAR_GLOB_STRING
,
823 [ BYTECODE_OP_LOAD_S64
] = &&LABEL_BYTECODE_OP_LOAD_S64
,
824 [ BYTECODE_OP_LOAD_DOUBLE
] = &&LABEL_BYTECODE_OP_LOAD_DOUBLE
,
827 [ BYTECODE_OP_CAST_TO_S64
] = &&LABEL_BYTECODE_OP_CAST_TO_S64
,
828 [ BYTECODE_OP_CAST_DOUBLE_TO_S64
] = &&LABEL_BYTECODE_OP_CAST_DOUBLE_TO_S64
,
829 [ BYTECODE_OP_CAST_NOP
] = &&LABEL_BYTECODE_OP_CAST_NOP
,
831 /* get context ref */
832 [ BYTECODE_OP_GET_CONTEXT_REF
] = &&LABEL_BYTECODE_OP_GET_CONTEXT_REF
,
833 [ BYTECODE_OP_GET_CONTEXT_REF_STRING
] = &&LABEL_BYTECODE_OP_GET_CONTEXT_REF_STRING
,
834 [ BYTECODE_OP_GET_CONTEXT_REF_S64
] = &&LABEL_BYTECODE_OP_GET_CONTEXT_REF_S64
,
835 [ BYTECODE_OP_GET_CONTEXT_REF_DOUBLE
] = &&LABEL_BYTECODE_OP_GET_CONTEXT_REF_DOUBLE
,
837 /* Instructions for recursive traversal through composed types. */
838 [ BYTECODE_OP_GET_CONTEXT_ROOT
] = &&LABEL_BYTECODE_OP_GET_CONTEXT_ROOT
,
839 [ BYTECODE_OP_GET_APP_CONTEXT_ROOT
] = &&LABEL_BYTECODE_OP_GET_APP_CONTEXT_ROOT
,
840 [ BYTECODE_OP_GET_PAYLOAD_ROOT
] = &&LABEL_BYTECODE_OP_GET_PAYLOAD_ROOT
,
842 [ BYTECODE_OP_GET_SYMBOL
] = &&LABEL_BYTECODE_OP_GET_SYMBOL
,
843 [ BYTECODE_OP_GET_SYMBOL_FIELD
] = &&LABEL_BYTECODE_OP_GET_SYMBOL_FIELD
,
844 [ BYTECODE_OP_GET_INDEX_U16
] = &&LABEL_BYTECODE_OP_GET_INDEX_U16
,
845 [ BYTECODE_OP_GET_INDEX_U64
] = &&LABEL_BYTECODE_OP_GET_INDEX_U64
,
847 [ BYTECODE_OP_LOAD_FIELD
] = &&LABEL_BYTECODE_OP_LOAD_FIELD
,
848 [ BYTECODE_OP_LOAD_FIELD_S8
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_S8
,
849 [ BYTECODE_OP_LOAD_FIELD_S16
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_S16
,
850 [ BYTECODE_OP_LOAD_FIELD_S32
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_S32
,
851 [ BYTECODE_OP_LOAD_FIELD_S64
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_S64
,
852 [ BYTECODE_OP_LOAD_FIELD_U8
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_U8
,
853 [ BYTECODE_OP_LOAD_FIELD_U16
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_U16
,
854 [ BYTECODE_OP_LOAD_FIELD_U32
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_U32
,
855 [ BYTECODE_OP_LOAD_FIELD_U64
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_U64
,
856 [ BYTECODE_OP_LOAD_FIELD_STRING
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_STRING
,
857 [ BYTECODE_OP_LOAD_FIELD_SEQUENCE
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_SEQUENCE
,
858 [ BYTECODE_OP_LOAD_FIELD_DOUBLE
] = &&LABEL_BYTECODE_OP_LOAD_FIELD_DOUBLE
,
860 [ BYTECODE_OP_UNARY_BIT_NOT
] = &&LABEL_BYTECODE_OP_UNARY_BIT_NOT
,
862 [ BYTECODE_OP_RETURN_S64
] = &&LABEL_BYTECODE_OP_RETURN_S64
,
864 #endif /* #ifndef INTERPRETER_USE_SWITCH */
868 OP(BYTECODE_OP_UNKNOWN
):
869 OP(BYTECODE_OP_LOAD_FIELD_REF
):
870 #ifdef INTERPRETER_USE_SWITCH
872 #endif /* INTERPRETER_USE_SWITCH */
873 ERR("unknown bytecode op %u",
874 (unsigned int) *(bytecode_opcode_t
*) pc
);
878 OP(BYTECODE_OP_RETURN
):
879 /* LTTNG_UST_BYTECODE_INTERPRETER_DISCARD or LTTNG_UST_BYTECODE_INTERPRETER_RECORD_FLAG */
880 /* Handle dynamic typing. */
881 switch (estack_ax_t
) {
884 retval
= !!estack_ax_v
;
895 case REG_STAR_GLOB_STRING
:
904 OP(BYTECODE_OP_RETURN_S64
):
905 /* LTTNG_UST_BYTECODE_INTERPRETER_DISCARD or LTTNG_UST_BYTECODE_INTERPRETER_RECORD_FLAG */
906 retval
= !!estack_ax_v
;
914 OP(BYTECODE_OP_PLUS
):
915 OP(BYTECODE_OP_MINUS
):
916 ERR("unsupported bytecode op %u",
917 (unsigned int) *(bytecode_opcode_t
*) pc
);
923 /* Dynamic typing. */
924 switch (estack_ax_t
) {
925 case REG_S64
: /* Fall-through */
927 switch (estack_bx_t
) {
928 case REG_S64
: /* Fall-through */
930 JUMP_TO(BYTECODE_OP_EQ_S64
);
932 JUMP_TO(BYTECODE_OP_EQ_DOUBLE_S64
);
933 case REG_STRING
: /* Fall-through */
934 case REG_STAR_GLOB_STRING
:
938 ERR("Unknown interpreter register type (%d)",
945 switch (estack_bx_t
) {
946 case REG_S64
: /* Fall-through */
948 JUMP_TO(BYTECODE_OP_EQ_S64_DOUBLE
);
950 JUMP_TO(BYTECODE_OP_EQ_DOUBLE
);
951 case REG_STRING
: /* Fall-through */
952 case REG_STAR_GLOB_STRING
:
956 ERR("Unknown interpreter register type (%d)",
963 switch (estack_bx_t
) {
964 case REG_S64
: /* Fall-through */
965 case REG_U64
: /* Fall-through */
970 JUMP_TO(BYTECODE_OP_EQ_STRING
);
971 case REG_STAR_GLOB_STRING
:
972 JUMP_TO(BYTECODE_OP_EQ_STAR_GLOB_STRING
);
974 ERR("Unknown interpreter register type (%d)",
980 case REG_STAR_GLOB_STRING
:
981 switch (estack_bx_t
) {
982 case REG_S64
: /* Fall-through */
983 case REG_U64
: /* Fall-through */
988 JUMP_TO(BYTECODE_OP_EQ_STAR_GLOB_STRING
);
989 case REG_STAR_GLOB_STRING
:
993 ERR("Unknown interpreter register type (%d)",
1000 ERR("Unknown interpreter register type (%d)",
1008 /* Dynamic typing. */
1009 switch (estack_ax_t
) {
1010 case REG_S64
: /* Fall-through */
1012 switch (estack_bx_t
) {
1013 case REG_S64
: /* Fall-through */
1015 JUMP_TO(BYTECODE_OP_NE_S64
);
1017 JUMP_TO(BYTECODE_OP_NE_DOUBLE_S64
);
1018 case REG_STRING
: /* Fall-through */
1019 case REG_STAR_GLOB_STRING
:
1023 ERR("Unknown interpreter register type (%d)",
1030 switch (estack_bx_t
) {
1031 case REG_S64
: /* Fall-through */
1033 JUMP_TO(BYTECODE_OP_NE_S64_DOUBLE
);
1035 JUMP_TO(BYTECODE_OP_NE_DOUBLE
);
1036 case REG_STRING
: /* Fall-through */
1037 case REG_STAR_GLOB_STRING
:
1041 ERR("Unknown interpreter register type (%d)",
1048 switch (estack_bx_t
) {
1049 case REG_S64
: /* Fall-through */
1055 JUMP_TO(BYTECODE_OP_NE_STRING
);
1056 case REG_STAR_GLOB_STRING
:
1057 JUMP_TO(BYTECODE_OP_NE_STAR_GLOB_STRING
);
1059 ERR("Unknown interpreter register type (%d)",
1065 case REG_STAR_GLOB_STRING
:
1066 switch (estack_bx_t
) {
1067 case REG_S64
: /* Fall-through */
1073 JUMP_TO(BYTECODE_OP_NE_STAR_GLOB_STRING
);
1074 case REG_STAR_GLOB_STRING
:
1078 ERR("Unknown interpreter register type (%d)",
1085 ERR("Unknown interpreter register type (%d)",
1093 /* Dynamic typing. */
1094 switch (estack_ax_t
) {
1095 case REG_S64
: /* Fall-through */
1097 switch (estack_bx_t
) {
1098 case REG_S64
: /* Fall-through */
1100 JUMP_TO(BYTECODE_OP_GT_S64
);
1102 JUMP_TO(BYTECODE_OP_GT_DOUBLE_S64
);
1103 case REG_STRING
: /* Fall-through */
1104 case REG_STAR_GLOB_STRING
:
1108 ERR("Unknown interpreter register type (%d)",
1115 switch (estack_bx_t
) {
1116 case REG_S64
: /* Fall-through */
1118 JUMP_TO(BYTECODE_OP_GT_S64_DOUBLE
);
1120 JUMP_TO(BYTECODE_OP_GT_DOUBLE
);
1121 case REG_STRING
: /* Fall-through */
1122 case REG_STAR_GLOB_STRING
:
1126 ERR("Unknown interpreter register type (%d)",
1133 switch (estack_bx_t
) {
1134 case REG_S64
: /* Fall-through */
1135 case REG_U64
: /* Fall-through */
1136 case REG_DOUBLE
: /* Fall-through */
1137 case REG_STAR_GLOB_STRING
:
1141 JUMP_TO(BYTECODE_OP_GT_STRING
);
1143 ERR("Unknown interpreter register type (%d)",
1150 ERR("Unknown interpreter register type (%d)",
1158 /* Dynamic typing. */
1159 switch (estack_ax_t
) {
1160 case REG_S64
: /* Fall-through */
1162 switch (estack_bx_t
) {
1163 case REG_S64
: /* Fall-through */
1165 JUMP_TO(BYTECODE_OP_LT_S64
);
1167 JUMP_TO(BYTECODE_OP_LT_DOUBLE_S64
);
1168 case REG_STRING
: /* Fall-through */
1169 case REG_STAR_GLOB_STRING
:
1173 ERR("Unknown interpreter register type (%d)",
1180 switch (estack_bx_t
) {
1181 case REG_S64
: /* Fall-through */
1183 JUMP_TO(BYTECODE_OP_LT_S64_DOUBLE
);
1185 JUMP_TO(BYTECODE_OP_LT_DOUBLE
);
1186 case REG_STRING
: /* Fall-through */
1187 case REG_STAR_GLOB_STRING
:
1191 ERR("Unknown interpreter register type (%d)",
1198 switch (estack_bx_t
) {
1199 case REG_S64
: /* Fall-through */
1200 case REG_U64
: /* Fall-through */
1201 case REG_DOUBLE
: /* Fall-through */
1202 case REG_STAR_GLOB_STRING
:
1206 JUMP_TO(BYTECODE_OP_LT_STRING
);
1208 ERR("Unknown interpreter register type (%d)",
1215 ERR("Unknown interpreter register type (%d)",
1223 /* Dynamic typing. */
1224 switch (estack_ax_t
) {
1225 case REG_S64
: /* Fall-through */
1227 switch (estack_bx_t
) {
1228 case REG_S64
: /* Fall-through */
1230 JUMP_TO(BYTECODE_OP_GE_S64
);
1232 JUMP_TO(BYTECODE_OP_GE_DOUBLE_S64
);
1233 case REG_STRING
: /* Fall-through */
1234 case REG_STAR_GLOB_STRING
:
1238 ERR("Unknown interpreter register type (%d)",
1245 switch (estack_bx_t
) {
1246 case REG_S64
: /* Fall-through */
1248 JUMP_TO(BYTECODE_OP_GE_S64_DOUBLE
);
1250 JUMP_TO(BYTECODE_OP_GE_DOUBLE
);
1251 case REG_STRING
: /* Fall-through */
1252 case REG_STAR_GLOB_STRING
:
1256 ERR("Unknown interpreter register type (%d)",
1263 switch (estack_bx_t
) {
1264 case REG_S64
: /* Fall-through */
1265 case REG_U64
: /* Fall-through */
1266 case REG_DOUBLE
: /* Fall-through */
1267 case REG_STAR_GLOB_STRING
:
1271 JUMP_TO(BYTECODE_OP_GE_STRING
);
1273 ERR("Unknown interpreter register type (%d)",
1280 ERR("Unknown interpreter register type (%d)",
1288 /* Dynamic typing. */
1289 switch (estack_ax_t
) {
1290 case REG_S64
: /* Fall-through */
1292 switch (estack_bx_t
) {
1293 case REG_S64
: /* Fall-through */
1295 JUMP_TO(BYTECODE_OP_LE_S64
);
1297 JUMP_TO(BYTECODE_OP_LE_DOUBLE_S64
);
1298 case REG_STRING
: /* Fall-through */
1299 case REG_STAR_GLOB_STRING
:
1303 ERR("Unknown interpreter register type (%d)",
1310 switch (estack_bx_t
) {
1311 case REG_S64
: /* Fall-through */
1313 JUMP_TO(BYTECODE_OP_LE_S64_DOUBLE
);
1315 JUMP_TO(BYTECODE_OP_LE_DOUBLE
);
1316 case REG_STRING
: /* Fall-through */
1317 case REG_STAR_GLOB_STRING
:
1321 ERR("Unknown interpreter register type (%d)",
1328 switch (estack_bx_t
) {
1329 case REG_S64
: /* Fall-through */
1330 case REG_U64
: /* Fall-through */
1331 case REG_DOUBLE
: /* Fall-through */
1332 case REG_STAR_GLOB_STRING
:
1336 JUMP_TO(BYTECODE_OP_LE_STRING
);
1338 ERR("Unknown interpreter register type (%d)",
1345 ERR("Unknown interpreter register type (%d)",
1352 OP(BYTECODE_OP_EQ_STRING
):
1356 res
= (stack_strcmp(stack
, top
, "==") == 0);
1357 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1359 estack_ax_t
= REG_S64
;
1360 next_pc
+= sizeof(struct binary_op
);
1363 OP(BYTECODE_OP_NE_STRING
):
1367 res
= (stack_strcmp(stack
, top
, "!=") != 0);
1368 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1370 estack_ax_t
= REG_S64
;
1371 next_pc
+= sizeof(struct binary_op
);
1374 OP(BYTECODE_OP_GT_STRING
):
1378 res
= (stack_strcmp(stack
, top
, ">") > 0);
1379 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1381 estack_ax_t
= REG_S64
;
1382 next_pc
+= sizeof(struct binary_op
);
1385 OP(BYTECODE_OP_LT_STRING
):
1389 res
= (stack_strcmp(stack
, top
, "<") < 0);
1390 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1392 estack_ax_t
= REG_S64
;
1393 next_pc
+= sizeof(struct binary_op
);
1396 OP(BYTECODE_OP_GE_STRING
):
1400 res
= (stack_strcmp(stack
, top
, ">=") >= 0);
1401 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1403 estack_ax_t
= REG_S64
;
1404 next_pc
+= sizeof(struct binary_op
);
1407 OP(BYTECODE_OP_LE_STRING
):
1411 res
= (stack_strcmp(stack
, top
, "<=") <= 0);
1412 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1414 estack_ax_t
= REG_S64
;
1415 next_pc
+= sizeof(struct binary_op
);
1419 OP(BYTECODE_OP_EQ_STAR_GLOB_STRING
):
1423 res
= (stack_star_glob_match(stack
, top
, "==") == 0);
1424 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1426 estack_ax_t
= REG_S64
;
1427 next_pc
+= sizeof(struct binary_op
);
1430 OP(BYTECODE_OP_NE_STAR_GLOB_STRING
):
1434 res
= (stack_star_glob_match(stack
, top
, "!=") != 0);
1435 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1437 estack_ax_t
= REG_S64
;
1438 next_pc
+= sizeof(struct binary_op
);
1442 OP(BYTECODE_OP_EQ_S64
):
1446 res
= (estack_bx_v
== estack_ax_v
);
1447 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1449 estack_ax_t
= REG_S64
;
1450 next_pc
+= sizeof(struct binary_op
);
1453 OP(BYTECODE_OP_NE_S64
):
1457 res
= (estack_bx_v
!= estack_ax_v
);
1458 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1460 estack_ax_t
= REG_S64
;
1461 next_pc
+= sizeof(struct binary_op
);
1464 OP(BYTECODE_OP_GT_S64
):
1468 res
= (estack_bx_v
> estack_ax_v
);
1469 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1471 estack_ax_t
= REG_S64
;
1472 next_pc
+= sizeof(struct binary_op
);
1475 OP(BYTECODE_OP_LT_S64
):
1479 res
= (estack_bx_v
< estack_ax_v
);
1480 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1482 estack_ax_t
= REG_S64
;
1483 next_pc
+= sizeof(struct binary_op
);
1486 OP(BYTECODE_OP_GE_S64
):
1490 res
= (estack_bx_v
>= estack_ax_v
);
1491 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1493 estack_ax_t
= REG_S64
;
1494 next_pc
+= sizeof(struct binary_op
);
1497 OP(BYTECODE_OP_LE_S64
):
1501 res
= (estack_bx_v
<= estack_ax_v
);
1502 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1504 estack_ax_t
= REG_S64
;
1505 next_pc
+= sizeof(struct binary_op
);
1509 OP(BYTECODE_OP_EQ_DOUBLE
):
1513 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax(stack
, top
)->u
.d
);
1514 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1516 estack_ax_t
= REG_S64
;
1517 next_pc
+= sizeof(struct binary_op
);
1520 OP(BYTECODE_OP_NE_DOUBLE
):
1524 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax(stack
, top
)->u
.d
);
1525 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1527 estack_ax_t
= REG_S64
;
1528 next_pc
+= sizeof(struct binary_op
);
1531 OP(BYTECODE_OP_GT_DOUBLE
):
1535 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax(stack
, top
)->u
.d
);
1536 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1538 estack_ax_t
= REG_S64
;
1539 next_pc
+= sizeof(struct binary_op
);
1542 OP(BYTECODE_OP_LT_DOUBLE
):
1546 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax(stack
, top
)->u
.d
);
1547 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1549 estack_ax_t
= REG_S64
;
1550 next_pc
+= sizeof(struct binary_op
);
1553 OP(BYTECODE_OP_GE_DOUBLE
):
1557 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax(stack
, top
)->u
.d
);
1558 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1560 estack_ax_t
= REG_S64
;
1561 next_pc
+= sizeof(struct binary_op
);
1564 OP(BYTECODE_OP_LE_DOUBLE
):
1568 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax(stack
, top
)->u
.d
);
1569 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1571 estack_ax_t
= REG_S64
;
1572 next_pc
+= sizeof(struct binary_op
);
1576 /* Mixed S64-double binary comparators */
1577 OP(BYTECODE_OP_EQ_DOUBLE_S64
):
1581 res
= (estack_bx(stack
, top
)->u
.d
== estack_ax_v
);
1582 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1584 estack_ax_t
= REG_S64
;
1585 next_pc
+= sizeof(struct binary_op
);
1588 OP(BYTECODE_OP_NE_DOUBLE_S64
):
1592 res
= (estack_bx(stack
, top
)->u
.d
!= estack_ax_v
);
1593 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1595 estack_ax_t
= REG_S64
;
1596 next_pc
+= sizeof(struct binary_op
);
1599 OP(BYTECODE_OP_GT_DOUBLE_S64
):
1603 res
= (estack_bx(stack
, top
)->u
.d
> estack_ax_v
);
1604 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1606 estack_ax_t
= REG_S64
;
1607 next_pc
+= sizeof(struct binary_op
);
1610 OP(BYTECODE_OP_LT_DOUBLE_S64
):
1614 res
= (estack_bx(stack
, top
)->u
.d
< estack_ax_v
);
1615 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1617 estack_ax_t
= REG_S64
;
1618 next_pc
+= sizeof(struct binary_op
);
1621 OP(BYTECODE_OP_GE_DOUBLE_S64
):
1625 res
= (estack_bx(stack
, top
)->u
.d
>= estack_ax_v
);
1626 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1628 estack_ax_t
= REG_S64
;
1629 next_pc
+= sizeof(struct binary_op
);
1632 OP(BYTECODE_OP_LE_DOUBLE_S64
):
1636 res
= (estack_bx(stack
, top
)->u
.d
<= estack_ax_v
);
1637 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1639 estack_ax_t
= REG_S64
;
1640 next_pc
+= sizeof(struct binary_op
);
1644 OP(BYTECODE_OP_EQ_S64_DOUBLE
):
1648 res
= (estack_bx_v
== estack_ax(stack
, top
)->u
.d
);
1649 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1651 estack_ax_t
= REG_S64
;
1652 next_pc
+= sizeof(struct binary_op
);
1655 OP(BYTECODE_OP_NE_S64_DOUBLE
):
1659 res
= (estack_bx_v
!= estack_ax(stack
, top
)->u
.d
);
1660 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1662 estack_ax_t
= REG_S64
;
1663 next_pc
+= sizeof(struct binary_op
);
1666 OP(BYTECODE_OP_GT_S64_DOUBLE
):
1670 res
= (estack_bx_v
> estack_ax(stack
, top
)->u
.d
);
1671 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1673 estack_ax_t
= REG_S64
;
1674 next_pc
+= sizeof(struct binary_op
);
1677 OP(BYTECODE_OP_LT_S64_DOUBLE
):
1681 res
= (estack_bx_v
< estack_ax(stack
, top
)->u
.d
);
1682 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1684 estack_ax_t
= REG_S64
;
1685 next_pc
+= sizeof(struct binary_op
);
1688 OP(BYTECODE_OP_GE_S64_DOUBLE
):
1692 res
= (estack_bx_v
>= estack_ax(stack
, top
)->u
.d
);
1693 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1695 estack_ax_t
= REG_S64
;
1696 next_pc
+= sizeof(struct binary_op
);
1699 OP(BYTECODE_OP_LE_S64_DOUBLE
):
1703 res
= (estack_bx_v
<= estack_ax(stack
, top
)->u
.d
);
1704 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1706 estack_ax_t
= REG_S64
;
1707 next_pc
+= sizeof(struct binary_op
);
1710 OP(BYTECODE_OP_BIT_RSHIFT
):
1714 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1719 /* Catch undefined behavior. */
1720 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1724 res
= ((uint64_t) estack_bx_v
>> (uint32_t) estack_ax_v
);
1725 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1727 estack_ax_t
= REG_U64
;
1728 next_pc
+= sizeof(struct binary_op
);
1731 OP(BYTECODE_OP_BIT_LSHIFT
):
1735 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1740 /* Catch undefined behavior. */
1741 if (caa_unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
1745 res
= ((uint64_t) estack_bx_v
<< (uint32_t) estack_ax_v
);
1746 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1748 estack_ax_t
= REG_U64
;
1749 next_pc
+= sizeof(struct binary_op
);
1752 OP(BYTECODE_OP_BIT_AND
):
1756 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1761 res
= ((uint64_t) estack_bx_v
& (uint64_t) estack_ax_v
);
1762 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1764 estack_ax_t
= REG_U64
;
1765 next_pc
+= sizeof(struct binary_op
);
1768 OP(BYTECODE_OP_BIT_OR
):
1772 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1777 res
= ((uint64_t) estack_bx_v
| (uint64_t) estack_ax_v
);
1778 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1780 estack_ax_t
= REG_U64
;
1781 next_pc
+= sizeof(struct binary_op
);
1784 OP(BYTECODE_OP_BIT_XOR
):
1788 if (!IS_INTEGER_REGISTER(estack_ax_t
) || !IS_INTEGER_REGISTER(estack_bx_t
)) {
1793 res
= ((uint64_t) estack_bx_v
^ (uint64_t) estack_ax_v
);
1794 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1796 estack_ax_t
= REG_U64
;
1797 next_pc
+= sizeof(struct binary_op
);
1802 OP(BYTECODE_OP_UNARY_PLUS
):
1804 /* Dynamic typing. */
1805 switch (estack_ax_t
) {
1806 case REG_S64
: /* Fall-through. */
1808 JUMP_TO(BYTECODE_OP_UNARY_PLUS_S64
);
1810 JUMP_TO(BYTECODE_OP_UNARY_PLUS_DOUBLE
);
1811 case REG_STRING
: /* Fall-through */
1812 case REG_STAR_GLOB_STRING
:
1816 ERR("Unknown interpreter register type (%d)",
1822 OP(BYTECODE_OP_UNARY_MINUS
):
1824 /* Dynamic typing. */
1825 switch (estack_ax_t
) {
1826 case REG_S64
: /* Fall-through. */
1828 JUMP_TO(BYTECODE_OP_UNARY_MINUS_S64
);
1830 JUMP_TO(BYTECODE_OP_UNARY_MINUS_DOUBLE
);
1831 case REG_STRING
: /* Fall-through */
1832 case REG_STAR_GLOB_STRING
:
1836 ERR("Unknown interpreter register type (%d)",
1842 OP(BYTECODE_OP_UNARY_NOT
):
1844 /* Dynamic typing. */
1845 switch (estack_ax_t
) {
1846 case REG_S64
: /* Fall-through. */
1848 JUMP_TO(BYTECODE_OP_UNARY_NOT_S64
);
1850 JUMP_TO(BYTECODE_OP_UNARY_NOT_DOUBLE
);
1851 case REG_STRING
: /* Fall-through */
1852 case REG_STAR_GLOB_STRING
:
1856 ERR("Unknown interpreter register type (%d)",
1861 next_pc
+= sizeof(struct unary_op
);
1865 OP(BYTECODE_OP_UNARY_BIT_NOT
):
1867 /* Dynamic typing. */
1868 if (!IS_INTEGER_REGISTER(estack_ax_t
)) {
1873 estack_ax_v
= ~(uint64_t) estack_ax_v
;
1874 estack_ax_t
= REG_U64
;
1875 next_pc
+= sizeof(struct unary_op
);
1879 OP(BYTECODE_OP_UNARY_PLUS_S64
):
1880 OP(BYTECODE_OP_UNARY_PLUS_DOUBLE
):
1882 next_pc
+= sizeof(struct unary_op
);
1885 OP(BYTECODE_OP_UNARY_MINUS_S64
):
1887 estack_ax_v
= -estack_ax_v
;
1888 next_pc
+= sizeof(struct unary_op
);
1891 OP(BYTECODE_OP_UNARY_MINUS_DOUBLE
):
1893 estack_ax(stack
, top
)->u
.d
= -estack_ax(stack
, top
)->u
.d
;
1894 next_pc
+= sizeof(struct unary_op
);
1897 OP(BYTECODE_OP_UNARY_NOT_S64
):
1899 estack_ax_v
= !estack_ax_v
;
1900 estack_ax_t
= REG_S64
;
1901 next_pc
+= sizeof(struct unary_op
);
1904 OP(BYTECODE_OP_UNARY_NOT_DOUBLE
):
1906 estack_ax_v
= !estack_ax(stack
, top
)->u
.d
;
1907 estack_ax_t
= REG_S64
;
1908 next_pc
+= sizeof(struct unary_op
);
1913 OP(BYTECODE_OP_AND
):
1915 struct logical_op
*insn
= (struct logical_op
*) pc
;
1917 if (estack_ax_t
!= REG_S64
&& estack_ax_t
!= REG_U64
) {
1921 /* If AX is 0, skip and evaluate to 0 */
1922 if (unlikely(estack_ax_v
== 0)) {
1923 dbg_printf("Jumping to bytecode offset %u\n",
1924 (unsigned int) insn
->skip_offset
);
1925 next_pc
= start_pc
+ insn
->skip_offset
;
1927 /* Pop 1 when jump not taken */
1928 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1929 next_pc
+= sizeof(struct logical_op
);
1935 struct logical_op
*insn
= (struct logical_op
*) pc
;
1937 if (estack_ax_t
!= REG_S64
&& estack_ax_t
!= REG_U64
) {
1941 /* If AX is nonzero, skip and evaluate to 1 */
1942 if (unlikely(estack_ax_v
!= 0)) {
1944 dbg_printf("Jumping to bytecode offset %u\n",
1945 (unsigned int) insn
->skip_offset
);
1946 next_pc
= start_pc
+ insn
->skip_offset
;
1948 /* Pop 1 when jump not taken */
1949 estack_pop(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1950 next_pc
+= sizeof(struct logical_op
);
1956 /* load field ref */
1957 OP(BYTECODE_OP_LOAD_FIELD_REF_STRING
):
1959 struct load_op
*insn
= (struct load_op
*) pc
;
1960 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1962 dbg_printf("load field ref offset %u type string\n",
1964 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1965 estack_ax(stack
, top
)->u
.s
.str
=
1966 *(const char * const *) &interpreter_stack_data
[ref
->offset
];
1967 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1968 dbg_printf("Interpreter warning: loading a NULL string.\n");
1972 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
1973 estack_ax(stack
, top
)->u
.s
.literal_type
=
1974 ESTACK_STRING_LITERAL_TYPE_NONE
;
1975 estack_ax_t
= REG_STRING
;
1976 dbg_printf("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1977 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1981 OP(BYTECODE_OP_LOAD_FIELD_REF_SEQUENCE
):
1983 struct load_op
*insn
= (struct load_op
*) pc
;
1984 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1986 dbg_printf("load field ref offset %u type sequence\n",
1988 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
1989 estack_ax(stack
, top
)->u
.s
.seq_len
=
1990 *(unsigned long *) &interpreter_stack_data
[ref
->offset
];
1991 estack_ax(stack
, top
)->u
.s
.str
=
1992 *(const char **) (&interpreter_stack_data
[ref
->offset
1993 + sizeof(unsigned long)]);
1994 estack_ax_t
= REG_STRING
;
1995 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1996 dbg_printf("Interpreter warning: loading a NULL sequence.\n");
2000 estack_ax(stack
, top
)->u
.s
.literal_type
=
2001 ESTACK_STRING_LITERAL_TYPE_NONE
;
2002 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2006 OP(BYTECODE_OP_LOAD_FIELD_REF_S64
):
2008 struct load_op
*insn
= (struct load_op
*) pc
;
2009 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2011 dbg_printf("load field ref offset %u type s64\n",
2013 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2015 ((struct literal_numeric
*) &interpreter_stack_data
[ref
->offset
])->v
;
2016 estack_ax_t
= REG_S64
;
2017 dbg_printf("ref load s64 %" PRIi64
"\n", estack_ax_v
);
2018 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2022 OP(BYTECODE_OP_LOAD_FIELD_REF_DOUBLE
):
2024 struct load_op
*insn
= (struct load_op
*) pc
;
2025 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2027 dbg_printf("load field ref offset %u type double\n",
2029 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2030 memcpy(&estack_ax(stack
, top
)->u
.d
, &interpreter_stack_data
[ref
->offset
],
2031 sizeof(struct literal_double
));
2032 estack_ax_t
= REG_DOUBLE
;
2033 dbg_printf("ref load double %g\n", estack_ax(stack
, top
)->u
.d
);
2034 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2038 /* load from immediate operand */
2039 OP(BYTECODE_OP_LOAD_STRING
):
2041 struct load_op
*insn
= (struct load_op
*) pc
;
2043 dbg_printf("load string %s\n", insn
->data
);
2044 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2045 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
2046 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2047 estack_ax(stack
, top
)->u
.s
.literal_type
=
2048 ESTACK_STRING_LITERAL_TYPE_PLAIN
;
2049 estack_ax_t
= REG_STRING
;
2050 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
2054 OP(BYTECODE_OP_LOAD_STAR_GLOB_STRING
):
2056 struct load_op
*insn
= (struct load_op
*) pc
;
2058 dbg_printf("load globbing pattern %s\n", insn
->data
);
2059 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2060 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
2061 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2062 estack_ax(stack
, top
)->u
.s
.literal_type
=
2063 ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
;
2064 estack_ax_t
= REG_STAR_GLOB_STRING
;
2065 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
2069 OP(BYTECODE_OP_LOAD_S64
):
2071 struct load_op
*insn
= (struct load_op
*) pc
;
2073 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2074 estack_ax_v
= ((struct literal_numeric
*) insn
->data
)->v
;
2075 estack_ax_t
= REG_S64
;
2076 dbg_printf("load s64 %" PRIi64
"\n", estack_ax_v
);
2077 next_pc
+= sizeof(struct load_op
)
2078 + sizeof(struct literal_numeric
);
2082 OP(BYTECODE_OP_LOAD_DOUBLE
):
2084 struct load_op
*insn
= (struct load_op
*) pc
;
2086 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2087 memcpy(&estack_ax(stack
, top
)->u
.d
, insn
->data
,
2088 sizeof(struct literal_double
));
2089 estack_ax_t
= REG_DOUBLE
;
2090 dbg_printf("load double %g\n", estack_ax(stack
, top
)->u
.d
);
2091 next_pc
+= sizeof(struct load_op
)
2092 + sizeof(struct literal_double
);
2097 OP(BYTECODE_OP_CAST_TO_S64
):
2099 /* Dynamic typing. */
2100 switch (estack_ax_t
) {
2102 JUMP_TO(BYTECODE_OP_CAST_NOP
);
2104 JUMP_TO(BYTECODE_OP_CAST_DOUBLE_TO_S64
);
2106 estack_ax_t
= REG_S64
;
2107 next_pc
+= sizeof(struct cast_op
);
2108 case REG_STRING
: /* Fall-through */
2109 case REG_STAR_GLOB_STRING
:
2113 ERR("Unknown interpreter register type (%d)",
2120 OP(BYTECODE_OP_CAST_DOUBLE_TO_S64
):
2122 estack_ax_v
= (int64_t) estack_ax(stack
, top
)->u
.d
;
2123 estack_ax_t
= REG_S64
;
2124 next_pc
+= sizeof(struct cast_op
);
2128 OP(BYTECODE_OP_CAST_NOP
):
2130 next_pc
+= sizeof(struct cast_op
);
2134 /* get context ref */
2135 OP(BYTECODE_OP_GET_CONTEXT_REF
):
2137 struct load_op
*insn
= (struct load_op
*) pc
;
2138 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2139 struct lttng_ust_ctx_field
*ctx_field
;
2140 struct lttng_ust_ctx_value v
;
2142 dbg_printf("get context ref offset %u type dynamic\n",
2144 ctx_field
= ctx
->fields
[ref
->offset
];
2145 ctx_field
->get_value(ctx_field
, &v
);
2146 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2148 case LTTNG_UST_DYNAMIC_TYPE_NONE
:
2151 case LTTNG_UST_DYNAMIC_TYPE_S64
:
2152 estack_ax_v
= v
.u
.s64
;
2153 estack_ax_t
= REG_S64
;
2154 dbg_printf("ref get context dynamic s64 %" PRIi64
"\n", estack_ax_v
);
2156 case LTTNG_UST_DYNAMIC_TYPE_DOUBLE
:
2157 estack_ax(stack
, top
)->u
.d
= v
.u
.d
;
2158 estack_ax_t
= REG_DOUBLE
;
2159 dbg_printf("ref get context dynamic double %g\n", estack_ax(stack
, top
)->u
.d
);
2161 case LTTNG_UST_DYNAMIC_TYPE_STRING
:
2162 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2163 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2164 dbg_printf("Interpreter warning: loading a NULL string.\n");
2168 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2169 estack_ax(stack
, top
)->u
.s
.literal_type
=
2170 ESTACK_STRING_LITERAL_TYPE_NONE
;
2171 dbg_printf("ref get context dynamic string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2172 estack_ax_t
= REG_STRING
;
2175 dbg_printf("Interpreter warning: unknown dynamic type (%d).\n", (int) v
.sel
);
2179 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2183 OP(BYTECODE_OP_GET_CONTEXT_REF_STRING
):
2185 struct load_op
*insn
= (struct load_op
*) pc
;
2186 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2187 struct lttng_ust_ctx_field
*ctx_field
;
2188 struct lttng_ust_ctx_value v
;
2190 dbg_printf("get context ref offset %u type string\n",
2192 ctx_field
= ctx
->fields
[ref
->offset
];
2193 ctx_field
->get_value(ctx_field
, &v
);
2194 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2195 estack_ax(stack
, top
)->u
.s
.str
= v
.u
.str
;
2196 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2197 dbg_printf("Interpreter warning: loading a NULL string.\n");
2201 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2202 estack_ax(stack
, top
)->u
.s
.literal_type
=
2203 ESTACK_STRING_LITERAL_TYPE_NONE
;
2204 estack_ax_t
= REG_STRING
;
2205 dbg_printf("ref get context string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
2206 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2210 OP(BYTECODE_OP_GET_CONTEXT_REF_S64
):
2212 struct load_op
*insn
= (struct load_op
*) pc
;
2213 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2214 struct lttng_ust_ctx_field
*ctx_field
;
2215 struct lttng_ust_ctx_value v
;
2217 dbg_printf("get context ref offset %u type s64\n",
2219 ctx_field
= ctx
->fields
[ref
->offset
];
2220 ctx_field
->get_value(ctx_field
, &v
);
2221 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2222 estack_ax_v
= v
.u
.s64
;
2223 estack_ax_t
= REG_S64
;
2224 dbg_printf("ref get context s64 %" PRIi64
"\n", estack_ax_v
);
2225 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2229 OP(BYTECODE_OP_GET_CONTEXT_REF_DOUBLE
):
2231 struct load_op
*insn
= (struct load_op
*) pc
;
2232 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
2233 struct lttng_ust_ctx_field
*ctx_field
;
2234 struct lttng_ust_ctx_value v
;
2236 dbg_printf("get context ref offset %u type double\n",
2238 ctx_field
= ctx
->fields
[ref
->offset
];
2239 ctx_field
->get_value(ctx_field
, &v
);
2240 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2241 memcpy(&estack_ax(stack
, top
)->u
.d
, &v
.u
.d
, sizeof(struct literal_double
));
2242 estack_ax_t
= REG_DOUBLE
;
2243 dbg_printf("ref get context double %g\n", estack_ax(stack
, top
)->u
.d
);
2244 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
2248 OP(BYTECODE_OP_GET_CONTEXT_ROOT
):
2250 dbg_printf("op get context root\n");
2251 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2252 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_CONTEXT
;
2253 /* "field" only needed for variants. */
2254 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2255 estack_ax_t
= REG_PTR
;
2256 next_pc
+= sizeof(struct load_op
);
2260 OP(BYTECODE_OP_GET_APP_CONTEXT_ROOT
):
2262 dbg_printf("op get app context root\n");
2263 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2264 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_APP_CONTEXT
;
2265 /* "field" only needed for variants. */
2266 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2267 estack_ax_t
= REG_PTR
;
2268 next_pc
+= sizeof(struct load_op
);
2272 OP(BYTECODE_OP_GET_PAYLOAD_ROOT
):
2274 dbg_printf("op get app payload root\n");
2275 estack_push(stack
, top
, ax
, bx
, ax_t
, bx_t
);
2276 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_PAYLOAD
;
2277 estack_ax(stack
, top
)->u
.ptr
.ptr
= interpreter_stack_data
;
2278 /* "field" only needed for variants. */
2279 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
2280 estack_ax_t
= REG_PTR
;
2281 next_pc
+= sizeof(struct load_op
);
2285 OP(BYTECODE_OP_GET_SYMBOL
):
2287 dbg_printf("op get symbol\n");
2288 switch (estack_ax(stack
, top
)->u
.ptr
.type
) {
2290 ERR("Nested fields not implemented yet.");
2293 case LOAD_ROOT_CONTEXT
:
2294 case LOAD_ROOT_APP_CONTEXT
:
2295 case LOAD_ROOT_PAYLOAD
:
2297 * symbol lookup is performed by
2303 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_symbol
);
2307 OP(BYTECODE_OP_GET_SYMBOL_FIELD
):
2310 * Used for first variant encountered in a
2311 * traversal. Variants are not implemented yet.
2317 OP(BYTECODE_OP_GET_INDEX_U16
):
2319 struct load_op
*insn
= (struct load_op
*) pc
;
2320 struct get_index_u16
*index
= (struct get_index_u16
*) insn
->data
;
2322 dbg_printf("op get index u16\n");
2323 ret
= dynamic_get_index(ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
2326 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2327 estack_ax_t
= estack_ax(stack
, top
)->type
;
2328 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u16
);
2332 OP(BYTECODE_OP_GET_INDEX_U64
):
2334 struct load_op
*insn
= (struct load_op
*) pc
;
2335 struct get_index_u64
*index
= (struct get_index_u64
*) insn
->data
;
2337 dbg_printf("op get index u64\n");
2338 ret
= dynamic_get_index(ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
2341 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2342 estack_ax_t
= estack_ax(stack
, top
)->type
;
2343 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u64
);
2347 OP(BYTECODE_OP_LOAD_FIELD
):
2349 dbg_printf("op load field\n");
2350 ret
= dynamic_load_field(estack_ax(stack
, top
));
2353 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
2354 estack_ax_t
= estack_ax(stack
, top
)->type
;
2355 next_pc
+= sizeof(struct load_op
);
2359 OP(BYTECODE_OP_LOAD_FIELD_S8
):
2361 dbg_printf("op load field s8\n");
2363 estack_ax_v
= *(int8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2364 estack_ax_t
= REG_S64
;
2365 next_pc
+= sizeof(struct load_op
);
2368 OP(BYTECODE_OP_LOAD_FIELD_S16
):
2370 dbg_printf("op load field s16\n");
2372 estack_ax_v
= *(int16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2373 estack_ax_t
= REG_S64
;
2374 next_pc
+= sizeof(struct load_op
);
2377 OP(BYTECODE_OP_LOAD_FIELD_S32
):
2379 dbg_printf("op load field s32\n");
2381 estack_ax_v
= *(int32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2382 estack_ax_t
= REG_S64
;
2383 next_pc
+= sizeof(struct load_op
);
2386 OP(BYTECODE_OP_LOAD_FIELD_S64
):
2388 dbg_printf("op load field s64\n");
2390 estack_ax_v
= *(int64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2391 estack_ax_t
= REG_S64
;
2392 next_pc
+= sizeof(struct load_op
);
2395 OP(BYTECODE_OP_LOAD_FIELD_U8
):
2397 dbg_printf("op load field u8\n");
2399 estack_ax_v
= *(uint8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2400 estack_ax_t
= REG_U64
;
2401 next_pc
+= sizeof(struct load_op
);
2404 OP(BYTECODE_OP_LOAD_FIELD_U16
):
2406 dbg_printf("op load field u16\n");
2408 estack_ax_v
= *(uint16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2409 estack_ax_t
= REG_U64
;
2410 next_pc
+= sizeof(struct load_op
);
2413 OP(BYTECODE_OP_LOAD_FIELD_U32
):
2415 dbg_printf("op load field u32\n");
2417 estack_ax_v
= *(uint32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2418 estack_ax_t
= REG_U64
;
2419 next_pc
+= sizeof(struct load_op
);
2422 OP(BYTECODE_OP_LOAD_FIELD_U64
):
2424 dbg_printf("op load field u64\n");
2426 estack_ax_v
= *(uint64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2427 estack_ax_t
= REG_U64
;
2428 next_pc
+= sizeof(struct load_op
);
2431 OP(BYTECODE_OP_LOAD_FIELD_DOUBLE
):
2433 dbg_printf("op load field double\n");
2435 memcpy(&estack_ax(stack
, top
)->u
.d
,
2436 estack_ax(stack
, top
)->u
.ptr
.ptr
,
2437 sizeof(struct literal_double
));
2438 estack_ax(stack
, top
)->type
= REG_DOUBLE
;
2439 next_pc
+= sizeof(struct load_op
);
2443 OP(BYTECODE_OP_LOAD_FIELD_STRING
):
2447 dbg_printf("op load field string\n");
2448 str
= (const char *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
2449 estack_ax(stack
, top
)->u
.s
.str
= str
;
2450 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2451 dbg_printf("Interpreter warning: loading a NULL string.\n");
2455 estack_ax(stack
, top
)->u
.s
.seq_len
= SIZE_MAX
;
2456 estack_ax(stack
, top
)->u
.s
.literal_type
=
2457 ESTACK_STRING_LITERAL_TYPE_NONE
;
2458 estack_ax(stack
, top
)->type
= REG_STRING
;
2459 next_pc
+= sizeof(struct load_op
);
2463 OP(BYTECODE_OP_LOAD_FIELD_SEQUENCE
):
2467 dbg_printf("op load field string sequence\n");
2468 ptr
= estack_ax(stack
, top
)->u
.ptr
.ptr
;
2469 estack_ax(stack
, top
)->u
.s
.seq_len
= *(unsigned long *) ptr
;
2470 estack_ax(stack
, top
)->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
2471 estack_ax(stack
, top
)->type
= REG_STRING
;
2472 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
2473 dbg_printf("Interpreter warning: loading a NULL sequence.\n");
2477 estack_ax(stack
, top
)->u
.s
.literal_type
=
2478 ESTACK_STRING_LITERAL_TYPE_NONE
;
2479 next_pc
+= sizeof(struct load_op
);
2485 /* Return _DISCARD on error. */
2487 return LTTNG_UST_BYTECODE_INTERPRETER_DISCARD
;
2490 return lttng_bytecode_interpret_format_output(estack_ax(stack
, top
),
2497 uint64_t lttng_bytecode_filter_interpret(void *filter_data
,
2498 const char *filter_stack_data
)
2500 return bytecode_interpret(filter_data
, filter_stack_data
, NULL
);
2503 uint64_t lttng_bytecode_capture_interpret(void *capture_data
,
2504 const char *capture_stack_data
,
2505 struct lttng_interpreter_output
*output
)
2507 return bytecode_interpret(capture_data
, capture_stack_data
,
2508 (struct lttng_interpreter_output
*) output
);