bytecode: Add `OBJECT_TYPE_{UN,}SIGNED_ENUM` type
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Wed, 13 May 2020 15:42:09 +0000 (11:42 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 25 Nov 2020 18:17:32 +0000 (13:17 -0500)
Enumerations are currently converted to their integer counterparts as
soon as they are encountered.

In order to use them in captures, we need to differentiate the
enumerations from integers for the entirety of the interpretation.

This commit adds the `OBJECT_TYPE_SIGNED_ENUM` and
`OBJECT_TYPE_UNSIGNED_ENUM` to keep track of these objects

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic0ab518588d7250190e42576d9baba2e8d8ce94a

include/lttng/lttng-bytecode.h
src/lttng-bytecode-interpreter.c
src/lttng-bytecode-specialize.c

index 79a562bfb5c50f57ecff10958f126737e177bb4f..3a11e23000befe0a8304e038b89dc4dd025a1d91 100644 (file)
@@ -71,6 +71,9 @@ enum object_type {
        OBJECT_TYPE_U32,
        OBJECT_TYPE_U64,
 
+       OBJECT_TYPE_SIGNED_ENUM,
+       OBJECT_TYPE_UNSIGNED_ENUM,
+
        OBJECT_TYPE_DOUBLE,
        OBJECT_TYPE_STRING,
        OBJECT_TYPE_STRING_SEQUENCE,
index 950c0ba028fcc6ac619f27023ec9fb7dcf549d8f..8252cdf15501a12367579ede9792083cd5d11df4 100644 (file)
@@ -298,11 +298,11 @@ static int context_get_index(struct lttng_probe_ctx *lttng_probe_ctx,
 
                ctx_field->get_value(ctx_field, lttng_probe_ctx, &v);
                if (itype->signedness) {
-                       ptr->object_type = OBJECT_TYPE_S64;
+                       ptr->object_type = OBJECT_TYPE_SIGNED_ENUM;
                        ptr->u.s64 = v.s64;
                        ptr->ptr = &ptr->u.s64;
                } else {
-                       ptr->object_type = OBJECT_TYPE_U64;
+                       ptr->object_type = OBJECT_TYPE_UNSIGNED_ENUM;
                        ptr->u.u64 = v.s64;     /* Cast. */
                        ptr->ptr = &ptr->u.u64;
                }
@@ -496,6 +496,18 @@ static int dynamic_load_field(struct estack_entry *stack_top)
                stack_top->type = REG_S64;
                break;
        }
+       case OBJECT_TYPE_SIGNED_ENUM:
+       {
+               int64_t tmp;
+
+               dbg_printk("op load field signed enumeration\n");
+               tmp = *(int64_t *) stack_top->u.ptr.ptr;
+               if (stack_top->u.ptr.rev_bo)
+                       __swab64s(&tmp);
+               stack_top->u.v = tmp;
+               stack_top->type = REG_S64;
+               break;
+       }
        case OBJECT_TYPE_U8:
                dbg_printk("op load field u8\n");
                stack_top->u.v = *(uint8_t *) stack_top->u.ptr.ptr;
@@ -537,6 +549,18 @@ static int dynamic_load_field(struct estack_entry *stack_top)
                stack_top->type = REG_U64;
                break;
        }
+       case OBJECT_TYPE_UNSIGNED_ENUM:
+       {
+               uint64_t tmp;
+
+               dbg_printk("op load field unsigned enumeration\n");
+               tmp = *(uint64_t *) stack_top->u.ptr.ptr;
+               if (stack_top->u.ptr.rev_bo)
+                       __swab64s(&tmp);
+               stack_top->u.v = tmp;
+               stack_top->type = REG_U64;
+               break;
+       }
        case OBJECT_TYPE_STRING:
        {
                const char *str;
@@ -649,6 +673,20 @@ again:
                        output->u.sequence.nr_elem = ax->u.ptr.field->type.u.array_nestable.length;
                        output->u.sequence.nested_type = ax->u.ptr.field->type.u.array_nestable.elem_type;
                        break;
+               case OBJECT_TYPE_SIGNED_ENUM:
+                       ret = dynamic_load_field(ax);
+                       if (ret)
+                               return ret;
+                       output->type = LTTNG_INTERPRETER_TYPE_SIGNED_ENUM;
+                       output->u.s = ax->u.v;
+                       break;
+               case OBJECT_TYPE_UNSIGNED_ENUM:
+                       ret = dynamic_load_field(ax);
+                       if (ret)
+                               return ret;
+                       output->type = LTTNG_INTERPRETER_TYPE_UNSIGNED_ENUM;
+                       output->u.u = ax->u.v;
+                       break;
                case OBJECT_TYPE_STRUCT:
                case OBJECT_TYPE_VARIANT:
                default:
index 83ba6f55b8e2d1a74c7c5c01752bcf64f7a9ee99..1ad577a32fb1af3039001fc1eb5cef6b8d2e894c 100644 (file)
@@ -95,6 +95,10 @@ static int specialize_load_field(struct vstack_entry *stack_top,
                if (!stack_top->load.rev_bo)
                        insn->op = BYTECODE_OP_LOAD_FIELD_S64;
                break;
+       case OBJECT_TYPE_SIGNED_ENUM:
+               dbg_printk("op load field signed enumeration\n");
+               stack_top->type = REG_PTR;
+               break;
        case OBJECT_TYPE_U8:
                dbg_printk("op load field u8\n");
                stack_top->type = REG_S64;
@@ -118,6 +122,10 @@ static int specialize_load_field(struct vstack_entry *stack_top,
                if (!stack_top->load.rev_bo)
                        insn->op = BYTECODE_OP_LOAD_FIELD_U64;
                break;
+       case OBJECT_TYPE_UNSIGNED_ENUM:
+               dbg_printk("op load field unsigned enumeration\n");
+               stack_top->type = REG_PTR;
+               break;
        case OBJECT_TYPE_DOUBLE:
                printk(KERN_WARNING "LTTng: bytecode: Double type unsupported\n\n");
                ret = -EINVAL;
@@ -328,9 +336,9 @@ static int specialize_load_object(const struct lttng_event_field *field,
                        &field->type.u.enum_nestable.container_type->u.integer;
 
                if (itype->signedness)
-                       load->object_type = OBJECT_TYPE_S64;
+                       load->object_type = OBJECT_TYPE_SIGNED_ENUM;
                else
-                       load->object_type = OBJECT_TYPE_U64;
+                       load->object_type = OBJECT_TYPE_UNSIGNED_ENUM;
                load->rev_bo = false;
                break;
        }
This page took 0.02939 seconds and 4 git commands to generate.