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);
160 PyTuple_SetItem(tmp, 0, name);
161 PyTuple_SetItem(tmp, 1, path);
162 PyTuple_SetItem(tmp, 2, enabled);
163 PyList_Append(sessions, tmp);
168 %typemap(in,numinputs=0) struct lttng_session **sessions (struct lttng_session *temp){
173 %typemap(argout) struct lttng_domain **domains{
175 int l = PyInt_AsSsize_t($result);
178 PyObject *dom = PyList_New(0);
182 PyObject *tmp = PyTuple_New(5);
183 PyObject *type = PyInt_FromSize_t((*$1)[i].type);
184 PyObject *execname = PyString_FromString((*$1)[i].attr.exec_name);
185 PyObject *pid = PyInt_FromSize_t((*$1)[i].attr.pid);
186 PyObject *padding = PyString_FromString((*$1)[i].padding);
187 PyObject *attrpadding = PyString_FromString((*$1)[i].attr.padding);
189 PyTuple_SetItem(tmp, 0, type);
190 PyTuple_SetItem(tmp, 1, padding);
191 PyTuple_SetItem(tmp, 2, pid);
192 PyTuple_SetItem(tmp, 3, execname);
193 PyTuple_SetItem(tmp, 4, attrpadding);
194 PyList_Append(dom, tmp);
199 %typemap(in,numinputs=0) struct lttng_domain **domains (struct lttng_domain *temp){
204 %typemap(argout) struct lttng_channel **channels{
206 int l = PyInt_AsSsize_t($result);
209 PyObject *chan = PyList_New(0);
213 PyObject *tmp = PyTuple_New(4);
214 PyObject *name = PyString_FromString((*$1)[i].name);
215 PyObject *enabled = PyInt_FromSize_t((*$1)[i].enabled);
216 PyObject *padding = PyString_FromString((*$1)[i].padding);
218 PyObject *attrtmp = PyTuple_New(7);
219 PyObject *overwrite = PyInt_FromLong((*$1)[i].attr.overwrite);
220 PyObject *subbuf = PyInt_FromSize_t((*$1)[i].attr.subbuf_size);
221 PyObject *num = PyInt_FromSize_t((*$1)[i].attr.num_subbuf);
222 PyObject *switchtimer = PyInt_FromSize_t((*$1)[i].attr.switch_timer_interval);
223 PyObject *readtimer = PyInt_FromSize_t((*$1)[i].attr.read_timer_interval);
224 PyObject *output = PyInt_FromSize_t((*$1)[i].attr.output);
225 PyObject *attrpad = PyString_FromString((*$1)[i].attr.padding);
227 PyTuple_SetItem(attrtmp, 0, overwrite);
228 PyTuple_SetItem(attrtmp, 1, subbuf);
229 PyTuple_SetItem(attrtmp, 2, num);
230 PyTuple_SetItem(attrtmp, 3, switchtimer);
231 PyTuple_SetItem(attrtmp, 4, readtimer);
232 PyTuple_SetItem(attrtmp, 5, output);
233 PyTuple_SetItem(attrtmp, 6, attrpad);
235 PyTuple_SetItem(tmp, 0, name);
236 PyTuple_SetItem(tmp, 1, enabled);
237 PyTuple_SetItem(tmp, 2, padding);
238 PyTuple_SetItem(tmp, 3, attrtmp);
239 PyList_Append(chan, tmp);
244 %typemap(in,numinputs=0) struct lttng_channel **channels (struct lttng_channel *temp){
248 //list_events & list_tracepoints
249 %typemap(argout) struct lttng_event **events{
251 int l = PyInt_AsSsize_t($result);
254 PyObject *events = PyList_New(0);
258 PyObject *tmp = PyTuple_New(10);
259 PyObject *name = PyString_FromString((*$1)[i].name);
260 PyObject *type = PyInt_FromSize_t((*$1)[i].type);
261 PyObject *logleveltype = PyInt_FromSize_t((*$1)[i].loglevel_type);
262 PyObject *loglevel = PyInt_FromLong((*$1)[i].loglevel);
263 PyObject *enabled = PyInt_FromLong((*$1)[i].enabled);
264 PyObject *pid = PyInt_FromSize_t((*$1)[i].pid);
265 PyObject *padding = PyString_FromString((*$1)[i].padding);
266 PyObject *attrpadding = PyString_FromString((*$1)[i].attr.padding);
268 PyObject *probe = PyTuple_New(4);
269 PyObject *addr = PyInt_FromSize_t((*$1)[i].attr.probe.addr);
270 PyObject *offset = PyInt_FromSize_t((*$1)[i].attr.probe.offset);
271 PyObject *symbolname = PyString_FromString((*$1)[i].attr.probe.symbol_name);
272 PyObject *probepad = PyString_FromString((*$1)[i].attr.probe.padding);
274 PyObject *function = PyTuple_New(2);
275 PyObject *f_symbolname = PyString_FromString((*$1)[i].attr.ftrace.symbol_name);
276 PyObject *f_pad = PyString_FromString((*$1)[i].attr.ftrace.padding);
278 PyTuple_SetItem(function, 0, f_symbolname);
279 PyTuple_SetItem(function, 1, f_pad);
281 PyTuple_SetItem(probe, 0, addr);
282 PyTuple_SetItem(probe, 1, offset);
283 PyTuple_SetItem(probe, 2, symbolname);
284 PyTuple_SetItem(probe, 3, probepad);
286 PyTuple_SetItem(tmp, 0, name);
287 PyTuple_SetItem(tmp, 1, type);
288 PyTuple_SetItem(tmp, 2, logleveltype);
289 PyTuple_SetItem(tmp, 3, loglevel);
290 PyTuple_SetItem(tmp, 4, enabled);
291 PyTuple_SetItem(tmp, 5, pid);
292 PyTuple_SetItem(tmp, 6, padding);
293 PyTuple_SetItem(tmp, 7, probe);
294 PyTuple_SetItem(tmp, 8, function);
295 PyTuple_SetItem(tmp, 9, attrpadding);
296 PyList_Append(events, tmp);
301 %typemap(in,numinputs=0) struct lttng_event **events (struct lttng_event *temp){
307 // =============================================
309 // =============================================
311 %rename("create") lttng_create_session(const char *name, const char *path);
312 %rename("create_snapshot") lttng_create_session_snapshot(const char *name, const char *snapshot_url);
313 %rename("destroy") lttng_destroy_session(const char *name);
314 %rename("_lttng_create_handle") lttng_create_handle(const char *session_name, struct lttng_domain *domain);
315 %rename("_lttng_destroy_handle") lttng_destroy_handle(struct lttng_handle *handle);
316 %rename("_lttng_list_sessions") lttng_list_sessions(struct lttng_session **sessions);
317 %rename("_lttng_list_domains") lttng_list_domains(const char *session_name, struct lttng_domain **domains);
318 %rename("_lttng_list_channels") lttng_list_channels(struct lttng_handle *handle,struct lttng_channel **channels);
319 %rename("_lttng_list_events") lttng_list_events(struct lttng_handle *handle, const char *channel_name, struct lttng_event **events);
320 %rename("_lttng_list_tracepoints") lttng_list_tracepoints(struct lttng_handle *handle, struct lttng_event **events);
321 %rename("session_daemon_alive") lttng_session_daemon_alive(void);
322 %rename("set_tracing_group") lttng_set_tracing_group(const char *name);
323 %rename("strerror") lttng_strerror(int code);
324 %rename("_lttng_register_consumer") lttng_register_consumer(struct lttng_handle *handle, const char *socket_path);
325 %rename("start") lttng_start_tracing(const char *session_name);
326 %rename("stop") lttng_stop_tracing(const char *session_name);
327 %rename("_lttng_add_context") lttng_add_context(struct lttng_handle *handle, struct lttng_event_context *ctx, const char *event_name, const char *channel_name);
328 %rename("_lttng_enable_event") lttng_enable_event(struct lttng_handle *handle, struct lttng_event *ev, const char *channel_name);
329 %rename("_lttng_enable_channel") lttng_enable_channel(struct lttng_handle *handle, struct lttng_channel *chan);
330 %rename("_lttng_disable_event") lttng_disable_event(struct lttng_handle *handle, const char *name, const char *channel_name);
331 %rename("_lttng_disable_channel") lttng_disable_channel(struct lttng_handle *handle, const char *name);
332 %rename("channel_set_default_attr") lttng_channel_set_default_attr(struct lttng_domain *domain, struct lttng_channel_attr *attr);
334 //Redefined functions
335 struct lttng_handle *lttng_create_handle(const char *session_name,
336 struct lttng_domain *domain);
337 void lttng_destroy_handle(struct lttng_handle *handle);
338 int lttng_list_channels(struct lttng_handle *handle,struct lttng_channel **channels);
339 int lttng_list_events(struct lttng_handle *handle,
340 const char *channel_name, struct lttng_event **events);
341 int lttng_list_tracepoints(struct lttng_handle *handle, struct lttng_event **events);
342 int lttng_add_context(struct lttng_handle *handle, struct lttng_event_context *ctx,
343 const char *event_name, const char *channel_name);
344 int lttng_enable_event(struct lttng_handle *handle,
345 struct lttng_event *ev, const char *channel_name);
346 int lttng_enable_channel(struct lttng_handle *handle, struct lttng_channel *chan);
347 int lttng_disable_event(struct lttng_handle *handle,
348 const char *name, const char *channel_name);
349 int lttng_disable_channel(struct lttng_handle *handle, const char *name);
350 int lttng_register_consumer(struct lttng_handle *handle, const char *socket_path);
351 int lttng_list_sessions(struct lttng_session **sessions);
352 int lttng_list_domains(const char *session_name, struct lttng_domain **domains);
354 //Functions not needing redefinition
355 %feature("docstring")"create(str name, str path) -> int
357 Create a new tracing session using name and path.
358 Returns 0 on success or a negative error code."
359 int lttng_create_session(const char *name, const char *path);
361 %feature("docstring")"create_snapshot(str name, str snapshot_url) -> int
363 Create a new tracing session using name and snapshot_url in snapshot
364 mode (flight recorder).
365 Returns 0 on success or a negative error code."
366 int lttng_create_session_snapshot(const char *name, const char *path);
368 %feature("docstring")"destroy(str name) -> int
370 Tear down tracing session using name.
371 Returns 0 on success or a negative error code."
372 int lttng_destroy_session(const char *name);
375 %feature("docstring")"session_daemon_alive() -> int
377 Check if session daemon is alive.
378 Return 1 if alive or 0 if not.
379 On error returns a negative value."
380 int lttng_session_daemon_alive(void);
383 %feature("docstring")"set_tracing_group(str name) -> int
385 Sets the tracing_group variable with name.
386 This function allocates memory pointed to by tracing_group.
387 On success, returns 0, on error, returns -1 (null name) or -ENOMEM."
388 int lttng_set_tracing_group(const char *name);
391 %feature("docstring")"strerror(int code) -> char
393 Returns a human readable string describing
394 the error code (a negative value)."
395 const char *lttng_strerror(int code);
398 %feature("docstring")"start(str session_name) -> int
400 Start tracing for all traces of the session.
401 Returns size of returned session payload data or a negative error code."
402 int lttng_start_tracing(const char *session_name);
405 %feature("docstring")"stop(str session_name) -> int
407 Stop tracing for all traces of the session.
408 Returns size of returned session payload data or a negative error code."
409 int lttng_stop_tracing(const char *session_name);
412 %feature("docstring")"channel_set_default_attr(Domain domain, ChannelAttr attr)
414 Set default channel attributes.
415 If either or both of the arguments are null, attr content is zeroe'd."
416 void lttng_channel_set_default_attr(struct lttng_domain *domain, struct lttng_channel_attr *attr);
419 // =============================================
420 // Python redefinition of some functions
421 // (List and Handle-related)
422 // =============================================
424 %feature("docstring")""
429 list_sessions() -> dict
431 Ask the session daemon for all available sessions.
432 Returns a dict of Session instances, the key is the name;
433 on error, returns a negative value.
436 ses_list = _lttng_list_sessions()
437 if type(ses_list) is int:
442 for ses_elements in ses_list:
444 ses.name = ses_elements[0]
445 ses.path = ses_elements[1]
446 ses.enabled = ses_elements[2]
447 ses.padding = ses_elements[3]
449 sessions[ses.name] = ses
454 def list_domains(session_name):
456 list_domains(str session_name) -> list
458 Ask the session daemon for all available domains of a session.
459 Returns a list of Domain instances;
460 on error, returns a negative value.
463 dom_list = _lttng_list_domains(session_name)
464 if type(dom_list) is int:
469 for dom_elements in dom_list:
471 dom.type = dom_elements[0]
472 dom.paddinf = dom_elements[1]
473 dom.attr.pid = dom_elements[2]
474 dom.attr.exec_name = dom_elements[3]
475 dom.attr.padding = dom_elements[4]
482 def list_channels(handle):
484 list_channels(Handle handle) -> dict
486 Ask the session daemon for all available channels of a session.
487 Returns a dict of Channel instances, the key is the name;
488 on error, returns a negative value.
492 chan_list = _lttng_list_channels(handle._h)
493 except AttributeError:
494 raise TypeError("in method 'list_channels', argument 1 must be a Handle instance")
496 if type(chan_list) is int:
501 for channel_elements in chan_list:
503 chan.name = channel_elements[0]
504 chan.enabled = channel_elements[1]
505 chan.padding = channel_elements[2]
506 chan.attr.overwrite = channel_elements[3][0]
507 chan.attr.subbuf_size = channel_elements[3][1]
508 chan.attr.num_subbuf = channel_elements[3][2]
509 chan.attr.switch_timer_interval = channel_elements[3][3]
510 chan.attr.read_timer_interval = channel_elements[3][4]
511 chan.attr.output = channel_elements[3][5]
512 chan.attr.padding = channel_elements[3][6]
514 channels[chan.name] = chan
519 def list_events(handle, channel_name):
521 list_events(Handle handle, str channel_name) -> dict
523 Ask the session daemon for all available events of a session channel.
524 Returns a dict of Event instances, the key is the name;
525 on error, returns a negative value.
529 ev_list = _lttng_list_events(handle._h, channel_name)
530 except AttributeError:
531 raise TypeError("in method 'list_events', argument 1 must be a Handle instance")
533 if type(ev_list) is int:
538 for ev_elements in ev_list:
540 ev.name = ev_elements[0]
541 ev.type = ev_elements[1]
542 ev.loglevel_type = ev_elements[2]
543 ev.loglevel = ev_elements[3]
544 ev.enabled = ev_elements[4]
545 ev.pid = ev_elements[5]
546 ev.attr.padding = ev_elements[6]
547 ev.attr.probe.addr = ev_elements[7][0]
548 ev.attr.probe.offset = ev_elements[7][1]
549 ev.attr.probe.symbol_name = ev_elements[7][2]
550 ev.attr.probe.padding = ev_elements[7][3]
551 ev.attr.ftrace.symbol_name = ev_elements[8][0]
552 ev.attr.ftrace.padding = ev_elements[8][1]
553 ev.attr.padding = ev_elements[9]
560 def list_tracepoints(handle):
562 list_tracepoints(Handle handle) -> dict
564 Returns a dict of Event instances, the key is the name;
565 on error, returns a negative value.
569 ev_list = _lttng_list_tracepoints(handle._h)
570 except AttributeError:
571 raise TypeError("in method 'list_tracepoints', argument 1 must be a Handle instance")
573 if type(ev_list) is int:
578 for ev_elements in ev_list:
580 ev.name = ev_elements[0]
581 ev.type = ev_elements[1]
582 ev.loglevel_type = ev_elements[2]
583 ev.loglevel = ev_elements[3]
584 ev.enabled = ev_elements[4]
585 ev.pid = ev_elements[5]
586 ev.attr.padding = ev_elements[6]
587 ev.attr.probe.addr = ev_elements[7][0]
588 ev.attr.probe.offset = ev_elements[7][1]
589 ev.attr.probe.symbol_name = ev_elements[7][2]
590 ev.attr.probe.padding = ev_elements[7][3]
591 ev.attr.ftrace.symbol_name = ev_elements[8][0]
592 ev.attr.ftrace.padding = ev_elements[8][1]
593 ev.attr.padding = ev_elements[9]
600 def register_consumer(handle, socket_path):
602 register_consumer(Handle handle, str socket_path) -> int
604 Register an outside consumer.
605 Returns size of returned session payload data or a negative error code.
609 return _lttng_register_consumer(handle._h, socket_path)
610 except AttributeError:
611 raise TypeError("in method 'register_consumer', argument 1 must be a Handle instance")
614 def add_context(handle, event_context, event_name, channel_name):
616 add_context(Handle handle, EventContext ctx,
617 str event_name, str channel_name) -> int
619 Add context to event and/or channel.
620 If event_name is None, the context is applied to all events of the channel.
621 If channel_name is None, a lookup of the event's channel is done.
622 If both are None, the context is applied to all events of all channels.
623 Returns the size of the returned payload data or a negative error code.
627 return _lttng_add_context(handle._h, event_context, event_name, channel_name)
628 except AttributeError:
629 raise TypeError("in method 'add_context', argument 1 must be a Handle instance")
632 def enable_event(handle, event, channel_name):
634 enable_event(Handle handle, Event event,
635 str channel_name) -> int
637 Enable event(s) for a channel.
638 If no event name is specified, all events are enabled.
639 If no channel name is specified, the default 'channel0' is used.
640 Returns size of returned session payload data or a negative error code.
644 return _lttng_enable_event(handle._h, event, channel_name)
645 except AttributeError:
646 raise TypeError("in method 'enable_event', argument 1 must be a Handle instance")
649 def enable_channel(handle, channel):
651 enable_channel(Handle handle, Channel channel -> int
653 Enable channel per domain
654 Returns size of returned session payload data or a negative error code.
658 return _lttng_enable_channel(handle._h, channel)
659 except AttributeError:
660 raise TypeError("in method 'enable_channel', argument 1 must be a Handle instance")
663 def disable_event(handle, name, channel_name):
665 disable_event(Handle handle, str name, str channel_name) -> int
667 Disable event(s) of a channel and domain.
668 If no event name is specified, all events are disabled.
669 If no channel name is specified, the default 'channel0' is used.
670 Returns size of returned session payload data or a negative error code
674 return _lttng_disable_event(handle._h, name, channel_name)
675 except AttributeError:
676 raise TypeError("in method 'disable_event', argument 1 must be a Handle instance")
679 def disable_channel(handle, name):
681 disable_channel(Handle handle, str name) -> int
683 All tracing will be stopped for registered events of the channel.
684 Returns size of returned session payload data or a negative error code.
688 return _lttng_disable_channel(handle._h, name)
689 except AttributeError:
690 raise TypeError("in method 'disable_channel', argument 1 must be a Handle instance")
694 // =============================================
696 // Used to prevent freeing unallocated memory
697 // =============================================
699 %feature("docstring")""
700 %feature("autodoc", "1");
706 Takes two arguments: (str session_name, Domain domain)
711 def __init__(self, session_name, domain):
712 if type(session_name) is not str:
713 raise TypeError("in method '__init__', argument 2 of type 'str'")
714 if type(domain) is not Domain and domain is not None:
715 raise TypeError("in method '__init__', argument 3 of type 'lttng.Domain'")
717 self._sname = session_name
721 self._domtype = domain.type
722 self._h = _lttng_create_handle(session_name, domain)
726 _lttng_destroy_handle(self._h)
729 if self._domtype == 1:
730 domstr = "DOMAIN_KERNEL"
731 elif self._domtype == 2:
732 domstr = "DOMAIN_UST"
734 domstr = self._domtype
736 return "lttng.Handle; session('{}'), domain.type({})".format(
739 def __setattr__(self, attr, val):
741 raise NotImplementedError("cannot modify attributes")
743 self.__dict__[attr] = val
747 // =============================================
749 // These are directly taken from lttng.h.
750 // Any change to these structures must also be
752 // =============================================
754 %rename("Domain") lttng_domain;
755 %rename("EventContext") lttng_event_context;
756 %rename("Event") lttng_event;
757 %rename("ChannelAttr") lttng_channel_attr;
758 %rename("Channel") lttng_channel;
759 %rename("Session") lttng_session;
762 enum lttng_domain_type type;
763 char padding[LTTNG_DOMAIN_PADDING1];
767 char exec_name[NAME_MAX];
768 char padding[LTTNG_DOMAIN_PADDING2];
773 static char temp[256];
774 switch ( $self->type ) {
776 sprintf(temp, "lttng.Domain; type(DOMAIN_KERNEL)");
779 sprintf(temp, "lttng.Domain; type(DOMAIN_UST)");
782 sprintf(temp, "lttng.Domain; type(%i)", $self->type);
790 struct lttng_event_context {
791 enum lttng_event_context_type ctx;
792 char padding[LTTNG_EVENT_CONTEXT_PADDING1];
795 struct lttng_event_perf_counter_ctx perf_counter;
796 char padding[LTTNG_EVENT_CONTEXT_PADDING2];
801 static char temp[256];
802 switch ( $self->ctx ) {
804 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PID)");
807 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PERF_COUNTER)");
810 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PROCNAME)");
813 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PRIO)");
816 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_NICE)");
819 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VPID)");
822 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_TID)");
825 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VTID)");
828 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PPID)");
831 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VPPID)");
834 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PTHREAD_ID)");
837 sprintf(temp, "lttng.EventContext; type(%i)", $self->ctx);
845 struct lttng_event_probe_attr {
848 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
849 char padding[LTTNG_EVENT_PROBE_PADDING1];
852 struct lttng_event_function_attr {
853 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
854 char padding[LTTNG_EVENT_FUNCTION_PADDING1];
858 enum lttng_event_type type;
859 char name[LTTNG_SYMBOL_NAME_LEN];
861 enum lttng_loglevel_type loglevel_type;
867 char padding[LTTNG_EVENT_PADDING1];
870 struct lttng_event_probe_attr probe;
871 struct lttng_event_function_attr ftrace;
873 char padding[LTTNG_EVENT_PADDING2];
878 static char temp[512];
882 switch ( $self->type ) {
884 sprintf(evtype, "EVENT_ALL");
887 sprintf(evtype, "EVENT_TRACEPOINT");
890 sprintf(evtype, "EVENT_PROBE");
893 sprintf(evtype, "EVENT_FUNCTION");
896 sprintf(evtype, "EVENT_FUNCTION_ENTRY");
899 sprintf(evtype, "EVENT_NOOP");
902 sprintf(evtype, "EVENT_SYSCALL");
905 sprintf(evtype, "%i", $self->type);
909 switch ( $self->loglevel_type ) {
911 sprintf(logtype, "EVENT_LOGLEVEL_ALL");
914 sprintf(logtype, "EVENT_LOGLEVEL_RANGE");
917 sprintf(logtype, "EVENT_LOGLEVEL_SINGLE");
920 sprintf(logtype, "%i", $self->loglevel_type);
924 sprintf(temp, "lttng.Event; name('%s'), type(%s), "
925 "loglevel_type(%s), loglevel(%i), "
926 "enabled(%s), pid(%i)",
927 $self->name, evtype, logtype, $self->loglevel,
928 $self->enabled ? "True" : "False", $self->pid);
934 struct lttng_channel_attr {
936 uint64_t subbuf_size;
938 unsigned int switch_timer_interval;
939 unsigned int read_timer_interval;
940 enum lttng_event_output output;
942 char padding[LTTNG_CHANNEL_ATTR_PADDING1];
946 static char temp[256];
949 switch ( $self->output ) {
951 sprintf(evout, "EVENT_SPLICE");
954 sprintf(evout, "EVENT_MMAP");
957 sprintf(evout, "%i", $self->output);
960 sprintf(temp, "lttng.ChannelAttr; overwrite(%i), subbuf_size(%"PRIu64"), "
961 "num_subbuf(%"PRIu64"), switch_timer_interval(%u), "
962 "read_timer_interval(%u), output(%s)",
963 $self->overwrite, $self->subbuf_size, $self->num_subbuf,
964 $self->switch_timer_interval, $self->read_timer_interval,
971 struct lttng_channel {
972 char name[LTTNG_SYMBOL_NAME_LEN];
974 struct lttng_channel_attr attr;
975 char padding[LTTNG_CHANNEL_PADDING1];
979 static char temp[512];
980 snprintf(temp, sizeof(temp), "lttng.Channel; name('%s'), enabled(%s)",
981 $self->name, $self->enabled ? "True" : "False");
987 struct lttng_session {
991 uint32_t snapshot_mode;
992 unsigned int live_timer_interval;
994 char padding[LTTNG_SESSION_PADDING1];
1000 static char temp[PATH_MAX + NAME_MAX + 512];
1001 snprintf(temp, sizeof(temp), "lttng.Session; name('%s'), path('%s'), enabled(%s)",
1002 $self->name, $self->path,
1003 $self->enabled ? "True" : "False");