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_COMP_LOG_SELF_COMP (dmesg_comp->self_comp)
25 #define BT_LOG_OUTPUT_LEVEL (dmesg_comp->log_level)
26 #define BT_LOG_TAG "PLUGIN/SRC.TEXT.DMESG"
27 #include "plugins/comp-logging.h"
33 #include "common/common.h"
34 #include "common/assert.h"
35 #include <babeltrace2/babeltrace.h>
36 #include "compat/utc.h"
37 #include "compat/stdio.h"
40 #define NSEC_PER_USEC 1000UL
41 #define NSEC_PER_MSEC 1000000UL
42 #define NSEC_PER_SEC 1000000000ULL
43 #define USEC_PER_SEC 1000000UL
45 struct dmesg_component
;
47 struct dmesg_msg_iter
{
48 struct dmesg_component
*dmesg_comp
;
49 bt_self_message_iterator
*pc_msg_iter
; /* Weak */
53 bt_message
*tmp_event_msg
;
54 uint64_t last_clock_value
;
57 STATE_EMIT_STREAM_BEGINNING
,
59 STATE_EMIT_STREAM_END
,
64 struct dmesg_component
{
65 bt_logging_level log_level
;
69 bt_bool read_from_stdin
;
73 bt_self_component_source
*self_comp_src
;
74 bt_self_component
*self_comp
;
75 bt_trace_class
*trace_class
;
76 bt_stream_class
*stream_class
;
77 bt_event_class
*event_class
;
80 bt_clock_class
*clock_class
;
84 bt_field_class
*create_event_payload_fc(struct dmesg_component
*dmesg_comp
,
85 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_COMP_LOGE_STR("Cannot create an empty structure field class object.");
97 fc
= bt_field_class_string_create(trace_class
);
99 BT_COMP_LOGE_STR("Cannot create a string field class object.");
103 ret
= bt_field_class_structure_append_member(root_fc
,
106 BT_COMP_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(dmesg_comp
->self_comp
);
128 if (!dmesg_comp
->trace_class
) {
129 BT_COMP_LOGE_STR("Cannot create an empty trace class object.");
133 dmesg_comp
->stream_class
= bt_stream_class_create(
134 dmesg_comp
->trace_class
);
135 if (!dmesg_comp
->stream_class
) {
136 BT_COMP_LOGE_STR("Cannot create a stream class object.");
141 dmesg_comp
->clock_class
= bt_clock_class_create(
142 dmesg_comp
->self_comp
);
143 if (!dmesg_comp
->clock_class
) {
144 BT_COMP_LOGE_STR("Cannot create clock class.");
149 * The `dmesg` timestamp's origin is not the Unix epoch,
150 * it's the boot time.
152 bt_clock_class_set_origin_is_unix_epoch(dmesg_comp
->clock_class
,
155 ret
= bt_stream_class_set_default_clock_class(
156 dmesg_comp
->stream_class
, dmesg_comp
->clock_class
);
158 BT_COMP_LOGE_STR("Cannot set stream class's default clock class.");
163 dmesg_comp
->event_class
= bt_event_class_create(
164 dmesg_comp
->stream_class
);
165 if (!dmesg_comp
->event_class
) {
166 BT_COMP_LOGE_STR("Cannot create an event class object.");
170 ret
= bt_event_class_set_name(dmesg_comp
->event_class
, "string");
172 BT_COMP_LOGE_STR("Cannot set event class's name.");
176 fc
= create_event_payload_fc(dmesg_comp
, dmesg_comp
->trace_class
);
178 BT_COMP_LOGE_STR("Cannot create event payload field class.");
182 ret
= bt_event_class_set_payload_field_class(dmesg_comp
->event_class
, fc
);
184 BT_COMP_LOGE_STR("Cannot set event class's event payload field class.");
194 bt_field_class_put_ref(fc
);
199 int handle_params(struct dmesg_component
*dmesg_comp
,
200 const bt_value
*params
)
202 const bt_value
*no_timestamp
= NULL
;
203 const bt_value
*path
= NULL
;
204 const char *path_str
;
207 no_timestamp
= bt_value_map_borrow_entry_value_const(params
,
208 "no-extract-timestamp");
210 if (!bt_value_is_bool(no_timestamp
)) {
211 BT_COMP_LOGE("Expecting a boolean value for the `no-extract-timestamp` parameter: "
213 bt_common_value_type_string(
214 bt_value_get_type(no_timestamp
)));
218 dmesg_comp
->params
.no_timestamp
=
219 bt_value_bool_get(no_timestamp
);
222 path
= bt_value_map_borrow_entry_value_const(params
, "path");
224 if (dmesg_comp
->params
.read_from_stdin
) {
225 BT_COMP_LOGE_STR("Cannot specify both `read-from-stdin` and `path` parameters.");
229 if (!bt_value_is_string(path
)) {
230 BT_COMP_LOGE("Expecting a string value for the `path` parameter: "
232 bt_common_value_type_string(
233 bt_value_get_type(path
)));
237 path_str
= bt_value_string_get(path
);
238 g_string_assign(dmesg_comp
->params
.path
, path_str
);
240 dmesg_comp
->params
.read_from_stdin
= true;
253 int create_stream_and_trace(struct dmesg_component
*dmesg_comp
)
256 const char *trace_name
= NULL
;
257 gchar
*basename
= NULL
;
259 dmesg_comp
->trace
= bt_trace_create(dmesg_comp
->trace_class
);
260 if (!dmesg_comp
->trace
) {
261 BT_COMP_LOGE_STR("Cannot create trace object.");
265 if (dmesg_comp
->params
.read_from_stdin
) {
266 trace_name
= "STDIN";
268 basename
= g_path_get_basename(dmesg_comp
->params
.path
->str
);
271 if (strcmp(basename
, G_DIR_SEPARATOR_S
) != 0 &&
272 strcmp(basename
, ".") != 0) {
273 trace_name
= basename
;
278 ret
= bt_trace_set_name(dmesg_comp
->trace
, trace_name
);
280 BT_COMP_LOGE("Cannot set trace's name: name=\"%s\"",
286 dmesg_comp
->stream
= bt_stream_create(dmesg_comp
->stream_class
,
288 if (!dmesg_comp
->stream
) {
289 BT_COMP_LOGE_STR("Cannot create stream object.");
305 int try_create_meta_stream(struct dmesg_component
*dmesg_comp
, bool has_ts
)
309 if (dmesg_comp
->trace
) {
310 /* Already created */
314 ret
= create_meta(dmesg_comp
, has_ts
);
316 BT_COMP_LOGE("Cannot create metadata objects: dmesg-comp-addr=%p",
321 ret
= create_stream_and_trace(dmesg_comp
);
323 BT_COMP_LOGE("Cannot create stream object: "
324 "dmesg-comp-addr=%p", dmesg_comp
);
338 void destroy_dmesg_component(struct dmesg_component
*dmesg_comp
)
344 if (dmesg_comp
->params
.path
) {
345 g_string_free(dmesg_comp
->params
.path
, TRUE
);
348 bt_trace_put_ref(dmesg_comp
->trace
);
349 bt_stream_class_put_ref(dmesg_comp
->stream_class
);
350 bt_event_class_put_ref(dmesg_comp
->event_class
);
351 bt_stream_put_ref(dmesg_comp
->stream
);
352 bt_clock_class_put_ref(dmesg_comp
->clock_class
);
353 bt_trace_class_put_ref(dmesg_comp
->trace_class
);
358 bt_component_class_init_method_status
create_port(
359 bt_self_component_source
*self_comp
)
361 bt_component_class_init_method_status status
;
362 bt_self_component_add_port_status add_port_status
;
364 add_port_status
= bt_self_component_source_add_output_port(self_comp
,
366 switch (add_port_status
) {
367 case BT_SELF_COMPONENT_ADD_PORT_STATUS_OK
:
368 status
= BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK
;
370 case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR
:
371 status
= BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR
;
373 case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR
:
374 status
= BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR
;
384 bt_component_class_init_method_status
dmesg_init(
385 bt_self_component_source
*self_comp_src
,
386 bt_value
*params
, void *init_method_data
)
389 struct dmesg_component
*dmesg_comp
= g_new0(struct dmesg_component
, 1);
390 bt_component_class_init_method_status status
=
391 BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK
;
392 bt_self_component
*self_comp
=
393 bt_self_component_source_as_self_component(self_comp_src
);
394 const bt_component
*comp
= bt_self_component_as_component(self_comp
);
395 bt_logging_level log_level
= bt_component_get_logging_level(comp
);
398 /* Implicit log level is not available here */
399 BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR
, log_level
, self_comp
,
400 "Failed to allocate one dmesg component structure.");
404 dmesg_comp
->log_level
= log_level
;
405 dmesg_comp
->self_comp
= self_comp
;
406 dmesg_comp
->self_comp_src
= self_comp_src
;
407 dmesg_comp
->params
.path
= g_string_new(NULL
);
408 if (!dmesg_comp
->params
.path
) {
409 BT_COMP_LOGE_STR("Failed to allocate a GString.");
413 ret
= handle_params(dmesg_comp
, params
);
415 BT_COMP_LOGE("Invalid parameters: comp-addr=%p", self_comp
);
419 if (!dmesg_comp
->params
.read_from_stdin
&&
420 !g_file_test(dmesg_comp
->params
.path
->str
,
421 G_FILE_TEST_IS_REGULAR
)) {
422 BT_COMP_LOGE("Input path is not a regular file: "
423 "comp-addr=%p, path=\"%s\"", self_comp
,
424 dmesg_comp
->params
.path
->str
);
428 status
= create_port(self_comp_src
);
429 if (status
!= BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK
) {
433 bt_self_component_set_data(self_comp
, dmesg_comp
);
434 BT_COMP_LOGI_STR("Component initialized.");
438 destroy_dmesg_component(dmesg_comp
);
439 bt_self_component_set_data(self_comp
, NULL
);
442 status
= BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR
;
450 void dmesg_finalize(bt_self_component_source
*self_comp
)
452 destroy_dmesg_component(bt_self_component_get_data(
453 bt_self_component_source_as_self_component(self_comp
)));
457 bt_message
*create_init_event_msg_from_line(
458 struct dmesg_msg_iter
*msg_iter
,
459 const char *line
, const char **new_start
)
462 bt_message
*msg
= NULL
;
463 bool has_timestamp
= false;
464 unsigned long sec
, usec
, msec
;
465 unsigned int year
, mon
, mday
, hour
, min
;
468 struct dmesg_component
*dmesg_comp
= msg_iter
->dmesg_comp
;
472 if (dmesg_comp
->params
.no_timestamp
) {
476 /* Extract time from input line */
477 if (sscanf(line
, "[%lu.%lu] ", &sec
, &usec
) == 2) {
478 ts
= (uint64_t) sec
* USEC_PER_SEC
+ (uint64_t) usec
;
481 * The clock class we use has a 1 GHz frequency: convert
485 has_timestamp
= true;
486 } else if (sscanf(line
, "[%u-%u-%u %u:%u:%lu.%lu] ",
487 &year
, &mon
, &mday
, &hour
, &min
,
492 memset(&ti
, 0, sizeof(ti
));
493 ti
.tm_year
= year
- 1900; /* From 1900 */
494 ti
.tm_mon
= mon
- 1; /* 0 to 11 */
500 ep_sec
= bt_timegm(&ti
);
501 if (ep_sec
!= (time_t) -1) {
502 ts
= (uint64_t) ep_sec
* NSEC_PER_SEC
503 + (uint64_t) msec
* NSEC_PER_MSEC
;
506 has_timestamp
= true;
510 /* Set new start for the message portion of the line */
511 *new_start
= strchr(line
, ']');
512 BT_ASSERT(*new_start
);
515 if ((*new_start
)[0] == ' ') {
522 * At this point, we know if the stream class's event header
523 * field class should have a timestamp or not, so we can lazily
524 * create the metadata and stream objects.
526 ret
= try_create_meta_stream(dmesg_comp
, has_timestamp
);
528 /* try_create_meta_stream() logs errors */
532 if (dmesg_comp
->clock_class
) {
533 msg
= bt_message_event_create_with_default_clock_snapshot(
534 msg_iter
->pc_msg_iter
,
535 dmesg_comp
->event_class
, dmesg_comp
->stream
, ts
);
536 msg_iter
->last_clock_value
= ts
;
538 msg
= bt_message_event_create(msg_iter
->pc_msg_iter
,
539 dmesg_comp
->event_class
, dmesg_comp
->stream
);
543 BT_COMP_LOGE_STR("Cannot create event message.");
547 event
= bt_message_event_borrow_event(msg
);
552 BT_MESSAGE_PUT_REF_AND_RESET(msg
);
559 int fill_event_payload_from_line(struct dmesg_component
*dmesg_comp
,
560 const char *line
, bt_event
*event
)
562 bt_field
*ep_field
= NULL
;
563 bt_field
*str_field
= NULL
;
567 ep_field
= bt_event_borrow_payload_field(event
);
569 str_field
= bt_field_structure_borrow_member_field_by_index(
572 BT_COMP_LOGE_STR("Cannot borrow `timestamp` field from event payload structure field.");
577 if (line
[len
- 1] == '\n') {
578 /* Do not include the newline character in the payload */
582 bt_field_string_clear(str_field
);
583 ret
= bt_field_string_append_with_length(str_field
, line
, len
);
585 BT_COMP_LOGE("Cannot append value to string field object: "
600 bt_message
*create_msg_from_line(
601 struct dmesg_msg_iter
*dmesg_msg_iter
, const char *line
)
603 struct dmesg_component
*dmesg_comp
= dmesg_msg_iter
->dmesg_comp
;
604 bt_event
*event
= NULL
;
605 bt_message
*msg
= NULL
;
606 const char *new_start
;
609 msg
= create_init_event_msg_from_line(dmesg_msg_iter
,
612 BT_COMP_LOGE_STR("Cannot create and initialize event message from line.");
616 event
= bt_message_event_borrow_event(msg
);
618 ret
= fill_event_payload_from_line(dmesg_comp
, new_start
, event
);
620 BT_COMP_LOGE("Cannot fill event payload field from line: "
628 BT_MESSAGE_PUT_REF_AND_RESET(msg
);
635 void destroy_dmesg_msg_iter(struct dmesg_msg_iter
*dmesg_msg_iter
)
637 struct dmesg_component
*dmesg_comp
= dmesg_msg_iter
->dmesg_comp
;
639 if (!dmesg_msg_iter
) {
643 if (dmesg_msg_iter
->fp
&& dmesg_msg_iter
->fp
!= stdin
) {
644 if (fclose(dmesg_msg_iter
->fp
)) {
645 BT_COMP_LOGE_ERRNO("Cannot close input file", ".");
649 bt_message_put_ref(dmesg_msg_iter
->tmp_event_msg
);
650 free(dmesg_msg_iter
->linebuf
);
651 g_free(dmesg_msg_iter
);
657 bt_component_class_message_iterator_init_method_status
dmesg_msg_iter_init(
658 bt_self_message_iterator
*self_msg_iter
,
659 bt_self_component_source
*self_comp
,
660 bt_self_component_port_output
*self_port
)
662 struct dmesg_component
*dmesg_comp
= bt_self_component_get_data(
663 bt_self_component_source_as_self_component(self_comp
));
664 struct dmesg_msg_iter
*dmesg_msg_iter
=
665 g_new0(struct dmesg_msg_iter
, 1);
666 bt_component_class_message_iterator_init_method_status status
=
667 BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_OK
;
669 if (!dmesg_msg_iter
) {
670 BT_COMP_LOGE_STR("Failed to allocate on dmesg message iterator structure.");
674 BT_ASSERT(dmesg_comp
);
675 dmesg_msg_iter
->dmesg_comp
= dmesg_comp
;
676 dmesg_msg_iter
->pc_msg_iter
= self_msg_iter
;
678 if (dmesg_comp
->params
.read_from_stdin
) {
679 dmesg_msg_iter
->fp
= stdin
;
681 dmesg_msg_iter
->fp
= fopen(dmesg_comp
->params
.path
->str
, "r");
682 if (!dmesg_msg_iter
->fp
) {
683 BT_COMP_LOGE_ERRNO("Cannot open input file in read mode", ": path=\"%s\"",
684 dmesg_comp
->params
.path
->str
);
689 bt_self_message_iterator_set_data(self_msg_iter
,
694 destroy_dmesg_msg_iter(dmesg_msg_iter
);
695 bt_self_message_iterator_set_data(self_msg_iter
, NULL
);
697 status
= BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_ERROR
;
705 void dmesg_msg_iter_finalize(
706 bt_self_message_iterator
*priv_msg_iter
)
708 destroy_dmesg_msg_iter(bt_self_message_iterator_get_data(
713 bt_component_class_message_iterator_next_method_status
dmesg_msg_iter_next_one(
714 struct dmesg_msg_iter
*dmesg_msg_iter
,
718 struct dmesg_component
*dmesg_comp
;
719 bt_component_class_message_iterator_next_method_status status
=
720 BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK
;
722 BT_ASSERT(dmesg_msg_iter
);
723 dmesg_comp
= dmesg_msg_iter
->dmesg_comp
;
724 BT_ASSERT(dmesg_comp
);
726 if (dmesg_msg_iter
->state
== STATE_DONE
) {
727 status
= BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END
;
731 if (dmesg_msg_iter
->tmp_event_msg
||
732 dmesg_msg_iter
->state
== STATE_EMIT_STREAM_END
) {
738 bool only_spaces
= true;
740 len
= bt_getline(&dmesg_msg_iter
->linebuf
,
741 &dmesg_msg_iter
->linebuf_len
, dmesg_msg_iter
->fp
);
743 if (errno
== EINVAL
) {
744 status
= BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR
;
745 } else if (errno
== ENOMEM
) {
746 status
= BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR
;
748 if (dmesg_msg_iter
->state
== STATE_EMIT_STREAM_BEGINNING
) {
749 /* Stream did not even begin */
750 status
= BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END
;
754 dmesg_msg_iter
->state
=
755 STATE_EMIT_STREAM_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_COMP_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_EVENT
;
797 case STATE_EMIT_EVENT
:
798 BT_ASSERT(dmesg_msg_iter
->tmp_event_msg
);
799 *msg
= dmesg_msg_iter
->tmp_event_msg
;
800 dmesg_msg_iter
->tmp_event_msg
= NULL
;
802 case STATE_EMIT_STREAM_END
:
803 *msg
= bt_message_stream_end_create(
804 dmesg_msg_iter
->pc_msg_iter
, dmesg_comp
->stream
);
805 dmesg_msg_iter
->state
= STATE_DONE
;
812 BT_COMP_LOGE("Cannot create message: dmesg-comp-addr=%p",
814 status
= BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR
;
822 bt_component_class_message_iterator_next_method_status
dmesg_msg_iter_next(
823 bt_self_message_iterator
*self_msg_iter
,
824 bt_message_array_const msgs
, uint64_t capacity
,
827 struct dmesg_msg_iter
*dmesg_msg_iter
=
828 bt_self_message_iterator_get_data(
830 bt_component_class_message_iterator_next_method_status status
=
831 BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK
;
834 while (i
< capacity
&&
835 status
== BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK
) {
836 bt_message
*priv_msg
= NULL
;
838 status
= dmesg_msg_iter_next_one(dmesg_msg_iter
,
841 if (status
== BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK
) {
848 * Even if dmesg_msg_iter_next_one() returned
849 * something else than
850 * BT_SELF_MESSAGE_ITERATOR_STATUS_OK, we
851 * accumulated message objects in the output
852 * message array, so we need to return
853 * BT_SELF_MESSAGE_ITERATOR_STATUS_OK so that they
854 * are transfered to downstream. This other status
855 * occurs again the next time muxer_msg_iter_do_next()
856 * is called, possibly without any accumulated
857 * message, in which case we'll return it.
860 status
= BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK
;
867 bt_bool
dmesg_msg_iter_can_seek_beginning(
868 bt_self_message_iterator
*self_msg_iter
)
870 struct dmesg_msg_iter
*dmesg_msg_iter
=
871 bt_self_message_iterator_get_data(self_msg_iter
);
873 /* Can't seek the beginning of the standard input stream */
874 return !dmesg_msg_iter
->dmesg_comp
->params
.read_from_stdin
;
878 bt_component_class_message_iterator_seek_beginning_method_status
879 dmesg_msg_iter_seek_beginning(
880 bt_self_message_iterator
*self_msg_iter
)
882 struct dmesg_msg_iter
*dmesg_msg_iter
=
883 bt_self_message_iterator_get_data(self_msg_iter
);
885 BT_ASSERT(!dmesg_msg_iter
->dmesg_comp
->params
.read_from_stdin
);
887 BT_MESSAGE_PUT_REF_AND_RESET(dmesg_msg_iter
->tmp_event_msg
);
888 dmesg_msg_iter
->last_clock_value
= 0;
889 dmesg_msg_iter
->state
= STATE_EMIT_STREAM_BEGINNING
;
890 return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK
;