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-existent directory. */
204 while ((d
= readdir(dir
)) != NULL
) {
205 /* Ignore "." and ".." directories. */
228 int make_trace_path(struct writer_component
*writer_component
,
229 struct bt_ctf_trace
*trace
, char *trace_path
)
232 const char *trace_name
;
234 if (writer_component
->single_trace
) {
237 trace_name
= bt_ctf_trace_get_name(trace
);
239 trace_name
= writer_component
->trace_name_base
->str
;
243 /* Sanitize the trace name. */
244 if (strlen(trace_name
) == 2 && !strcmp(trace_name
, "..")) {
245 fprintf(writer_component
->err
, "[error] Trace name cannot "
250 if (strstr(trace_name
, "../")) {
251 fprintf(writer_component
->err
, "[error] Trace name cannot "
252 "contain \"../\", received \"%s\"\n",
258 snprintf(trace_path
, PATH_MAX
, "%s/%s",
259 writer_component
->base_path
->str
,
262 * Append a suffix if the trace_path exists and we are not in
265 if (writer_component
->single_trace
) {
266 if (valid_single_trace_path(trace_path
) != 0) {
267 fprintf(writer_component
->err
,
268 "[error] Invalid output directory\n");
272 if (g_file_test(trace_path
, G_FILE_TEST_EXISTS
)) {
276 snprintf(trace_path
, PATH_MAX
, "%s/%s-%d",
277 writer_component
->base_path
->str
,
279 } while (g_file_test(trace_path
, G_FILE_TEST_EXISTS
) && i
< INT_MAX
);
281 fprintf(writer_component
->err
, "[error] Unable to find "
282 "a unique trace path\n");
298 struct fs_writer
*insert_new_writer(
299 struct writer_component
*writer_component
,
300 struct bt_ctf_trace
*trace
)
302 struct bt_ctf_writer
*ctf_writer
= NULL
;
303 struct bt_ctf_trace
*writer_trace
= NULL
;
304 char trace_path
[PATH_MAX
];
305 enum bt_component_status ret
;
306 struct bt_ctf_stream
*stream
= NULL
;
307 struct fs_writer
*fs_writer
= NULL
;
310 if (writer_component
->single_trace
&& writer_component
->nr_traces
> 0) {
311 fprintf(writer_component
->err
, "[error] Trying to process more "
312 "than one trace but --single-trace mode "
317 ret
= make_trace_path(writer_component
, trace
, trace_path
);
319 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
320 __func__
, __FILE__
, __LINE__
);
324 printf("ctf.fs sink creating trace in %s\n", trace_path
);
326 ctf_writer
= bt_ctf_writer_create(trace_path
);
328 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
329 __func__
, __FILE__
, __LINE__
);
333 writer_trace
= bt_ctf_writer_get_trace(ctf_writer
);
335 fprintf(writer_component
->err
,
336 "[error] %s in %s:%d\n", __func__
, __FILE__
,
341 ret
= ctf_copy_trace(writer_component
->err
, trace
, writer_trace
);
342 if (ret
!= BT_COMPONENT_STATUS_OK
) {
343 fprintf(writer_component
->err
, "[error] Failed to copy trace\n");
344 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
345 __func__
, __FILE__
, __LINE__
);
350 fs_writer
= g_new0(struct fs_writer
, 1);
352 fprintf(writer_component
->err
,
353 "[error] %s in %s:%d\n", __func__
, __FILE__
,
357 fs_writer
->writer
= ctf_writer
;
358 fs_writer
->trace
= trace
;
359 fs_writer
->writer_trace
= writer_trace
;
360 fs_writer
->writer_component
= writer_component
;
361 BT_PUT(writer_trace
);
362 fs_writer
->stream_class_map
= g_hash_table_new_full(g_direct_hash
,
363 g_direct_equal
, NULL
, (GDestroyNotify
) unref_stream_class
);
364 fs_writer
->stream_map
= g_hash_table_new_full(g_direct_hash
,
365 g_direct_equal
, NULL
, (GDestroyNotify
) unref_stream
);
366 fs_writer
->stream_states
= g_hash_table_new_full(g_direct_hash
,
367 g_direct_equal
, NULL
, destroy_stream_state_key
);
369 /* Set all the existing streams in the unknown state. */
370 nr_stream
= bt_ctf_trace_get_stream_count(trace
);
371 for (i
= 0; i
< nr_stream
; i
++) {
372 stream
= bt_ctf_trace_get_stream_by_index(trace
, i
);
374 fprintf(writer_component
->err
,
375 "[error] %s in %s:%d\n", __func__
,
379 insert_new_stream_state(writer_component
, fs_writer
, stream
);
383 /* Check if the trace is already static or register a listener. */
384 if (bt_ctf_trace_is_static(trace
)) {
385 fs_writer
->trace_static
= 1;
386 fs_writer
->static_listener_id
= -1;
388 ret
= bt_ctf_trace_add_is_static_listener(trace
,
389 trace_is_static_listener
, fs_writer
);
391 fprintf(writer_component
->err
,
392 "[error] %s in %s:%d\n", __func__
, __FILE__
,
396 fs_writer
->static_listener_id
= ret
;
399 writer_component
->nr_traces
++;
400 g_hash_table_insert(writer_component
->trace_map
, (gpointer
) trace
,
408 bt_put(writer_trace
);
416 struct fs_writer
*get_fs_writer(struct writer_component
*writer_component
,
417 struct bt_ctf_stream_class
*stream_class
)
419 struct bt_ctf_trace
*trace
= NULL
;
420 struct fs_writer
*fs_writer
;
422 trace
= bt_ctf_stream_class_get_trace(stream_class
);
424 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
425 __func__
, __FILE__
, __LINE__
);
429 fs_writer
= g_hash_table_lookup(writer_component
->trace_map
,
432 fs_writer
= insert_new_writer(writer_component
, trace
);
444 struct fs_writer
*get_fs_writer_from_stream(
445 struct writer_component
*writer_component
,
446 struct bt_ctf_stream
*stream
)
448 struct bt_ctf_stream_class
*stream_class
= NULL
;
449 struct fs_writer
*fs_writer
;
451 stream_class
= bt_ctf_stream_get_class(stream
);
453 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
454 __func__
, __FILE__
, __LINE__
);
458 fs_writer
= get_fs_writer(writer_component
, stream_class
);
465 bt_put(stream_class
);
470 struct bt_ctf_stream_class
*lookup_stream_class(
471 struct writer_component
*writer_component
,
472 struct bt_ctf_stream_class
*stream_class
)
474 struct fs_writer
*fs_writer
= get_fs_writer(
475 writer_component
, stream_class
);
477 return (struct bt_ctf_stream_class
*) g_hash_table_lookup(
478 fs_writer
->stream_class_map
, (gpointer
) stream_class
);
482 struct bt_ctf_stream
*lookup_stream(struct writer_component
*writer_component
,
483 struct bt_ctf_stream
*stream
)
485 struct fs_writer
*fs_writer
= get_fs_writer_from_stream(
486 writer_component
, stream
);
488 return (struct bt_ctf_stream
*) g_hash_table_lookup(
489 fs_writer
->stream_map
, (gpointer
) stream
);
493 struct bt_ctf_stream
*insert_new_stream(
494 struct writer_component
*writer_component
,
495 struct fs_writer
*fs_writer
,
496 struct bt_ctf_stream_class
*stream_class
,
497 struct bt_ctf_stream
*stream
)
499 struct bt_ctf_stream
*writer_stream
= NULL
;
500 struct bt_ctf_stream_class
*writer_stream_class
= NULL
;
501 struct bt_ctf_writer
*ctf_writer
= bt_get(fs_writer
->writer
);
503 writer_stream_class
= lookup_stream_class(writer_component
,
505 if (!writer_stream_class
) {
506 writer_stream_class
= insert_new_stream_class(
507 writer_component
, fs_writer
, stream_class
);
508 if (!writer_stream_class
) {
509 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
510 __func__
, __FILE__
, __LINE__
);
514 bt_get(writer_stream_class
);
516 writer_stream
= bt_ctf_writer_create_stream(ctf_writer
,
517 writer_stream_class
);
518 if (!writer_stream
) {
519 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
520 __func__
, __FILE__
, __LINE__
);
524 g_hash_table_insert(fs_writer
->stream_map
, (gpointer
) stream
,
530 BT_PUT(writer_stream
);
533 bt_put(writer_stream_class
);
534 return writer_stream
;
538 struct bt_ctf_event_class
*get_event_class(struct writer_component
*writer_component
,
539 struct bt_ctf_stream_class
*writer_stream_class
,
540 struct bt_ctf_event_class
*event_class
)
542 return bt_ctf_stream_class_get_event_class_by_id(writer_stream_class
,
543 bt_ctf_event_class_get_id(event_class
));
547 struct bt_ctf_stream
*get_writer_stream(
548 struct writer_component
*writer_component
,
549 struct bt_ctf_packet
*packet
, struct bt_ctf_stream
*stream
)
551 struct bt_ctf_stream
*writer_stream
= NULL
;
553 writer_stream
= lookup_stream(writer_component
, stream
);
554 if (!writer_stream
) {
555 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
556 __func__
, __FILE__
, __LINE__
);
559 bt_get(writer_stream
);
564 BT_PUT(writer_stream
);
566 return writer_stream
;
570 void writer_close(struct writer_component
*writer_component
,
571 struct fs_writer
*fs_writer
)
573 if (fs_writer
->static_listener_id
>= 0) {
574 bt_ctf_trace_remove_is_static_listener(fs_writer
->trace
,
575 fs_writer
->static_listener_id
);
578 /* Empty the stream class HT. */
579 g_hash_table_foreach_remove(fs_writer
->stream_class_map
,
581 g_hash_table_destroy(fs_writer
->stream_class_map
);
583 /* Empty the stream HT. */
584 g_hash_table_foreach_remove(fs_writer
->stream_map
,
585 empty_streams_ht
, NULL
);
586 g_hash_table_destroy(fs_writer
->stream_map
);
588 /* Empty the stream state HT. */
589 g_hash_table_foreach_remove(fs_writer
->stream_states
,
591 g_hash_table_destroy(fs_writer
->stream_states
);
595 enum bt_component_status
writer_stream_begin(
596 struct writer_component
*writer_component
,
597 struct bt_ctf_stream
*stream
)
599 struct bt_ctf_stream_class
*stream_class
= NULL
;
600 struct fs_writer
*fs_writer
;
601 struct bt_ctf_stream
*writer_stream
= NULL
;
602 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
603 enum fs_writer_stream_state
*state
;
605 stream_class
= bt_ctf_stream_get_class(stream
);
607 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
608 __func__
, __FILE__
, __LINE__
);
612 fs_writer
= get_fs_writer(writer_component
, stream_class
);
614 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
615 __func__
, __FILE__
, __LINE__
);
619 /* Set the stream as active */
620 state
= g_hash_table_lookup(fs_writer
->stream_states
, stream
);
622 if (fs_writer
->trace_static
) {
623 fprintf(writer_component
->err
, "[error] Adding a new "
624 "stream on a static trace\n");
627 state
= insert_new_stream_state(writer_component
, fs_writer
,
630 if (*state
!= FS_WRITER_UNKNOWN_STREAM
) {
631 fprintf(writer_component
->err
, "[error] Unexpected stream "
632 "state %d\n", *state
);
635 *state
= FS_WRITER_ACTIVE_STREAM
;
637 writer_stream
= insert_new_stream(writer_component
, fs_writer
,
638 stream_class
, stream
);
639 if (!writer_stream
) {
640 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
641 __func__
, __FILE__
, __LINE__
);
648 ret
= BT_COMPONENT_STATUS_ERROR
;
650 bt_put(stream_class
);
655 enum bt_component_status
writer_stream_end(
656 struct writer_component
*writer_component
,
657 struct bt_ctf_stream
*stream
)
659 struct bt_ctf_stream_class
*stream_class
= NULL
;
660 struct fs_writer
*fs_writer
;
661 struct bt_ctf_trace
*trace
= NULL
;
662 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
663 enum fs_writer_stream_state
*state
;
665 stream_class
= bt_ctf_stream_get_class(stream
);
667 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
668 __func__
, __FILE__
, __LINE__
);
672 fs_writer
= get_fs_writer(writer_component
, stream_class
);
674 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
675 __func__
, __FILE__
, __LINE__
);
679 state
= g_hash_table_lookup(fs_writer
->stream_states
, stream
);
680 if (*state
!= FS_WRITER_ACTIVE_STREAM
) {
681 fprintf(writer_component
->err
, "[error] Unexpected stream "
682 "state %d\n", *state
);
685 *state
= FS_WRITER_COMPLETED_STREAM
;
687 g_hash_table_remove(fs_writer
->stream_map
, stream
);
689 if (fs_writer
->trace_static
) {
690 int trace_completed
= 1;
692 g_hash_table_foreach(fs_writer
->stream_states
,
693 check_completed_trace
, &trace_completed
);
694 if (trace_completed
) {
695 writer_close(writer_component
, fs_writer
);
696 g_hash_table_remove(writer_component
->trace_map
,
704 ret
= BT_COMPONENT_STATUS_ERROR
;
707 BT_PUT(stream_class
);
712 enum bt_component_status
writer_new_packet(
713 struct writer_component
*writer_component
,
714 struct bt_ctf_packet
*packet
)
716 struct bt_ctf_stream
*stream
= NULL
, *writer_stream
= NULL
;
717 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
720 stream
= bt_ctf_packet_get_stream(packet
);
722 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
723 __func__
, __FILE__
, __LINE__
);
727 writer_stream
= get_writer_stream(writer_component
, packet
, stream
);
728 if (!writer_stream
) {
729 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
730 __func__
, __FILE__
, __LINE__
);
735 int_ret
= ctf_stream_copy_packet_context(
736 writer_component
->err
, packet
, writer_stream
);
738 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
739 __func__
, __FILE__
, __LINE__
);
743 ret
= ctf_stream_copy_packet_header(writer_component
->err
,
744 packet
, writer_stream
);
746 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
747 __func__
, __FILE__
, __LINE__
);
754 ret
= BT_COMPONENT_STATUS_ERROR
;
756 bt_put(writer_stream
);
762 enum bt_component_status
writer_close_packet(
763 struct writer_component
*writer_component
,
764 struct bt_ctf_packet
*packet
)
766 struct bt_ctf_stream
*stream
= NULL
, *writer_stream
= NULL
;
767 enum bt_component_status ret
;
769 stream
= bt_ctf_packet_get_stream(packet
);
771 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
772 __func__
, __FILE__
, __LINE__
);
776 writer_stream
= lookup_stream(writer_component
, stream
);
777 if (!writer_stream
) {
778 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
779 __func__
, __FILE__
, __LINE__
);
784 bt_get(writer_stream
);
786 ret
= bt_ctf_stream_flush(writer_stream
);
788 fprintf(writer_component
->err
,
789 "[error] Failed to flush packet\n");
792 BT_PUT(writer_stream
);
794 ret
= BT_COMPONENT_STATUS_OK
;
798 ret
= BT_COMPONENT_STATUS_ERROR
;
800 bt_put(writer_stream
);
806 enum bt_component_status
writer_output_event(
807 struct writer_component
*writer_component
,
808 struct bt_ctf_event
*event
)
810 enum bt_component_status ret
;
811 struct bt_ctf_event_class
*event_class
= NULL
, *writer_event_class
= NULL
;
812 struct bt_ctf_stream
*stream
= NULL
, *writer_stream
= NULL
;
813 struct bt_ctf_stream_class
*stream_class
= NULL
, *writer_stream_class
= NULL
;
814 struct bt_ctf_event
*writer_event
= NULL
;
815 const char *event_name
;
818 event_class
= bt_ctf_event_get_class(event
);
820 fprintf(writer_component
->err
, "[error] %s in %s:%d\n", __func__
,
825 event_name
= bt_ctf_event_class_get_name(event_class
);
827 fprintf(writer_component
->err
, "[error] %s in %s:%d\n", __func__
,
832 stream
= bt_ctf_event_get_stream(event
);
834 fprintf(writer_component
->err
, "[error] %s in %s:%d\n", __func__
,
839 writer_stream
= lookup_stream(writer_component
, stream
);
840 if (!writer_stream
|| !bt_get(writer_stream
)) {
841 fprintf(writer_component
->err
, "[error] %s in %s:%d\n", __func__
,
846 stream_class
= bt_ctf_event_class_get_stream_class(event_class
);
848 fprintf(writer_component
->err
, "[error] %s in %s:%d\n", __func__
,
853 writer_stream_class
= lookup_stream_class(writer_component
, stream_class
);
854 if (!writer_stream_class
|| !bt_get(writer_stream_class
)) {
855 fprintf(writer_component
->err
, "[error] %s in %s:%d\n", __func__
,
860 writer_event_class
= get_event_class(writer_component
,
861 writer_stream_class
, event_class
);
862 if (!writer_event_class
) {
863 writer_event_class
= ctf_copy_event_class(writer_component
->err
,
865 if (!writer_event_class
) {
866 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
867 __func__
, __FILE__
, __LINE__
);
870 int_ret
= bt_ctf_stream_class_add_event_class(
871 writer_stream_class
, writer_event_class
);
873 fprintf(writer_component
->err
, "[error] %s in %s:%d\n",
874 __func__
, __FILE__
, __LINE__
);
879 writer_event
= ctf_copy_event(writer_component
->err
, event
,
880 writer_event_class
, true);
882 fprintf(writer_component
->err
, "[error] %s in %s:%d\n", __func__
,
884 fprintf(writer_component
->err
, "[error] Failed to copy event %s\n",
885 bt_ctf_event_class_get_name(writer_event_class
));
889 int_ret
= bt_ctf_stream_append_event(writer_stream
, writer_event
);
891 fprintf(writer_component
->err
, "[error] %s in %s:%d\n", __func__
,
893 fprintf(writer_component
->err
, "[error] Failed to append event %s\n",
894 bt_ctf_event_class_get_name(writer_event_class
));
898 ret
= BT_COMPONENT_STATUS_OK
;
902 ret
= BT_COMPONENT_STATUS_ERROR
;
904 bt_put(writer_event
);
905 bt_put(writer_event_class
);
906 bt_put(writer_stream_class
);
907 bt_put(stream_class
);
908 bt_put(writer_stream
);