X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Fconvert%2Fconvert.c;h=efacdcb630690bcc464689a7d3d82a9f2e4d5957;hb=cf74a6f1dc8fdeb7f7216d1c22f89fff405f9df1;hp=ccec523fc029da3683718b65adfa8660eacc0f1d;hpb=acd767ee11976fedd7455f3891d7f11d75d550df;p=lttv.git diff --git a/ltt/branches/poly/ltt/convert/convert.c b/ltt/branches/poly/ltt/convert/convert.c index ccec523f..efacdcb6 100644 --- a/ltt/branches/poly/ltt/convert/convert.c +++ b/ltt/branches/poly/ltt/convert/convert.c @@ -1,8 +1,11 @@ #include +#include #include #include #include -#include +#include +#include +#include #include #include "LTTTypes.h" @@ -13,7 +16,7 @@ #define PROCESS_EXIT_ID 21 #define INFO_ENTRY 9 -#define OVERFLOW_FIGURE 4294967296 +#define OVERFLOW_FIGURE 0x100000000ULL typedef struct _new_process { @@ -30,10 +33,14 @@ do\ int readFile(int fd, void * buf, size_t size, char * mesg) { - ssize_t nbBytes; - nbBytes = read(fd, buf, size); - if(nbBytes != size){ - printf("%s\n",mesg); + ssize_t nbBytes = read(fd, buf, size); + + if((size_t)nbBytes != size) { + if(nbBytes < 0) { + perror("Error in readFile : "); + } else { + printf("%s\n",mesg); + } exit(1); } return 0; @@ -92,12 +99,12 @@ int main(int argc, char ** argv){ char hardware_platform[BUFFER_SIZE]; char operating_system[BUFFER_SIZE]; int cpu; - int ltt_block_size; - int ltt_major_version; - int ltt_minor_version; + int ltt_block_size=0; + int ltt_major_version=0; + int ltt_minor_version=0; int ltt_log_cpu; char buf[BUFFER_SIZE]; - int i,j, k; + int i, k; uint8_t cpu_id; @@ -124,7 +131,7 @@ int main(int argc, char ** argv){ trace_file_system * tFileSys; uint16_t newId, startId, tmpId; uint8_t evId; - uint32_t time_delta, startTimeDelta, previous_time_delta; + uint32_t time_delta, startTimeDelta; void * cur_pos, *end_pos; buffer_start start, start_proc, start_intr; buffer_start end, end_proc, end_intr; @@ -137,7 +144,8 @@ int main(int argc, char ** argv){ new_process process; if(argc < 4){ - printf("Not enough parameters\n"); + printf("Usage : ./convert processfile_name number_of_cpu tracefile1 tracefile2 ... trace_creation_directory\n"); + printf("For more details, see README.\n"); exit(1); } @@ -305,7 +313,7 @@ int main(int argc, char ** argv){ buf_out = g_new(char, block_size); write_pos = buf_out; - sprintf(cpuStr,"%s/%d\0",foo_cpu,k); + sprintf(cpuStr,"%s/%d",foo_cpu,k); fdCpu = open(cpuStr, O_CREAT | O_RDWR | O_TRUNC,S_IRUSR |S_IWUSR | S_IRGRP | S_IROTH); //for cpu k if(fdCpu < 0) g_error("Unable to open cpu file %d\n", k); lseek(fd,0,SEEK_SET); @@ -338,7 +346,6 @@ int main(int argc, char ** argv){ startId = newId; startTimeDelta = time_delta; - previous_time_delta = time_delta; start.seconds = tBufStart->Time.tv_sec; start.nanoseconds = tBufStart->Time.tv_usec; start.cycle_count = tBufStart->TSC; @@ -437,16 +444,13 @@ int main(int argc, char ** argv){ time_delta = *(uint32_t*)cur_pos; cur_pos += sizeof(uint32_t); - if(time_delta < previous_time_delta){ - end.cycle_count += OVERFLOW_FIGURE; - } - previous_time_delta = time_delta; - //write event_id and time_delta write_to_buffer(write_pos,(void*)&newId,sizeof(uint16_t)); write_to_buffer(write_pos,(void*)&time_delta, sizeof(uint32_t)); if(evId == TRACE_BUFFER_END){ + end.cycle_count = start.cycle_count + + beat_count * OVERFLOW_FIGURE; 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)); write_pos = buf_out + block_size - sizeof(uint32_t); @@ -556,10 +560,9 @@ int main(int argc, char ** argv){ beat_count++; beat.seconds = 0; beat.nanoseconds = 0; - beat.cycle_count = start.cycle_count + beat_count * OVERFLOW_FIGURE; + beat.cycle_count = (uint64_t)start.cycle_count + + (uint64_t)beat_count * OVERFLOW_FIGURE; event_size = 0; - - // end.cycle_count += OVERFLOW_FIGURE; write_to_buffer(write_pos_intr,(void*)&newId, sizeof(uint16_t)); write_to_buffer(write_pos_intr,(void*)&timeDelta, sizeof(uint32_t)); @@ -618,22 +621,22 @@ int main(int argc, char ** argv){ //write to system.xml - fprintf(fp,"\n"); fprintf(fp,"This is just a test\n"); fprintf(fp,"\n"); @@ -644,5 +647,6 @@ int main(int argc, char ** argv){ close(fdProc); fclose(fp); + return 0; }