Commit | Line | Data |
---|---|---|
d8866baa PP |
1 | /* |
2 | * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation | |
834e9996 | 3 | * Copyright 2017 Philippe Proulx <pproulx@efficios.com> |
d8866baa PP |
4 | * |
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: | |
11 | * | |
12 | * The above copyright notice and this permission notice shall be included in | |
13 | * all copies or substantial portions of the Software. | |
14 | * | |
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 | |
21 | * SOFTWARE. | |
22 | */ | |
23 | ||
4b1e4687 | 24 | #define BT_COMP_LOG_SELF_COMP (dmesg_comp->self_comp) |
f9291fb7 | 25 | #define BT_LOG_OUTPUT_LEVEL (dmesg_comp->log_level) |
b03487ab | 26 | #define BT_LOG_TAG "PLUGIN/SRC.TEXT.DMESG" |
4b1e4687 | 27 | #include "plugins/comp-logging.h" |
e2531d3b | 28 | |
d8866baa | 29 | #include <stdbool.h> |
e2531d3b PP |
30 | #include <string.h> |
31 | #include <ctype.h> | |
d8866baa | 32 | #include <stdio.h> |
57952005 | 33 | #include "common/common.h" |
f9291fb7 | 34 | #include "common/assert.h" |
71c5da58 | 35 | #include <babeltrace2/babeltrace.h> |
57952005 MJ |
36 | #include "compat/utc.h" |
37 | #include "compat/stdio.h" | |
d8866baa PP |
38 | #include <glib.h> |
39 | ||
e2531d3b PP |
40 | #define NSEC_PER_USEC 1000UL |
41 | #define NSEC_PER_MSEC 1000000UL | |
42 | #define NSEC_PER_SEC 1000000000ULL | |
43 | #define USEC_PER_SEC 1000000UL | |
44 | ||
d8866baa PP |
45 | struct dmesg_component; |
46 | ||
b09a5592 | 47 | struct dmesg_msg_iter { |
d8866baa | 48 | struct dmesg_component *dmesg_comp; |
b09a5592 | 49 | bt_self_message_iterator *pc_msg_iter; /* Weak */ |
e2531d3b PP |
50 | char *linebuf; |
51 | size_t linebuf_len; | |
d8866baa | 52 | FILE *fp; |
b09a5592 | 53 | bt_message *tmp_event_msg; |
96a0a69d | 54 | uint64_t last_clock_value; |
a6918753 PP |
55 | |
56 | enum { | |
57 | STATE_EMIT_STREAM_BEGINNING, | |
66ff4085 | 58 | STATE_EMIT_STREAM_ACTIVITY_BEGINNING, |
a6918753 PP |
59 | STATE_EMIT_PACKET_BEGINNING, |
60 | STATE_EMIT_EVENT, | |
61 | STATE_EMIT_PACKET_END, | |
66ff4085 | 62 | STATE_EMIT_STREAM_ACTIVITY_END, |
a6918753 PP |
63 | STATE_EMIT_STREAM_END, |
64 | STATE_DONE, | |
65 | } state; | |
d8866baa PP |
66 | }; |
67 | ||
68 | struct dmesg_component { | |
f9291fb7 PP |
69 | bt_logging_level log_level; |
70 | ||
d8866baa PP |
71 | struct { |
72 | GString *path; | |
e2531d3b | 73 | bt_bool read_from_stdin; |
8743317e | 74 | bt_bool no_timestamp; |
d8866baa PP |
75 | } params; |
76 | ||
4b1e4687 PP |
77 | bt_self_component_source *self_comp_src; |
78 | bt_self_component *self_comp; | |
8eee8ea2 PP |
79 | bt_trace_class *trace_class; |
80 | bt_stream_class *stream_class; | |
81 | bt_event_class *event_class; | |
82 | bt_trace *trace; | |
83 | bt_stream *stream; | |
84 | bt_packet *packet; | |
85 | bt_clock_class *clock_class; | |
d8866baa PP |
86 | }; |
87 | ||
e2531d3b | 88 | static |
f9291fb7 PP |
89 | bt_field_class *create_event_payload_fc(struct dmesg_component *dmesg_comp, |
90 | bt_trace_class *trace_class) | |
e2531d3b | 91 | { |
8eee8ea2 PP |
92 | bt_field_class *root_fc = NULL; |
93 | bt_field_class *fc = NULL; | |
e2531d3b PP |
94 | int ret; |
95 | ||
b7396828 | 96 | root_fc = bt_field_class_structure_create(trace_class); |
939190b3 | 97 | if (!root_fc) { |
4b1e4687 | 98 | BT_COMP_LOGE_STR("Cannot create an empty structure field class object."); |
e2531d3b PP |
99 | goto error; |
100 | } | |
101 | ||
b7396828 | 102 | fc = bt_field_class_string_create(trace_class); |
939190b3 | 103 | if (!fc) { |
4b1e4687 | 104 | BT_COMP_LOGE_STR("Cannot create a string field class object."); |
e2531d3b PP |
105 | goto error; |
106 | } | |
107 | ||
78cf9df6 | 108 | ret = bt_field_class_structure_append_member(root_fc, |
9e550e5f | 109 | "str", fc); |
e2531d3b | 110 | if (ret) { |
4b1e4687 | 111 | BT_COMP_LOGE("Cannot add `str` member to structure field class: " |
e2531d3b PP |
112 | "ret=%d", ret); |
113 | goto error; | |
114 | } | |
115 | ||
116 | goto end; | |
117 | ||
118 | error: | |
8c6884d9 | 119 | BT_FIELD_CLASS_PUT_REF_AND_RESET(root_fc); |
e2531d3b PP |
120 | |
121 | end: | |
8c6884d9 | 122 | bt_field_class_put_ref(fc); |
939190b3 | 123 | return root_fc; |
e2531d3b PP |
124 | } |
125 | ||
e2531d3b PP |
126 | static |
127 | int create_meta(struct dmesg_component *dmesg_comp, bool has_ts) | |
128 | { | |
8eee8ea2 | 129 | bt_field_class *fc = NULL; |
d8866baa PP |
130 | int ret = 0; |
131 | ||
4b1e4687 | 132 | dmesg_comp->trace_class = bt_trace_class_create(dmesg_comp->self_comp); |
10b7a2e4 | 133 | if (!dmesg_comp->trace_class) { |
4b1e4687 | 134 | BT_COMP_LOGE_STR("Cannot create an empty trace class object."); |
e2531d3b PP |
135 | goto error; |
136 | } | |
137 | ||
78cf9df6 | 138 | dmesg_comp->stream_class = bt_stream_class_create( |
10b7a2e4 | 139 | dmesg_comp->trace_class); |
e2531d3b | 140 | if (!dmesg_comp->stream_class) { |
4b1e4687 | 141 | BT_COMP_LOGE_STR("Cannot create a stream class object."); |
e2531d3b PP |
142 | goto error; |
143 | } | |
144 | ||
e2531d3b | 145 | if (has_ts) { |
35fa110e | 146 | dmesg_comp->clock_class = bt_clock_class_create( |
4b1e4687 | 147 | dmesg_comp->self_comp); |
e2531d3b | 148 | if (!dmesg_comp->clock_class) { |
4b1e4687 | 149 | BT_COMP_LOGE_STR("Cannot create clock class."); |
e2531d3b PP |
150 | goto error; |
151 | } | |
152 | ||
44de4099 | 153 | /* |
d608d675 PP |
154 | * The `dmesg` timestamp's origin is not the Unix epoch, |
155 | * it's the boot time. | |
44de4099 | 156 | */ |
d608d675 | 157 | bt_clock_class_set_origin_is_unix_epoch(dmesg_comp->clock_class, |
44de4099 PP |
158 | BT_FALSE); |
159 | ||
78cf9df6 PP |
160 | ret = bt_stream_class_set_default_clock_class( |
161 | dmesg_comp->stream_class, dmesg_comp->clock_class); | |
e2531d3b | 162 | if (ret) { |
4b1e4687 | 163 | BT_COMP_LOGE_STR("Cannot set stream class's default clock class."); |
e2531d3b PP |
164 | goto error; |
165 | } | |
34e13c22 | 166 | |
5ef34326 | 167 | bt_stream_class_set_packets_have_beginning_default_clock_snapshot( |
34e13c22 | 168 | dmesg_comp->stream_class, BT_TRUE); |
5ef34326 | 169 | bt_stream_class_set_packets_have_end_default_clock_snapshot( |
34e13c22 | 170 | dmesg_comp->stream_class, BT_TRUE); |
e2531d3b PP |
171 | } |
172 | ||
78cf9df6 | 173 | dmesg_comp->event_class = bt_event_class_create( |
7b33a0e0 | 174 | dmesg_comp->stream_class); |
e2531d3b | 175 | if (!dmesg_comp->event_class) { |
4b1e4687 | 176 | BT_COMP_LOGE_STR("Cannot create an event class object."); |
7b33a0e0 PP |
177 | goto error; |
178 | } | |
179 | ||
78cf9df6 | 180 | ret = bt_event_class_set_name(dmesg_comp->event_class, "string"); |
7b33a0e0 | 181 | if (ret) { |
4b1e4687 | 182 | BT_COMP_LOGE_STR("Cannot set event class's name."); |
e2531d3b PP |
183 | goto error; |
184 | } | |
185 | ||
f9291fb7 | 186 | fc = create_event_payload_fc(dmesg_comp, dmesg_comp->trace_class); |
939190b3 | 187 | if (!fc) { |
4b1e4687 | 188 | BT_COMP_LOGE_STR("Cannot create event payload field class."); |
d8866baa PP |
189 | goto error; |
190 | } | |
191 | ||
78cf9df6 | 192 | ret = bt_event_class_set_payload_field_class(dmesg_comp->event_class, fc); |
e2531d3b | 193 | if (ret) { |
4b1e4687 | 194 | BT_COMP_LOGE_STR("Cannot set event class's event payload field class."); |
e2531d3b PP |
195 | goto error; |
196 | } | |
197 | ||
e2531d3b PP |
198 | goto end; |
199 | ||
200 | error: | |
201 | ret = -1; | |
202 | ||
203 | end: | |
8c6884d9 | 204 | bt_field_class_put_ref(fc); |
e2531d3b PP |
205 | return ret; |
206 | } | |
207 | ||
208 | static | |
ce141536 | 209 | int handle_params(struct dmesg_component *dmesg_comp, |
8eee8ea2 | 210 | const bt_value *params) |
e2531d3b | 211 | { |
8eee8ea2 PP |
212 | const bt_value *no_timestamp = NULL; |
213 | const bt_value *path = NULL; | |
e2531d3b PP |
214 | const char *path_str; |
215 | int ret = 0; | |
216 | ||
ce141536 | 217 | no_timestamp = bt_value_map_borrow_entry_value_const(params, |
44514773 | 218 | "no-extract-timestamp"); |
8743317e PP |
219 | if (no_timestamp) { |
220 | if (!bt_value_is_bool(no_timestamp)) { | |
4b1e4687 | 221 | BT_COMP_LOGE("Expecting a boolean value for the `no-extract-timestamp` parameter: " |
8743317e | 222 | "type=%s", |
17582c6d | 223 | bt_common_value_type_string( |
8743317e PP |
224 | bt_value_get_type(no_timestamp))); |
225 | goto error; | |
226 | } | |
227 | ||
b5cdc106 PP |
228 | dmesg_comp->params.no_timestamp = |
229 | bt_value_bool_get(no_timestamp); | |
8743317e PP |
230 | } |
231 | ||
ce141536 | 232 | path = bt_value_map_borrow_entry_value_const(params, "path"); |
d8866baa PP |
233 | if (path) { |
234 | if (dmesg_comp->params.read_from_stdin) { | |
4b1e4687 | 235 | BT_COMP_LOGE_STR("Cannot specify both `read-from-stdin` and `path` parameters."); |
d8866baa PP |
236 | goto error; |
237 | } | |
238 | ||
239 | if (!bt_value_is_string(path)) { | |
4b1e4687 | 240 | BT_COMP_LOGE("Expecting a string value for the `path` parameter: " |
e2531d3b | 241 | "type=%s", |
17582c6d | 242 | bt_common_value_type_string( |
e2531d3b | 243 | bt_value_get_type(path))); |
d8866baa PP |
244 | goto error; |
245 | } | |
246 | ||
b5cdc106 | 247 | path_str = bt_value_string_get(path); |
d8866baa PP |
248 | g_string_assign(dmesg_comp->params.path, path_str); |
249 | } else { | |
2a2f36a2 | 250 | dmesg_comp->params.read_from_stdin = true; |
d8866baa PP |
251 | } |
252 | ||
253 | goto end; | |
254 | ||
255 | error: | |
256 | ret = -1; | |
257 | ||
258 | end: | |
d8866baa PP |
259 | return ret; |
260 | } | |
261 | ||
e2531d3b | 262 | static |
10b7a2e4 | 263 | int create_packet_and_stream_and_trace(struct dmesg_component *dmesg_comp) |
e2531d3b PP |
264 | { |
265 | int ret = 0; | |
a260020d | 266 | const char *trace_name = NULL; |
10b7a2e4 PP |
267 | gchar *basename = NULL; |
268 | ||
269 | dmesg_comp->trace = bt_trace_create(dmesg_comp->trace_class); | |
270 | if (!dmesg_comp->trace) { | |
4b1e4687 | 271 | BT_COMP_LOGE_STR("Cannot create trace object."); |
10b7a2e4 PP |
272 | goto error; |
273 | } | |
e2531d3b | 274 | |
10b7a2e4 PP |
275 | if (dmesg_comp->params.read_from_stdin) { |
276 | trace_name = "STDIN"; | |
277 | } else { | |
278 | basename = g_path_get_basename(dmesg_comp->params.path->str); | |
279 | BT_ASSERT(basename); | |
280 | ||
281 | if (strcmp(basename, G_DIR_SEPARATOR_S) != 0 && | |
282 | strcmp(basename, ".") != 0) { | |
283 | trace_name = basename; | |
284 | } | |
285 | } | |
286 | ||
287 | if (trace_name) { | |
288 | ret = bt_trace_set_name(dmesg_comp->trace, trace_name); | |
289 | if (ret) { | |
4b1e4687 | 290 | BT_COMP_LOGE("Cannot set trace's name: name=\"%s\"", |
10b7a2e4 PP |
291 | trace_name); |
292 | goto error; | |
293 | } | |
294 | } | |
295 | ||
296 | dmesg_comp->stream = bt_stream_create(dmesg_comp->stream_class, | |
297 | dmesg_comp->trace); | |
e2531d3b | 298 | if (!dmesg_comp->stream) { |
4b1e4687 | 299 | BT_COMP_LOGE_STR("Cannot create stream object."); |
e2531d3b PP |
300 | goto error; |
301 | } | |
302 | ||
78cf9df6 | 303 | dmesg_comp->packet = bt_packet_create(dmesg_comp->stream); |
e2531d3b | 304 | if (!dmesg_comp->packet) { |
4b1e4687 | 305 | BT_COMP_LOGE_STR("Cannot create packet object."); |
e2531d3b PP |
306 | goto error; |
307 | } | |
308 | ||
e2531d3b PP |
309 | goto end; |
310 | ||
311 | error: | |
312 | ret = -1; | |
313 | ||
314 | end: | |
10b7a2e4 PP |
315 | if (basename) { |
316 | g_free(basename); | |
317 | } | |
318 | ||
e2531d3b PP |
319 | return ret; |
320 | } | |
321 | ||
322 | static | |
323 | int try_create_meta_stream_packet(struct dmesg_component *dmesg_comp, | |
324 | bool has_ts) | |
325 | { | |
326 | int ret = 0; | |
327 | ||
328 | if (dmesg_comp->trace) { | |
329 | /* Already created */ | |
330 | goto end; | |
331 | } | |
332 | ||
333 | ret = create_meta(dmesg_comp, has_ts); | |
334 | if (ret) { | |
4b1e4687 | 335 | BT_COMP_LOGE("Cannot create metadata objects: dmesg-comp-addr=%p", |
e2531d3b PP |
336 | dmesg_comp); |
337 | goto error; | |
338 | } | |
339 | ||
10b7a2e4 | 340 | ret = create_packet_and_stream_and_trace(dmesg_comp); |
e2531d3b | 341 | if (ret) { |
4b1e4687 | 342 | BT_COMP_LOGE("Cannot create packet and stream objects: " |
e2531d3b PP |
343 | "dmesg-comp-addr=%p", dmesg_comp); |
344 | goto error; | |
345 | } | |
346 | ||
347 | goto end; | |
348 | ||
349 | error: | |
350 | ret = -1; | |
351 | ||
352 | end: | |
353 | return ret; | |
354 | } | |
d8866baa PP |
355 | |
356 | static | |
357 | void destroy_dmesg_component(struct dmesg_component *dmesg_comp) | |
358 | { | |
359 | if (!dmesg_comp) { | |
360 | return; | |
361 | } | |
362 | ||
363 | if (dmesg_comp->params.path) { | |
364 | g_string_free(dmesg_comp->params.path, TRUE); | |
365 | } | |
366 | ||
8c6884d9 PP |
367 | bt_packet_put_ref(dmesg_comp->packet); |
368 | bt_trace_put_ref(dmesg_comp->trace); | |
369 | bt_stream_class_put_ref(dmesg_comp->stream_class); | |
370 | bt_event_class_put_ref(dmesg_comp->event_class); | |
371 | bt_stream_put_ref(dmesg_comp->stream); | |
372 | bt_clock_class_put_ref(dmesg_comp->clock_class); | |
224b2711 | 373 | bt_trace_class_put_ref(dmesg_comp->trace_class); |
d8866baa PP |
374 | g_free(dmesg_comp); |
375 | } | |
376 | ||
e2531d3b | 377 | static |
fb25b9e3 | 378 | bt_component_class_init_method_status create_port( |
8eee8ea2 | 379 | bt_self_component_source *self_comp) |
e2531d3b | 380 | { |
fb25b9e3 PP |
381 | bt_component_class_init_method_status status; |
382 | bt_self_component_add_port_status add_port_status; | |
383 | ||
384 | add_port_status = bt_self_component_source_add_output_port(self_comp, | |
e2531d3b | 385 | "out", NULL, NULL); |
fb25b9e3 PP |
386 | switch (add_port_status) { |
387 | case BT_SELF_COMPONENT_ADD_PORT_STATUS_OK: | |
388 | status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK; | |
389 | break; | |
390 | case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR: | |
391 | status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; | |
392 | break; | |
393 | case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR: | |
394 | status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; | |
395 | break; | |
396 | default: | |
397 | abort(); | |
398 | } | |
399 | ||
400 | return status; | |
e2531d3b PP |
401 | } |
402 | ||
d8866baa | 403 | BT_HIDDEN |
fb25b9e3 | 404 | bt_component_class_init_method_status dmesg_init( |
4b1e4687 | 405 | bt_self_component_source *self_comp_src, |
8eee8ea2 | 406 | bt_value *params, void *init_method_data) |
d8866baa PP |
407 | { |
408 | int ret = 0; | |
409 | struct dmesg_component *dmesg_comp = g_new0(struct dmesg_component, 1); | |
fb25b9e3 PP |
410 | bt_component_class_init_method_status status = |
411 | BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK; | |
4b1e4687 PP |
412 | bt_self_component *self_comp = |
413 | bt_self_component_source_as_self_component(self_comp_src); | |
414 | const bt_component *comp = bt_self_component_as_component(self_comp); | |
f9291fb7 | 415 | bt_logging_level log_level = bt_component_get_logging_level(comp); |
d8866baa PP |
416 | |
417 | if (!dmesg_comp) { | |
f9291fb7 | 418 | /* Implicit log level is not available here */ |
4b1e4687 | 419 | BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, log_level, self_comp, |
f9291fb7 | 420 | "Failed to allocate one dmesg component structure."); |
d8866baa PP |
421 | goto error; |
422 | } | |
423 | ||
f9291fb7 | 424 | dmesg_comp->log_level = log_level; |
e5e71bf8 | 425 | dmesg_comp->self_comp = self_comp; |
4b1e4687 | 426 | dmesg_comp->self_comp_src = self_comp_src; |
d8866baa PP |
427 | dmesg_comp->params.path = g_string_new(NULL); |
428 | if (!dmesg_comp->params.path) { | |
4b1e4687 | 429 | BT_COMP_LOGE_STR("Failed to allocate a GString."); |
d8866baa PP |
430 | goto error; |
431 | } | |
432 | ||
e2531d3b | 433 | ret = handle_params(dmesg_comp, params); |
d8866baa | 434 | if (ret) { |
4b1e4687 | 435 | BT_COMP_LOGE("Invalid parameters: comp-addr=%p", self_comp); |
d8866baa PP |
436 | goto error; |
437 | } | |
438 | ||
e2531d3b PP |
439 | if (!dmesg_comp->params.read_from_stdin && |
440 | !g_file_test(dmesg_comp->params.path->str, | |
441 | G_FILE_TEST_IS_REGULAR)) { | |
4b1e4687 | 442 | BT_COMP_LOGE("Input path is not a regular file: " |
834e9996 | 443 | "comp-addr=%p, path=\"%s\"", self_comp, |
e2531d3b PP |
444 | dmesg_comp->params.path->str); |
445 | goto error; | |
446 | } | |
d8866baa | 447 | |
4b1e4687 | 448 | status = create_port(self_comp_src); |
fb25b9e3 | 449 | if (status != BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK) { |
e2531d3b PP |
450 | goto error; |
451 | } | |
d8866baa | 452 | |
4b1e4687 PP |
453 | bt_self_component_set_data(self_comp, dmesg_comp); |
454 | BT_COMP_LOGI_STR("Component initialized."); | |
d8866baa PP |
455 | goto end; |
456 | ||
457 | error: | |
458 | destroy_dmesg_component(dmesg_comp); | |
4b1e4687 | 459 | bt_self_component_set_data(self_comp, NULL); |
e2531d3b PP |
460 | |
461 | if (status >= 0) { | |
fb25b9e3 | 462 | status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; |
e2531d3b | 463 | } |
d8866baa PP |
464 | |
465 | end: | |
466 | return status; | |
467 | } | |
468 | ||
469 | BT_HIDDEN | |
8eee8ea2 | 470 | void dmesg_finalize(bt_self_component_source *self_comp) |
d8866baa | 471 | { |
834e9996 | 472 | destroy_dmesg_component(bt_self_component_get_data( |
bb61965b | 473 | bt_self_component_source_as_self_component(self_comp))); |
e2531d3b PP |
474 | } |
475 | ||
476 | static | |
b09a5592 PP |
477 | bt_message *create_init_event_msg_from_line( |
478 | struct dmesg_msg_iter *msg_iter, | |
a6918753 | 479 | const char *line, const char **new_start) |
e2531d3b | 480 | { |
8eee8ea2 | 481 | bt_event *event; |
b09a5592 | 482 | bt_message *msg = NULL; |
e2531d3b PP |
483 | bool has_timestamp = false; |
484 | unsigned long sec, usec, msec; | |
485 | unsigned int year, mon, mday, hour, min; | |
486 | uint64_t ts = 0; | |
e2531d3b | 487 | int ret = 0; |
b09a5592 | 488 | struct dmesg_component *dmesg_comp = msg_iter->dmesg_comp; |
e2531d3b | 489 | |
e2531d3b PP |
490 | *new_start = line; |
491 | ||
8743317e PP |
492 | if (dmesg_comp->params.no_timestamp) { |
493 | goto skip_ts; | |
494 | } | |
495 | ||
e2531d3b PP |
496 | /* Extract time from input line */ |
497 | if (sscanf(line, "[%lu.%lu] ", &sec, &usec) == 2) { | |
498 | ts = (uint64_t) sec * USEC_PER_SEC + (uint64_t) usec; | |
499 | ||
500 | /* | |
501 | * The clock class we use has a 1 GHz frequency: convert | |
502 | * from µs to ns. | |
503 | */ | |
504 | ts *= NSEC_PER_USEC; | |
505 | has_timestamp = true; | |
506 | } else if (sscanf(line, "[%u-%u-%u %u:%u:%lu.%lu] ", | |
507 | &year, &mon, &mday, &hour, &min, | |
508 | &sec, &msec) == 7) { | |
509 | time_t ep_sec; | |
510 | struct tm ti; | |
511 | ||
512 | memset(&ti, 0, sizeof(ti)); | |
513 | ti.tm_year = year - 1900; /* From 1900 */ | |
514 | ti.tm_mon = mon - 1; /* 0 to 11 */ | |
515 | ti.tm_mday = mday; | |
516 | ti.tm_hour = hour; | |
517 | ti.tm_min = min; | |
518 | ti.tm_sec = sec; | |
519 | ||
520 | ep_sec = bt_timegm(&ti); | |
521 | if (ep_sec != (time_t) -1) { | |
522 | ts = (uint64_t) ep_sec * NSEC_PER_SEC | |
523 | + (uint64_t) msec * NSEC_PER_MSEC; | |
524 | } | |
525 | ||
526 | has_timestamp = true; | |
527 | } | |
528 | ||
529 | if (has_timestamp) { | |
530 | /* Set new start for the message portion of the line */ | |
531 | *new_start = strchr(line, ']'); | |
8b45963b | 532 | BT_ASSERT(*new_start); |
e2531d3b PP |
533 | (*new_start)++; |
534 | ||
535 | if ((*new_start)[0] == ' ') { | |
536 | (*new_start)++; | |
537 | } | |
538 | } | |
539 | ||
8743317e | 540 | skip_ts: |
e2531d3b PP |
541 | /* |
542 | * At this point, we know if the stream class's event header | |
939190b3 | 543 | * field class should have a timestamp or not, so we can lazily |
e2531d3b PP |
544 | * create the metadata, stream, and packet objects. |
545 | */ | |
546 | ret = try_create_meta_stream_packet(dmesg_comp, has_timestamp); | |
547 | if (ret) { | |
548 | /* try_create_meta_stream_packet() logs errors */ | |
549 | goto error; | |
550 | } | |
551 | ||
9c04b633 PP |
552 | if (dmesg_comp->clock_class) { |
553 | msg = bt_message_event_create_with_default_clock_snapshot( | |
554 | msg_iter->pc_msg_iter, | |
555 | dmesg_comp->event_class, dmesg_comp->packet, ts); | |
556 | msg_iter->last_clock_value = ts; | |
557 | } else { | |
558 | msg = bt_message_event_create(msg_iter->pc_msg_iter, | |
559 | dmesg_comp->event_class, dmesg_comp->packet); | |
560 | } | |
561 | ||
b09a5592 | 562 | if (!msg) { |
4b1e4687 | 563 | BT_COMP_LOGE_STR("Cannot create event message."); |
a6918753 PP |
564 | goto error; |
565 | } | |
e2531d3b | 566 | |
b09a5592 | 567 | event = bt_message_event_borrow_event(msg); |
a6918753 | 568 | BT_ASSERT(event); |
e2531d3b PP |
569 | goto end; |
570 | ||
571 | error: | |
b09a5592 | 572 | BT_MESSAGE_PUT_REF_AND_RESET(msg); |
e2531d3b PP |
573 | |
574 | end: | |
b09a5592 | 575 | return msg; |
e2531d3b PP |
576 | } |
577 | ||
578 | static | |
f9291fb7 PP |
579 | int fill_event_payload_from_line(struct dmesg_component *dmesg_comp, |
580 | const char *line, bt_event *event) | |
e2531d3b | 581 | { |
8eee8ea2 PP |
582 | bt_field *ep_field = NULL; |
583 | bt_field *str_field = NULL; | |
e2531d3b PP |
584 | size_t len; |
585 | int ret; | |
586 | ||
78cf9df6 | 587 | ep_field = bt_event_borrow_payload_field(event); |
a6918753 | 588 | BT_ASSERT(ep_field); |
78cf9df6 | 589 | str_field = bt_field_structure_borrow_member_field_by_index( |
9e550e5f | 590 | ep_field, 0); |
e2531d3b | 591 | if (!str_field) { |
4b1e4687 | 592 | BT_COMP_LOGE_STR("Cannot borrow `timestamp` field from event payload structure field."); |
e2531d3b PP |
593 | goto error; |
594 | } | |
595 | ||
596 | len = strlen(line); | |
597 | if (line[len - 1] == '\n') { | |
598 | /* Do not include the newline character in the payload */ | |
599 | len--; | |
600 | } | |
601 | ||
fb25b9e3 | 602 | bt_field_string_clear(str_field); |
78cf9df6 | 603 | ret = bt_field_string_append_with_length(str_field, line, len); |
e2531d3b | 604 | if (ret) { |
4b1e4687 | 605 | BT_COMP_LOGE("Cannot append value to string field object: " |
e2531d3b PP |
606 | "len=%zu", len); |
607 | goto error; | |
608 | } | |
609 | ||
e2531d3b PP |
610 | goto end; |
611 | ||
612 | error: | |
613 | ret = -1; | |
614 | ||
615 | end: | |
e2531d3b PP |
616 | return ret; |
617 | } | |
618 | ||
619 | static | |
b09a5592 PP |
620 | bt_message *create_msg_from_line( |
621 | struct dmesg_msg_iter *dmesg_msg_iter, const char *line) | |
e2531d3b | 622 | { |
f9291fb7 | 623 | struct dmesg_component *dmesg_comp = dmesg_msg_iter->dmesg_comp; |
8eee8ea2 | 624 | bt_event *event = NULL; |
b09a5592 | 625 | bt_message *msg = NULL; |
e2531d3b PP |
626 | const char *new_start; |
627 | int ret; | |
628 | ||
b09a5592 | 629 | msg = create_init_event_msg_from_line(dmesg_msg_iter, |
03e18d5d | 630 | line, &new_start); |
b09a5592 | 631 | if (!msg) { |
4b1e4687 | 632 | BT_COMP_LOGE_STR("Cannot create and initialize event message from line."); |
e2531d3b PP |
633 | goto error; |
634 | } | |
635 | ||
b09a5592 | 636 | event = bt_message_event_borrow_event(msg); |
a6918753 | 637 | BT_ASSERT(event); |
f9291fb7 | 638 | ret = fill_event_payload_from_line(dmesg_comp, new_start, event); |
e2531d3b | 639 | if (ret) { |
4b1e4687 | 640 | BT_COMP_LOGE("Cannot fill event payload field from line: " |
e2531d3b PP |
641 | "ret=%d", ret); |
642 | goto error; | |
643 | } | |
644 | ||
e2531d3b PP |
645 | goto end; |
646 | ||
647 | error: | |
b09a5592 | 648 | BT_MESSAGE_PUT_REF_AND_RESET(msg); |
e2531d3b PP |
649 | |
650 | end: | |
b09a5592 | 651 | return msg; |
e2531d3b PP |
652 | } |
653 | ||
654 | static | |
b09a5592 | 655 | void destroy_dmesg_msg_iter(struct dmesg_msg_iter *dmesg_msg_iter) |
e2531d3b | 656 | { |
f9291fb7 PP |
657 | struct dmesg_component *dmesg_comp = dmesg_msg_iter->dmesg_comp; |
658 | ||
b09a5592 | 659 | if (!dmesg_msg_iter) { |
e2531d3b PP |
660 | return; |
661 | } | |
662 | ||
b09a5592 PP |
663 | if (dmesg_msg_iter->fp && dmesg_msg_iter->fp != stdin) { |
664 | if (fclose(dmesg_msg_iter->fp)) { | |
4b1e4687 | 665 | BT_COMP_LOGE_ERRNO("Cannot close input file", "."); |
e2531d3b PP |
666 | } |
667 | } | |
d8866baa | 668 | |
b09a5592 PP |
669 | bt_message_put_ref(dmesg_msg_iter->tmp_event_msg); |
670 | free(dmesg_msg_iter->linebuf); | |
671 | g_free(dmesg_msg_iter); | |
d8866baa PP |
672 | } |
673 | ||
12b0fa51 PP |
674 | |
675 | ||
d8866baa | 676 | BT_HIDDEN |
fb25b9e3 | 677 | bt_component_class_message_iterator_init_method_status dmesg_msg_iter_init( |
b09a5592 | 678 | bt_self_message_iterator *self_msg_iter, |
8eee8ea2 PP |
679 | bt_self_component_source *self_comp, |
680 | bt_self_component_port_output *self_port) | |
d8866baa | 681 | { |
f9291fb7 PP |
682 | struct dmesg_component *dmesg_comp = bt_self_component_get_data( |
683 | bt_self_component_source_as_self_component(self_comp)); | |
b09a5592 PP |
684 | struct dmesg_msg_iter *dmesg_msg_iter = |
685 | g_new0(struct dmesg_msg_iter, 1); | |
fb25b9e3 PP |
686 | bt_component_class_message_iterator_init_method_status status = |
687 | BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_OK; | |
e2531d3b | 688 | |
b09a5592 | 689 | if (!dmesg_msg_iter) { |
4b1e4687 | 690 | BT_COMP_LOGE_STR("Failed to allocate on dmesg message iterator structure."); |
e2531d3b PP |
691 | goto error; |
692 | } | |
693 | ||
8b45963b | 694 | BT_ASSERT(dmesg_comp); |
b09a5592 PP |
695 | dmesg_msg_iter->dmesg_comp = dmesg_comp; |
696 | dmesg_msg_iter->pc_msg_iter = self_msg_iter; | |
d8866baa | 697 | |
e2531d3b | 698 | if (dmesg_comp->params.read_from_stdin) { |
b09a5592 | 699 | dmesg_msg_iter->fp = stdin; |
e2531d3b | 700 | } else { |
b09a5592 PP |
701 | dmesg_msg_iter->fp = fopen(dmesg_comp->params.path->str, "r"); |
702 | if (!dmesg_msg_iter->fp) { | |
4b1e4687 | 703 | BT_COMP_LOGE_ERRNO("Cannot open input file in read mode", ": path=\"%s\"", |
e2531d3b PP |
704 | dmesg_comp->params.path->str); |
705 | goto error; | |
706 | } | |
707 | } | |
708 | ||
b09a5592 PP |
709 | bt_self_message_iterator_set_data(self_msg_iter, |
710 | dmesg_msg_iter); | |
e2531d3b PP |
711 | goto end; |
712 | ||
713 | error: | |
b09a5592 PP |
714 | destroy_dmesg_msg_iter(dmesg_msg_iter); |
715 | bt_self_message_iterator_set_data(self_msg_iter, NULL); | |
e2531d3b | 716 | if (status >= 0) { |
fb25b9e3 | 717 | status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_ERROR; |
e2531d3b PP |
718 | } |
719 | ||
720 | end: | |
e2531d3b | 721 | return status; |
d8866baa PP |
722 | } |
723 | ||
724 | BT_HIDDEN | |
b09a5592 PP |
725 | void dmesg_msg_iter_finalize( |
726 | bt_self_message_iterator *priv_msg_iter) | |
d8866baa | 727 | { |
b09a5592 PP |
728 | destroy_dmesg_msg_iter(bt_self_message_iterator_get_data( |
729 | priv_msg_iter)); | |
d8866baa PP |
730 | } |
731 | ||
3fd7b79d | 732 | static |
fb25b9e3 | 733 | bt_component_class_message_iterator_next_method_status dmesg_msg_iter_next_one( |
b09a5592 PP |
734 | struct dmesg_msg_iter *dmesg_msg_iter, |
735 | bt_message **msg) | |
d8866baa | 736 | { |
e2531d3b | 737 | ssize_t len; |
e2531d3b | 738 | struct dmesg_component *dmesg_comp; |
fb25b9e3 PP |
739 | bt_component_class_message_iterator_next_method_status status = |
740 | BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; | |
d8866baa | 741 | |
b09a5592 PP |
742 | BT_ASSERT(dmesg_msg_iter); |
743 | dmesg_comp = dmesg_msg_iter->dmesg_comp; | |
8b45963b | 744 | BT_ASSERT(dmesg_comp); |
e2531d3b | 745 | |
b09a5592 | 746 | if (dmesg_msg_iter->state == STATE_DONE) { |
fb25b9e3 | 747 | status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; |
a6918753 PP |
748 | goto end; |
749 | } | |
750 | ||
b09a5592 PP |
751 | if (dmesg_msg_iter->tmp_event_msg || |
752 | dmesg_msg_iter->state == STATE_EMIT_PACKET_END || | |
66ff4085 | 753 | dmesg_msg_iter->state == STATE_EMIT_STREAM_ACTIVITY_END || |
b09a5592 | 754 | dmesg_msg_iter->state == STATE_EMIT_STREAM_END) { |
a6918753 PP |
755 | goto handle_state; |
756 | } | |
757 | ||
e2531d3b PP |
758 | while (true) { |
759 | const char *ch; | |
760 | bool only_spaces = true; | |
761 | ||
b09a5592 PP |
762 | len = bt_getline(&dmesg_msg_iter->linebuf, |
763 | &dmesg_msg_iter->linebuf_len, dmesg_msg_iter->fp); | |
e2531d3b PP |
764 | if (len < 0) { |
765 | if (errno == EINVAL) { | |
fb25b9e3 | 766 | status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; |
e2531d3b | 767 | } else if (errno == ENOMEM) { |
fb25b9e3 | 768 | status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; |
e2531d3b | 769 | } else { |
b09a5592 | 770 | if (dmesg_msg_iter->state == STATE_EMIT_STREAM_BEGINNING) { |
a6918753 | 771 | /* Stream did not even begin */ |
fb25b9e3 | 772 | status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; |
a6918753 PP |
773 | goto end; |
774 | } else { | |
775 | /* End current packet now */ | |
b09a5592 | 776 | dmesg_msg_iter->state = |
a6918753 PP |
777 | STATE_EMIT_PACKET_END; |
778 | goto handle_state; | |
779 | } | |
e2531d3b PP |
780 | } |
781 | ||
782 | goto end; | |
783 | } | |
784 | ||
b09a5592 | 785 | BT_ASSERT(dmesg_msg_iter->linebuf); |
e2531d3b PP |
786 | |
787 | /* Ignore empty lines, once trimmed */ | |
b09a5592 | 788 | for (ch = dmesg_msg_iter->linebuf; *ch != '\0'; ch++) { |
e2531d3b PP |
789 | if (!isspace(*ch)) { |
790 | only_spaces = false; | |
791 | break; | |
792 | } | |
793 | } | |
794 | ||
795 | if (!only_spaces) { | |
796 | break; | |
797 | } | |
798 | } | |
799 | ||
b09a5592 PP |
800 | dmesg_msg_iter->tmp_event_msg = create_msg_from_line( |
801 | dmesg_msg_iter, dmesg_msg_iter->linebuf); | |
802 | if (!dmesg_msg_iter->tmp_event_msg) { | |
4b1e4687 | 803 | BT_COMP_LOGE("Cannot create event message from line: " |
e2531d3b | 804 | "dmesg-comp-addr=%p, line=\"%s\"", dmesg_comp, |
b09a5592 | 805 | dmesg_msg_iter->linebuf); |
a6918753 PP |
806 | goto end; |
807 | } | |
808 | ||
809 | handle_state: | |
810 | BT_ASSERT(dmesg_comp->trace); | |
811 | ||
b09a5592 | 812 | switch (dmesg_msg_iter->state) { |
a6918753 | 813 | case STATE_EMIT_STREAM_BEGINNING: |
b09a5592 PP |
814 | BT_ASSERT(dmesg_msg_iter->tmp_event_msg); |
815 | *msg = bt_message_stream_beginning_create( | |
816 | dmesg_msg_iter->pc_msg_iter, dmesg_comp->stream); | |
66ff4085 PP |
817 | dmesg_msg_iter->state = STATE_EMIT_STREAM_ACTIVITY_BEGINNING; |
818 | break; | |
819 | case STATE_EMIT_STREAM_ACTIVITY_BEGINNING: | |
820 | BT_ASSERT(dmesg_msg_iter->tmp_event_msg); | |
821 | *msg = bt_message_stream_activity_beginning_create( | |
822 | dmesg_msg_iter->pc_msg_iter, dmesg_comp->stream); | |
b09a5592 | 823 | dmesg_msg_iter->state = STATE_EMIT_PACKET_BEGINNING; |
a6918753 PP |
824 | break; |
825 | case STATE_EMIT_PACKET_BEGINNING: | |
b09a5592 | 826 | BT_ASSERT(dmesg_msg_iter->tmp_event_msg); |
96a0a69d PP |
827 | |
828 | if (dmesg_comp->clock_class) { | |
829 | *msg = bt_message_packet_beginning_create_with_default_clock_snapshot( | |
830 | dmesg_msg_iter->pc_msg_iter, dmesg_comp->packet, | |
831 | dmesg_msg_iter->last_clock_value); | |
832 | } else { | |
833 | *msg = bt_message_packet_beginning_create( | |
834 | dmesg_msg_iter->pc_msg_iter, dmesg_comp->packet); | |
835 | } | |
836 | ||
b09a5592 | 837 | dmesg_msg_iter->state = STATE_EMIT_EVENT; |
a6918753 PP |
838 | break; |
839 | case STATE_EMIT_EVENT: | |
b09a5592 PP |
840 | BT_ASSERT(dmesg_msg_iter->tmp_event_msg); |
841 | *msg = dmesg_msg_iter->tmp_event_msg; | |
842 | dmesg_msg_iter->tmp_event_msg = NULL; | |
a6918753 PP |
843 | break; |
844 | case STATE_EMIT_PACKET_END: | |
96a0a69d PP |
845 | if (dmesg_comp->clock_class) { |
846 | *msg = bt_message_packet_end_create_with_default_clock_snapshot( | |
847 | dmesg_msg_iter->pc_msg_iter, dmesg_comp->packet, | |
848 | dmesg_msg_iter->last_clock_value); | |
849 | } else { | |
850 | *msg = bt_message_packet_end_create( | |
851 | dmesg_msg_iter->pc_msg_iter, dmesg_comp->packet); | |
852 | } | |
853 | ||
66ff4085 PP |
854 | dmesg_msg_iter->state = STATE_EMIT_STREAM_ACTIVITY_END; |
855 | break; | |
856 | case STATE_EMIT_STREAM_ACTIVITY_END: | |
857 | *msg = bt_message_stream_activity_end_create( | |
858 | dmesg_msg_iter->pc_msg_iter, dmesg_comp->stream); | |
b09a5592 | 859 | dmesg_msg_iter->state = STATE_EMIT_STREAM_END; |
a6918753 PP |
860 | break; |
861 | case STATE_EMIT_STREAM_END: | |
b09a5592 PP |
862 | *msg = bt_message_stream_end_create( |
863 | dmesg_msg_iter->pc_msg_iter, dmesg_comp->stream); | |
864 | dmesg_msg_iter->state = STATE_DONE; | |
a6918753 PP |
865 | break; |
866 | default: | |
867 | break; | |
868 | } | |
869 | ||
b09a5592 | 870 | if (!*msg) { |
4b1e4687 | 871 | BT_COMP_LOGE("Cannot create message: dmesg-comp-addr=%p", |
a6918753 | 872 | dmesg_comp); |
fb25b9e3 | 873 | status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; |
e2531d3b PP |
874 | } |
875 | ||
876 | end: | |
3fd7b79d PP |
877 | return status; |
878 | } | |
879 | ||
880 | BT_HIDDEN | |
fb25b9e3 | 881 | bt_component_class_message_iterator_next_method_status dmesg_msg_iter_next( |
b09a5592 PP |
882 | bt_self_message_iterator *self_msg_iter, |
883 | bt_message_array_const msgs, uint64_t capacity, | |
3fd7b79d PP |
884 | uint64_t *count) |
885 | { | |
b09a5592 PP |
886 | struct dmesg_msg_iter *dmesg_msg_iter = |
887 | bt_self_message_iterator_get_data( | |
888 | self_msg_iter); | |
fb25b9e3 PP |
889 | bt_component_class_message_iterator_next_method_status status = |
890 | BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; | |
3fd7b79d PP |
891 | uint64_t i = 0; |
892 | ||
834e9996 | 893 | while (i < capacity && |
fb25b9e3 | 894 | status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { |
b09a5592 | 895 | bt_message *priv_msg = NULL; |
9e550e5f | 896 | |
b09a5592 PP |
897 | status = dmesg_msg_iter_next_one(dmesg_msg_iter, |
898 | &priv_msg); | |
899 | msgs[i] = priv_msg; | |
fb25b9e3 | 900 | if (status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { |
3fd7b79d PP |
901 | i++; |
902 | } | |
903 | } | |
904 | ||
905 | if (i > 0) { | |
906 | /* | |
b09a5592 | 907 | * Even if dmesg_msg_iter_next_one() returned |
3fd7b79d | 908 | * something else than |
b09a5592 PP |
909 | * BT_SELF_MESSAGE_ITERATOR_STATUS_OK, we |
910 | * accumulated message objects in the output | |
911 | * message array, so we need to return | |
912 | * BT_SELF_MESSAGE_ITERATOR_STATUS_OK so that they | |
834e9996 | 913 | * are transfered to downstream. This other status |
b09a5592 | 914 | * occurs again the next time muxer_msg_iter_do_next() |
834e9996 | 915 | * is called, possibly without any accumulated |
b09a5592 | 916 | * message, in which case we'll return it. |
3fd7b79d PP |
917 | */ |
918 | *count = i; | |
fb25b9e3 | 919 | status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; |
3fd7b79d PP |
920 | } |
921 | ||
922 | return status; | |
d8866baa | 923 | } |
12b0fa51 PP |
924 | |
925 | BT_HIDDEN | |
926 | bt_bool dmesg_msg_iter_can_seek_beginning( | |
927 | bt_self_message_iterator *self_msg_iter) | |
928 | { | |
929 | struct dmesg_msg_iter *dmesg_msg_iter = | |
930 | bt_self_message_iterator_get_data(self_msg_iter); | |
931 | ||
932 | /* Can't seek the beginning of the standard input stream */ | |
933 | return !dmesg_msg_iter->dmesg_comp->params.read_from_stdin; | |
934 | } | |
935 | ||
936 | BT_HIDDEN | |
fb25b9e3 PP |
937 | bt_component_class_message_iterator_seek_beginning_method_status |
938 | dmesg_msg_iter_seek_beginning( | |
12b0fa51 PP |
939 | bt_self_message_iterator *self_msg_iter) |
940 | { | |
941 | struct dmesg_msg_iter *dmesg_msg_iter = | |
942 | bt_self_message_iterator_get_data(self_msg_iter); | |
943 | ||
944 | BT_ASSERT(!dmesg_msg_iter->dmesg_comp->params.read_from_stdin); | |
945 | ||
946 | BT_MESSAGE_PUT_REF_AND_RESET(dmesg_msg_iter->tmp_event_msg); | |
947 | dmesg_msg_iter->last_clock_value = 0; | |
948 | dmesg_msg_iter->state = STATE_EMIT_STREAM_BEGINNING; | |
fb25b9e3 | 949 | return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK; |
12b0fa51 | 950 | } |