From 63c35f6c3a742bb0bcd558c4899221231bcb05d7 Mon Sep 17 00:00:00 2001 From: compudj Date: Tue, 17 Aug 2004 00:10:18 +0000 Subject: [PATCH] time and TSC _fixed_, get long uint and uint now give guint64 and gint64 git-svn-id: http://ltt.polymtl.ca/svn@797 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/ltt/convert/convert.c | 45 +++++++++---- ltt/branches/poly/ltt/event.c | 66 ++++++++++--------- ltt/branches/poly/ltt/event.h | 8 +-- ltt/branches/poly/ltt/tracefile.c | 8 ++- .../poly/lttv/modules/text/textDump.c | 4 +- 5 files changed, 79 insertions(+), 52 deletions(-) diff --git a/ltt/branches/poly/ltt/convert/convert.c b/ltt/branches/poly/ltt/convert/convert.c index 2fb4d66f..29622190 100644 --- a/ltt/branches/poly/ltt/convert/convert.c +++ b/ltt/branches/poly/ltt/convert/convert.c @@ -75,6 +75,14 @@ typedef struct _buffer_start{ uint32_t block_id; } __attribute__ ((packed)) buffer_start; +typedef struct _buffer_end{ + uint32_t seconds; + uint32_t nanoseconds; + uint64_t cycle_count; + uint32_t block_id; +} __attribute__ ((packed)) buffer_end; + + typedef struct _heartbeat{ uint32_t seconds; uint32_t nanoseconds; @@ -134,7 +142,7 @@ int main(int argc, char ** argv){ uint32_t time_delta, startTimeDelta; void * cur_pos, *end_pos; buffer_start start, start_proc, start_intr; - buffer_start end, end_proc, end_intr; + buffer_end end, end_proc, end_intr; heartbeat beat; uint64_t beat_count; uint32_t size_lost; @@ -289,7 +297,8 @@ int main(int argc, char ** argv){ startId = newId; startTimeDelta = time_delta; start.seconds = tBufStart->Time.tv_sec; - start.nanoseconds = tBufStart->Time.tv_usec; + /* Fix (Mathieu) */ + start.nanoseconds = tBufStart->Time.tv_usec * 1000; start.cycle_count = tBufStart->TSC; start.block_id = tBufStart->ID; end.block_id = start.block_id; @@ -299,11 +308,11 @@ int main(int argc, char ** argv){ ltt_block_size = tStart->BufferSize; ltt_log_cpu = tStart->LogCPUID; - block_size = ltt_block_size; - block_number = file_size/block_size; + block_size = ltt_block_size;//FIXME + block_number = file_size/ltt_block_size; g_free(buffer); - buffer = g_new(char, block_size); + buffer = g_new(char, ltt_block_size); buf_fac = g_new(char, block_size); write_pos_fac = buf_fac; buf_intr = g_new(char, block_size); @@ -330,8 +339,8 @@ int main(int argc, char ** argv){ write_pos_fac = buf_fac; write_pos_proc = buf_proc; - memset((void*)buffer,0,block_size); - readFile(fd,(void*)buffer, block_size, "Unable to read block header"); + memset((void*)buffer,0,ltt_block_size); + readFile(fd,(void*)buffer, ltt_block_size, "Unable to read block header"); cur_pos= buffer; evId = *(uint8_t *)cur_pos; @@ -353,10 +362,10 @@ int main(int argc, char ** argv){ start.block_id = tBufStart->ID; end.block_id = start.block_id; - end_pos = buffer + block_size; //end of the buffer + end_pos = buffer + ltt_block_size; //end of the buffer size_lost = *(uint32_t*)(end_pos - sizeof(uint32_t)); - end_pos = buffer + block_size - size_lost ; //buffer_end event + end_pos = buffer + ltt_block_size - size_lost ; //buffer_end event if(ltt_log_cpu){ tBufEnd = (trace_buffer_end*)(end_pos + 2 * sizeof(uint8_t)+sizeof(uint32_t)); }else{ @@ -455,16 +464,26 @@ int main(int argc, char ** argv){ end.cycle_count = start.cycle_count + beat_count * OVERFLOW_FIGURE; #endif //) - int size = block_size + ((void*)buf_out - write_pos)+ sizeof(uint16_t) + sizeof(uint32_t); - write_to_buffer(write_pos,(void*)&end,sizeof(buffer_start)); + int size = (void*)buf_out + block_size - write_pos + - sizeof(buffer_end) - sizeof(uint32_t); + + /* size _lost_ ? */ + //int size = (void*)buf_out + block_size - write_pos + // + sizeof(uint16_t) + sizeof(uint32_t); + g_assert((void*)write_pos < (void*)buf_out + block_size); + write_to_buffer(write_pos,(void*)&end,sizeof(buffer_end)); write_pos = buf_out + block_size - sizeof(uint32_t); write_to_buffer(write_pos,(void*)&size, sizeof(uint32_t)); write(fdCpu,(void*)buf_out, block_size); //write out processes and intrrupts files { - int size_intr = block_size - (write_pos_intr - (void*)buf_intr); - int size_proc = block_size - (write_pos_proc - (void*)buf_proc); + int size_intr = block_size + (void*)buf_intr - write_pos_intr + - sizeof(buffer_end) - sizeof(uint32_t); + int size_proc = block_size + (void*)buf_proc - write_pos_proc + - sizeof(buffer_end) - sizeof(uint32_t); + //int size_intr = block_size - (write_pos_intr - (void*)buf_intr); + //int size_proc = block_size - (write_pos_proc - (void*)buf_proc); write_to_buffer(write_pos_intr,(void*)&newId,sizeof(uint16_t)); write_to_buffer(write_pos_intr,(void*)&time_delta, sizeof(uint32_t)); end_intr = end; diff --git a/ltt/branches/poly/ltt/event.c b/ltt/branches/poly/ltt/event.c index 56c52f68..438c3597 100644 --- a/ltt/branches/poly/ltt/event.c +++ b/ltt/branches/poly/ltt/event.c @@ -548,7 +548,7 @@ void ltt_event_field_element_select(LttEvent *e, LttField *f, unsigned i) * conversions ****************************************************************************/ -unsigned ltt_event_get_unsigned(LttEvent *e, LttField *f) +guint32 ltt_event_get_unsigned(LttEvent *e, LttField *f) { int revFlag = e->tracefile->trace->my_arch_endian == e->tracefile->trace->system_description->endian ? 0:1; @@ -558,31 +558,34 @@ unsigned ltt_event_get_unsigned(LttEvent *e, LttField *f) if(f->field_size == 1){ guint8 x = *(guint8 *)(e->data + f->offset_root); - return (unsigned int) x; + return (guint32) x; }else if(f->field_size == 2){ guint16 x = *(guint16 *)(e->data + f->offset_root); if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) - return (unsigned int) (revFlag ? GUINT16_FROM_BE(x): x); + return (guint32) (revFlag ? GUINT16_FROM_BE(x): x); else - return (unsigned int) (revFlag ? GUINT16_FROM_LE(x): x); + return (guint32) (revFlag ? GUINT16_FROM_LE(x): x); }else if(f->field_size == 4){ guint32 x = *(guint32 *)(e->data + f->offset_root); if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) - return (unsigned int) (revFlag ? GUINT32_FROM_BE(x): x); + return (guint32) (revFlag ? GUINT32_FROM_BE(x): x); else - return (unsigned int) (revFlag ? GUINT32_FROM_LE(x): x); - }else if(f->field_size == 8){ + return (guint32) (revFlag ? GUINT32_FROM_LE(x): x); + } +#if 0 + else if(f->field_size == 8){ guint64 x = *(guint64 *)(e->data + f->offset_root); if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) return (unsigned int) (revFlag ? GUINT64_FROM_BE(x): x); else return (unsigned int) (revFlag ? GUINT64_FROM_LE(x): x); } +#endif //0 g_critical("ltt_event_get_unsigned : field size %i unknown", f->field_size); return 0; } -int ltt_event_get_int(LttEvent *e, LttField *f) +gint32 ltt_event_get_int(LttEvent *e, LttField *f) { int revFlag = e->tracefile->trace->my_arch_endian == e->tracefile->trace->system_description->endian ? 0:1; @@ -591,31 +594,34 @@ int ltt_event_get_int(LttEvent *e, LttField *f) if(f->field_size == 1){ gint8 x = *(gint8 *)(e->data + f->offset_root); - return (int) x; + return (gint32) x; }else if(f->field_size == 2){ gint16 x = *(gint16 *)(e->data + f->offset_root); if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) - return (int) (revFlag ? GINT16_FROM_BE(x): x); + return (gint32) (revFlag ? GINT16_FROM_BE(x): x); else - return (int) (revFlag ? GINT16_FROM_LE(x): x); + return (gint32) (revFlag ? GINT16_FROM_LE(x): x); }else if(f->field_size == 4){ gint32 x = *(gint32 *)(e->data + f->offset_root); if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) - return (int) (revFlag ? GINT32_FROM_BE(x): x); + return (gint32) (revFlag ? GINT32_FROM_BE(x): x); else - return (int) (revFlag ? GINT32_FROM_LE(x): x); - }else if(f->field_size == 8){ + return (gint32) (revFlag ? GINT32_FROM_LE(x): x); + } +#if 0 + else if(f->field_size == 8){ gint64 x = *(gint64 *)(e->data + f->offset_root); if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) return (int) (revFlag ? GINT64_FROM_BE(x): x); else return (int) (revFlag ? GINT64_FROM_LE(x): x); } +#endif //0 g_critical("ltt_event_get_int : field size %i unknown", f->field_size); return 0; } -unsigned long ltt_event_get_long_unsigned(LttEvent *e, LttField *f) +guint64 ltt_event_get_long_unsigned(LttEvent *e, LttField *f) { int revFlag = e->tracefile->trace->my_arch_endian == e->tracefile->trace->system_description->endian ? 0:1; @@ -625,31 +631,31 @@ unsigned long ltt_event_get_long_unsigned(LttEvent *e, LttField *f) if(f->field_size == 1){ guint8 x = *(guint8 *)(e->data + f->offset_root); - return (unsigned long) x; + return (guint64) x; }else if(f->field_size == 2){ guint16 x = *(guint16 *)(e->data + f->offset_root); if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) - return (unsigned long) (revFlag ? GUINT16_FROM_BE(x): x); + return (guint64) (revFlag ? GUINT16_FROM_BE(x): x); else - return (unsigned long) (revFlag ? GUINT16_FROM_LE(x): x); + return (guint64) (revFlag ? GUINT16_FROM_LE(x): x); }else if(f->field_size == 4){ guint32 x = *(guint32 *)(e->data + f->offset_root); if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) - return (unsigned long) (revFlag ? GUINT32_FROM_BE(x): x); + return (guint64) (revFlag ? GUINT32_FROM_BE(x): x); else - return (unsigned long) (revFlag ? GUINT32_FROM_LE(x): x); + return (guint64) (revFlag ? GUINT32_FROM_LE(x): x); }else if(f->field_size == 8){ guint64 x = *(guint64 *)(e->data + f->offset_root); if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) - return (unsigned long) (revFlag ? GUINT64_FROM_BE(x): x); + return (guint64) (revFlag ? GUINT64_FROM_BE(x): x); else - return (unsigned long) (revFlag ? GUINT64_FROM_LE(x): x); + return (guint64) (revFlag ? GUINT64_FROM_LE(x): x); } g_critical("ltt_event_get_long_unsigned : field size %i unknown", f->field_size); return 0; } -long int ltt_event_get_long_int(LttEvent *e, LttField *f) +gint64 ltt_event_get_long_int(LttEvent *e, LttField *f) { int revFlag = e->tracefile->trace->my_arch_endian == e->tracefile->trace->system_description->endian ? 0:1; @@ -658,25 +664,25 @@ long int ltt_event_get_long_int(LttEvent *e, LttField *f) if(f->field_size == 1){ gint8 x = *(gint8 *)(e->data + f->offset_root); - return (long) x; + return (gint64) x; }else if(f->field_size == 2){ gint16 x = *(gint16 *)(e->data + f->offset_root); if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) - return (long) (revFlag ? GINT16_FROM_BE(x): x); + return (gint64) (revFlag ? GINT16_FROM_BE(x): x); else - return (long) (revFlag ? GINT16_FROM_LE(x): x); + return (gint64) (revFlag ? GINT16_FROM_LE(x): x); }else if(f->field_size == 4){ gint32 x = *(gint32 *)(e->data + f->offset_root); if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) - return (long) (revFlag ? GINT32_FROM_BE(x): x); + return (gint64) (revFlag ? GINT32_FROM_BE(x): x); else - return (long) (revFlag ? GINT32_FROM_LE(x): x); + return (gint64) (revFlag ? GINT32_FROM_LE(x): x); }else if(f->field_size == 8){ gint64 x = *(gint64 *)(e->data + f->offset_root); if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) - return (long) (revFlag ? GINT64_FROM_BE(x): x); + return (gint64) (revFlag ? GINT64_FROM_BE(x): x); else - return (long) (revFlag ? GINT64_FROM_LE(x): x); + return (gint64) (revFlag ? GINT64_FROM_LE(x): x); } g_critical("ltt_event_get_long_int : field size %i unknown", f->field_size); return 0; diff --git a/ltt/branches/poly/ltt/event.h b/ltt/branches/poly/ltt/event.h index c3500120..f1371075 100644 --- a/ltt/branches/poly/ltt/event.h +++ b/ltt/branches/poly/ltt/event.h @@ -114,13 +114,13 @@ unsigned ltt_event_field_union_member(LttEvent *e, LttField *f); /* These functions extract data from an event after architecture specific conversions. */ -unsigned ltt_event_get_unsigned(LttEvent *e, LttField *f); +guint32 ltt_event_get_unsigned(LttEvent *e, LttField *f); -int ltt_event_get_int(LttEvent *e, LttField *f); +gint32 ltt_event_get_int(LttEvent *e, LttField *f); -unsigned long ltt_event_get_long_unsigned(LttEvent *e, LttField *f); +guint64 ltt_event_get_long_unsigned(LttEvent *e, LttField *f); -long int ltt_event_get_long_int(LttEvent *e, LttField *f); +gint64 ltt_event_get_long_int(LttEvent *e, LttField *f); float ltt_event_get_float(LttEvent *e, LttField *f); diff --git a/ltt/branches/poly/ltt/tracefile.c b/ltt/branches/poly/ltt/tracefile.c index 67c0efe4..acd9954b 100644 --- a/ltt/branches/poly/ltt/tracefile.c +++ b/ltt/branches/poly/ltt/tracefile.c @@ -1350,9 +1350,11 @@ int readBlock(LttTracefile * tf, int whichBlock) tf->a_block_start=(BlockStart *) (tf->buffer + EVENT_HEADER_SIZE); lostSize = *(guint32 *)(tf->buffer + tf->block_size - sizeof(guint32)); - tf->a_block_end=(BlockEnd *)(tf->buffer + tf->block_size - - lostSize + EVENT_HEADER_SIZE); - tf->last_event_pos = tf->buffer + tf->block_size - lostSize; + tf->a_block_end=(BlockEnd *)(tf->buffer + tf->block_size + - sizeof(guint32) - lostSize - sizeof(BlockEnd)); + tf->last_event_pos = tf->buffer + tf->block_size - + sizeof(guint32) - lostSize + - sizeof(BlockEnd) - EVENT_HEADER_SIZE; tf->which_block = whichBlock; tf->which_event = 1; diff --git a/ltt/branches/poly/lttv/modules/text/textDump.c b/ltt/branches/poly/lttv/modules/text/textDump.c index 5c4cd426..ded3c897 100644 --- a/ltt/branches/poly/lttv/modules/text/textDump.c +++ b/ltt/branches/poly/lttv/modules/text/textDump.c @@ -63,11 +63,11 @@ void print_field(LttEvent *e, LttField *f, GString *s, gboolean field_names) { type = ltt_field_type(f); switch(ltt_type_class(type)) { case LTT_INT: - g_string_append_printf(s, " %ld", ltt_event_get_long_int(e,f)); + g_string_append_printf(s, " %lld", ltt_event_get_long_int(e,f)); break; case LTT_UINT: - g_string_append_printf(s, " %lu", ltt_event_get_long_unsigned(e,f)); + g_string_append_printf(s, " %llu", ltt_event_get_long_unsigned(e,f)); break; case LTT_FLOAT: -- 2.34.1