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;
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;
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;
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);
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;
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{
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;
* 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;
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;
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;
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;
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;