4 * Babeltrace CTF Text Output Plugin Event Printing
6 * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
7 * Copyright 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 #include <babeltrace/ctf-ir/event.h>
31 #include <babeltrace/ctf-ir/event-class.h>
32 #include <babeltrace/ctf-ir/packet.h>
33 #include <babeltrace/ctf-ir/stream.h>
34 #include <babeltrace/ctf-ir/stream-class.h>
35 #include <babeltrace/ctf-ir/clock-class.h>
36 #include <babeltrace/ctf-ir/field-types.h>
37 #include <babeltrace/ctf-ir/fields.h>
38 #include <babeltrace/ctf-ir/trace.h>
39 #include <babeltrace/graph/notification-event.h>
40 #include <babeltrace/graph/notification-discarded-events.h>
41 #include <babeltrace/graph/notification-discarded-packets.h>
42 #include <babeltrace/graph/clock-class-priority-map.h>
43 #include <babeltrace/bitfield-internal.h>
44 #include <babeltrace/common-internal.h>
45 #include <babeltrace/compat/time-internal.h>
50 #define NSEC_PER_SEC 1000000000LL
52 #define COLOR_NAME BT_COMMON_COLOR_BOLD
53 #define COLOR_FIELD_NAME BT_COMMON_COLOR_FG_CYAN
54 #define COLOR_RST BT_COMMON_COLOR_RESET
55 #define COLOR_STRING_VALUE BT_COMMON_COLOR_BOLD
56 #define COLOR_NUMBER_VALUE BT_COMMON_COLOR_BOLD
57 #define COLOR_ENUM_MAPPING_NAME BT_COMMON_COLOR_BOLD
58 #define COLOR_UNKNOWN BT_COMMON_COLOR_BOLD BT_COMMON_COLOR_FG_RED
59 #define COLOR_EVENT_NAME BT_COMMON_COLOR_BOLD BT_COMMON_COLOR_FG_MAGENTA
60 #define COLOR_TIMESTAMP BT_COMMON_COLOR_BOLD BT_COMMON_COLOR_FG_YELLOW
63 const char *rem_(const char *str
)
72 int64_t real_timestamp
; /* Relative to UNIX epoch. */
73 uint64_t clock_value
; /* In cycles. */
77 enum bt_component_status
print_field(struct pretty_component
*pretty
,
78 struct bt_ctf_field
*field
, bool print_names
,
79 GQuark
*filters_fields
, int filter_array_len
);
82 void print_name_equal(struct pretty_component
*pretty
, const char *name
)
84 if (pretty
->use_colors
) {
85 g_string_append_printf(pretty
->string
, "%s%s%s = ", COLOR_NAME
,
88 g_string_append_printf(pretty
->string
, "%s = ", name
);
93 void print_field_name_equal(struct pretty_component
*pretty
, const char *name
)
95 if (pretty
->use_colors
) {
96 g_string_append_printf(pretty
->string
, "%s%s%s = ",
97 COLOR_FIELD_NAME
, name
, COLOR_RST
);
99 g_string_append_printf(pretty
->string
, "%s = ", name
);
104 void print_timestamp_cycles(struct pretty_component
*pretty
,
105 struct bt_ctf_clock_class
*clock_class
,
106 struct bt_ctf_event
*event
)
109 struct bt_ctf_clock_value
*clock_value
;
112 clock_value
= bt_ctf_event_get_clock_value(event
, clock_class
);
114 g_string_append(pretty
->string
, "????????????????????");
118 ret
= bt_ctf_clock_value_get_value(clock_value
, &cycles
);
121 // TODO: log, this is unexpected
122 g_string_append(pretty
->string
, "Error");
126 g_string_append_printf(pretty
->string
, "%020" PRIu64
, cycles
);
128 if (pretty
->last_cycles_timestamp
!= -1ULL) {
129 pretty
->delta_cycles
= cycles
- pretty
->last_cycles_timestamp
;
131 pretty
->last_cycles_timestamp
= cycles
;
135 void print_timestamp_wall(struct pretty_component
*pretty
,
136 struct bt_ctf_clock_value
*clock_value
)
139 int64_t ts_nsec
= 0; /* add configurable offset */
140 int64_t ts_sec
= 0; /* add configurable offset */
141 uint64_t ts_sec_abs
, ts_nsec_abs
;
145 g_string_append(pretty
->string
, "??:??:??.?????????");
149 ret
= bt_ctf_clock_value_get_value_ns_from_epoch(clock_value
, &ts_nsec
);
151 // TODO: log, this is unexpected
152 g_string_append(pretty
->string
, "Error");
156 if (pretty
->last_real_timestamp
!= -1ULL) {
157 pretty
->delta_real_timestamp
= ts_nsec
- pretty
->last_real_timestamp
;
160 pretty
->last_real_timestamp
= ts_nsec
;
161 ts_sec
+= ts_nsec
/ NSEC_PER_SEC
;
162 ts_nsec
= ts_nsec
% NSEC_PER_SEC
;
164 if (ts_sec
>= 0 && ts_nsec
>= 0) {
167 ts_nsec_abs
= ts_nsec
;
168 } else if (ts_sec
> 0 && ts_nsec
< 0) {
170 ts_sec_abs
= ts_sec
- 1;
171 ts_nsec_abs
= NSEC_PER_SEC
+ ts_nsec
;
172 } else if (ts_sec
== 0 && ts_nsec
< 0) {
175 ts_nsec_abs
= -ts_nsec
;
176 } else if (ts_sec
< 0 && ts_nsec
> 0) {
178 ts_sec_abs
= -(ts_sec
+ 1);
179 ts_nsec_abs
= NSEC_PER_SEC
- ts_nsec
;
180 } else if (ts_sec
< 0 && ts_nsec
== 0) {
182 ts_sec_abs
= -ts_sec
;
183 ts_nsec_abs
= ts_nsec
;
184 } else { /* (ts_sec < 0 && ts_nsec < 0) */
186 ts_sec_abs
= -ts_sec
;
187 ts_nsec_abs
= -ts_nsec
;
190 if (!pretty
->options
.clock_seconds
) {
192 time_t time_s
= (time_t) ts_sec_abs
;
196 fprintf(stderr
, "[warning] Fallback to [sec.ns] to print negative time value. Use --clock-seconds.\n");
200 if (!pretty
->options
.clock_gmt
) {
203 res
= bt_localtime_r(&time_s
, &tm
);
206 fprintf(stderr
, "[warning] Unable to get localtime.\n");
212 res
= bt_gmtime_r(&time_s
, &tm
);
215 fprintf(stderr
, "[warning] Unable to get gmtime.\n");
219 if (pretty
->options
.clock_date
) {
223 /* Print date and time */
224 res
= strftime(timestr
, sizeof(timestr
),
228 fprintf(stderr
, "[warning] Unable to print ascii time.\n");
232 g_string_append(pretty
->string
, timestr
);
235 /* Print time in HH:MM:SS.ns */
236 g_string_append_printf(pretty
->string
,
237 "%02d:%02d:%02d.%09" PRIu64
, tm
.tm_hour
, tm
.tm_min
,
238 tm
.tm_sec
, ts_nsec_abs
);
242 g_string_append_printf(pretty
->string
, "%s%" PRId64
".%09" PRIu64
,
243 is_negative
? "-" : "", ts_sec_abs
, ts_nsec_abs
);
249 enum bt_component_status
print_event_timestamp(struct pretty_component
*pretty
,
250 struct bt_ctf_event
*event
,
251 struct bt_clock_class_priority_map
*cc_prio_map
,
254 bool print_names
= pretty
->options
.print_header_field_names
;
255 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
256 struct bt_ctf_stream
*stream
= NULL
;
257 struct bt_ctf_stream_class
*stream_class
= NULL
;
258 struct bt_ctf_trace
*trace
= NULL
;
259 struct bt_ctf_clock_class
*clock_class
= NULL
;
261 stream
= bt_ctf_event_get_stream(event
);
263 ret
= BT_COMPONENT_STATUS_ERROR
;
267 stream_class
= bt_ctf_stream_get_class(stream
);
269 ret
= BT_COMPONENT_STATUS_ERROR
;
272 trace
= bt_ctf_stream_class_get_trace(stream_class
);
274 ret
= BT_COMPONENT_STATUS_ERROR
;
278 if (bt_clock_class_priority_map_get_clock_class_count(cc_prio_map
) == 0) {
279 /* No clock class: skip the timestamp without an error */
284 bt_clock_class_priority_map_get_highest_priority_clock_class(
287 ret
= BT_COMPONENT_STATUS_ERROR
;
292 print_name_equal(pretty
, "timestamp");
294 g_string_append(pretty
->string
, "[");
296 if (pretty
->use_colors
) {
297 g_string_append(pretty
->string
, COLOR_TIMESTAMP
);
299 if (pretty
->options
.print_timestamp_cycles
) {
300 print_timestamp_cycles(pretty
, clock_class
, event
);
302 struct bt_ctf_clock_value
*clock_value
=
303 bt_ctf_event_get_clock_value(event
, clock_class
);
305 print_timestamp_wall(pretty
, clock_value
);
308 if (pretty
->use_colors
) {
309 g_string_append(pretty
->string
, COLOR_RST
);
313 g_string_append(pretty
->string
, "] ");
315 if (pretty
->options
.print_delta_field
) {
317 g_string_append(pretty
->string
, ", ");
318 print_name_equal(pretty
, "delta");
320 g_string_append(pretty
->string
, "(");
322 if (pretty
->options
.print_timestamp_cycles
) {
323 if (pretty
->delta_cycles
== -1ULL) {
324 g_string_append(pretty
->string
,
325 "+??????????\?\?) "); /* Not a trigraph. */
327 g_string_append_printf(pretty
->string
,
328 "+%012" PRIu64
, pretty
->delta_cycles
);
331 if (pretty
->delta_real_timestamp
!= -1ULL) {
332 uint64_t delta_sec
, delta_nsec
, delta
;
334 delta
= pretty
->delta_real_timestamp
;
335 delta_sec
= delta
/ NSEC_PER_SEC
;
336 delta_nsec
= delta
% NSEC_PER_SEC
;
337 g_string_append_printf(pretty
->string
,
338 "+%" PRIu64
".%09" PRIu64
,
339 delta_sec
, delta_nsec
);
341 g_string_append(pretty
->string
, "+?.?????????");
345 g_string_append(pretty
->string
, ") ");
348 *start_line
= !print_names
;
353 bt_put(stream_class
);
359 enum bt_component_status
print_event_header(struct pretty_component
*pretty
,
360 struct bt_ctf_event
*event
,
361 struct bt_clock_class_priority_map
*cc_prio_map
)
363 bool print_names
= pretty
->options
.print_header_field_names
;
364 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
365 struct bt_ctf_event_class
*event_class
= NULL
;
366 struct bt_ctf_stream_class
*stream_class
= NULL
;
367 struct bt_ctf_trace
*trace_class
= NULL
;
370 event_class
= bt_ctf_event_get_class(event
);
372 ret
= BT_COMPONENT_STATUS_ERROR
;
375 stream_class
= bt_ctf_event_class_get_stream_class(event_class
);
377 ret
= BT_COMPONENT_STATUS_ERROR
;
380 trace_class
= bt_ctf_stream_class_get_trace(stream_class
);
382 ret
= BT_COMPONENT_STATUS_ERROR
;
385 ret
= print_event_timestamp(pretty
, event
, cc_prio_map
,
386 &pretty
->start_line
);
387 if (ret
!= BT_COMPONENT_STATUS_OK
) {
390 if (pretty
->options
.print_trace_field
) {
393 name
= bt_ctf_trace_get_name(trace_class
);
395 if (!pretty
->start_line
) {
396 g_string_append(pretty
->string
, ", ");
399 print_name_equal(pretty
, "trace");
402 g_string_append(pretty
->string
, name
);
405 g_string_append(pretty
->string
, " ");
409 if (pretty
->options
.print_trace_hostname_field
) {
410 struct bt_value
*hostname_str
;
412 hostname_str
= bt_ctf_trace_get_environment_field_value_by_name(trace_class
,
417 if (!pretty
->start_line
) {
418 g_string_append(pretty
->string
, ", ");
421 print_name_equal(pretty
, "trace:hostname");
423 if (bt_value_string_get(hostname_str
, &str
)
424 == BT_VALUE_STATUS_OK
) {
425 g_string_append(pretty
->string
, str
);
427 bt_put(hostname_str
);
431 if (pretty
->options
.print_trace_domain_field
) {
432 struct bt_value
*domain_str
;
434 domain_str
= bt_ctf_trace_get_environment_field_value_by_name(trace_class
,
439 if (!pretty
->start_line
) {
440 g_string_append(pretty
->string
, ", ");
443 print_name_equal(pretty
, "trace:domain");
444 } else if (dom_print
) {
445 g_string_append(pretty
->string
, ":");
447 if (bt_value_string_get(domain_str
, &str
)
448 == BT_VALUE_STATUS_OK
) {
449 g_string_append(pretty
->string
, str
);
455 if (pretty
->options
.print_trace_procname_field
) {
456 struct bt_value
*procname_str
;
458 procname_str
= bt_ctf_trace_get_environment_field_value_by_name(trace_class
,
463 if (!pretty
->start_line
) {
464 g_string_append(pretty
->string
, ", ");
467 print_name_equal(pretty
, "trace:procname");
468 } else if (dom_print
) {
469 g_string_append(pretty
->string
, ":");
471 if (bt_value_string_get(procname_str
, &str
)
472 == BT_VALUE_STATUS_OK
) {
473 g_string_append(pretty
->string
, str
);
475 bt_put(procname_str
);
479 if (pretty
->options
.print_trace_vpid_field
) {
480 struct bt_value
*vpid_value
;
482 vpid_value
= bt_ctf_trace_get_environment_field_value_by_name(trace_class
,
487 if (!pretty
->start_line
) {
488 g_string_append(pretty
->string
, ", ");
491 print_name_equal(pretty
, "trace:vpid");
492 } else if (dom_print
) {
493 g_string_append(pretty
->string
, ":");
495 if (bt_value_integer_get(vpid_value
, &value
)
496 == BT_VALUE_STATUS_OK
) {
497 g_string_append_printf(pretty
->string
, "(%" PRId64
")", value
);
503 if (pretty
->options
.print_loglevel_field
) {
504 static const char *log_level_names
[] = {
505 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_EMERGENCY
] = "TRACE_EMERG",
506 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_ALERT
] = "TRACE_ALERT",
507 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_CRITICAL
] = "TRACE_CRIT",
508 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_ERROR
] = "TRACE_ERR",
509 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_WARNING
] = "TRACE_WARNING",
510 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_NOTICE
] = "TRACE_NOTICE",
511 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_INFO
] = "TRACE_INFO",
512 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM
] = "TRACE_DEBUG_SYSTEM",
513 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM
] = "TRACE_DEBUG_PROGRAM",
514 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS
] = "TRACE_DEBUG_PROCESS",
515 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE
] = "TRACE_DEBUG_MODULE",
516 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT
] = "TRACE_DEBUG_UNIT",
517 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION
] = "TRACE_DEBUG_FUNCTION",
518 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE
] = "TRACE_DEBUG_LINE",
519 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG
] = "TRACE_DEBUG",
521 enum bt_ctf_event_class_log_level log_level
;
522 const char *log_level_str
= NULL
;
524 log_level
= bt_ctf_event_class_get_log_level(event_class
);
525 assert(log_level
!= BT_CTF_EVENT_CLASS_LOG_LEVEL_UNKNOWN
);
526 if (log_level
!= BT_CTF_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED
) {
527 log_level_str
= log_level_names
[log_level
];
531 if (!pretty
->start_line
) {
532 g_string_append(pretty
->string
, ", ");
535 print_name_equal(pretty
, "loglevel");
536 } else if (dom_print
) {
537 g_string_append(pretty
->string
, ":");
540 g_string_append(pretty
->string
, log_level_str
);
541 g_string_append_printf(
542 pretty
->string
, " (%d)", (int) log_level
);
546 if (pretty
->options
.print_emf_field
) {
549 uri_str
= bt_ctf_event_class_get_emf_uri(event_class
);
551 if (!pretty
->start_line
) {
552 g_string_append(pretty
->string
, ", ");
555 print_name_equal(pretty
, "model.emf.uri");
556 } else if (dom_print
) {
557 g_string_append(pretty
->string
, ":");
560 g_string_append(pretty
->string
, uri_str
);
564 if (dom_print
&& !print_names
) {
565 g_string_append(pretty
->string
, " ");
567 if (!pretty
->start_line
) {
568 g_string_append(pretty
->string
, ", ");
570 pretty
->start_line
= true;
572 print_name_equal(pretty
, "name");
574 if (pretty
->use_colors
) {
575 g_string_append(pretty
->string
, COLOR_EVENT_NAME
);
577 g_string_append(pretty
->string
, bt_ctf_event_class_get_name(event_class
));
578 if (pretty
->use_colors
) {
579 g_string_append(pretty
->string
, COLOR_RST
);
582 g_string_append(pretty
->string
, ": ");
584 g_string_append(pretty
->string
, ", ");
588 bt_put(stream_class
);
594 enum bt_component_status
print_integer(struct pretty_component
*pretty
,
595 struct bt_ctf_field
*field
)
597 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
598 struct bt_ctf_field_type
*field_type
= NULL
;
599 enum bt_ctf_integer_base base
;
600 enum bt_ctf_string_encoding encoding
;
606 bool rst_color
= false;
608 field_type
= bt_ctf_field_get_type(field
);
610 ret
= BT_COMPONENT_STATUS_ERROR
;
613 signedness
= bt_ctf_field_type_integer_get_signed(field_type
);
614 if (signedness
< 0) {
615 ret
= BT_COMPONENT_STATUS_ERROR
;
619 if (bt_ctf_field_unsigned_integer_get_value(field
, &v
.u
) < 0) {
620 ret
= BT_COMPONENT_STATUS_ERROR
;
624 if (bt_ctf_field_signed_integer_get_value(field
, &v
.s
) < 0) {
625 ret
= BT_COMPONENT_STATUS_ERROR
;
630 encoding
= bt_ctf_field_type_integer_get_encoding(field_type
);
632 case BT_CTF_STRING_ENCODING_UTF8
:
633 case BT_CTF_STRING_ENCODING_ASCII
:
634 g_string_append_c(pretty
->tmp_string
, (int) v
.u
);
636 case BT_CTF_STRING_ENCODING_NONE
:
637 case BT_CTF_STRING_ENCODING_UNKNOWN
:
640 ret
= BT_COMPONENT_STATUS_ERROR
;
644 if (pretty
->use_colors
) {
645 g_string_append(pretty
->string
, COLOR_NUMBER_VALUE
);
649 base
= bt_ctf_field_type_integer_get_base(field_type
);
651 case BT_CTF_INTEGER_BASE_BINARY
:
655 len
= bt_ctf_field_type_integer_get_size(field_type
);
657 ret
= BT_COMPONENT_STATUS_ERROR
;
660 g_string_append(pretty
->string
, "0b");
661 v
.u
= _bt_piecewise_lshift(v
.u
, 64 - len
);
662 for (bitnr
= 0; bitnr
< len
; bitnr
++) {
663 g_string_append_printf(pretty
->string
, "%u", (v
.u
& (1ULL << 63)) ? 1 : 0);
664 v
.u
= _bt_piecewise_lshift(v
.u
, 1);
668 case BT_CTF_INTEGER_BASE_OCTAL
:
673 len
= bt_ctf_field_type_integer_get_size(field_type
);
675 ret
= BT_COMPONENT_STATUS_ERROR
;
682 /* Round length to the nearest 3-bit */
683 rounded_len
= (((len
- 1) / 3) + 1) * 3;
684 v
.u
&= ((uint64_t) 1 << rounded_len
) - 1;
688 g_string_append_printf(pretty
->string
, "0%" PRIo64
, v
.u
);
691 case BT_CTF_INTEGER_BASE_DECIMAL
:
692 case BT_CTF_INTEGER_BASE_UNSPECIFIED
:
694 g_string_append_printf(pretty
->string
, "%" PRIu64
, v
.u
);
696 g_string_append_printf(pretty
->string
, "%" PRId64
, v
.s
);
699 case BT_CTF_INTEGER_BASE_HEXADECIMAL
:
703 len
= bt_ctf_field_type_integer_get_size(field_type
);
705 ret
= BT_COMPONENT_STATUS_ERROR
;
709 /* Round length to the nearest nibble */
710 uint8_t rounded_len
= ((len
+ 3) & ~0x3);
712 v
.u
&= ((uint64_t) 1 << rounded_len
) - 1;
715 g_string_append_printf(pretty
->string
, "0x%" PRIX64
, v
.u
);
719 ret
= BT_COMPONENT_STATUS_ERROR
;
724 g_string_append(pretty
->string
, COLOR_RST
);
731 void print_escape_string(struct pretty_component
*pretty
, const char *str
)
735 g_string_append_c(pretty
->string
, '"');
737 for (i
= 0; i
< strlen(str
); i
++) {
738 /* Escape sequences not recognized by iscntrl(). */
741 g_string_append(pretty
->string
, "\\\\");
744 g_string_append(pretty
->string
, "\\\'");
747 g_string_append(pretty
->string
, "\\\"");
750 g_string_append(pretty
->string
, "\\\?");
754 /* Standard characters. */
755 if (!iscntrl(str
[i
])) {
756 g_string_append_c(pretty
->string
, str
[i
]);
762 g_string_append(pretty
->string
, "\\0");
765 g_string_append(pretty
->string
, "\\a");
768 g_string_append(pretty
->string
, "\\b");
771 g_string_append(pretty
->string
, "\\e");
774 g_string_append(pretty
->string
, "\\f");
777 g_string_append(pretty
->string
, "\\n");
780 g_string_append(pretty
->string
, "\\r");
783 g_string_append(pretty
->string
, "\\t");
786 g_string_append(pretty
->string
, "\\v");
789 /* Unhandled control-sequence, print as hex. */
790 g_string_append_printf(pretty
->string
, "\\x%02x", str
[i
]);
795 g_string_append_c(pretty
->string
, '"');
799 enum bt_component_status
print_enum(struct pretty_component
*pretty
,
800 struct bt_ctf_field
*field
)
802 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
803 struct bt_ctf_field
*container_field
= NULL
;
804 struct bt_ctf_field_type
*enumeration_field_type
= NULL
;
805 struct bt_ctf_field_type
*container_field_type
= NULL
;
806 struct bt_ctf_field_type_enumeration_mapping_iterator
*iter
= NULL
;
810 enumeration_field_type
= bt_ctf_field_get_type(field
);
811 if (!enumeration_field_type
) {
812 ret
= BT_COMPONENT_STATUS_ERROR
;
815 container_field
= bt_ctf_field_enumeration_get_container(field
);
816 if (!container_field
) {
817 ret
= BT_COMPONENT_STATUS_ERROR
;
820 container_field_type
= bt_ctf_field_get_type(container_field
);
821 if (!container_field_type
) {
822 ret
= BT_COMPONENT_STATUS_ERROR
;
825 is_signed
= bt_ctf_field_type_integer_get_signed(container_field_type
);
827 ret
= BT_COMPONENT_STATUS_ERROR
;
833 if (bt_ctf_field_signed_integer_get_value(container_field
,
835 ret
= BT_COMPONENT_STATUS_ERROR
;
838 iter
= bt_ctf_field_type_enumeration_find_mappings_by_signed_value(
839 enumeration_field_type
, value
);
843 if (bt_ctf_field_unsigned_integer_get_value(container_field
,
845 ret
= BT_COMPONENT_STATUS_ERROR
;
848 iter
= bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value(
849 enumeration_field_type
, value
);
852 ret
= BT_COMPONENT_STATUS_ERROR
;
855 g_string_append(pretty
->string
, "( ");
857 const char *mapping_name
;
859 if (bt_ctf_field_type_enumeration_mapping_iterator_get_signed(
860 iter
, &mapping_name
, NULL
, NULL
) < 0) {
861 ret
= BT_COMPONENT_STATUS_ERROR
;
865 g_string_append(pretty
->string
, ", ");
866 if (pretty
->use_colors
) {
867 g_string_append(pretty
->string
, COLOR_ENUM_MAPPING_NAME
);
869 print_escape_string(pretty
, mapping_name
);
870 if (pretty
->use_colors
) {
871 g_string_append(pretty
->string
, COLOR_RST
);
873 if (bt_ctf_field_type_enumeration_mapping_iterator_next(iter
) < 0) {
878 if (pretty
->use_colors
) {
879 g_string_append(pretty
->string
, COLOR_UNKNOWN
);
881 g_string_append(pretty
->string
, "<unknown>");
882 if (pretty
->use_colors
) {
883 g_string_append(pretty
->string
, COLOR_RST
);
886 g_string_append(pretty
->string
, " : container = ");
887 ret
= print_integer(pretty
, container_field
);
888 if (ret
!= BT_COMPONENT_STATUS_OK
) {
891 g_string_append(pretty
->string
, " )");
894 bt_put(container_field_type
);
895 bt_put(container_field
);
896 bt_put(enumeration_field_type
);
901 int filter_field_name(struct pretty_component
*pretty
, const char *field_name
,
902 GQuark
*filter_fields
, int filter_array_len
)
905 GQuark field_quark
= g_quark_try_string(field_name
);
907 if (!field_quark
|| pretty
->options
.verbose
) {
911 for (i
= 0; i
< filter_array_len
; i
++) {
912 if (field_quark
== filter_fields
[i
]) {
920 enum bt_component_status
print_struct_field(struct pretty_component
*pretty
,
921 struct bt_ctf_field
*_struct
,
922 struct bt_ctf_field_type
*struct_type
,
923 int i
, bool print_names
, int *nr_printed_fields
,
924 GQuark
*filter_fields
, int filter_array_len
)
926 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
927 const char *field_name
;
928 struct bt_ctf_field
*field
= NULL
;
929 struct bt_ctf_field_type
*field_type
= NULL
;;
931 field
= bt_ctf_field_structure_get_field_by_index(_struct
, i
);
933 ret
= BT_COMPONENT_STATUS_ERROR
;
936 if (bt_ctf_field_type_structure_get_field(struct_type
,
937 &field_name
, &field_type
, i
) < 0) {
938 ret
= BT_COMPONENT_STATUS_ERROR
;
942 if (filter_fields
&& !filter_field_name(pretty
, field_name
,
943 filter_fields
, filter_array_len
)) {
944 ret
= BT_COMPONENT_STATUS_OK
;
948 if (*nr_printed_fields
> 0) {
949 g_string_append(pretty
->string
, ", ");
951 g_string_append(pretty
->string
, " ");
954 print_field_name_equal(pretty
, rem_(field_name
));
956 ret
= print_field(pretty
, field
, print_names
, NULL
, 0);
957 *nr_printed_fields
+= 1;
965 enum bt_component_status
print_struct(struct pretty_component
*pretty
,
966 struct bt_ctf_field
*_struct
, bool print_names
,
967 GQuark
*filter_fields
, int filter_array_len
)
969 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
970 struct bt_ctf_field_type
*struct_type
= NULL
;
971 int nr_fields
, i
, nr_printed_fields
;
973 struct_type
= bt_ctf_field_get_type(_struct
);
975 ret
= BT_COMPONENT_STATUS_ERROR
;
978 nr_fields
= bt_ctf_field_type_structure_get_field_count(struct_type
);
980 ret
= BT_COMPONENT_STATUS_ERROR
;
983 g_string_append(pretty
->string
, "{");
985 nr_printed_fields
= 0;
986 for (i
= 0; i
< nr_fields
; i
++) {
987 ret
= print_struct_field(pretty
, _struct
, struct_type
, i
,
988 print_names
, &nr_printed_fields
, filter_fields
,
990 if (ret
!= BT_COMPONENT_STATUS_OK
) {
995 g_string_append(pretty
->string
, " }");
1002 enum bt_component_status
print_array_field(struct pretty_component
*pretty
,
1003 struct bt_ctf_field
*array
, uint64_t i
,
1004 bool is_string
, bool print_names
)
1006 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1007 struct bt_ctf_field
*field
= NULL
;
1011 g_string_append(pretty
->string
, ", ");
1013 g_string_append(pretty
->string
, " ");
1016 g_string_append_printf(pretty
->string
, "[%" PRIu64
"] = ", i
);
1019 field
= bt_ctf_field_array_get_field(array
, i
);
1021 ret
= BT_COMPONENT_STATUS_ERROR
;
1024 ret
= print_field(pretty
, field
, print_names
, NULL
, 0);
1031 enum bt_component_status
print_array(struct pretty_component
*pretty
,
1032 struct bt_ctf_field
*array
, bool print_names
)
1034 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1035 struct bt_ctf_field_type
*array_type
= NULL
, *field_type
= NULL
;
1036 enum bt_ctf_field_type_id type_id
;
1039 bool is_string
= false;
1041 array_type
= bt_ctf_field_get_type(array
);
1043 ret
= BT_COMPONENT_STATUS_ERROR
;
1046 field_type
= bt_ctf_field_type_array_get_element_type(array_type
);
1048 ret
= BT_COMPONENT_STATUS_ERROR
;
1051 len
= bt_ctf_field_type_array_get_length(array_type
);
1053 ret
= BT_COMPONENT_STATUS_ERROR
;
1056 type_id
= bt_ctf_field_type_get_type_id(field_type
);
1057 if (type_id
== BT_CTF_FIELD_TYPE_ID_INTEGER
) {
1058 enum bt_ctf_string_encoding encoding
;
1060 encoding
= bt_ctf_field_type_integer_get_encoding(field_type
);
1061 if (encoding
== BT_CTF_STRING_ENCODING_UTF8
1062 || encoding
== BT_CTF_STRING_ENCODING_ASCII
) {
1063 int integer_len
, integer_alignment
;
1065 integer_len
= bt_ctf_field_type_integer_get_size(field_type
);
1066 if (integer_len
< 0) {
1067 return BT_COMPONENT_STATUS_ERROR
;
1069 integer_alignment
= bt_ctf_field_type_get_alignment(field_type
);
1070 if (integer_alignment
< 0) {
1071 return BT_COMPONENT_STATUS_ERROR
;
1073 if (integer_len
== CHAR_BIT
1074 && integer_alignment
== CHAR_BIT
) {
1081 g_string_assign(pretty
->tmp_string
, "");
1083 g_string_append(pretty
->string
, "[");
1087 for (i
= 0; i
< len
; i
++) {
1088 ret
= print_array_field(pretty
, array
, i
, is_string
, print_names
);
1089 if (ret
!= BT_COMPONENT_STATUS_OK
) {
1096 if (pretty
->use_colors
) {
1097 g_string_append(pretty
->string
, COLOR_STRING_VALUE
);
1099 print_escape_string(pretty
, pretty
->tmp_string
->str
);
1100 if (pretty
->use_colors
) {
1101 g_string_append(pretty
->string
, COLOR_RST
);
1104 g_string_append(pretty
->string
, " ]");
1113 enum bt_component_status
print_sequence_field(struct pretty_component
*pretty
,
1114 struct bt_ctf_field
*seq
, uint64_t i
,
1115 bool is_string
, bool print_names
)
1117 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1118 struct bt_ctf_field
*field
= NULL
;
1122 g_string_append(pretty
->string
, ", ");
1124 g_string_append(pretty
->string
, " ");
1127 g_string_append_printf(pretty
->string
, "[%" PRIu64
"] = ", i
);
1130 field
= bt_ctf_field_sequence_get_field(seq
, i
);
1132 ret
= BT_COMPONENT_STATUS_ERROR
;
1135 ret
= print_field(pretty
, field
, print_names
, NULL
, 0);
1142 enum bt_component_status
print_sequence(struct pretty_component
*pretty
,
1143 struct bt_ctf_field
*seq
, bool print_names
)
1145 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1146 struct bt_ctf_field_type
*seq_type
= NULL
, *field_type
= NULL
;
1147 struct bt_ctf_field
*length_field
= NULL
;
1148 enum bt_ctf_field_type_id type_id
;
1151 bool is_string
= false;
1153 seq_type
= bt_ctf_field_get_type(seq
);
1155 ret
= BT_COMPONENT_STATUS_ERROR
;
1158 length_field
= bt_ctf_field_sequence_get_length(seq
);
1159 if (!length_field
) {
1160 ret
= BT_COMPONENT_STATUS_ERROR
;
1163 if (bt_ctf_field_unsigned_integer_get_value(length_field
, &len
) < 0) {
1164 ret
= BT_COMPONENT_STATUS_ERROR
;
1167 field_type
= bt_ctf_field_type_sequence_get_element_type(seq_type
);
1169 ret
= BT_COMPONENT_STATUS_ERROR
;
1172 type_id
= bt_ctf_field_type_get_type_id(field_type
);
1173 if (type_id
== BT_CTF_FIELD_TYPE_ID_INTEGER
) {
1174 enum bt_ctf_string_encoding encoding
;
1176 encoding
= bt_ctf_field_type_integer_get_encoding(field_type
);
1177 if (encoding
== BT_CTF_STRING_ENCODING_UTF8
1178 || encoding
== BT_CTF_STRING_ENCODING_ASCII
) {
1179 int integer_len
, integer_alignment
;
1181 integer_len
= bt_ctf_field_type_integer_get_size(field_type
);
1182 if (integer_len
< 0) {
1183 ret
= BT_COMPONENT_STATUS_ERROR
;
1186 integer_alignment
= bt_ctf_field_type_get_alignment(field_type
);
1187 if (integer_alignment
< 0) {
1188 ret
= BT_COMPONENT_STATUS_ERROR
;
1191 if (integer_len
== CHAR_BIT
1192 && integer_alignment
== CHAR_BIT
) {
1199 g_string_assign(pretty
->tmp_string
, "");
1201 g_string_append(pretty
->string
, "[");
1205 for (i
= 0; i
< len
; i
++) {
1206 ret
= print_sequence_field(pretty
, seq
, i
,
1207 is_string
, print_names
);
1208 if (ret
!= BT_COMPONENT_STATUS_OK
) {
1215 if (pretty
->use_colors
) {
1216 g_string_append(pretty
->string
, COLOR_STRING_VALUE
);
1218 print_escape_string(pretty
, pretty
->tmp_string
->str
);
1219 if (pretty
->use_colors
) {
1220 g_string_append(pretty
->string
, COLOR_RST
);
1223 g_string_append(pretty
->string
, " ]");
1226 bt_put(length_field
);
1233 enum bt_component_status
print_variant(struct pretty_component
*pretty
,
1234 struct bt_ctf_field
*variant
, bool print_names
)
1236 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1237 struct bt_ctf_field
*field
= NULL
;
1239 field
= bt_ctf_field_variant_get_current_field(variant
);
1241 ret
= BT_COMPONENT_STATUS_ERROR
;
1244 g_string_append(pretty
->string
, "{ ");
1248 struct bt_ctf_field
*tag_field
= NULL
;
1249 const char *tag_choice
;
1250 struct bt_ctf_field_type_enumeration_mapping_iterator
*iter
;
1252 tag_field
= bt_ctf_field_variant_get_tag(variant
);
1254 ret
= BT_COMPONENT_STATUS_ERROR
;
1258 iter
= bt_ctf_field_enumeration_get_mappings(tag_field
);
1261 ret
= BT_COMPONENT_STATUS_ERROR
;
1266 bt_ctf_field_type_enumeration_mapping_iterator_get_signed(
1267 iter
, &tag_choice
, NULL
, NULL
);
1271 ret
= BT_COMPONENT_STATUS_ERROR
;
1274 print_field_name_equal(pretty
, rem_(tag_choice
));
1278 ret
= print_field(pretty
, field
, print_names
, NULL
, 0);
1279 if (ret
!= BT_COMPONENT_STATUS_OK
) {
1283 g_string_append(pretty
->string
, " }");
1290 enum bt_component_status
print_field(struct pretty_component
*pretty
,
1291 struct bt_ctf_field
*field
, bool print_names
,
1292 GQuark
*filter_fields
, int filter_array_len
)
1294 enum bt_ctf_field_type_id type_id
;
1296 type_id
= bt_ctf_field_get_type_id(field
);
1298 case CTF_TYPE_INTEGER
:
1299 return print_integer(pretty
, field
);
1300 case CTF_TYPE_FLOAT
:
1304 if (bt_ctf_field_floating_point_get_value(field
, &v
)) {
1305 return BT_COMPONENT_STATUS_ERROR
;
1307 if (pretty
->use_colors
) {
1308 g_string_append(pretty
->string
, COLOR_NUMBER_VALUE
);
1310 g_string_append_printf(pretty
->string
, "%g", v
);
1311 if (pretty
->use_colors
) {
1312 g_string_append(pretty
->string
, COLOR_RST
);
1314 return BT_COMPONENT_STATUS_OK
;
1317 return print_enum(pretty
, field
);
1318 case CTF_TYPE_STRING
:
1319 if (pretty
->use_colors
) {
1320 g_string_append(pretty
->string
, COLOR_STRING_VALUE
);
1322 print_escape_string(pretty
, bt_ctf_field_string_get_value(field
));
1323 if (pretty
->use_colors
) {
1324 g_string_append(pretty
->string
, COLOR_RST
);
1326 return BT_COMPONENT_STATUS_OK
;
1327 case CTF_TYPE_STRUCT
:
1328 return print_struct(pretty
, field
, print_names
, filter_fields
,
1330 case CTF_TYPE_VARIANT
:
1331 return print_variant(pretty
, field
, print_names
);
1332 case CTF_TYPE_ARRAY
:
1333 return print_array(pretty
, field
, print_names
);
1334 case CTF_TYPE_SEQUENCE
:
1335 return print_sequence(pretty
, field
, print_names
);
1337 // TODO: log instead
1338 fprintf(pretty
->err
, "[error] Unknown type id: %d\n", (int) type_id
);
1339 return BT_COMPONENT_STATUS_ERROR
;
1344 enum bt_component_status
print_stream_packet_context(struct pretty_component
*pretty
,
1345 struct bt_ctf_event
*event
)
1347 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1348 struct bt_ctf_packet
*packet
= NULL
;
1349 struct bt_ctf_field
*main_field
= NULL
;
1351 packet
= bt_ctf_event_get_packet(event
);
1353 ret
= BT_COMPONENT_STATUS_ERROR
;
1356 main_field
= bt_ctf_packet_get_context(packet
);
1360 if (!pretty
->start_line
) {
1361 g_string_append(pretty
->string
, ", ");
1363 pretty
->start_line
= false;
1364 if (pretty
->options
.print_scope_field_names
) {
1365 print_name_equal(pretty
, "stream.packet.context");
1367 ret
= print_field(pretty
, main_field
,
1368 pretty
->options
.print_context_field_names
,
1369 stream_packet_context_quarks
,
1370 STREAM_PACKET_CONTEXT_QUARKS_LEN
);
1378 enum bt_component_status
print_event_header_raw(struct pretty_component
*pretty
,
1379 struct bt_ctf_event
*event
)
1381 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1382 struct bt_ctf_field
*main_field
= NULL
;
1384 main_field
= bt_ctf_event_get_header(event
);
1388 if (!pretty
->start_line
) {
1389 g_string_append(pretty
->string
, ", ");
1391 pretty
->start_line
= false;
1392 if (pretty
->options
.print_scope_field_names
) {
1393 print_name_equal(pretty
, "stream.event.header");
1395 ret
= print_field(pretty
, main_field
,
1396 pretty
->options
.print_header_field_names
, NULL
, 0);
1403 enum bt_component_status
print_stream_event_context(struct pretty_component
*pretty
,
1404 struct bt_ctf_event
*event
)
1406 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1407 struct bt_ctf_field
*main_field
= NULL
;
1409 main_field
= bt_ctf_event_get_stream_event_context(event
);
1413 if (!pretty
->start_line
) {
1414 g_string_append(pretty
->string
, ", ");
1416 pretty
->start_line
= false;
1417 if (pretty
->options
.print_scope_field_names
) {
1418 print_name_equal(pretty
, "stream.event.context");
1420 ret
= print_field(pretty
, main_field
,
1421 pretty
->options
.print_context_field_names
, NULL
, 0);
1428 enum bt_component_status
print_event_context(struct pretty_component
*pretty
,
1429 struct bt_ctf_event
*event
)
1431 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1432 struct bt_ctf_field
*main_field
= NULL
;
1434 main_field
= bt_ctf_event_get_event_context(event
);
1438 if (!pretty
->start_line
) {
1439 g_string_append(pretty
->string
, ", ");
1441 pretty
->start_line
= false;
1442 if (pretty
->options
.print_scope_field_names
) {
1443 print_name_equal(pretty
, "event.context");
1445 ret
= print_field(pretty
, main_field
,
1446 pretty
->options
.print_context_field_names
, NULL
, 0);
1453 enum bt_component_status
print_event_payload(struct pretty_component
*pretty
,
1454 struct bt_ctf_event
*event
)
1456 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1457 struct bt_ctf_field
*main_field
= NULL
;
1459 main_field
= bt_ctf_event_get_event_payload(event
);
1463 if (!pretty
->start_line
) {
1464 g_string_append(pretty
->string
, ", ");
1466 pretty
->start_line
= false;
1467 if (pretty
->options
.print_scope_field_names
) {
1468 print_name_equal(pretty
, "event.fields");
1470 ret
= print_field(pretty
, main_field
,
1471 pretty
->options
.print_payload_field_names
, NULL
, 0);
1478 int flush_buf(struct pretty_component
*pretty
)
1482 if (pretty
->string
->len
== 0) {
1486 if (fwrite(pretty
->string
->str
, pretty
->string
->len
, 1, pretty
->out
) != 1) {
1495 enum bt_component_status
pretty_print_event(struct pretty_component
*pretty
,
1496 struct bt_notification
*event_notif
)
1498 enum bt_component_status ret
;
1499 struct bt_ctf_event
*event
=
1500 bt_notification_event_get_event(event_notif
);
1501 struct bt_clock_class_priority_map
*cc_prio_map
=
1502 bt_notification_event_get_clock_class_priority_map(event_notif
);
1505 assert(cc_prio_map
);
1506 pretty
->start_line
= true;
1507 g_string_assign(pretty
->string
, "");
1508 ret
= print_event_header(pretty
, event
, cc_prio_map
);
1509 if (ret
!= BT_COMPONENT_STATUS_OK
) {
1513 ret
= print_stream_packet_context(pretty
, event
);
1514 if (ret
!= BT_COMPONENT_STATUS_OK
) {
1518 if (pretty
->options
.verbose
) {
1519 ret
= print_event_header_raw(pretty
, event
);
1520 if (ret
!= BT_COMPONENT_STATUS_OK
) {
1525 ret
= print_stream_event_context(pretty
, event
);
1526 if (ret
!= BT_COMPONENT_STATUS_OK
) {
1530 ret
= print_event_context(pretty
, event
);
1531 if (ret
!= BT_COMPONENT_STATUS_OK
) {
1535 ret
= print_event_payload(pretty
, event
);
1536 if (ret
!= BT_COMPONENT_STATUS_OK
) {
1540 g_string_append_c(pretty
->string
, '\n');
1541 if (flush_buf(pretty
)) {
1542 ret
= BT_COMPONENT_STATUS_ERROR
;
1548 bt_put(cc_prio_map
);
1553 enum bt_component_status
pretty_print_discarded_elements(
1554 struct pretty_component
*pretty
,
1555 struct bt_notification
*notif
)
1557 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1558 struct bt_ctf_stream
*stream
= NULL
;
1559 struct bt_ctf_stream_class
*stream_class
= NULL
;
1560 struct bt_ctf_trace
*trace
= NULL
;
1561 const char *stream_name
;
1562 const char *trace_name
;
1563 const unsigned char *trace_uuid
;
1564 int64_t stream_class_id
;
1566 bool is_discarded_events
;
1568 struct bt_ctf_clock_value
*clock_value
= NULL
;
1571 switch (bt_notification_get_type(notif
)) {
1572 case BT_NOTIFICATION_TYPE_DISCARDED_EVENTS
:
1573 stream
= bt_notification_discarded_events_get_stream(notif
);
1574 count
= bt_notification_discarded_events_get_count(notif
);
1575 is_discarded_events
= true;
1577 case BT_NOTIFICATION_TYPE_DISCARDED_PACKETS
:
1578 stream
= bt_notification_discarded_packets_get_stream(notif
);
1579 count
= bt_notification_discarded_packets_get_count(notif
);
1580 is_discarded_events
= false;
1587 stream_name
= bt_ctf_stream_get_name(stream
);
1589 /* Stream class ID */
1590 stream_class
= bt_ctf_stream_get_class(stream
);
1591 assert(stream_class
);
1592 stream_class_id
= bt_ctf_stream_class_get_id(stream_class
);
1595 stream_id
= bt_ctf_stream_get_id(stream
);
1598 trace
= bt_ctf_stream_class_get_trace(stream_class
);
1600 trace_name
= bt_ctf_trace_get_name(trace
);
1602 trace_name
= "(unknown)";
1606 trace_uuid
= bt_ctf_trace_get_uuid(trace
);
1609 * Print to standard error stream to remain backward compatible
1610 * with Babeltrace 1.
1613 "%s%sWARNING%s%s: Tracer discarded %" PRId64
" %s%s between [",
1614 bt_common_color_fg_yellow(),
1615 bt_common_color_bold(),
1616 bt_common_color_reset(),
1617 bt_common_color_fg_yellow(),
1618 count
, is_discarded_events
? "event" : "packet",
1619 count
== 1 ? "" : "s");
1620 g_string_assign(pretty
->string
, "");
1621 clock_value
= is_discarded_events
?
1622 bt_notification_discarded_events_get_begin_clock_value(notif
) :
1623 bt_notification_discarded_packets_get_begin_clock_value(notif
);
1624 print_timestamp_wall(pretty
, clock_value
);
1625 BT_PUT(clock_value
);
1626 fprintf(stderr
, "%s] and [", pretty
->string
->str
);
1627 g_string_assign(pretty
->string
, "");
1628 clock_value
= is_discarded_events
?
1629 bt_notification_discarded_events_get_end_clock_value(notif
) :
1630 bt_notification_discarded_packets_get_end_clock_value(notif
);
1631 print_timestamp_wall(pretty
, clock_value
);
1632 BT_PUT(clock_value
);
1633 fprintf(stderr
, "%s] in trace \"%s\" ",
1634 pretty
->string
->str
, trace_name
);
1638 "(UUID: %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x) ",
1656 fprintf(stderr
, "(no UUID) ");
1659 fprintf(stderr
, "within stream \"%s\" (stream class ID: %" PRId64
", ",
1660 stream_name
, stream_class_id
);
1662 if (stream_id
>= 0) {
1663 fprintf(stderr
, "stream ID: %" PRId64
, stream_id
);
1665 fprintf(stderr
, "no stream ID");
1668 fprintf(stderr
, ").%s\n", bt_common_color_reset());
1670 bt_put(stream_class
);
1672 bt_put(clock_value
);