Add pthread id event context
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 28 Sep 2011 00:09:43 +0000 (20:09 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 28 Sep 2011 00:09:43 +0000 (20:09 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/ust/lttng-ust-abi.h
libust/lttng-context-pthread-id.c
libust/lttng-ust-abi.c
tests/ust-basic-tracing/ust-basic-tracing.c

index ef1e7e542548140f612bcfeaef94d5cdb7c28483..04965387c1c8ad13144569e5c7b14fd41f979031 100644 (file)
@@ -66,7 +66,7 @@ struct lttng_ust_event {
 };
 
 enum lttng_ust_context_type {
-       LTTNG_UST_CONTEXT_VTID                  = 0,
+       LTTNG_UST_CONTEXT_PTHREAD_ID            = 0,
 };
 
 struct lttng_ust_context {
index f65968bf3c5f9c681b79de3b4d2778ec228b3859..d5ca230939eef0ad88d3b21d4c09a94b10ead1ff 100644 (file)
@@ -17,8 +17,8 @@ size_t pthread_id_get_size(size_t offset)
 {
        size_t size = 0;
 
-       size += lib_ring_buffer_align(offset, lttng_alignof(pid_t));
-       size += sizeof(pid_t);
+       size += lib_ring_buffer_align(offset, lttng_alignof(unsigned long));
+       size += sizeof(unsigned long);
        return size;
 }
 
@@ -47,8 +47,8 @@ int lttng_add_pthread_id_to_ctx(struct lttng_ctx **ctx)
        }
        field->event_field.name = "pthread_id";
        field->event_field.type.atype = atype_integer;
-       field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
-       field->event_field.type.u.basic.integer.alignment = lttng_alignof(pid_t) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.size = sizeof(unsigned long) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.alignment = lttng_alignof(unsigned long) * CHAR_BIT;
        field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(pid_t);
        field->event_field.type.u.basic.integer.reverse_byte_order = 0;
        field->event_field.type.u.basic.integer.base = 10;
index 31306fb2c34e5997ac53ff40f317dc20922d66fd..924b7afaea342684d4510f2f121214a91addc709 100644 (file)
@@ -272,8 +272,8 @@ long lttng_abi_add_context(int objd,
                return -EPERM;
 
        switch (context_param->ctx) {
-       case LTTNG_UST_CONTEXT_VTID:
-               //TODO return lttng_add_vtid_to_ctx(ctx);
+       case LTTNG_UST_CONTEXT_PTHREAD_ID:
+               return lttng_add_pthread_id_to_ctx(ctx);
        default:
                return -EINVAL;
        }
index 8e0847fa41c5828828bc9e0a6d94872402b441bb..d0ba4137d9899ed760194e749b94626fc8d022b1 100644 (file)
@@ -56,6 +56,7 @@ static struct object_data metadata_data;
 static struct object_data channel_data;
 static struct object_data stream_data[MAX_NR_STREAMS];
 static int event_handle[MAX_NR_EVENTS];
+static int context_handle;
 
 static int apps_socket = -1;
 static char apps_sock_path[PATH_MAX];
@@ -564,6 +565,17 @@ int send_app_msgs(int sock, const char *outputpath,
                printf("received event handle %u\n", event_handle[k]);
        }
 
+       /* Attach pthread_id context */
+       memset(&lum, 0, sizeof(lum));
+       lum.handle = channel_data.handle;
+       lum.cmd = LTTNG_UST_CONTEXT;
+       lum.u.context.ctx = LTTNG_UST_CONTEXT_PTHREAD_ID;
+       ret = send_app_cmd(sock, &lum, &lur);
+       if (ret)
+               return ret;
+       context_handle = lur.ret_val;
+       printf("received context handle %u\n", context_handle);
+
        /* Get references to channel streams */
        ret = open_streams(sock, channel_data.handle,
                        stream_data, MAX_NR_STREAMS);
@@ -604,6 +616,14 @@ int send_app_msgs(int sock, const char *outputpath,
        if (ret)
                return ret;
 
+       /* Release context */
+       memset(&lum, 0, sizeof(lum));
+       lum.handle = context_handle;
+       lum.cmd = LTTNG_UST_RELEASE;
+       ret = send_app_cmd(sock, &lum, &lur);
+       if (ret)
+               return ret;
+
        /* Release events */
        for (k = 0; k < nr_events; k++) {
                memset(&lum, 0, sizeof(lum));
This page took 0.02778 seconds and 4 git commands to generate.