2 * ctf-visitor-generate-io-struct.c
4 * Common Trace Format Metadata Visitor (generate I/O structures).
6 * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
27 #include <babeltrace/list.h>
28 #include "ctf-scanner.h"
29 #include "ctf-parser.h"
32 #define fprintf_dbg(fd, fmt, args...) fprintf(fd, "%s: " fmt, __func__, ## args)
34 #define _cds_list_first_entry(ptr, type, member) \
35 cds_list_entry((ptr)->next, type, member)
38 int ctf_visitor_print_type_specifier(FILE *fd
, int depth
, struct ctf_node
*node
)
40 print_tabs(fd
, depth
);
41 fprintf(fd
, "<type_specifier \"");
43 switch (node
->u
.type_specifier
.type
) {
63 fprintf(fd
, "double");
66 fprintf(fd
, "signed");
68 case TYPESPEC_UNSIGNED
:
69 fprintf(fd
, "unsigned");
74 case TYPESPEC_COMPLEX
:
75 fprintf(fd
, "complex");
80 case TYPESPEC_ID_TYPE
:
81 fprintf(fd
, "%s", node
->u
.type_specifier
.id_type
);
84 case TYPESPEC_UNKNOWN
:
86 fprintf(stderr
, "[error] %s: unknown type specifier %d\n", __func__
,
87 (int) node
->u
.type_specifier
.type
);
90 fprintf(fd
, "\"/>\n");
95 int ctf_visitor_print_type_declarator(FILE *fd
, int depth
, struct ctf_node
*node
)
98 struct ctf_node
*iter
;
100 print_tabs(fd
, depth
);
101 fprintf(fd
, "<type_declarator>\n");
104 if (!cds_list_empty(&node
->u
.type_declarator
.pointers
)) {
105 print_tabs(fd
, depth
);
106 fprintf(fd
, "<pointers>\n");
107 cds_list_for_each_entry(iter
, &node
->u
.type_declarator
.pointers
,
109 ret
= ctf_visitor_print_xml(fd
, depth
+ 1, iter
);
113 print_tabs(fd
, depth
);
114 fprintf(fd
, "</pointers>\n");
117 switch (node
->u
.type_declarator
.type
) {
119 if (node
->u
.type_declarator
.u
.id
) {
120 print_tabs(fd
, depth
);
121 fprintf(fd
, "<id \"");
122 fprintf(fd
, "%s", node
->u
.type_declarator
.u
.id
);
123 fprintf(fd
, "\" />\n");
127 if (node
->u
.type_declarator
.u
.nested
.type_declarator
) {
128 print_tabs(fd
, depth
);
129 fprintf(fd
, "<type_declarator>\n");
130 ret
= ctf_visitor_print_xml(fd
, depth
+ 1,
131 node
->u
.type_declarator
.u
.nested
.type_declarator
);
134 print_tabs(fd
, depth
);
135 fprintf(fd
, "</type_declarator>\n");
137 if (node
->u
.type_declarator
.u
.nested
.length
) {
138 print_tabs(fd
, depth
);
139 fprintf(fd
, "<length>\n");
140 ret
= ctf_visitor_print_xml(fd
, depth
+ 1,
141 node
->u
.type_declarator
.u
.nested
.length
);
144 print_tabs(fd
, depth
);
145 fprintf(fd
, "</length>\n");
147 if (node
->u
.type_declarator
.u
.nested
.abstract_array
) {
148 print_tabs(fd
, depth
);
149 fprintf(fd
, "<length>\n");
150 print_tabs(fd
, depth
);
151 fprintf(fd
, "</length>\n");
153 if (node
->u
.type_declarator
.bitfield_len
) {
154 print_tabs(fd
, depth
);
155 fprintf(fd
, "<bitfield_len>\n");
156 ret
= ctf_visitor_print_xml(fd
, depth
+ 1,
157 node
->u
.type_declarator
.bitfield_len
);
160 print_tabs(fd
, depth
);
161 fprintf(fd
, "</bitfield_len>\n");
164 case TYPEDEC_UNKNOWN
:
166 fprintf(stderr
, "[error] %s: unknown type declarator %d\n", __func__
,
167 (int) node
->u
.type_declarator
.type
);
172 print_tabs(fd
, depth
);
173 fprintf(fd
, "</type_declarator>\n");
178 * String returned must be freed by the caller.
181 char *concatenate_unary_strings(struct list_head
*head
)
187 int get_unary_unsigned(struct list_head
*head
, uint64_t *value
)
193 int get_unary_uuid(struct list_head
*head
, uuid_t
*uuid
)
199 struct ctf_stream
*trace_stream_lookup(struct ctf_trace
*trace
, uint64_t stream_id
)
201 if (trace
->streams
->len
<= stream_id
)
203 return g_ptr_array_index(trace
->streams
, stream_id
);
207 * Also add named variant, struct or enum to the current declaration scope.
210 struct ctf_declaration
*ctf_declaration_specifier_visit(FILE *fd
,
211 int depth
, struct list_head
*head
,
212 struct declaration_scope
*declaration_scope
)
214 struct ctf_declaration
*declaration
;
217 first
= _cds_list_first_entry(head
, struct node
, siblings
);
219 switch (first
->type
) {
222 * For named struct (without body), lookup in
223 * declaration scope and create declaration copy.
225 /* For named struct (with body), create type and add to declaration scope */
226 /* For unnamed struct, create type */
230 * For named variant (without body), lookup in
231 * declaration scope and create declaration copy.
233 /* For named variant (with body), create type and add to declaration scope */
234 /* For unnamed variant, create type */
235 /* If variant has a tag field specifier, assign tag name. */
239 * For named enum (without body), lookup in declaration
240 * scope and create declaration copy.
242 /* For named enum (with body), create type and add to declaration scope */
243 /* For unnamed enum, create type */
244 /* Enumerations need to have their size/type specifier (< >). */
248 * Create an integer declaration.
251 case NODE_FLOATING_POINT
:
253 * Create a floating point declaration.
258 * Create a string declaration.
261 case NODE_TYPE_SPECIFIER
:
263 * Lookup named type in typedef declarations (in
264 * declaration scope). Create a copy of the declaration.
272 int ctf_typedef_declarator_visit(FILE *fd
, int depth
,
273 struct list_head
*declaration_specifier
,
274 struct node
*type_declarator
,
275 struct declaration_scope
*declaration_scope
)
278 * Build the type using declaration specifier (creating
279 * declaration from type_specifier), then apply type declarator,
280 * add the resulting type to the current declaration scope.
282 cds_list_for_each_entry(iter
, declaration_specifier
, siblings
) {
290 int ctf_typedef_visit(FILE *fd
, int depth
,
291 struct list_head
*declaration_specifier
,
292 struct list_head
*type_declarators
,
293 struct declaration_scope
*declaration_scope
)
295 struct ctf_node
*iter
;
297 cds_list_for_each_entry(iter
, type_declarators
, siblings
) {
298 ret
= ctf_typedef_declarator_visit(fd
, depth
+ 1,
299 &node
->u
._typedef
.declaration_specifier
, iter
,
308 int ctf_typealias_visit(FILE *fd
, int depth
, struct ctf_node
*target
,
309 struct ctf_node
*alias
,
310 struct declaration_scope
*declaration_scope
)
313 * Build target type, check that it is reachable in current
317 /* Only one type declarator is allowed */
319 /* Build alias type, add to current declaration scope. */
320 /* Only one type declarator is allowed */
324 int ctf_event_declaration_visit(FILE *fd
, int depth
, struct ctf_node
*node
, struct ctf_event
*event
, struct ctf_trace
*trace
)
328 switch (node
->type
) {
330 ret
= ctf_typedef_visit(fd
, depth
+ 1,
331 &node
->u
._typedef
.declaration_specifier
,
332 &node
->u
._typedef
.type_declarators
,
333 event
->declaration_scope
);
338 ret
= ctf_typealias_visit(fd
, depth
+ 1,
339 &node
->u
.typealias
.target
, &node
->u
.typealias
.alias
340 event
->declaration_scope
);
344 case NODE_CTF_EXPRESSION
:
348 left
= concatenate_unary_strings(&node
->u
.ctf_expression
.left
);
349 if (!strcmp(left
, "name")) {
352 if (CTF_EVENT_FIELD_IS_SET(event
, name
))
354 right
= concatenate_unary_strings(&node
->u
.ctf_expression
.right
);
356 fprintf(stderr
, "[error] %s: unexpected unary expression for event name\n", __func__
);
359 event
->name
= g_quark_from_string(right
);
361 CTF_EVENT_SET_FIELD(event
, name
);
362 } else if (!strcmp(left
, "id")) {
363 if (CTF_EVENT_FIELD_IS_SET(event
, id
))
365 ret
= get_unary_unsigned(&node
->u
.ctf_expression
.right
, &event
->id
);
367 fprintf(stderr
, "[error] %s: unexpected unary expression for event id\n", __func__
);
370 CTF_EVENT_SET_FIELD(event
, id
);
371 } else if (!strcmp(left
, "stream_id")) {
372 if (CTF_EVENT_FIELD_IS_SET(event
, stream_id
))
374 ret
= get_unary_unsigned(&node
->u
.ctf_expression
.right
, &event
->stream_id
);
376 fprintf(stderr
, "[error] %s: unexpected unary expression for event stream_id\n", __func__
);
379 event
->stream
= trace_stream_lookup(trace
, event
->stream_id
);
380 if (!event
->stream
) {
381 fprintf(stderr
, "[error] %s: stream id %" PRIu64
" cannot be found\n", __func__
, event
->stream_id
);
384 event
->definition_scope
= new_definition_scope(stream
->definition_scope
);
385 if (!event
->definition_scope
) {
386 fprintf(stderr
, "[error] %s: Error allocating declaration scope\n", __func__
);
389 CTF_EVENT_SET_FIELD(event
, stream_id
);
390 } else if (!strcmp(left
, "context")) {
391 struct declaration
*declaration
;
393 if (!event
->definition_scope
)
395 declaration
= ctf_declaration_specifier_visit(fd
, depth
,
396 &node
->u
.ctf_expression
.right
,
397 event
->declaration_scope
);
400 if (declaration
->type
->id
!= CTF_TYPE_STRUCT
)
402 /* TODO: definition */
403 event
->context
= container_of(declaration
, struct declaration_struct
, p
);
404 } else if (!strcmp(left
, "fields")) {
405 struct declaration
*declaration
;
407 if (!event
->definition_scope
)
409 declaration
= ctf_declaration_specifier_visit(fd
, depth
,
410 &node
->u
.ctf_expression
.right
,
411 event
->declaration_scope
);
414 if (declaration
->type
->id
!= CTF_TYPE_STRUCT
)
416 /* TODO: definition */
417 event
->fields
= container_of(declaration
, struct declaration_struct
, p
);
424 /* TODO: declaration specifier should be added. */
431 int ctf_event_visit(FILE *fd
, int depth
, struct ctf_node
*node
,
432 struct declaration_scope
*parent_declaration_scope
, struct ctf_trace
*trace
)
435 struct ctf_node
*iter
;
436 struct ctf_event
*event
;
438 event
= g_new0(struct ctf_event
, 1);
439 event
->declaration_scope
= new_declaration_scope(parent_declaration_scope
);
440 cds_list_for_each_entry(iter
, &node
->u
.event
.declaration_list
, siblings
) {
441 ret
= ctf_event_declaration_visit(fd
, depth
+ 1, iter
, event
, trace
);
445 if (!CTF_EVENT_FIELD_IS_SET(event
, name
)) {
449 if (!CTF_EVENT_FIELD_IS_SET(event
, id
)) {
453 if (!CTF_EVENT_FIELD_IS_SET(event
, stream_id
)) {
457 if (event
->stream
->events_by_id
->len
<= event
->id
)
458 g_ptr_array_set_size(event
->stream
->events_by_id
, event
->id
+ 1);
459 g_ptr_array_index(event
->stream
->events_by_id
, event
->id
) = event
;
460 g_hash_table_insert(event
->stream
->event_quark_to_id
,
461 (gpointer
)(unsigned long) event
->name
,
466 declaration_unref(event
->fields
);
467 declaration_unref(event
->context
);
468 free_definition_scope(event
->definition_scope
);
469 free_declaration_scope(event
->declaration_scope
);
476 int ctf_stream_declaration_visit(FILE *fd
, int depth
, struct ctf_node
*node
, struct ctf_stream
*stream
, struct ctf_trace
*trace
)
480 switch (node
->type
) {
482 ret
= ctf_typedef_visit(fd
, depth
+ 1,
483 &node
->u
._typedef
.declaration_specifier
,
484 &node
->u
._typedef
.type_declarators
,
485 stream
->declaration_scope
);
490 ret
= ctf_typealias_visit(fd
, depth
+ 1,
491 &node
->u
.typealias
.target
, &node
->u
.typealias
.alias
492 stream
->declaration_scope
);
496 case NODE_CTF_EXPRESSION
:
500 left
= concatenate_unary_strings(&node
->u
.ctf_expression
.left
);
501 if (!strcmp(left
, "stream_id")) {
502 if (CTF_EVENT_FIELD_IS_SET(event
, stream_id
))
504 ret
= get_unary_unsigned(&node
->u
.ctf_expression
.right
, &event
->stream_id
);
506 fprintf(stderr
, "[error] %s: unexpected unary expression for event stream_id\n", __func__
);
509 CTF_EVENT_SET_FIELD(event
, stream_id
);
510 } else if (!strcmp(left
, "event_header")) {
511 struct declaration
*declaration
;
513 declaration
= ctf_declaration_specifier_visit(fd
, depth
,
514 &node
->u
.ctf_expression
.right
,
515 stream
->declaration_scope
, stream
->definition_scope
);
518 if (declaration
->type
->id
!= CTF_TYPE_STRUCT
)
520 /* TODO: definition */
521 stream
->event_header
= container_of(declaration
, struct declaration_struct
, p
);
522 } else if (!strcmp(left
, "event_context")) {
523 struct declaration
*declaration
;
525 declaration
= ctf_declaration_specifier_visit(fd
, depth
,
526 &node
->u
.ctf_expression
.right
,
527 stream
->declaration_scope
);
530 if (declaration
->type
->id
!= CTF_TYPE_STRUCT
)
532 /* TODO: definition */
533 stream
->event_context
= container_of(declaration
, struct declaration_struct
, p
);
534 } else if (!strcmp(left
, "packet_context")) {
535 struct declaration
*declaration
;
537 declaration
= ctf_declaration_specifier_visit(fd
, depth
,
538 &node
->u
.ctf_expression
.right
,
539 stream
->declaration_scope
);
542 if (declaration
->type
->id
!= CTF_TYPE_STRUCT
)
544 /* TODO: definition */
545 stream
->packet_context
= container_of(declaration
, struct declaration_struct
, p
);
552 /* TODO: declaration specifier should be added. */
559 int ctf_stream_visit(FILE *fd
, int depth
, struct ctf_node
*node
,
560 struct declaration_scope
*parent_declaration_scope
, struct ctf_trace
*trace
)
563 struct ctf_node
*iter
;
564 struct ctf_stream
*stream
;
566 stream
= g_new0(struct ctf_stream
, 1);
567 stream
->declaration_scope
= new_declaration_scope(parent_declaration_scope
);
568 stream
->definition_scope
= new_definition_scope(trace
->definition_scope
);
569 stream
->events_by_id
= g_ptr_array_new();
570 stream
->event_quark_to_id
= g_hash_table_new(g_int_hash
, g_int_equal
);
571 cds_list_for_each_entry(iter
, &node
->u
.stream
.declaration_list
, siblings
) {
572 ret
= ctf_stream_declaration_visit(fd
, depth
+ 1, iter
, stream
, trace
);
576 if (!CTF_EVENT_FIELD_IS_SET(stream
, stream_id
)) {
580 if (trace
->streams
->len
<= stream
->stream_id
)
581 g_ptr_array_set_size(trace
->streams
, stream
->stream_id
+ 1);
582 g_ptr_array_index(trace
->streams
, stream
->stream_id
) = stream
;
586 declaration_unref(stream
->event_header
);
587 declaration_unref(stream
->event_context
);
588 declaration_unref(stream
->packet_context
);
589 g_ptr_array_free(stream
->events_by_id
, TRUE
);
590 g_hash_table_free(stream
->event_quark_to_id
);
591 free_definition_scope(stream
->definition_scope
);
592 free_declaration_scope(stream
->declaration_scope
);
598 int ctf_trace_declaration_visit(FILE *fd
, int depth
, struct ctf_node
*node
, struct ctf_trace
*trace
)
602 switch (node
->type
) {
604 ret
= ctf_typedef_visit(fd
, depth
+ 1,
605 &node
->u
._typedef
.declaration_specifier
,
606 &node
->u
._typedef
.type_declarators
,
607 trace
->declaration_scope
);
612 ret
= ctf_typealias_visit(fd
, depth
+ 1,
613 &node
->u
.typealias
.target
, &node
->u
.typealias
.alias
614 trace
->declaration_scope
);
618 case NODE_CTF_EXPRESSION
:
622 left
= concatenate_unary_strings(&node
->u
.ctf_expression
.left
);
623 if (!strcmp(left
, "major")) {
624 if (CTF_EVENT_FIELD_IS_SET(trace
, major
))
626 ret
= get_unary_unsigned(&node
->u
.ctf_expression
.right
, &trace
->major
);
628 fprintf(stderr
, "[error] %s: unexpected unary expression for trace major number\n", __func__
);
631 CTF_EVENT_SET_FIELD(trace
, major
);
632 } else if (!strcmp(left
, "minor")) {
633 if (CTF_EVENT_FIELD_IS_SET(trace
, minor
))
635 ret
= get_unary_unsigned(&node
->u
.ctf_expression
.right
, &trace
->minor
);
637 fprintf(stderr
, "[error] %s: unexpected unary expression for trace minor number\n", __func__
);
640 CTF_EVENT_SET_FIELD(trace
, minor
);
641 } else if (!strcmp(left
, "word_size")) {
642 if (CTF_EVENT_FIELD_IS_SET(trace
, word_size
))
644 ret
= get_unary_unsigned(&node
->u
.ctf_expression
.right
, &trace
->word_size
);
646 fprintf(stderr
, "[error] %s: unexpected unary expression for trace word_size\n", __func__
);
649 CTF_EVENT_SET_FIELD(trace
, word_size
);
650 } else if (!strcmp(left
, "uuid")) {
651 if (CTF_EVENT_FIELD_IS_SET(trace
, uuid
))
653 ret
= get_unary_uuid(&node
->u
.ctf_expression
.right
, &trace
->uuid
);
655 fprintf(stderr
, "[error] %s: unexpected unary expression for trace uuid\n", __func__
);
658 CTF_EVENT_SET_FIELD(trace
, uuid
);
665 /* TODO: declaration specifier should be added. */
673 int ctf_trace_visit(FILE *fd
, int depth
, struct ctf_node
*node
, struct ctf_trace
*trace
)
676 struct ctf_node
*iter
;
678 if (trace
->declaration_scope
)
680 trace
->declaration_scope
= new_declaration_scope(trace
->root_declaration_scope
);
681 trace
->definition_scope
= new_definition_scope(trace
->root_definition_scope
);
682 trace
->streams
= g_ptr_array_new();
683 cds_list_for_each_entry(iter
, &node
->u
.trace
.declaration_list
, siblings
) {
684 ret
= ctf_trace_declaration_visit(fd
, depth
+ 1, iter
, trace
);
688 if (!CTF_EVENT_FIELD_IS_SET(trace
, major
)) {
692 if (!CTF_EVENT_FIELD_IS_SET(trace
, minor
)) {
696 if (!CTF_EVENT_FIELD_IS_SET(trace
, uuid
)) {
700 if (!CTF_EVENT_FIELD_IS_SET(trace
, word_size
)) {
707 g_ptr_array_free(trace
->streams
, TRUE
);
708 free_definition_scope(stream
->definition_scope
);
709 free_declaration_scope(stream
->declaration_scope
);
713 int _ctf_visitor(FILE *fd
, int depth
, struct ctf_node
*node
, struct ctf_trace
*trace
)
716 struct ctf_node
*iter
;
718 switch (node
->type
) {
720 cds_list_for_each_entry(iter
, &node
->u
.root
._typedef
,
722 ret
= ctf_typedef_visit(fd
, depth
+ 1,
723 &iter
->u
._typedef
.declaration_specifier
,
724 &iter
->u
._typedef
.type_declarators
,
725 trace
->declaration_scope
);
729 cds_list_for_each_entry(iter
, &node
->u
.root
.typealias
,
731 ret
= ctf_typealias_visit(fd
, depth
+ 1,
732 &iter
->u
.typealias
.target
, &iter
->u
.typealias
.alias
733 trace
->declaration_scope
);
737 cds_list_for_each_entry(iter
, &node
->u
.root
.declaration_specifier
, siblings
) {
738 ret
= ctf_declaration_specifier_visit(fd
, depth
, iter
,
739 trace
->root_declaration_scope
);
743 cds_list_for_each_entry(iter
, &node
->u
.root
.trace
, siblings
) {
744 ret
= ctf_trace_visit(fd
, depth
+ 1, iter
, trace
);
748 cds_list_for_each_entry(iter
, &node
->u
.root
.stream
, siblings
) {
749 ret
= ctf_stream_visit(fd
, depth
+ 1, iter
,
750 trace
->declaration_scope
, trace
);
754 cds_list_for_each_entry(iter
, &node
->u
.root
.event
, siblings
) {
755 ret
= ctf_event_visit(fd
, depth
+ 1, iter
,
756 trace
->declaration_scope
, trace
);
762 case NODE_TYPEALIAS_TARGET
:
763 print_tabs(fd
, depth
);
764 fprintf(fd
, "<target>\n");
767 print_tabs(fd
, depth
);
768 fprintf(fd
, "<declaration_specifier>\n");
769 cds_list_for_each_entry(iter
, &node
->u
.typealias_target
.declaration_specifier
, siblings
) {
770 ret
= ctf_visitor_print_xml(fd
, depth
+ 1, iter
);
774 print_tabs(fd
, depth
);
775 fprintf(fd
, "</declaration_specifier>\n");
777 print_tabs(fd
, depth
);
778 fprintf(fd
, "<type_declarators>\n");
779 cds_list_for_each_entry(iter
, &node
->u
.typealias_target
.type_declarators
, siblings
) {
780 ret
= ctf_visitor_print_xml(fd
, depth
+ 1, iter
);
784 print_tabs(fd
, depth
);
785 fprintf(fd
, "</type_declarators>\n");
788 print_tabs(fd
, depth
);
789 fprintf(fd
, "</target>\n");
791 case NODE_TYPEALIAS_ALIAS
:
792 print_tabs(fd
, depth
);
793 fprintf(fd
, "<alias>\n");
796 print_tabs(fd
, depth
);
797 fprintf(fd
, "<declaration_specifier>\n");
798 cds_list_for_each_entry(iter
, &node
->u
.typealias_alias
.declaration_specifier
, siblings
) {
799 ret
= ctf_visitor_print_xml(fd
, depth
+ 1, iter
);
803 print_tabs(fd
, depth
);
804 fprintf(fd
, "</declaration_specifier>\n");
806 print_tabs(fd
, depth
);
807 fprintf(fd
, "<type_declarators>\n");
808 cds_list_for_each_entry(iter
, &node
->u
.typealias_alias
.type_declarators
, siblings
) {
809 ret
= ctf_visitor_print_xml(fd
, depth
+ 1, iter
);
813 print_tabs(fd
, depth
);
814 fprintf(fd
, "</type_declarators>\n");
817 print_tabs(fd
, depth
);
818 fprintf(fd
, "</alias>\n");
821 print_tabs(fd
, depth
);
822 fprintf(fd
, "<typealias>\n");
823 ret
= ctf_visitor_print_xml(fd
, depth
+ 1, node
->u
.typealias
.target
);
826 ret
= ctf_visitor_print_xml(fd
, depth
+ 1, node
->u
.typealias
.alias
);
829 print_tabs(fd
, depth
);
830 fprintf(fd
, "</typealias>\n");
833 case NODE_TYPE_SPECIFIER
:
834 ret
= ctf_visitor_print_type_specifier(fd
, depth
, node
);
839 print_tabs(fd
, depth
);
840 if (node
->u
.pointer
.const_qualifier
)
841 fprintf(fd
, "<const_pointer />\n");
843 fprintf(fd
, "<pointer />\n");
845 case NODE_TYPE_DECLARATOR
:
846 ret
= ctf_visitor_print_type_declarator(fd
, depth
, node
);
851 case NODE_FLOATING_POINT
:
852 print_tabs(fd
, depth
);
853 fprintf(fd
, "<floating_point>\n");
854 cds_list_for_each_entry(iter
, &node
->u
.floating_point
.expressions
, siblings
) {
855 ret
= ctf_visitor_print_xml(fd
, depth
+ 1, iter
);
859 print_tabs(fd
, depth
);
860 fprintf(fd
, "</floating_point>\n");
863 print_tabs(fd
, depth
);
864 fprintf(fd
, "<integer>\n");
865 cds_list_for_each_entry(iter
, &node
->u
.integer
.expressions
, siblings
) {
866 ret
= ctf_visitor_print_xml(fd
, depth
+ 1, iter
);
870 print_tabs(fd
, depth
);
871 fprintf(fd
, "</integer>\n");
874 print_tabs(fd
, depth
);
875 fprintf(fd
, "<string>\n");
876 cds_list_for_each_entry(iter
, &node
->u
.string
.expressions
, siblings
) {
877 ret
= ctf_visitor_print_xml(fd
, depth
+ 1, iter
);
881 print_tabs(fd
, depth
);
882 fprintf(fd
, "</string>\n");
884 case NODE_ENUMERATOR
:
885 print_tabs(fd
, depth
);
886 fprintf(fd
, "<enumerator");
887 if (node
->u
.enumerator
.id
)
888 fprintf(fd
, " id=\"%s\"", node
->u
.enumerator
.id
);
890 cds_list_for_each_entry(iter
, &node
->u
.enumerator
.values
, siblings
) {
891 ret
= ctf_visitor_print_xml(fd
, depth
+ 1, iter
);
895 print_tabs(fd
, depth
);
896 fprintf(fd
, "</enumerator>\n");
899 print_tabs(fd
, depth
);
900 if (node
->u
._struct
.name
)
901 fprintf(fd
, "<enum name=\"%s\">\n",
902 node
->u
._enum
.enum_id
);
904 fprintf(fd
, "<enum >\n");
907 if (node
->u
._enum
.container_type
) {
908 print_tabs(fd
, depth
);
909 fprintf(fd
, "<container_type>\n");
910 ret
= ctf_visitor_print_xml(fd
, depth
+ 1, node
->u
._enum
.container_type
);
913 print_tabs(fd
, depth
);
914 fprintf(fd
, "</container_type>\n");
917 print_tabs(fd
, depth
);
918 fprintf(fd
, "<enumerator_list>\n");
919 cds_list_for_each_entry(iter
, &node
->u
._enum
.enumerator_list
, siblings
) {
920 ret
= ctf_visitor_print_xml(fd
, depth
+ 1, iter
);
924 print_tabs(fd
, depth
);
925 fprintf(fd
, "</enumerator_list>\n");
928 print_tabs(fd
, depth
);
929 fprintf(fd
, "</enum>\n");
931 case NODE_STRUCT_OR_VARIANT_DECLARATION
:
932 print_tabs(fd
, depth
);
933 fprintf(fd
, "<declaration_specifier>\n");
934 cds_list_for_each_entry(iter
, &node
->u
.struct_or_variant_declaration
.declaration_specifier
, siblings
) {
935 ret
= ctf_visitor_print_xml(fd
, depth
+ 1, iter
);
939 print_tabs(fd
, depth
);
940 fprintf(fd
, "</declaration_specifier>\n");
942 print_tabs(fd
, depth
);
943 fprintf(fd
, "<type_declarators>\n");
944 cds_list_for_each_entry(iter
, &node
->u
.struct_or_variant_declaration
.type_declarators
, siblings
) {
945 ret
= ctf_visitor_print_xml(fd
, depth
+ 1, iter
);
949 print_tabs(fd
, depth
);
950 fprintf(fd
, "</type_declarators>\n");
953 print_tabs(fd
, depth
);
954 fprintf(fd
, "<variant");
955 if (node
->u
.variant
.name
)
956 fprintf(fd
, " name=\"%s\"", node
->u
.variant
.name
);
957 if (node
->u
.variant
.choice
)
958 fprintf(fd
, " choice=\"%s\"", node
->u
.variant
.choice
);
960 cds_list_for_each_entry(iter
, &node
->u
.variant
.declaration_list
, siblings
) {
961 ret
= ctf_visitor_print_xml(fd
, depth
+ 1, iter
);
965 print_tabs(fd
, depth
);
966 fprintf(fd
, "</variant>\n");
969 print_tabs(fd
, depth
);
970 if (node
->u
._struct
.name
)
971 fprintf(fd
, "<struct name=\"%s\">\n",
972 node
->u
._struct
.name
);
974 fprintf(fd
, "<struct>\n");
975 cds_list_for_each_entry(iter
, &node
->u
._struct
.declaration_list
, siblings
) {
976 ret
= ctf_visitor_print_xml(fd
, depth
+ 1, iter
);
980 print_tabs(fd
, depth
);
981 fprintf(fd
, "</struct>\n");
986 fprintf(stderr
, "[error] %s: unknown node type %d\n", __func__
,