2 * (C) Copyright 2009-2011 -
3 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 * LTTng UST pthread_id context.
7 * Dual LGPL v2.1/GPL v2 license.
11 #include <ust/lttng-events.h>
12 #include <ust/lttng-tracer.h>
13 #include <ust/ringbuffer-config.h>
16 size_t pthread_id_get_size(size_t offset
)
20 size
+= lib_ring_buffer_align(offset
, lttng_alignof(unsigned long));
21 size
+= sizeof(unsigned long);
26 void pthread_id_record(struct lttng_ctx_field
*field
,
27 struct lttng_ust_lib_ring_buffer_ctx
*ctx
,
28 struct ltt_channel
*chan
)
30 unsigned long pthread_id
;
32 pthread_id
= (unsigned long) pthread_self();
33 lib_ring_buffer_align_ctx(ctx
, lttng_alignof(pthread_id
));
34 chan
->ops
->event_write(ctx
, &pthread_id
, sizeof(pthread_id
));
37 int lttng_add_pthread_id_to_ctx(struct lttng_ctx
**ctx
)
39 struct lttng_ctx_field
*field
;
41 field
= lttng_append_context(ctx
);
44 if (lttng_find_context(*ctx
, "pthread_id")) {
45 lttng_remove_context_field(ctx
, field
);
48 field
->event_field
.name
= "pthread_id";
49 field
->event_field
.type
.atype
= atype_integer
;
50 field
->event_field
.type
.u
.basic
.integer
.size
= sizeof(unsigned long) * CHAR_BIT
;
51 field
->event_field
.type
.u
.basic
.integer
.alignment
= lttng_alignof(unsigned long) * CHAR_BIT
;
52 field
->event_field
.type
.u
.basic
.integer
.signedness
= lttng_is_signed_type(unsigned long);
53 field
->event_field
.type
.u
.basic
.integer
.reverse_byte_order
= 0;
54 field
->event_field
.type
.u
.basic
.integer
.base
= 10;
55 field
->event_field
.type
.u
.basic
.integer
.encoding
= lttng_encode_none
;
56 field
->get_size
= pthread_id_get_size
;
57 field
->record
= pthread_id_record
;