Introduce common event structure
[lttng-ust.git] / liblttng-ust / lttng-bytecode-specialize.c
index 15a45b93947fb19f9ae057984f6307c98befb45c..f571dd60197b08b38f247f288ebd38d8e4063703 100644 (file)
@@ -1,35 +1,19 @@
 /*
- * lttng-bytecode-specialize.c
- *
- * LTTng UST bytecode specializer.
+ * SPDX-License-Identifier: MIT
  *
  * Copyright (C) 2010-2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * LTTng UST bytecode specializer.
  */
 
 #define _LGPL_SOURCE
 #include <stddef.h>
 #include <stdint.h>
 
-#include "lttng-bytecode.h"
 #include <lttng/align.h>
+
+#include "context-internal.h"
+#include "lttng-bytecode.h"
 #include "ust-events-internal.h"
 
 static int lttng_fls(int val)
@@ -275,10 +259,6 @@ static int specialize_get_index(struct bytecode_runtime *runtime,
 
                        field = stack_top->load.field;
                        switch (field->type.atype) {
-                       case atype_array:
-                               integer_type = &field->type.u.legacy.array.elem_type.u.basic.integer;
-                               num_elems = field->type.u.legacy.array.length;
-                               break;
                        case atype_array_nestable:
                                if (field->type.u.array_nestable.elem_type->atype != atype_integer) {
                                        ret = -EINVAL;
@@ -319,9 +299,6 @@ static int specialize_get_index(struct bytecode_runtime *runtime,
 
                        field = stack_top->load.field;
                        switch (field->type.atype) {
-                       case atype_sequence:
-                               integer_type = &field->type.u.legacy.sequence.elem_type.u.basic.integer;
-                               break;
                        case atype_sequence_nestable:
                                if (field->type.u.sequence_nestable.elem_type->atype != atype_integer) {
                                        ret = -EINVAL;
@@ -396,7 +373,7 @@ static int specialize_context_lookup_name(struct lttng_ctx *ctx,
        const char *name;
 
        offset = ((struct get_symbol *) insn->data)->offset;
-       name = bytecode->p.bc->bc.data + bytecode->p.bc->bc.reloc_offset + offset;
+       name = bytecode->p.priv->bc->bc.data + bytecode->p.priv->bc->bc.reloc_offset + offset;
        return lttng_get_context_index(ctx, name);
 }
 
@@ -413,16 +390,11 @@ static int specialize_load_object(const struct lttng_event_field *field,
                        load->object_type = OBJECT_TYPE_U64;
                load->rev_bo = false;
                break;
-       case atype_enum:
        case atype_enum_nestable:
        {
                const struct lttng_integer_type *itype;
 
-               if (field->type.atype == atype_enum) {
-                       itype = &field->type.u.legacy.basic.enumeration.container_type;
-               } else {
-                       itype = &field->type.u.enum_nestable.container_type->u.integer;
-               }
+               itype = &field->type.u.enum_nestable.container_type->u.integer;
                if (itype->signedness)
                        load->object_type = OBJECT_TYPE_SIGNED_ENUM;
                else
@@ -430,22 +402,6 @@ static int specialize_load_object(const struct lttng_event_field *field,
                load->rev_bo = false;
                break;
        }
-       case atype_array:
-               if (field->type.u.legacy.array.elem_type.atype != atype_integer) {
-                       ERR("Array nesting only supports integer types.");
-                       return -EINVAL;
-               }
-               if (is_context) {
-                       load->object_type = OBJECT_TYPE_STRING;
-               } else {
-                       if (field->type.u.legacy.array.elem_type.u.basic.integer.encoding == lttng_encode_none) {
-                               load->object_type = OBJECT_TYPE_ARRAY;
-                               load->field = field;
-                       } else {
-                               load->object_type = OBJECT_TYPE_STRING_SEQUENCE;
-                       }
-               }
-               break;
        case atype_array_nestable:
                if (field->type.u.array_nestable.elem_type->atype != atype_integer) {
                        ERR("Array nesting only supports integer types.");
@@ -462,22 +418,6 @@ static int specialize_load_object(const struct lttng_event_field *field,
                        }
                }
                break;
-       case atype_sequence:
-               if (field->type.u.legacy.sequence.elem_type.atype != atype_integer) {
-                       ERR("Sequence nesting only supports integer types.");
-                       return -EINVAL;
-               }
-               if (is_context) {
-                       load->object_type = OBJECT_TYPE_STRING;
-               } else {
-                       if (field->type.u.legacy.sequence.elem_type.u.basic.integer.encoding == lttng_encode_none) {
-                               load->object_type = OBJECT_TYPE_SEQUENCE;
-                               load->field = field;
-                       } else {
-                               load->object_type = OBJECT_TYPE_STRING_SEQUENCE;
-                       }
-               }
-               break;
        case atype_sequence_nestable:
                if (field->type.u.sequence_nestable.elem_type->atype != atype_integer) {
                        ERR("Sequence nesting only supports integer types.");
@@ -504,9 +444,6 @@ static int specialize_load_object(const struct lttng_event_field *field,
        case atype_dynamic:
                load->object_type = OBJECT_TYPE_DYNAMIC;
                break;
-       case atype_struct:
-               ERR("Structure type cannot be loaded.");
-               return -EINVAL;
        default:
                ERR("Unknown type: %d", (int) field->type.atype);
                return -EINVAL;
@@ -565,7 +502,7 @@ static int specialize_app_context_lookup(struct lttng_ctx **pctx,
        ssize_t data_offset;
 
        offset = ((struct get_symbol *) insn->data)->offset;
-       orig_name = runtime->p.bc->bc.data + runtime->p.bc->bc.reloc_offset + offset;
+       orig_name = runtime->p.priv->bc->bc.data + runtime->p.priv->bc->bc.reloc_offset + offset;
        name = zmalloc(strlen(orig_name) + strlen("$app.") + 1);
        if (!name) {
                ret = -ENOMEM;
@@ -626,7 +563,7 @@ static int specialize_payload_lookup(const struct lttng_event_desc *event_desc,
 
        nr_fields = event_desc->nr_fields;
        offset = ((struct get_symbol *) insn->data)->offset;
-       name = runtime->p.bc->bc.data + runtime->p.bc->bc.reloc_offset + offset;
+       name = runtime->p.priv->bc->bc.data + runtime->p.priv->bc->bc.reloc_offset + offset;
        for (i = 0; i < nr_fields; i++) {
                field = &event_desc->fields[i];
                if (field->u.ext.nofilter) {
@@ -639,13 +576,10 @@ static int specialize_payload_lookup(const struct lttng_event_desc *event_desc,
                /* compute field offset on stack */
                switch (field->type.atype) {
                case atype_integer:
-               case atype_enum:
                case atype_enum_nestable:
                        field_offset += sizeof(int64_t);
                        break;
-               case atype_array:
                case atype_array_nestable:
-               case atype_sequence:
                case atype_sequence_nestable:
                        field_offset += sizeof(unsigned long);
                        field_offset += sizeof(void *);
@@ -696,7 +630,7 @@ int lttng_bytecode_specialize(const struct lttng_event_desc *event_desc,
        int ret = -EINVAL;
        struct vstack _stack;
        struct vstack *stack = &_stack;
-       struct lttng_ctx **pctx = bytecode->p.pctx;
+       struct lttng_ctx **pctx = bytecode->p.priv->pctx;
 
        vstack_init(stack);
 
This page took 0.025471 seconds and 4 git commands to generate.