- name = bt_ctf_clock_class_get_name(clock_class);
- if (!name) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end;
- }
-
- writer_clock_class = bt_ctf_clock_class_create(name);
- if (!writer_clock_class) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end;
- }
-
- description = bt_ctf_clock_class_get_description(clock_class);
- if (!description) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end_destroy;
- }
-
- int_ret = bt_ctf_clock_class_set_description(writer_clock_class,
- description);
- if (int_ret != 0) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end_destroy;
- }
-
- u64_ret = bt_ctf_clock_class_get_frequency(clock_class);
- if (u64_ret == -1ULL) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end_destroy;
- }
- int_ret = bt_ctf_clock_class_set_frequency(writer_clock_class, u64_ret);
- if (int_ret != 0) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end_destroy;
- }
-
- u64_ret = bt_ctf_clock_class_get_precision(clock_class);
- if (u64_ret == -1ULL) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end_destroy;
- }
- int_ret = bt_ctf_clock_class_set_precision(writer_clock_class,
- u64_ret);
- if (int_ret != 0) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end_destroy;
- }
-
- int_ret = bt_ctf_clock_class_get_offset_s(clock_class, &offset_s);
- if (int_ret != 0) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end_destroy;
- }
-
- int_ret = bt_ctf_clock_class_set_offset_s(writer_clock_class, offset_s);
- if (int_ret != 0) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end_destroy;
- }
-
- int_ret = bt_ctf_clock_class_get_offset_cycles(clock_class, &offset);
- if (int_ret != 0) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end_destroy;
- }
-
- int_ret = bt_ctf_clock_class_set_offset_cycles(writer_clock_class, offset);
- if (int_ret != 0) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end_destroy;
- }
-
- int_ret = bt_ctf_clock_class_get_is_absolute(clock_class);
- if (int_ret == -1) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end_destroy;
- }
-
- int_ret = bt_ctf_clock_class_set_is_absolute(writer_clock_class, int_ret);
- if (int_ret != 0) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end_destroy;
- }
-
- trace = bt_ctf_writer_get_trace(writer);
- if (!trace) {
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end_destroy;
- }
-
- int_ret = bt_ctf_trace_add_clock_class(trace, writer_clock_class);
- if (int_ret != 0) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end_destroy;
- }
-
- /*
- * Ownership transferred to the writer and the stream_class.
- */
- bt_put(writer_clock_class);
- ret = BT_COMPONENT_STATUS_OK;
-
- goto end;
-
-end_destroy:
- BT_PUT(writer_clock_class);
-end:
- BT_PUT(trace);
- return ret;
-}
-
-static
-struct bt_ctf_event_class *copy_event_class(FILE *err, struct bt_ctf_event_class *event_class)
-{
- struct bt_ctf_event_class *writer_event_class = NULL;
- const char *name;
- struct bt_ctf_field_type *context;
- int count, i, ret;
-
- name = bt_ctf_event_class_get_name(event_class);
- if (!name) {
- fprintf(err, "[error] %s in %s:%d\n", __func__,
- __FILE__, __LINE__);
- goto end;
- }
-
- writer_event_class = bt_ctf_event_class_create(name);
- if (!writer_event_class) {
- fprintf(err, "[error] %s in %s:%d\n", __func__,
- __FILE__, __LINE__);
- goto end;
- }
-
- count = bt_ctf_event_class_get_attribute_count(event_class);
- for (i = 0; i < count; i++) {
- const char *attr_name;
- struct bt_value *attr_value;
- int ret;
-
- attr_name = bt_ctf_event_class_get_attribute_name(event_class, i);
- if (!attr_name) {
- fprintf(err, "[error] %s in %s:%d\n", __func__,
- __FILE__, __LINE__);
- BT_PUT(writer_event_class);
- goto end;
- }
- attr_value = bt_ctf_event_class_get_attribute_value(event_class, i);
- if (!attr_value) {
- fprintf(err, "[error] %s in %s:%d\n", __func__,
- __FILE__, __LINE__);
- BT_PUT(writer_event_class);
- goto end;
- }
-
- ret = bt_ctf_event_class_set_attribute(writer_event_class,
- attr_name, attr_value);
- bt_put(attr_value);
- if (ret < 0) {
- fprintf(err, "[error] %s in %s:%d\n", __func__,
- __FILE__, __LINE__);
- BT_PUT(writer_event_class);
- goto end;
- }
- }
-
- context = bt_ctf_event_class_get_context_type(event_class);
- ret = bt_ctf_event_class_set_context_type(writer_event_class, context);
- bt_put(context);
- if (ret < 0) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- goto end;
- }
-
- count = bt_ctf_event_class_get_field_count(event_class);
- for (i = 0; i < count; i++) {
- const char *field_name;
- struct bt_ctf_field_type *field_type;
- int ret;
-
- ret = bt_ctf_event_class_get_field(event_class, &field_name,
- &field_type, i);
- if (ret < 0) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__);
- BT_PUT(writer_event_class);
- goto end;
- }
-
- ret = bt_ctf_event_class_add_field(writer_event_class, field_type,
- field_name);
- if (ret < 0) {
- fprintf(err, "[error] Cannot add field %s\n", field_name);
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__);
- bt_put(field_type);
- BT_PUT(writer_event_class);
- goto end;
- }
- bt_put(field_type);
- }
-
-end:
- return writer_event_class;
-}
-
-static
-enum bt_component_status copy_event_classes(FILE *err,
- struct bt_ctf_writer *writer,
- struct bt_ctf_stream_class *stream_class,
- struct bt_ctf_stream_class *writer_stream_class)
-{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
- int count, i;
-
- count = bt_ctf_stream_class_get_event_class_count(stream_class);
- if (count < 0) {
- fprintf(err, "[error] %s in %s:%d\n", __func__,
- __FILE__, __LINE__);