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