lib: make can_seek_ns_from_origin logic use `can_seek_forward` property of iterator
[babeltrace.git] / src / plugins / lttng-utils / debug-info / debug-info.c
index 06c8a9b1edbc77cc2e9c1c9aa59c54632ac35a92..c948df24b73b3719667f634a5e0255731a37e19a 100644 (file)
@@ -29,7 +29,7 @@
 #define BT_COMP_LOG_SELF_COMP self_comp
 #define BT_LOG_OUTPUT_LEVEL log_level
 #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO"
-#include "plugins/comp-logging.h"
+#include "logging/comp-logging.h"
 
 #include <glib.h>
 
@@ -119,7 +119,7 @@ struct debug_info {
        bt_self_component *self_comp;
        struct debug_info_component *comp;
        const bt_trace *input_trace;
-       uint64_t destruction_listener_id;
+       bt_listener_id destruction_listener_id;
 
        /*
         * Hash table of VPIDs (pointer to int64_t) to
@@ -363,7 +363,7 @@ static inline
 void event_get_common_context_signed_integer_field_value(
                const bt_event *event, const char *field_name, int64_t *value)
 {
-       *value = bt_field_signed_integer_get_value(
+       *value = bt_field_integer_signed_get_value(
                        event_borrow_common_context_field(event, field_name));
 }
 
@@ -417,7 +417,7 @@ int event_get_payload_build_id_value(const bt_event *event,
                        bt_field_array_borrow_element_field_by_index_const(
                                        build_id_field, i);
 
-               build_id[i] = bt_field_unsigned_integer_get_value(curr_field);
+               build_id[i] = bt_field_integer_unsigned_get_value(curr_field);
        }
 
        return ret;
@@ -427,7 +427,7 @@ static
 void event_get_payload_unsigned_integer_field_value(const bt_event *event,
                const char *field_name, uint64_t *value)
 {
-       *value = bt_field_unsigned_integer_get_value(
+       *value = bt_field_integer_unsigned_get_value(
                        event_borrow_payload_field(event, field_name));
 }
 
@@ -443,7 +443,7 @@ static inline
 bool event_has_payload_field(const bt_event *event,
                const char *field_name)
 {
-       return event_borrow_payload_field(event, field_name) != NULL;
+       return event_borrow_payload_field(event, field_name);
 }
 
 static
@@ -571,7 +571,7 @@ void debug_info_destroy(struct debug_info *debug_info)
 {
        bt_logging_level log_level;
        bt_self_component *self_comp;
-       bt_trace_status status;
+       bt_trace_remove_listener_status remove_listener_status;
        if (!debug_info) {
                goto end;
        }
@@ -583,10 +583,12 @@ void debug_info_destroy(struct debug_info *debug_info)
                g_hash_table_destroy(debug_info->vpid_to_proc_dbg_info_src);
        }
 
-       status = bt_trace_remove_destruction_listener(debug_info->input_trace,
+       remove_listener_status = bt_trace_remove_destruction_listener(
+                       debug_info->input_trace,
                        debug_info->destruction_listener_id);
-       if (status != BT_TRACE_STATUS_OK) {
+       if (remove_listener_status != BT_TRACE_REMOVE_LISTENER_STATUS_OK) {
                BT_COMP_LOGE("Trace destruction listener removal failed.");
+               bt_current_thread_clear_error();
        }
 
        g_free(debug_info);
@@ -889,13 +891,17 @@ void handle_event_statedump(struct debug_info_msg_iter *debug_it,
 
        debug_info = g_hash_table_lookup(debug_it->debug_info_map, trace);
        if (!debug_info) {
+               bt_trace_add_listener_status add_listener_status;
+
                debug_info = debug_info_create(debug_it->debug_info_component,
                                trace, &debug_it->fd_cache);
                g_hash_table_insert(debug_it->debug_info_map, (gpointer) trace,
                                debug_info);
-               bt_trace_add_destruction_listener(trace,
-                               trace_debug_info_remove_func, debug_it,
+               add_listener_status = bt_trace_add_destruction_listener(
+                               trace, trace_debug_info_remove_func,
+                               debug_it,
                                &debug_info->destruction_listener_id);
+               BT_ASSERT(add_listener_status == BT_TRACE_ADD_LISTENER_STATUS_OK);
        }
 
        q_event_name = g_quark_try_string(event_name);
@@ -949,36 +955,41 @@ void fill_debug_info_bin_field(struct debug_info_source *dbg_info_src,
                bool full_path, bt_field *curr_field,
                bt_logging_level log_level, bt_self_component *self_comp)
 {
-       bt_field_status status;
+       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_FIELD_CLASS_TYPE_STRING);
 
        if (dbg_info_src) {
                if (full_path) {
-                       status = bt_field_string_set_value(curr_field,
-                                       dbg_info_src->bin_path);
+                       set_status = bt_field_string_set_value(curr_field,
+                               dbg_info_src->bin_path);
                } else {
-                       status = bt_field_string_set_value(curr_field,
-                                       dbg_info_src->short_bin_path);
+                       set_status = bt_field_string_set_value(curr_field,
+                               dbg_info_src->short_bin_path);
                }
-               if (status != BT_FIELD_STATUS_OK) {
+               if (set_status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
                        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();
                }
 
-               status = bt_field_string_append(curr_field, dbg_info_src->bin_loc);
-               if (status != BT_FIELD_STATUS_OK) {
+               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\" "
                                "curr_field field's value: str-fc-addr=%p",
                                curr_field);
+                       bt_current_thread_clear_error();
                }
        } else {
-               status = bt_field_string_set_value(curr_field, "");
-               if (status != BT_FIELD_STATUS_OK) {
+               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: "
                                "str-fc-addr=%p", curr_field);
+                       bt_current_thread_clear_error();
                }
        }
 }
@@ -988,19 +999,20 @@ void fill_debug_info_func_field(struct debug_info_source *dbg_info_src,
                bt_field *curr_field, bt_logging_level log_level,
                bt_self_component *self_comp)
 {
-       bt_field_status status;
+       bt_field_string_set_value_status status;
 
        BT_ASSERT(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,
-                               dbg_info_src->func);
+                       dbg_info_src->func);
        } else {
                status = bt_field_string_set_value(curr_field, "");
        }
-       if (status != BT_FIELD_STATUS_OK) {
+       if (status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
                BT_COMP_LOGE("Cannot set \"func\" curr_field field's value: "
                        "str-fc-addr=%p", curr_field);
+               bt_current_thread_clear_error();
        }
 }
 
@@ -1010,43 +1022,49 @@ void fill_debug_info_src_field(struct debug_info_source *dbg_info_src,
                bt_logging_level log_level,
                bt_self_component *self_comp)
 {
-       bt_field_status status;
+       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_FIELD_CLASS_TYPE_STRING);
 
        if (dbg_info_src && dbg_info_src->src_path) {
                if (full_path) {
-                       status = bt_field_string_set_value(curr_field,
+                       set_status = bt_field_string_set_value(curr_field,
                                        dbg_info_src->src_path);
                } else {
-                       status = bt_field_string_set_value(curr_field,
+                       set_status = bt_field_string_set_value(curr_field,
                                        dbg_info_src->short_src_path);
                }
-               if (status != BT_FIELD_STATUS_OK) {
+               if (set_status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
                        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();
                }
 
-               status = bt_field_string_append(curr_field, ":");
-               if (status != BT_FIELD_STATUS_OK) {
+               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\" "
                                "curr_field field's value: str-fc-addr=%p",
                                curr_field);
+                       bt_current_thread_clear_error();
                }
 
-               status = bt_field_string_append(curr_field, dbg_info_src->line_no);
-               if (status != BT_FIELD_STATUS_OK) {
+               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\" "
                                "curr_field field's value: str-fc-addr=%p",
                                curr_field);
+                       bt_current_thread_clear_error();
                }
        } else {
-               status = bt_field_string_set_value(curr_field, "");
-               if (status != BT_FIELD_STATUS_OK) {
+               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: "
                                "str-fc-addr=%p", curr_field);
+                       bt_current_thread_clear_error();
                }
        }
 }
@@ -1055,7 +1073,7 @@ static
 void fill_debug_info_field_empty(bt_field *debug_info_field,
        bt_logging_level log_level, bt_self_component *self_comp)
 {
-       bt_field_status status;
+       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) ==
@@ -1076,21 +1094,24 @@ void fill_debug_info_field_empty(bt_field *debug_info_field,
                        BT_FIELD_CLASS_TYPE_STRING);
 
        status = bt_field_string_set_value(bin_field, "");
-       if (status != BT_FIELD_STATUS_OK) {
+       if (status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
                BT_COMP_LOGE("Cannot set \"bin\" bin_field 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_STATUS_OK) {
+       if (status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
                BT_COMP_LOGE("Cannot set \"func\" func_field 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_STATUS_OK) {
+       if (status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
                BT_COMP_LOGE("Cannot set \"src\" src_field field's value: "
                        "str-fc-addr=%p", src_field);
+               bt_current_thread_clear_error();
        }
 }
 static
@@ -1174,8 +1195,8 @@ void fill_debug_info_event_if_needed(struct debug_info_msg_iter *debug_it,
        ip_field = bt_field_structure_borrow_member_field_by_name_const(
                        out_common_ctx_field, IP_FIELD_NAME);
 
-       vpid = bt_field_signed_integer_get_value(vpid_field);
-       ip = bt_field_unsigned_integer_get_value(ip_field);
+       vpid = bt_field_integer_signed_get_value(vpid_field);
+       ip = bt_field_integer_unsigned_get_value(ip_field);
 
        /*
         * Borrow the debug_info structure needed for the source
@@ -1240,8 +1261,10 @@ bt_message *handle_event_message(struct debug_info_msg_iter *debug_it,
        const bt_clock_snapshot *cs;
        const bt_clock_class *default_cc;
        const bt_packet *in_packet;
+       const bt_stream *in_stream;
+       const bt_stream *out_stream;
        bt_event_class *out_event_class;
-       bt_packet *out_packet;
+       bt_packet *out_packet = NULL;
        bt_event *out_event;
        bt_logging_level log_level = debug_it->log_level;
        bt_self_component *self_comp = debug_it->self_comp;
@@ -1264,10 +1287,19 @@ bt_message *handle_event_message(struct debug_info_msg_iter *debug_it,
        }
        BT_ASSERT(out_event_class);
 
+       /* Borrow the input stream. */
+       in_stream = bt_event_borrow_stream_const(in_event);
+       BT_ASSERT(in_stream);
+       out_stream = trace_ir_mapping_borrow_mapped_stream(debug_it->ir_maps,
+               in_stream);
+       BT_ASSERT(in_stream);
+
        /* Borrow the input and output packets. */
        in_packet = bt_event_borrow_packet_const(in_event);
-       out_packet = trace_ir_mapping_borrow_mapped_packet(debug_it->ir_maps,
-                       in_packet);
+       if (in_packet) {
+               out_packet = trace_ir_mapping_borrow_mapped_packet(
+                       debug_it->ir_maps, in_packet);
+       }
 
        default_cc = bt_stream_class_borrow_default_clock_class_const(
                        bt_event_class_borrow_stream_class_const(in_event_class));
@@ -1277,13 +1309,29 @@ bt_message *handle_event_message(struct debug_info_msg_iter *debug_it,
                                in_message);
 
                /* Create an output event message. */
-               out_message = bt_message_event_create_with_default_clock_snapshot(
+               if (out_packet) {
+                       out_message =
+                               bt_message_event_create_with_packet_and_default_clock_snapshot(
                                        debug_it->input_iterator,
                                        out_event_class, out_packet,
                                        bt_clock_snapshot_get_value(cs));
+               } else {
+                       out_message =
+                               bt_message_event_create_with_default_clock_snapshot(
+                                       debug_it->input_iterator,
+                                       out_event_class, out_stream,
+                                       bt_clock_snapshot_get_value(cs));
+               }
        } else {
-               out_message = bt_message_event_create(debug_it->input_iterator,
-                               out_event_class, out_packet);
+               if (out_packet) {
+                       out_message = bt_message_event_create_with_packet(
+                               debug_it->input_iterator, out_event_class,
+                               out_packet);
+               } else {
+                       out_message = bt_message_event_create(
+                               debug_it->input_iterator, out_event_class,
+                               out_stream);
+               }
        }
 
        if (!out_message) {
@@ -1361,11 +1409,13 @@ bt_message *handle_stream_end_message(struct debug_info_msg_iter *debug_it,
        if (!out_message) {
                BT_COMP_LOGE("Error creating output stream end message: out-s-addr=%p",
                                out_stream);
+               goto end;
        }
 
        /* Remove stream from trace mapping hashtable. */
        trace_ir_mapping_remove_mapped_stream(debug_it->ir_maps, in_stream);
 
+end:
        return out_message;
 }
 
@@ -1457,11 +1507,13 @@ 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: "
                        "out-p-addr=%p", out_packet);
+               goto end;
        }
 
        /* Remove packet from data mapping hashtable. */
        trace_ir_mapping_remove_mapped_packet(debug_it->ir_maps, in_packet);
 
+end:
        return out_message;
 }
 
@@ -1477,110 +1529,6 @@ bt_message *handle_msg_iterator_inactivity(struct debug_info_msg_iter *debug_it,
        return (bt_message*) in_message;
 }
 
-static
-bt_message *handle_stream_act_begin_message(struct debug_info_msg_iter *debug_it,
-               const bt_message *in_message)
-{
-       const bt_clock_snapshot *cs;
-       const bt_clock_class *default_cc;
-       bt_message *out_message = NULL;
-       bt_stream *out_stream;
-       uint64_t cs_value;
-       bt_message_stream_activity_clock_snapshot_state cs_state;
-       bt_logging_level log_level = debug_it->log_level;
-       bt_self_component *self_comp = debug_it->self_comp;
-
-       const bt_stream *in_stream =
-               bt_message_stream_activity_beginning_borrow_stream_const(
-                       in_message);
-       BT_ASSERT(in_stream);
-
-       out_stream = trace_ir_mapping_borrow_mapped_stream(debug_it->ir_maps,
-                       in_stream);
-       BT_ASSERT(out_stream);
-
-       out_message = bt_message_stream_activity_beginning_create(
-                       debug_it->input_iterator, out_stream);
-       if (!out_message) {
-               BT_COMP_LOGE("Error creating output stream activity beginning "
-                       "message: out-s-addr=%p", out_stream);
-               goto error;
-       }
-
-       default_cc = bt_stream_class_borrow_default_clock_class_const(
-                       bt_stream_borrow_class_const(in_stream));
-       if (default_cc) {
-               /* Borrow clock snapshot. */
-               cs_state =
-                       bt_message_stream_activity_beginning_borrow_default_clock_snapshot_const(
-                                       in_message, &cs);
-
-               if (cs_state == BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN) {
-                       cs_value = bt_clock_snapshot_get_value(cs);
-                       bt_message_stream_activity_beginning_set_default_clock_snapshot(
-                                       out_message, cs_value);
-               } else {
-                       bt_message_stream_activity_beginning_set_default_clock_snapshot_state(
-                                       out_message, cs_state);
-               }
-       }
-
-error:
-       return out_message;
-}
-
-static
-bt_message *handle_stream_act_end_message(struct debug_info_msg_iter *debug_it,
-               const bt_message *in_message)
-{
-       const bt_clock_snapshot *cs;
-       const bt_clock_class *default_cc;
-       const bt_stream *in_stream;
-       bt_message *out_message;
-       bt_stream *out_stream;
-       uint64_t cs_value;
-       bt_message_stream_activity_clock_snapshot_state cs_state;
-       bt_logging_level log_level = debug_it->log_level;
-       bt_self_component *self_comp = debug_it->self_comp;
-
-       in_stream = bt_message_stream_activity_end_borrow_stream_const(
-                       in_message);
-       BT_ASSERT(in_stream);
-
-       out_stream = trace_ir_mapping_borrow_mapped_stream(debug_it->ir_maps,
-               in_stream);
-       BT_ASSERT(out_stream);
-
-       out_message = bt_message_stream_activity_end_create(
-                       debug_it->input_iterator, out_stream);
-       if (!out_message) {
-               BT_COMP_LOGE("Error creating output stream activity end message: "
-                       "out-s-addr=%p", out_stream);
-               goto error;
-       }
-
-       default_cc = bt_stream_class_borrow_default_clock_class_const(
-                       bt_stream_borrow_class_const(in_stream));
-
-       if (default_cc) {
-               cs_state =
-                       bt_message_stream_activity_end_borrow_default_clock_snapshot_const(
-                                       in_message, &cs);
-
-               if (cs_state == BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN ) {
-                       cs_value = bt_clock_snapshot_get_value(cs);
-                       bt_message_stream_activity_end_set_default_clock_snapshot(
-                                       out_message, cs_value);
-               } else {
-                       bt_message_stream_activity_end_set_default_clock_snapshot_state(
-                                       out_message, cs_state);
-               }
-       }
-
-error:
-       return out_message;
-}
-
 static
 bt_message *handle_discarded_events_message(struct debug_info_msg_iter *debug_it,
                const bt_message *in_message)
@@ -1735,14 +1683,6 @@ const bt_message *handle_message(struct debug_info_msg_iter *debug_it,
                out_message = handle_msg_iterator_inactivity(debug_it,
                                in_message);
                break;
-       case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING:
-               out_message = handle_stream_act_begin_message(debug_it,
-                               in_message);
-               break;
-       case BT_MESSAGE_TYPE_STREAM_ACTIVITY_END:
-               out_message = handle_stream_act_end_message(debug_it,
-                               in_message);
-               break;
        case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
                out_message = handle_discarded_events_message(debug_it,
                                in_message);
@@ -1806,13 +1746,16 @@ int init_from_params(struct debug_info_component *debug_info_component,
 }
 
 BT_HIDDEN
-bt_self_component_status debug_info_comp_init(
+bt_component_class_initialize_method_status debug_info_comp_init(
                bt_self_component_filter *self_comp_flt,
+               bt_self_component_filter_configuration *config,
                const bt_value *params, __attribute__((unused)) void *init_method_data)
 {
        int ret;
        struct debug_info_component *debug_info_comp;
-       bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
+       bt_component_class_initialize_method_status status =
+               BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
+       bt_self_component_add_port_status add_port_status;
        bt_self_component *self_comp =
                bt_self_component_filter_as_self_component(self_comp_flt);
        bt_logging_level log_level = bt_component_get_logging_level(
@@ -1832,16 +1775,30 @@ bt_self_component_status debug_info_comp_init(
        debug_info_comp->self_comp = self_comp;
        bt_self_component_set_data(self_comp, debug_info_comp);
 
-       status = bt_self_component_filter_add_input_port(self_comp_flt, "in",
-                       NULL, NULL);
-       if (status != BT_SELF_COMPONENT_STATUS_OK) {
+       add_port_status = bt_self_component_filter_add_input_port(
+               self_comp_flt, "in", NULL, NULL);
+       switch (add_port_status) {
+       case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR:
+               status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
                goto error;
+       case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR:
+               status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+               goto error;
+       default:
+               break;
        }
 
-       status = bt_self_component_filter_add_output_port(self_comp_flt, "out",
-                       NULL, NULL);
-       if (status != BT_SELF_COMPONENT_STATUS_OK) {
+       add_port_status = bt_self_component_filter_add_output_port(
+                       self_comp_flt, "out", NULL, NULL);
+       switch (add_port_status) {
+       case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR:
+               status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
                goto error;
+       case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR:
+               status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+               goto error;
+       default:
+               break;
        }
 
        ret = init_from_params(debug_info_comp, params);
@@ -1858,8 +1815,8 @@ error:
        destroy_debug_info_comp(debug_info_comp);
        bt_self_component_set_data(self_comp, NULL);
 
-       if (status == BT_SELF_COMPONENT_STATUS_OK) {
-               status = BT_SELF_COMPONENT_STATUS_ERROR;
+       if (status == BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK) {
+               status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
        }
 end:
        return status;
@@ -1882,22 +1839,22 @@ void debug_info_comp_finalize(bt_self_component_filter *self_comp_flt)
 }
 
 BT_HIDDEN
-bt_self_message_iterator_status debug_info_msg_iter_next(
+bt_component_class_message_iterator_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_status upstream_iterator_ret_status;
+       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_self_message_iterator_status status;
+       bt_component_class_message_iterator_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_SELF_MESSAGE_ITERATOR_STATUS_OK;
+       status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
 
        self_comp = bt_self_message_iterator_borrow_component(self_msg_iter);
        BT_ASSERT(self_comp);
@@ -1914,13 +1871,14 @@ bt_self_message_iterator_status debug_info_msg_iter_next(
        upstream_iterator_ret_status =
                bt_self_component_port_input_message_iterator_next(
                                upstream_iterator, &input_msgs, count);
-       if (upstream_iterator_ret_status != BT_MESSAGE_ITERATOR_STATUS_OK) {
+       if (upstream_iterator_ret_status !=
+                       BT_MESSAGE_ITERATOR_NEXT_STATUS_OK) {
                /*
-                * No messages were returned. Not necessarily an error. Convert
-                * the upstream message iterator status to a self status.
+                * No messages were returned. Not necessarily an error.
+                * Convert the upstream message iterator status to a
+                * self status.
                 */
-               status = bt_common_message_iterator_status_to_self(
-                               upstream_iterator_ret_status);
+               status = (int) upstream_iterator_ret_status;
                goto end;
        }
 
@@ -1932,7 +1890,7 @@ bt_self_message_iterator_status debug_info_msg_iter_next(
 
        for (curr_msg_idx = 0; curr_msg_idx < *count; curr_msg_idx++) {
                out_message = handle_message(debug_info_msg_iter,
-                               input_msgs[curr_msg_idx]);
+                       input_msgs[curr_msg_idx]);
                if (!out_message) {
                        goto handle_msg_error;
                }
@@ -1956,7 +1914,16 @@ handle_msg_error:
                bt_message_put_ref(msgs[i]);
        }
 
-       status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM;
+       /*
+        * Drop references of all the input messages not dropped before the
+        * failure.
+        */
+       for (i = curr_msg_idx; i < *count; i++) {
+               bt_message_put_ref(input_msgs[i]);
+       }
+
+       status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR;
+
 end:
        return status;
 }
@@ -1989,12 +1956,15 @@ end:
 }
 
 BT_HIDDEN
-bt_self_message_iterator_status debug_info_msg_iter_init(
+bt_component_class_message_iterator_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_self_message_iterator_status status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK;
+       bt_component_class_message_iterator_initialize_method_status status;
+       bt_self_component_port_input_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;
        struct debug_info_msg_iter *debug_info_msg_iter = NULL;
@@ -2009,13 +1979,13 @@ bt_self_message_iterator_status debug_info_msg_iter_init(
        input_port = bt_self_component_filter_borrow_input_port_by_name(
                self_comp_flt, "in");
        if (!input_port) {
-               status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
+               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_SELF_MESSAGE_ITERATOR_STATUS_NOMEM;
+               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
                goto error;
        }
 
@@ -2023,10 +1993,10 @@ bt_self_message_iterator_status debug_info_msg_iter_init(
        debug_info_msg_iter->self_comp = self_comp;
 
        /* Create an iterator on the upstream component. */
-       upstream_iterator = bt_self_component_port_input_message_iterator_create(
-               input_port);
-       if (!upstream_iterator) {
-               status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM;
+       msg_iter_status = bt_self_component_port_input_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) {
+               status = (int) msg_iter_status;
                goto error;
        }
 
@@ -2038,7 +2008,7 @@ bt_self_message_iterator_status debug_info_msg_iter_init(
                g_direct_hash, g_direct_equal, (GDestroyNotify) NULL,
                (GDestroyNotify) debug_info_destroy);
        if (!debug_info_msg_iter->debug_info_map) {
-               status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM;
+               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
                goto error;
        }
 
@@ -2051,61 +2021,72 @@ bt_self_message_iterator_status debug_info_msg_iter_init(
        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_SELF_MESSAGE_ITERATOR_STATUS_NOMEM;
+               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
                goto error;
        }
 
        ret = bt_fd_cache_init(&debug_info_msg_iter->fd_cache, log_level);
        if (ret) {
-               status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM;
+               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_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(
+                       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;
        goto end;
 
 error:
        debug_info_msg_iter_destroy(debug_info_msg_iter);
+
 end:
        return status;
 }
 
 BT_HIDDEN
-bt_bool debug_info_msg_iter_can_seek_beginning(
-               bt_self_message_iterator *self_msg_iter)
+bt_component_class_message_iterator_can_seek_beginning_method_status
+debug_info_msg_iter_can_seek_beginning(
+       bt_self_message_iterator *self_msg_iter, bt_bool *can_seek)
 {
        struct debug_info_msg_iter *debug_info_msg_iter =
                bt_self_message_iterator_get_data(self_msg_iter);
        BT_ASSERT(debug_info_msg_iter);
 
-       return bt_self_component_port_input_message_iterator_can_seek_beginning(
-                       debug_info_msg_iter->msg_iter);
+       return (int) bt_self_component_port_input_message_iterator_can_seek_beginning(
+               debug_info_msg_iter->msg_iter, can_seek);
 }
 
 BT_HIDDEN
-bt_self_message_iterator_status debug_info_msg_iter_seek_beginning(
+bt_component_class_message_iterator_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_message_iterator_status status = BT_MESSAGE_ITERATOR_STATUS_OK;
+       bt_component_class_message_iterator_seek_beginning_method_status status =
+               BT_COMPONENT_CLASS_MESSAGE_ITERATOR_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. */
-       status = bt_self_component_port_input_message_iterator_seek_beginning(
+       seek_beg_status = bt_self_component_port_input_message_iterator_seek_beginning(
                debug_info_msg_iter->msg_iter);
-       if (status != BT_MESSAGE_ITERATOR_STATUS_OK) {
+       if (seek_beg_status != BT_MESSAGE_ITERATOR_SEEK_BEGINNING_STATUS_OK) {
+               status = (int) seek_beg_status;
                goto end;
        }
 
        /* Clear this iterator data. */
        trace_ir_maps_clear(debug_info_msg_iter->ir_maps);
        g_hash_table_remove_all(debug_info_msg_iter->debug_info_map);
+
 end:
-       return bt_common_message_iterator_status_to_self(status);
+       return status;
 }
 
 BT_HIDDEN
This page took 0.033979 seconds and 4 git commands to generate.