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("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 {
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 {
65 LTTNG_EVENT_TRACEPOINT = 0,
66 LTTNG_EVENT_PROBE = 1,
67 LTTNG_EVENT_FUNCTION = 2,
68 LTTNG_EVENT_FUNCTION_ENTRY = 3,
70 LTTNG_EVENT_SYSCALL = 5,
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,
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;
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,
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,
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;
133 enum lttng_event_context_type {
134 LTTNG_EVENT_CONTEXT_PID = 0,
135 LTTNG_EVENT_CONTEXT_PERF_COUNTER = 1,
136 LTTNG_EVENT_CONTEXT_PROCNAME = 2,
137 LTTNG_EVENT_CONTEXT_PRIO = 3,
138 LTTNG_EVENT_CONTEXT_NICE = 4,
139 LTTNG_EVENT_CONTEXT_VPID = 5,
140 LTTNG_EVENT_CONTEXT_TID = 6,
141 LTTNG_EVENT_CONTEXT_VTID = 7,
142 LTTNG_EVENT_CONTEXT_PPID = 8,
143 LTTNG_EVENT_CONTEXT_VPPID = 9,
144 LTTNG_EVENT_CONTEXT_PTHREAD_ID = 10,
150 // =============================================
152 // =============================================
155 %typemap(argout) struct lttng_session **sessions{
157 int l = PyInt_AsSsize_t($result);
160 PyObject *sessions = PyList_New(0);
164 PyObject *tmp = PyTuple_New(4);
165 PyObject *name = PyString_FromString((*$1)[i].name);
166 PyObject *path = PyString_FromString((*$1)[i].path);
167 PyObject *enabled = PyInt_FromSize_t((*$1)[i].enabled);
169 PyTuple_SetItem(tmp, 0, name);
170 PyTuple_SetItem(tmp, 1, path);
171 PyTuple_SetItem(tmp, 2, enabled);
172 PyList_Append(sessions, tmp);
177 %typemap(in,numinputs=0) struct lttng_session **sessions (struct lttng_session *temp){
182 %typemap(argout) struct lttng_domain **domains{
184 int l = PyInt_AsSsize_t($result);
187 PyObject *dom = PyList_New(0);
191 PyObject *tmp = PyTuple_New(6);
192 PyObject *type = PyInt_FromSize_t((*$1)[i].type);
193 PyObject *buf_type = PyInt_FromSize_t((*$1)[i].buf_type);
194 PyObject *execname = PyString_FromString((*$1)[i].attr.exec_name);
195 PyObject *pid = PyInt_FromSize_t((*$1)[i].attr.pid);
196 PyObject *padding = PyString_FromString((*$1)[i].padding);
197 PyObject *attrpadding = PyString_FromString((*$1)[i].attr.padding);
199 PyTuple_SetItem(tmp, 0, type);
200 PyTuple_SetItem(tmp, 1, buf_type);
201 PyTuple_SetItem(tmp, 2, padding);
202 PyTuple_SetItem(tmp, 3, pid);
203 PyTuple_SetItem(tmp, 4, execname);
204 PyTuple_SetItem(tmp, 5, attrpadding);
205 PyList_Append(dom, tmp);
210 %typemap(in,numinputs=0) struct lttng_domain **domains (struct lttng_domain *temp){
215 %typemap(argout) struct lttng_channel **channels{
217 int l = PyInt_AsSsize_t($result);
220 PyObject *chan = PyList_New(0);
224 PyObject *tmp = PyTuple_New(4);
225 PyObject *name = PyString_FromString((*$1)[i].name);
226 PyObject *enabled = PyInt_FromSize_t((*$1)[i].enabled);
227 PyObject *padding = PyString_FromString((*$1)[i].padding);
229 PyObject *attrtmp = PyTuple_New(7);
230 PyObject *overwrite = PyInt_FromLong((*$1)[i].attr.overwrite);
231 PyObject *subbuf = PyInt_FromSize_t((*$1)[i].attr.subbuf_size);
232 PyObject *num = PyInt_FromSize_t((*$1)[i].attr.num_subbuf);
233 PyObject *switchtimer = PyInt_FromSize_t((*$1)[i].attr.switch_timer_interval);
234 PyObject *readtimer = PyInt_FromSize_t((*$1)[i].attr.read_timer_interval);
235 PyObject *output = PyInt_FromSize_t((*$1)[i].attr.output);
236 PyObject *attrpad = PyString_FromString((*$1)[i].attr.padding);
238 PyTuple_SetItem(attrtmp, 0, overwrite);
239 PyTuple_SetItem(attrtmp, 1, subbuf);
240 PyTuple_SetItem(attrtmp, 2, num);
241 PyTuple_SetItem(attrtmp, 3, switchtimer);
242 PyTuple_SetItem(attrtmp, 4, readtimer);
243 PyTuple_SetItem(attrtmp, 5, output);
244 PyTuple_SetItem(attrtmp, 6, attrpad);
246 PyTuple_SetItem(tmp, 0, name);
247 PyTuple_SetItem(tmp, 1, enabled);
248 PyTuple_SetItem(tmp, 2, padding);
249 PyTuple_SetItem(tmp, 3, attrtmp);
250 PyList_Append(chan, tmp);
255 %typemap(in,numinputs=0) struct lttng_channel **channels (struct lttng_channel *temp){
259 //list_events & list_tracepoints
260 %typemap(argout) struct lttng_event **events{
262 int l = PyInt_AsSsize_t($result);
265 PyObject *events = PyList_New(0);
269 PyObject *tmp = PyTuple_New(10);
270 PyObject *name = PyString_FromString((*$1)[i].name);
271 PyObject *type = PyInt_FromSize_t((*$1)[i].type);
272 PyObject *logleveltype = PyInt_FromSize_t((*$1)[i].loglevel_type);
273 PyObject *loglevel = PyInt_FromLong((*$1)[i].loglevel);
274 PyObject *enabled = PyInt_FromLong((*$1)[i].enabled);
275 PyObject *pid = PyInt_FromSize_t((*$1)[i].pid);
276 PyObject *padding = PyString_FromString((*$1)[i].padding);
277 PyObject *attrpadding = PyString_FromString((*$1)[i].attr.padding);
279 PyObject *probe = PyTuple_New(4);
280 PyObject *addr = PyInt_FromSize_t((*$1)[i].attr.probe.addr);
281 PyObject *offset = PyInt_FromSize_t((*$1)[i].attr.probe.offset);
282 PyObject *symbolname = PyString_FromString((*$1)[i].attr.probe.symbol_name);
283 PyObject *probepad = PyString_FromString((*$1)[i].attr.probe.padding);
285 PyObject *function = PyTuple_New(2);
286 PyObject *f_symbolname = PyString_FromString((*$1)[i].attr.ftrace.symbol_name);
287 PyObject *f_pad = PyString_FromString((*$1)[i].attr.ftrace.padding);
289 PyTuple_SetItem(function, 0, f_symbolname);
290 PyTuple_SetItem(function, 1, f_pad);
292 PyTuple_SetItem(probe, 0, addr);
293 PyTuple_SetItem(probe, 1, offset);
294 PyTuple_SetItem(probe, 2, symbolname);
295 PyTuple_SetItem(probe, 3, probepad);
297 PyTuple_SetItem(tmp, 0, name);
298 PyTuple_SetItem(tmp, 1, type);
299 PyTuple_SetItem(tmp, 2, logleveltype);
300 PyTuple_SetItem(tmp, 3, loglevel);
301 PyTuple_SetItem(tmp, 4, enabled);
302 PyTuple_SetItem(tmp, 5, pid);
303 PyTuple_SetItem(tmp, 6, padding);
304 PyTuple_SetItem(tmp, 7, probe);
305 PyTuple_SetItem(tmp, 8, function);
306 PyTuple_SetItem(tmp, 9, attrpadding);
307 PyList_Append(events, tmp);
312 %typemap(in,numinputs=0) struct lttng_event **events (struct lttng_event *temp){
318 // =============================================
320 // =============================================
322 %rename("create") lttng_create_session(const char *name, const char *path);
323 %rename("create_snapshot") lttng_create_session_snapshot(const char *name, const char *snapshot_url);
324 %rename("destroy") lttng_destroy_session(const char *name);
325 %rename("_lttng_create_handle") lttng_create_handle(const char *session_name, struct lttng_domain *domain);
326 %rename("_lttng_destroy_handle") lttng_destroy_handle(struct lttng_handle *handle);
327 %rename("_lttng_list_sessions") lttng_list_sessions(struct lttng_session **sessions);
328 %rename("_lttng_list_domains") lttng_list_domains(const char *session_name, struct lttng_domain **domains);
329 %rename("_lttng_list_channels") lttng_list_channels(struct lttng_handle *handle,struct lttng_channel **channels);
330 %rename("_lttng_list_events") lttng_list_events(struct lttng_handle *handle, const char *channel_name, struct lttng_event **events);
331 %rename("_lttng_list_tracepoints") lttng_list_tracepoints(struct lttng_handle *handle, struct lttng_event **events);
332 %rename("session_daemon_alive") lttng_session_daemon_alive(void);
333 %rename("set_tracing_group") lttng_set_tracing_group(const char *name);
334 %rename("strerror") lttng_strerror(int code);
335 %rename("_lttng_register_consumer") lttng_register_consumer(struct lttng_handle *handle, const char *socket_path);
336 %rename("start") lttng_start_tracing(const char *session_name);
337 %rename("stop") lttng_stop_tracing(const char *session_name);
338 %rename("_lttng_add_context") lttng_add_context(struct lttng_handle *handle, struct lttng_event_context *ctx, const char *event_name, const char *channel_name);
339 %rename("_lttng_enable_event") lttng_enable_event(struct lttng_handle *handle, struct lttng_event *ev, const char *channel_name);
340 %rename("_lttng_enable_channel") lttng_enable_channel(struct lttng_handle *handle, struct lttng_channel *chan);
341 %rename("_lttng_disable_event") lttng_disable_event(struct lttng_handle *handle, const char *name, const char *channel_name);
342 %rename("_lttng_disable_channel") lttng_disable_channel(struct lttng_handle *handle, const char *name);
343 %rename("channel_set_default_attr") lttng_channel_set_default_attr(struct lttng_domain *domain, struct lttng_channel_attr *attr);
345 //Redefined functions
346 struct lttng_handle *lttng_create_handle(const char *session_name,
347 struct lttng_domain *domain);
348 void lttng_destroy_handle(struct lttng_handle *handle);
349 int lttng_list_channels(struct lttng_handle *handle,struct lttng_channel **channels);
350 int lttng_list_events(struct lttng_handle *handle,
351 const char *channel_name, struct lttng_event **events);
352 int lttng_list_tracepoints(struct lttng_handle *handle, struct lttng_event **events);
353 int lttng_add_context(struct lttng_handle *handle, struct lttng_event_context *ctx,
354 const char *event_name, const char *channel_name);
355 int lttng_enable_event(struct lttng_handle *handle,
356 struct lttng_event *ev, const char *channel_name);
357 int lttng_enable_channel(struct lttng_handle *handle, struct lttng_channel *chan);
358 int lttng_disable_event(struct lttng_handle *handle,
359 const char *name, const char *channel_name);
360 int lttng_disable_channel(struct lttng_handle *handle, const char *name);
361 int lttng_register_consumer(struct lttng_handle *handle, const char *socket_path);
362 int lttng_list_sessions(struct lttng_session **sessions);
363 int lttng_list_domains(const char *session_name, struct lttng_domain **domains);
365 //Functions not needing redefinition
366 %feature("docstring")"create(str name, str path) -> int
368 Create a new tracing session using name and path.
369 Returns 0 on success or a negative error code."
370 int lttng_create_session(const char *name, const char *path);
372 %feature("docstring")"create_snapshot(str name, str snapshot_url) -> int
374 Create a new tracing session using name and snapshot_url in snapshot
375 mode (flight recorder).
376 Returns 0 on success or a negative error code."
377 int lttng_create_session_snapshot(const char *name, const char *path);
379 %feature("docstring")"destroy(str name) -> int
381 Tear down tracing session using name.
382 Returns 0 on success or a negative error code."
383 int lttng_destroy_session(const char *name);
386 %feature("docstring")"session_daemon_alive() -> int
388 Check if session daemon is alive.
389 Return 1 if alive or 0 if not.
390 On error returns a negative value."
391 int lttng_session_daemon_alive(void);
394 %feature("docstring")"set_tracing_group(str name) -> int
396 Sets the tracing_group variable with name.
397 This function allocates memory pointed to by tracing_group.
398 On success, returns 0, on error, returns -1 (null name) or -ENOMEM."
399 int lttng_set_tracing_group(const char *name);
402 %feature("docstring")"strerror(int code) -> char
404 Returns a human readable string describing
405 the error code (a negative value)."
406 const char *lttng_strerror(int code);
409 %feature("docstring")"start(str session_name) -> int
411 Start tracing for all traces of the session.
412 Returns size of returned session payload data or a negative error code."
413 int lttng_start_tracing(const char *session_name);
416 %feature("docstring")"stop(str session_name) -> int
418 Stop tracing for all traces of the session.
419 Returns size of returned session payload data or a negative error code."
420 int lttng_stop_tracing(const char *session_name);
423 %feature("docstring")"channel_set_default_attr(Domain domain, ChannelAttr attr)
425 Set default channel attributes.
426 If either or both of the arguments are null, attr content is zeroe'd."
427 void lttng_channel_set_default_attr(struct lttng_domain *domain, struct lttng_channel_attr *attr);
430 // =============================================
431 // Python redefinition of some functions
432 // (List and Handle-related)
433 // =============================================
435 %feature("docstring")""
440 list_sessions() -> dict
442 Ask the session daemon for all available sessions.
443 Returns a dict of Session instances, the key is the name;
444 on error, returns a negative value.
447 ses_list = _lttng_list_sessions()
448 if type(ses_list) is int:
453 for ses_elements in ses_list:
455 ses.name = ses_elements[0]
456 ses.path = ses_elements[1]
457 ses.enabled = ses_elements[2]
458 ses.padding = ses_elements[3]
460 sessions[ses.name] = ses
465 def list_domains(session_name):
467 list_domains(str session_name) -> list
469 Ask the session daemon for all available domains of a session.
470 Returns a list of Domain instances;
471 on error, returns a negative value.
474 dom_list = _lttng_list_domains(session_name)
475 if type(dom_list) is int:
480 for dom_elements in dom_list:
482 dom.type = dom_elements[0]
483 dom.buf_type = dom_elements[1]
484 dom.paddinf = dom_elements[2]
485 dom.attr.pid = dom_elements[3]
486 dom.attr.exec_name = dom_elements[4]
487 dom.attr.padding = dom_elements[5]
494 def list_channels(handle):
496 list_channels(Handle handle) -> dict
498 Ask the session daemon for all available channels of a session.
499 Returns a dict of Channel instances, the key is the name;
500 on error, returns a negative value.
504 chan_list = _lttng_list_channels(handle._h)
505 except AttributeError:
506 raise TypeError("in method 'list_channels', argument 1 must be a Handle instance")
508 if type(chan_list) is int:
513 for channel_elements in chan_list:
515 chan.name = channel_elements[0]
516 chan.enabled = channel_elements[1]
517 chan.padding = channel_elements[2]
518 chan.attr.overwrite = channel_elements[3][0]
519 chan.attr.subbuf_size = channel_elements[3][1]
520 chan.attr.num_subbuf = channel_elements[3][2]
521 chan.attr.switch_timer_interval = channel_elements[3][3]
522 chan.attr.read_timer_interval = channel_elements[3][4]
523 chan.attr.output = channel_elements[3][5]
524 chan.attr.padding = channel_elements[3][6]
526 channels[chan.name] = chan
531 def list_events(handle, channel_name):
533 list_events(Handle handle, str channel_name) -> dict
535 Ask the session daemon for all available events of a session channel.
536 Returns a dict of Event instances, the key is the name;
537 on error, returns a negative value.
541 ev_list = _lttng_list_events(handle._h, channel_name)
542 except AttributeError:
543 raise TypeError("in method 'list_events', argument 1 must be a Handle instance")
545 if type(ev_list) is int:
550 for ev_elements in ev_list:
552 ev.name = ev_elements[0]
553 ev.type = ev_elements[1]
554 ev.loglevel_type = ev_elements[2]
555 ev.loglevel = ev_elements[3]
556 ev.enabled = ev_elements[4]
557 ev.pid = ev_elements[5]
558 ev.attr.padding = ev_elements[6]
559 ev.attr.probe.addr = ev_elements[7][0]
560 ev.attr.probe.offset = ev_elements[7][1]
561 ev.attr.probe.symbol_name = ev_elements[7][2]
562 ev.attr.probe.padding = ev_elements[7][3]
563 ev.attr.ftrace.symbol_name = ev_elements[8][0]
564 ev.attr.ftrace.padding = ev_elements[8][1]
565 ev.attr.padding = ev_elements[9]
572 def list_tracepoints(handle):
574 list_tracepoints(Handle handle) -> dict
576 Returns a dict of Event instances, the key is the name;
577 on error, returns a negative value.
581 ev_list = _lttng_list_tracepoints(handle._h)
582 except AttributeError:
583 raise TypeError("in method 'list_tracepoints', argument 1 must be a Handle instance")
585 if type(ev_list) is int:
590 for ev_elements in ev_list:
592 ev.name = ev_elements[0]
593 ev.type = ev_elements[1]
594 ev.loglevel_type = ev_elements[2]
595 ev.loglevel = ev_elements[3]
596 ev.enabled = ev_elements[4]
597 ev.pid = ev_elements[5]
598 ev.attr.padding = ev_elements[6]
599 ev.attr.probe.addr = ev_elements[7][0]
600 ev.attr.probe.offset = ev_elements[7][1]
601 ev.attr.probe.symbol_name = ev_elements[7][2]
602 ev.attr.probe.padding = ev_elements[7][3]
603 ev.attr.ftrace.symbol_name = ev_elements[8][0]
604 ev.attr.ftrace.padding = ev_elements[8][1]
605 ev.attr.padding = ev_elements[9]
612 def register_consumer(handle, socket_path):
614 register_consumer(Handle handle, str socket_path) -> int
616 Register an outside consumer.
617 Returns size of returned session payload data or a negative error code.
621 return _lttng_register_consumer(handle._h, socket_path)
622 except AttributeError:
623 raise TypeError("in method 'register_consumer', argument 1 must be a Handle instance")
626 def add_context(handle, event_context, event_name, channel_name):
628 add_context(Handle handle, EventContext ctx,
629 str event_name, str channel_name) -> int
631 Add context to event and/or channel.
632 If event_name is None, the context is applied to all events of the channel.
633 If channel_name is None, a lookup of the event's channel is done.
634 If both are None, the context is applied to all events of all channels.
635 Returns the size of the returned payload data or a negative error code.
639 return _lttng_add_context(handle._h, event_context, event_name, channel_name)
640 except AttributeError:
641 raise TypeError("in method 'add_context', argument 1 must be a Handle instance")
644 def enable_event(handle, event, channel_name):
646 enable_event(Handle handle, Event event,
647 str channel_name) -> int
649 Enable event(s) for a channel.
650 If no event name is specified, all events are enabled.
651 If no channel name is specified, the default 'channel0' is used.
652 Returns size of returned session payload data or a negative error code.
656 return _lttng_enable_event(handle._h, event, channel_name)
657 except AttributeError:
658 raise TypeError("in method 'enable_event', argument 1 must be a Handle instance")
661 def enable_channel(handle, channel):
663 enable_channel(Handle handle, Channel channel -> int
665 Enable channel per domain
666 Returns size of returned session payload data or a negative error code.
670 return _lttng_enable_channel(handle._h, channel)
671 except AttributeError:
672 raise TypeError("in method 'enable_channel', argument 1 must be a Handle instance")
675 def disable_event(handle, name, channel_name):
677 disable_event(Handle handle, str name, str channel_name) -> int
679 Disable event(s) of a channel and domain.
680 If no event name is specified, all events are disabled.
681 If no channel name is specified, the default 'channel0' is used.
682 Returns size of returned session payload data or a negative error code
686 return _lttng_disable_event(handle._h, name, channel_name)
687 except AttributeError:
688 raise TypeError("in method 'disable_event', argument 1 must be a Handle instance")
691 def disable_channel(handle, name):
693 disable_channel(Handle handle, str name) -> int
695 All tracing will be stopped for registered events of the channel.
696 Returns size of returned session payload data or a negative error code.
700 return _lttng_disable_channel(handle._h, name)
701 except AttributeError:
702 raise TypeError("in method 'disable_channel', argument 1 must be a Handle instance")
706 // =============================================
708 // Used to prevent freeing unallocated memory
709 // =============================================
711 %feature("docstring")""
712 %feature("autodoc", "1");
718 Takes two arguments: (str session_name, Domain domain)
723 def __init__(self, session_name, domain):
724 if type(session_name) is not str:
725 raise TypeError("in method '__init__', argument 2 of type 'str'")
726 if type(domain) is not Domain and domain is not None:
727 raise TypeError("in method '__init__', argument 3 of type 'lttng.Domain'")
729 self._sname = session_name
733 self._domtype = domain.type
734 self._h = _lttng_create_handle(session_name, domain)
738 _lttng_destroy_handle(self._h)
741 if self._domtype == 1:
742 domstr = "DOMAIN_KERNEL"
743 elif self._domtype == 2:
744 domstr = "DOMAIN_UST"
746 domstr = self._domtype
748 return "lttng.Handle; session('{}'), domain.type({})".format(
751 def __setattr__(self, attr, val):
753 raise NotImplementedError("cannot modify attributes")
755 self.__dict__[attr] = val
759 // =============================================
761 // These are directly taken from lttng.h.
762 // Any change to these structures must also be
764 // =============================================
766 %rename("Domain") lttng_domain;
767 %rename("EventContext") lttng_event_context;
768 %rename("Event") lttng_event;
769 %rename("ChannelAttr") lttng_channel_attr;
770 %rename("Channel") lttng_channel;
771 %rename("Session") lttng_session;
774 enum lttng_domain_type type;
775 enum lttng_buffer_type buf_type;
776 char padding[LTTNG_DOMAIN_PADDING1];
780 char exec_name[NAME_MAX];
781 char padding[LTTNG_DOMAIN_PADDING2];
786 static char temp[256];
787 static char domain_type[25];
788 static char buffer_type[25];
789 switch ( $self->type ) {
791 sprintf(domain_type, "type(DOMAIN_KERNEL)");
794 sprintf(domain_type, "type(DOMAIN_UST)");
797 sprintf(domain_type, "type(%i)", $self->type);
801 switch ( $self->buf_type ) {
802 case LTTNG_BUFFER_PER_UID:
803 sprintf(buffer_type, "buf_type(BUFFER_PER_UID)");
805 case LTTNG_BUFFER_PER_PID:
806 sprintf(buffer_type, "buf_type(BUFFER_PER_PID)");
808 case LTTNG_BUFFER_GLOBAL:
809 sprintf(buffer_type, "buf_type(BUFFER_GLOBAL)");
812 sprintf(buffer_type, "buf_type(%i)", $self->buf_type);
816 sprintf(temp, "lttng.Domain; %s, %s",
825 struct lttng_event_context {
826 enum lttng_event_context_type ctx;
827 char padding[LTTNG_EVENT_CONTEXT_PADDING1];
830 struct lttng_event_perf_counter_ctx perf_counter;
831 char padding[LTTNG_EVENT_CONTEXT_PADDING2];
836 static char temp[256];
837 switch ( $self->ctx ) {
839 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PID)");
842 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PERF_COUNTER)");
845 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PROCNAME)");
848 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PRIO)");
851 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_NICE)");
854 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VPID)");
857 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_TID)");
860 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VTID)");
863 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PPID)");
866 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VPPID)");
869 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PTHREAD_ID)");
872 sprintf(temp, "lttng.EventContext; type(%i)", $self->ctx);
880 struct lttng_event_probe_attr {
883 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
884 char padding[LTTNG_EVENT_PROBE_PADDING1];
887 struct lttng_event_function_attr {
888 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
889 char padding[LTTNG_EVENT_FUNCTION_PADDING1];
893 enum lttng_event_type type;
894 char name[LTTNG_SYMBOL_NAME_LEN];
896 enum lttng_loglevel_type loglevel_type;
902 char padding[LTTNG_EVENT_PADDING1];
905 struct lttng_event_probe_attr probe;
906 struct lttng_event_function_attr ftrace;
908 char padding[LTTNG_EVENT_PADDING2];
913 static char temp[512];
917 switch ( $self->type ) {
919 sprintf(evtype, "EVENT_ALL");
922 sprintf(evtype, "EVENT_TRACEPOINT");
925 sprintf(evtype, "EVENT_PROBE");
928 sprintf(evtype, "EVENT_FUNCTION");
931 sprintf(evtype, "EVENT_FUNCTION_ENTRY");
934 sprintf(evtype, "EVENT_NOOP");
937 sprintf(evtype, "EVENT_SYSCALL");
940 sprintf(evtype, "%i", $self->type);
944 switch ( $self->loglevel_type ) {
946 sprintf(logtype, "EVENT_LOGLEVEL_ALL");
949 sprintf(logtype, "EVENT_LOGLEVEL_RANGE");
952 sprintf(logtype, "EVENT_LOGLEVEL_SINGLE");
955 sprintf(logtype, "%i", $self->loglevel_type);
959 sprintf(temp, "lttng.Event; name('%s'), type(%s), "
960 "loglevel_type(%s), loglevel(%i), "
961 "enabled(%s), pid(%i)",
962 $self->name, evtype, logtype, $self->loglevel,
963 $self->enabled ? "True" : "False", $self->pid);
969 struct lttng_channel_attr {
971 uint64_t subbuf_size;
973 unsigned int switch_timer_interval;
974 unsigned int read_timer_interval;
975 enum lttng_event_output output;
977 char padding[LTTNG_CHANNEL_ATTR_PADDING1];
981 static char temp[256];
984 switch ( $self->output ) {
986 sprintf(evout, "EVENT_SPLICE");
989 sprintf(evout, "EVENT_MMAP");
992 sprintf(evout, "%i", $self->output);
995 sprintf(temp, "lttng.ChannelAttr; overwrite(%i), subbuf_size(%"PRIu64"), "
996 "num_subbuf(%"PRIu64"), switch_timer_interval(%u), "
997 "read_timer_interval(%u), output(%s)",
998 $self->overwrite, $self->subbuf_size, $self->num_subbuf,
999 $self->switch_timer_interval, $self->read_timer_interval,
1006 struct lttng_channel {
1007 char name[LTTNG_SYMBOL_NAME_LEN];
1009 struct lttng_channel_attr attr;
1010 char padding[LTTNG_CHANNEL_PADDING1];
1014 static char temp[512];
1015 snprintf(temp, sizeof(temp), "lttng.Channel; name('%s'), enabled(%s)",
1016 $self->name, $self->enabled ? "True" : "False");
1022 struct lttng_session {
1023 char name[NAME_MAX];
1024 char path[PATH_MAX];
1026 uint32_t snapshot_mode;
1027 unsigned int live_timer_interval;
1029 char padding[LTTNG_SESSION_PADDING1];
1035 static char temp[PATH_MAX + NAME_MAX + 512];
1036 snprintf(temp, sizeof(temp), "lttng.Session; name('%s'), path('%s'), enabled(%s)",
1037 $self->name, $self->path,
1038 $self->enabled ? "True" : "False");