X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Fconvert%2Fconvert.c;h=b996b8b2bffc914e9e3997a2fc2145a45922fd56;hb=e4eced0fb7cd23ba2b16eff08f2185bed49ab5e5;hp=8bead005964dc0c5560c8d2b7df4e5a3e2f0e4c0;hpb=c9e8ac961da21abe4748d38bdb0f43cce273a052;p=lttv.git diff --git a/ltt/branches/poly/ltt/convert/convert.c b/ltt/branches/poly/ltt/convert/convert.c index 8bead005..b996b8b2 100644 --- a/ltt/branches/poly/ltt/convert/convert.c +++ b/ltt/branches/poly/ltt/convert/convert.c @@ -9,9 +9,18 @@ #include "LinuxEvents.h" #define TRACE_HEARTBEAT_ID 19 +#define PROCESS_FORK_ID 20 +#define PROCESS_EXIT_ID 21 + #define INFO_ENTRY 9 #define OVERFLOW_FIGURE 4294967296 +typedef struct _new_process +{ + uint32_t event_data1; /* Data associated with event */ + uint32_t event_data2; +} LTT_PACKED_STRUCT new_process; + #define write_to_buffer(DEST, SRC, SIZE) \ do\ {\ @@ -113,9 +122,9 @@ int main(int argc, char ** argv){ trace_buffer_start *tBufStart; trace_buffer_end *tBufEnd; trace_file_system * tFileSys; - uint16_t newId, startId; + uint16_t newId, startId, tmpId; uint8_t evId; - uint32_t time_delta, startTimeDelta; + uint32_t time_delta, startTimeDelta, previous_time_delta; void * cur_pos, *end_pos; buffer_start start, start_proc, start_intr; buffer_start end, end_proc, end_intr; @@ -125,6 +134,8 @@ int main(int argc, char ** argv){ uint32_t size_lost; int reserve_size = sizeof(buffer_start) + sizeof(uint16_t) + 2*sizeof(uint32_t);//lost_size and buffer_end event + new_process process; + if(argc != 4 && argc != 5){ printf("need a trace file and cpu number or root directory for the new tracefile\n"); exit(1); @@ -333,6 +344,7 @@ 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; @@ -367,13 +379,13 @@ int main(int argc, char ** argv){ write_to_buffer(write_pos_intr,(void*)&startId, sizeof(uint16_t)); write_to_buffer(write_pos_intr,(void*)&startTimeDelta, sizeof(uint32_t)); start_intr = start; - start_intr.nanoseconds -= 40; + start_intr.nanoseconds -= 20; write_to_buffer(write_pos_intr,(void*)&start_intr, sizeof(buffer_start)); write_to_buffer(write_pos_proc,(void*)&startId, sizeof(uint16_t)); write_to_buffer(write_pos_proc,(void*)&startTimeDelta, sizeof(uint32_t)); start_proc = start; - start_proc.nanoseconds -= 20; + start_proc.nanoseconds -= 40; write_to_buffer(write_pos_proc,(void*)&start_proc, sizeof(buffer_start)); //parse *.proc file to get process and irq info @@ -383,7 +395,6 @@ int main(int argc, char ** argv){ char lName[256]; /* Process name */ FILE * fProc; uint16_t defaultId; - trace_process process; trace_irq_entry irq; fProc = fopen(argv[2],"r"); @@ -392,13 +403,12 @@ int main(int argc, char ** argv){ } while(fscanf(fProc, "PID: %d; PPID: %d; NAME: %s\n", &lPID, &lPPID, lName) > 0){ - defaultId = TRACE_PROCESS; - process.event_sub_id = TRACE_PROCESS_FORK; + defaultId = PROCESS_FORK_ID; process.event_data1 = lPID; process.event_data2 = lPPID; write_to_buffer(write_pos_proc,(void*)&defaultId, sizeof(uint16_t)); write_to_buffer(write_pos_proc,(void*)&startTimeDelta, sizeof(uint32_t)); - write_to_buffer(write_pos_proc,(void*)&process, sizeof(trace_process)); + write_to_buffer(write_pos_proc,(void*)&process, sizeof(new_process)); } while(fscanf(fProc, "IRQ: %d; NAME: ", &lIntID) > 0){ @@ -439,6 +449,11 @@ 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; + if(ltt_log_cpu){ write_to_buffer(write_pos[cpu_id],(void*)&newId,sizeof(uint16_t)); write_to_buffer(write_pos[cpu_id],(void*)&time_delta, sizeof(uint32_t)); @@ -475,13 +490,13 @@ int main(int argc, char ** argv){ 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; - end_intr.nanoseconds += 20; + end_intr.nanoseconds -= 20; write_to_buffer(write_pos_intr,(void*)&end_intr,sizeof(buffer_start)); write_to_buffer(write_pos_proc,(void*)&newId,sizeof(uint16_t)); write_to_buffer(write_pos_proc,(void*)&time_delta, sizeof(uint32_t)); end_proc = end; - end_proc.nanoseconds += 40; + end_proc.nanoseconds -= 40; write_to_buffer(write_pos_proc,(void*)&end_proc,sizeof(buffer_start)); write_pos_intr = buf_intr + block_size - sizeof(uint32_t); @@ -539,9 +554,13 @@ int main(int argc, char ** argv){ timeDelta = time_delta; subId = *(uint8_t*)cur_pos; if(subId == TRACE_PROCESS_FORK || subId ==TRACE_PROCESS_EXIT){ - write_to_buffer(write_pos_proc,(void*)&newId, sizeof(uint16_t)); + if( subId == TRACE_PROCESS_FORK)tmpId = PROCESS_FORK_ID; + else tmpId = PROCESS_EXIT_ID; + write_to_buffer(write_pos_proc,(void*)&tmpId, sizeof(uint16_t)); write_to_buffer(write_pos_proc,(void*)&timeDelta, sizeof(uint32_t)); - write_to_buffer(write_pos_proc,cur_pos, event_size); + + process = *(new_process*)(cur_pos + sizeof(uint8_t)); + write_to_buffer(write_pos_proc,(void*)&process, sizeof(new_process)); } break; case TRACE_FILE_SYSTEM: @@ -569,7 +588,7 @@ int main(int argc, char ** argv){ beat.cycle_count = start.cycle_count + beat_count * OVERFLOW_FIGURE; event_size = 0; - end.cycle_count += OVERFLOW_FIGURE; + // 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));