From 86133cafe8f32497f53f4b469b8d3357470e7080 Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Tue, 26 May 2020 11:02:19 -0400 Subject: [PATCH] bytecode: handle all integer types of dynamic contexts Signed-off-by: Francis Deslauriers Signed-off-by: Mathieu Desnoyers Change-Id: I86d24abd87bc6ed3fb2fbe659bc2bab877017c08 --- include/lttng/ust-events.h | 1 + liblttng-ust/lttng-bytecode-interpreter.c | 13 +++++++++++++ tests/compile/test-app-ctx/hello.c | 8 ++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index 4e3163c4..5bd15838 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -315,6 +315,7 @@ struct lttng_ctx_value { enum lttng_ust_dynamic_type sel; union { int64_t s64; + uint64_t u64; const char *str; double d; } u; diff --git a/liblttng-ust/lttng-bytecode-interpreter.c b/liblttng-ust/lttng-bytecode-interpreter.c index 9a2aaa45..ea5eca19 100644 --- a/liblttng-ust/lttng-bytecode-interpreter.c +++ b/liblttng-ust/lttng-bytecode-interpreter.c @@ -345,12 +345,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; diff --git a/tests/compile/test-app-ctx/hello.c b/tests/compile/test-app-ctx/hello.c index e9e45ec7..ec512635 100644 --- a/tests/compile/test-app-ctx/hello.c +++ b/tests/compile/test-app-ctx/hello.c @@ -240,16 +240,16 @@ void test_get_value(struct lttng_ctx_field *field, value->u.s64 = -64; break; case LTTNG_UST_DYNAMIC_TYPE_U8: - value->u.s64 = 8; + value->u.u64 = 8; break; case LTTNG_UST_DYNAMIC_TYPE_U16: - value->u.s64 = 16; + value->u.u64 = 16; break; case LTTNG_UST_DYNAMIC_TYPE_U32: - value->u.s64 = 32; + value->u.u64 = 32; break; case LTTNG_UST_DYNAMIC_TYPE_U64: - value->u.s64 = 64; + value->u.u64 = 64; break; case LTTNG_UST_DYNAMIC_TYPE_FLOAT: value->u.d = 22322.0; -- 2.34.1