| 1 | /* |
| 2 | * Copyright (C) 2012 Danny Serres <danny.serres@efficios.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0-only |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | %define DOCSTRING |
| 9 | "LTTNG_VERSION_STR |
| 10 | |
| 11 | The LTTng project aims at providing highly efficient tracing tools for Linux. |
| 12 | It's tracers help tracking down performance issues and debugging problems involving |
| 13 | multiple concurrent processes and threads. Tracing across multiple systems is also possible." |
| 14 | %enddef |
| 15 | |
| 16 | %module(docstring=DOCSTRING) lttng |
| 17 | |
| 18 | %include "typemaps.i" |
| 19 | %include "stdint.i" |
| 20 | %include "pyabc.i" |
| 21 | %{ |
| 22 | #define SWIG_FILE_WITH_INIT |
| 23 | #include <lttng/lttng.h> |
| 24 | %} |
| 25 | |
| 26 | %{ |
| 27 | #if PY_MAJOR_VERSION >= 3 |
| 28 | // The PyInt and PyLong types were unified as of Python 3 |
| 29 | // This makes the typemap code useable with both Python 2 and 3. |
| 30 | #define PyInt_AsSsize_t PyLong_AsSsize_t |
| 31 | #endif |
| 32 | |
| 33 | // Avoid -Wmissing-declarations warning. |
| 34 | PyObject *SWIG_init(void); |
| 35 | %} |
| 36 | |
| 37 | typedef unsigned int uint32_t; |
| 38 | typedef int int32_t; |
| 39 | typedef unsigned long long uint64_t; |
| 40 | typedef long pid_t; |
| 41 | |
| 42 | |
| 43 | // ============================================= |
| 44 | // ENUMS |
| 45 | // These are directly taken from lttng.h. |
| 46 | // Any change to these enums must also be |
| 47 | // made here. |
| 48 | // ============================================= |
| 49 | |
| 50 | %rename("DOMAIN_KERNEL") LTTNG_DOMAIN_KERNEL; |
| 51 | %rename("DOMAIN_UST") LTTNG_DOMAIN_UST; |
| 52 | enum lttng_domain_type { |
| 53 | LTTNG_DOMAIN_KERNEL = 1, |
| 54 | LTTNG_DOMAIN_UST = 2, |
| 55 | }; |
| 56 | |
| 57 | %rename("BUFFER_PER_PID") LTTNG_BUFFER_PER_PID; |
| 58 | %rename("BUFFER_PER_UID") LTTNG_BUFFER_PER_UID; |
| 59 | %rename("BUFFER_GLOBAL") LTTNG_BUFFER_GLOBAL; |
| 60 | enum lttng_buffer_type { |
| 61 | LTTNG_BUFFER_PER_PID, |
| 62 | LTTNG_BUFFER_PER_UID, |
| 63 | LTTNG_BUFFER_GLOBAL, |
| 64 | }; |
| 65 | |
| 66 | %rename("EVENT_ALL") LTTNG_EVENT_ALL; |
| 67 | %rename("EVENT_TRACEPOINT") LTTNG_EVENT_TRACEPOINT; |
| 68 | %rename("EVENT_PROBE") LTTNG_EVENT_PROBE; |
| 69 | %rename("EVENT_FUNCTION")LTTNG_EVENT_FUNCTION; |
| 70 | %rename("EVENT_FUNCTION_ENTRY") LTTNG_EVENT_FUNCTION_ENTRY; |
| 71 | %rename("EVENT_NOOP") LTTNG_EVENT_NOOP; |
| 72 | %rename("EVENT_SYSCALL") LTTNG_EVENT_SYSCALL; |
| 73 | enum lttng_event_type { |
| 74 | LTTNG_EVENT_ALL = -1, |
| 75 | LTTNG_EVENT_TRACEPOINT = 0, |
| 76 | LTTNG_EVENT_PROBE = 1, |
| 77 | LTTNG_EVENT_FUNCTION = 2, |
| 78 | LTTNG_EVENT_FUNCTION_ENTRY = 3, |
| 79 | LTTNG_EVENT_NOOP = 4, |
| 80 | LTTNG_EVENT_SYSCALL = 5, |
| 81 | }; |
| 82 | |
| 83 | %rename("EVENT_LOGLEVEL_ALL") LTTNG_EVENT_LOGLEVEL_ALL; |
| 84 | %rename("EVENT_LOGLEVEL_RANGE") LTTNG_EVENT_LOGLEVEL_RANGE; |
| 85 | %rename("EVENT_LOGLEVEL_SINGLE") LTTNG_EVENT_LOGLEVEL_SINGLE; |
| 86 | enum lttng_loglevel_type { |
| 87 | LTTNG_EVENT_LOGLEVEL_ALL = 0, |
| 88 | LTTNG_EVENT_LOGLEVEL_RANGE = 1, |
| 89 | LTTNG_EVENT_LOGLEVEL_SINGLE = 2, |
| 90 | }; |
| 91 | |
| 92 | %rename("LOGLEVEL_EMERG") LTTNG_LOGLEVEL_EMERG; |
| 93 | %rename("LOGLEVEL_ALERT") LTTNG_LOGLEVEL_ALERT; |
| 94 | %rename("LOGLEVEL_CRIT") LTTNG_LOGLEVEL_CRIT; |
| 95 | %rename("LOGLEVEL_ERR") LTTNG_LOGLEVEL_ERR; |
| 96 | %rename("LOGLEVEL_WARNING") LTTNG_LOGLEVEL_WARNING; |
| 97 | %rename("LOGLEVEL_NOTICE") LTTNG_LOGLEVEL_NOTICE; |
| 98 | %rename("LOGLEVEL_INFO") LTTNG_LOGLEVEL_INFO; |
| 99 | %rename("LOGLEVEL_DEBUG_SYSTEM") LTTNG_LOGLEVEL_DEBUG_SYSTEM; |
| 100 | %rename("LOGLEVEL_DEBUG_PROGRAM") LTTNG_LOGLEVEL_DEBUG_PROGRAM; |
| 101 | %rename("LOGLEVEL_DEBUG_PROCESS") LTTNG_LOGLEVEL_DEBUG_PROCESS; |
| 102 | %rename("LOGLEVEL_DEBUG_MODULE") LTTNG_LOGLEVEL_DEBUG_MODULE; |
| 103 | %rename("LOGLEVEL_DEBUG_UNIT") LTTNG_LOGLEVEL_DEBUG_UNIT; |
| 104 | %rename("LOGLEVEL_DEBUG_FUNCTION") LTTNG_LOGLEVEL_DEBUG_FUNCTION; |
| 105 | %rename("LOGLEVEL_DEBUG_LINE") LTTNG_LOGLEVEL_DEBUG_LINE; |
| 106 | %rename("LOGLEVEL_DEBUG") LTTNG_LOGLEVEL_DEBUG; |
| 107 | enum lttng_loglevel { |
| 108 | LTTNG_LOGLEVEL_EMERG = 0, |
| 109 | LTTNG_LOGLEVEL_ALERT = 1, |
| 110 | LTTNG_LOGLEVEL_CRIT = 2, |
| 111 | LTTNG_LOGLEVEL_ERR = 3, |
| 112 | LTTNG_LOGLEVEL_WARNING = 4, |
| 113 | LTTNG_LOGLEVEL_NOTICE = 5, |
| 114 | LTTNG_LOGLEVEL_INFO = 6, |
| 115 | LTTNG_LOGLEVEL_DEBUG_SYSTEM = 7, |
| 116 | LTTNG_LOGLEVEL_DEBUG_PROGRAM = 8, |
| 117 | LTTNG_LOGLEVEL_DEBUG_PROCESS = 9, |
| 118 | LTTNG_LOGLEVEL_DEBUG_MODULE = 10, |
| 119 | LTTNG_LOGLEVEL_DEBUG_UNIT = 11, |
| 120 | LTTNG_LOGLEVEL_DEBUG_FUNCTION = 12, |
| 121 | LTTNG_LOGLEVEL_DEBUG_LINE = 13, |
| 122 | LTTNG_LOGLEVEL_DEBUG = 14, |
| 123 | }; |
| 124 | |
| 125 | %rename("EVENT_SPLICE") LTTNG_EVENT_SPLICE; |
| 126 | %rename("EVENT_MMAP") LTTNG_EVENT_MMAP; |
| 127 | enum lttng_event_output { |
| 128 | LTTNG_EVENT_SPLICE = 0, |
| 129 | LTTNG_EVENT_MMAP = 1, |
| 130 | }; |
| 131 | |
| 132 | %rename("EVENT_CONTEXT_PID") LTTNG_EVENT_CONTEXT_PID; |
| 133 | %rename("EVENT_CONTEXT_PERF_COUNTER") LTTNG_EVENT_CONTEXT_PERF_COUNTER; |
| 134 | %rename("EVENT_CONTEXT_PROCNAME") LTTNG_EVENT_CONTEXT_PROCNAME; |
| 135 | %rename("EVENT_CONTEXT_PRIO") LTTNG_EVENT_CONTEXT_PRIO; |
| 136 | %rename("EVENT_CONTEXT_NICE") LTTNG_EVENT_CONTEXT_NICE; |
| 137 | %rename("EVENT_CONTEXT_VPID") LTTNG_EVENT_CONTEXT_VPID; |
| 138 | %rename("EVENT_CONTEXT_TID") LTTNG_EVENT_CONTEXT_TID; |
| 139 | %rename("EVENT_CONTEXT_VTID") LTTNG_EVENT_CONTEXT_VTID; |
| 140 | %rename("EVENT_CONTEXT_PPID") LTTNG_EVENT_CONTEXT_PPID; |
| 141 | %rename("EVENT_CONTEXT_VPPID") LTTNG_EVENT_CONTEXT_VPPID; |
| 142 | %rename("EVENT_CONTEXT_PTHREAD_ID") LTTNG_EVENT_CONTEXT_PTHREAD_ID; |
| 143 | %rename("EVENT_CONTEXT_HOSTNAME") LTTNG_EVENT_CONTEXT_HOSTNAME; |
| 144 | %rename("EVENT_CONTEXT_IP") LTTNG_EVENT_CONTEXT_IP; |
| 145 | %rename("EVENT_CONTEXT_PERF_CPU_COUNTER") LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER; |
| 146 | %rename("EVENT_CONTEXT_PERF_THREAD_COUNTER") LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER; |
| 147 | %rename("EVENT_CONTEXT_APP_CONTEXT") LTTNG_EVENT_CONTEXT_APP_CONTEXT; |
| 148 | %rename("EVENT_CONTEXT_INTERRUPTIBLE") LTTNG_EVENT_CONTEXT_INTERRUPTIBLE; |
| 149 | %rename("EVENT_CONTEXT_PREEMPTIBLE") LTTNG_EVENT_CONTEXT_PREEMPTIBLE; |
| 150 | %rename("EVENT_CONTEXT_NEED_RESCHEDULE") LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE; |
| 151 | %rename("EVENT_CONTEXT_MIGRATABLE") LTTNG_EVENT_CONTEXT_MIGRATABLE; |
| 152 | enum lttng_event_context_type { |
| 153 | LTTNG_EVENT_CONTEXT_PID = 0, |
| 154 | LTTNG_EVENT_CONTEXT_PERF_COUNTER = 1, |
| 155 | LTTNG_EVENT_CONTEXT_PROCNAME = 2, |
| 156 | LTTNG_EVENT_CONTEXT_PRIO = 3, |
| 157 | LTTNG_EVENT_CONTEXT_NICE = 4, |
| 158 | LTTNG_EVENT_CONTEXT_VPID = 5, |
| 159 | LTTNG_EVENT_CONTEXT_TID = 6, |
| 160 | LTTNG_EVENT_CONTEXT_VTID = 7, |
| 161 | LTTNG_EVENT_CONTEXT_PPID = 8, |
| 162 | LTTNG_EVENT_CONTEXT_VPPID = 9, |
| 163 | LTTNG_EVENT_CONTEXT_PTHREAD_ID = 10, |
| 164 | LTTNG_EVENT_CONTEXT_HOSTNAME = 11, |
| 165 | LTTNG_EVENT_CONTEXT_IP = 12, |
| 166 | LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER = 13, |
| 167 | LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER = 14, |
| 168 | LTTNG_EVENT_CONTEXT_APP_CONTEXT = 15, |
| 169 | LTTNG_EVENT_CONTEXT_INTERRUPTIBLE = 16, |
| 170 | LTTNG_EVENT_CONTEXT_PREEMPTIBLE = 17, |
| 171 | LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE = 18, |
| 172 | LTTNG_EVENT_CONTEXT_MIGRATABLE = 19, |
| 173 | }; |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | // ============================================= |
| 179 | // TYPEMAPS |
| 180 | // ============================================= |
| 181 | |
| 182 | //list_sessions |
| 183 | %typemap(argout) struct lttng_session **sessions{ |
| 184 | |
| 185 | int l = PyInt_AsSsize_t($result); |
| 186 | if (l >= 0) |
| 187 | { |
| 188 | PyObject *sessions = PyList_New(0); |
| 189 | int i; |
| 190 | for(i=0; i<l; i++) |
| 191 | { |
| 192 | PyObject *tmp = PyTuple_New(4); |
| 193 | PyObject *name = PyString_FromString((*$1)[i].name); |
| 194 | PyObject *path = PyString_FromString((*$1)[i].path); |
| 195 | PyObject *enabled = PyInt_FromSize_t((*$1)[i].enabled); |
| 196 | |
| 197 | PyTuple_SetItem(tmp, 0, name); |
| 198 | PyTuple_SetItem(tmp, 1, path); |
| 199 | PyTuple_SetItem(tmp, 2, enabled); |
| 200 | PyList_Append(sessions, tmp); |
| 201 | } |
| 202 | $result = sessions; |
| 203 | } |
| 204 | } |
| 205 | %typemap(in,numinputs=0) struct lttng_session **sessions (struct lttng_session *temp){ |
| 206 | $1=&temp; |
| 207 | } |
| 208 | |
| 209 | //list_domains |
| 210 | %typemap(argout) struct lttng_domain **domains{ |
| 211 | |
| 212 | int l = PyInt_AsSsize_t($result); |
| 213 | if (l >= 0) |
| 214 | { |
| 215 | PyObject *dom = PyList_New(0); |
| 216 | int i; |
| 217 | for(i=0; i<l; i++) |
| 218 | { |
| 219 | PyObject *tmp = PyTuple_New(6); |
| 220 | PyObject *type = PyInt_FromSize_t((*$1)[i].type); |
| 221 | PyObject *buf_type = PyInt_FromSize_t((*$1)[i].buf_type); |
| 222 | PyObject *execname = PyString_FromString((*$1)[i].attr.exec_name); |
| 223 | PyObject *pid = PyInt_FromSize_t((*$1)[i].attr.pid); |
| 224 | PyObject *padding = PyString_FromString((*$1)[i].padding); |
| 225 | PyObject *attrpadding = PyString_FromString((*$1)[i].attr.padding); |
| 226 | |
| 227 | PyTuple_SetItem(tmp, 0, type); |
| 228 | PyTuple_SetItem(tmp, 1, buf_type); |
| 229 | PyTuple_SetItem(tmp, 2, padding); |
| 230 | PyTuple_SetItem(tmp, 3, pid); |
| 231 | PyTuple_SetItem(tmp, 4, execname); |
| 232 | PyTuple_SetItem(tmp, 5, attrpadding); |
| 233 | PyList_Append(dom, tmp); |
| 234 | } |
| 235 | $result = dom; |
| 236 | } |
| 237 | } |
| 238 | %typemap(in,numinputs=0) struct lttng_domain **domains (struct lttng_domain *temp){ |
| 239 | $1=&temp; |
| 240 | } |
| 241 | |
| 242 | //list_channels |
| 243 | %typemap(argout) struct lttng_channel **channels{ |
| 244 | |
| 245 | int l = PyInt_AsSsize_t($result); |
| 246 | if (l >= 0) |
| 247 | { |
| 248 | PyObject *chan = PyList_New(0); |
| 249 | int i; |
| 250 | for(i=0; i<l; i++) |
| 251 | { |
| 252 | PyObject *tmp = PyTuple_New(4); |
| 253 | PyObject *name = PyString_FromString((*$1)[i].name); |
| 254 | PyObject *enabled = PyInt_FromSize_t((*$1)[i].enabled); |
| 255 | PyObject *padding = PyString_FromString((*$1)[i].padding); |
| 256 | |
| 257 | PyObject *attrtmp = PyTuple_New(7); |
| 258 | PyObject *overwrite = PyInt_FromLong((*$1)[i].attr.overwrite); |
| 259 | PyObject *subbuf = PyInt_FromSize_t((*$1)[i].attr.subbuf_size); |
| 260 | PyObject *num = PyInt_FromSize_t((*$1)[i].attr.num_subbuf); |
| 261 | PyObject *switchtimer = PyInt_FromSize_t((*$1)[i].attr.switch_timer_interval); |
| 262 | PyObject *readtimer = PyInt_FromSize_t((*$1)[i].attr.read_timer_interval); |
| 263 | PyObject *output = PyInt_FromSize_t((*$1)[i].attr.output); |
| 264 | PyObject *attrpad = PyString_FromString((*$1)[i].attr.padding); |
| 265 | |
| 266 | PyTuple_SetItem(attrtmp, 0, overwrite); |
| 267 | PyTuple_SetItem(attrtmp, 1, subbuf); |
| 268 | PyTuple_SetItem(attrtmp, 2, num); |
| 269 | PyTuple_SetItem(attrtmp, 3, switchtimer); |
| 270 | PyTuple_SetItem(attrtmp, 4, readtimer); |
| 271 | PyTuple_SetItem(attrtmp, 5, output); |
| 272 | PyTuple_SetItem(attrtmp, 6, attrpad); |
| 273 | |
| 274 | PyTuple_SetItem(tmp, 0, name); |
| 275 | PyTuple_SetItem(tmp, 1, enabled); |
| 276 | PyTuple_SetItem(tmp, 2, padding); |
| 277 | PyTuple_SetItem(tmp, 3, attrtmp); |
| 278 | PyList_Append(chan, tmp); |
| 279 | } |
| 280 | $result = chan; |
| 281 | } |
| 282 | } |
| 283 | %typemap(in,numinputs=0) struct lttng_channel **channels (struct lttng_channel *temp){ |
| 284 | $1=&temp; |
| 285 | } |
| 286 | |
| 287 | //list_events & list_tracepoints |
| 288 | %typemap(argout) struct lttng_event **events{ |
| 289 | |
| 290 | int l = PyInt_AsSsize_t($result); |
| 291 | if (l >= 0) |
| 292 | { |
| 293 | PyObject *events = PyList_New(0); |
| 294 | int i; |
| 295 | for(i=0; i<l; i++) |
| 296 | { |
| 297 | PyObject *tmp = PyTuple_New(10); |
| 298 | PyObject *name = PyString_FromString((*$1)[i].name); |
| 299 | PyObject *type = PyInt_FromSize_t((*$1)[i].type); |
| 300 | PyObject *logleveltype = PyInt_FromSize_t((*$1)[i].loglevel_type); |
| 301 | PyObject *loglevel = PyInt_FromLong((*$1)[i].loglevel); |
| 302 | PyObject *enabled = PyInt_FromLong((*$1)[i].enabled); |
| 303 | PyObject *pid = PyInt_FromSize_t((*$1)[i].pid); |
| 304 | PyObject *padding = PyString_FromString((*$1)[i].padding); |
| 305 | PyObject *attrpadding = PyString_FromString((*$1)[i].attr.padding); |
| 306 | |
| 307 | PyObject *probe = PyTuple_New(4); |
| 308 | PyObject *addr = PyInt_FromSize_t((*$1)[i].attr.probe.addr); |
| 309 | PyObject *offset = PyInt_FromSize_t((*$1)[i].attr.probe.offset); |
| 310 | PyObject *symbolname = PyString_FromString((*$1)[i].attr.probe.symbol_name); |
| 311 | PyObject *probepad = PyString_FromString((*$1)[i].attr.probe.padding); |
| 312 | |
| 313 | PyObject *function = PyTuple_New(2); |
| 314 | PyObject *f_symbolname = PyString_FromString((*$1)[i].attr.ftrace.symbol_name); |
| 315 | PyObject *f_pad = PyString_FromString((*$1)[i].attr.ftrace.padding); |
| 316 | |
| 317 | PyTuple_SetItem(function, 0, f_symbolname); |
| 318 | PyTuple_SetItem(function, 1, f_pad); |
| 319 | |
| 320 | PyTuple_SetItem(probe, 0, addr); |
| 321 | PyTuple_SetItem(probe, 1, offset); |
| 322 | PyTuple_SetItem(probe, 2, symbolname); |
| 323 | PyTuple_SetItem(probe, 3, probepad); |
| 324 | |
| 325 | PyTuple_SetItem(tmp, 0, name); |
| 326 | PyTuple_SetItem(tmp, 1, type); |
| 327 | PyTuple_SetItem(tmp, 2, logleveltype); |
| 328 | PyTuple_SetItem(tmp, 3, loglevel); |
| 329 | PyTuple_SetItem(tmp, 4, enabled); |
| 330 | PyTuple_SetItem(tmp, 5, pid); |
| 331 | PyTuple_SetItem(tmp, 6, padding); |
| 332 | PyTuple_SetItem(tmp, 7, probe); |
| 333 | PyTuple_SetItem(tmp, 8, function); |
| 334 | PyTuple_SetItem(tmp, 9, attrpadding); |
| 335 | PyList_Append(events, tmp); |
| 336 | } |
| 337 | $result = events; |
| 338 | } |
| 339 | } |
| 340 | %typemap(in,numinputs=0) struct lttng_event **events (struct lttng_event *temp){ |
| 341 | $1=&temp; |
| 342 | } |
| 343 | |
| 344 | |
| 345 | |
| 346 | // ============================================= |
| 347 | // FUNCTIONS |
| 348 | // ============================================= |
| 349 | |
| 350 | %rename("create") lttng_create_session(const char *name, const char *path); |
| 351 | %rename("create_snapshot") lttng_create_session_snapshot(const char *name, const char *snapshot_url); |
| 352 | %rename("destroy") lttng_destroy_session(const char *name); |
| 353 | %rename("_lttng_create_handle") lttng_create_handle(const char *session_name, struct lttng_domain *domain); |
| 354 | %rename("_lttng_destroy_handle") lttng_destroy_handle(struct lttng_handle *handle); |
| 355 | %rename("_lttng_list_sessions") lttng_list_sessions(struct lttng_session **sessions); |
| 356 | %rename("_lttng_list_domains") lttng_list_domains(const char *session_name, struct lttng_domain **domains); |
| 357 | %rename("_lttng_list_channels") lttng_list_channels(struct lttng_handle *handle,struct lttng_channel **channels); |
| 358 | %rename("_lttng_list_events") lttng_list_events(struct lttng_handle *handle, const char *channel_name, struct lttng_event **events); |
| 359 | %rename("_lttng_list_tracepoints") lttng_list_tracepoints(struct lttng_handle *handle, struct lttng_event **events); |
| 360 | %rename("session_daemon_alive") lttng_session_daemon_alive(void); |
| 361 | %rename("set_tracing_group") lttng_set_tracing_group(const char *name); |
| 362 | %rename("strerror") lttng_strerror(int code); |
| 363 | %rename("_lttng_register_consumer") lttng_register_consumer(struct lttng_handle *handle, const char *socket_path); |
| 364 | %rename("start") lttng_start_tracing(const char *session_name); |
| 365 | %rename("stop") lttng_stop_tracing(const char *session_name); |
| 366 | %rename("_lttng_add_context") lttng_add_context(struct lttng_handle *handle, struct lttng_event_context *ctx, const char *event_name, const char *channel_name); |
| 367 | %rename("_lttng_enable_event") lttng_enable_event(struct lttng_handle *handle, struct lttng_event *ev, const char *channel_name); |
| 368 | %rename("_lttng_enable_channel") lttng_enable_channel(struct lttng_handle *handle, struct lttng_channel *chan); |
| 369 | %rename("_lttng_disable_event") lttng_disable_event(struct lttng_handle *handle, const char *name, const char *channel_name); |
| 370 | %rename("_lttng_disable_channel") lttng_disable_channel(struct lttng_handle *handle, const char *name); |
| 371 | %rename("channel_set_default_attr") lttng_channel_set_default_attr(struct lttng_domain *domain, struct lttng_channel_attr *attr); |
| 372 | |
| 373 | //Redefined functions |
| 374 | struct lttng_handle *lttng_create_handle(const char *session_name, |
| 375 | struct lttng_domain *domain); |
| 376 | void lttng_destroy_handle(struct lttng_handle *handle); |
| 377 | int lttng_list_channels(struct lttng_handle *handle,struct lttng_channel **channels); |
| 378 | int lttng_list_events(struct lttng_handle *handle, |
| 379 | const char *channel_name, struct lttng_event **events); |
| 380 | int lttng_list_tracepoints(struct lttng_handle *handle, struct lttng_event **events); |
| 381 | int lttng_add_context(struct lttng_handle *handle, struct lttng_event_context *ctx, |
| 382 | const char *event_name, const char *channel_name); |
| 383 | int lttng_enable_event(struct lttng_handle *handle, |
| 384 | struct lttng_event *ev, const char *channel_name); |
| 385 | int lttng_enable_channel(struct lttng_handle *handle, struct lttng_channel *chan); |
| 386 | int lttng_disable_event(struct lttng_handle *handle, |
| 387 | const char *name, const char *channel_name); |
| 388 | int lttng_disable_channel(struct lttng_handle *handle, const char *name); |
| 389 | int lttng_register_consumer(struct lttng_handle *handle, const char *socket_path); |
| 390 | int lttng_list_sessions(struct lttng_session **sessions); |
| 391 | int lttng_list_domains(const char *session_name, struct lttng_domain **domains); |
| 392 | |
| 393 | //Functions not needing redefinition |
| 394 | %feature("docstring")"create(str name, str path) -> int |
| 395 | |
| 396 | Create a new tracing session using name and path. |
| 397 | Returns 0 on success or a negative error code." |
| 398 | int lttng_create_session(const char *name, const char *path); |
| 399 | |
| 400 | %feature("docstring")"create_snapshot(str name, str snapshot_url) -> int |
| 401 | |
| 402 | Create a new tracing session using name and snapshot_url in snapshot |
| 403 | mode (flight recorder). |
| 404 | Returns 0 on success or a negative error code." |
| 405 | int lttng_create_session_snapshot(const char *name, const char *path); |
| 406 | |
| 407 | %feature("docstring")"destroy(str name) -> int |
| 408 | |
| 409 | Tear down tracing session using name. |
| 410 | Returns 0 on success or a negative error code." |
| 411 | int lttng_destroy_session(const char *name); |
| 412 | |
| 413 | |
| 414 | %feature("docstring")"session_daemon_alive() -> int |
| 415 | |
| 416 | Check if session daemon is alive. |
| 417 | Return 1 if alive or 0 if not. |
| 418 | On error returns a negative value." |
| 419 | int lttng_session_daemon_alive(void); |
| 420 | |
| 421 | |
| 422 | %feature("docstring")"set_tracing_group(str name) -> int |
| 423 | |
| 424 | Sets the tracing_group variable with name. |
| 425 | This function allocates memory pointed to by tracing_group. |
| 426 | On success, returns 0, on error, returns -1 (null name) or -ENOMEM." |
| 427 | int lttng_set_tracing_group(const char *name); |
| 428 | |
| 429 | |
| 430 | %feature("docstring")"strerror(int code) -> char |
| 431 | |
| 432 | Returns a human readable string describing |
| 433 | the error code (a negative value)." |
| 434 | const char *lttng_strerror(int code); |
| 435 | |
| 436 | |
| 437 | %feature("docstring")"start(str session_name) -> int |
| 438 | |
| 439 | Start tracing for all traces of the session. |
| 440 | Returns size of returned session payload data or a negative error code." |
| 441 | int lttng_start_tracing(const char *session_name); |
| 442 | |
| 443 | |
| 444 | %feature("docstring")"stop(str session_name) -> int |
| 445 | |
| 446 | Stop tracing for all traces of the session. |
| 447 | Returns size of returned session payload data or a negative error code." |
| 448 | int lttng_stop_tracing(const char *session_name); |
| 449 | |
| 450 | |
| 451 | %feature("docstring")"channel_set_default_attr(Domain domain, ChannelAttr attr) |
| 452 | |
| 453 | Set default channel attributes. |
| 454 | If either or both of the arguments are null, attr content is zeroe'd." |
| 455 | void lttng_channel_set_default_attr(struct lttng_domain *domain, struct lttng_channel_attr *attr); |
| 456 | |
| 457 | |
| 458 | // ============================================= |
| 459 | // Python redefinition of some functions |
| 460 | // (List and Handle-related) |
| 461 | // ============================================= |
| 462 | |
| 463 | %feature("docstring")"" |
| 464 | %pythoncode %{ |
| 465 | |
| 466 | def list_sessions(): |
| 467 | """ |
| 468 | list_sessions() -> dict |
| 469 | |
| 470 | Ask the session daemon for all available sessions. |
| 471 | Returns a dict of Session instances, the key is the name; |
| 472 | on error, returns a negative value. |
| 473 | """ |
| 474 | |
| 475 | ses_list = _lttng_list_sessions() |
| 476 | if type(ses_list) is int: |
| 477 | return ses_list |
| 478 | |
| 479 | sessions = {} |
| 480 | |
| 481 | for ses_elements in ses_list: |
| 482 | ses = Session() |
| 483 | ses.name = ses_elements[0] |
| 484 | ses.path = ses_elements[1] |
| 485 | ses.enabled = ses_elements[2] |
| 486 | ses.padding = ses_elements[3] |
| 487 | |
| 488 | sessions[ses.name] = ses |
| 489 | |
| 490 | return sessions |
| 491 | |
| 492 | |
| 493 | def list_domains(session_name): |
| 494 | """ |
| 495 | list_domains(str session_name) -> list |
| 496 | |
| 497 | Ask the session daemon for all available domains of a session. |
| 498 | Returns a list of Domain instances; |
| 499 | on error, returns a negative value. |
| 500 | """ |
| 501 | |
| 502 | dom_list = _lttng_list_domains(session_name) |
| 503 | if type(dom_list) is int: |
| 504 | return dom_list |
| 505 | |
| 506 | domains = [] |
| 507 | |
| 508 | for dom_elements in dom_list: |
| 509 | dom = Domain() |
| 510 | dom.type = dom_elements[0] |
| 511 | dom.buf_type = dom_elements[1] |
| 512 | dom.paddinf = dom_elements[2] |
| 513 | dom.attr.pid = dom_elements[3] |
| 514 | dom.attr.exec_name = dom_elements[4] |
| 515 | dom.attr.padding = dom_elements[5] |
| 516 | |
| 517 | domains.append(dom) |
| 518 | |
| 519 | return domains |
| 520 | |
| 521 | |
| 522 | def list_channels(handle): |
| 523 | """ |
| 524 | list_channels(Handle handle) -> dict |
| 525 | |
| 526 | Ask the session daemon for all available channels of a session. |
| 527 | Returns a dict of Channel instances, the key is the name; |
| 528 | on error, returns a negative value. |
| 529 | """ |
| 530 | |
| 531 | try: |
| 532 | chan_list = _lttng_list_channels(handle._h) |
| 533 | except AttributeError: |
| 534 | raise TypeError("in method 'list_channels', argument 1 must be a Handle instance") |
| 535 | |
| 536 | if type(chan_list) is int: |
| 537 | return chan_list |
| 538 | |
| 539 | channels = {} |
| 540 | |
| 541 | for channel_elements in chan_list: |
| 542 | chan = Channel() |
| 543 | chan.name = channel_elements[0] |
| 544 | chan.enabled = channel_elements[1] |
| 545 | chan.padding = channel_elements[2] |
| 546 | chan.attr.overwrite = channel_elements[3][0] |
| 547 | chan.attr.subbuf_size = channel_elements[3][1] |
| 548 | chan.attr.num_subbuf = channel_elements[3][2] |
| 549 | chan.attr.switch_timer_interval = channel_elements[3][3] |
| 550 | chan.attr.read_timer_interval = channel_elements[3][4] |
| 551 | chan.attr.output = channel_elements[3][5] |
| 552 | chan.attr.padding = channel_elements[3][6] |
| 553 | |
| 554 | channels[chan.name] = chan |
| 555 | |
| 556 | return channels |
| 557 | |
| 558 | |
| 559 | def list_events(handle, channel_name): |
| 560 | """ |
| 561 | list_events(Handle handle, str channel_name) -> dict |
| 562 | |
| 563 | Ask the session daemon for all available events of a session channel. |
| 564 | Returns a dict of Event instances, the key is the name; |
| 565 | on error, returns a negative value. |
| 566 | """ |
| 567 | |
| 568 | try: |
| 569 | ev_list = _lttng_list_events(handle._h, channel_name) |
| 570 | except AttributeError: |
| 571 | raise TypeError("in method 'list_events', argument 1 must be a Handle instance") |
| 572 | |
| 573 | if type(ev_list) is int: |
| 574 | return ev_list |
| 575 | |
| 576 | events = {} |
| 577 | |
| 578 | for ev_elements in ev_list: |
| 579 | ev = Event() |
| 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] |
| 594 | |
| 595 | events[ev.name] = ev |
| 596 | |
| 597 | return events |
| 598 | |
| 599 | |
| 600 | def list_tracepoints(handle): |
| 601 | """ |
| 602 | list_tracepoints(Handle handle) -> dict |
| 603 | |
| 604 | Returns a dict of Event instances, the key is the name; |
| 605 | on error, returns a negative value. |
| 606 | """ |
| 607 | |
| 608 | try: |
| 609 | ev_list = _lttng_list_tracepoints(handle._h) |
| 610 | except AttributeError: |
| 611 | raise TypeError("in method 'list_tracepoints', argument 1 must be a Handle instance") |
| 612 | |
| 613 | if type(ev_list) is int: |
| 614 | return ev_list |
| 615 | |
| 616 | events = {} |
| 617 | |
| 618 | for ev_elements in ev_list: |
| 619 | ev = Event() |
| 620 | ev.name = ev_elements[0] |
| 621 | ev.type = ev_elements[1] |
| 622 | ev.loglevel_type = ev_elements[2] |
| 623 | ev.loglevel = ev_elements[3] |
| 624 | ev.enabled = ev_elements[4] |
| 625 | ev.pid = ev_elements[5] |
| 626 | ev.attr.padding = ev_elements[6] |
| 627 | ev.attr.probe.addr = ev_elements[7][0] |
| 628 | ev.attr.probe.offset = ev_elements[7][1] |
| 629 | ev.attr.probe.symbol_name = ev_elements[7][2] |
| 630 | ev.attr.probe.padding = ev_elements[7][3] |
| 631 | ev.attr.ftrace.symbol_name = ev_elements[8][0] |
| 632 | ev.attr.ftrace.padding = ev_elements[8][1] |
| 633 | ev.attr.padding = ev_elements[9] |
| 634 | |
| 635 | events[ev.name] = ev |
| 636 | |
| 637 | return events |
| 638 | |
| 639 | |
| 640 | def register_consumer(handle, socket_path): |
| 641 | """ |
| 642 | register_consumer(Handle handle, str socket_path) -> int |
| 643 | |
| 644 | Register an outside consumer. |
| 645 | Returns size of returned session payload data or a negative error code. |
| 646 | """ |
| 647 | |
| 648 | try: |
| 649 | return _lttng_register_consumer(handle._h, socket_path) |
| 650 | except AttributeError: |
| 651 | raise TypeError("in method 'register_consumer', argument 1 must be a Handle instance") |
| 652 | |
| 653 | |
| 654 | def add_context(handle, event_context, event_name, channel_name): |
| 655 | """ |
| 656 | add_context(Handle handle, EventContext ctx, |
| 657 | str event_name, str channel_name) -> int |
| 658 | |
| 659 | Add context to event and/or channel. |
| 660 | If event_name is None, the context is applied to all events of the channel. |
| 661 | If channel_name is None, a lookup of the event's channel is done. |
| 662 | If both are None, the context is applied to all events of all channels. |
| 663 | Returns the size of the returned payload data or a negative error code. |
| 664 | """ |
| 665 | |
| 666 | try: |
| 667 | return _lttng_add_context(handle._h, event_context, event_name, channel_name) |
| 668 | except AttributeError: |
| 669 | raise TypeError("in method 'add_context', argument 1 must be a Handle instance") |
| 670 | |
| 671 | |
| 672 | def enable_event(handle, event, channel_name): |
| 673 | """ |
| 674 | enable_event(Handle handle, Event event, |
| 675 | str channel_name) -> int |
| 676 | |
| 677 | Enable event(s) for a channel. |
| 678 | If no event name is specified, all events are enabled. |
| 679 | If no channel name is specified, the default 'channel0' is used. |
| 680 | Returns size of returned session payload data or a negative error code. |
| 681 | """ |
| 682 | |
| 683 | try: |
| 684 | return _lttng_enable_event(handle._h, event, channel_name) |
| 685 | except AttributeError: |
| 686 | raise TypeError("in method 'enable_event', argument 1 must be a Handle instance") |
| 687 | |
| 688 | |
| 689 | def enable_channel(handle, channel): |
| 690 | """ |
| 691 | enable_channel(Handle handle, Channel channel -> int |
| 692 | |
| 693 | Enable channel per domain |
| 694 | Returns size of returned session payload data or a negative error code. |
| 695 | """ |
| 696 | |
| 697 | try: |
| 698 | return _lttng_enable_channel(handle._h, channel) |
| 699 | except AttributeError: |
| 700 | raise TypeError("in method 'enable_channel', argument 1 must be a Handle instance") |
| 701 | |
| 702 | |
| 703 | def disable_event(handle, name, channel_name): |
| 704 | """ |
| 705 | disable_event(Handle handle, str name, str channel_name) -> int |
| 706 | |
| 707 | Disable event(s) of a channel and domain. |
| 708 | If no event name is specified, all events are disabled. |
| 709 | If no channel name is specified, the default 'channel0' is used. |
| 710 | Returns size of returned session payload data or a negative error code |
| 711 | """ |
| 712 | |
| 713 | try: |
| 714 | return _lttng_disable_event(handle._h, name, channel_name) |
| 715 | except AttributeError: |
| 716 | raise TypeError("in method 'disable_event', argument 1 must be a Handle instance") |
| 717 | |
| 718 | |
| 719 | def disable_channel(handle, name): |
| 720 | """ |
| 721 | disable_channel(Handle handle, str name) -> int |
| 722 | |
| 723 | All tracing will be stopped for registered events of the channel. |
| 724 | Returns size of returned session payload data or a negative error code. |
| 725 | """ |
| 726 | |
| 727 | try: |
| 728 | return _lttng_disable_channel(handle._h, name) |
| 729 | except AttributeError: |
| 730 | raise TypeError("in method 'disable_channel', argument 1 must be a Handle instance") |
| 731 | %} |
| 732 | |
| 733 | |
| 734 | // ============================================= |
| 735 | // Handle class |
| 736 | // Used to prevent freeing unallocated memory |
| 737 | // ============================================= |
| 738 | |
| 739 | %feature("docstring")"" |
| 740 | %feature("autodoc", "1"); |
| 741 | |
| 742 | %pythoncode %{ |
| 743 | class Handle: |
| 744 | """ |
| 745 | Manages a handle. |
| 746 | Takes two arguments: (str session_name, Domain domain) |
| 747 | """ |
| 748 | |
| 749 | __frozen = False |
| 750 | |
| 751 | def __init__(self, session_name, domain): |
| 752 | if type(session_name) is not str: |
| 753 | raise TypeError("in method '__init__', argument 2 of type 'str'") |
| 754 | if type(domain) is not Domain and domain is not None: |
| 755 | raise TypeError("in method '__init__', argument 3 of type 'lttng.Domain'") |
| 756 | |
| 757 | self._sname = session_name |
| 758 | if domain is None: |
| 759 | self._domtype = None |
| 760 | else: |
| 761 | self._domtype = domain.type |
| 762 | self._h = _lttng_create_handle(session_name, domain) |
| 763 | self.__frozen = True |
| 764 | |
| 765 | def __del__(self): |
| 766 | _lttng_destroy_handle(self._h) |
| 767 | |
| 768 | def __repr__(self): |
| 769 | if self._domtype == 1: |
| 770 | domstr = "DOMAIN_KERNEL" |
| 771 | elif self._domtype == 2: |
| 772 | domstr = "DOMAIN_UST" |
| 773 | else: |
| 774 | domstr = self._domtype |
| 775 | |
| 776 | return "lttng.Handle; session('{}'), domain.type({})".format( |
| 777 | self._sname, domstr) |
| 778 | |
| 779 | def __setattr__(self, attr, val): |
| 780 | if self.__frozen: |
| 781 | raise NotImplementedError("cannot modify attributes") |
| 782 | else: |
| 783 | self.__dict__[attr] = val |
| 784 | %} |
| 785 | |
| 786 | |
| 787 | // ============================================= |
| 788 | // STRUCTURES |
| 789 | // These are directly taken from lttng.h. |
| 790 | // Any change to these structures must also be |
| 791 | // made here. |
| 792 | // ============================================= |
| 793 | |
| 794 | %rename("Domain") lttng_domain; |
| 795 | %rename("EventContext") lttng_event_context; |
| 796 | %rename("Event") lttng_event; |
| 797 | %rename("ChannelAttr") lttng_channel_attr; |
| 798 | %rename("Channel") lttng_channel; |
| 799 | %rename("Session") lttng_session; |
| 800 | |
| 801 | struct lttng_domain{ |
| 802 | enum lttng_domain_type type; |
| 803 | enum lttng_buffer_type buf_type; |
| 804 | char padding[LTTNG_DOMAIN_PADDING1]; |
| 805 | |
| 806 | union { |
| 807 | pid_t pid; |
| 808 | char exec_name[NAME_MAX]; |
| 809 | char padding[LTTNG_DOMAIN_PADDING2]; |
| 810 | } attr; |
| 811 | |
| 812 | %extend { |
| 813 | char *__repr__() { |
| 814 | static char temp[256]; |
| 815 | static char domain_type[25]; |
| 816 | static char buffer_type[25]; |
| 817 | switch ( $self->type ) { |
| 818 | case 1: |
| 819 | sprintf(domain_type, "type(DOMAIN_KERNEL)"); |
| 820 | break; |
| 821 | case 2: |
| 822 | sprintf(domain_type, "type(DOMAIN_UST)"); |
| 823 | break; |
| 824 | default: |
| 825 | sprintf(domain_type, "type(%i)", $self->type); |
| 826 | break; |
| 827 | } |
| 828 | |
| 829 | switch ( $self->buf_type ) { |
| 830 | case LTTNG_BUFFER_PER_UID: |
| 831 | sprintf(buffer_type, "buf_type(BUFFER_PER_UID)"); |
| 832 | break; |
| 833 | case LTTNG_BUFFER_PER_PID: |
| 834 | sprintf(buffer_type, "buf_type(BUFFER_PER_PID)"); |
| 835 | break; |
| 836 | case LTTNG_BUFFER_GLOBAL: |
| 837 | sprintf(buffer_type, "buf_type(BUFFER_GLOBAL)"); |
| 838 | break; |
| 839 | default: |
| 840 | sprintf(buffer_type, "buf_type(%i)", $self->buf_type); |
| 841 | break; |
| 842 | } |
| 843 | |
| 844 | sprintf(temp, "lttng.Domain; %s, %s", |
| 845 | domain_type, |
| 846 | buffer_type |
| 847 | ); |
| 848 | return &temp[0]; |
| 849 | } |
| 850 | } |
| 851 | }; |
| 852 | |
| 853 | struct lttng_event_context { |
| 854 | enum lttng_event_context_type ctx; |
| 855 | char padding[LTTNG_EVENT_CONTEXT_PADDING1]; |
| 856 | |
| 857 | union { |
| 858 | struct lttng_event_perf_counter_ctx perf_counter; |
| 859 | char padding[LTTNG_EVENT_CONTEXT_PADDING2]; |
| 860 | } u; |
| 861 | |
| 862 | %extend { |
| 863 | char *__repr__() { |
| 864 | static char temp[256]; |
| 865 | switch ( $self->ctx ) { |
| 866 | case 0: |
| 867 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PID)"); |
| 868 | break; |
| 869 | case 1: |
| 870 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PERF_COUNTER)"); |
| 871 | break; |
| 872 | case 2: |
| 873 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PROCNAME)"); |
| 874 | break; |
| 875 | case 3: |
| 876 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PRIO)"); |
| 877 | break; |
| 878 | case 4: |
| 879 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_NICE)"); |
| 880 | break; |
| 881 | case 5: |
| 882 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VPID)"); |
| 883 | break; |
| 884 | case 6: |
| 885 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_TID)"); |
| 886 | break; |
| 887 | case 7: |
| 888 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VTID)"); |
| 889 | break; |
| 890 | case 8: |
| 891 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PPID)"); |
| 892 | break; |
| 893 | case 9: |
| 894 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_VPPID)"); |
| 895 | break; |
| 896 | case 10: |
| 897 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PTHREAD_ID)"); |
| 898 | break; |
| 899 | case 11: |
| 900 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_HOSTNAME)"); |
| 901 | break; |
| 902 | case 12: |
| 903 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_IP)"); |
| 904 | break; |
| 905 | case 13: |
| 906 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PERF_CPU_COUNTER)"); |
| 907 | break; |
| 908 | case 14: |
| 909 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PERF_THREAD_COUNTER)"); |
| 910 | break; |
| 911 | case 15: |
| 912 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_APP_CONTEXT)"); |
| 913 | break; |
| 914 | case 16: |
| 915 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_INTERRUPTIBLE)"); |
| 916 | break; |
| 917 | case 17: |
| 918 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_PREEMPTIBLE)"); |
| 919 | break; |
| 920 | case 18: |
| 921 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_NEED_RESCHEDULE)"); |
| 922 | break; |
| 923 | case 19: |
| 924 | sprintf(temp, "lttng.EventContext; ctx(EVENT_CONTEXT_MIGRATABLE)"); |
| 925 | break; |
| 926 | default: |
| 927 | sprintf(temp, "lttng.EventContext; type(%i)", $self->ctx); |
| 928 | break; |
| 929 | } |
| 930 | return &temp[0]; |
| 931 | } |
| 932 | } |
| 933 | }; |
| 934 | |
| 935 | struct lttng_event_probe_attr { |
| 936 | uint64_t addr; |
| 937 | uint64_t offset; |
| 938 | char symbol_name[LTTNG_SYMBOL_NAME_LEN]; |
| 939 | char padding[LTTNG_EVENT_PROBE_PADDING1]; |
| 940 | }; |
| 941 | |
| 942 | struct lttng_event_function_attr { |
| 943 | char symbol_name[LTTNG_SYMBOL_NAME_LEN]; |
| 944 | char padding[LTTNG_EVENT_FUNCTION_PADDING1]; |
| 945 | }; |
| 946 | |
| 947 | struct lttng_event { |
| 948 | enum lttng_event_type type; |
| 949 | char name[LTTNG_SYMBOL_NAME_LEN]; |
| 950 | |
| 951 | enum lttng_loglevel_type loglevel_type; |
| 952 | int loglevel; |
| 953 | |
| 954 | int32_t enabled; |
| 955 | pid_t pid; |
| 956 | |
| 957 | char padding[LTTNG_EVENT_PADDING1]; |
| 958 | |
| 959 | union { |
| 960 | struct lttng_event_probe_attr probe; |
| 961 | struct lttng_event_function_attr ftrace; |
| 962 | |
| 963 | char padding[LTTNG_EVENT_PADDING2]; |
| 964 | } attr; |
| 965 | |
| 966 | %extend { |
| 967 | char *__repr__() { |
| 968 | static char temp[512]; |
| 969 | char evtype[50]; |
| 970 | char logtype[50]; |
| 971 | |
| 972 | switch ( $self->type ) { |
| 973 | case -1: |
| 974 | sprintf(evtype, "EVENT_ALL"); |
| 975 | break; |
| 976 | case 0: |
| 977 | sprintf(evtype, "EVENT_TRACEPOINT"); |
| 978 | break; |
| 979 | case 1: |
| 980 | sprintf(evtype, "EVENT_PROBE"); |
| 981 | break; |
| 982 | case 2: |
| 983 | sprintf(evtype, "EVENT_FUNCTION"); |
| 984 | break; |
| 985 | case 3: |
| 986 | sprintf(evtype, "EVENT_FUNCTION_ENTRY"); |
| 987 | break; |
| 988 | case 4: |
| 989 | sprintf(evtype, "EVENT_NOOP"); |
| 990 | break; |
| 991 | case 5: |
| 992 | sprintf(evtype, "EVENT_SYSCALL"); |
| 993 | break; |
| 994 | default: |
| 995 | sprintf(evtype, "%i", $self->type); |
| 996 | break; |
| 997 | } |
| 998 | |
| 999 | switch ( $self->loglevel_type ) { |
| 1000 | case 0: |
| 1001 | sprintf(logtype, "EVENT_LOGLEVEL_ALL"); |
| 1002 | break; |
| 1003 | case 1: |
| 1004 | sprintf(logtype, "EVENT_LOGLEVEL_RANGE"); |
| 1005 | break; |
| 1006 | case 2: |
| 1007 | sprintf(logtype, "EVENT_LOGLEVEL_SINGLE"); |
| 1008 | break; |
| 1009 | default: |
| 1010 | sprintf(logtype, "%i", $self->loglevel_type); |
| 1011 | break; |
| 1012 | } |
| 1013 | |
| 1014 | sprintf(temp, "lttng.Event; name('%s'), type(%s), " |
| 1015 | "loglevel_type(%s), loglevel(%i), " |
| 1016 | "enabled(%s), pid(%i)", |
| 1017 | $self->name, evtype, logtype, $self->loglevel, |
| 1018 | $self->enabled ? "True" : "False", $self->pid); |
| 1019 | return &temp[0]; |
| 1020 | } |
| 1021 | } |
| 1022 | }; |
| 1023 | |
| 1024 | struct lttng_channel_attr { |
| 1025 | int overwrite; |
| 1026 | uint64_t subbuf_size; |
| 1027 | uint64_t num_subbuf; |
| 1028 | unsigned int switch_timer_interval; |
| 1029 | unsigned int read_timer_interval; |
| 1030 | enum lttng_event_output output; |
| 1031 | |
| 1032 | char padding[LTTNG_CHANNEL_ATTR_PADDING1]; |
| 1033 | |
| 1034 | %extend { |
| 1035 | char *__repr__() { |
| 1036 | static char temp[256]; |
| 1037 | char evout[25]; |
| 1038 | |
| 1039 | switch ( $self->output ) { |
| 1040 | case 0: |
| 1041 | sprintf(evout, "EVENT_SPLICE"); |
| 1042 | break; |
| 1043 | case 1: |
| 1044 | sprintf(evout, "EVENT_MMAP"); |
| 1045 | break; |
| 1046 | default: |
| 1047 | sprintf(evout, "%i", $self->output); |
| 1048 | break; |
| 1049 | } |
| 1050 | sprintf(temp, "lttng.ChannelAttr; overwrite(%i), subbuf_size(%"PRIu64"), " |
| 1051 | "num_subbuf(%"PRIu64"), switch_timer_interval(%u), " |
| 1052 | "read_timer_interval(%u), output(%s)", |
| 1053 | $self->overwrite, $self->subbuf_size, $self->num_subbuf, |
| 1054 | $self->switch_timer_interval, $self->read_timer_interval, |
| 1055 | evout); |
| 1056 | return &temp[0]; |
| 1057 | } |
| 1058 | } |
| 1059 | }; |
| 1060 | |
| 1061 | struct lttng_channel { |
| 1062 | char name[LTTNG_SYMBOL_NAME_LEN]; |
| 1063 | uint32_t enabled; |
| 1064 | struct lttng_channel_attr attr; |
| 1065 | char padding[LTTNG_CHANNEL_PADDING1]; |
| 1066 | |
| 1067 | %extend { |
| 1068 | char *__repr__() { |
| 1069 | static char temp[512]; |
| 1070 | snprintf(temp, sizeof(temp), "lttng.Channel; name('%s'), enabled(%s)", |
| 1071 | $self->name, $self->enabled ? "True" : "False"); |
| 1072 | return &temp[0]; |
| 1073 | } |
| 1074 | } |
| 1075 | }; |
| 1076 | |
| 1077 | struct lttng_session { |
| 1078 | char name[NAME_MAX]; |
| 1079 | char path[PATH_MAX]; |
| 1080 | uint32_t enabled; |
| 1081 | uint32_t snapshot_mode; |
| 1082 | unsigned int live_timer_interval; |
| 1083 | union { |
| 1084 | char padding[LTTNG_SESSION_PADDING1]; |
| 1085 | void *ptr; |
| 1086 | } extended; |
| 1087 | |
| 1088 | %extend { |
| 1089 | char *__repr__() { |
| 1090 | static char temp[PATH_MAX + NAME_MAX + 512]; |
| 1091 | snprintf(temp, sizeof(temp), "lttng.Session; name('%s'), path('%s'), enabled(%s)", |
| 1092 | $self->name, $self->path, |
| 1093 | $self->enabled ? "True" : "False"); |
| 1094 | return &temp[0]; |
| 1095 | } |
| 1096 | } |
| 1097 | }; |