X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Fmetadata%2Fctf-visitor-generate-io-struct.c;h=82af10a10f259be1fd05a6467bc210aa13c0ae83;hp=2eba30bd46d3475cf9a2c74e679646bba7fef119;hb=82662ad4362f791f9cd7026652f60708923554f4;hpb=7c8a138614de162b26bd280934a4d0569701f07c diff --git a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c index 2eba30bd..82af10a1 100644 --- a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c +++ b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -1093,7 +1093,7 @@ struct declaration *ctf_declaration_integer_visit(FILE *fd, int depth, struct ctf_trace *trace) { struct ctf_node *expression; - uint64_t alignment = 1, size; + uint64_t alignment = 1, size = 0; int byte_order = trace->byte_order; int signedness = 0; int has_alignment = 0, has_size = 0; @@ -1793,6 +1793,7 @@ int ctf_stream_visit(FILE *fd, int depth, struct ctf_node *node, if (trace->streams->len <= stream->stream_id) g_ptr_array_set_size(trace->streams, stream->stream_id + 1); g_ptr_array_index(trace->streams, stream->stream_id) = stream; + stream->trace = trace; return 0; @@ -1905,7 +1906,10 @@ int ctf_trace_declaration_visit(FILE *fd, int depth, struct ctf_node *node, stru * construction of the * intermediate representation. */ - return -EINTR; + trace->field_mask = 0; + CTF_TRACE_SET_FIELD(trace, byte_order); + ret = -EINTR; + goto error; } } CTF_TRACE_SET_FIELD(trace, byte_order); @@ -1954,7 +1958,6 @@ int ctf_trace_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_trace int ret = 0; struct ctf_node *iter; -restart: if (trace->declaration_scope) return -EEXIST; trace->declaration_scope = new_declaration_scope(trace->root_declaration_scope); @@ -1997,16 +2000,13 @@ restart: return 0; error: - if (trace->packet_header_decl) + if (trace->packet_header_decl) { declaration_unref(&trace->packet_header_decl->p); + trace->packet_header_decl = NULL; + } g_ptr_array_free(trace->streams, TRUE); free_declaration_scope(trace->declaration_scope); trace->declaration_scope = NULL; - /* byte order changed while creating types, retry. */ - if (ret == -EINTR) { - trace->field_mask = 0; - goto restart; - } return ret; } @@ -2062,9 +2062,11 @@ int ctf_visitor_construct_metadata(FILE *fd, int depth, struct ctf_node *node, struct ctf_node *iter; printf_verbose("CTF visitor: metadata construction... "); - trace->root_declaration_scope = new_declaration_scope(NULL); trace->byte_order = byte_order; +retry: + trace->root_declaration_scope = new_declaration_scope(NULL); + switch (node->type) { case NODE_ROOT: cds_list_for_each_entry(iter, &node->u.root.declaration_list, @@ -2077,6 +2079,15 @@ int ctf_visitor_construct_metadata(FILE *fd, int depth, struct ctf_node *node, } cds_list_for_each_entry(iter, &node->u.root.trace, siblings) { ret = ctf_trace_visit(fd, depth + 1, iter, trace); + if (ret == -EINTR) { + free_declaration_scope(trace->root_declaration_scope); + /* + * Need to restart creation of type + * definitions, aliases and + * trace header declarations. + */ + goto retry; + } if (ret) { fprintf(fd, "[error] %s: trace declaration error\n", __func__); goto error;