From 6841ae81a42627407787d3ebac0ff6e2111d53c6 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 20 Oct 2022 21:58:42 -0400 Subject: [PATCH] Introduce side_call* Signed-off-by: Mathieu Desnoyers --- include/side/trace.h | 13 +++++++++++-- src/Makefile | 7 +++++-- src/side.c | 31 +++++++++++++++++++++++++++++++ src/tracer.c | 4 ---- 4 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 src/side.c diff --git a/include/side/trace.h b/include/side/trace.h index 6a8ded7..77c6a25 100644 --- a/include/side/trace.h +++ b/include/side/trace.h @@ -243,6 +243,9 @@ enum side_event_flags { SIDE_EVENT_FLAG_VARIADIC = (1 << 0), }; +#define SIDE_EVENT_ENABLED_USER_MASK 0x0000FFFF +#define SIDE_EVENT_ENABLED_KERNEL_USER_EVENT_MASK 0x80000000 + struct side_event_description { uint32_t version; uint32_t enabled; @@ -799,7 +802,7 @@ struct side_tracer_dynamic_vla_visitor_ctx { .sav = side_sav, \ .len = SIDE_ARRAY_SIZE(side_sav), \ }; \ - tracer_call(desc, &sav_desc); \ + side_call(desc, &sav_desc); \ } #define side_event(desc, sav) \ @@ -818,7 +821,7 @@ struct side_tracer_dynamic_vla_visitor_ctx { .fields = side_fields, \ .len = SIDE_ARRAY_SIZE(side_fields), \ }; \ - tracer_call_variadic(desc, &sav_desc, &var_struct); \ + side_call_variadic(desc, &sav_desc, &var_struct); \ } #define side_event_variadic(desc, sav, var) \ @@ -873,4 +876,10 @@ struct side_tracer_dynamic_vla_visitor_ctx { #define side_declare_event(_identifier) \ struct side_event_description _identifier +void side_call(const struct side_event_description *desc, + const struct side_arg_vec_description *sav_desc); +void side_call_variadic(const struct side_event_description *desc, + const struct side_arg_vec_description *sav_desc, + const struct side_arg_dynamic_event_struct *var_struct); + #endif /* _SIDE_TRACE_H */ diff --git a/src/Makefile b/src/Makefile index 5056c13..5201974 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,13 +1,16 @@ all: test +side.o: side.c + gcc -O2 -g -Wall -I../include/ -c -o side.o side.c + tracer.o: tracer.c gcc -O2 -g -Wall -I../include/ -c -o tracer.o tracer.c test.o: test.c gcc -O2 -g -Wall -I../include/ -c -o test.o test.c -test: tracer.o test.o - gcc -O2 -g -Wall -o test tracer.o test.o +test: tracer.o test.o side.o + gcc -O2 -g -Wall -o test tracer.o test.o side.o .PHONY: clean diff --git a/src/side.c b/src/side.c new file mode 100644 index 0000000..6b67beb --- /dev/null +++ b/src/side.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright 2022 Mathieu Desnoyers + */ + +#include +#include "tracer.h" + +void side_call(const struct side_event_description *desc, const struct side_arg_vec_description *sav_desc) +{ + if (side_unlikely(desc->flags & SIDE_EVENT_FLAG_VARIADIC)) { + printf("ERROR: unexpected variadic event description\n"); + abort(); + } + if (side_unlikely(desc->enabled & SIDE_EVENT_ENABLED_KERNEL_USER_EVENT_MASK)) { + // TODO: call kernel ioctl. + } + //TODO: replace tracer_call by rcu iteration on list of registered callbacks + tracer_call(desc, sav_desc); +} + +void side_call_variadic(const struct side_event_description *desc, + const struct side_arg_vec_description *sav_desc, + const struct side_arg_dynamic_event_struct *var_struct) +{ + if (side_unlikely(desc->enabled & SIDE_EVENT_ENABLED_KERNEL_USER_EVENT_MASK)) { + // TODO: call kernel ioctl. + } + //TODO: replace tracer_call by rcu iteration on list of registered callbacks + tracer_call_variadic(desc, sav_desc, var_struct); +} diff --git a/src/tracer.c b/src/tracer.c index 3bd7dfc..24d6189 100644 --- a/src/tracer.c +++ b/src/tracer.c @@ -893,10 +893,6 @@ void tracer_call(const struct side_event_description *desc, const struct side_ar { int nr_fields = 0; - if (side_unlikely(desc->flags & SIDE_EVENT_FLAG_VARIADIC)) { - printf("ERROR: unexpected variadic event description\n"); - abort(); - } tracer_print_static_fields(desc, sav_desc, &nr_fields); if (nr_fields) printf(" ]"); -- 2.34.1