From f7b785acaab5692fd58bb3b2db7da23fc307931b Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Tue, 18 Jun 2019 14:38:53 -0400 Subject: [PATCH] `ctf` plugin: metadata: use BT_COMP_LOG*() instead of BT_LOG*() Because we need to pass around the log level and the self component pointer at several places within the files of this directory, this patch adds a new internal `struct meta_log_config` which contains both and can be passed as a single parameter and contained as a single member. It is not meant to be known by anything calling the functions from files outside this directory. The generated parser and lexer can't use the BT_COMP_LOG*() macros because they lack contextual data to access the self component pointer, so they are left as is. Signed-off-by: Philippe Proulx Change-Id: Ifa95256e7931416b890e8da0bb7c2552f396a8d2 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1499 --- src/plugins/ctf/common/metadata/ast.h | 7 +- .../ctf/common/metadata/ctf-meta-resolve.c | 112 ++-- .../ctf/common/metadata/ctf-meta-translate.c | 8 +- .../ctf-meta-update-default-clock-classes.c | 36 +- .../ctf/common/metadata/ctf-meta-validate.c | 74 +-- .../ctf/common/metadata/ctf-meta-visitors.h | 13 +- .../ctf-meta-warn-meaningless-header-fields.c | 28 +- src/plugins/ctf/common/metadata/decoder.c | 124 ++-- src/plugins/ctf/common/metadata/decoder.h | 11 +- src/plugins/ctf/common/metadata/logging.h | 21 + .../ctf/common/metadata/visitor-generate-ir.c | 549 +++++++++--------- .../common/metadata/visitor-parent-links.c | 109 ++-- .../metadata/visitor-semantic-validator.c | 157 ++--- src/plugins/ctf/fs-src/metadata.c | 5 +- src/plugins/ctf/fs-src/query.c | 4 +- src/plugins/ctf/lttng-live/metadata.c | 6 +- 16 files changed, 653 insertions(+), 611 deletions(-) diff --git a/src/plugins/ctf/common/metadata/ast.h b/src/plugins/ctf/common/metadata/ast.h index 52f2006e..6b305e53 100644 --- a/src/plugins/ctf/common/metadata/ast.h +++ b/src/plugins/ctf/common/metadata/ast.h @@ -316,9 +316,10 @@ struct ctf_ast { const char *node_type(struct ctf_node *node); +struct meta_log_config; + BT_HIDDEN struct ctf_visitor_generate_ir *ctf_visitor_generate_ir_create( - bt_self_component_source *self_comp, const struct ctf_metadata_decoder_config *config); void ctf_visitor_generate_ir_destroy(struct ctf_visitor_generate_ir *visitor); @@ -337,10 +338,10 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, BT_HIDDEN int ctf_visitor_semantic_check(int depth, struct ctf_node *node, - bt_logging_level log_level); + struct meta_log_config *log_cfg); BT_HIDDEN int ctf_visitor_parent_links(int depth, struct ctf_node *node, - bt_logging_level log_level); + struct meta_log_config *log_cfg); #endif /* _CTF_AST_H */ diff --git a/src/plugins/ctf/common/metadata/ctf-meta-resolve.c b/src/plugins/ctf/common/metadata/ctf-meta-resolve.c index 4b6590f0..184805d9 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-resolve.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-resolve.c @@ -13,9 +13,10 @@ * all copies or substantial portions of the Software. */ +#define BT_COMP_LOG_SELF_COMP (ctx->self_comp) #define BT_LOG_OUTPUT_LEVEL (ctx->log_level) #define BT_LOG_TAG "PLUGIN/CTF/META/RESOLVE" -#include "logging/log.h" +#include "plugins/comp-logging.h" #include #include "common/macros.h" @@ -30,6 +31,7 @@ #include #include "ctf-meta-visitors.h" +#include "logging.h" typedef GPtrArray field_class_stack; @@ -52,6 +54,7 @@ struct field_class_stack_frame { */ struct resolve_context { bt_logging_level log_level; + bt_self_component *self_comp; struct ctf_trace_class *tc; struct ctf_stream_class *sc; struct ctf_event_class *ec; @@ -133,19 +136,19 @@ int field_class_stack_push(field_class_stack *stack, struct ctf_field_class *fc, struct field_class_stack_frame *frame = NULL; if (!stack || !fc) { - BT_LOGE("Invalid parameter: stack or field class is NULL."); + BT_COMP_LOGE("Invalid parameter: stack or field class is NULL."); ret = -1; goto end; } frame = g_new0(struct field_class_stack_frame, 1); if (!frame) { - BT_LOGE_STR("Failed to allocate one field class stack frame."); + BT_COMP_LOGE_STR("Failed to allocate one field class stack frame."); ret = -1; goto end; } - BT_LOGD("Pushing field class on context's stack: " + BT_COMP_LOGD("Pushing field class on context's stack: " "fc-addr=%p, stack-size-before=%u", fc, stack->len); frame->fc = fc; g_ptr_array_add(stack, frame); @@ -220,7 +223,7 @@ void field_class_stack_pop(field_class_stack *stack, * This will call the frame's destructor and free it, as * well as put its contained field class. */ - BT_LOGD("Popping context's stack: stack-size-before=%u", + BT_COMP_LOGD("Popping context's stack: stack-size-before=%u", stack->len); g_ptr_array_set_size(stack, stack->len - 1); } @@ -277,7 +280,7 @@ enum ctf_scope get_root_scope_from_absolute_pathstr(const char *pathstr, if (strncmp(pathstr, absolute_path_prefixes[scope], strlen(absolute_path_prefixes[scope]))) { /* Prefix does not match: try the next one */ - BT_LOGD("Prefix does not match: trying the next one: " + BT_COMP_LOGD("Prefix does not match: trying the next one: " "path=\"%s\", path-prefix=\"%s\", scope=%s", pathstr, absolute_path_prefixes[scope], ctf_scope_string(scope)); @@ -286,7 +289,7 @@ enum ctf_scope get_root_scope_from_absolute_pathstr(const char *pathstr, /* Found it! */ ret = scope; - BT_LOGD("Found root scope from absolute path: " + BT_COMP_LOGD("Found root scope from absolute path: " "path=\"%s\", scope=%s", pathstr, ctf_scope_string(scope)); goto end; @@ -348,7 +351,7 @@ GList *pathstr_to_ptokens(const char *pathstr, struct resolve_context *ctx) if (at == last) { /* Error: empty token */ - BT_LOGE("Empty path token: path=\"%s\", pos=%u", + BT_COMP_LOGE("Empty path token: path=\"%s\", pos=%u", pathstr, (unsigned int) (at - pathstr)); goto error; } @@ -397,7 +400,7 @@ int ptokens_to_field_path(GList *ptokens, struct ctf_field_path *field_path, struct ctf_field_class *child_fc; const char *ft_name = ptoken_get_string(cur_ptoken); - BT_LOGD("Current path token: token=\"%s\"", ft_name); + BT_COMP_LOGD("Current path token: token=\"%s\"", ft_name); /* Find to which index corresponds the current path token */ if (fc->type == CTF_FIELD_CLASS_TYPE_ARRAY || @@ -412,7 +415,7 @@ int ptokens_to_field_path(GList *ptokens, struct ctf_field_path *field_path, * Error: field name does not exist or * wrong current class. */ - BT_LOGD("Cannot get index of field class: " + BT_COMP_LOGD("Cannot get index of field class: " "field-name=\"%s\", " "src-index=%" PRId64 ", " "child-index=%" PRId64 ", " @@ -423,7 +426,7 @@ int ptokens_to_field_path(GList *ptokens, struct ctf_field_path *field_path, goto end; } else if (child_index > src_index && !first_level_done) { - BT_LOGD("Child field class is located after source field class: " + BT_COMP_LOGD("Child field class is located after source field class: " "field-name=\"%s\", " "src-index=%" PRId64 ", " "child-index=%" PRId64 ", " @@ -478,7 +481,7 @@ int absolute_ptokens_to_field_path(GList *ptokens, switch (field_path->root) { case CTF_SCOPE_PACKET_HEADER: if (ctx->tc->is_translated) { - BT_LOGE("Trace class is already translated: " + BT_COMP_LOGE("Trace class is already translated: " "root-scope=%s", ctf_scope_string(field_path->root)); ret = -1; @@ -490,7 +493,7 @@ int absolute_ptokens_to_field_path(GList *ptokens, case CTF_SCOPE_EVENT_HEADER: case CTF_SCOPE_EVENT_COMMON_CONTEXT: if (!ctx->sc) { - BT_LOGE("No current stream class: " + BT_COMP_LOGE("No current stream class: " "root-scope=%s", ctf_scope_string(field_path->root)); ret = -1; @@ -498,7 +501,7 @@ int absolute_ptokens_to_field_path(GList *ptokens, } if (ctx->sc->is_translated) { - BT_LOGE("Stream class is already translated: " + BT_COMP_LOGE("Stream class is already translated: " "root-scope=%s", ctf_scope_string(field_path->root)); ret = -1; @@ -509,7 +512,7 @@ int absolute_ptokens_to_field_path(GList *ptokens, case CTF_SCOPE_EVENT_SPECIFIC_CONTEXT: case CTF_SCOPE_EVENT_PAYLOAD: if (!ctx->ec) { - BT_LOGE("No current event class: " + BT_COMP_LOGE("No current event class: " "root-scope=%s", ctf_scope_string(field_path->root)); ret = -1; @@ -517,7 +520,7 @@ int absolute_ptokens_to_field_path(GList *ptokens, } if (ctx->ec->is_translated) { - BT_LOGE("Event class is already translated: " + BT_COMP_LOGE("Event class is already translated: " "root-scope=%s", ctf_scope_string(field_path->root)); ret = -1; @@ -538,7 +541,7 @@ int absolute_ptokens_to_field_path(GList *ptokens, fc = borrow_class_from_ctx(ctx, field_path->root); if (!fc) { /* Error: root class is not available */ - BT_LOGE("Root field class is not available: " + BT_COMP_LOGE("Root field class is not available: " "root-scope=%s", ctf_scope_string(field_path->root)); ret = -1; @@ -577,7 +580,7 @@ int relative_ptokens_to_field_path(GList *ptokens, int64_t cur_index = field_class_stack_at(ctx->field_class_stack, parent_pos_in_stack)->index; - BT_LOGD("Locating target field class from current parent field class: " + BT_COMP_LOGD("Locating target field class from current parent field class: " "parent-pos=%" PRId64 ", parent-fc-addr=%p, " "cur-index=%" PRId64, parent_pos_in_stack, parent_class, cur_index); @@ -587,7 +590,7 @@ int relative_ptokens_to_field_path(GList *ptokens, parent_class, cur_index, ctx); if (ret) { /* Not found... yet */ - BT_LOGD_STR("Not found at this point."); + BT_COMP_LOGD_STR("Not found at this point."); ctf_field_path_clear(&tail_field_path); } else { /* Found: stitch tail field path to head field path */ @@ -649,7 +652,7 @@ int pathstr_to_field_path(const char *pathstr, /* Convert path string to path tokens */ ptokens = pathstr_to_ptokens(pathstr, ctx); if (!ptokens) { - BT_LOGE("Cannot convert path string to path tokens: " + BT_COMP_LOGE("Cannot convert path string to path tokens: " "path=\"%s\"", pathstr); ret = -1; goto end; @@ -661,11 +664,11 @@ int pathstr_to_field_path(const char *pathstr, if (root_scope == -1) { /* Relative path: start with current root scope */ field_path->root = ctx->root_scope; - BT_LOGD("Detected relative path: starting with current root scope: " + BT_COMP_LOGD("Detected relative path: starting with current root scope: " "scope=%s", ctf_scope_string(field_path->root)); ret = relative_ptokens_to_field_path(ptokens, field_path, ctx); if (ret) { - BT_LOGE("Cannot get relative field path of path string: " + BT_COMP_LOGE("Cannot get relative field path of path string: " "path=\"%s\", start-scope=%s, end-scope=%s", pathstr, ctf_scope_string(ctx->root_scope), ctf_scope_string(field_path->root)); @@ -674,11 +677,11 @@ int pathstr_to_field_path(const char *pathstr, } else { /* Absolute path: use found root scope */ field_path->root = root_scope; - BT_LOGD("Detected absolute path: using root scope: " + BT_COMP_LOGD("Detected absolute path: using root scope: " "scope=%s", ctf_scope_string(field_path->root)); ret = absolute_ptokens_to_field_path(ptokens, field_path, ctx); if (ret) { - BT_LOGE("Cannot get absolute field path of path string: " + BT_COMP_LOGE("Cannot get absolute field path of path string: " "path=\"%s\", root-scope=%s", pathstr, ctf_scope_string(root_scope)); goto end; @@ -690,7 +693,7 @@ int pathstr_to_field_path(const char *pathstr, const char *field_path_pretty_str = field_path_pretty ? field_path_pretty->str : NULL; - BT_LOGD("Found field path: path=\"%s\", field-path=\"%s\"", + BT_COMP_LOGD("Found field path: path=\"%s\", field-path=\"%s\"", pathstr, field_path_pretty_str); if (field_path_pretty) { @@ -718,7 +721,7 @@ struct ctf_field_class *field_path_to_field_class( fc = borrow_class_from_ctx(ctx, field_path->root); if (!fc) { /* Error: root class is not available */ - BT_LOGE("Root field class is not available: root-scope=%s", + BT_COMP_LOGE("Root field class is not available: root-scope=%s", ctf_scope_string(field_path->root)); goto end; } @@ -784,7 +787,7 @@ int64_t get_field_paths_lca_index(struct ctf_field_path *field_path1, const char *field_path2_pretty_str = field_path2_pretty ? field_path2_pretty->str : NULL; - BT_LOGD("Finding lowest common ancestor (LCA) between two field paths: " + BT_COMP_LOGD("Finding lowest common ancestor (LCA) between two field paths: " "field-path-1=\"%s\", field-path-2=\"%s\"", field_path1_pretty_str, field_path2_pretty_str); @@ -814,7 +817,7 @@ int64_t get_field_paths_lca_index(struct ctf_field_path *field_path1, * This is invalid because the target cannot be * an ancestor of the source. */ - BT_LOGE("Source field class is an ancestor of target field class or vice versa: " + BT_COMP_LOGE("Source field class is an ancestor of target field class or vice versa: " "lca-index=%" PRId64 ", " "field-path-1-len=%" PRIu64 ", " "field-path-2-len=%" PRIu64, @@ -836,7 +839,7 @@ int64_t get_field_paths_lca_index(struct ctf_field_path *field_path1, lca_index++; } - BT_LOGD("Found LCA: lca-index=%" PRId64, lca_index); + BT_COMP_LOGD("Found LCA: lca-index=%" PRId64, lca_index); return lca_index; } @@ -861,7 +864,7 @@ int validate_target_field_path(struct ctf_field_path *target_field_path, * Make sure the target is not a root. */ if (target_field_path_len == 0) { - BT_LOGE_STR("Target field path's length is 0 (targeting the root)."); + BT_COMP_LOGE_STR("Target field path's length is 0 (targeting the root)."); ret = -1; goto end; } @@ -871,7 +874,7 @@ int validate_target_field_path(struct ctf_field_path *target_field_path, * after the context field path's root. */ if (target_field_path->root > ctx_field_path.root) { - BT_LOGE("Target field class is located after source field class: " + BT_COMP_LOGE("Target field class is located after source field class: " "target-root=%s, source-root=%s", ctf_scope_string(target_field_path->root), ctf_scope_string(ctx_field_path.root)); @@ -889,7 +892,7 @@ int validate_target_field_path(struct ctf_field_path *target_field_path, lca_index = get_field_paths_lca_index(target_field_path, &ctx_field_path, ctx); if (lca_index < 0) { - BT_LOGE_STR("Cannot get least common ancestor."); + BT_COMP_LOGE_STR("Cannot get least common ancestor."); ret = -1; goto end; } @@ -904,7 +907,7 @@ int validate_target_field_path(struct ctf_field_path *target_field_path, &ctx_field_path, (uint64_t) lca_index); if (target_index >= ctx_index) { - BT_LOGE("Target field class's index is greater than or equal to source field class's index in LCA: " + BT_COMP_LOGE("Target field class's index is greater than or equal to source field class's index in LCA: " "lca-index=%" PRId64 ", " "target-index=%" PRId64 ", " "source-index=%" PRId64, @@ -920,7 +923,7 @@ int validate_target_field_path(struct ctf_field_path *target_field_path, switch (ctx->cur_fc->type) { case CTF_FIELD_CLASS_TYPE_VARIANT: if (target_fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { - BT_LOGE("Variant field class's tag field class is not an enumeration field class: " + BT_COMP_LOGE("Variant field class's tag field class is not an enumeration field class: " "tag-fc-addr=%p, tag-fc-id=%d", target_fc, target_fc->type); ret = -1; @@ -933,7 +936,7 @@ int validate_target_field_path(struct ctf_field_path *target_field_path, if (target_fc->type != CTF_FIELD_CLASS_TYPE_INT && target_fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { - BT_LOGE("Sequence field class's length field class is not an unsigned integer field class: " + BT_COMP_LOGE("Sequence field class's length field class is not an unsigned integer field class: " "length-fc-addr=%p, length-fc-id=%d", target_fc, target_fc->type); ret = -1; @@ -941,7 +944,7 @@ int validate_target_field_path(struct ctf_field_path *target_field_path, } if (int_fc->is_signed) { - BT_LOGE("Sequence field class's length field class is not an unsigned integer field class: " + BT_COMP_LOGE("Sequence field class's length field class is not an unsigned integer field class: " "length-fc-addr=%p, length-fc-id=%d", target_fc, target_fc->type); ret = -1; @@ -993,7 +996,7 @@ int resolve_sequence_or_variant_field_class(struct ctf_field_class *fc, } if (!pathstr) { - BT_LOGE_STR("Cannot get path string."); + BT_COMP_LOGE_STR("Cannot get path string."); ret = -1; goto end; } @@ -1001,7 +1004,7 @@ int resolve_sequence_or_variant_field_class(struct ctf_field_class *fc, /* Get target field path out of path string */ ret = pathstr_to_field_path(pathstr, &target_field_path, ctx); if (ret) { - BT_LOGE("Cannot get target field path for path string: " + BT_COMP_LOGE("Cannot get target field path for path string: " "path=\"%s\"", pathstr); goto end; } @@ -1014,7 +1017,7 @@ int resolve_sequence_or_variant_field_class(struct ctf_field_class *fc, /* Get target field class */ target_fc = field_path_to_field_class(&target_field_path, ctx); if (!target_fc) { - BT_LOGE("Cannot get target field class for path string: " + BT_COMP_LOGE("Cannot get target field class for path string: " "path=\"%s\", target-field-path=\"%s\"", pathstr, target_field_path_pretty_str); ret = -1; @@ -1024,7 +1027,7 @@ int resolve_sequence_or_variant_field_class(struct ctf_field_class *fc, ret = validate_target_field_path(&target_field_path, target_fc, ctx); if (ret) { - BT_LOGE("Invalid target field path for path string: " + BT_COMP_LOGE("Invalid target field path for path string: " "path=\"%s\", target-field-path=\"%s\"", pathstr, target_field_path_pretty_str); goto end; @@ -1085,7 +1088,7 @@ int resolve_field_class(struct ctf_field_class *fc, struct resolve_context *ctx) case CTF_FIELD_CLASS_TYPE_VARIANT: ret = resolve_sequence_or_variant_field_class(fc, ctx); if (ret) { - BT_LOGE("Cannot resolve sequence field class's length or variant field class's tag: " + BT_COMP_LOGE("Cannot resolve sequence field class's length or variant field class's tag: " "ret=%d, fc-addr=%p", ret, fc); goto end; } @@ -1108,7 +1111,7 @@ int resolve_field_class(struct ctf_field_class *fc, struct resolve_context *ctx) ret = field_class_stack_push(ctx->field_class_stack, fc, ctx); if (ret) { - BT_LOGE("Cannot push field class on context's stack: " + BT_COMP_LOGE("Cannot push field class on context's stack: " "fc-addr=%p", fc); goto end; } @@ -1130,7 +1133,7 @@ int resolve_field_class(struct ctf_field_class *fc, struct resolve_context *ctx) (int64_t) i; } - BT_LOGD("Resolving field class's child field class: " + BT_COMP_LOGD("Resolving field class's child field class: " "parent-fc-addr=%p, child-fc-addr=%p, " "index=%" PRIu64 ", count=%" PRIu64, fc, child_fc, i, field_count); @@ -1183,7 +1186,7 @@ int resolve_event_class_field_classes(struct resolve_context *ctx, ctx->scopes.event_spec_context = ec->spec_context_fc; ret = resolve_root_class(CTF_SCOPE_EVENT_COMMON_CONTEXT, ctx); if (ret) { - BT_LOGE("Cannot resolve event specific context field class: " + BT_COMP_LOGE("Cannot resolve event specific context field class: " "ret=%d", ret); goto end; } @@ -1191,7 +1194,7 @@ int resolve_event_class_field_classes(struct resolve_context *ctx, ctx->scopes.event_payload = ec->payload_fc; ret = resolve_root_class(CTF_SCOPE_EVENT_PAYLOAD, ctx); if (ret) { - BT_LOGE("Cannot resolve event payload field class: " + BT_COMP_LOGE("Cannot resolve event payload field class: " "ret=%d", ret); goto end; } @@ -1219,7 +1222,7 @@ int resolve_stream_class_field_classes(struct resolve_context *ctx, ctx->scopes.packet_context = sc->packet_context_fc; ret = resolve_root_class(CTF_SCOPE_PACKET_CONTEXT, ctx); if (ret) { - BT_LOGE("Cannot resolve packet context field class: " + BT_COMP_LOGE("Cannot resolve packet context field class: " "ret=%d", ret); goto end; } @@ -1227,7 +1230,7 @@ int resolve_stream_class_field_classes(struct resolve_context *ctx, ctx->scopes.event_header = sc->event_header_fc; ret = resolve_root_class(CTF_SCOPE_EVENT_HEADER, ctx); if (ret) { - BT_LOGE("Cannot resolve event header field class: " + BT_COMP_LOGE("Cannot resolve event header field class: " "ret=%d", ret); goto end; } @@ -1235,7 +1238,7 @@ int resolve_stream_class_field_classes(struct resolve_context *ctx, ctx->scopes.event_common_context = sc->event_common_context_fc; ret = resolve_root_class(CTF_SCOPE_EVENT_SPECIFIC_CONTEXT, ctx); if (ret) { - BT_LOGE("Cannot resolve event common context field class: " + BT_COMP_LOGE("Cannot resolve event common context field class: " "ret=%d", ret); goto end; } @@ -1250,7 +1253,7 @@ int resolve_stream_class_field_classes(struct resolve_context *ctx, ret = resolve_event_class_field_classes(ctx, ec); if (ret) { - BT_LOGE("Cannot resolve event class's field classes: " + BT_COMP_LOGE("Cannot resolve event class's field classes: " "ec-id=%" PRIu64 ", ec-name=\"%s\"", ec->id, ec->name->str); goto end; @@ -1267,12 +1270,13 @@ end: BT_HIDDEN int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc, - bt_logging_level log_level) + struct meta_log_config *log_cfg) { int ret = 0; uint64_t i; struct resolve_context local_ctx = { - .log_level = log_level, + .log_level = log_cfg->log_level, + .self_comp = log_cfg->self_comp, .tc = tc, .sc = NULL, .ec = NULL, @@ -1292,7 +1296,7 @@ int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc, /* Initialize class stack */ ctx->field_class_stack = field_class_stack_create(); if (!ctx->field_class_stack) { - BT_LOGE_STR("Cannot create field class stack."); + BT_COMP_LOGE_STR("Cannot create field class stack."); ret = -1; goto end; } @@ -1301,7 +1305,7 @@ int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc, ctx->scopes.packet_header = tc->packet_header_fc; ret = resolve_root_class(CTF_SCOPE_PACKET_HEADER, ctx); if (ret) { - BT_LOGE("Cannot resolve packet header field class: " + BT_COMP_LOGE("Cannot resolve packet header field class: " "ret=%d", ret); goto end; } @@ -1314,7 +1318,7 @@ int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc, ret = resolve_stream_class_field_classes(ctx, sc); if (ret) { - BT_LOGE("Cannot resolve stream class's field classes: " + BT_COMP_LOGE("Cannot resolve stream class's field classes: " "sc-id=%" PRIu64, sc->id); goto end; } diff --git a/src/plugins/ctf/common/metadata/ctf-meta-translate.c b/src/plugins/ctf/common/metadata/ctf-meta-translate.c index 6fdc2dc8..9f6b32e5 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-translate.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-translate.c @@ -23,7 +23,7 @@ #include "ctf-meta-visitors.h" struct ctx { - bt_self_component_source *self_comp; + bt_self_component *self_comp; bt_trace_class *ir_tc; bt_stream_class *ir_sc; struct ctf_trace_class *tc; @@ -571,9 +571,7 @@ 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( - bt_self_component_source_as_self_component( - ctx->self_comp)); + cc->ir_cc = bt_clock_class_create(ctx->self_comp); ctf_clock_class_to_ir(cc->ir_cc, cc); } @@ -587,7 +585,7 @@ end: } BT_HIDDEN -int ctf_trace_class_translate(bt_self_component_source *self_comp, +int ctf_trace_class_translate(bt_self_component *self_comp, bt_trace_class *ir_tc, struct ctf_trace_class *tc) { int ret = 0; diff --git a/src/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.c b/src/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.c index e9578641..85575c0a 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.c @@ -12,9 +12,10 @@ * all copies or substantial portions of the Software. */ -#define BT_LOG_OUTPUT_LEVEL log_level +#define BT_COMP_LOG_SELF_COMP (log_cfg->self_comp) +#define BT_LOG_OUTPUT_LEVEL (log_cfg->log_level) #define BT_LOG_TAG "PLUGIN/CTF/META/UPDATE-DEF-CC" -#include "logging/log.h" +#include "plugins/comp-logging.h" #include #include "common/macros.h" @@ -25,11 +26,12 @@ #include #include "ctf-meta-visitors.h" +#include "logging.h" static inline int find_mapped_clock_class(struct ctf_field_class *fc, struct ctf_clock_class **clock_class, - bt_logging_level log_level) + struct meta_log_config *log_cfg) { int ret = 0; uint64_t i; @@ -47,7 +49,7 @@ int find_mapped_clock_class(struct ctf_field_class *fc, if (int_fc->mapped_clock_class) { if (*clock_class && *clock_class != int_fc->mapped_clock_class) { - BT_LOGE("Stream class contains more than one " + BT_COMP_LOGE("Stream class contains more than one " "clock class: expected-cc-name=\"%s\", " "other-cc-name=\"%s\"", (*clock_class)->name->str, @@ -71,7 +73,7 @@ int find_mapped_clock_class(struct ctf_field_class *fc, struct_fc, i); ret = find_mapped_clock_class(named_fc->fc, - clock_class, log_level); + clock_class, log_cfg); if (ret) { goto end; } @@ -89,7 +91,7 @@ int find_mapped_clock_class(struct ctf_field_class *fc, var_fc, i); ret = find_mapped_clock_class(named_fc->fc, - clock_class, log_level); + clock_class, log_cfg); if (ret) { goto end; } @@ -103,7 +105,7 @@ int find_mapped_clock_class(struct ctf_field_class *fc, struct ctf_field_class_array_base *array_fc = (void *) fc; ret = find_mapped_clock_class(array_fc->elem_fc, clock_class, - log_level); + log_cfg); if (ret) { goto end; } @@ -121,7 +123,7 @@ end: static inline int update_stream_class_default_clock_class( struct ctf_stream_class *stream_class, - bt_logging_level log_level) + struct meta_log_config *log_cfg) { int ret = 0; struct ctf_clock_class *clock_class = @@ -129,19 +131,19 @@ int update_stream_class_default_clock_class( uint64_t i; ret = find_mapped_clock_class(stream_class->packet_context_fc, - &clock_class, log_level); + &clock_class, log_cfg); if (ret) { goto end; } ret = find_mapped_clock_class(stream_class->event_header_fc, - &clock_class, log_level); + &clock_class, log_cfg); if (ret) { goto end; } ret = find_mapped_clock_class(stream_class->event_common_context_fc, - &clock_class, log_level); + &clock_class, log_cfg); if (ret) { goto end; } @@ -151,13 +153,13 @@ int update_stream_class_default_clock_class( stream_class->event_classes->pdata[i]; ret = find_mapped_clock_class(event_class->spec_context_fc, - &clock_class, log_level); + &clock_class, log_cfg); if (ret) { goto end; } ret = find_mapped_clock_class(event_class->payload_fc, - &clock_class, log_level); + &clock_class, log_cfg); if (ret) { goto end; } @@ -173,14 +175,14 @@ end: BT_HIDDEN int ctf_trace_class_update_default_clock_classes(struct ctf_trace_class *ctf_tc, - bt_logging_level log_level) + struct meta_log_config *log_cfg) { uint64_t i; int ret = 0; struct ctf_clock_class *clock_class = NULL; ret = find_mapped_clock_class(ctf_tc->packet_header_fc, &clock_class, - log_level); + log_cfg); if (ret) { goto end; } @@ -195,9 +197,9 @@ int ctf_trace_class_update_default_clock_classes(struct ctf_trace_class *ctf_tc, ctf_tc->stream_classes->pdata[i]; ret = update_stream_class_default_clock_class( - ctf_tc->stream_classes->pdata[i], log_level); + ctf_tc->stream_classes->pdata[i], log_cfg); if (ret) { - BT_LOGE("Stream class contains more than one " + BT_COMP_LOGE("Stream class contains more than one " "clock class: stream-class-id=%" PRIu64, sc->id); goto end; diff --git a/src/plugins/ctf/common/metadata/ctf-meta-validate.c b/src/plugins/ctf/common/metadata/ctf-meta-validate.c index 74e02bb3..997deb48 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-validate.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-validate.c @@ -12,9 +12,10 @@ * all copies or substantial portions of the Software. */ -#define BT_LOG_OUTPUT_LEVEL log_level +#define BT_COMP_LOG_SELF_COMP (log_cfg->self_comp) +#define BT_LOG_OUTPUT_LEVEL (log_cfg->log_level) #define BT_LOG_TAG "PLUGIN/CTF/META/VALIDATE" -#include "logging/log.h" +#include "plugins/comp-logging.h" #include #include "common/macros.h" @@ -25,10 +26,11 @@ #include #include "ctf-meta-visitors.h" +#include "logging.h" static int validate_stream_class(struct ctf_stream_class *sc, - bt_logging_level log_level) + struct meta_log_config *log_cfg) { int ret = 0; struct ctf_field_class_int *int_fc; @@ -43,7 +45,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_LOGE_STR("Invalid packet context field class: " + BT_COMP_LOGE_STR("Invalid packet context field class: " "`timestamp_begin` member is not an integer field class."); goto invalid; } @@ -51,7 +53,7 @@ int validate_stream_class(struct ctf_stream_class *sc, int_fc = (void *) fc; if (int_fc->is_signed) { - BT_LOGE_STR("Invalid packet context field class: " + BT_COMP_LOGE_STR("Invalid packet context field class: " "`timestamp_begin` member is signed."); goto invalid; } @@ -62,7 +64,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_LOGE_STR("Invalid packet context field class: " + BT_COMP_LOGE_STR("Invalid packet context field class: " "`timestamp_end` member is not an integer field class."); goto invalid; } @@ -70,7 +72,7 @@ int validate_stream_class(struct ctf_stream_class *sc, int_fc = (void *) fc; if (int_fc->is_signed) { - BT_LOGE_STR("Invalid packet context field class: " + BT_COMP_LOGE_STR("Invalid packet context field class: " "`timestamp_end` member is signed."); goto invalid; } @@ -81,7 +83,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_LOGE_STR("Invalid packet context field class: " + BT_COMP_LOGE_STR("Invalid packet context field class: " "`events_discarded` member is not an integer field class."); goto invalid; } @@ -89,7 +91,7 @@ int validate_stream_class(struct ctf_stream_class *sc, int_fc = (void *) fc; if (int_fc->is_signed) { - BT_LOGE_STR("Invalid packet context field class: " + BT_COMP_LOGE_STR("Invalid packet context field class: " "`events_discarded` member is signed."); goto invalid; } @@ -100,7 +102,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_LOGE_STR("Invalid packet context field class: " + BT_COMP_LOGE_STR("Invalid packet context field class: " "`packet_seq_num` member is not an integer field class."); goto invalid; } @@ -108,7 +110,7 @@ int validate_stream_class(struct ctf_stream_class *sc, int_fc = (void *) fc; if (int_fc->is_signed) { - BT_LOGE_STR("Invalid packet context field class: " + BT_COMP_LOGE_STR("Invalid packet context field class: " "`packet_seq_num` member is signed."); goto invalid; } @@ -119,7 +121,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_LOGE_STR("Invalid packet context field class: " + BT_COMP_LOGE_STR("Invalid packet context field class: " "`packet_size` member is not an integer field class."); goto invalid; } @@ -127,7 +129,7 @@ int validate_stream_class(struct ctf_stream_class *sc, int_fc = (void *) fc; if (int_fc->is_signed) { - BT_LOGE_STR("Invalid packet context field class: " + BT_COMP_LOGE_STR("Invalid packet context field class: " "`packet_size` member is signed."); goto invalid; } @@ -138,7 +140,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_LOGE_STR("Invalid packet context field class: " + BT_COMP_LOGE_STR("Invalid packet context field class: " "`content_size` member is not an integer field class."); goto invalid; } @@ -146,7 +148,7 @@ int validate_stream_class(struct ctf_stream_class *sc, int_fc = (void *) fc; if (int_fc->is_signed) { - BT_LOGE_STR("Invalid packet context field class: " + BT_COMP_LOGE_STR("Invalid packet context field class: " "`content_size` member is signed."); goto invalid; } @@ -157,7 +159,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_LOGE_STR("Invalid event header field class: " + BT_COMP_LOGE_STR("Invalid event header field class: " "`id` member is not an integer field class."); goto invalid; } @@ -165,13 +167,13 @@ int validate_stream_class(struct ctf_stream_class *sc, int_fc = (void *) fc; if (int_fc->is_signed) { - BT_LOGE_STR("Invalid event header field class: " + BT_COMP_LOGE_STR("Invalid event header field class: " "`id` member is signed."); goto invalid; } } else { if (sc->event_classes->len > 1) { - BT_LOGE_STR("Invalid event header field class: " + BT_COMP_LOGE_STR("Invalid event header field class: " "missing `id` member as there's " "more than one event class."); goto invalid; @@ -189,7 +191,7 @@ end: BT_HIDDEN int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, - bt_logging_level log_level) + struct meta_log_config *log_cfg) { int ret = 0; struct ctf_field_class_int *int_fc; @@ -207,14 +209,14 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, 0); if (named_fc->fc != fc) { - BT_LOGE_STR("Invalid packet header field class: " + BT_COMP_LOGE_STR("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_LOGE_STR("Invalid packet header field class: " + BT_COMP_LOGE_STR("Invalid packet header field class: " "`magic` member is not an integer field class."); goto invalid; } @@ -222,13 +224,13 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, int_fc = (void *) fc; if (int_fc->is_signed) { - BT_LOGE_STR("Invalid packet header field class: " + BT_COMP_LOGE_STR("Invalid packet header field class: " "`magic` member is signed."); goto invalid; } if (int_fc->base.size != 32) { - BT_LOGE_STR("Invalid packet header field class: " + BT_COMP_LOGE_STR("Invalid packet header field class: " "`magic` member is not 32-bit."); goto invalid; } @@ -239,7 +241,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_LOGE_STR("Invalid packet header field class: " + BT_COMP_LOGE_STR("Invalid packet header field class: " "`stream_id` member is not an integer field class."); goto invalid; } @@ -247,13 +249,13 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, int_fc = (void *) fc; if (int_fc->is_signed) { - BT_LOGE_STR("Invalid packet header field class: " + BT_COMP_LOGE_STR("Invalid packet header field class: " "`stream_id` member is signed."); goto invalid; } } else { if (ctf_tc->stream_classes->len > 1) { - BT_LOGE_STR("Invalid packet header field class: " + BT_COMP_LOGE_STR("Invalid packet header field class: " "missing `stream_id` member as there's " "more than one stream class."); goto invalid; @@ -266,7 +268,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_LOGE_STR("Invalid packet header field class: " + BT_COMP_LOGE_STR("Invalid packet header field class: " "`stream_instance_id` member is not an integer field class."); goto invalid; } @@ -274,7 +276,7 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, int_fc = (void *) fc; if (int_fc->is_signed) { - BT_LOGE_STR("Invalid packet header field class: " + BT_COMP_LOGE_STR("Invalid packet header field class: " "`stream_instance_id` member is signed."); goto invalid; } @@ -286,7 +288,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_LOGE_STR("Invalid packet header field class: " + BT_COMP_LOGE_STR("Invalid packet header field class: " "`uuid` member is not an array field class."); goto invalid; } @@ -294,13 +296,13 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, array_fc = (void *) fc; if (array_fc->length != 16) { - BT_LOGE_STR("Invalid packet header field class: " + BT_COMP_LOGE_STR("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_LOGE_STR("Invalid packet header field class: " + BT_COMP_LOGE_STR("Invalid packet header field class: " "`uuid` member's element field class is not " "an integer field class."); goto invalid; @@ -309,21 +311,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_LOGE_STR("Invalid packet header field class: " + BT_COMP_LOGE_STR("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_LOGE_STR("Invalid packet header field class: " + BT_COMP_LOGE_STR("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_LOGE_STR("Invalid packet header field class: " + BT_COMP_LOGE_STR("Invalid packet header field class: " "`uuid` member's element field class's " "alignment is not 8."); goto invalid; @@ -335,9 +337,9 @@ int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, struct ctf_stream_class *sc = ctf_tc->stream_classes->pdata[i]; - ret = validate_stream_class(sc, log_level); + ret = validate_stream_class(sc, log_cfg); if (ret) { - BT_LOGE("Invalid stream class: sc-id=%" PRIu64, sc->id); + BT_COMP_LOGE("Invalid stream class: sc-id=%" PRIu64, sc->id); goto invalid; } } diff --git a/src/plugins/ctf/common/metadata/ctf-meta-visitors.h b/src/plugins/ctf/common/metadata/ctf-meta-visitors.h index 875a8ce4..98e794c0 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-visitors.h +++ b/src/plugins/ctf/common/metadata/ctf-meta-visitors.h @@ -20,18 +20,20 @@ #include "ctf-meta.h" +struct meta_log_config; + BT_HIDDEN int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc, - bt_logging_level log_level); + struct meta_log_config *log_cfg); BT_HIDDEN -int ctf_trace_class_translate(bt_self_component_source *self_comp, +int ctf_trace_class_translate(bt_self_component *self_comp, bt_trace_class *ir_tc, struct ctf_trace_class *tc); BT_HIDDEN int ctf_trace_class_update_default_clock_classes( struct ctf_trace_class *ctf_tc, - bt_logging_level log_level); + struct meta_log_config *log_cfg); BT_HIDDEN int ctf_trace_class_update_in_ir(struct ctf_trace_class *ctf_tc); @@ -50,10 +52,11 @@ int ctf_trace_class_update_stream_class_config(struct ctf_trace_class *ctf_tc); BT_HIDDEN int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc, - bt_logging_level log_level); + struct meta_log_config *log_cfg); BT_HIDDEN void ctf_trace_class_warn_meaningless_header_fields( - struct ctf_trace_class *ctf_tc, bt_logging_level log_level); + struct ctf_trace_class *ctf_tc, + struct meta_log_config *log_cfg); #endif /* _CTF_META_VISITORS_H */ diff --git a/src/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.c b/src/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.c index 27c47983..e8a90220 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.c @@ -12,9 +12,10 @@ * all copies or substantial portions of the Software. */ -#define BT_LOG_OUTPUT_LEVEL log_level +#define BT_COMP_LOG_SELF_COMP (log_cfg->self_comp) +#define BT_LOG_OUTPUT_LEVEL (log_cfg->log_level) #define BT_LOG_TAG "PLUGIN/CTF/META/WARN-MEANINGLESS-HEADER-FIELDS" -#include "logging/log.h" +#include "plugins/comp-logging.h" #include #include "common/macros.h" @@ -25,18 +26,19 @@ #include #include "ctf-meta-visitors.h" +#include "logging.h" static inline void warn_meaningless_field(const char *name, const char *scope_name, - bt_logging_level log_level) + struct meta_log_config *log_cfg) { - BT_LOGW("User field found in %s: ignoring: name=\"%s\"", + BT_COMP_LOGW("User field found in %s: ignoring: name=\"%s\"", scope_name, name); } static inline void warn_meaningless_fields(struct ctf_field_class *fc, const char *name, - const char *scope_name, bt_logging_level log_level) + const char *scope_name, struct meta_log_config *log_cfg) { uint64_t i; @@ -47,7 +49,7 @@ void warn_meaningless_fields(struct ctf_field_class *fc, const char *name, switch (fc->type) { case CTF_FIELD_CLASS_TYPE_FLOAT: case CTF_FIELD_CLASS_TYPE_STRING: - warn_meaningless_field(name, scope_name, log_level); + warn_meaningless_field(name, scope_name, log_cfg); break; case CTF_FIELD_CLASS_TYPE_INT: case CTF_FIELD_CLASS_TYPE_ENUM: @@ -56,7 +58,7 @@ void warn_meaningless_fields(struct ctf_field_class *fc, const char *name, if (int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE && !int_fc->mapped_clock_class) { - warn_meaningless_field(name, scope_name, log_level); + warn_meaningless_field(name, scope_name, log_cfg); } break; @@ -71,7 +73,7 @@ void warn_meaningless_fields(struct ctf_field_class *fc, const char *name, struct_fc, i); warn_meaningless_fields(named_fc->fc, - named_fc->name->str, scope_name, log_level); + named_fc->name->str, scope_name, log_cfg); } break; @@ -86,7 +88,7 @@ void warn_meaningless_fields(struct ctf_field_class *fc, const char *name, var_fc, i); warn_meaningless_fields(named_fc->fc, - named_fc->name->str, scope_name, log_level); + named_fc->name->str, scope_name, log_cfg); } break; @@ -106,7 +108,7 @@ void warn_meaningless_fields(struct ctf_field_class *fc, const char *name, struct ctf_field_class_array_base *array_fc = (void *) fc; warn_meaningless_fields(array_fc->elem_fc, name, scope_name, - log_level); + log_cfg); break; } default: @@ -120,14 +122,14 @@ end: BT_HIDDEN void ctf_trace_class_warn_meaningless_header_fields( struct ctf_trace_class *ctf_tc, - bt_logging_level log_level) + struct meta_log_config *log_cfg) { uint64_t i; if (!ctf_tc->is_translated) { warn_meaningless_fields( ctf_tc->packet_header_fc, NULL, "packet header", - log_level); + log_cfg); } for (i = 0; i < ctf_tc->stream_classes->len; i++) { @@ -135,7 +137,7 @@ void ctf_trace_class_warn_meaningless_header_fields( if (!sc->is_translated) { warn_meaningless_fields(sc->event_header_fc, NULL, - "event header", log_level); + "event header", log_cfg); } } } diff --git a/src/plugins/ctf/common/metadata/decoder.c b/src/plugins/ctf/common/metadata/decoder.c index 5f20eae8..188faebe 100644 --- a/src/plugins/ctf/common/metadata/decoder.c +++ b/src/plugins/ctf/common/metadata/decoder.c @@ -12,9 +12,10 @@ * all copies or substantial portions of the Software. */ +#define BT_COMP_LOG_SELF_COMP (mdec->config.self_comp) #define BT_LOG_OUTPUT_LEVEL (mdec->config.log_level) #define BT_LOG_TAG "PLUGIN/CTF/META/DECODER" -#include "logging/log.h" +#include "plugins/comp-logging.h" #include #include @@ -31,6 +32,7 @@ #include "ast.h" #include "decoder.h" #include "scanner.h" +#include "logging.h" #define TSDL_MAGIC 0x75d11d57 @@ -60,7 +62,7 @@ struct packet_header { BT_HIDDEN bool ctf_metadata_decoder_is_packetized(FILE *fp, int *byte_order, - bt_logging_level log_level) + bt_logging_level log_level, bt_self_component *self_comp) { uint32_t magic; size_t len; @@ -68,7 +70,7 @@ bool ctf_metadata_decoder_is_packetized(FILE *fp, int *byte_order, len = fread(&magic, sizeof(magic), 1, fp); if (len != 1) { - BT_LOG_WRITE_CUR_LVL(BT_LOG_INFO, log_level, BT_LOG_TAG, + BT_COMP_LOG_CUR_LVL(BT_LOG_INFO, log_level, self_comp, "Cannot read first metadata packet header: assuming the stream is not packetized."); goto end; } @@ -107,19 +109,19 @@ int decode_packet(struct ctf_metadata_decoder *mdec, FILE *in_fp, FILE *out_fp, const long offset = ftell(in_fp); if (offset < 0) { - BT_LOGE_ERRNO("Failed to get current metadata file position", + BT_COMP_LOGE_ERRNO("Failed to get current metadata file position", "."); goto error; } - BT_LOGD("Decoding metadata packet: mdec-addr=%p, offset=%ld", + BT_COMP_LOGD("Decoding metadata packet: mdec-addr=%p, offset=%ld", mdec, offset); readlen = fread(&header, sizeof(header), 1, in_fp); if (feof(in_fp) != 0) { - BT_LOGI("Reached end of file: offset=%ld", ftell(in_fp)); + BT_COMP_LOGI("Reached end of file: offset=%ld", ftell(in_fp)); goto end; } if (readlen < 1) { - BT_LOGE("Cannot decode metadata packet: offset=%ld", offset); + BT_COMP_LOGE("Cannot decode metadata packet: offset=%ld", offset); goto error; } @@ -131,21 +133,21 @@ int decode_packet(struct ctf_metadata_decoder *mdec, FILE *in_fp, FILE *out_fp, } if (header.compression_scheme) { - BT_LOGE("Metadata packet compression is not supported as of this version: " + BT_COMP_LOGE("Metadata packet compression is not supported as of this version: " "compression-scheme=%u, offset=%ld", (unsigned int) header.compression_scheme, offset); goto error; } if (header.encryption_scheme) { - BT_LOGE("Metadata packet encryption is not supported as of this version: " + BT_COMP_LOGE("Metadata packet encryption is not supported as of this version: " "encryption-scheme=%u, offset=%ld", (unsigned int) header.encryption_scheme, offset); goto error; } if (header.checksum || header.checksum_scheme) { - BT_LOGE("Metadata packet checksum verification is not supported as of this version: " + BT_COMP_LOGE("Metadata packet checksum verification is not supported as of this version: " "checksum-scheme=%u, checksum=%x, offset=%ld", (unsigned int) header.checksum_scheme, header.checksum, offset); @@ -153,7 +155,7 @@ int decode_packet(struct ctf_metadata_decoder *mdec, FILE *in_fp, FILE *out_fp, } if (!is_version_valid(header.major, header.minor)) { - BT_LOGE("Invalid metadata packet version: " + BT_COMP_LOGE("Invalid metadata packet version: " "version=%u.%u, offset=%ld", header.major, header.minor, offset); goto error; @@ -165,7 +167,7 @@ int decode_packet(struct ctf_metadata_decoder *mdec, FILE *in_fp, FILE *out_fp, memcpy(mdec->uuid, header.uuid, sizeof(header.uuid)); mdec->is_uuid_set = true; } else if (bt_uuid_compare(header.uuid, mdec->uuid)) { - BT_LOGE("Metadata UUID mismatch between packets of the same stream: " + BT_COMP_LOGE("Metadata UUID mismatch between packets of the same stream: " "packet-uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\", " "expected-uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\", " "offset=%ld", @@ -207,7 +209,7 @@ int decode_packet(struct ctf_metadata_decoder *mdec, FILE *in_fp, FILE *out_fp, } if ((header.content_size / CHAR_BIT) < sizeof(header)) { - BT_LOGE("Bad metadata packet content size: content-size=%u, " + BT_COMP_LOGE("Bad metadata packet content size: content-size=%u, " "offset=%ld", header.content_size, offset); goto error; } @@ -220,13 +222,13 @@ int decode_packet(struct ctf_metadata_decoder *mdec, FILE *in_fp, FILE *out_fp, loop_read = MIN(sizeof(buf) - 1, toread); readlen = fread(buf, sizeof(uint8_t), loop_read, in_fp); if (ferror(in_fp)) { - BT_LOGE("Cannot read metadata packet buffer: " + BT_COMP_LOGE("Cannot read metadata packet buffer: " "offset=%ld, read-size=%zu", ftell(in_fp), loop_read); goto error; } if (readlen > loop_read) { - BT_LOGE("fread returned more byte than expected: " + BT_COMP_LOGE("fread returned more byte than expected: " "read-size-asked=%zu, read-size-returned=%zu", loop_read, readlen); goto error; @@ -234,7 +236,7 @@ int decode_packet(struct ctf_metadata_decoder *mdec, FILE *in_fp, FILE *out_fp, writelen = fwrite(buf, sizeof(uint8_t), readlen, out_fp); if (writelen < readlen || ferror(out_fp)) { - BT_LOGE("Cannot write decoded metadata text to buffer: " + BT_COMP_LOGE("Cannot write decoded metadata text to buffer: " "read-offset=%ld, write-size=%zu", ftell(in_fp), readlen); goto error; @@ -249,7 +251,7 @@ int decode_packet(struct ctf_metadata_decoder *mdec, FILE *in_fp, FILE *out_fp, CHAR_BIT; fseek_ret = fseek(in_fp, toread, SEEK_CUR); if (fseek_ret < 0) { - BT_LOGW_STR("Missing padding at the end of the metadata stream."); + BT_COMP_LOGW_STR("Missing padding at the end of the metadata stream."); } break; } @@ -267,7 +269,8 @@ end: static int ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec( struct ctf_metadata_decoder *mdec, FILE *fp, - char **buf, int byte_order, bt_logging_level log_level) + char **buf, int byte_order, bt_logging_level log_level, + bt_self_component *self_comp) { FILE *out_fp; size_t size; @@ -277,7 +280,7 @@ int ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec( out_fp = bt_open_memstream(buf, &size); if (out_fp == NULL) { - BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG, + BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, log_level, self_comp, "Cannot open memory stream: %s: mdec-addr=%p", strerror(errno), mdec); goto error; @@ -290,7 +293,7 @@ int ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec( tret = decode_packet(mdec, fp, out_fp, byte_order); if (tret) { - BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG, + BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, log_level, self_comp, "Cannot decode packet: index=%zu, mdec-addr=%p", packet_index, mdec); goto error; @@ -302,7 +305,7 @@ int ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec( /* Make sure the whole string ends with a null character */ tret = fputc('\0', out_fp); if (tret == EOF) { - BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG, + BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, log_level, self_comp, "Cannot append '\\0' to the decoded metadata buffer: " "mdec-addr=%p", mdec); goto error; @@ -318,7 +321,7 @@ int ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec( */ out_fp = NULL; if (ret < 0) { - BT_LOG_WRITE_ERRNO_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG, + BT_COMP_LOG_ERRNO_CUR_LVL(BT_LOG_ERROR, log_level, self_comp, "Cannot close memory stream", ": mdec-addr=%p", mdec); goto error; } @@ -330,9 +333,9 @@ error: if (out_fp) { if (bt_close_memstream(buf, &size, out_fp)) { - BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG, - "Cannot close memory stream: %s: mdec-addr=%p", - strerror(errno), mdec); + BT_COMP_LOG_ERRNO_CUR_LVL(BT_LOG_ERROR, log_level, + self_comp, "Cannot close memory stream", + ": mdec-addr=%p", mdec); } } @@ -348,49 +351,45 @@ end: BT_HIDDEN int ctf_metadata_decoder_packetized_file_stream_to_buf( FILE *fp, char **buf, int byte_order, - bt_logging_level log_level) + bt_logging_level log_level, + bt_self_component *self_comp) { return ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec( - NULL, fp, buf, byte_order, log_level); + NULL, fp, buf, byte_order, log_level, self_comp); } BT_HIDDEN struct ctf_metadata_decoder *ctf_metadata_decoder_create( - bt_self_component_source *self_comp, const struct ctf_metadata_decoder_config *config) { struct ctf_metadata_decoder *mdec = g_new0(struct ctf_metadata_decoder, 1); - struct ctf_metadata_decoder_config default_config = { - .clock_class_offset_s = 0, - .clock_class_offset_ns = 0, - }; - if (!config) { - config = &default_config; - } - - BT_LOGD("Creating CTF metadata decoder: " + BT_ASSERT(config); + BT_COMP_LOG_CUR_LVL(BT_LOG_DEBUG, config->log_level, config->self_comp, + "Creating CTF metadata decoder: " "clock-class-offset-s=%" PRId64 ", " "clock-class-offset-ns=%" PRId64, config->clock_class_offset_s, config->clock_class_offset_ns); if (!mdec) { - BT_LOGE_STR("Failed to allocate one CTF metadata decoder."); + BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, config->log_level, + config->self_comp, + "Failed to allocate one CTF metadata decoder."); goto end; } mdec->config = *config; - mdec->visitor = ctf_visitor_generate_ir_create(self_comp, config); + mdec->visitor = ctf_visitor_generate_ir_create(config); if (!mdec->visitor) { - BT_LOGE("Failed to create a CTF IR metadata AST visitor: " + BT_COMP_LOGE("Failed to create a CTF IR metadata AST visitor: " "mdec-addr=%p", mdec); ctf_metadata_decoder_destroy(mdec); mdec = NULL; goto end; } - BT_LOGD("Creating CTF metadata decoder: " + BT_COMP_LOGD("Creating CTF metadata decoder: " "clock-class-offset-s=%" PRId64 ", " "clock-class-offset-ns=%" PRId64 ", addr=%p", config->clock_class_offset_s, config->clock_class_offset_ns, @@ -407,7 +406,7 @@ void ctf_metadata_decoder_destroy(struct ctf_metadata_decoder *mdec) return; } - BT_LOGD("Destroying CTF metadata decoder: addr=%p", mdec); + BT_COMP_LOGD("Destroying CTF metadata decoder: addr=%p", mdec); ctf_visitor_generate_ir_destroy(mdec->visitor); g_free(mdec); } @@ -422,16 +421,20 @@ enum ctf_metadata_decoder_status ctf_metadata_decoder_decode( struct ctf_scanner *scanner = NULL; char *buf = NULL; bool close_fp = false; + struct meta_log_config log_cfg; BT_ASSERT(mdec); + log_cfg.log_level = mdec->config.log_level; + log_cfg.self_comp = mdec->config.self_comp; if (ctf_metadata_decoder_is_packetized(fp, &mdec->bo, - BT_LOG_OUTPUT_LEVEL)) { - BT_LOGI("Metadata stream is packetized: mdec-addr=%p", mdec); + mdec->config.log_level, mdec->config.self_comp)) { + BT_COMP_LOGI("Metadata stream is packetized: mdec-addr=%p", mdec); ret = ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec( - mdec, fp, &buf, mdec->bo, BT_LOG_OUTPUT_LEVEL); + mdec, fp, &buf, mdec->bo, mdec->config.log_level, + mdec->config.self_comp); if (ret) { - BT_LOGE("Cannot decode packetized metadata packets to metadata text: " + BT_COMP_LOGE("Cannot decode packetized metadata packets to metadata text: " "mdec-addr=%p, ret=%d", mdec, ret); status = CTF_METADATA_DECODER_STATUS_ERROR; goto end; @@ -446,7 +449,7 @@ enum ctf_metadata_decoder_status ctf_metadata_decoder_decode( fp = bt_fmemopen(buf, strlen(buf), "rb"); close_fp = true; if (!fp) { - BT_LOGE("Cannot memory-open metadata buffer: %s: " + BT_COMP_LOGE("Cannot memory-open metadata buffer: %s: " "mdec-addr=%p", strerror(errno), mdec); status = CTF_METADATA_DECODER_STATUS_ERROR; goto end; @@ -456,10 +459,10 @@ enum ctf_metadata_decoder_status ctf_metadata_decoder_decode( ssize_t nr_items; const long init_pos = ftell(fp); - BT_LOGI("Metadata stream is plain text: mdec-addr=%p", mdec); + BT_COMP_LOGI("Metadata stream is plain text: mdec-addr=%p", mdec); if (init_pos < 0) { - BT_LOGE_ERRNO("Failed to get current file position", "."); + BT_COMP_LOGE_ERRNO("Failed to get current file position", "."); status = CTF_METADATA_DECODER_STATUS_ERROR; goto end; } @@ -467,14 +470,14 @@ enum ctf_metadata_decoder_status ctf_metadata_decoder_decode( /* Check text-only metadata header and version */ nr_items = fscanf(fp, "/* CTF %10u.%10u", &major, &minor); if (nr_items < 2) { - BT_LOGW("Missing \"/* CTF major.minor\" signature in plain text metadata file stream: " + BT_COMP_LOGW("Missing \"/* CTF major.minor\" signature in plain text metadata file stream: " "mdec-addr=%p", mdec); } - BT_LOGI("Found metadata stream version in signature: version=%u.%u", major, minor); + BT_COMP_LOGI("Found metadata stream version in signature: version=%u.%u", major, minor); if (!is_version_valid(major, minor)) { - BT_LOGE("Invalid metadata version found in plain text signature: " + BT_COMP_LOGE("Invalid metadata version found in plain text signature: " "version=%u.%u, mdec-addr=%p", major, minor, mdec); status = CTF_METADATA_DECODER_STATUS_INVAL_VERSION; @@ -482,7 +485,7 @@ enum ctf_metadata_decoder_status ctf_metadata_decoder_decode( } if (fseek(fp, init_pos, SEEK_SET)) { - BT_LOGE("Cannot seek metadata file stream to initial position: %s: " + BT_COMP_LOGE("Cannot seek metadata file stream to initial position: %s: " "mdec-addr=%p", strerror(errno), mdec); status = CTF_METADATA_DECODER_STATUS_ERROR; goto end; @@ -496,7 +499,7 @@ enum ctf_metadata_decoder_status ctf_metadata_decoder_decode( /* Allocate a scanner and append the metadata text content */ scanner = ctf_scanner_alloc(); if (!scanner) { - BT_LOGE("Cannot allocate a metadata lexical scanner: " + BT_COMP_LOGE("Cannot allocate a metadata lexical scanner: " "mdec-addr=%p", mdec); status = CTF_METADATA_DECODER_STATUS_ERROR; goto end; @@ -505,16 +508,15 @@ enum ctf_metadata_decoder_status ctf_metadata_decoder_decode( BT_ASSERT(fp); ret = ctf_scanner_append_ast(scanner, fp); if (ret) { - BT_LOGE("Cannot create the metadata AST out of the metadata text: " + BT_COMP_LOGE("Cannot create the metadata AST out of the metadata text: " "mdec-addr=%p", mdec); status = CTF_METADATA_DECODER_STATUS_INCOMPLETE; goto end; } - ret = ctf_visitor_semantic_check(0, &scanner->ast->root, - mdec->config.log_level); + ret = ctf_visitor_semantic_check(0, &scanner->ast->root, &log_cfg); if (ret) { - BT_LOGE("Validation of the metadata semantics failed: " + BT_COMP_LOGE("Validation of the metadata semantics failed: " "mdec-addr=%p", mdec); status = CTF_METADATA_DECODER_STATUS_ERROR; goto end; @@ -527,12 +529,12 @@ enum ctf_metadata_decoder_status ctf_metadata_decoder_decode( /* Success */ break; case -EINCOMPLETE: - BT_LOGD("While visiting metadata AST: incomplete data: " + BT_COMP_LOGD("While visiting metadata AST: incomplete data: " "mdec-addr=%p", mdec); status = CTF_METADATA_DECODER_STATUS_INCOMPLETE; goto end; default: - BT_LOGE("Failed to visit AST node to create CTF IR objects: " + BT_COMP_LOGE("Failed to visit AST node to create CTF IR objects: " "mdec-addr=%p, ret=%d", mdec, ret); status = CTF_METADATA_DECODER_STATUS_IR_VISITOR_ERROR; goto end; @@ -547,7 +549,7 @@ end: if (fp && close_fp) { if (fclose(fp)) { - BT_LOGE("Cannot close metadata file stream: " + BT_COMP_LOGE("Cannot close metadata file stream: " "mdec-addr=%p", mdec); } } diff --git a/src/plugins/ctf/common/metadata/decoder.h b/src/plugins/ctf/common/metadata/decoder.h index 4d77b472..e40356e3 100644 --- a/src/plugins/ctf/common/metadata/decoder.h +++ b/src/plugins/ctf/common/metadata/decoder.h @@ -37,6 +37,10 @@ enum ctf_metadata_decoder_status { /* Decoding configuration */ struct ctf_metadata_decoder_config { bt_logging_level log_level; + + /* Weak */ + bt_self_component *self_comp; + int64_t clock_class_offset_s; int64_t clock_class_offset_ns; }; @@ -48,7 +52,6 @@ struct ctf_metadata_decoder_config { */ BT_HIDDEN struct ctf_metadata_decoder *ctf_metadata_decoder_create( - bt_self_component_source *self_comp, const struct ctf_metadata_decoder_config *config); /* @@ -104,7 +107,8 @@ struct ctf_trace_class *ctf_metadata_decoder_borrow_ctf_trace_class( */ BT_HIDDEN bool ctf_metadata_decoder_is_packetized(FILE *fp, int *byte_order, - bt_logging_level log_level); + bt_logging_level log_level, + bt_self_component *self_comp); /* * Decodes a packetized metadata file stream to a NULL-terminated @@ -113,6 +117,7 @@ bool ctf_metadata_decoder_is_packetized(FILE *fp, int *byte_order, BT_HIDDEN int ctf_metadata_decoder_packetized_file_stream_to_buf( FILE *fp, char **buf, int byte_order, - bt_logging_level log_level); + bt_logging_level log_level, + bt_self_component *self_comp); #endif /* _METADATA_DECODER_H */ diff --git a/src/plugins/ctf/common/metadata/logging.h b/src/plugins/ctf/common/metadata/logging.h index dbd00474..0d60cd36 100644 --- a/src/plugins/ctf/common/metadata/logging.h +++ b/src/plugins/ctf/common/metadata/logging.h @@ -23,6 +23,7 @@ * SOFTWARE. */ +#include #include "logging/log.h" /* @@ -31,6 +32,17 @@ */ BT_LOG_LEVEL_EXTERN_SYMBOL(ctf_plugin_metadata_log_level); +/* + * To be used by functions without a context structure to pass all the + * logging configuration at once. + */ +struct meta_log_config { + bt_logging_level log_level; + + /* Weak */ + bt_self_component *self_comp; +}; + #define _BT_LOGV_LINENO(_lineno, _msg, args...) \ BT_LOGV("At line %u in metadata stream: " _msg, _lineno, ## args) @@ -40,4 +52,13 @@ BT_LOG_LEVEL_EXTERN_SYMBOL(ctf_plugin_metadata_log_level); #define _BT_LOGE_LINENO(_lineno, _msg, args...) \ BT_LOGE("At line %u in metadata stream: " _msg, _lineno, ## args) +#define _BT_COMP_LOGV_LINENO(_lineno, _msg, args...) \ + BT_COMP_LOGV("At line %u in metadata stream: " _msg, _lineno, ## args) + +#define _BT_COMP_LOGW_LINENO(_lineno, _msg, args...) \ + BT_COMP_LOGW("At line %u in metadata stream: " _msg, _lineno, ## args) + +#define _BT_COMP_LOGE_LINENO(_lineno, _msg, args...) \ + BT_COMP_LOGE("At line %u in metadata stream: " _msg, _lineno, ## args) + #endif /* CTF_METADATA_LOGGING_H */ diff --git a/src/plugins/ctf/common/metadata/visitor-generate-ir.c b/src/plugins/ctf/common/metadata/visitor-generate-ir.c index 09edde35..6fc4649a 100644 --- a/src/plugins/ctf/common/metadata/visitor-generate-ir.c +++ b/src/plugins/ctf/common/metadata/visitor-generate-ir.c @@ -27,9 +27,10 @@ * SOFTWARE. */ -#define BT_LOG_OUTPUT_LEVEL (ctx->log_level) +#define BT_COMP_LOG_SELF_COMP (ctx->log_cfg.self_comp) +#define BT_LOG_OUTPUT_LEVEL (ctx->log_cfg.log_level) #define BT_LOG_TAG "PLUGIN/CTF/META/IR-VISITOR" -#include "logging/log.h" +#include "plugins/comp-logging.h" #include #include @@ -68,7 +69,7 @@ do { \ ret = ctx_push_scope(ctx); \ if (ret) { \ - BT_LOGE_STR("Cannot push scope."); \ + BT_COMP_LOGE_STR("Cannot push scope."); \ goto error; \ } \ } while (0) @@ -160,19 +161,19 @@ enum loglevel { #define _BT_LIST_FIRST_ENTRY(_ptr, _class, _member) \ bt_list_entry((_ptr)->next, _class, _member) -#define _BT_LOGE_DUP_ATTR(_node, _attr, _entity) \ - _BT_LOGE_LINENO((_node)->lineno, \ +#define _BT_COMP_LOGE_DUP_ATTR(_node, _attr, _entity) \ + _BT_COMP_LOGE_LINENO((_node)->lineno, \ "Duplicate attribute in %s: attr-name=\"%s\"", \ _entity, _attr) -#define _BT_LOGE_NODE(_node, _msg, args...) \ - _BT_LOGE_LINENO((_node)->lineno, _msg, ## args) +#define _BT_COMP_LOGE_NODE(_node, _msg, args...) \ + _BT_COMP_LOGE_LINENO((_node)->lineno, _msg, ## args) -#define _BT_LOGW_NODE(_node, _msg, args...) \ - _BT_LOGW_LINENO((_node)->lineno, _msg, ## args) +#define _BT_COMP_LOGW_NODE(_node, _msg, args...) \ + _BT_COMP_LOGW_LINENO((_node)->lineno, _msg, ## args) -#define _BT_LOGV_NODE(_node, _msg, args...) \ - _BT_LOGV_LINENO((_node)->lineno, _msg, ## args) +#define _BT_COMP_LOGV_NODE(_node, _msg, args...) \ + _BT_COMP_LOGV_LINENO((_node)->lineno, _msg, ## args) /* * Declaration scope of a visitor context. This represents a TSDL @@ -195,8 +196,8 @@ struct ctx_decl_scope { * Visitor context (private). */ struct ctx { - bt_logging_level log_level; - bt_self_component_source *self_comp; + struct meta_log_config log_cfg; + /* Trace IR trace class being filled (owned by this) */ bt_trace_class *trace_class; @@ -235,7 +236,7 @@ struct ctx_decl_scope *ctx_decl_scope_create(struct ctx *ctx, scope = g_new(struct ctx_decl_scope, 1); if (!scope) { - BT_LOGE_STR("Failed to allocate one declaration scope."); + BT_COMP_LOGE_STR("Failed to allocate one declaration scope."); goto end; } @@ -285,7 +286,7 @@ GQuark get_prefixed_named_quark(struct ctx *ctx, char prefix, const char *name) /* Prefix character + original string + '\0' */ char *prname = g_new(char, strlen(name) + 2); if (!prname) { - BT_LOGE_STR("Failed to allocate a string."); + BT_COMP_LOGE_STR("Failed to allocate a string."); goto end; } @@ -578,8 +579,7 @@ end: * @returns New visitor context, or NULL on error */ static -struct ctx *ctx_create(bt_self_component_source *self_comp, - const struct ctf_metadata_decoder_config *decoder_config) +struct ctx *ctx_create(const struct ctf_metadata_decoder_config *decoder_config) { struct ctx *ctx = NULL; @@ -587,34 +587,34 @@ struct ctx *ctx_create(bt_self_component_source *self_comp, ctx = g_new0(struct ctx, 1); if (!ctx) { - BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, decoder_config->log_level, - BT_LOG_TAG, + BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, decoder_config->log_level, + decoder_config->self_comp, "Failed to allocate one visitor context."); goto error; } - ctx->log_level = decoder_config->log_level; + ctx->log_cfg.log_level = decoder_config->log_level; + ctx->log_cfg.self_comp = decoder_config->self_comp; - if (self_comp) { + if (decoder_config->self_comp) { ctx->trace_class = bt_trace_class_create( - bt_self_component_source_as_self_component(self_comp)); + decoder_config->self_comp); if (!ctx->trace_class) { - BT_LOGE_STR("Cannot create empty trace class."); + BT_COMP_LOGE_STR("Cannot create empty trace class."); goto error; } - ctx->self_comp = self_comp; } ctx->ctf_tc = ctf_trace_class_create(); if (!ctx->ctf_tc) { - BT_LOGE_STR("Cannot create CTF trace class."); + BT_COMP_LOGE_STR("Cannot create CTF trace class."); goto error; } /* Root declaration scope */ ctx->current_scope = ctx_decl_scope_create(ctx, NULL); if (!ctx->current_scope) { - BT_LOGE_STR("Cannot create declaration scope."); + BT_COMP_LOGE_STR("Cannot create declaration scope."); goto error; } @@ -645,7 +645,7 @@ int ctx_push_scope(struct ctx *ctx) BT_ASSERT(ctx); new_scope = ctx_decl_scope_create(ctx, ctx->current_scope); if (!new_scope) { - BT_LOGE_STR("Cannot create declaration scope."); + BT_COMP_LOGE_STR("Cannot create declaration scope."); ret = -ENOMEM; goto end; } @@ -693,7 +693,7 @@ char *remove_underscores_from_field_ref(struct ctx *ctx, const char *field_ref) BT_ASSERT(field_ref); ret = calloc(strlen(field_ref) + 1, 1); if (!ret) { - BT_LOGE("Failed to allocate a string: size=%zu", + BT_COMP_LOGE("Failed to allocate a string: size=%zu", strlen(field_ref) + 1); goto end; } @@ -906,7 +906,7 @@ int get_unary_unsigned(struct ctx *ctx, struct bt_list_head *head, uexpr_type != UNARY_UNSIGNED_CONSTANT || uexpr_link != UNARY_LINK_UNKNOWN || i != 0; if (cond) { - _BT_LOGE_NODE(node, "Invalid constant unsigned integer."); + _BT_COMP_LOGE_NODE(node, "Invalid constant unsigned integer."); ret = -EINVAL; goto end; } @@ -1001,7 +1001,7 @@ int get_unary_uuid(struct ctx *ctx, struct bt_list_head *head, src_string = node->u.unary_expression.u.string; ret = bt_uuid_parse(src_string, uuid); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot parse UUID: uuid=\"%s\"", src_string); goto end; } @@ -1017,7 +1017,7 @@ int get_boolean(struct ctx *ctx, struct ctf_node *unary_expr) int ret = 0; if (unary_expr->type != NODE_UNARY_EXPRESSION) { - _BT_LOGE_NODE(unary_expr, + _BT_COMP_LOGE_NODE(unary_expr, "Expecting unary expression: node-type=%d", unary_expr->type); ret = -EINVAL; @@ -1040,7 +1040,7 @@ int get_boolean(struct ctx *ctx, struct ctf_node *unary_expr) } else if (!strcmp(str, "false") || !strcmp(str, "FALSE")) { ret = FALSE; } else { - _BT_LOGE_NODE(unary_expr, + _BT_COMP_LOGE_NODE(unary_expr, "Unexpected boolean value: value=\"%s\"", str); ret = -EINVAL; goto end; @@ -1048,7 +1048,7 @@ int get_boolean(struct ctx *ctx, struct ctf_node *unary_expr) break; } default: - _BT_LOGE_NODE(unary_expr, + _BT_COMP_LOGE_NODE(unary_expr, "Unexpected unary expression type: node-type=%d", unary_expr->u.unary_expression.type); ret = -EINVAL; @@ -1067,7 +1067,7 @@ enum ctf_byte_order byte_order_from_unary_expr(struct ctx *ctx, enum ctf_byte_order bo = -1; if (unary_expr->u.unary_expression.type != UNARY_STRING) { - _BT_LOGE_NODE(unary_expr, + _BT_COMP_LOGE_NODE(unary_expr, "\"byte_order\" attribute: expecting `be`, `le`, `network`, or `native`."); goto end; } @@ -1081,7 +1081,7 @@ enum ctf_byte_order byte_order_from_unary_expr(struct ctx *ctx, } else if (!strcmp(str, "native")) { bo = CTF_BYTE_ORDER_DEFAULT; } else { - _BT_LOGE_NODE(unary_expr, + _BT_COMP_LOGE_NODE(unary_expr, "Unexpected \"byte_order\" attribute value: " "expecting `be`, `le`, `network`, or `native`: value=\"%s\"", str); @@ -1118,7 +1118,7 @@ int get_class_specifier_name(struct ctx *ctx, struct ctf_node *cls_specifier, int ret = 0; if (cls_specifier->type != NODE_TYPE_SPECIFIER) { - _BT_LOGE_NODE(cls_specifier, + _BT_COMP_LOGE_NODE(cls_specifier, "Unexpected node type: node-type=%d", cls_specifier->type); ret = -EINVAL; @@ -1176,7 +1176,7 @@ int get_class_specifier_name(struct ctx *ctx, struct ctf_node *cls_specifier, struct ctf_node *node = cls_specifier->u.field_class_specifier.node; if (!node->u._struct.name) { - _BT_LOGE_NODE(node, "Unexpected empty structure field class name."); + _BT_COMP_LOGE_NODE(node, "Unexpected empty structure field class name."); ret = -EINVAL; goto end; } @@ -1190,7 +1190,7 @@ int get_class_specifier_name(struct ctx *ctx, struct ctf_node *cls_specifier, struct ctf_node *node = cls_specifier->u.field_class_specifier.node; if (!node->u.variant.name) { - _BT_LOGE_NODE(node, "Unexpected empty variant field class name."); + _BT_COMP_LOGE_NODE(node, "Unexpected empty variant field class name."); ret = -EINVAL; goto end; } @@ -1204,7 +1204,7 @@ int get_class_specifier_name(struct ctx *ctx, struct ctf_node *cls_specifier, struct ctf_node *node = cls_specifier->u.field_class_specifier.node; if (!node->u._enum.enum_id) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Unexpected empty enumeration field class (`enum`) name."); ret = -EINVAL; goto end; @@ -1218,7 +1218,7 @@ int get_class_specifier_name(struct ctx *ctx, struct ctf_node *cls_specifier, case TYPESPEC_INTEGER: case TYPESPEC_STRING: default: - _BT_LOGE_NODE(cls_specifier->u.field_class_specifier.node, + _BT_COMP_LOGE_NODE(cls_specifier->u.field_class_specifier.node, "Unexpected field class specifier type: %d", cls_specifier->u.field_class_specifier.type); ret = -EINVAL; @@ -1310,7 +1310,7 @@ int visit_field_class_declarator(struct ctx *ctx, if (node_field_class_declarator) { if (node_field_class_declarator->u.field_class_declarator.type == TYPEDEC_UNKNOWN) { - _BT_LOGE_NODE(node_field_class_declarator, + _BT_COMP_LOGE_NODE(node_field_class_declarator, "Unexpected field class declarator type: type=%d", node_field_class_declarator->u.field_class_declarator.type); ret = -EINVAL; @@ -1320,7 +1320,7 @@ int visit_field_class_declarator(struct ctx *ctx, /* TODO: GCC bitfields not supported yet */ if (node_field_class_declarator->u.field_class_declarator.bitfield_len != NULL) { - _BT_LOGE_NODE(node_field_class_declarator, + _BT_COMP_LOGE_NODE(node_field_class_declarator, "GCC bitfields are not supported as of this version."); ret = -EPERM; goto error; @@ -1347,7 +1347,7 @@ int visit_field_class_declarator(struct ctx *ctx, ctx->current_scope, g_quark_to_string(qalias), -1, true); if (!nested_decl) { - _BT_LOGE_NODE(node_field_class_declarator, + _BT_COMP_LOGE_NODE(node_field_class_declarator, "Cannot find class alias: name=\"%s\"", g_quark_to_string(qalias)); ret = -EINVAL; @@ -1407,7 +1407,7 @@ int visit_field_class_declarator(struct ctx *ctx, /* Create array/sequence, pass nested_decl as child */ if (bt_list_empty(length)) { - _BT_LOGE_NODE(node_field_class_declarator, + _BT_COMP_LOGE_NODE(node_field_class_declarator, "Expecting length field reference or value."); ret = -EINVAL; goto error; @@ -1415,7 +1415,7 @@ int visit_field_class_declarator(struct ctx *ctx, first = _BT_LIST_FIRST_ENTRY(length, struct ctf_node, siblings); if (first->type != NODE_UNARY_EXPRESSION) { - _BT_LOGE_NODE(first, + _BT_COMP_LOGE_NODE(first, "Unexpected node type: node-type=%d", first->type); ret = -EINVAL; @@ -1443,7 +1443,7 @@ int visit_field_class_declarator(struct ctx *ctx, char *length_name = concatenate_unary_strings(length); if (!length_name) { - _BT_LOGE_NODE(node_field_class_declarator, + _BT_COMP_LOGE_NODE(node_field_class_declarator, "Cannot concatenate unary strings."); ret = -EINVAL; goto error; @@ -1458,7 +1458,7 @@ int visit_field_class_declarator(struct ctx *ctx, struct ctf_field_class_array *array_decl; if (!env_entry) { - _BT_LOGE_NODE(node_field_class_declarator, + _BT_COMP_LOGE_NODE(node_field_class_declarator, "Cannot find environment entry: " "name=\"%s\"", env_entry_name); ret = -EINVAL; @@ -1466,7 +1466,7 @@ int visit_field_class_declarator(struct ctx *ctx, } if (env_entry->type != CTF_TRACE_CLASS_ENV_ENTRY_TYPE_INT) { - _BT_LOGE_NODE(node_field_class_declarator, + _BT_COMP_LOGE_NODE(node_field_class_declarator, "Wrong environment entry type " "(expecting integer): " "name=\"%s\"", env_entry_name); @@ -1475,7 +1475,7 @@ int visit_field_class_declarator(struct ctx *ctx, } if (env_entry->value.i < 0) { - _BT_LOGE_NODE(node_field_class_declarator, + _BT_COMP_LOGE_NODE(node_field_class_declarator, "Invalid, negative array length: " "env-entry-name=\"%s\", " "value=%" PRId64, @@ -1586,7 +1586,7 @@ int visit_struct_decl_field(struct ctx *ctx, &qfield_name, iter, &field_decl, NULL); if (ret) { BT_ASSERT(!field_decl); - _BT_LOGE_NODE(cls_specifier_list, + _BT_COMP_LOGE_NODE(cls_specifier_list, "Cannot visit field class declarator: ret=%d", ret); goto error; } @@ -1597,7 +1597,7 @@ int visit_struct_decl_field(struct ctx *ctx, /* Check if field with same name already exists */ if (ctf_field_class_struct_borrow_member_by_name( struct_decl, field_name)) { - _BT_LOGE_NODE(cls_specifier_list, + _BT_COMP_LOGE_NODE(cls_specifier_list, "Duplicate field in structure field class: " "field-name=\"%s\"", field_name); ret = -EINVAL; @@ -1637,7 +1637,7 @@ int visit_variant_decl_field(struct ctx *ctx, &qfield_name, iter, &field_decl, NULL); if (ret) { BT_ASSERT(!field_decl); - _BT_LOGE_NODE(cls_specifier_list, + _BT_COMP_LOGE_NODE(cls_specifier_list, "Cannot visit field class declarator: ret=%d", ret); goto error; } @@ -1648,7 +1648,7 @@ int visit_variant_decl_field(struct ctx *ctx, /* Check if field with same name already exists */ if (ctf_field_class_variant_borrow_option_by_name( variant_decl, field_name)) { - _BT_LOGE_NODE(cls_specifier_list, + _BT_COMP_LOGE_NODE(cls_specifier_list, "Duplicate field in variant field class: " "field-name=\"%s\"", field_name); ret = -EINVAL; @@ -1682,7 +1682,7 @@ int visit_field_class_def(struct ctx *ctx, struct ctf_node *cls_specifier_list, ret = visit_field_class_declarator(ctx, cls_specifier_list, &qidentifier, iter, &class_decl, NULL); if (ret) { - _BT_LOGE_NODE(iter, + _BT_COMP_LOGE_NODE(iter, "Cannot visit field class declarator: ret=%d", ret); ret = -EINVAL; goto end; @@ -1694,7 +1694,7 @@ int visit_field_class_def(struct ctx *ctx, struct ctf_node *cls_specifier_list, (void *) class_decl; if (var_fc->tag_path.path->len == 0) { - _BT_LOGE_NODE(iter, + _BT_COMP_LOGE_NODE(iter, "Type definition of untagged variant field class is not allowed."); ret = -EPERM; goto end; @@ -1704,7 +1704,7 @@ int visit_field_class_def(struct ctx *ctx, struct ctf_node *cls_specifier_list, ret = ctx_decl_scope_register_alias(ctx, ctx->current_scope, g_quark_to_string(qidentifier), class_decl); if (ret) { - _BT_LOGE_NODE(iter, + _BT_COMP_LOGE_NODE(iter, "Cannot register field class alias: name=\"%s\"", g_quark_to_string(qidentifier)); goto end; @@ -1741,7 +1741,7 @@ int visit_field_class_alias(struct ctx *ctx, struct ctf_node *target, &qdummy_field_name, node, &class_decl, NULL); if (ret) { BT_ASSERT(!class_decl); - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot visit field class declarator: ret=%d", ret); goto end; } @@ -1751,7 +1751,7 @@ int visit_field_class_alias(struct ctx *ctx, struct ctf_node *target, struct ctf_field_class_variant *var_fc = (void *) class_decl; if (var_fc->tag_path.path->len == 0) { - _BT_LOGE_NODE(target, + _BT_COMP_LOGE_NODE(target, "Type definition of untagged variant field class is not allowed."); ret = -EPERM; goto end; @@ -1763,7 +1763,7 @@ int visit_field_class_alias(struct ctx *ctx, struct ctf_node *target, * abstract or not (if it has an identifier). Check it here. */ if (qdummy_field_name != 0) { - _BT_LOGE_NODE(target, + _BT_COMP_LOGE_NODE(target, "Expecting empty identifier: id=\"%s\"", g_quark_to_string(qdummy_field_name)); ret = -EINVAL; @@ -1778,7 +1778,7 @@ int visit_field_class_alias(struct ctx *ctx, struct ctf_node *target, ret = ctx_decl_scope_register_alias(ctx, ctx->current_scope, g_quark_to_string(qalias), class_decl); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot register class alias: name=\"%s\"", g_quark_to_string(qalias)); goto end; @@ -1802,7 +1802,7 @@ int visit_struct_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, entry_node->u.field_class_def.field_class_specifier_list, &entry_node->u.field_class_def.field_class_declarators); if (ret) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Cannot add field class found in structure field class: ret=%d", ret); goto end; @@ -1812,7 +1812,7 @@ int visit_struct_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, ret = visit_field_class_alias(ctx, entry_node->u.field_class_alias.target, entry_node->u.field_class_alias.alias); if (ret) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Cannot add field class alias found in structure field class: ret=%d", ret); goto end; @@ -1830,7 +1830,7 @@ int visit_struct_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, } break; default: - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Unexpected node type: node-type=%d", entry_node->type); ret = -EINVAL; goto end; @@ -1852,7 +1852,7 @@ int visit_variant_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, entry_node->u.field_class_def.field_class_specifier_list, &entry_node->u.field_class_def.field_class_declarators); if (ret) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Cannot add field class found in variant field class: ret=%d", ret); goto end; @@ -1862,7 +1862,7 @@ int visit_variant_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, ret = visit_field_class_alias(ctx, entry_node->u.field_class_alias.target, entry_node->u.field_class_alias.alias); if (ret) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Cannot add field class alias found in variant field class: ret=%d", ret); goto end; @@ -1880,7 +1880,7 @@ int visit_variant_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, } break; default: - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Unexpected node type: node-type=%d", entry_node->type); ret = -EINVAL; @@ -1905,7 +1905,7 @@ int visit_struct_decl(struct ctx *ctx, const char *name, /* For named struct (without body), lookup in declaration scope */ if (!has_body) { if (!name) { - BT_LOGE_STR("Bodyless structure field class: missing name."); + BT_COMP_LOGE_STR("Bodyless structure field class: missing name."); ret = -EPERM; goto error; } @@ -1913,7 +1913,7 @@ int visit_struct_decl(struct ctx *ctx, const char *name, *struct_decl = ctx_decl_scope_lookup_struct(ctx, ctx->current_scope, name, -1, true); if (!*struct_decl) { - BT_LOGE("Cannot find structure field class: name=\"struct %s\"", + BT_COMP_LOGE("Cannot find structure field class: name=\"struct %s\"", name); ret = -EINVAL; goto error; @@ -1925,7 +1925,7 @@ int visit_struct_decl(struct ctx *ctx, const char *name, if (name) { if (ctx_decl_scope_lookup_struct(ctx, ctx->current_scope, name, 1, false)) { - BT_LOGE("Structure field class already declared in local scope: " + BT_COMP_LOGE("Structure field class already declared in local scope: " "name=\"struct %s\"", name); ret = -EINVAL; goto error; @@ -1936,7 +1936,7 @@ int visit_struct_decl(struct ctx *ctx, const char *name, ret = get_unary_unsigned(ctx, min_align, &min_align_value); if (ret) { - BT_LOGE("Unexpected unary expression for structure field class's `align` attribute: " + BT_COMP_LOGE("Unexpected unary expression for structure field class's `align` attribute: " "ret=%d", ret); goto error; } @@ -1955,7 +1955,7 @@ int visit_struct_decl(struct ctx *ctx, const char *name, ret = visit_struct_decl_entry(ctx, entry_node, *struct_decl); if (ret) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Cannot visit structure field class entry: " "ret=%d", ret); ctx_pop_scope(ctx); @@ -1969,7 +1969,7 @@ int visit_struct_decl(struct ctx *ctx, const char *name, ret = ctx_decl_scope_register_struct(ctx, ctx->current_scope, name, *struct_decl); if (ret) { - BT_LOGE("Cannot register structure field class in declaration scope: " + BT_COMP_LOGE("Cannot register structure field class in declaration scope: " "name=\"struct %s\", ret=%d", name, ret); goto error; } @@ -1998,7 +1998,7 @@ int visit_variant_decl(struct ctx *ctx, const char *name, /* For named variant (without body), lookup in declaration scope */ if (!has_body) { if (!name) { - BT_LOGE_STR("Bodyless variant field class: missing name."); + BT_COMP_LOGE_STR("Bodyless variant field class: missing name."); ret = -EPERM; goto error; } @@ -2007,7 +2007,7 @@ int visit_variant_decl(struct ctx *ctx, const char *name, ctx_decl_scope_lookup_variant(ctx, ctx->current_scope, name, -1, true); if (!untagged_variant_decl) { - BT_LOGE("Cannot find variant field class: name=\"variant %s\"", + BT_COMP_LOGE("Cannot find variant field class: name=\"variant %s\"", name); ret = -EINVAL; goto error; @@ -2018,7 +2018,7 @@ int visit_variant_decl(struct ctx *ctx, const char *name, if (name) { if (ctx_decl_scope_lookup_variant(ctx, ctx->current_scope, name, 1, false)) { - BT_LOGE("Variant field class already declared in local scope: " + BT_COMP_LOGE("Variant field class already declared in local scope: " "name=\"variant %s\"", name); ret = -EINVAL; goto error; @@ -2033,7 +2033,7 @@ int visit_variant_decl(struct ctx *ctx, const char *name, ret = visit_variant_decl_entry(ctx, entry_node, untagged_variant_decl); if (ret) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Cannot visit variant field class entry: " "ret=%d", ret); ctx_pop_scope(ctx); @@ -2048,7 +2048,7 @@ int visit_variant_decl(struct ctx *ctx, const char *name, ctx->current_scope, name, untagged_variant_decl); if (ret) { - BT_LOGE("Cannot register variant field class in declaration scope: " + BT_COMP_LOGE("Cannot register variant field class in declaration scope: " "name=\"variant %s\", ret=%d", name, ret); goto error; } @@ -2125,7 +2125,7 @@ int visit_enum_decl_entry(struct ctx *ctx, struct ctf_node *enumerator, struct uori *target; if (iter->type != NODE_UNARY_EXPRESSION) { - _BT_LOGE_NODE(iter, + _BT_COMP_LOGE_NODE(iter, "Wrong expression for enumeration field class label: " "node-type=%d, label=\"%s\"", iter->type, label); @@ -2151,7 +2151,7 @@ int visit_enum_decl_entry(struct ctx *ctx, struct ctf_node *enumerator, iter->u.unary_expression.u.unsigned_constant; break; default: - _BT_LOGE_NODE(iter, + _BT_COMP_LOGE_NODE(iter, "Invalid enumeration field class entry: " "expecting constant signed or unsigned integer: " "node-type=%d, label=\"%s\"", @@ -2161,7 +2161,7 @@ int visit_enum_decl_entry(struct ctx *ctx, struct ctf_node *enumerator, } if (nr_vals > 1) { - _BT_LOGE_NODE(iter, + _BT_COMP_LOGE_NODE(iter, "Invalid enumeration field class entry: label=\"%s\"", label); ret = -EINVAL; @@ -2221,7 +2221,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name, /* For named enum (without body), lookup in declaration scope */ if (!has_body) { if (!name) { - BT_LOGE_STR("Bodyless enumeration field class: missing name."); + BT_COMP_LOGE_STR("Bodyless enumeration field class: missing name."); ret = -EPERM; goto error; } @@ -2229,7 +2229,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name, *enum_decl = ctx_decl_scope_lookup_enum(ctx, ctx->current_scope, name, -1, true); if (!*enum_decl) { - BT_LOGE("Cannot find enumeration field class: " + BT_COMP_LOGE("Cannot find enumeration field class: " "name=\"enum %s\"", name); ret = -EINVAL; goto error; @@ -2244,7 +2244,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name, if (name) { if (ctx_decl_scope_lookup_enum(ctx, ctx->current_scope, name, 1, false)) { - BT_LOGE("Enumeration field class already declared in local scope: " + BT_COMP_LOGE("Enumeration field class already declared in local scope: " "name=\"enum %s\"", name); ret = -EINVAL; goto error; @@ -2255,7 +2255,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name, integer_decl = (void *) ctx_decl_scope_lookup_alias(ctx, ctx->current_scope, "int", -1, true); if (!integer_decl) { - BT_LOGE_STR("Cannot find implicit `int` field class alias for enumeration field class."); + BT_COMP_LOGE_STR("Cannot find implicit `int` field class alias for enumeration field class."); ret = -EINVAL; goto error; } @@ -2273,7 +2273,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name, BT_ASSERT(integer_decl); if (integer_decl->base.base.type != CTF_FIELD_CLASS_TYPE_INT) { - BT_LOGE("Container field class for enumeration field class is not an integer field class: " + BT_COMP_LOGE("Container field class for enumeration field class is not an integer field class: " "fc-type=%d", integer_decl->base.base.type); ret = -EINVAL; goto error; @@ -2291,7 +2291,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name, ret = visit_enum_decl_entry(ctx, iter, *enum_decl, &last_value); if (ret) { - _BT_LOGE_NODE(iter, + _BT_COMP_LOGE_NODE(iter, "Cannot visit enumeration field class entry: " "ret=%d", ret); goto error; @@ -2302,7 +2302,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name, ret = ctx_decl_scope_register_enum(ctx, ctx->current_scope, name, *enum_decl); if (ret) { - BT_LOGE("Cannot register enumeration field class in declaration scope: " + BT_COMP_LOGE("Cannot register enumeration field class in declaration scope: " "ret=%d", ret); goto error; } @@ -2333,7 +2333,7 @@ int visit_field_class_specifier(struct ctx *ctx, str = g_string_new(""); ret = get_class_specifier_list_name(ctx, cls_specifier_list, str); if (ret) { - _BT_LOGE_NODE(cls_specifier_list, + _BT_COMP_LOGE_NODE(cls_specifier_list, "Cannot get field class specifier list's name: ret=%d", ret); goto error; } @@ -2341,7 +2341,7 @@ int visit_field_class_specifier(struct ctx *ctx, *decl = ctx_decl_scope_lookup_alias(ctx, ctx->current_scope, str->str, -1, true); if (!*decl) { - _BT_LOGE_NODE(cls_specifier_list, + _BT_COMP_LOGE_NODE(cls_specifier_list, "Cannot find field class alias: name=\"%s\"", str->str); ret = -EINVAL; goto error; @@ -2389,7 +2389,7 @@ int visit_integer_decl(struct ctx *ctx, siblings); if (left->u.unary_expression.type != UNARY_STRING) { - _BT_LOGE_NODE(left, + _BT_COMP_LOGE_NODE(left, "Unexpected unary expression type: type=%d", left->u.unary_expression.type); ret = -EINVAL; @@ -2398,7 +2398,7 @@ int visit_integer_decl(struct ctx *ctx, if (!strcmp(left->u.unary_expression.u.string, "signed")) { if (_IS_SET(&set, _INTEGER_SIGNED_SET)) { - _BT_LOGE_DUP_ATTR(left, "signed", + _BT_COMP_LOGE_DUP_ATTR(left, "signed", "integer field class"); ret = -EPERM; goto error; @@ -2406,7 +2406,7 @@ int visit_integer_decl(struct ctx *ctx, signedness = get_boolean(ctx, right); if (signedness < 0) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid boolean value for integer field class's `signed` attribute: " "ret=%d", ret); ret = -EINVAL; @@ -2417,7 +2417,7 @@ int visit_integer_decl(struct ctx *ctx, } else if (!strcmp(left->u.unary_expression.u.string, "byte_order")) { if (_IS_SET(&set, _INTEGER_BYTE_ORDER_SET)) { - _BT_LOGE_DUP_ATTR(left, "byte_order", + _BT_COMP_LOGE_DUP_ATTR(left, "byte_order", "integer field class"); ret = -EPERM; goto error; @@ -2425,7 +2425,7 @@ int visit_integer_decl(struct ctx *ctx, byte_order = get_real_byte_order(ctx, right); if (byte_order == -1) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `byte_order` attribute in integer field class: " "ret=%d", ret); ret = -EINVAL; @@ -2435,7 +2435,7 @@ int visit_integer_decl(struct ctx *ctx, _SET(&set, _INTEGER_BYTE_ORDER_SET); } else if (!strcmp(left->u.unary_expression.u.string, "size")) { if (_IS_SET(&set, _INTEGER_SIZE_SET)) { - _BT_LOGE_DUP_ATTR(left, "size", + _BT_COMP_LOGE_DUP_ATTR(left, "size", "integer field class"); ret = -EPERM; goto error; @@ -2443,7 +2443,7 @@ int visit_integer_decl(struct ctx *ctx, if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `size` attribute in integer field class: " "expecting unsigned constant integer: " "node-type=%d", @@ -2454,14 +2454,14 @@ int visit_integer_decl(struct ctx *ctx, size = right->u.unary_expression.u.unsigned_constant; if (size == 0) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `size` attribute in integer field class: " "expecting positive constant integer: " "size=%" PRIu64, size); ret = -EINVAL; goto error; } else if (size > 64) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `size` attribute in integer field class: " "integer fields over 64 bits are not supported as of this version: " "size=%" PRIu64, size); @@ -2473,7 +2473,7 @@ int visit_integer_decl(struct ctx *ctx, } else if (!strcmp(left->u.unary_expression.u.string, "align")) { if (_IS_SET(&set, _INTEGER_ALIGN_SET)) { - _BT_LOGE_DUP_ATTR(left, "align", + _BT_COMP_LOGE_DUP_ATTR(left, "align", "integer field class"); ret = -EPERM; goto error; @@ -2481,7 +2481,7 @@ int visit_integer_decl(struct ctx *ctx, if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `align` attribute in integer field class: " "expecting unsigned constant integer: " "node-type=%d", @@ -2493,7 +2493,7 @@ int visit_integer_decl(struct ctx *ctx, alignment = right->u.unary_expression.u.unsigned_constant; if (!is_align_valid(alignment)) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `align` attribute in integer field class: " "expecting power of two: " "align=%" PRIu64, alignment); @@ -2504,7 +2504,7 @@ int visit_integer_decl(struct ctx *ctx, _SET(&set, _INTEGER_ALIGN_SET); } else if (!strcmp(left->u.unary_expression.u.string, "base")) { if (_IS_SET(&set, _INTEGER_BASE_SET)) { - _BT_LOGE_DUP_ATTR(left, "base", + _BT_COMP_LOGE_DUP_ATTR(left, "base", "integer field class"); ret = -EPERM; goto error; @@ -2530,7 +2530,7 @@ int visit_integer_decl(struct ctx *ctx, base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL; break; default: - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `base` attribute in integer field class: " "base=%" PRIu64, right->u.unary_expression.u.unsigned_constant); @@ -2544,7 +2544,7 @@ int visit_integer_decl(struct ctx *ctx, char *s_right = concatenate_unary_strings( &expression->u.ctf_expression.right); if (!s_right) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Unexpected unary expression for integer field class's `base` attribute."); ret = -EINVAL; goto error; @@ -2570,7 +2570,7 @@ int visit_integer_decl(struct ctx *ctx, !strcmp(s_right, "b")) { base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY; } else { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Unexpected unary expression for integer field class's `base` attribute: " "base=\"%s\"", s_right); g_free(s_right); @@ -2582,7 +2582,7 @@ int visit_integer_decl(struct ctx *ctx, break; } default: - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `base` attribute in integer field class: " "expecting unsigned constant integer or unary string."); ret = -EINVAL; @@ -2595,14 +2595,14 @@ int visit_integer_decl(struct ctx *ctx, char *s_right; if (_IS_SET(&set, _INTEGER_ENCODING_SET)) { - _BT_LOGE_DUP_ATTR(left, "encoding", + _BT_COMP_LOGE_DUP_ATTR(left, "encoding", "integer field class"); ret = -EPERM; goto error; } if (right->u.unary_expression.type != UNARY_STRING) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `encoding` attribute in integer field class: " "expecting unary string."); ret = -EINVAL; @@ -2612,7 +2612,7 @@ int visit_integer_decl(struct ctx *ctx, s_right = concatenate_unary_strings( &expression->u.ctf_expression.right); if (!s_right) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Unexpected unary expression for integer field class's `encoding` attribute."); ret = -EINVAL; goto error; @@ -2628,7 +2628,7 @@ int visit_integer_decl(struct ctx *ctx, } else if (!strcmp(s_right, "none")) { encoding = CTF_ENCODING_NONE; } else { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `encoding` attribute in integer field class: " "unknown encoding: encoding=\"%s\"", s_right); @@ -2643,14 +2643,14 @@ int visit_integer_decl(struct ctx *ctx, const char *clock_name; if (_IS_SET(&set, _INTEGER_MAP_SET)) { - _BT_LOGE_DUP_ATTR(left, "map", + _BT_COMP_LOGE_DUP_ATTR(left, "map", "integer field class"); ret = -EPERM; goto error; } if (right->u.unary_expression.type != UNARY_STRING) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `map` attribute in integer field class: " "expecting unary string."); ret = -EINVAL; @@ -2665,13 +2665,13 @@ int visit_integer_decl(struct ctx *ctx, &expression->u.ctf_expression.right); if (!s_right) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Unexpected unary expression for integer field class's `map` attribute."); ret = -EINVAL; goto error; } - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `map` attribute in integer field class: " "cannot find clock class at this point: name=\"%s\"", s_right); @@ -2684,7 +2684,7 @@ int visit_integer_decl(struct ctx *ctx, ctf_trace_class_borrow_clock_class_by_name( ctx->ctf_tc, clock_name); if (!mapped_clock_class) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `map` attribute in integer field class: " "cannot find clock class at this point: name=\"%s\"", clock_name); @@ -2694,7 +2694,7 @@ int visit_integer_decl(struct ctx *ctx, _SET(&set, _INTEGER_MAP_SET); } else { - _BT_LOGW_NODE(left, + _BT_COMP_LOGW_NODE(left, "Unknown attribute in integer field class: " "attr-name=\"%s\"", left->u.unary_expression.u.string); @@ -2702,7 +2702,7 @@ int visit_integer_decl(struct ctx *ctx, } if (!_IS_SET(&set, _INTEGER_SIZE_SET)) { - BT_LOGE_STR("Missing `size` attribute in integer field class."); + BT_COMP_LOGE_STR("Missing `size` attribute in integer field class."); ret = -EPERM; goto error; } @@ -2757,7 +2757,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, siblings); if (left->u.unary_expression.type != UNARY_STRING) { - _BT_LOGE_NODE(left, + _BT_COMP_LOGE_NODE(left, "Unexpected unary expression type: type=%d", left->u.unary_expression.type); ret = -EINVAL; @@ -2766,7 +2766,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, if (!strcmp(left->u.unary_expression.u.string, "byte_order")) { if (_IS_SET(&set, _FLOAT_BYTE_ORDER_SET)) { - _BT_LOGE_DUP_ATTR(left, "byte_order", + _BT_COMP_LOGE_DUP_ATTR(left, "byte_order", "floating point number field class"); ret = -EPERM; goto error; @@ -2774,7 +2774,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, byte_order = get_real_byte_order(ctx, right); if (byte_order == -1) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `byte_order` attribute in floating point number field class: " "ret=%d", ret); ret = -EINVAL; @@ -2785,7 +2785,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, } else if (!strcmp(left->u.unary_expression.u.string, "exp_dig")) { if (_IS_SET(&set, _FLOAT_EXP_DIG_SET)) { - _BT_LOGE_DUP_ATTR(left, "exp_dig", + _BT_COMP_LOGE_DUP_ATTR(left, "exp_dig", "floating point number field class"); ret = -EPERM; goto error; @@ -2793,7 +2793,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `exp_dig` attribute in floating point number field class: " "expecting unsigned constant integer: " "node-type=%d", @@ -2807,7 +2807,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, } else if (!strcmp(left->u.unary_expression.u.string, "mant_dig")) { if (_IS_SET(&set, _FLOAT_MANT_DIG_SET)) { - _BT_LOGE_DUP_ATTR(left, "mant_dig", + _BT_COMP_LOGE_DUP_ATTR(left, "mant_dig", "floating point number field class"); ret = -EPERM; goto error; @@ -2815,7 +2815,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `mant_dig` attribute in floating point number field class: " "expecting unsigned constant integer: " "node-type=%d", @@ -2830,7 +2830,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, } else if (!strcmp(left->u.unary_expression.u.string, "align")) { if (_IS_SET(&set, _FLOAT_ALIGN_SET)) { - _BT_LOGE_DUP_ATTR(left, "align", + _BT_COMP_LOGE_DUP_ATTR(left, "align", "floating point number field class"); ret = -EPERM; goto error; @@ -2838,7 +2838,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `align` attribute in floating point number field class: " "expecting unsigned constant integer: " "node-type=%d", @@ -2851,7 +2851,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, unsigned_constant; if (!is_align_valid(alignment)) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `align` attribute in floating point number field class: " "expecting power of two: " "align=%" PRIu64, alignment); @@ -2861,7 +2861,7 @@ int visit_floating_point_number_decl(struct ctx *ctx, _SET(&set, _FLOAT_ALIGN_SET); } else { - _BT_LOGW_NODE(left, + _BT_COMP_LOGW_NODE(left, "Unknown attribute in floating point number field class: " "attr-name=\"%s\"", left->u.unary_expression.u.string); @@ -2869,31 +2869,31 @@ int visit_floating_point_number_decl(struct ctx *ctx, } if (!_IS_SET(&set, _FLOAT_MANT_DIG_SET)) { - BT_LOGE_STR("Missing `mant_dig` attribute in floating point number field class."); + BT_COMP_LOGE_STR("Missing `mant_dig` attribute in floating point number field class."); ret = -EPERM; goto error; } if (!_IS_SET(&set, _FLOAT_EXP_DIG_SET)) { - BT_LOGE_STR("Missing `exp_dig` attribute in floating point number field class."); + BT_COMP_LOGE_STR("Missing `exp_dig` attribute in floating point number field class."); ret = -EPERM; goto error; } if (mant_dig != 24 && mant_dig != 53) { - BT_LOGE_STR("`mant_dig` attribute: expecting 24 or 53."); + BT_COMP_LOGE_STR("`mant_dig` attribute: expecting 24 or 53."); ret = -EPERM; goto error; } if (mant_dig == 24 && exp_dig != 8) { - BT_LOGE_STR("`exp_dig` attribute: expecting 8 because `mant_dig` is 24."); + BT_COMP_LOGE_STR("`exp_dig` attribute: expecting 8 because `mant_dig` is 24."); ret = -EPERM; goto error; } if (mant_dig == 53 && exp_dig != 11) { - BT_LOGE_STR("`exp_dig` attribute: expecting 11 because `mant_dig` is 53."); + BT_COMP_LOGE_STR("`exp_dig` attribute: expecting 11 because `mant_dig` is 53."); ret = -EPERM; goto error; } @@ -2943,7 +2943,7 @@ int visit_string_decl(struct ctx *ctx, siblings); if (left->u.unary_expression.type != UNARY_STRING) { - _BT_LOGE_NODE(left, + _BT_COMP_LOGE_NODE(left, "Unexpected unary expression type: type=%d", left->u.unary_expression.type); ret = -EINVAL; @@ -2954,14 +2954,14 @@ int visit_string_decl(struct ctx *ctx, char *s_right; if (_IS_SET(&set, _STRING_ENCODING_SET)) { - _BT_LOGE_DUP_ATTR(left, "encoding", + _BT_COMP_LOGE_DUP_ATTR(left, "encoding", "string field class"); ret = -EPERM; goto error; } if (right->u.unary_expression.type != UNARY_STRING) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `encoding` attribute in string field class: " "expecting unary string."); ret = -EINVAL; @@ -2971,7 +2971,7 @@ int visit_string_decl(struct ctx *ctx, s_right = concatenate_unary_strings( &expression->u.ctf_expression.right); if (!s_right) { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Unexpected unary expression for string field class's `encoding` attribute."); ret = -EINVAL; goto error; @@ -2987,7 +2987,7 @@ int visit_string_decl(struct ctx *ctx, } else if (!strcmp(s_right, "none")) { encoding = CTF_ENCODING_NONE; } else { - _BT_LOGE_NODE(right, + _BT_COMP_LOGE_NODE(right, "Invalid `encoding` attribute in string field class: " "unknown encoding: encoding=\"%s\"", s_right); @@ -2999,7 +2999,7 @@ int visit_string_decl(struct ctx *ctx, g_free(s_right); _SET(&set, _STRING_ENCODING_SET); } else { - _BT_LOGW_NODE(left, + _BT_COMP_LOGW_NODE(left, "Unknown attribute in string field class: " "attr-name=\"%s\"", left->u.unary_expression.u.string); @@ -3027,7 +3027,7 @@ int visit_field_class_specifier_list(struct ctx *ctx, *decl = NULL; if (ts_list->type != NODE_TYPE_SPECIFIER_LIST) { - _BT_LOGE_NODE(ts_list, + _BT_COMP_LOGE_NODE(ts_list, "Unexpected node type: node-type=%d", ts_list->type); ret = -EINVAL; goto error; @@ -3036,7 +3036,7 @@ int visit_field_class_specifier_list(struct ctx *ctx, first = _BT_LIST_FIRST_ENTRY(&ts_list->u.field_class_specifier_list.head, struct ctf_node, siblings); if (first->type != NODE_TYPE_SPECIFIER) { - _BT_LOGE_NODE(first, + _BT_COMP_LOGE_NODE(first, "Unexpected node type: node-type=%d", first->type); ret = -EINVAL; goto error; @@ -3115,7 +3115,7 @@ int visit_field_class_specifier_list(struct ctx *ctx, case TYPESPEC_ID_TYPE: ret = visit_field_class_specifier(ctx, ts_list, decl); if (ret) { - _BT_LOGE_NODE(first, + _BT_COMP_LOGE_NODE(first, "Cannot visit field class specifier: ret=%d", ret); BT_ASSERT(!*decl); @@ -3123,7 +3123,7 @@ int visit_field_class_specifier_list(struct ctx *ctx, } break; default: - _BT_LOGE_NODE(first, + _BT_COMP_LOGE_NODE(first, "Unexpected field class specifier type: node-type=%d", first->u.field_class_specifier.type); ret = -EINVAL; @@ -3152,7 +3152,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = visit_field_class_def(ctx, node->u.field_class_def.field_class_specifier_list, &node->u.field_class_def.field_class_declarators); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot add field class found in event class."); goto error; } @@ -3161,7 +3161,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = visit_field_class_alias(ctx, node->u.field_class_alias.target, node->u.field_class_alias.alias); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot add field class alias found in event class."); goto error; } @@ -3170,7 +3170,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, { left = concatenate_unary_strings(&node->u.ctf_expression.left); if (!left) { - _BT_LOGE_NODE(node, "Cannot concatenate unary strings."); + _BT_COMP_LOGE_NODE(node, "Cannot concatenate unary strings."); ret = -EINVAL; goto error; } @@ -3178,7 +3178,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, if (!strcmp(left, "name")) { /* This is already known at this stage */ if (_IS_SET(set, _EVENT_NAME_SET)) { - _BT_LOGE_DUP_ATTR(node, "name", "event class"); + _BT_COMP_LOGE_DUP_ATTR(node, "name", "event class"); ret = -EPERM; goto error; } @@ -3188,7 +3188,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, int64_t id = -1; if (_IS_SET(set, _EVENT_ID_SET)) { - _BT_LOGE_DUP_ATTR(node, "id", "event class"); + _BT_COMP_LOGE_DUP_ATTR(node, "id", "event class"); ret = -EPERM; goto error; } @@ -3198,7 +3198,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, (uint64_t *) &id); /* Only read "id" if get_unary_unsigned() succeeded. */ if (ret || (!ret && id < 0)) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Unexpected unary expression for event class's `id` attribute."); ret = -EINVAL; goto error; @@ -3208,7 +3208,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, _SET(set, _EVENT_ID_SET); } else if (!strcmp(left, "stream_id")) { if (_IS_SET(set, _EVENT_STREAM_ID_SET)) { - _BT_LOGE_DUP_ATTR(node, "stream_id", + _BT_COMP_LOGE_DUP_ATTR(node, "stream_id", "event class"); ret = -EPERM; goto error; @@ -3222,7 +3222,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, * succeeded. */ if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Unexpected unary expression for event class's `stream_id` attribute."); ret = -EINVAL; goto error; @@ -3231,7 +3231,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, _SET(set, _EVENT_STREAM_ID_SET); } else if (!strcmp(left, "context")) { if (_IS_SET(set, _EVENT_CONTEXT_SET)) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Duplicate `context` entry in event class."); ret = -EPERM; goto error; @@ -3243,7 +3243,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, struct ctf_node, siblings), &event_class->spec_context_fc); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot create event class's context field class."); goto error; } @@ -3252,7 +3252,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, _SET(set, _EVENT_CONTEXT_SET); } else if (!strcmp(left, "fields")) { if (_IS_SET(set, _EVENT_FIELDS_SET)) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Duplicate `fields` entry in event class."); ret = -EPERM; goto error; @@ -3264,7 +3264,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, struct ctf_node, siblings), &event_class->payload_fc); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot create event class's payload field class."); goto error; } @@ -3276,7 +3276,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, bt_event_class_log_level log_level = -1; if (_IS_SET(set, _EVENT_LOG_LEVEL_SET)) { - _BT_LOGE_DUP_ATTR(node, "loglevel", + _BT_COMP_LOGE_DUP_ATTR(node, "loglevel", "event class"); ret = -EPERM; goto error; @@ -3285,7 +3285,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = get_unary_unsigned(ctx, &node->u.ctf_expression.right, &loglevel_value); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Unexpected unary expression for event class's `loglevel` attribute."); ret = -EINVAL; goto error; @@ -3338,7 +3338,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, log_level = BT_EVENT_CLASS_LOG_LEVEL_DEBUG; break; default: - _BT_LOGW_NODE(node, "Not setting event class's log level because its value is unknown: " + _BT_COMP_LOGW_NODE(node, "Not setting event class's log level because its value is unknown: " "log-level=%" PRIu64, loglevel_value); } @@ -3351,7 +3351,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, char *right; if (_IS_SET(set, _EVENT_MODEL_EMF_URI_SET)) { - _BT_LOGE_DUP_ATTR(node, "model.emf.uri", + _BT_COMP_LOGE_DUP_ATTR(node, "model.emf.uri", "event class"); ret = -EPERM; goto error; @@ -3360,14 +3360,14 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, right = concatenate_unary_strings( &node->u.ctf_expression.right); if (!right) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Unexpected unary expression for event class's `model.emf.uri` attribute."); ret = -EINVAL; goto error; } if (strlen(right) == 0) { - _BT_LOGW_NODE(node, + _BT_COMP_LOGW_NODE(node, "Not setting event class's EMF URI because it's empty."); } else { g_string_assign(event_class->emf_uri, @@ -3377,7 +3377,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, g_free(right); _SET(set, _EVENT_MODEL_EMF_URI_SET); } else { - _BT_LOGW_NODE(node, + _BT_COMP_LOGW_NODE(node, "Unknown attribute in event class: " "attr-name=\"%s\"", left); } @@ -3417,7 +3417,7 @@ char *get_event_decl_name(struct ctx *ctx, struct ctf_node *node) left = concatenate_unary_strings(&iter->u.ctf_expression.left); if (!left) { - _BT_LOGE_NODE(iter, + _BT_COMP_LOGE_NODE(iter, "Cannot concatenate unary strings."); goto error; } @@ -3426,7 +3426,7 @@ char *get_event_decl_name(struct ctx *ctx, struct ctf_node *node) name = concatenate_unary_strings( &iter->u.ctf_expression.right); if (!name) { - _BT_LOGE_NODE(iter, + _BT_COMP_LOGE_NODE(iter, "Unexpected unary expression for event class's `name` attribute."); goto error; } @@ -3467,7 +3467,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) node->visited = TRUE; event_name = get_event_decl_name(ctx, node); if (!event_name) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Missing `name` attribute in event class."); ret = -EPERM; goto error; @@ -3483,7 +3483,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) ret = visit_event_decl_entry(ctx, iter, event_class, &stream_id, &set); if (ret) { - _BT_LOGE_NODE(iter, "Cannot visit event class's entry: " + _BT_COMP_LOGE_NODE(iter, "Cannot visit event class's entry: " "ret=%d", ret); goto error; } @@ -3510,7 +3510,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) stream_id = stream_class->id; break; default: - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Missing `stream_id` attribute in event class."); ret = -EPERM; goto error; @@ -3522,7 +3522,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) stream_class = ctf_trace_class_borrow_stream_class_by_id( ctx->ctf_tc, stream_id); if (!stream_class) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot find stream class at this point: " "id=%" PRId64, stream_id); ret = -EINVAL; @@ -3535,7 +3535,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) if (!_IS_SET(&set, _EVENT_ID_SET)) { /* Allow only one event without ID per stream */ if (stream_class->event_classes->len != 0) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Missing `id` attribute in event class."); ret = -EPERM; goto error; @@ -3547,7 +3547,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) if (ctf_stream_class_borrow_event_class_by_id(stream_class, event_class->id)) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Duplicate event class (same ID) in the same stream class: " "id=%" PRId64, event_class->id); ret = -EEXIST; @@ -3630,7 +3630,7 @@ int auto_map_field_to_trace_clock_class(struct ctx *ctx, * Timestamp field not mapped to a clock class and there's more * than one clock class in the trace: this is an error. */ - BT_LOGE_STR("Timestamp field found with no mapped clock class, " + BT_COMP_LOGE_STR("Timestamp field found with no mapped clock class, " "but there's more than one clock class in the trace at this point."); ret = -1; goto end; @@ -3682,7 +3682,7 @@ int auto_map_fields_to_trace_clock_class(struct ctx *ctx, ret = auto_map_field_to_trace_clock_class(ctx, named_fc->fc); if (ret) { - BT_LOGE("Cannot automatically map field to trace's clock class: " + BT_COMP_LOGE("Cannot automatically map field to trace's clock class: " "field-name=\"%s\"", field_name); goto end; } @@ -3691,7 +3691,7 @@ int auto_map_fields_to_trace_clock_class(struct ctx *ctx, ret = auto_map_fields_to_trace_clock_class(ctx, named_fc->fc, field_name); if (ret) { - BT_LOGE("Cannot automatically map structure or variant field class's fields to trace's clock class: " + BT_COMP_LOGE("Cannot automatically map structure or variant field class's fields to trace's clock class: " "field-name=\"%s\", root-field-name=\"%s\"", field_name, named_fc->name->str); goto end; @@ -3714,7 +3714,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = visit_field_class_def(ctx, node->u.field_class_def.field_class_specifier_list, &node->u.field_class_def.field_class_declarators); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot add field class found in stream class."); goto error; } @@ -3723,7 +3723,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = visit_field_class_alias(ctx, node->u.field_class_alias.target, node->u.field_class_alias.alias); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot add field class alias found in stream class."); goto error; } @@ -3732,7 +3732,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, { left = concatenate_unary_strings(&node->u.ctf_expression.left); if (!left) { - _BT_LOGE_NODE(node, "Cannot concatenate unary strings."); + _BT_COMP_LOGE_NODE(node, "Cannot concatenate unary strings."); ret = -EINVAL; goto error; } @@ -3741,7 +3741,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, int64_t id; if (_IS_SET(set, _STREAM_ID_SET)) { - _BT_LOGE_DUP_ATTR(node, "id", + _BT_COMP_LOGE_DUP_ATTR(node, "id", "stream declaration"); ret = -EPERM; goto error; @@ -3753,7 +3753,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, /* Only read "id" if get_unary_unsigned() succeeded. */ if (ret || (!ret && id < 0)) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Unexpected unary expression for stream class's `id` attribute."); ret = -EINVAL; goto error; @@ -3761,7 +3761,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, if (ctf_trace_class_borrow_stream_class_by_id( ctx->ctf_tc, id)) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Duplicate stream class (same ID): id=%" PRId64, id); ret = -EEXIST; @@ -3772,7 +3772,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, _SET(set, _STREAM_ID_SET); } else if (!strcmp(left, "event.header")) { if (_IS_SET(set, _STREAM_EVENT_HEADER_SET)) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Duplicate `event.header` entry in stream class."); ret = -EPERM; goto error; @@ -3784,7 +3784,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, struct ctf_node, siblings), &stream_class->event_header_fc); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot create stream class's event header field class."); goto error; } @@ -3793,7 +3793,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = auto_map_fields_to_trace_clock_class(ctx, stream_class->event_header_fc, "timestamp"); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot automatically map specific event header field class fields named `timestamp` to trace's clock class."); goto error; } @@ -3801,7 +3801,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, _SET(set, _STREAM_EVENT_HEADER_SET); } else if (!strcmp(left, "event.context")) { if (_IS_SET(set, _STREAM_EVENT_CONTEXT_SET)) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Duplicate `event.context` entry in stream class."); ret = -EPERM; goto error; @@ -3813,7 +3813,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, struct ctf_node, siblings), &stream_class->event_common_context_fc); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot create stream class's event context field class."); goto error; } @@ -3822,7 +3822,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, _SET(set, _STREAM_EVENT_CONTEXT_SET); } else if (!strcmp(left, "packet.context")) { if (_IS_SET(set, _STREAM_PACKET_CONTEXT_SET)) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Duplicate `packet.context` entry in stream class."); ret = -EPERM; goto error; @@ -3834,7 +3834,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, struct ctf_node, siblings), &stream_class->packet_context_fc); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot create stream class's packet context field class."); goto error; } @@ -3844,7 +3844,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, stream_class->packet_context_fc, "timestamp_begin"); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot automatically map specific packet context field class fields named `timestamp_begin` to trace's clock class."); goto error; } @@ -3853,14 +3853,14 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, stream_class->packet_context_fc, "timestamp_end"); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot automatically map specific packet context field class fields named `timestamp_end` to trace's clock class."); goto error; } _SET(set, _STREAM_PACKET_CONTEXT_SET); } else { - _BT_LOGW_NODE(node, + _BT_COMP_LOGW_NODE(node, "Unknown attribute in stream class: " "attr-name=\"%s\"", left); } @@ -3903,7 +3903,7 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) bt_list_for_each_entry(iter, decl_list, siblings) { ret = visit_stream_decl_entry(ctx, iter, stream_class, &set); if (ret) { - _BT_LOGE_NODE(iter, + _BT_COMP_LOGE_NODE(iter, "Cannot visit stream class's entry: " "ret=%d", ret); ctx_pop_scope(ctx); @@ -3918,7 +3918,7 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) struct ctf_named_field_class *named_fc = NULL; if (!ctx->ctf_tc->packet_header_fc) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Stream class has a `id` attribute, " "but trace has no packet header field class."); goto error; @@ -3927,7 +3927,7 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) named_fc = ctf_field_class_struct_borrow_member_by_name( (void *) ctx->ctf_tc->packet_header_fc, "stream_id"); if (!named_fc) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Stream class has a `id` attribute, " "but trace's packet header field class has no `stream_id` field."); goto error; @@ -3935,7 +3935,7 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) if (named_fc->fc->type != CTF_FIELD_CLASS_TYPE_INT && named_fc->fc->type != CTF_FIELD_CLASS_TYPE_ENUM) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Stream class has a `id` attribute, " "but trace's packet header field class's `stream_id` field is not an integer field class."); goto error; @@ -3943,7 +3943,7 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) } else { /* Allow only _one_ ID-less stream */ if (ctx->ctf_tc->stream_classes->len != 0) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Missing `id` attribute in stream class as there's more than one stream class in the trace."); ret = -EPERM; goto error; @@ -3959,7 +3959,7 @@ int visit_stream_decl(struct ctx *ctx, struct ctf_node *node) */ if (ctf_trace_class_borrow_stream_class_by_id(ctx->ctf_tc, stream_class->id)) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Duplicate stream class (same ID): id=%" PRId64, stream_class->id); ret = -EINVAL; @@ -3990,7 +3990,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) ret = visit_field_class_def(ctx, node->u.field_class_def.field_class_specifier_list, &node->u.field_class_def.field_class_declarators); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot add field class found in trace (`trace` block)."); goto error; } @@ -3999,7 +3999,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) ret = visit_field_class_alias(ctx, node->u.field_class_alias.target, node->u.field_class_alias.alias); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot add field class alias found in trace (`trace` block)."); goto error; } @@ -4008,14 +4008,14 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) { left = concatenate_unary_strings(&node->u.ctf_expression.left); if (!left) { - _BT_LOGE_NODE(node, "Cannot concatenate unary strings."); + _BT_COMP_LOGE_NODE(node, "Cannot concatenate unary strings."); ret = -EINVAL; goto error; } if (!strcmp(left, "major")) { if (_IS_SET(set, _TRACE_MAJOR_SET)) { - _BT_LOGE_DUP_ATTR(node, "major", "trace"); + _BT_COMP_LOGE_DUP_ATTR(node, "major", "trace"); ret = -EPERM; goto error; } @@ -4023,14 +4023,14 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) ret = get_unary_unsigned(ctx, &node->u.ctf_expression.right, &val); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Unexpected unary expression for trace's `major` attribute."); ret = -EINVAL; goto error; } if (val != 1) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Invalid trace's `minor` attribute: expecting 1."); goto error; } @@ -4039,7 +4039,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) _SET(set, _TRACE_MAJOR_SET); } else if (!strcmp(left, "minor")) { if (_IS_SET(set, _TRACE_MINOR_SET)) { - _BT_LOGE_DUP_ATTR(node, "minor", "trace"); + _BT_COMP_LOGE_DUP_ATTR(node, "minor", "trace"); ret = -EPERM; goto error; } @@ -4047,14 +4047,14 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) ret = get_unary_unsigned(ctx, &node->u.ctf_expression.right, &val); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Unexpected unary expression for trace's `minor` attribute."); ret = -EINVAL; goto error; } if (val != 8) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Invalid trace's `minor` attribute: expecting 8."); goto error; } @@ -4063,7 +4063,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) _SET(set, _TRACE_MINOR_SET); } else if (!strcmp(left, "uuid")) { if (_IS_SET(set, _TRACE_UUID_SET)) { - _BT_LOGE_DUP_ATTR(node, "uuid", "trace"); + _BT_COMP_LOGE_DUP_ATTR(node, "uuid", "trace"); ret = -EPERM; goto error; } @@ -4072,7 +4072,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) &node->u.ctf_expression.right, ctx->ctf_tc->uuid); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Invalid trace's `uuid` attribute."); goto error; } @@ -4082,7 +4082,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) } else if (!strcmp(left, "byte_order")) { /* Default byte order is already known at this stage */ if (_IS_SET(set, _TRACE_BYTE_ORDER_SET)) { - _BT_LOGE_DUP_ATTR(node, "byte_order", + _BT_COMP_LOGE_DUP_ATTR(node, "byte_order", "trace"); ret = -EPERM; goto error; @@ -4092,7 +4092,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) _SET(set, _TRACE_BYTE_ORDER_SET); } else if (!strcmp(left, "packet.header")) { if (_IS_SET(set, _TRACE_PACKET_HEADER_SET)) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Duplicate `packet.header` entry in trace."); ret = -EPERM; goto error; @@ -4104,7 +4104,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) struct ctf_node, siblings), &ctx->ctf_tc->packet_header_fc); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot create trace's packet header field class."); goto error; } @@ -4112,7 +4112,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) BT_ASSERT(ctx->ctf_tc->packet_header_fc); _SET(set, _TRACE_PACKET_HEADER_SET); } else { - _BT_LOGW_NODE(node, + _BT_COMP_LOGW_NODE(node, "Unknown attribute in stream class: " "attr-name=\"%s\"", left); } @@ -4122,7 +4122,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) break; } default: - _BT_LOGE_NODE(node, "Unknown expression in trace."); + _BT_COMP_LOGE_NODE(node, "Unknown expression in trace."); ret = -EINVAL; goto error; } @@ -4149,7 +4149,7 @@ int visit_trace_decl(struct ctx *ctx, struct ctf_node *node) node->visited = TRUE; if (ctx->is_trace_visited) { - _BT_LOGE_NODE(node, "Duplicate trace (`trace` block)."); + _BT_COMP_LOGE_NODE(node, "Duplicate trace (`trace` block)."); ret = -EEXIST; goto error; } @@ -4159,7 +4159,7 @@ int visit_trace_decl(struct ctx *ctx, struct ctf_node *node) bt_list_for_each_entry(iter, decl_list, siblings) { ret = visit_trace_decl_entry(ctx, iter, &set); if (ret) { - _BT_LOGE_NODE(iter, "Cannot visit trace's entry (`trace` block): " + _BT_COMP_LOGE_NODE(iter, "Cannot visit trace's entry (`trace` block): " "ret=%d", ret); ctx_pop_scope(ctx); goto error; @@ -4169,21 +4169,21 @@ int visit_trace_decl(struct ctx *ctx, struct ctf_node *node) ctx_pop_scope(ctx); if (!_IS_SET(&set, _TRACE_MAJOR_SET)) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Missing `major` attribute in trace (`trace` block)."); ret = -EPERM; goto error; } if (!_IS_SET(&set, _TRACE_MINOR_SET)) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Missing `minor` attribute in trace (`trace` block)."); ret = -EPERM; goto error; } if (!_IS_SET(&set, _TRACE_BYTE_ORDER_SET)) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Missing `byte_order` attribute in trace (`trace` block)."); ret = -EPERM; goto error; @@ -4217,7 +4217,7 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) &entry_node->u.ctf_expression.right; if (entry_node->type != NODE_CTF_EXPRESSION) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Wrong expression in environment entry: " "node-type=%d", entry_node->type); ret = -EPERM; @@ -4227,7 +4227,7 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) left = concatenate_unary_strings( &entry_node->u.ctf_expression.left); if (!left) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Cannot get environment entry's name."); ret = -EINVAL; goto error; @@ -4237,7 +4237,7 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) char *right = concatenate_unary_strings(right_head); if (!right) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Unexpected unary expression for environment entry's value: " "name=\"%s\"", left); ret = -EINVAL; @@ -4246,7 +4246,7 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) if (strcmp(left, "tracer_name") == 0) { if (strncmp(right, "lttng", 5) == 0) { - BT_LOGI("Detected LTTng trace from `%s` environment value: " + BT_COMP_LOGI("Detected LTTng trace from `%s` environment value: " "tracer-name=\"%s\"", left, right); ctx->is_lttng = true; @@ -4268,7 +4268,7 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) ret = get_unary_signed(right_head, &v); } if (ret) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Unexpected unary expression for environment entry's value: " "name=\"%s\"", left); ret = -EINVAL; @@ -4279,7 +4279,7 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) left, CTF_TRACE_CLASS_ENV_ENTRY_TYPE_INT, NULL, v); } else { - _BT_LOGW_NODE(entry_node, + _BT_COMP_LOGW_NODE(entry_node, "Environment entry has unknown type: " "name=\"%s\"", left); } @@ -4312,7 +4312,7 @@ int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node) left = concatenate_unary_strings( &node->u.ctf_expression.left); if (!left) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot concatenate unary strings."); ret = -EINVAL; goto error; @@ -4322,7 +4322,7 @@ int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node) enum ctf_byte_order bo; if (_IS_SET(&set, _TRACE_BYTE_ORDER_SET)) { - _BT_LOGE_DUP_ATTR(node, "byte_order", + _BT_COMP_LOGE_DUP_ATTR(node, "byte_order", "trace"); ret = -EPERM; goto error; @@ -4335,13 +4335,13 @@ int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node) bo = byte_order_from_unary_expr(ctx, right_node); if (bo == -1) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Invalid `byte_order` attribute in trace (`trace` block): " "expecting `le`, `be`, or `network`."); ret = -EINVAL; goto error; } else if (bo == CTF_BYTE_ORDER_DEFAULT) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Invalid `byte_order` attribute in trace (`trace` block): " "cannot be set to `native` here."); ret = -EPERM; @@ -4357,7 +4357,7 @@ int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node) } if (!_IS_SET(&set, _TRACE_BYTE_ORDER_SET)) { - _BT_LOGE_NODE(trace_node, + _BT_COMP_LOGE_NODE(trace_node, "Missing `byte_order` attribute in trace (`trace` block)."); ret = -EINVAL; goto error; @@ -4379,7 +4379,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, char *left = NULL; if (entry_node->type != NODE_CTF_EXPRESSION) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Unexpected node type: node-type=%d", entry_node->type); ret = -EPERM; @@ -4388,7 +4388,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, left = concatenate_unary_strings(&entry_node->u.ctf_expression.left); if (!left) { - _BT_LOGE_NODE(entry_node, "Cannot concatenate unary strings."); + _BT_COMP_LOGE_NODE(entry_node, "Cannot concatenate unary strings."); ret = -EINVAL; goto error; } @@ -4397,7 +4397,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, char *right; if (_IS_SET(set, _CLOCK_NAME_SET)) { - _BT_LOGE_DUP_ATTR(entry_node, "name", "clock class"); + _BT_COMP_LOGE_DUP_ATTR(entry_node, "name", "clock class"); ret = -EPERM; goto error; } @@ -4405,7 +4405,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, right = concatenate_unary_strings( &entry_node->u.ctf_expression.right); if (!right) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Unexpected unary expression for clock class's `name` attribute."); ret = -EINVAL; goto error; @@ -4418,7 +4418,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, uint8_t uuid[BABELTRACE_UUID_LEN]; if (_IS_SET(set, _CLOCK_UUID_SET)) { - _BT_LOGE_DUP_ATTR(entry_node, "uuid", "clock class"); + _BT_COMP_LOGE_DUP_ATTR(entry_node, "uuid", "clock class"); ret = -EPERM; goto error; } @@ -4426,7 +4426,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, ret = get_unary_uuid(ctx, &entry_node->u.ctf_expression.right, uuid); if (ret) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Invalid clock class's `uuid` attribute."); goto error; } @@ -4438,7 +4438,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, char *right; if (_IS_SET(set, _CLOCK_DESCRIPTION_SET)) { - _BT_LOGE_DUP_ATTR(entry_node, "description", + _BT_COMP_LOGE_DUP_ATTR(entry_node, "description", "clock class"); ret = -EPERM; goto error; @@ -4447,7 +4447,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, right = concatenate_unary_strings( &entry_node->u.ctf_expression.right); if (!right) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Unexpected unary expression for clock class's `description` attribute."); ret = -EINVAL; goto error; @@ -4460,7 +4460,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, uint64_t freq = UINT64_C(-1); if (_IS_SET(set, _CLOCK_FREQ_SET)) { - _BT_LOGE_DUP_ATTR(entry_node, "freq", "clock class"); + _BT_COMP_LOGE_DUP_ATTR(entry_node, "freq", "clock class"); ret = -EPERM; goto error; } @@ -4468,14 +4468,14 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, ret = get_unary_unsigned(ctx, &entry_node->u.ctf_expression.right, &freq); if (ret) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Unexpected unary expression for clock class's `freq` attribute."); ret = -EINVAL; goto error; } if (freq == UINT64_C(-1) || freq == 0) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Invalid clock class frequency: freq=%" PRIu64, freq); ret = -EINVAL; @@ -4488,7 +4488,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, uint64_t precision; if (_IS_SET(set, _CLOCK_PRECISION_SET)) { - _BT_LOGE_DUP_ATTR(entry_node, "precision", + _BT_COMP_LOGE_DUP_ATTR(entry_node, "precision", "clock class"); ret = -EPERM; goto error; @@ -4497,7 +4497,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, ret = get_unary_unsigned(ctx, &entry_node->u.ctf_expression.right, &precision); if (ret) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Unexpected unary expression for clock class's `precision` attribute."); ret = -EINVAL; goto error; @@ -4507,7 +4507,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, _SET(set, _CLOCK_PRECISION_SET); } else if (!strcmp(left, "offset_s")) { if (_IS_SET(set, _CLOCK_OFFSET_S_SET)) { - _BT_LOGE_DUP_ATTR(entry_node, "offset_s", + _BT_COMP_LOGE_DUP_ATTR(entry_node, "offset_s", "clock class"); ret = -EPERM; goto error; @@ -4516,7 +4516,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, ret = get_unary_signed( &entry_node->u.ctf_expression.right, offset_seconds); if (ret) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Unexpected unary expression for clock class's `offset_s` attribute."); ret = -EINVAL; goto error; @@ -4525,7 +4525,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, _SET(set, _CLOCK_OFFSET_S_SET); } else if (!strcmp(left, "offset")) { if (_IS_SET(set, _CLOCK_OFFSET_SET)) { - _BT_LOGE_DUP_ATTR(entry_node, "offset", "clock class"); + _BT_COMP_LOGE_DUP_ATTR(entry_node, "offset", "clock class"); ret = -EPERM; goto error; } @@ -4533,7 +4533,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, ret = get_unary_unsigned(ctx, &entry_node->u.ctf_expression.right, offset_cycles); if (ret) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Unexpected unary expression for clock class's `offset` attribute."); ret = -EINVAL; goto error; @@ -4544,7 +4544,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, struct ctf_node *right; if (_IS_SET(set, _CLOCK_ABSOLUTE_SET)) { - _BT_LOGE_DUP_ATTR(entry_node, "absolute", + _BT_COMP_LOGE_DUP_ATTR(entry_node, "absolute", "clock class"); ret = -EPERM; goto error; @@ -4555,7 +4555,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, struct ctf_node, siblings); ret = get_boolean(ctx, right); if (ret < 0) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Unexpected unary expression for clock class's `absolute` attribute."); ret = -EINVAL; goto error; @@ -4564,7 +4564,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, clock->is_absolute = ret; _SET(set, _CLOCK_ABSOLUTE_SET); } else { - _BT_LOGW_NODE(entry_node, + _BT_COMP_LOGW_NODE(entry_node, "Unknown attribute in clock class: attr-name=\"%s\"", left); } @@ -4686,7 +4686,7 @@ int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node) /* CTF 1.8's default frequency for a clock class is 1 GHz */ clock = ctf_clock_class_create(); if (!clock) { - _BT_LOGE_NODE(clock_node, + _BT_COMP_LOGE_NODE(clock_node, "Cannot create default clock class."); ret = -ENOMEM; goto end; @@ -4696,7 +4696,7 @@ int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node) ret = visit_clock_decl_entry(ctx, entry_node, clock, &set, &offset_seconds, &offset_cycles); if (ret) { - _BT_LOGE_NODE(entry_node, + _BT_COMP_LOGE_NODE(entry_node, "Cannot visit clock class's entry: ret=%d", ret); goto end; @@ -4704,7 +4704,7 @@ int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node) } if (!_IS_SET(&set, _CLOCK_NAME_SET)) { - _BT_LOGE_NODE(clock_node, + _BT_COMP_LOGE_NODE(clock_node, "Missing `name` attribute in clock class."); ret = -EPERM; goto end; @@ -4760,7 +4760,7 @@ int visit_root_decl(struct ctx *ctx, struct ctf_node *root_decl_node) root_decl_node->u.field_class_def.field_class_specifier_list, &root_decl_node->u.field_class_def.field_class_declarators); if (ret) { - _BT_LOGE_NODE(root_decl_node, + _BT_COMP_LOGE_NODE(root_decl_node, "Cannot add field class found in root scope."); goto end; } @@ -4769,7 +4769,7 @@ int visit_root_decl(struct ctx *ctx, struct ctf_node *root_decl_node) ret = visit_field_class_alias(ctx, root_decl_node->u.field_class_alias.target, root_decl_node->u.field_class_alias.alias); if (ret) { - _BT_LOGE_NODE(root_decl_node, + _BT_COMP_LOGE_NODE(root_decl_node, "Cannot add field class alias found in root scope."); goto end; } @@ -4784,7 +4784,7 @@ int visit_root_decl(struct ctx *ctx, struct ctf_node *root_decl_node) */ ret = visit_field_class_specifier_list(ctx, root_decl_node, &decl); if (ret) { - _BT_LOGE_NODE(root_decl_node, + _BT_COMP_LOGE_NODE(root_decl_node, "Cannot visit root scope's field class: " "ret=%d", ret); BT_ASSERT(!decl); @@ -4796,7 +4796,7 @@ int visit_root_decl(struct ctx *ctx, struct ctf_node *root_decl_node) break; } default: - _BT_LOGE_NODE(root_decl_node, + _BT_COMP_LOGE_NODE(root_decl_node, "Unexpected node type: node-type=%d", root_decl_node->type); ret = -EPERM; @@ -4809,15 +4809,14 @@ end: BT_HIDDEN struct ctf_visitor_generate_ir *ctf_visitor_generate_ir_create( - bt_self_component_source *self_comp, const struct ctf_metadata_decoder_config *decoder_config) { struct ctx *ctx = NULL; /* Create visitor's context */ - ctx = ctx_create(self_comp, decoder_config); + ctx = ctx_create(decoder_config); if (!ctx) { - BT_LOGE_STR("Cannot create visitor's context."); + BT_COMP_LOGE_STR("Cannot create visitor's context."); goto error; } @@ -4870,7 +4869,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, int ret = 0; struct ctx *ctx = (void *) visitor; - BT_LOGI_STR("Visiting metadata's AST to generate CTF IR objects."); + BT_COMP_LOGI_STR("Visiting metadata's AST to generate CTF IR objects."); switch (node->type) { case NODE_ROOT: @@ -4888,7 +4887,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, if (ctx->ctf_tc->default_byte_order == -1) { bt_list_for_each_entry(iter, &node->u.root.trace, siblings) { if (got_trace_decl) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Duplicate trace (`trace` block)."); ret = -1; goto end; @@ -4896,7 +4895,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, ret = set_trace_byte_order(ctx, iter); if (ret) { - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Cannot set trace's native byte order: " "ret=%d", ret); goto end; @@ -4906,7 +4905,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, } if (!got_trace_decl) { - BT_LOGD_STR("Incomplete AST: need trace (`trace` block)."); + BT_COMP_LOGD_STR("Incomplete AST: need trace (`trace` block)."); ret = -EINCOMPLETE; goto end; } @@ -4921,7 +4920,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, bt_list_for_each_entry(iter, &node->u.root.env, siblings) { ret = visit_env(ctx, iter); if (ret) { - _BT_LOGE_NODE(iter, + _BT_COMP_LOGE_NODE(iter, "Cannot visit trace's environment (`env` block) entry: " "ret=%d", ret); goto end; @@ -4937,7 +4936,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, bt_list_for_each_entry(iter, &node->u.root.clock, siblings) { ret = visit_clock_decl(ctx, iter); if (ret) { - _BT_LOGE_NODE(iter, + _BT_COMP_LOGE_NODE(iter, "Cannot visit clock class: ret=%d", ret); goto end; @@ -4955,7 +4954,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, siblings) { ret = visit_root_decl(ctx, iter); if (ret) { - _BT_LOGE_NODE(iter, + _BT_COMP_LOGE_NODE(iter, "Cannot visit root entry: ret=%d", ret); goto end; @@ -4967,7 +4966,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, /* Callsite blocks are not supported */ bt_list_for_each_entry(iter, &node->u.root.callsite, siblings) { - _BT_LOGW_NODE(iter, + _BT_COMP_LOGW_NODE(iter, "\"callsite\" blocks are not supported as of this version."); } @@ -4978,7 +4977,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, bt_list_for_each_entry(iter, &node->u.root.trace, siblings) { ret = visit_trace_decl(ctx, iter); if (ret) { - _BT_LOGE_NODE(iter, + _BT_COMP_LOGE_NODE(iter, "Cannot visit trace (`trace` block): " "ret=%d", ret); goto end; @@ -4992,7 +4991,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, bt_list_for_each_entry(iter, &node->u.root.stream, siblings) { ret = visit_stream_decl(ctx, iter); if (ret) { - _BT_LOGE_NODE(iter, + _BT_COMP_LOGE_NODE(iter, "Cannot visit stream class: ret=%d", ret); goto end; @@ -5006,7 +5005,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, bt_list_for_each_entry(iter, &node->u.root.event, siblings) { ret = visit_event_decl(ctx, iter); if (ret) { - _BT_LOGE_NODE(iter, + _BT_COMP_LOGE_NODE(iter, "Cannot visit event class: ret=%d", ret); goto end; @@ -5018,7 +5017,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, break; } default: - _BT_LOGE_NODE(node, + _BT_COMP_LOGE_NODE(node, "Unexpected node type: node-type=%d", node->type); ret = -EINVAL; @@ -5027,7 +5026,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, /* Update default clock classes */ ret = ctf_trace_class_update_default_clock_classes(ctx->ctf_tc, - ctx->log_level); + &ctx->log_cfg); if (ret) { ret = -EINVAL; goto end; @@ -5055,8 +5054,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, } /* Resolve sequence lengths and variant tags */ - ret = ctf_trace_class_resolve_field_classes(ctx->ctf_tc, - ctx->log_level); + ret = ctf_trace_class_resolve_field_classes(ctx->ctf_tc, &ctx->log_cfg); if (ret) { ret = -EINVAL; goto end; @@ -5085,8 +5083,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, } /* Validate what we have so far */ - ret = ctf_trace_class_validate(ctx->ctf_tc, - ctx->log_level); + ret = ctf_trace_class_validate(ctx->ctf_tc, &ctx->log_cfg); if (ret) { ret = -EINVAL; goto end; @@ -5098,11 +5095,11 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor, * classes, warn about it because they are never translated. */ ctf_trace_class_warn_meaningless_header_fields(ctx->ctf_tc, - ctx->log_level); + &ctx->log_cfg); if (ctx->trace_class) { /* Copy new CTF metadata -> new IR metadata */ - ret = ctf_trace_class_translate(ctx->self_comp, + ret = ctf_trace_class_translate(ctx->log_cfg.self_comp, ctx->trace_class, ctx->ctf_tc); if (ret) { ret = -EINVAL; diff --git a/src/plugins/ctf/common/metadata/visitor-parent-links.c b/src/plugins/ctf/common/metadata/visitor-parent-links.c index 6b05a338..bfa3f0cf 100644 --- a/src/plugins/ctf/common/metadata/visitor-parent-links.c +++ b/src/plugins/ctf/common/metadata/visitor-parent-links.c @@ -24,9 +24,10 @@ * SOFTWARE. */ -#define BT_LOG_OUTPUT_LEVEL log_level +#define BT_COMP_LOG_SELF_COMP (log_cfg->self_comp) +#define BT_LOG_OUTPUT_LEVEL (log_cfg->log_level) #define BT_LOG_TAG "PLUGIN/CTF/META/PARENT-LINKS-VISITOR" -#include "logging/log.h" +#include "plugins/comp-logging.h" #include #include @@ -45,7 +46,7 @@ static int ctf_visitor_unary_expression(int depth, struct ctf_node *node, - bt_logging_level log_level) + struct meta_log_config *log_cfg) { int ret = 0; @@ -56,7 +57,7 @@ int ctf_visitor_unary_expression(int depth, struct ctf_node *node, case UNARY_DOTDOTDOT: break; default: - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Unknown expression link type: type=%d\n", node->u.unary_expression.link); return -EINVAL; @@ -71,14 +72,14 @@ int ctf_visitor_unary_expression(int depth, struct ctf_node *node, node->u.unary_expression.u.sbrac_exp->parent = node; ret = ctf_visitor_unary_expression(depth + 1, node->u.unary_expression.u.sbrac_exp, - log_level); + log_cfg); if (ret) return ret; break; case UNARY_UNKNOWN: default: - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Unknown expression link type: type=%d\n", node->u.unary_expression.link); return -EINVAL; @@ -88,7 +89,7 @@ int ctf_visitor_unary_expression(int depth, struct ctf_node *node, static int ctf_visitor_type_specifier(int depth, struct ctf_node *node, - bt_logging_level log_level) + struct meta_log_config *log_cfg) { int ret; @@ -117,14 +118,14 @@ int ctf_visitor_type_specifier(int depth, struct ctf_node *node, node->u.field_class_specifier.node->parent = node; ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_specifier.node, - log_level); + log_cfg); if (ret) return ret; break; case TYPESPEC_UNKNOWN: default: - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Unknown type specifier: type=%d\n", node->u.field_class_specifier.type); return -EINVAL; @@ -134,7 +135,7 @@ int ctf_visitor_type_specifier(int depth, struct ctf_node *node, static int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node, - bt_logging_level log_level) + struct meta_log_config *log_cfg) { int ret = 0; struct ctf_node *iter; @@ -144,7 +145,7 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.field_class_declarator.pointers, siblings) { iter->parent = node; - ret = ctf_visitor_parent_links(depth + 1, iter, log_level); + ret = ctf_visitor_parent_links(depth + 1, iter, log_cfg); if (ret) return ret; } @@ -157,7 +158,7 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node, node->u.field_class_declarator.u.nested.field_class_declarator->parent = node; ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_declarator.u.nested.field_class_declarator, - log_level); + log_cfg); if (ret) return ret; } @@ -166,7 +167,7 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -175,14 +176,14 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node, node->u.field_class_declarator.bitfield_len = node; ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_declarator.bitfield_len, - log_level); + log_cfg); if (ret) return ret; } break; case TYPEDEC_UNKNOWN: default: - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Unknown type declarator: type=%d\n", node->u.field_class_declarator.type); return -EINVAL; @@ -192,7 +193,7 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node, } int ctf_visitor_parent_links(int depth, struct ctf_node *node, - bt_logging_level log_level) + struct meta_log_config *log_cfg) { int ret = 0; struct ctf_node *iter; @@ -205,42 +206,42 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.root.declaration_list, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.root.trace, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.root.stream, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.root.event, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.root.clock, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.root.callsite, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -250,7 +251,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.event.declaration_list, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -259,7 +260,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.stream.declaration_list, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -268,7 +269,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.env.declaration_list, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -277,7 +278,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.trace.declaration_list, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -286,7 +287,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.clock.declaration_list, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -295,7 +296,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.callsite.declaration_list, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -306,34 +307,34 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.ctf_expression.left, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.ctf_expression.right, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } depth--; break; case NODE_UNARY_EXPRESSION: - return ctf_visitor_unary_expression(depth, node, log_level); + return ctf_visitor_unary_expression(depth, node, log_cfg); case NODE_TYPEDEF: depth++; node->u.field_class_def.field_class_specifier_list->parent = node; ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_def.field_class_specifier_list, - log_level); + log_cfg); if (ret) return ret; bt_list_for_each_entry(iter, &node->u.field_class_def.field_class_declarators, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -344,13 +345,13 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, node->u.field_class_alias_target.field_class_specifier_list->parent = node; ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_alias_target.field_class_specifier_list, - log_level); + log_cfg); if (ret) return ret; bt_list_for_each_entry(iter, &node->u.field_class_alias_target.field_class_declarators, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -361,13 +362,13 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, node->u.field_class_alias_name.field_class_specifier_list->parent = node; ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_alias_name.field_class_specifier_list, - log_level); + log_cfg); if (ret) return ret; bt_list_for_each_entry(iter, &node->u.field_class_alias_name.field_class_declarators, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -376,12 +377,12 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, case NODE_TYPEALIAS: node->u.field_class_alias.target->parent = node; ret = ctf_visitor_parent_links(depth + 1, - node->u.field_class_alias.target, log_level); + node->u.field_class_alias.target, log_cfg); if (ret) return ret; node->u.field_class_alias.alias->parent = node; ret = ctf_visitor_parent_links(depth + 1, - node->u.field_class_alias.alias, log_level); + node->u.field_class_alias.alias, log_cfg); if (ret) return ret; break; @@ -390,14 +391,14 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.field_class_specifier_list.head, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } break; case NODE_TYPE_SPECIFIER: - ret = ctf_visitor_type_specifier(depth, node, log_level); + ret = ctf_visitor_type_specifier(depth, node, log_cfg); if (ret) return ret; break; @@ -405,7 +406,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, break; case NODE_TYPE_DECLARATOR: ret = ctf_visitor_field_class_declarator(depth, node, - log_level); + log_cfg); if (ret) return ret; break; @@ -414,7 +415,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.floating_point.expressions, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -423,7 +424,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.integer.expressions, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -432,7 +433,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.string.expressions, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -441,7 +442,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.enumerator.values, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -450,7 +451,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, depth++; if (node->u._enum.container_field_class) { ret = ctf_visitor_parent_links(depth + 1, - node->u._enum.container_field_class, log_level); + node->u._enum.container_field_class, log_cfg); if (ret) return ret; } @@ -458,7 +459,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u._enum.enumerator_list, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -468,13 +469,13 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, node->u.struct_or_variant_declaration.field_class_specifier_list->parent = node; ret = ctf_visitor_parent_links(depth + 1, node->u.struct_or_variant_declaration.field_class_specifier_list, - log_level); + log_cfg); if (ret) return ret; bt_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.field_class_declarators, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -483,7 +484,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.variant.declaration_list, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -492,7 +493,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u._struct.declaration_list, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -500,7 +501,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -508,7 +509,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node, case NODE_UNKNOWN: default: - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Unknown node type: type=%d\n", node->type); return -EINVAL; } diff --git a/src/plugins/ctf/common/metadata/visitor-semantic-validator.c b/src/plugins/ctf/common/metadata/visitor-semantic-validator.c index 0c4aa125..17f63ac9 100644 --- a/src/plugins/ctf/common/metadata/visitor-semantic-validator.c +++ b/src/plugins/ctf/common/metadata/visitor-semantic-validator.c @@ -24,9 +24,10 @@ * SOFTWARE. */ -#define BT_LOG_OUTPUT_LEVEL log_level +#define BT_COMP_LOG_SELF_COMP (log_cfg->self_comp) +#define BT_LOG_OUTPUT_LEVEL (log_cfg->log_level) #define BT_LOG_TAG "PLUGIN/CTF/META/SEMANTIC-VALIDATOR-VISITOR" -#include "logging/log.h" +#include "plugins/comp-logging.h" #include #include @@ -47,11 +48,11 @@ static int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, - bt_logging_level log_level); + struct meta_log_config *log_cfg); static int ctf_visitor_unary_expression(int depth, struct ctf_node *node, - bt_logging_level log_level) + struct meta_log_config *log_cfg) { struct ctf_node *iter; int is_ctf_exp = 0, is_ctf_exp_left = 0; @@ -68,7 +69,7 @@ int ctf_visitor_unary_expression(int depth, struct ctf_node *node, * We are only allowed to be a string. */ if (node->u.unary_expression.type != UNARY_STRING) { - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Left child of a CTF expression is only allowed to be a string."); goto errperm; } @@ -86,7 +87,7 @@ int ctf_visitor_unary_expression(int depth, struct ctf_node *node, case UNARY_STRING: break; default: - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Children of field class declarator and `enum` can only be unsigned numeric constants or references to fields (e.g., `a.b.c`)."); goto errperm; } @@ -100,7 +101,7 @@ int ctf_visitor_unary_expression(int depth, struct ctf_node *node, case UNARY_UNSIGNED_CONSTANT: break; default: - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Structure alignment attribute can only be an unsigned numeric constant."); goto errperm; } @@ -115,7 +116,7 @@ int ctf_visitor_unary_expression(int depth, struct ctf_node *node, * We disallow nested unary expressions and "sbrac" unary * expressions. */ - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Nested unary expressions not allowed (`()` and `[]`)."); goto errperm; @@ -150,7 +151,7 @@ int ctf_visitor_unary_expression(int depth, struct ctf_node *node, &node->parent->u.ctf_expression.right, struct ctf_node, siblings) != node) { - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Empty link is not allowed except on first node of unary expression (need to separate nodes with `.` or `->`)."); goto errperm; } @@ -159,7 +160,7 @@ int ctf_visitor_unary_expression(int depth, struct ctf_node *node, case UNARY_ARROWLINK: /* We only allow -> and . links between children of ctf_expression. */ if (node->parent->type != NODE_CTF_EXPRESSION) { - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Links `.` and `->` are only allowed as children of CTF expression."); goto errperm; } @@ -168,7 +169,7 @@ int ctf_visitor_unary_expression(int depth, struct ctf_node *node, * This includes "", '' and non-quoted identifiers. */ if (node->u.unary_expression.type != UNARY_STRING) { - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Links `.` and `->` are only allowed to separate strings and identifiers."); goto errperm; } @@ -178,7 +179,7 @@ int ctf_visitor_unary_expression(int depth, struct ctf_node *node, &node->parent->u.ctf_expression.right, struct ctf_node, siblings) == node) { - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Links `.` and `->` are not allowed before first node of the unary expression list."); goto errperm; } @@ -186,7 +187,7 @@ int ctf_visitor_unary_expression(int depth, struct ctf_node *node, case UNARY_DOTDOTDOT: /* We only allow ... link between children of enumerator. */ if (node->parent->type != NODE_ENUMERATOR) { - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Link `...` is only allowed within enumerator."); goto errperm; } @@ -194,13 +195,13 @@ int ctf_visitor_unary_expression(int depth, struct ctf_node *node, if (_bt_list_first_entry(&node->parent->u.enumerator.values, struct ctf_node, siblings) == node) { - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Link `...` is not allowed on the first node of the unary expression list."); goto errperm; } break; default: - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Unknown expression link type: type=%d", node->u.unary_expression.link); return -EINVAL; @@ -208,13 +209,13 @@ int ctf_visitor_unary_expression(int depth, struct ctf_node *node, return 0; errinval: - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Incoherent parent node's type: node-type=%s, parent-node-type=%s", node_type(node), node_type(node->parent)); return -EINVAL; /* Incoherent structure */ errperm: - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Semantic error: node-type=%s, parent-node-type=%s", node_type(node), node_type(node->parent)); return -EPERM; /* Structure not allowed */ @@ -222,7 +223,7 @@ errperm: static int ctf_visitor_field_class_specifier_list(int depth, struct ctf_node *node, - bt_logging_level log_level) + struct meta_log_config *log_cfg) { switch (node->parent->type) { case NODE_CTF_EXPRESSION: @@ -257,7 +258,7 @@ int ctf_visitor_field_class_specifier_list(int depth, struct ctf_node *node, } return 0; errinval: - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Incoherent parent node's type: node-type=%s, parent-node-type=%s", node_type(node), node_type(node->parent)); return -EINVAL; /* Incoherent structure */ @@ -265,7 +266,7 @@ errinval: static int ctf_visitor_field_class_specifier(int depth, struct ctf_node *node, - bt_logging_level log_level) + struct meta_log_config *log_cfg) { switch (node->parent->type) { case NODE_TYPE_SPECIFIER_LIST: @@ -300,7 +301,7 @@ int ctf_visitor_field_class_specifier(int depth, struct ctf_node *node, } return 0; errinval: - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Incoherent parent node's type: node-type=%s, parent-node-type=%s", node_type(node), node_type(node->parent)); return -EINVAL; /* Incoherent structure */ @@ -308,7 +309,7 @@ errinval: static int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node, - bt_logging_level log_level) + struct meta_log_config *log_cfg) { int ret = 0; struct ctf_node *iter; @@ -389,7 +390,7 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.field_class_declarator.pointers, siblings) { - ret = _ctf_visitor_semantic_check(depth + 1, iter, log_level); + ret = _ctf_visitor_semantic_check(depth + 1, iter, log_cfg); if (ret) return ret; } @@ -402,7 +403,7 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node, if (node->u.field_class_declarator.u.nested.field_class_declarator) { ret = _ctf_visitor_semantic_check(depth + 1, node->u.field_class_declarator.u.nested.field_class_declarator, - log_level); + log_cfg); if (ret) return ret; } @@ -410,19 +411,19 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.field_class_declarator.u.nested.length, siblings) { if (iter->type != NODE_UNARY_EXPRESSION) { - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Expecting unary expression as length: node-type=%s", node_type(iter)); return -EINVAL; } ret = _ctf_visitor_semantic_check(depth + 1, - iter, log_level); + iter, log_cfg); if (ret) return ret; } } else { if (node->parent->type == NODE_TYPEALIAS_TARGET) { - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Abstract array declarator not permitted as target of field class alias."); return -EINVAL; } @@ -430,7 +431,7 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node, if (node->u.field_class_declarator.bitfield_len) { ret = _ctf_visitor_semantic_check(depth + 1, node->u.field_class_declarator.bitfield_len, - log_level); + log_cfg); if (ret) return ret; } @@ -438,7 +439,7 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node, } case TYPEDEC_UNKNOWN: default: - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Unknown field class declarator: type=%d", node->u.field_class_declarator.type); return -EINVAL; @@ -447,13 +448,13 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node, return 0; errinval: - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Incoherent parent node's type: node-type=%s, parent-node-type=%s", node_type(node), node_type(node->parent)); return -EINVAL; /* Incoherent structure */ errperm: - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Semantic error: node-type=%s, parent-node-type=%s", node_type(node), node_type(node->parent)); return -EPERM; /* Structure not allowed */ @@ -461,7 +462,7 @@ errperm: static int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, - bt_logging_level log_level) + struct meta_log_config *log_cfg) { int ret = 0; struct ctf_node *iter; @@ -473,25 +474,25 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, case NODE_ROOT: bt_list_for_each_entry(iter, &node->u.root.declaration_list, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.root.trace, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.root.stream, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.root.event, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -507,7 +508,7 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.event.declaration_list, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -522,7 +523,7 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.stream.declaration_list, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -537,7 +538,7 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.env.declaration_list, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -552,7 +553,7 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.trace.declaration_list, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -567,7 +568,7 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.clock.declaration_list, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -582,7 +583,7 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.callsite.declaration_list, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -624,20 +625,20 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, depth++; bt_list_for_each_entry(iter, &node->u.ctf_expression.left, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } bt_list_for_each_entry(iter, &node->u.ctf_expression.right, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } depth--; break; case NODE_UNARY_EXPRESSION: - return ctf_visitor_unary_expression(depth, node, log_level); + return ctf_visitor_unary_expression(depth, node, log_cfg); case NODE_TYPEDEF: switch (node->parent->type) { @@ -675,12 +676,12 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, depth++; ret = _ctf_visitor_semantic_check(depth + 1, node->u.field_class_def.field_class_specifier_list, - log_level); + log_cfg); if (ret) return ret; bt_list_for_each_entry(iter, &node->u.field_class_def.field_class_declarators, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -700,19 +701,19 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, depth++; ret = _ctf_visitor_semantic_check(depth + 1, node->u.field_class_alias_target.field_class_specifier_list, - log_level); + log_cfg); if (ret) return ret; nr_declarators = 0; bt_list_for_each_entry(iter, &node->u.field_class_alias_target.field_class_declarators, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; nr_declarators++; } if (nr_declarators > 1) { - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Too many declarators in field class alias's name (maximum is 1): count=%d", nr_declarators); return -EINVAL; @@ -734,19 +735,19 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, depth++; ret = _ctf_visitor_semantic_check(depth + 1, node->u.field_class_alias_name.field_class_specifier_list, - log_level); + log_cfg); if (ret) return ret; nr_declarators = 0; bt_list_for_each_entry(iter, &node->u.field_class_alias_name.field_class_declarators, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; nr_declarators++; } if (nr_declarators > 1) { - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Too many declarators in field class alias's name (maximum is 1): count=%d", nr_declarators); return -EINVAL; @@ -788,24 +789,24 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, } ret = _ctf_visitor_semantic_check(depth + 1, - node->u.field_class_alias.target, log_level); + node->u.field_class_alias.target, log_cfg); if (ret) return ret; ret = _ctf_visitor_semantic_check(depth + 1, - node->u.field_class_alias.alias, log_level); + node->u.field_class_alias.alias, log_cfg); if (ret) return ret; break; case NODE_TYPE_SPECIFIER_LIST: ret = ctf_visitor_field_class_specifier_list(depth, node, - log_level); + log_cfg); if (ret) return ret; break; case NODE_TYPE_SPECIFIER: ret = ctf_visitor_field_class_specifier(depth, node, - log_level); + log_cfg); if (ret) return ret; break; @@ -819,7 +820,7 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, break; case NODE_TYPE_DECLARATOR: ret = ctf_visitor_field_class_declarator(depth, node, - log_level); + log_cfg); if (ret) return ret; break; @@ -836,7 +837,7 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, } bt_list_for_each_entry(iter, &node->u.floating_point.expressions, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -852,7 +853,7 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.integer.expressions, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -870,7 +871,7 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.string.expressions, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -897,7 +898,7 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, || (iter->u.unary_expression.type != UNARY_SIGNED_CONSTANT && iter->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) || iter->u.unary_expression.link != UNARY_LINK_UNKNOWN) { - _BT_LOGE_LINENO(iter->lineno, + _BT_COMP_LOGE_LINENO(iter->lineno, "First unary expression of enumerator is unexpected."); goto errperm; } @@ -906,7 +907,7 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, || (iter->u.unary_expression.type != UNARY_SIGNED_CONSTANT && iter->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) || iter->u.unary_expression.link != UNARY_DOTDOTDOT) { - _BT_LOGE_LINENO(iter->lineno, + _BT_COMP_LOGE_LINENO(iter->lineno, "Second unary expression of enumerator is unexpected."); goto errperm; } @@ -919,7 +920,7 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, bt_list_for_each_entry(iter, &node->u.enumerator.values, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -937,13 +938,13 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, depth++; ret = _ctf_visitor_semantic_check(depth + 1, - node->u._enum.container_field_class, log_level); + node->u._enum.container_field_class, log_cfg); if (ret) return ret; bt_list_for_each_entry(iter, &node->u._enum.enumerator_list, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -959,12 +960,12 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, } ret = _ctf_visitor_semantic_check(depth + 1, node->u.struct_or_variant_declaration.field_class_specifier_list, - log_level); + log_cfg); if (ret) return ret; bt_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.field_class_declarators, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -981,7 +982,7 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, } bt_list_for_each_entry(iter, &node->u.variant.declaration_list, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -999,7 +1000,7 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, } bt_list_for_each_entry(iter, &node->u._struct.declaration_list, siblings) { ret = _ctf_visitor_semantic_check(depth + 1, iter, - log_level); + log_cfg); if (ret) return ret; } @@ -1007,27 +1008,27 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node, case NODE_UNKNOWN: default: - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Unknown node type: type=%d", node->type); return -EINVAL; } return ret; errinval: - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Incoherent parent node's type: node-type=%s, parent-node-type=%s", node_type(node), node_type(node->parent)); return -EINVAL; /* Incoherent structure */ errperm: - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Semantic error: node-type=%s, parent-node-type=%s", node_type(node), node_type(node->parent)); return -EPERM; /* Structure not allowed */ } int ctf_visitor_semantic_check(int depth, struct ctf_node *node, - bt_logging_level log_level) + struct meta_log_config *log_cfg) { int ret = 0; @@ -1036,17 +1037,17 @@ int ctf_visitor_semantic_check(int depth, struct ctf_node *node, * take the safe route and recreate them at each validation, just in * case the structure has changed. */ - ret = ctf_visitor_parent_links(depth, node, log_level); + ret = ctf_visitor_parent_links(depth, node, log_cfg); if (ret) { - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Cannot create parent links in metadata's AST: " "ret=%d", ret); goto end; } - ret = _ctf_visitor_semantic_check(depth, node, log_level); + ret = _ctf_visitor_semantic_check(depth, node, log_cfg); if (ret) { - _BT_LOGE_LINENO(node->lineno, + _BT_COMP_LOGE_LINENO(node->lineno, "Cannot check metadata's AST semantics: " "ret=%d", ret); goto end; diff --git a/src/plugins/ctf/fs-src/metadata.c b/src/plugins/ctf/fs-src/metadata.c index 342b290f..16463292 100644 --- a/src/plugins/ctf/fs-src/metadata.c +++ b/src/plugins/ctf/fs-src/metadata.c @@ -96,6 +96,7 @@ int ctf_fs_metadata_set_trace_class( struct ctf_fs_file *file = NULL; struct ctf_metadata_decoder_config decoder_config = { .log_level = BT_LOG_OUTPUT_LEVEL, + .self_comp = bt_self_component_source_as_self_component(self_comp), .clock_class_offset_s = config ? config->clock_class_offset_s : 0, .clock_class_offset_ns = config ? config->clock_class_offset_ns : 0, }; @@ -107,8 +108,8 @@ int ctf_fs_metadata_set_trace_class( goto end; } - ctf_fs_trace->metadata->decoder = ctf_metadata_decoder_create(self_comp, - config ? &decoder_config : NULL); + ctf_fs_trace->metadata->decoder = ctf_metadata_decoder_create( + &decoder_config); if (!ctf_fs_trace->metadata->decoder) { BT_LOGE("Cannot create metadata decoder object"); ret = -1; diff --git a/src/plugins/ctf/fs-src/query.c b/src/plugins/ctf/fs-src/query.c index 0a89084d..5df82599 100644 --- a/src/plugins/ctf/fs-src/query.c +++ b/src/plugins/ctf/fs-src/query.c @@ -99,12 +99,12 @@ bt_query_status metadata_info_query( } is_packetized = ctf_metadata_decoder_is_packetized(metadata_fp, - &bo, BT_LOG_OUTPUT_LEVEL); + &bo, BT_LOG_OUTPUT_LEVEL, NULL); if (is_packetized) { ret = ctf_metadata_decoder_packetized_file_stream_to_buf( metadata_fp, &metadata_text, bo, - BT_LOG_OUTPUT_LEVEL); + BT_LOG_OUTPUT_LEVEL, NULL); if (ret) { BT_LOGE("Cannot decode packetized metadata file: path=\"%s\"", path); diff --git a/src/plugins/ctf/lttng-live/metadata.c b/src/plugins/ctf/lttng-live/metadata.c index 181a92b1..decae60e 100644 --- a/src/plugins/ctf/lttng-live/metadata.c +++ b/src/plugins/ctf/lttng-live/metadata.c @@ -274,6 +274,9 @@ int lttng_live_metadata_create_stream(struct lttng_live_session *session, const char *match; struct ctf_metadata_decoder_config cfg = { .log_level = session->log_level, + .self_comp = + bt_self_component_source_as_self_component( + lttng_live->self_comp), .clock_class_offset_s = 0, .clock_class_offset_ns = 0, }; @@ -290,8 +293,7 @@ int lttng_live_metadata_create_stream(struct lttng_live_session *session, goto error; } - metadata->decoder = ctf_metadata_decoder_create( - lttng_live->self_comp, &cfg); + metadata->decoder = ctf_metadata_decoder_create(&cfg); if (!metadata->decoder) { goto error; } -- 2.34.1