From dd5f427a5998f826204ac3bfc1659cd7177dc747 Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Thu, 23 May 2019 14:02:26 -0400 Subject: [PATCH] Fix: python binding: expose domain buffer type MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit On enable_channel the domain buffer type is used to create a temporary channel. This currently fail for kernel channel since the buffer type is not exposed at the binding level and default to LTTNG_BUFFER_PER_PID. Channel for the kernel domain can only be created in LTTNG_BUFFER_GLOBAL mode. Exposing the buffer type also allow userpsace channel to use the per uid buffering scheme. The current bindings are in a rough state. This is to at least get them to work with kernel domain. Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau --- extras/bindings/swig/python/lttng.i.in | 59 ++++++++++++++++++++------ 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/extras/bindings/swig/python/lttng.i.in b/extras/bindings/swig/python/lttng.i.in index 7418d01d6..780ee01b5 100644 --- a/extras/bindings/swig/python/lttng.i.in +++ b/extras/bindings/swig/python/lttng.i.in @@ -44,6 +44,15 @@ enum lttng_domain_type { LTTNG_DOMAIN_UST = 2, }; +%rename("BUFFER_PER_PID") LTTNG_BUFFER_PER_PID; +%rename("BUFFER_PER_UID") LTTNG_BUFFER_PER_UID; +%rename("BUFFER_GLOBAL") LTTNG_BUFFER_GLOBAL; +enum lttng_buffer_type { + LTTNG_BUFFER_PER_PID, + LTTNG_BUFFER_PER_UID, + LTTNG_BUFFER_GLOBAL, +}; + %rename("EVENT_ALL") LTTNG_EVENT_ALL; %rename("EVENT_TRACEPOINT") LTTNG_EVENT_TRACEPOINT; %rename("EVENT_PROBE") LTTNG_EVENT_PROBE; @@ -179,18 +188,20 @@ enum lttng_event_context_type { int i; for(i=0; itype ) { case 1: - sprintf(temp, "lttng.Domain; type(DOMAIN_KERNEL)"); + sprintf(domain_type, "type(DOMAIN_KERNEL)"); break; case 2: - sprintf(temp, "lttng.Domain; type(DOMAIN_UST)"); + sprintf(domain_type, "type(DOMAIN_UST)"); break; default: - sprintf(temp, "lttng.Domain; type(%i)", $self->type); + sprintf(domain_type, "type(%i)", $self->type); break; } + + switch ( $self->buf_type ) { + case LTTNG_BUFFER_PER_UID: + sprintf(buffer_type, "buf_type(BUFFER_PER_UID)"); + break; + case LTTNG_BUFFER_PER_PID: + sprintf(buffer_type, "buf_type(BUFFER_PER_PID)"); + break; + case LTTNG_BUFFER_GLOBAL: + sprintf(buffer_type, "buf_type(BUFFER_GLOBAL)"); + break; + default: + sprintf(buffer_type, "buf_type(%i)", $self->buf_type); + break; + } + + sprintf(temp, "lttng.Domain; %s, %s", + domain_type, + buffer_type + ); return &temp[0]; } } -- 2.34.1