4 * Babeltrace CTF Writer Output Plugin Event Handling
6 * Copyright 2016 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-ir/event.h>
30 #include <babeltrace/ctf-ir/packet.h>
31 #include <babeltrace/ctf-ir/event-class.h>
32 #include <babeltrace/ctf-ir/stream.h>
33 #include <babeltrace/ctf-ir/stream-class.h>
34 #include <babeltrace/ctf-ir/clock-class.h>
35 #include <babeltrace/ctf-ir/fields.h>
36 #include <babeltrace/ctf-writer/stream-class.h>
37 #include <babeltrace/ctf-writer/stream.h>
40 #include <ctfcopytrace.h>
45 void unref_stream_class(struct bt_ctf_stream_class
*writer_stream_class
)
47 bt_put(writer_stream_class
);
51 void unref_stream(struct bt_ctf_stream_class
*writer_stream
)
53 bt_put(writer_stream
);
57 gboolean
empty_ht(gpointer key
, gpointer value
, gpointer user_data
)
63 gboolean
empty_streams_ht(gpointer key
, gpointer value
, gpointer user_data
)
65 struct bt_ctf_stream
*writer_stream
= value
;
67 bt_ctf_stream_flush(writer_stream
);
73 void destroy_stream_state_key(gpointer key
)
75 g_free((enum fs_writer_stream_state
*) key
);
79 void check_completed_trace(gpointer key
, gpointer value
, gpointer user_data
)
81 enum fs_writer_stream_state
*state
= value
;
82 int *trace_completed
= user_data
;
84 if (*state
!= FS_WRITER_COMPLETED_STREAM
) {
90 void trace_is_static_listener(struct bt_ctf_trace
*trace
, void *data
)
92 struct fs_writer
*fs_writer
= data
;
93 int trace_completed
= 1;
95 fs_writer
->trace_static
= 1;
97 g_hash_table_foreach(fs_writer
->stream_states
,
98 check_completed_trace
, &trace_completed
);
99 if (trace_completed
) {
100 writer_close(fs_writer
->writer_component
, fs_writer
);
101 g_hash_table_remove(fs_writer
->writer_component
->trace_map
,
107 struct bt_ctf_stream_class
*insert_new_stream_class(
108 struct writer_component
*writer_component
,
109 struct fs_writer
*fs_writer
,
110 struct bt_ctf_stream_class
*stream_class
)
112 struct bt_ctf_stream_class
*writer_stream_class
= NULL
;
113 struct bt_ctf_trace
*trace
= NULL
, *writer_trace
= NULL
;
114 struct bt_ctf_writer
*ctf_writer
= fs_writer
->writer
;
115 enum bt_component_status ret
;
117 trace
= bt_ctf_stream_class_get_trace(stream_class
);
119 fprintf(writer_component
->err
,
120 "[error] %s in %s:%d\n", __func__
, __FILE__
,
125 writer_trace
= bt_ctf_writer_get_trace(ctf_writer
);
127 fprintf(writer_component
->err
,
128 "[error] %s in %s:%d\n", __func__
, __FILE__
,
133 ret
= ctf_copy_clock_classes(writer_component
->err
, writer_trace
,
134 writer_stream_class
, trace
);
135 if (ret
!= BT_COMPONENT_STATUS_OK
) {
136 fprintf(writer_component
->err
,
137 "[error] %s in %s:%d\n", __func__
, __FILE__
,
142 writer_stream_class
= ctf_copy_stream_class(writer_component
->err
,
143 stream_class
, writer_trace
, true);
144 if (!writer_stream_class
) {
145 fprintf(writer_component
->err
, "[error] Failed to copy stream class\n");
146 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
147 __func__
, __FILE__
, __LINE__
);
151 g_hash_table_insert(fs_writer
->stream_class_map
,
152 (gpointer
) stream_class
, writer_stream_class
);
157 BT_PUT(writer_stream_class
);
159 bt_put(writer_trace
);
161 return writer_stream_class
;
165 enum fs_writer_stream_state
*insert_new_stream_state(
166 struct writer_component
*writer_component
,
167 struct fs_writer
*fs_writer
, struct bt_ctf_stream
*stream
)
169 enum fs_writer_stream_state
*v
= NULL
;
171 v
= g_new0(enum fs_writer_stream_state
, 1);
173 fprintf(writer_component
->err
,
174 "[error] %s in %s:%d\n", __func__
,
177 *v
= FS_WRITER_UNKNOWN_STREAM
;
179 g_hash_table_insert(fs_writer
->stream_states
, stream
, v
);
185 * Make sure the output path is valid for a single trace: either it does
186 * not exists or it is empty.
188 * Return 0 if the path is valid, -1 otherwise.
191 bool valid_single_trace_path(const char *path
)
195 DIR *dir
= opendir(path
);
198 /* non-existant directory */
204 while ((d
= readdir(dir
)) != NULL
) {
227 int make_trace_path(struct writer_component
*writer_component
,
228 struct bt_ctf_trace
*trace
, char *trace_path
)
231 const char *trace_name
;
233 if (writer_component
->single_trace
) {
236 trace_name
= bt_ctf_trace_get_name(trace
);
238 trace_name
= writer_component
->trace_name_base
->str
;
242 /* Sanitize the trace name. */
243 if (strlen(trace_name
) == 2 && !strcmp(trace_name
, "..")) {
244 fprintf(writer_component
->err
, "[error] Trace name cannot "
249 if (strstr(trace_name
, "../")) {
250 fprintf(writer_component
->err
, "[error] Trace name cannot "
251 "contain \"../\", received \"%s\"\n",
257 snprintf(trace_path
, PATH_MAX
, "%s/%s",
258 writer_component
->base_path
->str
,
261 * Append a suffix if the trace_path exists and we are not in
264 if (writer_component
->single_trace
) {
265 if (valid_single_trace_path(trace_path
) != 0) {
266 fprintf(writer_component
->err
,
267 "[error] Invalid output directory\n");
271 if (g_file_test(trace_path
, G_FILE_TEST_EXISTS
)) {
275 snprintf(trace_path
, PATH_MAX
, "%s/%s-%d",
276 writer_component
->base_path
->str
,
278 } while (g_file_test(trace_path
, G_FILE_TEST_EXISTS
) && i
< INT_MAX
);
280 fprintf(writer_component
->err
, "[error] Unable to find "
281 "a unique trace path\n");
297 struct fs_writer
*insert_new_writer(
298 struct writer_component
*writer_component
,
299 struct bt_ctf_trace
*trace
)
301 struct bt_ctf_writer
*ctf_writer
= NULL
;
302 struct bt_ctf_trace
*writer_trace
= NULL
;
303 char trace_path
[PATH_MAX
];
304 enum bt_component_status ret
;
305 struct bt_ctf_stream
*stream
= NULL
;
306 struct fs_writer
*fs_writer
= NULL
;
309 if (writer_component
->single_trace
&& writer_component
->nr_traces
> 0) {
310 fprintf(writer_component
->err
, "[error] Trying to process more "
311 "than one trace but --single-trace mode "
316 ret
= make_trace_path(writer_component
, trace
, trace_path
);
318 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
319 __func__
, __FILE__
, __LINE__
);
323 printf("ctf.fs sink creating trace in %s\n", trace_path
);
325 ctf_writer
= bt_ctf_writer_create(trace_path
);
327 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
328 __func__
, __FILE__
, __LINE__
);
332 writer_trace
= bt_ctf_writer_get_trace(ctf_writer
);
334 fprintf(writer_component
->err
,
335 "[error] %s in %s:%d\n", __func__
, __FILE__
,
340 ret
= ctf_copy_trace(writer_component
->err
, trace
, writer_trace
);
341 if (ret
!= BT_COMPONENT_STATUS_OK
) {
342 fprintf(writer_component
->err
, "[error] Failed to copy trace\n");
343 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
344 __func__
, __FILE__
, __LINE__
);
349 fs_writer
= g_new0(struct fs_writer
, 1);
351 fprintf(writer_component
->err
,
352 "[error] %s in %s:%d\n", __func__
, __FILE__
,
356 fs_writer
->writer
= ctf_writer
;
357 fs_writer
->trace
= trace
;
358 fs_writer
->writer_trace
= writer_trace
;
359 fs_writer
->writer_component
= writer_component
;
360 BT_PUT(writer_trace
);
361 fs_writer
->stream_class_map
= g_hash_table_new_full(g_direct_hash
,
362 g_direct_equal
, NULL
, (GDestroyNotify
) unref_stream_class
);
363 fs_writer
->stream_map
= g_hash_table_new_full(g_direct_hash
,
364 g_direct_equal
, NULL
, (GDestroyNotify
) unref_stream
);
365 fs_writer
->stream_states
= g_hash_table_new_full(g_direct_hash
,
366 g_direct_equal
, NULL
, destroy_stream_state_key
);
368 /* Set all the existing streams in the unknown state. */
369 nr_stream
= bt_ctf_trace_get_stream_count(trace
);
370 for (i
= 0; i
< nr_stream
; i
++) {
371 stream
= bt_ctf_trace_get_stream_by_index(trace
, i
);
373 fprintf(writer_component
->err
,
374 "[error] %s in %s:%d\n", __func__
,
378 insert_new_stream_state(writer_component
, fs_writer
, stream
);
382 /* Check if the trace is already static or register a listener. */
383 if (bt_ctf_trace_is_static(trace
)) {
384 fs_writer
->trace_static
= 1;
385 fs_writer
->static_listener_id
= -1;
387 ret
= bt_ctf_trace_add_is_static_listener(trace
,
388 trace_is_static_listener
, fs_writer
);
390 fprintf(writer_component
->err
,
391 "[error] %s in %s:%d\n", __func__
, __FILE__
,
395 fs_writer
->static_listener_id
= ret
;
398 writer_component
->nr_traces
++;
399 g_hash_table_insert(writer_component
->trace_map
, (gpointer
) trace
,
407 bt_put(writer_trace
);
415 struct fs_writer
*get_fs_writer(struct writer_component
*writer_component
,
416 struct bt_ctf_stream_class
*stream_class
)
418 struct bt_ctf_trace
*trace
= NULL
;
419 struct fs_writer
*fs_writer
;
421 trace
= bt_ctf_stream_class_get_trace(stream_class
);
423 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
424 __func__
, __FILE__
, __LINE__
);
428 fs_writer
= g_hash_table_lookup(writer_component
->trace_map
,
431 fs_writer
= insert_new_writer(writer_component
, trace
);
443 struct fs_writer
*get_fs_writer_from_stream(
444 struct writer_component
*writer_component
,
445 struct bt_ctf_stream
*stream
)
447 struct bt_ctf_stream_class
*stream_class
= NULL
;
448 struct fs_writer
*fs_writer
;
450 stream_class
= bt_ctf_stream_get_class(stream
);
452 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
453 __func__
, __FILE__
, __LINE__
);
457 fs_writer
= get_fs_writer(writer_component
, stream_class
);
464 bt_put(stream_class
);
469 struct bt_ctf_stream_class
*lookup_stream_class(
470 struct writer_component
*writer_component
,
471 struct bt_ctf_stream_class
*stream_class
)
473 struct fs_writer
*fs_writer
= get_fs_writer(
474 writer_component
, stream_class
);
476 return (struct bt_ctf_stream_class
*) g_hash_table_lookup(
477 fs_writer
->stream_class_map
, (gpointer
) stream_class
);
481 struct bt_ctf_stream
*lookup_stream(struct writer_component
*writer_component
,
482 struct bt_ctf_stream
*stream
)
484 struct fs_writer
*fs_writer
= get_fs_writer_from_stream(
485 writer_component
, stream
);
487 return (struct bt_ctf_stream
*) g_hash_table_lookup(
488 fs_writer
->stream_map
, (gpointer
) stream
);
492 struct bt_ctf_stream
*insert_new_stream(
493 struct writer_component
*writer_component
,
494 struct fs_writer
*fs_writer
,
495 struct bt_ctf_stream_class
*stream_class
,
496 struct bt_ctf_stream
*stream
)
498 struct bt_ctf_stream
*writer_stream
= NULL
;
499 struct bt_ctf_stream_class
*writer_stream_class
= NULL
;
500 struct bt_ctf_writer
*ctf_writer
= bt_get(fs_writer
->writer
);
502 writer_stream_class
= lookup_stream_class(writer_component
,
504 if (!writer_stream_class
) {
505 writer_stream_class
= insert_new_stream_class(
506 writer_component
, fs_writer
, stream_class
);
507 if (!writer_stream_class
) {
508 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
509 __func__
, __FILE__
, __LINE__
);
513 bt_get(writer_stream_class
);
515 writer_stream
= bt_ctf_writer_create_stream(ctf_writer
,
516 writer_stream_class
);
517 if (!writer_stream
) {
518 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
519 __func__
, __FILE__
, __LINE__
);
523 g_hash_table_insert(fs_writer
->stream_map
, (gpointer
) stream
,
529 BT_PUT(writer_stream
);
532 bt_put(writer_stream_class
);
533 return writer_stream
;
537 struct bt_ctf_event_class
*get_event_class(struct writer_component
*writer_component
,
538 struct bt_ctf_stream_class
*writer_stream_class
,
539 struct bt_ctf_event_class
*event_class
)
541 return bt_ctf_stream_class_get_event_class_by_id(writer_stream_class
,
542 bt_ctf_event_class_get_id(event_class
));
546 struct bt_ctf_stream
*get_writer_stream(
547 struct writer_component
*writer_component
,
548 struct bt_ctf_packet
*packet
, struct bt_ctf_stream
*stream
)
550 struct bt_ctf_stream
*writer_stream
= NULL
;
552 writer_stream
= lookup_stream(writer_component
, stream
);
553 if (!writer_stream
) {
554 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
555 __func__
, __FILE__
, __LINE__
);
558 bt_get(writer_stream
);
563 BT_PUT(writer_stream
);
565 return writer_stream
;
569 void writer_close(struct writer_component
*writer_component
,
570 struct fs_writer
*fs_writer
)
572 if (fs_writer
->static_listener_id
>= 0) {
573 bt_ctf_trace_remove_is_static_listener(fs_writer
->trace
,
574 fs_writer
->static_listener_id
);
577 /* Empty the stream class HT. */
578 g_hash_table_foreach_remove(fs_writer
->stream_class_map
,
580 g_hash_table_destroy(fs_writer
->stream_class_map
);
582 /* Empty the stream HT. */
583 g_hash_table_foreach_remove(fs_writer
->stream_map
,
584 empty_streams_ht
, NULL
);
585 g_hash_table_destroy(fs_writer
->stream_map
);
587 /* Empty the stream state HT. */
588 g_hash_table_foreach_remove(fs_writer
->stream_states
,
590 g_hash_table_destroy(fs_writer
->stream_states
);
594 enum bt_component_status
writer_stream_begin(
595 struct writer_component
*writer_component
,
596 struct bt_ctf_stream
*stream
)
598 struct bt_ctf_stream_class
*stream_class
= NULL
;
599 struct fs_writer
*fs_writer
;
600 struct bt_ctf_stream
*writer_stream
= NULL
;
601 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
602 enum fs_writer_stream_state
*state
;
604 stream_class
= bt_ctf_stream_get_class(stream
);
606 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
607 __func__
, __FILE__
, __LINE__
);
611 fs_writer
= get_fs_writer(writer_component
, stream_class
);
613 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
614 __func__
, __FILE__
, __LINE__
);
618 /* Set the stream as active */
619 state
= g_hash_table_lookup(fs_writer
->stream_states
, stream
);
621 if (fs_writer
->trace_static
) {
622 fprintf(writer_component
->err
, "[error] Adding a new "
623 "stream on a static trace\n");
626 state
= insert_new_stream_state(writer_component
, fs_writer
,
629 if (*state
!= FS_WRITER_UNKNOWN_STREAM
) {
630 fprintf(writer_component
->err
, "[error] Unexpected stream "
631 "state %d\n", *state
);
634 *state
= FS_WRITER_ACTIVE_STREAM
;
636 writer_stream
= insert_new_stream(writer_component
, fs_writer
,
637 stream_class
, stream
);
638 if (!writer_stream
) {
639 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
640 __func__
, __FILE__
, __LINE__
);
647 ret
= BT_COMPONENT_STATUS_ERROR
;
649 bt_put(stream_class
);
654 enum bt_component_status
writer_stream_end(
655 struct writer_component
*writer_component
,
656 struct bt_ctf_stream
*stream
)
658 struct bt_ctf_stream_class
*stream_class
= NULL
;
659 struct fs_writer
*fs_writer
;
660 struct bt_ctf_trace
*trace
= NULL
;
661 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
662 enum fs_writer_stream_state
*state
;
664 stream_class
= bt_ctf_stream_get_class(stream
);
666 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
667 __func__
, __FILE__
, __LINE__
);
671 fs_writer
= get_fs_writer(writer_component
, stream_class
);
673 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
674 __func__
, __FILE__
, __LINE__
);
678 state
= g_hash_table_lookup(fs_writer
->stream_states
, stream
);
679 if (*state
!= FS_WRITER_ACTIVE_STREAM
) {
680 fprintf(writer_component
->err
, "[error] Unexpected stream "
681 "state %d\n", *state
);
684 *state
= FS_WRITER_COMPLETED_STREAM
;
686 g_hash_table_remove(fs_writer
->stream_map
, stream
);
688 if (fs_writer
->trace_static
) {
689 int trace_completed
= 1;
691 g_hash_table_foreach(fs_writer
->stream_states
,
692 check_completed_trace
, &trace_completed
);
693 if (trace_completed
) {
694 writer_close(writer_component
, fs_writer
);
695 g_hash_table_remove(writer_component
->trace_map
,
703 ret
= BT_COMPONENT_STATUS_ERROR
;
706 BT_PUT(stream_class
);
711 enum bt_component_status
writer_new_packet(
712 struct writer_component
*writer_component
,
713 struct bt_ctf_packet
*packet
)
715 struct bt_ctf_stream
*stream
= NULL
, *writer_stream
= NULL
;
716 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
719 stream
= bt_ctf_packet_get_stream(packet
);
721 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
722 __func__
, __FILE__
, __LINE__
);
726 writer_stream
= get_writer_stream(writer_component
, packet
, stream
);
727 if (!writer_stream
) {
728 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
729 __func__
, __FILE__
, __LINE__
);
734 int_ret
= ctf_stream_copy_packet_context(
735 writer_component
->err
, packet
, writer_stream
);
737 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
738 __func__
, __FILE__
, __LINE__
);
742 ret
= ctf_stream_copy_packet_header(writer_component
->err
,
743 packet
, writer_stream
);
745 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
746 __func__
, __FILE__
, __LINE__
);
753 ret
= BT_COMPONENT_STATUS_ERROR
;
755 bt_put(writer_stream
);
761 enum bt_component_status
writer_close_packet(
762 struct writer_component
*writer_component
,
763 struct bt_ctf_packet
*packet
)
765 struct bt_ctf_stream
*stream
= NULL
, *writer_stream
= NULL
;
766 enum bt_component_status ret
;
768 stream
= bt_ctf_packet_get_stream(packet
);
770 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
771 __func__
, __FILE__
, __LINE__
);
775 writer_stream
= lookup_stream(writer_component
, stream
);
776 if (!writer_stream
) {
777 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
778 __func__
, __FILE__
, __LINE__
);
783 bt_get(writer_stream
);
785 ret
= bt_ctf_stream_flush(writer_stream
);
787 fprintf(writer_component
->err
,
788 "[error] Failed to flush packet\n");
791 BT_PUT(writer_stream
);
793 ret
= BT_COMPONENT_STATUS_OK
;
797 ret
= BT_COMPONENT_STATUS_ERROR
;
799 bt_put(writer_stream
);
805 enum bt_component_status
writer_output_event(
806 struct writer_component
*writer_component
,
807 struct bt_ctf_event
*event
)
809 enum bt_component_status ret
;
810 struct bt_ctf_event_class
*event_class
= NULL
, *writer_event_class
= NULL
;
811 struct bt_ctf_stream
*stream
= NULL
, *writer_stream
= NULL
;
812 struct bt_ctf_stream_class
*stream_class
= NULL
, *writer_stream_class
= NULL
;
813 struct bt_ctf_event
*writer_event
= NULL
;
814 const char *event_name
;
817 event_class
= bt_ctf_event_get_class(event
);
819 fprintf(writer_component
->err
, "[error] %s in %s:%d\n", __func__
,
824 event_name
= bt_ctf_event_class_get_name(event_class
);
826 fprintf(writer_component
->err
, "[error] %s in %s:%d\n", __func__
,
831 stream
= bt_ctf_event_get_stream(event
);
833 fprintf(writer_component
->err
, "[error] %s in %s:%d\n", __func__
,
838 writer_stream
= lookup_stream(writer_component
, stream
);
839 if (!writer_stream
|| !bt_get(writer_stream
)) {
840 fprintf(writer_component
->err
, "[error] %s in %s:%d\n", __func__
,
845 stream_class
= bt_ctf_event_class_get_stream_class(event_class
);
847 fprintf(writer_component
->err
, "[error] %s in %s:%d\n", __func__
,
852 writer_stream_class
= lookup_stream_class(writer_component
, stream_class
);
853 if (!writer_stream_class
|| !bt_get(writer_stream_class
)) {
854 fprintf(writer_component
->err
, "[error] %s in %s:%d\n", __func__
,
859 writer_event_class
= get_event_class(writer_component
,
860 writer_stream_class
, event_class
);
861 if (!writer_event_class
) {
862 writer_event_class
= ctf_copy_event_class(writer_component
->err
,
864 if (!writer_event_class
) {
865 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
866 __func__
, __FILE__
, __LINE__
);
869 int_ret
= bt_ctf_stream_class_add_event_class(
870 writer_stream_class
, writer_event_class
);
872 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
873 __func__
, __FILE__
, __LINE__
);
878 writer_event
= ctf_copy_event(writer_component
->err
, event
,
879 writer_event_class
, true);
881 fprintf(writer_component
->err
, "[error] %s in %s:%d\n", __func__
,
883 fprintf(writer_component
->err
, "[error] Failed to copy event %s\n",
884 bt_ctf_event_class_get_name(writer_event_class
));
888 int_ret
= bt_ctf_stream_append_event(writer_stream
, writer_event
);
890 fprintf(writer_component
->err
, "[error] %s in %s:%d\n", __func__
,
892 fprintf(writer_component
->err
, "[error] Failed to append event %s\n",
893 bt_ctf_event_class_get_name(writer_event_class
));
897 ret
= BT_COMPONENT_STATUS_OK
;
901 ret
= BT_COMPONENT_STATUS_ERROR
;
903 bt_put(writer_event
);
904 bt_put(writer_event_class
);
905 bt_put(writer_stream_class
);
906 bt_put(stream_class
);
907 bt_put(writer_stream
);