lib: create a clock class object from component
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Sat, 23 Feb 2019 00:53:15 +0000 (19:53 -0500)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 2 May 2019 20:50:15 +0000 (20:50 +0000)
Before this commit, a trace class was needed for the creation of a clock
class. Turns out that clock class may be needed before the creation any
trace class. For example, Inactivity messages created before a trace has
generated any data need a clock class but no trace class was created yet.

This commit allows for the creation of clock classes even when no trace
classes exist using a component class.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
include/babeltrace/trace-ir/clock-class.h
lib/trace-ir/clock-class.c
plugins/ctf/common/metadata/ctf-meta-translate.c
plugins/ctf/common/metadata/ctf-meta-visitors.h
plugins/ctf/common/metadata/visitor-generate-ir.c
plugins/text/dmesg/dmesg.c

index 544288cd5a678708a3d4b61954a7c07edf02f735..ced017f3345f3006f70d538cb2f25d36d3ddb7fa 100644 (file)
@@ -39,7 +39,7 @@
 extern "C" {
 #endif
 
-extern bt_clock_class *bt_clock_class_create(bt_trace_class *trace_class);
+extern bt_clock_class *bt_clock_class_create(bt_self_component *self_comp);
 
 extern bt_clock_class_status bt_clock_class_set_name(
                bt_clock_class *clock_class, const char *name);
index 7f87e57b4d7c2ed79ff754d092a164c47e1f1001..3c64ccd7e84fb9c413702601555a51ee06901b3d 100644 (file)
@@ -79,12 +79,12 @@ void set_base_offset(struct bt_clock_class *clock_class)
                clock_class->frequency, &clock_class->base_offset.value_ns);
 }
 
-struct bt_clock_class *bt_clock_class_create(bt_trace_class *trace_class)
+struct bt_clock_class *bt_clock_class_create(bt_self_component *self_comp)
 {
        int ret;
        struct bt_clock_class *clock_class = NULL;
 
-       BT_ASSERT_PRE_NON_NULL(trace_class, "Trace class");
+       BT_ASSERT_PRE_NON_NULL(self_comp, "Self component");
        BT_LOGD_STR("Creating default clock class object");
 
        clock_class = g_new0(struct bt_clock_class, 1);
index 9a5986228901b0c06c1f45d70beb0e46970b0941..d307094ef12fa643fa693475275fca056a844e85 100644 (file)
@@ -26,6 +26,7 @@
 #include "ctf-meta-visitors.h"
 
 struct ctx {
+       bt_self_component_source *self_comp;
        bt_trace_class *ir_tc;
        bt_stream_class *ir_sc;
        struct ctf_trace_class *tc;
@@ -580,7 +581,9 @@ int ctf_trace_class_to_ir(struct ctx *ctx)
        for (i = 0; i < ctx->tc->clock_classes->len; i++) {
                struct ctf_clock_class *cc = ctx->tc->clock_classes->pdata[i];
 
-               cc->ir_cc = bt_clock_class_create(ctx->ir_tc);
+               cc->ir_cc = bt_clock_class_create(
+                               bt_self_component_source_as_self_component(
+                                       ctx->self_comp));
                ctf_clock_class_to_ir(cc->ir_cc, cc);
        }
 
@@ -594,13 +597,14 @@ end:
 }
 
 BT_HIDDEN
-int ctf_trace_class_translate(bt_trace_class *ir_tc,
-               struct ctf_trace_class *tc)
+int ctf_trace_class_translate(bt_self_component_source *self_comp,
+               bt_trace_class *ir_tc, struct ctf_trace_class *tc)
 {
        int ret = 0;
        uint64_t i;
        struct ctx ctx = { 0 };
 
+       ctx.self_comp = self_comp;
        ctx.tc = tc;
        ctx.ir_tc = ir_tc;
        ret = ctf_trace_class_to_ir(&ctx);
index 846aee9d5530443578236a3ebe5c19e45edd58da..9e835158e9636301055cb2a950b07aaa4be03788 100644 (file)
@@ -24,8 +24,8 @@ BT_HIDDEN
 int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc);
 
 BT_HIDDEN
-int ctf_trace_class_translate(bt_trace_class *ir_tc,
-               struct ctf_trace_class *tc);
+int ctf_trace_class_translate(bt_self_component_source *self_comp,
+               bt_trace_class *ir_tc, struct ctf_trace_class *tc);
 
 BT_HIDDEN
 int ctf_trace_class_update_default_clock_classes(
index ac1d2e9d653c33523a1a9e8b19c745e54e06fd60..a34cbf2619fc69cb6554760273773090515f779e 100644 (file)
@@ -193,6 +193,7 @@ struct ctx_decl_scope {
  * Visitor context (private).
  */
 struct ctx {
+       bt_self_component_source *self_comp;
        /* Trace IR trace class being filled (owned by this) */
        bt_trace_class *trace_class;
 
@@ -590,6 +591,7 @@ struct ctx *ctx_create(bt_self_component_source *self_comp,
                        BT_LOGE_STR("Cannot create empty trace class.");
                        goto error;
                }
+               ctx->self_comp = self_comp;
        }
 
        ctx->ctf_tc = ctf_trace_class_create();
@@ -5068,7 +5070,8 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
 
        if (ctx->trace_class) {
                /* Copy new CTF metadata -> new IR metadata */
-               ret = ctf_trace_class_translate(ctx->trace_class, ctx->ctf_tc);
+               ret = ctf_trace_class_translate(ctx->self_comp,
+                               ctx->trace_class, ctx->ctf_tc);
                if (ret) {
                        ret = -EINVAL;
                        goto end;
index 914ae06361e6db2a583a6c90deb4a88b4d21e5f9..d8afa858c4af47006a1d8d2a51603c0cb4de0c76 100644 (file)
@@ -141,7 +141,8 @@ int create_meta(struct dmesg_component *dmesg_comp, bool has_ts)
 
        if (has_ts) {
                dmesg_comp->clock_class = bt_clock_class_create(
-                       dmesg_comp->trace_class);
+                               bt_self_component_source_as_self_component(
+                                       dmesg_comp->self_comp));
                if (!dmesg_comp->clock_class) {
                        BT_LOGE_STR("Cannot create clock class.");
                        goto error;
This page took 0.029705 seconds and 4 git commands to generate.