Move to kernel style SPDX license identifiers
[lttng-ust.git] / liblttng-ust / lttng-bytecode-interpreter.c
index 9a2aaa45ec97b63748150c7700dadaac6f49ddc6..ee44a8aff68f76bd804776a8c8e281a708fc9a29 100644 (file)
@@ -1,35 +1,16 @@
 /*
- * 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
 #include <stddef.h>
 #include <stdint.h>
-#include <urcu-pointer.h>
-#include <byteswap.h>
 
+#include <lttng/urcu/pointer.h>
 #include <lttng/ust-endian.h>
 #include <lttng/ust-events.h>
 
@@ -172,6 +153,13 @@ uint64_t lttng_bytecode_filter_interpret_false(void *filter_data,
        return LTTNG_INTERPRETER_DISCARD;
 }
 
+uint64_t lttng_bytecode_capture_interpret_false(void *capture_data,
+               const char *capture_stack_data,
+               struct lttng_interpreter_output *output)
+{
+       return LTTNG_INTERPRETER_DISCARD;
+}
+
 #ifdef INTERPRETER_USE_SWITCH
 
 /*
@@ -345,12 +333,25 @@ static int context_get_index(struct lttng_ctx *ctx,
                switch (v.sel) {
                case LTTNG_UST_DYNAMIC_TYPE_NONE:
                        return -EINVAL;
+               case LTTNG_UST_DYNAMIC_TYPE_U8:
+               case LTTNG_UST_DYNAMIC_TYPE_U16:
+               case LTTNG_UST_DYNAMIC_TYPE_U32:
+               case LTTNG_UST_DYNAMIC_TYPE_U64:
+                       ptr->object_type = OBJECT_TYPE_U64;
+                       ptr->u.u64 = v.u.u64;
+                       ptr->ptr = &ptr->u.u64;
+                       dbg_printf("context get index dynamic u64 %" PRIi64 "\n", ptr->u.u64);
+                       break;
+               case LTTNG_UST_DYNAMIC_TYPE_S8:
+               case LTTNG_UST_DYNAMIC_TYPE_S16:
+               case LTTNG_UST_DYNAMIC_TYPE_S32:
                case LTTNG_UST_DYNAMIC_TYPE_S64:
                        ptr->object_type = OBJECT_TYPE_S64;
                        ptr->u.s64 = v.u.s64;
                        ptr->ptr = &ptr->u.s64;
                        dbg_printf("context get index dynamic s64 %" PRIi64 "\n", ptr->u.s64);
                        break;
+               case LTTNG_UST_DYNAMIC_TYPE_FLOAT:
                case LTTNG_UST_DYNAMIC_TYPE_DOUBLE:
                        ptr->object_type = OBJECT_TYPE_DOUBLE;
                        ptr->u.d = v.u.d;
@@ -738,9 +739,12 @@ again:
 }
 
 /*
- * Return 0 (discard), or raise the 0x1 flag (log event).
- * Currently, other flags are kept for future extensions and have no
- * effect.
+ * For `output` equal to NULL:
+ *  Return 0 (discard), or raise the 0x1 flag (log event).
+ *  Currently, other flags are kept for future extensions and have no
+ *  effect.
+ * For `output` not equal to NULL:
+ *  Return 0 on success, negative error value on error.
  */
 static
 uint64_t bytecode_interpret(void *interpreter_data,
@@ -748,7 +752,7 @@ uint64_t bytecode_interpret(void *interpreter_data,
                struct lttng_interpreter_output *output)
 {
        struct bytecode_runtime *bytecode = interpreter_data;
-       struct lttng_ctx *ctx = rcu_dereference(*bytecode->p.pctx);
+       struct lttng_ctx *ctx = lttng_ust_rcu_dereference(*bytecode->p.pctx);
        void *pc, *next_pc, *start_pc;
        int ret = -EINVAL;
        uint64_t retval = 0;
@@ -2531,6 +2535,14 @@ uint64_t lttng_bytecode_filter_interpret(void *filter_data,
        return bytecode_interpret(filter_data, filter_stack_data, NULL);
 }
 
+uint64_t lttng_bytecode_capture_interpret(void *capture_data,
+               const char *capture_stack_data,
+               struct lttng_interpreter_output *output)
+{
+       return bytecode_interpret(capture_data, capture_stack_data,
+                       (struct lttng_interpreter_output *) output);
+}
+
 #undef START_OP
 #undef OP
 #undef PO
This page took 0.024301 seconds and 4 git commands to generate.