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
;
194 if (is_negative
&& !pretty
->negative_timestamp_warning_done
) {
196 fprintf(stderr
, "[warning] Fallback to [sec.ns] to print negative time value. Use --clock-seconds.\n");
197 pretty
->negative_timestamp_warning_done
= true;
201 if (!pretty
->options
.clock_gmt
) {
204 res
= bt_localtime_r(&time_s
, &tm
);
207 fprintf(stderr
, "[warning] Unable to get localtime.\n");
213 res
= bt_gmtime_r(&time_s
, &tm
);
216 fprintf(stderr
, "[warning] Unable to get gmtime.\n");
220 if (pretty
->options
.clock_date
) {
224 /* Print date and time */
225 res
= strftime(timestr
, sizeof(timestr
),
229 fprintf(stderr
, "[warning] Unable to print ascii time.\n");
233 g_string_append(pretty
->string
, timestr
);
236 /* Print time in HH:MM:SS.ns */
237 g_string_append_printf(pretty
->string
,
238 "%02d:%02d:%02d.%09" PRIu64
, tm
.tm_hour
, tm
.tm_min
,
239 tm
.tm_sec
, ts_nsec_abs
);
243 g_string_append_printf(pretty
->string
, "%s%" PRId64
".%09" PRIu64
,
244 is_negative
? "-" : "", ts_sec_abs
, ts_nsec_abs
);
250 enum bt_component_status
print_event_timestamp(struct pretty_component
*pretty
,
251 struct bt_ctf_event
*event
,
252 struct bt_clock_class_priority_map
*cc_prio_map
,
255 bool print_names
= pretty
->options
.print_header_field_names
;
256 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
257 struct bt_ctf_stream
*stream
= NULL
;
258 struct bt_ctf_stream_class
*stream_class
= NULL
;
259 struct bt_ctf_trace
*trace
= NULL
;
260 struct bt_ctf_clock_class
*clock_class
= NULL
;
262 stream
= bt_ctf_event_get_stream(event
);
264 ret
= BT_COMPONENT_STATUS_ERROR
;
268 stream_class
= bt_ctf_stream_get_class(stream
);
270 ret
= BT_COMPONENT_STATUS_ERROR
;
273 trace
= bt_ctf_stream_class_get_trace(stream_class
);
275 ret
= BT_COMPONENT_STATUS_ERROR
;
279 if (bt_clock_class_priority_map_get_clock_class_count(cc_prio_map
) == 0) {
280 /* No clock class: skip the timestamp without an error */
285 bt_clock_class_priority_map_get_highest_priority_clock_class(
288 ret
= BT_COMPONENT_STATUS_ERROR
;
293 print_name_equal(pretty
, "timestamp");
295 g_string_append(pretty
->string
, "[");
297 if (pretty
->use_colors
) {
298 g_string_append(pretty
->string
, COLOR_TIMESTAMP
);
300 if (pretty
->options
.print_timestamp_cycles
) {
301 print_timestamp_cycles(pretty
, clock_class
, event
);
303 struct bt_ctf_clock_value
*clock_value
=
304 bt_ctf_event_get_clock_value(event
, clock_class
);
306 print_timestamp_wall(pretty
, clock_value
);
309 if (pretty
->use_colors
) {
310 g_string_append(pretty
->string
, COLOR_RST
);
314 g_string_append(pretty
->string
, "] ");
316 if (pretty
->options
.print_delta_field
) {
318 g_string_append(pretty
->string
, ", ");
319 print_name_equal(pretty
, "delta");
321 g_string_append(pretty
->string
, "(");
323 if (pretty
->options
.print_timestamp_cycles
) {
324 if (pretty
->delta_cycles
== -1ULL) {
325 g_string_append(pretty
->string
,
326 "+??????????\?\?) "); /* Not a trigraph. */
328 g_string_append_printf(pretty
->string
,
329 "+%012" PRIu64
, pretty
->delta_cycles
);
332 if (pretty
->delta_real_timestamp
!= -1ULL) {
333 uint64_t delta_sec
, delta_nsec
, delta
;
335 delta
= pretty
->delta_real_timestamp
;
336 delta_sec
= delta
/ NSEC_PER_SEC
;
337 delta_nsec
= delta
% NSEC_PER_SEC
;
338 g_string_append_printf(pretty
->string
,
339 "+%" PRIu64
".%09" PRIu64
,
340 delta_sec
, delta_nsec
);
342 g_string_append(pretty
->string
, "+?.?????????");
346 g_string_append(pretty
->string
, ") ");
349 *start_line
= !print_names
;
354 bt_put(stream_class
);
360 enum bt_component_status
print_event_header(struct pretty_component
*pretty
,
361 struct bt_ctf_event
*event
,
362 struct bt_clock_class_priority_map
*cc_prio_map
)
364 bool print_names
= pretty
->options
.print_header_field_names
;
365 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
366 struct bt_ctf_event_class
*event_class
= NULL
;
367 struct bt_ctf_stream_class
*stream_class
= NULL
;
368 struct bt_ctf_trace
*trace_class
= NULL
;
371 event_class
= bt_ctf_event_get_class(event
);
373 ret
= BT_COMPONENT_STATUS_ERROR
;
376 stream_class
= bt_ctf_event_class_get_stream_class(event_class
);
378 ret
= BT_COMPONENT_STATUS_ERROR
;
381 trace_class
= bt_ctf_stream_class_get_trace(stream_class
);
383 ret
= BT_COMPONENT_STATUS_ERROR
;
386 ret
= print_event_timestamp(pretty
, event
, cc_prio_map
,
387 &pretty
->start_line
);
388 if (ret
!= BT_COMPONENT_STATUS_OK
) {
391 if (pretty
->options
.print_trace_field
) {
394 name
= bt_ctf_trace_get_name(trace_class
);
396 if (!pretty
->start_line
) {
397 g_string_append(pretty
->string
, ", ");
400 print_name_equal(pretty
, "trace");
403 g_string_append(pretty
->string
, name
);
406 g_string_append(pretty
->string
, " ");
410 if (pretty
->options
.print_trace_hostname_field
) {
411 struct bt_value
*hostname_str
;
413 hostname_str
= bt_ctf_trace_get_environment_field_value_by_name(trace_class
,
418 if (!pretty
->start_line
) {
419 g_string_append(pretty
->string
, ", ");
422 print_name_equal(pretty
, "trace:hostname");
424 if (bt_value_string_get(hostname_str
, &str
)
425 == BT_VALUE_STATUS_OK
) {
426 g_string_append(pretty
->string
, str
);
428 bt_put(hostname_str
);
432 if (pretty
->options
.print_trace_domain_field
) {
433 struct bt_value
*domain_str
;
435 domain_str
= bt_ctf_trace_get_environment_field_value_by_name(trace_class
,
440 if (!pretty
->start_line
) {
441 g_string_append(pretty
->string
, ", ");
444 print_name_equal(pretty
, "trace:domain");
445 } else if (dom_print
) {
446 g_string_append(pretty
->string
, ":");
448 if (bt_value_string_get(domain_str
, &str
)
449 == BT_VALUE_STATUS_OK
) {
450 g_string_append(pretty
->string
, str
);
456 if (pretty
->options
.print_trace_procname_field
) {
457 struct bt_value
*procname_str
;
459 procname_str
= bt_ctf_trace_get_environment_field_value_by_name(trace_class
,
464 if (!pretty
->start_line
) {
465 g_string_append(pretty
->string
, ", ");
468 print_name_equal(pretty
, "trace:procname");
469 } else if (dom_print
) {
470 g_string_append(pretty
->string
, ":");
472 if (bt_value_string_get(procname_str
, &str
)
473 == BT_VALUE_STATUS_OK
) {
474 g_string_append(pretty
->string
, str
);
476 bt_put(procname_str
);
480 if (pretty
->options
.print_trace_vpid_field
) {
481 struct bt_value
*vpid_value
;
483 vpid_value
= bt_ctf_trace_get_environment_field_value_by_name(trace_class
,
488 if (!pretty
->start_line
) {
489 g_string_append(pretty
->string
, ", ");
492 print_name_equal(pretty
, "trace:vpid");
493 } else if (dom_print
) {
494 g_string_append(pretty
->string
, ":");
496 if (bt_value_integer_get(vpid_value
, &value
)
497 == BT_VALUE_STATUS_OK
) {
498 g_string_append_printf(pretty
->string
, "(%" PRId64
")", value
);
504 if (pretty
->options
.print_loglevel_field
) {
505 static const char *log_level_names
[] = {
506 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_EMERGENCY
] = "TRACE_EMERG",
507 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_ALERT
] = "TRACE_ALERT",
508 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_CRITICAL
] = "TRACE_CRIT",
509 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_ERROR
] = "TRACE_ERR",
510 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_WARNING
] = "TRACE_WARNING",
511 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_NOTICE
] = "TRACE_NOTICE",
512 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_INFO
] = "TRACE_INFO",
513 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM
] = "TRACE_DEBUG_SYSTEM",
514 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM
] = "TRACE_DEBUG_PROGRAM",
515 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS
] = "TRACE_DEBUG_PROCESS",
516 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE
] = "TRACE_DEBUG_MODULE",
517 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT
] = "TRACE_DEBUG_UNIT",
518 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION
] = "TRACE_DEBUG_FUNCTION",
519 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE
] = "TRACE_DEBUG_LINE",
520 [ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG
] = "TRACE_DEBUG",
522 enum bt_ctf_event_class_log_level log_level
;
523 const char *log_level_str
= NULL
;
525 log_level
= bt_ctf_event_class_get_log_level(event_class
);
526 assert(log_level
!= BT_CTF_EVENT_CLASS_LOG_LEVEL_UNKNOWN
);
527 if (log_level
!= BT_CTF_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED
) {
528 log_level_str
= log_level_names
[log_level
];
532 if (!pretty
->start_line
) {
533 g_string_append(pretty
->string
, ", ");
536 print_name_equal(pretty
, "loglevel");
537 } else if (dom_print
) {
538 g_string_append(pretty
->string
, ":");
541 g_string_append(pretty
->string
, log_level_str
);
542 g_string_append_printf(
543 pretty
->string
, " (%d)", (int) log_level
);
547 if (pretty
->options
.print_emf_field
) {
550 uri_str
= bt_ctf_event_class_get_emf_uri(event_class
);
552 if (!pretty
->start_line
) {
553 g_string_append(pretty
->string
, ", ");
556 print_name_equal(pretty
, "model.emf.uri");
557 } else if (dom_print
) {
558 g_string_append(pretty
->string
, ":");
561 g_string_append(pretty
->string
, uri_str
);
565 if (dom_print
&& !print_names
) {
566 g_string_append(pretty
->string
, " ");
568 if (!pretty
->start_line
) {
569 g_string_append(pretty
->string
, ", ");
571 pretty
->start_line
= true;
573 print_name_equal(pretty
, "name");
575 if (pretty
->use_colors
) {
576 g_string_append(pretty
->string
, COLOR_EVENT_NAME
);
578 g_string_append(pretty
->string
, bt_ctf_event_class_get_name(event_class
));
579 if (pretty
->use_colors
) {
580 g_string_append(pretty
->string
, COLOR_RST
);
583 g_string_append(pretty
->string
, ": ");
585 g_string_append(pretty
->string
, ", ");
589 bt_put(stream_class
);
595 enum bt_component_status
print_integer(struct pretty_component
*pretty
,
596 struct bt_ctf_field
*field
)
598 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
599 struct bt_ctf_field_type
*field_type
= NULL
;
600 enum bt_ctf_integer_base base
;
601 enum bt_ctf_string_encoding encoding
;
607 bool rst_color
= false;
609 field_type
= bt_ctf_field_get_type(field
);
611 ret
= BT_COMPONENT_STATUS_ERROR
;
614 signedness
= bt_ctf_field_type_integer_get_signed(field_type
);
615 if (signedness
< 0) {
616 ret
= BT_COMPONENT_STATUS_ERROR
;
620 if (bt_ctf_field_unsigned_integer_get_value(field
, &v
.u
) < 0) {
621 ret
= BT_COMPONENT_STATUS_ERROR
;
625 if (bt_ctf_field_signed_integer_get_value(field
, &v
.s
) < 0) {
626 ret
= BT_COMPONENT_STATUS_ERROR
;
631 encoding
= bt_ctf_field_type_integer_get_encoding(field_type
);
633 case BT_CTF_STRING_ENCODING_UTF8
:
634 case BT_CTF_STRING_ENCODING_ASCII
:
635 g_string_append_c(pretty
->tmp_string
, (int) v
.u
);
637 case BT_CTF_STRING_ENCODING_NONE
:
638 case BT_CTF_STRING_ENCODING_UNKNOWN
:
641 ret
= BT_COMPONENT_STATUS_ERROR
;
645 if (pretty
->use_colors
) {
646 g_string_append(pretty
->string
, COLOR_NUMBER_VALUE
);
650 base
= bt_ctf_field_type_integer_get_base(field_type
);
652 case BT_CTF_INTEGER_BASE_BINARY
:
656 len
= bt_ctf_field_type_integer_get_size(field_type
);
658 ret
= BT_COMPONENT_STATUS_ERROR
;
661 g_string_append(pretty
->string
, "0b");
662 v
.u
= _bt_piecewise_lshift(v
.u
, 64 - len
);
663 for (bitnr
= 0; bitnr
< len
; bitnr
++) {
664 g_string_append_printf(pretty
->string
, "%u", (v
.u
& (1ULL << 63)) ? 1 : 0);
665 v
.u
= _bt_piecewise_lshift(v
.u
, 1);
669 case BT_CTF_INTEGER_BASE_OCTAL
:
674 len
= bt_ctf_field_type_integer_get_size(field_type
);
676 ret
= BT_COMPONENT_STATUS_ERROR
;
683 /* Round length to the nearest 3-bit */
684 rounded_len
= (((len
- 1) / 3) + 1) * 3;
685 v
.u
&= ((uint64_t) 1 << rounded_len
) - 1;
689 g_string_append_printf(pretty
->string
, "0%" PRIo64
, v
.u
);
692 case BT_CTF_INTEGER_BASE_DECIMAL
:
693 case BT_CTF_INTEGER_BASE_UNSPECIFIED
:
695 g_string_append_printf(pretty
->string
, "%" PRIu64
, v
.u
);
697 g_string_append_printf(pretty
->string
, "%" PRId64
, v
.s
);
700 case BT_CTF_INTEGER_BASE_HEXADECIMAL
:
704 len
= bt_ctf_field_type_integer_get_size(field_type
);
706 ret
= BT_COMPONENT_STATUS_ERROR
;
710 /* Round length to the nearest nibble */
711 uint8_t rounded_len
= ((len
+ 3) & ~0x3);
713 v
.u
&= ((uint64_t) 1 << rounded_len
) - 1;
716 g_string_append_printf(pretty
->string
, "0x%" PRIX64
, v
.u
);
720 ret
= BT_COMPONENT_STATUS_ERROR
;
725 g_string_append(pretty
->string
, COLOR_RST
);
732 void print_escape_string(struct pretty_component
*pretty
, const char *str
)
736 g_string_append_c(pretty
->string
, '"');
738 for (i
= 0; i
< strlen(str
); i
++) {
739 /* Escape sequences not recognized by iscntrl(). */
742 g_string_append(pretty
->string
, "\\\\");
745 g_string_append(pretty
->string
, "\\\'");
748 g_string_append(pretty
->string
, "\\\"");
751 g_string_append(pretty
->string
, "\\\?");
755 /* Standard characters. */
756 if (!iscntrl(str
[i
])) {
757 g_string_append_c(pretty
->string
, str
[i
]);
763 g_string_append(pretty
->string
, "\\0");
766 g_string_append(pretty
->string
, "\\a");
769 g_string_append(pretty
->string
, "\\b");
772 g_string_append(pretty
->string
, "\\e");
775 g_string_append(pretty
->string
, "\\f");
778 g_string_append(pretty
->string
, "\\n");
781 g_string_append(pretty
->string
, "\\r");
784 g_string_append(pretty
->string
, "\\t");
787 g_string_append(pretty
->string
, "\\v");
790 /* Unhandled control-sequence, print as hex. */
791 g_string_append_printf(pretty
->string
, "\\x%02x", str
[i
]);
796 g_string_append_c(pretty
->string
, '"');
800 enum bt_component_status
print_enum(struct pretty_component
*pretty
,
801 struct bt_ctf_field
*field
)
803 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
804 struct bt_ctf_field
*container_field
= NULL
;
805 struct bt_ctf_field_type
*enumeration_field_type
= NULL
;
806 struct bt_ctf_field_type
*container_field_type
= NULL
;
807 struct bt_ctf_field_type_enumeration_mapping_iterator
*iter
= NULL
;
811 enumeration_field_type
= bt_ctf_field_get_type(field
);
812 if (!enumeration_field_type
) {
813 ret
= BT_COMPONENT_STATUS_ERROR
;
816 container_field
= bt_ctf_field_enumeration_get_container(field
);
817 if (!container_field
) {
818 ret
= BT_COMPONENT_STATUS_ERROR
;
821 container_field_type
= bt_ctf_field_get_type(container_field
);
822 if (!container_field_type
) {
823 ret
= BT_COMPONENT_STATUS_ERROR
;
826 is_signed
= bt_ctf_field_type_integer_get_signed(container_field_type
);
828 ret
= BT_COMPONENT_STATUS_ERROR
;
834 if (bt_ctf_field_signed_integer_get_value(container_field
,
836 ret
= BT_COMPONENT_STATUS_ERROR
;
839 iter
= bt_ctf_field_type_enumeration_find_mappings_by_signed_value(
840 enumeration_field_type
, value
);
844 if (bt_ctf_field_unsigned_integer_get_value(container_field
,
846 ret
= BT_COMPONENT_STATUS_ERROR
;
849 iter
= bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value(
850 enumeration_field_type
, value
);
853 ret
= BT_COMPONENT_STATUS_ERROR
;
856 g_string_append(pretty
->string
, "( ");
858 const char *mapping_name
;
860 if (bt_ctf_field_type_enumeration_mapping_iterator_get_signed(
861 iter
, &mapping_name
, NULL
, NULL
) < 0) {
862 ret
= BT_COMPONENT_STATUS_ERROR
;
866 g_string_append(pretty
->string
, ", ");
867 if (pretty
->use_colors
) {
868 g_string_append(pretty
->string
, COLOR_ENUM_MAPPING_NAME
);
870 print_escape_string(pretty
, mapping_name
);
871 if (pretty
->use_colors
) {
872 g_string_append(pretty
->string
, COLOR_RST
);
874 if (bt_ctf_field_type_enumeration_mapping_iterator_next(iter
) < 0) {
879 if (pretty
->use_colors
) {
880 g_string_append(pretty
->string
, COLOR_UNKNOWN
);
882 g_string_append(pretty
->string
, "<unknown>");
883 if (pretty
->use_colors
) {
884 g_string_append(pretty
->string
, COLOR_RST
);
887 g_string_append(pretty
->string
, " : container = ");
888 ret
= print_integer(pretty
, container_field
);
889 if (ret
!= BT_COMPONENT_STATUS_OK
) {
892 g_string_append(pretty
->string
, " )");
895 bt_put(container_field_type
);
896 bt_put(container_field
);
897 bt_put(enumeration_field_type
);
902 int filter_field_name(struct pretty_component
*pretty
, const char *field_name
,
903 GQuark
*filter_fields
, int filter_array_len
)
906 GQuark field_quark
= g_quark_try_string(field_name
);
908 if (!field_quark
|| pretty
->options
.verbose
) {
912 for (i
= 0; i
< filter_array_len
; i
++) {
913 if (field_quark
== filter_fields
[i
]) {
921 enum bt_component_status
print_struct_field(struct pretty_component
*pretty
,
922 struct bt_ctf_field
*_struct
,
923 struct bt_ctf_field_type
*struct_type
,
924 int i
, bool print_names
, int *nr_printed_fields
,
925 GQuark
*filter_fields
, int filter_array_len
)
927 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
928 const char *field_name
;
929 struct bt_ctf_field
*field
= NULL
;
930 struct bt_ctf_field_type
*field_type
= NULL
;;
932 field
= bt_ctf_field_structure_get_field_by_index(_struct
, i
);
934 ret
= BT_COMPONENT_STATUS_ERROR
;
937 if (bt_ctf_field_type_structure_get_field(struct_type
,
938 &field_name
, &field_type
, i
) < 0) {
939 ret
= BT_COMPONENT_STATUS_ERROR
;
943 if (filter_fields
&& !filter_field_name(pretty
, field_name
,
944 filter_fields
, filter_array_len
)) {
945 ret
= BT_COMPONENT_STATUS_OK
;
949 if (*nr_printed_fields
> 0) {
950 g_string_append(pretty
->string
, ", ");
952 g_string_append(pretty
->string
, " ");
955 print_field_name_equal(pretty
, rem_(field_name
));
957 ret
= print_field(pretty
, field
, print_names
, NULL
, 0);
958 *nr_printed_fields
+= 1;
966 enum bt_component_status
print_struct(struct pretty_component
*pretty
,
967 struct bt_ctf_field
*_struct
, bool print_names
,
968 GQuark
*filter_fields
, int filter_array_len
)
970 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
971 struct bt_ctf_field_type
*struct_type
= NULL
;
972 int nr_fields
, i
, nr_printed_fields
;
974 struct_type
= bt_ctf_field_get_type(_struct
);
976 ret
= BT_COMPONENT_STATUS_ERROR
;
979 nr_fields
= bt_ctf_field_type_structure_get_field_count(struct_type
);
981 ret
= BT_COMPONENT_STATUS_ERROR
;
984 g_string_append(pretty
->string
, "{");
986 nr_printed_fields
= 0;
987 for (i
= 0; i
< nr_fields
; i
++) {
988 ret
= print_struct_field(pretty
, _struct
, struct_type
, i
,
989 print_names
, &nr_printed_fields
, filter_fields
,
991 if (ret
!= BT_COMPONENT_STATUS_OK
) {
996 g_string_append(pretty
->string
, " }");
1003 enum bt_component_status
print_array_field(struct pretty_component
*pretty
,
1004 struct bt_ctf_field
*array
, uint64_t i
,
1005 bool is_string
, bool print_names
)
1007 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1008 struct bt_ctf_field
*field
= NULL
;
1012 g_string_append(pretty
->string
, ", ");
1014 g_string_append(pretty
->string
, " ");
1017 g_string_append_printf(pretty
->string
, "[%" PRIu64
"] = ", i
);
1020 field
= bt_ctf_field_array_get_field(array
, i
);
1022 ret
= BT_COMPONENT_STATUS_ERROR
;
1025 ret
= print_field(pretty
, field
, print_names
, NULL
, 0);
1032 enum bt_component_status
print_array(struct pretty_component
*pretty
,
1033 struct bt_ctf_field
*array
, bool print_names
)
1035 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1036 struct bt_ctf_field_type
*array_type
= NULL
, *field_type
= NULL
;
1037 enum bt_ctf_field_type_id type_id
;
1040 bool is_string
= false;
1042 array_type
= bt_ctf_field_get_type(array
);
1044 ret
= BT_COMPONENT_STATUS_ERROR
;
1047 field_type
= bt_ctf_field_type_array_get_element_type(array_type
);
1049 ret
= BT_COMPONENT_STATUS_ERROR
;
1052 len
= bt_ctf_field_type_array_get_length(array_type
);
1054 ret
= BT_COMPONENT_STATUS_ERROR
;
1057 type_id
= bt_ctf_field_type_get_type_id(field_type
);
1058 if (type_id
== BT_CTF_FIELD_TYPE_ID_INTEGER
) {
1059 enum bt_ctf_string_encoding encoding
;
1061 encoding
= bt_ctf_field_type_integer_get_encoding(field_type
);
1062 if (encoding
== BT_CTF_STRING_ENCODING_UTF8
1063 || encoding
== BT_CTF_STRING_ENCODING_ASCII
) {
1064 int integer_len
, integer_alignment
;
1066 integer_len
= bt_ctf_field_type_integer_get_size(field_type
);
1067 if (integer_len
< 0) {
1068 return BT_COMPONENT_STATUS_ERROR
;
1070 integer_alignment
= bt_ctf_field_type_get_alignment(field_type
);
1071 if (integer_alignment
< 0) {
1072 return BT_COMPONENT_STATUS_ERROR
;
1074 if (integer_len
== CHAR_BIT
1075 && integer_alignment
== CHAR_BIT
) {
1082 g_string_assign(pretty
->tmp_string
, "");
1084 g_string_append(pretty
->string
, "[");
1088 for (i
= 0; i
< len
; i
++) {
1089 ret
= print_array_field(pretty
, array
, i
, is_string
, print_names
);
1090 if (ret
!= BT_COMPONENT_STATUS_OK
) {
1097 if (pretty
->use_colors
) {
1098 g_string_append(pretty
->string
, COLOR_STRING_VALUE
);
1100 print_escape_string(pretty
, pretty
->tmp_string
->str
);
1101 if (pretty
->use_colors
) {
1102 g_string_append(pretty
->string
, COLOR_RST
);
1105 g_string_append(pretty
->string
, " ]");
1114 enum bt_component_status
print_sequence_field(struct pretty_component
*pretty
,
1115 struct bt_ctf_field
*seq
, uint64_t i
,
1116 bool is_string
, bool print_names
)
1118 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1119 struct bt_ctf_field
*field
= NULL
;
1123 g_string_append(pretty
->string
, ", ");
1125 g_string_append(pretty
->string
, " ");
1128 g_string_append_printf(pretty
->string
, "[%" PRIu64
"] = ", i
);
1131 field
= bt_ctf_field_sequence_get_field(seq
, i
);
1133 ret
= BT_COMPONENT_STATUS_ERROR
;
1136 ret
= print_field(pretty
, field
, print_names
, NULL
, 0);
1143 enum bt_component_status
print_sequence(struct pretty_component
*pretty
,
1144 struct bt_ctf_field
*seq
, bool print_names
)
1146 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1147 struct bt_ctf_field_type
*seq_type
= NULL
, *field_type
= NULL
;
1148 struct bt_ctf_field
*length_field
= NULL
;
1149 enum bt_ctf_field_type_id type_id
;
1152 bool is_string
= false;
1154 seq_type
= bt_ctf_field_get_type(seq
);
1156 ret
= BT_COMPONENT_STATUS_ERROR
;
1159 length_field
= bt_ctf_field_sequence_get_length(seq
);
1160 if (!length_field
) {
1161 ret
= BT_COMPONENT_STATUS_ERROR
;
1164 if (bt_ctf_field_unsigned_integer_get_value(length_field
, &len
) < 0) {
1165 ret
= BT_COMPONENT_STATUS_ERROR
;
1168 field_type
= bt_ctf_field_type_sequence_get_element_type(seq_type
);
1170 ret
= BT_COMPONENT_STATUS_ERROR
;
1173 type_id
= bt_ctf_field_type_get_type_id(field_type
);
1174 if (type_id
== BT_CTF_FIELD_TYPE_ID_INTEGER
) {
1175 enum bt_ctf_string_encoding encoding
;
1177 encoding
= bt_ctf_field_type_integer_get_encoding(field_type
);
1178 if (encoding
== BT_CTF_STRING_ENCODING_UTF8
1179 || encoding
== BT_CTF_STRING_ENCODING_ASCII
) {
1180 int integer_len
, integer_alignment
;
1182 integer_len
= bt_ctf_field_type_integer_get_size(field_type
);
1183 if (integer_len
< 0) {
1184 ret
= BT_COMPONENT_STATUS_ERROR
;
1187 integer_alignment
= bt_ctf_field_type_get_alignment(field_type
);
1188 if (integer_alignment
< 0) {
1189 ret
= BT_COMPONENT_STATUS_ERROR
;
1192 if (integer_len
== CHAR_BIT
1193 && integer_alignment
== CHAR_BIT
) {
1200 g_string_assign(pretty
->tmp_string
, "");
1202 g_string_append(pretty
->string
, "[");
1206 for (i
= 0; i
< len
; i
++) {
1207 ret
= print_sequence_field(pretty
, seq
, i
,
1208 is_string
, print_names
);
1209 if (ret
!= BT_COMPONENT_STATUS_OK
) {
1216 if (pretty
->use_colors
) {
1217 g_string_append(pretty
->string
, COLOR_STRING_VALUE
);
1219 print_escape_string(pretty
, pretty
->tmp_string
->str
);
1220 if (pretty
->use_colors
) {
1221 g_string_append(pretty
->string
, COLOR_RST
);
1224 g_string_append(pretty
->string
, " ]");
1227 bt_put(length_field
);
1234 enum bt_component_status
print_variant(struct pretty_component
*pretty
,
1235 struct bt_ctf_field
*variant
, bool print_names
)
1237 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1238 struct bt_ctf_field
*field
= NULL
;
1240 field
= bt_ctf_field_variant_get_current_field(variant
);
1242 ret
= BT_COMPONENT_STATUS_ERROR
;
1245 g_string_append(pretty
->string
, "{ ");
1249 struct bt_ctf_field
*tag_field
= NULL
;
1250 const char *tag_choice
;
1251 struct bt_ctf_field_type_enumeration_mapping_iterator
*iter
;
1253 tag_field
= bt_ctf_field_variant_get_tag(variant
);
1255 ret
= BT_COMPONENT_STATUS_ERROR
;
1259 iter
= bt_ctf_field_enumeration_get_mappings(tag_field
);
1262 ret
= BT_COMPONENT_STATUS_ERROR
;
1267 bt_ctf_field_type_enumeration_mapping_iterator_get_signed(
1268 iter
, &tag_choice
, NULL
, NULL
);
1272 ret
= BT_COMPONENT_STATUS_ERROR
;
1275 print_field_name_equal(pretty
, rem_(tag_choice
));
1279 ret
= print_field(pretty
, field
, print_names
, NULL
, 0);
1280 if (ret
!= BT_COMPONENT_STATUS_OK
) {
1284 g_string_append(pretty
->string
, " }");
1291 enum bt_component_status
print_field(struct pretty_component
*pretty
,
1292 struct bt_ctf_field
*field
, bool print_names
,
1293 GQuark
*filter_fields
, int filter_array_len
)
1295 enum bt_ctf_field_type_id type_id
;
1297 type_id
= bt_ctf_field_get_type_id(field
);
1299 case CTF_TYPE_INTEGER
:
1300 return print_integer(pretty
, field
);
1301 case CTF_TYPE_FLOAT
:
1305 if (bt_ctf_field_floating_point_get_value(field
, &v
)) {
1306 return BT_COMPONENT_STATUS_ERROR
;
1308 if (pretty
->use_colors
) {
1309 g_string_append(pretty
->string
, COLOR_NUMBER_VALUE
);
1311 g_string_append_printf(pretty
->string
, "%g", v
);
1312 if (pretty
->use_colors
) {
1313 g_string_append(pretty
->string
, COLOR_RST
);
1315 return BT_COMPONENT_STATUS_OK
;
1318 return print_enum(pretty
, field
);
1319 case CTF_TYPE_STRING
:
1323 str
= bt_ctf_field_string_get_value(field
);
1325 return BT_COMPONENT_STATUS_ERROR
;
1328 if (pretty
->use_colors
) {
1329 g_string_append(pretty
->string
, COLOR_STRING_VALUE
);
1331 print_escape_string(pretty
, str
);
1332 if (pretty
->use_colors
) {
1333 g_string_append(pretty
->string
, COLOR_RST
);
1335 return BT_COMPONENT_STATUS_OK
;
1337 case CTF_TYPE_STRUCT
:
1338 return print_struct(pretty
, field
, print_names
, filter_fields
,
1340 case CTF_TYPE_VARIANT
:
1341 return print_variant(pretty
, field
, print_names
);
1342 case CTF_TYPE_ARRAY
:
1343 return print_array(pretty
, field
, print_names
);
1344 case CTF_TYPE_SEQUENCE
:
1345 return print_sequence(pretty
, field
, print_names
);
1347 // TODO: log instead
1348 fprintf(pretty
->err
, "[error] Unknown type id: %d\n", (int) type_id
);
1349 return BT_COMPONENT_STATUS_ERROR
;
1354 enum bt_component_status
print_stream_packet_context(struct pretty_component
*pretty
,
1355 struct bt_ctf_event
*event
)
1357 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1358 struct bt_ctf_packet
*packet
= NULL
;
1359 struct bt_ctf_field
*main_field
= NULL
;
1361 packet
= bt_ctf_event_get_packet(event
);
1363 ret
= BT_COMPONENT_STATUS_ERROR
;
1366 main_field
= bt_ctf_packet_get_context(packet
);
1370 if (!pretty
->start_line
) {
1371 g_string_append(pretty
->string
, ", ");
1373 pretty
->start_line
= false;
1374 if (pretty
->options
.print_scope_field_names
) {
1375 print_name_equal(pretty
, "stream.packet.context");
1377 ret
= print_field(pretty
, main_field
,
1378 pretty
->options
.print_context_field_names
,
1379 stream_packet_context_quarks
,
1380 STREAM_PACKET_CONTEXT_QUARKS_LEN
);
1388 enum bt_component_status
print_event_header_raw(struct pretty_component
*pretty
,
1389 struct bt_ctf_event
*event
)
1391 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1392 struct bt_ctf_field
*main_field
= NULL
;
1394 main_field
= bt_ctf_event_get_header(event
);
1398 if (!pretty
->start_line
) {
1399 g_string_append(pretty
->string
, ", ");
1401 pretty
->start_line
= false;
1402 if (pretty
->options
.print_scope_field_names
) {
1403 print_name_equal(pretty
, "stream.event.header");
1405 ret
= print_field(pretty
, main_field
,
1406 pretty
->options
.print_header_field_names
, NULL
, 0);
1413 enum bt_component_status
print_stream_event_context(struct pretty_component
*pretty
,
1414 struct bt_ctf_event
*event
)
1416 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1417 struct bt_ctf_field
*main_field
= NULL
;
1419 main_field
= bt_ctf_event_get_stream_event_context(event
);
1423 if (!pretty
->start_line
) {
1424 g_string_append(pretty
->string
, ", ");
1426 pretty
->start_line
= false;
1427 if (pretty
->options
.print_scope_field_names
) {
1428 print_name_equal(pretty
, "stream.event.context");
1430 ret
= print_field(pretty
, main_field
,
1431 pretty
->options
.print_context_field_names
, NULL
, 0);
1438 enum bt_component_status
print_event_context(struct pretty_component
*pretty
,
1439 struct bt_ctf_event
*event
)
1441 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1442 struct bt_ctf_field
*main_field
= NULL
;
1444 main_field
= bt_ctf_event_get_event_context(event
);
1448 if (!pretty
->start_line
) {
1449 g_string_append(pretty
->string
, ", ");
1451 pretty
->start_line
= false;
1452 if (pretty
->options
.print_scope_field_names
) {
1453 print_name_equal(pretty
, "event.context");
1455 ret
= print_field(pretty
, main_field
,
1456 pretty
->options
.print_context_field_names
, NULL
, 0);
1463 enum bt_component_status
print_event_payload(struct pretty_component
*pretty
,
1464 struct bt_ctf_event
*event
)
1466 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1467 struct bt_ctf_field
*main_field
= NULL
;
1469 main_field
= bt_ctf_event_get_event_payload(event
);
1473 if (!pretty
->start_line
) {
1474 g_string_append(pretty
->string
, ", ");
1476 pretty
->start_line
= false;
1477 if (pretty
->options
.print_scope_field_names
) {
1478 print_name_equal(pretty
, "event.fields");
1480 ret
= print_field(pretty
, main_field
,
1481 pretty
->options
.print_payload_field_names
, NULL
, 0);
1488 int flush_buf(struct pretty_component
*pretty
)
1492 if (pretty
->string
->len
== 0) {
1496 if (fwrite(pretty
->string
->str
, pretty
->string
->len
, 1, pretty
->out
) != 1) {
1505 enum bt_component_status
pretty_print_event(struct pretty_component
*pretty
,
1506 struct bt_notification
*event_notif
)
1508 enum bt_component_status ret
;
1509 struct bt_ctf_event
*event
=
1510 bt_notification_event_get_event(event_notif
);
1511 struct bt_clock_class_priority_map
*cc_prio_map
=
1512 bt_notification_event_get_clock_class_priority_map(event_notif
);
1515 assert(cc_prio_map
);
1516 pretty
->start_line
= true;
1517 g_string_assign(pretty
->string
, "");
1518 ret
= print_event_header(pretty
, event
, cc_prio_map
);
1519 if (ret
!= BT_COMPONENT_STATUS_OK
) {
1523 ret
= print_stream_packet_context(pretty
, event
);
1524 if (ret
!= BT_COMPONENT_STATUS_OK
) {
1528 if (pretty
->options
.verbose
) {
1529 ret
= print_event_header_raw(pretty
, event
);
1530 if (ret
!= BT_COMPONENT_STATUS_OK
) {
1535 ret
= print_stream_event_context(pretty
, event
);
1536 if (ret
!= BT_COMPONENT_STATUS_OK
) {
1540 ret
= print_event_context(pretty
, event
);
1541 if (ret
!= BT_COMPONENT_STATUS_OK
) {
1545 ret
= print_event_payload(pretty
, event
);
1546 if (ret
!= BT_COMPONENT_STATUS_OK
) {
1550 g_string_append_c(pretty
->string
, '\n');
1551 if (flush_buf(pretty
)) {
1552 ret
= BT_COMPONENT_STATUS_ERROR
;
1558 bt_put(cc_prio_map
);
1563 enum bt_component_status
pretty_print_discarded_elements(
1564 struct pretty_component
*pretty
,
1565 struct bt_notification
*notif
)
1567 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
1568 struct bt_ctf_stream
*stream
= NULL
;
1569 struct bt_ctf_stream_class
*stream_class
= NULL
;
1570 struct bt_ctf_trace
*trace
= NULL
;
1571 const char *stream_name
;
1572 const char *trace_name
;
1573 const unsigned char *trace_uuid
;
1574 int64_t stream_class_id
;
1576 bool is_discarded_events
;
1578 struct bt_ctf_clock_value
*clock_value
= NULL
;
1581 switch (bt_notification_get_type(notif
)) {
1582 case BT_NOTIFICATION_TYPE_DISCARDED_EVENTS
:
1583 stream
= bt_notification_discarded_events_get_stream(notif
);
1584 count
= bt_notification_discarded_events_get_count(notif
);
1585 is_discarded_events
= true;
1587 case BT_NOTIFICATION_TYPE_DISCARDED_PACKETS
:
1588 stream
= bt_notification_discarded_packets_get_stream(notif
);
1589 count
= bt_notification_discarded_packets_get_count(notif
);
1590 is_discarded_events
= false;
1597 stream_name
= bt_ctf_stream_get_name(stream
);
1599 /* Stream class ID */
1600 stream_class
= bt_ctf_stream_get_class(stream
);
1601 assert(stream_class
);
1602 stream_class_id
= bt_ctf_stream_class_get_id(stream_class
);
1605 stream_id
= bt_ctf_stream_get_id(stream
);
1608 trace
= bt_ctf_stream_class_get_trace(stream_class
);
1610 trace_name
= bt_ctf_trace_get_name(trace
);
1612 trace_name
= "(unknown)";
1616 trace_uuid
= bt_ctf_trace_get_uuid(trace
);
1619 * Print to standard error stream to remain backward compatible
1620 * with Babeltrace 1.
1623 "%s%sWARNING%s%s: Tracer discarded %" PRId64
" %s%s between [",
1624 bt_common_color_fg_yellow(),
1625 bt_common_color_bold(),
1626 bt_common_color_reset(),
1627 bt_common_color_fg_yellow(),
1628 count
, is_discarded_events
? "event" : "packet",
1629 count
== 1 ? "" : "s");
1630 g_string_assign(pretty
->string
, "");
1631 clock_value
= is_discarded_events
?
1632 bt_notification_discarded_events_get_begin_clock_value(notif
) :
1633 bt_notification_discarded_packets_get_begin_clock_value(notif
);
1634 print_timestamp_wall(pretty
, clock_value
);
1635 BT_PUT(clock_value
);
1636 fprintf(stderr
, "%s] and [", pretty
->string
->str
);
1637 g_string_assign(pretty
->string
, "");
1638 clock_value
= is_discarded_events
?
1639 bt_notification_discarded_events_get_end_clock_value(notif
) :
1640 bt_notification_discarded_packets_get_end_clock_value(notif
);
1641 print_timestamp_wall(pretty
, clock_value
);
1642 BT_PUT(clock_value
);
1643 fprintf(stderr
, "%s] in trace \"%s\" ",
1644 pretty
->string
->str
, trace_name
);
1648 "(UUID: %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x) ",
1666 fprintf(stderr
, "(no UUID) ");
1669 fprintf(stderr
, "within stream \"%s\" (stream class ID: %" PRId64
", ",
1670 stream_name
, stream_class_id
);
1672 if (stream_id
>= 0) {
1673 fprintf(stderr
, "stream ID: %" PRId64
, stream_id
);
1675 fprintf(stderr
, "no stream ID");
1678 fprintf(stderr
, ").%s\n", bt_common_color_reset());
1680 bt_put(stream_class
);
1682 bt_put(clock_value
);