0a988db3d3f2d2c5ec2c9e204a8c00039aaea1a1
[babeltrace.git] / lib / lib-logging.c
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
23 #define BT_LOG_TAG "LIB-LOGGING"
24
25 #include <stdarg.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <inttypes.h>
30 #include <stdint.h>
31 #include <wchar.h>
32 #include <glib.h>
33 #include <babeltrace/lib-logging-internal.h>
34 #include <babeltrace/assert-pre-internal.h>
35 #include <babeltrace/common-internal.h>
36 #include <babeltrace/lib-logging-internal.h>
37 #include <babeltrace/value-internal.h>
38 #include <babeltrace/value-internal.h>
39 #include <babeltrace/object-pool-internal.h>
40 #include <babeltrace/trace-ir/field-class-internal.h>
41 #include <babeltrace/trace-ir/field-internal.h>
42 #include <babeltrace/trace-ir/event-class-internal.h>
43 #include <babeltrace/trace-ir/event-const.h>
44 #include <babeltrace/trace-ir/event-internal.h>
45 #include <babeltrace/trace-ir/packet-const.h>
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>
49 #include <babeltrace/trace-ir/stream-const.h>
50 #include <babeltrace/trace-ir/trace-internal.h>
51 #include <babeltrace/trace-ir/trace-class-internal.h>
52 #include <babeltrace/trace-ir/clock-class-internal.h>
53 #include <babeltrace/trace-ir/clock-snapshot-internal.h>
54 #include <babeltrace/trace-ir/field-path-internal.h>
55 #include <babeltrace/trace-ir/utils-internal.h>
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>
64 #include <babeltrace/graph/message-event-internal.h>
65 #include <babeltrace/graph/message-message-iterator-inactivity-internal.h>
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>
70 #include <babeltrace/graph/message-stream-activity-internal.h>
71 #include <babeltrace/graph/message-discarded-items-internal.h>
72 #include <babeltrace/graph/port-internal.h>
73 #include <babeltrace/plugin/plugin-internal.h>
74 #include <babeltrace/plugin/plugin-so-internal.h>
75
76 #define LIB_LOGGING_BUF_SIZE (4096 * 4)
77
78 static __thread char lib_logging_buf[LIB_LOGGING_BUF_SIZE];
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__); \
86 BT_ASSERT(_count >= 0); \
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) \
94 do { \
95 BUF_APPEND(", %suuid=", prefix); \
96 format_uuid(buf_ch, (_uuid)); \
97 } while (0)
98
99 #define PRFIELD(_expr) prefix, (_expr)
100
101 #define PRFIELD_GSTRING(_expr) PRFIELD((_expr) ? (_expr)->str : NULL)
102
103 #define TMP_PREFIX_LEN 64
104 #define SET_TMP_PREFIX(_prefix2) \
105 do { \
106 strncpy(tmp_prefix, prefix, TMP_PREFIX_LEN); \
107 strncat(tmp_prefix, (_prefix2), TMP_PREFIX_LEN); \
108 } while (0)
109
110 static inline void format_component(char **buf_ch, bool extended,
111 const char *prefix, const struct bt_component *component);
112
113 static inline void format_port(char **buf_ch, bool extended,
114 const char *prefix, const struct bt_port *port);
115
116 static inline void format_connection(char **buf_ch, bool extended,
117 const char *prefix, const struct bt_connection *connection);
118
119 static inline void format_clock_snapshot(char **buf_ch, bool extended,
120 const char *prefix, const struct bt_clock_snapshot *clock_snapshot);
121
122 static inline void format_field_path(char **buf_ch, bool extended,
123 const char *prefix, const struct bt_field_path *field_path);
124
125 static inline void format_object(char **buf_ch, bool extended,
126 const char *prefix, const struct bt_object *obj)
127 {
128 BUF_APPEND(", %sref-count=%llu", prefix, obj->ref_count);
129 }
130
131 static inline void format_uuid(char **buf_ch, bt_uuid uuid)
132 {
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]);
150 }
151
152 static inline void format_object_pool(char **buf_ch, bool extended,
153 const char *prefix, const struct bt_object_pool *pool)
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
162 static inline void format_integer_field_class(char **buf_ch,
163 bool extended, const char *prefix,
164 const struct bt_field_class *field_class)
165 {
166 const struct bt_field_class_integer *int_fc =
167 (const void *) field_class;
168
169 BUF_APPEND(", %srange-size=%" PRIu64 ", %sbase=%s",
170 PRFIELD(int_fc->range),
171 PRFIELD(bt_common_field_class_integer_preferred_display_base_string(int_fc->base)));
172 }
173
174 static inline void format_array_field_class(char **buf_ch,
175 bool extended, const char *prefix,
176 const struct bt_field_class *field_class)
177 {
178 const struct bt_field_class_array *array_fc =
179 (const void *) field_class;
180
181 BUF_APPEND(", %selement-fc-addr=%p, %selement-fc-type=%s",
182 PRFIELD(array_fc->element_fc),
183 PRFIELD(bt_common_field_class_type_string(array_fc->element_fc->type)));
184 }
185
186 static inline void format_field_class(char **buf_ch, bool extended,
187 const char *prefix, const struct bt_field_class *field_class)
188 {
189 char tmp_prefix[TMP_PREFIX_LEN];
190
191 BUF_APPEND(", %stype=%s",
192 PRFIELD(bt_common_field_class_type_string(field_class->type)));
193
194 if (extended) {
195 BUF_APPEND(", %sis-frozen=%d", PRFIELD(field_class->frozen));
196 BUF_APPEND(", %sis-part-of-trace-class=%d",
197 PRFIELD(field_class->part_of_trace_class));
198 } else {
199 return;
200 }
201
202 switch (field_class->type) {
203 case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER:
204 case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER:
205 {
206 format_integer_field_class(buf_ch, extended, prefix, field_class);
207 break;
208 }
209 case BT_FIELD_CLASS_TYPE_REAL:
210 {
211 const struct bt_field_class_real *real_fc = (void *) field_class;
212
213 BUF_APPEND(", %sis-single-precision=%d",
214 PRFIELD(real_fc->is_single_precision));
215 break;
216 }
217 case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION:
218 case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION:
219 {
220 const struct bt_field_class_enumeration *enum_fc =
221 (const void *) field_class;
222
223 format_integer_field_class(buf_ch, extended, prefix, field_class);
224 BUF_APPEND(", %smapping-count=%u",
225 PRFIELD(enum_fc->mappings->len));
226 break;
227 }
228 case BT_FIELD_CLASS_TYPE_STRUCTURE:
229 {
230 const struct bt_field_class_structure *struct_fc =
231 (const void *) field_class;
232
233 if (struct_fc->common.named_fcs) {
234 BUF_APPEND(", %smember-count=%u",
235 PRFIELD(struct_fc->common.named_fcs->len));
236 }
237
238 break;
239 }
240 case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
241 {
242 const struct bt_field_class_static_array *array_fc =
243 (const void *) field_class;
244
245 format_array_field_class(buf_ch, extended, prefix, field_class);
246 BUF_APPEND(", %slength=%" PRIu64, PRFIELD(array_fc->length));
247 break;
248 }
249 case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
250 {
251 const struct bt_field_class_dynamic_array *array_fc =
252 (const void *) field_class;
253
254 format_array_field_class(buf_ch, extended, prefix, field_class);
255
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);
260 }
261
262 if (array_fc->length_field_path) {
263 SET_TMP_PREFIX("length-field-path-");
264 format_field_path(buf_ch, extended, tmp_prefix,
265 array_fc->length_field_path);
266 }
267
268 break;
269 }
270 case BT_FIELD_CLASS_TYPE_VARIANT:
271 {
272 const struct bt_field_class_variant *var_fc =
273 (const void *) field_class;
274
275 if (var_fc->common.named_fcs) {
276 BUF_APPEND(", %soption-count=%u",
277 PRFIELD(var_fc->common.named_fcs->len));
278 }
279
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);
284 }
285
286 if (var_fc->selector_field_path) {
287 SET_TMP_PREFIX("selector-field-path-");
288 format_field_path(buf_ch, extended, tmp_prefix,
289 var_fc->selector_field_path);
290 }
291
292 break;
293 }
294 default:
295 break;
296 }
297 }
298
299 static inline void format_field_integer_extended(char **buf_ch,
300 const char *prefix, const struct bt_field *field)
301 {
302 const struct bt_field_integer *integer = (void *) field;
303 const struct bt_field_class_integer *field_class =
304 (void *) field->class;
305 const char *fmt = NULL;
306
307 BT_ASSERT(field_class);
308
309 if (field_class->base == BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL) {
310 fmt = ", %svalue=%" PRIo64;
311 } else if (field_class->base == BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL) {
312 fmt = ", %svalue=%" PRIx64;
313 }
314
315 if (field_class->common.type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER ||
316 field_class->common.type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) {
317 if (!fmt) {
318 fmt = ", %svalue=%" PRId64;
319 }
320
321 BUF_APPEND(fmt, PRFIELD(integer->value.i));
322 } else {
323 if (!fmt) {
324 fmt = ", %svalue=%" PRIu64;
325 }
326
327 BUF_APPEND(fmt, PRFIELD(integer->value.u));
328 }
329 }
330
331 static inline void format_field(char **buf_ch, bool extended,
332 const char *prefix, const struct bt_field *field)
333 {
334 BUF_APPEND(", %sis-set=%d", PRFIELD(field->is_set));
335
336 if (extended) {
337 BUF_APPEND(", %sis-frozen=%d", PRFIELD(field->frozen));
338 }
339
340 BUF_APPEND(", %sclass-addr=%p", PRFIELD(field->class));
341
342 if (!field->class) {
343 return;
344 }
345
346 BUF_APPEND(", %sclass-type=%s",
347 PRFIELD(bt_common_field_class_type_string(field->class->type)));
348
349 if (!extended || !field->is_set) {
350 return;
351 }
352
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:
358 {
359 format_field_integer_extended(buf_ch, prefix, field);
360 break;
361 }
362 case BT_FIELD_CLASS_TYPE_REAL:
363 {
364 const struct bt_field_real *real_field = (const void *) field;
365
366 BUF_APPEND(", %svalue=%f", PRFIELD(real_field->value));
367 break;
368 }
369 case BT_FIELD_CLASS_TYPE_STRING:
370 {
371 const struct bt_field_string *str = (const void *) field;
372
373 if (str->buf) {
374 BT_ASSERT(str->buf->data);
375 BUF_APPEND(", %spartial-value=\"%.32s\"",
376 PRFIELD(str->buf->data));
377 }
378
379 break;
380 }
381 case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
382 case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
383 {
384 const struct bt_field_array *array_field = (const void *) field;
385
386 BUF_APPEND(", %slength=%" PRIu64, PRFIELD(array_field->length));
387
388 if (array_field->fields) {
389 BUF_APPEND(", %sallocated-length=%u",
390 PRFIELD(array_field->fields->len));
391 }
392
393 break;
394 }
395 case BT_FIELD_CLASS_TYPE_VARIANT:
396 {
397 const struct bt_field_variant *var_field = (const void *) field;
398
399 BUF_APPEND(", %sselected-field-index=%" PRIu64,
400 PRFIELD(var_field->selected_index));
401 break;
402 }
403 default:
404 break;
405 }
406 }
407
408 static inline void format_field_path(char **buf_ch, bool extended,
409 const char *prefix, const struct bt_field_path *field_path)
410 {
411 uint64_t i;
412
413 if (field_path->items) {
414 BT_ASSERT(field_path->items);
415 BUF_APPEND(", %sitem-count=%u",
416 PRFIELD(field_path->items->len));
417 }
418
419 if (!extended || !field_path->items) {
420 return;
421 }
422
423 BUF_APPEND(", %spath=[%s",
424 PRFIELD(bt_common_scope_string(field_path->root)));
425
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 }
441 }
442
443 BUF_APPEND("%s", "]");
444 }
445
446 static inline void format_trace_class(char **buf_ch, bool extended,
447 const char *prefix, const struct bt_trace_class *trace_class)
448 {
449 if (trace_class->name.value) {
450 BUF_APPEND(", %sname=\"%s\"",
451 PRFIELD(trace_class->name.value));
452 }
453
454 if (!extended) {
455 return;
456 }
457
458 BUF_APPEND(", %sis-frozen=%d", PRFIELD(trace_class->frozen));
459
460 if (trace_class->uuid.value) {
461 BUF_APPEND_UUID(trace_class->uuid.value);
462 }
463
464 if (trace_class->stream_classes) {
465 BUF_APPEND(", %sstream-class-count=%u",
466 PRFIELD(trace_class->stream_classes->len));
467 }
468
469 BUF_APPEND(", %sassigns-auto-sc-id=%d",
470 PRFIELD(trace_class->assigns_automatic_stream_class_id));
471 }
472
473 static inline void format_trace(char **buf_ch, bool extended,
474 const char *prefix, const struct bt_trace *trace)
475 {
476 char tmp_prefix[TMP_PREFIX_LEN];
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
488 if (trace->streams) {
489 BUF_APPEND(", %sstream-count=%u",
490 PRFIELD(trace->streams->len));
491 }
492
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);
500 }
501
502 static inline void format_stream_class(char **buf_ch, bool extended,
503 const char *prefix,
504 const struct bt_stream_class *stream_class)
505 {
506 const struct bt_trace_class *trace_class;
507 char tmp_prefix[TMP_PREFIX_LEN];
508
509 BUF_APPEND(", %sid=%" PRIu64, PRFIELD(stream_class->id));
510
511 if (stream_class->name.value) {
512 BUF_APPEND(", %sname=\"%s\"",
513 PRFIELD(stream_class->name.value));
514 }
515
516 if (!extended) {
517 return;
518 }
519
520 BUF_APPEND(", %sis-frozen=%d", PRFIELD(stream_class->frozen));
521
522 if (stream_class->event_classes) {
523 BUF_APPEND(", %sevent-class-count=%u",
524 PRFIELD(stream_class->event_classes->len));
525 }
526
527 BUF_APPEND(", %spacket-context-fc-addr=%p, "
528 "%sevent-common-context-fc-addr=%p",
529 PRFIELD(stream_class->packet_context_fc),
530 PRFIELD(stream_class->event_common_context_fc));
531 trace_class = bt_stream_class_borrow_trace_class_inline(stream_class);
532 if (!trace_class) {
533 return;
534 }
535
536 BUF_APPEND(", %sassigns-auto-ec-id=%d, %sassigns-auto-stream-id=%d",
537 PRFIELD(stream_class->assigns_automatic_event_class_id),
538 PRFIELD(stream_class->assigns_automatic_stream_id));
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);
542 SET_TMP_PREFIX("pcf-pool-");
543 format_object_pool(buf_ch, extended, tmp_prefix,
544 &stream_class->packet_context_field_pool);
545 }
546
547 static inline void format_event_class(char **buf_ch, bool extended,
548 const char *prefix, const struct bt_event_class *event_class)
549 {
550 const struct bt_stream_class *stream_class;
551 const struct bt_trace_class *trace_class;
552 char tmp_prefix[TMP_PREFIX_LEN];
553
554 BUF_APPEND(", %sid=%" PRIu64, PRFIELD(event_class->id));
555
556 if (event_class->name.value) {
557 BUF_APPEND(", %sname=\"%s\"",
558 PRFIELD(event_class->name.value));
559 }
560
561 if (!extended) {
562 return;
563 }
564
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 }
572
573 if (event_class->emf_uri.value) {
574 BUF_APPEND(", %semf-uri=\"%s\"",
575 PRFIELD(event_class->emf_uri.value));
576 }
577
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));
581
582 stream_class = bt_event_class_borrow_stream_class_const(event_class);
583 if (!stream_class) {
584 return;
585 }
586
587 BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class));
588 SET_TMP_PREFIX("stream-class-");
589 format_stream_class(buf_ch, false, tmp_prefix, stream_class);
590 trace_class = bt_stream_class_borrow_trace_class_inline(stream_class);
591 if (!trace_class) {
592 return;
593 }
594
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);
598 SET_TMP_PREFIX("event-pool-");
599 format_object_pool(buf_ch, extended, tmp_prefix,
600 &event_class->event_pool);
601 }
602
603 static inline void format_stream(char **buf_ch, bool extended,
604 const char *prefix, const struct bt_stream *stream)
605 {
606 const struct bt_stream_class *stream_class;
607 const struct bt_trace_class *trace_class = NULL;
608 const struct bt_trace *trace = NULL;
609 char tmp_prefix[TMP_PREFIX_LEN];
610
611 BUF_APPEND(", %sid=%" PRIu64, PRFIELD(stream->id));
612
613 if (stream->name.value) {
614 BUF_APPEND(", %sname=\"%s\"", PRFIELD(stream->name.value));
615 }
616
617 if (!extended) {
618 return;
619 }
620
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);
627 }
628
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);
640 }
641
642 SET_TMP_PREFIX("packet-pool-");
643 format_object_pool(buf_ch, extended, tmp_prefix, &stream->packet_pool);
644 }
645
646 static inline void format_packet(char **buf_ch, bool extended,
647 const char *prefix, const struct bt_packet *packet)
648 {
649 const struct bt_stream *stream;
650 const struct bt_trace_class *trace_class;
651 char tmp_prefix[TMP_PREFIX_LEN];
652
653 if (!extended) {
654 return;
655 }
656
657 BUF_APPEND(", %sis-frozen=%d, %scontext-field-addr=%p",
658 PRFIELD(packet->frozen),
659 PRFIELD(packet->context_field ? packet->context_field->field : NULL));
660 stream = bt_packet_borrow_stream_const(packet);
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);
668 trace_class = (const struct bt_trace_class *) bt_object_borrow_parent(&stream->base);
669 if (!trace_class) {
670 return;
671 }
672
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);
676 }
677
678 static inline void format_event(char **buf_ch, bool extended,
679 const char *prefix, const struct bt_event *event)
680 {
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;
685 char tmp_prefix[TMP_PREFIX_LEN];
686
687 if (!extended) {
688 return;
689 }
690
691 BUF_APPEND(", %sis-frozen=%d, "
692 "%scommon-context-field-addr=%p, "
693 "%sspecific-context-field-addr=%p, "
694 "%spayload-field-addr=%p, ",
695 PRFIELD(event->frozen),
696 PRFIELD(event->common_context_field),
697 PRFIELD(event->specific_context_field),
698 PRFIELD(event->payload_field));
699 BUF_APPEND(", %sevent-class-addr=%p", PRFIELD(event->class));
700
701 if (!event->class) {
702 return;
703 }
704
705 SET_TMP_PREFIX("event-class-");
706 format_event_class(buf_ch, false, tmp_prefix, event->class);
707 stream_class = bt_event_class_borrow_stream_class(event->class);
708 if (stream_class) {
709 BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class));
710 SET_TMP_PREFIX("stream-class-");
711 format_stream_class(buf_ch, false, tmp_prefix,
712 stream_class);
713
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);
722 }
723 }
724
725 packet = bt_event_borrow_packet_const(event);
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);
733 stream = bt_packet_borrow_stream_const(packet);
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,
744 const char *prefix, const struct bt_clock_class *clock_class)
745 {
746 char tmp_prefix[TMP_PREFIX_LEN];
747
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));
753
754 if (!extended) {
755 return;
756 }
757
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);
765 }
766
767 BUF_APPEND(", %sis-frozen=%d, %sprecision=%" PRIu64 ", "
768 "%soffset-s=%" PRId64 ", "
769 "%soffset-cycles=%" PRIu64 ", %sorigin-is-unix-epoch=%d, "
770 "%sbase-offset-ns=%" PRId64,
771 PRFIELD(clock_class->frozen), PRFIELD(clock_class->precision),
772 PRFIELD(clock_class->offset_seconds),
773 PRFIELD(clock_class->offset_cycles),
774 PRFIELD(clock_class->origin_is_unix_epoch),
775 PRFIELD(clock_class->base_offset.value_ns));
776
777 SET_TMP_PREFIX("cs-pool-");
778 format_object_pool(buf_ch, extended, tmp_prefix,
779 &clock_class->cs_pool);
780 }
781
782 static inline void format_clock_snapshot(char **buf_ch, bool extended,
783 const char *prefix, const struct bt_clock_snapshot *clock_snapshot)
784 {
785 char tmp_prefix[TMP_PREFIX_LEN];
786 BUF_APPEND(", %svalue=%" PRIu64 ", %sns-from-origin=%" PRId64,
787 PRFIELD(clock_snapshot->value_cycles),
788 PRFIELD(clock_snapshot->ns_from_origin));
789
790 if (!extended) {
791 return;
792 }
793
794 BUF_APPEND(", %sis-set=%d", PRFIELD(clock_snapshot->is_set));
795
796 if (clock_snapshot->clock_class) {
797 BUF_APPEND(", %sclock-class-addr=%p",
798 PRFIELD(clock_snapshot->clock_class));
799 SET_TMP_PREFIX("clock-class-");
800 format_clock_class(buf_ch, false, tmp_prefix,
801 clock_snapshot->clock_class);
802 }
803 }
804
805 static inline void format_value(char **buf_ch, bool extended,
806 const char *prefix, const struct bt_value *value)
807 {
808 BUF_APPEND(", %stype=%s",
809 PRFIELD(bt_common_value_type_string(bt_value_get_type(value))));
810
811 if (!extended) {
812 return;
813 }
814
815 switch (bt_value_get_type(value)) {
816 case BT_VALUE_TYPE_BOOL:
817 {
818 bt_bool val = bt_value_bool_get(value);
819
820 BUF_APPEND(", %svalue=%d", PRFIELD(val));
821 break;
822 }
823 case BT_VALUE_TYPE_UNSIGNED_INTEGER:
824 {
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)));
833 break;
834 }
835 case BT_VALUE_TYPE_REAL:
836 {
837 double val = bt_value_real_get(value);
838
839 BUF_APPEND(", %svalue=%f", PRFIELD(val));
840 break;
841 }
842 case BT_VALUE_TYPE_STRING:
843 {
844 const char *val = bt_value_string_get(value);
845
846 BUF_APPEND(", %spartial-value=\"%.32s\"", PRFIELD(val));
847 break;
848 }
849 case BT_VALUE_TYPE_ARRAY:
850 {
851 int64_t count = bt_value_array_get_size(value);
852
853 BT_ASSERT(count >= 0);
854 BUF_APPEND(", %selement-count=%" PRId64, PRFIELD(count));
855 break;
856 }
857 case BT_VALUE_TYPE_MAP:
858 {
859 int64_t count = bt_value_map_get_size(value);
860
861 BT_ASSERT(count >= 0);
862 BUF_APPEND(", %selement-count=%" PRId64, PRFIELD(count));
863 break;
864 }
865 default:
866 break;
867 }
868 }
869
870 static inline void format_message(char **buf_ch, bool extended,
871 const char *prefix, const struct bt_message *msg)
872 {
873 char tmp_prefix[TMP_PREFIX_LEN];
874
875 BUF_APPEND(", %stype=%s",
876 PRFIELD(bt_message_type_string(msg->type)));
877
878 if (!extended) {
879 return;
880 }
881
882 BUF_APPEND(", %sis-frozen=%d, %sgraph-addr=%p",
883 PRFIELD(msg->frozen), PRFIELD(msg->graph));
884
885 switch (msg->type) {
886 case BT_MESSAGE_TYPE_EVENT:
887 {
888 const struct bt_message_event *msg_event =
889 (const void *) msg;
890
891 if (msg_event->event) {
892 SET_TMP_PREFIX("event-");
893 format_event(buf_ch, true, tmp_prefix,
894 msg_event->event);
895 }
896
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
903 break;
904 }
905 case BT_MESSAGE_TYPE_STREAM_BEGINNING:
906 case BT_MESSAGE_TYPE_STREAM_END:
907 {
908 const struct bt_message_stream *msg_stream = (const void *) msg;
909
910 if (msg_stream->stream) {
911 SET_TMP_PREFIX("stream-");
912 format_stream(buf_ch, true, tmp_prefix,
913 msg_stream->stream);
914 }
915
916 break;
917 }
918 case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING:
919 case BT_MESSAGE_TYPE_STREAM_ACTIVITY_END:
920 {
921 const struct bt_message_stream_activity *msg_stream_activity =
922 (const void *) msg;
923
924 if (msg_stream_activity->stream) {
925 SET_TMP_PREFIX("stream-");
926 format_stream(buf_ch, true, tmp_prefix,
927 msg_stream_activity->stream);
928 }
929
930 BUF_APPEND(", %sdefault-cs-state=%s",
931 PRFIELD(bt_message_stream_activity_clock_snapshot_state_string(
932 msg_stream_activity->default_cs_state)));
933
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);
938 }
939
940 break;
941 }
942 case BT_MESSAGE_TYPE_PACKET_BEGINNING:
943 case BT_MESSAGE_TYPE_PACKET_END:
944 {
945 const struct bt_message_packet *msg_packet = (const void *) msg;
946
947 if (msg_packet->packet) {
948 SET_TMP_PREFIX("packet-");
949 format_packet(buf_ch, true, tmp_prefix,
950 msg_packet->packet);
951 }
952
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
959 break;
960 }
961 case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
962 case BT_MESSAGE_TYPE_DISCARDED_PACKETS:
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 }
992 default:
993 break;
994 }
995 }
996
997 static inline void format_plugin_so_shared_lib_handle(char **buf_ch,
998 const char *prefix,
999 const struct bt_plugin_so_shared_lib_handle *handle)
1000 {
1001 BUF_APPEND(", %saddr=%p", PRFIELD(handle));
1002
1003 if (handle->path) {
1004 BUF_APPEND(", %spath=\"%s\"", PRFIELD_GSTRING(handle->path));
1005 }
1006 }
1007
1008 static inline void format_component_class(char **buf_ch, bool extended,
1009 const char *prefix,
1010 const struct bt_component_class *comp_class)
1011 {
1012 char tmp_prefix[TMP_PREFIX_LEN];
1013
1014 BUF_APPEND(", %stype=%s, %sname=\"%s\"",
1015 PRFIELD(bt_component_class_type_string(comp_class->type)),
1016 PRFIELD_GSTRING(comp_class->name));
1017
1018 if (comp_class->description) {
1019 BUF_APPEND(", %spartial-descr=\"%.32s\"",
1020 PRFIELD_GSTRING(comp_class->description));
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,
1037 const char *prefix, const struct bt_component *component)
1038 {
1039 char tmp_prefix[TMP_PREFIX_LEN];
1040
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 }
1049
1050 if (!extended) {
1051 return;
1052 }
1053
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 }
1063 }
1064
1065 static inline void format_port(char **buf_ch, bool extended,
1066 const char *prefix, const struct bt_port *port)
1067 {
1068 char tmp_prefix[TMP_PREFIX_LEN];
1069
1070 BUF_APPEND(", %stype=%s, %sname=\"%s\"",
1071 PRFIELD(bt_port_type_string(port->type)),
1072 PRFIELD_GSTRING(port->name));
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,
1085 const char *prefix, const struct bt_connection *connection)
1086 {
1087 char tmp_prefix[TMP_PREFIX_LEN];
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,
1107 const char *prefix, const struct bt_graph *graph)
1108 {
1109 char tmp_prefix[TMP_PREFIX_LEN];
1110
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)));
1116
1117 if (!extended) {
1118 return;
1119 }
1120
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 }
1130
1131 SET_TMP_PREFIX("en-pool-");
1132 format_object_pool(buf_ch, extended, tmp_prefix,
1133 &graph->event_msg_pool);
1134 SET_TMP_PREFIX("pbn-pool-");
1135 format_object_pool(buf_ch, extended, tmp_prefix,
1136 &graph->packet_begin_msg_pool);
1137 SET_TMP_PREFIX("pen-pool-");
1138 format_object_pool(buf_ch, extended, tmp_prefix,
1139 &graph->packet_end_msg_pool);
1140 }
1141
1142 static inline void format_message_iterator(char **buf_ch,
1143 bool extended, const char *prefix,
1144 const struct bt_message_iterator *iterator)
1145 {
1146 const char *type;
1147 char tmp_prefix[TMP_PREFIX_LEN];
1148
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";
1153 } else {
1154 type = "(unknown)";
1155 }
1156
1157 BUF_APPEND(", %stype=%s", PRFIELD(type));
1158
1159 switch (iterator->type) {
1160 case BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT:
1161 {
1162 const struct bt_self_component_port_input_message_iterator *
1163 port_in_iter = (const void *) iterator;
1164
1165 if (port_in_iter->upstream_component) {
1166 SET_TMP_PREFIX("upstream-comp-");
1167 format_component(buf_ch, false, tmp_prefix,
1168 port_in_iter->upstream_component);
1169 }
1170
1171 if (port_in_iter->upstream_port) {
1172 SET_TMP_PREFIX("upstream-port-");
1173 format_port(buf_ch, false, tmp_prefix,
1174 port_in_iter->upstream_port);
1175 }
1176
1177 if (port_in_iter->connection) {
1178 SET_TMP_PREFIX("upstream-conn-");
1179 format_connection(buf_ch, false, tmp_prefix,
1180 port_in_iter->connection);
1181 }
1182 break;
1183 }
1184 case BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT:
1185 {
1186 const struct bt_port_output_message_iterator *port_out_iter =
1187 (const void *) iterator;
1188
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
1201 break;
1202 }
1203 default:
1204 break;
1205 }
1206 }
1207
1208 static inline void format_plugin(char **buf_ch, bool extended,
1209 const char *prefix, const struct bt_plugin *plugin)
1210 {
1211 char tmp_prefix[TMP_PREFIX_LEN];
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\"",
1217 PRFIELD_GSTRING(plugin->info.path));
1218 }
1219
1220 if (plugin->info.name_set) {
1221 BUF_APPEND(", %sname=\"%s\"",
1222 PRFIELD_GSTRING(plugin->info.name));
1223 }
1224
1225 if (!extended) {
1226 return;
1227 }
1228
1229 if (plugin->info.author_set) {
1230 BUF_APPEND(", %sauthor=\"%s\"",
1231 PRFIELD_GSTRING(plugin->info.author));
1232 }
1233
1234 if (plugin->info.license_set) {
1235 BUF_APPEND(", %slicense=\"%s\"",
1236 PRFIELD_GSTRING(plugin->info.license));
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
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));
1253
1254 if (plugin->spec_data) {
1255 const struct bt_plugin_so_spec_data *spec_data =
1256 (const void *) plugin->spec_data;
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
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;
1274 const void *obj;
1275
1276 /* skip "%!" */
1277 fmt_ch += 2;
1278
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
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
1317 switch (*fmt_ch) {
1318 case 'F':
1319 format_field_class(buf_ch, extended, prefix, obj);
1320 break;
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);
1335 break;
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;
1345 case 'T':
1346 format_trace_class(buf_ch, extended, prefix, obj);
1347 break;
1348 case 'K':
1349 format_clock_class(buf_ch, extended, prefix, obj);
1350 break;
1351 case 'k':
1352 format_clock_snapshot(buf_ch, extended, prefix, obj);
1353 break;
1354 case 'v':
1355 format_value(buf_ch, extended, prefix, obj);
1356 break;
1357 case 'n':
1358 format_message(buf_ch, extended, prefix, obj);
1359 break;
1360 case 'i':
1361 format_message_iterator(buf_ch, extended, prefix, obj);
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;
1375 case 'l':
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();
1389 }
1390
1391 update_fmt:
1392 fmt_ch++;
1393 *out_fmt_ch = fmt_ch;
1394 }
1395
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
1401 BT_ASSERT(fmt);
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 }
This page took 0.064227 seconds and 4 git commands to generate.