Tracepoint API namespacing ctf_sequence
[lttng-ust.git] / doc / examples / easy-ust / sample_component_provider.h
CommitLineData
4807c6de 1/*
c0c0989a 2 * SPDX-License-Identifier: MIT
4807c6de 3 *
c0c0989a
MJ
4 * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 * Copyright (C) 2011-2012 Matthew Khouzam <matthew.khouzam@ericsson.com>
4807c6de 6 */
a60af3a5 7
4807c6de 8/*
a60af3a5 9 * Sample lttng-ust tracepoint provider.
4807c6de
MD
10 */
11
12/*
13 * First part: defines
14 * We undef a macro before defining it as it can be used in several files.
15 */
16
a60af3a5
FD
17/*
18 * Must be included before include tracepoint provider
4807c6de
MD
19 * ex.: project_event
20 * ex.: project_component_event
21 *
22 * Optional company name goes here
23 * ex.: com_efficios_project_component_event
24 *
25 * In this example, "sample" is the project, and "component" is the
26 * component.
27 */
5b393d64
MJ
28#undef LTTNG_UST_TRACEPOINT_PROVIDER
29#define LTTNG_UST_TRACEPOINT_PROVIDER sample_component
4807c6de
MD
30
31/*
32 * include file (this files's name)
33 */
bb71a8ea
MJ
34#undef LTTNG_UST_TRACEPOINT_INCLUDE
35#define LTTNG_UST_TRACEPOINT_INCLUDE "./sample_component_provider.h"
4807c6de 36
4807c6de
MD
37/*
38 * Add this precompiler conditionals to ensure the tracepoint event generation
39 * can include this file more than once.
40 */
c2c72dde 41#if !defined(_SAMPLE_COMPONENT_PROVIDER_H) || defined(LTTNG_UST_TRACEPOINT_HEADER_MULTI_READ)
4807c6de
MD
42#define _SAMPLE_COMPONENT_PROVIDER_H
43/*
44 * Add this to allow programs to call "tracepoint(...):
a60af3a5
FD
45 */
46#include <lttng/tracepoint.h>
4807c6de
MD
47
48/*
49 * The following tracepoint event writes a message (c string) into the
50 * field message of the trace event message in the provider
51 * sample_component in other words:
52 *
a60af3a5 53 * sample_component:message:message = text.
4807c6de 54 */
7f2f82c3 55LTTNG_UST_TRACEPOINT_EVENT(
4807c6de
MD
56 /*
57 * provider name, not a variable but a string starting with a letter
a60af3a5 58 * and containing either letters, numbers or underscores.
5b393d64 59 * Needs to be the same as LTTNG_UST_TRACEPOINT_PROVIDER
4807c6de
MD
60 */
61 sample_component,
62 /*
a60af3a5
FD
63 * tracepoint name, same format as sample provider. Does not need to be
64 * declared before. in this case the name is "message"
4807c6de
MD
65 */
66 message,
67 /*
cadfcbfc 68 * LTTNG_UST_TP_ARGS macro contains the arguments passed for the tracepoint
4807c6de 69 * it is in the following format
cadfcbfc 70 * LTTNG_UST_TP_ARGS( type1, name1, type2, name2, ... type10, name10)
a60af3a5
FD
71 * where there can be from zero to ten elements.
72 * typeN is the datatype, such as int, struct or double **.
73 * name is the variable name (in "int myInt" the name would be myint)
cadfcbfc
MJ
74 * LTTNG_UST_TP_ARGS() is valid to mean no arguments
75 * LTTNG_UST_TP_ARGS( void ) is valid too
a60af3a5 76 */
cadfcbfc 77 LTTNG_UST_TP_ARGS(const char *, text),
4807c6de 78 /*
efa14d16 79 * LTTNG_UST_TP_FIELDS describes how to write the fields of the trace event.
4807c6de
MD
80 * You can use the args here
81 */
efa14d16 82 LTTNG_UST_TP_FIELDS(
4807c6de
MD
83 /*
84 * The ctf_string macro takes a c string and writes it into a field
a60af3a5
FD
85 * named "message"
86 */
4807c6de
MD
87 ctf_string(message, text)
88 )
89)
90/*
612e9ce4
MJ
91 * Trace loglevel, shows the level of the trace event. It can be
92 * LTTNG_UST_TRACEPOINT_LOGLEVEL_EMERG, LTTNG_UST_TRACEPOINT_LOGLEVEL_ALERT,
93 * LTTNG_UST_TRACEPOINT_LOGLEVEL_CRIT, LTTNG_UST_TRACEPOINT_LOGLEVEL_ERR,
94 * LTTNG_UST_TRACEPOINT_LOGLEVEL_WARNING, LTTNG_UST_TRACEPOINT_LOGLEVEL_INFO or
95 * others. If this is not set, LTTNG_UST_TRACEPOINT_LOGLEVEL_DEFAULT is
96 * assumed. The first two arguments identify the tracepoint See details in
97 * <lttng/tracepoint.h> line 347
4807c6de 98 */
612e9ce4 99LTTNG_UST_TRACEPOINT_LOGLEVEL(
4807c6de 100 /*
a60af3a5 101 * The provider name, must be the same as the provider name in the
5b393d64 102 * LTTNG_UST_TRACEPOINT_EVENT and as LTTNG_UST_TRACEPOINT_PROVIDER above.
4807c6de 103 */
a60af3a5
FD
104 sample_component,
105 /*
106 * The tracepoint name, must be the same as the tracepoint name in the
7f2f82c3 107 * LTTNG_UST_TRACEPOINT_EVENT
4807c6de 108 */
a60af3a5 109 message,
4807c6de
MD
110 /*
111 * The tracepoint loglevel. Warning, some levels are abbreviated and
112 * others are not, please see <lttng/tracepoint.h>
113 */
612e9ce4 114 LTTNG_UST_TRACEPOINT_LOGLEVEL_WARNING)
4807c6de
MD
115
116#endif /* _SAMPLE_COMPONENT_PROVIDER_H */
117
118/*
a60af3a5
FD
119 * Add this after defining the tracepoint events to expand the macros.
120 */
4807c6de 121#include <lttng/tracepoint-event.h>
This page took 0.034524 seconds and 4 git commands to generate.