Commit | Line | Data |
---|---|---|
2d1318e4 JG |
1 | /* |
2 | * event-internal.h | |
3 | * | |
4 | * Linux Trace Toolkit Control Library | |
5 | * | |
ab5be9fa | 6 | * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
2d1318e4 | 7 | * |
ab5be9fa | 8 | * SPDX-License-Identifier: LGPL-2.1-only |
2d1318e4 | 9 | * |
2d1318e4 JG |
10 | */ |
11 | ||
12 | #ifndef LTTNG_EVENT_INTERNAL_H | |
13 | #define LTTNG_EVENT_INTERNAL_H | |
14 | ||
c9e313bc | 15 | #include <common/macros.hpp> |
28f23191 | 16 | |
76fcf151 | 17 | #include <lttng/event.h> |
8ddd72ef | 18 | #include <lttng/lttng-error.h> |
76fcf151 | 19 | |
8ddd72ef | 20 | struct lttng_event_exclusion; |
2d1318e4 | 21 | struct lttng_userspace_probe_location; |
8ddd72ef JR |
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; | |
28f23191 | 62 | char payload[]; |
8ddd72ef JR |
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; | |
2d1318e4 | 80 | |
26e1c61f JR |
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 | ||
b2d68839 JR |
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 | ||
2d1318e4 JG |
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 | ||
76fcf151 JG |
155 | struct lttng_event *lttng_event_copy(const struct lttng_event *event); |
156 | ||
8ddd72ef | 157 | ssize_t lttng_event_create_from_payload(struct lttng_payload_view *view, |
28f23191 JG |
158 | struct lttng_event **out_event, |
159 | struct lttng_event_exclusion **out_exclusion, | |
160 | char **out_filter_expression, | |
161 | struct lttng_bytecode **out_bytecode); | |
8ddd72ef JR |
162 | |
163 | int lttng_event_serialize(const struct lttng_event *event, | |
28f23191 | 164 | unsigned int exclusion_count, |
1e0019bb | 165 | const char *const *exclusion_list, |
dd7ef124 | 166 | const char *filter_expression, |
28f23191 JG |
167 | size_t bytecode_len, |
168 | struct lttng_bytecode *bytecode, | |
169 | struct lttng_payload *payload); | |
8ddd72ef | 170 | |
28f23191 JG |
171 | ssize_t lttng_event_context_create_from_payload(struct lttng_payload_view *view, |
172 | struct lttng_event_context **event_ctx); | |
26e1c61f JR |
173 | |
174 | int lttng_event_context_serialize(struct lttng_event_context *context, | |
28f23191 | 175 | struct lttng_payload *payload); |
26e1c61f JR |
176 | |
177 | void lttng_event_context_destroy(struct lttng_event_context *context); | |
178 | ||
28f23191 JG |
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); | |
8ddd72ef | 182 | |
28f23191 JG |
183 | ssize_t lttng_event_field_create_from_payload(struct lttng_payload_view *view, |
184 | struct lttng_event_field **field); | |
b2d68839 JR |
185 | |
186 | int lttng_event_field_serialize(const struct lttng_event_field *field, | |
28f23191 | 187 | struct lttng_payload *payload); |
b2d68839 JR |
188 | |
189 | enum lttng_error_code lttng_event_fields_create_and_flatten_from_payload( | |
28f23191 | 190 | struct lttng_payload_view *view, unsigned int count, struct lttng_event_field **fields); |
b2d68839 | 191 | |
2d1318e4 | 192 | #endif /* LTTNG_EVENT_INTERNAL_H */ |