4 * Babeltrace CTF IR - Event
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 #include <babeltrace/ctf-writer/event.h>
30 #include <babeltrace/ctf-writer/event-types.h>
31 #include <babeltrace/ctf-writer/event-fields.h>
32 #include <babeltrace/ctf-ir/event-fields-internal.h>
33 #include <babeltrace/ctf-ir/event-types-internal.h>
34 #include <babeltrace/ctf-ir/event-internal.h>
35 #include <babeltrace/ctf-ir/stream-class.h>
36 #include <babeltrace/ctf-ir/stream-class-internal.h>
37 #include <babeltrace/ctf-ir/trace-internal.h>
38 #include <babeltrace/ctf-ir/utils.h>
39 #include <babeltrace/ctf-ir/attributes-internal.h>
40 #include <babeltrace/compiler.h>
43 void bt_ctf_event_class_destroy(struct bt_ctf_ref
*ref
);
45 void bt_ctf_event_destroy(struct bt_ctf_ref
*ref
);
47 int set_integer_field_value(struct bt_ctf_field
*field
, uint64_t value
);
49 struct bt_ctf_event_class
*bt_ctf_event_class_create(const char *name
)
52 struct bt_object
*obj
= NULL
;
53 struct bt_ctf_event_class
*event_class
= NULL
;
55 if (bt_ctf_validate_identifier(name
)) {
59 event_class
= g_new0(struct bt_ctf_event_class
, 1);
64 bt_ctf_ref_init(&event_class
->ref_count
);
65 event_class
->fields
= bt_ctf_field_type_structure_create();
66 if (!event_class
->fields
) {
70 event_class
->attributes
= bt_ctf_attributes_create();
71 if (!event_class
->attributes
) {
75 obj
= bt_object_integer_create_init(-1);
80 ret
= bt_ctf_attributes_set_field_value(event_class
->attributes
,
88 obj
= bt_object_string_create_init(name
);
93 ret
= bt_ctf_attributes_set_field_value(event_class
->attributes
,
105 bt_ctf_event_class_put(event_class
);
113 const char *bt_ctf_event_class_get_name(struct bt_ctf_event_class
*event_class
)
115 struct bt_object
*obj
= NULL
;
116 const char *name
= NULL
;
122 obj
= bt_ctf_attributes_get_field_value(event_class
->attributes
,
123 BT_CTF_EVENT_CLASS_ATTR_NAME_INDEX
);
128 if (bt_object_string_get(obj
, &name
)) {
138 int64_t bt_ctf_event_class_get_id(struct bt_ctf_event_class
*event_class
)
140 struct bt_object
*obj
= NULL
;
148 obj
= bt_ctf_attributes_get_field_value(event_class
->attributes
,
149 BT_CTF_EVENT_CLASS_ATTR_ID_INDEX
);
154 if (bt_object_integer_get(obj
, &ret
)) {
159 /* means ID is not set */
170 int bt_ctf_event_class_set_id(struct bt_ctf_event_class
*event_class
,
174 struct bt_object
*obj
= NULL
;
181 if (event_class
->stream_class
) {
183 * We don't allow changing the id if the event class has already
184 * been added to a stream class.
190 obj
= bt_ctf_attributes_get_field_value(event_class
->attributes
,
191 BT_CTF_EVENT_CLASS_ATTR_ID_INDEX
);
196 if (bt_object_integer_set(obj
, id
)) {
207 int bt_ctf_event_class_set_attribute(
208 struct bt_ctf_event_class
*event_class
, const char *name
,
209 struct bt_object
*value
)
213 if (!event_class
|| !name
|| !value
|| event_class
->frozen
) {
218 if (!strcmp(name
, "id") || !strcmp(name
, "loglevel")) {
219 if (!bt_object_is_integer(value
)) {
223 } else if (!strcmp(name
, "name") || !strcmp(name
, "model.emf.uri")) {
224 if (!bt_object_is_string(value
)) {
229 /* unknown attribute */
234 /* "id" special case: >= 0 */
235 if (!strcmp(name
, "id")) {
238 ret
= bt_object_integer_get(value
, &val
);
250 ret
= bt_ctf_attributes_set_field_value(event_class
->attributes
,
257 int bt_ctf_event_class_get_attribute_count(
258 struct bt_ctf_event_class
*event_class
)
267 ret
= bt_ctf_attributes_get_count(event_class
->attributes
);
274 bt_ctf_event_class_get_attribute_name(
275 struct bt_ctf_event_class
*event_class
, int index
)
284 ret
= bt_ctf_attributes_get_field_name(event_class
->attributes
, index
);
291 bt_ctf_event_class_get_attribute_value(struct bt_ctf_event_class
*event_class
,
294 struct bt_object
*ret
;
301 ret
= bt_ctf_attributes_get_field_value(event_class
->attributes
, index
);
308 bt_ctf_event_class_get_attribute_value_by_name(
309 struct bt_ctf_event_class
*event_class
, const char *name
)
311 struct bt_object
*ret
;
313 if (!event_class
|| !name
) {
318 ret
= bt_ctf_attributes_get_field_value_by_name(event_class
->attributes
,
326 struct bt_ctf_stream_class
*bt_ctf_event_class_get_stream_class(
327 struct bt_ctf_event_class
*event_class
)
329 struct bt_ctf_stream_class
*stream_class
= NULL
;
335 stream_class
= event_class
->stream_class
;
336 bt_ctf_stream_class_get(stream_class
);
341 struct bt_ctf_field_type
*bt_ctf_event_class_get_payload_type(
342 struct bt_ctf_event_class
*event_class
)
344 struct bt_ctf_field_type
*payload
= NULL
;
350 bt_ctf_field_type_get(event_class
->fields
);
351 payload
= event_class
->fields
;
356 int bt_ctf_event_class_set_payload_type(struct bt_ctf_event_class
*event_class
,
357 struct bt_ctf_field_type
*payload
)
361 if (!event_class
|| !payload
||
362 bt_ctf_field_type_get_type_id(payload
) != CTF_TYPE_STRUCT
) {
367 bt_ctf_field_type_get(payload
);
368 bt_ctf_field_type_put(event_class
->fields
);
369 event_class
->fields
= payload
;
374 int bt_ctf_event_class_add_field(struct bt_ctf_event_class
*event_class
,
375 struct bt_ctf_field_type
*type
,
380 if (!event_class
|| !type
|| bt_ctf_validate_identifier(name
) ||
381 event_class
->frozen
) {
386 if (bt_ctf_field_type_get_type_id(event_class
->fields
) !=
392 ret
= bt_ctf_field_type_structure_add_field(event_class
->fields
,
398 int bt_ctf_event_class_get_field_count(
399 struct bt_ctf_event_class
*event_class
)
408 if (bt_ctf_field_type_get_type_id(event_class
->fields
) !=
414 ret
= bt_ctf_field_type_structure_get_field_count(event_class
->fields
);
419 int bt_ctf_event_class_get_field(struct bt_ctf_event_class
*event_class
,
420 const char **field_name
, struct bt_ctf_field_type
**field_type
,
425 if (!event_class
|| index
< 0) {
430 if (bt_ctf_field_type_get_type_id(event_class
->fields
) !=
436 ret
= bt_ctf_field_type_structure_get_field(event_class
->fields
,
437 field_name
, field_type
, index
);
442 struct bt_ctf_field_type
*bt_ctf_event_class_get_field_by_name(
443 struct bt_ctf_event_class
*event_class
, const char *name
)
446 struct bt_ctf_field_type
*field_type
= NULL
;
448 if (!event_class
|| !name
) {
452 if (bt_ctf_field_type_get_type_id(event_class
->fields
) !=
457 name_quark
= g_quark_try_string(name
);
463 * No need to increment field_type's reference count since getting it
464 * from the structure already does.
466 field_type
= bt_ctf_field_type_structure_get_field_type_by_name(
467 event_class
->fields
, name
);
472 struct bt_ctf_field_type
*bt_ctf_event_class_get_context_type(
473 struct bt_ctf_event_class
*event_class
)
475 struct bt_ctf_field_type
*context_type
= NULL
;
477 if (!event_class
|| !event_class
->context
) {
481 bt_ctf_field_type_get(event_class
->context
);
482 context_type
= event_class
->context
;
487 int bt_ctf_event_class_set_context_type(
488 struct bt_ctf_event_class
*event_class
,
489 struct bt_ctf_field_type
*context
)
493 if (!event_class
|| !context
|| event_class
->frozen
) {
498 if (bt_ctf_field_type_get_type_id(context
) != CTF_TYPE_STRUCT
) {
503 bt_ctf_field_type_get(context
);
504 bt_ctf_field_type_put(event_class
->context
);
505 event_class
->context
= context
;
511 void bt_ctf_event_class_get(struct bt_ctf_event_class
*event_class
)
517 bt_ctf_ref_get(&event_class
->ref_count
);
520 void bt_ctf_event_class_put(struct bt_ctf_event_class
*event_class
)
526 bt_ctf_ref_put(&event_class
->ref_count
, bt_ctf_event_class_destroy
);
530 int bt_ctf_event_class_set_stream_id(struct bt_ctf_event_class
*event_class
,
534 struct bt_object
*obj
;
536 obj
= bt_object_integer_create_init(stream_id
);
543 ret
= bt_ctf_attributes_set_field_value(event_class
->attributes
,
552 struct bt_ctf_event
*bt_ctf_event_create(struct bt_ctf_event_class
*event_class
)
554 struct bt_ctf_event
*event
= NULL
;
561 * The event class does not keep ownership of the stream class to
562 * which it as been added. Therefore, it can't assume it has been
563 * set. However, we disallow the creation of an event if its
564 * associated stream class has been reclaimed.
566 if (!event_class
->stream_class
) {
569 assert(event_class
->stream_class
->event_header_type
);
570 event
= g_new0(struct bt_ctf_event
, 1);
575 bt_ctf_ref_init(&event
->ref_count
);
576 bt_ctf_event_class_get(event_class
);
577 bt_ctf_event_class_freeze(event_class
);
578 event
->event_class
= event_class
;
580 event
->event_header
= bt_ctf_field_create(
581 event_class
->stream_class
->event_header_type
);
582 if (!event
->event_header
) {
585 if (event_class
->context
) {
586 event
->context_payload
= bt_ctf_field_create(
587 event_class
->context
);
588 if (!event
->context_payload
) {
592 event
->fields_payload
= bt_ctf_field_create(event_class
->fields
);
593 if (!event
->fields_payload
) {
598 * Freeze the stream class since the event header must not be changed
601 bt_ctf_stream_class_freeze(event_class
->stream_class
);
606 bt_ctf_event_destroy(&event
->ref_count
);
612 struct bt_ctf_event_class
*bt_ctf_event_get_class(struct bt_ctf_event
*event
)
614 struct bt_ctf_event_class
*event_class
= NULL
;
620 event_class
= event
->event_class
;
621 bt_ctf_event_class_get(event_class
);
626 struct bt_ctf_stream
*bt_ctf_event_get_stream(struct bt_ctf_event
*event
)
628 struct bt_ctf_stream
*stream
= NULL
;
634 stream
= event
->stream
;
636 bt_ctf_stream_get(stream
);
642 struct bt_ctf_clock
*bt_ctf_event_get_clock(struct bt_ctf_event
*event
)
644 struct bt_ctf_clock
*clock
= NULL
;
645 struct bt_ctf_event_class
*event_class
;
646 struct bt_ctf_stream_class
*stream_class
;
652 event_class
= bt_ctf_event_get_class(event
);
657 stream_class
= bt_ctf_event_class_get_stream_class(event_class
);
659 goto error_put_event_class
;
662 clock
= bt_ctf_stream_class_get_clock(stream_class
);
664 goto error_put_stream_class
;
667 error_put_stream_class
:
668 bt_ctf_stream_class_put(stream_class
);
669 error_put_event_class
:
670 bt_ctf_event_class_put(event_class
);
675 int bt_ctf_event_set_payload(struct bt_ctf_event
*event
,
677 struct bt_ctf_field
*payload
)
681 if (!event
|| !payload
) {
687 ret
= bt_ctf_field_structure_set_field(event
->fields_payload
,
690 struct bt_ctf_field_type
*payload_type
;
692 payload_type
= bt_ctf_field_get_type(payload
);
693 if (payload_type
== event
->event_class
->fields
) {
694 bt_ctf_field_put(event
->fields_payload
);
695 bt_ctf_field_get(payload
);
696 event
->fields_payload
= payload
;
701 bt_ctf_field_type_put(payload_type
);
707 struct bt_ctf_field
*bt_ctf_event_get_payload_field(struct bt_ctf_event
*event
)
709 struct bt_ctf_field
*payload
= NULL
;
711 if (!event
|| !event
->fields_payload
) {
715 payload
= event
->fields_payload
;
716 bt_ctf_field_get(payload
);
721 int bt_ctf_event_set_payload_field(struct bt_ctf_event
*event
,
722 struct bt_ctf_field
*payload
)
725 struct bt_ctf_field_type
*payload_type
= NULL
;
727 if (!event
|| !payload
) {
732 payload_type
= bt_ctf_field_get_type(payload
);
738 if (bt_ctf_field_type_get_type_id(payload_type
) != CTF_TYPE_STRUCT
) {
743 bt_ctf_field_get(payload
);
744 if (event
->fields_payload
) {
745 bt_ctf_field_put(event
->fields_payload
);
747 event
->fields_payload
= payload
;
751 bt_ctf_field_type_put(payload_type
);
756 struct bt_ctf_field
*bt_ctf_event_get_payload(struct bt_ctf_event
*event
,
759 struct bt_ctf_field
*field
= NULL
;
766 field
= bt_ctf_field_structure_get_field(event
->fields_payload
,
769 field
= event
->fields_payload
;
770 bt_ctf_field_get(field
);
776 struct bt_ctf_field
*bt_ctf_event_get_payload_by_index(
777 struct bt_ctf_event
*event
, int index
)
779 struct bt_ctf_field
*field
= NULL
;
781 if (!event
|| index
< 0) {
785 field
= bt_ctf_field_structure_get_field_by_index(event
->fields_payload
,
791 struct bt_ctf_field
*bt_ctf_event_get_header(
792 struct bt_ctf_event
*event
)
794 struct bt_ctf_field
*header
= NULL
;
796 if (!event
|| !event
->event_header
) {
800 header
= event
->event_header
;
801 bt_ctf_field_get(header
);
806 int bt_ctf_event_set_header(struct bt_ctf_event
*event
,
807 struct bt_ctf_field
*header
)
810 struct bt_ctf_field_type
*field_type
= NULL
;
812 if (!event
|| !header
) {
817 /* Could be NULL since an event class doesn't own a stream class */
818 if (!event
->event_class
->stream_class
) {
824 * Ensure the provided header's type matches the one registered to the
827 field_type
= bt_ctf_field_get_type(header
);
828 if (field_type
!= event
->event_class
->stream_class
->event_header_type
) {
833 bt_ctf_field_get(header
);
834 bt_ctf_field_put(event
->event_header
);
835 event
->event_header
= header
;
838 bt_ctf_field_type_put(field_type
);
843 struct bt_ctf_field
*bt_ctf_event_get_event_context(
844 struct bt_ctf_event
*event
)
846 struct bt_ctf_field
*context
= NULL
;
848 if (!event
|| !event
->context_payload
) {
852 context
= event
->context_payload
;
853 bt_ctf_field_get(context
);
858 int bt_ctf_event_set_event_context(struct bt_ctf_event
*event
,
859 struct bt_ctf_field
*context
)
862 struct bt_ctf_field_type
*field_type
= NULL
;
864 if (!event
|| !context
) {
869 field_type
= bt_ctf_field_get_type(context
);
870 if (field_type
!= event
->event_class
->context
) {
875 bt_ctf_field_get(context
);
876 bt_ctf_field_put(event
->context_payload
);
877 event
->context_payload
= context
;
880 bt_ctf_field_type_put(field_type
);
885 void bt_ctf_event_get(struct bt_ctf_event
*event
)
891 bt_ctf_ref_get(&event
->ref_count
);
894 void bt_ctf_event_put(struct bt_ctf_event
*event
)
900 bt_ctf_ref_put(&event
->ref_count
, bt_ctf_event_destroy
);
904 void bt_ctf_event_class_destroy(struct bt_ctf_ref
*ref
)
906 struct bt_ctf_event_class
*event_class
;
913 * Don't call put() on the stream class. See comment in
914 * bt_ctf_event_class_set_stream_class for explanation.
916 event_class
= container_of(ref
, struct bt_ctf_event_class
, ref_count
);
917 if (event_class
->attributes
) {
918 bt_ctf_attributes_destroy(event_class
->attributes
);
920 if (event_class
->context
) {
921 bt_ctf_field_type_put(event_class
->context
);
923 if (event_class
->fields
) {
924 bt_ctf_field_type_put(event_class
->fields
);
930 void bt_ctf_event_destroy(struct bt_ctf_ref
*ref
)
932 struct bt_ctf_event
*event
;
938 event
= container_of(ref
, struct bt_ctf_event
,
940 if (event
->event_class
) {
941 bt_ctf_event_class_put(event
->event_class
);
943 if (event
->event_header
) {
944 bt_ctf_field_put(event
->event_header
);
946 if (event
->context_payload
) {
947 bt_ctf_field_put(event
->context_payload
);
949 if (event
->fields_payload
) {
950 bt_ctf_field_put(event
->fields_payload
);
956 int set_integer_field_value(struct bt_ctf_field
* field
, uint64_t value
)
959 struct bt_ctf_field_type
*field_type
= NULL
;
966 if (!bt_ctf_field_validate(field
)) {
967 /* Payload already set, skip! (not an error) */
971 field_type
= bt_ctf_field_get_type(field
);
974 if (bt_ctf_field_type_get_type_id(field_type
) != CTF_TYPE_INTEGER
) {
975 /* Not an integer and the value is unset, error. */
980 if (bt_ctf_field_type_integer_get_signed(field_type
)) {
981 ret
= bt_ctf_field_signed_integer_set_value(field
, (int64_t) value
);
983 /* Value is out of range, error. */
987 ret
= bt_ctf_field_unsigned_integer_set_value(field
, value
);
989 /* Value is out of range, error. */
994 bt_ctf_field_type_put(field_type
);
999 void bt_ctf_event_class_freeze(struct bt_ctf_event_class
*event_class
)
1001 assert(event_class
);
1002 event_class
->frozen
= 1;
1003 bt_ctf_field_type_freeze(event_class
->context
);
1004 bt_ctf_field_type_freeze(event_class
->fields
);
1005 bt_ctf_attributes_freeze(event_class
->attributes
);
1009 int bt_ctf_event_class_set_stream_class(struct bt_ctf_event_class
*event_class
,
1010 struct bt_ctf_stream_class
*stream_class
)
1019 /* Allow a NULL stream_class to unset the current stream_class */
1020 if (stream_class
&& event_class
->stream_class
) {
1025 event_class
->stream_class
= stream_class
;
1027 * We don't get() the stream_class since doing so would introduce
1028 * a circular ownership between event classes and stream classes.
1030 * A stream class will always unset itself from its events before
1031 * being destroyed. This ensures that a user won't get a pointer
1032 * to a stale stream class instance from an event class.
1039 int bt_ctf_event_class_serialize(struct bt_ctf_event_class
*event_class
,
1040 struct metadata_context
*context
)
1045 struct bt_object
*attr_value
= NULL
;
1047 assert(event_class
);
1050 context
->current_indentation_level
= 1;
1051 g_string_assign(context
->field_name
, "");
1052 g_string_append(context
->string
, "event {\n");
1053 count
= bt_ctf_event_class_get_attribute_count(event_class
);
1060 for (i
= 0; i
< count
; ++i
) {
1061 const char *attr_name
= NULL
;
1063 attr_name
= bt_ctf_event_class_get_attribute_name(
1065 attr_value
= bt_ctf_event_class_get_attribute_value(
1068 if (!attr_name
|| !attr_value
) {
1073 switch (bt_object_get_type(attr_value
)) {
1074 case BT_OBJECT_TYPE_INTEGER
:
1078 ret
= bt_object_integer_get(attr_value
, &value
);
1084 g_string_append_printf(context
->string
,
1085 "\t%s = %" PRId64
";\n", attr_name
, value
);
1089 case BT_OBJECT_TYPE_STRING
:
1093 ret
= bt_object_string_get(attr_value
, &value
);
1099 g_string_append_printf(context
->string
,
1100 "\t%s = \"%s\";\n", attr_name
, value
);
1105 /* should never happen */
1110 BT_OBJECT_PUT(attr_value
);
1113 if (event_class
->context
) {
1114 g_string_append(context
->string
, "\tcontext := ");
1115 ret
= bt_ctf_field_type_serialize(event_class
->context
,
1120 g_string_append(context
->string
, ";\n");
1123 if (event_class
->fields
) {
1124 g_string_append(context
->string
, "\tfields := ");
1125 ret
= bt_ctf_field_type_serialize(event_class
->fields
, context
);
1129 g_string_append(context
->string
, ";\n");
1132 g_string_append(context
->string
, "};\n\n");
1134 context
->current_indentation_level
= 0;
1135 BT_OBJECT_PUT(attr_value
);
1139 void bt_ctf_event_class_set_native_byte_order(
1140 struct bt_ctf_event_class
*event_class
,
1147 bt_ctf_field_type_set_native_byte_order(event_class
->context
,
1149 bt_ctf_field_type_set_native_byte_order(event_class
->fields
,
1154 int bt_ctf_event_validate(struct bt_ctf_event
*event
)
1156 /* Make sure each field's payload has been set */
1160 ret
= bt_ctf_field_validate(event
->event_header
);
1165 ret
= bt_ctf_field_validate(event
->fields_payload
);
1170 if (event
->event_class
->context
) {
1171 ret
= bt_ctf_field_validate(event
->context_payload
);
1178 int bt_ctf_event_serialize(struct bt_ctf_event
*event
,
1179 struct ctf_stream_pos
*pos
)
1185 if (event
->context_payload
) {
1186 ret
= bt_ctf_field_serialize(event
->context_payload
, pos
);
1192 if (event
->fields_payload
) {
1193 ret
= bt_ctf_field_serialize(event
->fields_payload
, pos
);
1203 int bt_ctf_event_populate_event_header(struct bt_ctf_event
*event
)
1206 struct bt_ctf_field
*id_field
= NULL
, *timestamp_field
= NULL
;
1213 id_field
= bt_ctf_field_structure_get_field(event
->event_header
, "id");
1215 ret
= set_integer_field_value(id_field
,
1216 (uint64_t) bt_ctf_event_class_get_id(
1217 event
->event_class
));
1223 timestamp_field
= bt_ctf_field_structure_get_field(event
->event_header
,
1225 if (timestamp_field
) {
1226 struct bt_ctf_field_type
*timestamp_field_type
=
1227 bt_ctf_field_get_type(timestamp_field
);
1228 struct bt_ctf_clock
*mapped_clock
;
1230 assert(timestamp_field_type
);
1231 mapped_clock
= bt_ctf_field_type_integer_get_mapped_clock(
1232 timestamp_field_type
);
1233 bt_ctf_field_type_put(timestamp_field_type
);
1235 uint64_t timestamp
= bt_ctf_clock_get_time(
1238 bt_ctf_clock_put(mapped_clock
);
1239 if (timestamp
== (uint64_t) -1ULL) {
1243 ret
= set_integer_field_value(timestamp_field
,
1252 bt_ctf_field_put(id_field
);
1254 if (timestamp_field
) {
1255 bt_ctf_field_put(timestamp_field
);
1261 int bt_ctf_event_set_stream(struct bt_ctf_event
*event
,
1262 struct bt_ctf_stream
*stream
)
1271 if (event
->stream
&& stream
) {
1272 /* Already attached to a stream */
1277 event
->stream
= stream
;
1282 struct bt_ctf_event
*bt_ctf_event_copy(struct bt_ctf_event
*event
)
1284 struct bt_ctf_event
*copy
= NULL
;
1290 copy
= g_new0(struct bt_ctf_event
, 1);
1295 bt_ctf_ref_init(©
->ref_count
);
1296 copy
->event_class
= event
->event_class
;
1297 bt_ctf_event_class_get(copy
->event_class
);
1298 copy
->stream
= event
->stream
;
1300 if (event
->event_header
) {
1301 copy
->event_header
= bt_ctf_field_copy(event
->event_header
);
1303 if (!copy
->event_header
) {
1308 if (event
->context_payload
) {
1309 copy
->context_payload
= bt_ctf_field_copy(
1310 event
->context_payload
);
1312 if (!copy
->context_payload
) {
1317 if (event
->fields_payload
) {
1318 copy
->fields_payload
= bt_ctf_field_copy(event
->fields_payload
);
1320 if (!copy
->fields_payload
) {
1329 if (copy
->event_class
) {
1330 bt_ctf_event_class_put(copy
->event_class
);
1333 if (copy
->event_header
) {
1334 bt_ctf_field_put(copy
->event_header
);
1337 if (copy
->context_payload
) {
1338 bt_ctf_field_put(copy
->context_payload
);
1341 if (copy
->fields_payload
) {
1342 bt_ctf_field_put(copy
->fields_payload
);