API fix : fill the values for timestamp begin and end
authorJulien Desfossez <julien.desfossez@efficios.com>
Thu, 5 Apr 2012 15:49:40 +0000 (11:49 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 5 Apr 2012 15:49:40 +0000 (11:49 -0400)
The API functions were defined and exported but not implemented.

Signed-off-by: Julien Desfossez <julien.desfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/ctf.c
include/babeltrace/format.h
include/babeltrace/trace-handle.h
lib/context.c

index 91fc20c3972626a59075b13dcf72df981b30f2a3..32206166b2a2c43a637dbf7e0e36489d297bd0da 100644 (file)
@@ -87,6 +87,12 @@ void ctf_set_handle(struct trace_descriptor *descriptor,
 
 static
 void ctf_close_trace(struct trace_descriptor *descriptor);
+static
+uint64_t ctf_timestamp_begin(struct trace_descriptor *descriptor,
+               struct bt_trace_handle *handle);
+static
+uint64_t ctf_timestamp_end(struct trace_descriptor *descriptor,
+               struct bt_trace_handle *handle);
 
 static
 rw_dispatch read_dispatch_table[] = {
@@ -119,8 +125,97 @@ struct format ctf_format = {
        .close_trace = ctf_close_trace,
        .set_context = ctf_set_context,
        .set_handle = ctf_set_handle,
+       .timestamp_begin = ctf_timestamp_begin,
+       .timestamp_end = ctf_timestamp_end,
 };
 
+static
+uint64_t ctf_timestamp_begin(struct trace_descriptor *descriptor,
+               struct bt_trace_handle *handle)
+{
+       struct ctf_trace *tin;
+       uint64_t begin = ULLONG_MAX;
+       int i, j;
+
+       tin = container_of(descriptor, struct ctf_trace, parent);
+
+       if (!tin)
+               goto error;
+
+       /* for each stream_class */
+       for (i = 0; i < tin->streams->len; i++) {
+               struct ctf_stream_declaration *stream_class;
+
+               stream_class = g_ptr_array_index(tin->streams, i);
+               /* for each file_stream */
+               for (j = 0; j < stream_class->streams->len; j++) {
+                       struct ctf_stream_definition *stream;
+                       struct ctf_file_stream *cfs;
+                       struct ctf_stream_pos *stream_pos;
+                       struct packet_index *index;
+
+                       stream = g_ptr_array_index(stream_class->streams, j);
+                       cfs = container_of(stream, struct ctf_file_stream,
+                                       parent);
+                       stream_pos = &cfs->pos;
+
+                       index = &g_array_index(stream_pos->packet_index,
+                                       struct packet_index, 0);
+                       if (index->timestamp_begin < begin)
+                               begin = index->timestamp_begin;
+               }
+       }
+
+       return begin;
+
+error:
+       return -1ULL;
+}
+
+static
+uint64_t ctf_timestamp_end(struct trace_descriptor *descriptor,
+               struct bt_trace_handle *handle)
+{
+       struct ctf_trace *tin;
+       uint64_t end = 0;
+       int i, j;
+
+       tin = container_of(descriptor, struct ctf_trace, parent);
+
+       if (!tin)
+               goto error;
+
+       /* for each stream_class */
+       for (i = 0; i < tin->streams->len; i++) {
+               struct ctf_stream_declaration *stream_class;
+
+               stream_class = g_ptr_array_index(tin->streams, i);
+               /* for each file_stream */
+               for (j = 0; j < stream_class->streams->len; j++) {
+                       struct ctf_stream_definition *stream;
+                       struct ctf_file_stream *cfs;
+                       struct ctf_stream_pos *stream_pos;
+                       struct packet_index *index;
+
+                       stream = g_ptr_array_index(stream_class->streams, j);
+                       cfs = container_of(stream, struct ctf_file_stream,
+                                       parent);
+                       stream_pos = &cfs->pos;
+
+                       index = &g_array_index(stream_pos->packet_index,
+                                       struct packet_index,
+                                       stream_pos->packet_index->len - 1);
+                       if (index->timestamp_end > end)
+                               end = index->timestamp_end;
+               }
+       }
+
+       return end;
+
+error:
+       return -1ULL;
+}
+
 /*
  * Update stream current timestamp, keep at clock frequency.
  */
index b67dd5dc77298d434557f3fe3afe00a1bbd8e8cd..c3e7a209f7e785fc08a887a34c25d68f8dbae2ab 100644 (file)
@@ -62,6 +62,10 @@ struct format {
                        struct bt_context *ctx);
        void (*set_handle)(struct trace_descriptor *descriptor,
                        struct bt_trace_handle *handle);
+       uint64_t (*timestamp_begin)(struct trace_descriptor *descriptor,
+                       struct bt_trace_handle *handle);
+       uint64_t (*timestamp_end)(struct trace_descriptor *descriptor,
+                       struct bt_trace_handle *handle);
 };
 
 extern struct format *bt_lookup_format(bt_intern_str qname);
index 31877ee1886a681165d25fdd9d2b2b94e9252af9..65171e7090cfd1574db20874c753ae2e3281b0c2 100644 (file)
@@ -39,14 +39,14 @@ struct bt_ctf_event;
 const char *bt_trace_handle_get_path(struct bt_context *ctx, int handle_id);
 
 /*
- * bt_trace_handle_get_timestamp_begin : returns the beginning timestamp
+ * bt_trace_handle_get_timestamp_begin : returns the creation time of the buffers
  * of a trace.
  */
 uint64_t bt_trace_handle_get_timestamp_begin(struct bt_context *ctx, int handle_id);
 
 /*
- * bt_trace_handle_get_timestamp_end : returns the end timestamp of a
- * trace.
+ * bt_trace_handle_get_timestamp_end : returns the destruction timestamp of the
+ * buffers of a trace.
  */
 uint64_t bt_trace_handle_get_timestamp_end(struct bt_context *ctx, int handle_id);
 
index dbab33754cab346ba6c8a2054d72398338ffde23..d3232fe9720878f6f1b9cde0ebe27b1f5a7072ea 100644 (file)
@@ -104,6 +104,8 @@ int bt_context_add_trace(struct bt_context *ctx, const char *path,
        }
        handle->format = fmt;
        handle->td = td;
+       handle->timestamp_begin = fmt->timestamp_begin(td, handle);
+       handle->timestamp_end = fmt->timestamp_end(td, handle);
        strncpy(handle->path, path, PATH_MAX);
        handle->path[PATH_MAX - 1] = '\0';
 
This page took 0.027885 seconds and 4 git commands to generate.