From: Mathieu Desnoyers Date: Wed, 28 Sep 2011 00:09:43 +0000 (-0400) Subject: Add pthread id event context X-Git-Tag: v1.9.1~175 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8de38cf7e2d29984b9a699e90b3e20e9ce0882f3;p=lttng-ust.git Add pthread id event context Signed-off-by: Mathieu Desnoyers --- diff --git a/include/ust/lttng-ust-abi.h b/include/ust/lttng-ust-abi.h index ef1e7e54..04965387 100644 --- a/include/ust/lttng-ust-abi.h +++ b/include/ust/lttng-ust-abi.h @@ -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 { diff --git a/libust/lttng-context-pthread-id.c b/libust/lttng-context-pthread-id.c index f65968bf..d5ca2309 100644 --- a/libust/lttng-context-pthread-id.c +++ b/libust/lttng-context-pthread-id.c @@ -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; diff --git a/libust/lttng-ust-abi.c b/libust/lttng-ust-abi.c index 31306fb2..924b7afa 100644 --- a/libust/lttng-ust-abi.c +++ b/libust/lttng-ust-abi.c @@ -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; } diff --git a/tests/ust-basic-tracing/ust-basic-tracing.c b/tests/ust-basic-tracing/ust-basic-tracing.c index 8e0847fa..d0ba4137 100644 --- a/tests/ust-basic-tracing/ust-basic-tracing.c +++ b/tests/ust-basic-tracing/ust-basic-tracing.c @@ -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));