4 * Babeltrace CTF IR - Stream Class
6 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 #define BT_LOG_TAG "STREAM-CLASS"
30 #include <babeltrace/lib-logging-internal.h>
32 #include <babeltrace/assert-pre-internal.h>
33 #include <babeltrace/ctf-ir/clock-class-internal.h>
34 #include <babeltrace/ctf-ir/event-class-internal.h>
35 #include <babeltrace/ctf-ir/field-types-internal.h>
36 #include <babeltrace/ctf-ir/fields-internal.h>
37 #include <babeltrace/ctf-ir/stream-class-internal.h>
38 #include <babeltrace/ctf-ir/validation-internal.h>
39 #include <babeltrace/ctf-ir/visitor-internal.h>
40 #include <babeltrace/ctf-ir/utils.h>
41 #include <babeltrace/ctf-ir/utils-internal.h>
42 #include <babeltrace/ctf-ir/field-wrapper-internal.h>
43 #include <babeltrace/ref.h>
44 #include <babeltrace/compiler-internal.h>
45 #include <babeltrace/align-internal.h>
46 #include <babeltrace/endian-internal.h>
47 #include <babeltrace/assert-internal.h>
53 int bt_stream_class_common_initialize(struct bt_stream_class_common
*stream_class
,
54 const char *name
, bt_object_release_func release_func
)
56 BT_LOGD("Initializing common stream class object: name=\"%s\"", name
);
58 bt_object_init(stream_class
, release_func
);
59 stream_class
->name
= g_string_new(name
);
60 stream_class
->event_classes
= g_ptr_array_new_with_free_func(
61 (GDestroyNotify
) bt_object_release
);
62 if (!stream_class
->event_classes
) {
63 BT_LOGE_STR("Failed to allocate a GPtrArray.");
67 stream_class
->event_classes_ht
= g_hash_table_new_full(g_int64_hash
,
68 g_int64_equal
, g_free
, NULL
);
69 if (!stream_class
->event_classes_ht
) {
70 BT_LOGE_STR("Failed to allocate a GHashTable.");
74 BT_LOGD("Initialized common stream class object: addr=%p, name=\"%s\"",
83 void bt_stream_class_common_finalize(struct bt_stream_class_common
*stream_class
)
85 BT_LOGD("Finalizing common stream class: addr=%p, name=\"%s\", id=%" PRId64
,
86 stream_class
, bt_stream_class_common_get_name(stream_class
),
87 bt_stream_class_common_get_id(stream_class
));
88 bt_put(stream_class
->clock_class
);
90 if (stream_class
->event_classes_ht
) {
91 g_hash_table_destroy(stream_class
->event_classes_ht
);
93 if (stream_class
->event_classes
) {
94 BT_LOGD_STR("Destroying event classes.");
95 g_ptr_array_free(stream_class
->event_classes
, TRUE
);
98 if (stream_class
->name
) {
99 g_string_free(stream_class
->name
, TRUE
);
102 BT_LOGD_STR("Putting event header field type.");
103 bt_put(stream_class
->event_header_field_type
);
104 BT_LOGD_STR("Putting packet context field type.");
105 bt_put(stream_class
->packet_context_field_type
);
106 BT_LOGD_STR("Putting event context field type.");
107 bt_put(stream_class
->event_context_field_type
);
111 void bt_stream_class_destroy(struct bt_object
*obj
)
113 struct bt_stream_class
*stream_class
;
115 stream_class
= (void *) obj
;
116 BT_LOGD("Destroying stream class: addr=%p, name=\"%s\", id=%" PRId64
,
117 stream_class
, bt_stream_class_get_name(stream_class
),
118 bt_stream_class_get_id(stream_class
));
121 * IMPORTANT: Finalize the common stream class BEFORE finalizing
122 * the pools because otherwise this scenario is possible:
124 * 1. Event header field object pool is finalized, thus
125 * destroying its internal array and state.
127 * 2. Stream class is finalized: each event class is destroyed.
129 * 3. Destroying an event class finalizes its event pool,
130 * destroying each contained event.
132 * 4. Destroying an event makes it recycle its event header
133 * field to its stream class's event header field pool. But
134 * said pool is already destroyed.
136 bt_stream_class_common_finalize(BT_TO_COMMON(stream_class
));
137 bt_object_pool_finalize(&stream_class
->event_header_field_pool
);
138 bt_object_pool_finalize(&stream_class
->packet_context_field_pool
);
139 g_free(stream_class
);
143 void free_field_wrapper(struct bt_field_wrapper
*field_wrapper
,
144 struct bt_stream_class
*stream_class
)
146 bt_field_wrapper_destroy((void *) field_wrapper
);
149 struct bt_stream_class
*bt_stream_class_create(const char *name
)
151 struct bt_stream_class
*stream_class
= NULL
;
154 BT_LOGD("Creating stream class object: name=\"%s\"", name
);
155 stream_class
= g_new0(struct bt_stream_class
, 1);
157 BT_LOGE_STR("Failed to allocate one stream class.");
161 ret
= bt_stream_class_common_initialize(BT_TO_COMMON(stream_class
),
162 name
, bt_stream_class_destroy
);
164 /* bt_stream_class_common_initialize() logs errors */
168 ret
= bt_object_pool_initialize(&stream_class
->event_header_field_pool
,
169 (bt_object_pool_new_object_func
) bt_field_wrapper_new
,
170 (bt_object_pool_destroy_object_func
) free_field_wrapper
,
173 BT_LOGE("Failed to initialize event header field pool: ret=%d",
178 ret
= bt_object_pool_initialize(&stream_class
->packet_context_field_pool
,
179 (bt_object_pool_new_object_func
) bt_field_wrapper_new
,
180 (bt_object_pool_destroy_object_func
) free_field_wrapper
,
183 BT_LOGE("Failed to initialize packet context field pool: ret=%d",
188 BT_LOGD("Created stream class object: addr=%p, name=\"%s\"",
193 bt_put(stream_class
);
197 struct bt_event_header_field
*bt_stream_class_create_event_header_field(
198 struct bt_stream_class
*stream_class
)
200 struct bt_field_wrapper
*field_wrapper
;
202 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
203 BT_ASSERT_PRE(stream_class
->common
.frozen
,
204 "Stream class is not part of a trace: %!+S", stream_class
);
205 BT_ASSERT_PRE(stream_class
->common
.event_header_field_type
,
206 "Stream class has no event header field type: %!+S",
208 field_wrapper
= bt_field_wrapper_create(
209 &stream_class
->event_header_field_pool
,
210 (void *) stream_class
->common
.event_header_field_type
);
211 if (!field_wrapper
) {
212 BT_LIB_LOGE("Cannot allocate one event header field from stream class: "
213 "%![sc-]+S", stream_class
);
217 BT_ASSERT(field_wrapper
->field
);
222 bt_field_wrapper_destroy(field_wrapper
);
223 field_wrapper
= NULL
;
227 return (void *) field_wrapper
;
230 struct bt_packet_context_field
*bt_stream_class_create_packet_context_field(
231 struct bt_stream_class
*stream_class
)
233 struct bt_field_wrapper
*field_wrapper
;
235 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
236 BT_ASSERT_PRE(stream_class
->common
.frozen
,
237 "Stream class is not part of a trace: %!+S", stream_class
);
238 BT_ASSERT_PRE(stream_class
->common
.packet_context_field_type
,
239 "Stream class has no packet context field type: %!+S",
241 field_wrapper
= bt_field_wrapper_create(
242 &stream_class
->packet_context_field_pool
,
243 (void *) stream_class
->common
.packet_context_field_type
);
244 if (!field_wrapper
) {
245 BT_LIB_LOGE("Cannot allocate one packet context field from stream class: "
246 "%![sc-]+S", stream_class
);
250 BT_ASSERT(field_wrapper
->field
);
255 bt_field_wrapper_destroy(field_wrapper
);
256 field_wrapper
= NULL
;
260 return (void *) field_wrapper
;
263 struct bt_trace
*bt_stream_class_borrow_trace(struct bt_stream_class
*stream_class
)
265 return BT_FROM_COMMON(bt_stream_class_common_borrow_trace(
266 BT_TO_COMMON(stream_class
)));
269 const char *bt_stream_class_get_name(struct bt_stream_class
*stream_class
)
271 return bt_stream_class_common_get_name(BT_TO_COMMON(stream_class
));
274 int bt_stream_class_set_name(struct bt_stream_class
*stream_class
,
277 return bt_stream_class_common_set_name(BT_TO_COMMON(stream_class
),
281 int64_t bt_stream_class_get_id(struct bt_stream_class
*stream_class
)
283 return bt_stream_class_common_get_id(BT_TO_COMMON(stream_class
));
286 int bt_stream_class_set_id(struct bt_stream_class
*stream_class
, uint64_t id
)
288 return bt_stream_class_common_set_id(BT_TO_COMMON(stream_class
), id
);
292 void event_class_exists(gpointer element
, gpointer query
)
294 struct bt_event_class_common
*event_class_a
= element
;
295 struct search_query
*search_query
= query
;
296 struct bt_event_class_common
*event_class_b
= search_query
->value
;
299 if (search_query
->value
== element
) {
300 search_query
->found
= 1;
305 * Two event classes cannot share the same ID in a given
308 id_a
= bt_event_class_common_get_id(event_class_a
);
309 id_b
= bt_event_class_common_get_id(event_class_b
);
311 if (id_a
< 0 || id_b
< 0) {
312 /* at least one ID is not set: will be automatically set later */
317 BT_LOGW("Event class with this ID already exists in the stream class: "
318 "id=%" PRId64
", name=\"%s\"",
319 id_a
, bt_event_class_common_get_name(event_class_a
));
320 search_query
->found
= 1;
329 int bt_stream_class_common_add_event_class(
330 struct bt_stream_class_common
*stream_class
,
331 struct bt_event_class_common
*event_class
,
332 bt_validation_flag_copy_field_type_func copy_field_type_func
)
335 int64_t *event_id
= NULL
;
336 struct bt_trace_common
*trace
= NULL
;
337 struct bt_stream_class_common
*old_stream_class
= NULL
;
338 struct bt_validation_output validation_output
= { 0 };
339 struct bt_field_type_common
*packet_header_type
= NULL
;
340 struct bt_field_type_common
*packet_context_type
= NULL
;
341 struct bt_field_type_common
*event_header_type
= NULL
;
342 struct bt_field_type_common
*stream_event_ctx_type
= NULL
;
343 struct bt_field_type_common
*event_context_type
= NULL
;
344 struct bt_field_type_common
*event_payload_type
= NULL
;
345 const enum bt_validation_flag validation_flags
=
346 BT_VALIDATION_FLAG_EVENT
;
347 struct bt_clock_class
*expected_clock_class
= NULL
;
349 BT_ASSERT(copy_field_type_func
);
351 if (!stream_class
|| !event_class
) {
352 BT_LOGW("Invalid parameter: stream class or event class is NULL: "
353 "stream-class-addr=%p, event-class-addr=%p",
354 stream_class
, event_class
);
359 BT_LOGD("Adding event class to stream class: "
360 "stream-class-addr=%p, stream-class-name=\"%s\", "
361 "stream-class-id=%" PRId64
", event-class-addr=%p, "
362 "event-class-name=\"%s\", event-class-id=%" PRId64
,
363 stream_class
, bt_stream_class_common_get_name(stream_class
),
364 bt_stream_class_common_get_id(stream_class
),
366 bt_event_class_common_get_name(event_class
),
367 bt_event_class_common_get_id(event_class
));
368 trace
= bt_stream_class_common_borrow_trace(stream_class
);
370 if (stream_class
->frozen
) {
372 * We only check that the event class to be added has a
373 * single class which matches the stream class's
374 * expected clock class if the stream class is frozen.
375 * If it's not, then this event class is added "as is"
376 * and the validation will be performed when calling
377 * either bt_trace_add_stream_class() or
378 * bt_event_create(). This is because the stream class's
379 * field types (packet context, event header, event
380 * context) could change before the next call to one of
381 * those two functions.
383 expected_clock_class
= bt_get(stream_class
->clock_class
);
386 * At this point, `expected_clock_class` can be NULL,
387 * and bt_event_class_validate_single_clock_class()
390 ret
= bt_event_class_common_validate_single_clock_class(
391 event_class
, &expected_clock_class
);
393 BT_LOGW("Event class contains a field type which is not "
394 "recursively mapped to its stream class's "
395 "expected clock class: "
396 "stream-class-addr=%p, "
397 "stream-class-id=%" PRId64
", "
398 "stream-class-name=\"%s\", "
399 "expected-clock-class-addr=%p, "
400 "expected-clock-class-name=\"%s\"",
402 bt_stream_class_common_get_id(stream_class
),
403 bt_stream_class_common_get_name(stream_class
),
404 expected_clock_class
,
405 expected_clock_class
?
406 bt_clock_class_get_name(expected_clock_class
) :
412 event_id
= g_new(int64_t, 1);
414 BT_LOGE_STR("Failed to allocate one int64_t.");
419 /* Check for duplicate event classes */
420 struct search_query query
= { .value
= event_class
, .found
= 0 };
421 g_ptr_array_foreach(stream_class
->event_classes
, event_class_exists
,
424 BT_LOGW_STR("Another event class part of this stream class has the same ID.");
429 old_stream_class
= bt_event_class_common_borrow_stream_class(event_class
);
430 if (old_stream_class
) {
431 /* Event class is already associated to a stream class. */
432 BT_LOGW("Event class is already part of another stream class: "
433 "event-class-stream-class-addr=%p, "
434 "event-class-stream-class-name=\"%s\", "
435 "event-class-stream-class-id=%" PRId64
,
437 bt_stream_class_common_get_name(old_stream_class
),
438 bt_stream_class_common_get_id(old_stream_class
));
445 * If the stream class is associated with a trace, then
446 * both those objects are frozen. Also, this event class
447 * is about to be frozen.
449 * Therefore the event class must be validated here.
450 * The trace and stream class should be valid at this
453 BT_ASSERT(trace
->valid
);
454 BT_ASSERT(stream_class
->valid
);
456 bt_trace_common_borrow_packet_header_field_type(trace
);
457 packet_context_type
=
458 bt_stream_class_common_borrow_packet_context_field_type(
461 bt_stream_class_common_borrow_event_header_field_type(
463 stream_event_ctx_type
=
464 bt_stream_class_common_borrow_event_context_field_type(
467 bt_event_class_common_borrow_context_field_type(
470 bt_event_class_common_borrow_payload_field_type(
472 ret
= bt_validate_class_types(
473 trace
->environment
, packet_header_type
,
474 packet_context_type
, event_header_type
,
475 stream_event_ctx_type
, event_context_type
,
476 event_payload_type
, trace
->valid
,
477 stream_class
->valid
, event_class
->valid
,
478 &validation_output
, validation_flags
,
479 copy_field_type_func
);
483 * This means something went wrong during the
484 * validation process, not that the objects are
487 BT_LOGE("Failed to validate event class: ret=%d", ret
);
491 if ((validation_output
.valid_flags
& validation_flags
) !=
493 /* Invalid event class */
494 BT_LOGW("Invalid trace, stream class, or event class: "
496 validation_output
.valid_flags
);
502 /* Only set an event ID if none was explicitly set before */
503 *event_id
= bt_event_class_common_get_id(event_class
);
505 BT_LOGV("Event class has no ID: automatically setting it: "
506 "id=%" PRId64
, stream_class
->next_event_id
);
508 if (bt_event_class_common_set_id(event_class
,
509 stream_class
->next_event_id
)) {
510 BT_LOGE("Cannot set event class's ID: id=%" PRId64
,
511 stream_class
->next_event_id
);
515 stream_class
->next_event_id
++;
516 *event_id
= stream_class
->next_event_id
;
519 bt_object_set_parent(event_class
, stream_class
);
523 * At this point we know that the function will be
524 * successful. Therefore we can replace the event
525 * class's field types with what's in the validation
526 * output structure and mark this event class as valid.
528 bt_validation_replace_types(NULL
, NULL
, event_class
,
529 &validation_output
, validation_flags
);
530 event_class
->valid
= 1;
533 * Put what was not moved in
534 * bt_validation_replace_types().
536 bt_validation_output_put_types(&validation_output
);
539 /* Add to the event classes of the stream class */
540 g_ptr_array_add(stream_class
->event_classes
, event_class
);
541 g_hash_table_insert(stream_class
->event_classes_ht
, event_id
,
545 /* Freeze the event class */
546 bt_event_class_common_freeze(event_class
);
549 * It is safe to set the stream class's unique clock class
550 * now if the stream class is frozen.
552 if (stream_class
->frozen
&& expected_clock_class
) {
553 BT_ASSERT(!stream_class
->clock_class
||
554 stream_class
->clock_class
== expected_clock_class
);
555 BT_MOVE(stream_class
->clock_class
, expected_clock_class
);
558 BT_LOGD("Added event class to stream class: "
559 "stream-class-addr=%p, stream-class-name=\"%s\", "
560 "stream-class-id=%" PRId64
", event-class-addr=%p, "
561 "event-class-name=\"%s\", event-class-id=%" PRId64
,
562 stream_class
, bt_stream_class_common_get_name(stream_class
),
563 bt_stream_class_common_get_id(stream_class
),
565 bt_event_class_common_get_name(event_class
),
566 bt_event_class_common_get_id(event_class
));
569 bt_validation_output_put_types(&validation_output
);
570 bt_put(expected_clock_class
);
575 int bt_stream_class_add_event_class(
576 struct bt_stream_class
*stream_class
,
577 struct bt_event_class
*event_class
)
579 struct bt_trace
*trace
;
582 struct bt_clock_class
*old_clock_class
;
585 BT_LOGW("Invalid parameter: stream class is NULL: "
586 "stream-class-addr=%p", stream_class
);
591 old_clock_class
= stream_class
->common
.clock_class
;
592 trace
= BT_FROM_COMMON(bt_stream_class_common_borrow_trace(
593 BT_TO_COMMON(stream_class
)));
594 if (trace
&& trace
->is_static
) {
595 BT_LOGW("Invalid parameter: stream class's trace is static: "
596 "trace-addr=%p, trace-name=\"%s\"",
597 trace
, bt_trace_get_name(trace
));
602 ret
= bt_stream_class_common_add_event_class(
603 BT_TO_COMMON(stream_class
), BT_TO_COMMON(event_class
),
604 (bt_validation_flag_copy_field_type_func
) bt_field_type_copy
);
609 /* Notifiy listeners of the trace's schema modification. */
611 struct bt_visitor_object obj
= { .object
= event_class
,
612 .type
= BT_VISITOR_OBJECT_TYPE_EVENT_CLASS
};
614 (void) bt_trace_object_modification(&obj
, trace
);
617 if (!old_clock_class
&& stream_class
->common
.clock_class
) {
619 * Adding this event class updated the stream class's
620 * single clock class: make sure all the events which
621 * exist in event pools have an existing clock value for
622 * this clock class so that any created event object in
623 * the future (from a pool or not) has this clock value
626 for (i
= 0; i
< stream_class
->common
.event_classes
->len
; i
++) {
627 struct bt_event_class
*event_class
=
628 stream_class
->common
.event_classes
->pdata
[i
];
630 BT_ASSERT(event_class
);
631 ret
= bt_event_class_update_event_pool_clock_values(
643 int64_t bt_stream_class_get_event_class_count(
644 struct bt_stream_class
*stream_class
)
646 return bt_stream_class_common_get_event_class_count(
647 BT_TO_COMMON(stream_class
));
650 struct bt_event_class
*bt_stream_class_borrow_event_class_by_index(
651 struct bt_stream_class
*stream_class
, uint64_t index
)
653 return BT_FROM_COMMON(bt_stream_class_common_borrow_event_class_by_index(
654 BT_TO_COMMON(stream_class
), index
));
657 struct bt_event_class
*bt_stream_class_borrow_event_class_by_id(
658 struct bt_stream_class
*stream_class
, uint64_t id
)
660 return BT_FROM_COMMON(bt_stream_class_common_borrow_event_class_by_id(
661 BT_TO_COMMON(stream_class
), id
));
664 struct bt_field_type
*bt_stream_class_borrow_packet_context_field_type(
665 struct bt_stream_class
*stream_class
)
667 return BT_FROM_COMMON(bt_stream_class_common_borrow_packet_context_field_type(
668 BT_TO_COMMON(stream_class
)));
671 int bt_stream_class_set_packet_context_field_type(
672 struct bt_stream_class
*stream_class
,
673 struct bt_field_type
*packet_context_type
)
675 return bt_stream_class_common_set_packet_context_field_type(
676 BT_TO_COMMON(stream_class
), (void *) packet_context_type
);
679 struct bt_field_type
*bt_stream_class_borrow_event_header_field_type(
680 struct bt_stream_class
*stream_class
)
682 return BT_FROM_COMMON(bt_stream_class_common_borrow_event_header_field_type(
683 BT_TO_COMMON(stream_class
)));
686 int bt_stream_class_set_event_header_field_type(
687 struct bt_stream_class
*stream_class
,
688 struct bt_field_type
*event_header_type
)
690 return bt_stream_class_common_set_event_header_field_type(
691 BT_TO_COMMON(stream_class
), (void *) event_header_type
);
694 struct bt_field_type
*bt_stream_class_borrow_event_context_field_type(
695 struct bt_stream_class
*stream_class
)
697 return BT_FROM_COMMON(bt_stream_class_common_borrow_event_context_field_type(
698 BT_TO_COMMON(stream_class
)));
701 int bt_stream_class_set_event_context_field_type(
702 struct bt_stream_class
*stream_class
,
703 struct bt_field_type
*event_context_type
)
705 return bt_stream_class_common_set_event_context_field_type(
706 BT_TO_COMMON(stream_class
), (void *) event_context_type
);
710 int64_t get_event_class_count(void *element
)
712 return bt_stream_class_get_event_class_count(
713 (struct bt_stream_class
*) element
);
717 void *get_event_class(void *element
, int i
)
719 return bt_stream_class_get_event_class_by_index(
720 (struct bt_stream_class
*) element
, i
);
724 int visit_event_class(void *object
, bt_visitor visitor
,void *data
)
726 struct bt_visitor_object obj
= {
728 .type
= BT_VISITOR_OBJECT_TYPE_EVENT_CLASS
731 return visitor(&obj
, data
);
735 int bt_stream_class_common_visit(struct bt_stream_class_common
*stream_class
,
736 bt_visitor visitor
, void *data
)
739 struct bt_visitor_object obj
= {
740 .object
= stream_class
,
741 .type
= BT_VISITOR_OBJECT_TYPE_STREAM_CLASS
744 if (!stream_class
|| !visitor
) {
745 BT_LOGW("Invalid parameter: stream class or visitor is NULL: "
746 "stream-class-addr=%p, visitor=%p",
747 stream_class
, visitor
);
752 ret
= visitor_helper(&obj
, get_event_class_count
,
754 visit_event_class
, visitor
, data
);
755 BT_LOGV("visitor_helper() returned: ret=%d", ret
);
761 int bt_stream_class_visit(struct bt_stream_class
*stream_class
,
762 bt_visitor visitor
, void *data
)
764 return bt_stream_class_common_visit(BT_FROM_COMMON(stream_class
),
769 void bt_stream_class_common_freeze(struct bt_stream_class_common
*stream_class
)
771 if (!stream_class
|| stream_class
->frozen
) {
775 BT_LOGD("Freezing stream class: addr=%p, name=\"%s\", id=%" PRId64
,
776 stream_class
, bt_stream_class_common_get_name(stream_class
),
777 bt_stream_class_common_get_id(stream_class
));
778 stream_class
->frozen
= 1;
779 bt_field_type_common_freeze(stream_class
->event_header_field_type
);
780 bt_field_type_common_freeze(stream_class
->packet_context_field_type
);
781 bt_field_type_common_freeze(stream_class
->event_context_field_type
);
782 bt_clock_class_freeze(stream_class
->clock_class
);
785 void bt_stream_class_freeze(struct bt_stream_class
*stream_class
)
787 bt_stream_class_common_freeze(BT_TO_COMMON(stream_class
));
791 int bt_stream_class_common_validate_single_clock_class(
792 struct bt_stream_class_common
*stream_class
,
793 struct bt_clock_class
**expected_clock_class
)
798 BT_ASSERT(stream_class
);
799 BT_ASSERT(expected_clock_class
);
800 ret
= bt_field_type_common_validate_single_clock_class(
801 stream_class
->packet_context_field_type
,
802 expected_clock_class
);
804 BT_LOGW("Stream class's packet context field type "
805 "is not recursively mapped to the "
806 "expected clock class: "
807 "stream-class-addr=%p, "
808 "stream-class-name=\"%s\", "
809 "stream-class-id=%" PRId64
", "
812 bt_stream_class_common_get_name(stream_class
),
814 stream_class
->packet_context_field_type
);
818 ret
= bt_field_type_common_validate_single_clock_class(
819 stream_class
->event_header_field_type
,
820 expected_clock_class
);
822 BT_LOGW("Stream class's event header field type "
823 "is not recursively mapped to the "
824 "expected clock class: "
825 "stream-class-addr=%p, "
826 "stream-class-name=\"%s\", "
827 "stream-class-id=%" PRId64
", "
830 bt_stream_class_common_get_name(stream_class
),
832 stream_class
->event_header_field_type
);
836 ret
= bt_field_type_common_validate_single_clock_class(
837 stream_class
->event_context_field_type
,
838 expected_clock_class
);
840 BT_LOGW("Stream class's event context field type "
841 "is not recursively mapped to the "
842 "expected clock class: "
843 "stream-class-addr=%p, "
844 "stream-class-name=\"%s\", "
845 "stream-class-id=%" PRId64
", "
848 bt_stream_class_common_get_name(stream_class
),
850 stream_class
->event_context_field_type
);
854 for (i
= 0; i
< stream_class
->event_classes
->len
; i
++) {
855 struct bt_event_class_common
*event_class
=
856 g_ptr_array_index(stream_class
->event_classes
, i
);
858 BT_ASSERT(event_class
);
859 ret
= bt_event_class_common_validate_single_clock_class(
860 event_class
, expected_clock_class
);
862 BT_LOGW("Stream class's event class contains a "
863 "field type which is not recursively mapped to "
864 "the expected clock class: "
865 "stream-class-addr=%p, "
866 "stream-class-name=\"%s\", "
867 "stream-class-id=%" PRId64
,
869 bt_stream_class_common_get_name(stream_class
),