Add PID context
[lttng-modules.git] / probes / lttng-context-pid.c
CommitLineData
9e7e4892
MD
1/*
2 * (C) Copyright 2009-2011 -
3 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 *
5 * LTTng PID context.
6 *
7 * Dual LGPL v2.1/GPL v2 license.
8 */
9
10#include <linux/module.h>
11#include <linux/slab.h>
12#include <linux/sched.h>
13#include "../ltt-events.h"
14#include "../wrapper/ringbuffer/frontend_types.h"
15#include "../wrapper/vmalloc.h"
16#include "../ltt-tracer.h"
17
18static
19void pid_record(struct lttng_ctx_field *field,
20 struct lib_ring_buffer_ctx *ctx,
21 struct ltt_channel *chan)
22{
23 pid_t pid;
24
25 pid = current->pid;
26 lib_ring_buffer_align_ctx(ctx, ltt_alignof(pid));
27 chan->ops->event_write(ctx, &pid, sizeof(pid));
28}
29
30int lttng_add_pid_to_ctx(struct lttng_ctx **ctx)
31{
32 struct lttng_ctx_field *field;
33 int ret;
34
35 field = lttng_append_context(ctx);
36 if (!field)
37 return ret;
38 field->name = "pid";
39 field->type.atype = atype_integer;
40 field->type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
41 field->type.u.basic.integer.alignment = ltt_alignof(pid_t) * CHAR_BIT;
42 field->type.u.basic.integer.signedness = is_signed_type(pid_t);
43 field->type.u.basic.integer.reverse_byte_order = 0;
44 field->type.u.basic.integer.base = 10;
45 field->type.u.basic.integer.encoding = lttng_encode_none;
46 field->callback = pid_record;
47 wrapper_vmalloc_sync_all();
48 return 0;
49}
50
51MODULE_LICENSE("GPL and additional rights");
52MODULE_AUTHOR("Mathieu Desnoyers");
53MODULE_DESCRIPTION("Linux Trace Toolkit Perf Support");
This page took 0.02409 seconds and 4 git commands to generate.