Move to kernel style SPDX license identifiers
[babeltrace.git] / src / plugins / lttng-utils / debug-info / debug-info.c
index 9f1be4bf35ae5645d133c68f0d4e809f787d07d6..fd47e3dfc80cad57c270563bbb6e45e654370383 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Babeltrace - Debug Information State Tracker
+ * SPDX-License-Identifier: MIT
  *
  * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
  * Copyright (c) 2015 Philippe Proulx <pproulx@efficios.com>
@@ -7,23 +7,7 @@
  * Copyright (c) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  * Copyright (c) 2019 Francis Deslauriers <francis.deslauriers@efficios.com>
  *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * Babeltrace - Debug Information State Tracker
  */
 
 #define BT_COMP_LOG_SELF_COMP self_comp
@@ -31,6 +15,8 @@
 #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO"
 #include "logging/comp-logging.h"
 
+#include <stdbool.h>
+
 #include <glib.h>
 
 #include "common/assert.h"
@@ -60,6 +46,7 @@
 struct debug_info_component {
        bt_logging_level log_level;
        bt_self_component *self_comp;
+       bt_self_component_filter *self_comp_filter;
        gchar *arg_debug_dir;
        gchar *arg_debug_info_field_name;
        gchar *arg_target_prefix;
@@ -71,7 +58,7 @@ struct debug_info_msg_iter {
        struct debug_info_component *debug_info_component;
        bt_self_message_iterator *input_iterator;
        bt_self_component *self_comp;
-       bt_self_component_port_input_message_iterator *msg_iter;
+       bt_message_iterator *msg_iter;
 
        struct trace_ir_maps *ir_maps;
        /* in_trace -> debug_info_mapping. */
@@ -178,7 +165,11 @@ struct debug_info_source *debug_info_source_create_from_bin(
        int ret;
        struct debug_info_source *debug_info_src = NULL;
        struct source_location *src_loc = NULL;
-       bt_logging_level log_level = bin->log_level;
+       bt_logging_level log_level;
+
+       BT_ASSERT(bin);
+
+       log_level = bin->log_level;
 
        debug_info_src = g_new0(struct debug_info_source, 1);
 
@@ -205,7 +196,8 @@ struct debug_info_source *debug_info_source_create_from_bin(
                debug_info_src->line_no =
                        g_strdup_printf("%"PRId64, src_loc->line_no);
                if (!debug_info_src->line_no) {
-                       BT_COMP_LOGE("Error occured when setting line_no field.");
+                       BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+                               "Error occurred when setting `line_no` field.");
                        goto error;
                }
 
@@ -335,7 +327,7 @@ const bt_field *event_borrow_payload_field(const bt_event *event,
        const bt_field *event_payload, *field;
 
        event_payload =  bt_event_borrow_payload_field_const(event);
-       BT_ASSERT(event_payload);
+       BT_ASSERT_DBG(event_payload);
 
        field = bt_field_structure_borrow_member_field_by_name_const(
                event_payload, field_name);
@@ -369,7 +361,7 @@ void event_get_common_context_signed_integer_field_value(
 }
 
 static inline
-int event_get_payload_build_id_length(const bt_event *event,
+void event_get_payload_build_id_length(const bt_event *event,
                const char *field_name, uint64_t *build_id_len)
 {
        const bt_field *build_id_field;
@@ -388,20 +380,15 @@ int event_get_payload_build_id_length(const bt_event *event,
                BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER);
 
        *build_id_len = bt_field_array_get_length(build_id_field);
-
-       return 0;
 }
 
 static inline
-int event_get_payload_build_id_value(const bt_event *event,
+void event_get_payload_build_id_value(const bt_event *event,
                const char *field_name, uint8_t *build_id)
 {
        const bt_field *curr_field, *build_id_field;
        const bt_field_class *build_id_field_class;
        uint64_t i, build_id_len;
-       int ret;
-
-       ret = 0;
 
        build_id_field = event_borrow_payload_field(event, field_name);
        build_id_field_class = bt_field_borrow_class_const(build_id_field);
@@ -419,12 +406,10 @@ int event_get_payload_build_id_value(const bt_event *event,
 
        for (i = 0; i < build_id_len; i++) {
                curr_field = bt_field_array_borrow_element_field_by_index_const(
-                               build_id_field, i);
+                       build_id_field, i);
 
                build_id[i] = bt_field_integer_unsigned_get_value(curr_field);
        }
-
-       return ret;
 }
 
 static
@@ -630,7 +615,8 @@ void handle_event_statedump_build_id(struct debug_info *debug_info,
                 */
                goto end;
        }
-       ret = event_get_payload_build_id_length(event, BUILD_ID_FIELD_NAME,
+
+       event_get_payload_build_id_length(event, BUILD_ID_FIELD_NAME,
                &build_id_len);
 
        build_id = g_new0(uint8_t, build_id_len);
@@ -638,11 +624,7 @@ void handle_event_statedump_build_id(struct debug_info *debug_info,
                goto end;
        }
 
-       ret = event_get_payload_build_id_value(event, BUILD_ID_FIELD_NAME,
-               build_id);
-       if (ret) {
-               goto end;
-       }
+       event_get_payload_build_id_value(event, BUILD_ID_FIELD_NAME, build_id);
 
        ret = bin_info_set_build_id(bin, build_id, build_id_len);
        if (ret) {
@@ -861,6 +843,7 @@ end:
        return;
 }
 
+static
 void trace_debug_info_remove_func(const bt_trace *in_trace, void *data)
 {
        struct debug_info_msg_iter *debug_it = data;
@@ -960,7 +943,7 @@ void fill_debug_info_bin_field(struct debug_info_source *dbg_info_src,
        bt_field_string_set_value_status set_status;
        bt_field_string_append_status append_status;
 
-       BT_ASSERT(bt_field_get_class_type(curr_field) ==
+       BT_ASSERT_DBG(bt_field_get_class_type(curr_field) ==
                BT_FIELD_CLASS_TYPE_STRING);
 
        if (dbg_info_src) {
@@ -972,7 +955,7 @@ void fill_debug_info_bin_field(struct debug_info_source *dbg_info_src,
                                dbg_info_src->short_bin_path);
                }
                if (set_status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
-                       BT_COMP_LOGE("Cannot set path component of \"bin\" "
+                       BT_COMP_LOGE("Cannot set path component of `bin` "
                                "curr_field field's value: str-fc-addr=%p",
                                curr_field);
                        bt_current_thread_clear_error();
@@ -981,7 +964,7 @@ void fill_debug_info_bin_field(struct debug_info_source *dbg_info_src,
                append_status = bt_field_string_append(curr_field,
                        dbg_info_src->bin_loc);
                if (append_status != BT_FIELD_STRING_APPEND_STATUS_OK) {
-                       BT_COMP_LOGE("Cannot set bin location component of \"bin\" "
+                       BT_COMP_LOGE("Cannot set bin location component of `bin` "
                                "curr_field field's value: str-fc-addr=%p",
                                curr_field);
                        bt_current_thread_clear_error();
@@ -989,7 +972,7 @@ void fill_debug_info_bin_field(struct debug_info_source *dbg_info_src,
        } else {
                set_status = bt_field_string_set_value(curr_field, "");
                if (set_status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
-                       BT_COMP_LOGE("Cannot set \"bin\" curr_field field's value: "
+                       BT_COMP_LOGE("Cannot set `bin` curr_field field's value: "
                                "str-fc-addr=%p", curr_field);
                        bt_current_thread_clear_error();
                }
@@ -1003,7 +986,7 @@ void fill_debug_info_func_field(struct debug_info_source *dbg_info_src,
 {
        bt_field_string_set_value_status status;
 
-       BT_ASSERT(bt_field_get_class_type(curr_field) ==
+       BT_ASSERT_DBG(bt_field_get_class_type(curr_field) ==
                        BT_FIELD_CLASS_TYPE_STRING);
        if (dbg_info_src && dbg_info_src->func) {
                status = bt_field_string_set_value(curr_field,
@@ -1012,7 +995,7 @@ void fill_debug_info_func_field(struct debug_info_source *dbg_info_src,
                status = bt_field_string_set_value(curr_field, "");
        }
        if (status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
-               BT_COMP_LOGE("Cannot set \"func\" curr_field field's value: "
+               BT_COMP_LOGE("Cannot set `func` curr_field field's value: "
                        "str-fc-addr=%p", curr_field);
                bt_current_thread_clear_error();
        }
@@ -1027,7 +1010,7 @@ void fill_debug_info_src_field(struct debug_info_source *dbg_info_src,
        bt_field_string_set_value_status set_status;
        bt_field_string_append_status append_status;
 
-       BT_ASSERT(bt_field_get_class_type(curr_field) ==
+       BT_ASSERT_DBG(bt_field_get_class_type(curr_field) ==
                BT_FIELD_CLASS_TYPE_STRING);
 
        if (dbg_info_src && dbg_info_src->src_path) {
@@ -1039,7 +1022,7 @@ void fill_debug_info_src_field(struct debug_info_source *dbg_info_src,
                                dbg_info_src->short_src_path);
                }
                if (set_status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
-                       BT_COMP_LOGE("Cannot set path component of \"src\" "
+                       BT_COMP_LOGE("Cannot set path component of `src` "
                                "curr_field field's value: str-fc-addr=%p",
                                curr_field);
                        bt_current_thread_clear_error();
@@ -1047,7 +1030,7 @@ void fill_debug_info_src_field(struct debug_info_source *dbg_info_src,
 
                append_status = bt_field_string_append(curr_field, ":");
                if (append_status != BT_FIELD_STRING_APPEND_STATUS_OK) {
-                       BT_COMP_LOGE("Cannot set colon component of \"src\" "
+                       BT_COMP_LOGE("Cannot set colon component of `src` "
                                "curr_field field's value: str-fc-addr=%p",
                                curr_field);
                        bt_current_thread_clear_error();
@@ -1056,7 +1039,7 @@ void fill_debug_info_src_field(struct debug_info_source *dbg_info_src,
                append_status = bt_field_string_append(curr_field,
                        dbg_info_src->line_no);
                if (append_status != BT_FIELD_STRING_APPEND_STATUS_OK) {
-                       BT_COMP_LOGE("Cannot set line number component of \"src\" "
+                       BT_COMP_LOGE("Cannot set line number component of `src` "
                                "curr_field field's value: str-fc-addr=%p",
                                curr_field);
                        bt_current_thread_clear_error();
@@ -1064,7 +1047,7 @@ void fill_debug_info_src_field(struct debug_info_source *dbg_info_src,
        } else {
                set_status = bt_field_string_set_value(curr_field, "");
                if (set_status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
-                       BT_COMP_LOGE("Cannot set \"src\" curr_field field's value: "
+                       BT_COMP_LOGE("Cannot set `src` curr_field field's value: "
                                "str-fc-addr=%p", curr_field);
                        bt_current_thread_clear_error();
                }
@@ -1078,7 +1061,7 @@ void fill_debug_info_field_empty(bt_field *debug_info_field,
        bt_field_string_set_value_status status;
        bt_field *bin_field, *func_field, *src_field;
 
-       BT_ASSERT(bt_field_get_class_type(debug_info_field) ==
+       BT_ASSERT_DBG(bt_field_get_class_type(debug_info_field) ==
                BT_FIELD_CLASS_TYPE_STRUCTURE);
 
        bin_field = bt_field_structure_borrow_member_field_by_name(
@@ -1088,30 +1071,30 @@ void fill_debug_info_field_empty(bt_field *debug_info_field,
        src_field = bt_field_structure_borrow_member_field_by_name(
                debug_info_field, "src");
 
-       BT_ASSERT(bt_field_get_class_type(bin_field) ==
+       BT_ASSERT_DBG(bt_field_get_class_type(bin_field) ==
                BT_FIELD_CLASS_TYPE_STRING);
-       BT_ASSERT(bt_field_get_class_type(func_field) ==
+       BT_ASSERT_DBG(bt_field_get_class_type(func_field) ==
                BT_FIELD_CLASS_TYPE_STRING);
-       BT_ASSERT(bt_field_get_class_type(src_field) ==
+       BT_ASSERT_DBG(bt_field_get_class_type(src_field) ==
                BT_FIELD_CLASS_TYPE_STRING);
 
        status = bt_field_string_set_value(bin_field, "");
        if (status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
-               BT_COMP_LOGE("Cannot set \"bin\" bin_field field's value: "
+               BT_COMP_LOGE("Cannot set `bin` field's value: "
                        "str-fc-addr=%p", bin_field);
                bt_current_thread_clear_error();
        }
 
        status = bt_field_string_set_value(func_field, "");
        if (status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
-               BT_COMP_LOGE("Cannot set \"func\" func_field field's value: "
+               BT_COMP_LOGE("Cannot set `func` field's value: "
                        "str-fc-addr=%p", func_field);
                bt_current_thread_clear_error();
        }
 
        status = bt_field_string_set_value(src_field, "");
        if (status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
-               BT_COMP_LOGE("Cannot set \"src\" src_field field's value: "
+               BT_COMP_LOGE("Cannot set `src` field's value: "
                        "str-fc-addr=%p", src_field);
                bt_current_thread_clear_error();
        }
@@ -1123,12 +1106,13 @@ void fill_debug_info_field(struct debug_info *debug_info, int64_t vpid,
        struct debug_info_source *dbg_info_src;
        const bt_field_class *debug_info_fc;
 
-       BT_ASSERT(bt_field_get_class_type(debug_info_field) ==
+       BT_ASSERT_DBG(bt_field_get_class_type(debug_info_field) ==
                BT_FIELD_CLASS_TYPE_STRUCTURE);
 
        debug_info_fc = bt_field_borrow_class_const(debug_info_field);
 
-       BT_ASSERT(bt_field_class_structure_get_member_count(debug_info_fc) == 3);
+       BT_ASSERT_DBG(bt_field_class_structure_get_member_count(
+               debug_info_fc) == 3);
 
        dbg_info_src = debug_info_query(debug_info, vpid, ip);
 
@@ -1287,14 +1271,14 @@ bt_message *handle_event_message(struct debug_info_msg_iter *debug_it,
                out_event_class = trace_ir_mapping_create_new_mapped_event_class(
                        debug_it->ir_maps, in_event_class);
        }
-       BT_ASSERT(out_event_class);
+       BT_ASSERT_DBG(out_event_class);
 
        /* Borrow the input stream. */
        in_stream = bt_event_borrow_stream_const(in_event);
-       BT_ASSERT(in_stream);
+       BT_ASSERT_DBG(in_stream);
        out_stream = trace_ir_mapping_borrow_mapped_stream(debug_it->ir_maps,
                in_stream);
-       BT_ASSERT(in_stream);
+       BT_ASSERT_DBG(in_stream);
 
        /* Borrow the input and output packets. */
        in_packet = bt_event_borrow_packet_const(in_event);
@@ -1337,14 +1321,21 @@ bt_message *handle_event_message(struct debug_info_msg_iter *debug_it,
        }
 
        if (!out_message) {
-               BT_COMP_LOGE("Error creating output event message.");
+               BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+                       "Error creating output event message.");
                goto error;
        }
 
        out_event = bt_message_event_borrow_event(out_message);
 
        /* Copy the original fields to the output event. */
-       copy_event_content(in_event, out_event, log_level, self_comp);
+       if (copy_event_content(in_event, out_event, log_level, self_comp) !=
+                       DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK) {
+               BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+                       "Error copying event message content output event message: "
+                       "in-ev-addr=%p, out-ev-addr=%p", in_event, out_event);
+               goto error;
+       }
 
        /*
         * Try to set the debug-info fields based on debug information that is
@@ -1352,7 +1343,11 @@ bt_message *handle_event_message(struct debug_info_msg_iter *debug_it,
         */
        fill_debug_info_event_if_needed(debug_it, in_event, out_event);
 
+       goto end;
+
 error:
+       BT_MESSAGE_PUT_REF_AND_RESET(out_message);
+end:
        return out_message;
 }
 
@@ -1381,7 +1376,8 @@ bt_message *handle_stream_begin_message(struct debug_info_msg_iter *debug_it,
        out_message = bt_message_stream_beginning_create(
                debug_it->input_iterator, out_stream);
        if (!out_message) {
-               BT_COMP_LOGE("Error creating output stream beginning message: "
+               BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+                       "Error creating output stream beginning message: "
                        "out-s-addr=%p", out_stream);
        }
 error:
@@ -1409,8 +1405,9 @@ bt_message *handle_stream_end_message(struct debug_info_msg_iter *debug_it,
        out_message = bt_message_stream_end_create(debug_it->input_iterator,
                out_stream);
        if (!out_message) {
-               BT_COMP_LOGE("Error creating output stream end message: out-s-addr=%p",
-                               out_stream);
+               BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+                       "Error creating output stream end message: "
+                       "out-s-addr=%p", out_stream);
                goto end;
        }
 
@@ -1463,7 +1460,8 @@ bt_message *handle_packet_begin_message(struct debug_info_msg_iter *debug_it,
                        debug_it->input_iterator, out_packet);
        }
        if (!out_message) {
-               BT_COMP_LOGE("Error creating output packet beginning message: "
+               BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+                       "Error creating output packet beginning message: "
                        "out-p-addr=%p", out_packet);
        }
 
@@ -1507,7 +1505,8 @@ bt_message *handle_packet_end_message(struct debug_info_msg_iter *debug_it,
        }
 
        if (!out_message) {
-               BT_COMP_LOGE("Error creating output packet end message: "
+               BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+                       "Error creating output packet end message: "
                        "out-p-addr=%p", out_packet);
                goto end;
        }
@@ -1573,7 +1572,8 @@ bt_message *handle_discarded_events_message(struct debug_info_msg_iter *debug_it
                        debug_it->input_iterator, out_stream);
        }
        if (!out_message) {
-               BT_COMP_LOGE("Error creating output discarded events message: "
+               BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+                       "Error creating output discarded events message: "
                        "out-s-addr=%p", out_stream);
                goto error;
        }
@@ -1633,7 +1633,8 @@ bt_message *handle_discarded_packets_message(struct debug_info_msg_iter *debug_i
                        debug_it->input_iterator, out_stream);
        }
        if (!out_message) {
-               BT_COMP_LOGE("Error creating output discarded packet message: "
+               BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+                       "Error creating output discarded packet message: "
                        "out-s-addr=%p", out_stream);
                goto error;
        }
@@ -1681,13 +1682,14 @@ const bt_message *handle_message(struct debug_info_msg_iter *debug_it,
                out_message = handle_discarded_packets_message(debug_it, in_message);
                break;
        default:
-               abort();
+               bt_common_abort();
                break;
        }
 
        return out_message;
 }
 
+static
 struct bt_param_validation_map_value_entry_descr debug_info_params[] = {
        { "debug-info-field-name", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_STRING } },
        { "debug-info-dir", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_STRING } },
@@ -1783,12 +1785,14 @@ bt_component_class_initialize_method_status debug_info_comp_init(
 
        debug_info_comp = g_new0(struct debug_info_component, 1);
        if (!debug_info_comp) {
-               BT_COMP_LOGE_STR("Failed to allocate one debug_info component.");
+               BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+                       "Failed to allocate one debug_info component.");
                goto error;
        }
 
        debug_info_comp->log_level = log_level;
        debug_info_comp->self_comp = self_comp;
+       debug_info_comp->self_comp_filter = self_comp_flt;
        bt_self_component_set_data(self_comp, debug_info_comp);
 
        add_port_status = bt_self_component_filter_add_input_port(
@@ -1807,7 +1811,8 @@ bt_component_class_initialize_method_status debug_info_comp_init(
 
        status = init_from_params(debug_info_comp, params);
        if (status != BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK) {
-               BT_COMP_LOGE("Cannot configure debug_info component: "
+               BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+                       "Cannot configure debug_info component: "
                        "debug_info-comp-addr=%p, params-addr=%p",
                        debug_info_comp, params);
                goto error;
@@ -1843,37 +1848,37 @@ void debug_info_comp_finalize(bt_self_component_filter *self_comp_flt)
 }
 
 BT_HIDDEN
-bt_component_class_message_iterator_next_method_status debug_info_msg_iter_next(
+bt_message_iterator_class_next_method_status debug_info_msg_iter_next(
                bt_self_message_iterator *self_msg_iter,
                const bt_message_array_const msgs, uint64_t capacity,
                uint64_t *count)
 {
-       bt_self_component_port_input_message_iterator *upstream_iterator = NULL;
+       bt_message_iterator *upstream_iterator = NULL;
        bt_message_iterator_next_status upstream_iterator_ret_status;
        struct debug_info_msg_iter *debug_info_msg_iter;
        struct debug_info_component *debug_info = NULL;
-       bt_component_class_message_iterator_next_method_status status;
+       bt_message_iterator_class_next_method_status status;
        bt_self_component *self_comp = NULL;
        bt_message_array_const input_msgs;
        const bt_message *out_message;
        uint64_t curr_msg_idx, i;
 
-       status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
+       status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
 
        self_comp = bt_self_message_iterator_borrow_component(self_msg_iter);
-       BT_ASSERT(self_comp);
+       BT_ASSERT_DBG(self_comp);
 
        debug_info = bt_self_component_get_data(self_comp);
-       BT_ASSERT(debug_info);
+       BT_ASSERT_DBG(debug_info);
 
        debug_info_msg_iter = bt_self_message_iterator_get_data(self_msg_iter);
-       BT_ASSERT(debug_info_msg_iter);
+       BT_ASSERT_DBG(debug_info_msg_iter);
 
        upstream_iterator = debug_info_msg_iter->msg_iter;
-       BT_ASSERT(upstream_iterator);
+       BT_ASSERT_DBG(upstream_iterator);
 
        upstream_iterator_ret_status =
-               bt_self_component_port_input_message_iterator_next(
+               bt_message_iterator_next(
                        upstream_iterator, &input_msgs, count);
        if (upstream_iterator_ret_status !=
                        BT_MESSAGE_ITERATOR_NEXT_STATUS_OK) {
@@ -1890,7 +1895,7 @@ bt_component_class_message_iterator_next_method_status debug_info_msg_iter_next(
         * There should never be more received messages than the capacity we
         * provided.
         */
-       BT_ASSERT(*count <= capacity);
+       BT_ASSERT_DBG(*count <= capacity);
 
        for (curr_msg_idx = 0; curr_msg_idx < *count; curr_msg_idx++) {
                out_message = handle_message(debug_info_msg_iter,
@@ -1926,7 +1931,7 @@ handle_msg_error:
                bt_message_put_ref(input_msgs[i]);
        }
 
-       status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR;
+       status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR;
 
 end:
        return status;
@@ -1940,7 +1945,7 @@ void debug_info_msg_iter_destroy(struct debug_info_msg_iter *debug_info_msg_iter
        }
 
        if (debug_info_msg_iter->msg_iter) {
-               bt_self_component_port_input_message_iterator_put_ref(
+               bt_message_iterator_put_ref(
                        debug_info_msg_iter->msg_iter);
        }
 
@@ -1960,51 +1965,54 @@ end:
 }
 
 BT_HIDDEN
-bt_component_class_message_iterator_initialize_method_status debug_info_msg_iter_init(
+bt_message_iterator_class_initialize_method_status debug_info_msg_iter_init(
                bt_self_message_iterator *self_msg_iter,
                bt_self_message_iterator_configuration *config,
-               bt_self_component_filter *self_comp_flt,
                bt_self_component_port_output *self_port)
 {
-       bt_component_class_message_iterator_initialize_method_status status;
-       bt_self_component_port_input_message_iterator_create_from_message_iterator_status
+       bt_message_iterator_class_initialize_method_status status;
+       bt_message_iterator_create_from_message_iterator_status
                msg_iter_status;
        struct bt_self_component_port_input *input_port = NULL;
-       bt_self_component_port_input_message_iterator *upstream_iterator = NULL;
+       bt_message_iterator *upstream_iterator = NULL;
        struct debug_info_msg_iter *debug_info_msg_iter = NULL;
        gchar *debug_info_field_name;
        int ret;
        bt_self_component *self_comp =
-               bt_self_component_filter_as_self_component(self_comp_flt);
+               bt_self_message_iterator_borrow_component(self_msg_iter);
        bt_logging_level log_level = bt_component_get_logging_level(
                bt_self_component_as_component(self_comp));
 
-       /* Borrow the upstream input port. */
-       input_port = bt_self_component_filter_borrow_input_port_by_name(
-               self_comp_flt, "in");
-       if (!input_port) {
-               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_ERROR;
-               goto error;
-       }
-
        debug_info_msg_iter = g_new0(struct debug_info_msg_iter, 1);
        if (!debug_info_msg_iter) {
-               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+               status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
                goto error;
        }
 
        debug_info_msg_iter->log_level = log_level;
        debug_info_msg_iter->self_comp = self_comp;
 
+       debug_info_msg_iter->debug_info_component =
+               bt_self_component_get_data(self_comp);
+
+       /* Borrow the upstream input port. */
+       input_port = bt_self_component_filter_borrow_input_port_by_name(
+                       debug_info_msg_iter->debug_info_component->self_comp_filter,
+                       "in");
+       if (!input_port) {
+               status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
+               goto error;
+       }
+
        /* Create an iterator on the upstream component. */
-       msg_iter_status = bt_self_component_port_input_message_iterator_create_from_message_iterator(
+       msg_iter_status = bt_message_iterator_create_from_message_iterator(
                self_msg_iter, input_port, &upstream_iterator);
-       if (msg_iter_status != BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_CREATE_FROM_MESSAGE_ITERATOR_STATUS_OK) {
+       if (msg_iter_status != BT_MESSAGE_ITERATOR_CREATE_FROM_MESSAGE_ITERATOR_STATUS_OK) {
                status = (int) msg_iter_status;
                goto error;
        }
 
-       BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_MOVE_REF(
+       BT_MESSAGE_ITERATOR_MOVE_REF(
                debug_info_msg_iter->msg_iter, upstream_iterator);
 
        /* Create hashtable that will contain debug info mapping. */
@@ -2012,37 +2020,34 @@ bt_component_class_message_iterator_initialize_method_status debug_info_msg_iter
                g_direct_hash, g_direct_equal, (GDestroyNotify) NULL,
                (GDestroyNotify) debug_info_destroy);
        if (!debug_info_msg_iter->debug_info_map) {
-               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+               status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
                goto error;
        }
 
-       debug_info_msg_iter->debug_info_component =
-               bt_self_component_get_data(self_comp);
-
        debug_info_field_name =
                debug_info_msg_iter->debug_info_component->arg_debug_info_field_name;
 
        debug_info_msg_iter->ir_maps = trace_ir_maps_create(self_comp,
                debug_info_field_name, log_level);
        if (!debug_info_msg_iter->ir_maps) {
-               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+               status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
                goto error;
        }
 
        ret = bt_fd_cache_init(&debug_info_msg_iter->fd_cache, log_level);
        if (ret) {
-               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+               status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
                goto error;
        }
 
        bt_self_message_iterator_configuration_set_can_seek_forward(config,
-               bt_self_component_port_input_message_iterator_can_seek_forward(
+               bt_message_iterator_can_seek_forward(
                        debug_info_msg_iter->msg_iter));
 
        bt_self_message_iterator_set_data(self_msg_iter, debug_info_msg_iter);
        debug_info_msg_iter->input_iterator = self_msg_iter;
 
-       status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK;
+       status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
        goto end;
 
 error:
@@ -2053,7 +2058,7 @@ end:
 }
 
 BT_HIDDEN
-bt_component_class_message_iterator_can_seek_beginning_method_status
+bt_message_iterator_class_can_seek_beginning_method_status
 debug_info_msg_iter_can_seek_beginning(bt_self_message_iterator *self_msg_iter,
                bt_bool *can_seek)
 {
@@ -2061,24 +2066,24 @@ debug_info_msg_iter_can_seek_beginning(bt_self_message_iterator *self_msg_iter,
                bt_self_message_iterator_get_data(self_msg_iter);
        BT_ASSERT(debug_info_msg_iter);
 
-       return (int) bt_self_component_port_input_message_iterator_can_seek_beginning(
+       return (int) bt_message_iterator_can_seek_beginning(
                debug_info_msg_iter->msg_iter, can_seek);
 }
 
 BT_HIDDEN
-bt_component_class_message_iterator_seek_beginning_method_status
+bt_message_iterator_class_seek_beginning_method_status
 debug_info_msg_iter_seek_beginning(bt_self_message_iterator *self_msg_iter)
 {
        struct debug_info_msg_iter *debug_info_msg_iter =
                bt_self_message_iterator_get_data(self_msg_iter);
-       bt_component_class_message_iterator_seek_beginning_method_status status =
-               BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK;
+       bt_message_iterator_class_seek_beginning_method_status status =
+               BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_OK;
        bt_message_iterator_seek_beginning_status seek_beg_status;
 
        BT_ASSERT(debug_info_msg_iter);
 
        /* Ask the upstream component to seek to the beginning. */
-       seek_beg_status = bt_self_component_port_input_message_iterator_seek_beginning(
+       seek_beg_status = bt_message_iterator_seek_beginning(
                debug_info_msg_iter->msg_iter);
        if (seek_beg_status != BT_MESSAGE_ITERATOR_SEEK_BEGINNING_STATUS_OK) {
                status = (int) seek_beg_status;
This page took 0.048999 seconds and 4 git commands to generate.