lib: rename functions to clearly indicate API inheritance
[babeltrace.git] / src / plugins / lttng-utils / debug-info / trace-ir-data-copy.c
index feb8347b92a27cf1a4bc55ec57612d66e20ee85f..274c3170ee2b9f19b901a3b09370250827d29db3 100644 (file)
@@ -41,6 +41,7 @@ void copy_trace_content(const bt_trace *in_trace, bt_trace *out_trace,
 {
        bt_trace_set_name_status status;
        const char *trace_name;
+       uint64_t i, env_field_count;
 
        BT_COMP_LOGD("Copying content of trace: in-t-addr=%p, out-t-addr=%p",
                        in_trace, out_trace);
@@ -56,6 +57,56 @@ void copy_trace_content(const bt_trace *in_trace, bt_trace *out_trace,
                }
        }
 
+       /*
+        * Do not copy the trace UUID as it may be modified and should
+        * no longer have the same UUID.
+        */
+
+       /*
+        * Go over all the entries in the environment section of the
+        * trace and copy the content to the new trace.
+        */
+       env_field_count = bt_trace_get_environment_entry_count(in_trace);
+       for (i = 0; i < env_field_count; i++) {
+               const char *value_name;
+               const bt_value *value = NULL;
+               bt_trace_set_environment_entry_status set_env_status;
+
+               bt_trace_borrow_environment_entry_by_index_const(
+                       in_trace, i, &value_name, &value);
+
+               BT_COMP_LOGD("Copying trace environnement entry: "
+                       "index=%" PRId64 ", value-addr=%p, value-name=%s",
+                       i, value, value_name);
+
+               BT_ASSERT(value_name);
+               BT_ASSERT(value);
+
+               if (bt_value_is_signed_integer(value)) {
+                       set_env_status =
+                               bt_trace_set_environment_entry_integer(
+                                               out_trace, value_name,
+                                               bt_value_integer_signed_get(
+                                                       value));
+               } else if (bt_value_is_string(value)) {
+                       set_env_status =
+                               bt_trace_set_environment_entry_string(
+                                       out_trace, value_name,
+                                       bt_value_string_get(value));
+               } else {
+                       abort();
+               }
+
+               if (set_env_status !=
+                               BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_OK) {
+                       BT_COMP_LOGE("Cannot copy trace's environment: "
+                               "trace-addr=%p, name=\"%s\"",
+                               out_trace, trace_name);
+                       bt_current_thread_clear_error();
+                       goto end;
+               }
+       }
+
        BT_COMP_LOGD("Copied content of trace: in-t-addr=%p, out-t-addr=%p",
                        in_trace, out_trace);
 end:
@@ -170,13 +221,13 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field,
        switch (in_fc_type) {
        case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER:
        case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION:
-               bt_field_unsigned_integer_set_value(out_field,
-                               bt_field_unsigned_integer_get_value(in_field));
+               bt_field_integer_unsigned_set_value(out_field,
+                               bt_field_integer_unsigned_get_value(in_field));
                break;
        case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER:
        case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION:
-               bt_field_signed_integer_set_value(out_field,
-                               bt_field_signed_integer_get_value(in_field));
+               bt_field_integer_signed_set_value(out_field,
+                               bt_field_integer_signed_get_value(in_field));
                break;
        case BT_FIELD_CLASS_TYPE_REAL:
                bt_field_real_set_value(out_field,
@@ -240,12 +291,12 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field,
                const bt_field *in_element_field;
                bt_field *out_element_field;
                uint64_t i, array_len;
-               bt_field_dynamic_array_set_length_status set_len_status;
+               bt_field_array_dynamic_set_length_status set_len_status;
 
                array_len = bt_field_array_get_length(in_field);
 
                if (in_fc_type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY) {
-                       set_len_status = bt_field_dynamic_array_set_length(
+                       set_len_status = bt_field_array_dynamic_set_length(
                                out_field, array_len);
                        if (set_len_status !=
                                        BT_FIELD_DYNAMIC_ARRAY_SET_LENGTH_STATUS_OK) {
@@ -268,9 +319,11 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field,
                }
                break;
        }
-       case BT_FIELD_CLASS_TYPE_VARIANT:
+       case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR:
+       case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR:
+       case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR:
        {
-               bt_field_variant_select_option_field_status sel_opt_status;
+               bt_field_variant_select_option_field_by_index_status sel_opt_status;
                uint64_t in_selected_option_idx;
                const bt_field *in_option_field;
                bt_field *out_option_field;
@@ -278,7 +331,7 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field,
                in_selected_option_idx =
                        bt_field_variant_get_selected_option_field_index(
                                        in_field);
-               sel_opt_status = bt_field_variant_select_option_field(out_field,
+               sel_opt_status = bt_field_variant_select_option_field_by_index(out_field,
                                in_selected_option_idx);
                if (sel_opt_status !=
                                BT_FIELD_VARIANT_SELECT_OPTION_FIELD_STATUS_OK) {
This page took 0.025669 seconds and 4 git commands to generate.