2 * SPDX-License-Identifier: MIT
4 * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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.
11 #ifndef _LTTNG_UST_CONTEXT_PROVIDER_H
12 #define _LTTNG_UST_CONTEXT_PROVIDER_H
15 #include <lttng/ust-events.h>
16 #include <urcu/hlist.h>
18 #include "ust-dynamic-type.h"
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
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.
32 struct lttng_ust_ctx_value
{
35 enum lttng_ust_dynamic_type sel
;
43 /* End of base ABI. Fields below should be used after checking struct_size. */
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
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.
58 struct lttng_ust_ctx_field
{
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
,
65 struct lttng_ust_lib_ring_buffer_ctx
*ctx
,
66 struct lttng_channel
*chan
);
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
);
70 char *field_name
; /* Has ownership, dynamically allocated. */
72 /* End of base ABI. Fields below should be used after checking struct_size. */
76 * All context fields for a given event/channel
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
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.
87 struct lttng_ust_ctx
{
90 struct lttng_ust_ctx_field
**fields
;
91 unsigned int nr_fields
;
92 unsigned int allocated_fields
;
93 unsigned int largest_align
;
95 /* End of base ABI. Fields below should be used after checking struct_size. */
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
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.
110 struct lttng_ust_context_provider
{
111 uint32_t struct_size
;
114 size_t (*get_size
)(struct lttng_ust_ctx_field
*field
, size_t offset
);
115 void (*record
)(struct lttng_ust_ctx_field
*field
,
116 struct lttng_ust_lib_ring_buffer_ctx
*ctx
,
117 struct lttng_channel
*chan
);
118 void (*get_value
)(struct lttng_ust_ctx_field
*field
,
119 struct lttng_ust_ctx_value
*value
);
120 struct cds_hlist_node node
;
122 /* End of base ABI. Fields below should be used after checking struct_size. */
125 int lttng_ust_context_provider_register(struct lttng_ust_context_provider
*provider
);
126 void lttng_ust_context_provider_unregister(struct lttng_ust_context_provider
*provider
);
128 void lttng_ust_context_set_session_provider(const char *name
,
129 size_t (*get_size
)(struct lttng_ust_ctx_field
*field
, size_t offset
),
130 void (*record
)(struct lttng_ust_ctx_field
*field
,
131 struct lttng_ust_lib_ring_buffer_ctx
*ctx
,
132 struct lttng_channel
*chan
),
133 void (*get_value
)(struct lttng_ust_ctx_field
*field
,
134 struct lttng_ust_ctx_value
*value
));
136 int lttng_ust_add_app_context_to_ctx_rcu(const char *name
, struct lttng_ust_ctx
**ctx
);
137 int lttng_ust_context_set_provider_rcu(struct lttng_ust_ctx
**_ctx
,
139 size_t (*get_size
)(struct lttng_ust_ctx_field
*field
, size_t offset
),
140 void (*record
)(struct lttng_ust_ctx_field
*field
,
141 struct lttng_ust_lib_ring_buffer_ctx
*ctx
,
142 struct lttng_channel
*chan
),
143 void (*get_value
)(struct lttng_ust_ctx_field
*field
,
144 struct lttng_ust_ctx_value
*value
));
146 #endif /* _LTTNG_UST_CONTEXT_PROVIDER_H */