Fix: python binding: expose domain buffer type
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Thu, 23 May 2019 18:02:26 +0000 (14:02 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 24 May 2019 19:02:19 +0000 (15:02 -0400)
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 <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
extras/bindings/swig/python/lttng.i.in

index 7418d01d635c24778b55309de35aff4a4716086d..780ee01b5222ee2c87f004c8e51ce513e2e6806d 100644 (file)
@@ -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; i<l; i++)
                {
-                       PyObject *tmp = PyTuple_New(5);
+                       PyObject *tmp = PyTuple_New(6);
                        PyObject *type = PyInt_FromSize_t((*$1)[i].type);
+                       PyObject *buf_type = PyInt_FromSize_t((*$1)[i].buf_type);
                        PyObject *execname = PyString_FromString((*$1)[i].attr.exec_name);
                        PyObject *pid = PyInt_FromSize_t((*$1)[i].attr.pid);
                        PyObject *padding = PyString_FromString((*$1)[i].padding);
                        PyObject *attrpadding = PyString_FromString((*$1)[i].attr.padding);
 
                        PyTuple_SetItem(tmp, 0, type);
-                       PyTuple_SetItem(tmp, 1, padding);
-                       PyTuple_SetItem(tmp, 2, pid);
-                       PyTuple_SetItem(tmp, 3, execname);
-                       PyTuple_SetItem(tmp, 4, attrpadding);
+                       PyTuple_SetItem(tmp, 1, buf_type);
+                       PyTuple_SetItem(tmp, 2, padding);
+                       PyTuple_SetItem(tmp, 3, pid);
+                       PyTuple_SetItem(tmp, 4, execname);
+                       PyTuple_SetItem(tmp, 5, attrpadding);
                        PyList_Append(dom, tmp);
                }
                $result = dom;
@@ -469,10 +480,11 @@ def list_domains(session_name):
        for dom_elements in dom_list:
                dom = Domain()
                dom.type = dom_elements[0]
-               dom.paddinf = dom_elements[1]
-               dom.attr.pid = dom_elements[2]
-               dom.attr.exec_name = dom_elements[3]
-               dom.attr.padding = dom_elements[4]
+               dom.buf_type = dom_elements[1]
+               dom.paddinf = dom_elements[2]
+               dom.attr.pid = dom_elements[3]
+               dom.attr.exec_name = dom_elements[4]
+               dom.attr.padding = dom_elements[5]
 
                domains.append(dom)
 
@@ -760,6 +772,7 @@ class Handle:
 
 struct lttng_domain{
        enum lttng_domain_type type;
+       enum lttng_buffer_type buf_type;
        char padding[LTTNG_DOMAIN_PADDING1];
 
        union {
@@ -771,17 +784,39 @@ struct lttng_domain{
        %extend {
                char *__repr__() {
                        static char temp[256];
+                       static char domain_type[25];
+                       static char buffer_type[25];
                        switch ( $self->type ) {
                        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];
                }
        }
This page took 0.028077 seconds and 4 git commands to generate.