X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=trunk%2Flttv%2Fltt%2Ftracefile.c;h=24722d29808aaadce2fc9d845f66133df083be1a;hb=0c2f49848e239920c666c0052d20ea5e23c5c6e7;hp=7f0e3fb832b3ea321ed9e6c4395e971e47551d23;hpb=64dd41a5e4653a36bd966e1badbe2c3d78b66ef1;p=lttv.git diff --git a/trunk/lttv/ltt/tracefile.c b/trunk/lttv/ltt/tracefile.c index 7f0e3fb8..24722d29 100644 --- a/trunk/lttv/ltt/tracefile.c +++ b/trunk/lttv/ltt/tracefile.c @@ -152,10 +152,10 @@ static int parse_trace_header(ltt_subbuffer_header_t *header, break; case 2: switch(header->minor_version) { - case 0: + case 2: { - struct ltt_subbuffer_header_2_0 *vheader = header; - tf->buffer_header_size = sizeof(struct ltt_subbuffer_header_2_0) ; + struct ltt_subbuffer_header_2_2 *vheader = header; + tf->buffer_header_size = ltt_subbuffer_header_size(); tf->tscbits = 27; tf->eventbits = 5; tf->tsc_mask = ((1ULL << tf->tscbits) - 1); @@ -238,7 +238,7 @@ static gint ltt_tracefile_open(LttTrace *t, gchar * fileName, LttTracefile *tf) // Is the file large enough to contain a trace if(lTDFStat.st_size < - (off_t)(sizeof(ltt_subbuffer_header_t))){ + (off_t)(ltt_subbuffer_header_size())){ g_print("The input data file %s does not contain a trace\n", fileName); goto close_file; } @@ -246,7 +246,7 @@ static gint ltt_tracefile_open(LttTrace *t, gchar * fileName, LttTracefile *tf) /* Temporarily map the buffer start header to get trace information */ /* Multiple of pages aligned head */ tf->buffer.head = mmap(0, - PAGE_ALIGN(sizeof(ltt_subbuffer_header_t)), PROT_READ, + PAGE_ALIGN(ltt_subbuffer_header_size()), PROT_READ, MAP_PRIVATE, tf->fd, 0); if(tf->buffer.head == MAP_FAILED) { perror("Error in allocating memory for buffer of tracefile"); @@ -265,11 +265,13 @@ static gint ltt_tracefile_open(LttTrace *t, gchar * fileName, LttTracefile *tf) tf->file_size = lTDFStat.st_size; tf->buf_size = ltt_get_uint32(LTT_GET_BO(tf), &header->buf_size); tf->num_blocks = tf->file_size / tf->buf_size; + tf->events_lost = 0; + tf->subbuf_corrupt = 0; if(munmap(tf->buffer.head, - PAGE_ALIGN(sizeof(ltt_subbuffer_header_t)))) { + PAGE_ALIGN(ltt_subbuffer_header_size()))) { g_warning("unmap size : %u\n", - PAGE_ALIGN(sizeof(ltt_subbuffer_header_t))); + PAGE_ALIGN(ltt_subbuffer_header_size())); perror("munmap error"); g_assert(0); } @@ -286,9 +288,9 @@ static gint ltt_tracefile_open(LttTrace *t, gchar * fileName, LttTracefile *tf) /* Error */ unmap_file: if(munmap(tf->buffer.head, - PAGE_ALIGN(sizeof(ltt_subbuffer_header_t)))) { + PAGE_ALIGN(ltt_subbuffer_header_size()))) { g_warning("unmap size : %u\n", - PAGE_ALIGN(sizeof(ltt_subbuffer_header_t))); + PAGE_ALIGN(ltt_subbuffer_header_size())); perror("munmap error"); g_assert(0); } @@ -772,11 +774,18 @@ LttTrace *ltt_trace_open(const gchar *pathname) goto metadata_error; } - /* Get the trace information for the control/metadata_0 tracefile */ + /* + * Get the trace information for the control/metadata_0 tracefile. + * Getting a correct trace start_time and start_tsc is insured by the fact + * that no subbuffers are supposed to be lost in the metadata channel. + * Therefore, the first subbuffer contains the start_tsc timestamp in its + * buffer header. + */ g_assert(group->len > 0); tf = &g_array_index (group, LttTracefile, 0); header = (ltt_subbuffer_header_t *)tf->buffer.head; - g_assert(parse_trace_header(header, tf, t) == 0); + ret = parse_trace_header(header, tf, t); + g_assert(!ret); t->num_cpu = group->len; @@ -1378,6 +1387,21 @@ static gint map_block(LttTracefile * tf, guint block_num) tf->event.block = block_num; tf->event.offset = 0; + if (header->events_lost) { + g_warning("%d events lost so far in tracefile %s at block %u", + (guint)header->events_lost, + g_quark_to_string(tf->long_name), + block_num); + tf->events_lost = header->events_lost; + } + if (header->subbuf_corrupt) { + g_warning("%d subbuffer(s) corrupted so far in tracefile %s at block %u", + (guint)header->subbuf_corrupt, + g_quark_to_string(tf->long_name), + block_num); + tf->subbuf_corrupt = header->subbuf_corrupt; + } + return 0; map_error: @@ -1468,7 +1492,8 @@ void ltt_update_event_size(LttTracefile *tf) */ if (likely(info && info->fields)) { /* alignment */ - tf->event.data += ltt_align((off_t)tf->event.data, info->largest_align, + tf->event.data += ltt_align((off_t)(unsigned long)tf->event.data, + info->largest_align, info->alignment); /* size, dynamically computed */ if (info->size != -1)