X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fplugins%2Flttng-utils%2Fdebug-info%2Fdebug-info.c;h=aa791ddd2a21d532e34550ddc433424b55af286d;hb=5b5c34865c6b97850ce780f804f4e4842e58608a;hp=c98cf604175bd31fdce288f170ee614460ec24cd;hpb=d9120ccba72cfe3173cf5987871e9667d4c4c547;p=babeltrace.git diff --git a/src/plugins/lttng-utils/debug-info/debug-info.c b/src/plugins/lttng-utils/debug-info/debug-info.c index c98cf604..aa791ddd 100644 --- a/src/plugins/lttng-utils/debug-info/debug-info.c +++ b/src/plugins/lttng-utils/debug-info/debug-info.c @@ -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 @@ -7,23 +7,7 @@ * Copyright (c) 2016 Jérémie Galarneau * Copyright (c) 2019 Francis Deslauriers * - * 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 @@ -49,19 +33,11 @@ #define DEFAULT_DEBUG_INFO_FIELD_NAME "debug_info" #define LTTNG_UST_STATEDUMP_PREFIX "lttng_ust" -#define VPID_FIELD_NAME "vpid" -#define IP_FIELD_NAME "ip" -#define BADDR_FIELD_NAME "baddr" -#define CRC32_FIELD_NAME "crc" -#define BUILD_ID_FIELD_NAME "build_id" -#define FILENAME_FIELD_NAME "filename" -#define IS_PIC_FIELD_NAME "is_pic" -#define MEMSZ_FIELD_NAME "memsz" -#define PATH_FIELD_NAME "path" 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; @@ -73,7 +49,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. */ @@ -212,7 +188,7 @@ struct debug_info_source *debug_info_source_create_from_bin( g_strdup_printf("%"PRId64, src_loc->line_no); if (!debug_info_src->line_no) { BT_COMP_LOGE_APPEND_CAUSE(self_comp, - "Error occured when setting `line_no` field."); + "Error occurred when setting `line_no` field."); goto error; } @@ -930,7 +906,7 @@ void handle_event_statedump(struct debug_info_msg_iter *debug_it, } else if (q_event_name == debug_info->q_statedump_build_id) { /* Build ID info */ handle_event_statedump_build_id(debug_info, event); - } else if (q_event_name == debug_info-> q_lib_unload) { + } else if (q_event_name == debug_info->q_lib_unload) { handle_event_lib_unload(debug_info, event); } @@ -1807,6 +1783,7 @@ bt_component_class_initialize_method_status debug_info_comp_init( 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( @@ -1862,22 +1839,22 @@ 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_DBG(self_comp); @@ -1892,7 +1869,7 @@ bt_component_class_message_iterator_next_method_status debug_info_msg_iter_next( 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) { @@ -1945,7 +1922,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; @@ -1959,7 +1936,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); } @@ -1979,51 +1956,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. */ @@ -2031,37 +2011,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: @@ -2072,7 +2049,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) { @@ -2080,24 +2057,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;