Tracepoint API namespacing ust-endian
[lttng-ust.git] / src / lib / lttng-ust / lttng-context-ip.c
... / ...
CommitLineData
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 <limits.h>
11#include <stddef.h>
12#include <sys/types.h>
13#include <unistd.h>
14#include <lttng/ust-events.h>
15#include <lttng/ust-tracer.h>
16#include <lttng/ust-ringbuffer-context.h>
17
18#include "context-internal.h"
19
20static
21size_t ip_get_size(void *priv __attribute__((unused)),
22 size_t offset)
23{
24 size_t size = 0;
25
26 size += lttng_ust_ring_buffer_align(offset, lttng_ust_rb_alignof(void *));
27 size += sizeof(void *);
28 return size;
29}
30
31static
32void ip_record(void *priv __attribute__((unused)),
33 struct lttng_ust_ring_buffer_ctx *ctx,
34 struct lttng_ust_channel_buffer *chan)
35{
36 void *ip;
37
38 ip = ctx->ip;
39 chan->ops->event_write(ctx, &ip, sizeof(ip), lttng_ust_rb_alignof(ip));
40}
41
42static const struct lttng_ust_ctx_field *ctx_field = lttng_ust_static_ctx_field(
43 lttng_ust_static_event_field("ip",
44 lttng_ust_static_type_integer(sizeof(void *) * CHAR_BIT,
45 lttng_ust_rb_alignof(void *) * CHAR_BIT,
46 lttng_ust_is_signed_type(void *),
47 LTTNG_UST_BYTE_ORDER, 10),
48 false, false),
49 ip_get_size,
50 ip_record,
51 NULL, NULL, NULL);
52
53int lttng_add_ip_to_ctx(struct lttng_ust_ctx **ctx)
54{
55 int ret;
56
57 if (lttng_find_context(*ctx, ctx_field->event_field->name)) {
58 ret = -EEXIST;
59 goto error_find_context;
60 }
61 ret = lttng_ust_context_append(ctx, ctx_field);
62 if (ret)
63 return ret;
64 return 0;
65
66error_find_context:
67 return ret;
68}
This page took 0.023414 seconds and 4 git commands to generate.