Move clock to bt_trace_descriptor
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 23 Apr 2013 13:48:26 +0000 (09:48 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 23 Apr 2013 13:48:26 +0000 (09:48 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/ctf.c
formats/ctf/events-private.h
formats/ctf/metadata/ctf-visitor-generate-io-struct.c
include/babeltrace/ctf-ir/metadata.h
include/babeltrace/format-internal.h
lib/trace-collection.c

index 6bb31e55f4efb31346fcdc8ee14457565734a619..7b53dd6b188a51837aacd01123f55b3d1e224eee 100644 (file)
@@ -1655,7 +1655,7 @@ int ctf_open_file_stream_read(struct ctf_trace *td, const char *path, int flags,
        /*
         * For now, only a single clock per trace is supported.
         */
-       file_stream->parent.current_clock = td->single_clock;
+       file_stream->parent.current_clock = td->parent.single_clock;
        ret = create_stream_packet_index(td, file_stream);
        if (ret)
                goto error_index;
@@ -1896,7 +1896,7 @@ int ctf_open_mmap_stream_read(struct ctf_trace *td,
        /*
         * For now, only a single clock per trace is supported.
         */
-       file_stream->parent.current_clock = td->single_clock;
+       file_stream->parent.current_clock = td->parent.single_clock;
 
        /* Add stream file to stream class */
        g_ptr_array_add(file_stream->parent.stream_class->streams,
index 770012f405ce39703f7672ad46e94de7f5087dd4..4906c02aa9171ec6674b11b679ef74886e045e8f 100644 (file)
@@ -46,7 +46,7 @@ uint64_t ctf_get_real_timestamp(struct ctf_stream_definition *stream,
        if (tc->clock_use_offset_avg)
                tc_offset = tc->single_clock_offset_avg;
        else
-               tc_offset = trace->single_clock->offset;
+               tc_offset = trace->parent.single_clock->offset;
 
        ts_nsec = clock_cycles_to_ns(stream->current_clock, timestamp);
        ts_nsec += tc_offset;   /* Add offset */
index 17479ebaec39f384056ce479d68db3552c6c4560..0002fe4f45dd1135cba510427b86ab5b9cc92cfe 100644 (file)
@@ -271,7 +271,7 @@ struct ctf_stream_declaration *trace_stream_lookup(struct ctf_trace *trace, uint
 static
 struct ctf_clock *trace_clock_lookup(struct ctf_trace *trace, GQuark clock_name)
 {
-       return g_hash_table_lookup(trace->clocks, (gpointer) (unsigned long) clock_name);
+       return g_hash_table_lookup(trace->parent.clocks, (gpointer) (unsigned long) clock_name);
 }
 
 static
@@ -2450,13 +2450,13 @@ int ctf_clock_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_trace
                fprintf(fd, "[error] %s: missing name field in clock declaration\n", __func__);
                goto error;
        }
-       if (g_hash_table_size(trace->clocks) > 0) {
+       if (g_hash_table_size(trace->parent.clocks) > 0) {
                fprintf(fd, "[error] Only CTF traces with a single clock description are supported by this babeltrace version.\n");
                ret = -EINVAL;
                goto error;
        }
-       trace->single_clock = clock;
-       g_hash_table_insert(trace->clocks, (gpointer) (unsigned long) clock->name, clock);
+       trace->parent.single_clock = clock;
+       g_hash_table_insert(trace->parent.clocks, (gpointer) (unsigned long) clock->name, clock);
        return 0;
 
 error:
@@ -2490,8 +2490,8 @@ void ctf_clock_default(FILE *fd, int depth, struct ctf_trace *trace)
                clock->absolute = 0;    /* Not an absolute reference across traces */
        }
 
-       trace->single_clock = clock;
-       g_hash_table_insert(trace->clocks, (gpointer) (unsigned long) clock->name, clock);
+       trace->parent.single_clock = clock;
+       g_hash_table_insert(trace->parent.clocks, (gpointer) (unsigned long) clock->name, clock);
 }
 
 static
@@ -2920,8 +2920,8 @@ int ctf_visitor_construct_metadata(FILE *fd, int depth, struct ctf_node *node,
 
        printf_verbose("CTF visitor: metadata construction...\n");
        trace->byte_order = byte_order;
-       trace->clocks = g_hash_table_new_full(g_direct_hash, g_direct_equal,
-                               NULL, clock_free);
+       trace->parent.clocks = g_hash_table_new_full(g_direct_hash,
+                               g_direct_equal, NULL, clock_free);
        trace->callsites = g_hash_table_new_full(g_direct_hash, g_direct_equal,
                                NULL, callsite_free);
 
@@ -3023,7 +3023,7 @@ retry:
 error:
        bt_free_declaration_scope(trace->root_declaration_scope);
        g_hash_table_destroy(trace->callsites);
-       g_hash_table_destroy(trace->clocks);
+       g_hash_table_destroy(trace->parent.clocks);
        return ret;
 }
 
@@ -3122,7 +3122,7 @@ int ctf_destroy_metadata(struct ctf_trace *trace)
        bt_free_declaration_scope(trace->declaration_scope);
 
        g_hash_table_destroy(trace->callsites);
-       g_hash_table_destroy(trace->clocks);
+       g_hash_table_destroy(trace->parent.clocks);
 
        metadata_stream = container_of(trace->metadata, struct ctf_file_stream, parent);
        g_free(metadata_stream);
index 87ca4923af8f16d9116ed4e10d3901700a83c0e5..3d684fb661db86759b0080328bfe18597c5c660b 100644 (file)
@@ -188,9 +188,7 @@ struct ctf_trace {
        struct ctf_stream_definition *metadata;
        char *metadata_string;
        int metadata_packetized;
-       GHashTable *clocks;
        GHashTable *callsites;
-       struct ctf_clock *single_clock;         /* currently supports only one clock */
        GPtrArray *event_declarations;          /* Array of all the struct bt_ctf_event_decl */
 
        struct declaration_struct *packet_header_decl;
index 880a336e9c098e6bb26c6bb71810a27c49ce7ef4..7f3eb5ef9e723ec9657ae5a8e2c8fb043769d5bc 100644 (file)
@@ -43,6 +43,8 @@ struct bt_trace_descriptor {
        struct bt_context *ctx;
        struct bt_trace_handle *handle;
        struct trace_collection *collection;    /* Container of this trace */
+       GHashTable *clocks;
+       struct ctf_clock *single_clock;         /* currently supports only one clock */
 };
 
 #ifdef __cplusplus
index 6743ce6ba7467ef8c21daeea02d81b8073e9b632..b854c97440422b009ce12111d54f136f94431515 100644 (file)
@@ -156,15 +156,11 @@ static void clock_add(gpointer key, gpointer value, gpointer user_data)
  * convert the index from cycles to real time.
  */
 int bt_trace_collection_add(struct trace_collection *tc,
-                               struct bt_trace_descriptor *td)
+                       struct bt_trace_descriptor *trace)
 {
-       struct ctf_trace *trace;
-
-       if (!tc || !td)
+       if (!tc || !trace)
                return -EINVAL;
 
-       trace = container_of(td, struct ctf_trace, parent);
-
        if (tc->array->len > 1) {
                struct clock_match clock_match = {
                        .clocks = tc->clocks,
@@ -185,8 +181,8 @@ int bt_trace_collection_add(struct trace_collection *tc,
                }
        }
 
-       g_ptr_array_add(tc->array, td);
-       trace->parent.collection = tc;
+       g_ptr_array_add(tc->array, trace);
+       trace->collection = tc;
 
        {
                struct clock_match clock_match = {
This page took 0.029205 seconds and 4 git commands to generate.