X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fplugins%2Fctf%2Fcommon%2Fmetadata%2Fvisitor-parent-links.c;h=5afcb0e6e19e6e21724baf0e169b1ca3d04f6799;hb=50f6fce8d00bc6b70a814a0be3b71570fb65d070;hp=64098a9a43ec15d5e1838b7535133163e2387d28;hpb=578e048b5debf169e286e5b5cc747b5d6c16886d;p=babeltrace.git diff --git a/src/plugins/ctf/common/metadata/visitor-parent-links.c b/src/plugins/ctf/common/metadata/visitor-parent-links.c index 64098a9a..5afcb0e6 100644 --- a/src/plugins/ctf/common/metadata/visitor-parent-links.c +++ b/src/plugins/ctf/common/metadata/visitor-parent-links.c @@ -1,31 +1,15 @@ /* - * ctf-visitor-parent-links.c + * SPDX-License-Identifier: MIT * - * Common Trace Format Metadata Parent Link Creator. - * - * Copyright 2010 - Mathieu Desnoyers - * - * 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: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * Copyright 2010 Mathieu Desnoyers * - * 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_TAG "PLUGIN-CTF-METADATA-PARENT-LINKS-VISITOR" -#include "logging.h" +#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/comp-logging.h" #include #include @@ -35,14 +19,15 @@ #include #include #include -#include "common/babeltrace.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) +int ctf_visitor_unary_expression(int depth, struct ctf_node *node, + struct meta_log_config *log_cfg) { int ret = 0; @@ -53,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; @@ -67,14 +52,15 @@ 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_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; @@ -83,7 +69,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, + struct meta_log_config *log_cfg) { int ret; @@ -110,14 +97,16 @@ 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_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; @@ -126,7 +115,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, + struct meta_log_config *log_cfg) { int ret = 0; struct ctf_node *iter; @@ -136,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); + ret = ctf_visitor_parent_links(depth + 1, iter, log_cfg); if (ret) return ret; } @@ -148,7 +138,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_cfg); if (ret) return ret; } @@ -156,7 +147,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_cfg); if (ret) return ret; } @@ -164,14 +156,15 @@ 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_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; @@ -180,7 +173,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, + struct meta_log_config *log_cfg) { int ret = 0; struct ctf_node *iter; @@ -192,37 +186,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_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); + ret = ctf_visitor_parent_links(depth + 1, iter, + 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); + ret = ctf_visitor_parent_links(depth + 1, iter, + 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); + ret = ctf_visitor_parent_links(depth + 1, iter, + 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); + ret = ctf_visitor_parent_links(depth + 1, iter, + 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); + ret = ctf_visitor_parent_links(depth + 1, iter, + log_cfg); if (ret) return ret; } @@ -231,7 +231,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_cfg); if (ret) return ret; } @@ -239,7 +240,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_cfg); if (ret) return ret; } @@ -247,7 +249,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_cfg); if (ret) return ret; } @@ -255,7 +258,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_cfg); if (ret) return ret; } @@ -263,7 +267,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_cfg); if (ret) return ret; } @@ -271,7 +276,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_cfg); if (ret) return ret; } @@ -281,30 +287,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_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); + ret = ctf_visitor_parent_links(depth + 1, iter, + log_cfg); 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_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); + ret = ctf_visitor_parent_links(depth + 1, + node->u.field_class_def.field_class_specifier_list, + 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); + ret = ctf_visitor_parent_links(depth + 1, iter, + log_cfg); if (ret) return ret; } @@ -313,12 +324,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_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); + ret = ctf_visitor_parent_links(depth + 1, iter, + log_cfg); if (ret) return ret; } @@ -327,12 +341,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_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); + ret = ctf_visitor_parent_links(depth + 1, iter, + log_cfg); if (ret) return ret; } @@ -340,11 +357,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_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); + ret = ctf_visitor_parent_links(depth + 1, + node->u.field_class_alias.alias, log_cfg); if (ret) return ret; break; @@ -352,21 +371,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_cfg); if (ret) return ret; } break; case NODE_TYPE_SPECIFIER: - ret = ctf_visitor_type_specifier(depth, node); + ret = ctf_visitor_type_specifier(depth, node, log_cfg); 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_cfg); if (ret) return ret; break; @@ -374,7 +395,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_cfg); if (ret) return ret; } @@ -382,7 +404,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_cfg); if (ret) return ret; } @@ -390,7 +413,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_cfg); if (ret) return ret; } @@ -398,7 +422,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_cfg); if (ret) return ret; } @@ -406,14 +431,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_cfg); 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_cfg); if (ret) return ret; } @@ -422,12 +449,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_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); + ret = ctf_visitor_parent_links(depth + 1, iter, + log_cfg); if (ret) return ret; } @@ -435,7 +464,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_cfg); if (ret) return ret; } @@ -443,14 +473,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_cfg); 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_cfg); if (ret) return ret; } @@ -458,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; }