X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=formats%2Fctf%2Fir%2Ftrace.c;h=2cbfdb4e0e878ef1938fb3729a081d49918ba55e;hb=8bf65fbd5d6164488f1912f88ef632a58598ed2f;hp=0943e8f97c123aed0c1315ce5a9d579415d6ca16;hpb=c968baf7492f1d47b438c49428ac08f3aa3f4d2a;p=babeltrace.git diff --git a/formats/ctf/ir/trace.c b/formats/ctf/ir/trace.c index 0943e8f9..2cbfdb4e 100644 --- a/formats/ctf/ir/trace.c +++ b/formats/ctf/ir/trace.c @@ -30,18 +30,31 @@ #include #include #include +#include +#include +#include #include -#include +#include #include +#include +#include #include +#include #include -#include +#include +#include +#include #define DEFAULT_IDENTIFIER_SIZE 128 #define DEFAULT_METADATA_STRING_SIZE 4096 +struct notification_handler { + bt_ctf_notification_cb func; + void *data; +}; + static -void bt_ctf_trace_destroy(struct bt_ctf_ref *ref); +void bt_ctf_trace_destroy(struct bt_object *obj); static int init_trace_packet_header(struct bt_ctf_trace *trace); static @@ -65,13 +78,6 @@ const unsigned int field_type_aliases_sizes[] = { [FIELD_TYPE_ALIAS_UINT64_T] = 64, }; -static -void put_stream_class(struct bt_ctf_stream_class *stream_class) -{ - (void) bt_ctf_stream_class_set_trace(stream_class, NULL); - bt_ctf_stream_class_put(stream_class); -} - struct bt_ctf_trace *bt_ctf_trace_create(void) { struct bt_ctf_trace *trace = NULL; @@ -82,47 +88,41 @@ struct bt_ctf_trace *bt_ctf_trace_create(void) } bt_ctf_trace_set_byte_order(trace, BT_CTF_BYTE_ORDER_NATIVE); - bt_ctf_ref_init(&trace->ref_count); + bt_object_init(trace, bt_ctf_trace_destroy); trace->clocks = g_ptr_array_new_with_free_func( - (GDestroyNotify) bt_ctf_clock_put); + (GDestroyNotify) bt_put); trace->streams = g_ptr_array_new_with_free_func( - (GDestroyNotify) bt_ctf_stream_put); + (GDestroyNotify) bt_object_release); trace->stream_classes = g_ptr_array_new_with_free_func( - (GDestroyNotify) put_stream_class); + (GDestroyNotify) bt_object_release); if (!trace->clocks || !trace->stream_classes || !trace->streams) { - goto error_destroy; + goto error; } /* Generate a trace UUID */ uuid_generate(trace->uuid); if (init_trace_packet_header(trace)) { - goto error_destroy; + goto error; } /* Create the environment array object */ trace->environment = bt_ctf_attributes_create(); if (!trace->environment) { - goto error_destroy; + goto error; } return trace; -error_destroy: - bt_ctf_trace_destroy(&trace->ref_count); - trace = NULL; error: + BT_PUT(trace); return trace; } -void bt_ctf_trace_destroy(struct bt_ctf_ref *ref) +void bt_ctf_trace_destroy(struct bt_object *obj) { struct bt_ctf_trace *trace; - if (!ref) { - return; - } - - trace = container_of(ref, struct bt_ctf_trace, ref_count); + trace = container_of(obj, struct bt_ctf_trace, base); if (trace->environment) { bt_ctf_attributes_destroy(trace->environment); } @@ -139,57 +139,18 @@ void bt_ctf_trace_destroy(struct bt_ctf_ref *ref) g_ptr_array_free(trace->stream_classes, TRUE); } - bt_ctf_field_type_put(trace->packet_header_type); + bt_put(trace->packet_header_type); g_free(trace); } -struct bt_ctf_stream *bt_ctf_trace_create_stream(struct bt_ctf_trace *trace, - struct bt_ctf_stream_class *stream_class) -{ - int ret; - int stream_class_found = 0; - size_t i; - struct bt_ctf_stream *stream = NULL; - - if (!trace || !stream_class) { - goto error; - } - - stream = bt_ctf_stream_create(stream_class, trace); - if (!stream) { - goto error; - } - - for (i = 0; i < trace->stream_classes->len; i++) { - if (trace->stream_classes->pdata[i] == stream_class) { - stream_class_found = 1; - } - } - - if (!stream_class_found) { - ret = bt_ctf_trace_add_stream_class(trace, stream_class); - if (ret) { - goto error; - } - } - - bt_ctf_stream_get(stream); - g_ptr_array_add(trace->streams, stream); - - return stream; -error: - bt_ctf_stream_put(stream); - return NULL; -} - int bt_ctf_trace_set_environment_field(struct bt_ctf_trace *trace, - const char *name, struct bt_object *value) + const char *name, struct bt_value *value) { int ret = 0; if (!trace || !name || !value || bt_ctf_validate_identifier(name) || - !(bt_object_is_integer(value) || bt_object_is_string(value))) { + !(bt_value_is_integer(value) || bt_value_is_string(value))) { ret = -1; goto end; } @@ -206,17 +167,17 @@ int bt_ctf_trace_set_environment_field(struct bt_ctf_trace *trace, * * The object passed is frozen like all other attributes. */ - struct bt_object *attribute = + struct bt_value *attribute = bt_ctf_attributes_get_field_value_by_name( trace->environment, name); if (attribute) { - BT_OBJECT_PUT(attribute); + BT_PUT(attribute); ret = -1; goto end; } - bt_object_freeze(value); + bt_value_freeze(value); } ret = bt_ctf_attributes_set_field_value(trace->environment, name, @@ -230,7 +191,7 @@ int bt_ctf_trace_set_environment_field_string(struct bt_ctf_trace *trace, const char *name, const char *value) { int ret = 0; - struct bt_object *env_value_string_obj = NULL; + struct bt_value *env_value_string_obj = NULL; if (!trace || !name || !value) { ret = -1; @@ -242,18 +203,18 @@ int bt_ctf_trace_set_environment_field_string(struct bt_ctf_trace *trace, * New environment fields may be added to a frozen trace, * but existing fields may not be changed. */ - struct bt_object *attribute = + struct bt_value *attribute = bt_ctf_attributes_get_field_value_by_name( trace->environment, name); if (attribute) { - BT_OBJECT_PUT(attribute); + BT_PUT(attribute); ret = -1; goto end; } } - env_value_string_obj = bt_object_string_create_init(value); + env_value_string_obj = bt_value_string_create_init(value); if (!env_value_string_obj) { ret = -1; @@ -261,14 +222,13 @@ int bt_ctf_trace_set_environment_field_string(struct bt_ctf_trace *trace, } if (trace->frozen) { - bt_object_freeze(env_value_string_obj); + bt_value_freeze(env_value_string_obj); } ret = bt_ctf_trace_set_environment_field(trace, name, env_value_string_obj); end: - BT_OBJECT_PUT(env_value_string_obj); - + BT_PUT(env_value_string_obj); return ret; } @@ -276,7 +236,7 @@ int bt_ctf_trace_set_environment_field_integer(struct bt_ctf_trace *trace, const char *name, int64_t value) { int ret = 0; - struct bt_object *env_value_integer_obj = NULL; + struct bt_value *env_value_integer_obj = NULL; if (!trace || !name) { ret = -1; @@ -288,18 +248,18 @@ int bt_ctf_trace_set_environment_field_integer(struct bt_ctf_trace *trace, * New environment fields may be added to a frozen trace, * but existing fields may not be changed. */ - struct bt_object *attribute = + struct bt_value *attribute = bt_ctf_attributes_get_field_value_by_name( trace->environment, name); if (attribute) { - BT_OBJECT_PUT(attribute); + BT_PUT(attribute); ret = -1; goto end; } } - env_value_integer_obj = bt_object_integer_create_init(value); + env_value_integer_obj = bt_value_integer_create_init(value); if (!env_value_integer_obj) { ret = -1; goto end; @@ -308,11 +268,10 @@ int bt_ctf_trace_set_environment_field_integer(struct bt_ctf_trace *trace, ret = bt_ctf_trace_set_environment_field(trace, name, env_value_integer_obj); if (trace->frozen) { - bt_object_freeze(env_value_integer_obj); + bt_value_freeze(env_value_integer_obj); } end: - BT_OBJECT_PUT(env_value_integer_obj); - + BT_PUT(env_value_integer_obj); return ret; } @@ -347,10 +306,10 @@ end: return ret; } -struct bt_object *bt_ctf_trace_get_environment_field_value( +struct bt_value *bt_ctf_trace_get_environment_field_value( struct bt_ctf_trace *trace, int index) { - struct bt_object *ret = NULL; + struct bt_value *ret = NULL; if (!trace) { goto end; @@ -362,10 +321,10 @@ end: return ret; } -struct bt_object *bt_ctf_trace_get_environment_field_value_by_name( +struct bt_value *bt_ctf_trace_get_environment_field_value_by_name( struct bt_ctf_trace *trace, const char *name) { - struct bt_object *ret = NULL; + struct bt_value *ret = NULL; if (!trace || !name) { goto end; @@ -396,8 +355,21 @@ int bt_ctf_trace_add_clock(struct bt_ctf_trace *trace, goto end; } - bt_ctf_clock_get(clock); + bt_get(clock); g_ptr_array_add(trace->clocks, clock); + + if (!trace->is_created_by_writer) { + /* + * Non-writer mode trace: disable clock value functions + * because clock values are per-stream in that + * situation. + */ + clock->has_value = 0; + } + + if (trace->frozen) { + bt_ctf_clock_freeze(clock); + } end: return ret; } @@ -425,7 +397,7 @@ struct bt_ctf_clock *bt_ctf_trace_get_clock(struct bt_ctf_trace *trace, } clock = g_ptr_array_index(trace->clocks, index); - bt_ctf_clock_get(clock); + bt_get(clock); end: return clock; } @@ -435,15 +407,154 @@ int bt_ctf_trace_add_stream_class(struct bt_ctf_trace *trace, { int ret, i; int64_t stream_id; + struct bt_ctf_validation_output trace_sc_validation_output = { 0 }; + struct bt_ctf_validation_output *ec_validation_outputs = NULL; + const enum bt_ctf_validation_flag trace_sc_validation_flags = + BT_CTF_VALIDATION_FLAG_TRACE | + BT_CTF_VALIDATION_FLAG_STREAM; + const enum bt_ctf_validation_flag ec_validation_flags = + BT_CTF_VALIDATION_FLAG_EVENT; + struct bt_ctf_field_type *packet_header_type = NULL; + struct bt_ctf_field_type *packet_context_type = NULL; + struct bt_ctf_field_type *event_header_type = NULL; + struct bt_ctf_field_type *stream_event_ctx_type = NULL; + int event_class_count; + struct bt_ctf_clock *clock_to_add_to_trace = NULL; if (!trace || !stream_class) { ret = -1; goto end; } + event_class_count = + bt_ctf_stream_class_get_event_class_count(stream_class); + assert(event_class_count >= 0); + + /* Check for duplicate stream classes */ for (i = 0; i < trace->stream_classes->len; i++) { if (trace->stream_classes->pdata[i] == stream_class) { - /* Stream already registered to the trace */ + /* Stream class already registered to the trace */ + ret = -1; + goto end; + } + } + + /* + * If the stream class has a clock, register this clock to this + * trace if not already done. + */ + if (stream_class->clock) { + const char *clock_name = + bt_ctf_clock_get_name(stream_class->clock); + struct bt_ctf_clock *trace_clock; + + assert(clock_name); + trace_clock = bt_ctf_trace_get_clock_by_name(trace, clock_name); + bt_put(trace_clock); + if (trace_clock) { + if (trace_clock != stream_class->clock) { + /* + * Error: two different clocks in the + * trace would share the same name. + */ + ret = -1; + goto end; + } + } else { + clock_to_add_to_trace = bt_get(stream_class->clock); + } + } + + /* + * We're about to freeze both the trace and the stream class. + * Also, each event class contained in this stream class are + * already frozen. + * + * This trace, this stream class, and all its event classes + * should be valid at this point. + * + * Validate trace and stream class first, then each event + * class of this stream class can be validated individually. + */ + packet_header_type = + bt_ctf_trace_get_packet_header_type(trace); + packet_context_type = + bt_ctf_stream_class_get_packet_context_type(stream_class); + event_header_type = + bt_ctf_stream_class_get_event_header_type(stream_class); + stream_event_ctx_type = + bt_ctf_stream_class_get_event_context_type(stream_class); + ret = bt_ctf_validate_class_types(trace->environment, + packet_header_type, packet_context_type, event_header_type, + stream_event_ctx_type, NULL, NULL, trace->valid, + stream_class->valid, 1, &trace_sc_validation_output, + trace_sc_validation_flags); + BT_PUT(packet_header_type); + BT_PUT(packet_context_type); + BT_PUT(event_header_type); + BT_PUT(stream_event_ctx_type); + + if (ret) { + /* + * This means something went wrong during the validation + * process, not that the objects are invalid. + */ + goto end; + } + + if ((trace_sc_validation_output.valid_flags & + trace_sc_validation_flags) != + trace_sc_validation_flags) { + /* Invalid trace/stream class */ + ret = -1; + goto end; + } + + if (event_class_count > 0) { + ec_validation_outputs = g_new0(struct bt_ctf_validation_output, + event_class_count); + if (!ec_validation_outputs) { + ret = -1; + goto end; + } + } + + /* Validate each event class individually */ + for (i = 0; i < event_class_count; i++) { + struct bt_ctf_event_class *event_class = + bt_ctf_stream_class_get_event_class(stream_class, i); + struct bt_ctf_field_type *event_context_type = NULL; + struct bt_ctf_field_type *event_payload_type = NULL; + + event_context_type = + bt_ctf_event_class_get_context_type(event_class); + event_payload_type = + bt_ctf_event_class_get_payload_type(event_class); + + /* + * It is important to use the field types returned by + * the previous trace and stream class validation here + * because copies could have been made. + */ + ret = bt_ctf_validate_class_types(trace->environment, + trace_sc_validation_output.packet_header_type, + trace_sc_validation_output.packet_context_type, + trace_sc_validation_output.event_header_type, + trace_sc_validation_output.stream_event_ctx_type, + event_context_type, event_payload_type, + 1, 1, event_class->valid, &ec_validation_outputs[i], + ec_validation_flags); + BT_PUT(event_context_type); + BT_PUT(event_payload_type); + BT_PUT(event_class); + + if (ret) { + goto end; + } + + if ((ec_validation_outputs[i].valid_flags & + ec_validation_flags) != ec_validation_flags) { + /* Invalid event class */ ret = -1; goto end; } @@ -463,44 +574,92 @@ int bt_ctf_trace_add_stream_class(struct bt_ctf_trace *trace, } } - if (bt_ctf_stream_class_set_id_no_check(stream_class, stream_id)) { + if (bt_ctf_stream_class_set_id_no_check(stream_class, + stream_id)) { /* TODO Should retry with a different stream id */ ret = -1; goto end; } } - /* Set weak reference to trace in stream class */ - ret = bt_ctf_stream_class_set_trace(stream_class, trace); - if (ret) { - /* Stream class already part of another trace */ - goto end; - } - - bt_ctf_stream_class_get(stream_class); + bt_object_set_parent(stream_class, trace); g_ptr_array_add(trace->stream_classes, stream_class); /* - * Freeze the trace and its packet header. - * + * At this point we know that the function will be successful. + * Therefore we can replace the trace and stream class field + * types with what's in their validation output structure and + * mark them as valid. We can also replace the field types of + * all the event classes of the stream class and mark them as + * valid. + */ + bt_ctf_validation_replace_types(trace, stream_class, NULL, + &trace_sc_validation_output, trace_sc_validation_flags); + trace->valid = 1; + stream_class->valid = 1; + + /* + * Put what was not moved in bt_ctf_validation_replace_types(). + */ + bt_ctf_validation_output_put_types(&trace_sc_validation_output); + + for (i = 0; i < event_class_count; i++) { + struct bt_ctf_event_class *event_class = + bt_ctf_stream_class_get_event_class(stream_class, i); + + bt_ctf_validation_replace_types(NULL, NULL, event_class, + &ec_validation_outputs[i], ec_validation_flags); + event_class->valid = 1; + BT_PUT(event_class); + + /* + * Put what was not moved in + * bt_ctf_validation_replace_types(). + */ + bt_ctf_validation_output_put_types(&ec_validation_outputs[i]); + } + + /* * All field type byte orders set as "native" byte ordering can now be * safely set to trace's own endianness, including the stream class'. */ bt_ctf_field_type_set_native_byte_order(trace->packet_header_type, trace->byte_order); - ret = bt_ctf_stream_class_set_byte_order(stream_class, - trace->byte_order == LITTLE_ENDIAN ? - BT_CTF_BYTE_ORDER_LITTLE_ENDIAN : BT_CTF_BYTE_ORDER_BIG_ENDIAN); - if (ret) { - goto end; + bt_ctf_stream_class_set_byte_order(stream_class, trace->byte_order); + + /* Add stream class's clock if it exists */ + if (clock_to_add_to_trace) { + int add_clock_ret = + bt_ctf_trace_add_clock(trace, clock_to_add_to_trace); + assert(add_clock_ret == 0); } + /* + * Freeze the trace and the stream class. + */ bt_ctf_stream_class_freeze(stream_class); bt_ctf_trace_freeze(trace); + end: if (ret) { - (void) bt_ctf_stream_class_set_trace(stream_class, NULL); + bt_object_set_parent(stream_class, NULL); + + if (ec_validation_outputs) { + for (i = 0; i < event_class_count; i++) { + bt_ctf_validation_output_put_types( + &ec_validation_outputs[i]); + } + } } + + g_free(ec_validation_outputs); + bt_ctf_validation_output_put_types(&trace_sc_validation_output); + BT_PUT(clock_to_add_to_trace); + assert(!packet_header_type); + assert(!packet_context_type); + assert(!event_header_type); + assert(!stream_event_ctx_type); + return ret; } @@ -528,7 +687,35 @@ struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class( } stream_class = g_ptr_array_index(trace->stream_classes, index); - bt_ctf_stream_class_get(stream_class); + bt_get(stream_class); +end: + return stream_class; +} + +struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_id( + struct bt_ctf_trace *trace, uint32_t id) +{ + int i; + struct bt_ctf_stream_class *stream_class = NULL; + + if (!trace) { + goto end; + } + + for (i = 0; i < trace->stream_classes->len; i++) { + struct bt_ctf_stream_class *stream_class_candidate; + + stream_class_candidate = + g_ptr_array_index(trace->stream_classes, i); + + if (bt_ctf_stream_class_get_id(stream_class_candidate) == + (int64_t) id) { + stream_class = stream_class_candidate; + bt_get(stream_class); + goto end; + } + } + end: return stream_class; } @@ -543,7 +730,7 @@ struct bt_ctf_clock *bt_ctf_trace_get_clock_by_name( goto end; } - for (i = 0; i < trace->clocks->len; ++i) { + for (i = 0; i < trace->clocks->len; i++) { struct bt_ctf_clock *cur_clk = g_ptr_array_index(trace->clocks, i); const char *cur_clk_name = bt_ctf_clock_get_name(cur_clk); @@ -554,7 +741,7 @@ struct bt_ctf_clock *bt_ctf_trace_get_clock_by_name( if (!strcmp(cur_clk_name, name)) { clock = cur_clk; - bt_ctf_clock_get(clock); + bt_get(clock); goto end; } } @@ -634,8 +821,8 @@ void append_env_metadata(struct bt_ctf_trace *trace, g_string_append(context->string, "env {\n"); - for (i = 0; i < env_size; ++i) { - struct bt_object *env_field_value_obj = NULL; + for (i = 0; i < env_size; i++) { + struct bt_value *env_field_value_obj = NULL; const char *entry_name; entry_name = bt_ctf_attributes_get_field_name( @@ -647,13 +834,13 @@ void append_env_metadata(struct bt_ctf_trace *trace, goto loop_next; } - switch (bt_object_get_type(env_field_value_obj)) { - case BT_OBJECT_TYPE_INTEGER: + switch (bt_value_get_type(env_field_value_obj)) { + case BT_VALUE_TYPE_INTEGER: { int ret; int64_t int_value; - ret = bt_object_integer_get(env_field_value_obj, + ret = bt_value_integer_get(env_field_value_obj, &int_value); if (ret) { @@ -665,13 +852,13 @@ void append_env_metadata(struct bt_ctf_trace *trace, int_value); break; } - case BT_OBJECT_TYPE_STRING: + case BT_VALUE_TYPE_STRING: { int ret; const char *str_value; char *escaped_str = NULL; - ret = bt_object_string_get(env_field_value_obj, + ret = bt_value_string_get(env_field_value_obj, &str_value); if (ret) { @@ -695,7 +882,7 @@ void append_env_metadata(struct bt_ctf_trace *trace, } loop_next: - BT_OBJECT_PUT(env_field_value_obj); + BT_PUT(env_field_value_obj); } g_string_append(context->string, "};\n\n"); @@ -817,7 +1004,7 @@ struct bt_ctf_field_type *bt_ctf_trace_get_packet_header_type( goto end; } - bt_ctf_field_type_get(trace->packet_header_type); + bt_get(trace->packet_header_type); field_type = trace->packet_header_type; end: return field_type; @@ -835,57 +1022,148 @@ int bt_ctf_trace_set_packet_header_type(struct bt_ctf_trace *trace, /* packet_header_type must be a structure */ if (bt_ctf_field_type_get_type_id(packet_header_type) != - CTF_TYPE_STRUCT) { + BT_CTF_TYPE_ID_STRUCT) { ret = -1; goto end; } - bt_ctf_field_type_get(packet_header_type); - bt_ctf_field_type_put(trace->packet_header_type); + bt_get(packet_header_type); + bt_put(trace->packet_header_type); trace->packet_header_type = packet_header_type; end: return ret; } -void bt_ctf_trace_get(struct bt_ctf_trace *trace) +static +int get_stream_class_count(void *element) { - if (!trace) { - return; + return bt_ctf_trace_get_stream_class_count( + (struct bt_ctf_trace *) element); +} + +static +void *get_stream_class(void *element, int i) +{ + return bt_ctf_trace_get_stream_class( + (struct bt_ctf_trace *) element, i); +} + +static +int visit_stream_class(void *element, bt_ctf_ir_visitor visitor,void *data) +{ + return bt_ctf_stream_class_visit(element, visitor, data); +} + +int bt_ctf_trace_visit(struct bt_ctf_trace *trace, + bt_ctf_ir_visitor visitor, void *data) +{ + int ret; + struct bt_ctf_ir_element element = + { .element = trace, .type = BT_CTF_IR_TYPE_TRACE }; + + if (!trace || !visitor) { + ret = -1; + goto end; } - bt_ctf_ref_get(&trace->ref_count); + ret = visitor_helper(&element, get_stream_class_count, + get_stream_class, visit_stream_class, visitor, data); +end: + return ret; } -void bt_ctf_trace_put(struct bt_ctf_trace *trace) +static +int ir_visitor(struct bt_ctf_ir_element *element, void *data) { - if (!trace) { - return; + int ret = 0; + + switch (element->type) { + case BT_CTF_IR_TYPE_TRACE: + { + break; + } + case BT_CTF_IR_TYPE_STREAM_CLASS: + { + break; + } + case BT_CTF_IR_TYPE_EVENT_CLASS: + { + break; + } + default: + assert(0); + ret = -1; + goto end; + } +end: + return ret; +} + +int bt_ctf_trace_add_notification_handler_cb(struct bt_ctf_trace *trace, + bt_ctf_notification_cb handler, void *handler_data) +{ + int ret = 0; + struct notification_handler *handler_wrapper = + g_new0(struct notification_handler, 1); + + if (!trace || !handler || !handler_wrapper) { + ret = -1; + goto error; } - bt_ctf_ref_put(&trace->ref_count, bt_ctf_trace_destroy); + handler_wrapper->func = handler; + handler_wrapper->data = handler_data; + + /* Emit notifications describing the current schema. */ + ret = bt_ctf_trace_visit(trace, ir_visitor, handler_wrapper); + if (ret) { + goto error; + } + + g_ptr_array_add(trace->notification_handlers, handler_wrapper); + return ret; +error: + g_free(handler_wrapper); + return ret; } BT_HIDDEN struct bt_ctf_field_type *get_field_type(enum field_type_alias alias) { + int ret; unsigned int alignment, size; - struct bt_ctf_field_type *field_type; + struct bt_ctf_field_type *field_type = NULL; if (alias >= NR_FIELD_TYPE_ALIAS) { - return NULL; + goto end; } alignment = field_type_aliases_alignments[alias]; size = field_type_aliases_sizes[alias]; field_type = bt_ctf_field_type_integer_create(size); - bt_ctf_field_type_set_alignment(field_type, alignment); + ret = bt_ctf_field_type_set_alignment(field_type, alignment); + if (ret) { + BT_PUT(field_type); + } +end: return field_type; } static void bt_ctf_trace_freeze(struct bt_ctf_trace *trace) { + int i; + + bt_ctf_field_type_freeze(trace->packet_header_type); bt_ctf_attributes_freeze(trace->environment); + + for (i = 0; i < trace->clocks->len; i++) { + struct bt_ctf_clock *clock = + g_ptr_array_index(trace->clocks, i); + + bt_ctf_clock_freeze(clock); + } + trace->frozen = 1; } @@ -932,12 +1210,11 @@ int init_trace_packet_header(struct bt_ctf_trace *trace) goto end; } end: - bt_ctf_field_type_put(uuid_array_type); - bt_ctf_field_type_put(_uint32_t); - bt_ctf_field_type_put(_uint8_t); - bt_ctf_field_put(magic); - bt_ctf_field_put(uuid_array); - bt_ctf_field_type_put(trace_packet_header_type); - + bt_put(uuid_array_type); + bt_put(_uint32_t); + bt_put(_uint8_t); + bt_put(magic); + bt_put(uuid_array); + bt_put(trace_packet_header_type); return ret; }