X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fplugins%2Flttng-utils%2Fdebug-info%2Ftrace-ir-metadata-field-class-copy.c;h=c3f80a941ff64817d601859fdd21c0376941b34a;hb=d24d56638469189904fb6ddbb3c725817b3e9417;hp=f7cab92fe005249b6f1f5a75a3b72b22a34f7383;hpb=350ad6c1c5f45a4e90c33e3c1354125c209bbf02;p=babeltrace.git diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c index f7cab92f..c3f80a94 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c +++ b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c @@ -24,8 +24,10 @@ * SOFTWARE. */ +#define BT_COMP_LOG_SELF_COMP (md_maps->self_comp) +#define BT_LOG_OUTPUT_LEVEL (md_maps->log_level) #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/TRACE-IR-META-FC-COPY" -#include "logging.h" +#include "plugins/comp-logging.h" #include "common/assert.h" #include "common/common.h" @@ -41,14 +43,14 @@ * structures ultimately leading to a field class. */ static -const bt_field_class *walk_field_path(const bt_field_path *fp, - const bt_field_class *fc) +const bt_field_class *walk_field_path(struct trace_ir_metadata_maps *md_maps, + const bt_field_path *fp, const bt_field_class *fc) { uint64_t i, fp_item_count; const bt_field_class *curr_fc; BT_ASSERT(bt_field_class_get_type(fc) == BT_FIELD_CLASS_TYPE_STRUCTURE); - BT_LOGD("Walking field path on field class: fp-addr=%p, fc-addr=%p", + BT_COMP_LOGD("Walking field path on field class: fp-addr=%p, fc-addr=%p", fp, fc); fp_item_count = bt_field_path_get_item_count(fp); @@ -110,23 +112,27 @@ const bt_field_class *resolve_field_path_to_field_class(const bt_field_path *fp, const bt_field_class *fc; bt_scope fp_scope; - BT_LOGD("Resolving field path: fp-addr=%p", fp); + BT_COMP_LOGD("Resolving field path: fp-addr=%p", fp); fc_resolving_ctx = md_maps->fc_resolving_ctx; fp_scope = bt_field_path_get_root_scope(fp); switch (fp_scope) { case BT_SCOPE_PACKET_CONTEXT: - fc = walk_field_path(fp, fc_resolving_ctx->packet_context); + fc = walk_field_path(md_maps, fp, + fc_resolving_ctx->packet_context); break; case BT_SCOPE_EVENT_COMMON_CONTEXT: - fc = walk_field_path(fp, fc_resolving_ctx->event_common_context); + fc = walk_field_path(md_maps, fp, + fc_resolving_ctx->event_common_context); break; case BT_SCOPE_EVENT_SPECIFIC_CONTEXT: - fc = walk_field_path(fp, fc_resolving_ctx->event_specific_context); + fc = walk_field_path(md_maps, fp, + fc_resolving_ctx->event_specific_context); break; case BT_SCOPE_EVENT_PAYLOAD: - fc = walk_field_path(fp, fc_resolving_ctx->event_payload); + fc = walk_field_path(md_maps, fp, + fc_resolving_ctx->event_payload); break; default: abort(); @@ -151,13 +157,13 @@ int field_class_unsigned_integer_copy( const bt_field_class *in_field_class, bt_field_class *out_field_class) { - BT_LOGD("Copying content of unsigned integer field class: " + BT_COMP_LOGD("Copying content of unsigned integer field class: " "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); field_class_integer_set_props(in_field_class, out_field_class); - BT_LOGD("Copied content of unsigned integer field class: " + BT_COMP_LOGD("Copied content of unsigned integer field class: " "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); return 0; @@ -169,13 +175,13 @@ int field_class_signed_integer_copy( const bt_field_class *in_field_class, bt_field_class *out_field_class) { - BT_LOGD("Copying content of signed integer field class: " + BT_COMP_LOGD("Copying content of signed integer field class: " "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); field_class_integer_set_props(in_field_class, out_field_class); - BT_LOGD("Copied content of signed integer field class: " + BT_COMP_LOGD("Copied content of signed integer field class: " "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); return 0; @@ -190,7 +196,7 @@ int field_class_unsigned_enumeration_copy( uint64_t i, enum_mapping_count; int ret = 0; - BT_LOGD("Copying content of unsigned enumeration field class: " + BT_COMP_LOGD("Copying content of unsigned enumeration field class: " "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); @@ -222,20 +228,18 @@ int field_class_unsigned_enumeration_copy( */ for (range_index = 0; range_index < range_count; range_index++) { uint64_t lower, upper; - bt_field_class_status status; bt_field_class_unsigned_enumeration_mapping_get_range_by_index( u_mapping, range_index, &lower, &upper); - BT_LOGD("Copying range in enumeration field class: " + BT_COMP_LOGD("Copying range in enumeration field class: " "label=%s, lower=%"PRId64", upper=%"PRId64, label, lower, upper); /* Add the label and its range to the copy field class. */ - status = bt_field_class_unsigned_enumeration_map_range( - out_field_class, label, lower, upper); - - if (status != BT_FIELD_CLASS_STATUS_OK) { - BT_LOGE_STR("Failed to add range to unsigned " + if (bt_field_class_unsigned_enumeration_map_range( + out_field_class, label, lower, upper) != + BT_FIELD_CLASS_ENUMERATION_MAP_RANGE_STATUS_OK) { + BT_COMP_LOGE_STR("Failed to add range to unsigned " "enumeration."); BT_FIELD_CLASS_PUT_REF_AND_RESET(out_field_class); ret = -1; @@ -244,7 +248,7 @@ int field_class_unsigned_enumeration_copy( } } - BT_LOGD("Copied content of unsigned enumeration field class: " + BT_COMP_LOGD("Copied content of unsigned enumeration field class: " "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); @@ -261,7 +265,7 @@ int field_class_signed_enumeration_copy( uint64_t i, enum_mapping_count; int ret = 0; - BT_LOGD("Copying content of signed enumeration field class: " + BT_COMP_LOGD("Copying content of signed enumeration field class: " "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); @@ -294,19 +298,18 @@ int field_class_signed_enumeration_copy( */ for (range_index = 0; range_index < range_count; range_index++) { int64_t lower, upper; - bt_field_class_status status; bt_field_class_signed_enumeration_mapping_get_range_by_index( i_mapping, range_index, &lower, &upper); - BT_LOGD("Copying range in enumeration field class: " + BT_COMP_LOGD("Copying range in enumeration field class: " "label=%s, lower=%"PRId64", upper=%"PRId64, label, lower, upper); /* Add the label and its range to the copy field class. */ - status = bt_field_class_signed_enumeration_map_range( - out_field_class, label, lower, upper); - if (status != BT_FIELD_CLASS_STATUS_OK) { - BT_LOGE_STR("Failed to add range to signed " + if (bt_field_class_signed_enumeration_map_range( + out_field_class, label, lower, upper) != + BT_FIELD_CLASS_ENUMERATION_MAP_RANGE_STATUS_OK) { + BT_COMP_LOGE_STR("Failed to add range to signed " "enumeration."); BT_FIELD_CLASS_PUT_REF_AND_RESET(out_field_class); ret = -1; @@ -315,7 +318,7 @@ int field_class_signed_enumeration_copy( } } - BT_LOGD("Copied content of signed enumeration field class: " + BT_COMP_LOGD("Copied content of signed enumeration field class: " "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); @@ -329,14 +332,14 @@ int field_class_real_copy( const bt_field_class *in_field_class, bt_field_class *out_field_class) { - BT_LOGD("Copying content of real field class: " + BT_COMP_LOGD("Copying content of real field class: " "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); bt_field_class_real_set_is_single_precision(out_field_class, bt_field_class_real_is_single_precision(in_field_class)); - BT_LOGD("Copied content real field class: in-fc-addr=%p, " + BT_COMP_LOGD("Copied content real field class: in-fc-addr=%p, " "out-fc-addr=%p", in_field_class, out_field_class); return 0; @@ -349,10 +352,9 @@ int field_class_structure_copy( bt_field_class *out_field_class) { uint64_t i, struct_member_count; - bt_field_class_status status; int ret = 0; - BT_LOGD("Copying content of structure field class: " + BT_COMP_LOGD("Copying content of structure field class: " "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); /* Get the number of member in that struct. */ @@ -371,7 +373,7 @@ int field_class_structure_copy( member_fc = bt_field_class_structure_member_borrow_field_class_const( member); member_name = bt_field_class_structure_member_get_name(member); - BT_LOGD("Copying structure field class's field: " + BT_COMP_LOGD("Copying structure field class's field: " "index=%" PRId64 ", " "member-fc-addr=%p, field-name=\"%s\"", i, member_fc, member_name); @@ -379,7 +381,7 @@ int field_class_structure_copy( out_member_field_class = create_field_class_copy(md_maps, member_fc); if (!out_member_field_class) { - BT_LOGE("Cannot copy structure field class's field: " + BT_COMP_LOGE("Cannot copy structure field class's field: " "index=%" PRId64 ", " "field-fc-addr=%p, field-name=\"%s\"", i, member_fc, member_name); @@ -392,10 +394,10 @@ int field_class_structure_copy( goto error; } - status = bt_field_class_structure_append_member(out_field_class, - member_name, out_member_field_class); - if (status != BT_FIELD_CLASS_STATUS_OK) { - BT_LOGE("Cannot append structure field class's field: " + if (bt_field_class_structure_append_member(out_field_class, + member_name, out_member_field_class) != + BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK) { + BT_COMP_LOGE("Cannot append structure field class's field: " "index=%" PRId64 ", " "field-fc-addr=%p, field-name=\"%s\"", i, member_fc, member_name); @@ -405,7 +407,7 @@ int field_class_structure_copy( } } - BT_LOGD("Copied structure field class: original-fc-addr=%p, copy-fc-addr=%p", + BT_COMP_LOGD("Copied structure field class: original-fc-addr=%p, copy-fc-addr=%p", in_field_class, out_field_class); error: @@ -424,7 +426,7 @@ int field_class_variant_copy( const bt_field_class *tag_fc; int ret = 0; - BT_LOGD("Copying content of variant field class: " + BT_COMP_LOGD("Copying content of variant field class: " "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); @@ -437,7 +439,7 @@ int field_class_variant_copy( out_tag_field_class = g_hash_table_lookup( md_maps->field_class_map, tag_fc); if (!out_tag_field_class) { - BT_LOGE_STR("Cannot find the tag field class."); + BT_COMP_LOGE_STR("Cannot find the tag field class."); ret = -1; goto error; } @@ -451,7 +453,6 @@ int field_class_variant_copy( const bt_field_class *option_fc; const char *option_name; bt_field_class *out_option_field_class; - bt_field_class_status status; const bt_field_class_variant_option *option; option = bt_field_class_variant_borrow_option_by_index_const( @@ -462,30 +463,30 @@ int field_class_variant_copy( out_option_field_class = create_field_class_copy_internal( md_maps, option_fc); if (!out_option_field_class) { - BT_LOGE_STR("Cannot copy field class."); + BT_COMP_LOGE_STR("Cannot copy field class."); ret = -1; goto error; } ret = copy_field_class_content_internal(md_maps, option_fc, out_option_field_class); if (ret) { - BT_LOGE_STR("Error copying content of option variant " + BT_COMP_LOGE_STR("Error copying content of option variant " "field class'"); goto error; } - status = bt_field_class_variant_append_option( + if (bt_field_class_variant_append_option( out_field_class, option_name, - out_option_field_class); - if (status != BT_FIELD_CLASS_STATUS_OK) { - BT_LOGE_STR("Cannot append option to variant field class'"); + out_option_field_class) != + BT_FIELD_CLASS_VARIANT_APPEND_OPTION_STATUS_OK) { + BT_COMP_LOGE_STR("Cannot append option to variant field class'"); BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class); ret = -1; goto error; } } - BT_LOGD("Copied content of variant field class: in-fc-addr=%p, " + BT_COMP_LOGD("Copied content of variant field class: in-fc-addr=%p, " "out-fc-addr=%p", in_field_class, out_field_class); error: @@ -498,13 +499,13 @@ int field_class_static_array_copy( const bt_field_class *in_field_class, bt_field_class *out_field_class) { - BT_LOGD("Copying content of static array field class: in-fc-addr=%p, " + BT_COMP_LOGD("Copying content of static array 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_LOGD("Copied content of static array field class: in-fc-addr=%p, " + BT_COMP_LOGD("Copied content of static array field class: in-fc-addr=%p, " "out-fc-addr=%p", in_field_class, out_field_class); return 0; @@ -518,11 +519,10 @@ int field_class_dynamic_array_copy( { const bt_field_class *len_fc; const bt_field_path *len_fp; - bt_field_class_status status; bt_field_class *out_len_field_class; int ret = 0; - BT_LOGD("Copying content of dynamic array field class: " + BT_COMP_LOGD("Copying content of dynamic array field class: " "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); @@ -530,23 +530,23 @@ int field_class_dynamic_array_copy( in_field_class); if (len_fp) { - BT_LOGD("Copying dynamic array length field class using " + BT_COMP_LOGD("Copying dynamic array length field class using " "field path: in-len-fp=%p", len_fp); len_fc = resolve_field_path_to_field_class( len_fp, md_maps); out_len_field_class = g_hash_table_lookup( md_maps->field_class_map, len_fc); if (!out_len_field_class) { - BT_LOGE_STR("Cannot find the output matching length" + BT_COMP_LOGE_STR("Cannot find the output matching length" "field class."); ret = -1; goto error; } - status = bt_field_class_dynamic_array_set_length_field_class( - out_field_class, out_len_field_class); - if (status != BT_FIELD_CLASS_STATUS_OK) { - BT_LOGE_STR("Cannot set dynamic array field class' " + if (bt_field_class_dynamic_array_set_length_field_class( + out_field_class, out_len_field_class) != + BT_FIELD_CLASS_DYNAMIC_ARRAY_SET_LENGTH_FIELD_CLASS_STATUS_OK) { + BT_COMP_LOGE_STR("Cannot set dynamic array field class' " "length field class."); BT_FIELD_CLASS_PUT_REF_AND_RESET(out_len_field_class); ret = -1; @@ -554,7 +554,7 @@ int field_class_dynamic_array_copy( } } - BT_LOGD("Copied dynamic array field class: in-fc-addr=%p, " + BT_COMP_LOGD("Copied dynamic array field class: in-fc-addr=%p, " "out-fc-addr=%p", in_field_class, out_field_class); error: @@ -566,13 +566,13 @@ int field_class_string_copy(struct trace_ir_metadata_maps *md_maps, const bt_field_class *in_field_class, bt_field_class *out_field_class) { - BT_LOGD("Copying content of string field class: in-fc-addr=%p, " + BT_COMP_LOGD("Copying content of string 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_LOGD("Copied content of string field class: in-fc-addr=%p, " + BT_COMP_LOGD("Copied content of string field class: in-fc-addr=%p, " "out-fc-addr=%p", in_field_class, out_field_class); return 0; @@ -586,7 +586,7 @@ bt_field_class *copy_field_class_array_element(struct trace_ir_metadata_maps *md bt_field_class *out_elem_fc = create_field_class_copy_internal(md_maps, in_elem_fc); if (!out_elem_fc) { - BT_LOGE("Error creating output elem field class " + BT_COMP_LOGE("Error creating output elem field class " "from input elem field class for static array: " "in-fc-addr=%p", in_elem_fc); goto error; @@ -594,7 +594,7 @@ bt_field_class *copy_field_class_array_element(struct trace_ir_metadata_maps *md ret = copy_field_class_content_internal(md_maps, in_elem_fc, out_elem_fc); if (ret) { - BT_LOGE("Error creating output elem field class " + BT_COMP_LOGE("Error creating output elem field class " "from input elem field class for static array: " "in-fc-addr=%p", in_elem_fc); BT_FIELD_CLASS_PUT_REF_AND_RESET(out_elem_fc); @@ -611,7 +611,7 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps * { bt_field_class *out_field_class = NULL; - BT_LOGD("Creating bare field class based on field class: in-fc-addr=%p", + BT_COMP_LOGD("Creating bare field class based on field class: in-fc-addr=%p", in_field_class); switch(bt_field_class_get_type(in_field_class)) { @@ -699,10 +699,10 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps * error: if(out_field_class){ - BT_LOGD("Created bare field class based on field class: in-fc-addr=%p, " + BT_COMP_LOGD("Created bare field class based on field class: in-fc-addr=%p, " "out-fc-addr=%p", in_field_class, out_field_class); } else { - BT_LOGE("Error creating output field class from input field " + BT_COMP_LOGE("Error creating output field class from input field " "class: in-fc-addr=%p", in_field_class); }