Filter out redundant packet context fields unless in verbose mode
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 24 May 2011 14:09:06 +0000 (10:09 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 24 May 2011 14:09:06 +0000 (10:09 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf-text/ctf-text.c
formats/ctf-text/types/array.c
formats/ctf-text/types/enum.c
formats/ctf-text/types/float.c
formats/ctf-text/types/integer.c
formats/ctf-text/types/sequence.c
formats/ctf-text/types/string.c
formats/ctf-text/types/struct.c
formats/ctf-text/types/variant.c
include/babeltrace/ctf-text/types.h

index 0d551179710dafc368ed9059cbe2a40b62d5facf..1500d735c18c437be2fc9c0744498ce9ffd222e8 100644 (file)
@@ -53,6 +53,43 @@ struct format ctf_text_format = {
        .close_trace = ctf_text_close_trace,
 };
 
        .close_trace = ctf_text_close_trace,
 };
 
+static GQuark Q_STREAM_PACKET_CONTEXT_TIMESTAMP_BEGIN,
+       Q_STREAM_PACKET_CONTEXT_TIMESTAMP_END,
+       Q_STREAM_PACKET_CONTEXT_EVENTS_DISCARDED,
+       Q_STREAM_PACKET_CONTEXT_CONTENT_SIZE,
+       Q_STREAM_PACKET_CONTEXT_PACKET_SIZE;
+
+static
+void __attribute__((constructor)) init_quarks(void)
+{
+       Q_STREAM_PACKET_CONTEXT_TIMESTAMP_BEGIN = g_quark_from_static_string("stream.packet.context.timestamp_begin");
+       Q_STREAM_PACKET_CONTEXT_TIMESTAMP_END = g_quark_from_static_string("stream.packet.context.timestamp_end");
+       Q_STREAM_PACKET_CONTEXT_EVENTS_DISCARDED = g_quark_from_static_string("stream.packet.context.events_discarded");
+       Q_STREAM_PACKET_CONTEXT_CONTENT_SIZE = g_quark_from_static_string("stream.packet.context.content_size");
+       Q_STREAM_PACKET_CONTEXT_PACKET_SIZE = g_quark_from_static_string("stream.packet.context.packet_size");
+}
+
+int print_field(struct definition *definition)
+{
+       /* Print all fields in verbose mode */
+       if (babeltrace_verbose)
+               return 1;
+
+       /* Filter out part of the packet context */
+       if (definition->path == Q_STREAM_PACKET_CONTEXT_TIMESTAMP_BEGIN)
+               return 0;
+       if (definition->path == Q_STREAM_PACKET_CONTEXT_TIMESTAMP_END)
+               return 0;
+       if (definition->path == Q_STREAM_PACKET_CONTEXT_EVENTS_DISCARDED)
+               return 0;
+       if (definition->path == Q_STREAM_PACKET_CONTEXT_CONTENT_SIZE)
+               return 0;
+       if (definition->path == Q_STREAM_PACKET_CONTEXT_PACKET_SIZE)
+               return 0;
+
+       return 1;
+}
+
 static
 int ctf_text_write_event(struct stream_pos *ppos,
                         struct ctf_stream *stream)
 static
 int ctf_text_write_event(struct stream_pos *ppos,
                         struct ctf_stream *stream)
index db941426d82da754d86650162c1f9c8260943849..1ee556a02431bcf3b1796c2a9efeba5f5ff57200 100644 (file)
@@ -30,6 +30,9 @@ int ctf_text_array_write(struct stream_pos *ppos, struct definition *definition)
        int field_nr_saved;
        int ret = 0;
 
        int field_nr_saved;
        int ret = 0;
 
+       if (!print_field(definition))
+               return 0;
+
        if (!pos->dummy) {
                if (pos->field_nr++ != 0)
                        fprintf(pos->fp, ",");
        if (!pos->dummy) {
                if (pos->field_nr++ != 0)
                        fprintf(pos->fp, ",");
index 4a3eac0feecfb93e7f401b4abbf7bee8ada932ab..9043277d19b07b634cf33c522e0d117e8fcb6e43 100644 (file)
@@ -31,6 +31,9 @@ int ctf_text_enum_write(struct stream_pos *ppos, struct definition *definition)
        int i, ret;
        int field_nr_saved;
 
        int i, ret;
        int field_nr_saved;
 
+       if (!print_field(definition))
+               return 0;
+
        if (pos->dummy)
                return 0;
 
        if (pos->dummy)
                return 0;
 
index 2ec7728eb1a907cc5ba6592ee7df4fda6c347292..7fe4fe0042fb1f314b3b70d8fcb7984864788ace 100644 (file)
@@ -27,6 +27,9 @@ int ctf_text_float_write(struct stream_pos *ppos, struct definition *definition)
                container_of(definition, struct definition_float, p);
        struct ctf_text_stream_pos *pos = ctf_text_pos(ppos);
 
                container_of(definition, struct definition_float, p);
        struct ctf_text_stream_pos *pos = ctf_text_pos(ppos);
 
+       if (!print_field(definition))
+               return 0;
+
        if (pos->dummy)
                return 0;
 
        if (pos->dummy)
                return 0;
 
index 457ea804e5133ca1e32488e857b2ad6b0369da9e..30209d6be6c66fbcad295273c947b2d14bfdeefe 100644 (file)
@@ -30,6 +30,9 @@ int ctf_text_integer_write(struct stream_pos *ppos, struct definition *definitio
                integer_definition->declaration;
        struct ctf_text_stream_pos *pos = ctf_text_pos(ppos);
 
                integer_definition->declaration;
        struct ctf_text_stream_pos *pos = ctf_text_pos(ppos);
 
+       if (!print_field(definition))
+               return 0;
+
        if (pos->dummy)
                return 0;
 
        if (pos->dummy)
                return 0;
 
index a3982a210cd3898cd94740051ee61f183cb51c35..cdf393086d8559adb68a510c5bed7c02cd4806ad 100644 (file)
@@ -30,6 +30,9 @@ int ctf_text_sequence_write(struct stream_pos *ppos, struct definition *definiti
        int field_nr_saved;
        int ret = 0;
 
        int field_nr_saved;
        int ret = 0;
 
+       if (!print_field(definition))
+               return 0;
+
        if (!pos->dummy) {
                if (pos->field_nr++ != 0)
                        fprintf(pos->fp, ",");
        if (!pos->dummy) {
                if (pos->field_nr++ != 0)
                        fprintf(pos->fp, ",");
index eca5f91f9e3d7dc8b1dca38c2b7d06c2aa615b6e..610d6db3a59930cc208ad5ce69cd29be15abc94c 100644 (file)
@@ -29,6 +29,10 @@ int ctf_text_string_write(struct stream_pos *ppos,
        struct ctf_text_stream_pos *pos = ctf_text_pos(ppos);
 
        assert(string_definition->value != NULL);
        struct ctf_text_stream_pos *pos = ctf_text_pos(ppos);
 
        assert(string_definition->value != NULL);
+
+       if (!print_field(definition))
+               return 0;
+
        if (pos->dummy)
                return 0;
 
        if (pos->dummy)
                return 0;
 
index 3a69994fae5746ebcec45c81abc88dfcedfa870c..cc36fde9e2f5aff0177db425bd3ba6c5992de815 100644 (file)
@@ -29,6 +29,9 @@ int ctf_text_struct_write(struct stream_pos *ppos, struct definition *definition
        int field_nr_saved;
        int ret;
 
        int field_nr_saved;
        int ret;
 
+       if (!print_field(definition))
+               return 0;
+
        if (!pos->dummy) {
                if (pos->depth >= 0) {
                        if (pos->field_nr++ != 0)
        if (!pos->dummy) {
                if (pos->depth >= 0) {
                        if (pos->field_nr++ != 0)
index 50d21903ce3dc83aa37dc42619e18737609e8e37..a21197aa1b3ad35bdac68c980fe2cf7c4bed0d88 100644 (file)
@@ -25,6 +25,9 @@ int ctf_text_variant_write(struct stream_pos *ppos, struct definition *definitio
        int field_nr_saved;
        int ret;
 
        int field_nr_saved;
        int ret;
 
+       if (!print_field(definition))
+               return 0;
+
        if (!pos->dummy) {
                if (pos->depth >= 0) {
                        if (pos->field_nr++ != 0)
        if (!pos->dummy) {
                if (pos->depth >= 0) {
                        if (pos->field_nr++ != 0)
index 7703e7b8e25148272f5c6ed91f8e0264ea0d4706..1b05523e5430585afd3ed9984294825fbd3d413b 100644 (file)
@@ -69,4 +69,9 @@ void print_pos_tabs(struct ctf_text_stream_pos *pos)
                fprintf(pos->fp, "\t");
 }
 
                fprintf(pos->fp, "\t");
 }
 
+/*
+ * Check if the field must be printed.
+ */
+int print_field(struct definition *definition);
+
 #endif /* _BABELTRACE_CTF_TEXT_TYPES_H */
 #endif /* _BABELTRACE_CTF_TEXT_TYPES_H */
This page took 0.039413 seconds and 4 git commands to generate.