Commit | Line | Data |
---|---|---|
57ffc2f1 PP |
1 | /* |
2 | * Copyright 2018 Philippe Proulx <pproulx@efficios.com> | |
3 | * | |
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
5 | * of this software and associated documentation files (the "Software"), to deal | |
6 | * in the Software without restriction, including without limitation the rights | |
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
8 | * copies of the Software, and to permit persons to whom the Software is | |
9 | * furnished to do so, subject to the following conditions: | |
10 | * | |
11 | * The above copyright notice and this permission notice shall be included in | |
12 | * all copies or substantial portions of the Software. | |
13 | * | |
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
20 | * SOFTWARE. | |
21 | */ | |
22 | ||
b03487ab PP |
23 | /* |
24 | * This is just to satisfy the preprocessor check in "lib/logging.h": | |
25 | * this file does not log anything. | |
26 | */ | |
27 | #define BT_LOG_TAG "" | |
8deee039 | 28 | |
57ffc2f1 PP |
29 | #include <stdarg.h> |
30 | #include <stdio.h> | |
31 | #include <stdlib.h> | |
32 | #include <string.h> | |
33 | #include <inttypes.h> | |
34 | #include <stdint.h> | |
57ffc2f1 PP |
35 | #include <wchar.h> |
36 | #include <glib.h> | |
57952005 | 37 | #include "common/common.h" |
71c5da58 | 38 | #include <babeltrace2/trace-ir/event-const.h> |
71c5da58 | 39 | #include <babeltrace2/trace-ir/packet-const.h> |
71c5da58 | 40 | #include <babeltrace2/trace-ir/stream-const.h> |
57952005 | 41 | |
0341b021 PP |
42 | #include "logging.h" |
43 | #include "assert-pre.h" | |
44 | #include "assert-post.h" | |
45 | #include "value.h" | |
46 | #include "object-pool.h" | |
57952005 MJ |
47 | #include "graph/component-class.h" |
48 | #include "graph/component-class-sink-colander.h" | |
49 | #include "graph/component-filter.h" | |
50 | #include "graph/component.h" | |
51 | #include "graph/component-sink.h" | |
52 | #include "graph/component-source.h" | |
53 | #include "graph/connection.h" | |
54 | #include "graph/graph.h" | |
55 | #include "graph/message/discarded-items.h" | |
56 | #include "graph/message/event.h" | |
57 | #include "graph/message/iterator.h" | |
58 | #include "graph/message/message.h" | |
59 | #include "graph/message/message-iterator-inactivity.h" | |
60 | #include "graph/message/packet.h" | |
61 | #include "graph/message/stream-activity.h" | |
62 | #include "graph/message/stream.h" | |
63 | #include "graph/port.h" | |
57952005 MJ |
64 | #include "plugin/plugin.h" |
65 | #include "plugin/plugin-so.h" | |
66 | #include "trace-ir/clock-class.h" | |
67 | #include "trace-ir/clock-snapshot.h" | |
68 | #include "trace-ir/event-class.h" | |
69 | #include "trace-ir/event.h" | |
70 | #include "trace-ir/field-class.h" | |
71 | #include "trace-ir/field.h" | |
72 | #include "trace-ir/field-path.h" | |
73 | #include "trace-ir/packet.h" | |
74 | #include "trace-ir/stream-class.h" | |
75 | #include "trace-ir/stream.h" | |
76 | #include "trace-ir/trace-class.h" | |
77 | #include "trace-ir/trace.h" | |
78 | #include "trace-ir/utils.h" | |
c0e90f23 PP |
79 | #include "error.h" |
80 | #include "assert-pre.h" | |
57ffc2f1 PP |
81 | |
82 | #define LIB_LOGGING_BUF_SIZE (4096 * 4) | |
83 | ||
91f92a2f | 84 | static __thread char lib_logging_buf[LIB_LOGGING_BUF_SIZE]; |
57ffc2f1 PP |
85 | |
86 | #define BUF_APPEND(_fmt, ...) \ | |
87 | do { \ | |
88 | int _count; \ | |
89 | size_t _size = LIB_LOGGING_BUF_SIZE - \ | |
90 | (size_t) (*buf_ch - lib_logging_buf); \ | |
91 | _count = snprintf(*buf_ch, _size, (_fmt), __VA_ARGS__); \ | |
8b45963b | 92 | BT_ASSERT(_count >= 0); \ |
57ffc2f1 PP |
93 | *buf_ch += MIN(_count, _size); \ |
94 | if (*buf_ch >= lib_logging_buf + LIB_LOGGING_BUF_SIZE - 1) { \ | |
95 | return; \ | |
96 | } \ | |
97 | } while (0) | |
98 | ||
99 | #define BUF_APPEND_UUID(_uuid) \ | |
7b33a0e0 PP |
100 | do { \ |
101 | BUF_APPEND(", %suuid=", prefix); \ | |
102 | format_uuid(buf_ch, (_uuid)); \ | |
103 | } while (0) | |
57ffc2f1 PP |
104 | |
105 | #define PRFIELD(_expr) prefix, (_expr) | |
106 | ||
834e9996 PP |
107 | #define PRFIELD_GSTRING(_expr) PRFIELD((_expr) ? (_expr)->str : NULL) |
108 | ||
ed47d568 | 109 | #define TMP_PREFIX_LEN 64 |
57ffc2f1 PP |
110 | #define SET_TMP_PREFIX(_prefix2) \ |
111 | do { \ | |
cd6d1a17 FD |
112 | snprintf(tmp_prefix, TMP_PREFIX_LEN - 1, "%s%s", \ |
113 | prefix, (_prefix2)); \ | |
114 | tmp_prefix[TMP_PREFIX_LEN - 1] = '\0'; \ | |
57ffc2f1 PP |
115 | } while (0) |
116 | ||
117 | static inline void format_component(char **buf_ch, bool extended, | |
10b7a2e4 | 118 | const char *prefix, const struct bt_component *component); |
57ffc2f1 PP |
119 | |
120 | static inline void format_port(char **buf_ch, bool extended, | |
10b7a2e4 | 121 | const char *prefix, const struct bt_port *port); |
57ffc2f1 PP |
122 | |
123 | static inline void format_connection(char **buf_ch, bool extended, | |
10b7a2e4 | 124 | const char *prefix, const struct bt_connection *connection); |
57ffc2f1 | 125 | |
ecbb78c0 PP |
126 | static inline void format_clock_snapshot(char **buf_ch, bool extended, |
127 | const char *prefix, const struct bt_clock_snapshot *clock_snapshot); | |
8fc063a2 | 128 | |
7b33a0e0 | 129 | static inline void format_field_path(char **buf_ch, bool extended, |
10b7a2e4 | 130 | const char *prefix, const struct bt_field_path *field_path); |
7b33a0e0 | 131 | |
1d7bf349 | 132 | static inline void format_object(char **buf_ch, bool extended, |
10b7a2e4 | 133 | const char *prefix, const struct bt_object *obj) |
57ffc2f1 | 134 | { |
1d7bf349 | 135 | BUF_APPEND(", %sref-count=%llu", prefix, obj->ref_count); |
57ffc2f1 PP |
136 | } |
137 | ||
7b33a0e0 | 138 | static inline void format_uuid(char **buf_ch, bt_uuid uuid) |
8fc063a2 | 139 | { |
7b33a0e0 PP |
140 | BUF_APPEND("\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"", |
141 | (unsigned int) uuid[0], | |
142 | (unsigned int) uuid[1], | |
143 | (unsigned int) uuid[2], | |
144 | (unsigned int) uuid[3], | |
145 | (unsigned int) uuid[4], | |
146 | (unsigned int) uuid[5], | |
147 | (unsigned int) uuid[6], | |
148 | (unsigned int) uuid[7], | |
149 | (unsigned int) uuid[8], | |
150 | (unsigned int) uuid[9], | |
151 | (unsigned int) uuid[10], | |
152 | (unsigned int) uuid[11], | |
153 | (unsigned int) uuid[12], | |
154 | (unsigned int) uuid[13], | |
155 | (unsigned int) uuid[14], | |
156 | (unsigned int) uuid[15]); | |
8fc063a2 PP |
157 | } |
158 | ||
a6918753 | 159 | static inline void format_object_pool(char **buf_ch, bool extended, |
10b7a2e4 | 160 | const char *prefix, const struct bt_object_pool *pool) |
a6918753 PP |
161 | { |
162 | BUF_APPEND(", %ssize=%zu", PRFIELD(pool->size)); | |
163 | ||
164 | if (pool->objects) { | |
165 | BUF_APPEND(", %scap=%u", PRFIELD(pool->objects->len)); | |
166 | } | |
167 | } | |
168 | ||
939190b3 | 169 | static inline void format_integer_field_class(char **buf_ch, |
7b33a0e0 | 170 | bool extended, const char *prefix, |
10b7a2e4 | 171 | const struct bt_field_class *field_class) |
7b33a0e0 | 172 | { |
10b7a2e4 PP |
173 | const struct bt_field_class_integer *int_fc = |
174 | (const void *) field_class; | |
7b33a0e0 PP |
175 | |
176 | BUF_APPEND(", %srange-size=%" PRIu64 ", %sbase=%s", | |
939190b3 PP |
177 | PRFIELD(int_fc->range), |
178 | PRFIELD(bt_common_field_class_integer_preferred_display_base_string(int_fc->base))); | |
7b33a0e0 PP |
179 | } |
180 | ||
939190b3 | 181 | static inline void format_array_field_class(char **buf_ch, |
7b33a0e0 | 182 | bool extended, const char *prefix, |
10b7a2e4 | 183 | const struct bt_field_class *field_class) |
7b33a0e0 | 184 | { |
10b7a2e4 PP |
185 | const struct bt_field_class_array *array_fc = |
186 | (const void *) field_class; | |
7b33a0e0 | 187 | |
af0c18e3 | 188 | BUF_APPEND(", %selement-fc-addr=%p, %selement-fc-type=%s", |
939190b3 | 189 | PRFIELD(array_fc->element_fc), |
af0c18e3 | 190 | PRFIELD(bt_common_field_class_type_string(array_fc->element_fc->type))); |
7b33a0e0 PP |
191 | } |
192 | ||
939190b3 | 193 | static inline void format_field_class(char **buf_ch, bool extended, |
10b7a2e4 | 194 | const char *prefix, const struct bt_field_class *field_class) |
57ffc2f1 | 195 | { |
ed47d568 | 196 | char tmp_prefix[TMP_PREFIX_LEN]; |
7b33a0e0 | 197 | |
af0c18e3 PP |
198 | BUF_APPEND(", %stype=%s", |
199 | PRFIELD(bt_common_field_class_type_string(field_class->type))); | |
57ffc2f1 PP |
200 | |
201 | if (extended) { | |
939190b3 | 202 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(field_class->frozen)); |
10b7a2e4 PP |
203 | BUF_APPEND(", %sis-part-of-trace-class=%d", |
204 | PRFIELD(field_class->part_of_trace_class)); | |
57ffc2f1 PP |
205 | } else { |
206 | return; | |
207 | } | |
208 | ||
af0c18e3 PP |
209 | switch (field_class->type) { |
210 | case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER: | |
211 | case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER: | |
57ffc2f1 | 212 | { |
939190b3 | 213 | format_integer_field_class(buf_ch, extended, prefix, field_class); |
57ffc2f1 PP |
214 | break; |
215 | } | |
af0c18e3 | 216 | case BT_FIELD_CLASS_TYPE_REAL: |
57ffc2f1 | 217 | { |
10b7a2e4 | 218 | const struct bt_field_class_real *real_fc = (void *) field_class; |
57ffc2f1 | 219 | |
7b33a0e0 | 220 | BUF_APPEND(", %sis-single-precision=%d", |
939190b3 | 221 | PRFIELD(real_fc->is_single_precision)); |
57ffc2f1 PP |
222 | break; |
223 | } | |
af0c18e3 PP |
224 | case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION: |
225 | case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION: | |
57ffc2f1 | 226 | { |
10b7a2e4 PP |
227 | const struct bt_field_class_enumeration *enum_fc = |
228 | (const void *) field_class; | |
57ffc2f1 | 229 | |
939190b3 | 230 | format_integer_field_class(buf_ch, extended, prefix, field_class); |
57ffc2f1 | 231 | BUF_APPEND(", %smapping-count=%u", |
939190b3 | 232 | PRFIELD(enum_fc->mappings->len)); |
57ffc2f1 PP |
233 | break; |
234 | } | |
af0c18e3 | 235 | case BT_FIELD_CLASS_TYPE_STRUCTURE: |
57ffc2f1 | 236 | { |
10b7a2e4 PP |
237 | const struct bt_field_class_structure *struct_fc = |
238 | (const void *) field_class; | |
7b33a0e0 | 239 | |
939190b3 | 240 | if (struct_fc->common.named_fcs) { |
7b33a0e0 | 241 | BUF_APPEND(", %smember-count=%u", |
939190b3 | 242 | PRFIELD(struct_fc->common.named_fcs->len)); |
7b33a0e0 | 243 | } |
57ffc2f1 | 244 | |
57ffc2f1 PP |
245 | break; |
246 | } | |
af0c18e3 | 247 | case BT_FIELD_CLASS_TYPE_STATIC_ARRAY: |
57ffc2f1 | 248 | { |
10b7a2e4 PP |
249 | const struct bt_field_class_static_array *array_fc = |
250 | (const void *) field_class; | |
57ffc2f1 | 251 | |
939190b3 PP |
252 | format_array_field_class(buf_ch, extended, prefix, field_class); |
253 | BUF_APPEND(", %slength=%" PRIu64, PRFIELD(array_fc->length)); | |
57ffc2f1 PP |
254 | break; |
255 | } | |
af0c18e3 | 256 | case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY: |
57ffc2f1 | 257 | { |
10b7a2e4 PP |
258 | const struct bt_field_class_dynamic_array *array_fc = |
259 | (const void *) field_class; | |
7b33a0e0 | 260 | |
939190b3 | 261 | format_array_field_class(buf_ch, extended, prefix, field_class); |
7b33a0e0 | 262 | |
939190b3 PP |
263 | if (array_fc->length_fc) { |
264 | SET_TMP_PREFIX("length-fc-"); | |
265 | format_field_class(buf_ch, extended, tmp_prefix, | |
266 | array_fc->length_fc); | |
7b33a0e0 PP |
267 | } |
268 | ||
939190b3 | 269 | if (array_fc->length_field_path) { |
7b33a0e0 PP |
270 | SET_TMP_PREFIX("length-field-path-"); |
271 | format_field_path(buf_ch, extended, tmp_prefix, | |
939190b3 | 272 | array_fc->length_field_path); |
7b33a0e0 | 273 | } |
57ffc2f1 | 274 | |
57ffc2f1 PP |
275 | break; |
276 | } | |
af0c18e3 | 277 | case BT_FIELD_CLASS_TYPE_VARIANT: |
57ffc2f1 | 278 | { |
10b7a2e4 PP |
279 | const struct bt_field_class_variant *var_fc = |
280 | (const void *) field_class; | |
7b33a0e0 | 281 | |
939190b3 | 282 | if (var_fc->common.named_fcs) { |
7b33a0e0 | 283 | BUF_APPEND(", %soption-count=%u", |
939190b3 | 284 | PRFIELD(var_fc->common.named_fcs->len)); |
7b33a0e0 PP |
285 | } |
286 | ||
939190b3 PP |
287 | if (var_fc->selector_fc) { |
288 | SET_TMP_PREFIX("selector-fc-"); | |
289 | format_field_class(buf_ch, extended, tmp_prefix, | |
290 | var_fc->selector_fc); | |
7b33a0e0 PP |
291 | } |
292 | ||
939190b3 | 293 | if (var_fc->selector_field_path) { |
7b33a0e0 PP |
294 | SET_TMP_PREFIX("selector-field-path-"); |
295 | format_field_path(buf_ch, extended, tmp_prefix, | |
939190b3 | 296 | var_fc->selector_field_path); |
7b33a0e0 | 297 | } |
57ffc2f1 | 298 | |
57ffc2f1 PP |
299 | break; |
300 | } | |
301 | default: | |
302 | break; | |
303 | } | |
304 | } | |
305 | ||
18acc6f8 | 306 | static inline void format_field_integer_extended(char **buf_ch, |
10b7a2e4 | 307 | const char *prefix, const struct bt_field *field) |
57ffc2f1 | 308 | { |
10b7a2e4 PP |
309 | const struct bt_field_integer *integer = (void *) field; |
310 | const struct bt_field_class_integer *field_class = | |
311 | (void *) field->class; | |
57ffc2f1 PP |
312 | const char *fmt = NULL; |
313 | ||
939190b3 | 314 | BT_ASSERT(field_class); |
a6918753 | 315 | |
939190b3 | 316 | if (field_class->base == BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL) { |
57ffc2f1 | 317 | fmt = ", %svalue=%" PRIo64; |
939190b3 | 318 | } else if (field_class->base == BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL) { |
57ffc2f1 PP |
319 | fmt = ", %svalue=%" PRIx64; |
320 | } | |
321 | ||
af0c18e3 PP |
322 | if (field_class->common.type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || |
323 | field_class->common.type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) { | |
57ffc2f1 PP |
324 | if (!fmt) { |
325 | fmt = ", %svalue=%" PRId64; | |
326 | } | |
327 | ||
7b33a0e0 | 328 | BUF_APPEND(fmt, PRFIELD(integer->value.i)); |
57ffc2f1 PP |
329 | } else { |
330 | if (!fmt) { | |
331 | fmt = ", %svalue=%" PRIu64; | |
332 | } | |
333 | ||
7b33a0e0 | 334 | BUF_APPEND(fmt, PRFIELD(integer->value.u)); |
57ffc2f1 PP |
335 | } |
336 | } | |
337 | ||
18acc6f8 | 338 | static inline void format_field(char **buf_ch, bool extended, |
10b7a2e4 | 339 | const char *prefix, const struct bt_field *field) |
57ffc2f1 | 340 | { |
7b33a0e0 | 341 | BUF_APPEND(", %sis-set=%d", PRFIELD(field->is_set)); |
57ffc2f1 PP |
342 | |
343 | if (extended) { | |
344 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(field->frozen)); | |
345 | } | |
346 | ||
af0c18e3 | 347 | BUF_APPEND(", %sclass-addr=%p", PRFIELD(field->class)); |
a6918753 | 348 | |
939190b3 | 349 | if (!field->class) { |
a6918753 PP |
350 | return; |
351 | } | |
352 | ||
af0c18e3 PP |
353 | BUF_APPEND(", %sclass-type=%s", |
354 | PRFIELD(bt_common_field_class_type_string(field->class->type))); | |
57ffc2f1 | 355 | |
7b33a0e0 | 356 | if (!extended || !field->is_set) { |
57ffc2f1 PP |
357 | return; |
358 | } | |
359 | ||
af0c18e3 PP |
360 | switch (field->class->type) { |
361 | case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER: | |
362 | case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER: | |
363 | case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION: | |
364 | case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION: | |
57ffc2f1 | 365 | { |
18acc6f8 | 366 | format_field_integer_extended(buf_ch, prefix, field); |
57ffc2f1 PP |
367 | break; |
368 | } | |
af0c18e3 | 369 | case BT_FIELD_CLASS_TYPE_REAL: |
57ffc2f1 | 370 | { |
10b7a2e4 | 371 | const struct bt_field_real *real_field = (const void *) field; |
57ffc2f1 | 372 | |
7b33a0e0 | 373 | BUF_APPEND(", %svalue=%f", PRFIELD(real_field->value)); |
57ffc2f1 PP |
374 | break; |
375 | } | |
af0c18e3 | 376 | case BT_FIELD_CLASS_TYPE_STRING: |
57ffc2f1 | 377 | { |
10b7a2e4 | 378 | const struct bt_field_string *str = (const void *) field; |
57ffc2f1 | 379 | |
e42dd763 PP |
380 | if (str->buf) { |
381 | BT_ASSERT(str->buf->data); | |
a6918753 | 382 | BUF_APPEND(", %spartial-value=\"%.32s\"", |
e42dd763 | 383 | PRFIELD(str->buf->data)); |
a6918753 | 384 | } |
7b33a0e0 | 385 | |
57ffc2f1 PP |
386 | break; |
387 | } | |
af0c18e3 PP |
388 | case BT_FIELD_CLASS_TYPE_STATIC_ARRAY: |
389 | case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY: | |
57ffc2f1 | 390 | { |
10b7a2e4 | 391 | const struct bt_field_array *array_field = (const void *) field; |
57ffc2f1 | 392 | |
7b33a0e0 | 393 | BUF_APPEND(", %slength=%" PRIu64, PRFIELD(array_field->length)); |
a6918753 | 394 | |
7b33a0e0 | 395 | if (array_field->fields) { |
a6918753 | 396 | BUF_APPEND(", %sallocated-length=%u", |
7b33a0e0 | 397 | PRFIELD(array_field->fields->len)); |
a6918753 | 398 | } |
7b33a0e0 | 399 | |
57ffc2f1 PP |
400 | break; |
401 | } | |
af0c18e3 | 402 | case BT_FIELD_CLASS_TYPE_VARIANT: |
57ffc2f1 | 403 | { |
10b7a2e4 | 404 | const struct bt_field_variant *var_field = (const void *) field; |
a6918753 | 405 | |
7b33a0e0 PP |
406 | BUF_APPEND(", %sselected-field-index=%" PRIu64, |
407 | PRFIELD(var_field->selected_index)); | |
a6918753 PP |
408 | break; |
409 | } | |
410 | default: | |
411 | break; | |
412 | } | |
8deee039 PP |
413 | } |
414 | ||
57ffc2f1 | 415 | static inline void format_field_path(char **buf_ch, bool extended, |
10b7a2e4 | 416 | const char *prefix, const struct bt_field_path *field_path) |
57ffc2f1 PP |
417 | { |
418 | uint64_t i; | |
419 | ||
1d4afa5f PP |
420 | if (field_path->items) { |
421 | BT_ASSERT(field_path->items); | |
422 | BUF_APPEND(", %sitem-count=%u", | |
423 | PRFIELD(field_path->items->len)); | |
a6918753 | 424 | } |
57ffc2f1 | 425 | |
1d4afa5f | 426 | if (!extended || !field_path->items) { |
57ffc2f1 PP |
427 | return; |
428 | } | |
429 | ||
18acc6f8 PP |
430 | BUF_APPEND(", %spath=[%s", |
431 | PRFIELD(bt_common_scope_string(field_path->root))); | |
57ffc2f1 | 432 | |
1d4afa5f PP |
433 | for (i = 0; i < bt_field_path_get_item_count(field_path); i++) { |
434 | const struct bt_field_path_item *fp_item = | |
435 | bt_field_path_borrow_item_by_index_const(field_path, i); | |
436 | ||
437 | switch (bt_field_path_item_get_type(fp_item)) { | |
438 | case BT_FIELD_PATH_ITEM_TYPE_INDEX: | |
439 | BUF_APPEND(", %" PRIu64, | |
440 | bt_field_path_item_index_get_index(fp_item)); | |
441 | break; | |
442 | case BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT: | |
443 | BUF_APPEND("%s", ", <CUR>"); | |
444 | break; | |
445 | default: | |
446 | abort(); | |
447 | } | |
57ffc2f1 PP |
448 | } |
449 | ||
450 | BUF_APPEND("%s", "]"); | |
451 | } | |
452 | ||
10b7a2e4 PP |
453 | static inline void format_trace_class(char **buf_ch, bool extended, |
454 | const char *prefix, const struct bt_trace_class *trace_class) | |
57ffc2f1 | 455 | { |
10b7a2e4 PP |
456 | if (trace_class->name.value) { |
457 | BUF_APPEND(", %sname=\"%s\"", | |
458 | PRFIELD(trace_class->name.value)); | |
57ffc2f1 PP |
459 | } |
460 | ||
461 | if (!extended) { | |
462 | return; | |
463 | } | |
464 | ||
10b7a2e4 | 465 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(trace_class->frozen)); |
57ffc2f1 | 466 | |
10b7a2e4 PP |
467 | if (trace_class->uuid.value) { |
468 | BUF_APPEND_UUID(trace_class->uuid.value); | |
a6918753 PP |
469 | } |
470 | ||
10b7a2e4 | 471 | if (trace_class->stream_classes) { |
a6918753 | 472 | BUF_APPEND(", %sstream-class-count=%u", |
10b7a2e4 | 473 | PRFIELD(trace_class->stream_classes->len)); |
a6918753 PP |
474 | } |
475 | ||
0476f6f7 | 476 | BUF_APPEND(", %sassigns-auto-sc-id=%d", |
10b7a2e4 | 477 | PRFIELD(trace_class->assigns_automatic_stream_class_id)); |
10b7a2e4 PP |
478 | } |
479 | ||
480 | static inline void format_trace(char **buf_ch, bool extended, | |
481 | const char *prefix, const struct bt_trace *trace) | |
482 | { | |
ed47d568 | 483 | char tmp_prefix[TMP_PREFIX_LEN]; |
10b7a2e4 PP |
484 | |
485 | if (trace->name.value) { | |
486 | BUF_APPEND(", %sname=\"%s\"", PRFIELD(trace->name.value)); | |
487 | } | |
488 | ||
489 | if (!extended) { | |
490 | return; | |
491 | } | |
492 | ||
493 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(trace->frozen)); | |
494 | ||
a6918753 PP |
495 | if (trace->streams) { |
496 | BUF_APPEND(", %sstream-count=%u", | |
497 | PRFIELD(trace->streams->len)); | |
498 | } | |
499 | ||
10b7a2e4 PP |
500 | if (!trace->class) { |
501 | return; | |
502 | } | |
503 | ||
504 | BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace->class)); | |
505 | SET_TMP_PREFIX("trace-class-"); | |
506 | format_trace_class(buf_ch, false, tmp_prefix, trace->class); | |
8deee039 PP |
507 | } |
508 | ||
18acc6f8 | 509 | static inline void format_stream_class(char **buf_ch, bool extended, |
10b7a2e4 PP |
510 | const char *prefix, |
511 | const struct bt_stream_class *stream_class) | |
8deee039 | 512 | { |
10b7a2e4 | 513 | const struct bt_trace_class *trace_class; |
ed47d568 | 514 | char tmp_prefix[TMP_PREFIX_LEN]; |
57ffc2f1 | 515 | |
7b33a0e0 | 516 | BUF_APPEND(", %sid=%" PRIu64, PRFIELD(stream_class->id)); |
57ffc2f1 | 517 | |
7b33a0e0 PP |
518 | if (stream_class->name.value) { |
519 | BUF_APPEND(", %sname=\"%s\"", | |
520 | PRFIELD(stream_class->name.value)); | |
57ffc2f1 PP |
521 | } |
522 | ||
523 | if (!extended) { | |
524 | return; | |
525 | } | |
526 | ||
527 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(stream_class->frozen)); | |
a6918753 PP |
528 | |
529 | if (stream_class->event_classes) { | |
530 | BUF_APPEND(", %sevent-class-count=%u", | |
531 | PRFIELD(stream_class->event_classes->len)); | |
532 | } | |
533 | ||
939190b3 | 534 | BUF_APPEND(", %spacket-context-fc-addr=%p, " |
0476f6f7 | 535 | "%sevent-common-context-fc-addr=%p", |
939190b3 | 536 | PRFIELD(stream_class->packet_context_fc), |
939190b3 | 537 | PRFIELD(stream_class->event_common_context_fc)); |
10b7a2e4 PP |
538 | trace_class = bt_stream_class_borrow_trace_class_inline(stream_class); |
539 | if (!trace_class) { | |
57ffc2f1 PP |
540 | return; |
541 | } | |
542 | ||
3f511a69 PP |
543 | BUF_APPEND(", %sassigns-auto-ec-id=%d, %sassigns-auto-stream-id=%d, " |
544 | "%spackets-have-default-beginning-cs=%d, " | |
77037b2b PP |
545 | "%spackets-have-default-end-cs=%d, " |
546 | "%ssupports-discarded-events=%d, " | |
547 | "%sdiscarded-events-have-default-cs=%d, " | |
548 | "%ssupports-discarded-packets=%d, " | |
549 | "%sdiscarded-packets-have-default-cs=%d", | |
7b33a0e0 | 550 | PRFIELD(stream_class->assigns_automatic_event_class_id), |
3f511a69 | 551 | PRFIELD(stream_class->assigns_automatic_stream_id), |
5ef34326 PP |
552 | PRFIELD(stream_class->packets_have_beginning_default_clock_snapshot), |
553 | PRFIELD(stream_class->packets_have_end_default_clock_snapshot), | |
77037b2b PP |
554 | PRFIELD(stream_class->supports_discarded_events), |
555 | PRFIELD(stream_class->discarded_events_have_default_clock_snapshots), | |
556 | PRFIELD(stream_class->supports_discarded_packets), | |
557 | PRFIELD(stream_class->discarded_packets_have_default_clock_snapshots)); | |
10b7a2e4 PP |
558 | BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class)); |
559 | SET_TMP_PREFIX("trace-class-"); | |
560 | format_trace_class(buf_ch, false, tmp_prefix, trace_class); | |
f7c3ac09 | 561 | SET_TMP_PREFIX("pcf-pool-"); |
09f603c6 | 562 | format_object_pool(buf_ch, extended, tmp_prefix, |
f7c3ac09 | 563 | &stream_class->packet_context_field_pool); |
8deee039 PP |
564 | } |
565 | ||
18acc6f8 | 566 | static inline void format_event_class(char **buf_ch, bool extended, |
10b7a2e4 | 567 | const char *prefix, const struct bt_event_class *event_class) |
8deee039 | 568 | { |
10b7a2e4 PP |
569 | const struct bt_stream_class *stream_class; |
570 | const struct bt_trace_class *trace_class; | |
ed47d568 | 571 | char tmp_prefix[TMP_PREFIX_LEN]; |
57ffc2f1 | 572 | |
7b33a0e0 | 573 | BUF_APPEND(", %sid=%" PRIu64, PRFIELD(event_class->id)); |
57ffc2f1 | 574 | |
7b33a0e0 | 575 | if (event_class->name.value) { |
18acc6f8 | 576 | BUF_APPEND(", %sname=\"%s\"", |
7b33a0e0 | 577 | PRFIELD(event_class->name.value)); |
57ffc2f1 PP |
578 | } |
579 | ||
580 | if (!extended) { | |
581 | return; | |
582 | } | |
583 | ||
7b33a0e0 PP |
584 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(event_class->frozen)); |
585 | ||
586 | if (event_class->log_level.base.avail) { | |
587 | BUF_APPEND(", %slog-level=%s", | |
588 | PRFIELD(bt_common_event_class_log_level_string( | |
589 | (int) event_class->log_level.value))); | |
590 | } | |
57ffc2f1 | 591 | |
7b33a0e0 | 592 | if (event_class->emf_uri.value) { |
57ffc2f1 | 593 | BUF_APPEND(", %semf-uri=\"%s\"", |
7b33a0e0 | 594 | PRFIELD(event_class->emf_uri.value)); |
57ffc2f1 PP |
595 | } |
596 | ||
939190b3 PP |
597 | BUF_APPEND(", %sspecific-context-fc-addr=%p, %spayload-fc-addr=%p", |
598 | PRFIELD(event_class->specific_context_fc), | |
599 | PRFIELD(event_class->payload_fc)); | |
57ffc2f1 | 600 | |
10b7a2e4 | 601 | stream_class = bt_event_class_borrow_stream_class_const(event_class); |
57ffc2f1 PP |
602 | if (!stream_class) { |
603 | return; | |
604 | } | |
605 | ||
606 | BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class)); | |
607 | SET_TMP_PREFIX("stream-class-"); | |
18acc6f8 | 608 | format_stream_class(buf_ch, false, tmp_prefix, stream_class); |
10b7a2e4 PP |
609 | trace_class = bt_stream_class_borrow_trace_class_inline(stream_class); |
610 | if (!trace_class) { | |
57ffc2f1 PP |
611 | return; |
612 | } | |
613 | ||
10b7a2e4 PP |
614 | BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class)); |
615 | SET_TMP_PREFIX("trace-class-"); | |
616 | format_trace_class(buf_ch, false, tmp_prefix, trace_class); | |
a6918753 | 617 | SET_TMP_PREFIX("event-pool-"); |
09f603c6 PP |
618 | format_object_pool(buf_ch, extended, tmp_prefix, |
619 | &event_class->event_pool); | |
8deee039 PP |
620 | } |
621 | ||
18acc6f8 | 622 | static inline void format_stream(char **buf_ch, bool extended, |
10b7a2e4 | 623 | const char *prefix, const struct bt_stream *stream) |
8deee039 | 624 | { |
10b7a2e4 PP |
625 | const struct bt_stream_class *stream_class; |
626 | const struct bt_trace_class *trace_class = NULL; | |
627 | const struct bt_trace *trace = NULL; | |
ed47d568 | 628 | char tmp_prefix[TMP_PREFIX_LEN]; |
57ffc2f1 | 629 | |
7b33a0e0 | 630 | BUF_APPEND(", %sid=%" PRIu64, PRFIELD(stream->id)); |
57ffc2f1 | 631 | |
7b33a0e0 PP |
632 | if (stream->name.value) { |
633 | BUF_APPEND(", %sname=\"%s\"", PRFIELD(stream->name.value)); | |
57ffc2f1 PP |
634 | } |
635 | ||
57ffc2f1 PP |
636 | if (!extended) { |
637 | return; | |
638 | } | |
639 | ||
10b7a2e4 PP |
640 | stream_class = bt_stream_borrow_class_const(stream); |
641 | if (stream_class) { | |
642 | BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class)); | |
643 | SET_TMP_PREFIX("stream-class-"); | |
644 | format_stream_class(buf_ch, false, tmp_prefix, stream_class); | |
645 | trace_class = bt_stream_class_borrow_trace_class_inline(stream_class); | |
57ffc2f1 PP |
646 | } |
647 | ||
10b7a2e4 PP |
648 | if (trace_class) { |
649 | BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class)); | |
650 | SET_TMP_PREFIX("trace-class-"); | |
651 | format_trace_class(buf_ch, false, tmp_prefix, trace_class); | |
652 | } | |
653 | ||
654 | trace = bt_stream_borrow_trace_inline(stream); | |
655 | if (trace) { | |
656 | BUF_APPEND(", %strace-addr=%p", PRFIELD(trace)); | |
657 | SET_TMP_PREFIX("trace-"); | |
658 | format_trace(buf_ch, false, tmp_prefix, trace); | |
57ffc2f1 PP |
659 | } |
660 | ||
a6918753 | 661 | SET_TMP_PREFIX("packet-pool-"); |
09f603c6 | 662 | format_object_pool(buf_ch, extended, tmp_prefix, &stream->packet_pool); |
8deee039 PP |
663 | } |
664 | ||
57ffc2f1 | 665 | static inline void format_packet(char **buf_ch, bool extended, |
10b7a2e4 | 666 | const char *prefix, const struct bt_packet *packet) |
57ffc2f1 | 667 | { |
10b7a2e4 PP |
668 | const struct bt_stream *stream; |
669 | const struct bt_trace_class *trace_class; | |
ed47d568 | 670 | char tmp_prefix[TMP_PREFIX_LEN]; |
57ffc2f1 PP |
671 | |
672 | if (!extended) { | |
673 | return; | |
674 | } | |
675 | ||
0476f6f7 | 676 | BUF_APPEND(", %sis-frozen=%d, %scontext-field-addr=%p", |
57ffc2f1 | 677 | PRFIELD(packet->frozen), |
7b33a0e0 | 678 | PRFIELD(packet->context_field ? packet->context_field->field : NULL)); |
10b7a2e4 | 679 | stream = bt_packet_borrow_stream_const(packet); |
57ffc2f1 PP |
680 | if (!stream) { |
681 | return; | |
682 | } | |
683 | ||
684 | BUF_APPEND(", %sstream-addr=%p", PRFIELD(stream)); | |
685 | SET_TMP_PREFIX("stream-"); | |
686 | format_stream(buf_ch, false, tmp_prefix, stream); | |
10b7a2e4 PP |
687 | trace_class = (const struct bt_trace_class *) bt_object_borrow_parent(&stream->base); |
688 | if (!trace_class) { | |
57ffc2f1 PP |
689 | return; |
690 | } | |
691 | ||
10b7a2e4 PP |
692 | BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class)); |
693 | SET_TMP_PREFIX("trace-class-"); | |
694 | format_trace_class(buf_ch, false, tmp_prefix, trace_class); | |
57ffc2f1 PP |
695 | } |
696 | ||
18acc6f8 | 697 | static inline void format_event(char **buf_ch, bool extended, |
10b7a2e4 | 698 | const char *prefix, const struct bt_event *event) |
57ffc2f1 | 699 | { |
10b7a2e4 PP |
700 | const struct bt_packet *packet; |
701 | const struct bt_stream *stream; | |
702 | const struct bt_trace_class *trace_class; | |
703 | const struct bt_stream_class *stream_class; | |
ed47d568 | 704 | char tmp_prefix[TMP_PREFIX_LEN]; |
57ffc2f1 PP |
705 | |
706 | if (!extended) { | |
707 | return; | |
708 | } | |
709 | ||
0476f6f7 | 710 | BUF_APPEND(", %sis-frozen=%d, " |
7b33a0e0 | 711 | "%scommon-context-field-addr=%p, " |
834e9996 | 712 | "%sspecific-context-field-addr=%p, " |
7b33a0e0 | 713 | "%spayload-field-addr=%p, ", |
57ffc2f1 | 714 | PRFIELD(event->frozen), |
7b33a0e0 PP |
715 | PRFIELD(event->common_context_field), |
716 | PRFIELD(event->specific_context_field), | |
8deee039 PP |
717 | PRFIELD(event->payload_field)); |
718 | BUF_APPEND(", %sevent-class-addr=%p", PRFIELD(event->class)); | |
a6918753 PP |
719 | |
720 | if (!event->class) { | |
721 | return; | |
722 | } | |
723 | ||
57ffc2f1 | 724 | SET_TMP_PREFIX("event-class-"); |
18acc6f8 PP |
725 | format_event_class(buf_ch, false, tmp_prefix, event->class); |
726 | stream_class = bt_event_class_borrow_stream_class(event->class); | |
57ffc2f1 PP |
727 | if (stream_class) { |
728 | BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class)); | |
729 | SET_TMP_PREFIX("stream-class-"); | |
18acc6f8 | 730 | format_stream_class(buf_ch, false, tmp_prefix, |
8deee039 | 731 | stream_class); |
57ffc2f1 | 732 | |
10b7a2e4 PP |
733 | trace_class = bt_stream_class_borrow_trace_class_inline( |
734 | stream_class); | |
735 | if (trace_class) { | |
736 | BUF_APPEND(", %strace-class-addr=%p", | |
737 | PRFIELD(trace_class)); | |
738 | SET_TMP_PREFIX("trace-class-"); | |
739 | format_trace_class(buf_ch, false, tmp_prefix, | |
740 | trace_class); | |
57ffc2f1 PP |
741 | } |
742 | } | |
8deee039 | 743 | |
10b7a2e4 | 744 | packet = bt_event_borrow_packet_const(event); |
57ffc2f1 PP |
745 | if (!packet) { |
746 | return; | |
747 | } | |
748 | ||
749 | BUF_APPEND(", %spacket-addr=%p", PRFIELD(packet)); | |
750 | SET_TMP_PREFIX("packet-"); | |
751 | format_packet(buf_ch, false, tmp_prefix, packet); | |
10b7a2e4 | 752 | stream = bt_packet_borrow_stream_const(packet); |
57ffc2f1 PP |
753 | if (!stream) { |
754 | return; | |
755 | } | |
756 | ||
757 | BUF_APPEND(", %sstream-addr=%p", PRFIELD(stream)); | |
758 | SET_TMP_PREFIX("stream-"); | |
759 | format_stream(buf_ch, false, tmp_prefix, stream); | |
760 | } | |
761 | ||
762 | static inline void format_clock_class(char **buf_ch, bool extended, | |
10b7a2e4 | 763 | const char *prefix, const struct bt_clock_class *clock_class) |
57ffc2f1 | 764 | { |
ed47d568 | 765 | char tmp_prefix[TMP_PREFIX_LEN]; |
a6918753 | 766 | |
7b33a0e0 PP |
767 | if (clock_class->name.value) { |
768 | BUF_APPEND(", %sname=\"%s\"", PRFIELD(clock_class->name.value)); | |
769 | } | |
770 | ||
771 | BUF_APPEND(", %sfreq=%" PRIu64, PRFIELD(clock_class->frequency)); | |
57ffc2f1 PP |
772 | |
773 | if (!extended) { | |
774 | return; | |
775 | } | |
776 | ||
7b33a0e0 PP |
777 | if (clock_class->description.value) { |
778 | BUF_APPEND(", %spartial-descr=\"%.32s\"", | |
779 | PRFIELD(clock_class->description.value)); | |
780 | } | |
781 | ||
782 | if (clock_class->uuid.value) { | |
783 | BUF_APPEND_UUID(clock_class->uuid.value); | |
57ffc2f1 PP |
784 | } |
785 | ||
786 | BUF_APPEND(", %sis-frozen=%d, %sprecision=%" PRIu64 ", " | |
787 | "%soffset-s=%" PRId64 ", " | |
d608d675 | 788 | "%soffset-cycles=%" PRIu64 ", %sorigin-is-unix-epoch=%d, " |
7b33a0e0 | 789 | "%sbase-offset-ns=%" PRId64, |
57ffc2f1 | 790 | PRFIELD(clock_class->frozen), PRFIELD(clock_class->precision), |
7b33a0e0 PP |
791 | PRFIELD(clock_class->offset_seconds), |
792 | PRFIELD(clock_class->offset_cycles), | |
d608d675 | 793 | PRFIELD(clock_class->origin_is_unix_epoch), |
7b33a0e0 | 794 | PRFIELD(clock_class->base_offset.value_ns)); |
a6918753 | 795 | |
ecbb78c0 | 796 | SET_TMP_PREFIX("cs-pool-"); |
09f603c6 PP |
797 | format_object_pool(buf_ch, extended, tmp_prefix, |
798 | &clock_class->cs_pool); | |
57ffc2f1 PP |
799 | } |
800 | ||
ecbb78c0 PP |
801 | static inline void format_clock_snapshot(char **buf_ch, bool extended, |
802 | const char *prefix, const struct bt_clock_snapshot *clock_snapshot) | |
57ffc2f1 | 803 | { |
ed47d568 | 804 | char tmp_prefix[TMP_PREFIX_LEN]; |
7b33a0e0 | 805 | BUF_APPEND(", %svalue=%" PRIu64 ", %sns-from-origin=%" PRId64, |
ecbb78c0 PP |
806 | PRFIELD(clock_snapshot->value_cycles), |
807 | PRFIELD(clock_snapshot->ns_from_origin)); | |
57ffc2f1 PP |
808 | |
809 | if (!extended) { | |
810 | return; | |
811 | } | |
812 | ||
ecbb78c0 | 813 | BUF_APPEND(", %sis-set=%d", PRFIELD(clock_snapshot->is_set)); |
834e9996 | 814 | |
ecbb78c0 | 815 | if (clock_snapshot->clock_class) { |
834e9996 | 816 | BUF_APPEND(", %sclock-class-addr=%p", |
ecbb78c0 | 817 | PRFIELD(clock_snapshot->clock_class)); |
834e9996 PP |
818 | SET_TMP_PREFIX("clock-class-"); |
819 | format_clock_class(buf_ch, false, tmp_prefix, | |
ecbb78c0 | 820 | clock_snapshot->clock_class); |
834e9996 | 821 | } |
57ffc2f1 PP |
822 | } |
823 | ||
824 | static inline void format_value(char **buf_ch, bool extended, | |
10b7a2e4 | 825 | const char *prefix, const struct bt_value *value) |
57ffc2f1 PP |
826 | { |
827 | BUF_APPEND(", %stype=%s", | |
17582c6d | 828 | PRFIELD(bt_common_value_type_string(bt_value_get_type(value)))); |
57ffc2f1 PP |
829 | |
830 | if (!extended) { | |
831 | return; | |
832 | } | |
833 | ||
834 | switch (bt_value_get_type(value)) { | |
835 | case BT_VALUE_TYPE_BOOL: | |
836 | { | |
b5cdc106 | 837 | bt_bool val = bt_value_bool_get(value); |
57ffc2f1 | 838 | |
57ffc2f1 PP |
839 | BUF_APPEND(", %svalue=%d", PRFIELD(val)); |
840 | break; | |
841 | } | |
68d9d039 | 842 | case BT_VALUE_TYPE_UNSIGNED_INTEGER: |
57ffc2f1 | 843 | { |
68d9d039 PP |
844 | BUF_APPEND(", %svalue=%" PRIu64, |
845 | PRFIELD(bt_value_unsigned_integer_get(value))); | |
846 | break; | |
847 | } | |
848 | case BT_VALUE_TYPE_SIGNED_INTEGER: | |
849 | { | |
850 | BUF_APPEND(", %svalue=%" PRId64, | |
851 | PRFIELD(bt_value_signed_integer_get(value))); | |
57ffc2f1 PP |
852 | break; |
853 | } | |
944421ed | 854 | case BT_VALUE_TYPE_REAL: |
57ffc2f1 | 855 | { |
b5cdc106 | 856 | double val = bt_value_real_get(value); |
57ffc2f1 | 857 | |
57ffc2f1 PP |
858 | BUF_APPEND(", %svalue=%f", PRFIELD(val)); |
859 | break; | |
860 | } | |
861 | case BT_VALUE_TYPE_STRING: | |
862 | { | |
b5cdc106 | 863 | const char *val = bt_value_string_get(value); |
57ffc2f1 | 864 | |
57ffc2f1 PP |
865 | BUF_APPEND(", %spartial-value=\"%.32s\"", PRFIELD(val)); |
866 | break; | |
867 | } | |
868 | case BT_VALUE_TYPE_ARRAY: | |
869 | { | |
44514773 | 870 | int64_t count = bt_value_array_get_size(value); |
57ffc2f1 | 871 | |
8b45963b | 872 | BT_ASSERT(count >= 0); |
57ffc2f1 PP |
873 | BUF_APPEND(", %selement-count=%" PRId64, PRFIELD(count)); |
874 | break; | |
875 | } | |
876 | case BT_VALUE_TYPE_MAP: | |
877 | { | |
44514773 | 878 | int64_t count = bt_value_map_get_size(value); |
57ffc2f1 | 879 | |
8b45963b | 880 | BT_ASSERT(count >= 0); |
57ffc2f1 PP |
881 | BUF_APPEND(", %selement-count=%" PRId64, PRFIELD(count)); |
882 | break; | |
883 | } | |
884 | default: | |
885 | break; | |
886 | } | |
887 | } | |
888 | ||
b09a5592 PP |
889 | static inline void format_message(char **buf_ch, bool extended, |
890 | const char *prefix, const struct bt_message *msg) | |
57ffc2f1 | 891 | { |
ed47d568 | 892 | char tmp_prefix[TMP_PREFIX_LEN]; |
57ffc2f1 PP |
893 | |
894 | BUF_APPEND(", %stype=%s", | |
b09a5592 | 895 | PRFIELD(bt_message_type_string(msg->type))); |
57ffc2f1 PP |
896 | |
897 | if (!extended) { | |
898 | return; | |
899 | } | |
900 | ||
f7c3ac09 | 901 | BUF_APPEND(", %sis-frozen=%d, %sgraph-addr=%p", |
b09a5592 | 902 | PRFIELD(msg->frozen), PRFIELD(msg->graph)); |
57ffc2f1 | 903 | |
b09a5592 PP |
904 | switch (msg->type) { |
905 | case BT_MESSAGE_TYPE_EVENT: | |
57ffc2f1 | 906 | { |
b09a5592 PP |
907 | const struct bt_message_event *msg_event = |
908 | (const void *) msg; | |
57ffc2f1 | 909 | |
b09a5592 | 910 | if (msg_event->event) { |
834e9996 | 911 | SET_TMP_PREFIX("event-"); |
a1f053a9 PP |
912 | format_event(buf_ch, true, tmp_prefix, |
913 | msg_event->event); | |
834e9996 PP |
914 | } |
915 | ||
7370b11d PP |
916 | if (msg_event->default_cs) { |
917 | SET_TMP_PREFIX("default-cs-"); | |
918 | format_clock_snapshot(buf_ch, true, tmp_prefix, | |
919 | msg_event->default_cs); | |
920 | } | |
921 | ||
57ffc2f1 PP |
922 | break; |
923 | } | |
b09a5592 | 924 | case BT_MESSAGE_TYPE_STREAM_BEGINNING: |
a1f053a9 | 925 | case BT_MESSAGE_TYPE_STREAM_END: |
57ffc2f1 | 926 | { |
a1f053a9 | 927 | const struct bt_message_stream *msg_stream = (const void *) msg; |
57ffc2f1 | 928 | |
b09a5592 | 929 | if (msg_stream->stream) { |
834e9996 | 930 | SET_TMP_PREFIX("stream-"); |
a1f053a9 PP |
931 | format_stream(buf_ch, true, tmp_prefix, |
932 | msg_stream->stream); | |
834e9996 PP |
933 | } |
934 | ||
57ffc2f1 PP |
935 | break; |
936 | } | |
a1f053a9 PP |
937 | case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING: |
938 | case BT_MESSAGE_TYPE_STREAM_ACTIVITY_END: | |
57ffc2f1 | 939 | { |
a1f053a9 | 940 | const struct bt_message_stream_activity *msg_stream_activity = |
b09a5592 | 941 | (const void *) msg; |
57ffc2f1 | 942 | |
a1f053a9 | 943 | if (msg_stream_activity->stream) { |
834e9996 | 944 | SET_TMP_PREFIX("stream-"); |
a1f053a9 PP |
945 | format_stream(buf_ch, true, tmp_prefix, |
946 | msg_stream_activity->stream); | |
834e9996 PP |
947 | } |
948 | ||
a1f053a9 PP |
949 | BUF_APPEND(", %sdefault-cs-state=%s", |
950 | PRFIELD(bt_message_stream_activity_clock_snapshot_state_string( | |
951 | msg_stream_activity->default_cs_state))); | |
57ffc2f1 | 952 | |
a1f053a9 PP |
953 | if (msg_stream_activity->default_cs) { |
954 | SET_TMP_PREFIX("default-cs-"); | |
955 | format_clock_snapshot(buf_ch, true, tmp_prefix, | |
956 | msg_stream_activity->default_cs); | |
834e9996 PP |
957 | } |
958 | ||
57ffc2f1 PP |
959 | break; |
960 | } | |
a1f053a9 | 961 | case BT_MESSAGE_TYPE_PACKET_BEGINNING: |
b09a5592 | 962 | case BT_MESSAGE_TYPE_PACKET_END: |
57ffc2f1 | 963 | { |
a1f053a9 | 964 | const struct bt_message_packet *msg_packet = (const void *) msg; |
57ffc2f1 | 965 | |
b09a5592 | 966 | if (msg_packet->packet) { |
834e9996 | 967 | SET_TMP_PREFIX("packet-"); |
a1f053a9 PP |
968 | format_packet(buf_ch, true, tmp_prefix, |
969 | msg_packet->packet); | |
834e9996 PP |
970 | } |
971 | ||
7370b11d PP |
972 | if (msg_packet->default_cs) { |
973 | SET_TMP_PREFIX("default-cs-"); | |
974 | format_clock_snapshot(buf_ch, true, tmp_prefix, | |
975 | msg_packet->default_cs); | |
976 | } | |
977 | ||
57ffc2f1 PP |
978 | break; |
979 | } | |
8f1a1bbb | 980 | case BT_MESSAGE_TYPE_DISCARDED_EVENTS: |
2df5d26f | 981 | case BT_MESSAGE_TYPE_DISCARDED_PACKETS: |
8f1a1bbb PP |
982 | { |
983 | const struct bt_message_discarded_items *msg_disc_items = | |
984 | (const void *) msg; | |
985 | ||
986 | if (msg_disc_items->stream) { | |
987 | SET_TMP_PREFIX("stream-"); | |
988 | format_stream(buf_ch, true, tmp_prefix, | |
989 | msg_disc_items->stream); | |
990 | } | |
991 | ||
992 | if (msg_disc_items->default_begin_cs) { | |
993 | SET_TMP_PREFIX("default-begin-cs-"); | |
994 | format_clock_snapshot(buf_ch, true, tmp_prefix, | |
995 | msg_disc_items->default_begin_cs); | |
996 | } | |
997 | ||
998 | if (msg_disc_items->default_end_cs) { | |
999 | SET_TMP_PREFIX("default-end-cs-"); | |
1000 | format_clock_snapshot(buf_ch, true, tmp_prefix, | |
1001 | msg_disc_items->default_end_cs); | |
1002 | } | |
1003 | ||
1004 | if (msg_disc_items->count.base.avail) { | |
1005 | BUF_APPEND(", %scount=%" PRIu64, | |
1006 | PRFIELD(msg_disc_items->count.value)); | |
1007 | } | |
1008 | ||
1009 | break; | |
1010 | } | |
57ffc2f1 PP |
1011 | default: |
1012 | break; | |
1013 | } | |
1014 | } | |
1015 | ||
1016 | static inline void format_plugin_so_shared_lib_handle(char **buf_ch, | |
1017 | const char *prefix, | |
10b7a2e4 | 1018 | const struct bt_plugin_so_shared_lib_handle *handle) |
57ffc2f1 PP |
1019 | { |
1020 | BUF_APPEND(", %saddr=%p", PRFIELD(handle)); | |
1021 | ||
1022 | if (handle->path) { | |
834e9996 | 1023 | BUF_APPEND(", %spath=\"%s\"", PRFIELD_GSTRING(handle->path)); |
57ffc2f1 PP |
1024 | } |
1025 | } | |
1026 | ||
1027 | static inline void format_component_class(char **buf_ch, bool extended, | |
10b7a2e4 PP |
1028 | const char *prefix, |
1029 | const struct bt_component_class *comp_class) | |
57ffc2f1 | 1030 | { |
ed47d568 | 1031 | char tmp_prefix[TMP_PREFIX_LEN]; |
57ffc2f1 PP |
1032 | |
1033 | BUF_APPEND(", %stype=%s, %sname=\"%s\"", | |
1034 | PRFIELD(bt_component_class_type_string(comp_class->type)), | |
834e9996 | 1035 | PRFIELD_GSTRING(comp_class->name)); |
57ffc2f1 PP |
1036 | |
1037 | if (comp_class->description) { | |
1038 | BUF_APPEND(", %spartial-descr=\"%.32s\"", | |
834e9996 | 1039 | PRFIELD_GSTRING(comp_class->description)); |
57ffc2f1 PP |
1040 | } |
1041 | ||
1042 | if (!extended) { | |
1043 | return; | |
1044 | } | |
1045 | ||
1046 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(comp_class->frozen)); | |
1047 | ||
1048 | if (comp_class->so_handle) { | |
1049 | SET_TMP_PREFIX("so-handle-"); | |
1050 | format_plugin_so_shared_lib_handle(buf_ch, tmp_prefix, | |
1051 | comp_class->so_handle); | |
1052 | } | |
1053 | } | |
1054 | ||
1055 | static inline void format_component(char **buf_ch, bool extended, | |
10b7a2e4 | 1056 | const char *prefix, const struct bt_component *component) |
57ffc2f1 | 1057 | { |
ed47d568 | 1058 | char tmp_prefix[TMP_PREFIX_LEN]; |
57ffc2f1 | 1059 | |
cc81b5ab PP |
1060 | BUF_APPEND(", %sname=\"%s\", %slog-level=%s", |
1061 | PRFIELD_GSTRING(component->name), | |
1062 | PRFIELD(bt_common_logging_level_string(component->log_level))); | |
834e9996 PP |
1063 | |
1064 | if (component->class) { | |
1065 | SET_TMP_PREFIX("class-"); | |
1066 | format_component_class(buf_ch, extended, tmp_prefix, | |
1067 | component->class); | |
1068 | } | |
57ffc2f1 PP |
1069 | |
1070 | if (!extended) { | |
1071 | return; | |
1072 | } | |
1073 | ||
a6918753 PP |
1074 | if (component->input_ports) { |
1075 | BUF_APPEND(", %sinput-port-count=%u", | |
1076 | PRFIELD(component->input_ports->len)); | |
1077 | } | |
1078 | ||
1079 | if (component->output_ports) { | |
1080 | BUF_APPEND(", %soutput-port-count=%u", | |
1081 | PRFIELD(component->output_ports->len)); | |
1082 | } | |
57ffc2f1 PP |
1083 | } |
1084 | ||
1085 | static inline void format_port(char **buf_ch, bool extended, | |
10b7a2e4 | 1086 | const char *prefix, const struct bt_port *port) |
57ffc2f1 | 1087 | { |
ed47d568 | 1088 | char tmp_prefix[TMP_PREFIX_LEN]; |
57ffc2f1 PP |
1089 | |
1090 | BUF_APPEND(", %stype=%s, %sname=\"%s\"", | |
1091 | PRFIELD(bt_port_type_string(port->type)), | |
834e9996 | 1092 | PRFIELD_GSTRING(port->name)); |
57ffc2f1 PP |
1093 | |
1094 | if (!extended) { | |
1095 | return; | |
1096 | } | |
1097 | ||
1098 | if (port->connection) { | |
1099 | SET_TMP_PREFIX("conn-"); | |
1100 | format_connection(buf_ch, false, tmp_prefix, port->connection); | |
1101 | } | |
1102 | } | |
1103 | ||
1104 | static inline void format_connection(char **buf_ch, bool extended, | |
10b7a2e4 | 1105 | const char *prefix, const struct bt_connection *connection) |
57ffc2f1 | 1106 | { |
ed47d568 | 1107 | char tmp_prefix[TMP_PREFIX_LEN]; |
57ffc2f1 PP |
1108 | |
1109 | if (!extended) { | |
1110 | return; | |
1111 | } | |
1112 | ||
1113 | if (connection->upstream_port) { | |
1114 | SET_TMP_PREFIX("upstream-port-"); | |
1115 | format_port(buf_ch, false, tmp_prefix, | |
1116 | connection->upstream_port); | |
1117 | } | |
1118 | ||
1119 | if (connection->downstream_port) { | |
1120 | SET_TMP_PREFIX("downstream-port-"); | |
1121 | format_port(buf_ch, false, tmp_prefix, | |
1122 | connection->downstream_port); | |
1123 | } | |
1124 | } | |
1125 | ||
1126 | static inline void format_graph(char **buf_ch, bool extended, | |
10b7a2e4 | 1127 | const char *prefix, const struct bt_graph *graph) |
57ffc2f1 | 1128 | { |
ed47d568 | 1129 | char tmp_prefix[TMP_PREFIX_LEN]; |
f7c3ac09 | 1130 | |
1043fdea PP |
1131 | BUF_APPEND(", %sis-canceled=%d, %scan-consume=%d, " |
1132 | "%sconfig-state=%s", | |
1133 | PRFIELD(graph->canceled), | |
1134 | PRFIELD(graph->can_consume), | |
1135 | PRFIELD(bt_graph_configuration_state_string(graph->config_state))); | |
57ffc2f1 PP |
1136 | |
1137 | if (!extended) { | |
1138 | return; | |
1139 | } | |
1140 | ||
a6918753 PP |
1141 | if (graph->components) { |
1142 | BUF_APPEND(", %scomp-count=%u", | |
1143 | PRFIELD(graph->components->len)); | |
1144 | } | |
1145 | ||
1146 | if (graph->connections) { | |
1147 | BUF_APPEND(", %sconn-count=%u", | |
1148 | PRFIELD(graph->connections->len)); | |
1149 | } | |
f7c3ac09 PP |
1150 | |
1151 | SET_TMP_PREFIX("en-pool-"); | |
09f603c6 | 1152 | format_object_pool(buf_ch, extended, tmp_prefix, |
b09a5592 | 1153 | &graph->event_msg_pool); |
f7c3ac09 | 1154 | SET_TMP_PREFIX("pbn-pool-"); |
09f603c6 | 1155 | format_object_pool(buf_ch, extended, tmp_prefix, |
b09a5592 | 1156 | &graph->packet_begin_msg_pool); |
f7c3ac09 | 1157 | SET_TMP_PREFIX("pen-pool-"); |
09f603c6 | 1158 | format_object_pool(buf_ch, extended, tmp_prefix, |
b09a5592 | 1159 | &graph->packet_end_msg_pool); |
57ffc2f1 PP |
1160 | } |
1161 | ||
b09a5592 | 1162 | static inline void format_message_iterator(char **buf_ch, |
57ffc2f1 | 1163 | bool extended, const char *prefix, |
b09a5592 | 1164 | const struct bt_message_iterator *iterator) |
57ffc2f1 PP |
1165 | { |
1166 | const char *type; | |
ed47d568 | 1167 | char tmp_prefix[TMP_PREFIX_LEN]; |
57ffc2f1 | 1168 | |
b09a5592 PP |
1169 | if (iterator->type == BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT) { |
1170 | type = "BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT"; | |
1171 | } else if (iterator->type == BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT) { | |
1172 | type = "BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT"; | |
57ffc2f1 PP |
1173 | } else { |
1174 | type = "(unknown)"; | |
1175 | } | |
1176 | ||
1177 | BUF_APPEND(", %stype=%s", PRFIELD(type)); | |
1178 | ||
1179 | switch (iterator->type) { | |
b09a5592 | 1180 | case BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT: |
57ffc2f1 | 1181 | { |
b09a5592 | 1182 | const struct bt_self_component_port_input_message_iterator * |
10b7a2e4 | 1183 | port_in_iter = (const void *) iterator; |
57ffc2f1 | 1184 | |
834e9996 | 1185 | if (port_in_iter->upstream_component) { |
57ffc2f1 PP |
1186 | SET_TMP_PREFIX("upstream-comp-"); |
1187 | format_component(buf_ch, false, tmp_prefix, | |
834e9996 | 1188 | port_in_iter->upstream_component); |
57ffc2f1 PP |
1189 | } |
1190 | ||
834e9996 | 1191 | if (port_in_iter->upstream_port) { |
57ffc2f1 PP |
1192 | SET_TMP_PREFIX("upstream-port-"); |
1193 | format_port(buf_ch, false, tmp_prefix, | |
834e9996 | 1194 | port_in_iter->upstream_port); |
57ffc2f1 PP |
1195 | } |
1196 | ||
834e9996 | 1197 | if (port_in_iter->connection) { |
57ffc2f1 PP |
1198 | SET_TMP_PREFIX("upstream-conn-"); |
1199 | format_connection(buf_ch, false, tmp_prefix, | |
834e9996 | 1200 | port_in_iter->connection); |
57ffc2f1 PP |
1201 | } |
1202 | break; | |
1203 | } | |
b09a5592 | 1204 | case BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT: |
57ffc2f1 | 1205 | { |
b09a5592 | 1206 | const struct bt_port_output_message_iterator *port_out_iter = |
10b7a2e4 | 1207 | (const void *) iterator; |
57ffc2f1 | 1208 | |
834e9996 PP |
1209 | if (port_out_iter->graph) { |
1210 | SET_TMP_PREFIX("graph-"); | |
1211 | format_graph(buf_ch, false, tmp_prefix, | |
1212 | port_out_iter->graph); | |
1213 | } | |
1214 | ||
1215 | if (port_out_iter->colander) { | |
1216 | SET_TMP_PREFIX("colander-comp-"); | |
1217 | format_component(buf_ch, false, tmp_prefix, | |
1218 | (void *) port_out_iter->colander); | |
1219 | } | |
1220 | ||
57ffc2f1 PP |
1221 | break; |
1222 | } | |
1223 | default: | |
1224 | break; | |
1225 | } | |
1226 | } | |
1227 | ||
1228 | static inline void format_plugin(char **buf_ch, bool extended, | |
3a2cb327 | 1229 | const char *prefix, const struct bt_plugin *plugin) |
57ffc2f1 | 1230 | { |
ed47d568 | 1231 | char tmp_prefix[TMP_PREFIX_LEN]; |
57ffc2f1 PP |
1232 | |
1233 | BUF_APPEND(", %stype=%s", PRFIELD(bt_plugin_type_string(plugin->type))); | |
1234 | ||
1235 | if (plugin->info.path_set) { | |
1236 | BUF_APPEND(", %spath=\"%s\"", | |
834e9996 | 1237 | PRFIELD_GSTRING(plugin->info.path)); |
57ffc2f1 PP |
1238 | } |
1239 | ||
1240 | if (plugin->info.name_set) { | |
1241 | BUF_APPEND(", %sname=\"%s\"", | |
834e9996 | 1242 | PRFIELD_GSTRING(plugin->info.name)); |
57ffc2f1 PP |
1243 | } |
1244 | ||
1245 | if (!extended) { | |
1246 | return; | |
1247 | } | |
1248 | ||
1249 | if (plugin->info.author_set) { | |
1250 | BUF_APPEND(", %sauthor=\"%s\"", | |
834e9996 | 1251 | PRFIELD_GSTRING(plugin->info.author)); |
57ffc2f1 PP |
1252 | } |
1253 | ||
1254 | if (plugin->info.license_set) { | |
1255 | BUF_APPEND(", %slicense=\"%s\"", | |
834e9996 | 1256 | PRFIELD_GSTRING(plugin->info.license)); |
57ffc2f1 PP |
1257 | } |
1258 | ||
1259 | if (plugin->info.version_set) { | |
1260 | BUF_APPEND(", %sversion=%u.%u.%u%s", | |
1261 | PRFIELD(plugin->info.version.major), | |
1262 | plugin->info.version.minor, | |
1263 | plugin->info.version.patch, | |
1264 | plugin->info.version.extra ? | |
1265 | plugin->info.version.extra->str : ""); | |
1266 | } | |
1267 | ||
834e9996 PP |
1268 | BUF_APPEND(", %ssrc-comp-class-count=%u, %sflt-comp-class-count=%u, " |
1269 | "%ssink-comp-class-count=%u", | |
1270 | PRFIELD(plugin->src_comp_classes->len), | |
1271 | PRFIELD(plugin->flt_comp_classes->len), | |
1272 | PRFIELD(plugin->sink_comp_classes->len)); | |
57ffc2f1 PP |
1273 | |
1274 | if (plugin->spec_data) { | |
10b7a2e4 PP |
1275 | const struct bt_plugin_so_spec_data *spec_data = |
1276 | (const void *) plugin->spec_data; | |
57ffc2f1 PP |
1277 | |
1278 | if (spec_data->shared_lib_handle) { | |
1279 | SET_TMP_PREFIX("so-handle-"); | |
1280 | format_plugin_so_shared_lib_handle(buf_ch, tmp_prefix, | |
1281 | spec_data->shared_lib_handle); | |
1282 | } | |
1283 | } | |
1284 | } | |
1285 | ||
c0e90f23 PP |
1286 | static inline void format_error_cause(char **buf_ch, bool extended, |
1287 | const char *prefix, const struct bt_error_cause *cause) | |
1288 | { | |
1289 | const struct bt_error_cause_component_class_id *comp_class_id = NULL; | |
1290 | ||
1291 | BUF_APPEND(", %sactor-type=%s, %smodule-name=\"%s\"", | |
1292 | PRFIELD(bt_error_cause_actor_type_string(cause->actor_type)), | |
1293 | PRFIELD_GSTRING(cause->module_name)); | |
1294 | ||
1295 | if (!extended) { | |
1296 | return; | |
1297 | } | |
1298 | ||
1299 | BUF_APPEND(", %spartial-msg=\"%.32s\"", | |
1300 | PRFIELD_GSTRING(cause->message)); | |
1301 | ||
1302 | switch (cause->actor_type) { | |
1303 | case BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT: | |
1304 | { | |
1305 | const struct bt_error_cause_component_actor *spec_cause = | |
1306 | (const void *) cause; | |
1307 | ||
1308 | BUF_APPEND(", %scomp-name=\"%s\"", | |
1309 | PRFIELD_GSTRING(spec_cause->comp_name)); | |
1310 | comp_class_id = &spec_cause->comp_class_id; | |
1311 | break; | |
1312 | } | |
1313 | case BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS: | |
1314 | { | |
1315 | const struct bt_error_cause_component_class_actor *spec_cause = | |
1316 | (const void *) cause; | |
1317 | ||
1318 | comp_class_id = &spec_cause->comp_class_id; | |
1319 | break; | |
1320 | } | |
1321 | case BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR: | |
1322 | { | |
1323 | const struct bt_error_cause_message_iterator_actor *spec_cause = | |
1324 | (const void *) cause; | |
1325 | ||
1326 | BUF_APPEND(", %scomp-name=\"%s\", %scomp-out-port-name=\"%s\"", | |
1327 | PRFIELD_GSTRING(spec_cause->comp_name), | |
1328 | PRFIELD_GSTRING(spec_cause->output_port_name)); | |
1329 | comp_class_id = &spec_cause->comp_class_id; | |
1330 | break; | |
1331 | } | |
1332 | default: | |
1333 | break; | |
1334 | } | |
1335 | ||
1336 | if (comp_class_id) { | |
1337 | BUF_APPEND(", %scomp-cls-type=%s, %scomp-cls-name=\"%s\", " | |
1338 | "%splugin-name=\"%s\"", | |
1339 | PRFIELD(bt_component_class_type_string( | |
1340 | comp_class_id->type)), | |
1341 | PRFIELD_GSTRING(comp_class_id->name), | |
1342 | PRFIELD_GSTRING(comp_class_id->plugin_name)); | |
1343 | } | |
1344 | } | |
1345 | ||
57ffc2f1 PP |
1346 | static inline void handle_conversion_specifier_bt(void *priv_data, |
1347 | char **buf_ch, size_t avail_size, | |
1348 | const char **out_fmt_ch, va_list *args) | |
1349 | { | |
1350 | const char *fmt_ch = *out_fmt_ch; | |
1351 | bool extended = false; | |
1352 | char prefix[64]; | |
1353 | char *prefix_ch = prefix; | |
10b7a2e4 | 1354 | const void *obj; |
57ffc2f1 PP |
1355 | |
1356 | /* skip "%!" */ | |
1357 | fmt_ch += 2; | |
1358 | ||
7b33a0e0 PP |
1359 | if (*fmt_ch == 'u') { |
1360 | /* UUID */ | |
1361 | obj = va_arg(*args, void *); | |
1362 | format_uuid(buf_ch, obj); | |
1363 | goto update_fmt; | |
1364 | } | |
1365 | ||
57ffc2f1 PP |
1366 | if (*fmt_ch == '[') { |
1367 | /* local prefix */ | |
1368 | fmt_ch++; | |
1369 | ||
1370 | while (true) { | |
1371 | if (*fmt_ch == ']') { | |
1372 | *prefix_ch = '\0'; | |
1373 | fmt_ch++; | |
1374 | break; | |
1375 | } | |
1376 | ||
1377 | *prefix_ch = *fmt_ch; | |
1378 | prefix_ch++; | |
1379 | fmt_ch++; | |
1380 | } | |
1381 | } | |
1382 | ||
1383 | *prefix_ch = '\0'; | |
1384 | ||
1385 | if (*fmt_ch == '+') { | |
1386 | extended = true; | |
1387 | fmt_ch++; | |
1388 | } | |
1389 | ||
1390 | obj = va_arg(*args, void *); | |
1391 | BUF_APPEND("%saddr=%p", prefix, obj); | |
1392 | ||
1393 | if (!obj) { | |
1394 | goto update_fmt; | |
1395 | } | |
1396 | ||
18acc6f8 PP |
1397 | switch (*fmt_ch) { |
1398 | case 'F': | |
939190b3 | 1399 | format_field_class(buf_ch, extended, prefix, obj); |
57ffc2f1 | 1400 | break; |
18acc6f8 PP |
1401 | case 'f': |
1402 | format_field(buf_ch, extended, prefix, obj); | |
1403 | break; | |
1404 | case 'P': | |
1405 | format_field_path(buf_ch, extended, prefix, obj); | |
1406 | break; | |
1407 | case 'E': | |
1408 | format_event_class(buf_ch, extended, prefix, obj); | |
1409 | break; | |
1410 | case 'e': | |
1411 | format_event(buf_ch, extended, prefix, obj); | |
1412 | break; | |
1413 | case 'S': | |
1414 | format_stream_class(buf_ch, extended, prefix, obj); | |
57ffc2f1 | 1415 | break; |
18acc6f8 PP |
1416 | case 's': |
1417 | format_stream(buf_ch, extended, prefix, obj); | |
1418 | break; | |
1419 | case 'a': | |
1420 | format_packet(buf_ch, extended, prefix, obj); | |
1421 | break; | |
1422 | case 't': | |
1423 | format_trace(buf_ch, extended, prefix, obj); | |
1424 | break; | |
10b7a2e4 PP |
1425 | case 'T': |
1426 | format_trace_class(buf_ch, extended, prefix, obj); | |
1427 | break; | |
18acc6f8 PP |
1428 | case 'K': |
1429 | format_clock_class(buf_ch, extended, prefix, obj); | |
1430 | break; | |
1431 | case 'k': | |
ecbb78c0 | 1432 | format_clock_snapshot(buf_ch, extended, prefix, obj); |
18acc6f8 PP |
1433 | break; |
1434 | case 'v': | |
1435 | format_value(buf_ch, extended, prefix, obj); | |
1436 | break; | |
1437 | case 'n': | |
b09a5592 | 1438 | format_message(buf_ch, extended, prefix, obj); |
18acc6f8 PP |
1439 | break; |
1440 | case 'i': | |
b09a5592 | 1441 | format_message_iterator(buf_ch, extended, prefix, obj); |
18acc6f8 PP |
1442 | break; |
1443 | case 'C': | |
1444 | format_component_class(buf_ch, extended, prefix, obj); | |
1445 | break; | |
1446 | case 'c': | |
1447 | format_component(buf_ch, extended, prefix, obj); | |
1448 | break; | |
1449 | case 'p': | |
1450 | format_port(buf_ch, extended, prefix, obj); | |
1451 | break; | |
1452 | case 'x': | |
1453 | format_connection(buf_ch, extended, prefix, obj); | |
1454 | break; | |
7b33a0e0 | 1455 | case 'l': |
18acc6f8 PP |
1456 | format_plugin(buf_ch, extended, prefix, obj); |
1457 | break; | |
1458 | case 'g': | |
1459 | format_graph(buf_ch, extended, prefix, obj); | |
1460 | break; | |
1461 | case 'o': | |
1462 | format_object_pool(buf_ch, extended, prefix, obj); | |
1463 | break; | |
1464 | case 'O': | |
1465 | format_object(buf_ch, extended, prefix, obj); | |
1466 | break; | |
c0e90f23 PP |
1467 | case 'r': |
1468 | format_error_cause(buf_ch, extended, prefix, obj); | |
1469 | break; | |
18acc6f8 PP |
1470 | default: |
1471 | abort(); | |
57ffc2f1 PP |
1472 | } |
1473 | ||
1474 | update_fmt: | |
1475 | fmt_ch++; | |
1476 | *out_fmt_ch = fmt_ch; | |
1477 | } | |
1478 | ||
57ffc2f1 PP |
1479 | void bt_lib_log(const char *func, const char *file, unsigned line, |
1480 | int lvl, const char *tag, const char *fmt, ...) | |
1481 | { | |
1482 | va_list args; | |
1483 | ||
8b45963b | 1484 | BT_ASSERT(fmt); |
57ffc2f1 PP |
1485 | va_start(args, fmt); |
1486 | bt_common_custom_vsnprintf(lib_logging_buf, LIB_LOGGING_BUF_SIZE, '!', | |
1487 | handle_conversion_specifier_bt, NULL, fmt, &args); | |
1488 | va_end(args); | |
1489 | _bt_log_write_d(func, file, line, lvl, tag, "%s", lib_logging_buf); | |
1490 | } |