Move to kernel style SPDX license identifiers
[lttng-ust.git] / liblttng-ust / lttng-context-ip.c
1 /*
2 * SPDX-License-Identifier: LGPL-2.1-only
3 *
4 * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 *
6 * LTTng UST Instruction Pointer Context.
7 */
8
9 #define _LGPL_SOURCE
10 #include <stddef.h>
11 #include <sys/types.h>
12 #include <unistd.h>
13 #include <lttng/ust-events.h>
14 #include <lttng/ust-tracer.h>
15 #include <lttng/ringbuffer-config.h>
16
17 static
18 size_t ip_get_size(struct lttng_ctx_field *field, size_t offset)
19 {
20 size_t size = 0;
21
22 size += lib_ring_buffer_align(offset, lttng_alignof(void *));
23 size += sizeof(void *);
24 return size;
25 }
26
27 static
28 void ip_record(struct lttng_ctx_field *field,
29 struct lttng_ust_lib_ring_buffer_ctx *ctx,
30 struct lttng_channel *chan)
31 {
32 void *ip;
33
34 ip = ctx->ip;
35 lib_ring_buffer_align_ctx(ctx, lttng_alignof(ip));
36 chan->ops->event_write(ctx, &ip, sizeof(ip));
37 }
38
39 int lttng_add_ip_to_ctx(struct lttng_ctx **ctx)
40 {
41 struct lttng_ctx_field *field;
42
43 field = lttng_append_context(ctx);
44 if (!field)
45 return -ENOMEM;
46 if (lttng_find_context(*ctx, "ip")) {
47 lttng_remove_context_field(ctx, field);
48 return -EEXIST;
49 }
50 field->event_field.name = "ip";
51 field->event_field.type.atype = atype_integer;
52 field->event_field.type.u.integer.size = sizeof(void *) * CHAR_BIT;
53 field->event_field.type.u.integer.alignment = lttng_alignof(void *) * CHAR_BIT;
54 field->event_field.type.u.integer.signedness = lttng_is_signed_type(void *);
55 field->event_field.type.u.integer.reverse_byte_order = 0;
56 field->event_field.type.u.integer.base = 16;
57 field->event_field.type.u.integer.encoding = lttng_encode_none;
58 field->get_size = ip_get_size;
59 field->record = ip_record;
60 lttng_context_update(*ctx);
61 return 0;
62 }
This page took 0.029812 seconds and 4 git commands to generate.