Commit | Line | Data |
---|---|---|
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 | */ | |
28 | #undef TRACEPOINT_PROVIDER | |
29 | #define TRACEPOINT_PROVIDER sample_component | |
30 | ||
31 | /* | |
32 | * include file (this files's name) | |
33 | */ | |
45f399e8 MD |
34 | #undef TRACEPOINT_INCLUDE |
35 | #define 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 | */ | |
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(...): | |
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 MD |
54 | */ |
55 | TRACEPOINT_EVENT( | |
56 | /* | |
57 | * provider name, not a variable but a string starting with a letter | |
a60af3a5 | 58 | * and containing either letters, numbers or underscores. |
4807c6de MD |
59 | * Needs to be the same as TRACEPOINT_PROVIDER |
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 | /* | |
a60af3a5 | 68 | * TP_ARGS macro contains the arguments passed for the tracepoint |
4807c6de MD |
69 | * it is in the following format |
70 | * 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) | |
4807c6de MD |
74 | * TP_ARGS() is valid to mean no arguments |
75 | * TP_ARGS( void ) is valid too | |
a60af3a5 | 76 | */ |
4807c6de MD |
77 | TP_ARGS(char *, text), |
78 | /* | |
a60af3a5 | 79 | * TP_FIELDS describes how to write the fields of the trace event. |
4807c6de MD |
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 | |
a60af3a5 FD |
85 | * named "message" |
86 | */ | |
4807c6de MD |
87 | ctf_string(message, text) |
88 | ) | |
89 | ) | |
90 | /* | |
a60af3a5 FD |
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. | |
4807c6de MD |
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 | /* | |
a60af3a5 | 99 | * The provider name, must be the same as the provider name in the |
4807c6de MD |
100 | * TRACEPOINT_EVENT and as TRACEPOINT_PROVIDER above. |
101 | */ | |
a60af3a5 FD |
102 | sample_component, |
103 | /* | |
104 | * The tracepoint name, must be the same as the tracepoint name in the | |
4807c6de MD |
105 | * TRACEPOINT_EVENT |
106 | */ | |
a60af3a5 | 107 | message, |
4807c6de MD |
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 | /* | |
a60af3a5 FD |
117 | * Add this after defining the tracepoint events to expand the macros. |
118 | */ | |
4807c6de | 119 | #include <lttng/tracepoint-event.h> |