Move hash tables to internal header
[lttng-ust.git] / liblttng-ust / lttng-bytecode-interpreter.c
index 6072aee9bd6105526e6063748c7c7e5f00b33b6f..46351a25f3ed4e23cd68a6edc7deafa7327794cc 100644 (file)
@@ -1,27 +1,9 @@
 /*
- * lttng-bytecode-interpreter.c
- *
- * LTTng UST bytecode interpreter.
+ * 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 interpreter.
  */
 
 #define _LGPL_SOURCE
@@ -31,6 +13,7 @@
 #include <lttng/urcu/pointer.h>
 #include <lttng/ust-endian.h>
 #include <lttng/ust-events.h>
+#include "ust-events-internal.h"
 
 #include "lttng-bytecode.h"
 #include "string-utils.h"
@@ -189,7 +172,7 @@ uint64_t lttng_bytecode_capture_interpret_false(void *capture_data,
        for (pc = next_pc = start_pc; pc - start_pc < bytecode->len;    \
                        pc = next_pc) {                                 \
                dbg_printf("Executing op %s (%u)\n",                    \
-                       print_op((unsigned int) *(bytecode_opcode_t *) pc), \
+                       lttng_bytecode_print_op((unsigned int) *(bytecode_opcode_t *) pc), \
                        (unsigned int) *(bytecode_opcode_t *) pc);      \
                switch (*(bytecode_opcode_t *) pc)      {
 
@@ -240,7 +223,7 @@ static int context_get_index(struct lttng_ctx *ctx,
 {
 
        struct lttng_ctx_field *ctx_field;
-       struct lttng_event_field *field;
+       struct lttng_ust_event_field *field;
        struct lttng_ctx_value v;
 
        ctx_field = &ctx->fields[idx];
@@ -261,16 +244,11 @@ static int context_get_index(struct lttng_ctx *ctx,
                        ptr->ptr = &ptr->u.u64;
                }
                break;
-       case atype_enum:        /* Fall-through */
        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;
                ctx_field->get_value(ctx_field, &v);
                if (itype->signedness) {
                        ptr->object_type = OBJECT_TYPE_SIGNED_ENUM;
@@ -283,19 +261,6 @@ static int context_get_index(struct lttng_ctx *ctx,
                }
                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 (field->type.u.legacy.array.elem_type.u.basic.integer.encoding == lttng_encode_none) {
-                       ERR("Only string arrays are supported for contexts.");
-                       return -EINVAL;
-               }
-               ptr->object_type = OBJECT_TYPE_STRING;
-               ctx_field->get_value(ctx_field, &v);
-               ptr->ptr = v.u.str;
-               break;
        case atype_array_nestable:
                if (field->type.u.array_nestable.elem_type->atype != atype_integer) {
                        ERR("Array nesting only supports integer types.");
@@ -309,19 +274,6 @@ static int context_get_index(struct lttng_ctx *ctx,
                ctx_field->get_value(ctx_field, &v);
                ptr->ptr = v.u.str;
                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 (field->type.u.legacy.sequence.elem_type.u.basic.integer.encoding == lttng_encode_none) {
-                       ERR("Only string sequences are supported for contexts.");
-                       return -EINVAL;
-               }
-               ptr->object_type = OBJECT_TYPE_STRING;
-               ctx_field->get_value(ctx_field, &v);
-               ptr->ptr = v.u.str;
-               break;
        case atype_sequence_nestable:
                if (field->type.u.sequence_nestable.elem_type->atype != atype_integer) {
                        ERR("Sequence nesting only supports integer types.");
@@ -386,9 +338,6 @@ static int context_get_index(struct lttng_ctx *ctx,
                        return -EINVAL;
                }
                break;
-       case atype_struct:
-               ERR("Structure type cannot be loaded.");
-               return -EINVAL;
        default:
                ERR("Unknown type: %d", (int) field->type.atype);
                return -EINVAL;
@@ -418,8 +367,7 @@ static int dynamic_get_index(struct lttng_ctx *ctx,
                        stack_top->u.ptr.ptr = ptr;
                        stack_top->u.ptr.object_type = gid->elem.type;
                        stack_top->u.ptr.rev_bo = gid->elem.rev_bo;
-                       assert(stack_top->u.ptr.field->type.atype == atype_array ||
-                                       stack_top->u.ptr.field->type.atype == atype_array_nestable);
+                       assert(stack_top->u.ptr.field->type.atype == atype_array_nestable);
                        stack_top->u.ptr.field = NULL;
                        break;
                }
@@ -438,8 +386,7 @@ static int dynamic_get_index(struct lttng_ctx *ctx,
                        stack_top->u.ptr.ptr = ptr;
                        stack_top->u.ptr.object_type = gid->elem.type;
                        stack_top->u.ptr.rev_bo = gid->elem.rev_bo;
-                       assert(stack_top->u.ptr.field->type.atype == atype_sequence ||
-                                       stack_top->u.ptr.field->type.atype == atype_sequence_nestable);
+                       assert(stack_top->u.ptr.field->type.atype == atype_sequence_nestable);
                        stack_top->u.ptr.field = NULL;
                        break;
                }
@@ -770,7 +717,7 @@ uint64_t bytecode_interpret(void *interpreter_data,
                struct lttng_interpreter_output *output)
 {
        struct bytecode_runtime *bytecode = interpreter_data;
-       struct lttng_ctx *ctx = lttng_ust_rcu_dereference(*bytecode->p.pctx);
+       struct lttng_ctx *ctx = lttng_ust_rcu_dereference(*bytecode->p.priv->pctx);
        void *pc, *next_pc, *start_pc;
        int ret = -EINVAL;
        uint64_t retval = 0;
This page took 0.025866 seconds and 4 git commands to generate.