callsite: support instruction pointer field
[babeltrace.git] / formats / ctf / metadata / ctf-visitor-semantic-validator.c
index da813e0a50acf6ce1b9eacde0e6caaaf81b15fde..1af74c42a8db04577d47a4d35c28c5509f9195f0 100644 (file)
@@ -30,8 +30,8 @@
 #include "ctf-parser.h"
 #include "ctf-ast.h"
 
-#define _cds_list_first_entry(ptr, type, member)       \
-       cds_list_entry((ptr)->next, type, member)
+#define _bt_list_first_entry(ptr, type, member)        \
+       bt_list_entry((ptr)->next, type, member)
 
 #define fprintf_dbg(fd, fmt, args...)  fprintf(fd, "%s: " fmt, __func__, ## args)
 
@@ -47,7 +47,7 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node)
        switch (node->parent->type) {
        case NODE_CTF_EXPRESSION:
                is_ctf_exp = 1;
-               cds_list_for_each_entry(iter, &node->parent->u.ctf_expression.left,
+               bt_list_for_each_entry(iter, &node->parent->u.ctf_expression.left,
                                        siblings) {
                        if (iter == node) {
                                is_ctf_exp_left = 1;
@@ -107,8 +107,10 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node)
        case NODE_ROOT:
        case NODE_EVENT:
        case NODE_STREAM:
+       case NODE_ENV:
        case NODE_TRACE:
        case NODE_CLOCK:
+       case NODE_CALLSITE:
        case NODE_TYPEDEF:
        case NODE_TYPEALIAS_TARGET:
        case NODE_TYPEALIAS_ALIAS:
@@ -128,7 +130,7 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node)
        switch (node->u.unary_expression.link) {
        case UNARY_LINK_UNKNOWN:
                /* We don't allow empty link except on the first node of the list */
-               if (is_ctf_exp && _cds_list_first_entry(is_ctf_exp_left ?
+               if (is_ctf_exp && _bt_list_first_entry(is_ctf_exp_left ?
                                          &node->parent->u.ctf_expression.left :
                                          &node->parent->u.ctf_expression.right,
                                          struct ctf_node,
@@ -153,7 +155,7 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node)
                        goto errperm;
                }
                /* We don't allow link on the first node of the list */
-               if (is_ctf_exp && _cds_list_first_entry(is_ctf_exp_left ?
+               if (is_ctf_exp && _bt_list_first_entry(is_ctf_exp_left ?
                                          &node->parent->u.ctf_expression.left :
                                          &node->parent->u.ctf_expression.right,
                                          struct ctf_node,
@@ -169,7 +171,7 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node)
                        goto errperm;
                }
                /* We don't allow link on the first node of the list */
-               if (_cds_list_first_entry(&node->parent->u.enumerator.values,
+               if (_bt_list_first_entry(&node->parent->u.enumerator.values,
                                          struct ctf_node,
                                          siblings) == node) {
                        fprintf(fd, "[error]: semantic error (link \"...\" is not allowed on the first node of the unary expression list)\n");
@@ -210,8 +212,10 @@ int ctf_visitor_type_specifier_list(FILE *fd, int depth, struct ctf_node *node)
 
        case NODE_EVENT:
        case NODE_STREAM:
+       case NODE_ENV:
        case NODE_TRACE:
        case NODE_CLOCK:
+       case NODE_CALLSITE:
        case NODE_UNARY_EXPRESSION:
        case NODE_TYPEALIAS:
        case NODE_TYPE_SPECIFIER:
@@ -250,8 +254,10 @@ int ctf_visitor_type_specifier(FILE *fd, int depth, struct ctf_node *node)
        case NODE_ROOT:
        case NODE_EVENT:
        case NODE_STREAM:
+       case NODE_ENV:
        case NODE_TRACE:
        case NODE_CLOCK:
+       case NODE_CALLSITE:
        case NODE_UNARY_EXPRESSION:
        case NODE_TYPEALIAS:
        case NODE_TYPE_SPECIFIER:
@@ -285,7 +291,7 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node)
                /*
                 * A nested type declarator is not allowed to contain pointers.
                 */
-               if (!cds_list_empty(&node->u.type_declarator.pointers))
+               if (!bt_list_empty(&node->u.type_declarator.pointers))
                        goto errperm;
                break;                  /* OK */
        case NODE_TYPEALIAS_TARGET:
@@ -304,7 +310,7 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node)
                 */
                if (node->u.type_declarator.type == TYPEDEC_NESTED)
                        goto errperm;
-               cds_list_for_each_entry(iter, &node->parent->u.typealias_alias.type_specifier_list->u.type_specifier_list.head,
+               bt_list_for_each_entry(iter, &node->parent->u.typealias_alias.type_specifier_list->u.type_specifier_list.head,
                                        siblings) {
                        switch (iter->u.type_specifier.type) {
                        case TYPESPEC_FLOATING_POINT:
@@ -313,7 +319,7 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node)
                        case TYPESPEC_STRUCT:
                        case TYPESPEC_VARIANT:
                        case TYPESPEC_ENUM:
-                               if (cds_list_empty(&node->u.type_declarator.pointers))
+                               if (bt_list_empty(&node->u.type_declarator.pointers))
                                        goto errperm;
                                break;
                        default:
@@ -331,8 +337,10 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node)
        case NODE_ROOT:
        case NODE_EVENT:
        case NODE_STREAM:
+       case NODE_ENV:
        case NODE_TRACE:
        case NODE_CLOCK:
+       case NODE_CALLSITE:
        case NODE_CTF_EXPRESSION:
        case NODE_UNARY_EXPRESSION:
        case NODE_TYPEALIAS:
@@ -349,7 +357,7 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node)
                goto errinval;
        }
 
-       cds_list_for_each_entry(iter, &node->u.type_declarator.pointers,
+       bt_list_for_each_entry(iter, &node->u.type_declarator.pointers,
                                siblings) {
                ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                if (ret)
@@ -368,7 +376,7 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node)
                                return ret;
                }
                if (!node->u.type_declarator.u.nested.abstract_array) {
-                       cds_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length,
+                       bt_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length,
                                                siblings) {
                                if (iter->type != NODE_UNARY_EXPRESSION) {
                                        fprintf(fd, "[error] %s: expecting unary expression as length\n", __func__);
@@ -420,22 +428,22 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
 
        switch (node->type) {
        case NODE_ROOT:
-               cds_list_for_each_entry(iter, &node->u.root.declaration_list, siblings) {
+               bt_list_for_each_entry(iter, &node->u.root.declaration_list, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
                }
-               cds_list_for_each_entry(iter, &node->u.root.trace, siblings) {
+               bt_list_for_each_entry(iter, &node->u.root.trace, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
                }
-               cds_list_for_each_entry(iter, &node->u.root.stream, siblings) {
+               bt_list_for_each_entry(iter, &node->u.root.stream, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
                }
-               cds_list_for_each_entry(iter, &node->u.root.event, siblings) {
+               bt_list_for_each_entry(iter, &node->u.root.event, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -450,7 +458,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                        goto errinval;
                }
 
-               cds_list_for_each_entry(iter, &node->u.event.declaration_list, siblings) {
+               bt_list_for_each_entry(iter, &node->u.event.declaration_list, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -464,7 +472,21 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                        goto errinval;
                }
 
-               cds_list_for_each_entry(iter, &node->u.stream.declaration_list, siblings) {
+               bt_list_for_each_entry(iter, &node->u.stream.declaration_list, siblings) {
+                       ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               break;
+       case NODE_ENV:
+               switch (node->parent->type) {
+               case NODE_ROOT:
+                       break;                  /* OK */
+               default:
+                       goto errinval;
+               }
+
+               bt_list_for_each_entry(iter, &node->u.env.declaration_list, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -478,7 +500,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                        goto errinval;
                }
 
-               cds_list_for_each_entry(iter, &node->u.trace.declaration_list, siblings) {
+               bt_list_for_each_entry(iter, &node->u.trace.declaration_list, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -492,21 +514,36 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                        goto errinval;
                }
 
-               cds_list_for_each_entry(iter, &node->u.clock.declaration_list, siblings) {
+               bt_list_for_each_entry(iter, &node->u.clock.declaration_list, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
                }
                break;
+       case NODE_CALLSITE:
+               switch (node->parent->type) {
+               case NODE_ROOT:
+                       break;                  /* OK */
+               default:
+                       goto errinval;
+               }
 
+               bt_list_for_each_entry(iter, &node->u.callsite.declaration_list, siblings) {
+                       ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               break;
 
        case NODE_CTF_EXPRESSION:
                switch (node->parent->type) {
                case NODE_ROOT:
                case NODE_EVENT:
                case NODE_STREAM:
+               case NODE_ENV:
                case NODE_TRACE:
                case NODE_CLOCK:
+               case NODE_CALLSITE:
                case NODE_FLOATING_POINT:
                case NODE_INTEGER:
                case NODE_STRING:
@@ -532,12 +569,12 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                }
 
                depth++;
-               cds_list_for_each_entry(iter, &node->u.ctf_expression.left, siblings) {
+               bt_list_for_each_entry(iter, &node->u.ctf_expression.left, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
                }
-               cds_list_for_each_entry(iter, &node->u.ctf_expression.right, siblings) {
+               bt_list_for_each_entry(iter, &node->u.ctf_expression.right, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -574,6 +611,8 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                case NODE_ENUMERATOR:
                case NODE_ENUM:
                case NODE_CLOCK:
+               case NODE_CALLSITE:
+               case NODE_ENV:
                default:
                        goto errinval;
                }
@@ -583,7 +622,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                        node->u._typedef.type_specifier_list);
                if (ret)
                        return ret;
-               cds_list_for_each_entry(iter, &node->u._typedef.type_declarators, siblings) {
+               bt_list_for_each_entry(iter, &node->u._typedef.type_declarators, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -607,7 +646,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                if (ret)
                        return ret;
                nr_declarators = 0;
-               cds_list_for_each_entry(iter, &node->u.typealias_target.type_declarators, siblings) {
+               bt_list_for_each_entry(iter, &node->u.typealias_target.type_declarators, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -638,7 +677,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                if (ret)
                        return ret;
                nr_declarators = 0;
-               cds_list_for_each_entry(iter, &node->u.typealias_alias.type_declarators, siblings) {
+               bt_list_for_each_entry(iter, &node->u.typealias_alias.type_declarators, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -679,6 +718,8 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                case NODE_ENUMERATOR:
                case NODE_ENUM:
                case NODE_CLOCK:
+               case NODE_CALLSITE:
+               case NODE_ENV:
                default:
                        goto errinval;
                }
@@ -725,7 +766,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                case NODE_UNARY_EXPRESSION:
                        goto errperm;
                }
-               cds_list_for_each_entry(iter, &node->u.floating_point.expressions, siblings) {
+               bt_list_for_each_entry(iter, &node->u.floating_point.expressions, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -740,7 +781,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
 
                }
 
-               cds_list_for_each_entry(iter, &node->u.integer.expressions, siblings) {
+               bt_list_for_each_entry(iter, &node->u.integer.expressions, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -757,7 +798,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                        goto errperm;
                }
 
-               cds_list_for_each_entry(iter, &node->u.string.expressions, siblings) {
+               bt_list_for_each_entry(iter, &node->u.string.expressions, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -778,7 +819,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                {
                        int count = 0;
 
-                       cds_list_for_each_entry(iter, &node->u.enumerator.values,
+                       bt_list_for_each_entry(iter, &node->u.enumerator.values,
                                                siblings) {
                                switch (count++) {
                                case 0: if (iter->type != NODE_UNARY_EXPRESSION
@@ -803,7 +844,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                        }
                }
 
-               cds_list_for_each_entry(iter, &node->u.enumerator.values, siblings) {
+               bt_list_for_each_entry(iter, &node->u.enumerator.values, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -825,7 +866,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                if (ret)
                        return ret;
 
-               cds_list_for_each_entry(iter, &node->u._enum.enumerator_list, siblings) {
+               bt_list_for_each_entry(iter, &node->u._enum.enumerator_list, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -844,7 +885,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                        node->u.struct_or_variant_declaration.type_specifier_list);
                if (ret)
                        return ret;
-               cds_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.type_declarators, siblings) {
+               bt_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.type_declarators, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -860,7 +901,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                case NODE_UNARY_EXPRESSION:
                        goto errperm;
                }
-               cds_list_for_each_entry(iter, &node->u.variant.declaration_list, siblings) {
+               bt_list_for_each_entry(iter, &node->u.variant.declaration_list, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -877,7 +918,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                case NODE_UNARY_EXPRESSION:
                        goto errperm;
                }
-               cds_list_for_each_entry(iter, &node->u._struct.declaration_list, siblings) {
+               bt_list_for_each_entry(iter, &node->u._struct.declaration_list, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
This page took 0.029299 seconds and 4 git commands to generate.