Fix: remove # in front on extern "C" {
[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
16 /*
17 * Sample lttng-ust tracepoint provider.
18 */
19
20 /*
21 * First part: defines
22 * We undef a macro before defining it as it can be used in several files.
23 */
24
25 /*
26 * Must be included before include tracepoint provider
27 * ex.: project_event
28 * ex.: project_component_event
29 *
30 * Optional company name goes here
31 * ex.: com_efficios_project_component_event
32 *
33 * In this example, "sample" is the project, and "component" is the
34 * component.
35 */
36 #undef TRACEPOINT_PROVIDER
37 #define TRACEPOINT_PROVIDER sample_component
38
39 /*
40 * include file (this files's name)
41 */
42 #undef TRACEPOINT_INCLUDE_FILE
43 #define TRACEPOINT_INCLUDE_FILE ./sample_component_provider.h
44
45 /*
46 * Add this macro and its matching element to make sure the program
47 * works in c++.
48 */
49 #ifdef __cplusplus
50 extern "C" {
51 #endif /* __cplusplus */
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>
136
137 /*
138 * Add this macro and its matching element to make sure the program
139 * works in c++.
140 */
141 #ifdef __cplusplus
142 }
143 #endif /* __cplusplus */
This page took 0.031742 seconds and 4 git commands to generate.