ctf: append error causes when returning errors
[babeltrace.git] / src / plugins / ctf / common / metadata / visitor-parent-links.c
index 6b05a3389a2fca15addc853679b7948e53565972..5afcb0e6e19e6e21724baf0e169b1ca3d04f6799 100644 (file)
@@ -1,32 +1,15 @@
 /*
- * ctf-visitor-parent-links.c
+ * SPDX-License-Identifier: MIT
  *
- * Common Trace Format Metadata Parent Link Creator.
- *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Copyright 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * Common Trace Format Metadata Parent Link Creator.
  */
 
-#define BT_LOG_OUTPUT_LEVEL log_level
+#define BT_COMP_LOG_SELF_COMP (log_cfg->self_comp)
+#define BT_LOG_OUTPUT_LEVEL (log_cfg->log_level)
 #define BT_LOG_TAG "PLUGIN/CTF/META/PARENT-LINKS-VISITOR"
-#include "logging/log.h"
+#include "logging/comp-logging.h"
 
 #include <stdio.h>
 #include <unistd.h>
 #include "common/macros.h"
 #include "common/list.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,
-               bt_logging_level log_level)
+               struct meta_log_config *log_cfg)
 {
        int ret = 0;
 
@@ -56,7 +38,7 @@ int ctf_visitor_unary_expression(int depth, struct ctf_node *node,
        case UNARY_DOTDOTDOT:
                break;
        default:
-               _BT_LOGE_LINENO(node->lineno,
+               _BT_COMP_LOGE_APPEND_CAUSE_LINENO(node->lineno,
                        "Unknown expression link type: type=%d\n",
                        node->u.unary_expression.link);
                return -EINVAL;
@@ -71,14 +53,14 @@ int ctf_visitor_unary_expression(int depth, struct ctf_node *node,
                node->u.unary_expression.u.sbrac_exp->parent = node;
                ret = ctf_visitor_unary_expression(depth + 1,
                        node->u.unary_expression.u.sbrac_exp,
-                       log_level);
+                       log_cfg);
                if (ret)
                        return ret;
                break;
 
        case UNARY_UNKNOWN:
        default:
-               _BT_LOGE_LINENO(node->lineno,
+               _BT_COMP_LOGE_APPEND_CAUSE_LINENO(node->lineno,
                        "Unknown expression link type: type=%d\n",
                        node->u.unary_expression.link);
                return -EINVAL;
@@ -88,7 +70,7 @@ int ctf_visitor_unary_expression(int depth, struct ctf_node *node,
 
 static
 int ctf_visitor_type_specifier(int depth, struct ctf_node *node,
-               bt_logging_level log_level)
+               struct meta_log_config *log_cfg)
 {
        int ret;
 
@@ -117,14 +99,14 @@ int ctf_visitor_type_specifier(int depth, struct ctf_node *node,
                node->u.field_class_specifier.node->parent = node;
                ret = ctf_visitor_parent_links(depth + 1,
                        node->u.field_class_specifier.node,
-                       log_level);
+                       log_cfg);
                if (ret)
                        return ret;
                break;
 
        case TYPESPEC_UNKNOWN:
        default:
-               _BT_LOGE_LINENO(node->lineno,
+               _BT_COMP_LOGE_APPEND_CAUSE_LINENO(node->lineno,
                        "Unknown type specifier: type=%d\n",
                        node->u.field_class_specifier.type);
                return -EINVAL;
@@ -134,7 +116,7 @@ int ctf_visitor_type_specifier(int depth, struct ctf_node *node,
 
 static
 int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node,
-               bt_logging_level log_level)
+               struct meta_log_config *log_cfg)
 {
        int ret = 0;
        struct ctf_node *iter;
@@ -144,7 +126,7 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node,
        bt_list_for_each_entry(iter, &node->u.field_class_declarator.pointers,
                                siblings) {
                iter->parent = node;
-               ret = ctf_visitor_parent_links(depth + 1, iter, log_level);
+               ret = ctf_visitor_parent_links(depth + 1, iter, log_cfg);
                if (ret)
                        return ret;
        }
@@ -157,7 +139,7 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node,
                        node->u.field_class_declarator.u.nested.field_class_declarator->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1,
                                node->u.field_class_declarator.u.nested.field_class_declarator,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -166,7 +148,7 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node,
                                                siblings) {
                                iter->parent = node;
                                ret = ctf_visitor_parent_links(depth + 1, iter,
-                                       log_level);
+                                       log_cfg);
                                if (ret)
                                        return ret;
                        }
@@ -175,14 +157,14 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node,
                        node->u.field_class_declarator.bitfield_len = node;
                        ret = ctf_visitor_parent_links(depth + 1,
                                node->u.field_class_declarator.bitfield_len,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
                break;
        case TYPEDEC_UNKNOWN:
        default:
-               _BT_LOGE_LINENO(node->lineno,
+               _BT_COMP_LOGE_APPEND_CAUSE_LINENO(node->lineno,
                        "Unknown type declarator: type=%d\n",
                        node->u.field_class_declarator.type);
                return -EINVAL;
@@ -192,7 +174,7 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node,
 }
 
 int ctf_visitor_parent_links(int depth, struct ctf_node *node,
-               bt_logging_level log_level)
+               struct meta_log_config *log_cfg)
 {
        int ret = 0;
        struct ctf_node *iter;
@@ -205,42 +187,42 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                bt_list_for_each_entry(iter, &node->u.root.declaration_list, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
                bt_list_for_each_entry(iter, &node->u.root.trace, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
                bt_list_for_each_entry(iter, &node->u.root.stream, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
                bt_list_for_each_entry(iter, &node->u.root.event, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
                bt_list_for_each_entry(iter, &node->u.root.clock, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
                bt_list_for_each_entry(iter, &node->u.root.callsite, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -250,7 +232,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                bt_list_for_each_entry(iter, &node->u.event.declaration_list, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -259,7 +241,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                bt_list_for_each_entry(iter, &node->u.stream.declaration_list, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -268,7 +250,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                bt_list_for_each_entry(iter, &node->u.env.declaration_list, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -277,7 +259,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                bt_list_for_each_entry(iter, &node->u.trace.declaration_list, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -286,7 +268,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                bt_list_for_each_entry(iter, &node->u.clock.declaration_list, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -295,7 +277,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                bt_list_for_each_entry(iter, &node->u.callsite.declaration_list, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -306,34 +288,34 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                bt_list_for_each_entry(iter, &node->u.ctf_expression.left, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
                bt_list_for_each_entry(iter, &node->u.ctf_expression.right, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
                depth--;
                break;
        case NODE_UNARY_EXPRESSION:
-               return ctf_visitor_unary_expression(depth, node, log_level);
+               return ctf_visitor_unary_expression(depth, node, log_cfg);
 
        case NODE_TYPEDEF:
                depth++;
                node->u.field_class_def.field_class_specifier_list->parent = node;
                ret = ctf_visitor_parent_links(depth + 1,
                        node->u.field_class_def.field_class_specifier_list,
-                       log_level);
+                       log_cfg);
                if (ret)
                        return ret;
                bt_list_for_each_entry(iter, &node->u.field_class_def.field_class_declarators, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -344,13 +326,13 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                node->u.field_class_alias_target.field_class_specifier_list->parent = node;
                ret = ctf_visitor_parent_links(depth + 1,
                        node->u.field_class_alias_target.field_class_specifier_list,
-                       log_level);
+                       log_cfg);
                if (ret)
                        return ret;
                bt_list_for_each_entry(iter, &node->u.field_class_alias_target.field_class_declarators, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -361,13 +343,13 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                node->u.field_class_alias_name.field_class_specifier_list->parent = node;
                ret = ctf_visitor_parent_links(depth + 1,
                        node->u.field_class_alias_name.field_class_specifier_list,
-                       log_level);
+                       log_cfg);
                if (ret)
                        return ret;
                bt_list_for_each_entry(iter, &node->u.field_class_alias_name.field_class_declarators, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -376,12 +358,12 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
        case NODE_TYPEALIAS:
                node->u.field_class_alias.target->parent = node;
                ret = ctf_visitor_parent_links(depth + 1,
-                       node->u.field_class_alias.target, log_level);
+                       node->u.field_class_alias.target, log_cfg);
                if (ret)
                        return ret;
                node->u.field_class_alias.alias->parent = node;
                ret = ctf_visitor_parent_links(depth + 1,
-                       node->u.field_class_alias.alias, log_level);
+                       node->u.field_class_alias.alias, log_cfg);
                if (ret)
                        return ret;
                break;
@@ -390,14 +372,14 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                bt_list_for_each_entry(iter, &node->u.field_class_specifier_list.head, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
                break;
 
        case NODE_TYPE_SPECIFIER:
-               ret = ctf_visitor_type_specifier(depth, node, log_level);
+               ret = ctf_visitor_type_specifier(depth, node, log_cfg);
                if (ret)
                        return ret;
                break;
@@ -405,7 +387,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                break;
        case NODE_TYPE_DECLARATOR:
                ret = ctf_visitor_field_class_declarator(depth, node,
-                       log_level);
+                       log_cfg);
                if (ret)
                        return ret;
                break;
@@ -414,7 +396,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                bt_list_for_each_entry(iter, &node->u.floating_point.expressions, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -423,7 +405,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                bt_list_for_each_entry(iter, &node->u.integer.expressions, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -432,7 +414,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                bt_list_for_each_entry(iter, &node->u.string.expressions, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -441,7 +423,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                bt_list_for_each_entry(iter, &node->u.enumerator.values, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -450,7 +432,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                depth++;
                if (node->u._enum.container_field_class) {
                        ret = ctf_visitor_parent_links(depth + 1,
-                               node->u._enum.container_field_class, log_level);
+                               node->u._enum.container_field_class, log_cfg);
                        if (ret)
                                return ret;
                }
@@ -458,7 +440,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                bt_list_for_each_entry(iter, &node->u._enum.enumerator_list, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -468,13 +450,13 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                node->u.struct_or_variant_declaration.field_class_specifier_list->parent = node;
                ret = ctf_visitor_parent_links(depth + 1,
                        node->u.struct_or_variant_declaration.field_class_specifier_list,
-                       log_level);
+                       log_cfg);
                if (ret)
                        return ret;
                bt_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.field_class_declarators, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -483,7 +465,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                bt_list_for_each_entry(iter, &node->u.variant.declaration_list, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -492,7 +474,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                bt_list_for_each_entry(iter, &node->u._struct.declaration_list, siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -500,7 +482,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
                                        siblings) {
                        iter->parent = node;
                        ret = ctf_visitor_parent_links(depth + 1, iter,
-                               log_level);
+                               log_cfg);
                        if (ret)
                                return ret;
                }
@@ -508,7 +490,7 @@ int ctf_visitor_parent_links(int depth, struct ctf_node *node,
 
        case NODE_UNKNOWN:
        default:
-               _BT_LOGE_LINENO(node->lineno,
+               _BT_COMP_LOGE_APPEND_CAUSE_LINENO(node->lineno,
                        "Unknown node type: type=%d\n", node->type);
                return -EINVAL;
        }
This page took 0.032123 seconds and 4 git commands to generate.