X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Fconvert%2Fconvert.c;h=60dc3a6031498a751fcb14726df56d5577a8a0cb;hb=9ca560eb801f018c5cbc64c24b66b36e52b8ba32;hp=67ee263080e2579d49153a63089063360291660f;hpb=160d4bdbeb06b0d2aab920a77193253eaae1a162;p=lttv.git diff --git a/ltt/branches/poly/ltt/convert/convert.c b/ltt/branches/poly/ltt/convert/convert.c index 67ee2630..60dc3a60 100644 --- a/ltt/branches/poly/ltt/convert/convert.c +++ b/ltt/branches/poly/ltt/convert/convert.c @@ -8,6 +8,19 @@ #include "LTTTypes.h" #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\ {\ @@ -109,38 +122,40 @@ 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; void * cur_pos, *end_pos; - buffer_start start; - buffer_start end; + buffer_start start, start_proc, start_intr; + buffer_start end, end_proc, end_intr; heartbeat beat; int beat_count = 0; gboolean * has_event; uint32_t size_lost; int reserve_size = sizeof(buffer_start) + sizeof(uint16_t) + 2*sizeof(uint32_t);//lost_size and buffer_end event - if(argc != 3 && argc != 4){ + 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); } - if(argc == 3){ + if(argc == 4){ strcpy(foo, "foo"); strcpy(foo_eventdefs, "foo/eventdefs"); strcpy(foo_control, "foo/control"); strcpy(foo_cpu, "foo/cpu"); strcpy(foo_info, "foo/info"); }else{ - strcpy(foo, argv[3]); - strcpy(foo_eventdefs, argv[3]); + strcpy(foo, argv[4]); + strcpy(foo_eventdefs, argv[4]); strcat(foo_eventdefs,"/eventdefs"); - strcpy(foo_control, argv[3]); + strcpy(foo_control, argv[4]); strcat(foo_control,"/control"); - strcpy(foo_cpu, argv[3]); + strcpy(foo_cpu, argv[4]); strcat(foo_cpu,"/cpu"); - strcpy(foo_info, argv[3]); + strcpy(foo_info, argv[4]); strcat(foo_info,"/info"); } strcpy(foo_control_facilities, foo_control); @@ -152,7 +167,7 @@ int main(int argc, char ** argv){ strcpy(foo_info_system, foo_info); strcat(foo_info_system, "/system.xml"); - cpu = atoi(argv[2]); + cpu = atoi(argv[3]); printf("cpu number = %d\n", cpu); @@ -164,7 +179,7 @@ int main(int argc, char ** argv){ g_error("Unable to open file sysInfo.out\n"); } - for(i=0;i<9;i++){ + for(i=0;i 0){ + 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(new_process)); + } + + while(fscanf(fProc, "IRQ: %d; NAME: ", &lIntID) > 0){ + /* Read 'til the end of the line */ + fgets(lName, 200, fProc); + + defaultId = TRACE_IRQ_ENTRY; + irq.irq_id = lIntID; + irq.kernel = 1; + write_to_buffer(write_pos_intr,(void*)&defaultId, sizeof(uint16_t)); + write_to_buffer(write_pos_intr,(void*)&startTimeDelta, sizeof(uint32_t)); + write_to_buffer(write_pos_intr,(void*)&irq, sizeof(trace_irq_entry)); + } + fclose(fProc); + } while(1){ int event_size; @@ -384,6 +441,9 @@ int main(int argc, char ** argv){ } evId = *(uint8_t *)cur_pos; newId = evId; + if(evId == TRACE_HEARTBEAT) { + newId = TRACE_HEARTBEAT_ID; + } cur_pos += sizeof(uint8_t); time_delta = *(uint32_t*)cur_pos; cur_pos += sizeof(uint32_t); @@ -419,12 +479,22 @@ int main(int argc, char ** argv){ //write out processes and intrrupts files { - int size_intr =(int) (write_pos_intr - (void*)buf_intr); - int size_proc =(int) (write_pos_proc - (void*)buf_proc); - write_to_buffer(write_pos_intr,(void*)&end,sizeof(buffer_start)); - write_to_buffer(write_pos_proc,(void*)&end,sizeof(buffer_start)); + 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; + 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; + write_to_buffer(write_pos_proc,(void*)&end_proc,sizeof(buffer_start)); + write_pos_intr = buf_intr + block_size - sizeof(uint32_t); - write_pos_proc = buf_intr + block_size - sizeof(uint32_t); + write_pos_proc = buf_proc + block_size - sizeof(uint32_t); write_to_buffer(write_pos_intr,(void*)&size_intr, sizeof(uint32_t)); write_to_buffer(write_pos_proc,(void*)&size_proc, sizeof(uint32_t)); write(fdIntr,(void*)buf_intr,block_size); @@ -451,14 +521,14 @@ int main(int argc, char ** argv){ event_size = sizeof(trace_irq_entry); timeDelta = time_delta; write_to_buffer(write_pos_intr,(void*)&newId, sizeof(uint16_t)); - write_to_buffer(write_pos_intr,(void*)&timeDelta, sizeof(uint64_t)); + write_to_buffer(write_pos_intr,(void*)&timeDelta, sizeof(uint32_t)); write_to_buffer(write_pos_intr,cur_pos, event_size); break; case TRACE_IRQ_EXIT: event_size = 0; timeDelta = time_delta; write_to_buffer(write_pos_intr,(void*)&newId, sizeof(uint16_t)); - write_to_buffer(write_pos_intr,(void*)&timeDelta, sizeof(uint64_t)); + write_to_buffer(write_pos_intr,(void*)&timeDelta, sizeof(uint32_t)); break; case TRACE_SCHEDCHANGE: event_size = sizeof(trace_schedchange); @@ -468,19 +538,23 @@ int main(int argc, char ** argv){ break; case TRACE_SOFT_IRQ: event_size = sizeof(trace_soft_irq); - timeDelta = time_delta; - write_to_buffer(write_pos_intr,(void*)&newId, sizeof(uint16_t)); - write_to_buffer(write_pos_intr,(void*)&timeDelta, sizeof(uint64_t)); - write_to_buffer(write_pos_intr,cur_pos, event_size); + // timeDelta = time_delta; + // write_to_buffer(write_pos_intr,(void*)&newId, sizeof(uint16_t)); + // write_to_buffer(write_pos_intr,(void*)&timeDelta, sizeof(uint32_t)); + // write_to_buffer(write_pos_intr,cur_pos, event_size); break; case TRACE_PROCESS: event_size = sizeof(trace_process); 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)); - write_to_buffer(write_pos_proc,(void*)&timeDelta, sizeof(uint64_t)); - write_to_buffer(write_pos_proc,cur_pos, event_size); + 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)); + + process = *(new_process*)(cur_pos + sizeof(uint8_t)); + write_to_buffer(write_pos_proc,(void*)&process, sizeof(new_process)); } break; case TRACE_FILE_SYSTEM: @@ -505,8 +579,17 @@ int main(int argc, char ** argv){ beat_count++; beat.seconds = 0; beat.nanoseconds = 0; - beat.cycle_count = start.cycle_count + beat_count * (0XFFFF+1); + beat.cycle_count = start.cycle_count + 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)); + write_to_buffer(write_pos_intr,(void*)&beat, sizeof(heartbeat)); + write_to_buffer(write_pos_proc,(void*)&newId, sizeof(uint16_t)); + write_to_buffer(write_pos_proc,(void*)&timeDelta, sizeof(uint32_t)); + write_to_buffer(write_pos_proc,(void*)&beat, sizeof(heartbeat)); break; default: event_size = -1;