flt.lttng-utils.debug-info: copy option field class and field objects
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 12 Aug 2019 22:11:31 +0000 (18:11 -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: I3451d3071655b4759c365adf9ff9c0ddd53425ba
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1898
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-field-class-copy.c

index d805735a95e7f6444d1b7c6ebfdd7f469eb12ae2..2d27b85b0b6c5bc7d006a5288c0acfe6ef40e1b2 100644 (file)
@@ -323,6 +323,26 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field,
                }
                break;
        }
+       case BT_FIELD_CLASS_TYPE_OPTION:
+       {
+               const bt_field *in_option_field;
+               bt_field *out_option_field;
+
+               in_option_field = bt_field_option_borrow_field_const(in_field);
+
+               if (in_option_field) {
+                       bt_field_option_set_has_field(out_field, BT_TRUE);
+                       out_option_field = bt_field_option_borrow_field(
+                               out_field);
+                       BT_ASSERT(out_option_field);
+                       copy_field_content(in_option_field, out_option_field,
+                               log_level, self_comp);
+               } else {
+                       bt_field_option_set_has_field(out_field, BT_FALSE);
+               }
+
+               break;
+       }
        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:
index 868699e580801b41f4d2ee5046b5d8ace8c55cf1..e82d96d8dd75a92c8ec4a659787886b15029fd0e 100644 (file)
@@ -74,6 +74,14 @@ const bt_field_class *walk_field_path(struct trace_ir_metadata_maps *md_maps,
                                member);
                        break;
                }
+               case BT_FIELD_CLASS_TYPE_OPTION:
+               {
+                       BT_ASSERT(bt_field_path_item_get_type(fp_item) ==
+                               BT_FIELD_PATH_ITEM_TYPE_CURRENT_OPTION_CONTENT);
+                       curr_fc = bt_field_class_option_borrow_field_class_const(
+                               curr_fc);
+                       break;
+               }
                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:
@@ -521,6 +529,26 @@ int field_class_dynamic_array_copy(
        return 0;
 }
 
+static inline
+int field_class_option_copy(
+               struct trace_ir_metadata_maps *md_maps,
+               const bt_field_class *in_field_class,
+               bt_field_class *out_field_class)
+{
+       BT_COMP_LOGD("Copying content of option field class: "
+                       "in-fc-addr=%p, out-fc-addr=%p",
+                       in_field_class, out_field_class);
+
+       /*
+        * There is no content to copy. Keep this function call anyway for
+        * logging purposes.
+        */
+       BT_COMP_LOGD("Copied option field class: in-fc-addr=%p, "
+                       "out-fc-addr=%p", in_field_class, out_field_class);
+
+       return 0;
+}
+
 static inline
 int field_class_string_copy(struct trace_ir_metadata_maps *md_maps,
                const bt_field_class *in_field_class,
@@ -661,6 +689,49 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps *
                                out_elem_fc, out_length_fc);
                break;
        }
+       case BT_FIELD_CLASS_TYPE_OPTION:
+       {
+               const bt_field_class *in_content_fc =
+                       bt_field_class_option_borrow_field_class_const(
+                                       in_field_class);
+               const bt_field_path *in_selector_fp =
+                       bt_field_class_option_borrow_selector_field_path_const(
+                               in_field_class);
+               bt_field_class *out_selector_fc = NULL;
+               bt_field_class *out_content_fc;
+               int ret;
+
+               out_content_fc = create_field_class_copy_internal(
+                               md_maps, in_content_fc);
+               if (!out_content_fc) {
+                       BT_COMP_LOGE_STR("Cannot copy option's content field class.");
+                       goto error;
+               }
+
+               ret = copy_field_class_content_internal(md_maps,
+                       in_content_fc, out_content_fc);
+               if (ret) {
+                       BT_COMP_LOGE_STR("Error copying content of option's "
+                               "content field class");
+                       goto error;
+               }
+
+               if (in_selector_fp) {
+                       const bt_field_class *in_selector_fc =
+                               resolve_field_path_to_field_class(
+                                       in_selector_fp, md_maps);
+
+                       BT_ASSERT(in_selector_fc);
+                       out_selector_fc = g_hash_table_lookup(
+                               md_maps->field_class_map, in_selector_fc);
+                       BT_ASSERT(out_selector_fc);
+               }
+
+               out_field_class = bt_field_class_option_create(
+                               md_maps->output_trace_class,
+                               out_content_fc, out_selector_fc);
+               break;
+       }
        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:
@@ -759,6 +830,10 @@ int copy_field_class_content_internal(
                ret = field_class_dynamic_array_copy(md_maps,
                                in_field_class, out_field_class);
                break;
+       case BT_FIELD_CLASS_TYPE_OPTION:
+               ret = field_class_option_copy(md_maps,
+                               in_field_class, out_field_class);
+               break;
        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:
This page took 0.027719 seconds and 4 git commands to generate.