tracepoint: Add LTTng tracepoint generation

Change-Id: I6358f3ab5f464f1a553814c58b22245ef64f0b52
This commit is contained in:
Olivier Dion
2021-12-10 12:51:23 -05:00
committed by Adrien Béraud
parent 983ae44f9e
commit e8b9309c5d
4 changed files with 94 additions and 0 deletions

View File

@ -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

26
src/jami/tracepoint-def.h Normal file
View File

@ -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

3
src/jami/tracepoint.c Normal file
View File

@ -0,0 +1,3 @@
#define LTTNG_UST_TRACEPOINT_CREATE_PROBES
#define LTTNG_UST_TRACEPOINT_DEFINE
#include "./tracepoint.h"

60
src/jami/tracepoint.h Normal file
View File

@ -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