Refactoring: struct lttng_ust_channel_ops
[lttng-ust.git] / include / ust-context-provider.h
CommitLineData
53569322 1/*
c0c0989a 2 * SPDX-License-Identifier: MIT
53569322 3 *
c0c0989a 4 * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
28b9540b
MJ
5 *
6 * The context provider feature is part of the ABI and used by the Java jni
7 * interface. This header should be moved to the public header directory once
8 * some test code and documentation is written.
53569322
MD
9 */
10
c0c0989a
MJ
11#ifndef _LTTNG_UST_CONTEXT_PROVIDER_H
12#define _LTTNG_UST_CONTEXT_PROVIDER_H
13
b4051ad8 14#include <stddef.h>
53569322
MD
15#include <lttng/ust-events.h>
16#include <urcu/hlist.h>
17
fa194c41
MJ
18#include "ust-dynamic-type.h"
19
daacdbfc
MD
20/*
21 * Context value
22 *
23 * IMPORTANT: this structure is part of the ABI between the probe and
24 * UST. Fields need to be only added at the end, never reordered, never
25 * removed.
26 *
27 * The field @struct_size should be used to determine the size of the
28 * structure. It should be queried before using additional fields added
29 * at the end of the structure.
30 */
31
32struct lttng_ust_ctx_value {
33 uint32_t struct_size;
34
fa194c41
MJ
35 enum lttng_ust_dynamic_type sel;
36 union {
37 int64_t s64;
38 uint64_t u64;
39 const char *str;
40 double d;
41 } u;
daacdbfc
MD
42
43 /* End of base ABI. Fields below should be used after checking struct_size. */
fa194c41
MJ
44};
45
daacdbfc
MD
46/*
47 * Context field
48 *
49 * IMPORTANT: this structure is part of the ABI between the probe and
50 * UST. Fields need to be only added at the end, never reordered, never
51 * removed.
52 *
53 * The field @struct_size should be used to determine the size of the
54 * structure. It should be queried before using additional fields added
55 * at the end of the structure.
56 */
57
58struct lttng_ust_ctx_field {
59 uint32_t struct_size;
60 void *priv;
fa194c41 61
daacdbfc
MD
62 struct lttng_ust_event_field *event_field;
63 size_t (*get_size)(struct lttng_ust_ctx_field *field, size_t offset);
64 void (*record)(struct lttng_ust_ctx_field *field,
fa194c41
MJ
65 struct lttng_ust_lib_ring_buffer_ctx *ctx,
66 struct lttng_channel *chan);
daacdbfc
MD
67 void (*get_value)(struct lttng_ust_ctx_field *field,
68 struct lttng_ust_ctx_value *value);
69 void (*destroy)(struct lttng_ust_ctx_field *field);
fa194c41 70 char *field_name; /* Has ownership, dynamically allocated. */
daacdbfc
MD
71
72 /* End of base ABI. Fields below should be used after checking struct_size. */
fa194c41
MJ
73};
74
daacdbfc
MD
75/*
76 * All context fields for a given event/channel
77 *
78 * IMPORTANT: this structure is part of the ABI between the probe and
79 * UST. Fields need to be only added at the end, never reordered, never
80 * removed.
81 *
82 * The field @struct_size should be used to determine the size of the
83 * structure. It should be queried before using additional fields added
84 * at the end of the structure.
85 */
86
87struct lttng_ust_ctx {
88 uint32_t struct_size;
89
90 struct lttng_ust_ctx_field **fields;
fa194c41
MJ
91 unsigned int nr_fields;
92 unsigned int allocated_fields;
93 unsigned int largest_align;
daacdbfc
MD
94
95 /* End of base ABI. Fields below should be used after checking struct_size. */
fa194c41
MJ
96};
97
daacdbfc
MD
98/*
99 * Context provider
100 *
101 * IMPORTANT: this structure is part of the ABI between the probe and
102 * UST. Fields need to be only added at the end, never reordered, never
103 * removed.
104 *
105 * The field @struct_size should be used to determine the size of the
106 * structure. It should be queried before using additional fields added
107 * at the end of the structure.
108 */
109
53569322 110struct lttng_ust_context_provider {
daacdbfc
MD
111 uint32_t struct_size;
112
53569322 113 char *name;
daacdbfc
MD
114 size_t (*get_size)(struct lttng_ust_ctx_field *field, size_t offset);
115 void (*record)(struct lttng_ust_ctx_field *field,
53569322
MD
116 struct lttng_ust_lib_ring_buffer_ctx *ctx,
117 struct lttng_channel *chan);
daacdbfc
MD
118 void (*get_value)(struct lttng_ust_ctx_field *field,
119 struct lttng_ust_ctx_value *value);
53569322 120 struct cds_hlist_node node;
daacdbfc
MD
121
122 /* End of base ABI. Fields below should be used after checking struct_size. */
53569322
MD
123};
124
125int lttng_ust_context_provider_register(struct lttng_ust_context_provider *provider);
126void lttng_ust_context_provider_unregister(struct lttng_ust_context_provider *provider);
127
53569322 128void lttng_ust_context_set_session_provider(const char *name,
daacdbfc
MD
129 size_t (*get_size)(struct lttng_ust_ctx_field *field, size_t offset),
130 void (*record)(struct lttng_ust_ctx_field *field,
53569322
MD
131 struct lttng_ust_lib_ring_buffer_ctx *ctx,
132 struct lttng_channel *chan),
daacdbfc
MD
133 void (*get_value)(struct lttng_ust_ctx_field *field,
134 struct lttng_ust_ctx_value *value));
53569322 135
daacdbfc
MD
136int lttng_ust_add_app_context_to_ctx_rcu(const char *name, struct lttng_ust_ctx **ctx);
137int lttng_ust_context_set_provider_rcu(struct lttng_ust_ctx **_ctx,
53569322 138 const char *name,
daacdbfc
MD
139 size_t (*get_size)(struct lttng_ust_ctx_field *field, size_t offset),
140 void (*record)(struct lttng_ust_ctx_field *field,
53569322
MD
141 struct lttng_ust_lib_ring_buffer_ctx *ctx,
142 struct lttng_channel *chan),
daacdbfc
MD
143 void (*get_value)(struct lttng_ust_ctx_field *field,
144 struct lttng_ust_ctx_value *value));
53569322
MD
145
146#endif /* _LTTNG_UST_CONTEXT_PROVIDER_H */
This page took 0.032434 seconds and 4 git commands to generate.