X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fplugins%2Fctf%2Fcommon%2Fsrc%2Fmetadata%2Ftsdl%2Fctf-meta-validate.cpp;h=cb4e2b8877896cf79c3a9d472a4512d81eda3244;hb=0f5c5d5ce30884c93b4e4d0662e2914029c3e90f;hp=9a01c593649d684f3d2614f1f753d60d6a513529;hpb=644c6ca70640ef866d636a634ceb1488fed09b53;p=babeltrace.git diff --git a/src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-validate.cpp b/src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-validate.cpp index 9a01c593..cb4e2b88 100644 --- a/src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-validate.cpp +++ b/src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-validate.cpp @@ -4,17 +4,13 @@ * Copyright 2018 Philippe Proulx */ -#include +#include -#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.hpp" +#include "cpp-common/bt2c/logging.hpp" #include "ctf-meta-visitors.hpp" -static int validate_stream_class(struct ctf_stream_class *sc, struct meta_log_config *log_cfg) +static int validate_stream_class(struct ctf_stream_class *sc, const bt2c::Logger& logger) { int ret = 0; struct ctf_field_class_int *int_fc; @@ -28,17 +24,17 @@ static int validate_stream_class(struct ctf_stream_class *sc, struct meta_log_co ctf_field_class_as_struct(sc->packet_context_fc), "timestamp_begin"); if (fc) { if (fc->type != CTF_FIELD_CLASS_TYPE_INT && fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE( - "Invalid packet context field class: " - "`timestamp_begin` member is not an integer field class."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, + "Invalid packet context field class: " + "`timestamp_begin` member is not an integer field class."); goto invalid; } int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: " - "`timestamp_begin` member is signed."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "Invalid packet context field class: " + "`timestamp_begin` member is signed."); goto invalid; } } @@ -47,17 +43,17 @@ static int validate_stream_class(struct ctf_stream_class *sc, struct meta_log_co ctf_field_class_as_struct(sc->packet_context_fc), "timestamp_end"); if (fc) { if (fc->type != CTF_FIELD_CLASS_TYPE_INT && fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE( - "Invalid packet context field class: " - "`timestamp_end` member is not an integer field class."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, + "Invalid packet context field class: " + "`timestamp_end` member is not an integer field class."); goto invalid; } int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: " - "`timestamp_end` member is signed."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "Invalid packet context field class: " + "`timestamp_end` member is signed."); goto invalid; } } @@ -66,17 +62,17 @@ static int validate_stream_class(struct ctf_stream_class *sc, struct meta_log_co ctf_field_class_as_struct(sc->packet_context_fc), "events_discarded"); if (fc) { if (fc->type != CTF_FIELD_CLASS_TYPE_INT && fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE( - "Invalid packet context field class: " - "`events_discarded` member is not an integer field class."); + BT_CPPLOGE_APPEND_CAUSE_SPEC( + logger, "Invalid packet context field class: " + "`events_discarded` member is not an integer field class."); goto invalid; } int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: " - "`events_discarded` member is signed."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "Invalid packet context field class: " + "`events_discarded` member is signed."); goto invalid; } } @@ -85,17 +81,17 @@ static int validate_stream_class(struct ctf_stream_class *sc, struct meta_log_co ctf_field_class_as_struct(sc->packet_context_fc), "packet_seq_num"); if (fc) { if (fc->type != CTF_FIELD_CLASS_TYPE_INT && fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE( - "Invalid packet context field class: " - "`packet_seq_num` member is not an integer field class."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, + "Invalid packet context field class: " + "`packet_seq_num` member is not an integer field class."); goto invalid; } int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: " - "`packet_seq_num` member is signed."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "Invalid packet context field class: " + "`packet_seq_num` member is signed."); goto invalid; } } @@ -104,17 +100,17 @@ static int validate_stream_class(struct ctf_stream_class *sc, struct meta_log_co ctf_field_class_as_struct(sc->packet_context_fc), "packet_size"); if (fc) { if (fc->type != CTF_FIELD_CLASS_TYPE_INT && fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE( - "Invalid packet context field class: " - "`packet_size` member is not an integer field class."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, + "Invalid packet context field class: " + "`packet_size` member is not an integer field class."); goto invalid; } int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: " - "`packet_size` member is signed."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "Invalid packet context field class: " + "`packet_size` member is signed."); goto invalid; } } @@ -123,17 +119,17 @@ static int validate_stream_class(struct ctf_stream_class *sc, struct meta_log_co ctf_field_class_as_struct(sc->packet_context_fc), "content_size"); if (fc) { if (fc->type != CTF_FIELD_CLASS_TYPE_INT && fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE( - "Invalid packet context field class: " - "`content_size` member is not an integer field class."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, + "Invalid packet context field class: " + "`content_size` member is not an integer field class."); goto invalid; } int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet context field class: " - "`content_size` member is signed."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "Invalid packet context field class: " + "`content_size` member is signed."); goto invalid; } } @@ -142,23 +138,23 @@ static int validate_stream_class(struct ctf_stream_class *sc, struct meta_log_co ctf_field_class_as_struct(sc->event_header_fc), "id"); if (fc) { if (fc->type != CTF_FIELD_CLASS_TYPE_INT && fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid event header field class: " - "`id` member is not an integer field class."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "Invalid event header field class: " + "`id` member is not an integer field class."); goto invalid; } int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid event header field class: " - "`id` member is signed."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "Invalid event header field class: " + "`id` member is signed."); goto invalid; } } else { if (sc->event_classes->len > 1) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid event header field class: " - "missing `id` member as there's " - "more than one event class."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "Invalid event header field class: " + "missing `id` member as there's " + "more than one event class."); goto invalid; } } @@ -172,12 +168,14 @@ end: return ret; } -int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, struct meta_log_config *log_cfg) +int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, const bt2c::Logger& parentLogger) { int ret = 0; struct ctf_field_class_int *int_fc; uint64_t i; + bt2c::Logger logger {parentLogger, "PLUGIN/CTF/META/VALIDATE"}; + if (!ctf_tc->is_translated) { struct ctf_field_class *fc; @@ -188,29 +186,29 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, struct meta_log_con ctf_field_class_as_struct(ctf_tc->packet_header_fc), 0); if (named_fc->fc != fc) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: " - "`magic` member is not the first member."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "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_OR_COMP_CLASS_LOGE_APPEND_CAUSE( - "Invalid packet header field class: " - "`magic` member is not an integer field class."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, + "Invalid packet header field class: " + "`magic` member is not an integer field class."); goto invalid; } int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: " - "`magic` member is signed."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "Invalid packet header field class: " + "`magic` member is signed."); goto invalid; } if (int_fc->base.size != 32) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: " - "`magic` member is not 32-bit."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "Invalid packet header field class: " + "`magic` member is not 32-bit."); goto invalid; } } @@ -219,24 +217,24 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, struct meta_log_con ctf_field_class_as_struct(ctf_tc->packet_header_fc), "stream_id"); if (fc) { if (fc->type != CTF_FIELD_CLASS_TYPE_INT && fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE( - "Invalid packet header field class: " - "`stream_id` member is not an integer field class."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, + "Invalid packet header field class: " + "`stream_id` member is not an integer field class."); goto invalid; } int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: " - "`stream_id` member is signed."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "Invalid packet header field class: " + "`stream_id` member is signed."); goto invalid; } } else { if (ctf_tc->stream_classes->len > 1) { - _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."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "Invalid packet header field class: " + "missing `stream_id` member as there's " + "more than one stream class."); goto invalid; } } @@ -245,17 +243,17 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, struct meta_log_con ctf_field_class_as_struct(ctf_tc->packet_header_fc), "stream_instance_id"); if (fc) { if (fc->type != CTF_FIELD_CLASS_TYPE_INT && fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE( - "Invalid packet header field class: " - "`stream_instance_id` member is not an integer field class."); + BT_CPPLOGE_APPEND_CAUSE_SPEC( + logger, "Invalid packet header field class: " + "`stream_instance_id` member is not an integer field class."); goto invalid; } int_fc = ctf_field_class_as_int(fc); if (int_fc->is_signed) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: " - "`stream_instance_id` member is signed."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "Invalid packet header field class: " + "`stream_instance_id` member is signed."); goto invalid; } } @@ -264,49 +262,47 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, struct meta_log_con ctf_field_class_as_struct(ctf_tc->packet_header_fc), "uuid"); if (fc) { if (fc->type != CTF_FIELD_CLASS_TYPE_ARRAY) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE( - "Invalid packet header field class: " - "`uuid` member is not an array field class."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "Invalid packet header field class: " + "`uuid` member is not an array field class."); goto invalid; } ctf_field_class_array *array_fc = ctf_field_class_as_array(fc); if (array_fc->length != 16) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE( - "Invalid packet header field class: " - "`uuid` member is not a 16-element array field class."); + BT_CPPLOGE_APPEND_CAUSE_SPEC( + logger, "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_OR_COMP_CLASS_LOGE_APPEND_CAUSE( - "Invalid packet header field class: " - "`uuid` member's element field class is not " - "an integer field class."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "Invalid packet header field class: " + "`uuid` member's element field class is not " + "an integer field class."); goto invalid; } int_fc = ctf_field_class_as_int(array_fc->base.elem_fc); if (int_fc->is_signed) { - _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."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "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_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."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "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_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid packet header field class: " - "`uuid` member's element field class's " - "alignment is not 8."); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "Invalid packet header field class: " + "`uuid` member's element field class's " + "alignment is not 8."); goto invalid; } } @@ -315,10 +311,9 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, struct meta_log_con for (i = 0; i < ctf_tc->stream_classes->len; i++) { struct ctf_stream_class *sc = (ctf_stream_class *) ctf_tc->stream_classes->pdata[i]; - ret = validate_stream_class(sc, log_cfg); + ret = validate_stream_class(sc, logger); if (ret) { - _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Invalid stream class: sc-id=%" PRIu64, - sc->id); + BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "Invalid stream class: sc-id={}", sc->id); goto invalid; } }