#include <glib.h>
#include <inttypes.h>
#include <errno.h>
+#include <babeltrace/babeltrace.h>
#include <babeltrace/list.h>
#include "ctf-scanner.h"
#include "ctf-parser.h"
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);
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) {
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:
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__,
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:
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");
}
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 (!cds_list_empty(&node->u.type_declarator.u.nested.length)) {
print_tabs(fd, depth);
fprintf(fd, "<length>\n");
+ cds_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");
}
}
print_tabs(fd, depth);
fprintf(fd, "</struct>\n");
+ if (!cds_list_empty(&node->u._struct.min_align)) {
+ print_tabs(fd, depth);
+ fprintf(fd, "<align>\n");
+ cds_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: