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."
9 %module(docstring=DOCSTRING) lttng
15 #define SWIG_FILE_WITH_INIT
16 #include <lttng/lttng.h>
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
27 typedef unsigned int uint32_t;
29 typedef unsigned long long uint64_t;
33 // =============================================
35 // These are directly taken from lttng.h.
36 // Any change to these enums must also be
38 // =============================================
40 %rename("DOMAIN_KERNEL") LTTNG_DOMAIN_KERNEL;
41 %rename("DOMAIN_UST") LTTNG_DOMAIN_UST;
42 enum lttng_domain_type {
43 LTTNG_DOMAIN_KERNEL = 1,
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 {
56 LTTNG_EVENT_TRACEPOINT = 0,
57 LTTNG_EVENT_PROBE = 1,
58 LTTNG_EVENT_FUNCTION = 2,
59 LTTNG_EVENT_FUNCTION_ENTRY = 3,
61 LTTNG_EVENT_SYSCALL = 5,
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,
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;
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,
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,
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,
138 %rename("CALIBRATE_FUNCTION") LTTNG_CALIBRATE_FUNCTION;
139 enum lttng_calibrate_type {
140 LTTNG_CALIBRATE_FUNCTION = 0,
145 // =============================================
147 // =============================================
150 %typemap(argout) struct lttng_session **sessions{
152 int l = PyInt_AsSsize_t($result);
155 PyObject *sessions = PyList_New(0);
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);
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);
174 %typemap(in,numinputs=0) struct lttng_session **sessions (struct lttng_session *temp){
179 %typemap(argout) struct lttng_domain **domains{
181 int l = PyInt_AsSsize_t($result);
184 PyObject *dom = PyList_New(0);
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);
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);
205 %typemap(in,numinputs=0) struct lttng_domain **domains (struct lttng_domain *temp){
210 %typemap(argout) struct lttng_channel **channels{
212 int l = PyInt_AsSsize_t($result);
215 PyObject *chan = PyList_New(0);
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);
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);
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);
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);
250 %typemap(in,numinputs=0) struct lttng_channel **channels (struct lttng_channel *temp){
254 //list_events & list_tracepoints
255 %typemap(argout) struct lttng_event **events{
257 int l = PyInt_AsSsize_t($result);
260 PyObject *events = PyList_New(0);
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);
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);
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);
284 PyTuple_SetItem(function, 0, f_symbolname);
285 PyTuple_SetItem(function, 1, f_pad);
287 PyTuple_SetItem(probe, 0, addr);
288 PyTuple_SetItem(probe, 1, offset);
289 PyTuple_SetItem(probe, 2, symbolname);
290 PyTuple_SetItem(probe, 3, probepad);
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);
307 %typemap(in,numinputs=0) struct lttng_event **events (struct lttng_event *temp){
313 // =============================================
315 // =============================================
317 %rename("create") lttng_create_session(const char *name, const char *path);
318 %rename("create_snapshot") lttng_create_session_snapshot(const char *name, const char *snapshot_url);
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);
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);
362 //Functions not needing redefinition
363 %feature("docstring")"create(str name, str path) -> int
365 Create a new tracing session using name and path.
366 Returns 0 on success or a negative error code."
367 int lttng_create_session(const char *name, const char *path);
369 %feature("docstring")"create_snapshot(str name, str snapshot_url) -> int
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);
376 %feature("docstring")"destroy(str name) -> int
378 Tear down tracing session using name.
379 Returns 0 on success or a negative error code."
380 int lttng_destroy_session(const char *name);
383 %feature("docstring")"session_daemon_alive() -> int
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);
391 %feature("docstring")"set_tracing_group(str name) -> int
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);
399 %feature("docstring")"strerror(int code) -> char
401 Returns a human readable string describing
402 the error code (a negative value)."
403 const char *lttng_strerror(int code);
406 %feature("docstring")"start(str session_name) -> int
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);
413 %feature("docstring")"stop(str session_name) -> int
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);
420 %feature("docstring")"channel_set_default_attr(Domain domain, ChannelAttr attr)
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);
427 // =============================================
428 // Python redefinition of some functions
429 // (List and Handle-related)
430 // =============================================
432 %feature("docstring")""
437 list_sessions() -> dict
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.
444 ses_list = _lttng_list_sessions()
445 if type(ses_list) is int:
450 for ses_elements in ses_list:
452 ses.name = ses_elements[0]
453 ses.path = ses_elements[1]
454 ses.enabled = ses_elements[2]
455 ses.padding = ses_elements[3]
457 sessions[ses.name] = ses
462 def list_domains(session_name):
464 list_domains(str session_name) -> list
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.
471 dom_list = _lttng_list_domains(session_name)
472 if type(dom_list) is int:
477 for dom_elements in dom_list:
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]
490 def list_channels(handle):
492 list_channels(Handle handle) -> dict
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.
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")
504 if type(chan_list) is int:
509 for channel_elements in chan_list:
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]
522 channels[chan.name] = chan
527 def list_events(handle, channel_name):
529 list_events(Handle handle, str channel_name) -> dict
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.
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")
541 if type(ev_list) is int:
546 for ev_elements in ev_list:
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]
568 def list_tracepoints(handle):
570 list_tracepoints(Handle handle) -> dict
572 Returns a dict of Event instances, the key is the name;
573 on error, returns a negative value.
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")
581 if type(ev_list) is int:
586 for ev_elements in ev_list:
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]
608 def register_consumer(handle, socket_path):
610 register_consumer(Handle handle, str socket_path) -> int
612 Register an outside consumer.
613 Returns size of returned session payload data or a negative error code.
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")
622 def add_context(handle, event_context, event_name, channel_name):
624 add_context(Handle handle, EventContext ctx,
625 str event_name, str channel_name) -> int
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.
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")
640 def enable_event(handle, event, channel_name):
642 enable_event(Handle handle, Event event,
643 str channel_name) -> int
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.
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")
657 def enable_channel(handle, channel):
659 enable_channel(Handle handle, Channel channel -> int
661 Enable channel per domain
662 Returns size of returned session payload data or a negative error code.
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")
671 def disable_event(handle, name, channel_name):
673 disable_event(Handle handle, str name, str channel_name) -> int
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
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")
687 def disable_channel(handle, name):
689 disable_channel(Handle handle, str name) -> int
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.
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")
701 def calibrate(handle, calibrate):
703 calibrate(Handle handle, Calibrate calibrate) -> int
705 Quantify LTTng overhead.
706 Returns size of returned session payload data or a negative error code.
710 return _lttng_calibrate(handle._h, calibrate)
711 except AttributeError:
712 raise TypeError("in method 'calibrate', argument 1 must be a Handle instance")
716 // =============================================
718 // Used to prevent freeing unallocated memory
719 // =============================================
721 %feature("docstring")""
722 %feature("autodoc", "1");
728 Takes two arguments: (str session_name, Domain domain)
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'")
739 self._sname = session_name
743 self._domtype = domain.type
744 self._h = _lttng_create_handle(session_name, domain)
748 _lttng_destroy_handle(self._h)
751 if self._domtype == 1:
752 domstr = "DOMAIN_KERNEL"
753 elif self._domtype == 2:
754 domstr = "DOMAIN_UST"
756 domstr = self._domtype
758 return "lttng.Handle; session('{}'), domain.type({})".format(
761 def __setattr__(self, attr, val):
763 raise NotImplementedError("cannot modify attributes")
765 self.__dict__[attr] = val
769 // =============================================
771 // These are directly taken from lttng.h.
772 // Any change to these structures must also be
774 // =============================================
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;
785 enum lttng_domain_type type;
786 char padding[LTTNG_DOMAIN_PADDING1];
790 char exec_name[NAME_MAX];
791 char padding[LTTNG_DOMAIN_PADDING2];
796 static char temp[256];
797 switch ( $self->type ) {
799 sprintf(temp, "lttng.Domain; type(DOMAIN_KERNEL)");
802 sprintf(temp, "lttng.Domain; type(DOMAIN_UST)");
805 sprintf(temp, "lttng.Domain; type(%i)", $self->type);
813 struct lttng_event_context {
814 enum lttng_event_context_type ctx;
815 char padding[LTTNG_EVENT_CONTEXT_PADDING1];
818 struct lttng_event_perf_counter_ctx perf_counter;
819 char padding[LTTNG_EVENT_CONTEXT_PADDING2];
824 static char temp[256];
825 switch ( $self->ctx ) {
827 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PID)");
830 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PERF_COUNTER)");
833 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PROCNAME)");
836 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PRIO)");
839 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_NICE)");
842 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VPID)");
845 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_TID)");
848 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VTID)");
851 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PPID)");
854 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VPPID)");
857 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PTHREAD_ID)");
860 sprintf(temp, "lttng.EventContext; type(%i)", $self->ctx);
868 struct lttng_event_probe_attr {
871 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
872 char padding[LTTNG_EVENT_PROBE_PADDING1];
875 struct lttng_event_function_attr {
876 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
877 char padding[LTTNG_EVENT_FUNCTION_PADDING1];
881 enum lttng_event_type type;
882 char name[LTTNG_SYMBOL_NAME_LEN];
884 enum lttng_loglevel_type loglevel_type;
890 char padding[LTTNG_EVENT_PADDING1];
893 struct lttng_event_probe_attr probe;
894 struct lttng_event_function_attr ftrace;
896 char padding[LTTNG_EVENT_PADDING2];
901 static char temp[512];
905 switch ( $self->type ) {
907 sprintf(evtype, "EVENT_ALL");
910 sprintf(evtype, "EVENT_TRACEPOINT");
913 sprintf(evtype, "EVENT_PROBE");
916 sprintf(evtype, "EVENT_FUNCTION");
919 sprintf(evtype, "EVENT_FUNCTION_ENTRY");
922 sprintf(evtype, "EVENT_NOOP");
925 sprintf(evtype, "EVENT_SYSCALL");
928 sprintf(evtype, "%i", $self->type);
932 switch ( $self->loglevel_type ) {
934 sprintf(logtype, "EVENT_LOGLEVEL_ALL");
937 sprintf(logtype, "EVENT_LOGLEVEL_RANGE");
940 sprintf(logtype, "EVENT_LOGLEVEL_SINGLE");
943 sprintf(logtype, "%i", $self->loglevel_type);
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);
957 struct lttng_calibrate {
958 enum lttng_calibrate_type type;
959 char padding[LTTNG_CALIBRATE_PADDING1];
963 static char temp[256];
964 switch ( $self->type ) {
966 sprintf(temp, "lttng.Calibrate; type(CALIBRATE_FUNCTION)");
969 sprintf(temp, "lttng.Calibrate; type(%i)", $self->type);
977 struct lttng_channel_attr {
979 uint64_t subbuf_size;
981 unsigned int switch_timer_interval;
982 unsigned int read_timer_interval;
983 enum lttng_event_output output;
985 char padding[LTTNG_CHANNEL_ATTR_PADDING1];
989 static char temp[256];
992 switch ( $self->output ) {
994 sprintf(evout, "EVENT_SPLICE");
997 sprintf(evout, "EVENT_MMAP");
1000 sprintf(evout, "%i", $self->output);
1003 sprintf(temp, "lttng.ChannelAttr; overwrite(%i), subbuf_size(%"PRIu64"), "
1004 "num_subbuf(%"PRIu64"), switch_timer_interval(%u), "
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,
1014 struct lttng_channel {
1015 char name[LTTNG_SYMBOL_NAME_LEN];
1017 struct lttng_channel_attr attr;
1018 char padding[LTTNG_CHANNEL_PADDING1];
1022 static char temp[512];
1023 sprintf(temp, "lttng.Channel; name('%s'), enabled(%s)",
1024 $self->name, $self->enabled ? "True" : "False");
1030 struct lttng_session {
1031 char name[NAME_MAX];
1032 char path[PATH_MAX];
1034 char padding[LTTNG_SESSION_PADDING1];
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");