16c1ee3c0bbf3b2ddf9264a797556c314b79264d
[lttng-ust.git] / doc / examples / easy-ust / sample_component_provider.h
1 /*
2 * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 * Copyright (C) 2011-2012 Matthew Khouzam <matthew.khouzam@ericsson.com>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24 /*
25 * Sample lttng-ust tracepoint provider.
26 */
27
28 /*
29 * First part: defines
30 * We undef a macro before defining it as it can be used in several files.
31 */
32
33 /*
34 * Must be included before include tracepoint provider
35 * ex.: project_event
36 * ex.: project_component_event
37 *
38 * Optional company name goes here
39 * ex.: com_efficios_project_component_event
40 *
41 * In this example, "sample" is the project, and "component" is the
42 * component.
43 */
44 #undef TRACEPOINT_PROVIDER
45 #define TRACEPOINT_PROVIDER sample_component
46
47 /*
48 * include file (this files's name)
49 */
50 #undef TRACEPOINT_INCLUDE
51 #define TRACEPOINT_INCLUDE "./sample_component_provider.h"
52
53 /*
54 * Add this precompiler conditionals to ensure the tracepoint event generation
55 * can include this file more than once.
56 */
57 #if !defined(_SAMPLE_COMPONENT_PROVIDER_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
58 #define _SAMPLE_COMPONENT_PROVIDER_H
59 /*
60 * Add this to allow programs to call "tracepoint(...):
61 */
62 #include <lttng/tracepoint.h>
63
64 /*
65 * The following tracepoint event writes a message (c string) into the
66 * field message of the trace event message in the provider
67 * sample_component in other words:
68 *
69 * sample_component:message:message = text.
70 */
71 TRACEPOINT_EVENT(
72 /*
73 * provider name, not a variable but a string starting with a letter
74 * and containing either letters, numbers or underscores.
75 * Needs to be the same as TRACEPOINT_PROVIDER
76 */
77 sample_component,
78 /*
79 * tracepoint name, same format as sample provider. Does not need to be
80 * declared before. in this case the name is "message"
81 */
82 message,
83 /*
84 * TP_ARGS macro contains the arguments passed for the tracepoint
85 * it is in the following format
86 * TP_ARGS( type1, name1, type2, name2, ... type10, name10)
87 * where there can be from zero to ten elements.
88 * typeN is the datatype, such as int, struct or double **.
89 * name is the variable name (in "int myInt" the name would be myint)
90 * TP_ARGS() is valid to mean no arguments
91 * TP_ARGS( void ) is valid too
92 */
93 TP_ARGS(char *, text),
94 /*
95 * TP_FIELDS describes how to write the fields of the trace event.
96 * You can use the args here
97 */
98 TP_FIELDS(
99 /*
100 * The ctf_string macro takes a c string and writes it into a field
101 * named "message"
102 */
103 ctf_string(message, text)
104 )
105 )
106 /*
107 * Trace loglevel, shows the level of the trace event. It can be TRACE_EMERG,
108 * TRACE_ALERT, TRACE_CRIT, TRACE_ERR, TRACE_WARNING, TRACE_INFO or others.
109 * If this is not set, TRACE_DEFAULT is assumed.
110 * The first two arguments identify the tracepoint
111 * See details in <lttng/tracepoint.h> line 347
112 */
113 TRACEPOINT_LOGLEVEL(
114 /*
115 * The provider name, must be the same as the provider name in the
116 * TRACEPOINT_EVENT and as TRACEPOINT_PROVIDER above.
117 */
118 sample_component,
119 /*
120 * The tracepoint name, must be the same as the tracepoint name in the
121 * TRACEPOINT_EVENT
122 */
123 message,
124 /*
125 * The tracepoint loglevel. Warning, some levels are abbreviated and
126 * others are not, please see <lttng/tracepoint.h>
127 */
128 TRACE_WARNING)
129
130 #endif /* _SAMPLE_COMPONENT_PROVIDER_H */
131
132 /*
133 * Add this after defining the tracepoint events to expand the macros.
134 */
135 #include <lttng/tracepoint-event.h>
This page took 0.0313 seconds and 3 git commands to generate.