Move to kernel style SPDX license identifiers
[lttng-ust.git] / doc / examples / easy-ust / sample_component_provider.h
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 * Copyright (C) 2011-2012 Matthew Khouzam <matthew.khouzam@ericsson.com>
6 */
7
8 /*
9 * Sample lttng-ust tracepoint provider.
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
17 /*
18 * Must be included before include tracepoint provider
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 */
28 #undef TRACEPOINT_PROVIDER
29 #define TRACEPOINT_PROVIDER sample_component
30
31 /*
32 * include file (this files's name)
33 */
34 #undef TRACEPOINT_INCLUDE
35 #define TRACEPOINT_INCLUDE "./sample_component_provider.h"
36
37 /*
38 * Add this precompiler conditionals to ensure the tracepoint event generation
39 * can include this file more than once.
40 */
41 #if !defined(_SAMPLE_COMPONENT_PROVIDER_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
42 #define _SAMPLE_COMPONENT_PROVIDER_H
43 /*
44 * Add this to allow programs to call "tracepoint(...):
45 */
46 #include <lttng/tracepoint.h>
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 *
53 * sample_component:message:message = text.
54 */
55 TRACEPOINT_EVENT(
56 /*
57 * provider name, not a variable but a string starting with a letter
58 * and containing either letters, numbers or underscores.
59 * Needs to be the same as TRACEPOINT_PROVIDER
60 */
61 sample_component,
62 /*
63 * tracepoint name, same format as sample provider. Does not need to be
64 * declared before. in this case the name is "message"
65 */
66 message,
67 /*
68 * TP_ARGS macro contains the arguments passed for the tracepoint
69 * it is in the following format
70 * TP_ARGS( type1, name1, type2, name2, ... type10, name10)
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)
74 * TP_ARGS() is valid to mean no arguments
75 * TP_ARGS( void ) is valid too
76 */
77 TP_ARGS(char *, text),
78 /*
79 * TP_FIELDS describes how to write the fields of the trace event.
80 * You can use the args here
81 */
82 TP_FIELDS(
83 /*
84 * The ctf_string macro takes a c string and writes it into a field
85 * named "message"
86 */
87 ctf_string(message, text)
88 )
89 )
90 /*
91 * Trace loglevel, shows the level of the trace event. It can be TRACE_EMERG,
92 * TRACE_ALERT, TRACE_CRIT, TRACE_ERR, TRACE_WARNING, TRACE_INFO or others.
93 * If this is not set, TRACE_DEFAULT is assumed.
94 * The first two arguments identify the tracepoint
95 * See details in <lttng/tracepoint.h> line 347
96 */
97 TRACEPOINT_LOGLEVEL(
98 /*
99 * The provider name, must be the same as the provider name in the
100 * TRACEPOINT_EVENT and as TRACEPOINT_PROVIDER above.
101 */
102 sample_component,
103 /*
104 * The tracepoint name, must be the same as the tracepoint name in the
105 * TRACEPOINT_EVENT
106 */
107 message,
108 /*
109 * The tracepoint loglevel. Warning, some levels are abbreviated and
110 * others are not, please see <lttng/tracepoint.h>
111 */
112 TRACE_WARNING)
113
114 #endif /* _SAMPLE_COMPONENT_PROVIDER_H */
115
116 /*
117 * Add this after defining the tracepoint events to expand the macros.
118 */
119 #include <lttng/tracepoint-event.h>
This page took 0.031493 seconds and 4 git commands to generate.