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("create_snapshot") lttng_create_session_snapshot(const char *name, const char *snapshot_url);
318 %rename("destroy") lttng_destroy_session(const char *name);
319 %rename("_lttng_create_handle") lttng_create_handle(const char *session_name, struct lttng_domain *domain);
320 %rename("_lttng_destroy_handle") lttng_destroy_handle(struct lttng_handle *handle);
321 %rename("_lttng_list_sessions") lttng_list_sessions(struct lttng_session **sessions);
322 %rename("_lttng_list_domains") lttng_list_domains(const char *session_name, struct lttng_domain **domains);
323 %rename("_lttng_list_channels") lttng_list_channels(struct lttng_handle *handle,struct lttng_channel **channels);
324 %rename("_lttng_list_events") lttng_list_events(struct lttng_handle *handle, const char *channel_name, struct lttng_event **events);
325 %rename("_lttng_list_tracepoints") lttng_list_tracepoints(struct lttng_handle *handle, struct lttng_event **events);
326 %rename("session_daemon_alive") lttng_session_daemon_alive(void);
327 %rename("set_tracing_group") lttng_set_tracing_group(const char *name);
328 %rename("strerror") lttng_strerror(int code);
329 %rename("_lttng_register_consumer") lttng_register_consumer(struct lttng_handle *handle, const char *socket_path);
330 %rename("start") lttng_start_tracing(const char *session_name);
331 %rename("stop") lttng_stop_tracing(const char *session_name);
332 %rename("_lttng_add_context") lttng_add_context(struct lttng_handle *handle, struct lttng_event_context *ctx, const char *event_name, const char *channel_name);
333 %rename("_lttng_enable_event") lttng_enable_event(struct lttng_handle *handle, struct lttng_event *ev, const char *channel_name);
334 %rename("_lttng_enable_channel") lttng_enable_channel(struct lttng_handle *handle, struct lttng_channel *chan);
335 %rename("_lttng_disable_event") lttng_disable_event(struct lttng_handle *handle, const char *name, const char *channel_name);
336 %rename("_lttng_disable_channel") lttng_disable_channel(struct lttng_handle *handle, const char *name);
337 %rename("_lttng_calibrate") lttng_calibrate(struct lttng_handle *handle, struct lttng_calibrate *calibrate);
338 %rename("channel_set_default_attr") lttng_channel_set_default_attr(struct lttng_domain *domain, struct lttng_channel_attr *attr);
340 //Redefined functions
341 struct lttng_handle *lttng_create_handle(const char *session_name,
342 struct lttng_domain *domain);
343 void lttng_destroy_handle(struct lttng_handle *handle);
344 int lttng_list_channels(struct lttng_handle *handle,struct lttng_channel **channels);
345 int lttng_list_events(struct lttng_handle *handle,
346 const char *channel_name, struct lttng_event **events);
347 int lttng_list_tracepoints(struct lttng_handle *handle, struct lttng_event **events);
348 int lttng_add_context(struct lttng_handle *handle, struct lttng_event_context *ctx,
349 const char *event_name, const char *channel_name);
350 int lttng_enable_event(struct lttng_handle *handle,
351 struct lttng_event *ev, const char *channel_name);
352 int lttng_enable_channel(struct lttng_handle *handle, struct lttng_channel *chan);
353 int lttng_disable_event(struct lttng_handle *handle,
354 const char *name, const char *channel_name);
355 int lttng_disable_channel(struct lttng_handle *handle, const char *name);
356 int lttng_calibrate(struct lttng_handle *handle, struct lttng_calibrate *calibrate);
357 int lttng_register_consumer(struct lttng_handle *handle, const char *socket_path);
358 int lttng_list_sessions(struct lttng_session **sessions);
359 int lttng_list_domains(const char *session_name, struct lttng_domain **domains);
361 //Functions not needing redefinition
362 %feature("docstring")"create(str name, str path) -> int
364 Create a new tracing session using name and path.
365 Returns 0 on success or a negative error code."
366 int lttng_create_session(const char *name, const char *path);
368 %feature("docstring")"create_snapshot(str name, str snapshot_url) -> int
370 Create a new tracing session using name and snapshot_url in snapshot
371 mode (flight recorder).
372 Returns 0 on success or a negative error code."
373 int lttng_create_session_snapshot(const char *name, const char *path);
375 %feature("docstring")"destroy(str name) -> int
377 Tear down tracing session using name.
378 Returns 0 on success or a negative error code."
379 int lttng_destroy_session(const char *name);
382 %feature("docstring")"session_daemon_alive() -> int
384 Check if session daemon is alive.
385 Return 1 if alive or 0 if not.
386 On error returns a negative value."
387 int lttng_session_daemon_alive(void);
390 %feature("docstring")"set_tracing_group(str name) -> int
392 Sets the tracing_group variable with name.
393 This function allocates memory pointed to by tracing_group.
394 On success, returns 0, on error, returns -1 (null name) or -ENOMEM."
395 int lttng_set_tracing_group(const char *name);
398 %feature("docstring")"strerror(int code) -> char
400 Returns a human readable string describing
401 the error code (a negative value)."
402 const char *lttng_strerror(int code);
405 %feature("docstring")"start(str session_name) -> int
407 Start tracing for all traces of the session.
408 Returns size of returned session payload data or a negative error code."
409 int lttng_start_tracing(const char *session_name);
412 %feature("docstring")"stop(str session_name) -> int
414 Stop tracing for all traces of the session.
415 Returns size of returned session payload data or a negative error code."
416 int lttng_stop_tracing(const char *session_name);
419 %feature("docstring")"channel_set_default_attr(Domain domain, ChannelAttr attr)
421 Set default channel attributes.
422 If either or both of the arguments are null, attr content is zeroe'd."
423 void lttng_channel_set_default_attr(struct lttng_domain *domain, struct lttng_channel_attr *attr);
426 // =============================================
427 // Python redefinition of some functions
428 // (List and Handle-related)
429 // =============================================
431 %feature("docstring")""
436 list_sessions() -> dict
438 Ask the session daemon for all available sessions.
439 Returns a dict of Session instances, the key is the name;
440 on error, returns a negative value.
443 ses_list = _lttng_list_sessions()
444 if type(ses_list) is int:
449 for ses_elements in ses_list:
451 ses.name = ses_elements[0]
452 ses.path = ses_elements[1]
453 ses.enabled = ses_elements[2]
454 ses.padding = ses_elements[3]
456 sessions[ses.name] = ses
461 def list_domains(session_name):
463 list_domains(str session_name) -> list
465 Ask the session daemon for all available domains of a session.
466 Returns a list of Domain instances;
467 on error, returns a negative value.
470 dom_list = _lttng_list_domains(session_name)
471 if type(dom_list) is int:
476 for dom_elements in dom_list:
478 dom.type = dom_elements[0]
479 dom.paddinf = dom_elements[1]
480 dom.attr.pid = dom_elements[2]
481 dom.attr.exec_name = dom_elements[3]
482 dom.attr.padding = dom_elements[4]
489 def list_channels(handle):
491 list_channels(Handle handle) -> dict
493 Ask the session daemon for all available channels of a session.
494 Returns a dict of Channel instances, the key is the name;
495 on error, returns a negative value.
499 chan_list = _lttng_list_channels(handle._h)
500 except AttributeError:
501 raise TypeError("in method 'list_channels', argument 1 must be a Handle instance")
503 if type(chan_list) is int:
508 for channel_elements in chan_list:
510 chan.name = channel_elements[0]
511 chan.enabled = channel_elements[1]
512 chan.padding = channel_elements[2]
513 chan.attr.overwrite = channel_elements[3][0]
514 chan.attr.subbuf_size = channel_elements[3][1]
515 chan.attr.num_subbuf = channel_elements[3][2]
516 chan.attr.switch_timer_interval = channel_elements[3][3]
517 chan.attr.read_timer_interval = channel_elements[3][4]
518 chan.attr.output = channel_elements[3][5]
519 chan.attr.padding = channel_elements[3][6]
521 channels[chan.name] = chan
526 def list_events(handle, channel_name):
528 list_events(Handle handle, str channel_name) -> dict
530 Ask the session daemon for all available events of a session channel.
531 Returns a dict of Event instances, the key is the name;
532 on error, returns a negative value.
536 ev_list = _lttng_list_events(handle._h, channel_name)
537 except AttributeError:
538 raise TypeError("in method 'list_events', argument 1 must be a Handle instance")
540 if type(ev_list) is int:
545 for ev_elements in ev_list:
547 ev.name = ev_elements[0]
548 ev.type = ev_elements[1]
549 ev.loglevel_type = ev_elements[2]
550 ev.loglevel = ev_elements[3]
551 ev.enabled = ev_elements[4]
552 ev.pid = ev_elements[5]
553 ev.attr.padding = ev_elements[6]
554 ev.attr.probe.addr = ev_elements[7][0]
555 ev.attr.probe.offset = ev_elements[7][1]
556 ev.attr.probe.symbol_name = ev_elements[7][2]
557 ev.attr.probe.padding = ev_elements[7][3]
558 ev.attr.ftrace.symbol_name = ev_elements[8][0]
559 ev.attr.ftrace.padding = ev_elements[8][1]
560 ev.attr.padding = ev_elements[9]
567 def list_tracepoints(handle):
569 list_tracepoints(Handle handle) -> dict
571 Returns a dict of Event instances, the key is the name;
572 on error, returns a negative value.
576 ev_list = _lttng_list_tracepoints(handle._h)
577 except AttributeError:
578 raise TypeError("in method 'list_tracepoints', argument 1 must be a Handle instance")
580 if type(ev_list) is int:
585 for ev_elements in ev_list:
587 ev.name = ev_elements[0]
588 ev.type = ev_elements[1]
589 ev.loglevel_type = ev_elements[2]
590 ev.loglevel = ev_elements[3]
591 ev.enabled = ev_elements[4]
592 ev.pid = ev_elements[5]
593 ev.attr.padding = ev_elements[6]
594 ev.attr.probe.addr = ev_elements[7][0]
595 ev.attr.probe.offset = ev_elements[7][1]
596 ev.attr.probe.symbol_name = ev_elements[7][2]
597 ev.attr.probe.padding = ev_elements[7][3]
598 ev.attr.ftrace.symbol_name = ev_elements[8][0]
599 ev.attr.ftrace.padding = ev_elements[8][1]
600 ev.attr.padding = ev_elements[9]
607 def register_consumer(handle, socket_path):
609 register_consumer(Handle handle, str socket_path) -> int
611 Register an outside consumer.
612 Returns size of returned session payload data or a negative error code.
616 return _lttng_register_consumer(handle._h, socket_path)
617 except AttributeError:
618 raise TypeError("in method 'register_consumer', argument 1 must be a Handle instance")
621 def add_context(handle, event_context, event_name, channel_name):
623 add_context(Handle handle, EventContext ctx,
624 str event_name, str channel_name) -> int
626 Add context to event and/or channel.
627 If event_name is None, the context is applied to all events of the channel.
628 If channel_name is None, a lookup of the event's channel is done.
629 If both are None, the context is applied to all events of all channels.
630 Returns the size of the returned payload data or a negative error code.
634 return _lttng_add_context(handle._h, event_context, event_name, channel_name)
635 except AttributeError:
636 raise TypeError("in method 'add_context', argument 1 must be a Handle instance")
639 def enable_event(handle, event, channel_name):
641 enable_event(Handle handle, Event event,
642 str channel_name) -> int
644 Enable event(s) for a channel.
645 If no event name is specified, all events are enabled.
646 If no channel name is specified, the default 'channel0' is used.
647 Returns size of returned session payload data or a negative error code.
651 return _lttng_enable_event(handle._h, event, channel_name)
652 except AttributeError:
653 raise TypeError("in method 'enable_event', argument 1 must be a Handle instance")
656 def enable_channel(handle, channel):
658 enable_channel(Handle handle, Channel channel -> int
660 Enable channel per domain
661 Returns size of returned session payload data or a negative error code.
665 return _lttng_enable_channel(handle._h, channel)
666 except AttributeError:
667 raise TypeError("in method 'enable_channel', argument 1 must be a Handle instance")
670 def disable_event(handle, name, channel_name):
672 disable_event(Handle handle, str name, str channel_name) -> int
674 Disable event(s) of a channel and domain.
675 If no event name is specified, all events are disabled.
676 If no channel name is specified, the default 'channel0' is used.
677 Returns size of returned session payload data or a negative error code
681 return _lttng_disable_event(handle._h, name, channel_name)
682 except AttributeError:
683 raise TypeError("in method 'disable_event', argument 1 must be a Handle instance")
686 def disable_channel(handle, name):
688 disable_channel(Handle handle, str name) -> int
690 All tracing will be stopped for registered events of the channel.
691 Returns size of returned session payload data or a negative error code.
695 return _lttng_disable_channel(handle._h, name)
696 except AttributeError:
697 raise TypeError("in method 'disable_channel', argument 1 must be a Handle instance")
700 def calibrate(handle, calibrate):
702 calibrate(Handle handle, Calibrate calibrate) -> int
704 Quantify LTTng overhead.
705 Returns size of returned session payload data or a negative error code.
709 return _lttng_calibrate(handle._h, calibrate)
710 except AttributeError:
711 raise TypeError("in method 'calibrate', argument 1 must be a Handle instance")
715 // =============================================
717 // Used to prevent freeing unallocated memory
718 // =============================================
720 %feature("docstring")""
721 %feature("autodoc", "1");
727 Takes two arguments: (str session_name, Domain domain)
732 def __init__(self, session_name, domain):
733 if type(session_name) is not str:
734 raise TypeError("in method '__init__', argument 2 of type 'str'")
735 if type(domain) is not Domain and domain is not None:
736 raise TypeError("in method '__init__', argument 3 of type 'lttng.Domain'")
738 self._sname = session_name
742 self._domtype = domain.type
743 self._h = _lttng_create_handle(session_name, domain)
747 _lttng_destroy_handle(self._h)
750 if self._domtype == 1:
751 domstr = "DOMAIN_KERNEL"
752 elif self._domtype == 2:
753 domstr = "DOMAIN_UST"
755 domstr = self._domtype
757 return "lttng.Handle; session('{}'), domain.type({})".format(
760 def __setattr__(self, attr, val):
762 raise NotImplementedError("cannot modify attributes")
764 self.__dict__[attr] = val
768 // =============================================
770 // These are directly taken from lttng.h.
771 // Any change to these structures must also be
773 // =============================================
775 %rename("Domain") lttng_domain;
776 %rename("EventContext") lttng_event_context;
777 %rename("Event") lttng_event;
778 %rename("Calibrate") lttng_calibrate;
779 %rename("ChannelAttr") lttng_channel_attr;
780 %rename("Channel") lttng_channel;
781 %rename("Session") lttng_session;
784 enum lttng_domain_type type;
785 char padding[LTTNG_DOMAIN_PADDING1];
789 char exec_name[NAME_MAX];
790 char padding[LTTNG_DOMAIN_PADDING2];
795 static char temp[256];
796 switch ( $self->type ) {
798 sprintf(temp, "lttng.Domain; type(DOMAIN_KERNEL)");
801 sprintf(temp, "lttng.Domain; type(DOMAIN_UST)");
804 sprintf(temp, "lttng.Domain; type(%i)", $self->type);
812 struct lttng_event_context {
813 enum lttng_event_context_type ctx;
814 char padding[LTTNG_EVENT_CONTEXT_PADDING1];
817 struct lttng_event_perf_counter_ctx perf_counter;
818 char padding[LTTNG_EVENT_CONTEXT_PADDING2];
823 static char temp[256];
824 switch ( $self->ctx ) {
826 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PID)");
829 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PERF_COUNTER)");
832 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PROCNAME)");
835 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PRIO)");
838 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_NICE)");
841 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VPID)");
844 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_TID)");
847 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VTID)");
850 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PPID)");
853 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VPPID)");
856 sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PTHREAD_ID)");
859 sprintf(temp, "lttng.EventContext; type(%i)", $self->ctx);
867 struct lttng_event_probe_attr {
870 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
871 char padding[LTTNG_EVENT_PROBE_PADDING1];
874 struct lttng_event_function_attr {
875 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
876 char padding[LTTNG_EVENT_FUNCTION_PADDING1];
880 enum lttng_event_type type;
881 char name[LTTNG_SYMBOL_NAME_LEN];
883 enum lttng_loglevel_type loglevel_type;
889 char padding[LTTNG_EVENT_PADDING1];
892 struct lttng_event_probe_attr probe;
893 struct lttng_event_function_attr ftrace;
895 char padding[LTTNG_EVENT_PADDING2];
900 static char temp[512];
904 switch ( $self->type ) {
906 sprintf(evtype, "EVENT_ALL");
909 sprintf(evtype, "EVENT_TRACEPOINT");
912 sprintf(evtype, "EVENT_PROBE");
915 sprintf(evtype, "EVENT_FUNCTION");
918 sprintf(evtype, "EVENT_FUNCTION_ENTRY");
921 sprintf(evtype, "EVENT_NOOP");
924 sprintf(evtype, "EVENT_SYSCALL");
927 sprintf(evtype, "%i", $self->type);
931 switch ( $self->loglevel_type ) {
933 sprintf(logtype, "EVENT_LOGLEVEL_ALL");
936 sprintf(logtype, "EVENT_LOGLEVEL_RANGE");
939 sprintf(logtype, "EVENT_LOGLEVEL_SINGLE");
942 sprintf(logtype, "%i", $self->loglevel_type);
946 sprintf(temp, "lttng.Event; name('%s'), type(%s), "
947 "loglevel_type(%s), loglevel(%i), "
948 "enabled(%s), pid(%i)",
949 $self->name, evtype, logtype, $self->loglevel,
950 $self->enabled ? "True" : "False", $self->pid);
956 struct lttng_calibrate {
957 enum lttng_calibrate_type type;
958 char padding[LTTNG_CALIBRATE_PADDING1];
962 static char temp[256];
963 switch ( $self->type ) {
965 sprintf(temp, "lttng.Calibrate; type(CALIBRATE_FUNCTION)");
968 sprintf(temp, "lttng.Calibrate; type(%i)", $self->type);
976 struct lttng_channel_attr {
978 uint64_t subbuf_size;
980 unsigned int switch_timer_interval;
981 unsigned int read_timer_interval;
982 enum lttng_event_output output;
984 char padding[LTTNG_CHANNEL_ATTR_PADDING1];
988 static char temp[256];
991 switch ( $self->output ) {
993 sprintf(evout, "EVENT_SPLICE");
996 sprintf(evout, "EVENT_MMAP");
999 sprintf(evout, "%i", $self->output);
1002 sprintf(temp, "lttng.ChannelAttr; overwrite(%i), subbuf_size(%lu), "
1003 "num_subbuf(%lu), switch_timer_interval(%u), "
1004 "read_timer_interval(%u), output(%s)",
1005 $self->overwrite, $self->subbuf_size, $self->num_subbuf,
1006 $self->switch_timer_interval, $self->read_timer_interval,
1013 struct lttng_channel {
1014 char name[LTTNG_SYMBOL_NAME_LEN];
1016 struct lttng_channel_attr attr;
1017 char padding[LTTNG_CHANNEL_PADDING1];
1021 static char temp[512];
1022 sprintf(temp, "lttng.Channel; name('%s'), enabled(%s)",
1023 $self->name, $self->enabled ? "True" : "False");
1029 struct lttng_session {
1030 char name[NAME_MAX];
1031 char path[PATH_MAX];
1033 char padding[LTTNG_SESSION_PADDING1];
1037 static char temp[512];
1038 sprintf(temp, "lttng.Session; name('%s'), path('%s'), enabled(%s)",
1039 $self->name, $self->path,
1040 $self->enabled ? "True" : "False");