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