X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=plugins%2Ftext%2Fprint.c;h=5ba979588d9381231bb6b0d2c20827faa3991547;hb=96e8f959f3f895366c26f945c418a006e6ea397c;hp=3a683a8388a12984729e71a4cd574437970f3773;hpb=3af83b5a0b18de8603239be8d7d50020d76c3d21;p=babeltrace.git diff --git a/plugins/text/print.c b/plugins/text/print.c index 3a683a83..5ba97958 100644 --- a/plugins/text/print.c +++ b/plugins/text/print.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include @@ -62,14 +62,14 @@ enum bt_component_status print_field(struct text_component *text, static void print_timestamp_cycles(struct text_component *text, - struct bt_ctf_clock *clock, + struct bt_ctf_clock_class *clock_class, struct bt_ctf_event *event) { int ret; struct bt_ctf_clock_value *clock_value; uint64_t cycles; - clock_value = bt_ctf_event_get_clock_value(event, clock); + clock_value = bt_ctf_event_get_clock_value(event, clock_class); if (!clock_value) { fputs("????????????????????", text->out); return; @@ -91,7 +91,7 @@ void print_timestamp_cycles(struct text_component *text, static void print_timestamp_wall(struct text_component *text, - struct bt_ctf_clock *clock, + struct bt_ctf_clock_class *clock_class, struct bt_ctf_event *event) { int ret; @@ -101,7 +101,7 @@ void print_timestamp_wall(struct text_component *text, uint64_t ts_sec_abs, ts_nsec_abs; bool is_negative; - clock_value = bt_ctf_event_get_clock_value(event, clock); + clock_value = bt_ctf_event_get_clock_value(event, clock_class); if (!clock_value) { fputs("??:??:??.?????????", text->out); return; @@ -207,10 +207,8 @@ enum bt_component_status print_event_timestamp(struct text_component *text, struct bt_ctf_stream *stream = NULL; struct bt_ctf_stream_class *stream_class = NULL; struct bt_ctf_trace *trace = NULL; - struct bt_ctf_clock *clock = NULL; + struct bt_ctf_clock_class *clock_class = NULL; FILE *out = text->out; - FILE *err = text->err; - uint64_t real_timestamp; stream = bt_ctf_event_get_stream(event); if (!stream) { @@ -228,17 +226,17 @@ enum bt_component_status print_event_timestamp(struct text_component *text, ret = BT_COMPONENT_STATUS_ERROR; goto end; } - clock = bt_ctf_trace_get_clock(trace, 0); - if (!clock) { + clock_class = bt_ctf_trace_get_clock_class(trace, 0); + if (!clock_class) { ret = BT_COMPONENT_STATUS_ERROR; goto end; } fputs(print_names ? "timestamp = " : "[", out); if (text->options.print_timestamp_cycles) { - print_timestamp_cycles(text, clock, event); + print_timestamp_cycles(text, clock_class, event); } else { - print_timestamp_wall(text, clock, event); + print_timestamp_wall(text, clock_class, event); } if (!print_names) @@ -276,7 +274,7 @@ enum bt_component_status print_event_timestamp(struct text_component *text, end: bt_put(stream); - bt_put(clock); + bt_put(clock_class); bt_put(stream_class); bt_put(trace); return ret; @@ -629,18 +627,75 @@ enum bt_component_status print_enum(struct text_component *text, { enum bt_component_status ret = BT_COMPONENT_STATUS_OK; struct bt_ctf_field *container_field = NULL; - const char *mapping_name; - + struct bt_ctf_field_type *enumeration_field_type = NULL; + struct bt_ctf_field_type *container_field_type = NULL; + struct bt_ctf_field_type_enumeration_mapping_iterator *iter = NULL; + int nr_mappings = 0; + int is_signed; + + enumeration_field_type = bt_ctf_field_get_type(field); + if (!enumeration_field_type) { + ret = BT_COMPONENT_STATUS_ERROR; + goto end; + } container_field = bt_ctf_field_enumeration_get_container(field); if (!container_field) { ret = BT_COMPONENT_STATUS_ERROR; goto end; } - mapping_name = bt_ctf_field_enumeration_get_mapping_name(field); - if (mapping_name) { - fprintf(text->out, "( \"%s\"", mapping_name); + container_field_type = bt_ctf_field_get_type(container_field); + if (!container_field_type) { + ret = BT_COMPONENT_STATUS_ERROR; + goto end; + } + is_signed = bt_ctf_field_type_integer_get_signed(container_field_type); + if (is_signed < 0) { + ret = BT_COMPONENT_STATUS_ERROR; + goto end; + } + if (is_signed) { + int64_t value; + + if (bt_ctf_field_signed_integer_get_value(container_field, + &value)) { + ret = BT_COMPONENT_STATUS_ERROR; + goto end; + } + iter = bt_ctf_field_type_enumeration_find_mappings_by_signed_value( + enumeration_field_type, value); } else { - fprintf(text->out, "( "); + uint64_t value; + + if (bt_ctf_field_unsigned_integer_get_value(container_field, + &value)) { + ret = BT_COMPONENT_STATUS_ERROR; + goto end; + } + iter = bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value( + enumeration_field_type, value); + } + if (!iter) { + ret = BT_COMPONENT_STATUS_ERROR; + goto end; + } + fprintf(text->out, "( "); + for (;;) { + const char *mapping_name; + + if (bt_ctf_field_type_enumeration_mapping_iterator_get_signed( + iter, &mapping_name, NULL, NULL) < 0) { + ret = BT_COMPONENT_STATUS_ERROR; + goto end; + } + if (nr_mappings++) + fprintf(text->out, ", "); + fprintf(text->out, "\"%s\"", mapping_name); + if (bt_ctf_field_type_enumeration_mapping_iterator_next(iter) < 0) { + break; + } + } + if (!nr_mappings) { + fprintf(text->out, ""); } fprintf(text->out, " : container = "); ret = print_integer(text, container_field); @@ -649,7 +704,10 @@ enum bt_component_status print_enum(struct text_component *text, } fprintf(text->out, " )"); end: + bt_put(iter); + bt_put(container_field_type); bt_put(container_field); + bt_put(enumeration_field_type); return ret; } @@ -960,7 +1018,7 @@ enum bt_component_status print_variant(struct text_component *text, ret = BT_COMPONENT_STATUS_ERROR; goto end; } - tag_choice = bt_ctf_field_enumeration_get_mapping_name(tag_field); + tag_choice = bt_ctf_field_enumeration_get_single_mapping_name(tag_field); if (!tag_choice) { bt_put(tag_field); ret = BT_COMPONENT_STATUS_ERROR; @@ -1035,7 +1093,6 @@ enum bt_component_status print_stream_packet_context(struct text_component *text } main_field = bt_ctf_packet_get_context(packet); if (!main_field) { - ret = BT_COMPONENT_STATUS_ERROR; goto end; } if (!text->start_line) { @@ -1062,7 +1119,6 @@ enum bt_component_status print_event_header_raw(struct text_component *text, main_field = bt_ctf_event_get_header(event); if (!main_field) { - ret = BT_COMPONENT_STATUS_ERROR; goto end; } if (!text->start_line) { @@ -1088,7 +1144,6 @@ enum bt_component_status print_stream_event_context(struct text_component *text, main_field = bt_ctf_event_get_stream_event_context(event); if (!main_field) { - ret = BT_COMPONENT_STATUS_ERROR; goto end; } if (!text->start_line) { @@ -1114,7 +1169,6 @@ enum bt_component_status print_event_context(struct text_component *text, main_field = bt_ctf_event_get_event_context(event); if (!main_field) { - ret = BT_COMPONENT_STATUS_ERROR; goto end; } if (!text->start_line) { @@ -1140,7 +1194,6 @@ enum bt_component_status print_event_payload(struct text_component *text, main_field = bt_ctf_event_get_payload_field(event); if (!main_field) { - ret = BT_COMPONENT_STATUS_ERROR; goto end; } if (!text->start_line) {