tap-driver.sh: flush stdout after each test result
[babeltrace.git] / plugins / ctf / common / metadata / ctf-meta-translate.c
index 1d318ccf0ddf85b62ef757c2e5dee7d742da6e6c..ca3069aee13bd1ab8091b6b9f5078247ad2d890a 100644 (file)
@@ -15,9 +15,9 @@
 #define BT_LOG_TAG "PLUGIN-CTF-METADATA-META-TRANSLATE"
 #include "logging.h"
 
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/assert-internal.h>
 #include <glib.h>
 #include <stdint.h>
 #include <string.h>
@@ -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;
@@ -325,6 +326,16 @@ bool ctf_field_class_struct_has_immediate_member_in_ir(
        uint64_t i;
        bool has_immediate_member_in_ir = false;
 
+       /*
+        * If the structure field class has no members at all, then it
+        * was an empty structure in the beginning, so leave it existing
+        * and empty.
+        */
+       if (fc->members->len == 0) {
+               has_immediate_member_in_ir = true;
+               goto end;
+       }
+
        for (i = 0; i < fc->members->len; i++) {
                struct ctf_named_field_class *named_fc =
                        ctf_field_class_struct_borrow_member_by_index(fc, i);
@@ -370,33 +381,6 @@ bt_field_class *scope_ctf_field_class_to_ir(struct ctx *ctx)
        return ir_fc;
 }
 
-static inline
-struct ctf_field_class_int *borrow_named_int_field_class(
-               struct ctf_field_class_struct *struct_fc, const char *name)
-{
-       struct ctf_named_field_class *named_fc = NULL;
-       struct ctf_field_class_int *int_fc = NULL;
-
-       if (!struct_fc) {
-               goto end;
-       }
-
-       named_fc = ctf_field_class_struct_borrow_member_by_name(struct_fc, name);
-       if (!named_fc) {
-               goto end;
-       }
-
-       if (named_fc->fc->type != CTF_FIELD_CLASS_TYPE_INT &&
-                       named_fc->fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-               goto end;
-       }
-
-       int_fc = (void *) named_fc->fc;
-
-end:
-       return int_fc;
-}
-
 static inline
 void ctf_event_class_to_ir(struct ctx *ctx)
 {
@@ -460,7 +444,6 @@ static inline
 void ctf_stream_class_to_ir(struct ctx *ctx)
 {
        int ret;
-       struct ctf_field_class_int *int_fc;
        bt_field_class *ir_fc;
 
        BT_ASSERT(ctx->sc);
@@ -504,42 +487,16 @@ void ctf_stream_class_to_ir(struct ctx *ctx)
                BT_ASSERT(ret == 0);
        }
 
-       int_fc = borrow_named_int_field_class((void *) ctx->sc->packet_context_fc,
-               "events_discarded");
-       if (int_fc) {
-               if (int_fc->meaning == CTF_FIELD_CLASS_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT) {
-                       bt_stream_class_set_packets_have_discarded_event_counter_snapshot(
-                               ctx->ir_sc, BT_TRUE);
-               }
-       }
-
-       int_fc = borrow_named_int_field_class((void *) ctx->sc->packet_context_fc,
-               "packet_seq_num");
-       if (int_fc) {
-               if (int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_COUNTER_SNAPSHOT) {
-                       bt_stream_class_set_packets_have_packet_counter_snapshot(
-                               ctx->ir_sc, BT_TRUE);
-               }
-       }
-
-       int_fc = borrow_named_int_field_class((void *) ctx->sc->packet_context_fc,
-               "timestamp_begin");
-       if (int_fc) {
-               if (int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_BEGINNING_TIME) {
-                       bt_stream_class_set_packets_have_default_beginning_clock_snapshot(
-                               ctx->ir_sc, BT_TRUE);
-               }
-       }
-
-       int_fc = borrow_named_int_field_class((void *) ctx->sc->packet_context_fc,
-               "timestamp_end");
-       if (int_fc) {
-               if (int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_END_TIME) {
-                       bt_stream_class_set_packets_have_default_end_clock_snapshot(
-                               ctx->ir_sc, BT_TRUE);
-               }
-       }
-
+       bt_stream_class_set_packets_have_beginning_default_clock_snapshot(
+               ctx->ir_sc, ctx->sc->packets_have_ts_begin);
+       bt_stream_class_set_packets_have_end_default_clock_snapshot(
+               ctx->ir_sc, ctx->sc->packets_have_ts_end);
+       bt_stream_class_set_supports_discarded_events(ctx->ir_sc,
+               ctx->sc->has_discarded_events,
+               ctx->sc->discarded_events_have_default_cs);
+       bt_stream_class_set_supports_discarded_packets(ctx->ir_sc,
+               ctx->sc->has_discarded_packets,
+               ctx->sc->discarded_packets_have_default_cs);
        ctx->sc->is_translated = true;
        ctx->sc->ir_sc = ctx->ir_sc;
 
@@ -570,7 +527,7 @@ void ctf_clock_class_to_ir(bt_clock_class *ir_cc, struct ctf_clock_class *cc)
                bt_clock_class_set_uuid(ir_cc, cc->uuid);
        }
 
-       bt_clock_class_set_is_absolute(ir_cc, cc->is_absolute);
+       bt_clock_class_set_origin_is_unix_epoch(ir_cc, cc->is_absolute);
 }
 
 static inline
@@ -617,7 +574,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);
        }
 
@@ -631,13 +590,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);
This page took 0.026669 seconds and 4 git commands to generate.