diff --git a/src/Makefile.am b/src/Makefile.am index b83726a94ffb1bf79dcef6bfe033a7aa11332b8c..64195d16368e3b2324f6bd78d7f1e3bb24032d79 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -161,3 +161,8 @@ if ENABLE_VIDEO nobase_include_HEADERS += \ ./jami/videomanager_interface.h endif + +if ENABLE_TRACEPOINTS +libring_la_SOURCES += jami/tracepoint.h jami/tracepoint-def.h jami/tracepoint.c +libring_la_LIBADD += $(LTTNG_LIBS) +endif diff --git a/src/jami/tracepoint-def.h b/src/jami/tracepoint-def.h new file mode 100644 index 0000000000000000000000000000000000000000..47ac84aa3543ee98565c39c7d3930acad29c04b0 --- /dev/null +++ b/src/jami/tracepoint-def.h @@ -0,0 +1,26 @@ +#include "config.h" + +#ifdef ENABLE_TRACEPOINTS + +#undef LTTNG_UST_TRACEPOINT_PROVIDER +#define LTTNG_UST_TRACEPOINT_PROVIDER jami + +#undef LTTNG_UST_TRACEPOINT_INCLUDE +#define LTTNG_UST_TRACEPOINT_INCLUDE "src/jami/tracepoint-def.h" + +#if !defined(TRACEPOINT_DEF_H) || defined(LTTNG_UST_TRACEPOINT_HEADER_MULTI_READ) +#define TRACEPOINT_DEF_H + +#include <lttng/tracepoint.h> + +/* + * Use LTTNG_UST_TRACEPOINT_EVENT(), LTTNG_UST_TRACEPOINT_EVENT_CLASS(), + * LTTNG_UST_TRACEPOINT_EVENT_INSTANCE(), and LTTNG_UST_TRACEPOINT_LOGLEVEL() + * here. + */ + +#endif /* TRACEPOINT_H */ + +#include <lttng/tracepoint-event.h> + +#endif diff --git a/src/jami/tracepoint.c b/src/jami/tracepoint.c new file mode 100644 index 0000000000000000000000000000000000000000..392fb0e92a1b92f6f66b93a52ea00591da3e5459 --- /dev/null +++ b/src/jami/tracepoint.c @@ -0,0 +1,3 @@ +#define LTTNG_UST_TRACEPOINT_CREATE_PROBES +#define LTTNG_UST_TRACEPOINT_DEFINE +#include "./tracepoint.h" diff --git a/src/jami/tracepoint.h b/src/jami/tracepoint.h new file mode 100644 index 0000000000000000000000000000000000000000..266ecb55fd66e71cb995241661a8e2e9a6d2a307 --- /dev/null +++ b/src/jami/tracepoint.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2022 Savoir-faire Linux Inc. + * + * Author: Olivier Dion <olivier.dion@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#pragma once +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#include "tracepoint-def.h" +#pragma GCC diagnostic pop + +#ifdef ENABLE_TRACEPOINTS + +# ifndef lttng_ust_tracepoint +# define lttng_ust_tracepoint(...) tracepoint(__VA_ARGS__) +# endif + +# ifndef lttng_ust_do_tracepoint +# define lttng_ust_do_tracepoint(...) do_tracepoint(__VA_ARGS__) +# endif + +# ifndef lttng_ust_tracepoint_enabled +# define lttng_ust_tracepoint_enabled(...) tracepoint_enabled(__VA_ARGS__) +# endif + +# define jami_tracepoint(tp_name, ...) \ + lttng_ust_tracepoint(jami, tp_name __VA_OPT__(,) __VA_ARGS__) + +# define jami_tracepoint_if_enabled(tp_name, ...) \ + do { \ + if (lttng_ust_tracepoint_enabled(jami, tp_name)) { \ + lttng_ust_do_tracepoint(jami, \ + tp_name \ + __VA_OPT__(,) \ + __VA_ARGS__); \ + } \ + } \ + while (0) + +#else + +# define jami_tracepoint(...) static_assert(true) +# define jami_tracepoint_if_enabled(...) static_assert(true) + +#endif