Combine common recorder/notifier functions to lttng_free_event_filter_runtime
[lttng-ust.git] / liblttng-ust / lttng-context-ip.c
CommitLineData
96f85541 1/*
c0c0989a 2 * SPDX-License-Identifier: LGPL-2.1-only
96f85541
MD
3 *
4 * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 *
c0c0989a 6 * LTTng UST Instruction Pointer Context.
96f85541
MD
7 */
8
3fbec7dc 9#define _LGPL_SOURCE
b4051ad8 10#include <stddef.h>
96f85541
MD
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
fc80554e
MJ
17#include "context-internal.h"
18
96f85541 19static
53569322 20size_t ip_get_size(struct lttng_ctx_field *field, size_t offset)
96f85541
MD
21{
22 size_t size = 0;
23
24 size += lib_ring_buffer_align(offset, lttng_alignof(void *));
25 size += sizeof(void *);
26 return size;
27}
28
29static
30void ip_record(struct lttng_ctx_field *field,
31 struct lttng_ust_lib_ring_buffer_ctx *ctx,
32 struct lttng_channel *chan)
33{
34 void *ip;
35
36 ip = ctx->ip;
37 lib_ring_buffer_align_ctx(ctx, lttng_alignof(ip));
38 chan->ops->event_write(ctx, &ip, sizeof(ip));
39}
40
41int lttng_add_ip_to_ctx(struct lttng_ctx **ctx)
42{
43 struct lttng_ctx_field *field;
44
45 field = lttng_append_context(ctx);
46 if (!field)
47 return -ENOMEM;
48 if (lttng_find_context(*ctx, "ip")) {
49 lttng_remove_context_field(ctx, field);
50 return -EEXIST;
51 }
52 field->event_field.name = "ip";
53 field->event_field.type.atype = atype_integer;
218deb69
MD
54 field->event_field.type.u.integer.size = sizeof(void *) * CHAR_BIT;
55 field->event_field.type.u.integer.alignment = lttng_alignof(void *) * CHAR_BIT;
56 field->event_field.type.u.integer.signedness = lttng_is_signed_type(void *);
57 field->event_field.type.u.integer.reverse_byte_order = 0;
58 field->event_field.type.u.integer.base = 16;
59 field->event_field.type.u.integer.encoding = lttng_encode_none;
96f85541
MD
60 field->get_size = ip_get_size;
61 field->record = ip_record;
b2cc986a 62 lttng_context_update(*ctx);
96f85541
MD
63 return 0;
64}
This page took 0.03053 seconds and 4 git commands to generate.