switch(any->minor_version) {
case 3:
{
- struct ltt_trace_header_0_3 *header_0_3 =
- (struct ltt_trace_header_0_3 *)header;
-
+ tf->buffer_header_size =
+ sizeof(struct ltt_block_start_header)
+ + sizeof(struct ltt_trace_header_0_3);
}
break;
default:
}
// Is the file large enough to contain a trace
- if(lTDFStat.st_size < (off_t)(sizeof(struct ltt_block_start_header))){
+ if(lTDFStat.st_size <
+ (off_t)(sizeof(struct ltt_block_start_header)
+ + sizeof(struct ltt_trace_header_any))){
g_print("The input data file %s does not contain a trace\n", fileName);
goto close_file;
}
/* Temporarily map the buffer start header to get trace information */
/* Multiple of pages aligned head */
tf->buffer.head = mmap(0,
- PAGE_ALIGN(sizeof(struct ltt_block_start_header)), PROT_READ,
+ PAGE_ALIGN(sizeof(struct ltt_block_start_header)
+ + sizeof(struct ltt_trace_header_any)), PROT_READ,
MAP_PRIVATE, tf->fd, 0);
if(tf->buffer.head == MAP_FAILED) {
perror("Error in allocating memory for buffer of tracefile");
header = (struct ltt_block_start_header*)tf->buffer.head;
- if(parse_trace_header(header->trace, tf, NULL)) goto unmap_file;
+ if(parse_trace_header(header->trace, tf, NULL)) {
+ g_warning("parse_trace_header error");
+ goto unmap_file;
+ }
//store the size of the file
tf->file_size = lTDFStat.st_size;
tf->num_blocks = tf->file_size / tf->buf_size;
if(munmap(tf->buffer.head,
- PAGE_ALIGN(sizeof(struct ltt_block_start_header)))) {
+ PAGE_ALIGN(sizeof(struct ltt_block_start_header)
+ + sizeof(struct ltt_trace_header_any)))) {
g_warning("unmap size : %u\n",
- PAGE_ALIGN(sizeof(struct ltt_block_start_header)));
+ PAGE_ALIGN(sizeof(struct ltt_block_start_header)
+ + sizeof(struct ltt_trace_header_any)));
perror("munmap error");
g_assert(0);
}
/* Error */
unmap_file:
if(munmap(tf->buffer.head,
- PAGE_ALIGN(sizeof(struct ltt_block_start_header)))) {
+ PAGE_ALIGN(sizeof(struct ltt_block_start_header)
+ + sizeof(struct ltt_trace_header_any)))) {
g_warning("unmap size : %u\n",
- PAGE_ALIGN(sizeof(struct ltt_block_start_header)));
+ PAGE_ALIGN(sizeof(struct ltt_block_start_header)
+ + sizeof(struct ltt_trace_header_any)));
perror("munmap error");
g_assert(0);
}
g_assert(group->len > 0);
tf = &g_array_index (group, LttTracefile, 0);
header = (struct ltt_block_start_header*)tf->buffer.head;
- g_assert(parse_trace_header(header->trace, tf, t) == 0);
+ g_assert(parse_trace_header(header->trace,
+ tf, t) == 0);
t->num_cpu = group->len;
*Get the name of a tracefile
****************************************************************************/
-GQuark ltt_tracefile_name(LttTracefile *tf)
+GQuark ltt_tracefile_name(const LttTracefile *tf)
{
return tf->name;
}
+GQuark ltt_tracefile_long_name(const LttTracefile *tf)
+{
+ return tf->long_name;
+}
+
+
guint ltt_tracefile_num(LttTracefile *tf)
{
} else if(ltt_time_compare(time, tf->buffer.begin.timestamp) < 0) {
/* go to lower part */
- high = block_num;
+ high = block_num - 1;
} else if(ltt_time_compare(time, tf->buffer.end.timestamp) > 0) {
/* go to higher part */
- low = block_num;
+ low = block_num + 1;
} else {/* The event is right in the buffer!
(or in the next buffer first event) */
while(1) {
tf->buffer.begin.timestamp = ltt_get_time(LTT_GET_BO(tf),
&header->begin.timestamp);
tf->buffer.begin.timestamp.tv_nsec *= NSEC_PER_USEC;
- g_debug("block %u begin : %lu.%lu", block_num,
- tf->buffer.begin.timestamp.tv_sec, tf->buffer.begin.timestamp.tv_nsec);
+ //g_debug("block %u begin : %lu.%lu", block_num,
+ // tf->buffer.begin.timestamp.tv_sec, tf->buffer.begin.timestamp.tv_nsec);
tf->buffer.begin.cycle_count = ltt_get_uint64(LTT_GET_BO(tf),
&header->begin.cycle_count);
tf->buffer.end.timestamp = ltt_get_time(LTT_GET_BO(tf),
&header->end.timestamp);
tf->buffer.end.timestamp.tv_nsec *= NSEC_PER_USEC;
- g_debug("block %u end : %lu.%lu", block_num,
- tf->buffer.end.timestamp.tv_sec, tf->buffer.end.timestamp.tv_nsec);
+ //g_debug("block %u end : %lu.%lu", block_num,
+ // tf->buffer.end.timestamp.tv_sec, tf->buffer.end.timestamp.tv_nsec);
tf->buffer.end.cycle_count = ltt_get_uint64(LTT_GET_BO(tf),
&header->end.cycle_count);
tf->buffer.lost_size = ltt_get_uint32(LTT_GET_BO(tf),
switch((enum ltt_core_events)tf->event.event_id) {
case LTT_EVENT_FACILITY_LOAD:
size = strlen((char*)tf->event.data) + 1;
- g_debug("Update Event facility load of facility %s", (char*)tf->event.data);
+ //g_debug("Update Event facility load of facility %s", (char*)tf->event.data);
size += sizeof(struct LttFacilityLoad);
break;
case LTT_EVENT_FACILITY_UNLOAD:
- g_debug("Update Event facility unload");
+ //g_debug("Update Event facility unload");
size = sizeof(struct LttFacilityUnload);
break;
case LTT_EVENT_STATE_DUMP_FACILITY_LOAD:
size = strlen((char*)tf->event.data) + 1;
- g_debug("Update Event facility load state dump of facility %s",
- (char*)tf->event.data);
+ //g_debug("Update Event facility load state dump of facility %s",
+ // (char*)tf->event.data);
size += sizeof(struct LttStateDumpFacilityLoad);
break;
case LTT_EVENT_HEARTBEAT:
- g_debug("Update Event heartbeat");
+ //g_debug("Update Event heartbeat");
size = sizeof(TimeHeartbeat);
break;
default:
else
size = 0;
- g_debug("Event root field : f.e %hhu.%hhu size %zd",
- tf->event.facility_id,
- tf->event.event_id, size);
+ //g_debug("Event root field : f.e %hhu.%hhu size %zd",
+ // tf->event.facility_id,
+ // tf->event.event_id, size);
}
tf->event.data_size = size;
/* seek over the buffer header if we are at the buffer start */
if(tf->event.offset == 0) {
- tf->event.offset += sizeof(struct ltt_block_start_header);
+ tf->event.offset += tf->buffer_header_size;
if(tf->event.offset == tf->buf_size - tf->buffer.lost_size) {
ret = ERANGE;
ret = ERANGE;
goto found;
}
+ g_assert(tf->event.offset < tf->buf_size - tf->buffer.lost_size);
found:
return ret;