+ ret = bt_trace_collection_add(ctx->tc, td);
+ if (ret != 0)
+ goto error;
+
+ if (fmt->convert_index_timestamp) {
+ ret = fmt->convert_index_timestamp(td);
+ if (ret < 0)
+ goto error;
+ }
+
+ if (fmt->timestamp_begin)
+ handle->real_timestamp_begin = fmt->timestamp_begin(td,
+ handle, BT_CLOCK_REAL);
+ if (fmt->timestamp_end)
+ handle->real_timestamp_end = fmt->timestamp_end(td, handle,
+ BT_CLOCK_REAL);
+ if (fmt->timestamp_begin)
+ handle->cycles_timestamp_begin = fmt->timestamp_begin(td,
+ handle, BT_CLOCK_CYCLES);
+ if (fmt->timestamp_end)
+ handle->cycles_timestamp_end = fmt->timestamp_end(td, handle,
+ BT_CLOCK_CYCLES);
+
+ return handle->id;
+
+error:
+ closeret = fmt->close_trace(td);
+ if (closeret) {
+ fprintf(stderr, "Error in close_trace callback\n");
+ }