X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Fctf.c;h=f4432a89d167c0fe01e181232f246ad4cf5b73e0;hp=50cc93de1d866b83a3302767871707ff3c4e5799;hb=764af3f43c289a0a5cd8bf6fd85d9361ae17a253;hpb=312623540c466defab45503fbe0ce7ec79dcce85 diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index 50cc93de..f4432a89 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -80,10 +80,11 @@ struct format ctf_format = { }; static -int ctf_read_event(struct stream_pos *ppos, struct ctf_stream *stream_class) +int ctf_read_event(struct stream_pos *ppos, struct ctf_stream *stream) { struct ctf_stream_pos *pos = container_of(ppos, struct ctf_stream_pos, parent); + struct ctf_stream_class *stream_class = stream->stream_class; struct ctf_event *event_class; uint64_t id = 0; int len_index; @@ -110,6 +111,22 @@ int ctf_read_event(struct stream_pos *ppos, struct ctf_stream *stream_class) assert(defint->declaration->signedness == FALSE); id = defint->value._unsigned; /* set id */ } + + /* lookup timestamp */ + len_index = struct_declaration_lookup_field_index(stream_class->event_header_decl, + g_quark_from_static_string("timestamp")); + if (len_index >= 0) { + struct definition_integer *defint; + struct definition *field; + + field = struct_definition_get_field_from_index(stream_class->event_header, len_index); + assert(field->declaration->id == CTF_TYPE_INTEGER); + defint = container_of(field, struct definition_integer, p); + assert(defint->declaration->signedness == FALSE); + /* update timestamp */ + stream->timestamp = defint->value._unsigned; + } + } /* Read stream-declared event context */ @@ -151,8 +168,9 @@ error: } static -int ctf_write_event(struct stream_pos *pos, struct ctf_stream *stream_class) +int ctf_write_event(struct stream_pos *pos, struct ctf_stream *stream) { + struct ctf_stream_class *stream_class = stream->stream_class; struct ctf_event *event_class; uint64_t id = 0; int len_index; @@ -424,7 +442,7 @@ static int create_stream_packet_index(struct ctf_trace *td, struct ctf_file_stream *file_stream) { - struct ctf_stream *stream; + struct ctf_stream_class *stream; int len_index; struct ctf_stream_pos *pos; struct stat filestats; @@ -545,7 +563,7 @@ int create_stream_packet_index(struct ctf_trace *td, fprintf(stdout, "[error] Stream %" PRIu64 " is not declared in metadata.\n", stream_id); return -EINVAL; } - file_stream->stream = stream; + file_stream->stream.stream_class = stream; } first_packet = 0; @@ -639,7 +657,7 @@ int ctf_open_file_stream_read(struct ctf_trace *td, const char *path, int flags) if (ret) goto error_index; /* Add stream file to stream class */ - g_ptr_array_add(file_stream->stream->files, file_stream); + g_ptr_array_add(file_stream->stream.stream_class->files, file_stream); return 0; error_index: @@ -776,7 +794,7 @@ void ctf_close_trace(struct trace_descriptor *tdp) if (td->streams) { for (i = 0; i < td->streams->len; i++) { - struct ctf_stream *stream; + struct ctf_stream_class *stream; int j; stream = g_ptr_array_index(td->streams, i); for (j = 0; j < stream->files->len; j++) {