Add XML dump visitor
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 21 Feb 2011 06:15:07 +0000 (01:15 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 21 Feb 2011 06:15:07 +0000 (01:15 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/metadata/Makefile.am
formats/ctf/metadata/ctf-ast.h
formats/ctf/metadata/ctf-parser-test.c
formats/ctf/metadata/ctf-visitor-xml.c [new file with mode: 0644]

index 48df5ac2c0d565b5c6345bde98c74f70d82548a1..a75e10c618a17e45e0c6891316879043d8bf94c3 100644 (file)
@@ -7,4 +7,6 @@ noinst_LIBRARIES = libctf-parser.a
 libctf_parser_a_SOURCES = ctf-lexer.l ctf-parser.y
 
 bin_PROGRAMS = ctf-parser-test
-ctf_parser_test_SOURCES = ctf-parser-test.c ctf-lexer.l ctf-parser.y
+ctf_parser_test_SOURCES = \
+                       ctf-parser-test.c ctf-visitor-xml.c \
+                       ctf-lexer.l ctf-parser.y
index 7dcf9f966bb5a9366eb4e15690e52e951b8beca5..692cc7b539007a0aa01174a01ab2bfeaf9c50fb6 100644 (file)
@@ -107,8 +107,8 @@ struct ctf_node {
                                 * string literals and character constants.
                                 */
                                char *string;
-                               uint64_t unsigned_constant;
                                int64_t signed_constant;
+                               uint64_t unsigned_constant;
                                struct ctf_node *sbrac_exp;
                        } u;
                        enum {
@@ -204,15 +204,15 @@ struct ctf_node {
                        struct cds_list_head type_declarators;
                } struct_or_variant_declaration;
                struct {
-                       /* list of typedef, typealias and declarations */
-                       struct cds_list_head declaration_list;
                        char *name;
                        char *choice;
+                       /* list of typedef, typealias and declarations */
+                       struct cds_list_head declaration_list;
                } variant;
                struct {
+                       char *name;
                        /* list of typedef, typealias and declarations */
                        struct cds_list_head declaration_list;
-                       char *name;
                } _struct;
        } u;
 };
@@ -222,4 +222,6 @@ struct ctf_ast {
        struct cds_list_head allocated_nodes;
 };
 
+int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node);
+
 #endif /* _CTF_PARSER_H */
index 33fda7d12caeb68432aef6476dce99ffa778de23..cfd847d016bb1641b305d3de13a58a0dc7e0d4e3 100644 (file)
@@ -28,6 +28,7 @@ extern int yydebug;
 int main(int argc, char **argv)
 {
        struct ctf_scanner *scanner;
+       int ret = 0;
 
        yydebug = 1;
        scanner = ctf_scanner_alloc(stdin);
@@ -36,8 +37,14 @@ int main(int argc, char **argv)
                return -1;
        }
        ctf_scanner_append_ast(scanner);
+
+       if (ctf_visitor_print_xml(stdout, 0, &scanner->ast->root)) {
+               fprintf(stderr, "error visiting AST for XML output\n");
+               ret = -1;
+       }
        ctf_scanner_free(scanner);
-       return 0;
+
+       return ret;
 } 
 
 
diff --git a/formats/ctf/metadata/ctf-visitor-xml.c b/formats/ctf/metadata/ctf-visitor-xml.c
new file mode 100644 (file)
index 0000000..60ad8c9
--- /dev/null
@@ -0,0 +1,596 @@
+/*
+ * ctf-visitor-xml.c
+ *
+ * Common Trace Format Metadata Visitor (XML dump).
+ *
+ * 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:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <helpers/list.h>
+#include <glib.h>
+#include <errno.h>
+#include "ctf-scanner.h"
+#include "ctf-parser.h"
+#include "ctf-ast.h"
+
+#define printf_dbg(fmt, args...)       fprintf(stderr, "%s: " fmt, __func__, ## args)
+
+static void print_tabs(FILE *fd, int depth)
+{
+       int i;
+
+       for (i = 0; i < depth; i++)
+               fprintf(fd, "\t");
+}
+
+int ctf_visitor_print_unary_expression(FILE *fd, int depth, struct ctf_node *node)
+{
+       int ret = 0;
+
+       switch (node->u.unary_expression.type) {
+       case UNARY_STRING:
+               print_tabs(fd, depth);
+               fprintf(fd, "<unary_expression value=");
+               fprintf(fd, "\"%s\"", node->u.unary_expression.u.string);
+               fprintf(fd, "/>\n");
+               break;
+       case UNARY_SIGNED_CONSTANT:
+               print_tabs(fd, depth);
+               fprintf(fd, "<unary_expression value=");
+               fprintf(fd, "%lld", node->u.unary_expression.u.signed_constant);
+               fprintf(fd, "/>\n");
+               break;
+       case UNARY_UNSIGNED_CONSTANT:
+               print_tabs(fd, depth);
+               fprintf(fd, "<unary_expression value=");
+               fprintf(fd, "%llu", node->u.unary_expression.u.signed_constant);
+               fprintf(fd, "/>\n");
+               break;
+       case UNARY_SBRAC:
+               print_tabs(fd, depth);
+               fprintf(fd, "<unary_expression_sbrac>");
+               ret = ctf_visitor_print_unary_expression(fd, depth + 1,
+                       node->u.unary_expression.u.sbrac_exp);
+               if (ret)
+                       return ret;
+               print_tabs(fd, depth);
+               fprintf(fd, "</unary_expression_sbrac>");
+               break;
+
+       case UNARY_UNKNOWN:
+       default:
+               fprintf(stderr, "[error] %s: unknown expression type %d\n", __func__,
+                       (int) node->u.unary_expression.type);
+               return -EINVAL;
+       }
+       switch (node->u.unary_expression.link) {
+       case UNARY_LINK_UNKNOWN:
+               break;
+       case UNARY_DOTLINK:
+               print_tabs(fd, depth);
+               fprintf(fd, "<dotlink/>\n");
+               break;
+       case UNARY_ARROWLINK:
+               print_tabs(fd, depth);
+               fprintf(fd, "<arrowlink/>\n");
+               break;
+       default:
+               fprintf(stderr, "[error] %s: unknown expression link type %d\n", __func__,
+                       (int) node->u.unary_expression.link);
+               return -EINVAL;
+       }
+       return 0;
+}
+
+int ctf_visitor_print_type_specifier(FILE *fd, int depth, struct ctf_node *node)
+{
+       print_tabs(fd, depth);
+       fprintf(fd, "<type_specifier =\"");
+
+       switch (node->u.type_specifier.type) {
+       case TYPESPEC_VOID:
+               fprintf(fd, "void");
+               break;
+       case TYPESPEC_CHAR:
+               fprintf(fd, "char");
+               break;
+       case TYPESPEC_SHORT:
+               fprintf(fd, "short");
+               break;
+       case TYPESPEC_INT:
+               fprintf(fd, "int");
+               break;
+       case TYPESPEC_LONG:
+               fprintf(fd, "long");
+               break;
+       case TYPESPEC_FLOAT:
+               fprintf(fd, "float");
+               break;
+       case TYPESPEC_DOUBLE:
+               fprintf(fd, "double");
+               break;
+       case TYPESPEC_SIGNED:
+               fprintf(fd, "signed");
+               break;
+       case TYPESPEC_UNSIGNED:
+               fprintf(fd, "unsigned");
+               break;
+       case TYPESPEC_BOOL:
+               fprintf(fd, "bool");
+               break;
+       case TYPESPEC_COMPLEX:
+               fprintf(fd, "complex");
+               break;
+       case TYPESPEC_CONST:
+               fprintf(fd, "const");
+               break;
+       case TYPESPEC_ID_TYPE:
+               fprintf(fd, "%s", node->u.type_specifier.id_type);
+               break;
+
+       case TYPESPEC_UNKNOWN:
+       default:
+               fprintf(stderr, "[error] %s: unknown type specifier %d\n", __func__,
+                       (int) node->u.type_specifier.type);
+               return -EINVAL;
+       }
+       fprintf(fd, "\"/>\n");
+       return 0;
+}
+
+int ctf_visitor_print_type_declarator(FILE *fd, int depth, struct ctf_node *node)
+{
+       int ret = 0;
+       struct ctf_node *iter;
+
+       print_tabs(fd, depth);
+       fprintf(fd, "<type_declarator>\n");
+       depth++;
+
+       print_tabs(fd, depth);
+       fprintf(fd, "<pointers>\n");
+       cds_list_for_each_entry(iter, &node->u.type_declarator.pointers,
+                               siblings) {
+               ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+               if (ret)
+                       return ret;
+       }
+       print_tabs(fd, depth);
+       fprintf(fd, "</pointers>\n");
+
+       switch (node->u.type_declarator.type) {
+       case TYPEDEC_ID:
+               print_tabs(fd, depth);
+               fprintf(fd, "<id \"");
+               fprintf(fd, "%s", node->u.type_declarator.u.id);
+               fprintf(fd, "<\" />\n");
+               break;
+       case TYPEDEC_NESTED:
+               if (node->u.type_declarator.u.nested.type_declarator) {
+                       print_tabs(fd, depth);
+                       fprintf(fd, "<type_declarator>\n");
+                       ret = ctf_visitor_print_xml(fd, depth + 1,
+                               node->u.type_declarator.u.nested.type_declarator);
+                       if (ret)
+                               return ret;
+                       print_tabs(fd, depth);
+                       fprintf(fd, "</type_declarator>\n");
+               }
+               if (node->u.type_declarator.u.nested.length) {
+                       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) {
+                       print_tabs(fd, depth);
+                       fprintf(fd, "<length>\n");
+                       print_tabs(fd, depth);
+                       fprintf(fd, "</length>\n");
+               }
+               if (node->u.type_declarator.bitfield_len) {
+                       print_tabs(fd, depth);
+                       fprintf(fd, "<bitfield_len>\n");
+                       ret = ctf_visitor_print_xml(fd, depth + 1,
+                               node->u.type_declarator.bitfield_len);
+                       if (ret)
+                               return ret;
+                       print_tabs(fd, depth);
+                       fprintf(fd, "</bitfield_len>\n");
+               }
+               break;
+       case TYPEDEC_UNKNOWN:
+       default:
+               fprintf(stderr, "[error] %s: unknown type declarator %d\n", __func__,
+                       (int) node->u.type_declarator.type);
+               return -EINVAL;
+       }
+
+       depth--;
+       print_tabs(fd, depth);
+       fprintf(fd, "</type_declarator>\n");
+       return 0;
+}
+
+int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
+{
+       int ret = 0;
+       struct ctf_node *iter;
+
+       switch (node->type) {
+       case NODE_ROOT:
+               print_tabs(fd, depth);
+               fprintf(fd, "<root>\n");
+               cds_list_for_each_entry(iter, &node->u.root._typedef,
+                                       siblings) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               cds_list_for_each_entry(iter, &node->u.root.typealias,
+                                       siblings) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               cds_list_for_each_entry(iter, &node->u.root.declaration_specifier, 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) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               cds_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) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</root>\n");
+               break;
+
+       case NODE_EVENT:
+               print_tabs(fd, depth);
+               fprintf(fd, "<event>\n");
+               cds_list_for_each_entry(iter, &node->u.event.declaration_list, siblings) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</event>\n");
+               break;
+       case NODE_STREAM:
+               print_tabs(fd, depth);
+               fprintf(fd, "<stream>\n");
+               cds_list_for_each_entry(iter, &node->u.stream.declaration_list, siblings) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</stream>\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) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</trace>\n");
+               break;
+
+       case NODE_CTF_EXPRESSION:
+               print_tabs(fd, depth);
+               fprintf(fd, "<ctf_expression>\n");
+               depth++;
+               print_tabs(fd, depth);
+               fprintf(fd, "<left>\n");
+               ret = ctf_visitor_print_xml(fd, depth + 1, node->u.ctf_expression.left);
+               if (ret)
+                       return ret;
+               print_tabs(fd, depth);
+               fprintf(fd, "</left>\n");
+
+               print_tabs(fd, depth);
+               fprintf(fd, "<right>\n");
+               ret = ctf_visitor_print_xml(fd, depth + 1, node->u.ctf_expression.right);
+               if (ret)
+                       return ret;
+               print_tabs(fd, depth);
+               fprintf(fd, "</right>\n");
+               depth--;
+               print_tabs(fd, depth);
+               fprintf(fd, "</ctf_expression>\n");
+               break;
+       case NODE_UNARY_EXPRESSION:
+               return ctf_visitor_print_unary_expression(fd, depth, node);
+
+       case NODE_TYPEDEF:
+               print_tabs(fd, depth);
+               fprintf(fd, "<typedef>\n");
+               depth++;
+               print_tabs(fd, depth);
+               fprintf(fd, "<declaration_specifier>\n");
+               cds_list_for_each_entry(iter, &node->u._typedef.declaration_specifier, siblings) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</declaration_specifier>\n");
+
+               print_tabs(fd, depth);
+               fprintf(fd, "<type_declarators>\n");
+               cds_list_for_each_entry(iter, &node->u._typedef.type_declarators, siblings) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</type_declarators>\n");
+               depth--;
+               print_tabs(fd, depth);
+               fprintf(fd, "</typedef>\n");
+               break;
+       case NODE_TYPEALIAS_TARGET:
+               print_tabs(fd, depth);
+               fprintf(fd, "<target>\n");
+               depth++;
+
+               print_tabs(fd, depth);
+               fprintf(fd, "<declaration_specifier>\n");
+               cds_list_for_each_entry(iter, &node->u.typealias_target.declaration_specifier, siblings) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</declaration_specifier>\n");
+
+               print_tabs(fd, depth);
+               fprintf(fd, "<type_declarators>\n");
+               cds_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;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</type_declarators>\n");
+
+               depth--;
+               print_tabs(fd, depth);
+               fprintf(fd, "</target>\n");
+               break;
+       case NODE_TYPEALIAS_ALIAS:
+               print_tabs(fd, depth);
+               fprintf(fd, "<alias>\n");
+               depth++;
+
+               print_tabs(fd, depth);
+               fprintf(fd, "<declaration_specifier>\n");
+               cds_list_for_each_entry(iter, &node->u.typealias_alias.declaration_specifier, siblings) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</declaration_specifier>\n");
+
+               print_tabs(fd, depth);
+               fprintf(fd, "<type_declarators>\n");
+               cds_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;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</type_declarators>\n");
+
+               depth--;
+               print_tabs(fd, depth);
+               fprintf(fd, "</alias>\n");
+               break;
+       case NODE_TYPEALIAS:
+               print_tabs(fd, depth);
+               fprintf(fd, "<typealias>\n");
+               ret = ctf_visitor_print_xml(fd, depth + 1, node->u.typealias.target);
+               if (ret)
+                       return ret;
+               ret = ctf_visitor_print_xml(fd, depth + 1, node->u.typealias.alias);
+               if (ret)
+                       return ret;
+               print_tabs(fd, depth);
+               fprintf(fd, "</typealias>\n");
+               break;
+
+       case NODE_TYPE_SPECIFIER:
+               ret = ctf_visitor_print_type_specifier(fd, depth, node);
+               if (ret)
+                       return ret;
+               break;
+       case NODE_POINTER:
+               print_tabs(fd, depth);
+               if (node->u.pointer.const_qualifier)
+                       fprintf(fd, "<const_pointer />\n");
+               else
+                       fprintf(fd, "<pointer />\n");
+               break;
+       case NODE_TYPE_DECLARATOR:
+               ret = ctf_visitor_print_type_declarator(fd, depth, node);
+               if (ret)
+                       return ret;
+               break;
+
+       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) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</floating_point>\n");
+               break;
+       case NODE_INTEGER:
+               print_tabs(fd, depth);
+               fprintf(fd, "<integer>\n");
+               cds_list_for_each_entry(iter, &node->u.integer.expressions, siblings) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</integer>\n");
+               break;
+       case NODE_STRING:
+               print_tabs(fd, depth);
+               fprintf(fd, "<string>\n");
+               cds_list_for_each_entry(iter, &node->u.string.expressions, siblings) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</string>\n");
+               break;
+       case NODE_ENUMERATOR:
+               print_tabs(fd, depth);
+               fprintf(fd, "<enumerator");
+               if (node->u.enumerator.id)
+                       fprintf(fd, " id=\"%s\"", node->u.enumerator.id);
+               fprintf(fd, ">\n");
+               if (node->u.enumerator.values) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1,
+                               node->u.enumerator.values);
+                       if (ret)
+                               return ret;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</enumerator>");
+               break;
+       case NODE_ENUM:
+               print_tabs(fd, depth);
+               if (node->u._struct.name)
+                       fprintf(fd, "<enum name=\"%s\">\n",
+                               node->u._enum.enum_id);
+               else
+                       fprintf(fd, "<enum >\n");
+               depth++;
+
+               if (node->u._enum.container_type) {
+                       print_tabs(fd, depth);
+                       fprintf(fd, "<container_type>");
+                       ret = ctf_visitor_print_xml(fd, depth + 1, node->u._enum.container_type);
+                       if (ret)
+                               return ret;
+                       print_tabs(fd, depth);
+                       fprintf(fd, "</container_type>");
+               }
+
+               print_tabs(fd, depth);
+               fprintf(fd, "<enumerator_list>");
+               cds_list_for_each_entry(iter, &node->u._enum.enumerator_list, siblings) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</enumerator_list>");
+
+               depth--;
+               print_tabs(fd, depth);
+               fprintf(fd, "</enum>\n");
+               break;
+       case NODE_STRUCT_OR_VARIANT_DECLARATION:
+               print_tabs(fd, depth);
+               fprintf(fd, "<declaration_specifier>\n");
+               cds_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.declaration_specifier, siblings) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</declaration_specifier>\n");
+
+               print_tabs(fd, depth);
+               fprintf(fd, "<type_declarators>\n");
+               cds_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;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</type_declarators>\n");
+               break;
+       case NODE_VARIANT:
+               print_tabs(fd, depth);
+               fprintf(fd, "<variant");
+               if (node->u.variant.name)
+                       fprintf(fd, " name=\"%s\"", node->u.variant.name);
+               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) {
+                       ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               print_tabs(fd, depth);
+               fprintf(fd, "</variant>\n");
+               break;
+       case NODE_STRUCT:
+               print_tabs(fd, depth);
+               if (node->u._struct.name)
+                       fprintf(fd, "<struct name=\"%s\">\n",
+                               node->u._struct.name);
+               else
+                       fprintf(fd, "<struct>\n");
+               cds_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");
+               break;
+
+       case NODE_UNKNOWN:
+       default:
+               fprintf(stderr, "[error] %s: unknown node type %d\n", __func__,
+                       (int) node->type);
+               return -EINVAL;
+       }
+       return ret;
+}
This page took 0.033067 seconds and 4 git commands to generate.