From 823820eb1852619c9a24af4a01622356214c01b4 Mon Sep 17 00:00:00 2001 From: compudj Date: Tue, 23 Aug 2005 23:33:05 +0000 Subject: [PATCH] fix offset from header git-svn-id: http://ltt.polymtl.ca/svn@1068 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/ltt/ltt-private.h | 7 ++----- ltt/branches/poly/ltt/tracefile.c | 26 ++++++++++++++++++-------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/ltt/branches/poly/ltt/ltt-private.h b/ltt/branches/poly/ltt/ltt-private.h index 6a0c4578..b525f9d7 100644 --- a/ltt/branches/poly/ltt/ltt-private.h +++ b/ltt/branches/poly/ltt/ltt-private.h @@ -47,7 +47,6 @@ #define LTT_GET_FLOAT_BO(t) \ (((t)->float_word_order==__BYTE_ORDER)?0:1) - /* Hardcoded core events */ enum ltt_core_events { LTT_EVENT_FACILITY_LOAD, @@ -188,10 +187,6 @@ struct ltt_block_start_header { } LTT_PACKED_STRUCT; - - - - struct _LttType{ GQuark type_name; //type name if it is a named type GQuark element_name; //elements name of the struct @@ -353,6 +348,8 @@ struct _LttTracefile{ gboolean reverse_bo; //must we reverse byte order ? gboolean float_word_order; //what is the byte order of floats ? + size_t buffer_header_size; + /* Current event */ LttEvent event; //Event currently accessible in the trace diff --git a/ltt/branches/poly/ltt/tracefile.c b/ltt/branches/poly/ltt/tracefile.c index 1f7249da..c9564bf4 100644 --- a/ltt/branches/poly/ltt/tracefile.c +++ b/ltt/branches/poly/ltt/tracefile.c @@ -234,7 +234,9 @@ int parse_trace_header(void *header, LttTracefile *tf, LttTrace *t) { 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: @@ -289,7 +291,9 @@ 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(struct ltt_block_start_header))){ + if(lTDFStat.st_size < + (off_t)(sizeof(struct ltt_block_start_header + + sizeof(ltt_trace_header_any)))){ g_print("The input data file %s does not contain a trace\n", fileName); goto close_file; } @@ -297,7 +301,8 @@ 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(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"); @@ -315,9 +320,11 @@ gint ltt_tracefile_open(LttTrace *t, gchar * fileName, LttTracefile *tf) 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); } @@ -334,9 +341,11 @@ gint ltt_tracefile_open(LttTrace *t, gchar * fileName, LttTracefile *tf) /* 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); } @@ -1851,7 +1860,8 @@ static int ltt_seek_next_event(LttTracefile *tf) /* 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 += sizeof(struct ltt_block_start_header + + tf->buffer_header_size); if(tf->event.offset == tf->buf_size - tf->buffer.lost_size) { ret = ERANGE; -- 2.34.1