Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: benjamin.poirier@polymtl.ca (Benjamin Poirier)
Subject: [ltt-dev] [PATCH] Do not initialize times before the frequency has been read
Date: Mon, 24 Aug 2009 09:23:47 -0400	[thread overview]
Message-ID: <4A929463.2090105@polymtl.ca> (raw)

Do not calculate bogus begin and end values. Instead, skip that section of
code until the trace header has been read.

Signed-off-by: Benjamin Poirier <benjamin.poirier at polymtl.ca>
---

This is an independant fix of the problem addressed in
04ad7785b5c1efc53fe5e71b8111a2793e923c6c "initialize fields of LttTrace to
ensure deterministic behavior and that valgrid does not complain". The end
result is the same but I think it makes a little more sense; merge it if you
agree.

 ltt/tracefile.c |   24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/ltt/tracefile.c b/ltt/tracefile.c
index 9cd1305..1b65455 100644
--- a/ltt/tracefile.c
+++ b/ltt/tracefile.c
@@ -764,11 +764,6 @@ LttTrace *ltt_trace_open(const gchar *pathname)
   get_absolute_pathname(pathname, abs_path);
   t->pathname = g_quark_from_string(abs_path);
 
-  t->start_tsc = 0;
-  t->freq_scale = 1;
-  t->start_freq = 1;
-  t->start_time_from_tsc = ltt_time_zero;
-
   g_datalist_init(&t->tracefiles);
 
   /* Test to see if it looks like a trace */
@@ -790,6 +785,7 @@ LttTrace *ltt_trace_open(const gchar *pathname)
   closedir(dir);
   
   /* Open all the tracefiles */
+  t->start_freq= 0;
   if(open_tracefiles(t, abs_path, "")) {
     g_warning("Error opening tracefile %s", abs_path);
     goto find_error;
@@ -1389,22 +1385,24 @@ static gint map_block(LttTracefile * tf, guint block_num)
 
   tf->buffer.begin.cycle_count = ltt_get_uint64(LTT_GET_BO(tf),
                                               &header->cycle_count_begin);
-  tf->buffer.begin.freq = tf->trace->start_freq;
-
-  tf->buffer.begin.timestamp = ltt_interpolate_time_from_tsc(tf, 
-                                          tf->buffer.begin.cycle_count);
   tf->buffer.end.cycle_count = ltt_get_uint64(LTT_GET_BO(tf),
                                               &header->cycle_count_end);
-  tf->buffer.end.freq = tf->trace->start_freq;
-  
   tf->buffer.lost_size = ltt_get_uint32(LTT_GET_BO(tf),
                                         &header->lost_size);
-  tf->buffer.end.timestamp = ltt_interpolate_time_from_tsc(tf,
-                                        tf->buffer.end.cycle_count);
   tf->buffer.tsc =  tf->buffer.begin.cycle_count;
   tf->event.tsc = tf->buffer.tsc;
   tf->buffer.freq = tf->buffer.begin.freq;
 
+  if (tf->trace->start_freq)
+  {
+    tf->buffer.begin.freq = tf->trace->start_freq;
+    tf->buffer.begin.timestamp = ltt_interpolate_time_from_tsc(tf,
+      tf->buffer.begin.cycle_count);
+    tf->buffer.end.freq = tf->trace->start_freq;
+    tf->buffer.end.timestamp = ltt_interpolate_time_from_tsc(tf,
+      tf->buffer.end.cycle_count);
+  }
+
   /* FIXME
    * eventually support variable buffer size : will need a partial pre-read of
    * the headers to create an index when we open the trace... eventually. */
-- 
1.6.3.3





                 reply	other threads:[~2009-08-24 13:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A929463.2090105@polymtl.ca \
    --to=benjamin.poirier@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox