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"
20 struct lttng_ctx_value
{
21 enum lttng_ust_dynamic_type sel
;
30 struct lttng_perf_counter_field
;
32 #define LTTNG_UST_CTX_FIELD_PADDING 40
33 struct lttng_ctx_field
{
34 struct lttng_ust_event_field event_field
;
35 size_t (*get_size
)(struct lttng_ctx_field
*field
, size_t offset
);
36 void (*record
)(struct lttng_ctx_field
*field
,
37 struct lttng_ust_lib_ring_buffer_ctx
*ctx
,
38 struct lttng_channel
*chan
);
39 void (*get_value
)(struct lttng_ctx_field
*field
,
40 struct lttng_ctx_value
*value
);
42 struct lttng_perf_counter_field
*perf_counter
;
43 char padding
[LTTNG_UST_CTX_FIELD_PADDING
];
45 void (*destroy
)(struct lttng_ctx_field
*field
);
46 char *field_name
; /* Has ownership, dynamically allocated. */
49 #define LTTNG_UST_CTX_PADDING 20
51 struct lttng_ctx_field
*fields
;
52 unsigned int nr_fields
;
53 unsigned int allocated_fields
;
54 unsigned int largest_align
;
55 char padding
[LTTNG_UST_CTX_PADDING
];
58 struct lttng_ust_context_provider
{
60 size_t (*get_size
)(struct lttng_ctx_field
*field
, size_t offset
);
61 void (*record
)(struct lttng_ctx_field
*field
,
62 struct lttng_ust_lib_ring_buffer_ctx
*ctx
,
63 struct lttng_channel
*chan
);
64 void (*get_value
)(struct lttng_ctx_field
*field
,
65 struct lttng_ctx_value
*value
);
66 struct cds_hlist_node node
;
69 int lttng_ust_context_provider_register(struct lttng_ust_context_provider
*provider
);
70 void lttng_ust_context_provider_unregister(struct lttng_ust_context_provider
*provider
);
72 void lttng_ust_context_set_session_provider(const char *name
,
73 size_t (*get_size
)(struct lttng_ctx_field
*field
, size_t offset
),
74 void (*record
)(struct lttng_ctx_field
*field
,
75 struct lttng_ust_lib_ring_buffer_ctx
*ctx
,
76 struct lttng_channel
*chan
),
77 void (*get_value
)(struct lttng_ctx_field
*field
,
78 struct lttng_ctx_value
*value
));
80 int lttng_ust_add_app_context_to_ctx_rcu(const char *name
, struct lttng_ctx
**ctx
);
81 int lttng_ust_context_set_provider_rcu(struct lttng_ctx
**_ctx
,
83 size_t (*get_size
)(struct lttng_ctx_field
*field
, size_t offset
),
84 void (*record
)(struct lttng_ctx_field
*field
,
85 struct lttng_ust_lib_ring_buffer_ctx
*ctx
,
86 struct lttng_channel
*chan
),
87 void (*get_value
)(struct lttng_ctx_field
*field
,
88 struct lttng_ctx_value
*value
));
90 #endif /* _LTTNG_UST_CONTEXT_PROVIDER_H */