-BT_ASSERT_PRE_FUNC static inline
-bt_bool validate_clock_classes(struct bt_notification_event *notif)
-{
- /*
- * For each clock class found in the notification's clock class
- * priority map, make sure the event has a clock value set for
- * this clock class. Also make sure that those clock classes
- * are part of the trace to which the event belongs.
- */
- bt_bool is_valid = BT_TRUE;
-
- int trace_cc_count;
- int cc_prio_map_cc_count;
- size_t cc_prio_map_cc_i, trace_cc_i;
- struct bt_clock_value *clock_value = NULL;
- struct bt_clock_class *clock_class = NULL;
- struct bt_event_class *event_class = NULL;
- struct bt_stream_class *stream_class = NULL;
- struct bt_trace *trace = NULL;
-
- event_class = bt_event_borrow_class(notif->event);
- BT_ASSERT(event_class);
- stream_class = bt_event_class_borrow_stream_class(event_class);
- BT_ASSERT(stream_class);
- trace = bt_stream_class_borrow_trace(stream_class);
- BT_ASSERT(trace);
- trace_cc_count = bt_trace_get_clock_class_count(trace);
- BT_ASSERT(trace_cc_count >= 0);
- cc_prio_map_cc_count =
- bt_clock_class_priority_map_get_clock_class_count(
- notif->cc_prio_map);
- BT_ASSERT(cc_prio_map_cc_count >= 0);
-
- for (cc_prio_map_cc_i = 0; cc_prio_map_cc_i < cc_prio_map_cc_count;
- cc_prio_map_cc_i++) {
- bt_bool found_in_trace = BT_FALSE;
-
- clock_class =
- bt_clock_class_priority_map_get_clock_class_by_index(
- notif->cc_prio_map, cc_prio_map_cc_i);
- BT_ASSERT(clock_class);
- clock_value = bt_event_get_clock_value(notif->event,
- clock_class);
- if (!clock_value) {
- BT_ASSERT_PRE_MSG("Event has no clock value for a clock class which exists in the notification's clock class priority map: "
- "notif-addr=%p, event-addr=%p, "
- "event-class-addr=%p, event-class-name=\"%s\", "
- "event-class-id=%" PRId64 ", "
- "cc-prio-map-addr=%p, "
- "clock-class-addr=%p, clock-class-name=\"%s\"",
- notif, notif->event, event_class,
- bt_event_class_get_name(event_class),
- bt_event_class_get_id(event_class),
- notif->cc_prio_map, clock_class,
- bt_clock_class_get_name(clock_class));
- is_valid = BT_FALSE;
- goto end;
- }
-
- for (trace_cc_i = 0; trace_cc_i < trace_cc_count;
- trace_cc_i++) {
- struct bt_clock_class *trace_clock_class =
- bt_trace_get_clock_class_by_index(trace,
- trace_cc_i);
-
- BT_ASSERT(trace_clock_class);
- bt_put(trace_clock_class);
-
- if (trace_clock_class == clock_class) {
- found_in_trace = BT_TRUE;
- break;
- }
- }
-
- if (!found_in_trace) {
- BT_ASSERT_PRE_MSG("A clock class found in the event notification's clock class priority map does not exist in the notification's event's trace: "
- "notif-addr=%p, trace-addr=%p, "
- "trace-name=\"%s\", cc-prio-map-addr=%p, "
- "clock-class-addr=%p, clock-class-name=\"%s\"",
- notif, trace, bt_trace_get_name(trace),
- notif->cc_prio_map, clock_class,
- bt_clock_class_get_name(clock_class));
- is_valid = BT_FALSE;
- goto end;
- }
-
- BT_PUT(clock_value);
- BT_PUT(clock_class);
- }
-
-end:
- bt_put(clock_value);
- bt_put(clock_class);
- return is_valid;
-}
-