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,
141 // =============================================
143 // =============================================
146 %typemap(argout) struct lttng_session **sessions{
148 int l = PyInt_AsSsize_t($result);
151 PyObject *sessions = PyList_New(0);
155 PyObject *tmp = PyTuple_New(4);
156 PyObject *name = PyString_FromString((*$1)[i].name);
157 PyObject *path = PyString_FromString((*$1)[i].path);
158 PyObject *enabled = PyInt_FromSize_t((*$1)[i].enabled);
159 PyObject *padding = PyString_FromString((*$1)[i].padding);
161 PyTuple_SetItem(tmp, 0, name);
162 PyTuple_SetItem(tmp, 1, path);
163 PyTuple_SetItem(tmp, 2, enabled);
164 PyTuple_SetItem(tmp, 3, padding);
165 PyList_Append(sessions, tmp);
170 %typemap(in,numinputs=0) struct lttng_session **sessions (struct lttng_session *temp){
175 %typemap(argout) struct lttng_domain **domains{
177 int l = PyInt_AsSsize_t($result);
180 PyObject *dom = PyList_New(0);
184 PyObject *tmp = PyTuple_New(5);
185 PyObject *type = PyInt_FromSize_t((*$1)[i].type);
186 PyObject *execname = PyString_FromString((*$1)[i].attr.exec_name);
187 PyObject *pid = PyInt_FromSize_t((*$1)[i].attr.pid);
188 PyObject *padding = PyString_FromString((*$1)[i].padding);
189 PyObject *attrpadding = PyString_FromString((*$1)[i].attr.padding);
191 PyTuple_SetItem(tmp, 0, type);
192 PyTuple_SetItem(tmp, 1, padding);
193 PyTuple_SetItem(tmp, 2, pid);
194 PyTuple_SetItem(tmp, 3, execname);
195 PyTuple_SetItem(tmp, 4, attrpadding);
196 PyList_Append(dom, tmp);
201 %typemap(in,numinputs=0) struct lttng_domain **domains (struct lttng_domain *temp){
206 %typemap(argout) struct lttng_channel **channels{
208 int l = PyInt_AsSsize_t($result);
211 PyObject *chan = PyList_New(0);
215 PyObject *tmp = PyTuple_New(4);
216 PyObject *name = PyString_FromString((*$1)[i].name);
217 PyObject *enabled = PyInt_FromSize_t((*$1)[i].enabled);
218 PyObject *padding = PyString_FromString((*$1)[i].padding);
220 PyObject *attrtmp = PyTuple_New(7);
221 PyObject *overwrite = PyInt_FromLong((*$1)[i].attr.overwrite);
222 PyObject *subbuf = PyInt_FromSize_t((*$1)[i].attr.subbuf_size);
223 PyObject *num = PyInt_FromSize_t((*$1)[i].attr.num_subbuf);
224 PyObject *switchtimer = PyInt_FromSize_t((*$1)[i].attr.switch_timer_interval);
225 PyObject *readtimer = PyInt_FromSize_t((*$1)[i].attr.read_timer_interval);
226 PyObject *output = PyInt_FromSize_t((*$1)[i].attr.output);
227 PyObject *attrpad = PyString_FromString((*$1)[i].attr.padding);
229 PyTuple_SetItem(attrtmp, 0, overwrite);
230 PyTuple_SetItem(attrtmp, 1, subbuf);
231 PyTuple_SetItem(attrtmp, 2, num);
232 PyTuple_SetItem(attrtmp, 3, switchtimer);
233 PyTuple_SetItem(attrtmp, 4, readtimer);
234 PyTuple_SetItem(attrtmp, 5, output);
235 PyTuple_SetItem(attrtmp, 6, attrpad);
237 PyTuple_SetItem(tmp, 0, name);
238 PyTuple_SetItem(tmp, 1, enabled);
239 PyTuple_SetItem(tmp, 2, padding);
240 PyTuple_SetItem(tmp, 3, attrtmp);
241 PyList_Append(chan, tmp);
246 %typemap(in,numinputs=0) struct lttng_channel **channels (struct lttng_channel *temp){
250 //list_events & list_tracepoints
251 %typemap(argout) struct lttng_event **events{
253 int l = PyInt_AsSsize_t($result);
256 PyObject *events = PyList_New(0);
260 PyObject *tmp = PyTuple_New(10);
261 PyObject *name = PyString_FromString((*$1)[i].name);
262 PyObject *type = PyInt_FromSize_t((*$1)[i].type);
263 PyObject *logleveltype = PyInt_FromSize_t((*$1)[i].loglevel_type);
264 PyObject *loglevel = PyInt_FromLong((*$1)[i].loglevel);
265 PyObject *enabled = PyInt_FromLong((*$1)[i].enabled);
266 PyObject *pid = PyInt_FromSize_t((*$1)[i].pid);
267 PyObject *padding = PyString_FromString((*$1)[i].padding);
268 PyObject *attrpadding = PyString_FromString((*$1)[i].attr.padding);
270 PyObject *probe = PyTuple_New(4);
271 PyObject *addr = PyInt_FromSize_t((*$1)[i].attr.probe.addr);
272 PyObject *offset = PyInt_FromSize_t((*$1)[i].attr.probe.offset);
273 PyObject *symbolname = PyString_FromString((*$1)[i].attr.probe.symbol_name);
274 PyObject *probepad = PyString_FromString((*$1)[i].attr.probe.padding);
276 PyObject *function = PyTuple_New(2);
277 PyObject *f_symbolname = PyString_FromString((*$1)[i].attr.ftrace.symbol_name);
278 PyObject *f_pad = PyString_FromString((*$1)[i].attr.ftrace.padding);
280 PyTuple_SetItem(function, 0, f_symbolname);
281 PyTuple_SetItem(function, 1, f_pad);
283 PyTuple_SetItem(probe, 0, addr);
284 PyTuple_SetItem(probe, 1, offset);
285 PyTuple_SetItem(probe, 2, symbolname);
286 PyTuple_SetItem(probe, 3, probepad);
288 PyTuple_SetItem(tmp, 0, name);
289 PyTuple_SetItem(tmp, 1, type);
290 PyTuple_SetItem(tmp, 2, logleveltype);
291 PyTuple_SetItem(tmp, 3, loglevel);
292 PyTuple_SetItem(tmp, 4, enabled);
293 PyTuple_SetItem(tmp, 5, pid);
294 PyTuple_SetItem(tmp, 6, padding);
295 PyTuple_SetItem(tmp, 7, probe);
296 PyTuple_SetItem(tmp, 8, function);
297 PyTuple_SetItem(tmp, 9, attrpadding);
298 PyList_Append(events, tmp);
303 %typemap(in,numinputs=0) struct lttng_event **events (struct lttng_event *temp){
309 // =============================================
311 // =============================================
313 %rename("create") lttng_create_session(const char *name, const char *path);
314 %rename("create_snapshot") lttng_create_session_snapshot(const char *name, const char *snapshot_url);
315 %rename("destroy") lttng_destroy_session(const char *name);
316 %rename("_lttng_create_handle") lttng_create_handle(const char *session_name, struct lttng_domain *domain);
317 %rename("_lttng_destroy_handle") lttng_destroy_handle(struct lttng_handle *handle);
318 %rename("_lttng_list_sessions") lttng_list_sessions(struct lttng_session **sessions);
319 %rename("_lttng_list_domains") lttng_list_domains(const char *session_name, struct lttng_domain **domains);
320 %rename("_lttng_list_channels") lttng_list_channels(struct lttng_handle *handle,struct lttng_channel **channels);
321 %rename("_lttng_list_events") lttng_list_events(struct lttng_handle *handle, const char *channel_name, struct lttng_event **events);
322 %rename("_lttng_list_tracepoints") lttng_list_tracepoints(struct lttng_handle *handle, struct lttng_event **events);
323 %rename("session_daemon_alive") lttng_session_daemon_alive(void);
324 %rename("set_tracing_group") lttng_set_tracing_group(const char *name);
325 %rename("strerror") lttng_strerror(int code);
326 %rename("_lttng_register_consumer") lttng_register_consumer(struct lttng_handle *handle, const char *socket_path);
327 %rename("start") lttng_start_tracing(const char *session_name);
328 %rename("stop") lttng_stop_tracing(const char *session_name);
329 %rename("_lttng_add_context") lttng_add_context(struct lttng_handle *handle, struct lttng_event_context *ctx, const char *event_name, const char *channel_name);
330 %rename("_lttng_enable_event") lttng_enable_event(struct lttng_handle *handle, struct lttng_event *ev, const char *channel_name);
331 %rename("_lttng_enable_channel") lttng_enable_channel(struct lttng_handle *handle, struct lttng_channel *chan);
332 %rename("_lttng_disable_event") lttng_disable_event(struct lttng_handle *handle, const char *name, const char *channel_name);
333 %rename("_lttng_disable_channel") lttng_disable_channel(struct lttng_handle *handle, const char *name);
334 %rename("channel_set_default_attr") lttng_channel_set_default_attr(struct lttng_domain *domain, struct lttng_channel_attr *attr);
336 //Redefined functions
337 struct lttng_handle *lttng_create_handle(const char *session_name,
338 struct lttng_domain *domain);
339 void lttng_destroy_handle(struct lttng_handle *handle);
340 int lttng_list_channels(struct lttng_handle *handle,struct lttng_channel **channels);
341 int lttng_list_events(struct lttng_handle *handle,
342 const char *channel_name, struct lttng_event **events);
343 int lttng_list_tracepoints(struct lttng_handle *handle, struct lttng_event **events);
344 int lttng_add_context(struct lttng_handle *handle, struct lttng_event_context *ctx,
345 const char *event_name, const char *channel_name);
346 int lttng_enable_event(struct lttng_handle *handle,
347 struct lttng_event *ev, const char *channel_name);
348 int lttng_enable_channel(struct lttng_handle *handle, struct lttng_channel *chan);
349 int lttng_disable_event(struct lttng_handle *handle,
350 const char *name, const char *channel_name);
351 int lttng_disable_channel(struct lttng_handle *handle, const char *name);
352 int lttng_register_consumer(struct lttng_handle *handle, const char *socket_path);
353 int lttng_list_sessions(struct lttng_session **sessions);
354 int lttng_list_domains(const char *session_name, struct lttng_domain **domains);
356 //Functions not needing redefinition
357 %feature("docstring")"create(str name, str path) -> int
359 Create a new tracing session using name and path.
360 Returns 0 on success or a negative error code."
361 int lttng_create_session(const char *name, const char *path);
363 %feature("docstring")"create_snapshot(str name, str snapshot_url) -> int
365 Create a new tracing session using name and snapshot_url in snapshot
366 mode (flight recorder).
367 Returns 0 on success or a negative error code."
368 int lttng_create_session_snapshot(const char *name, const char *path);
370 %feature("docstring")"destroy(str name) -> int
372 Tear down tracing session using name.
373 Returns 0 on success or a negative error code."
374 int lttng_destroy_session(const char *name);
377 %feature("docstring")"session_daemon_alive() -> int
379 Check if session daemon is alive.
380 Return 1 if alive or 0 if not.
381 On error returns a negative value."
382 int lttng_session_daemon_alive(void);
385 %feature("docstring")"set_tracing_group(str name) -> int
387 Sets the tracing_group variable with name.
388 This function allocates memory pointed to by tracing_group.
389 On success, returns 0, on error, returns -1 (null name) or -ENOMEM."
390 int lttng_set_tracing_group(const char *name);
393 %feature("docstring")"strerror(int code) -> char
395 Returns a human readable string describing
396 the error code (a negative value)."
397 const char *lttng_strerror(int code);
400 %feature("docstring")"start(str session_name) -> int
402 Start tracing for all traces of the session.
403 Returns size of returned session payload data or a negative error code."
404 int lttng_start_tracing(const char *session_name);
407 %feature("docstring")"stop(str session_name) -> int
409 Stop tracing for all traces of the session.
410 Returns size of returned session payload data or a negative error code."
411 int lttng_stop_tracing(const char *session_name);
414 %feature("docstring")"channel_set_default_attr(Domain domain, ChannelAttr attr)
416 Set default channel attributes.
417 If either or both of the arguments are null, attr content is zeroe'd."
418 void lttng_channel_set_default_attr(struct lttng_domain *domain, struct lttng_channel_attr *attr);
421 // =============================================
422 // Python redefinition of some functions
423 // (List and Handle-related)
424 // =============================================
426 %feature("docstring")""
431 list_sessions() -> dict
433 Ask the session daemon for all available sessions.
434 Returns a dict of Session instances, the key is the name;
435 on error, returns a negative value.
438 ses_list = _lttng_list_sessions()
439 if type(ses_list) is int:
444 for ses_elements in ses_list:
446 ses.name = ses_elements[0]
447 ses.path = ses_elements[1]
448 ses.enabled = ses_elements[2]
449 ses.padding = ses_elements[3]
451 sessions[ses.name] = ses
456 def list_domains(session_name):
458 list_domains(str session_name) -> list
460 Ask the session daemon for all available domains of a session.
461 Returns a list of Domain instances;
462 on error, returns a negative value.
465 dom_list = _lttng_list_domains(session_name)
466 if type(dom_list) is int:
471 for dom_elements in dom_list:
473 dom.type = dom_elements[0]
474 dom.paddinf = dom_elements[1]
475 dom.attr.pid = dom_elements[2]
476 dom.attr.exec_name = dom_elements[3]
477 dom.attr.padding = dom_elements[4]
484 def list_channels(handle):
486 list_channels(Handle handle) -> dict
488 Ask the session daemon for all available channels of a session.
489 Returns a dict of Channel instances, the key is the name;
490 on error, returns a negative value.
494 chan_list = _lttng_list_channels(handle._h)
495 except AttributeError:
496 raise TypeError("in method 'list_channels', argument 1 must be a Handle instance")
498 if type(chan_list) is int:
503 for channel_elements in chan_list:
505 chan.name = channel_elements[0]
506 chan.enabled = channel_elements[1]
507 chan.padding = channel_elements[2]
508 chan.attr.overwrite = channel_elements[3][0]
509 chan.attr.subbuf_size = channel_elements[3][1]
510 chan.attr.num_subbuf = channel_elements[3][2]
511 chan.attr.switch_timer_interval = channel_elements[3][3]
512 chan.attr.read_timer_interval = channel_elements[3][4]
513 chan.attr.output = channel_elements[3][5]
514 chan.attr.padding = channel_elements[3][6]
516 channels[chan.name] = chan
521 def list_events(handle, channel_name):
523 list_events(Handle handle, str channel_name) -> dict
525 Ask the session daemon for all available events of a session channel.
526 Returns a dict of Event instances, the key is the name;
527 on error, returns a negative value.
531 ev_list = _lttng_list_events(handle._h, channel_name)
532 except AttributeError:
533 raise TypeError("in method 'list_events', argument 1 must be a Handle instance")
535 if type(ev_list) is int:
540 for ev_elements in ev_list:
542 ev.name = ev_elements[0]
543 ev.type = ev_elements[1]
544 ev.loglevel_type = ev_elements[2]
545 ev.loglevel = ev_elements[3]
546 ev.enabled = ev_elements[4]
547 ev.pid = ev_elements[5]
548 ev.attr.padding = ev_elements[6]
549 ev.attr.probe.addr = ev_elements[7][0]
550 ev.attr.probe.offset = ev_elements[7][1]
551 ev.attr.probe.symbol_name = ev_elements[7][2]
552 ev.attr.probe.padding = ev_elements[7][3]
553 ev.attr.ftrace.symbol_name = ev_elements[8][0]
554 ev.attr.ftrace.padding = ev_elements[8][1]
555 ev.attr.padding = ev_elements[9]
562 def list_tracepoints(handle):
564 list_tracepoints(Handle handle) -> dict
566 Returns a dict of Event instances, the key is the name;
567 on error, returns a negative value.
571 ev_list = _lttng_list_tracepoints(handle._h)
572 except AttributeError:
573 raise TypeError("in method 'list_tracepoints', argument 1 must be a Handle instance")
575 if type(ev_list) is int:
580 for ev_elements in ev_list:
582 ev.name = ev_elements[0]
583 ev.type = ev_elements[1]
584 ev.loglevel_type = ev_elements[2]
585 ev.loglevel = ev_elements[3]
586 ev.enabled = ev_elements[4]
587 ev.pid = ev_elements[5]
588 ev.attr.padding = ev_elements[6]
589 ev.attr.probe.addr = ev_elements[7][0]
590 ev.attr.probe.offset = ev_elements[7][1]
591 ev.attr.probe.symbol_name = ev_elements[7][2]
592 ev.attr.probe.padding = ev_elements[7][3]
593 ev.attr.ftrace.symbol_name = ev_elements[8][0]
594 ev.attr.ftrace.padding = ev_elements[8][1]
595 ev.attr.padding = ev_elements[9]
602 def register_consumer(handle, socket_path):
604 register_consumer(Handle handle, str socket_path) -> int
606 Register an outside consumer.
607 Returns size of returned session payload data or a negative error code.
611 return _lttng_register_consumer(handle._h, socket_path)
612 except AttributeError:
613 raise TypeError("in method 'register_consumer', argument 1 must be a Handle instance")
616 def add_context(handle, event_context, event_name, channel_name):
618 add_context(Handle handle, EventContext ctx,
619 str event_name, str channel_name) -> int
621 Add context to event and/or channel.
622 If event_name is None, the context is applied to all events of the channel.
623 If channel_name is None, a lookup of the event's channel is done.
624 If both are None, the context is applied to all events of all channels.
625 Returns the size of the returned payload data or a negative error code.
629 return _lttng_add_context(handle._h, event_context, event_name, channel_name)
630 except AttributeError:
631 raise TypeError("in method 'add_context', argument 1 must be a Handle instance")
634 def enable_event(handle, event, channel_name):
636 enable_event(Handle handle, Event event,
637 str channel_name) -> int
639 Enable event(s) for a channel.
640 If no event name is specified, all events are enabled.
641 If no channel name is specified, the default 'channel0' is used.
642 Returns size of returned session payload data or a negative error code.
646 return _lttng_enable_event(handle._h, event, channel_name)
647 except AttributeError:
648 raise TypeError("in method 'enable_event', argument 1 must be a Handle instance")
651 def enable_channel(handle, channel):
653 enable_channel(Handle handle, Channel channel -> int
655 Enable channel per domain
656 Returns size of returned session payload data or a negative error code.
660 return _lttng_enable_channel(handle._h, channel)
661 except AttributeError:
662 raise TypeError("in method 'enable_channel', argument 1 must be a Handle instance")
665 def disable_event(handle, name, channel_name):
667 disable_event(Handle handle, str name, str channel_name) -> int
669 Disable event(s) of a channel and domain.
670 If no event name is specified, all events are disabled.
671 If no channel name is specified, the default 'channel0' is used.
672 Returns size of returned session payload data or a negative error code
676 return _lttng_disable_event(handle._h, name, channel_name)
677 except AttributeError:
678 raise TypeError("in method 'disable_event', argument 1 must be a Handle instance")
681 def disable_channel(handle, name):
683 disable_channel(Handle handle, str name) -> int
685 All tracing will be stopped for registered events of the channel.
686 Returns size of returned session payload data or a negative error code.
690 return _lttng_disable_channel(handle._h, name)
691 except AttributeError:
692 raise TypeError("in method 'disable_channel', argument 1 must be a Handle instance")
696 // =============================================
698 // Used to prevent freeing unallocated memory
699 // =============================================
701 %feature("docstring")""
702 %feature("autodoc", "1");
708 Takes two arguments: (str session_name, Domain domain)
713 def __init__(self, session_name, domain):
714 if type(session_name) is not str:
715 raise TypeError("in method '__init__', argument 2 of type 'str'")
716 if type(domain) is not Domain and domain is not None:
717 raise TypeError("in method '__init__', argument 3 of type 'lttng.Domain'")
719 self._sname = session_name
723 self._domtype = domain.type
724 self._h = _lttng_create_handle(session_name, domain)
728 _lttng_destroy_handle(self._h)
731 if self._domtype == 1:
732 domstr = "DOMAIN_KERNEL"
733 elif self._domtype == 2:
734 domstr = "DOMAIN_UST"
736 domstr = self._domtype
738 return "lttng.Handle; session('{}'), domain.type({})".format(
741 def __setattr__(self, attr, val):
743 raise NotImplementedError("cannot modify attributes")
745 self.__dict__[attr] = val
749 // =============================================
751 // These are directly taken from lttng.h.
752 // Any change to these structures must also be
754 // =============================================
756 %rename("Domain") lttng_domain;
757 %rename("EventContext") lttng_event_context;
758 %rename("Event") lttng_event;
759 %rename("ChannelAttr") lttng_channel_attr;
760 %rename("Channel") lttng_channel;
761 %rename("Session") lttng_session;
764 enum lttng_domain_type type;
765 char padding[LTTNG_DOMAIN_PADDING1];
769 char exec_name[NAME_MAX];
770 char padding[LTTNG_DOMAIN_PADDING2];
775 static char temp[256];
776 switch ( $self->type ) {
778 sprintf(temp, "lttng.Domain; type(DOMAIN_KERNEL)");
781 sprintf(temp, "lttng.Domain; type(DOMAIN_UST)");
784 sprintf(temp, "lttng.Domain; type(%i)", $self->type);
792 struct lttng_event_context {
793 enum lttng_event_context_type ctx;
794 char padding[LTTNG_EVENT_CONTEXT_PADDING1];
797 struct lttng_event_perf_counter_ctx perf_counter;
798 char padding[LTTNG_EVENT_CONTEXT_PADDING2];
803 static char temp[256];
804 switch ( $self->ctx ) {
806 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PID)");
809 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PERF_COUNTER)");
812 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PROCNAME)");
815 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PRIO)");
818 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_NICE)");
821 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VPID)");
824 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_TID)");
827 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VTID)");
830 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PPID)");
833 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VPPID)");
836 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PTHREAD_ID)");
839 sprintf(temp, "lttng.EventContext; type(%i)", $self->ctx);
847 struct lttng_event_probe_attr {
850 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
851 char padding[LTTNG_EVENT_PROBE_PADDING1];
854 struct lttng_event_function_attr {
855 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
856 char padding[LTTNG_EVENT_FUNCTION_PADDING1];
860 enum lttng_event_type type;
861 char name[LTTNG_SYMBOL_NAME_LEN];
863 enum lttng_loglevel_type loglevel_type;
869 char padding[LTTNG_EVENT_PADDING1];
872 struct lttng_event_probe_attr probe;
873 struct lttng_event_function_attr ftrace;
875 char padding[LTTNG_EVENT_PADDING2];
880 static char temp[512];
884 switch ( $self->type ) {
886 sprintf(evtype, "EVENT_ALL");
889 sprintf(evtype, "EVENT_TRACEPOINT");
892 sprintf(evtype, "EVENT_PROBE");
895 sprintf(evtype, "EVENT_FUNCTION");
898 sprintf(evtype, "EVENT_FUNCTION_ENTRY");
901 sprintf(evtype, "EVENT_NOOP");
904 sprintf(evtype, "EVENT_SYSCALL");
907 sprintf(evtype, "%i", $self->type);
911 switch ( $self->loglevel_type ) {
913 sprintf(logtype, "EVENT_LOGLEVEL_ALL");
916 sprintf(logtype, "EVENT_LOGLEVEL_RANGE");
919 sprintf(logtype, "EVENT_LOGLEVEL_SINGLE");
922 sprintf(logtype, "%i", $self->loglevel_type);
926 sprintf(temp, "lttng.Event; name('%s'), type(%s), "
927 "loglevel_type(%s), loglevel(%i), "
928 "enabled(%s), pid(%i)",
929 $self->name, evtype, logtype, $self->loglevel,
930 $self->enabled ? "True" : "False", $self->pid);
936 struct lttng_channel_attr {
938 uint64_t subbuf_size;
940 unsigned int switch_timer_interval;
941 unsigned int read_timer_interval;
942 enum lttng_event_output output;
944 char padding[LTTNG_CHANNEL_ATTR_PADDING1];
948 static char temp[256];
951 switch ( $self->output ) {
953 sprintf(evout, "EVENT_SPLICE");
956 sprintf(evout, "EVENT_MMAP");
959 sprintf(evout, "%i", $self->output);
962 sprintf(temp, "lttng.ChannelAttr; overwrite(%i), subbuf_size(%"PRIu64"), "
963 "num_subbuf(%"PRIu64"), switch_timer_interval(%u), "
964 "read_timer_interval(%u), output(%s)",
965 $self->overwrite, $self->subbuf_size, $self->num_subbuf,
966 $self->switch_timer_interval, $self->read_timer_interval,
973 struct lttng_channel {
974 char name[LTTNG_SYMBOL_NAME_LEN];
976 struct lttng_channel_attr attr;
977 char padding[LTTNG_CHANNEL_PADDING1];
981 static char temp[512];
982 sprintf(temp, "lttng.Channel; name('%s'), enabled(%s)",
983 $self->name, $self->enabled ? "True" : "False");
989 struct lttng_session {
993 char padding[LTTNG_SESSION_PADDING1];
997 static char temp[512];
998 sprintf(temp, "lttng.Session; name('%s'), path('%s'), enabled(%s)",
999 $self->name, $self->path,
1000 $self->enabled ? "True" : "False");