X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Fctf.c;h=4f14d7a0b8a45a1994e46d355aabb7af0a930734;hp=83680cd697f764e23969a19ae86df8763e8bc508;hb=43e34335c78d923564d369e9af46b634ce9ad55f;hpb=e419579102094d83539d79ce6af83d9786d387ee diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index 83680cd6..4f14d7a0 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -23,12 +23,12 @@ #include #include #include +#include +#include #include #include -#include #include #include -#include #include #include #include @@ -40,6 +40,7 @@ #include "metadata/ctf-scanner.h" #include "metadata/ctf-parser.h" #include "metadata/ctf-ast.h" +#include "events-private.h" /* * We currently simply map a page to read the packet header and packet @@ -47,7 +48,6 @@ */ #define MAX_PACKET_HEADER_LEN (getpagesize() * CHAR_BIT) #define WRITE_PACKET_LEN (getpagesize() * 8 * CHAR_BIT) -#define UUID_LEN 16 /* uuid by value len */ #ifndef min #define min(a, b) (((a) < (b)) ? (a) : (b)) @@ -149,21 +149,14 @@ void ctf_print_timestamp(FILE *fp, uint64_t timestamp) { uint64_t ts_sec = 0, ts_nsec; - struct ctf_trace *trace = stream->stream_class->trace; - struct trace_collection *tc = trace->collection; - uint64_t tc_offset = tc->single_clock_offset_avg; - if (stream->current_clock->freq == 1000000000ULL) { - ts_nsec = timestamp; + if (opt_clock_raw) { + ts_nsec = ctf_get_timestamp_raw(stream, timestamp); } else { - ts_nsec = (uint64_t) ((double) timestamp * 1000000000.0 - / (double) stream->current_clock->freq); + ts_nsec = ctf_get_timestamp(stream, timestamp); } - /* Add offsets */ - if (!opt_clock_raw) { - ts_nsec += tc_offset; - } + /* Add command-line offset */ ts_sec += opt_clock_offset; ts_sec += ts_nsec / NSEC_PER_SEC; @@ -535,16 +528,25 @@ void ctf_packet_seek(struct stream_pos *stream_pos, size_t index, int whence) * be printed in the output. */ if (file_stream->parent.events_discarded) { - fflush(stdout); - fprintf(stderr, "[warning] Tracer discarded %d events at end of stream between [", - file_stream->parent.events_discarded); - ctf_print_timestamp(stderr, &file_stream->parent, - file_stream->parent.prev_timestamp); - fprintf(stderr, "] and ["); - ctf_print_timestamp(stderr, &file_stream->parent, - file_stream->parent.prev_timestamp_end); - fprintf(stderr, "]. You should consider increasing the buffer size.\n"); - fflush(stderr); + /* + * We need to check if we are in trace + * read or called from packet indexing. + * In this last case, the collection is + * not there, so we cannot print the + * timestamps. + */ + if ((&file_stream->parent)->stream_class->trace->collection) { + fflush(stdout); + fprintf(stderr, "[warning] Tracer discarded %d events at end of stream between [", + file_stream->parent.events_discarded); + ctf_print_timestamp(stderr, &file_stream->parent, + file_stream->parent.prev_timestamp); + fprintf(stderr, "] and ["); + ctf_print_timestamp(stderr, &file_stream->parent, + file_stream->parent.prev_timestamp_end); + fprintf(stderr, "]. You should consider increasing the buffer size.\n"); + fflush(stderr); + } file_stream->parent.events_discarded = 0; } pos->offset = EOF; @@ -686,7 +688,7 @@ int ctf_open_trace_metadata_packet_read(struct ctf_trace *td, FILE *in, memcpy(td->uuid, header.uuid, sizeof(header.uuid)); CTF_TRACE_SET_FIELD(td, uuid); } else { - if (uuid_compare(header.uuid, td->uuid)) + if (babeltrace_uuid_compare(header.uuid, td->uuid)) return -EINVAL; } @@ -1074,20 +1076,20 @@ int create_stream_packet_index(struct ctf_trace *td, struct definition_array *defarray; struct definition *field; uint64_t i; - uint8_t uuidval[UUID_LEN]; + uint8_t uuidval[BABELTRACE_UUID_LEN]; field = struct_definition_get_field_from_index(file_stream->parent.trace_packet_header, len_index); assert(field->declaration->id == CTF_TYPE_ARRAY); defarray = container_of(field, struct definition_array, p); - assert(array_len(defarray) == UUID_LEN); + assert(array_len(defarray) == BABELTRACE_UUID_LEN); - for (i = 0; i < UUID_LEN; i++) { + for (i = 0; i < BABELTRACE_UUID_LEN; i++) { struct definition *elem; elem = array_index(defarray, i); uuidval[i] = get_unsigned_int(elem); } - ret = uuid_compare(td->uuid, uuidval); + ret = babeltrace_uuid_compare(td->uuid, uuidval); if (ret) { fprintf(stderr, "[error] Unique Universal Identifiers do not match.\n"); return -EINVAL;