Move enabler structures to internal header
[lttng-modules.git] / include / lttng / events-internal.h
CommitLineData
92bc1e23
MD
1/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
2 *
3 * lttng/events-internal.h
4 *
5 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 */
7
8#ifndef _LTTNG_EVENTS_INTERNAL_H
9#define _LTTNG_EVENTS_INTERNAL_H
10
437d5aa5
MD
11#include <lttng/events.h>
12
a67ba386
MD
13struct lttng_kernel_event_common_private {
14 struct lttng_kernel_event_common *pub; /* Public event interface */
15
16 const struct lttng_kernel_event_desc *desc;
17 /* Backward references: list of lttng_enabler_ref (ref to enablers) */
18 struct list_head enablers_ref_head;
19 int registered; /* has reg'd tracepoint probe */
20 uint64_t user_token;
21
22 int has_enablers_without_filter_bytecode;
8a445457 23 /* list of struct lttng_bytecode_runtime, sorted by seqnum */
a67ba386
MD
24 struct list_head filter_bytecode_runtime_head;
25 enum lttng_kernel_abi_instrumentation instrumentation;
26 /* Selected by instrumentation */
27 union {
28 struct lttng_kprobe kprobe;
29 struct lttng_uprobe uprobe;
30 struct {
31 struct lttng_krp *lttng_krp;
32 char *symbol_name;
33 } kretprobe;
34 struct {
35 enum lttng_syscall_entryexit entryexit;
36 enum lttng_syscall_abi abi;
37 struct hlist_node node; /* chain registered syscall event_notifier */
38 unsigned int syscall_id;
39 } syscall;
40 } u;
41};
42
43struct lttng_kernel_event_recorder_private {
44 struct lttng_kernel_event_common_private parent;
45
46 struct lttng_kernel_event_recorder *pub; /* Public event interface */
47 struct list_head node; /* Event recorder list */
48 struct hlist_node hlist; /* Hash table of event recorders */
49 struct lttng_kernel_ctx *ctx;
50 unsigned int id;
51 unsigned int metadata_dumped:1;
52};
53
54struct lttng_kernel_event_notifier_private {
55 struct lttng_kernel_event_common_private parent;
56
57 struct lttng_kernel_event_notifier *pub; /* Public event notifier interface */
58 struct lttng_event_notifier_group *group; /* weak ref */
59 size_t num_captures; /* Needed to allocate the msgpack array. */
60 uint64_t error_counter_index;
61 struct list_head node; /* Event notifier list */
62 struct hlist_node hlist; /* Hash table of event notifiers */
63 struct list_head capture_bytecode_runtime_head;
64
65};
66
8a445457
MD
67enum lttng_kernel_bytecode_interpreter_ret {
68 LTTNG_KERNEL_BYTECODE_INTERPRETER_ERROR = -1,
69 LTTNG_KERNEL_BYTECODE_INTERPRETER_OK = 0,
70};
71
72enum lttng_kernel_bytecode_filter_result {
73 LTTNG_KERNEL_BYTECODE_FILTER_ACCEPT = 0,
74 LTTNG_KERNEL_BYTECODE_FILTER_REJECT = 1,
75};
76
77struct lttng_kernel_bytecode_filter_ctx {
78 enum lttng_kernel_bytecode_filter_result result;
79};
80
5e08a34f
MD
81/*
82 * Enabler field, within whatever object is enabling an event. Target of
83 * backward reference.
84 */
85struct lttng_enabler {
86 enum lttng_enabler_format_type format_type;
87
88 /* head list of struct lttng_bytecode_node */
89 struct list_head filter_bytecode_head;
90
91 struct lttng_kernel_abi_event event_param;
92 unsigned int enabled:1;
93
94 uint64_t user_token; /* User-provided token. */
95};
96
97struct lttng_event_enabler {
98 struct lttng_enabler base;
99 struct list_head node; /* per-session list of enablers */
100 struct lttng_channel *chan;
101};
102
103struct lttng_event_notifier_enabler {
104 struct lttng_enabler base;
105 uint64_t error_counter_index;
106 struct list_head node; /* List of event_notifier enablers */
107 struct lttng_event_notifier_group *group;
108
109 /* head list of struct lttng_bytecode_node */
110 struct list_head capture_bytecode_head;
111 uint64_t num_captures;
112};
113
437d5aa5
MD
114static inline
115const struct lttng_kernel_type_integer *lttng_kernel_get_type_integer(const struct lttng_kernel_type_common *type)
116{
117 if (type->type != lttng_kernel_type_integer)
118 return NULL;
119 return container_of(type, const struct lttng_kernel_type_integer, parent);
120}
121
122static inline
123const struct lttng_kernel_type_string *lttng_kernel_get_type_string(const struct lttng_kernel_type_common *type)
124{
125 if (type->type != lttng_kernel_type_string)
126 return NULL;
127 return container_of(type, const struct lttng_kernel_type_string, parent);
128}
129
130static inline
131const struct lttng_kernel_type_enum *lttng_kernel_get_type_enum(const struct lttng_kernel_type_common *type)
132{
133 if (type->type != lttng_kernel_type_enum)
134 return NULL;
135 return container_of(type, const struct lttng_kernel_type_enum, parent);
136}
137
138static inline
139const struct lttng_kernel_type_array *lttng_kernel_get_type_array(const struct lttng_kernel_type_common *type)
140{
141 if (type->type != lttng_kernel_type_array)
142 return NULL;
143 return container_of(type, const struct lttng_kernel_type_array, parent);
144}
145
146static inline
147const struct lttng_kernel_type_sequence *lttng_kernel_get_type_sequence(const struct lttng_kernel_type_common *type)
148{
149 if (type->type != lttng_kernel_type_sequence)
150 return NULL;
151 return container_of(type, const struct lttng_kernel_type_sequence, parent);
152}
153
154static inline
155const struct lttng_kernel_type_struct *lttng_kernel_get_type_struct(const struct lttng_kernel_type_common *type)
156{
157 if (type->type != lttng_kernel_type_struct)
158 return NULL;
159 return container_of(type, const struct lttng_kernel_type_struct, parent);
160}
161
162static inline
163const struct lttng_kernel_type_variant *lttng_kernel_get_type_variant(const struct lttng_kernel_type_common *type)
164{
165 if (type->type != lttng_kernel_type_variant)
166 return NULL;
167 return container_of(type, const struct lttng_kernel_type_variant, parent);
168}
169
170static inline bool lttng_kernel_type_is_bytewise_integer(const struct lttng_kernel_type_common *type)
171{
172 const struct lttng_kernel_type_integer *type_integer = lttng_kernel_get_type_integer(type);
173
174 if (!type_integer)
175 return false;
176 switch (type_integer->size) {
177 case 8: /* Fall-through. */
178 case 16: /* Fall-through. */
179 case 32: /* Fall-through. */
180 case 64:
181 break;
182 default:
183 return false;
184 }
185 return true;
186}
187
8a445457
MD
188int lttng_kernel_interpret_event_filter(const struct lttng_kernel_event_common *event,
189 const char *interpreter_stack_data,
190 struct lttng_probe_ctx *probe_ctx,
191 void *event_filter_ctx);
192
5e08a34f
MD
193static inline
194struct lttng_enabler *lttng_event_enabler_as_enabler(
195 struct lttng_event_enabler *event_enabler)
196{
197 return &event_enabler->base;
198}
199
200static inline
201struct lttng_enabler *lttng_event_notifier_enabler_as_enabler(
202 struct lttng_event_notifier_enabler *event_notifier_enabler)
203{
204 return &event_notifier_enabler->base;
205}
206
92bc1e23 207#endif /* _LTTNG_EVENTS_INTERNAL_H */
This page took 0.030157 seconds and 4 git commands to generate.