Print events discarded
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 30 Jan 2012 18:57:41 +0000 (13:57 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 30 Jan 2012 18:57:41 +0000 (13:57 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/ctf.c
include/babeltrace/ctf/types.h

index 03312f59303bb4ced8691bec3f1c2fd82bac1acc..d4004d856b731555be744afc6481d8afe9f9d84c 100644 (file)
@@ -392,12 +392,32 @@ void ctf_move_pos_slow(struct ctf_stream_pos *pos, size_t offset, int whence)
        read_next_packet:
                switch (whence) {
                case SEEK_CUR:
+               {
+                       uint32_t events_discarded_diff;
+
+                       /* Print lost event count */
+                       index = &g_array_index(pos->packet_index,
+                                       struct packet_index, pos->cur_index);
+                       events_discarded_diff = index->events_discarded;
+                       if (pos->cur_index > 0) {
+                               index = &g_array_index(pos->packet_index,
+                                               struct packet_index,
+                                               pos->cur_index - 1);
+                               events_discarded_diff -= index->events_discarded;
+                       }
+                       if (events_discarded_diff != 0) {
+                               fflush(stdout);
+                               fprintf(stderr, "[warning] %d events discarded by tracer. You should try using larger buffers.\n",
+                                       events_discarded_diff);
+                               fflush(stderr);
+                       }
                        if (pos->offset == EOF)
                                return;
                        /* The reader will expect us to skip padding */
                        assert(pos->offset + offset == pos->content_size);
                        ++pos->cur_index;
                        break;
+               }
                case SEEK_SET:
                        assert(offset == 0);    /* only seek supported for now */
                        pos->cur_index = 0;
@@ -904,6 +924,7 @@ int create_stream_packet_index(struct ctf_trace *td,
                packet_index.packet_size = 0;
                packet_index.timestamp_begin = 0;
                packet_index.timestamp_end = 0;
+               packet_index.events_discarded = 0;
 
                /* read and check header, set stream id (and check) */
                if (file_stream->parent.trace_packet_header) {
@@ -1031,6 +1052,15 @@ int create_stream_packet_index(struct ctf_trace *td,
                                field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
                                packet_index.timestamp_end = get_unsigned_int(field);
                        }
+
+                       /* read events discarded from header */
+                       len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("events_discarded"));
+                       if (len_index >= 0) {
+                               struct definition *field;
+
+                               field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
+                               packet_index.events_discarded = get_unsigned_int(field);
+                       }
                } else {
                        /* Use file size for packet size */
                        packet_index.content_size = filestats.st_size * CHAR_BIT;
index 68ccf7af6931ec5c06e204fb12da3457c3b7bb8f..0b045448908e3db9afba22ae165751776722f7ec 100644 (file)
@@ -40,6 +40,7 @@ struct packet_index {
        size_t content_size;    /* content size, in bits */
        uint64_t timestamp_begin;
        uint64_t timestamp_end;
+       uint32_t events_discarded;
 };
 
 /*
This page took 0.035811 seconds and 4 git commands to generate.