dc196ee1c5e04b2e95ba843994be3376af6c9bcd
1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
7 * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 #include <linux/module.h>
11 #include <linux/slab.h>
12 #include <linux/sched.h>
13 #include <lttng/lttng-events.h>
14 #include <ringbuffer/frontend_types.h>
15 #include <lttng/lttng-tracer.h>
18 size_t pid_get_size(size_t offset
)
22 size
+= lib_ring_buffer_align(offset
, lttng_alignof(pid_t
));
23 size
+= sizeof(pid_t
);
28 void pid_record(struct lttng_ctx_field
*field
,
29 struct lib_ring_buffer_ctx
*ctx
,
30 struct lttng_channel
*chan
)
34 pid
= task_tgid_nr(current
);
35 lib_ring_buffer_align_ctx(ctx
, lttng_alignof(pid
));
36 chan
->ops
->event_write(ctx
, &pid
, sizeof(pid
));
40 void pid_get_value(struct lttng_ctx_field
*field
,
41 struct lttng_probe_ctx
*lttng_probe_ctx
,
42 union lttng_ctx_value
*value
)
44 value
->s64
= task_tgid_nr(current
);
47 int lttng_add_pid_to_ctx(struct lttng_ctx
**ctx
)
49 struct lttng_ctx_field
*field
;
51 field
= lttng_append_context(ctx
);
54 if (lttng_find_context(*ctx
, "pid")) {
55 lttng_remove_context_field(ctx
, field
);
58 field
->event_field
.name
= "pid";
59 field
->event_field
.type
.atype
= atype_integer
;
60 field
->event_field
.type
.u
.integer
.size
= sizeof(pid_t
) * CHAR_BIT
;
61 field
->event_field
.type
.u
.integer
.alignment
= lttng_alignof(pid_t
) * CHAR_BIT
;
62 field
->event_field
.type
.u
.integer
.signedness
= lttng_is_signed_type(pid_t
);
63 field
->event_field
.type
.u
.integer
.reverse_byte_order
= 0;
64 field
->event_field
.type
.u
.integer
.base
= 10;
65 field
->event_field
.type
.u
.integer
.encoding
= lttng_encode_none
;
66 field
->get_size
= pid_get_size
;
67 field
->record
= pid_record
;
68 field
->get_value
= pid_get_value
;
69 lttng_context_update(*ctx
);
72 EXPORT_SYMBOL_GPL(lttng_add_pid_to_ctx
);
This page took 0.031169 seconds and 4 git commands to generate.