#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
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;
* 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;