2 * SPDX-License-Identifier: MIT
4 * Copyright 2019 Francis Deslauriers <francis.deslauriers@efficios.com>
7 #include <babeltrace2/babeltrace.h>
13 #include "common/assert.h"
14 #include "common/common.h"
15 #include "common/macros.h"
16 #include "common/uuid.h"
20 struct message_to_compare
{
21 const bt_message
*msg
;
22 const bt_trace
*trace
;
23 const bt_stream
*stream
;
26 struct messages_to_compare
{
27 struct message_to_compare left
;
28 struct message_to_compare right
;
32 int message_type_weight(const bt_message_type msg_type
)
37 case BT_MESSAGE_TYPE_STREAM_BEGINNING
:
40 case BT_MESSAGE_TYPE_PACKET_BEGINNING
:
43 case BT_MESSAGE_TYPE_EVENT
:
46 case BT_MESSAGE_TYPE_DISCARDED_EVENTS
:
49 case BT_MESSAGE_TYPE_PACKET_END
:
52 case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY
:
55 case BT_MESSAGE_TYPE_DISCARDED_PACKETS
:
58 case BT_MESSAGE_TYPE_STREAM_END
:
69 * Compare 2 messages to order them in a deterministic way based on their
71 * Returns -1 is left message must go first
72 * Returns 1 is right message must go first
75 int compare_messages_by_type(struct messages_to_compare
*msgs
)
77 bt_message_type left_msg_type
= bt_message_get_type(msgs
->left
.msg
);
78 bt_message_type right_msg_type
= bt_message_get_type(msgs
->right
.msg
);
80 return message_type_weight(right_msg_type
) -
81 message_type_weight(left_msg_type
);
85 int compare_events(const bt_event
*left_event
, const bt_event
*right_event
)
88 const bt_event_class
*left_event_class
, *right_event_class
;
89 uint64_t left_event_class_id
, right_event_class_id
;
90 const char *left_event_class_name
, *right_event_class_name
,
91 *left_event_class_emf_uri
, *right_event_class_emf_uri
;
92 bt_event_class_log_level left_event_class_log_level
, right_event_class_log_level
;
93 bt_property_availability left_log_level_avail
, right_log_level_avail
;
95 left_event_class
= bt_event_borrow_class_const(left_event
);
96 right_event_class
= bt_event_borrow_class_const(right_event
);
98 left_event_class_id
= bt_event_class_get_id(left_event_class
);
99 right_event_class_id
= bt_event_class_get_id(right_event_class
);
101 if (left_event_class_id
> right_event_class_id
) {
104 } else if (left_event_class_id
< right_event_class_id
) {
109 left_event_class_name
= bt_event_class_get_name(left_event_class
);
110 right_event_class_name
= bt_event_class_get_name(right_event_class
);
111 if (left_event_class_name
&& right_event_class_name
) {
112 ret
= strcmp(left_event_class_name
, right_event_class_name
);
116 } else if (!left_event_class_name
&& right_event_class_name
) {
119 } else if (left_event_class_name
&& !right_event_class_name
) {
124 left_log_level_avail
= bt_event_class_get_log_level(left_event_class
,
125 &left_event_class_log_level
);
126 right_log_level_avail
= bt_event_class_get_log_level(right_event_class
,
127 &right_event_class_log_level
);
129 if (left_log_level_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
&&
130 right_log_level_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
) {
131 ret
= left_event_class_log_level
- right_event_class_log_level
;
135 } else if (left_log_level_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
&&
136 right_log_level_avail
== BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE
) {
139 } else if (left_log_level_avail
== BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE
&&
140 right_log_level_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
) {
145 left_event_class_emf_uri
= bt_event_class_get_emf_uri(left_event_class
);
146 right_event_class_emf_uri
= bt_event_class_get_emf_uri(right_event_class
);
147 if (left_event_class_emf_uri
&& right_event_class_emf_uri
) {
148 ret
= strcmp(left_event_class_emf_uri
, right_event_class_emf_uri
);
152 } else if (!left_event_class_emf_uri
&& right_event_class_emf_uri
) {
155 } else if (left_event_class_emf_uri
&& !right_event_class_emf_uri
) {
166 int compare_clock_classes(const bt_clock_class
*left_cc
,
167 const bt_clock_class
*right_cc
)
170 const char *left_clock_class_name
, *right_clock_class_name
;
171 bt_uuid left_clock_class_uuid
, right_clock_class_uuid
;
172 uint64_t left_freq
, right_freq
, left_prec
, right_prec
;
174 left_clock_class_uuid
= bt_clock_class_get_uuid(left_cc
);
175 right_clock_class_uuid
= bt_clock_class_get_uuid(right_cc
);
177 if (left_clock_class_uuid
&& !right_clock_class_uuid
) {
180 } else if (!left_clock_class_uuid
&& right_clock_class_uuid
) {
183 } else if (left_clock_class_uuid
&& right_clock_class_uuid
) {
184 ret
= bt_uuid_compare(left_clock_class_uuid
,
185 right_clock_class_uuid
);
192 left_clock_class_name
= bt_clock_class_get_name(left_cc
);
193 right_clock_class_name
= bt_clock_class_get_name(right_cc
);
195 if (left_clock_class_name
&& !right_clock_class_name
) {
198 } else if (!left_clock_class_name
&& right_clock_class_name
) {
201 } else if (left_clock_class_name
&& right_clock_class_name
) {
202 ret
= strcmp(left_clock_class_name
, right_clock_class_name
);
208 left_freq
= bt_clock_class_get_frequency(left_cc
);
209 right_freq
= bt_clock_class_get_frequency(right_cc
);
211 ret
= right_freq
- left_freq
;
216 left_prec
= bt_clock_class_get_precision(left_cc
);
217 right_prec
= bt_clock_class_get_precision(right_cc
);
219 ret
= right_prec
- left_prec
;
229 int compare_streams(const bt_stream
*left_stream
, const bt_stream
*right_stream
)
232 const char *left_stream_name
, *right_stream_name
,
233 *left_stream_class_name
, *right_stream_class_name
;
234 const bt_stream_class
*left_stream_class
, *right_stream_class
;
235 const bt_clock_class
*left_cc
, *right_cc
;
238 * No need to compare stream id as it was checked earlier and if we are
239 * here it means they are identical or both absent.
241 BT_ASSERT_DBG(bt_stream_get_id(left_stream
) ==
242 bt_stream_get_id(right_stream
));
244 /* Compare stream name. */
245 left_stream_name
= bt_stream_get_name(left_stream
);
246 right_stream_name
= bt_stream_get_name(right_stream
);
248 if (left_stream_name
&& right_stream_name
) {
249 ret
= strcmp(left_stream_name
, right_stream_name
);
253 } else if (!left_stream_name
&& right_stream_name
) {
256 } else if (left_stream_name
&& !right_stream_name
) {
261 left_stream_class
= bt_stream_borrow_class_const(left_stream
);
262 right_stream_class
= bt_stream_borrow_class_const(right_stream
);
265 * No need to compare stream class id as it was checked earlier and if
266 * we are here it means they are identical.
268 BT_ASSERT_DBG(bt_stream_class_get_id(left_stream_class
) ==
269 bt_stream_class_get_id(right_stream_class
));
271 /* Compare stream class name. */
272 left_stream_class_name
= bt_stream_class_get_name(left_stream_class
);
273 right_stream_class_name
= bt_stream_class_get_name(right_stream_class
);
275 if (left_stream_class_name
&& right_stream_class_name
) {
276 ret
= strcmp(left_stream_class_name
, right_stream_class_name
);
280 } else if (!left_stream_class_name
&& right_stream_class_name
) {
283 } else if (left_stream_class_name
&& !right_stream_class_name
) {
288 /* Compare stream class automatic event class id assignment. */
289 if (bt_stream_class_assigns_automatic_event_class_id(left_stream_class
) &&
290 !bt_stream_class_assigns_automatic_event_class_id(right_stream_class
)) {
293 } else if (!bt_stream_class_assigns_automatic_event_class_id(left_stream_class
) &&
294 bt_stream_class_assigns_automatic_event_class_id(right_stream_class
)) {
299 /* Compare stream class automatic stream id assignment. */
300 if (bt_stream_class_assigns_automatic_stream_id(left_stream_class
) &&
301 !bt_stream_class_assigns_automatic_stream_id(right_stream_class
)) {
304 } else if (!bt_stream_class_assigns_automatic_stream_id(left_stream_class
) &&
305 bt_stream_class_assigns_automatic_stream_id(right_stream_class
)) {
310 /* Compare stream class support of discarded events. */
311 if (bt_stream_class_supports_discarded_events(left_stream_class
) &&
312 !bt_stream_class_supports_discarded_events(right_stream_class
)) {
315 } else if (!bt_stream_class_supports_discarded_events(left_stream_class
) &&
316 bt_stream_class_supports_discarded_events(right_stream_class
)) {
321 /* Compare stream class discarded events default clock snapshot. */
322 if (bt_stream_class_discarded_events_have_default_clock_snapshots(left_stream_class
) &&
323 !bt_stream_class_discarded_events_have_default_clock_snapshots(right_stream_class
)) {
326 } else if (!bt_stream_class_discarded_events_have_default_clock_snapshots(left_stream_class
) &&
327 bt_stream_class_discarded_events_have_default_clock_snapshots(right_stream_class
)) {
332 /* Compare stream class support of packets. */
333 if (bt_stream_class_supports_packets(left_stream_class
) &&
334 !bt_stream_class_supports_packets(right_stream_class
)) {
337 } else if (!bt_stream_class_supports_packets(left_stream_class
) &&
338 bt_stream_class_supports_packets(right_stream_class
)) {
343 if (bt_stream_class_supports_packets(left_stream_class
)) {
345 * Compare stream class presence of discarded packets beginning default
348 if (bt_stream_class_packets_have_beginning_default_clock_snapshot(left_stream_class
) &&
349 !bt_stream_class_packets_have_beginning_default_clock_snapshot(right_stream_class
)) {
352 } else if (!bt_stream_class_packets_have_beginning_default_clock_snapshot(left_stream_class
) &&
353 bt_stream_class_packets_have_beginning_default_clock_snapshot(right_stream_class
)) {
359 * Compare stream class presence of discarded packets end default clock
362 if (bt_stream_class_packets_have_end_default_clock_snapshot(left_stream_class
) &&
363 !bt_stream_class_packets_have_end_default_clock_snapshot(right_stream_class
)) {
366 } else if (!bt_stream_class_packets_have_end_default_clock_snapshot(left_stream_class
) &&
367 bt_stream_class_packets_have_end_default_clock_snapshot(right_stream_class
)) {
372 /* Compare stream class support of discarded packets. */
373 if (bt_stream_class_supports_discarded_packets(left_stream_class
) &&
374 !bt_stream_class_supports_discarded_packets(right_stream_class
)) {
377 } else if (!bt_stream_class_supports_discarded_packets(left_stream_class
) &&
378 bt_stream_class_supports_discarded_packets(right_stream_class
)) {
383 /* Compare stream class discarded packets default clock snapshot. */
384 if (bt_stream_class_discarded_packets_have_default_clock_snapshots(left_stream_class
) &&
385 !bt_stream_class_discarded_packets_have_default_clock_snapshots(right_stream_class
)) {
388 } else if (!bt_stream_class_discarded_packets_have_default_clock_snapshots(left_stream_class
) &&
389 bt_stream_class_discarded_packets_have_default_clock_snapshots(right_stream_class
)) {
395 /* Compare the clock classes associated to the stream classes. */
396 left_cc
= bt_stream_class_borrow_default_clock_class_const(left_stream_class
);
397 right_cc
= bt_stream_class_borrow_default_clock_class_const(right_stream_class
);
399 if (!left_cc
&& !right_cc
) {
400 ret
= compare_clock_classes(left_cc
, right_cc
);
405 } else if (left_cc
&& !right_cc
) {
408 } else if (!left_cc
&& right_cc
) {
418 int compare_clock_snapshots(const bt_clock_snapshot
*left_cs
,
419 const bt_clock_snapshot
*right_cs
)
421 uint64_t left_cs_value
= bt_clock_snapshot_get_value(left_cs
);
422 uint64_t right_cs_value
= bt_clock_snapshot_get_value(right_cs
);
424 return left_cs_value
- right_cs_value
;
428 const bt_stream
*borrow_stream(const bt_message
*msg
)
430 bt_message_type msg_type
= bt_message_get_type(msg
);
431 const bt_stream
*stream
= NULL
;
432 const bt_packet
*packet
= NULL
;
433 const bt_event
*event
= NULL
;
436 case BT_MESSAGE_TYPE_STREAM_BEGINNING
:
437 stream
= bt_message_stream_beginning_borrow_stream_const(msg
);
439 case BT_MESSAGE_TYPE_STREAM_END
:
440 stream
= bt_message_stream_end_borrow_stream_const(msg
);
442 case BT_MESSAGE_TYPE_PACKET_BEGINNING
:
443 packet
= bt_message_packet_beginning_borrow_packet_const(msg
);
444 stream
= bt_packet_borrow_stream_const(packet
);
446 case BT_MESSAGE_TYPE_PACKET_END
:
447 packet
= bt_message_packet_end_borrow_packet_const(msg
);
448 stream
= bt_packet_borrow_stream_const(packet
);
450 case BT_MESSAGE_TYPE_EVENT
:
451 event
= bt_message_event_borrow_event_const(msg
);
452 stream
= bt_event_borrow_stream_const(event
);
454 case BT_MESSAGE_TYPE_DISCARDED_EVENTS
:
455 stream
= bt_message_discarded_events_borrow_stream_const(msg
);
457 case BT_MESSAGE_TYPE_DISCARDED_PACKETS
:
458 stream
= bt_message_discarded_packets_borrow_stream_const(msg
);
460 case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY
:
471 const bt_trace
*borrow_trace(const bt_message
*msg
)
473 const bt_trace
*trace
= NULL
;
474 const bt_stream
*stream
= NULL
;
476 stream
= borrow_stream(msg
);
478 trace
= bt_stream_borrow_trace_const(stream
);
485 int compare_messages_by_trace_name(struct messages_to_compare
*msgs
)
488 const char *left_trace_name
= NULL
, *right_trace_name
= NULL
;
490 if (msgs
->left
.trace
&& !msgs
->right
.trace
) {
495 if (!msgs
->left
.trace
&& msgs
->right
.trace
) {
500 if (!msgs
->left
.trace
&& !msgs
->right
.trace
) {
505 left_trace_name
= bt_trace_get_name(msgs
->left
.trace
);
506 right_trace_name
= bt_trace_get_name(msgs
->right
.trace
);
508 if (left_trace_name
&& !right_trace_name
) {
513 if (!left_trace_name
&& right_trace_name
) {
518 if (!left_trace_name
&& !right_trace_name
) {
523 ret
= strcmp(left_trace_name
, right_trace_name
);
529 int compare_messages_by_trace_uuid(struct messages_to_compare
*msgs
)
532 bt_uuid left_trace_uuid
= NULL
, right_trace_uuid
= NULL
;
534 if (msgs
->left
.trace
&& !msgs
->right
.trace
) {
539 if (!msgs
->left
.trace
&& msgs
->right
.trace
) {
544 if (!msgs
->left
.trace
&& !msgs
->right
.trace
) {
549 left_trace_uuid
= bt_trace_get_uuid(msgs
->left
.trace
);
550 right_trace_uuid
= bt_trace_get_uuid(msgs
->right
.trace
);
552 if (left_trace_uuid
&& !right_trace_uuid
) {
557 if (!left_trace_uuid
&& right_trace_uuid
) {
562 if (!left_trace_uuid
&& !right_trace_uuid
) {
567 ret
= bt_uuid_compare(left_trace_uuid
, right_trace_uuid
);
573 int compare_messages_by_stream_class_id(struct messages_to_compare
*msgs
)
576 uint64_t left_stream_class_id
= 0, right_stream_class_id
= 0;
578 if (msgs
->left
.stream
&& !msgs
->right
.stream
) {
583 if (!msgs
->left
.stream
&& msgs
->right
.stream
) {
588 if (!msgs
->left
.stream
&& !msgs
->right
.stream
) {
593 left_stream_class_id
= bt_stream_class_get_id(
594 bt_stream_borrow_class_const(msgs
->left
.stream
));
596 right_stream_class_id
= bt_stream_class_get_id(
597 bt_stream_borrow_class_const(msgs
->right
.stream
));
599 if (left_stream_class_id
== right_stream_class_id
) {
604 ret
= (left_stream_class_id
< right_stream_class_id
) ? -1 : 1;
611 int compare_messages_by_stream_id(struct messages_to_compare
*msgs
)
614 uint64_t left_stream_id
= 0, right_stream_id
= 0;
616 if (msgs
->left
.stream
&& !msgs
->right
.stream
) {
621 if (!msgs
->left
.stream
&& msgs
->right
.stream
) {
626 if (!msgs
->left
.stream
&& !msgs
->right
.stream
) {
631 left_stream_id
= bt_stream_get_id(msgs
->left
.stream
);
632 right_stream_id
= bt_stream_get_id(msgs
->right
.stream
);
634 if (left_stream_id
== right_stream_id
) {
639 ret
= (left_stream_id
< right_stream_id
) ? -1 : 1;
646 int compare_messages_same_type(struct messages_to_compare
*msgs
)
651 * Both messages are of the same type, we must compare characteristics of
652 * the messages such as the attributes of the event in a event message.
654 BT_ASSERT_DBG(bt_message_get_type(msgs
->left
.msg
) ==
655 bt_message_get_type(msgs
->right
.msg
));
657 switch (bt_message_get_type(msgs
->left
.msg
)) {
658 case BT_MESSAGE_TYPE_STREAM_BEGINNING
:
660 case BT_MESSAGE_TYPE_STREAM_END
:
662 case BT_MESSAGE_TYPE_PACKET_BEGINNING
:
664 case BT_MESSAGE_TYPE_PACKET_END
:
665 ret
= compare_streams(msgs
->left
.stream
, msgs
->right
.stream
);
671 case BT_MESSAGE_TYPE_EVENT
:
673 const bt_event
*left_event
, *right_event
;
674 left_event
= bt_message_event_borrow_event_const(msgs
->left
.msg
);
675 right_event
= bt_message_event_borrow_event_const(msgs
->right
.msg
);
677 ret
= compare_events(left_event
, right_event
);
682 ret
= compare_streams(msgs
->left
.stream
, msgs
->right
.stream
);
688 case BT_MESSAGE_TYPE_DISCARDED_EVENTS
:
690 const bt_stream_class
*left_stream_class
;
691 bt_property_availability left_event_count_avail
,
692 right_event_count_avail
;
693 uint64_t left_event_count
, right_event_count
;
696 * Compare streams first to check if there is a
697 * mismatch about discarded event related configuration
698 * in the stream class.
700 ret
= compare_streams(msgs
->left
.stream
, msgs
->right
.stream
);
705 left_stream_class
= bt_stream_borrow_class_const(msgs
->left
.stream
);
706 if (bt_stream_class_discarded_events_have_default_clock_snapshots(
707 left_stream_class
)) {
708 const bt_clock_snapshot
*left_beg_cs
=
709 bt_message_discarded_events_borrow_beginning_default_clock_snapshot_const(msgs
->left
.msg
);
710 const bt_clock_snapshot
*right_beg_cs
=
711 bt_message_discarded_events_borrow_beginning_default_clock_snapshot_const(msgs
->right
.msg
);
712 const bt_clock_snapshot
*left_end_cs
=
713 bt_message_discarded_events_borrow_end_default_clock_snapshot_const(msgs
->left
.msg
);
714 const bt_clock_snapshot
*right_end_cs
=
715 bt_message_discarded_events_borrow_end_default_clock_snapshot_const(msgs
->right
.msg
);
717 ret
= compare_clock_snapshots(left_beg_cs
, right_beg_cs
);
722 ret
= compare_clock_snapshots(left_end_cs
, right_end_cs
);
727 ret
= compare_clock_classes(
728 bt_clock_snapshot_borrow_clock_class_const(left_beg_cs
),
729 bt_clock_snapshot_borrow_clock_class_const(right_beg_cs
));
735 left_event_count_avail
=
736 bt_message_discarded_events_get_count(
737 msgs
->left
.msg
, &left_event_count
);
738 right_event_count_avail
=
739 bt_message_discarded_events_get_count(
740 msgs
->right
.msg
, &right_event_count
);
741 if (left_event_count_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
&&
742 right_event_count_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
) {
743 ret
= left_event_count
- right_event_count
;
747 } else if (left_event_count_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
&&
748 right_event_count_avail
== BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE
) {
751 } else if (left_event_count_avail
== BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE
&&
752 right_event_count_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
) {
759 case BT_MESSAGE_TYPE_DISCARDED_PACKETS
:
761 const bt_stream_class
*left_stream_class
;
762 bt_property_availability left_packet_count_avail
,
763 right_packet_count_avail
;
764 uint64_t left_packet_count
, right_packet_count
;
767 * Compare streams first to check if there is a
768 * mismatch about discarded packets related
769 * configuration in the stream class.
771 ret
= compare_streams(msgs
->left
.stream
, msgs
->right
.stream
);
776 left_stream_class
= bt_stream_borrow_class_const(msgs
->left
.stream
);
778 if (bt_stream_class_discarded_packets_have_default_clock_snapshots(
779 left_stream_class
)) {
780 const bt_clock_snapshot
*left_beg_cs
=
781 bt_message_discarded_packets_borrow_beginning_default_clock_snapshot_const(msgs
->left
.msg
);
782 const bt_clock_snapshot
*right_beg_cs
=
783 bt_message_discarded_packets_borrow_beginning_default_clock_snapshot_const(msgs
->right
.msg
);
784 const bt_clock_snapshot
*left_end_cs
=
785 bt_message_discarded_packets_borrow_end_default_clock_snapshot_const(msgs
->left
.msg
);
786 const bt_clock_snapshot
*right_end_cs
=
787 bt_message_discarded_packets_borrow_end_default_clock_snapshot_const(msgs
->right
.msg
);
789 ret
= compare_clock_snapshots(left_beg_cs
, right_beg_cs
);
794 ret
= compare_clock_snapshots(left_end_cs
, right_end_cs
);
799 ret
= compare_clock_classes(
800 bt_clock_snapshot_borrow_clock_class_const(left_beg_cs
),
801 bt_clock_snapshot_borrow_clock_class_const(right_beg_cs
));
807 left_packet_count_avail
= bt_message_discarded_packets_get_count(
808 msgs
->left
.msg
, &left_packet_count
);
809 right_packet_count_avail
= bt_message_discarded_packets_get_count(
810 msgs
->right
.msg
, &right_packet_count
);
811 if (left_packet_count_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
&&
812 right_packet_count_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
) {
813 ret
= left_packet_count
- right_packet_count
;
817 } else if (left_packet_count_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
&&
818 right_packet_count_avail
== BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE
) {
821 } else if (left_packet_count_avail
== BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE
&&
822 right_packet_count_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
) {
829 case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY
:
831 const bt_clock_snapshot
*left_cs
=
832 bt_message_message_iterator_inactivity_borrow_clock_snapshot_const(msgs
->left
.msg
);
833 const bt_clock_snapshot
*right_cs
=
834 bt_message_message_iterator_inactivity_borrow_clock_snapshot_const(msgs
->right
.msg
);
836 ret
= compare_clock_snapshots(left_cs
, right_cs
);
841 ret
= compare_clock_classes(
842 bt_clock_snapshot_borrow_clock_class_const(left_cs
),
843 bt_clock_snapshot_borrow_clock_class_const(right_cs
));
858 int common_muxing_compare_messages(const bt_message
*left_msg
,
859 const bt_message
*right_msg
)
862 struct messages_to_compare msgs
;
864 BT_ASSERT_DBG(left_msg
!= right_msg
);
866 msgs
.left
.msg
= left_msg
;
867 msgs
.left
.trace
= borrow_trace(left_msg
);
868 msgs
.left
.stream
= borrow_stream(left_msg
);
870 msgs
.right
.msg
= right_msg
;
871 msgs
.right
.trace
= borrow_trace(right_msg
);
872 msgs
.right
.stream
= borrow_stream(right_msg
);
874 /* Same timestamp: compare trace UUIDs. */
875 ret
= compare_messages_by_trace_uuid(&msgs
);
880 /* Same timestamp and trace UUID: compare trace names. */
881 ret
= compare_messages_by_trace_name(&msgs
);
887 * Same timestamp, trace name, and trace UUID: compare stream class
890 ret
= compare_messages_by_stream_class_id(&msgs
);
896 * Same timestamp, trace name, trace UUID, and stream class ID: compare
899 ret
= compare_messages_by_stream_id(&msgs
);
904 if (bt_message_get_type(msgs
.left
.msg
) !=
905 bt_message_get_type(msgs
.right
.msg
)) {
907 * The messages are of different type, we order (arbitrarily)
908 * in the following way:
909 * SB < PB < EV < DE < MI < PE < DP < SE
911 ret
= compare_messages_by_type(&msgs
);
916 /* The messages are of the same type. */
917 ret
= compare_messages_same_type(&msgs
);