Commit | Line | Data |
---|---|---|
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 | ||
20 | struct lttng_ctx_value { | |
21 | enum lttng_ust_dynamic_type sel; | |
22 | union { | |
23 | int64_t s64; | |
24 | uint64_t u64; | |
25 | const char *str; | |
26 | double d; | |
27 | } u; | |
28 | }; | |
29 | ||
30 | struct lttng_perf_counter_field; | |
31 | ||
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); | |
41 | union { | |
42 | struct lttng_perf_counter_field *perf_counter; | |
43 | char padding[LTTNG_UST_CTX_FIELD_PADDING]; | |
44 | } u; | |
45 | void (*destroy)(struct lttng_ctx_field *field); | |
46 | char *field_name; /* Has ownership, dynamically allocated. */ | |
47 | }; | |
48 | ||
49 | #define LTTNG_UST_CTX_PADDING 20 | |
50 | struct lttng_ctx { | |
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]; | |
56 | }; | |
57 | ||
53569322 MD |
58 | struct lttng_ust_context_provider { |
59 | char *name; | |
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; | |
67 | }; | |
68 | ||
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); | |
71 | ||
53569322 MD |
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)); | |
79 | ||
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, | |
82 | const char *name, | |
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)); | |
53569322 MD |
89 | |
90 | #endif /* _LTTNG_UST_CONTEXT_PROVIDER_H */ |