ctf: append error causes when returning errors
[babeltrace.git] / src / plugins / ctf / common / metadata / ctf-meta-validate.c
index 10f65da84875b0bd76bd93581646952beb5412c8..da5c95c27ec0908361be5a7bf55dffc91882d7fb 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 #define BT_COMP_LOG_SELF_COMP (log_cfg->self_comp)
+#define BT_COMP_LOG_SELF_COMP_CLASS (log_cfg->self_comp_class)
 #define BT_LOG_OUTPUT_LEVEL (log_cfg->log_level)
 #define BT_LOG_TAG "PLUGIN/CTF/META/VALIDATE"
 #include "logging/comp-logging.h"
@@ -37,7 +38,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
        if (fc) {
                if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                       BT_COMP_LOGE_STR("Invalid packet context field class: "
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: "
                                "`timestamp_begin` member is not an integer field class.");
                        goto invalid;
                }
@@ -45,7 +46,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
                int_fc = (void *) fc;
 
                if (int_fc->is_signed) {
-                       BT_COMP_LOGE_STR("Invalid packet context field class: "
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: "
                                "`timestamp_begin` member is signed.");
                        goto invalid;
                }
@@ -56,7 +57,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
        if (fc) {
                if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                       BT_COMP_LOGE_STR("Invalid packet context field class: "
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: "
                                "`timestamp_end` member is not an integer field class.");
                        goto invalid;
                }
@@ -64,7 +65,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
                int_fc = (void *) fc;
 
                if (int_fc->is_signed) {
-                       BT_COMP_LOGE_STR("Invalid packet context field class: "
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: "
                                "`timestamp_end` member is signed.");
                        goto invalid;
                }
@@ -75,7 +76,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
        if (fc) {
                if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                       BT_COMP_LOGE_STR("Invalid packet context field class: "
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: "
                                "`events_discarded` member is not an integer field class.");
                        goto invalid;
                }
@@ -83,7 +84,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
                int_fc = (void *) fc;
 
                if (int_fc->is_signed) {
-                       BT_COMP_LOGE_STR("Invalid packet context field class: "
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: "
                                "`events_discarded` member is signed.");
                        goto invalid;
                }
@@ -94,7 +95,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
        if (fc) {
                if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                       BT_COMP_LOGE_STR("Invalid packet context field class: "
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: "
                                "`packet_seq_num` member is not an integer field class.");
                        goto invalid;
                }
@@ -102,7 +103,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
                int_fc = (void *) fc;
 
                if (int_fc->is_signed) {
-                       BT_COMP_LOGE_STR("Invalid packet context field class: "
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: "
                                "`packet_seq_num` member is signed.");
                        goto invalid;
                }
@@ -113,7 +114,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
        if (fc) {
                if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                       BT_COMP_LOGE_STR("Invalid packet context field class: "
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: "
                                "`packet_size` member is not an integer field class.");
                        goto invalid;
                }
@@ -121,7 +122,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
                int_fc = (void *) fc;
 
                if (int_fc->is_signed) {
-                       BT_COMP_LOGE_STR("Invalid packet context field class: "
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: "
                                "`packet_size` member is signed.");
                        goto invalid;
                }
@@ -132,7 +133,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
        if (fc) {
                if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                       BT_COMP_LOGE_STR("Invalid packet context field class: "
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: "
                                "`content_size` member is not an integer field class.");
                        goto invalid;
                }
@@ -140,7 +141,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
                int_fc = (void *) fc;
 
                if (int_fc->is_signed) {
-                       BT_COMP_LOGE_STR("Invalid packet context field class: "
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: "
                                "`content_size` member is signed.");
                        goto invalid;
                }
@@ -151,7 +152,7 @@ int validate_stream_class(struct ctf_stream_class *sc,
        if (fc) {
                if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                       BT_COMP_LOGE_STR("Invalid event header field class: "
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid event header field class: "
                                "`id` member is not an integer field class.");
                        goto invalid;
                }
@@ -159,13 +160,13 @@ int validate_stream_class(struct ctf_stream_class *sc,
                int_fc = (void *) fc;
 
                if (int_fc->is_signed) {
-                       BT_COMP_LOGE_STR("Invalid event header field class: "
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid event header field class: "
                                "`id` member is signed.");
                        goto invalid;
                }
        } else {
                if (sc->event_classes->len > 1) {
-                       BT_COMP_LOGE_STR("Invalid event header field class: "
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid event header field class: "
                                "missing `id` member as there's "
                                "more than one event class.");
                        goto invalid;
@@ -201,14 +202,14 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
                                        0);
 
                        if (named_fc->fc != fc) {
-                               BT_COMP_LOGE_STR("Invalid packet header field class: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: "
                                        "`magic` member is not the first member.");
                                goto invalid;
                        }
 
                        if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                        fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                               BT_COMP_LOGE_STR("Invalid packet header field class: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: "
                                        "`magic` member is not an integer field class.");
                                goto invalid;
                        }
@@ -216,13 +217,13 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
                        int_fc = (void *) fc;
 
                        if (int_fc->is_signed) {
-                               BT_COMP_LOGE_STR("Invalid packet header field class: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: "
                                        "`magic` member is signed.");
                                goto invalid;
                        }
 
                        if (int_fc->base.size != 32) {
-                               BT_COMP_LOGE_STR("Invalid packet header field class: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: "
                                        "`magic` member is not 32-bit.");
                                goto invalid;
                        }
@@ -233,7 +234,7 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
                if (fc) {
                        if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                        fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                               BT_COMP_LOGE_STR("Invalid packet header field class: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: "
                                        "`stream_id` member is not an integer field class.");
                                goto invalid;
                        }
@@ -241,13 +242,13 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
                        int_fc = (void *) fc;
 
                        if (int_fc->is_signed) {
-                               BT_COMP_LOGE_STR("Invalid packet header field class: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: "
                                        "`stream_id` member is signed.");
                                goto invalid;
                        }
                } else {
                        if (ctf_tc->stream_classes->len > 1) {
-                               BT_COMP_LOGE_STR("Invalid packet header field class: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: "
                                        "missing `stream_id` member as there's "
                                        "more than one stream class.");
                                goto invalid;
@@ -260,7 +261,7 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
                if (fc) {
                        if (fc->type != CTF_FIELD_CLASS_TYPE_INT &&
                                        fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
-                               BT_COMP_LOGE_STR("Invalid packet header field class: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: "
                                        "`stream_instance_id` member is not an integer field class.");
                                goto invalid;
                        }
@@ -268,7 +269,7 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
                        int_fc = (void *) fc;
 
                        if (int_fc->is_signed) {
-                               BT_COMP_LOGE_STR("Invalid packet header field class: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: "
                                        "`stream_instance_id` member is signed.");
                                goto invalid;
                        }
@@ -280,7 +281,7 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
                        struct ctf_field_class_array *array_fc = (void *) fc;
 
                        if (fc->type != CTF_FIELD_CLASS_TYPE_ARRAY) {
-                               BT_COMP_LOGE_STR("Invalid packet header field class: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: "
                                        "`uuid` member is not an array field class.");
                                goto invalid;
                        }
@@ -288,13 +289,13 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
                        array_fc = (void *) fc;
 
                        if (array_fc->length != 16) {
-                               BT_COMP_LOGE_STR("Invalid packet header field class: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: "
                                        "`uuid` member is not a 16-element array field class.");
                                goto invalid;
                        }
 
                        if (array_fc->base.elem_fc->type != CTF_FIELD_CLASS_TYPE_INT) {
-                               BT_COMP_LOGE_STR("Invalid packet header field class: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: "
                                        "`uuid` member's element field class is not "
                                        "an integer field class.");
                                goto invalid;
@@ -303,21 +304,21 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
                        int_fc = (void *) array_fc->base.elem_fc;
 
                        if (int_fc->is_signed) {
-                               BT_COMP_LOGE_STR("Invalid packet header field class: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: "
                                        "`uuid` member's element field class "
                                        "is a signed integer field class.");
                                goto invalid;
                        }
 
                        if (int_fc->base.size != 8) {
-                               BT_COMP_LOGE_STR("Invalid packet header field class: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: "
                                        "`uuid` member's element field class "
                                        "is not an 8-bit integer field class.");
                                goto invalid;
                        }
 
                        if (int_fc->base.base.alignment != 8) {
-                               BT_COMP_LOGE_STR("Invalid packet header field class: "
+                               _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: "
                                        "`uuid` member's element field class's "
                                        "alignment is not 8.");
                                goto invalid;
@@ -331,7 +332,7 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
 
                ret = validate_stream_class(sc, log_cfg);
                if (ret) {
-                       BT_COMP_LOGE("Invalid stream class: sc-id=%" PRIu64, sc->id);
+                       _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid stream class: sc-id=%" PRIu64, sc->id);
                        goto invalid;
                }
        }
This page took 0.028354 seconds and 4 git commands to generate.