* 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;
}
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:
}
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:
}
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;
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;
}
{
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;
}
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;
}
}
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;
}
}
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;
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
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) {
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;
}
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++;
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++;
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;
}
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;
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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
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;
}
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;
}
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;
}
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;
* 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: "
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: "