2 * SPDX-License-Identifier: LGPL-2.1-only
4 * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 * LTTng UST Instruction Pointer Context.
12 #include <sys/types.h>
14 #include <lttng/ust-events.h>
15 #include <lttng/ust-tracer.h>
16 #include <lttng/ringbuffer-context.h>
18 #include "context-internal.h"
21 size_t ip_get_size(struct lttng_ust_ctx_field
*field
, size_t offset
)
25 size
+= lttng_ust_lib_ring_buffer_align(offset
, lttng_alignof(void *));
26 size
+= sizeof(void *);
31 void ip_record(struct lttng_ust_ctx_field
*field
,
32 struct lttng_ust_lib_ring_buffer_ctx
*ctx
,
33 struct lttng_ust_channel_buffer
*chan
)
38 lttng_ust_lib_ring_buffer_align_ctx(ctx
, lttng_alignof(ip
));
39 chan
->ops
->event_write(ctx
, &ip
, sizeof(ip
));
42 int lttng_add_ip_to_ctx(struct lttng_ust_ctx
**ctx
)
44 struct lttng_ust_ctx_field
*field
;
45 struct lttng_ust_type_common
*type
;
48 type
= lttng_ust_create_type_integer(sizeof(void *) * CHAR_BIT
,
49 lttng_alignof(void *) * CHAR_BIT
,
50 lttng_ust_is_signed_type(void *),
54 field
= lttng_append_context(ctx
);
59 if (lttng_find_context(*ctx
, "ip")) {
61 goto error_find_context
;
63 field
->event_field
->name
= strdup("ip");
64 if (!field
->event_field
->name
) {
68 field
->event_field
->type
= type
;
69 field
->get_size
= ip_get_size
;
70 field
->record
= ip_record
;
71 lttng_context_update(*ctx
);
76 lttng_remove_context_field(ctx
, field
);
78 lttng_ust_destroy_type(type
);