From 5e2eb0aebe6dd62c86d2b96030cb1ba3a0793bec Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 28 Jun 2011 18:18:01 -0400 Subject: [PATCH] Pretty-print 0-value timestamps Useful when dealing with dmesg logs which have 0-value timestamp. Signed-off-by: Mathieu Desnoyers --- formats/ctf-text/ctf-text.c | 2 +- formats/ctf/ctf.c | 3 +++ include/babeltrace/ctf-ir/metadata.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/formats/ctf-text/ctf-text.c b/formats/ctf-text/ctf-text.c index 361c527c..d169caac 100644 --- a/formats/ctf-text/ctf-text.c +++ b/formats/ctf-text/ctf-text.c @@ -145,7 +145,7 @@ int ctf_text_write_event(struct stream_pos *ppos, return -EINVAL; } - if (stream->timestamp) { + if (stream->has_timestamp) { if (pos->print_names) fprintf(pos->fp, "timestamp = "); else diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index 6e45ea36..28be4fd0 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -156,14 +156,17 @@ int ctf_read_event(struct stream_pos *ppos, struct ctf_stream *stream) } /* lookup timestamp */ + stream->has_timestamp = 0; integer_definition = lookup_integer(&stream->stream_event_header->p, "timestamp", FALSE); if (integer_definition) { ctf_update_timestamp(stream, integer_definition); + stream->has_timestamp = 1; } else { if (variant) { integer_definition = lookup_integer(variant, "timestamp", FALSE); if (integer_definition) { ctf_update_timestamp(stream, integer_definition); + stream->has_timestamp = 1; } } } diff --git a/include/babeltrace/ctf-ir/metadata.h b/include/babeltrace/ctf-ir/metadata.h index 9c4d4500..14c788c6 100644 --- a/include/babeltrace/ctf-ir/metadata.h +++ b/include/babeltrace/ctf-ir/metadata.h @@ -36,6 +36,7 @@ struct ctf_event; struct ctf_stream { struct ctf_stream_class *stream_class; uint64_t timestamp; /* Current timestamp, in ns */ + int has_timestamp; uint64_t stream_id; struct definition_struct *trace_packet_header; -- 2.34.1