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>
18 typedef unsigned int uint32_t;
20 typedef unsigned long long uint64_t;
24 // =============================================
26 // These are directly taken from lttng.h.
27 // Any change to these enums must also be
29 // =============================================
31 %rename("DOMAIN_KERNEL") LTTNG_DOMAIN_KERNEL;
32 %rename("DOMAIN_UST") LTTNG_DOMAIN_UST;
33 enum lttng_domain_type {
34 LTTNG_DOMAIN_KERNEL = 1,
38 %rename("EVENT_ALL") LTTNG_EVENT_ALL;
39 %rename("EVENT_TRACEPOINT") LTTNG_EVENT_TRACEPOINT;
40 %rename("EVENT_PROBE") LTTNG_EVENT_PROBE;
41 %rename("EVENT_FUNCTION")LTTNG_EVENT_FUNCTION;
42 %rename("EVENT_FUNCTION_ENTRY") LTTNG_EVENT_FUNCTION_ENTRY;
43 %rename("EVENT_NOOP") LTTNG_EVENT_NOOP;
44 %rename("EVENT_SYSCALL") LTTNG_EVENT_SYSCALL;
45 enum lttng_event_type {
47 LTTNG_EVENT_TRACEPOINT = 0,
48 LTTNG_EVENT_PROBE = 1,
49 LTTNG_EVENT_FUNCTION = 2,
50 LTTNG_EVENT_FUNCTION_ENTRY = 3,
52 LTTNG_EVENT_SYSCALL = 5,
55 %rename("EVENT_LOGLEVEL_ALL") LTTNG_EVENT_LOGLEVEL_ALL;
56 %rename("EVENT_LOGLEVEL_RANGE") LTTNG_EVENT_LOGLEVEL_RANGE;
57 %rename("EVENT_LOGLEVEL_SINGLE") LTTNG_EVENT_LOGLEVEL_SINGLE;
58 enum lttng_loglevel_type {
59 LTTNG_EVENT_LOGLEVEL_ALL = 0,
60 LTTNG_EVENT_LOGLEVEL_RANGE = 1,
61 LTTNG_EVENT_LOGLEVEL_SINGLE = 2,
64 %rename("LOGLEVEL_EMERG") LTTNG_LOGLEVEL_EMERG;
65 %rename("LOGLEVEL_ALERT") LTTNG_LOGLEVEL_ALERT;
66 %rename("LOGLEVEL_CRIT") LTTNG_LOGLEVEL_CRIT;
67 %rename("LOGLEVEL_ERR") LTTNG_LOGLEVEL_ERR;
68 %rename("LOGLEVEL_WARNING") LTTNG_LOGLEVEL_WARNING;
69 %rename("LOGLEVEL_NOTICE") LTTNG_LOGLEVEL_NOTICE;
70 %rename("LOGLEVEL_INFO") LTTNG_LOGLEVEL_INFO;
71 %rename("LOGLEVEL_DEBUG_SYSTEM") LTTNG_LOGLEVEL_DEBUG_SYSTEM;
72 %rename("LOGLEVEL_DEBUG_PROGRAM") LTTNG_LOGLEVEL_DEBUG_PROGRAM;
73 %rename("LOGLEVEL_DEBUG_PROCESS") LTTNG_LOGLEVEL_DEBUG_PROCESS;
74 %rename("LOGLEVEL_DEBUG_MODULE") LTTNG_LOGLEVEL_DEBUG_MODULE;
75 %rename("LOGLEVEL_DEBUG_UNIT") LTTNG_LOGLEVEL_DEBUG_UNIT;
76 %rename("LOGLEVEL_DEBUG_FUNCTION") LTTNG_LOGLEVEL_DEBUG_FUNCTION;
77 %rename("LOGLEVEL_DEBUG_LINE") LTTNG_LOGLEVEL_DEBUG_LINE;
78 %rename("LOGLEVEL_DEBUG") LTTNG_LOGLEVEL_DEBUG;
80 LTTNG_LOGLEVEL_EMERG = 0,
81 LTTNG_LOGLEVEL_ALERT = 1,
82 LTTNG_LOGLEVEL_CRIT = 2,
83 LTTNG_LOGLEVEL_ERR = 3,
84 LTTNG_LOGLEVEL_WARNING = 4,
85 LTTNG_LOGLEVEL_NOTICE = 5,
86 LTTNG_LOGLEVEL_INFO = 6,
87 LTTNG_LOGLEVEL_DEBUG_SYSTEM = 7,
88 LTTNG_LOGLEVEL_DEBUG_PROGRAM = 8,
89 LTTNG_LOGLEVEL_DEBUG_PROCESS = 9,
90 LTTNG_LOGLEVEL_DEBUG_MODULE = 10,
91 LTTNG_LOGLEVEL_DEBUG_UNIT = 11,
92 LTTNG_LOGLEVEL_DEBUG_FUNCTION = 12,
93 LTTNG_LOGLEVEL_DEBUG_LINE = 13,
94 LTTNG_LOGLEVEL_DEBUG = 14,
97 %rename("EVENT_SPLICE") LTTNG_EVENT_SPLICE;
98 %rename("EVENT_MMAP") LTTNG_EVENT_MMAP;
99 enum lttng_event_output {
100 LTTNG_EVENT_SPLICE = 0,
101 LTTNG_EVENT_MMAP = 1,
104 %rename("EVENT_CONTEXT_PID") LTTNG_EVENT_CONTEXT_PID;
105 %rename("EVENT_CONTEXT_PERF_COUNTER") LTTNG_EVENT_CONTEXT_PERF_COUNTER;
106 %rename("EVENT_CONTEXT_PROCNAME") LTTNG_EVENT_CONTEXT_PROCNAME;
107 %rename("EVENT_CONTEXT_PRIO") LTTNG_EVENT_CONTEXT_PRIO;
108 %rename("EVENT_CONTEXT_NICE") LTTNG_EVENT_CONTEXT_NICE;
109 %rename("EVENT_CONTEXT_VPID") LTTNG_EVENT_CONTEXT_VPID;
110 %rename("EVENT_CONTEXT_TID") LTTNG_EVENT_CONTEXT_TID;
111 %rename("EVENT_CONTEXT_VTID") LTTNG_EVENT_CONTEXT_VTID;
112 %rename("EVENT_CONTEXT_PPID") LTTNG_EVENT_CONTEXT_PPID;
113 %rename("EVENT_CONTEXT_VPPID") LTTNG_EVENT_CONTEXT_VPPID;
114 %rename("EVENT_CONTEXT_PTHREAD_ID") LTTNG_EVENT_CONTEXT_PTHREAD_ID;
115 enum lttng_event_context_type {
116 LTTNG_EVENT_CONTEXT_PID = 0,
117 LTTNG_EVENT_CONTEXT_PERF_COUNTER = 1,
118 LTTNG_EVENT_CONTEXT_PROCNAME = 2,
119 LTTNG_EVENT_CONTEXT_PRIO = 3,
120 LTTNG_EVENT_CONTEXT_NICE = 4,
121 LTTNG_EVENT_CONTEXT_VPID = 5,
122 LTTNG_EVENT_CONTEXT_TID = 6,
123 LTTNG_EVENT_CONTEXT_VTID = 7,
124 LTTNG_EVENT_CONTEXT_PPID = 8,
125 LTTNG_EVENT_CONTEXT_VPPID = 9,
126 LTTNG_EVENT_CONTEXT_PTHREAD_ID = 10,
129 %rename("CALIBRATE_FUNCTION") LTTNG_CALIBRATE_FUNCTION;
130 enum lttng_calibrate_type {
131 LTTNG_CALIBRATE_FUNCTION = 0,
136 // =============================================
138 // =============================================
141 %typemap(argout) struct lttng_session **sessions{
143 int l = PyInt_AsSsize_t($result);
146 PyObject *sessions = PyList_New(0);
150 PyObject *tmp = PyTuple_New(4);
151 PyObject *name = PyString_FromString((*$1)[i].name);
152 PyObject *path = PyString_FromString((*$1)[i].path);
153 PyObject *enabled = PyInt_FromSize_t((*$1)[i].enabled);
154 PyObject *padding = PyString_FromString((*$1)[i].padding);
156 PyTuple_SetItem(tmp, 0, name);
157 PyTuple_SetItem(tmp, 1, path);
158 PyTuple_SetItem(tmp, 2, enabled);
159 PyTuple_SetItem(tmp, 3, padding);
160 PyList_Append(sessions, tmp);
165 %typemap(in,numinputs=0) struct lttng_session **sessions (struct lttng_session *temp){
170 %typemap(argout) struct lttng_domain **domains{
172 int l = PyInt_AsSsize_t($result);
175 PyObject *dom = PyList_New(0);
179 PyObject *tmp = PyTuple_New(5);
180 PyObject *type = PyInt_FromSize_t((*$1)[i].type);
181 PyObject *execname = PyString_FromString((*$1)[i].attr.exec_name);
182 PyObject *pid = PyInt_FromSize_t((*$1)[i].attr.pid);
183 PyObject *padding = PyString_FromString((*$1)[i].padding);
184 PyObject *attrpadding = PyString_FromString((*$1)[i].attr.padding);
186 PyTuple_SetItem(tmp, 0, type);
187 PyTuple_SetItem(tmp, 1, padding);
188 PyTuple_SetItem(tmp, 2, pid);
189 PyTuple_SetItem(tmp, 3, execname);
190 PyTuple_SetItem(tmp, 4, attrpadding);
191 PyList_Append(dom, tmp);
196 %typemap(in,numinputs=0) struct lttng_domain **domains (struct lttng_domain *temp){
201 %typemap(argout) struct lttng_channel **channels{
203 int l = PyInt_AsSsize_t($result);
206 PyObject *chan = PyList_New(0);
210 PyObject *tmp = PyTuple_New(4);
211 PyObject *name = PyString_FromString((*$1)[i].name);
212 PyObject *enabled = PyInt_FromSize_t((*$1)[i].enabled);
213 PyObject *padding = PyString_FromString((*$1)[i].padding);
215 PyObject *attrtmp = PyTuple_New(7);
216 PyObject *overwrite = PyInt_FromLong((*$1)[i].attr.overwrite);
217 PyObject *subbuf = PyInt_FromSize_t((*$1)[i].attr.subbuf_size);
218 PyObject *num = PyInt_FromSize_t((*$1)[i].attr.num_subbuf);
219 PyObject *switchtimer = PyInt_FromSize_t((*$1)[i].attr.switch_timer_interval);
220 PyObject *readtimer = PyInt_FromSize_t((*$1)[i].attr.read_timer_interval);
221 PyObject *output = PyInt_FromSize_t((*$1)[i].attr.output);
222 PyObject *attrpad = PyString_FromString((*$1)[i].attr.padding);
224 PyTuple_SetItem(attrtmp, 0, overwrite);
225 PyTuple_SetItem(attrtmp, 1, subbuf);
226 PyTuple_SetItem(attrtmp, 2, num);
227 PyTuple_SetItem(attrtmp, 3, switchtimer);
228 PyTuple_SetItem(attrtmp, 4, readtimer);
229 PyTuple_SetItem(attrtmp, 5, output);
230 PyTuple_SetItem(attrtmp, 6, attrpad);
232 PyTuple_SetItem(tmp, 0, name);
233 PyTuple_SetItem(tmp, 1, enabled);
234 PyTuple_SetItem(tmp, 2, padding);
235 PyTuple_SetItem(tmp, 3, attrtmp);
236 PyList_Append(chan, tmp);
241 %typemap(in,numinputs=0) struct lttng_channel **channels (struct lttng_channel *temp){
245 //list_events & list_tracepoints
246 %typemap(argout) struct lttng_event **events{
248 int l = PyInt_AsSsize_t($result);
251 PyObject *events = PyList_New(0);
255 PyObject *tmp = PyTuple_New(10);
256 PyObject *name = PyString_FromString((*$1)[i].name);
257 PyObject *type = PyInt_FromSize_t((*$1)[i].type);
258 PyObject *logleveltype = PyInt_FromSize_t((*$1)[i].loglevel_type);
259 PyObject *loglevel = PyInt_FromLong((*$1)[i].loglevel);
260 PyObject *enabled = PyInt_FromLong((*$1)[i].enabled);
261 PyObject *pid = PyInt_FromSize_t((*$1)[i].pid);
262 PyObject *padding = PyString_FromString((*$1)[i].padding);
263 PyObject *attrpadding = PyString_FromString((*$1)[i].attr.padding);
265 PyObject *probe = PyTuple_New(4);
266 PyObject *addr = PyInt_FromSize_t((*$1)[i].attr.probe.addr);
267 PyObject *offset = PyInt_FromSize_t((*$1)[i].attr.probe.offset);
268 PyObject *symbolname = PyString_FromString((*$1)[i].attr.probe.symbol_name);
269 PyObject *probepad = PyString_FromString((*$1)[i].attr.probe.padding);
271 PyObject *function = PyTuple_New(2);
272 PyObject *f_symbolname = PyString_FromString((*$1)[i].attr.ftrace.symbol_name);
273 PyObject *f_pad = PyString_FromString((*$1)[i].attr.ftrace.padding);
275 PyTuple_SetItem(function, 0, f_symbolname);
276 PyTuple_SetItem(function, 1, f_pad);
278 PyTuple_SetItem(probe, 0, addr);
279 PyTuple_SetItem(probe, 1, offset);
280 PyTuple_SetItem(probe, 2, symbolname);
281 PyTuple_SetItem(probe, 3, probepad);
283 PyTuple_SetItem(tmp, 0, name);
284 PyTuple_SetItem(tmp, 1, type);
285 PyTuple_SetItem(tmp, 2, logleveltype);
286 PyTuple_SetItem(tmp, 3, loglevel);
287 PyTuple_SetItem(tmp, 4, enabled);
288 PyTuple_SetItem(tmp, 5, pid);
289 PyTuple_SetItem(tmp, 6, padding);
290 PyTuple_SetItem(tmp, 7, probe);
291 PyTuple_SetItem(tmp, 8, function);
292 PyTuple_SetItem(tmp, 9, attrpadding);
293 PyList_Append(events, tmp);
298 %typemap(in,numinputs=0) struct lttng_event **events (struct lttng_event *temp){
304 // =============================================
306 // =============================================
308 %rename("create") lttng_create_session(const char *name, const char *path);
309 %rename("destroy") lttng_destroy_session(const char *name);
310 %rename("_lttng_create_handle") lttng_create_handle(const char *session_name, struct lttng_domain *domain);
311 %rename("_lttng_destroy_handle") lttng_destroy_handle(struct lttng_handle *handle);
312 %rename("_lttng_list_sessions") lttng_list_sessions(struct lttng_session **sessions);
313 %rename("_lttng_list_domains") lttng_list_domains(const char *session_name, struct lttng_domain **domains);
314 %rename("_lttng_list_channels") lttng_list_channels(struct lttng_handle *handle,struct lttng_channel **channels);
315 %rename("_lttng_list_events") lttng_list_events(struct lttng_handle *handle, const char *channel_name, struct lttng_event **events);
316 %rename("_lttng_list_tracepoints") lttng_list_tracepoints(struct lttng_handle *handle, struct lttng_event **events);
317 %rename("session_daemon_alive") lttng_session_daemon_alive(void);
318 %rename("set_tracing_group") lttng_set_tracing_group(const char *name);
319 %rename("strerror") lttng_strerror(int code);
320 %rename("_lttng_register_consumer") lttng_register_consumer(struct lttng_handle *handle, const char *socket_path);
321 %rename("start") lttng_start_tracing(const char *session_name);
322 %rename("stop") lttng_stop_tracing(const char *session_name);
323 %rename("_lttng_add_context") lttng_add_context(struct lttng_handle *handle, struct lttng_event_context *ctx, const char *event_name, const char *channel_name);
324 %rename("_lttng_enable_event") lttng_enable_event(struct lttng_handle *handle, struct lttng_event *ev, const char *channel_name);
325 %rename("_lttng_enable_channel") lttng_enable_channel(struct lttng_handle *handle, struct lttng_channel *chan);
326 %rename("_lttng_disable_event") lttng_disable_event(struct lttng_handle *handle, const char *name, const char *channel_name);
327 %rename("_lttng_disable_channel") lttng_disable_channel(struct lttng_handle *handle, const char *name);
328 %rename("_lttng_calibrate") lttng_calibrate(struct lttng_handle *handle, struct lttng_calibrate *calibrate);
329 %rename("channel_set_default_attr") lttng_channel_set_default_attr(struct lttng_domain *domain, struct lttng_channel_attr *attr);
331 //Redefined functions
332 struct lttng_handle *lttng_create_handle(const char *session_name,
333 struct lttng_domain *domain);
334 void lttng_destroy_handle(struct lttng_handle *handle);
335 int lttng_list_channels(struct lttng_handle *handle,struct lttng_channel **channels);
336 int lttng_list_events(struct lttng_handle *handle,
337 const char *channel_name, struct lttng_event **events);
338 int lttng_list_tracepoints(struct lttng_handle *handle, struct lttng_event **events);
339 int lttng_add_context(struct lttng_handle *handle, struct lttng_event_context *ctx,
340 const char *event_name, const char *channel_name);
341 int lttng_enable_event(struct lttng_handle *handle,
342 struct lttng_event *ev, const char *channel_name);
343 int lttng_enable_channel(struct lttng_handle *handle, struct lttng_channel *chan);
344 int lttng_disable_event(struct lttng_handle *handle,
345 const char *name, const char *channel_name);
346 int lttng_disable_channel(struct lttng_handle *handle, const char *name);
347 int lttng_calibrate(struct lttng_handle *handle, struct lttng_calibrate *calibrate);
348 int lttng_register_consumer(struct lttng_handle *handle, const char *socket_path);
349 int lttng_list_sessions(struct lttng_session **sessions);
350 int lttng_list_domains(const char *session_name, struct lttng_domain **domains);
352 //Functions not needing redefinition
353 %feature("docstring")"create(str name, str path) -> int
355 Create a new tracing session using name and path.
356 Returns size of returned session payload data or a negative error code."
357 int lttng_create_session(const char *name, const char *path);
360 %feature("docstring")"destroy(str name) -> int
362 Tear down tracing session using name.
363 Returns size of returned session payload data or a negative error code."
364 int lttng_destroy_session(const char *name);
367 %feature("docstring")"session_daemon_alive() -> int
369 Check if session daemon is alive.
370 Return 1 if alive or 0 if not.
371 On error returns a negative value."
372 int lttng_session_daemon_alive(void);
375 %feature("docstring")"set_tracing_group(str name) -> int
377 Sets the tracing_group variable with name.
378 This function allocates memory pointed to by tracing_group.
379 On success, returns 0, on error, returns -1 (null name) or -ENOMEM."
380 int lttng_set_tracing_group(const char *name);
383 %feature("docstring")"strerror(int code) -> char
385 Returns a human readable string describing
386 the error code (a negative value)."
387 const char *lttng_strerror(int code);
390 %feature("docstring")"start(str session_name) -> int
392 Start tracing for all traces of the session.
393 Returns size of returned session payload data or a negative error code."
394 int lttng_start_tracing(const char *session_name);
397 %feature("docstring")"stop(str session_name) -> int
399 Stop tracing for all traces of the session.
400 Returns size of returned session payload data or a negative error code."
401 int lttng_stop_tracing(const char *session_name);
404 %feature("docstring")"channel_set_default_attr(Domain domain, ChannelAttr attr)
406 Set default channel attributes.
407 If either or both of the arguments are null, attr content is zeroe'd."
408 void lttng_channel_set_default_attr(struct lttng_domain *domain, struct lttng_channel_attr *attr);
411 // =============================================
412 // Python redefinition of some functions
413 // (List and Handle-related)
414 // =============================================
416 %feature("docstring")""
421 list_sessions() -> dict
423 Ask the session daemon for all available sessions.
424 Returns a dict of Session instances, the key is the name;
425 on error, returns a negative value.
428 ses_list = _lttng_list_sessions()
429 if type(ses_list) is int:
434 for ses_elements in ses_list:
436 ses.name = ses_elements[0]
437 ses.path = ses_elements[1]
438 ses.enabled = ses_elements[2]
439 ses.padding = ses_elements[3]
441 sessions[ses.name] = ses
446 def list_domains(session_name):
448 list_domains(str session_name) -> list
450 Ask the session daemon for all available domains of a session.
451 Returns a list of Domain instances;
452 on error, returns a negative value.
455 dom_list = _lttng_list_domains(session_name)
456 if type(dom_list) is int:
461 for dom_elements in dom_list:
463 dom.type = dom_elements[0]
464 dom.paddinf = dom_elements[1]
465 dom.attr.pid = dom_elements[2]
466 dom.attr.exec_name = dom_elements[3]
467 dom.attr.padding = dom_elements[4]
474 def list_channels(handle):
476 list_channels(Handle handle) -> dict
478 Ask the session daemon for all available channels of a session.
479 Returns a dict of Channel instances, the key is the name;
480 on error, returns a negative value.
484 chan_list = _lttng_list_channels(handle._h)
485 except AttributeError:
486 raise TypeError("in method 'list_channels', argument 1 must be a Handle instance")
488 if type(chan_list) is int:
493 for channel_elements in chan_list:
495 chan.name = channel_elements[0]
496 chan.enabled = channel_elements[1]
497 chan.padding = channel_elements[2]
498 chan.attr.overwrite = channel_elements[3][0]
499 chan.attr.subbuf_size = channel_elements[3][1]
500 chan.attr.num_subbuf = channel_elements[3][2]
501 chan.attr.switch_timer_interval = channel_elements[3][3]
502 chan.attr.read_timer_interval = channel_elements[3][4]
503 chan.attr.output = channel_elements[3][5]
504 chan.attr.padding = channel_elements[3][6]
506 channels[chan.name] = chan
511 def list_events(handle, channel_name):
513 list_events(Handle handle, str channel_name) -> dict
515 Ask the session daemon for all available events of a session channel.
516 Returns a dict of Event instances, the key is the name;
517 on error, returns a negative value.
521 ev_list = _lttng_list_events(handle._h, channel_name)
522 except AttributeError:
523 raise TypeError("in method 'list_events', argument 1 must be a Handle instance")
525 if type(ev_list) is int:
530 for ev_elements in ev_list:
532 ev.name = ev_elements[0]
533 ev.type = ev_elements[1]
534 ev.loglevel_type = ev_elements[2]
535 ev.loglevel = ev_elements[3]
536 ev.enabled = ev_elements[4]
537 ev.pid = ev_elements[5]
538 ev.attr.padding = ev_elements[6]
539 ev.attr.probe.addr = ev_elements[7][0]
540 ev.attr.probe.offset = ev_elements[7][1]
541 ev.attr.probe.symbol_name = ev_elements[7][2]
542 ev.attr.probe.padding = ev_elements[7][3]
543 ev.attr.ftrace.symbol_name = ev_elements[8][0]
544 ev.attr.ftrace.padding = ev_elements[8][1]
545 ev.attr.padding = ev_elements[9]
552 def list_tracepoints(handle):
554 list_tracepoints(Handle handle) -> dict
556 Returns a dict of Event instances, the key is the name;
557 on error, returns a negative value.
561 ev_list = _lttng_list_tracepoints(handle._h)
562 except AttributeError:
563 raise TypeError("in method 'list_tracepoints', argument 1 must be a Handle instance")
565 if type(ev_list) is int:
570 for ev_elements in ev_list:
572 ev.name = ev_elements[0]
573 ev.type = ev_elements[1]
574 ev.loglevel_type = ev_elements[2]
575 ev.loglevel = ev_elements[3]
576 ev.enabled = ev_elements[4]
577 ev.pid = ev_elements[5]
578 ev.attr.padding = ev_elements[6]
579 ev.attr.probe.addr = ev_elements[7][0]
580 ev.attr.probe.offset = ev_elements[7][1]
581 ev.attr.probe.symbol_name = ev_elements[7][2]
582 ev.attr.probe.padding = ev_elements[7][3]
583 ev.attr.ftrace.symbol_name = ev_elements[8][0]
584 ev.attr.ftrace.padding = ev_elements[8][1]
585 ev.attr.padding = ev_elements[9]
592 def register_consumer(handle, socket_path):
594 register_consumer(Handle handle, str socket_path) -> int
596 Register an outside consumer.
597 Returns size of returned session payload data or a negative error code.
601 return _lttng_register_consumer(handle._h, socket_path)
602 except AttributeError:
603 raise TypeError("in method 'register_consumer', argument 1 must be a Handle instance")
606 def add_context(handle, event_context, event_name, channel_name):
608 add_context(Handle handle, EventContext ctx,
609 str event_name, str channel_name) -> int
611 Add context to event and/or channel.
612 If event_name is None, the context is applied to all events of the channel.
613 If channel_name is None, a lookup of the event's channel is done.
614 If both are None, the context is applied to all events of all channels.
615 Returns the size of the returned payload data or a negative error code.
619 return _lttng_add_context(handle._h, event_context, event_name, channel_name)
620 except AttributeError:
621 raise TypeError("in method 'add_context', argument 1 must be a Handle instance")
624 def enable_event(handle, event, channel_name):
626 enable_event(Handle handle, Event event,
627 str channel_name) -> int
629 Enable event(s) for a channel.
630 If no event name is specified, all events are enabled.
631 If no channel name is specified, the default 'channel0' is used.
632 Returns size of returned session payload data or a negative error code.
636 return _lttng_enable_event(handle._h, event, channel_name)
637 except AttributeError:
638 raise TypeError("in method 'enable_event', argument 1 must be a Handle instance")
641 def enable_channel(handle, channel):
643 enable_channel(Handle handle, Channel channel -> int
645 Enable channel per domain
646 Returns size of returned session payload data or a negative error code.
650 return _lttng_enable_channel(handle._h, channel)
651 except AttributeError:
652 raise TypeError("in method 'enable_channel', argument 1 must be a Handle instance")
655 def disable_event(handle, name, channel_name):
657 disable_event(Handle handle, str name, str channel_name) -> int
659 Disable event(s) of a channel and domain.
660 If no event name is specified, all events are disabled.
661 If no channel name is specified, the default 'channel0' is used.
662 Returns size of returned session payload data or a negative error code
666 return _lttng_disable_event(handle._h, name, channel_name)
667 except AttributeError:
668 raise TypeError("in method 'disable_event', argument 1 must be a Handle instance")
671 def disable_channel(handle, name):
673 disable_channel(Handle handle, str name) -> int
675 All tracing will be stopped for registered events of the channel.
676 Returns size of returned session payload data or a negative error code.
680 return _lttng_disable_channel(handle._h, name)
681 except AttributeError:
682 raise TypeError("in method 'disable_channel', argument 1 must be a Handle instance")
685 def calibrate(handle, calibrate):
687 calibrate(Handle handle, Calibrate calibrate) -> int
689 Quantify LTTng overhead.
690 Returns size of returned session payload data or a negative error code.
694 return _lttng_calibrate(handle._h, calibrate)
695 except AttributeError:
696 raise TypeError("in method 'calibrate', argument 1 must be a Handle instance")
700 // =============================================
702 // Used to prevent freeing unallocated memory
703 // =============================================
705 %feature("docstring")""
706 %feature("autodoc", "1");
712 Takes two arguments: (str session_name, Domain domain)
717 def __init__(self, session_name, domain):
718 if type(session_name) is not str:
719 raise TypeError("in method '__init__', argument 2 of type 'str'")
720 if type(domain) is not Domain and domain is not None:
721 raise TypeError("in method '__init__', argument 3 of type 'lttng.Domain'")
723 self._sname = session_name
727 self._domtype = domain.type
728 self._h = _lttng_create_handle(session_name, domain)
732 _lttng_destroy_handle(self._h)
735 if self._domtype == 1:
736 domstr = "DOMAIN_KERNEL"
737 elif self._domtype == 2:
738 domstr = "DOMAIN_UST"
740 domstr = self._domtype
742 return "lttng.Handle; session('{}'), domain.type({})".format(
745 def __setattr__(self, attr, val):
747 raise NotImplementedError("cannot modify attributes")
749 self.__dict__[attr] = val
753 // =============================================
755 // These are directly taken from lttng.h.
756 // Any change to these structures must also be
758 // =============================================
760 %rename("Domain") lttng_domain;
761 %rename("EventContext") lttng_event_context;
762 %rename("Event") lttng_event;
763 %rename("Calibrate") lttng_calibrate;
764 %rename("ChannelAttr") lttng_channel_attr;
765 %rename("Channel") lttng_channel;
766 %rename("Session") lttng_session;
769 enum lttng_domain_type type;
770 char padding[LTTNG_DOMAIN_PADDING1];
774 char exec_name[NAME_MAX];
775 char padding[LTTNG_DOMAIN_PADDING2];
780 static char temp[256];
781 switch ( $self->type ) {
783 sprintf(temp, "lttng.Domain; type(DOMAIN_KERNEL)");
786 sprintf(temp, "lttng.Domain; type(DOMAIN_UST)");
789 sprintf(temp, "lttng.Domain; type(%i)", $self->type);
797 struct lttng_event_context {
798 enum lttng_event_context_type ctx;
799 char padding[LTTNG_EVENT_CONTEXT_PADDING1];
802 struct lttng_event_perf_counter_ctx perf_counter;
803 char padding[LTTNG_EVENT_CONTEXT_PADDING2];
808 static char temp[256];
809 switch ( $self->ctx ) {
811 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PID)");
814 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PERF_COUNTER)");
817 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PROCNAME)");
820 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PRIO)");
823 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_NICE)");
826 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VPID)");
829 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_TID)");
832 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VTID)");
835 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PPID)");
838 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VPPID)");
841 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PTHREAD_ID)");
844 sprintf(temp, "lttng.EventContext; type(%i)", $self->ctx);
852 struct lttng_event_probe_attr {
855 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
856 char padding[LTTNG_EVENT_PROBE_PADDING1];
859 struct lttng_event_function_attr {
860 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
861 char padding[LTTNG_EVENT_FUNCTION_PADDING1];
865 enum lttng_event_type type;
866 char name[LTTNG_SYMBOL_NAME_LEN];
868 enum lttng_loglevel_type loglevel_type;
874 char padding[LTTNG_EVENT_PADDING1];
877 struct lttng_event_probe_attr probe;
878 struct lttng_event_function_attr ftrace;
880 char padding[LTTNG_EVENT_PADDING2];
885 static char temp[512];
889 switch ( $self->type ) {
891 sprintf(evtype, "EVENT_ALL");
894 sprintf(evtype, "EVENT_TRACEPOINT");
897 sprintf(evtype, "EVENT_PROBE");
900 sprintf(evtype, "EVENT_FUNCTION");
903 sprintf(evtype, "EVENT_FUNCTION_ENTRY");
906 sprintf(evtype, "EVENT_NOOP");
909 sprintf(evtype, "EVENT_SYSCALL");
912 sprintf(evtype, "%i", $self->type);
916 switch ( $self->loglevel_type ) {
918 sprintf(logtype, "EVENT_LOGLEVEL_ALL");
921 sprintf(logtype, "EVENT_LOGLEVEL_RANGE");
924 sprintf(logtype, "EVENT_LOGLEVEL_SINGLE");
927 sprintf(logtype, "%i", $self->loglevel_type);
931 sprintf(temp, "lttng.Event; name('%s'), type(%s), "
932 "loglevel_type(%s), loglevel(%i), "
933 "enabled(%s), pid(%i)",
934 $self->name, evtype, logtype, $self->loglevel,
935 $self->enabled ? "True" : "False", $self->pid);
941 struct lttng_calibrate {
942 enum lttng_calibrate_type type;
943 char padding[LTTNG_CALIBRATE_PADDING1];
947 static char temp[256];
948 switch ( $self->type ) {
950 sprintf(temp, "lttng.Calibrate; type(CALIBRATE_FUNCTION)");
953 sprintf(temp, "lttng.Calibrate; type(%i)", $self->type);
961 struct lttng_channel_attr {
963 uint64_t subbuf_size;
965 unsigned int switch_timer_interval;
966 unsigned int read_timer_interval;
967 enum lttng_event_output output;
969 char padding[LTTNG_CHANNEL_ATTR_PADDING1];
973 static char temp[256];
976 switch ( $self->output ) {
978 sprintf(evout, "EVENT_SPLICE");
981 sprintf(evout, "EVENT_MMAP");
984 sprintf(evout, "%i", $self->output);
987 sprintf(temp, "lttng.ChannelAttr; overwrite(%i), subbuf_size(%lu), "
988 "num_subbuf(%lu), switch_timer_interval(%u), "
989 "read_timer_interval(%u), output(%s)",
990 $self->overwrite, $self->subbuf_size, $self->num_subbuf,
991 $self->switch_timer_interval, $self->read_timer_interval,
998 struct lttng_channel {
999 char name[LTTNG_SYMBOL_NAME_LEN];
1001 struct lttng_channel_attr attr;
1002 char padding[LTTNG_CHANNEL_PADDING1];
1006 static char temp[512];
1007 sprintf(temp, "lttng.Channel; name('%s'), enabled(%s)",
1008 $self->name, $self->enabled ? "True" : "False");
1014 struct lttng_session {
1015 char name[NAME_MAX];
1016 char path[PATH_MAX];
1018 char padding[LTTNG_SESSION_PADDING1];
1022 static char temp[512];
1023 sprintf(temp, "lttng.Session; name('%s'), path('%s'), enabled(%s)",
1024 $self->name, $self->path,
1025 $self->enabled ? "True" : "False");