2 * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
3 * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 #define BT_LOG_TAG "PLUGIN-TEXT-DMESG-SRC"
31 #include <babeltrace2/assert-internal.h>
32 #include <babeltrace2/common-internal.h>
33 #include <babeltrace2/babeltrace.h>
34 #include <babeltrace2/value-internal.h>
35 #include <babeltrace2/compat/utc-internal.h>
36 #include <babeltrace2/compat/stdio-internal.h>
39 #define NSEC_PER_USEC 1000UL
40 #define NSEC_PER_MSEC 1000000UL
41 #define NSEC_PER_SEC 1000000000ULL
42 #define USEC_PER_SEC 1000000UL
44 struct dmesg_component
;
46 struct dmesg_msg_iter
{
47 struct dmesg_component
*dmesg_comp
;
48 bt_self_message_iterator
*pc_msg_iter
; /* Weak */
52 bt_message
*tmp_event_msg
;
53 uint64_t last_clock_value
;
56 STATE_EMIT_STREAM_BEGINNING
,
57 STATE_EMIT_STREAM_ACTIVITY_BEGINNING
,
58 STATE_EMIT_PACKET_BEGINNING
,
60 STATE_EMIT_PACKET_END
,
61 STATE_EMIT_STREAM_ACTIVITY_END
,
62 STATE_EMIT_STREAM_END
,
67 struct dmesg_component
{
70 bt_bool read_from_stdin
;
74 bt_self_component_source
*self_comp
;
75 bt_trace_class
*trace_class
;
76 bt_stream_class
*stream_class
;
77 bt_event_class
*event_class
;
81 bt_clock_class
*clock_class
;
85 bt_field_class
*create_event_payload_fc(bt_trace_class
*trace_class
)
87 bt_field_class
*root_fc
= NULL
;
88 bt_field_class
*fc
= NULL
;
91 root_fc
= bt_field_class_structure_create(trace_class
);
93 BT_LOGE_STR("Cannot create an empty structure field class object.");
97 fc
= bt_field_class_string_create(trace_class
);
99 BT_LOGE_STR("Cannot create a string field class object.");
103 ret
= bt_field_class_structure_append_member(root_fc
,
106 BT_LOGE("Cannot add `str` member to structure field class: "
114 BT_FIELD_CLASS_PUT_REF_AND_RESET(root_fc
);
117 bt_field_class_put_ref(fc
);
122 int create_meta(struct dmesg_component
*dmesg_comp
, bool has_ts
)
124 bt_field_class
*fc
= NULL
;
127 dmesg_comp
->trace_class
= bt_trace_class_create(
128 bt_self_component_source_as_self_component(
129 dmesg_comp
->self_comp
));
130 if (!dmesg_comp
->trace_class
) {
131 BT_LOGE_STR("Cannot create an empty trace class object.");
135 dmesg_comp
->stream_class
= bt_stream_class_create(
136 dmesg_comp
->trace_class
);
137 if (!dmesg_comp
->stream_class
) {
138 BT_LOGE_STR("Cannot create a stream class object.");
143 dmesg_comp
->clock_class
= bt_clock_class_create(
144 bt_self_component_source_as_self_component(
145 dmesg_comp
->self_comp
));
146 if (!dmesg_comp
->clock_class
) {
147 BT_LOGE_STR("Cannot create clock class.");
152 * The `dmesg` timestamp's origin is not the Unix epoch,
153 * it's the boot time.
155 bt_clock_class_set_origin_is_unix_epoch(dmesg_comp
->clock_class
,
158 ret
= bt_stream_class_set_default_clock_class(
159 dmesg_comp
->stream_class
, dmesg_comp
->clock_class
);
161 BT_LOGE_STR("Cannot set stream class's default clock class.");
165 bt_stream_class_set_packets_have_beginning_default_clock_snapshot(
166 dmesg_comp
->stream_class
, BT_TRUE
);
167 bt_stream_class_set_packets_have_end_default_clock_snapshot(
168 dmesg_comp
->stream_class
, BT_TRUE
);
171 dmesg_comp
->event_class
= bt_event_class_create(
172 dmesg_comp
->stream_class
);
173 if (!dmesg_comp
->event_class
) {
174 BT_LOGE_STR("Cannot create an event class object.");
178 ret
= bt_event_class_set_name(dmesg_comp
->event_class
, "string");
180 BT_LOGE_STR("Cannot set event class's name.");
184 fc
= create_event_payload_fc(dmesg_comp
->trace_class
);
186 BT_LOGE_STR("Cannot create event payload field class.");
190 ret
= bt_event_class_set_payload_field_class(dmesg_comp
->event_class
, fc
);
192 BT_LOGE_STR("Cannot set event class's event payload field class.");
202 bt_field_class_put_ref(fc
);
207 int handle_params(struct dmesg_component
*dmesg_comp
,
208 const bt_value
*params
)
210 const bt_value
*no_timestamp
= NULL
;
211 const bt_value
*path
= NULL
;
212 const char *path_str
;
215 no_timestamp
= bt_value_map_borrow_entry_value_const(params
,
216 "no-extract-timestamp");
218 if (!bt_value_is_bool(no_timestamp
)) {
219 BT_LOGE("Expecting a boolean value for the `no-extract-timestamp` parameter: "
221 bt_common_value_type_string(
222 bt_value_get_type(no_timestamp
)));
226 dmesg_comp
->params
.no_timestamp
=
227 bt_value_bool_get(no_timestamp
);
230 path
= bt_value_map_borrow_entry_value_const(params
, "path");
232 if (dmesg_comp
->params
.read_from_stdin
) {
233 BT_LOGE_STR("Cannot specify both `read-from-stdin` and `path` parameters.");
237 if (!bt_value_is_string(path
)) {
238 BT_LOGE("Expecting a string value for the `path` parameter: "
240 bt_common_value_type_string(
241 bt_value_get_type(path
)));
245 path_str
= bt_value_string_get(path
);
246 g_string_assign(dmesg_comp
->params
.path
, path_str
);
248 dmesg_comp
->params
.read_from_stdin
= true;
261 int create_packet_and_stream_and_trace(struct dmesg_component
*dmesg_comp
)
264 const char *trace_name
= NULL
;
265 gchar
*basename
= NULL
;
267 dmesg_comp
->trace
= bt_trace_create(dmesg_comp
->trace_class
);
268 if (!dmesg_comp
->trace
) {
269 BT_LOGE_STR("Cannot create trace object.");
273 if (dmesg_comp
->params
.read_from_stdin
) {
274 trace_name
= "STDIN";
276 basename
= g_path_get_basename(dmesg_comp
->params
.path
->str
);
279 if (strcmp(basename
, G_DIR_SEPARATOR_S
) != 0 &&
280 strcmp(basename
, ".") != 0) {
281 trace_name
= basename
;
286 ret
= bt_trace_set_name(dmesg_comp
->trace
, trace_name
);
288 BT_LOGE("Cannot set trace's name: name=\"%s\"",
294 dmesg_comp
->stream
= bt_stream_create(dmesg_comp
->stream_class
,
296 if (!dmesg_comp
->stream
) {
297 BT_LOGE_STR("Cannot create stream object.");
301 dmesg_comp
->packet
= bt_packet_create(dmesg_comp
->stream
);
302 if (!dmesg_comp
->packet
) {
303 BT_LOGE_STR("Cannot create packet object.");
321 int try_create_meta_stream_packet(struct dmesg_component
*dmesg_comp
,
326 if (dmesg_comp
->trace
) {
327 /* Already created */
331 ret
= create_meta(dmesg_comp
, has_ts
);
333 BT_LOGE("Cannot create metadata objects: dmesg-comp-addr=%p",
338 ret
= create_packet_and_stream_and_trace(dmesg_comp
);
340 BT_LOGE("Cannot create packet and stream objects: "
341 "dmesg-comp-addr=%p", dmesg_comp
);
355 void destroy_dmesg_component(struct dmesg_component
*dmesg_comp
)
361 if (dmesg_comp
->params
.path
) {
362 g_string_free(dmesg_comp
->params
.path
, TRUE
);
365 bt_packet_put_ref(dmesg_comp
->packet
);
366 bt_trace_put_ref(dmesg_comp
->trace
);
367 bt_stream_class_put_ref(dmesg_comp
->stream_class
);
368 bt_event_class_put_ref(dmesg_comp
->event_class
);
369 bt_stream_put_ref(dmesg_comp
->stream
);
370 bt_clock_class_put_ref(dmesg_comp
->clock_class
);
371 bt_trace_class_put_ref(dmesg_comp
->trace_class
);
376 bt_self_component_status
create_port(
377 bt_self_component_source
*self_comp
)
379 return bt_self_component_source_add_output_port(self_comp
,
384 bt_self_component_status
dmesg_init(
385 bt_self_component_source
*self_comp
,
386 bt_value
*params
, void *init_method_data
)
389 struct dmesg_component
*dmesg_comp
= g_new0(struct dmesg_component
, 1);
390 bt_self_component_status status
= BT_SELF_COMPONENT_STATUS_OK
;
393 BT_LOGE_STR("Failed to allocate one dmesg component structure.");
397 dmesg_comp
->self_comp
= self_comp
;
398 dmesg_comp
->params
.path
= g_string_new(NULL
);
399 if (!dmesg_comp
->params
.path
) {
400 BT_LOGE_STR("Failed to allocate a GString.");
404 ret
= handle_params(dmesg_comp
, params
);
406 BT_LOGE("Invalid parameters: comp-addr=%p", self_comp
);
410 if (!dmesg_comp
->params
.read_from_stdin
&&
411 !g_file_test(dmesg_comp
->params
.path
->str
,
412 G_FILE_TEST_IS_REGULAR
)) {
413 BT_LOGE("Input path is not a regular file: "
414 "comp-addr=%p, path=\"%s\"", self_comp
,
415 dmesg_comp
->params
.path
->str
);
419 status
= create_port(self_comp
);
420 if (status
!= BT_SELF_COMPONENT_STATUS_OK
) {
424 bt_self_component_set_data(
425 bt_self_component_source_as_self_component(self_comp
),
430 destroy_dmesg_component(dmesg_comp
);
431 bt_self_component_set_data(
432 bt_self_component_source_as_self_component(self_comp
),
436 status
= BT_SELF_COMPONENT_STATUS_ERROR
;
444 void dmesg_finalize(bt_self_component_source
*self_comp
)
446 destroy_dmesg_component(bt_self_component_get_data(
447 bt_self_component_source_as_self_component(self_comp
)));
451 bt_message
*create_init_event_msg_from_line(
452 struct dmesg_msg_iter
*msg_iter
,
453 const char *line
, const char **new_start
)
456 bt_message
*msg
= NULL
;
457 bool has_timestamp
= false;
458 unsigned long sec
, usec
, msec
;
459 unsigned int year
, mon
, mday
, hour
, min
;
462 struct dmesg_component
*dmesg_comp
= msg_iter
->dmesg_comp
;
466 if (dmesg_comp
->params
.no_timestamp
) {
470 /* Extract time from input line */
471 if (sscanf(line
, "[%lu.%lu] ", &sec
, &usec
) == 2) {
472 ts
= (uint64_t) sec
* USEC_PER_SEC
+ (uint64_t) usec
;
475 * The clock class we use has a 1 GHz frequency: convert
479 has_timestamp
= true;
480 } else if (sscanf(line
, "[%u-%u-%u %u:%u:%lu.%lu] ",
481 &year
, &mon
, &mday
, &hour
, &min
,
486 memset(&ti
, 0, sizeof(ti
));
487 ti
.tm_year
= year
- 1900; /* From 1900 */
488 ti
.tm_mon
= mon
- 1; /* 0 to 11 */
494 ep_sec
= bt_timegm(&ti
);
495 if (ep_sec
!= (time_t) -1) {
496 ts
= (uint64_t) ep_sec
* NSEC_PER_SEC
497 + (uint64_t) msec
* NSEC_PER_MSEC
;
500 has_timestamp
= true;
504 /* Set new start for the message portion of the line */
505 *new_start
= strchr(line
, ']');
506 BT_ASSERT(*new_start
);
509 if ((*new_start
)[0] == ' ') {
516 * At this point, we know if the stream class's event header
517 * field class should have a timestamp or not, so we can lazily
518 * create the metadata, stream, and packet objects.
520 ret
= try_create_meta_stream_packet(dmesg_comp
, has_timestamp
);
522 /* try_create_meta_stream_packet() logs errors */
526 if (dmesg_comp
->clock_class
) {
527 msg
= bt_message_event_create_with_default_clock_snapshot(
528 msg_iter
->pc_msg_iter
,
529 dmesg_comp
->event_class
, dmesg_comp
->packet
, ts
);
530 msg_iter
->last_clock_value
= ts
;
532 msg
= bt_message_event_create(msg_iter
->pc_msg_iter
,
533 dmesg_comp
->event_class
, dmesg_comp
->packet
);
537 BT_LOGE_STR("Cannot create event message.");
541 event
= bt_message_event_borrow_event(msg
);
546 BT_MESSAGE_PUT_REF_AND_RESET(msg
);
553 int fill_event_payload_from_line(const char *line
,
556 bt_field
*ep_field
= NULL
;
557 bt_field
*str_field
= NULL
;
561 ep_field
= bt_event_borrow_payload_field(event
);
563 str_field
= bt_field_structure_borrow_member_field_by_index(
566 BT_LOGE_STR("Cannot borrow `timestamp` field from event payload structure field.");
571 if (line
[len
- 1] == '\n') {
572 /* Do not include the newline character in the payload */
576 ret
= bt_field_string_clear(str_field
);
578 BT_LOGE_STR("Cannot clear string field object.");
582 ret
= bt_field_string_append_with_length(str_field
, line
, len
);
584 BT_LOGE("Cannot append value to string field object: "
599 bt_message
*create_msg_from_line(
600 struct dmesg_msg_iter
*dmesg_msg_iter
, const char *line
)
602 bt_event
*event
= NULL
;
603 bt_message
*msg
= NULL
;
604 const char *new_start
;
607 msg
= create_init_event_msg_from_line(dmesg_msg_iter
,
610 BT_LOGE_STR("Cannot create and initialize event message from line.");
614 event
= bt_message_event_borrow_event(msg
);
616 ret
= fill_event_payload_from_line(new_start
, event
);
618 BT_LOGE("Cannot fill event payload field from line: "
626 BT_MESSAGE_PUT_REF_AND_RESET(msg
);
633 void destroy_dmesg_msg_iter(struct dmesg_msg_iter
*dmesg_msg_iter
)
635 if (!dmesg_msg_iter
) {
639 if (dmesg_msg_iter
->fp
&& dmesg_msg_iter
->fp
!= stdin
) {
640 if (fclose(dmesg_msg_iter
->fp
)) {
641 BT_LOGE_ERRNO("Cannot close input file", ".");
645 bt_message_put_ref(dmesg_msg_iter
->tmp_event_msg
);
646 free(dmesg_msg_iter
->linebuf
);
647 g_free(dmesg_msg_iter
);
653 bt_self_message_iterator_status
dmesg_msg_iter_init(
654 bt_self_message_iterator
*self_msg_iter
,
655 bt_self_component_source
*self_comp
,
656 bt_self_component_port_output
*self_port
)
658 struct dmesg_component
*dmesg_comp
;
659 struct dmesg_msg_iter
*dmesg_msg_iter
=
660 g_new0(struct dmesg_msg_iter
, 1);
661 bt_self_message_iterator_status status
=
662 BT_SELF_MESSAGE_ITERATOR_STATUS_OK
;
664 if (!dmesg_msg_iter
) {
665 BT_LOGE_STR("Failed to allocate on dmesg message iterator structure.");
669 dmesg_comp
= bt_self_component_get_data(
670 bt_self_component_source_as_self_component(self_comp
));
671 BT_ASSERT(dmesg_comp
);
672 dmesg_msg_iter
->dmesg_comp
= dmesg_comp
;
673 dmesg_msg_iter
->pc_msg_iter
= self_msg_iter
;
675 if (dmesg_comp
->params
.read_from_stdin
) {
676 dmesg_msg_iter
->fp
= stdin
;
678 dmesg_msg_iter
->fp
= fopen(dmesg_comp
->params
.path
->str
, "r");
679 if (!dmesg_msg_iter
->fp
) {
680 BT_LOGE_ERRNO("Cannot open input file in read mode", ": path=\"%s\"",
681 dmesg_comp
->params
.path
->str
);
686 bt_self_message_iterator_set_data(self_msg_iter
,
691 destroy_dmesg_msg_iter(dmesg_msg_iter
);
692 bt_self_message_iterator_set_data(self_msg_iter
, NULL
);
694 status
= BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR
;
702 void dmesg_msg_iter_finalize(
703 bt_self_message_iterator
*priv_msg_iter
)
705 destroy_dmesg_msg_iter(bt_self_message_iterator_get_data(
710 bt_self_message_iterator_status
dmesg_msg_iter_next_one(
711 struct dmesg_msg_iter
*dmesg_msg_iter
,
715 struct dmesg_component
*dmesg_comp
;
716 bt_self_message_iterator_status status
=
717 BT_SELF_MESSAGE_ITERATOR_STATUS_OK
;
719 BT_ASSERT(dmesg_msg_iter
);
720 dmesg_comp
= dmesg_msg_iter
->dmesg_comp
;
721 BT_ASSERT(dmesg_comp
);
723 if (dmesg_msg_iter
->state
== STATE_DONE
) {
724 status
= BT_SELF_MESSAGE_ITERATOR_STATUS_END
;
728 if (dmesg_msg_iter
->tmp_event_msg
||
729 dmesg_msg_iter
->state
== STATE_EMIT_PACKET_END
||
730 dmesg_msg_iter
->state
== STATE_EMIT_STREAM_ACTIVITY_END
||
731 dmesg_msg_iter
->state
== STATE_EMIT_STREAM_END
) {
737 bool only_spaces
= true;
739 len
= bt_getline(&dmesg_msg_iter
->linebuf
,
740 &dmesg_msg_iter
->linebuf_len
, dmesg_msg_iter
->fp
);
742 if (errno
== EINVAL
) {
743 status
= BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR
;
744 } else if (errno
== ENOMEM
) {
746 BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM
;
748 if (dmesg_msg_iter
->state
== STATE_EMIT_STREAM_BEGINNING
) {
749 /* Stream did not even begin */
750 status
= BT_SELF_MESSAGE_ITERATOR_STATUS_END
;
753 /* End current packet now */
754 dmesg_msg_iter
->state
=
755 STATE_EMIT_PACKET_END
;
763 BT_ASSERT(dmesg_msg_iter
->linebuf
);
765 /* Ignore empty lines, once trimmed */
766 for (ch
= dmesg_msg_iter
->linebuf
; *ch
!= '\0'; ch
++) {
778 dmesg_msg_iter
->tmp_event_msg
= create_msg_from_line(
779 dmesg_msg_iter
, dmesg_msg_iter
->linebuf
);
780 if (!dmesg_msg_iter
->tmp_event_msg
) {
781 BT_LOGE("Cannot create event message from line: "
782 "dmesg-comp-addr=%p, line=\"%s\"", dmesg_comp
,
783 dmesg_msg_iter
->linebuf
);
788 BT_ASSERT(dmesg_comp
->trace
);
790 switch (dmesg_msg_iter
->state
) {
791 case STATE_EMIT_STREAM_BEGINNING
:
792 BT_ASSERT(dmesg_msg_iter
->tmp_event_msg
);
793 *msg
= bt_message_stream_beginning_create(
794 dmesg_msg_iter
->pc_msg_iter
, dmesg_comp
->stream
);
795 dmesg_msg_iter
->state
= STATE_EMIT_STREAM_ACTIVITY_BEGINNING
;
797 case STATE_EMIT_STREAM_ACTIVITY_BEGINNING
:
798 BT_ASSERT(dmesg_msg_iter
->tmp_event_msg
);
799 *msg
= bt_message_stream_activity_beginning_create(
800 dmesg_msg_iter
->pc_msg_iter
, dmesg_comp
->stream
);
801 dmesg_msg_iter
->state
= STATE_EMIT_PACKET_BEGINNING
;
803 case STATE_EMIT_PACKET_BEGINNING
:
804 BT_ASSERT(dmesg_msg_iter
->tmp_event_msg
);
806 if (dmesg_comp
->clock_class
) {
807 *msg
= bt_message_packet_beginning_create_with_default_clock_snapshot(
808 dmesg_msg_iter
->pc_msg_iter
, dmesg_comp
->packet
,
809 dmesg_msg_iter
->last_clock_value
);
811 *msg
= bt_message_packet_beginning_create(
812 dmesg_msg_iter
->pc_msg_iter
, dmesg_comp
->packet
);
815 dmesg_msg_iter
->state
= STATE_EMIT_EVENT
;
817 case STATE_EMIT_EVENT
:
818 BT_ASSERT(dmesg_msg_iter
->tmp_event_msg
);
819 *msg
= dmesg_msg_iter
->tmp_event_msg
;
820 dmesg_msg_iter
->tmp_event_msg
= NULL
;
822 case STATE_EMIT_PACKET_END
:
823 if (dmesg_comp
->clock_class
) {
824 *msg
= bt_message_packet_end_create_with_default_clock_snapshot(
825 dmesg_msg_iter
->pc_msg_iter
, dmesg_comp
->packet
,
826 dmesg_msg_iter
->last_clock_value
);
828 *msg
= bt_message_packet_end_create(
829 dmesg_msg_iter
->pc_msg_iter
, dmesg_comp
->packet
);
832 dmesg_msg_iter
->state
= STATE_EMIT_STREAM_ACTIVITY_END
;
834 case STATE_EMIT_STREAM_ACTIVITY_END
:
835 *msg
= bt_message_stream_activity_end_create(
836 dmesg_msg_iter
->pc_msg_iter
, dmesg_comp
->stream
);
837 dmesg_msg_iter
->state
= STATE_EMIT_STREAM_END
;
839 case STATE_EMIT_STREAM_END
:
840 *msg
= bt_message_stream_end_create(
841 dmesg_msg_iter
->pc_msg_iter
, dmesg_comp
->stream
);
842 dmesg_msg_iter
->state
= STATE_DONE
;
849 BT_LOGE("Cannot create message: dmesg-comp-addr=%p",
851 status
= BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR
;
859 bt_self_message_iterator_status
dmesg_msg_iter_next(
860 bt_self_message_iterator
*self_msg_iter
,
861 bt_message_array_const msgs
, uint64_t capacity
,
864 struct dmesg_msg_iter
*dmesg_msg_iter
=
865 bt_self_message_iterator_get_data(
867 bt_self_message_iterator_status status
=
868 BT_SELF_MESSAGE_ITERATOR_STATUS_OK
;
871 while (i
< capacity
&&
872 status
== BT_SELF_MESSAGE_ITERATOR_STATUS_OK
) {
873 bt_message
*priv_msg
= NULL
;
875 status
= dmesg_msg_iter_next_one(dmesg_msg_iter
,
878 if (status
== BT_SELF_MESSAGE_ITERATOR_STATUS_OK
) {
885 * Even if dmesg_msg_iter_next_one() returned
886 * something else than
887 * BT_SELF_MESSAGE_ITERATOR_STATUS_OK, we
888 * accumulated message objects in the output
889 * message array, so we need to return
890 * BT_SELF_MESSAGE_ITERATOR_STATUS_OK so that they
891 * are transfered to downstream. This other status
892 * occurs again the next time muxer_msg_iter_do_next()
893 * is called, possibly without any accumulated
894 * message, in which case we'll return it.
897 status
= BT_SELF_MESSAGE_ITERATOR_STATUS_OK
;
904 bt_bool
dmesg_msg_iter_can_seek_beginning(
905 bt_self_message_iterator
*self_msg_iter
)
907 struct dmesg_msg_iter
*dmesg_msg_iter
=
908 bt_self_message_iterator_get_data(self_msg_iter
);
910 /* Can't seek the beginning of the standard input stream */
911 return !dmesg_msg_iter
->dmesg_comp
->params
.read_from_stdin
;
915 bt_self_message_iterator_status
dmesg_msg_iter_seek_beginning(
916 bt_self_message_iterator
*self_msg_iter
)
918 struct dmesg_msg_iter
*dmesg_msg_iter
=
919 bt_self_message_iterator_get_data(self_msg_iter
);
921 BT_ASSERT(!dmesg_msg_iter
->dmesg_comp
->params
.read_from_stdin
);
923 BT_MESSAGE_PUT_REF_AND_RESET(dmesg_msg_iter
->tmp_event_msg
);
924 dmesg_msg_iter
->last_clock_value
= 0;
925 dmesg_msg_iter
->state
= STATE_EMIT_STREAM_BEGINNING
;
926 return BT_SELF_MESSAGE_ITERATOR_STATUS_OK
;