Add callsite support
[babeltrace.git] / formats / ctf / metadata / ctf-visitor-xml.c
index 96145f8b73bf249d797218413ac80dcc942dd457..437748cab323f5cedaf9fc3a530e8bf2b4bd5772 100644 (file)
@@ -24,6 +24,7 @@
 #include <glib.h>
 #include <inttypes.h>
 #include <errno.h>
+#include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/list.h>
 #include "ctf-scanner.h"
 #include "ctf-parser.h"
@@ -75,15 +76,15 @@ int ctf_visitor_print_unary_expression(FILE *fd, int depth, struct ctf_node *nod
                break;
        case UNARY_SIGNED_CONSTANT:
                print_tabs(fd, depth);
-               fprintf(fd, "<unary_expression value=");
+               fprintf(fd, "<unary_expression value=\"");
                fprintf(fd, "%" PRId64, node->u.unary_expression.u.signed_constant);
-               fprintf(fd, " />\n");
+               fprintf(fd, "\" />\n");
                break;
        case UNARY_UNSIGNED_CONSTANT:
                print_tabs(fd, depth);
-               fprintf(fd, "<unary_expression value=");
+               fprintf(fd, "<unary_expression value=\"");
                fprintf(fd, "%" PRIu64, node->u.unary_expression.u.signed_constant);
-               fprintf(fd, " />\n");
+               fprintf(fd, "\" />\n");
                break;
        case UNARY_SBRAC:
                print_tabs(fd, depth);
@@ -123,7 +124,7 @@ int ctf_visitor_print_type_specifier_list(FILE *fd, int depth, struct ctf_node *
 
        print_tabs(fd, depth);
        fprintf(fd, "<type_specifier_list>\n");
-       cds_list_for_each_entry(iter, &node->u.type_specifier_list.head, siblings) {
+       bt_list_for_each_entry(iter, &node->u.type_specifier_list.head, siblings) {
                ret = ctf_visitor_print_xml(fd, depth + 1, iter);
                if (ret)
                        return ret;
@@ -136,6 +137,7 @@ int ctf_visitor_print_type_specifier_list(FILE *fd, int depth, struct ctf_node *
 static
 int ctf_visitor_print_type_specifier(FILE *fd, int depth, struct ctf_node *node)
 {
+       int ret;
        print_tabs(fd, depth);
 
        switch (node->u.type_specifier.type) {
@@ -153,7 +155,7 @@ int ctf_visitor_print_type_specifier(FILE *fd, int depth, struct ctf_node *node)
        case TYPESPEC_IMAGINARY:
        case TYPESPEC_CONST:
        case TYPESPEC_ID_TYPE:
-               fprintf(fd, "<type_specifier \"");
+               fprintf(fd, "<type_specifier type=\"");
                break;
        case TYPESPEC_FLOATING_POINT:
        case TYPESPEC_INTEGER:
@@ -220,7 +222,10 @@ int ctf_visitor_print_type_specifier(FILE *fd, int depth, struct ctf_node *node)
        case TYPESPEC_STRUCT:
        case TYPESPEC_VARIANT:
        case TYPESPEC_ENUM:
-               return ctf_visitor_print_xml(fd, depth, node->u.type_specifier.node);
+               ret = ctf_visitor_print_xml(fd, depth, node->u.type_specifier.node);
+               if (ret)
+                       return ret;
+               break;
        case TYPESPEC_UNKNOWN:
        default:
                fprintf(stderr, "[error] %s: unknown type specifier %d\n", __func__,
@@ -251,9 +256,9 @@ int ctf_visitor_print_type_specifier(FILE *fd, int depth, struct ctf_node *node)
        case TYPESPEC_STRUCT:
        case TYPESPEC_VARIANT:
        case TYPESPEC_ENUM:
+               depth--;
                print_tabs(fd, depth);
                fprintf(fd, "</type_specifier>\n");
-               depth--;
                break;
        case TYPESPEC_UNKNOWN:
        default:
@@ -275,10 +280,10 @@ int ctf_visitor_print_type_declarator(FILE *fd, int depth, struct ctf_node *node
        fprintf(fd, "<type_declarator>\n");
        depth++;
 
-       if (!cds_list_empty(&node->u.type_declarator.pointers)) {
+       if (!bt_list_empty(&node->u.type_declarator.pointers)) {
                print_tabs(fd, depth);
                fprintf(fd, "<pointers>\n");
-               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_print_xml(fd, depth + 1, iter);
                        if (ret)
@@ -292,7 +297,7 @@ int ctf_visitor_print_type_declarator(FILE *fd, int depth, struct ctf_node *node
        case TYPEDEC_ID:
                if (node->u.type_declarator.u.id) {
                        print_tabs(fd, depth);
-                       fprintf(fd, "<id \"");
+                       fprintf(fd, "<id name=\"");
                        fprintf(fd, "%s", node->u.type_declarator.u.id);
                        fprintf(fd, "\" />\n");
                }
@@ -308,18 +313,20 @@ int ctf_visitor_print_type_declarator(FILE *fd, int depth, struct ctf_node *node
                        print_tabs(fd, depth);
                        fprintf(fd, "</type_declarator>\n");
                }
-               if (node->u.type_declarator.u.nested.length) {
+               if (node->u.type_declarator.u.nested.abstract_array) {
                        print_tabs(fd, depth);
                        fprintf(fd, "<length>\n");
-                       ret = ctf_visitor_print_xml(fd, depth + 1, node->u.type_declarator.u.nested.length);
-                       if (ret)
-                               return ret;
                        print_tabs(fd, depth);
                        fprintf(fd, "</length>\n");
-               }
-               if (node->u.type_declarator.u.nested.abstract_array) {
+               } else if (!bt_list_empty(&node->u.type_declarator.u.nested.length)) {
                        print_tabs(fd, depth);
                        fprintf(fd, "<length>\n");
+                       bt_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length,
+                                               siblings) {
+                               ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                               if (ret)
+                                       return ret;
+                       }
                        print_tabs(fd, depth);
                        fprintf(fd, "</length>\n");
                }
@@ -356,23 +363,23 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
        case NODE_ROOT:
                print_tabs(fd, depth);
                fprintf(fd, "<root>\n");
-               cds_list_for_each_entry(iter, &node->u.root.declaration_list,
+               bt_list_for_each_entry(iter, &node->u.root.declaration_list,
                                        siblings) {
                        ret = ctf_visitor_print_xml(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_print_xml(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_print_xml(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_print_xml(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -384,7 +391,7 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
        case NODE_EVENT:
                print_tabs(fd, depth);
                fprintf(fd, "<event>\n");
-               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_print_xml(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -395,7 +402,7 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
        case NODE_STREAM:
                print_tabs(fd, depth);
                fprintf(fd, "<stream>\n");
-               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_print_xml(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -403,10 +410,21 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
                print_tabs(fd, depth);
                fprintf(fd, "</stream>\n");
                break;
+       case NODE_ENV:
+               print_tabs(fd, depth);
+               fprintf(fd, "<env>\n");
+               bt_list_for_each_entry(iter, &node->u.env.declaration_list, siblings) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</env>\n");
+               break;
        case NODE_TRACE:
                print_tabs(fd, depth);
                fprintf(fd, "<trace>\n");
-               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_print_xml(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -414,6 +432,29 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
                print_tabs(fd, depth);
                fprintf(fd, "</trace>\n");
                break;
+       case NODE_CLOCK:
+               print_tabs(fd, depth);
+               fprintf(fd, "<clock>\n");
+               bt_list_for_each_entry(iter, &node->u.clock.declaration_list, siblings) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</clock>\n");
+               break;
+       case NODE_CALLSITE:
+               print_tabs(fd, depth);
+               fprintf(fd, "<callsite>\n");
+               bt_list_for_each_entry(iter, &node->u.callsite.declaration_list, siblings) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</callsite>\n");
+               break;
+
 
        case NODE_CTF_EXPRESSION:
                print_tabs(fd, depth);
@@ -421,7 +462,7 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
                depth++;
                print_tabs(fd, depth);
                fprintf(fd, "<left>\n");
-               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_print_xml(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -432,7 +473,7 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
 
                print_tabs(fd, depth);
                fprintf(fd, "<right>\n");
-               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_print_xml(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -456,7 +497,7 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
 
                print_tabs(fd, depth);
                fprintf(fd, "<type_declarator_list>\n");
-               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_print_xml(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -478,7 +519,7 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
 
                print_tabs(fd, depth);
                fprintf(fd, "<type_declarator_list>\n");
-               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_print_xml(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -501,7 +542,7 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
 
                print_tabs(fd, depth);
                fprintf(fd, "<type_declarator_list>\n");
-               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_print_xml(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -553,7 +594,7 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
        case NODE_FLOATING_POINT:
                print_tabs(fd, depth);
                fprintf(fd, "<floating_point>\n");
-               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_print_xml(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -564,7 +605,7 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
        case NODE_INTEGER:
                print_tabs(fd, depth);
                fprintf(fd, "<integer>\n");
-               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_print_xml(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -575,7 +616,7 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
        case NODE_STRING:
                print_tabs(fd, depth);
                fprintf(fd, "<string>\n");
-               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_print_xml(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -589,7 +630,7 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
                if (node->u.enumerator.id)
                        fprintf(fd, " id=\"%s\"", node->u.enumerator.id);
                fprintf(fd, ">\n");
-               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_print_xml(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -618,7 +659,7 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
 
                print_tabs(fd, depth);
                fprintf(fd, "<enumerator_list>\n");
-               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_print_xml(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -638,7 +679,7 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
 
                print_tabs(fd, depth);
                fprintf(fd, "<type_declarator_list>\n");
-               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_print_xml(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -654,7 +695,7 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
                if (node->u.variant.choice)
                        fprintf(fd, " choice=\"%s\"", node->u.variant.choice);
                fprintf(fd, ">\n");
-               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_print_xml(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -669,13 +710,24 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
                                node->u._struct.name);
                else
                        fprintf(fd, "<struct>\n");
-               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_print_xml(fd, depth + 1, iter);
                        if (ret)
                                return ret;
                }
                print_tabs(fd, depth);
                fprintf(fd, "</struct>\n");
+               if (!bt_list_empty(&node->u._struct.min_align)) {
+                       print_tabs(fd, depth);
+                       fprintf(fd, "<align>\n");
+                       bt_list_for_each_entry(iter, &node->u._struct.min_align, siblings) {
+                               ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                               if (ret)
+                                       return ret;
+                       }
+                       print_tabs(fd, depth);
+                       fprintf(fd, "</align>\n");
+               }
                break;
 
        case NODE_UNKNOWN:
This page took 0.02883 seconds and 4 git commands to generate.