X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Fconvert%2Fconvert.c;h=5f2de35fb5dc9902143700e98ccffc1841e199e8;hb=f628823c5712cc8b8bfe10ade63b6c7c2862f5e5;hp=a13daaf2a8b05b33da7cfe445d1312759889e119;hpb=8ee1c3d5b10c782b2785d39215727ff031983529;p=lttv.git diff --git a/ltt/branches/poly/ltt/convert/convert.c b/ltt/branches/poly/ltt/convert/convert.c index a13daaf2..5f2de35f 100644 --- a/ltt/branches/poly/ltt/convert/convert.c +++ b/ltt/branches/poly/ltt/convert/convert.c @@ -1,3 +1,7 @@ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include @@ -111,6 +115,7 @@ int main(int argc, char ** argv){ int ltt_major_version=0; int ltt_minor_version=0; int ltt_log_cpu; + guint ltt_trace_start_size = 0; char buf[BUFFER_SIZE]; int i, k; @@ -133,7 +138,7 @@ int main(int argc, char ** argv){ char * buffer, *buf_out, cpuStr[4*BUFFER_SIZE]; char * buf_fac, * buf_intr, * buf_proc; void * write_pos, *write_pos_fac, * write_pos_intr, *write_pos_proc; - trace_start *tStart; + trace_start_any *tStart; trace_buffer_start *tBufStart; trace_buffer_end *tBufEnd; trace_file_system * tFileSys; @@ -146,7 +151,9 @@ int main(int argc, char ** argv){ heartbeat beat; uint64_t adaptation_tsc; // (Mathieu) uint32_t size_lost; - int reserve_size = sizeof(buffer_start) + sizeof(uint16_t) + 2*sizeof(uint32_t);//lost_size and buffer_end event + int reserve_size = sizeof(buffer_start) + + sizeof(buffer_end) + //buffer_end event + sizeof(uint32_t); //lost size int nb_para; new_process process; @@ -290,9 +297,16 @@ int main(int argc, char ** argv){ cur_pos += sizeof(uint16_t); //Skip event size evId = *(uint8_t *)cur_pos; - cur_pos += sizeof(uint8_t); - cur_pos += sizeof(uint32_t); - tStart = (trace_start*)cur_pos; + g_assert(evId == TRACE_START); + cur_pos += sizeof(uint8_t); //skip EvId + cur_pos += sizeof(uint32_t); //skip time delta + tStart = (trace_start_any*)cur_pos; + if(tStart->MagicNumber != TRACER_MAGIC_NUMBER) + g_error("Trace magic number does not match : %x, should be %x", + tStart->MagicNumber, TRACER_MAGIC_NUMBER); + if(tStart->MajorVersion != TRACER_SUP_VERSION_MAJOR) + g_error("Trace Major number does match : %hu, should be %u", + tStart->MajorVersion, TRACER_SUP_VERSION_MAJOR); startId = newId; startTimeDelta = time_delta; @@ -303,10 +317,44 @@ int main(int argc, char ** argv){ start.block_id = tBufStart->ID; end.block_id = start.block_id; - ltt_major_version = tStart->MajorVersion; - ltt_minor_version = tStart->MinorVersion; - ltt_block_size = tStart->BufferSize; - ltt_log_cpu = tStart->LogCPUID; + + g_printf("Trace version %hu.%hu detected\n", + tStart->MajorVersion, + tStart->MinorVersion); + if(tStart->MinorVersion == 2) { + trace_start_2_2* tStart_2_2 = (trace_start_2_2*)tStart; + ltt_major_version = tStart_2_2->MajorVersion; + ltt_minor_version = tStart_2_2->MinorVersion; + ltt_block_size = tStart_2_2->BufferSize; + ltt_log_cpu = tStart_2_2->LogCPUID; + ltt_trace_start_size = sizeof(trace_start_2_2); + /* Verify if it's a broken 2.2 format */ + if(*(uint8_t*)(cur_pos + sizeof(trace_start_2_2)) == 0) { + /* Cannot have two trace start events. We cannot detect the problem + * if the flight recording flag is set to 1, as it conflicts + * with TRACE_SYSCALL_ENTRY. + */ + g_warning("This is a 2.3 trace format that has a 2.2 tag. Please upgrade your kernel"); + g_printf("Processing the trace as a 2.3 format\n"); + + tStart->MinorVersion = 3; + } + } + + if(tStart->MinorVersion == 3) { + trace_start_2_3* tStart_2_3 = (trace_start_2_3*)tStart; + ltt_major_version = tStart_2_3->MajorVersion; + ltt_minor_version = tStart_2_3->MinorVersion; + ltt_block_size = tStart_2_3->BufferSize; + ltt_log_cpu = tStart_2_3->LogCPUID; + ltt_trace_start_size = sizeof(trace_start_2_3); + /* We do not use the flight recorder information for now, because we + * never use the .proc file anyway */ + } + + if(ltt_trace_start_size == 0) + g_error("Minor version unknown : %hu. Supported minors : 2, 3", + tStart->MinorVersion); block_size = ltt_block_size;//FIXME block_number = file_size/ltt_block_size; @@ -380,7 +428,7 @@ int main(int argc, char ** argv){ //the first block adaptation_tsc = (uint64_t)tBufStart->TSC; cur_pos = buffer + sizeof(trace_buffer_start) - + sizeof(trace_start) + + ltt_trace_start_size + 2*(sizeof(uint8_t) + sizeof(uint16_t)+sizeof(uint32_t)); } else { @@ -480,8 +528,20 @@ int main(int argc, char ** argv){ //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)); - + + /* Fix (Mathieu) */ + if(time_delta < (0xFFFFFFFFULL&adaptation_tsc)) { + /* Overflow */ + adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + 0x100000000ULL + + (uint64_t)time_delta; + } else { + /* No overflow */ + adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + time_delta; + } + + if(evId == TRACE_BUFFER_END){ +#if 0 /* Fix (Mathieu) */ if(time_delta < (0xFFFFFFFFULL&adaptation_tsc)) { /* Overflow */ @@ -491,7 +551,7 @@ int main(int argc, char ** argv){ /* No overflow */ adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + time_delta; } - +#endif //0 end.cycle_count = adaptation_tsc; int size = (void*)buf_out + block_size - write_pos - sizeof(buffer_end) - sizeof(uint32_t); @@ -609,16 +669,6 @@ int main(int argc, char ** argv){ event_size = sizeof(trace_network); break; case TRACE_HEARTBEAT: - /* Fix (Mathieu) */ - if(time_delta < (0xFFFFFFFFULL&adaptation_tsc)) { - /* Overflow */ - adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + 0x100000000ULL - + (uint64_t)time_delta; - } else { - /* No overflow */ - adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + time_delta; - } - beat.seconds = 0; beat.nanoseconds = 0; beat.cycle_count = adaptation_tsc; @@ -707,6 +757,8 @@ int main(int argc, char ** argv){ close(fdProc); fclose(fp); + g_printf("Conversion completed. Don't forget to copy core.xml to eventdefs directory\n"); + return 0; }