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