flt.lttng-utils.debug-info: copy user attributes
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 14 Aug 2019 15:31:56 +0000 (11:31 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 15 Aug 2019 15:41:44 +0000 (11:41 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I757acc00be498e1ba82e6255f1d2b85ef9a2059c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1925
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
src/plugins/lttng-utils/debug-info/trace-ir-data-copy.c
src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.c
src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c

index e499ea3c7c907e8be42289fa05d1c1e536084f7c..c25e4b3d794efa434f960cd4ea73fca4f7286052 100644 (file)
@@ -57,6 +57,13 @@ void copy_trace_content(const bt_trace *in_trace, bt_trace *out_trace,
                }
        }
 
+       /*
+        * Safe to use the same value object because it's frozen at this
+        * point.
+        */
+       bt_trace_set_user_attributes(out_trace,
+               bt_trace_borrow_user_attributes_const(in_trace));
+
        /*
         * Do not copy the trace UUID as it may be modified and should
         * no longer have the same UUID.
@@ -133,6 +140,12 @@ void copy_stream_content(const bt_stream *in_stream, bt_stream *out_stream,
                }
        }
 
+       /*
+        * Safe to use the same value object because it's frozen at this
+        * point.
+        */
+       bt_stream_set_user_attributes(out_stream,
+               bt_stream_borrow_user_attributes_const(in_stream));
        BT_COMP_LOGD("Copied content of stream: in-s-addr=%p, out-s-addr=%p",
                        in_stream, out_stream);
 end:
index 0bc9194fc4f6a38ee7859cbc3f3a3588fbfabb84..f5571dbc2627da5db5963cfc854c4b6ed6e3594c 100644 (file)
@@ -46,6 +46,13 @@ int copy_trace_class_content(const bt_trace_class *in_trace_class,
        BT_COMP_LOGD("Copying content of trace class: in-tc-addr=%p, out-tc-addr=%p",
                        in_trace_class, out_trace_class);
 
+       /*
+        * Safe to use the same value object because it's frozen at this
+        * point.
+        */
+       bt_trace_class_set_user_attributes(out_trace_class,
+               bt_trace_class_borrow_user_attributes_const(in_trace_class));
+
        /* Use the same stream class ids as in the origin trace class. */
        bt_trace_class_set_assigns_automatic_stream_class_id(out_trace_class,
                        BT_FALSE);
@@ -81,6 +88,13 @@ int copy_clock_class_content(const bt_clock_class *in_clock_class,
                }
        }
 
+       /*
+        * Safe to use the same value object because it's frozen at this
+        * point.
+        */
+       bt_clock_class_set_user_attributes(out_clock_class,
+               bt_clock_class_borrow_user_attributes_const(in_clock_class));
+
        clock_class_description = bt_clock_class_get_description(in_clock_class);
 
        if (clock_class_description) {
@@ -204,6 +218,13 @@ int copy_stream_class_content(struct trace_ir_maps *ir_maps,
 
        }
 
+       /*
+        * Safe to use the same value object because it's frozen at this
+        * point.
+        */
+       bt_stream_class_set_user_attributes(out_stream_class,
+               bt_stream_class_borrow_user_attributes_const(in_stream_class));
+
        bt_stream_class_set_supports_packets(
                out_stream_class,
                bt_stream_class_supports_packets(in_stream_class),
@@ -345,6 +366,13 @@ int copy_event_class_content(struct trace_ir_maps *ir_maps,
                }
        }
 
+       /*
+        * Safe to use the same value object because it's frozen at this
+        * point.
+        */
+       bt_event_class_set_user_attributes(out_event_class,
+               bt_event_class_borrow_user_attributes_const(in_event_class));
+
        /* Copy event class loglevel. */
        prop_avail = bt_event_class_get_log_level(in_event_class,
                &ec_log_level);
index 2b1f4b04bc4617dfef8074e377c777bda5b0935e..73a7ad44aea2ee580eedfe7a3f742f79f04aa46e 100644 (file)
@@ -357,32 +357,33 @@ int field_class_structure_copy(
 
        /* Iterate over all the members of the struct. */
        for (i = 0; i < struct_member_count; i++) {
-               const bt_field_class_structure_member *member;
+               const bt_field_class_structure_member *in_member;
+               bt_field_class_structure_member *out_member;
                const char *member_name;
-               const bt_field_class *member_fc;
+               const bt_field_class *in_member_fc;
                bt_field_class *out_member_field_class;
 
-               member = bt_field_class_structure_borrow_member_by_index_const(
+               in_member = bt_field_class_structure_borrow_member_by_index_const(
                        in_field_class, i);
-               member_fc = bt_field_class_structure_member_borrow_field_class_const(
-                       member);
-               member_name = bt_field_class_structure_member_get_name(member);
+               in_member_fc = bt_field_class_structure_member_borrow_field_class_const(
+                       in_member);
+               member_name = bt_field_class_structure_member_get_name(in_member);
                BT_COMP_LOGD("Copying structure field class's field: "
                        "index=%" PRId64 ", "
                        "member-fc-addr=%p, field-name=\"%s\"",
-                       i, member_fc, member_name);
+                       i, in_member_fc, member_name);
 
                out_member_field_class = create_field_class_copy(md_maps,
-                               member_fc);
+                               in_member_fc);
                if (!out_member_field_class) {
                        BT_COMP_LOGE("Cannot copy structure field class's field: "
                                "index=%" PRId64 ", "
                                "field-fc-addr=%p, field-name=\"%s\"",
-                               i, member_fc, member_name);
+                               i, in_member_fc, member_name);
                        ret = -1;
                        goto error;
                }
-               ret = copy_field_class_content(md_maps, member_fc,
+               ret = copy_field_class_content(md_maps, in_member_fc,
                                out_member_field_class);
                if (ret) {
                        goto error;
@@ -394,11 +395,24 @@ int field_class_structure_copy(
                        BT_COMP_LOGE("Cannot append structure field class's field: "
                                "index=%" PRId64 ", "
                                "field-fc-addr=%p, field-name=\"%s\"",
-                               i, member_fc, member_name);
+                               i, in_member_fc, member_name);
                        BT_FIELD_CLASS_PUT_REF_AND_RESET(out_member_field_class);
                        ret = -1;
                        goto error;
                }
+
+               out_member = bt_field_class_structure_borrow_member_by_index(
+                       out_field_class, i);
+               BT_ASSERT(out_member);
+
+               /*
+                * Safe to use the same value object because it's frozen
+                * at this point.
+                */
+               bt_field_class_structure_member_set_user_attributes(
+                       out_member,
+                       bt_field_class_structure_member_borrow_user_attributes_const(
+                               in_member));
        }
 
        BT_COMP_LOGD("Copied structure field class: original-fc-addr=%p, copy-fc-addr=%p",
@@ -425,24 +439,25 @@ int field_class_variant_copy(
        variant_option_count =
                bt_field_class_variant_get_option_count(in_field_class);
        for (i = 0; i < variant_option_count; i++) {
-               const bt_field_class *option_fc;
+               const bt_field_class *in_option_fc;
                const char *option_name;
                bt_field_class *out_option_field_class;
-               const bt_field_class_variant_option *option;
+               const bt_field_class_variant_option *in_option;
+               bt_field_class_variant_option *out_option;
 
-               option = bt_field_class_variant_borrow_option_by_index_const(
+               in_option = bt_field_class_variant_borrow_option_by_index_const(
                        in_field_class, i);
-               option_fc = bt_field_class_variant_option_borrow_field_class_const(
-                       option);
-               option_name = bt_field_class_variant_option_get_name(option);
+               in_option_fc = bt_field_class_variant_option_borrow_field_class_const(
+                       in_option);
+               option_name = bt_field_class_variant_option_get_name(in_option);
                out_option_field_class = create_field_class_copy_internal(
-                               md_maps, option_fc);
+                               md_maps, in_option_fc);
                if (!out_option_field_class) {
                        BT_COMP_LOGE_STR("Cannot copy field class.");
                        ret = -1;
                        goto error;
                }
-               ret = copy_field_class_content_internal(md_maps, option_fc,
+               ret = copy_field_class_content_internal(md_maps, in_option_fc,
                                out_option_field_class);
                if (ret) {
                        BT_COMP_LOGE_STR("Error copying content of option variant "
@@ -497,6 +512,19 @@ int field_class_variant_copy(
                                goto error;
                        }
                }
+
+               out_option = bt_field_class_variant_borrow_option_by_index(
+                       out_field_class, i);
+               BT_ASSERT(out_option);
+
+               /*
+                * Safe to use the same value object because it's frozen
+                * at this point.
+                */
+               bt_field_class_variant_option_set_user_attributes(
+                       out_option,
+                       bt_field_class_variant_option_borrow_user_attributes_const(
+                               in_option));
        }
 
        BT_COMP_LOGD("Copied content of variant field class: in-fc-addr=%p, "
@@ -810,6 +838,14 @@ int copy_field_class_content_internal(
                bt_field_class *out_field_class)
 {
        int ret = 0;
+
+       /*
+        * Safe to use the same value object because it's frozen at this
+        * point.
+        */
+       bt_field_class_set_user_attributes(out_field_class,
+               bt_field_class_borrow_user_attributes_const(in_field_class));
+
        switch(bt_field_class_get_type(in_field_class)) {
        case BT_FIELD_CLASS_TYPE_BOOL:
                ret = field_class_bool_copy(md_maps,
This page took 0.031186 seconds and 4 git commands to generate.