Commit | Line | Data |
---|---|---|
4807c6de MD |
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 | * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED | |
6 | * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. | |
7 | * | |
8 | * Permission is hereby granted to use or copy this program for any | |
9 | * purpose, provided the above notices are retained on all copies. | |
10 | * Permission to modify the code and to distribute modified code is | |
11 | * granted, provided the above notices are retained, and a notice that | |
12 | * the code was modified is included with the above copyright notice. | |
13 | */ | |
14 | ||
15 | /* | |
16 | * Sample lttng-ust tracepoint provider. | |
17 | */ | |
18 | ||
19 | /* | |
20 | * First part: defines | |
21 | * We undef a macro before defining it as it can be used in several files. | |
22 | */ | |
23 | ||
24 | /* | |
25 | * Must be included before include tracepoint provider | |
26 | * ex.: project_event | |
27 | * ex.: project_component_event | |
28 | * | |
29 | * Optional company name goes here | |
30 | * ex.: com_efficios_project_component_event | |
31 | * | |
32 | * In this example, "sample" is the project, and "component" is the | |
33 | * component. | |
34 | */ | |
35 | #undef TRACEPOINT_PROVIDER | |
36 | #define TRACEPOINT_PROVIDER sample_component | |
37 | ||
38 | /* | |
39 | * include file (this files's name) | |
40 | */ | |
41 | #undef TRACEPOINT_INCLUDE_FILE | |
42 | #define TRACEPOINT_INCLUDE_FILE ./sample_component_provider.h | |
43 | ||
44 | /* | |
45 | * Add this macro and its matching element to make sure the program | |
46 | * works in c++. | |
47 | */ | |
48 | #ifdef __cplusplus | |
49 | #extern "C"{ | |
50 | #endif /*__cplusplus */ | |
51 | ||
52 | /* | |
53 | * Add this precompiler conditionals to ensure the tracepoint event generation | |
54 | * can include this file more than once. | |
55 | */ | |
56 | #if !defined(_SAMPLE_COMPONENT_PROVIDER_H) || defined(TRACEPOINT_HEADER_MULTI_READ) | |
57 | #define _SAMPLE_COMPONENT_PROVIDER_H | |
58 | /* | |
59 | * Add this to allow programs to call "tracepoint(...): | |
60 | */ | |
61 | #include <lttng/tracepoint.h> | |
62 | ||
63 | /* | |
64 | * The following tracepoint event writes a message (c string) into the | |
65 | * field message of the trace event message in the provider | |
66 | * sample_component in other words: | |
67 | * | |
68 | * sample_component:message:message = text. | |
69 | */ | |
70 | TRACEPOINT_EVENT( | |
71 | /* | |
72 | * provider name, not a variable but a string starting with a letter | |
73 | * and containing either letters, numbers or underscores. | |
74 | * Needs to be the same as TRACEPOINT_PROVIDER | |
75 | */ | |
76 | sample_component, | |
77 | /* | |
78 | * tracepoint name, same format as sample provider. Does not need to be | |
79 | * declared before. in this case the name is "message" | |
80 | */ | |
81 | message, | |
82 | /* | |
83 | * TP_ARGS macro contains the arguments passed for the tracepoint | |
84 | * it is in the following format | |
85 | * TP_ARGS( type1, name1, type2, name2, ... type10, name10) | |
86 | * where there can be from zero to ten elements. | |
87 | * typeN is the datatype, such as int, struct or double **. | |
88 | * name is the variable name (in "int myInt" the name would be myint) | |
89 | * TP_ARGS() is valid to mean no arguments | |
90 | * TP_ARGS( void ) is valid too | |
91 | */ | |
92 | TP_ARGS(char *, text), | |
93 | /* | |
94 | * TP_FIELDS describes how to write the fields of the trace event. | |
95 | * You can use the args here | |
96 | */ | |
97 | TP_FIELDS( | |
98 | /* | |
99 | * The ctf_string macro takes a c string and writes it into a field | |
100 | * named "message" | |
101 | */ | |
102 | ctf_string(message, text) | |
103 | ) | |
104 | ) | |
105 | /* | |
106 | * Trace loglevel, shows the level of the trace event. It can be TRACE_EMERG, | |
107 | * TRACE_ALERT, TRACE_CRIT, TRACE_ERR, TRACE_WARNING, TRACE_INFO or others. | |
108 | * If this is not set, TRACE_DEFAULT is assumed. | |
109 | * The first two arguments identify the tracepoint | |
110 | * See details in <lttng/tracepoint.h> line 347 | |
111 | */ | |
112 | TRACEPOINT_LOGLEVEL( | |
113 | /* | |
114 | * The provider name, must be the same as the provider name in the | |
115 | * TRACEPOINT_EVENT and as TRACEPOINT_PROVIDER above. | |
116 | */ | |
117 | sample_component, | |
118 | /* | |
119 | * The tracepoint name, must be the same as the tracepoint name in the | |
120 | * TRACEPOINT_EVENT | |
121 | */ | |
122 | message, | |
123 | /* | |
124 | * The tracepoint loglevel. Warning, some levels are abbreviated and | |
125 | * others are not, please see <lttng/tracepoint.h> | |
126 | */ | |
127 | TRACE_WARNING) | |
128 | ||
129 | #endif /* _SAMPLE_COMPONENT_PROVIDER_H */ | |
130 | ||
131 | /* | |
132 | * Add this after defining the tracepoint events to expand the macros. | |
133 | */ | |
134 | #include <lttng/tracepoint-event.h> | |
135 | ||
136 | /* | |
137 | * Add this macro and its matching element to make sure the program | |
138 | * works in c++. | |
139 | */ | |
140 | #ifdef __cplusplus | |
141 | } | |
142 | #endif /*__cplusplus */ |