`ctf` plugin: metadata: use local log level
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 17 Jun 2019 23:20:08 +0000 (19:20 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 20 Jun 2019 18:51:59 +0000 (14:51 -0400)
As of this patch, the users of the common metadata functions and objects
set the new log level parameters to their own (global) log level.

The goal is to eventually have a per-component log level for the `ctf`
plugin's component classes.

Unfortunately, `YYFPRINTF` and `YY_FATAL_ERROR` are pretty limited in
terms of available context. I'm leaving the
`BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL` environment variable to set
the logging level of the parser and lexer modules.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I34651e6d0c14b5acc9b4198681c2aea4c003dc7a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1490
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
25 files changed:
src/plugins/ctf/common/metadata/ast.h
src/plugins/ctf/common/metadata/ctf-meta-resolve.c
src/plugins/ctf/common/metadata/ctf-meta-translate.c
src/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.c
src/plugins/ctf/common/metadata/ctf-meta-update-in-ir.c
src/plugins/ctf/common/metadata/ctf-meta-update-meanings.c
src/plugins/ctf/common/metadata/ctf-meta-update-stream-class-config.c
src/plugins/ctf/common/metadata/ctf-meta-update-text-array-sequence.c
src/plugins/ctf/common/metadata/ctf-meta-update-value-storing-indexes.c
src/plugins/ctf/common/metadata/ctf-meta-validate.c
src/plugins/ctf/common/metadata/ctf-meta-visitors.h
src/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.c
src/plugins/ctf/common/metadata/decoder.c
src/plugins/ctf/common/metadata/decoder.h
src/plugins/ctf/common/metadata/lexer.l
src/plugins/ctf/common/metadata/logging.c
src/plugins/ctf/common/metadata/logging.h
src/plugins/ctf/common/metadata/objstack.c
src/plugins/ctf/common/metadata/parser.y
src/plugins/ctf/common/metadata/visitor-generate-ir.c
src/plugins/ctf/common/metadata/visitor-parent-links.c
src/plugins/ctf/common/metadata/visitor-semantic-validator.c
src/plugins/ctf/fs-src/metadata.c
src/plugins/ctf/fs-src/query.c
src/plugins/ctf/lttng-live/metadata.c

index d98ff09e125fc2af4a59646bea0cebe3a4569db7..52f2006e9afbc2b2a3cd63f5a52f9ff1db092b08 100644 (file)
@@ -336,9 +336,11 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
                struct ctf_node *node);
 
 BT_HIDDEN
-int ctf_visitor_semantic_check(int depth, struct ctf_node *node);
+int ctf_visitor_semantic_check(int depth, struct ctf_node *node,
+               bt_logging_level log_level);
 
 BT_HIDDEN
-int ctf_visitor_parent_links(int depth, struct ctf_node *node);
+int ctf_visitor_parent_links(int depth, struct ctf_node *node,
+               bt_logging_level log_level);
 
 #endif /* _CTF_AST_H */
index 17bfcf36e37fbe786460adb9a7b3aabe46135bb4..4b6590f0fdb5ee21f376e24088c4783f90371be4 100644 (file)
@@ -13,8 +13,9 @@
  * all copies or substantial portions of the Software.
  */
 
+#define BT_LOG_OUTPUT_LEVEL (ctx->log_level)
 #define BT_LOG_TAG "PLUGIN/CTF/META/RESOLVE"
-#include "logging.h"
+#include "logging/log.h"
 
 #include <babeltrace2/babeltrace.h>
 #include "common/macros.h"
@@ -50,6 +51,7 @@ struct field_class_stack_frame {
  * The current context of the resolving engine.
  */
 struct resolve_context {
+       bt_logging_level log_level;
        struct ctf_trace_class *tc;
        struct ctf_stream_class *sc;
        struct ctf_event_class *ec;
@@ -124,7 +126,8 @@ void field_class_stack_destroy(field_class_stack *stack)
  * Pushes a field class onto a class stack.
  */
 static
-int field_class_stack_push(field_class_stack *stack, struct ctf_field_class *fc)
+int field_class_stack_push(field_class_stack *stack, struct ctf_field_class *fc,
+               struct resolve_context *ctx)
 {
        int ret = 0;
        struct field_class_stack_frame *frame = NULL;
@@ -209,7 +212,8 @@ end:
  * Removes the top frame of `stack`.
  */
 static
-void field_class_stack_pop(field_class_stack *stack)
+void field_class_stack_pop(field_class_stack *stack,
+               struct resolve_context *ctx)
 {
        if (!field_class_stack_empty(stack)) {
                /*
@@ -254,7 +258,8 @@ struct ctf_field_class *borrow_class_from_ctx(struct resolve_context *ctx,
  * is found to be relative.
  */
 static
-enum ctf_scope get_root_scope_from_absolute_pathstr(const char *pathstr)
+enum ctf_scope get_root_scope_from_absolute_pathstr(const char *pathstr,
+               struct resolve_context *ctx)
 {
        enum ctf_scope scope;
        enum ctf_scope ret = -1;
@@ -331,7 +336,7 @@ const char *ptoken_get_string(GList *ptoken)
  * strings.
  */
 static
-GList *pathstr_to_ptokens(const char *pathstr)
+GList *pathstr_to_ptokens(const char *pathstr, struct resolve_context *ctx)
 {
        const char *at = pathstr;
        const char *last = at;
@@ -379,7 +384,8 @@ error:
  */
 static
 int ptokens_to_field_path(GList *ptokens, struct ctf_field_path *field_path,
-               struct ctf_field_class *fc, int64_t src_index)
+               struct ctf_field_class *fc, int64_t src_index,
+               struct resolve_context *ctx)
 {
        int ret = 0;
        GList *cur_ptoken = ptokens;
@@ -540,7 +546,7 @@ int absolute_ptokens_to_field_path(GList *ptokens,
        }
 
        /* Locate target */
-       ret = ptokens_to_field_path(cur_ptoken, field_path, fc, INT64_MAX);
+       ret = ptokens_to_field_path(cur_ptoken, field_path, fc, INT64_MAX, ctx);
 
 end:
        return ret;
@@ -578,7 +584,7 @@ int relative_ptokens_to_field_path(GList *ptokens,
 
                /* Locate target from current parent class */
                ret = ptokens_to_field_path(ptokens, &tail_field_path,
-                       parent_class, cur_index);
+                       parent_class, cur_index, ctx);
                if (ret) {
                        /* Not found... yet */
                        BT_LOGD_STR("Not found at this point.");
@@ -641,7 +647,7 @@ int pathstr_to_field_path(const char *pathstr,
        GList *ptokens = NULL;
 
        /* Convert path string to path tokens */
-       ptokens = pathstr_to_ptokens(pathstr);
+       ptokens = pathstr_to_ptokens(pathstr, ctx);
        if (!ptokens) {
                BT_LOGE("Cannot convert path string to path tokens: "
                        "path=\"%s\"", pathstr);
@@ -650,7 +656,7 @@ int pathstr_to_field_path(const char *pathstr,
        }
 
        /* Absolute or relative path? */
-       root_scope = get_root_scope_from_absolute_pathstr(pathstr);
+       root_scope = get_root_scope_from_absolute_pathstr(pathstr, ctx);
 
        if (root_scope == -1) {
                /* Relative path: start with current root scope */
@@ -762,7 +768,8 @@ void get_ctx_stack_field_path(struct resolve_context *ctx,
  * objects having the same root scope.
  */
 int64_t get_field_paths_lca_index(struct ctf_field_path *field_path1,
-               struct ctf_field_path *field_path2)
+               struct ctf_field_path *field_path2,
+               struct resolve_context *ctx)
 {
        int64_t lca_index = 0;
        uint64_t field_path1_len, field_path2_len;
@@ -880,7 +887,7 @@ int validate_target_field_path(struct ctf_field_path *target_field_path,
                 * paths.
                 */
                lca_index = get_field_paths_lca_index(target_field_path,
-                       &ctx_field_path);
+                       &ctx_field_path, ctx);
                if (lca_index < 0) {
                        BT_LOGE_STR("Cannot get least common ancestor.");
                        ret = -1;
@@ -1099,7 +1106,7 @@ int resolve_field_class(struct ctf_field_class *fc, struct resolve_context *ctx)
                uint64_t field_count =
                        ctf_field_class_compound_get_field_class_count(fc);
 
-               ret = field_class_stack_push(ctx->field_class_stack, fc);
+               ret = field_class_stack_push(ctx->field_class_stack, fc, ctx);
                if (ret) {
                        BT_LOGE("Cannot push field class on context's stack: "
                                "fc-addr=%p", fc);
@@ -1133,7 +1140,7 @@ int resolve_field_class(struct ctf_field_class *fc, struct resolve_context *ctx)
                        }
                }
 
-               field_class_stack_pop(ctx->field_class_stack);
+               field_class_stack_pop(ctx->field_class_stack, ctx);
                break;
        }
        default:
@@ -1259,11 +1266,13 @@ end:
 }
 
 BT_HIDDEN
-int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc)
+int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc,
+               bt_logging_level log_level)
 {
        int ret = 0;
        uint64_t i;
-       struct resolve_context ctx = {
+       struct resolve_context local_ctx = {
+               .log_level = log_level,
                .tc = tc,
                .sc = NULL,
                .ec = NULL,
@@ -1278,18 +1287,19 @@ int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc)
                .root_scope = CTF_SCOPE_PACKET_HEADER,
                .cur_fc = NULL,
        };
+       struct resolve_context *ctx = &local_ctx;
 
        /* Initialize class stack */
-       ctx.field_class_stack = field_class_stack_create();
-       if (!ctx.field_class_stack) {
+       ctx->field_class_stack = field_class_stack_create();
+       if (!ctx->field_class_stack) {
                BT_LOGE_STR("Cannot create field class stack.");
                ret = -1;
                goto end;
        }
 
        if (!tc->is_translated) {
-               ctx.scopes.packet_header = tc->packet_header_fc;
-               ret = resolve_root_class(CTF_SCOPE_PACKET_HEADER, &ctx);
+               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: "
                                "ret=%d", ret);
@@ -1297,12 +1307,12 @@ int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc)
                }
        }
 
-       ctx.scopes.packet_header = tc->packet_header_fc;
+       ctx->scopes.packet_header = tc->packet_header_fc;
 
        for (i = 0; i < tc->stream_classes->len; i++) {
                struct ctf_stream_class *sc = tc->stream_classes->pdata[i];
 
-               ret = resolve_stream_class_field_classes(&ctx, sc);
+               ret = resolve_stream_class_field_classes(ctx, sc);
                if (ret) {
                        BT_LOGE("Cannot resolve stream class's field classes: "
                                "sc-id=%" PRIu64, sc->id);
@@ -1311,6 +1321,6 @@ int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc)
        }
 
 end:
-       field_class_stack_destroy(ctx.field_class_stack);
+       field_class_stack_destroy(ctx->field_class_stack);
        return ret;
 }
index e05fdba824b6ed2985991309adb7382f81af19d0..6fdc2dc88486067a037151e02907ac6a5665a1e5 100644 (file)
@@ -12,9 +12,6 @@
  * all copies or substantial portions of the Software.
  */
 
-#define BT_LOG_TAG "PLUGIN/CTF/META/TRANSLATE"
-#include "logging.h"
-
 #include <babeltrace2/babeltrace.h>
 #include "common/macros.h"
 #include "common/assert.h"
index eea855fa26d25d44991d23c405f2c65d75df9942..e9578641959818754a5ce4be47d1b86a9b5ab0f5 100644 (file)
@@ -12,8 +12,9 @@
  * all copies or substantial portions of the Software.
  */
 
+#define BT_LOG_OUTPUT_LEVEL log_level
 #define BT_LOG_TAG "PLUGIN/CTF/META/UPDATE-DEF-CC"
-#include "logging.h"
+#include "logging/log.h"
 
 #include <babeltrace2/babeltrace.h>
 #include "common/macros.h"
@@ -27,7 +28,8 @@
 
 static inline
 int find_mapped_clock_class(struct ctf_field_class *fc,
-               struct ctf_clock_class **clock_class)
+               struct ctf_clock_class **clock_class,
+               bt_logging_level log_level)
 {
        int ret = 0;
        uint64_t i;
@@ -69,7 +71,7 @@ int find_mapped_clock_class(struct ctf_field_class *fc,
                                        struct_fc, i);
 
                        ret = find_mapped_clock_class(named_fc->fc,
-                               clock_class);
+                               clock_class, log_level);
                        if (ret) {
                                goto end;
                        }
@@ -87,7 +89,7 @@ int find_mapped_clock_class(struct ctf_field_class *fc,
                                        var_fc, i);
 
                        ret = find_mapped_clock_class(named_fc->fc,
-                               clock_class);
+                               clock_class, log_level);
                        if (ret) {
                                goto end;
                        }
@@ -100,7 +102,8 @@ 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);
+               ret = find_mapped_clock_class(array_fc->elem_fc, clock_class,
+                       log_level);
                if (ret) {
                        goto end;
                }
@@ -117,7 +120,8 @@ end:
 
 static inline
 int update_stream_class_default_clock_class(
-               struct ctf_stream_class *stream_class)
+               struct ctf_stream_class *stream_class,
+               bt_logging_level log_level)
 {
        int ret = 0;
        struct ctf_clock_class *clock_class =
@@ -125,19 +129,19 @@ int update_stream_class_default_clock_class(
        uint64_t i;
 
        ret = find_mapped_clock_class(stream_class->packet_context_fc,
-               &clock_class);
+               &clock_class, log_level);
        if (ret) {
                goto end;
        }
 
        ret = find_mapped_clock_class(stream_class->event_header_fc,
-               &clock_class);
+               &clock_class, log_level);
        if (ret) {
                goto end;
        }
 
        ret = find_mapped_clock_class(stream_class->event_common_context_fc,
-               &clock_class);
+               &clock_class, log_level);
        if (ret) {
                goto end;
        }
@@ -147,13 +151,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);
+                       &clock_class, log_level);
                if (ret) {
                        goto end;
                }
 
                ret = find_mapped_clock_class(event_class->payload_fc,
-                       &clock_class);
+                       &clock_class, log_level);
                if (ret) {
                        goto end;
                }
@@ -168,13 +172,15 @@ end:
 }
 
 BT_HIDDEN
-int ctf_trace_class_update_default_clock_classes(struct ctf_trace_class *ctf_tc)
+int ctf_trace_class_update_default_clock_classes(struct ctf_trace_class *ctf_tc,
+               bt_logging_level log_level)
 {
        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);
+       ret = find_mapped_clock_class(ctf_tc->packet_header_fc, &clock_class,
+               log_level);
        if (ret) {
                goto end;
        }
@@ -189,7 +195,7 @@ 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]);
+                       ctf_tc->stream_classes->pdata[i], log_level);
                if (ret) {
                        BT_LOGE("Stream class contains more than one "
                                "clock class: stream-class-id=%" PRIu64,
index cdafe1c8d1c1e77908e0a22d075c8e48a1f44917..ce6251a14becd5c8346e04fa2721f6e03544f8a2 100644 (file)
@@ -12,9 +12,6 @@
  * all copies or substantial portions of the Software.
  */
 
-#define BT_LOG_TAG "PLUGIN/CTF/META/UPDATE-IN-IR"
-#include "logging.h"
-
 #include <babeltrace2/babeltrace.h>
 #include "common/macros.h"
 #include "common/assert.h"
index 865ff59ca13ce8b3352fb296044324589a7d70ff..a9b1f1735d06fed6a82b6b5ff1d40007b3f60d03 100644 (file)
@@ -12,9 +12,6 @@
  * all copies or substantial portions of the Software.
  */
 
-#define BT_LOG_TAG "PLUGIN/CTF/META/UPDATE-MEANINGS"
-#include "logging.h"
-
 #include <babeltrace2/babeltrace.h>
 #include "common/macros.h"
 #include "common/assert.h"
index a9683718314da7bee548ccc8a9e220db8e1ba60f..ad304f0d114c1221bac3b4f765ea1ef69067b0d3 100644 (file)
@@ -12,9 +12,6 @@
  * all copies or substantial portions of the Software.
  */
 
-#define BT_LOG_TAG "PLUGIN/CTF/META/UPDATE-SC-CONFIG"
-#include "logging.h"
-
 #include <babeltrace2/babeltrace.h>
 #include "common/macros.h"
 #include "common/assert.h"
index c1b2ae76d596fbeaa7e2d8582cb7d183ba573eb6..9d1de5016d60741f5fa5ebc53c1dd7b06739d721 100644 (file)
@@ -12,9 +12,6 @@
  * all copies or substantial portions of the Software.
  */
 
-#define BT_LOG_TAG "PLUGIN/CTF/META/UPDATE-TEXT-ARRAY-SEQ"
-#include "logging.h"
-
 #include <babeltrace2/babeltrace.h>
 #include "common/macros.h"
 #include "common/assert.h"
index 20cd4cb6b31e8a7ae2d4c987dac7395885bd5861..2cb3e1d28581df40bf540e09169c2380eb2270bd 100644 (file)
@@ -12,9 +12,6 @@
  * all copies or substantial portions of the Software.
  */
 
-#define BT_LOG_TAG "PLUGIN/CTF/META/UPDATE-VALUE-STORING-INDEXES"
-#include "logging.h"
-
 #include <babeltrace2/babeltrace.h>
 #include "common/macros.h"
 #include "common/assert.h"
index d778270c2ded2dcd341832f908ebe60299394803..74e02bb36653985d1c5e91c7170191b3441f1b94 100644 (file)
@@ -12,8 +12,9 @@
  * all copies or substantial portions of the Software.
  */
 
+#define BT_LOG_OUTPUT_LEVEL log_level
 #define BT_LOG_TAG "PLUGIN/CTF/META/VALIDATE"
-#include "logging.h"
+#include "logging/log.h"
 
 #include <babeltrace2/babeltrace.h>
 #include "common/macros.h"
@@ -26,7 +27,8 @@
 #include "ctf-meta-visitors.h"
 
 static
-int validate_stream_class(struct ctf_stream_class *sc)
+int validate_stream_class(struct ctf_stream_class *sc,
+               bt_logging_level log_level)
 {
        int ret = 0;
        struct ctf_field_class_int *int_fc;
@@ -186,7 +188,8 @@ end:
 }
 
 BT_HIDDEN
-int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc)
+int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
+               bt_logging_level log_level)
 {
        int ret = 0;
        struct ctf_field_class_int *int_fc;
@@ -332,7 +335,7 @@ 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);
+               ret = validate_stream_class(sc, log_level);
                if (ret) {
                        BT_LOGE("Invalid stream class: sc-id=%" PRIu64, sc->id);
                        goto invalid;
index cfcb043e2327e63c4b544d8bd8379ef540f4831d..875a8ce4ff2311f19644f942380c9945198e2256 100644 (file)
@@ -21,7 +21,8 @@
 #include "ctf-meta.h"
 
 BT_HIDDEN
-int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc);
+int ctf_trace_class_resolve_field_classes(struct ctf_trace_class *tc,
+               bt_logging_level log_level);
 
 BT_HIDDEN
 int ctf_trace_class_translate(bt_self_component_source *self_comp,
@@ -29,7 +30,8 @@ int ctf_trace_class_translate(bt_self_component_source *self_comp,
 
 BT_HIDDEN
 int ctf_trace_class_update_default_clock_classes(
-               struct ctf_trace_class *ctf_tc);
+               struct ctf_trace_class *ctf_tc,
+               bt_logging_level log_level);
 
 BT_HIDDEN
 int ctf_trace_class_update_in_ir(struct ctf_trace_class *ctf_tc);
@@ -47,10 +49,11 @@ BT_HIDDEN
 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);
+int ctf_trace_class_validate(struct ctf_trace_class *ctf_tc,
+               bt_logging_level log_level);
 
 BT_HIDDEN
 void ctf_trace_class_warn_meaningless_header_fields(
-               struct ctf_trace_class *ctf_tc);
+               struct ctf_trace_class *ctf_tc, bt_logging_level log_level);
 
 #endif /* _CTF_META_VISITORS_H */
index c43648ac46079052dd55a07c76bfe21a7782edaf..27c4798322d33365830400d585d58133274569cd 100644 (file)
@@ -12,8 +12,9 @@
  * all copies or substantial portions of the Software.
  */
 
+#define BT_LOG_OUTPUT_LEVEL log_level
 #define BT_LOG_TAG "PLUGIN/CTF/META/WARN-MEANINGLESS-HEADER-FIELDS"
-#include "logging.h"
+#include "logging/log.h"
 
 #include <babeltrace2/babeltrace.h>
 #include "common/macros.h"
@@ -26,7 +27,8 @@
 #include "ctf-meta-visitors.h"
 
 static inline
-void warn_meaningless_field(const char *name, const char *scope_name)
+void warn_meaningless_field(const char *name, const char *scope_name,
+               bt_logging_level log_level)
 {
        BT_LOGW("User field found in %s: ignoring: name=\"%s\"",
                scope_name, name);
@@ -34,7 +36,7 @@ void warn_meaningless_field(const char *name, const char *scope_name)
 
 static inline
 void warn_meaningless_fields(struct ctf_field_class *fc, const char *name,
-               const char *scope_name)
+               const char *scope_name, bt_logging_level log_level)
 {
        uint64_t i;
 
@@ -45,7 +47,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);
+               warn_meaningless_field(name, scope_name, log_level);
                break;
        case CTF_FIELD_CLASS_TYPE_INT:
        case CTF_FIELD_CLASS_TYPE_ENUM:
@@ -54,7 +56,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);
+                       warn_meaningless_field(name, scope_name, log_level);
                }
 
                break;
@@ -69,7 +71,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);
+                               named_fc->name->str, scope_name, log_level);
                }
 
                break;
@@ -84,7 +86,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);
+                               named_fc->name->str, scope_name, log_level);
                }
 
                break;
@@ -103,7 +105,8 @@ 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);
+               warn_meaningless_fields(array_fc->elem_fc, name, scope_name,
+                       log_level);
                break;
        }
        default:
@@ -116,13 +119,15 @@ end:
 
 BT_HIDDEN
 void ctf_trace_class_warn_meaningless_header_fields(
-               struct ctf_trace_class *ctf_tc)
+               struct ctf_trace_class *ctf_tc,
+               bt_logging_level log_level)
 {
        uint64_t i;
 
        if (!ctf_tc->is_translated) {
                warn_meaningless_fields(
-                       ctf_tc->packet_header_fc, NULL, "packet header");
+                       ctf_tc->packet_header_fc, NULL, "packet header",
+                       log_level);
        }
 
        for (i = 0; i < ctf_tc->stream_classes->len; i++) {
@@ -130,7 +135,7 @@ void ctf_trace_class_warn_meaningless_header_fields(
 
                if (!sc->is_translated) {
                        warn_meaningless_fields(sc->event_header_fc, NULL,
-                               "event header");
+                               "event header", log_level);
                }
        }
 }
index 8422b16673cd8183dacb2a33c3af300c85edc4e5..5f20eae8945cb3f21608c34128ae9ab60535aed2 100644 (file)
@@ -12,8 +12,9 @@
  * all copies or substantial portions of the Software.
  */
 
+#define BT_LOG_OUTPUT_LEVEL (mdec->config.log_level)
 #define BT_LOG_TAG "PLUGIN/CTF/META/DECODER"
-#include "logging.h"
+#include "logging/log.h"
 
 #include <stdio.h>
 #include <stdbool.h>
@@ -58,7 +59,8 @@ struct packet_header {
 } __attribute__((__packed__));
 
 BT_HIDDEN
-bool ctf_metadata_decoder_is_packetized(FILE *fp, int *byte_order)
+bool ctf_metadata_decoder_is_packetized(FILE *fp, int *byte_order,
+               bt_logging_level log_level)
 {
        uint32_t magic;
        size_t len;
@@ -66,7 +68,8 @@ bool ctf_metadata_decoder_is_packetized(FILE *fp, int *byte_order)
 
        len = fread(&magic, sizeof(magic), 1, fp);
        if (len != 1) {
-               BT_LOGI_STR("Cannot read first metadata packet header: assuming the stream is not packetized.");
+               BT_LOG_WRITE_CUR_LVL(BT_LOG_INFO, log_level, BT_LOG_TAG,
+                       "Cannot read first metadata packet header: assuming the stream is not packetized.");
                goto end;
        }
 
@@ -264,7 +267,7 @@ 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)
+               char **buf, int byte_order, bt_logging_level log_level)
 {
        FILE *out_fp;
        size_t size;
@@ -274,7 +277,8 @@ int ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec(
 
        out_fp = bt_open_memstream(buf, &size);
        if (out_fp == NULL) {
-               BT_LOGE("Cannot open memory stream: %s: mdec-addr=%p",
+               BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
+                       "Cannot open memory stream: %s: mdec-addr=%p",
                        strerror(errno), mdec);
                goto error;
        }
@@ -286,7 +290,8 @@ int ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec(
 
                tret = decode_packet(mdec, fp, out_fp, byte_order);
                if (tret) {
-                       BT_LOGE("Cannot decode packet: index=%zu, mdec-addr=%p",
+                       BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
+                               "Cannot decode packet: index=%zu, mdec-addr=%p",
                                packet_index, mdec);
                        goto error;
                }
@@ -297,7 +302,8 @@ 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_LOGE("Cannot append '\\0' to the decoded metadata buffer: "
+               BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
+                       "Cannot append '\\0' to the decoded metadata buffer: "
                        "mdec-addr=%p", mdec);
                goto error;
        }
@@ -312,8 +318,8 @@ int ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec(
         */
        out_fp = NULL;
        if (ret < 0) {
-               BT_LOGE("Cannot close memory stream: %s: mdec-addr=%p",
-                       strerror(errno), mdec);
+               BT_LOG_WRITE_ERRNO_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
+                       "Cannot close memory stream", ": mdec-addr=%p", mdec);
                goto error;
        }
 
@@ -324,7 +330,8 @@ error:
 
        if (out_fp) {
                if (bt_close_memstream(buf, &size, out_fp)) {
-                       BT_LOGE("Cannot close memory stream: %s: mdec-addr=%p",
+                       BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
+                               "Cannot close memory stream: %s: mdec-addr=%p",
                                strerror(errno), mdec);
                }
        }
@@ -340,10 +347,11 @@ end:
 
 BT_HIDDEN
 int ctf_metadata_decoder_packetized_file_stream_to_buf(
-               FILE *fp, char **buf, int byte_order)
+               FILE *fp, char **buf, int byte_order,
+               bt_logging_level log_level)
 {
        return ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec(
-               NULL, fp, buf, byte_order);
+               NULL, fp, buf, byte_order, log_level);
 }
 
 BT_HIDDEN
@@ -417,10 +425,11 @@ enum ctf_metadata_decoder_status ctf_metadata_decoder_decode(
 
        BT_ASSERT(mdec);
 
-       if (ctf_metadata_decoder_is_packetized(fp, &mdec->bo)) {
+       if (ctf_metadata_decoder_is_packetized(fp, &mdec->bo,
+                       BT_LOG_OUTPUT_LEVEL)) {
                BT_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);
+                       mdec, fp, &buf, mdec->bo, BT_LOG_OUTPUT_LEVEL);
                if (ret) {
                        BT_LOGE("Cannot decode packetized metadata packets to metadata text: "
                                "mdec-addr=%p, ret=%d", mdec, ret);
@@ -502,7 +511,8 @@ enum ctf_metadata_decoder_status ctf_metadata_decoder_decode(
                goto end;
        }
 
-       ret = ctf_visitor_semantic_check(0, &scanner->ast->root);
+       ret = ctf_visitor_semantic_check(0, &scanner->ast->root,
+               mdec->config.log_level);
        if (ret) {
                BT_LOGE("Validation of the metadata semantics failed: "
                        "mdec-addr=%p", mdec);
index a231034fa72a67d8f405ba467de40a7cf85d59a2..4d77b472b35827f75c03557aa3d5259f1c1bc125 100644 (file)
@@ -36,6 +36,7 @@ enum ctf_metadata_decoder_status {
 
 /* Decoding configuration */
 struct ctf_metadata_decoder_config {
+       bt_logging_level log_level;
        int64_t clock_class_offset_s;
        int64_t clock_class_offset_ns;
 };
@@ -102,7 +103,8 @@ struct ctf_trace_class *ctf_metadata_decoder_borrow_ctf_trace_class(
  * if so, sets `*byte_order` to the byte order of the first packet.
  */
 BT_HIDDEN
-bool ctf_metadata_decoder_is_packetized(FILE *fp, int *byte_order);
+bool ctf_metadata_decoder_is_packetized(FILE *fp, int *byte_order,
+               bt_logging_level log_level);
 
 /*
  * Decodes a packetized metadata file stream to a NULL-terminated
@@ -110,6 +112,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);
+               FILE *fp, char **buf, int byte_order,
+               bt_logging_level log_level);
 
 #endif /* _METADATA_DECODER_H */
index 694ddc3aed28258b26ae0f36a27577841470a43b..09475a4aa67b623a86b02a4f5b62e3e40dd2c818 100644 (file)
@@ -25,6 +25,7 @@
  * SOFTWARE.
  */
 
+#define BT_LOG_OUTPUT_LEVEL ctf_plugin_metadata_log_level
 #define BT_LOG_TAG "PLUGIN-CTF-METADATA-LEXER"
 #include "logging.h"
 
index c7b514f460dca541ba358fed8c3b99328b110aac..7e37c3747302e140a6fe2084a21cbfffb18a60c2 100644 (file)
@@ -20,7 +20,7 @@
  * SOFTWARE.
  */
 
-#define BT_LOG_OUTPUT_LEVEL metadata_log_level
+#define BT_LOG_OUTPUT_LEVEL ctf_plugin_metadata_log_level
 #include "logging/log.h"
 
-BT_LOG_INIT_LOG_LEVEL(metadata_log_level, "BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL");
+BT_LOG_INIT_LOG_LEVEL(ctf_plugin_metadata_log_level, "BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL");
index 81f76a2a3166c0062b26d9e62b384c0f5a007958..dbd00474048ac004e7c74d884784724dca66e6c7 100644 (file)
  * SOFTWARE.
  */
 
-#define BT_LOG_OUTPUT_LEVEL metadata_log_level
 #include "logging/log.h"
 
-BT_LOG_LEVEL_EXTERN_SYMBOL(metadata_log_level);
+/*
+ * This global log level is for the generated lexer and parser: we can't
+ * use a contextual log level for their "tracing", so they rely on this.
+ */
+BT_LOG_LEVEL_EXTERN_SYMBOL(ctf_plugin_metadata_log_level);
 
 #define _BT_LOGV_LINENO(_lineno, _msg, args...) \
        BT_LOGV("At line %u in metadata stream: " _msg, _lineno, ## args)
index 20dbbdaef2f4394b1710452ea7e5ccef179b887c..febb9f287308697fb2f475dcb35a50dbe320aa03 100644 (file)
@@ -24,6 +24,7 @@
  * SOFTWARE.
  */
 
+#define BT_LOG_OUTPUT_LEVEL ctf_plugin_metadata_log_level
 #define BT_LOG_TAG "PLUGIN/CTF/META/OBJSTACK"
 #include "logging.h"
 
index 3f993cefd333f9d35d9ad4a5e36e9e1c501decb5..e014db1f2fb0c83b74cd219b56bd4342bb1e2fb2 100644 (file)
@@ -25,6 +25,7 @@
  * SOFTWARE.
  */
 
+#define BT_LOG_OUTPUT_LEVEL ctf_plugin_metadata_log_level
 #define BT_LOG_TAG "PLUGIN/CTF/META/PARSER"
 #include "logging.h"
 
index 2b87f609b421da3fbd046966a11b289bb734fe25..09edde35ef228b5a1eeb277349b376dd2a9c2398 100644 (file)
@@ -27,8 +27,9 @@
  * SOFTWARE.
  */
 
+#define BT_LOG_OUTPUT_LEVEL (ctx->log_level)
 #define BT_LOG_TAG "PLUGIN/CTF/META/IR-VISITOR"
-#include "logging.h"
+#include "logging/log.h"
 
 #include <stdio.h>
 #include <unistd.h>
@@ -45,6 +46,7 @@
 #include "compat/endian.h"
 #include <babeltrace2/babeltrace.h>
 
+#include "logging.h"
 #include "scanner.h"
 #include "parser.h"
 #include "ast.h"
@@ -193,6 +195,7 @@ struct ctx_decl_scope {
  * Visitor context (private).
  */
 struct ctx {
+       bt_logging_level log_level;
        bt_self_component_source *self_comp;
        /* Trace IR trace class being filled (owned by this) */
        bt_trace_class *trace_class;
@@ -225,7 +228,8 @@ struct ctf_visitor_generate_ir;
  * @returns            New declaration scope, or NULL on error
  */
 static
-struct ctx_decl_scope *ctx_decl_scope_create(struct ctx_decl_scope *par_scope)
+struct ctx_decl_scope *ctx_decl_scope_create(struct ctx *ctx,
+               struct ctx_decl_scope *par_scope)
 {
        struct ctx_decl_scope *scope;
 
@@ -272,7 +276,7 @@ end:
  * @returns            Associated GQuark, or 0 on error
  */
 static
-GQuark get_prefixed_named_quark(char prefix, const char *name)
+GQuark get_prefixed_named_quark(struct ctx *ctx, char prefix, const char *name)
 {
        GQuark qname = 0;
 
@@ -306,8 +310,8 @@ end:
  */
 static
 struct ctf_field_class *ctx_decl_scope_lookup_prefix_alias(
-               struct ctx_decl_scope *scope, char prefix, const char *name,
-               int levels, bool copy)
+               struct ctx *ctx, struct ctx_decl_scope *scope, char prefix,
+               const char *name, int levels, bool copy)
 {
        GQuark qname = 0;
        int cur_levels = 0;
@@ -316,7 +320,7 @@ struct ctf_field_class *ctx_decl_scope_lookup_prefix_alias(
 
        BT_ASSERT(scope);
        BT_ASSERT(name);
-       qname = get_prefixed_named_quark(prefix, name);
+       qname = get_prefixed_named_quark(ctx, prefix, name);
        if (!qname) {
                goto end;
        }
@@ -357,11 +361,11 @@ end:
  *                     or NULL if not found
  */
 static
-struct ctf_field_class *ctx_decl_scope_lookup_alias(
+struct ctf_field_class *ctx_decl_scope_lookup_alias(struct ctx *ctx,
                struct ctx_decl_scope *scope, const char *name, int levels,
                bool copy)
 {
-       return ctx_decl_scope_lookup_prefix_alias(scope, _PREFIX_ALIAS,
+       return ctx_decl_scope_lookup_prefix_alias(ctx, scope, _PREFIX_ALIAS,
                name, levels, copy);
 }
 
@@ -376,12 +380,12 @@ struct ctf_field_class *ctx_decl_scope_lookup_alias(
  *                     or NULL if not found
  */
 static
-struct ctf_field_class_enum *ctx_decl_scope_lookup_enum(
+struct ctf_field_class_enum *ctx_decl_scope_lookup_enum(struct ctx *ctx,
                struct ctx_decl_scope *scope, const char *name, int levels,
                bool copy)
 {
-       return (void *) ctx_decl_scope_lookup_prefix_alias(scope, _PREFIX_ENUM,
-               name, levels, copy);
+       return (void *) ctx_decl_scope_lookup_prefix_alias(ctx, scope,
+               _PREFIX_ENUM, name, levels, copy);
 }
 
 /**
@@ -395,11 +399,11 @@ struct ctf_field_class_enum *ctx_decl_scope_lookup_enum(
  *                     or NULL if not found
  */
 static
-struct ctf_field_class_struct *ctx_decl_scope_lookup_struct(
+struct ctf_field_class_struct *ctx_decl_scope_lookup_struct(struct ctx *ctx,
                struct ctx_decl_scope *scope, const char *name, int levels,
                bool copy)
 {
-       return (void *) ctx_decl_scope_lookup_prefix_alias(scope,
+       return (void *) ctx_decl_scope_lookup_prefix_alias(ctx, scope,
                _PREFIX_STRUCT, name, levels, copy);
 }
 
@@ -414,11 +418,11 @@ struct ctf_field_class_struct *ctx_decl_scope_lookup_struct(
  *                     or NULL if not found
  */
 static
-struct ctf_field_class_variant *ctx_decl_scope_lookup_variant(
+struct ctf_field_class_variant *ctx_decl_scope_lookup_variant(struct ctx *ctx,
                struct ctx_decl_scope *scope, const char *name, int levels,
                bool copy)
 {
-       return (void *) ctx_decl_scope_lookup_prefix_alias(scope,
+       return (void *) ctx_decl_scope_lookup_prefix_alias(ctx, scope,
                _PREFIX_VARIANT, name, levels, copy);
 }
 
@@ -432,8 +436,9 @@ struct ctf_field_class_variant *ctx_decl_scope_lookup_variant(
  * @returns            0 if registration went okay, negative value otherwise
  */
 static
-int ctx_decl_scope_register_prefix_alias(struct ctx_decl_scope *scope,
-               char prefix, const char *name, struct ctf_field_class *decl)
+int ctx_decl_scope_register_prefix_alias(struct ctx *ctx,
+               struct ctx_decl_scope *scope, char prefix, const char *name,
+               struct ctf_field_class *decl)
 {
        int ret = 0;
        GQuark qname = 0;
@@ -441,14 +446,14 @@ int ctx_decl_scope_register_prefix_alias(struct ctx_decl_scope *scope,
        BT_ASSERT(scope);
        BT_ASSERT(name);
        BT_ASSERT(decl);
-       qname = get_prefixed_named_quark(prefix, name);
+       qname = get_prefixed_named_quark(ctx, prefix, name);
        if (!qname) {
                ret = -ENOMEM;
                goto end;
        }
 
        /* Make sure alias does not exist in local scope */
-       if (ctx_decl_scope_lookup_prefix_alias(scope, prefix, name, 1,
+       if (ctx_decl_scope_lookup_prefix_alias(ctx, scope, prefix, name, 1,
                        false)) {
                ret = -EEXIST;
                goto end;
@@ -471,10 +476,10 @@ end:
  * @returns    0 if registration went okay, negative value otherwise
  */
 static
-int ctx_decl_scope_register_alias(struct ctx_decl_scope *scope,
+int ctx_decl_scope_register_alias(struct ctx *ctx, struct ctx_decl_scope *scope,
                const char *name, struct ctf_field_class *decl)
 {
-       return ctx_decl_scope_register_prefix_alias(scope, _PREFIX_ALIAS,
+       return ctx_decl_scope_register_prefix_alias(ctx, scope, _PREFIX_ALIAS,
                name, (void *) decl);
 }
 
@@ -487,10 +492,10 @@ int ctx_decl_scope_register_alias(struct ctx_decl_scope *scope,
  * @returns    0 if registration went okay, negative value otherwise
  */
 static
-int ctx_decl_scope_register_enum(struct ctx_decl_scope *scope,
+int ctx_decl_scope_register_enum(struct ctx *ctx, struct ctx_decl_scope *scope,
                const char *name, struct ctf_field_class_enum *decl)
 {
-       return ctx_decl_scope_register_prefix_alias(scope, _PREFIX_ENUM,
+       return ctx_decl_scope_register_prefix_alias(ctx, scope, _PREFIX_ENUM,
                name, (void *) decl);
 }
 
@@ -503,10 +508,11 @@ int ctx_decl_scope_register_enum(struct ctx_decl_scope *scope,
  * @returns    0 if registration went okay, negative value otherwise
  */
 static
-int ctx_decl_scope_register_struct(struct ctx_decl_scope *scope,
-               const char *name, struct ctf_field_class_struct *decl)
+int ctx_decl_scope_register_struct(struct ctx *ctx,
+               struct ctx_decl_scope *scope, const char *name,
+               struct ctf_field_class_struct *decl)
 {
-       return ctx_decl_scope_register_prefix_alias(scope, _PREFIX_STRUCT,
+       return ctx_decl_scope_register_prefix_alias(ctx, scope, _PREFIX_STRUCT,
                name, (void *) decl);
 }
 
@@ -519,10 +525,11 @@ int ctx_decl_scope_register_struct(struct ctx_decl_scope *scope,
  * @returns    0 if registration went okay, negative value otherwise
  */
 static
-int ctx_decl_scope_register_variant(struct ctx_decl_scope *scope,
-               const char *name, struct ctf_field_class_variant *decl)
+int ctx_decl_scope_register_variant(struct ctx *ctx,
+               struct ctx_decl_scope *scope, const char *name,
+               struct ctf_field_class_variant *decl)
 {
-       return ctx_decl_scope_register_prefix_alias(scope, _PREFIX_VARIANT,
+       return ctx_decl_scope_register_prefix_alias(ctx, scope, _PREFIX_VARIANT,
                name, (void *) decl);
 }
 
@@ -580,10 +587,14 @@ struct ctx *ctx_create(bt_self_component_source *self_comp,
 
        ctx = g_new0(struct ctx, 1);
        if (!ctx) {
-               BT_LOGE_STR("Failed to allocate one visitor context.");
+               BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, decoder_config->log_level,
+                       BT_LOG_TAG,
+                       "Failed to allocate one visitor context.");
                goto error;
        }
 
+       ctx->log_level = decoder_config->log_level;
+
        if (self_comp) {
                ctx->trace_class = bt_trace_class_create(
                        bt_self_component_source_as_self_component(self_comp));
@@ -601,7 +612,7 @@ struct ctx *ctx_create(bt_self_component_source *self_comp,
        }
 
        /* Root declaration scope */
-       ctx->current_scope = ctx_decl_scope_create(NULL);
+       ctx->current_scope = ctx_decl_scope_create(ctx, NULL);
        if (!ctx->current_scope) {
                BT_LOGE_STR("Cannot create declaration scope.");
                goto error;
@@ -632,7 +643,7 @@ int ctx_push_scope(struct ctx *ctx)
        struct ctx_decl_scope *new_scope;
 
        BT_ASSERT(ctx);
-       new_scope = ctx_decl_scope_create(ctx->current_scope);
+       new_scope = ctx_decl_scope_create(ctx, ctx->current_scope);
        if (!new_scope) {
                BT_LOGE_STR("Cannot create declaration scope.");
                ret = -ENOMEM;
@@ -669,7 +680,7 @@ int visit_field_class_specifier_list(struct ctx *ctx, struct ctf_node *ts_list,
                struct ctf_field_class **decl);
 
 static
-char *remove_underscores_from_field_ref(const char *field_ref)
+char *remove_underscores_from_field_ref(struct ctx *ctx, const char *field_ref)
 {
        const char *in_ch;
        char *out_ch;
@@ -874,7 +885,8 @@ int is_unary_unsigned(struct bt_list_head *head)
 }
 
 static
-int get_unary_unsigned(struct bt_list_head *head, uint64_t *value)
+int get_unary_unsigned(struct ctx *ctx, struct bt_list_head *head,
+               uint64_t *value)
 {
        int i = 0;
        int ret = 0;
@@ -966,7 +978,8 @@ end:
 }
 
 static
-int get_unary_uuid(struct bt_list_head *head, unsigned char *uuid)
+int get_unary_uuid(struct ctx *ctx, struct bt_list_head *head,
+               unsigned char *uuid)
 {
        int i = 0;
        int ret = 0;
@@ -999,7 +1012,7 @@ end:
 }
 
 static
-int get_boolean(struct ctf_node *unary_expr)
+int get_boolean(struct ctx *ctx, struct ctf_node *unary_expr)
 {
        int ret = 0;
 
@@ -1047,7 +1060,8 @@ end:
 }
 
 static
-enum ctf_byte_order byte_order_from_unary_expr(struct ctf_node *unary_expr)
+enum ctf_byte_order byte_order_from_unary_expr(struct ctx *ctx,
+               struct ctf_node *unary_expr)
 {
        const char *str;
        enum ctf_byte_order bo = -1;
@@ -1082,7 +1096,7 @@ static
 enum ctf_byte_order get_real_byte_order(struct ctx *ctx,
                struct ctf_node *uexpr)
 {
-       enum ctf_byte_order bo = byte_order_from_unary_expr(uexpr);
+       enum ctf_byte_order bo = byte_order_from_unary_expr(ctx, uexpr);
 
        if (bo == CTF_BYTE_ORDER_DEFAULT) {
                bo = ctx->ctf_tc->default_byte_order;
@@ -1329,7 +1343,8 @@ int visit_field_class_declarator(struct ctx *ctx,
                        qalias = create_class_alias_identifier(ctx,
                                cls_specifier_list, node_field_class_declarator);
                        nested_decl =
-                               ctx_decl_scope_lookup_alias(ctx->current_scope,
+                               ctx_decl_scope_lookup_alias(ctx,
+                                       ctx->current_scope,
                                        g_quark_to_string(qalias), -1, true);
                        if (!nested_decl) {
                                _BT_LOGE_NODE(node_field_class_declarator,
@@ -1479,7 +1494,7 @@ int visit_field_class_declarator(struct ctx *ctx,
                                decl = (void *) array_decl;
                        } else {
                                char *length_name_no_underscore =
-                                       remove_underscores_from_field_ref(
+                                       remove_underscores_from_field_ref(ctx,
                                                length_name);
                                if (!length_name_no_underscore) {
                                        /*
@@ -1686,7 +1701,7 @@ int visit_field_class_def(struct ctx *ctx, struct ctf_node *cls_specifier_list,
                        }
                }
 
-               ret = ctx_decl_scope_register_alias(ctx->current_scope,
+               ret = ctx_decl_scope_register_alias(ctx, ctx->current_scope,
                        g_quark_to_string(qidentifier), class_decl);
                if (ret) {
                        _BT_LOGE_NODE(iter,
@@ -1760,7 +1775,7 @@ int visit_field_class_alias(struct ctx *ctx, struct ctf_node *target,
                struct ctf_node, siblings);
        qalias = create_class_alias_identifier(ctx,
                alias->u.field_class_alias_name.field_class_specifier_list, node);
-       ret = ctx_decl_scope_register_alias(ctx->current_scope,
+       ret = ctx_decl_scope_register_alias(ctx, ctx->current_scope,
                g_quark_to_string(qalias), class_decl);
        if (ret) {
                _BT_LOGE_NODE(node,
@@ -1895,7 +1910,7 @@ int visit_struct_decl(struct ctx *ctx, const char *name,
                        goto error;
                }
 
-               *struct_decl = ctx_decl_scope_lookup_struct(ctx->current_scope,
+               *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\"",
@@ -1908,7 +1923,7 @@ int visit_struct_decl(struct ctx *ctx, const char *name,
                uint64_t min_align_value = 0;
 
                if (name) {
-                       if (ctx_decl_scope_lookup_struct(
+                       if (ctx_decl_scope_lookup_struct(ctx,
                                        ctx->current_scope, name, 1, false)) {
                                BT_LOGE("Structure field class already declared in local scope: "
                                        "name=\"struct %s\"", name);
@@ -1918,7 +1933,8 @@ int visit_struct_decl(struct ctx *ctx, const char *name,
                }
 
                if (!bt_list_empty(min_align)) {
-                       ret = get_unary_unsigned(min_align, &min_align_value);
+                       ret = get_unary_unsigned(ctx, min_align,
+                               &min_align_value);
                        if (ret) {
                                BT_LOGE("Unexpected unary expression for structure field class's `align` attribute: "
                                        "ret=%d", ret);
@@ -1950,8 +1966,8 @@ int visit_struct_decl(struct ctx *ctx, const char *name,
                ctx_pop_scope(ctx);
 
                if (name) {
-                       ret = ctx_decl_scope_register_struct(ctx->current_scope,
-                               name, *struct_decl);
+                       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: "
                                        "name=\"struct %s\", ret=%d", name, ret);
@@ -1988,7 +2004,7 @@ int visit_variant_decl(struct ctx *ctx, const char *name,
                }
 
                untagged_variant_decl =
-                       ctx_decl_scope_lookup_variant(ctx->current_scope,
+                       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\"",
@@ -2000,8 +2016,8 @@ int visit_variant_decl(struct ctx *ctx, const char *name,
                struct ctf_node *entry_node;
 
                if (name) {
-                       if (ctx_decl_scope_lookup_variant(ctx->current_scope,
-                                       name, 1, false)) {
+                       if (ctx_decl_scope_lookup_variant(ctx,
+                                       ctx->current_scope, name, 1, false)) {
                                BT_LOGE("Variant field class already declared in local scope: "
                                        "name=\"variant %s\"", name);
                                ret = -EINVAL;
@@ -2028,7 +2044,7 @@ int visit_variant_decl(struct ctx *ctx, const char *name,
                ctx_pop_scope(ctx);
 
                if (name) {
-                       ret = ctx_decl_scope_register_variant(
+                       ret = ctx_decl_scope_register_variant(ctx,
                                ctx->current_scope, name,
                                untagged_variant_decl);
                        if (ret) {
@@ -2052,7 +2068,7 @@ int visit_variant_decl(struct ctx *ctx, const char *name,
                 * else owns it. Set its tag now.
                 */
                char *tag_no_underscore =
-                       remove_underscores_from_field_ref(tag);
+                       remove_underscores_from_field_ref(ctx, tag);
 
                if (!tag_no_underscore) {
                        /* remove_underscores_from_field_ref() logs errors */
@@ -2210,7 +2226,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name,
                        goto error;
                }
 
-               *enum_decl = ctx_decl_scope_lookup_enum(ctx->current_scope,
+               *enum_decl = ctx_decl_scope_lookup_enum(ctx, ctx->current_scope,
                        name, -1, true);
                if (!*enum_decl) {
                        BT_LOGE("Cannot find enumeration field class: "
@@ -2226,7 +2242,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name,
                };
 
                if (name) {
-                       if (ctx_decl_scope_lookup_enum(ctx->current_scope,
+                       if (ctx_decl_scope_lookup_enum(ctx, ctx->current_scope,
                                        name, 1, false)) {
                                BT_LOGE("Enumeration field class already declared in local scope: "
                                        "name=\"enum %s\"", name);
@@ -2236,7 +2252,7 @@ int visit_enum_decl(struct ctx *ctx, const char *name,
                }
 
                if (!container_cls) {
-                       integer_decl = (void *) ctx_decl_scope_lookup_alias(
+                       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.");
@@ -2283,8 +2299,8 @@ int visit_enum_decl(struct ctx *ctx, const char *name,
                }
 
                if (name) {
-                       ret = ctx_decl_scope_register_enum(ctx->current_scope,
-                               name, *enum_decl);
+                       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: "
                                        "ret=%d", ret);
@@ -2322,8 +2338,8 @@ int visit_field_class_specifier(struct ctx *ctx,
                goto error;
        }
 
-       *decl = ctx_decl_scope_lookup_alias(ctx->current_scope, str->str, -1,
-               true);
+       *decl = ctx_decl_scope_lookup_alias(ctx, ctx->current_scope, str->str,
+               -1, true);
        if (!*decl) {
                _BT_LOGE_NODE(cls_specifier_list,
                        "Cannot find field class alias: name=\"%s\"", str->str);
@@ -2388,7 +2404,7 @@ int visit_integer_decl(struct ctx *ctx,
                                goto error;
                        }
 
-                       signedness = get_boolean(right);
+                       signedness = get_boolean(ctx, right);
                        if (signedness < 0) {
                                _BT_LOGE_NODE(right,
                                        "Invalid boolean value for integer field class's `signed` attribute: "
@@ -3177,7 +3193,8 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
                                goto error;
                        }
 
-                       ret = get_unary_unsigned(&node->u.ctf_expression.right,
+                       ret = get_unary_unsigned(ctx,
+                               &node->u.ctf_expression.right,
                                (uint64_t *) &id);
                        /* Only read "id" if get_unary_unsigned() succeeded. */
                        if (ret || (!ret && id < 0)) {
@@ -3197,8 +3214,8 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
                                goto error;
                        }
 
-                       ret = get_unary_unsigned(&node->u.ctf_expression.right,
-                               stream_id);
+                       ret = get_unary_unsigned(ctx,
+                               &node->u.ctf_expression.right, stream_id);
 
                        /*
                         * Only read "stream_id" if get_unary_unsigned()
@@ -3265,8 +3282,8 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
                                goto error;
                        }
 
-                       ret = get_unary_unsigned(&node->u.ctf_expression.right,
-                               &loglevel_value);
+                       ret = get_unary_unsigned(ctx,
+                               &node->u.ctf_expression.right, &loglevel_value);
                        if (ret) {
                                _BT_LOGE_NODE(node,
                                        "Unexpected unary expression for event class's `loglevel` attribute.");
@@ -3730,7 +3747,8 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node,
                                goto error;
                        }
 
-                       ret = get_unary_unsigned(&node->u.ctf_expression.right,
+                       ret = get_unary_unsigned(ctx,
+                               &node->u.ctf_expression.right,
                                (uint64_t *) &id);
 
                        /* Only read "id" if get_unary_unsigned() succeeded. */
@@ -4002,8 +4020,8 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set)
                                goto error;
                        }
 
-                       ret = get_unary_unsigned(&node->u.ctf_expression.right,
-                               &val);
+                       ret = get_unary_unsigned(ctx,
+                               &node->u.ctf_expression.right, &val);
                        if (ret) {
                                _BT_LOGE_NODE(node,
                                        "Unexpected unary expression for trace's `major` attribute.");
@@ -4026,8 +4044,8 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set)
                                goto error;
                        }
 
-                       ret = get_unary_unsigned(&node->u.ctf_expression.right,
-                               &val);
+                       ret = get_unary_unsigned(ctx,
+                               &node->u.ctf_expression.right, &val);
                        if (ret) {
                                _BT_LOGE_NODE(node,
                                        "Unexpected unary expression for trace's `minor` attribute.");
@@ -4050,7 +4068,8 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set)
                                goto error;
                        }
 
-                       ret = get_unary_uuid(&node->u.ctf_expression.right,
+                       ret = get_unary_uuid(ctx,
+                               &node->u.ctf_expression.right,
                                ctx->ctf_tc->uuid);
                        if (ret) {
                                _BT_LOGE_NODE(node,
@@ -4243,7 +4262,7 @@ int visit_env(struct ctx *ctx, struct ctf_node *node)
                        int64_t v;
 
                        if (is_unary_unsigned(right_head)) {
-                               ret = get_unary_unsigned(right_head,
+                               ret = get_unary_unsigned(ctx, right_head,
                                        (uint64_t *) &v);
                        } else {
                                ret = get_unary_signed(right_head, &v);
@@ -4313,7 +4332,8 @@ int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node)
                                right_node = _BT_LIST_FIRST_ENTRY(
                                        &node->u.ctf_expression.right,
                                        struct ctf_node, siblings);
-                               bo = byte_order_from_unary_expr(right_node);
+                               bo = byte_order_from_unary_expr(ctx,
+                                       right_node);
                                if (bo == -1) {
                                        _BT_LOGE_NODE(node,
                                                "Invalid `byte_order` attribute in trace (`trace` block): "
@@ -4403,7 +4423,8 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                        goto error;
                }
 
-               ret = get_unary_uuid(&entry_node->u.ctf_expression.right, uuid);
+               ret = get_unary_uuid(ctx, &entry_node->u.ctf_expression.right,
+                       uuid);
                if (ret) {
                        _BT_LOGE_NODE(entry_node,
                                "Invalid clock class's `uuid` attribute.");
@@ -4444,7 +4465,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                        goto error;
                }
 
-               ret = get_unary_unsigned(
+               ret = get_unary_unsigned(ctx,
                        &entry_node->u.ctf_expression.right, &freq);
                if (ret) {
                        _BT_LOGE_NODE(entry_node,
@@ -4473,7 +4494,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                        goto error;
                }
 
-               ret = get_unary_unsigned(
+               ret = get_unary_unsigned(ctx,
                        &entry_node->u.ctf_expression.right, &precision);
                if (ret) {
                        _BT_LOGE_NODE(entry_node,
@@ -4509,7 +4530,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                        goto error;
                }
 
-               ret = get_unary_unsigned(
+               ret = get_unary_unsigned(ctx,
                        &entry_node->u.ctf_expression.right, offset_cycles);
                if (ret) {
                        _BT_LOGE_NODE(entry_node,
@@ -4532,7 +4553,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                right = _BT_LIST_FIRST_ENTRY(
                        &entry_node->u.ctf_expression.right,
                        struct ctf_node, siblings);
-               ret = get_boolean(right);
+               ret = get_boolean(ctx, right);
                if (ret < 0) {
                        _BT_LOGE_NODE(entry_node,
                                "Unexpected unary expression for clock class's `absolute` attribute.");
@@ -5005,7 +5026,8 @@ 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);
+       ret = ctf_trace_class_update_default_clock_classes(ctx->ctf_tc,
+               ctx->log_level);
        if (ret) {
                ret = -EINVAL;
                goto end;
@@ -5033,7 +5055,8 @@ 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);
+       ret = ctf_trace_class_resolve_field_classes(ctx->ctf_tc,
+               ctx->log_level);
        if (ret) {
                ret = -EINVAL;
                goto end;
@@ -5062,7 +5085,8 @@ 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);
+       ret = ctf_trace_class_validate(ctx->ctf_tc,
+               ctx->log_level);
        if (ret) {
                ret = -EINVAL;
                goto end;
@@ -5073,7 +5097,8 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
         * itself in the packet header and in event header field
         * classes, warn about it because they are never translated.
         */
-       ctf_trace_class_warn_meaningless_header_fields(ctx->ctf_tc);
+       ctf_trace_class_warn_meaningless_header_fields(ctx->ctf_tc,
+               ctx->log_level);
 
        if (ctx->trace_class) {
                /* Copy new CTF metadata -> new IR metadata */
index a7f0e93ecd076ab0522333a38b2754ccfa2e87e2..6b05a3389a2fca15addc853679b7948e53565972 100644 (file)
@@ -24,8 +24,9 @@
  * SOFTWARE.
  */
 
+#define BT_LOG_OUTPUT_LEVEL log_level
 #define BT_LOG_TAG "PLUGIN/CTF/META/PARENT-LINKS-VISITOR"
-#include "logging.h"
+#include "logging/log.h"
 
 #include <stdio.h>
 #include <unistd.h>
 #include "scanner.h"
 #include "parser.h"
 #include "ast.h"
+#include "logging.h"
 
 static
-int ctf_visitor_unary_expression(int depth, struct ctf_node *node)
+int ctf_visitor_unary_expression(int depth, struct ctf_node *node,
+               bt_logging_level log_level)
 {
        int ret = 0;
 
@@ -67,7 +70,8 @@ int ctf_visitor_unary_expression(int depth, struct ctf_node *node)
        case UNARY_SBRAC:
                node->u.unary_expression.u.sbrac_exp->parent = node;
                ret = ctf_visitor_unary_expression(depth + 1,
-                       node->u.unary_expression.u.sbrac_exp);
+                       node->u.unary_expression.u.sbrac_exp,
+                       log_level);
                if (ret)
                        return ret;
                break;
@@ -83,7 +87,8 @@ int ctf_visitor_unary_expression(int depth, struct ctf_node *node)
 }
 
 static
-int ctf_visitor_type_specifier(int depth, struct ctf_node *node)
+int ctf_visitor_type_specifier(int depth, struct ctf_node *node,
+               bt_logging_level log_level)
 {
        int ret;
 
@@ -110,7 +115,9 @@ int ctf_visitor_type_specifier(int depth, struct ctf_node *node)
        case TYPESPEC_VARIANT:
        case TYPESPEC_ENUM:
                node->u.field_class_specifier.node->parent = node;
-               ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_specifier.node);
+               ret = ctf_visitor_parent_links(depth + 1,
+                       node->u.field_class_specifier.node,
+                       log_level);
                if (ret)
                        return ret;
                break;
@@ -126,7 +133,8 @@ int ctf_visitor_type_specifier(int depth, struct ctf_node *node)
 }
 
 static
-int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node)
+int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node,
+               bt_logging_level log_level)
 {
        int ret = 0;
        struct ctf_node *iter;
@@ -136,7 +144,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);
+               ret = ctf_visitor_parent_links(depth + 1, iter, log_level);
                if (ret)
                        return ret;
        }
@@ -148,7 +156,8 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node)
                if (node->u.field_class_declarator.u.nested.field_class_declarator) {
                        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);
+                               node->u.field_class_declarator.u.nested.field_class_declarator,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -156,7 +165,8 @@ 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) {
                                iter->parent = node;
-                               ret = ctf_visitor_parent_links(depth + 1, iter);
+                               ret = ctf_visitor_parent_links(depth + 1, iter,
+                                       log_level);
                                if (ret)
                                        return ret;
                        }
@@ -164,7 +174,8 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node)
                if (node->u.field_class_declarator.bitfield_len) {
                        node->u.field_class_declarator.bitfield_len = node;
                        ret = ctf_visitor_parent_links(depth + 1,
-                               node->u.field_class_declarator.bitfield_len);
+                               node->u.field_class_declarator.bitfield_len,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -180,7 +191,8 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node)
        return 0;
 }
 
-int ctf_visitor_parent_links(int depth, struct ctf_node *node)
+int ctf_visitor_parent_links(int depth, struct ctf_node *node,
+               bt_logging_level log_level)
 {
        int ret = 0;
        struct ctf_node *iter;
@@ -192,37 +204,43 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
        case NODE_ROOT:
                bt_list_for_each_entry(iter, &node->u.root.declaration_list, siblings) {
                        iter->parent = node;
-                       ret = ctf_visitor_parent_links(depth + 1, iter);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        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);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        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);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        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);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        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);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        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);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -231,7 +249,8 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
        case NODE_EVENT:
                bt_list_for_each_entry(iter, &node->u.event.declaration_list, siblings) {
                        iter->parent = node;
-                       ret = ctf_visitor_parent_links(depth + 1, iter);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -239,7 +258,8 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
        case NODE_STREAM:
                bt_list_for_each_entry(iter, &node->u.stream.declaration_list, siblings) {
                        iter->parent = node;
-                       ret = ctf_visitor_parent_links(depth + 1, iter);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -247,7 +267,8 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
        case NODE_ENV:
                bt_list_for_each_entry(iter, &node->u.env.declaration_list, siblings) {
                        iter->parent = node;
-                       ret = ctf_visitor_parent_links(depth + 1, iter);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -255,7 +276,8 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
        case NODE_TRACE:
                bt_list_for_each_entry(iter, &node->u.trace.declaration_list, siblings) {
                        iter->parent = node;
-                       ret = ctf_visitor_parent_links(depth + 1, iter);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -263,7 +285,8 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
        case NODE_CLOCK:
                bt_list_for_each_entry(iter, &node->u.clock.declaration_list, siblings) {
                        iter->parent = node;
-                       ret = ctf_visitor_parent_links(depth + 1, iter);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -271,7 +294,8 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
        case NODE_CALLSITE:
                bt_list_for_each_entry(iter, &node->u.callsite.declaration_list, siblings) {
                        iter->parent = node;
-                       ret = ctf_visitor_parent_links(depth + 1, iter);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -281,30 +305,35 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
                depth++;
                bt_list_for_each_entry(iter, &node->u.ctf_expression.left, siblings) {
                        iter->parent = node;
-                       ret = ctf_visitor_parent_links(depth + 1, iter);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        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);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
                depth--;
                break;
        case NODE_UNARY_EXPRESSION:
-               return ctf_visitor_unary_expression(depth, node);
+               return ctf_visitor_unary_expression(depth, node, log_level);
 
        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);
+               ret = ctf_visitor_parent_links(depth + 1,
+                       node->u.field_class_def.field_class_specifier_list,
+                       log_level);
                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);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -313,12 +342,15 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
        case NODE_TYPEALIAS_TARGET:
                depth++;
                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);
+               ret = ctf_visitor_parent_links(depth + 1,
+                       node->u.field_class_alias_target.field_class_specifier_list,
+                       log_level);
                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);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -327,12 +359,15 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
        case NODE_TYPEALIAS_ALIAS:
                depth++;
                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);
+               ret = ctf_visitor_parent_links(depth + 1,
+                       node->u.field_class_alias_name.field_class_specifier_list,
+                       log_level);
                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);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -340,11 +375,13 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
                break;
        case NODE_TYPEALIAS:
                node->u.field_class_alias.target->parent = node;
-               ret = ctf_visitor_parent_links(depth + 1, node->u.field_class_alias.target);
+               ret = ctf_visitor_parent_links(depth + 1,
+                       node->u.field_class_alias.target, log_level);
                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);
+               ret = ctf_visitor_parent_links(depth + 1,
+                       node->u.field_class_alias.alias, log_level);
                if (ret)
                        return ret;
                break;
@@ -352,21 +389,23 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
        case NODE_TYPE_SPECIFIER_LIST:
                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);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
                break;
 
        case NODE_TYPE_SPECIFIER:
-               ret = ctf_visitor_type_specifier(depth, node);
+               ret = ctf_visitor_type_specifier(depth, node, log_level);
                if (ret)
                        return ret;
                break;
        case NODE_POINTER:
                break;
        case NODE_TYPE_DECLARATOR:
-               ret = ctf_visitor_field_class_declarator(depth, node);
+               ret = ctf_visitor_field_class_declarator(depth, node,
+                       log_level);
                if (ret)
                        return ret;
                break;
@@ -374,7 +413,8 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
        case NODE_FLOATING_POINT:
                bt_list_for_each_entry(iter, &node->u.floating_point.expressions, siblings) {
                        iter->parent = node;
-                       ret = ctf_visitor_parent_links(depth + 1, iter);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -382,7 +422,8 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
        case NODE_INTEGER:
                bt_list_for_each_entry(iter, &node->u.integer.expressions, siblings) {
                        iter->parent = node;
-                       ret = ctf_visitor_parent_links(depth + 1, iter);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -390,7 +431,8 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
        case NODE_STRING:
                bt_list_for_each_entry(iter, &node->u.string.expressions, siblings) {
                        iter->parent = node;
-                       ret = ctf_visitor_parent_links(depth + 1, iter);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -398,7 +440,8 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
        case NODE_ENUMERATOR:
                bt_list_for_each_entry(iter, &node->u.enumerator.values, siblings) {
                        iter->parent = node;
-                       ret = ctf_visitor_parent_links(depth + 1, iter);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -406,14 +449,16 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
        case NODE_ENUM:
                depth++;
                if (node->u._enum.container_field_class) {
-                       ret = ctf_visitor_parent_links(depth + 1, node->u._enum.container_field_class);
+                       ret = ctf_visitor_parent_links(depth + 1,
+                               node->u._enum.container_field_class, log_level);
                        if (ret)
                                return ret;
                }
 
                bt_list_for_each_entry(iter, &node->u._enum.enumerator_list, siblings) {
                        iter->parent = node;
-                       ret = ctf_visitor_parent_links(depth + 1, iter);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -422,12 +467,14 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
        case NODE_STRUCT_OR_VARIANT_DECLARATION:
                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);
+                       node->u.struct_or_variant_declaration.field_class_specifier_list,
+                       log_level);
                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);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -435,7 +482,8 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
        case NODE_VARIANT:
                bt_list_for_each_entry(iter, &node->u.variant.declaration_list, siblings) {
                        iter->parent = node;
-                       ret = ctf_visitor_parent_links(depth + 1, iter);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -443,14 +491,16 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node)
        case NODE_STRUCT:
                bt_list_for_each_entry(iter, &node->u._struct.declaration_list, siblings) {
                        iter->parent = node;
-                       ret = ctf_visitor_parent_links(depth + 1, iter);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
                bt_list_for_each_entry(iter, &node->u._struct.min_align,
                                        siblings) {
                        iter->parent = node;
-                       ret = ctf_visitor_parent_links(depth + 1, iter);
+                       ret = ctf_visitor_parent_links(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
index bb0122be08426f4d3d43318d33c371553d488fc6..0c4aa12530c22995632d09d2f06891ce6da1e038 100644 (file)
@@ -24,8 +24,9 @@
  * SOFTWARE.
  */
 
+#define BT_LOG_OUTPUT_LEVEL log_level
 #define BT_LOG_TAG "PLUGIN/CTF/META/SEMANTIC-VALIDATOR-VISITOR"
-#include "logging.h"
+#include "logging/log.h"
 
 #include <stdio.h>
 #include <unistd.h>
 #include "scanner.h"
 #include "parser.h"
 #include "ast.h"
+#include "logging.h"
 
 #define _bt_list_first_entry(ptr, type, member)        \
        bt_list_entry((ptr)->next, type, member)
 
 static
-int _ctf_visitor_semantic_check(int depth, struct ctf_node *node);
+int _ctf_visitor_semantic_check(int depth, struct ctf_node *node,
+               bt_logging_level log_level);
 
 static
-int ctf_visitor_unary_expression(int depth, struct ctf_node *node)
+int ctf_visitor_unary_expression(int depth, struct ctf_node *node,
+               bt_logging_level log_level)
 {
        struct ctf_node *iter;
        int is_ctf_exp = 0, is_ctf_exp_left = 0;
@@ -217,7 +221,8 @@ errperm:
 }
 
 static
-int ctf_visitor_field_class_specifier_list(int depth, struct ctf_node *node)
+int ctf_visitor_field_class_specifier_list(int depth, struct ctf_node *node,
+               bt_logging_level log_level)
 {
        switch (node->parent->type) {
        case NODE_CTF_EXPRESSION:
@@ -259,7 +264,8 @@ errinval:
 }
 
 static
-int ctf_visitor_field_class_specifier(int depth, struct ctf_node *node)
+int ctf_visitor_field_class_specifier(int depth, struct ctf_node *node,
+               bt_logging_level log_level)
 {
        switch (node->parent->type) {
        case NODE_TYPE_SPECIFIER_LIST:
@@ -301,7 +307,8 @@ errinval:
 }
 
 static
-int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node)
+int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node,
+               bt_logging_level log_level)
 {
        int ret = 0;
        struct ctf_node *iter;
@@ -382,7 +389,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);
+               ret = _ctf_visitor_semantic_check(depth + 1, iter, log_level);
                if (ret)
                        return ret;
        }
@@ -394,7 +401,8 @@ 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);
+                               node->u.field_class_declarator.u.nested.field_class_declarator,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -407,7 +415,8 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node)
                                                node_type(iter));
                                        return -EINVAL;
                                }
-                               ret = _ctf_visitor_semantic_check(depth + 1, iter);
+                               ret = _ctf_visitor_semantic_check(depth + 1,
+                                       iter, log_level);
                                if (ret)
                                        return ret;
                        }
@@ -420,7 +429,8 @@ 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);
+                               node->u.field_class_declarator.bitfield_len,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -450,7 +460,8 @@ errperm:
 }
 
 static
-int _ctf_visitor_semantic_check(int depth, struct ctf_node *node)
+int _ctf_visitor_semantic_check(int depth, struct ctf_node *node,
+               bt_logging_level log_level)
 {
        int ret = 0;
        struct ctf_node *iter;
@@ -461,22 +472,26 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node)
        switch (node->type) {
        case NODE_ROOT:
                bt_list_for_each_entry(iter, &node->u.root.declaration_list, siblings) {
-                       ret = _ctf_visitor_semantic_check(depth + 1, iter);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
                bt_list_for_each_entry(iter, &node->u.root.trace, siblings) {
-                       ret = _ctf_visitor_semantic_check(depth + 1, iter);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
                bt_list_for_each_entry(iter, &node->u.root.stream, siblings) {
-                       ret = _ctf_visitor_semantic_check(depth + 1, iter);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
                bt_list_for_each_entry(iter, &node->u.root.event, siblings) {
-                       ret = _ctf_visitor_semantic_check(depth + 1, iter);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -491,7 +506,8 @@ 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);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -505,7 +521,8 @@ 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);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -519,7 +536,8 @@ 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);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -533,7 +551,8 @@ 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);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -547,7 +566,8 @@ 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);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -561,7 +581,8 @@ 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);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -602,19 +623,21 @@ 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);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
                bt_list_for_each_entry(iter, &node->u.ctf_expression.right, siblings) {
-                       ret = _ctf_visitor_semantic_check(depth + 1, iter);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
                depth--;
                break;
        case NODE_UNARY_EXPRESSION:
-               return ctf_visitor_unary_expression(depth, node);
+               return ctf_visitor_unary_expression(depth, node, log_level);
 
        case NODE_TYPEDEF:
                switch (node->parent->type) {
@@ -651,11 +674,13 @@ 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);
+                       node->u.field_class_def.field_class_specifier_list,
+                       log_level);
                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);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -674,12 +699,14 @@ 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);
+                       node->u.field_class_alias_target.field_class_specifier_list,
+                       log_level);
                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);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                        nr_declarators++;
@@ -706,12 +733,14 @@ 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);
+                       node->u.field_class_alias_name.field_class_specifier_list,
+                       log_level);
                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);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                        nr_declarators++;
@@ -758,21 +787,25 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node)
                        goto errinval;
                }
 
-               ret = _ctf_visitor_semantic_check(depth + 1, node->u.field_class_alias.target);
+               ret = _ctf_visitor_semantic_check(depth + 1,
+                       node->u.field_class_alias.target, log_level);
                if (ret)
                        return ret;
-               ret = _ctf_visitor_semantic_check(depth + 1, node->u.field_class_alias.alias);
+               ret = _ctf_visitor_semantic_check(depth + 1,
+                       node->u.field_class_alias.alias, log_level);
                if (ret)
                        return ret;
                break;
 
        case NODE_TYPE_SPECIFIER_LIST:
-               ret = ctf_visitor_field_class_specifier_list(depth, node);
+               ret = ctf_visitor_field_class_specifier_list(depth, node,
+                       log_level);
                if (ret)
                        return ret;
                break;
        case NODE_TYPE_SPECIFIER:
-               ret = ctf_visitor_field_class_specifier(depth, node);
+               ret = ctf_visitor_field_class_specifier(depth, node,
+                       log_level);
                if (ret)
                        return ret;
                break;
@@ -785,7 +818,8 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node)
                }
                break;
        case NODE_TYPE_DECLARATOR:
-               ret = ctf_visitor_field_class_declarator(depth, node);
+               ret = ctf_visitor_field_class_declarator(depth, node,
+                       log_level);
                if (ret)
                        return ret;
                break;
@@ -801,7 +835,8 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node)
                        goto errperm;
                }
                bt_list_for_each_entry(iter, &node->u.floating_point.expressions, siblings) {
-                       ret = _ctf_visitor_semantic_check(depth + 1, iter);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -816,7 +851,8 @@ 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);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -833,7 +869,8 @@ 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);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -881,7 +918,8 @@ 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);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -898,12 +936,14 @@ 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);
+               ret = _ctf_visitor_semantic_check(depth + 1,
+                       node->u._enum.container_field_class, log_level);
                if (ret)
                        return ret;
 
                bt_list_for_each_entry(iter, &node->u._enum.enumerator_list, siblings) {
-                       ret = _ctf_visitor_semantic_check(depth + 1, iter);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -918,11 +958,13 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node)
                        goto errinval;
                }
                ret = _ctf_visitor_semantic_check(depth + 1,
-                       node->u.struct_or_variant_declaration.field_class_specifier_list);
+                       node->u.struct_or_variant_declaration.field_class_specifier_list,
+                       log_level);
                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);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -938,7 +980,8 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node)
                        goto errperm;
                }
                bt_list_for_each_entry(iter, &node->u.variant.declaration_list, siblings) {
-                       ret = _ctf_visitor_semantic_check(depth + 1, iter);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -955,7 +998,8 @@ int _ctf_visitor_semantic_check(int depth, struct ctf_node *node)
                        goto errperm;
                }
                bt_list_for_each_entry(iter, &node->u._struct.declaration_list, siblings) {
-                       ret = _ctf_visitor_semantic_check(depth + 1, iter);
+                       ret = _ctf_visitor_semantic_check(depth + 1, iter,
+                               log_level);
                        if (ret)
                                return ret;
                }
@@ -982,7 +1026,8 @@ errperm:
        return -EPERM;          /* Structure not allowed */
 }
 
-int ctf_visitor_semantic_check(int depth, struct ctf_node *node)
+int ctf_visitor_semantic_check(int depth, struct ctf_node *node,
+               bt_logging_level log_level)
 {
        int ret = 0;
 
@@ -991,7 +1036,7 @@ 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);
+       ret = ctf_visitor_parent_links(depth, node, log_level);
        if (ret) {
                _BT_LOGE_LINENO(node->lineno,
                        "Cannot create parent links in metadata's AST: "
@@ -999,7 +1044,7 @@ int ctf_visitor_semantic_check(int depth, struct ctf_node *node)
                goto end;
        }
 
-       ret = _ctf_visitor_semantic_check(depth, node);
+       ret = _ctf_visitor_semantic_check(depth, node, log_level);
        if (ret) {
                _BT_LOGE_LINENO(node->lineno,
                        "Cannot check metadata's AST semantics: "
index 08545027c088cf5488a7c3be84fbd0b6caad8e46..342b290f38a051741f93638f598bcba52361ce79 100644 (file)
@@ -95,6 +95,7 @@ int ctf_fs_metadata_set_trace_class(
        int ret = 0;
        struct ctf_fs_file *file = NULL;
        struct ctf_metadata_decoder_config decoder_config = {
+               .log_level = BT_LOG_OUTPUT_LEVEL,
                .clock_class_offset_s = config ? config->clock_class_offset_s : 0,
                .clock_class_offset_ns = config ? config->clock_class_offset_ns : 0,
        };
index 3a58e1ff23f4b9a311e2b8899133d1be4ac7ff71..0a89084df7744d24df7de4f4f435c5a5f4bb9c1b 100644 (file)
@@ -99,11 +99,12 @@ bt_query_status metadata_info_query(
        }
 
        is_packetized = ctf_metadata_decoder_is_packetized(metadata_fp,
-               &bo);
+               &bo, BT_LOG_OUTPUT_LEVEL);
 
        if (is_packetized) {
                ret = ctf_metadata_decoder_packetized_file_stream_to_buf(
-                       metadata_fp, &metadata_text, bo);
+                       metadata_fp, &metadata_text, bo,
+                       BT_LOG_OUTPUT_LEVEL);
                if (ret) {
                        BT_LOGE("Cannot decode packetized metadata file: path=\"%s\"",
                                path);
index f8f2248048846ca0aeb3e1abd5e8ce36b52ea09c..0ea4c77d0db9b0fc0949e291211c99ff166372ab 100644 (file)
@@ -269,6 +269,11 @@ int lttng_live_metadata_create_stream(struct lttng_live_session *session,
        struct lttng_live_metadata *metadata = NULL;
        struct lttng_live_trace *trace;
        const char *match;
+       struct ctf_metadata_decoder_config cfg = {
+               .log_level = BT_LOG_OUTPUT_LEVEL,
+               .clock_class_offset_s = 0,
+               .clock_class_offset_ns = 0,
+       };
 
        metadata = g_new0(struct lttng_live_metadata, 1);
        if (!metadata) {
@@ -282,7 +287,7 @@ int lttng_live_metadata_create_stream(struct lttng_live_session *session,
        }
 
        metadata->decoder = ctf_metadata_decoder_create(
-                               lttng_live->self_comp, NULL);
+                               lttng_live->self_comp, &cfg);
        if (!metadata->decoder) {
                goto error;
        }
This page took 0.064557 seconds and 4 git commands to generate.