X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=src%2Fplugins%2Ftext%2Fpretty%2Fpretty.c;h=f177ad23316c1b38166909a88db9abfc5817f31c;hp=3ea6c54ad4be2316d99ebd93c2db34ee52c7bbe9;hb=0235b0db7de5bcacdb3650c92461f2ce5eb2143d;hpb=96eccbbcd37201bf462fe0d655ca77ecb81b7e1e diff --git a/src/plugins/text/pretty/pretty.c b/src/plugins/text/pretty/pretty.c index 3ea6c54a..f177ad23 100644 --- a/src/plugins/text/pretty/pretty.c +++ b/src/plugins/text/pretty/pretty.c @@ -1,26 +1,8 @@ /* + * SPDX-License-Identifier: MIT + * * Copyright 2016 Jérémie Galarneau * Copyright 2016 Mathieu Desnoyers - * - * Author: Jérémie Galarneau - * - * 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. */ #define BT_COMP_LOG_SELF_COMP self_comp @@ -50,7 +32,7 @@ void destroy_pretty_data(struct pretty_component *pretty) goto end; } - bt_self_component_port_input_message_iterator_put_ref(pretty->iterator); + bt_message_iterator_put_ref(pretty->iterator); if (pretty->string) { (void) g_string_free(pretty->string, TRUE); @@ -109,25 +91,25 @@ void pretty_finalize(bt_self_component_sink *comp) } static -bt_component_class_message_iterator_next_method_status handle_message( +bt_message_iterator_class_next_method_status handle_message( struct pretty_component *pretty, const bt_message *message) { - bt_component_class_message_iterator_next_method_status ret = - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + bt_message_iterator_class_next_method_status ret = + BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; - BT_ASSERT(pretty); + BT_ASSERT_DBG(pretty); switch (bt_message_get_type(message)) { case BT_MESSAGE_TYPE_EVENT: if (pretty_print_event(pretty, message)) { - ret = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + ret = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; } break; case BT_MESSAGE_TYPE_DISCARDED_EVENTS: case BT_MESSAGE_TYPE_DISCARDED_PACKETS: if (pretty_print_discarded_items(pretty, message)) { - ret = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + ret = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; } break; default: @@ -142,7 +124,7 @@ bt_component_class_sink_graph_is_configured_method_status pretty_graph_is_configured(bt_self_component_sink *comp) { bt_component_class_sink_graph_is_configured_method_status status; - bt_self_component_port_input_message_iterator_create_from_sink_component_status + bt_message_iterator_create_from_sink_component_status msg_iter_status; struct pretty_component *pretty; @@ -150,10 +132,10 @@ pretty_graph_is_configured(bt_self_component_sink *comp) bt_self_component_sink_as_self_component(comp)); BT_ASSERT(pretty); BT_ASSERT(!pretty->iterator); - msg_iter_status = bt_self_component_port_input_message_iterator_create_from_sink_component( + msg_iter_status = bt_message_iterator_create_from_sink_component( comp, bt_self_component_sink_borrow_input_port_by_name(comp, in_port_name), &pretty->iterator); - if (msg_iter_status != BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_CREATE_FROM_SINK_COMPONENT_STATUS_OK) { + if (msg_iter_status != BT_MESSAGE_ITERATOR_CREATE_FROM_SINK_COMPONENT_STATUS_OK) { status = (int) msg_iter_status; goto end; } @@ -171,7 +153,7 @@ bt_component_class_sink_consume_method_status pretty_consume( bt_component_class_sink_consume_method_status ret = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; bt_message_array_const msgs; - bt_self_component_port_input_message_iterator *it; + bt_message_iterator *it; struct pretty_component *pretty = bt_self_component_get_data( bt_self_component_sink_as_self_component(comp)); bt_message_iterator_next_status next_status; @@ -179,7 +161,7 @@ bt_component_class_sink_consume_method_status pretty_consume( uint64_t i = 0; it = pretty->iterator; - next_status = bt_self_component_port_input_message_iterator_next(it, + next_status = bt_message_iterator_next(it, &msgs, &count); switch (next_status) { @@ -191,7 +173,7 @@ bt_component_class_sink_consume_method_status pretty_consume( goto end; case BT_MESSAGE_ITERATOR_NEXT_STATUS_END: ret = (int) next_status; - BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_PUT_REF_AND_RESET( + BT_MESSAGE_ITERATOR_PUT_REF_AND_RESET( pretty->iterator); goto end; default: @@ -199,7 +181,7 @@ bt_component_class_sink_consume_method_status pretty_consume( goto end; } - BT_ASSERT(next_status == BT_MESSAGE_ITERATOR_NEXT_STATUS_OK); + BT_ASSERT_DBG(next_status == BT_MESSAGE_ITERATOR_NEXT_STATUS_OK); for (i = 0; i < count; i++) { ret = (int) handle_message(pretty, msgs[i]); @@ -296,6 +278,7 @@ end: static const char *color_choices[] = { "never", "auto", "always", NULL }; static const char *show_hide_choices[] = { "show", "hide", NULL }; +static struct bt_param_validation_map_value_entry_descr pretty_params[] = { { "color", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { BT_VALUE_TYPE_STRING, .string = { .choices = color_choices, @@ -430,7 +413,7 @@ bt_component_class_initialize_method_status apply_params( pretty->options.print_scope_field_names = false; break; default: - abort(); + bt_common_abort(); } apply_one_bool_if_specified("name-payload", params, @@ -492,7 +475,7 @@ bt_component_class_initialize_method_status apply_params( pretty->options.print_callsite_field = false; break; default: - abort(); + bt_common_abort(); } apply_one_bool_if_specified("field-trace", params, @@ -519,6 +502,7 @@ bt_component_class_initialize_method_status apply_params( apply_one_bool_if_specified("field-callsite", params, &pretty->options.print_callsite_field); + pretty_print_init(); status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK; end: