X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fplugins%2Ftext%2Fpretty%2Fpretty.c;h=cad275145392b9391d74667d3abc1f6907e72ce0;hb=5288c8aef93013b72a48cec6851a00b0c91f09dc;hp=a3aa3f812f8669865851176a235e5bac6d27d46d;hpb=ed30eb8d59e3bc1d26808d3414a1fbc5f8bb23d8;p=babeltrace.git diff --git a/src/plugins/text/pretty/pretty.c b/src/plugins/text/pretty/pretty.c index a3aa3f81..cad27514 100644 --- a/src/plugins/text/pretty/pretty.c +++ b/src/plugins/text/pretty/pretty.c @@ -28,6 +28,7 @@ const char * const in_port_name = "in"; static void destroy_pretty_data(struct pretty_component *pretty) { + uint64_t i; if (!pretty) { goto end; } @@ -50,6 +51,13 @@ void destroy_pretty_data(struct pretty_component *pretty) perror("close output file"); } } + + for (i = 0; i < ENUMERATION_MAX_BITFLAGS_COUNT; i++) { + if (pretty->enum_bit_labels[i]) { + g_ptr_array_free(pretty->enum_bit_labels[i], true); + } + } + g_free(pretty->options.output_path); g_free(pretty); @@ -312,6 +320,7 @@ struct bt_param_validation_map_value_entry_descr pretty_params[] = { { "field-loglevel", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_BOOL } }, { "field-emf", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_BOOL } }, { "field-callsite", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_BOOL } }, + { "print-enum-flags", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_BOOL } }, BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_END }; @@ -381,6 +390,9 @@ bt_component_class_initialize_method_status apply_params( apply_one_bool_with_default("verbose", params, &pretty->options.verbose, false); + apply_one_bool_with_default("print-enum-flags", params, + &pretty->options.print_enum_flags, false); + /* Names. */ value = bt_value_map_borrow_entry_value_const(params, "name-default"); if (value) { @@ -584,6 +596,18 @@ bt_component_class_initialize_method_status pretty_init( } set_use_colors(pretty); + + if (pretty->options.print_enum_flags) { + uint64_t i; + /* + * Allocate all label arrays during the initialization of the + * component and reuse the same set of arrays for all + * enumerations. + */ + for (i = 0; i < ENUMERATION_MAX_BITFLAGS_COUNT; i++) { + pretty->enum_bit_labels[i] = g_ptr_array_new(); + } + } bt_self_component_set_data(self_comp, pretty); status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;