4 * Linux Trace Toolkit Control Library
6 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 * SPDX-License-Identifier: LGPL-2.1-only
12 #ifndef LTTNG_EVENT_INTERNAL_H
13 #define LTTNG_EVENT_INTERNAL_H
15 #include <common/macros.hpp>
17 #include <lttng/event.h>
18 #include <lttng/lttng-error.h>
20 struct lttng_event_exclusion;
21 struct lttng_userspace_probe_location;
22 struct lttng_dynamic_buffer;
23 struct lttng_buffer_view;
25 struct lttng_event_comm {
34 /* Includes terminator `\0`. */
36 uint32_t exclusion_count;
37 /* Includes terminator `\0`. */
38 uint32_t filter_expression_len;
39 uint32_t bytecode_len;
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;
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.
59 struct lttng_event_exclusion_comm {
60 /* Includes terminator `\0`. */
65 struct lttng_event_probe_attr_comm {
68 /* Includes terminator `\0`. */
69 uint32_t symbol_name_len;
74 struct lttng_event_function_attr_comm {
75 /* Includes terminator `\0`. */
76 uint32_t symbol_name_len;
81 struct lttng_event_context_comm {
84 * Depending on the type.
86 * - LTTNG_EVENT_CONTEXT_APP_CONTEXT.
88 * -> struct lttng_event_context_app_comm
91 * - LTTNG_EVENT_CONTEXT_PERF_COUNTER,
92 * - LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER,
93 * - LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER.
95 * -> struct lttng_event_context_perf_counter_comm
97 * Other type -> no payload.
102 struct lttng_event_context_perf_counter_comm {
105 /* Includes terminator `\0`. */
108 * char name [name_len]
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;
119 * provider name [provider_name_len]
120 * ctx name [ctx_name_len]
125 struct lttng_event_field_comm {
128 /* Includes terminator `\0`. */
134 * - lttng_event object
139 struct lttng_event_extended {
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.
146 char *filter_expression;
149 /* Array of strings of fixed LTTNG_SYMBOL_NAME_LEN length. */
152 struct lttng_userspace_probe_location *probe_location;
155 struct lttng_event *lttng_event_copy(const struct lttng_event *event);
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);
163 int lttng_event_serialize(const struct lttng_event *event,
164 unsigned int exclusion_count,
165 char **exclusion_list,
166 char *filter_expression,
168 struct lttng_bytecode *bytecode,
169 struct lttng_payload *payload);
171 ssize_t lttng_event_context_create_from_payload(struct lttng_payload_view *view,
172 struct lttng_event_context **event_ctx);
174 int lttng_event_context_serialize(struct lttng_event_context *context,
175 struct lttng_payload *payload);
177 void lttng_event_context_destroy(struct lttng_event_context *context);
179 enum lttng_error_code lttng_events_create_and_flatten_from_payload(struct lttng_payload_view *view,
181 struct lttng_event **events);
183 ssize_t lttng_event_field_create_from_payload(struct lttng_payload_view *view,
184 struct lttng_event_field **field);
186 int lttng_event_field_serialize(const struct lttng_event_field *field,
187 struct lttng_payload *payload);
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);
192 #endif /* LTTNG_EVENT_INTERNAL_H */