text.pretty: use clock class with highest priority to print the timestamp
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 6 Apr 2017 20:43:26 +0000 (16:43 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:41 +0000 (12:57 -0400)
Also, if there's no clock class in the event notification's clock class
priority map, then do not print any timestamp.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
plugins/text/pretty/Makefile.am
plugins/text/pretty/pretty.c
plugins/text/pretty/pretty.h
plugins/text/pretty/print.c

index badc92a9eb252d91a3b7c5e071347f122f615c56..1cb89a2f1f052912fd0252339adfbd3ac58aa070 100644 (file)
@@ -1,7 +1,5 @@
 AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include -I$(top_srcdir)/plugins
 
-SUBDIRS = .
-
 noinst_LTLIBRARIES = libbabeltrace-plugin-text-pretty-cc.la
 
 # ctf-text plugin
index 14f8560c108f96bded8c82b0ee2fec4369a6962d..cbc2feba8f003675792790ac26de512a6b4eec6d 100644 (file)
@@ -144,15 +144,7 @@ enum bt_component_status handle_notification(struct pretty_component *pretty,
                break;
        case BT_NOTIFICATION_TYPE_EVENT:
        {
-               struct bt_ctf_event *event = bt_notification_event_get_event(
-                               notification);
-
-               if (!event) {
-                       ret = BT_COMPONENT_STATUS_ERROR;
-                       goto end;
-               }
-               ret = pretty_print_event(pretty, event);
-               bt_put(event);
+               ret = pretty_print_event(pretty, notification);
                if (ret != BT_COMPONENT_STATUS_OK) {
                        goto end;
                }
@@ -224,7 +216,6 @@ enum bt_component_status pretty_consume(struct bt_private_component *component)
        notification = bt_notification_iterator_get_notification(it);
        assert(notification);
        ret = handle_notification(pretty, notification);
-       pretty->processed_first_event = true;
 end:
        bt_put(notification);
        return ret;
index 9caa5778ea8f487673d4bdb1a0bb9d6c905ab6b2..0c8b27d99ec28572292616da49b850203814a248 100644 (file)
@@ -82,7 +82,6 @@ struct pretty_component {
        struct pretty_options options;
        struct bt_notification_iterator *input_iterator;
        FILE *out, *err;
-       bool processed_first_event; /* Should be per-iterator. */
        int depth;      /* nesting, used for tabulation alignment. */
        bool start_line;
        GString *string;
@@ -129,6 +128,6 @@ void pretty_finalize(struct bt_private_component *component);
 
 BT_HIDDEN
 enum bt_component_status pretty_print_event(struct pretty_component *pretty,
-               struct bt_ctf_event *event);
+               struct bt_notification *event_notif);
 
 #endif /* BABELTRACE_PLUGIN_TEXT_PRETTY_PRETTY_H */
index 77c42a089f5c7fd9bd3d401cca040bfb5d193038..fb7bae4f17e44a12c29a438bb9394673968efe14 100644 (file)
@@ -36,6 +36,8 @@
 #include <babeltrace/ctf-ir/field-types.h>
 #include <babeltrace/ctf-ir/fields.h>
 #include <babeltrace/ctf-ir/trace.h>
+#include <babeltrace/graph/notification-event.h>
+#include <babeltrace/graph/clock-class-priority-map.h>
 #include <babeltrace/bitfield-internal.h>
 #include <babeltrace/common-internal.h>
 #include <inttypes.h>
@@ -234,7 +236,9 @@ end:
 
 static
 enum bt_component_status print_event_timestamp(struct pretty_component *pretty,
-               struct bt_ctf_event *event, bool *start_line)
+               struct bt_ctf_event *event,
+               struct bt_clock_class_priority_map *cc_prio_map,
+               bool *start_line)
 {
        bool print_names = pretty->options.print_header_field_names;
        enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
@@ -260,7 +264,15 @@ enum bt_component_status print_event_timestamp(struct pretty_component *pretty,
                ret = BT_COMPONENT_STATUS_ERROR;
                goto end;
        }
-       clock_class = bt_ctf_trace_get_clock_class(trace, 0);
+
+       if (bt_clock_class_priority_map_get_clock_class_count(cc_prio_map) == 0) {
+               /* No clock class: skip the timestamp without an error */
+               goto end;
+       }
+
+       clock_class =
+               bt_clock_class_priority_map_get_highest_priority_clock_class(
+                       cc_prio_map);
        if (!clock_class) {
                ret = BT_COMPONENT_STATUS_ERROR;
                goto end;
@@ -328,7 +340,8 @@ end:
 
 static
 enum bt_component_status print_event_header(struct pretty_component *pretty,
-               struct bt_ctf_event *event)
+               struct bt_ctf_event *event,
+               struct bt_clock_class_priority_map *cc_prio_map)
 {
        bool print_names = pretty->options.print_header_field_names;
        enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
@@ -352,7 +365,8 @@ enum bt_component_status print_event_header(struct pretty_component *pretty,
                ret = BT_COMPONENT_STATUS_ERROR;
                goto end;
        }
-       ret = print_event_timestamp(pretty, event, &pretty->start_line);
+       ret = print_event_timestamp(pretty, event, cc_prio_map,
+               &pretty->start_line);
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto end;
        }
@@ -1446,12 +1460,18 @@ end:
 
 BT_HIDDEN
 enum bt_component_status pretty_print_event(struct pretty_component *pretty,
-               struct bt_ctf_event *event)
+               struct bt_notification *event_notif)
 {
        enum bt_component_status ret;
+       struct bt_ctf_event *event =
+               bt_notification_event_get_event(event_notif);
+       struct bt_clock_class_priority_map *cc_prio_map =
+               bt_notification_event_get_clock_class_priority_map(event_notif);
 
+       assert(event);
+       assert(cc_prio_map);
        pretty->start_line = true;
-       ret = print_event_header(pretty, event);
+       ret = print_event_header(pretty, event, cc_prio_map);
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto end;
        }
@@ -1485,5 +1505,7 @@ enum bt_component_status pretty_print_event(struct pretty_component *pretty,
 
        fputc('\n', pretty->out);
 end:
+       bt_put(event);
+       bt_put(cc_prio_map);
        return ret;
 }
This page took 0.029044 seconds and 4 git commands to generate.