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.
28 #include <babeltrace/list.h>
29 #include <uuid/uuid.h>
30 #include "ctf-scanner.h"
31 #include "ctf-parser.h"
34 #define fprintf_dbg(fd, fmt, args...) fprintf(fd, "%s: " fmt, __func__, ## args)
36 #define _cds_list_first_entry(ptr, type, member) \
37 cds_list_entry((ptr)->next, type, member)
40 struct declaration
*ctf_declaration_specifier_visit(FILE *fd
,
41 int depth
, struct cds_list_head
*head
,
42 struct declaration_scope
*declaration_scope
,
43 struct ctf_trace
*trace
);
46 * String returned must be freed by the caller using g_free.
49 char *concatenate_unary_strings(struct cds_list_head
*head
)
51 struct ctf_node
*node
;
56 cds_list_for_each_entry(node
, head
, siblings
) {
59 assert(node
->type
== NODE_UNARY_EXPRESSION
);
60 assert(node
->u
.unary_expression
.type
== UNARY_STRING
);
61 assert((node
->u
.unary_expression
.link
== UNARY_LINK_UNKNOWN
)
63 switch (node
->u
.unary_expression
.link
) {
65 g_string_append(str
, ".")
68 g_string_append(str
, "->")
71 g_string_append(str
, "...")
74 src_string
= u
.unary_expression
.u
.string
;
75 g_string_append(str
, src_string
);
78 return g_string_free(str
, FALSE
);
82 int get_unary_unsigned(struct cds_list_head
*head
, uint64_t *value
)
84 struct ctf_node
*node
;
87 cds_list_for_each_entry(node
, head
, siblings
) {
88 assert(node
->type
== NODE_UNARY_EXPRESSION
);
89 assert(node
->u
.unary_expression
.type
== UNARY_UNSIGNED_CONSTANT
);
90 assert(node
->u
.unary_expression
.link
== UNARY_LINK_UNKNOWN
);
92 *value
= node
->u
.unary_expression
.unsigned_constant
99 int get_unary_uuid(struct cds_list_head
*head
, uuid_t
*uuid
)
101 struct ctf_node
*node
;
105 cds_list_for_each_entry(node
, head
, siblings
) {
106 const char *src_string
;
108 assert(node
->type
== NODE_UNARY_EXPRESSION
);
109 assert(node
->u
.unary_expression
.type
== UNARY_STRING
);
110 assert(node
->u
.unary_expression
.link
== UNARY_LINK_UNKNOWN
);
112 src_string
= u
.unary_expression
.u
.string
;
113 ret
= uuid_parse(u
.unary_expression
.u
.string
, *uuid
);
119 struct ctf_stream
*trace_stream_lookup(struct ctf_trace
*trace
, uint64_t stream_id
)
121 if (trace
->streams
->len
<= stream_id
)
123 return g_ptr_array_index(trace
->streams
, stream_id
);
127 void visit_declaration_specifier(struct cds_list_head
*declaration_specifier
, GString
*str
)
129 struct ctf_node
*iter
;
130 int alias_item_nr
= 0;
133 cds_list_for_each_entry(iter
, declaration_specifier
, siblings
) {
134 if (alias_item_nr
!= 0)
135 g_string_append(str
, " ");
138 switch (iter
->type
) {
139 case NODE_TYPE_SPECIFIER
:
140 switch (iter
->u
.type_specifier
.type
) {
142 g_string_append(str
, "void");
145 g_string_append(str
, "char");
148 g_string_append(str
, "short");
151 g_string_append(str
, "int");
154 g_string_append(str
, "long");
157 g_string_append(str
, "float");
159 case TYPESPEC_DOUBLE
:
160 g_string_append(str
, "double");
162 case TYPESPEC_SIGNED
:
163 g_string_append(str
, "signed");
165 case TYPESPEC_UNSIGNED
:
166 g_string_append(str
, "unsigned");
169 g_string_append(str
, "bool");
171 case TYPESPEC_COMPLEX
:
172 g_string_append(str
, "_Complex");
174 case TYPESPEC_IMAGINARY
:
175 g_string_append(str
, "_Imaginary");
178 g_string_append(str
, "const");
180 case TYPESPEC_ID_TYPE
:
181 if (iter
->u
.type_specifier
.id_type
)
182 g_string_append(str
, iter
->u
.type_specifier
.id_type
);
185 fprintf(stderr
, "[error] %s: unknown specifier\n", __func__
);
191 if (!iter
->u
._enum
.enum_id
) {
192 fprintf(stderr
, "[error] %s: unexpected empty enum ID\n", __func__
);
196 g_string_append(str
, "enum ");
197 g_string_append(str
, iter
->u
._enum
.enum_id
);
200 if (!iter
->u
.variant
.name
) {
201 fprintf(stderr
, "[error] %s: unexpected empty variant name\n", __func__
);
205 g_string_append(str
, "variant ");
206 g_string_append(str
, iter
->u
.variant
.name
);
209 if (!iter
->u
._struct
.name
) {
210 fprintf(stderr
, "[error] %s: unexpected empty variant name\n", __func__
);
214 g_string_append(str
, "struct ");
215 g_string_append(str
, iter
->u
._struct
.name
);
218 fprintf(stderr
, "[error] %s: unexpected node type %d\n", __func__
, (int) iter
->type
);
229 GQuark
create_typealias_identifier(int fd
, int depth
,
230 struct cds_list_head
*declaration_specifier
,
231 struct ctf_node
*node_type_declarator
)
238 str
= g_string_new();
239 ret
= visit_declaration_specifier(declaration_specifier
, str
);
241 g_string_free(str
, TRUE
);
244 cds_list_for_each_entry(iter
, &node_type_declarator
->u
.type_declarator
.pointers
, siblings
) {
245 g_string_append(str
, " *");
246 if (iter
->u
.pointer
.const_qualifier
)
247 g_string_append(str
, " const");
249 str_c
= g_string_free(str
, FALSE
);
250 alias_q
= g_quark_from_string(str_c
);
256 struct declaration
*ctf_type_declarator_visit(int fd
, int depth
,
257 struct cds_list_head
*declaration_specifier
,
259 struct ctf_node
*node_type_declarator
,
260 struct declaration_scope
*declaration_scope
,
261 struct declaration
*nested_declaration
,
262 struct ctf_trace
*trace
)
265 * Visit type declarator by first taking care of sequence/array
266 * (recursively). Then, when we get to the identifier, take care
270 if (node_type_declarator
) {
271 assert(node_type_declarator
->u
.type_declarator
.type
!= TYPEDEC_UNKNOWN
);
273 /* TODO: gcc bitfields not supported yet. */
274 if (node_type_declarator
->u
.type_declarator
.bitfield_len
!= NULL
) {
275 fprintf(stderr
, "[error] %s: gcc bitfields are not supported yet.\n", __func__
);
280 if (!nested_declaration
) {
281 if (node_type_declarator
&& !cds_list_empty(&node_type_declarator
->u
.type_declarator
.pointers
)) {
285 * If we have a pointer declarator, it _has_ to be present in
286 * the typealiases (else fail).
288 alias_q
= create_typealias_identifier(fd
, depth
,
289 declaration_specifier
, node_type_declarator
);
290 nested_declaration
= lookup_declaration(alias_q
, declaration_scope
);
291 if (!nested_declaration
) {
292 fprintf(stderr
, "[error] %s: cannot find typealias \"%s\".\n", __func__
, g_quark_to_string(alias_q
));
296 nested_declaration
= ctf_declaration_specifier_visit(fd
, depth
,
297 declaration_specifier
, declaration_scope
, trace
);
301 if (!node_type_declarator
)
302 return nested_declaration
;
304 if (node_type_declarator
->u
.type_declarator
.type
== TYPEDEC_ID
) {
305 if (node_type_declarator
->u
.type_declarator
.u
.id
)
306 *field_name
= g_quark_from_string(node_type_declarator
->u
.type_declarator
.u
.id
);
309 return nested_declaration
;
311 struct declaration
*declaration
;
316 /* create array/sequence, pass nested_declaration as child. */
317 length
= node_type_declarator
->u
.type_declarator
.u
.nested
.length
;
319 switch (length
->type
) {
320 case NODE_UNARY_EXPRESSION
:
322 struct declaration_array
*array_declaration
;
325 if (length
->u
.unary_expression
.type
!= UNARY_UNSIGNED_CONSTANT
) {
326 fprintf(stderr
, "[error] %s: array: unexpected unary expression.\n", __func__
);
329 len
= length
->u
.unary_expression
.u
.unsigned_constant
;
330 array_declaration
= array_declaration_new(len
, nested_declaration
,
332 declaration
= &array_declaration
->p
;
336 case NODE_TYPE_SPECIFIER
:
338 struct declaration_sequence
*sequence_declaration
;
339 struct declaration_integer
*integer_declaration
;
342 declaration
= ctf_type_declarator_visit(fd
, depth
,
347 assert(declaration
->id
== CTF_TYPE_INTEGER
);
348 integer_declaration
= container_of(declaration
, struct declaration_integer
, p
);
349 declaration_sequence
= sequence_declaration_new(integer_declaration
,
350 nested_declaration
, declaration_scope
);
351 declaration
= &declaration_sequence
->p
;
359 /* Pass it as content of outer container */
360 declaration
= ctf_type_declarator_visit(fd
, depth
,
361 declaration_specifier
, field_name
,
362 node_type_declarator
->u
.type_declarator
.u
.nested
.type_declarator
,
363 declaration_scope
, declaration
, trace
);
369 int ctf_struct_type_declarators_visit(int fd
, int depth
,
370 struct declaration_struct
*struct_declaration
,
371 struct cds_list_head
*declaration_specifier
,
372 struct cds_list_head
*type_declarators
,
373 struct declaration_scope
*declaration_scope
,
374 struct ctf_trace
*trace
)
376 struct ctf_node
*iter
;
379 cds_list_for_each_entry(iter
, type_declarators
, siblings
) {
380 struct declaration
*field_declaration
;
382 field_declaration
= ctf_type_declarator_visit(fd
, depth
,
383 declaration_specifier
,
385 struct_declaration
->scope
,
387 struct_declaration_add_field(struct_declaration
,
388 g_quark_to_string(field_name
),
395 int ctf_variant_type_declarators_visit(int fd
, int depth
,
396 struct declaration_variant
*variant_declaration
,
397 struct cds_list_head
*declaration_specifier
,
398 struct cds_list_head
*type_declarators
,
399 struct declaration_scope
*declaration_scope
,
400 struct ctf_trace
*trace
)
402 struct ctf_node
*iter
;
405 cds_list_for_each_entry(iter
, type_declarators
, siblings
) {
406 struct declaration
*field_declaration
;
408 field_declaration
= ctf_type_declarator_visit(fd
, depth
,
409 declaration_specifier
,
411 variant_declaration
->scope
,
413 variant_declaration_add_field(variant_declaration
,
414 g_quark_to_string(field_name
),
421 int ctf_typedef_visit(int fd
, int depth
, struct declaration_scope
*scope
,
422 struct cds_list_head
*declaration_specifier
,
423 struct cds_list_head
*type_declarators
,
424 struct ctf_trace
*trace
)
426 struct ctf_node
*iter
;
429 cds_list_for_each_entry(iter
, type_declarators
, siblings
) {
430 struct declaration
*type_declaration
;
433 type_declaration
= ctf_type_declarator_visit(fd
, depth
,
434 declaration_specifier
,
437 ret
= register_declaration(identifier
, type_declaration
, scope
);
439 type_declaration
->declaration_free(type_declaration
);
447 int ctf_typealias_visit(int fd
, int depth
, struct declaration_scope
*scope
,
448 struct ctf_node
*target
, struct ctf_node
*alias
,
449 struct ctf_trace
*trace
)
451 struct declaration
*type_declaration
;
452 struct ctf_node
*iter
, *node
;
456 /* See ctf_visitor_type_declarator() in the semantic validator. */
459 * Create target type declaration.
462 type_declaration
= ctf_type_declarator_visit(fd
, depth
,
463 &target
->u
.typealias_target
.declaration_specifier
,
464 &dummy_id
, &target
->u
.typealias_target
.type_declarators
,
466 if (!type_declaration
) {
467 fprintf(stderr
, "[error] %s: problem creating type declaration\n", __func__
);
472 * The semantic validator does not check whether the target is
473 * abstract or not (if it has an identifier). Check it here.
476 fprintf(stderr
, "[error] %s: expecting empty identifier\n", __func__
);
481 * Create alias identifier.
484 node
= _cds_list_first_entry(&alias
->u
.typealias_alias
.type_declarators
,
485 struct node
, siblings
);
486 alias_q
= create_typealias_identifier(fd
, depth
,
487 &alias
->u
.typealias_alias
.declaration_specifier
, node
);
488 ret
= register_declaration(alias_q
, type_declaration
, scope
);
494 type_declaration
->declaration_free(type_declaration
);
499 int ctf_struct_declaration_list_visit(int fd
, int depth
,
500 struct ctf_node
*iter
, struct declaration_struct
*struct_declaration
,
501 struct ctf_trace
*trace
)
503 struct declaration
*declaration
;
506 switch (iter
->type
) {
508 /* For each declarator, declare type and add type to struct declaration scope */
509 ret
= ctf_typedef_visit(fd
, depth
,
510 struct_declaration
->scope
,
511 &iter
->u
._typedef
.declaration_specifier
,
512 &iter
->u
._typedef
.type_declarators
, trace
);
517 /* Declare type with declarator and add type to struct declaration scope */
518 ret
= ctf_typealias_visit(fd
, depth
,
519 struct_declaration
->scope
,
520 iter
->u
.typealias
.target
,
521 iter
->u
.typealias
.alias
, trace
);
525 case NODE_STRUCT_OR_VARIANT_DECLARATION
:
526 /* Add field to structure declaration */
527 ret
= ctf_struct_type_declarators_visit(fd
, depth
,
529 &iter
->u
.struct_or_variant_declaration
.declaration_specifier
,
530 &iter
->u
.struct_or_variant_declaration
.type_declarators
, trace
);
535 fprintf(stderr
, "[error] %s: unexpected node type %d\n", __func__
, (int) iter
->type
);
542 int ctf_variant_declaration_list_visit(int fd
, int depth
,
543 struct ctf_node
*iter
, struct declaration_variant
*variant_declaration
,
544 struct ctf_trace
*trace
)
546 struct declaration
*declaration
;
549 switch (iter
->type
) {
551 /* For each declarator, declare type and add type to variant declaration scope */
552 ret
= ctf_typedef_visit(fd
, depth
,
553 variant_declaration
->scope
,
554 &iter
->u
._typedef
.declaration_specifier
,
555 &iter
->u
._typedef
.type_declarators
, trace
);
560 /* Declare type with declarator and add type to variant declaration scope */
561 ret
= ctf_typealias_visit(fd
, depth
,
562 variant_declaration
->scope
,
563 iter
->u
.typealias
.target
,
564 iter
->u
.typealias
.alias
, trace
);
568 case NODE_STRUCT_OR_VARIANT_DECLARATION
:
569 /* Add field to structure declaration */
570 ret
= ctf_variant_type_declarators_visit(fd
, depth
,
572 &iter
->u
.struct_or_variant_declaration
.declaration_specifier
,
573 &iter
->u
.struct_or_variant_declaration
.type_declarators
, trace
);
578 fprintf(stderr
, "[error] %s: unexpected node type %d\n", __func__
, (int) iter
->type
);
585 struct declaration_struct
*ctf_declaration_struct_visit(FILE *fd
,
586 int depth
, const char *name
, struct cds_list_head
*declaration_list
,
587 int has_body
, struct declaration_scope
*declaration_scope
,
588 struct ctf_trace
*trace
)
590 struct declaration
*declaration
;
591 struct declaration_struct
*struct_declaration
;
592 struct ctf_node
*iter
;
595 * For named struct (without body), lookup in
596 * declaration scope. Don't take reference on struct
597 * declaration: ref is only taken upon definition.
602 lookup_struct_declaration(g_quark_from_string(name
),
604 return struct_declaration
;
606 /* For unnamed struct, create type */
607 /* For named struct (with body), create type and add to declaration scope */
609 if (lookup_struct_declaration(g_quark_from_string(name
),
610 declaration_scope
)) {
612 fprintf(stderr
, "[error] %s: struct %s already declared in scope\n", __func__
, name
);
616 struct_declaration
= struct_declaration_new(name
, declaration_scope
);
617 cds_list_for_each_entry(iter
, declaration_list
, siblings
) {
618 ret
= ctf_struct_declaration_list_visit(fd
, depth
+ 1, iter
,
619 struct_declaration
, trace
);
624 ret
= register_struct_declaration(g_quark_from_string(name
),
629 return struct_declaration
;
632 struct_declaration
->p
.declaration_free(&struct_declaration
->p
);
637 struct declaration_variant
*ctf_declaration_variant_visit(FILE *fd
,
638 int depth
, const char *name
, struct cds_list_head
*declaration_list
,
639 int has_body
, struct declaration_scope
*declaration_scope
,
640 struct ctf_trace
*trace
)
642 struct declaration
*declaration
;
643 struct declaration_variant
*variant_declaration
;
644 struct ctf_node
*iter
;
647 * For named variant (without body), lookup in
648 * declaration scope. Don't take reference on variant
649 * declaration: ref is only taken upon definition.
653 variant_declaration
=
654 lookup_variant_declaration(g_quark_from_string(name
),
656 return variant_declaration
;
658 /* For unnamed variant, create type */
659 /* For named variant (with body), create type and add to declaration scope */
661 if (lookup_variant_declaration(g_quark_from_string(name
),
662 declaration_scope
)) {
664 fprintf(stderr
, "[error] %s: variant %s already declared in scope\n", __func__
, name
);
668 variant_declaration
= variant_declaration_new(name
, declaration_scope
);
669 cds_list_for_each_entry(iter
, declaration_list
, siblings
) {
670 ret
= ctf_variant_declaration_list_visit(fd
, depth
+ 1, iter
,
671 variant_declaration
, trace
);
676 ret
= register_variant_declaration(g_quark_from_string(name
),
681 return variant_declaration
;
684 variant_declaration
->p
.declaration_free(&variant_declaration
->p
);
689 int ctf_enumerator_list_visit(int fd
, int depth
,
690 struct ctf_node
*enumerator
,
691 struct declaration_enum
*enum_declaration
)
694 struct ctf_node
*iter
;
696 q
= g_quark_from_string(enumerator
->u
.enumerator
.id
);
697 if (enum_declaration
->integer
->signedness
) {
701 cds_list_for_each_entry(iter
, enumerator
->u
.enumerator
.values
, siblings
) {
704 assert(iter
->type
== NODE_UNARY_EXPRESSION
);
710 switch (iter
->u
.unary_expression
.type
) {
711 case UNARY_SIGNED_CONSTANT
:
712 *target
= iter
->u
.unary_expression
.u
.signed_constant
;
714 case UNARY_UNSIGNED_CONSTANT
:
715 *target
= iter
->u
.unary_expression
.u
.unsigned_constant
;
718 fprintf(stderr
, "[error] %s: invalid enumerator\n", __func__
);
722 fprintf(stderr
, "[error] %s: invalid enumerator\n", __func__
);
729 enum_signed_insert(enum_declaration
, start
, end
, q
);
734 cds_list_for_each_entry(iter
, enumerator
->u
.enumerator
.values
, siblings
) {
737 assert(iter
->type
== NODE_UNARY_EXPRESSION
);
743 switch (iter
->u
.unary_expression
.type
) {
744 case UNARY_UNSIGNED_CONSTANT
:
745 *target
= iter
->u
.unary_expression
.u
.unsigned_constant
;
747 case UNARY_SIGNED_CONSTANT
:
749 * We don't accept signed constants for enums with unsigned
752 fprintf(stderr
, "[error] %s: invalid enumerator (signed constant encountered, but enum container type is unsigned)\n", __func__
);
755 fprintf(stderr
, "[error] %s: invalid enumerator\n", __func__
);
759 fprintf(stderr
, "[error] %s: invalid enumerator\n", __func__
);
766 enum_unsigned_insert(enum_declaration
, start
, end
, q
);
772 struct declaration
*ctf_declaration_enum_visit(int fd
, int depth
,
774 struct cds_list_head
*container_type
,
775 struct cds_list_head
*enumerator_list
,
777 struct declaration_scope
*declaration_scope
,
778 struct ctf_trace
*trace
)
780 struct declaration
*declaration
;
781 struct declaration_enum
*enum_declaration
;
782 struct declaration_integer
*integer_declaration
;
783 struct ctf_node
*iter
, *first
;
787 * For named enum (without body), lookup in
788 * declaration scope. Don't take reference on enum
789 * declaration: ref is only taken upon definition.
794 lookup_enum_declaration(g_quark_from_string(name
),
796 return enum_declaration
;
798 /* For unnamed enum, create type */
799 /* For named enum (with body), create type and add to declaration scope */
801 if (lookup_enum_declaration(g_quark_from_string(name
),
802 declaration_scope
)) {
804 fprintf(stderr
, "[error] %s: enum %s already declared in scope\n", __func__
, name
);
808 if (cds_list_empty(container_type
)) {
809 fprintf(stderr
, "[error] %s: missing container type for enumeration\n", __func__
, name
);
813 first
= _cds_list_first_entry(container_type
, struct node
, siblings
);
814 switch (first
->type
) {
816 case NODE_TYPE_SPECIFIER
:
817 declaration
= ctf_type_declarator_visit(fd
, depth
,
822 assert(declaration
->id
== CTF_TYPE_INTEGER
);
823 integer_declaration
= container_of(declaration
, struct declaration_integer
, p
);
829 enum_declaration
= enum_declaration_new(name
, integer_declaration
);
830 declaration_unref(&integer_declaration
->p
); /* leave ref to enum */
831 cds_list_for_each_entry(iter
, enumerator_list
, siblings
) {
832 ret
= ctf_enumerator_list_visit(fd
, depth
+ 1, iter
, enum_declaration
);
837 ret
= register_enum_declaration(g_quark_from_string(name
),
842 return enum_declaration
;
845 enum_declaration
->p
.declaration_free(&enum_declaration
->p
);
850 struct declaration
*ctf_declaration_type_specifier_visit(int fd
, int depth
,
851 struct cds_list_head
*declaration_specifier
,
852 struct declaration_scope
*declaration_scope
)
855 struct declaration
*declaration
;
858 str
= g_string_new();
859 ret
= visit_declaration_specifier(declaration_specifier
, str
);
862 str_c
= g_string_free(str
, FALSE
);
863 id_q
= g_quark_from_string(str_c
);
865 declaration
= lookup_declaration(id_q
, declaration_scope
);
870 * Returns 0/1 boolean, or < 0 on error.
873 int get_boolean(int fd
, int depth
, struct node
*unary_expression
)
875 if (unary_expression
->type
!= NODE_UNARY_EXPRESSION
) {
876 fprintf(stderr
, "[error] %s: expecting unary expression\n",
880 switch (unary_expression
->u
.unary_expression
.type
) {
881 case UNARY_UNSIGNED_CONSTANT
:
882 if (unary_expression
->u
.unary_expression
.u
.unsigned_constant
== 0)
886 case UNARY_SIGNED_CONSTANT
:
887 if (unary_expression
->u
.unary_expression
.u
.signed_constant
== 0)
892 if (!strcmp(unary_expression
->u
.unary_expression
.u
.string
, "true"))
894 else if (!strcmp(unary_expression
->u
.unary_expression
.u
.string
, "TRUE"))
896 else if (!strcmp(unary_expression
->u
.unary_expression
.u
.string
, "false"))
898 else if (!strcmp(unary_expression
->u
.unary_expression
.u
.string
, "FALSE"))
901 fprintf(stderr
, "[error] %s: unexpected string \"%s\"\n",
902 __func__
, unary_expression
->u
.unary_expression
.u
.string
);
907 fprintf(stderr
, "[error] %s: unexpected unary expression type\n",
915 int get_byte_order(int fd
, int depth
, struct node
*unary_expression
)
919 if (unary_expression
->u
.unary_expression
.type
!= UNARY_STRING
) {
920 fprintf(stderr
, "[error] %s: byte_order: expecting string\n",
924 if (!strcmp(unary_expression
->u
.unary_expression
.u
.string
, "native"))
925 byte_order
= trace
->byte_order
;
926 else if (!strcmp(unary_expression
->u
.unary_expression
.u
.string
, "network"))
927 byte_order
= BIG_ENDIAN
;
928 else if (!strcmp(unary_expression
->u
.unary_expression
.u
.string
, "be"))
929 byte_order
= BIG_ENDIAN
;
930 else if (!strcmp(unary_expression
->u
.unary_expression
.u
.string
, "le"))
931 byte_order
= LITTLE_ENDIAN
;
933 fprintf(stderr
, "[error] %s: unexpected string \"%s\". Should be \"native\", \"network\", \"be\" or \"le\".\n",
934 __func__
, right
->u
.unary_expression
.u
.string
);
941 struct declaration
*ctf_declaration_integer_visit(int fd
, int depth
,
942 struct cds_list_head
*expressions
,
943 struct ctf_trace
*trace
)
945 struct node
*expression
;
946 uint64_t alignment
, size
;
947 int byte_order
= trace
->byte_order
;
949 int has_alignment
= 0, has_size
= 0;
950 struct declaration_integer
*integer_declaration
;
952 cds_list_for_each_entry(expression
, expressions
, siblings
) {
953 struct node
*left
, *right
;
955 left
= expression
->u
.ctf_expression
.left
;
956 right
= expression
->u
.ctf_expression
.right
;
957 assert(left
->u
.unary_expression
.type
== UNARY_STRING
);
958 if (!strcmp(left
->u
.unary_expression
.u
.string
, "signed")) {
959 signedness
= get_boolean(fd
, depth
, right
);
962 } else if (!strcmp(left
->u
.unary_expression
.u
.string
, "byte_order")) {
963 byte_order
= get_byte_order(fd
, depth
, right
);
966 } else if (!strcmp(left
->u
.unary_expression
.u
.string
, "size")) {
967 if (right
->u
.unary_expression
.type
!= UNARY_UNSIGNED_CONSTANT
) {
968 fprintf(stderr
, "[error] %s: size: expecting unsigned constant\n",
972 size
= right
->u
.unary_expression
.u
.unsigned_constant
;
974 } else if (!strcmp(left
->u
.unary_expression
.u
.string
, "align")) {
975 if (right
->u
.unary_expression
.type
!= UNARY_UNSIGNED_CONSTANT
) {
976 fprintf(stderr
, "[error] %s: align: expecting unsigned constant\n",
980 alignment
= right
->u
.unary_expression
.u
.unsigned_constant
;
983 fprintf(stderr
, "[error] %s: unknown attribute name %s\n",
984 __func__
, left
->u
.unary_expression
.u
.string
);
989 fprintf(stderr
, "[error] %s: missing size attribute\n", __func__
);
992 if (!has_alignment
) {
993 if (size
% CHAR_BIT
) {
994 /* bit-packed alignment */
997 /* byte-packed alignment */
998 alignment
= CHAR_BIT
;
1001 integer_declaration
= integer_declaration_new(size
,
1002 byte_order
, signedness
, alignment
);
1003 return &integer_declaration
->p
;
1007 struct declaration
*ctf_declaration_floating_point_visit(int fd
, int depth
,
1008 struct cds_list_head
*expressions
,
1009 struct ctf_trace
*trace
)
1011 struct node
*expression
;
1012 uint64_t alignment
, exp_dig
, mant_dig
, byte_order
= trace
->byte_order
;
1013 int has_alignment
= 0, has_exp_dig
= 0, has_mant_dig
= 0;
1014 struct declaration_float
*float_declaration
;
1016 cds_list_for_each_entry(expression
, expressions
, siblings
) {
1017 struct node
*left
, *right
;
1019 left
= expression
->u
.ctf_expression
.left
;
1020 right
= expression
->u
.ctf_expression
.right
;
1021 assert(left
->u
.unary_expression
.type
== UNARY_STRING
);
1022 if (!strcmp(left
->u
.unary_expression
.u
.string
, "byte_order")) {
1023 byte_order
= get_byte_order(fd
, depth
, right
);
1026 } else if (!strcmp(left
->u
.unary_expression
.u
.string
, "exp_dig")) {
1027 if (right
->u
.unary_expression
.type
!= UNARY_UNSIGNED_CONSTANT
) {
1028 fprintf(stderr
, "[error] %s: exp_dig: expecting unsigned constant\n",
1032 exp_dig
= right
->u
.unary_expression
.u
.unsigned_constant
;
1034 } else if (!strcmp(left
->u
.unary_expression
.u
.string
, "mant_dig")) {
1035 if (right
->u
.unary_expression
.type
!= UNARY_UNSIGNED_CONSTANT
) {
1036 fprintf(stderr
, "[error] %s: mant_dig: expecting unsigned constant\n",
1040 mant_dig
= right
->u
.unary_expression
.u
.unsigned_constant
;
1042 } else if (!strcmp(left
->u
.unary_expression
.u
.string
, "align")) {
1043 if (right
->u
.unary_expression
.type
!= UNARY_UNSIGNED_CONSTANT
) {
1044 fprintf(stderr
, "[error] %s: align: expecting unsigned constant\n",
1048 alignment
= right
->u
.unary_expression
.u
.unsigned_constant
;
1051 fprintf(stderr
, "[error] %s: unknown attribute name %s\n",
1052 __func__
, left
->u
.unary_expression
.u
.string
);
1056 if (!has_mant_dig
) {
1057 fprintf(stderr
, "[error] %s: missing mant_dig attribute\n", __func__
);
1061 fprintf(stderr
, "[error] %s: missing exp_dig attribute\n", __func__
);
1064 if (!has_alignment
) {
1065 if ((mant_dig
+ exp_dig
) % CHAR_BIT
) {
1066 /* bit-packed alignment */
1069 /* byte-packed alignment */
1070 alignment
= CHAR_BIT
;
1073 float_declaration
= float_declaration_new(mant_dig
, exp_dig
,
1074 byte_order
, alignment
);
1075 return &float_declaration
->p
;
1079 struct declaration
*ctf_declaration_string_visit(int fd
, int depth
,
1080 struct cds_list_head
*expressions
,
1081 struct ctf_trace
*trace
)
1083 struct node
*expression
;
1084 const char *encoding_c
= NULL
;
1085 enum ctf_string_encoding encoding
= CTF_STRING_UTF8
;
1086 struct declaration_string
*string_declaration
;
1088 cds_list_for_each_entry(expression
, expressions
, siblings
) {
1089 struct node
*left
, *right
;
1091 left
= expression
->u
.ctf_expression
.left
;
1092 right
= expression
->u
.ctf_expression
.right
;
1093 assert(left
->u
.unary_expression
.type
== UNARY_STRING
);
1094 if (!strcmp(left
->u
.unary_expression
.u
.string
, "encoding")) {
1095 if (right
->u
.unary_expression
.type
!= UNARY_UNSIGNED_STRING
) {
1096 fprintf(stderr
, "[error] %s: encoding: expecting string\n",
1100 encoding_c
= right
->u
.unary_expression
.u
.string
;
1102 fprintf(stderr
, "[error] %s: unknown attribute name %s\n",
1103 __func__
, left
->u
.unary_expression
.u
.string
);
1107 if (encoding_c
&& !strcmp(encoding_c
, "ASCII"))
1108 encoding
= CTF_STRING_ASCII
;
1109 string_declaration
= string_declaration_new(encoding
);
1110 return &string_declaration
->p
;
1115 * Also add named variant, struct or enum to the current declaration scope.
1118 struct declaration
*ctf_declaration_specifier_visit(FILE *fd
,
1119 int depth
, struct cds_list_head
*head
,
1120 struct declaration_scope
*declaration_scope
,
1121 struct ctf_trace
*trace
)
1123 struct declaration
*declaration
;
1126 first
= _cds_list_first_entry(head
, struct node
, siblings
);
1128 switch (first
->type
) {
1130 return ctf_declaration_struct_visit(fd
, depth
,
1131 first
->u
._struct
.name
,
1132 &first
->u
._struct
.declaration_list
,
1133 first
->u
._struct
.has_body
,
1137 return ctf_declaration_variant_visit(fd
, depth
,
1138 first
->u
.variant
.name
,
1139 &first
->u
.variant
.declaration_list
,
1140 first
->u
.variant
.has_body
,
1144 return ctf_declaration_enum_visit(fd
, depth
,
1145 first
->u
._enum
.enum_id
,
1146 &first
->u
._enum
.container_type
,
1147 &first
->u
._enum
.enumerator_list
,
1148 first
->u
._enum
.has_body
,
1152 return ctf_declaration_integer_visit(fd
, depth
,
1153 &first
->u
.integer
.expressions
, trace
);
1154 case NODE_FLOATING_POINT
:
1155 return ctf_declaration_floating_point_visit(fd
, depth
,
1156 &first
->u
.floating_point
.expressions
, trace
);
1158 return ctf_declaration_string_visit(fd
, depth
,
1159 &first
->u
.string
.expressions
, trace
);
1160 case NODE_TYPE_SPECIFIER
:
1161 return ctf_declaration_type_specifier_visit(fd
, depth
,
1162 head
, declaration_scope
, trace
);
1167 int ctf_event_declaration_visit(FILE *fd
, int depth
, struct ctf_node
*node
, struct ctf_event
*event
, struct ctf_trace
*trace
)
1171 switch (node
->type
) {
1173 ret
= ctf_typedef_visit(fd
, depth
+ 1,
1174 &node
->u
._typedef
.declaration_specifier
,
1175 &node
->u
._typedef
.type_declarators
,
1176 event
->declaration_scope
);
1180 case NODE_TYPEALIAS
:
1181 ret
= ctf_typealias_visit(fd
, depth
+ 1,
1182 &node
->u
.typealias
.target
, &node
->u
.typealias
.alias
1183 event
->declaration_scope
);
1187 case NODE_CTF_EXPRESSION
:
1191 left
= concatenate_unary_strings(&node
->u
.ctf_expression
.left
);
1192 if (!strcmp(left
, "name")) {
1195 if (CTF_EVENT_FIELD_IS_SET(event
, name
))
1197 right
= concatenate_unary_strings(&node
->u
.ctf_expression
.right
);
1199 fprintf(stderr
, "[error] %s: unexpected unary expression for event name\n", __func__
);
1202 event
->name
= g_quark_from_string(right
);
1204 CTF_EVENT_SET_FIELD(event
, name
);
1205 } else if (!strcmp(left
, "id")) {
1206 if (CTF_EVENT_FIELD_IS_SET(event
, id
))
1208 ret
= get_unary_unsigned(&node
->u
.ctf_expression
.right
, &event
->id
);
1210 fprintf(stderr
, "[error] %s: unexpected unary expression for event id\n", __func__
);
1213 CTF_EVENT_SET_FIELD(event
, id
);
1214 } else if (!strcmp(left
, "stream_id")) {
1215 if (CTF_EVENT_FIELD_IS_SET(event
, stream_id
))
1217 ret
= get_unary_unsigned(&node
->u
.ctf_expression
.right
, &event
->stream_id
);
1219 fprintf(stderr
, "[error] %s: unexpected unary expression for event stream_id\n", __func__
);
1222 event
->stream
= trace_stream_lookup(trace
, event
->stream_id
);
1223 if (!event
->stream
) {
1224 fprintf(stderr
, "[error] %s: stream id %" PRIu64
" cannot be found\n", __func__
, event
->stream_id
);
1227 CTF_EVENT_SET_FIELD(event
, stream_id
);
1228 } else if (!strcmp(left
, "context")) {
1229 struct declaration
*declaration
;
1231 if (!event
->definition_scope
)
1233 declaration
= ctf_declaration_specifier_visit(fd
, depth
,
1234 &node
->u
.ctf_expression
.right
,
1235 event
->declaration_scope
, trace
);
1238 if (declaration
->type
->id
!= CTF_TYPE_STRUCT
)
1240 event
->context_decl
= container_of(declaration
, struct declaration_struct
, p
);
1241 } else if (!strcmp(left
, "fields")) {
1242 struct declaration
*declaration
;
1244 if (!event
->definition_scope
)
1246 declaration
= ctf_declaration_specifier_visit(fd
, depth
,
1247 &node
->u
.ctf_expression
.right
,
1248 event
->declaration_scope
, trace
);
1251 if (declaration
->type
->id
!= CTF_TYPE_STRUCT
)
1253 event
->fields_decl
= container_of(declaration
, struct declaration_struct
, p
);
1260 /* TODO: declaration specifier should be added. */
1267 int ctf_event_visit(FILE *fd
, int depth
, struct ctf_node
*node
,
1268 struct declaration_scope
*parent_declaration_scope
, struct ctf_trace
*trace
)
1271 struct ctf_node
*iter
;
1272 struct ctf_event
*event
;
1273 struct definition_scope
*parent_def_scope
;
1275 event
= g_new0(struct ctf_event
, 1);
1276 event
->declaration_scope
= new_declaration_scope(parent_declaration_scope
);
1277 cds_list_for_each_entry(iter
, &node
->u
.event
.declaration_list
, siblings
) {
1278 ret
= ctf_event_declaration_visit(fd
, depth
+ 1, iter
, event
, trace
);
1282 if (!CTF_EVENT_FIELD_IS_SET(event
, name
)) {
1286 if (!CTF_EVENT_FIELD_IS_SET(event
, id
)) {
1290 if (!CTF_EVENT_FIELD_IS_SET(event
, stream_id
)) {
1294 if (event
->stream
->events_by_id
->len
<= event
->id
)
1295 g_ptr_array_set_size(event
->stream
->events_by_id
, event
->id
+ 1);
1296 g_ptr_array_index(event
->stream
->events_by_id
, event
->id
) = event
;
1297 g_hash_table_insert(event
->stream
->event_quark_to_id
,
1298 (gpointer
)(unsigned long) event
->name
,
1300 parent_def_scope
= stream
->definition_scope
;
1301 if (event
->context_decl
) {
1303 event
->context_decl
->definition_new(event
->context_decl
,
1304 parent_def_scope
, 0, 0);
1305 set_dynamic_definition_scope(&event
->context
->p
,
1306 event
->context
->scope
,
1308 parent_def_scope
= event
->context
->scope
;
1309 declaration_unref(event
->context_decl
);
1311 if (event
->fields_decl
) {
1313 event
->fields_decl
->definition_new(event
->fields_decl
,
1314 parent_def_scope
, 0, 0);
1315 set_dynamic_definition_scope(&event
->fields
->p
,
1316 event
->fields
->scope
,
1318 parent_def_scope
= event
->fields
->scope
;
1319 declaration_unref(event
->fields_decl
);
1324 declaration_unref(event
->fields_decl
);
1325 declaration_unref(event
->context_decl
);
1326 free_definition_scope(event
->definition_scope
);
1327 free_declaration_scope(event
->declaration_scope
);
1334 int ctf_stream_declaration_visit(FILE *fd
, int depth
, struct ctf_node
*node
, struct ctf_stream
*stream
, struct ctf_trace
*trace
)
1338 switch (node
->type
) {
1340 ret
= ctf_typedef_visit(fd
, depth
+ 1,
1341 &node
->u
._typedef
.declaration_specifier
,
1342 &node
->u
._typedef
.type_declarators
,
1343 stream
->declaration_scope
);
1347 case NODE_TYPEALIAS
:
1348 ret
= ctf_typealias_visit(fd
, depth
+ 1,
1349 &node
->u
.typealias
.target
, &node
->u
.typealias
.alias
1350 stream
->declaration_scope
);
1354 case NODE_CTF_EXPRESSION
:
1358 left
= concatenate_unary_strings(&node
->u
.ctf_expression
.left
);
1359 if (!strcmp(left
, "stream_id")) {
1360 if (CTF_EVENT_FIELD_IS_SET(event
, stream_id
))
1362 ret
= get_unary_unsigned(&node
->u
.ctf_expression
.right
, &event
->stream_id
);
1364 fprintf(stderr
, "[error] %s: unexpected unary expression for event stream_id\n", __func__
);
1367 CTF_EVENT_SET_FIELD(event
, stream_id
);
1368 } else if (!strcmp(left
, "event.header")) {
1369 struct declaration
*declaration
;
1371 declaration
= ctf_declaration_specifier_visit(fd
, depth
,
1372 &node
->u
.ctf_expression
.right
,
1373 stream
->declaration_scope
, stream
->definition_scope
, trace
);
1376 if (declaration
->type
->id
!= CTF_TYPE_STRUCT
)
1378 stream
->event_header_decl
= container_of(declaration
, struct declaration_struct
, p
);
1379 } else if (!strcmp(left
, "event.context")) {
1380 struct declaration
*declaration
;
1382 declaration
= ctf_declaration_specifier_visit(fd
, depth
,
1383 &node
->u
.ctf_expression
.right
,
1384 stream
->declaration_scope
, trace
);
1387 if (declaration
->type
->id
!= CTF_TYPE_STRUCT
)
1389 stream
->event_context_decl
= container_of(declaration
, struct declaration_struct
, p
);
1390 } else if (!strcmp(left
, "packet.context")) {
1391 struct declaration
*declaration
;
1393 declaration
= ctf_declaration_specifier_visit(fd
, depth
,
1394 &node
->u
.ctf_expression
.right
,
1395 stream
->declaration_scope
, trace
);
1398 if (declaration
->type
->id
!= CTF_TYPE_STRUCT
)
1400 stream
->packet_context_decl
= container_of(declaration
, struct declaration_struct
, p
);
1407 /* TODO: declaration specifier should be added. */
1414 int ctf_stream_visit(FILE *fd
, int depth
, struct ctf_node
*node
,
1415 struct declaration_scope
*parent_declaration_scope
, struct ctf_trace
*trace
)
1418 struct ctf_node
*iter
;
1419 struct ctf_stream
*stream
;
1420 struct definition_scope
*parent_def_scope
;
1422 stream
= g_new0(struct ctf_stream
, 1);
1423 stream
->declaration_scope
= new_declaration_scope(parent_declaration_scope
);
1424 stream
->events_by_id
= g_ptr_array_new();
1425 stream
->event_quark_to_id
= g_hash_table_new(g_int_hash
, g_int_equal
);
1426 cds_list_for_each_entry(iter
, &node
->u
.stream
.declaration_list
, siblings
) {
1427 ret
= ctf_stream_declaration_visit(fd
, depth
+ 1, iter
, stream
, trace
);
1431 if (!CTF_EVENT_FIELD_IS_SET(stream
, stream_id
)) {
1435 if (trace
->streams
->len
<= stream
->stream_id
)
1436 g_ptr_array_set_size(trace
->streams
, stream
->stream_id
+ 1);
1437 g_ptr_array_index(trace
->streams
, stream
->stream_id
) = stream
;
1439 parent_def_scope
= NULL
;
1440 if (stream
->packet_context_decl
) {
1441 stream
->packet_context
=
1442 stream
->packet_context_decl
->definition_new(stream
->packet_context_decl
,
1443 parent_def_scope
, 0, 0);
1444 set_dynamic_definition_scope(&stream
->packet_context
->p
,
1445 stream
->packet_context
->scope
,
1446 "stream.packet.context");
1447 parent_def_scope
= stream
->packet_context
->scope
;
1448 declaration_unref(stream
->packet_context_decl
);
1450 if (stream
->event_header_decl
) {
1451 stream
->event_header
=
1452 stream
->event_header_decl
->definition_new(stream
->event_header_decl
,
1453 parent_def_scope
, 0, 0);
1454 set_dynamic_definition_scope(&stream
->event_header
->p
,
1455 stream
->event_header
->scope
,
1456 "stream.event.header");
1457 parent_def_scope
= stream
->event_header
->scope
;
1458 declaration_unref(stream
->event_header_decl
);
1460 if (stream
->event_context_decl
) {
1461 stream
->event_context
=
1462 stream
->event_context_decl
->definition_new(stream
->event_context_decl
,
1463 parent_def_scope
, 0, 0);
1464 set_dynamic_definition_scope(&stream
->event_context
->p
,
1465 stream
->event_context
->scope
,
1466 "stream.event.context");
1467 parent_def_scope
= stream
->event_context
->scope
;
1468 declaration_unref(stream
->event_context_decl
);
1470 stream
->definition_scope
= parent_def_scope
;
1475 declaration_unref(stream
->event_header
);
1476 declaration_unref(stream
->event_context
);
1477 declaration_unref(stream
->packet_context
);
1478 g_ptr_array_free(stream
->events_by_id
, TRUE
);
1479 g_hash_table_free(stream
->event_quark_to_id
);
1480 free_definition_scope(stream
->definition_scope
);
1481 free_declaration_scope(stream
->declaration_scope
);
1487 int ctf_trace_declaration_visit(FILE *fd
, int depth
, struct ctf_node
*node
, struct ctf_trace
*trace
)
1491 switch (node
->type
) {
1493 ret
= ctf_typedef_visit(fd
, depth
+ 1,
1494 &node
->u
._typedef
.declaration_specifier
,
1495 &node
->u
._typedef
.type_declarators
,
1496 trace
->declaration_scope
);
1500 case NODE_TYPEALIAS
:
1501 ret
= ctf_typealias_visit(fd
, depth
+ 1,
1502 &node
->u
.typealias
.target
, &node
->u
.typealias
.alias
1503 trace
->declaration_scope
);
1507 case NODE_CTF_EXPRESSION
:
1511 left
= concatenate_unary_strings(&node
->u
.ctf_expression
.left
);
1512 if (!strcmp(left
, "major")) {
1513 if (CTF_EVENT_FIELD_IS_SET(trace
, major
))
1515 ret
= get_unary_unsigned(&node
->u
.ctf_expression
.right
, &trace
->major
);
1517 fprintf(stderr
, "[error] %s: unexpected unary expression for trace major number\n", __func__
);
1520 CTF_EVENT_SET_FIELD(trace
, major
);
1521 } else if (!strcmp(left
, "minor")) {
1522 if (CTF_EVENT_FIELD_IS_SET(trace
, minor
))
1524 ret
= get_unary_unsigned(&node
->u
.ctf_expression
.right
, &trace
->minor
);
1526 fprintf(stderr
, "[error] %s: unexpected unary expression for trace minor number\n", __func__
);
1529 CTF_EVENT_SET_FIELD(trace
, minor
);
1530 } else if (!strcmp(left
, "word_size")) {
1531 if (CTF_EVENT_FIELD_IS_SET(trace
, word_size
))
1533 ret
= get_unary_unsigned(&node
->u
.ctf_expression
.right
, &trace
->word_size
);
1535 fprintf(stderr
, "[error] %s: unexpected unary expression for trace word_size\n", __func__
);
1538 CTF_EVENT_SET_FIELD(trace
, word_size
);
1539 } else if (!strcmp(left
, "uuid")) {
1540 if (CTF_EVENT_FIELD_IS_SET(trace
, uuid
))
1542 ret
= get_unary_uuid(&node
->u
.ctf_expression
.right
, &trace
->uuid
);
1544 fprintf(stderr
, "[error] %s: unexpected unary expression for trace uuid\n", __func__
);
1547 CTF_EVENT_SET_FIELD(trace
, uuid
);
1554 /* TODO: declaration specifier should be added. */
1561 int ctf_trace_visit(FILE *fd
, int depth
, struct ctf_node
*node
, struct ctf_trace
*trace
)
1564 struct ctf_node
*iter
;
1566 if (trace
->declaration_scope
)
1568 trace
->declaration_scope
= new_declaration_scope(trace
->root_declaration_scope
);
1569 trace
->definition_scope
= new_dynamic_definition_scope(trace
->root_definition_scope
);
1570 trace
->streams
= g_ptr_array_new();
1571 cds_list_for_each_entry(iter
, &node
->u
.trace
.declaration_list
, siblings
) {
1572 ret
= ctf_trace_declaration_visit(fd
, depth
+ 1, iter
, trace
);
1576 if (!CTF_EVENT_FIELD_IS_SET(trace
, major
)) {
1580 if (!CTF_EVENT_FIELD_IS_SET(trace
, minor
)) {
1584 if (!CTF_EVENT_FIELD_IS_SET(trace
, uuid
)) {
1588 if (!CTF_EVENT_FIELD_IS_SET(trace
, word_size
)) {
1595 g_ptr_array_free(trace
->streams
, TRUE
);
1596 free_definition_scope(stream
->definition_scope
);
1597 free_declaration_scope(stream
->declaration_scope
);
1601 int ctf_visitor_construct_metadata(FILE *fd
, int depth
, struct ctf_node
*node
,
1602 struct ctf_trace
*trace
, int byte_order
)
1605 struct ctf_node
*iter
;
1607 trace
->byte_order
= byte_order
;
1609 switch (node
->type
) {
1611 cds_list_for_each_entry(iter
, &node
->u
.root
._typedef
,
1613 ret
= ctf_typedef_visit(fd
, depth
+ 1,
1614 &iter
->u
._typedef
.declaration_specifier
,
1615 &iter
->u
._typedef
.type_declarators
,
1616 trace
->root_declaration_scope
);
1620 cds_list_for_each_entry(iter
, &node
->u
.root
.typealias
,
1622 ret
= ctf_typealias_visit(fd
, depth
+ 1,
1623 &iter
->u
.typealias
.target
, &iter
->u
.typealias
.alias
1624 trace
->root_declaration_scope
);
1628 cds_list_for_each_entry(iter
, &node
->u
.root
.declaration_specifier
, siblings
) {
1629 ret
= ctf_declaration_specifier_visit(fd
, depth
, iter
,
1630 trace
->root_declaration_scope
, trace
);
1634 cds_list_for_each_entry(iter
, &node
->u
.root
.trace
, siblings
) {
1635 ret
= ctf_trace_visit(fd
, depth
+ 1, iter
, trace
);
1639 cds_list_for_each_entry(iter
, &node
->u
.root
.stream
, siblings
) {
1640 ret
= ctf_stream_visit(fd
, depth
+ 1, iter
,
1641 trace
->root_declaration_scope
, trace
);
1645 cds_list_for_each_entry(iter
, &node
->u
.root
.event
, siblings
) {
1646 ret
= ctf_event_visit(fd
, depth
+ 1, iter
,
1647 trace
->root_declaration_scope
, trace
);
1654 fprintf(stderr
, "[error] %s: unknown node type %d\n", __func__
,