support 2.2 and 2.3 trace formats
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Sat, 21 Aug 2004 15:18:15 +0000 (15:18 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Sat, 21 Aug 2004 15:18:15 +0000 (15:18 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@824 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/ltt/convert/LinuxEvents.h
ltt/branches/poly/ltt/convert/convert.c

index d678df89c7b88a49f2e3dc447043da1ab93c1ce7..49ae4a8bce0616fb713cb5ebd1d629b34da2d103 100644 (file)
 /* The information logged when the tracing is started */
 #define TRACER_MAGIC_NUMBER        0x00D6B7ED     /* That day marks an important historical event ... */
 #define TRACER_SUP_VERSION_MAJOR            2     /* Major version number */
-#define TRACER_SUP_VERSION_MINOR            2     /* Minor version number */
-typedef struct _trace_start
+
+/* Minimum information contained in any trace start event */
+typedef struct _trace_start_any
+{
+  uint32_t           MagicNumber;      /* Magic number to identify a trace */
+  uint32_t           ArchType;         /* Type of architecture */
+  uint32_t           ArchVariant;      /* Variant of the given type of architecture */
+  uint32_t           SystemType;       /* Operating system type */
+  uint8_t            MajorVersion;     /* Major version of trace */
+  uint8_t            MinorVersion;     /* Minor version of trace */
+
+} LTT_PACKED_STRUCT trace_start_any;
+
+typedef struct _trace_start_2_2
 {
   uint32_t           MagicNumber;      /* Magic number to identify a trace */
   uint32_t           ArchType;         /* Type of architecture */
@@ -85,10 +97,27 @@ typedef struct _trace_start
   trace_event_mask   EventMask;        /* The event mask */
   trace_event_mask   DetailsMask;      /* Are the event details logged */
   uint8_t            LogCPUID;         /* Is the CPUID logged */
-  uint8_t            UseTSC;          /* Are we using TSCs or time deltas */
+  uint8_t            UseTSC;            /* Are we using TSCs or time deltas */
+
+} LTT_PACKED_STRUCT trace_start_2_2;
 
-} LTT_PACKED_STRUCT trace_start;
-#define START_EVENT(X) ((trace_start*)X)
+typedef struct _trace_start_2_3
+{
+  uint32_t           MagicNumber;      /* Magic number to identify a trace */
+  uint32_t           ArchType;         /* Type of architecture */
+  uint32_t           ArchVariant;      /* Variant of the given type of architecture */
+  uint32_t           SystemType;       /* Operating system type */
+  uint8_t            MajorVersion;     /* Major version of trace */
+  uint8_t            MinorVersion;     /* Minor version of trace */
+
+  uint32_t           BufferSize;       /* Size of buffers */
+  trace_event_mask   EventMask;        /* The event mask */
+  trace_event_mask   DetailsMask;      /* Are the event details logged */
+  uint8_t            LogCPUID;         /* Is the CPUID logged */
+  uint8_t            UseTSC;            /* Are we using TSCs or time deltas */
+  
+  uint8_t            FlightRecorder;   /* Is this a flight recorder trace ? */
+} LTT_PACKED_STRUCT trace_start_2_3;
 
 /*  TRACE_SYSCALL_ENTRY */
 typedef struct _trace_syscall_entry
index 58957f4d725bc3d0ca245d68b3f98b6512a14898..51f137934da20a649c18a789e9a91a0ad79eeb20 100644 (file)
@@ -111,6 +111,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;
   char buf[BUFFER_SIZE];
   int i, k;
 
@@ -133,7 +134,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 +147,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;
@@ -291,8 +294,14 @@ int main(int argc, char ** argv){
 
     evId = *(uint8_t *)cur_pos;
     cur_pos += sizeof(uint8_t);
-    cur_pos += sizeof(uint32_t); 
-    tStart = (trace_start*)cur_pos;
+    if(*(uint32_t*)cur_pos != TRACER_MAGIC_NUMBER)
+      g_error("Trace magic number does not match : %lx, should be %lx",
+               (uint32_t*)cur_pos, TRACER_MAGIC_NUMBER);
+    cur_pos += sizeof(uint32_t);
+    tStart = (trace_start_any*)cur_pos;
+    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 +312,27 @@ 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;
+    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);
+    } else 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 */
+    } else {
+      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 +406,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 {
This page took 0.025778 seconds and 4 git commands to generate.