Tests: Add test to check shared-memory FD leaks after relayd dies
[lttng-tools.git] / include / lttng / event-internal.hpp
1 /*
2 * event-internal.h
3 *
4 * Linux Trace Toolkit Control Library
5 *
6 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
7 *
8 * SPDX-License-Identifier: LGPL-2.1-only
9 *
10 */
11
12 #ifndef LTTNG_EVENT_INTERNAL_H
13 #define LTTNG_EVENT_INTERNAL_H
14
15 #include <common/macros.hpp>
16
17 #include <lttng/event.h>
18 #include <lttng/lttng-error.h>
19
20 struct lttng_event_exclusion;
21 struct lttng_userspace_probe_location;
22 struct lttng_dynamic_buffer;
23 struct lttng_buffer_view;
24
25 struct lttng_event_comm {
26 int8_t event_type;
27 int8_t loglevel_type;
28 int32_t loglevel;
29 int8_t enabled;
30 int32_t pid;
31 uint32_t flags;
32
33 /* Payload. */
34 /* Includes terminator `\0`. */
35 uint32_t name_len;
36 uint32_t exclusion_count;
37 /* Includes terminator `\0`. */
38 uint32_t filter_expression_len;
39 uint32_t bytecode_len;
40
41 /* Type specific payload. */
42 uint32_t userspace_probe_location_len;
43 uint32_t lttng_event_probe_attr_len;
44 uint32_t lttng_event_function_attr_len;
45
46 /*
47 * Contain:
48 * - name [name_len],
49 * - exclusions if any
50 * - char filter_expression[filter_expression_len],
51 * - unsigned char filter_bytecode[bytecode_len],
52 * - userspace probe location [userspace_probe_location_len],
53 * - probe or ftrace based on event type.
54 */
55
56 char payload[];
57 } LTTNG_PACKED;
58
59 struct lttng_event_exclusion_comm {
60 /* Includes terminator `\0`. */
61 uint32_t len;
62 char payload[];
63 } LTTNG_PACKED;
64
65 struct lttng_event_probe_attr_comm {
66 uint64_t addr;
67 uint64_t offset;
68 /* Includes terminator `\0`. */
69 uint32_t symbol_name_len;
70
71 char payload[];
72 } LTTNG_PACKED;
73
74 struct lttng_event_function_attr_comm {
75 /* Includes terminator `\0`. */
76 uint32_t symbol_name_len;
77
78 char payload[];
79 } LTTNG_PACKED;
80
81 struct lttng_event_context_comm {
82 uint32_t type;
83 /*
84 * Depending on the type.
85 * For:
86 * - LTTNG_EVENT_CONTEXT_APP_CONTEXT.
87 *
88 * -> struct lttng_event_context_app_comm
89 *
90 * For
91 * - LTTNG_EVENT_CONTEXT_PERF_COUNTER,
92 * - LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER,
93 * - LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER.
94 *
95 * -> struct lttng_event_context_perf_counter_comm
96 *
97 * Other type -> no payload.
98 */
99 char payload[];
100 } LTTNG_PACKED;
101
102 struct lttng_event_context_perf_counter_comm {
103 uint32_t type;
104 uint64_t config;
105 /* Includes terminator `\0`. */
106 uint32_t name_len;
107 /*
108 * char name [name_len]
109 */
110 char payload[];
111 } LTTNG_PACKED;
112
113 struct lttng_event_context_app_comm {
114 /* Includes terminator `\0`. */
115 uint32_t provider_name_len;
116 /* Includes terminator `\0`. */
117 uint32_t ctx_name_len;
118 /*
119 * provider name [provider_name_len]
120 * ctx name [ctx_name_len]
121 */
122 char payload[];
123 } LTTNG_PACKED;
124
125 struct lttng_event_field_comm {
126 uint8_t type;
127 uint8_t nowrite;
128 /* Includes terminator `\0`. */
129 uint32_t name_len;
130 uint32_t event_len;
131
132 /*
133 * - name [name_len]
134 * - lttng_event object
135 */
136 char payload[];
137 } LTTNG_PACKED;
138
139 struct lttng_event_extended {
140 /*
141 * exclusions and filter_expression are only set when the lttng_event
142 * was created/allocated by a list operation. These two elements must
143 * not be free'd as they are part of the same contiguous buffer that
144 * contains all events returned by the listing.
145 */
146 char *filter_expression;
147 struct {
148 unsigned int count;
149 /* Array of strings of fixed LTTNG_SYMBOL_NAME_LEN length. */
150 char *strings;
151 } exclusions;
152 struct lttng_userspace_probe_location *probe_location;
153 };
154
155 struct lttng_event *lttng_event_copy(const struct lttng_event *event);
156
157 ssize_t lttng_event_create_from_payload(struct lttng_payload_view *view,
158 struct lttng_event **out_event,
159 struct lttng_event_exclusion **out_exclusion,
160 char **out_filter_expression,
161 struct lttng_bytecode **out_bytecode);
162
163 int lttng_event_serialize(const struct lttng_event *event,
164 unsigned int exclusion_count,
165 char **exclusion_list,
166 char *filter_expression,
167 size_t bytecode_len,
168 struct lttng_bytecode *bytecode,
169 struct lttng_payload *payload);
170
171 ssize_t lttng_event_context_create_from_payload(struct lttng_payload_view *view,
172 struct lttng_event_context **event_ctx);
173
174 int lttng_event_context_serialize(struct lttng_event_context *context,
175 struct lttng_payload *payload);
176
177 void lttng_event_context_destroy(struct lttng_event_context *context);
178
179 enum lttng_error_code lttng_events_create_and_flatten_from_payload(struct lttng_payload_view *view,
180 unsigned int count,
181 struct lttng_event **events);
182
183 ssize_t lttng_event_field_create_from_payload(struct lttng_payload_view *view,
184 struct lttng_event_field **field);
185
186 int lttng_event_field_serialize(const struct lttng_event_field *field,
187 struct lttng_payload *payload);
188
189 enum lttng_error_code lttng_event_fields_create_and_flatten_from_payload(
190 struct lttng_payload_view *view, unsigned int count, struct lttng_event_field **fields);
191
192 #endif /* LTTNG_EVENT_INTERNAL_H */
This page took 0.032863 seconds and 4 git commands to generate.