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
14 #define SWIG_FILE_WITH_INIT
15 #include <lttng/lttng.h>
19 #if PY_MAJOR_VERSION >= 3
20 // The PyInt and PyLong types were unified as of Python 3
21 // This makes the typemap code useable with both Python 2 and 3.
22 #define PyInt_AsSsize_t PyLong_AsSsize_t
26 typedef unsigned int uint32_t;
28 typedef unsigned long long uint64_t;
32 // =============================================
34 // These are directly taken from lttng.h.
35 // Any change to these enums must also be
37 // =============================================
39 %rename("DOMAIN_KERNEL") LTTNG_DOMAIN_KERNEL;
40 %rename("DOMAIN_UST") LTTNG_DOMAIN_UST;
41 enum lttng_domain_type {
42 LTTNG_DOMAIN_KERNEL = 1,
46 %rename("EVENT_ALL") LTTNG_EVENT_ALL;
47 %rename("EVENT_TRACEPOINT") LTTNG_EVENT_TRACEPOINT;
48 %rename("EVENT_PROBE") LTTNG_EVENT_PROBE;
49 %rename("EVENT_FUNCTION")LTTNG_EVENT_FUNCTION;
50 %rename("EVENT_FUNCTION_ENTRY") LTTNG_EVENT_FUNCTION_ENTRY;
51 %rename("EVENT_NOOP") LTTNG_EVENT_NOOP;
52 %rename("EVENT_SYSCALL") LTTNG_EVENT_SYSCALL;
53 enum lttng_event_type {
55 LTTNG_EVENT_TRACEPOINT = 0,
56 LTTNG_EVENT_PROBE = 1,
57 LTTNG_EVENT_FUNCTION = 2,
58 LTTNG_EVENT_FUNCTION_ENTRY = 3,
60 LTTNG_EVENT_SYSCALL = 5,
63 %rename("EVENT_LOGLEVEL_ALL") LTTNG_EVENT_LOGLEVEL_ALL;
64 %rename("EVENT_LOGLEVEL_RANGE") LTTNG_EVENT_LOGLEVEL_RANGE;
65 %rename("EVENT_LOGLEVEL_SINGLE") LTTNG_EVENT_LOGLEVEL_SINGLE;
66 enum lttng_loglevel_type {
67 LTTNG_EVENT_LOGLEVEL_ALL = 0,
68 LTTNG_EVENT_LOGLEVEL_RANGE = 1,
69 LTTNG_EVENT_LOGLEVEL_SINGLE = 2,
72 %rename("LOGLEVEL_EMERG") LTTNG_LOGLEVEL_EMERG;
73 %rename("LOGLEVEL_ALERT") LTTNG_LOGLEVEL_ALERT;
74 %rename("LOGLEVEL_CRIT") LTTNG_LOGLEVEL_CRIT;
75 %rename("LOGLEVEL_ERR") LTTNG_LOGLEVEL_ERR;
76 %rename("LOGLEVEL_WARNING") LTTNG_LOGLEVEL_WARNING;
77 %rename("LOGLEVEL_NOTICE") LTTNG_LOGLEVEL_NOTICE;
78 %rename("LOGLEVEL_INFO") LTTNG_LOGLEVEL_INFO;
79 %rename("LOGLEVEL_DEBUG_SYSTEM") LTTNG_LOGLEVEL_DEBUG_SYSTEM;
80 %rename("LOGLEVEL_DEBUG_PROGRAM") LTTNG_LOGLEVEL_DEBUG_PROGRAM;
81 %rename("LOGLEVEL_DEBUG_PROCESS") LTTNG_LOGLEVEL_DEBUG_PROCESS;
82 %rename("LOGLEVEL_DEBUG_MODULE") LTTNG_LOGLEVEL_DEBUG_MODULE;
83 %rename("LOGLEVEL_DEBUG_UNIT") LTTNG_LOGLEVEL_DEBUG_UNIT;
84 %rename("LOGLEVEL_DEBUG_FUNCTION") LTTNG_LOGLEVEL_DEBUG_FUNCTION;
85 %rename("LOGLEVEL_DEBUG_LINE") LTTNG_LOGLEVEL_DEBUG_LINE;
86 %rename("LOGLEVEL_DEBUG") LTTNG_LOGLEVEL_DEBUG;
88 LTTNG_LOGLEVEL_EMERG = 0,
89 LTTNG_LOGLEVEL_ALERT = 1,
90 LTTNG_LOGLEVEL_CRIT = 2,
91 LTTNG_LOGLEVEL_ERR = 3,
92 LTTNG_LOGLEVEL_WARNING = 4,
93 LTTNG_LOGLEVEL_NOTICE = 5,
94 LTTNG_LOGLEVEL_INFO = 6,
95 LTTNG_LOGLEVEL_DEBUG_SYSTEM = 7,
96 LTTNG_LOGLEVEL_DEBUG_PROGRAM = 8,
97 LTTNG_LOGLEVEL_DEBUG_PROCESS = 9,
98 LTTNG_LOGLEVEL_DEBUG_MODULE = 10,
99 LTTNG_LOGLEVEL_DEBUG_UNIT = 11,
100 LTTNG_LOGLEVEL_DEBUG_FUNCTION = 12,
101 LTTNG_LOGLEVEL_DEBUG_LINE = 13,
102 LTTNG_LOGLEVEL_DEBUG = 14,
105 %rename("EVENT_SPLICE") LTTNG_EVENT_SPLICE;
106 %rename("EVENT_MMAP") LTTNG_EVENT_MMAP;
107 enum lttng_event_output {
108 LTTNG_EVENT_SPLICE = 0,
109 LTTNG_EVENT_MMAP = 1,
112 %rename("EVENT_CONTEXT_PID") LTTNG_EVENT_CONTEXT_PID;
113 %rename("EVENT_CONTEXT_PERF_COUNTER") LTTNG_EVENT_CONTEXT_PERF_COUNTER;
114 %rename("EVENT_CONTEXT_PROCNAME") LTTNG_EVENT_CONTEXT_PROCNAME;
115 %rename("EVENT_CONTEXT_PRIO") LTTNG_EVENT_CONTEXT_PRIO;
116 %rename("EVENT_CONTEXT_NICE") LTTNG_EVENT_CONTEXT_NICE;
117 %rename("EVENT_CONTEXT_VPID") LTTNG_EVENT_CONTEXT_VPID;
118 %rename("EVENT_CONTEXT_TID") LTTNG_EVENT_CONTEXT_TID;
119 %rename("EVENT_CONTEXT_VTID") LTTNG_EVENT_CONTEXT_VTID;
120 %rename("EVENT_CONTEXT_PPID") LTTNG_EVENT_CONTEXT_PPID;
121 %rename("EVENT_CONTEXT_VPPID") LTTNG_EVENT_CONTEXT_VPPID;
122 %rename("EVENT_CONTEXT_PTHREAD_ID") LTTNG_EVENT_CONTEXT_PTHREAD_ID;
123 enum lttng_event_context_type {
124 LTTNG_EVENT_CONTEXT_PID = 0,
125 LTTNG_EVENT_CONTEXT_PERF_COUNTER = 1,
126 LTTNG_EVENT_CONTEXT_PROCNAME = 2,
127 LTTNG_EVENT_CONTEXT_PRIO = 3,
128 LTTNG_EVENT_CONTEXT_NICE = 4,
129 LTTNG_EVENT_CONTEXT_VPID = 5,
130 LTTNG_EVENT_CONTEXT_TID = 6,
131 LTTNG_EVENT_CONTEXT_VTID = 7,
132 LTTNG_EVENT_CONTEXT_PPID = 8,
133 LTTNG_EVENT_CONTEXT_VPPID = 9,
134 LTTNG_EVENT_CONTEXT_PTHREAD_ID = 10,
137 %rename("CALIBRATE_FUNCTION") LTTNG_CALIBRATE_FUNCTION;
138 enum lttng_calibrate_type {
139 LTTNG_CALIBRATE_FUNCTION = 0,
144 // =============================================
146 // =============================================
149 %typemap(argout) struct lttng_session **sessions{
151 int l = PyInt_AsSsize_t($result);
154 PyObject *sessions = PyList_New(0);
158 PyObject *tmp = PyTuple_New(4);
159 PyObject *name = PyString_FromString((*$1)[i].name);
160 PyObject *path = PyString_FromString((*$1)[i].path);
161 PyObject *enabled = PyInt_FromSize_t((*$1)[i].enabled);
162 PyObject *padding = PyString_FromString((*$1)[i].padding);
164 PyTuple_SetItem(tmp, 0, name);
165 PyTuple_SetItem(tmp, 1, path);
166 PyTuple_SetItem(tmp, 2, enabled);
167 PyTuple_SetItem(tmp, 3, padding);
168 PyList_Append(sessions, tmp);
173 %typemap(in,numinputs=0) struct lttng_session **sessions (struct lttng_session *temp){
178 %typemap(argout) struct lttng_domain **domains{
180 int l = PyInt_AsSsize_t($result);
183 PyObject *dom = PyList_New(0);
187 PyObject *tmp = PyTuple_New(5);
188 PyObject *type = PyInt_FromSize_t((*$1)[i].type);
189 PyObject *execname = PyString_FromString((*$1)[i].attr.exec_name);
190 PyObject *pid = PyInt_FromSize_t((*$1)[i].attr.pid);
191 PyObject *padding = PyString_FromString((*$1)[i].padding);
192 PyObject *attrpadding = PyString_FromString((*$1)[i].attr.padding);
194 PyTuple_SetItem(tmp, 0, type);
195 PyTuple_SetItem(tmp, 1, padding);
196 PyTuple_SetItem(tmp, 2, pid);
197 PyTuple_SetItem(tmp, 3, execname);
198 PyTuple_SetItem(tmp, 4, attrpadding);
199 PyList_Append(dom, tmp);
204 %typemap(in,numinputs=0) struct lttng_domain **domains (struct lttng_domain *temp){
209 %typemap(argout) struct lttng_channel **channels{
211 int l = PyInt_AsSsize_t($result);
214 PyObject *chan = PyList_New(0);
218 PyObject *tmp = PyTuple_New(4);
219 PyObject *name = PyString_FromString((*$1)[i].name);
220 PyObject *enabled = PyInt_FromSize_t((*$1)[i].enabled);
221 PyObject *padding = PyString_FromString((*$1)[i].padding);
223 PyObject *attrtmp = PyTuple_New(7);
224 PyObject *overwrite = PyInt_FromLong((*$1)[i].attr.overwrite);
225 PyObject *subbuf = PyInt_FromSize_t((*$1)[i].attr.subbuf_size);
226 PyObject *num = PyInt_FromSize_t((*$1)[i].attr.num_subbuf);
227 PyObject *switchtimer = PyInt_FromSize_t((*$1)[i].attr.switch_timer_interval);
228 PyObject *readtimer = PyInt_FromSize_t((*$1)[i].attr.read_timer_interval);
229 PyObject *output = PyInt_FromSize_t((*$1)[i].attr.output);
230 PyObject *attrpad = PyString_FromString((*$1)[i].attr.padding);
232 PyTuple_SetItem(attrtmp, 0, overwrite);
233 PyTuple_SetItem(attrtmp, 1, subbuf);
234 PyTuple_SetItem(attrtmp, 2, num);
235 PyTuple_SetItem(attrtmp, 3, switchtimer);
236 PyTuple_SetItem(attrtmp, 4, readtimer);
237 PyTuple_SetItem(attrtmp, 5, output);
238 PyTuple_SetItem(attrtmp, 6, attrpad);
240 PyTuple_SetItem(tmp, 0, name);
241 PyTuple_SetItem(tmp, 1, enabled);
242 PyTuple_SetItem(tmp, 2, padding);
243 PyTuple_SetItem(tmp, 3, attrtmp);
244 PyList_Append(chan, tmp);
249 %typemap(in,numinputs=0) struct lttng_channel **channels (struct lttng_channel *temp){
253 //list_events & list_tracepoints
254 %typemap(argout) struct lttng_event **events{
256 int l = PyInt_AsSsize_t($result);
259 PyObject *events = PyList_New(0);
263 PyObject *tmp = PyTuple_New(10);
264 PyObject *name = PyString_FromString((*$1)[i].name);
265 PyObject *type = PyInt_FromSize_t((*$1)[i].type);
266 PyObject *logleveltype = PyInt_FromSize_t((*$1)[i].loglevel_type);
267 PyObject *loglevel = PyInt_FromLong((*$1)[i].loglevel);
268 PyObject *enabled = PyInt_FromLong((*$1)[i].enabled);
269 PyObject *pid = PyInt_FromSize_t((*$1)[i].pid);
270 PyObject *padding = PyString_FromString((*$1)[i].padding);
271 PyObject *attrpadding = PyString_FromString((*$1)[i].attr.padding);
273 PyObject *probe = PyTuple_New(4);
274 PyObject *addr = PyInt_FromSize_t((*$1)[i].attr.probe.addr);
275 PyObject *offset = PyInt_FromSize_t((*$1)[i].attr.probe.offset);
276 PyObject *symbolname = PyString_FromString((*$1)[i].attr.probe.symbol_name);
277 PyObject *probepad = PyString_FromString((*$1)[i].attr.probe.padding);
279 PyObject *function = PyTuple_New(2);
280 PyObject *f_symbolname = PyString_FromString((*$1)[i].attr.ftrace.symbol_name);
281 PyObject *f_pad = PyString_FromString((*$1)[i].attr.ftrace.padding);
283 PyTuple_SetItem(function, 0, f_symbolname);
284 PyTuple_SetItem(function, 1, f_pad);
286 PyTuple_SetItem(probe, 0, addr);
287 PyTuple_SetItem(probe, 1, offset);
288 PyTuple_SetItem(probe, 2, symbolname);
289 PyTuple_SetItem(probe, 3, probepad);
291 PyTuple_SetItem(tmp, 0, name);
292 PyTuple_SetItem(tmp, 1, type);
293 PyTuple_SetItem(tmp, 2, logleveltype);
294 PyTuple_SetItem(tmp, 3, loglevel);
295 PyTuple_SetItem(tmp, 4, enabled);
296 PyTuple_SetItem(tmp, 5, pid);
297 PyTuple_SetItem(tmp, 6, padding);
298 PyTuple_SetItem(tmp, 7, probe);
299 PyTuple_SetItem(tmp, 8, function);
300 PyTuple_SetItem(tmp, 9, attrpadding);
301 PyList_Append(events, tmp);
306 %typemap(in,numinputs=0) struct lttng_event **events (struct lttng_event *temp){
312 // =============================================
314 // =============================================
316 %rename("create") lttng_create_session(const char *name, const char *path);
317 %rename("destroy") lttng_destroy_session(const char *name);
318 %rename("_lttng_create_handle") lttng_create_handle(const char *session_name, struct lttng_domain *domain);
319 %rename("_lttng_destroy_handle") lttng_destroy_handle(struct lttng_handle *handle);
320 %rename("_lttng_list_sessions") lttng_list_sessions(struct lttng_session **sessions);
321 %rename("_lttng_list_domains") lttng_list_domains(const char *session_name, struct lttng_domain **domains);
322 %rename("_lttng_list_channels") lttng_list_channels(struct lttng_handle *handle,struct lttng_channel **channels);
323 %rename("_lttng_list_events") lttng_list_events(struct lttng_handle *handle, const char *channel_name, struct lttng_event **events);
324 %rename("_lttng_list_tracepoints") lttng_list_tracepoints(struct lttng_handle *handle, struct lttng_event **events);
325 %rename("session_daemon_alive") lttng_session_daemon_alive(void);
326 %rename("set_tracing_group") lttng_set_tracing_group(const char *name);
327 %rename("strerror") lttng_strerror(int code);
328 %rename("_lttng_register_consumer") lttng_register_consumer(struct lttng_handle *handle, const char *socket_path);
329 %rename("start") lttng_start_tracing(const char *session_name);
330 %rename("stop") lttng_stop_tracing(const char *session_name);
331 %rename("_lttng_add_context") lttng_add_context(struct lttng_handle *handle, struct lttng_event_context *ctx, const char *event_name, const char *channel_name);
332 %rename("_lttng_enable_event") lttng_enable_event(struct lttng_handle *handle, struct lttng_event *ev, const char *channel_name);
333 %rename("_lttng_enable_channel") lttng_enable_channel(struct lttng_handle *handle, struct lttng_channel *chan);
334 %rename("_lttng_disable_event") lttng_disable_event(struct lttng_handle *handle, const char *name, const char *channel_name);
335 %rename("_lttng_disable_channel") lttng_disable_channel(struct lttng_handle *handle, const char *name);
336 %rename("_lttng_calibrate") lttng_calibrate(struct lttng_handle *handle, struct lttng_calibrate *calibrate);
337 %rename("channel_set_default_attr") lttng_channel_set_default_attr(struct lttng_domain *domain, struct lttng_channel_attr *attr);
339 //Redefined functions
340 struct lttng_handle *lttng_create_handle(const char *session_name,
341 struct lttng_domain *domain);
342 void lttng_destroy_handle(struct lttng_handle *handle);
343 int lttng_list_channels(struct lttng_handle *handle,struct lttng_channel **channels);
344 int lttng_list_events(struct lttng_handle *handle,
345 const char *channel_name, struct lttng_event **events);
346 int lttng_list_tracepoints(struct lttng_handle *handle, struct lttng_event **events);
347 int lttng_add_context(struct lttng_handle *handle, struct lttng_event_context *ctx,
348 const char *event_name, const char *channel_name);
349 int lttng_enable_event(struct lttng_handle *handle,
350 struct lttng_event *ev, const char *channel_name);
351 int lttng_enable_channel(struct lttng_handle *handle, struct lttng_channel *chan);
352 int lttng_disable_event(struct lttng_handle *handle,
353 const char *name, const char *channel_name);
354 int lttng_disable_channel(struct lttng_handle *handle, const char *name);
355 int lttng_calibrate(struct lttng_handle *handle, struct lttng_calibrate *calibrate);
356 int lttng_register_consumer(struct lttng_handle *handle, const char *socket_path);
357 int lttng_list_sessions(struct lttng_session **sessions);
358 int lttng_list_domains(const char *session_name, struct lttng_domain **domains);
360 //Functions not needing redefinition
361 %feature("docstring")"create(str name, str path) -> int
363 Create a new tracing session using name and path.
364 Returns size of returned session payload data or a negative error code."
365 int lttng_create_session(const char *name, const char *path);
368 %feature("docstring")"destroy(str name) -> int
370 Tear down tracing session using name.
371 Returns size of returned session payload data 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")
693 def calibrate(handle, calibrate):
695 calibrate(Handle handle, Calibrate calibrate) -> int
697 Quantify LTTng overhead.
698 Returns size of returned session payload data or a negative error code.
702 return _lttng_calibrate(handle._h, calibrate)
703 except AttributeError:
704 raise TypeError("in method 'calibrate', argument 1 must be a Handle instance")
708 // =============================================
710 // Used to prevent freeing unallocated memory
711 // =============================================
713 %feature("docstring")""
714 %feature("autodoc", "1");
720 Takes two arguments: (str session_name, Domain domain)
725 def __init__(self, session_name, domain):
726 if type(session_name) is not str:
727 raise TypeError("in method '__init__', argument 2 of type 'str'")
728 if type(domain) is not Domain and domain is not None:
729 raise TypeError("in method '__init__', argument 3 of type 'lttng.Domain'")
731 self._sname = session_name
735 self._domtype = domain.type
736 self._h = _lttng_create_handle(session_name, domain)
740 _lttng_destroy_handle(self._h)
743 if self._domtype == 1:
744 domstr = "DOMAIN_KERNEL"
745 elif self._domtype == 2:
746 domstr = "DOMAIN_UST"
748 domstr = self._domtype
750 return "lttng.Handle; session('{}'), domain.type({})".format(
753 def __setattr__(self, attr, val):
755 raise NotImplementedError("cannot modify attributes")
757 self.__dict__[attr] = val
761 // =============================================
763 // These are directly taken from lttng.h.
764 // Any change to these structures must also be
766 // =============================================
768 %rename("Domain") lttng_domain;
769 %rename("EventContext") lttng_event_context;
770 %rename("Event") lttng_event;
771 %rename("Calibrate") lttng_calibrate;
772 %rename("ChannelAttr") lttng_channel_attr;
773 %rename("Channel") lttng_channel;
774 %rename("Session") lttng_session;
777 enum lttng_domain_type type;
778 char padding[LTTNG_DOMAIN_PADDING1];
782 char exec_name[NAME_MAX];
783 char padding[LTTNG_DOMAIN_PADDING2];
788 static char temp[256];
789 switch ( $self->type ) {
791 sprintf(temp, "lttng.Domain; type(DOMAIN_KERNEL)");
794 sprintf(temp, "lttng.Domain; type(DOMAIN_UST)");
797 sprintf(temp, "lttng.Domain; type(%i)", $self->type);
805 struct lttng_event_context {
806 enum lttng_event_context_type ctx;
807 char padding[LTTNG_EVENT_CONTEXT_PADDING1];
810 struct lttng_event_perf_counter_ctx perf_counter;
811 char padding[LTTNG_EVENT_CONTEXT_PADDING2];
816 static char temp[256];
817 switch ( $self->ctx ) {
819 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PID)");
822 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PERF_COUNTER)");
825 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PROCNAME)");
828 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PRIO)");
831 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_NICE)");
834 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VPID)");
837 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_TID)");
840 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VTID)");
843 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PPID)");
846 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VPPID)");
849 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PTHREAD_ID)");
852 sprintf(temp, "lttng.EventContext; type(%i)", $self->ctx);
860 struct lttng_event_probe_attr {
863 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
864 char padding[LTTNG_EVENT_PROBE_PADDING1];
867 struct lttng_event_function_attr {
868 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
869 char padding[LTTNG_EVENT_FUNCTION_PADDING1];
873 enum lttng_event_type type;
874 char name[LTTNG_SYMBOL_NAME_LEN];
876 enum lttng_loglevel_type loglevel_type;
882 char padding[LTTNG_EVENT_PADDING1];
885 struct lttng_event_probe_attr probe;
886 struct lttng_event_function_attr ftrace;
888 char padding[LTTNG_EVENT_PADDING2];
893 static char temp[512];
897 switch ( $self->type ) {
899 sprintf(evtype, "EVENT_ALL");
902 sprintf(evtype, "EVENT_TRACEPOINT");
905 sprintf(evtype, "EVENT_PROBE");
908 sprintf(evtype, "EVENT_FUNCTION");
911 sprintf(evtype, "EVENT_FUNCTION_ENTRY");
914 sprintf(evtype, "EVENT_NOOP");
917 sprintf(evtype, "EVENT_SYSCALL");
920 sprintf(evtype, "%i", $self->type);
924 switch ( $self->loglevel_type ) {
926 sprintf(logtype, "EVENT_LOGLEVEL_ALL");
929 sprintf(logtype, "EVENT_LOGLEVEL_RANGE");
932 sprintf(logtype, "EVENT_LOGLEVEL_SINGLE");
935 sprintf(logtype, "%i", $self->loglevel_type);
939 sprintf(temp, "lttng.Event; name('%s'), type(%s), "
940 "loglevel_type(%s), loglevel(%i), "
941 "enabled(%s), pid(%i)",
942 $self->name, evtype, logtype, $self->loglevel,
943 $self->enabled ? "True" : "False", $self->pid);
949 struct lttng_calibrate {
950 enum lttng_calibrate_type type;
951 char padding[LTTNG_CALIBRATE_PADDING1];
955 static char temp[256];
956 switch ( $self->type ) {
958 sprintf(temp, "lttng.Calibrate; type(CALIBRATE_FUNCTION)");
961 sprintf(temp, "lttng.Calibrate; type(%i)", $self->type);
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(%lu), "
996 "num_subbuf(%lu), 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 sprintf(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 char padding[LTTNG_SESSION_PADDING1];
1030 static char temp[512];
1031 sprintf(temp, "lttng.Session; name('%s'), path('%s'), enabled(%s)",
1032 $self->name, $self->path,
1033 $self->enabled ? "True" : "False");