Commit | Line | Data |
---|---|---|
36907cb5 DS |
1 | %define DOCSTRING |
2 | "LTTNG_VERSION_STR | |
3 | ||
4 | The LTTng project aims at providing highly efficient tracing tools for Linux. | |
5 | It's tracers help tracking down performance issues and debugging problems involving | |
6 | multiple concurrent processes and threads. Tracing across multiple systems is also possible." | |
7 | %enddef | |
8 | ||
9 | %module(docstring=DOCSTRING) lttng | |
10 | ||
11 | %include "typemaps.i" | |
bc3bdada | 12 | %include "stdint.i" |
36907cb5 DS |
13 | %include "pyabc.i" |
14 | %{ | |
15 | #define SWIG_FILE_WITH_INIT | |
16 | #include <lttng/lttng.h> | |
17 | %} | |
18 | ||
6c7ee73e JG |
19 | %{ |
20 | #if PY_MAJOR_VERSION >= 3 | |
21 | // The PyInt and PyLong types were unified as of Python 3 | |
22 | // This makes the typemap code useable with both Python 2 and 3. | |
23 | #define PyInt_AsSsize_t PyLong_AsSsize_t | |
24 | #endif | |
25 | %} | |
26 | ||
36907cb5 DS |
27 | typedef unsigned int uint32_t; |
28 | typedef int int32_t; | |
29 | typedef unsigned long long uint64_t; | |
30 | typedef long pid_t; | |
31 | ||
32 | ||
33 | // ============================================= | |
34 | // ENUMS | |
35 | // These are directly taken from lttng.h. | |
36 | // Any change to these enums must also be | |
37 | // made here. | |
38 | // ============================================= | |
39 | ||
40 | %rename("DOMAIN_KERNEL") LTTNG_DOMAIN_KERNEL; | |
41 | %rename("DOMAIN_UST") LTTNG_DOMAIN_UST; | |
42 | enum lttng_domain_type { | |
43 | LTTNG_DOMAIN_KERNEL = 1, | |
44 | LTTNG_DOMAIN_UST = 2, | |
45 | }; | |
46 | ||
dd5f427a JR |
47 | %rename("BUFFER_PER_PID") LTTNG_BUFFER_PER_PID; |
48 | %rename("BUFFER_PER_UID") LTTNG_BUFFER_PER_UID; | |
49 | %rename("BUFFER_GLOBAL") LTTNG_BUFFER_GLOBAL; | |
50 | enum lttng_buffer_type { | |
51 | LTTNG_BUFFER_PER_PID, | |
52 | LTTNG_BUFFER_PER_UID, | |
53 | LTTNG_BUFFER_GLOBAL, | |
54 | }; | |
55 | ||
36907cb5 DS |
56 | %rename("EVENT_ALL") LTTNG_EVENT_ALL; |
57 | %rename("EVENT_TRACEPOINT") LTTNG_EVENT_TRACEPOINT; | |
58 | %rename("EVENT_PROBE") LTTNG_EVENT_PROBE; | |
59 | %rename("EVENT_FUNCTION")LTTNG_EVENT_FUNCTION; | |
60 | %rename("EVENT_FUNCTION_ENTRY") LTTNG_EVENT_FUNCTION_ENTRY; | |
61 | %rename("EVENT_NOOP") LTTNG_EVENT_NOOP; | |
62 | %rename("EVENT_SYSCALL") LTTNG_EVENT_SYSCALL; | |
63 | enum lttng_event_type { | |
64 | LTTNG_EVENT_ALL = -1, | |
65 | LTTNG_EVENT_TRACEPOINT = 0, | |
66 | LTTNG_EVENT_PROBE = 1, | |
67 | LTTNG_EVENT_FUNCTION = 2, | |
68 | LTTNG_EVENT_FUNCTION_ENTRY = 3, | |
69 | LTTNG_EVENT_NOOP = 4, | |
70 | LTTNG_EVENT_SYSCALL = 5, | |
71 | }; | |
72 | ||
73 | %rename("EVENT_LOGLEVEL_ALL") LTTNG_EVENT_LOGLEVEL_ALL; | |
74 | %rename("EVENT_LOGLEVEL_RANGE") LTTNG_EVENT_LOGLEVEL_RANGE; | |
75 | %rename("EVENT_LOGLEVEL_SINGLE") LTTNG_EVENT_LOGLEVEL_SINGLE; | |
76 | enum lttng_loglevel_type { | |
77 | LTTNG_EVENT_LOGLEVEL_ALL = 0, | |
78 | LTTNG_EVENT_LOGLEVEL_RANGE = 1, | |
79 | LTTNG_EVENT_LOGLEVEL_SINGLE = 2, | |
80 | }; | |
81 | ||
82 | %rename("LOGLEVEL_EMERG") LTTNG_LOGLEVEL_EMERG; | |
83 | %rename("LOGLEVEL_ALERT") LTTNG_LOGLEVEL_ALERT; | |
84 | %rename("LOGLEVEL_CRIT") LTTNG_LOGLEVEL_CRIT; | |
85 | %rename("LOGLEVEL_ERR") LTTNG_LOGLEVEL_ERR; | |
86 | %rename("LOGLEVEL_WARNING") LTTNG_LOGLEVEL_WARNING; | |
87 | %rename("LOGLEVEL_NOTICE") LTTNG_LOGLEVEL_NOTICE; | |
88 | %rename("LOGLEVEL_INFO") LTTNG_LOGLEVEL_INFO; | |
89 | %rename("LOGLEVEL_DEBUG_SYSTEM") LTTNG_LOGLEVEL_DEBUG_SYSTEM; | |
90 | %rename("LOGLEVEL_DEBUG_PROGRAM") LTTNG_LOGLEVEL_DEBUG_PROGRAM; | |
91 | %rename("LOGLEVEL_DEBUG_PROCESS") LTTNG_LOGLEVEL_DEBUG_PROCESS; | |
92 | %rename("LOGLEVEL_DEBUG_MODULE") LTTNG_LOGLEVEL_DEBUG_MODULE; | |
93 | %rename("LOGLEVEL_DEBUG_UNIT") LTTNG_LOGLEVEL_DEBUG_UNIT; | |
94 | %rename("LOGLEVEL_DEBUG_FUNCTION") LTTNG_LOGLEVEL_DEBUG_FUNCTION; | |
95 | %rename("LOGLEVEL_DEBUG_LINE") LTTNG_LOGLEVEL_DEBUG_LINE; | |
96 | %rename("LOGLEVEL_DEBUG") LTTNG_LOGLEVEL_DEBUG; | |
97 | enum lttng_loglevel { | |
98 | LTTNG_LOGLEVEL_EMERG = 0, | |
99 | LTTNG_LOGLEVEL_ALERT = 1, | |
100 | LTTNG_LOGLEVEL_CRIT = 2, | |
101 | LTTNG_LOGLEVEL_ERR = 3, | |
102 | LTTNG_LOGLEVEL_WARNING = 4, | |
103 | LTTNG_LOGLEVEL_NOTICE = 5, | |
104 | LTTNG_LOGLEVEL_INFO = 6, | |
105 | LTTNG_LOGLEVEL_DEBUG_SYSTEM = 7, | |
106 | LTTNG_LOGLEVEL_DEBUG_PROGRAM = 8, | |
107 | LTTNG_LOGLEVEL_DEBUG_PROCESS = 9, | |
108 | LTTNG_LOGLEVEL_DEBUG_MODULE = 10, | |
109 | LTTNG_LOGLEVEL_DEBUG_UNIT = 11, | |
110 | LTTNG_LOGLEVEL_DEBUG_FUNCTION = 12, | |
111 | LTTNG_LOGLEVEL_DEBUG_LINE = 13, | |
112 | LTTNG_LOGLEVEL_DEBUG = 14, | |
113 | }; | |
114 | ||
115 | %rename("EVENT_SPLICE") LTTNG_EVENT_SPLICE; | |
116 | %rename("EVENT_MMAP") LTTNG_EVENT_MMAP; | |
117 | enum lttng_event_output { | |
118 | LTTNG_EVENT_SPLICE = 0, | |
119 | LTTNG_EVENT_MMAP = 1, | |
120 | }; | |
121 | ||
122 | %rename("EVENT_CONTEXT_PID") LTTNG_EVENT_CONTEXT_PID; | |
123 | %rename("EVENT_CONTEXT_PERF_COUNTER") LTTNG_EVENT_CONTEXT_PERF_COUNTER; | |
124 | %rename("EVENT_CONTEXT_PROCNAME") LTTNG_EVENT_CONTEXT_PROCNAME; | |
125 | %rename("EVENT_CONTEXT_PRIO") LTTNG_EVENT_CONTEXT_PRIO; | |
126 | %rename("EVENT_CONTEXT_NICE") LTTNG_EVENT_CONTEXT_NICE; | |
127 | %rename("EVENT_CONTEXT_VPID") LTTNG_EVENT_CONTEXT_VPID; | |
128 | %rename("EVENT_CONTEXT_TID") LTTNG_EVENT_CONTEXT_TID; | |
129 | %rename("EVENT_CONTEXT_VTID") LTTNG_EVENT_CONTEXT_VTID; | |
130 | %rename("EVENT_CONTEXT_PPID") LTTNG_EVENT_CONTEXT_PPID; | |
131 | %rename("EVENT_CONTEXT_VPPID") LTTNG_EVENT_CONTEXT_VPPID; | |
132 | %rename("EVENT_CONTEXT_PTHREAD_ID") LTTNG_EVENT_CONTEXT_PTHREAD_ID; | |
a593ba5a CB |
133 | %rename("EVENT_CONTEXT_HOSTNAME") LTTNG_EVENT_CONTEXT_HOSTNAME; |
134 | %rename("EVENT_CONTEXT_IP") LTTNG_EVENT_CONTEXT_IP; | |
135 | %rename("EVENT_CONTEXT_PERF_CPU_COUNTER") LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER; | |
136 | %rename("EVENT_CONTEXT_PERF_THREAD_COUNTER") LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER; | |
137 | %rename("EVENT_CONTEXT_APP_CONTEXT") LTTNG_EVENT_CONTEXT_APP_CONTEXT; | |
138 | %rename("EVENT_CONTEXT_INTERRUPTIBLE") LTTNG_EVENT_CONTEXT_INTERRUPTIBLE; | |
139 | %rename("EVENT_CONTEXT_PREEMPTIBLE") LTTNG_EVENT_CONTEXT_PREEMPTIBLE; | |
140 | %rename("EVENT_CONTEXT_NEED_RESCHEDULE") LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE; | |
141 | %rename("EVENT_CONTEXT_MIGRATABLE") LTTNG_EVENT_CONTEXT_MIGRATABLE; | |
36907cb5 DS |
142 | enum lttng_event_context_type { |
143 | LTTNG_EVENT_CONTEXT_PID = 0, | |
144 | LTTNG_EVENT_CONTEXT_PERF_COUNTER = 1, | |
145 | LTTNG_EVENT_CONTEXT_PROCNAME = 2, | |
146 | LTTNG_EVENT_CONTEXT_PRIO = 3, | |
147 | LTTNG_EVENT_CONTEXT_NICE = 4, | |
148 | LTTNG_EVENT_CONTEXT_VPID = 5, | |
149 | LTTNG_EVENT_CONTEXT_TID = 6, | |
150 | LTTNG_EVENT_CONTEXT_VTID = 7, | |
151 | LTTNG_EVENT_CONTEXT_PPID = 8, | |
152 | LTTNG_EVENT_CONTEXT_VPPID = 9, | |
153 | LTTNG_EVENT_CONTEXT_PTHREAD_ID = 10, | |
a593ba5a CB |
154 | LTTNG_EVENT_CONTEXT_HOSTNAME = 11, |
155 | LTTNG_EVENT_CONTEXT_IP = 12, | |
156 | LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER = 13, | |
157 | LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER = 14, | |
158 | LTTNG_EVENT_CONTEXT_APP_CONTEXT = 15, | |
159 | LTTNG_EVENT_CONTEXT_INTERRUPTIBLE = 16, | |
160 | LTTNG_EVENT_CONTEXT_PREEMPTIBLE = 17, | |
161 | LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE = 18, | |
162 | LTTNG_EVENT_CONTEXT_MIGRATABLE = 19, | |
36907cb5 DS |
163 | }; |
164 | ||
36907cb5 DS |
165 | |
166 | ||
167 | ||
168 | // ============================================= | |
169 | // TYPEMAPS | |
170 | // ============================================= | |
171 | ||
172 | //list_sessions | |
173 | %typemap(argout) struct lttng_session **sessions{ | |
174 | ||
175 | int l = PyInt_AsSsize_t($result); | |
176 | if (l >= 0) | |
177 | { | |
178 | PyObject *sessions = PyList_New(0); | |
179 | int i; | |
180 | for(i=0; i<l; i++) | |
181 | { | |
182 | PyObject *tmp = PyTuple_New(4); | |
183 | PyObject *name = PyString_FromString((*$1)[i].name); | |
184 | PyObject *path = PyString_FromString((*$1)[i].path); | |
185 | PyObject *enabled = PyInt_FromSize_t((*$1)[i].enabled); | |
36907cb5 DS |
186 | |
187 | PyTuple_SetItem(tmp, 0, name); | |
188 | PyTuple_SetItem(tmp, 1, path); | |
189 | PyTuple_SetItem(tmp, 2, enabled); | |
36907cb5 DS |
190 | PyList_Append(sessions, tmp); |
191 | } | |
192 | $result = sessions; | |
193 | } | |
194 | } | |
195 | %typemap(in,numinputs=0) struct lttng_session **sessions (struct lttng_session *temp){ | |
196 | $1=&temp; | |
197 | } | |
198 | ||
199 | //list_domains | |
200 | %typemap(argout) struct lttng_domain **domains{ | |
201 | ||
202 | int l = PyInt_AsSsize_t($result); | |
203 | if (l >= 0) | |
204 | { | |
205 | PyObject *dom = PyList_New(0); | |
206 | int i; | |
207 | for(i=0; i<l; i++) | |
208 | { | |
dd5f427a | 209 | PyObject *tmp = PyTuple_New(6); |
36907cb5 | 210 | PyObject *type = PyInt_FromSize_t((*$1)[i].type); |
dd5f427a | 211 | PyObject *buf_type = PyInt_FromSize_t((*$1)[i].buf_type); |
36907cb5 DS |
212 | PyObject *execname = PyString_FromString((*$1)[i].attr.exec_name); |
213 | PyObject *pid = PyInt_FromSize_t((*$1)[i].attr.pid); | |
214 | PyObject *padding = PyString_FromString((*$1)[i].padding); | |
215 | PyObject *attrpadding = PyString_FromString((*$1)[i].attr.padding); | |
216 | ||
217 | PyTuple_SetItem(tmp, 0, type); | |
dd5f427a JR |
218 | PyTuple_SetItem(tmp, 1, buf_type); |
219 | PyTuple_SetItem(tmp, 2, padding); | |
220 | PyTuple_SetItem(tmp, 3, pid); | |
221 | PyTuple_SetItem(tmp, 4, execname); | |
222 | PyTuple_SetItem(tmp, 5, attrpadding); | |
36907cb5 DS |
223 | PyList_Append(dom, tmp); |
224 | } | |
225 | $result = dom; | |
226 | } | |
227 | } | |
228 | %typemap(in,numinputs=0) struct lttng_domain **domains (struct lttng_domain *temp){ | |
229 | $1=&temp; | |
230 | } | |
231 | ||
232 | //list_channels | |
233 | %typemap(argout) struct lttng_channel **channels{ | |
234 | ||
235 | int l = PyInt_AsSsize_t($result); | |
236 | if (l >= 0) | |
237 | { | |
238 | PyObject *chan = PyList_New(0); | |
239 | int i; | |
240 | for(i=0; i<l; i++) | |
241 | { | |
242 | PyObject *tmp = PyTuple_New(4); | |
243 | PyObject *name = PyString_FromString((*$1)[i].name); | |
244 | PyObject *enabled = PyInt_FromSize_t((*$1)[i].enabled); | |
245 | PyObject *padding = PyString_FromString((*$1)[i].padding); | |
246 | ||
247 | PyObject *attrtmp = PyTuple_New(7); | |
248 | PyObject *overwrite = PyInt_FromLong((*$1)[i].attr.overwrite); | |
249 | PyObject *subbuf = PyInt_FromSize_t((*$1)[i].attr.subbuf_size); | |
250 | PyObject *num = PyInt_FromSize_t((*$1)[i].attr.num_subbuf); | |
251 | PyObject *switchtimer = PyInt_FromSize_t((*$1)[i].attr.switch_timer_interval); | |
252 | PyObject *readtimer = PyInt_FromSize_t((*$1)[i].attr.read_timer_interval); | |
253 | PyObject *output = PyInt_FromSize_t((*$1)[i].attr.output); | |
254 | PyObject *attrpad = PyString_FromString((*$1)[i].attr.padding); | |
255 | ||
256 | PyTuple_SetItem(attrtmp, 0, overwrite); | |
257 | PyTuple_SetItem(attrtmp, 1, subbuf); | |
258 | PyTuple_SetItem(attrtmp, 2, num); | |
259 | PyTuple_SetItem(attrtmp, 3, switchtimer); | |
260 | PyTuple_SetItem(attrtmp, 4, readtimer); | |
261 | PyTuple_SetItem(attrtmp, 5, output); | |
262 | PyTuple_SetItem(attrtmp, 6, attrpad); | |
263 | ||
264 | PyTuple_SetItem(tmp, 0, name); | |
265 | PyTuple_SetItem(tmp, 1, enabled); | |
266 | PyTuple_SetItem(tmp, 2, padding); | |
267 | PyTuple_SetItem(tmp, 3, attrtmp); | |
268 | PyList_Append(chan, tmp); | |
269 | } | |
270 | $result = chan; | |
271 | } | |
272 | } | |
273 | %typemap(in,numinputs=0) struct lttng_channel **channels (struct lttng_channel *temp){ | |
274 | $1=&temp; | |
275 | } | |
276 | ||
277 | //list_events & list_tracepoints | |
278 | %typemap(argout) struct lttng_event **events{ | |
279 | ||
280 | int l = PyInt_AsSsize_t($result); | |
281 | if (l >= 0) | |
282 | { | |
283 | PyObject *events = PyList_New(0); | |
284 | int i; | |
285 | for(i=0; i<l; i++) | |
286 | { | |
287 | PyObject *tmp = PyTuple_New(10); | |
288 | PyObject *name = PyString_FromString((*$1)[i].name); | |
289 | PyObject *type = PyInt_FromSize_t((*$1)[i].type); | |
290 | PyObject *logleveltype = PyInt_FromSize_t((*$1)[i].loglevel_type); | |
291 | PyObject *loglevel = PyInt_FromLong((*$1)[i].loglevel); | |
292 | PyObject *enabled = PyInt_FromLong((*$1)[i].enabled); | |
293 | PyObject *pid = PyInt_FromSize_t((*$1)[i].pid); | |
294 | PyObject *padding = PyString_FromString((*$1)[i].padding); | |
295 | PyObject *attrpadding = PyString_FromString((*$1)[i].attr.padding); | |
296 | ||
297 | PyObject *probe = PyTuple_New(4); | |
298 | PyObject *addr = PyInt_FromSize_t((*$1)[i].attr.probe.addr); | |
299 | PyObject *offset = PyInt_FromSize_t((*$1)[i].attr.probe.offset); | |
300 | PyObject *symbolname = PyString_FromString((*$1)[i].attr.probe.symbol_name); | |
301 | PyObject *probepad = PyString_FromString((*$1)[i].attr.probe.padding); | |
302 | ||
303 | PyObject *function = PyTuple_New(2); | |
304 | PyObject *f_symbolname = PyString_FromString((*$1)[i].attr.ftrace.symbol_name); | |
305 | PyObject *f_pad = PyString_FromString((*$1)[i].attr.ftrace.padding); | |
306 | ||
307 | PyTuple_SetItem(function, 0, f_symbolname); | |
308 | PyTuple_SetItem(function, 1, f_pad); | |
309 | ||
310 | PyTuple_SetItem(probe, 0, addr); | |
311 | PyTuple_SetItem(probe, 1, offset); | |
312 | PyTuple_SetItem(probe, 2, symbolname); | |
313 | PyTuple_SetItem(probe, 3, probepad); | |
314 | ||
315 | PyTuple_SetItem(tmp, 0, name); | |
316 | PyTuple_SetItem(tmp, 1, type); | |
317 | PyTuple_SetItem(tmp, 2, logleveltype); | |
318 | PyTuple_SetItem(tmp, 3, loglevel); | |
319 | PyTuple_SetItem(tmp, 4, enabled); | |
320 | PyTuple_SetItem(tmp, 5, pid); | |
321 | PyTuple_SetItem(tmp, 6, padding); | |
322 | PyTuple_SetItem(tmp, 7, probe); | |
323 | PyTuple_SetItem(tmp, 8, function); | |
324 | PyTuple_SetItem(tmp, 9, attrpadding); | |
325 | PyList_Append(events, tmp); | |
326 | } | |
327 | $result = events; | |
328 | } | |
329 | } | |
330 | %typemap(in,numinputs=0) struct lttng_event **events (struct lttng_event *temp){ | |
331 | $1=&temp; | |
332 | } | |
333 | ||
334 | ||
335 | ||
336 | // ============================================= | |
337 | // FUNCTIONS | |
338 | // ============================================= | |
339 | ||
340 | %rename("create") lttng_create_session(const char *name, const char *path); | |
9e52b0d8 | 341 | %rename("create_snapshot") lttng_create_session_snapshot(const char *name, const char *snapshot_url); |
36907cb5 DS |
342 | %rename("destroy") lttng_destroy_session(const char *name); |
343 | %rename("_lttng_create_handle") lttng_create_handle(const char *session_name, struct lttng_domain *domain); | |
344 | %rename("_lttng_destroy_handle") lttng_destroy_handle(struct lttng_handle *handle); | |
345 | %rename("_lttng_list_sessions") lttng_list_sessions(struct lttng_session **sessions); | |
346 | %rename("_lttng_list_domains") lttng_list_domains(const char *session_name, struct lttng_domain **domains); | |
347 | %rename("_lttng_list_channels") lttng_list_channels(struct lttng_handle *handle,struct lttng_channel **channels); | |
348 | %rename("_lttng_list_events") lttng_list_events(struct lttng_handle *handle, const char *channel_name, struct lttng_event **events); | |
349 | %rename("_lttng_list_tracepoints") lttng_list_tracepoints(struct lttng_handle *handle, struct lttng_event **events); | |
350 | %rename("session_daemon_alive") lttng_session_daemon_alive(void); | |
351 | %rename("set_tracing_group") lttng_set_tracing_group(const char *name); | |
352 | %rename("strerror") lttng_strerror(int code); | |
353 | %rename("_lttng_register_consumer") lttng_register_consumer(struct lttng_handle *handle, const char *socket_path); | |
354 | %rename("start") lttng_start_tracing(const char *session_name); | |
355 | %rename("stop") lttng_stop_tracing(const char *session_name); | |
356 | %rename("_lttng_add_context") lttng_add_context(struct lttng_handle *handle, struct lttng_event_context *ctx, const char *event_name, const char *channel_name); | |
357 | %rename("_lttng_enable_event") lttng_enable_event(struct lttng_handle *handle, struct lttng_event *ev, const char *channel_name); | |
358 | %rename("_lttng_enable_channel") lttng_enable_channel(struct lttng_handle *handle, struct lttng_channel *chan); | |
359 | %rename("_lttng_disable_event") lttng_disable_event(struct lttng_handle *handle, const char *name, const char *channel_name); | |
360 | %rename("_lttng_disable_channel") lttng_disable_channel(struct lttng_handle *handle, const char *name); | |
36907cb5 DS |
361 | %rename("channel_set_default_attr") lttng_channel_set_default_attr(struct lttng_domain *domain, struct lttng_channel_attr *attr); |
362 | ||
363 | //Redefined functions | |
364 | struct lttng_handle *lttng_create_handle(const char *session_name, | |
365 | struct lttng_domain *domain); | |
366 | void lttng_destroy_handle(struct lttng_handle *handle); | |
367 | int lttng_list_channels(struct lttng_handle *handle,struct lttng_channel **channels); | |
368 | int lttng_list_events(struct lttng_handle *handle, | |
369 | const char *channel_name, struct lttng_event **events); | |
370 | int lttng_list_tracepoints(struct lttng_handle *handle, struct lttng_event **events); | |
371 | int lttng_add_context(struct lttng_handle *handle, struct lttng_event_context *ctx, | |
372 | const char *event_name, const char *channel_name); | |
373 | int lttng_enable_event(struct lttng_handle *handle, | |
374 | struct lttng_event *ev, const char *channel_name); | |
375 | int lttng_enable_channel(struct lttng_handle *handle, struct lttng_channel *chan); | |
376 | int lttng_disable_event(struct lttng_handle *handle, | |
377 | const char *name, const char *channel_name); | |
378 | int lttng_disable_channel(struct lttng_handle *handle, const char *name); | |
36907cb5 DS |
379 | int lttng_register_consumer(struct lttng_handle *handle, const char *socket_path); |
380 | int lttng_list_sessions(struct lttng_session **sessions); | |
381 | int lttng_list_domains(const char *session_name, struct lttng_domain **domains); | |
382 | ||
383 | //Functions not needing redefinition | |
384 | %feature("docstring")"create(str name, str path) -> int | |
385 | ||
386 | Create a new tracing session using name and path. | |
9e52b0d8 | 387 | Returns 0 on success or a negative error code." |
36907cb5 DS |
388 | int lttng_create_session(const char *name, const char *path); |
389 | ||
9e52b0d8 MD |
390 | %feature("docstring")"create_snapshot(str name, str snapshot_url) -> int |
391 | ||
392 | Create a new tracing session using name and snapshot_url in snapshot | |
393 | mode (flight recorder). | |
394 | Returns 0 on success or a negative error code." | |
395 | int lttng_create_session_snapshot(const char *name, const char *path); | |
36907cb5 DS |
396 | |
397 | %feature("docstring")"destroy(str name) -> int | |
398 | ||
399 | Tear down tracing session using name. | |
9e52b0d8 | 400 | Returns 0 on success or a negative error code." |
36907cb5 DS |
401 | int lttng_destroy_session(const char *name); |
402 | ||
403 | ||
404 | %feature("docstring")"session_daemon_alive() -> int | |
405 | ||
406 | Check if session daemon is alive. | |
407 | Return 1 if alive or 0 if not. | |
408 | On error returns a negative value." | |
409 | int lttng_session_daemon_alive(void); | |
410 | ||
411 | ||
412 | %feature("docstring")"set_tracing_group(str name) -> int | |
413 | ||
414 | Sets the tracing_group variable with name. | |
415 | This function allocates memory pointed to by tracing_group. | |
416 | On success, returns 0, on error, returns -1 (null name) or -ENOMEM." | |
417 | int lttng_set_tracing_group(const char *name); | |
418 | ||
419 | ||
420 | %feature("docstring")"strerror(int code) -> char | |
421 | ||
422 | Returns a human readable string describing | |
423 | the error code (a negative value)." | |
424 | const char *lttng_strerror(int code); | |
425 | ||
426 | ||
427 | %feature("docstring")"start(str session_name) -> int | |
428 | ||
429 | Start tracing for all traces of the session. | |
430 | Returns size of returned session payload data or a negative error code." | |
431 | int lttng_start_tracing(const char *session_name); | |
432 | ||
433 | ||
434 | %feature("docstring")"stop(str session_name) -> int | |
435 | ||
436 | Stop tracing for all traces of the session. | |
437 | Returns size of returned session payload data or a negative error code." | |
438 | int lttng_stop_tracing(const char *session_name); | |
439 | ||
440 | ||
441 | %feature("docstring")"channel_set_default_attr(Domain domain, ChannelAttr attr) | |
442 | ||
443 | Set default channel attributes. | |
444 | If either or both of the arguments are null, attr content is zeroe'd." | |
445 | void lttng_channel_set_default_attr(struct lttng_domain *domain, struct lttng_channel_attr *attr); | |
446 | ||
447 | ||
448 | // ============================================= | |
449 | // Python redefinition of some functions | |
450 | // (List and Handle-related) | |
451 | // ============================================= | |
452 | ||
453 | %feature("docstring")"" | |
454 | %pythoncode %{ | |
455 | ||
456 | def list_sessions(): | |
457 | """ | |
458 | list_sessions() -> dict | |
459 | ||
460 | Ask the session daemon for all available sessions. | |
461 | Returns a dict of Session instances, the key is the name; | |
462 | on error, returns a negative value. | |
463 | """ | |
464 | ||
465 | ses_list = _lttng_list_sessions() | |
466 | if type(ses_list) is int: | |
467 | return ses_list | |
468 | ||
469 | sessions = {} | |
470 | ||
471 | for ses_elements in ses_list: | |
472 | ses = Session() | |
473 | ses.name = ses_elements[0] | |
474 | ses.path = ses_elements[1] | |
475 | ses.enabled = ses_elements[2] | |
476 | ses.padding = ses_elements[3] | |
477 | ||
478 | sessions[ses.name] = ses | |
479 | ||
480 | return sessions | |
481 | ||
482 | ||
483 | def list_domains(session_name): | |
484 | """ | |
485 | list_domains(str session_name) -> list | |
486 | ||
487 | Ask the session daemon for all available domains of a session. | |
488 | Returns a list of Domain instances; | |
489 | on error, returns a negative value. | |
490 | """ | |
491 | ||
492 | dom_list = _lttng_list_domains(session_name) | |
493 | if type(dom_list) is int: | |
494 | return dom_list | |
495 | ||
496 | domains = [] | |
497 | ||
498 | for dom_elements in dom_list: | |
499 | dom = Domain() | |
500 | dom.type = dom_elements[0] | |
dd5f427a JR |
501 | dom.buf_type = dom_elements[1] |
502 | dom.paddinf = dom_elements[2] | |
503 | dom.attr.pid = dom_elements[3] | |
504 | dom.attr.exec_name = dom_elements[4] | |
505 | dom.attr.padding = dom_elements[5] | |
36907cb5 DS |
506 | |
507 | domains.append(dom) | |
508 | ||
509 | return domains | |
510 | ||
511 | ||
512 | def list_channels(handle): | |
513 | """ | |
514 | list_channels(Handle handle) -> dict | |
515 | ||
516 | Ask the session daemon for all available channels of a session. | |
517 | Returns a dict of Channel instances, the key is the name; | |
518 | on error, returns a negative value. | |
519 | """ | |
520 | ||
521 | try: | |
522 | chan_list = _lttng_list_channels(handle._h) | |
523 | except AttributeError: | |
524 | raise TypeError("in method 'list_channels', argument 1 must be a Handle instance") | |
525 | ||
526 | if type(chan_list) is int: | |
527 | return chan_list | |
528 | ||
529 | channels = {} | |
530 | ||
531 | for channel_elements in chan_list: | |
532 | chan = Channel() | |
533 | chan.name = channel_elements[0] | |
534 | chan.enabled = channel_elements[1] | |
535 | chan.padding = channel_elements[2] | |
536 | chan.attr.overwrite = channel_elements[3][0] | |
537 | chan.attr.subbuf_size = channel_elements[3][1] | |
538 | chan.attr.num_subbuf = channel_elements[3][2] | |
539 | chan.attr.switch_timer_interval = channel_elements[3][3] | |
540 | chan.attr.read_timer_interval = channel_elements[3][4] | |
541 | chan.attr.output = channel_elements[3][5] | |
542 | chan.attr.padding = channel_elements[3][6] | |
543 | ||
544 | channels[chan.name] = chan | |
545 | ||
546 | return channels | |
547 | ||
548 | ||
549 | def list_events(handle, channel_name): | |
550 | """ | |
551 | list_events(Handle handle, str channel_name) -> dict | |
552 | ||
553 | Ask the session daemon for all available events of a session channel. | |
554 | Returns a dict of Event instances, the key is the name; | |
555 | on error, returns a negative value. | |
556 | """ | |
557 | ||
558 | try: | |
559 | ev_list = _lttng_list_events(handle._h, channel_name) | |
560 | except AttributeError: | |
561 | raise TypeError("in method 'list_events', argument 1 must be a Handle instance") | |
562 | ||
563 | if type(ev_list) is int: | |
564 | return ev_list | |
565 | ||
566 | events = {} | |
567 | ||
568 | for ev_elements in ev_list: | |
569 | ev = Event() | |
570 | ev.name = ev_elements[0] | |
571 | ev.type = ev_elements[1] | |
572 | ev.loglevel_type = ev_elements[2] | |
573 | ev.loglevel = ev_elements[3] | |
574 | ev.enabled = ev_elements[4] | |
575 | ev.pid = ev_elements[5] | |
576 | ev.attr.padding = ev_elements[6] | |
577 | ev.attr.probe.addr = ev_elements[7][0] | |
578 | ev.attr.probe.offset = ev_elements[7][1] | |
579 | ev.attr.probe.symbol_name = ev_elements[7][2] | |
580 | ev.attr.probe.padding = ev_elements[7][3] | |
581 | ev.attr.ftrace.symbol_name = ev_elements[8][0] | |
582 | ev.attr.ftrace.padding = ev_elements[8][1] | |
583 | ev.attr.padding = ev_elements[9] | |
584 | ||
585 | events[ev.name] = ev | |
586 | ||
587 | return events | |
588 | ||
589 | ||
590 | def list_tracepoints(handle): | |
591 | """ | |
592 | list_tracepoints(Handle handle) -> dict | |
593 | ||
594 | Returns a dict of Event instances, the key is the name; | |
595 | on error, returns a negative value. | |
596 | """ | |
597 | ||
598 | try: | |
599 | ev_list = _lttng_list_tracepoints(handle._h) | |
600 | except AttributeError: | |
601 | raise TypeError("in method 'list_tracepoints', argument 1 must be a Handle instance") | |
602 | ||
603 | if type(ev_list) is int: | |
604 | return ev_list | |
605 | ||
606 | events = {} | |
607 | ||
608 | for ev_elements in ev_list: | |
609 | ev = Event() | |
610 | ev.name = ev_elements[0] | |
611 | ev.type = ev_elements[1] | |
612 | ev.loglevel_type = ev_elements[2] | |
613 | ev.loglevel = ev_elements[3] | |
614 | ev.enabled = ev_elements[4] | |
615 | ev.pid = ev_elements[5] | |
616 | ev.attr.padding = ev_elements[6] | |
617 | ev.attr.probe.addr = ev_elements[7][0] | |
618 | ev.attr.probe.offset = ev_elements[7][1] | |
619 | ev.attr.probe.symbol_name = ev_elements[7][2] | |
620 | ev.attr.probe.padding = ev_elements[7][3] | |
621 | ev.attr.ftrace.symbol_name = ev_elements[8][0] | |
622 | ev.attr.ftrace.padding = ev_elements[8][1] | |
623 | ev.attr.padding = ev_elements[9] | |
624 | ||
625 | events[ev.name] = ev | |
626 | ||
627 | return events | |
628 | ||
629 | ||
630 | def register_consumer(handle, socket_path): | |
631 | """ | |
632 | register_consumer(Handle handle, str socket_path) -> int | |
633 | ||
634 | Register an outside consumer. | |
635 | Returns size of returned session payload data or a negative error code. | |
636 | """ | |
637 | ||
638 | try: | |
639 | return _lttng_register_consumer(handle._h, socket_path) | |
640 | except AttributeError: | |
641 | raise TypeError("in method 'register_consumer', argument 1 must be a Handle instance") | |
642 | ||
643 | ||
644 | def add_context(handle, event_context, event_name, channel_name): | |
645 | """ | |
646 | add_context(Handle handle, EventContext ctx, | |
647 | str event_name, str channel_name) -> int | |
648 | ||
649 | Add context to event and/or channel. | |
650 | If event_name is None, the context is applied to all events of the channel. | |
651 | If channel_name is None, a lookup of the event's channel is done. | |
652 | If both are None, the context is applied to all events of all channels. | |
653 | Returns the size of the returned payload data or a negative error code. | |
654 | """ | |
655 | ||
656 | try: | |
657 | return _lttng_add_context(handle._h, event_context, event_name, channel_name) | |
658 | except AttributeError: | |
659 | raise TypeError("in method 'add_context', argument 1 must be a Handle instance") | |
660 | ||
661 | ||
662 | def enable_event(handle, event, channel_name): | |
663 | """ | |
664 | enable_event(Handle handle, Event event, | |
665 | str channel_name) -> int | |
666 | ||
667 | Enable event(s) for a channel. | |
668 | If no event name is specified, all events are enabled. | |
669 | If no channel name is specified, the default 'channel0' is used. | |
670 | Returns size of returned session payload data or a negative error code. | |
671 | """ | |
672 | ||
673 | try: | |
674 | return _lttng_enable_event(handle._h, event, channel_name) | |
675 | except AttributeError: | |
676 | raise TypeError("in method 'enable_event', argument 1 must be a Handle instance") | |
677 | ||
678 | ||
679 | def enable_channel(handle, channel): | |
680 | """ | |
681 | enable_channel(Handle handle, Channel channel -> int | |
682 | ||
683 | Enable channel per domain | |
684 | Returns size of returned session payload data or a negative error code. | |
685 | """ | |
686 | ||
687 | try: | |
688 | return _lttng_enable_channel(handle._h, channel) | |
689 | except AttributeError: | |
690 | raise TypeError("in method 'enable_channel', argument 1 must be a Handle instance") | |
691 | ||
692 | ||
693 | def disable_event(handle, name, channel_name): | |
694 | """ | |
695 | disable_event(Handle handle, str name, str channel_name) -> int | |
696 | ||
697 | Disable event(s) of a channel and domain. | |
698 | If no event name is specified, all events are disabled. | |
699 | If no channel name is specified, the default 'channel0' is used. | |
700 | Returns size of returned session payload data or a negative error code | |
701 | """ | |
702 | ||
703 | try: | |
704 | return _lttng_disable_event(handle._h, name, channel_name) | |
705 | except AttributeError: | |
706 | raise TypeError("in method 'disable_event', argument 1 must be a Handle instance") | |
707 | ||
708 | ||
709 | def disable_channel(handle, name): | |
710 | """ | |
711 | disable_channel(Handle handle, str name) -> int | |
712 | ||
713 | All tracing will be stopped for registered events of the channel. | |
714 | Returns size of returned session payload data or a negative error code. | |
715 | """ | |
716 | ||
717 | try: | |
718 | return _lttng_disable_channel(handle._h, name) | |
719 | except AttributeError: | |
720 | raise TypeError("in method 'disable_channel', argument 1 must be a Handle instance") | |
36907cb5 DS |
721 | %} |
722 | ||
723 | ||
724 | // ============================================= | |
725 | // Handle class | |
726 | // Used to prevent freeing unallocated memory | |
727 | // ============================================= | |
728 | ||
729 | %feature("docstring")"" | |
730 | %feature("autodoc", "1"); | |
731 | ||
732 | %pythoncode %{ | |
733 | class Handle: | |
9c2fd06d | 734 | """ |
36907cb5 DS |
735 | Manages a handle. |
736 | Takes two arguments: (str session_name, Domain domain) | |
737 | """ | |
738 | ||
739 | __frozen = False | |
740 | ||
741 | def __init__(self, session_name, domain): | |
742 | if type(session_name) is not str: | |
743 | raise TypeError("in method '__init__', argument 2 of type 'str'") | |
744 | if type(domain) is not Domain and domain is not None: | |
745 | raise TypeError("in method '__init__', argument 3 of type 'lttng.Domain'") | |
746 | ||
747 | self._sname = session_name | |
748 | if domain is None: | |
749 | self._domtype = None | |
750 | else: | |
751 | self._domtype = domain.type | |
752 | self._h = _lttng_create_handle(session_name, domain) | |
753 | self.__frozen = True | |
754 | ||
755 | def __del__(self): | |
756 | _lttng_destroy_handle(self._h) | |
757 | ||
758 | def __repr__(self): | |
759 | if self._domtype == 1: | |
760 | domstr = "DOMAIN_KERNEL" | |
761 | elif self._domtype == 2: | |
762 | domstr = "DOMAIN_UST" | |
763 | else: | |
764 | domstr = self._domtype | |
765 | ||
766 | return "lttng.Handle; session('{}'), domain.type({})".format( | |
767 | self._sname, domstr) | |
768 | ||
769 | def __setattr__(self, attr, val): | |
770 | if self.__frozen: | |
771 | raise NotImplementedError("cannot modify attributes") | |
772 | else: | |
773 | self.__dict__[attr] = val | |
774 | %} | |
775 | ||
776 | ||
777 | // ============================================= | |
778 | // STRUCTURES | |
779 | // These are directly taken from lttng.h. | |
780 | // Any change to these structures must also be | |
781 | // made here. | |
782 | // ============================================= | |
783 | ||
784 | %rename("Domain") lttng_domain; | |
785 | %rename("EventContext") lttng_event_context; | |
786 | %rename("Event") lttng_event; | |
36907cb5 DS |
787 | %rename("ChannelAttr") lttng_channel_attr; |
788 | %rename("Channel") lttng_channel; | |
789 | %rename("Session") lttng_session; | |
790 | ||
791 | struct lttng_domain{ | |
792 | enum lttng_domain_type type; | |
dd5f427a | 793 | enum lttng_buffer_type buf_type; |
36907cb5 DS |
794 | char padding[LTTNG_DOMAIN_PADDING1]; |
795 | ||
796 | union { | |
797 | pid_t pid; | |
798 | char exec_name[NAME_MAX]; | |
799 | char padding[LTTNG_DOMAIN_PADDING2]; | |
800 | } attr; | |
801 | ||
802 | %extend { | |
803 | char *__repr__() { | |
804 | static char temp[256]; | |
dd5f427a JR |
805 | static char domain_type[25]; |
806 | static char buffer_type[25]; | |
36907cb5 DS |
807 | switch ( $self->type ) { |
808 | case 1: | |
dd5f427a | 809 | sprintf(domain_type, "type(DOMAIN_KERNEL)"); |
36907cb5 DS |
810 | break; |
811 | case 2: | |
dd5f427a | 812 | sprintf(domain_type, "type(DOMAIN_UST)"); |
36907cb5 DS |
813 | break; |
814 | default: | |
dd5f427a | 815 | sprintf(domain_type, "type(%i)", $self->type); |
36907cb5 DS |
816 | break; |
817 | } | |
dd5f427a JR |
818 | |
819 | switch ( $self->buf_type ) { | |
820 | case LTTNG_BUFFER_PER_UID: | |
821 | sprintf(buffer_type, "buf_type(BUFFER_PER_UID)"); | |
822 | break; | |
823 | case LTTNG_BUFFER_PER_PID: | |
824 | sprintf(buffer_type, "buf_type(BUFFER_PER_PID)"); | |
825 | break; | |
826 | case LTTNG_BUFFER_GLOBAL: | |
827 | sprintf(buffer_type, "buf_type(BUFFER_GLOBAL)"); | |
828 | break; | |
829 | default: | |
830 | sprintf(buffer_type, "buf_type(%i)", $self->buf_type); | |
831 | break; | |
832 | } | |
833 | ||
834 | sprintf(temp, "lttng.Domain; %s, %s", | |
835 | domain_type, | |
836 | buffer_type | |
837 | ); | |
36907cb5 DS |
838 | return &temp[0]; |
839 | } | |
840 | } | |
841 | }; | |
842 | ||
843 | struct lttng_event_context { | |
844 | enum lttng_event_context_type ctx; | |
845 | char padding[LTTNG_EVENT_CONTEXT_PADDING1]; | |
846 | ||
847 | union { | |
848 | struct lttng_event_perf_counter_ctx perf_counter; | |
849 | char padding[LTTNG_EVENT_CONTEXT_PADDING2]; | |
850 | } u; | |
851 | ||
852 | %extend { | |
853 | char *__repr__() { | |
854 | static char temp[256]; | |
855 | switch ( $self->ctx ) { | |
856 | case 0: | |
857 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PID)"); | |
858 | break; | |
859 | case 1: | |
860 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PERF_COUNTER)"); | |
861 | break; | |
862 | case 2: | |
863 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PROCNAME)"); | |
864 | break; | |
865 | case 3: | |
866 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PRIO)"); | |
867 | break; | |
868 | case 4: | |
869 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_NICE)"); | |
870 | break; | |
871 | case 5: | |
872 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VPID)"); | |
873 | break; | |
874 | case 6: | |
875 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_TID)"); | |
876 | break; | |
877 | case 7: | |
878 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VTID)"); | |
879 | break; | |
880 | case 8: | |
881 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PPID)"); | |
882 | break; | |
883 | case 9: | |
884 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VPPID)"); | |
885 | break; | |
886 | case 10: | |
887 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PTHREAD_ID)"); | |
888 | break; | |
a593ba5a CB |
889 | case 11: |
890 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_HOSTNAME)"); | |
891 | break; | |
892 | case 12: | |
893 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_IP)"); | |
894 | break; | |
895 | case 13: | |
896 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PERF_CPU_COUNTER)"); | |
897 | break; | |
898 | case 14: | |
899 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PERF_THREAD_COUNTER)"); | |
900 | break; | |
901 | case 15: | |
902 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_APP_CONTEXT)"); | |
903 | break; | |
904 | case 16: | |
905 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_INTERRUPTIBLE)"); | |
906 | break; | |
907 | case 17: | |
908 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PREEMPTIBLE)"); | |
909 | break; | |
910 | case 18: | |
911 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_NEED_RESCHEDULE)"); | |
912 | break; | |
913 | case 19: | |
914 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_MIGRATABLE)"); | |
915 | break; | |
36907cb5 DS |
916 | default: |
917 | sprintf(temp, "lttng.EventContext; type(%i)", $self->ctx); | |
918 | break; | |
919 | } | |
920 | return &temp[0]; | |
921 | } | |
922 | } | |
923 | }; | |
924 | ||
b6648478 JG |
925 | struct lttng_event_probe_attr { |
926 | uint64_t addr; | |
927 | uint64_t offset; | |
928 | char symbol_name[LTTNG_SYMBOL_NAME_LEN]; | |
929 | char padding[LTTNG_EVENT_PROBE_PADDING1]; | |
930 | }; | |
36907cb5 | 931 | |
b6648478 JG |
932 | struct lttng_event_function_attr { |
933 | char symbol_name[LTTNG_SYMBOL_NAME_LEN]; | |
934 | char padding[LTTNG_EVENT_FUNCTION_PADDING1]; | |
935 | }; | |
36907cb5 | 936 | |
b6648478 JG |
937 | struct lttng_event { |
938 | enum lttng_event_type type; | |
939 | char name[LTTNG_SYMBOL_NAME_LEN]; | |
36907cb5 | 940 | |
b6648478 JG |
941 | enum lttng_loglevel_type loglevel_type; |
942 | int loglevel; | |
943 | ||
944 | int32_t enabled; | |
945 | pid_t pid; | |
946 | ||
947 | char padding[LTTNG_EVENT_PADDING1]; | |
948 | ||
949 | union { | |
950 | struct lttng_event_probe_attr probe; | |
951 | struct lttng_event_function_attr ftrace; | |
952 | ||
953 | char padding[LTTNG_EVENT_PADDING2]; | |
954 | } attr; | |
955 | ||
956 | %extend { | |
957 | char *__repr__() { | |
958 | static char temp[512]; | |
959 | char evtype[50]; | |
960 | char logtype[50]; | |
961 | ||
962 | switch ( $self->type ) { | |
963 | case -1: | |
964 | sprintf(evtype, "EVENT_ALL"); | |
965 | break; | |
966 | case 0: | |
967 | sprintf(evtype, "EVENT_TRACEPOINT"); | |
968 | break; | |
969 | case 1: | |
970 | sprintf(evtype, "EVENT_PROBE"); | |
971 | break; | |
972 | case 2: | |
973 | sprintf(evtype, "EVENT_FUNCTION"); | |
974 | break; | |
975 | case 3: | |
976 | sprintf(evtype, "EVENT_FUNCTION_ENTRY"); | |
977 | break; | |
978 | case 4: | |
979 | sprintf(evtype, "EVENT_NOOP"); | |
980 | break; | |
981 | case 5: | |
982 | sprintf(evtype, "EVENT_SYSCALL"); | |
983 | break; | |
984 | default: | |
985 | sprintf(evtype, "%i", $self->type); | |
986 | break; | |
987 | } | |
988 | ||
989 | switch ( $self->loglevel_type ) { | |
990 | case 0: | |
991 | sprintf(logtype, "EVENT_LOGLEVEL_ALL"); | |
992 | break; | |
993 | case 1: | |
994 | sprintf(logtype, "EVENT_LOGLEVEL_RANGE"); | |
995 | break; | |
996 | case 2: | |
997 | sprintf(logtype, "EVENT_LOGLEVEL_SINGLE"); | |
998 | break; | |
999 | default: | |
1000 | sprintf(logtype, "%i", $self->loglevel_type); | |
1001 | break; | |
1002 | } | |
1003 | ||
1004 | sprintf(temp, "lttng.Event; name('%s'), type(%s), " | |
1005 | "loglevel_type(%s), loglevel(%i), " | |
1006 | "enabled(%s), pid(%i)", | |
1007 | $self->name, evtype, logtype, $self->loglevel, | |
1008 | $self->enabled ? "True" : "False", $self->pid); | |
1009 | return &temp[0]; | |
36907cb5 DS |
1010 | } |
1011 | } | |
b6648478 JG |
1012 | }; |
1013 | ||
b6648478 JG |
1014 | struct lttng_channel_attr { |
1015 | int overwrite; | |
1016 | uint64_t subbuf_size; | |
1017 | uint64_t num_subbuf; | |
1018 | unsigned int switch_timer_interval; | |
1019 | unsigned int read_timer_interval; | |
1020 | enum lttng_event_output output; | |
1021 | ||
1022 | char padding[LTTNG_CHANNEL_ATTR_PADDING1]; | |
1023 | ||
1024 | %extend { | |
1025 | char *__repr__() { | |
1026 | static char temp[256]; | |
1027 | char evout[25]; | |
1028 | ||
1029 | switch ( $self->output ) { | |
1030 | case 0: | |
1031 | sprintf(evout, "EVENT_SPLICE"); | |
1032 | break; | |
1033 | case 1: | |
1034 | sprintf(evout, "EVENT_MMAP"); | |
1035 | break; | |
1036 | default: | |
1037 | sprintf(evout, "%i", $self->output); | |
1038 | break; | |
1039 | } | |
bc3bdada JG |
1040 | sprintf(temp, "lttng.ChannelAttr; overwrite(%i), subbuf_size(%"PRIu64"), " |
1041 | "num_subbuf(%"PRIu64"), switch_timer_interval(%u), " | |
b6648478 JG |
1042 | "read_timer_interval(%u), output(%s)", |
1043 | $self->overwrite, $self->subbuf_size, $self->num_subbuf, | |
1044 | $self->switch_timer_interval, $self->read_timer_interval, | |
1045 | evout); | |
1046 | return &temp[0]; | |
1047 | } | |
dcac8046 | 1048 | } |
b6648478 JG |
1049 | }; |
1050 | ||
1051 | struct lttng_channel { | |
1052 | char name[LTTNG_SYMBOL_NAME_LEN]; | |
1053 | uint32_t enabled; | |
1054 | struct lttng_channel_attr attr; | |
1055 | char padding[LTTNG_CHANNEL_PADDING1]; | |
36907cb5 | 1056 | |
b6648478 JG |
1057 | %extend { |
1058 | char *__repr__() { | |
1059 | static char temp[512]; | |
25986cde | 1060 | snprintf(temp, sizeof(temp), "lttng.Channel; name('%s'), enabled(%s)", |
b6648478 JG |
1061 | $self->name, $self->enabled ? "True" : "False"); |
1062 | return &temp[0]; | |
1063 | } | |
36907cb5 | 1064 | } |
b6648478 | 1065 | }; |
dcac8046 | 1066 | |
b6648478 JG |
1067 | struct lttng_session { |
1068 | char name[NAME_MAX]; | |
1069 | char path[PATH_MAX]; | |
1070 | uint32_t enabled; | |
b178f53e JG |
1071 | uint32_t snapshot_mode; |
1072 | unsigned int live_timer_interval; | |
1073 | union { | |
1074 | char padding[LTTNG_SESSION_PADDING1]; | |
1075 | void *ptr; | |
1076 | } extended; | |
b6648478 JG |
1077 | |
1078 | %extend { | |
1079 | char *__repr__() { | |
25986cde JG |
1080 | static char temp[PATH_MAX + NAME_MAX + 512]; |
1081 | snprintf(temp, sizeof(temp), "lttng.Session; name('%s'), path('%s'), enabled(%s)", | |
b6648478 JG |
1082 | $self->name, $self->path, |
1083 | $self->enabled ? "True" : "False"); | |
1084 | return &temp[0]; | |
1085 | } | |
1086 | } | |
1087 | }; |