add per trace and per tracefile optional logging
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Sat, 20 Aug 2005 01:10:25 +0000 (01:10 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Sat, 20 Aug 2005 01:10:25 +0000 (01:10 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1023 04897980-b3bd-0310-b5e0-8ef037075253

genevent/core.xml
genevent/genevent.c
genevent/parser.c
genevent/parser.h

index 0f2aa80e7be75564b314adac2a2f0a6bba4a3bba..c9004d3fc647aa740e10ee77bdd23629c5e9a937 100644 (file)
@@ -21,7 +21,7 @@
     </struct>
   </event>
 
-  <event name=time_heartbeat>
+  <event name=time_heartbeat per_tracefile>
     <description>System time values sent periodically to detect cycle counter
      rollovers. Useful when only the 32 LSB of the TSC are saved in events
      header : we save the full 64 bits in this event.
@@ -29,7 +29,7 @@
     <typeref name=timestamp/>
   </event>
   
-  <event name=state_dump_facility_load>
+  <event name=state_dump_facility_load per_trace>
     <description>Facility is loaded while in state dump</description>
     <struct>
       <field name="name"><string/></field>
index 9c96d81f93fdf2b53a9add70f42187a8913ddc5e..316f15b7a076bf8e44be56b2943a1deb94a1ccf9 100644 (file)
@@ -417,6 +417,7 @@ void generateStructFunc(FILE * fp, char * facName, unsigned long checksum){
   type_descriptor * td;
   int pos, pos1;
   int hasStrSeq, flag, structCount, seqCount,strCount, whichTypeFirst=0;
+  int args_empty;
 
   for(pos = 0; pos < fac->events.position; pos++){
     ev = (event *) fac->events.array[pos];
@@ -457,23 +458,46 @@ void generateStructFunc(FILE * fp, char * facName, unsigned long checksum){
     strCount = 0;
                fprintf(fp, "#ifndef CONFIG_LTT\n");
     fprintf(fp,"static inline void trace_%s_%s(",facName,ev->name);
-    if(ev->type == 0)
-      fprintf(fp, "void");
-    else
+
+    args_empty = 1;
+
+    /* Does it support per trace tracing ? */
+    if(ev->per_trace) {
+      fprintf(fp, "struct ltt_trace_struct *dest_trace");
+      args_empty = 0;
+    }
+    
+    /* Does it support per tracefile tracing ? */
+    if(ev->per_tracefile) {
+      if(!args_empty) fprintf(fp, ", ");
+      fprintf(fp, "unsigned int tracefile_index");
+      args_empty = 0;
+    }
+    
+    if(ev->type != 0) {
       for(pos1 = 0; pos1 < ev->type->fields.position; pos1++){
         fld  = (field *)ev->type->fields.array[pos1];
         td = fld->type;
+        if(!args_empty) fprintf(fp, ", ");
         if(td->type == ARRAY ){
           fprintf(fp,"%s * %s",getTypeStr(td), fld->name);
+          args_empty = 0;
         }else if(td->type == STRING){
           fprintf(fp,"short int strlength_%d, %s * %s",
               ++strCount, getTypeStr(td), fld->name);
-       }else if(td->type == SEQUENCE){
+          args_empty = 0;
+        }else if(td->type == SEQUENCE){
           fprintf(fp,"%s seqlength_%d, %s * %s",
               uintOutputTypes[td->size], ++seqCount,getTypeStr(td), fld->name);
-       }else fprintf(fp,"%s %s",getTypeStr(td), fld->name);     
-       if(pos1 != ev->type->fields.position - 1) fprintf(fp,", ");
+          args_empty = 0;
+        }else {
+          fprintf(fp,"%s %s",getTypeStr(td), fld->name);     
+          args_empty = 0;
+        }
       }
+    }
+    if(args_empty) fprintf(fp, "void");
+
     fprintf(fp,")\n{\n");
     fprintf(fp,"}\n");
                fprintf(fp,"#else\n");
@@ -482,26 +506,47 @@ void generateStructFunc(FILE * fp, char * facName, unsigned long checksum){
     seqCount = 0;
     strCount = 0;
     fprintf(fp,"static inline void trace_%s_%s(",facName,ev->name);
-    if(ev->type == 0)
-      fprintf(fp, "void");
-    else
+
+    args_empty = 1;
+
+    /* Does it support per trace tracing ? */
+    if(ev->per_trace) {
+      fprintf(fp, "struct ltt_trace_struct *dest_trace");
+      args_empty = 0;
+    }
+    
+    /* Does it support per tracefile tracing ? */
+    if(ev->per_tracefile) {
+      if(!args_empty) fprintf(fp, ", ");
+      fprintf(fp, "unsigned int tracefile_index");
+      args_empty = 0;
+    }
+
+    if(ev->type != 0) {
       for(pos1 = 0; pos1 < ev->type->fields.position; pos1++){
         fld  = (field *)ev->type->fields.array[pos1];
         td = fld->type;
+        if(!args_empty) fprintf(fp, ", ");
         if(td->type == ARRAY ){
           fprintf(fp,"%s * %s",getTypeStr(td), fld->name);
+          args_empty = 0;
         }else if(td->type == STRING){
           fprintf(fp,"short int strlength_%d, %s * %s",
               ++strCount, getTypeStr(td), fld->name);
-       }else if(td->type == SEQUENCE){
+          args_empty = 0;
+        }else if(td->type == SEQUENCE){
           fprintf(fp,"%s seqlength_%d, %s * %s",
               uintOutputTypes[td->size], ++seqCount,getTypeStr(td), fld->name);
-       }else fprintf(fp,"%s %s",getTypeStr(td), fld->name);     
-       if(pos1 != ev->type->fields.position - 1) fprintf(fp,", ");
+          args_empty = 0;
+        }else {
+          fprintf(fp,"%s %s",getTypeStr(td), fld->name);     
+          args_empty = 0;
+        }
       }
-    fprintf(fp,")\n{\n");
-
+    }
+    if(args_empty) fprintf(fp, "void");
 
+    fprintf(fp,")\n{\n");
        
     //allocate buffer
     // MD no more need. fprintf(fp,"\tchar buff[buflength];\n");
@@ -540,16 +585,23 @@ void generateStructFunc(FILE * fp, char * facName, unsigned long checksum){
                fprintf(fp, "\tif(ltt_nesting[smp_processor_id()] > 1) goto unlock;\n");
     fprintf(fp, "\tspin_lock(&ltt_traces.locks[smp_processor_id()]);\n\n");
                
-    fprintf(fp, 
+    if(ev->per_tracefile) {
+      fprintf(fp, "\tindex = tracefile_index;\n");
+    } else {
+      fprintf(fp, 
         "\tindex = ltt_get_index_from_facility(ltt_facility_%s_%X,\n"\
             "\t\t\t\tevent_%s);\n",
         facName, checksum, ev->name);
+    }
     fprintf(fp,"\n");
 
     /* For each trace */
     fprintf(fp, "\tlist_for_each_entry(trace, &ltt_traces.head, list) {\n");
     fprintf(fp, "\t\tif(!trace->active) continue;\n\n");
 
+    if(ev->per_trace) {
+      fprintf(fp, "\t\tif(dest_trace != trace) continue;\n\n");
+    }
      //length of buffer : length of all structures
  //   if(ev->type == 0) fprintf(fp, "0");
    
@@ -673,77 +725,10 @@ void generateStructFunc(FILE * fp, char * facName, unsigned long checksum){
     fprintf(fp, "\n");
 
     if(ev->type != 0)
-      fprintf(fp, "\t\tchar *ptr = (char*)buff + _offset + header_length;\n");
-
-   
-    //declare a char pointer if needed : starts at the end of the structs.
-    //if(structCount + hasStrSeq > 1) {
-    //  fprintf(fp,"\t\tchar * ptr = (char*)buff + header_length");
-    //  for(pos1=0;pos1<structCount;pos1++){
-    //    fprintf(fp," + sizeof(struct %s_%s_%d)",ev->name, facName,pos1+1);
-    //  }
-    //  if(structCount + hasStrSeq > 1) fprintf(fp,";\n");
-    //}
-
-    // Declare an alias pointer of the struct type to the beginning
-    // of the reserved area, just after the event header.
-    if(ev->type != 0) {
-                       unsigned align = max(alignment, td->alignment);
-      if(align > 1) {
-        fprintf(fp,"\t\tptr+=(%u - ((unsigned int)ptr&(%u-1)))&(%u-1);\n",
-              align, align, align);
-      }
-    
-      fprintf(fp, "\t\t__1 = (struct %s_%s_1 *)(ptr);\n",
-          ev->name, facName);
-    }
-    //allocate memory for new struct and initialize it
-    //if(whichTypeFirst == 1){ //struct first
-      //for(pos1=0;pos1<structCount;pos1++){  
-      //  if(pos1==0) fprintf(fp,
-      //      "\tstruct %s_%s_1 * __1 = (struct %s_%s_1 *)buff;\n",
-      //      ev->name, facName,ev->name, facName);
-  //MD disabled      else fprintf(fp,
-  //          "\tstruct %s_%s_%d  __%d;\n",
-  //          ev->name, facName,pos1+1,pos1+1);
-      //}      
-    //}else if(whichTypeFirst == 2){
-     // for(pos1=0;pos1<structCount;pos1++)
-     //   fprintf(fp,"\tstruct %s_%s_%d  __%d;\n",
-     //       ev->name, facName,pos1+1,pos1+1);
-    //}
-    fprintf(fp,"\n");
-
-    if(structCount) fprintf(fp,"\t\t//initialize structs\n");
-    //flag = 0;
-    //structCount = 0;
-               if(ev->type != 0)
-                       for(pos1 = 0; pos1 < ev->type->fields.position; pos1++){
-                               fld  = (field *)ev->type->fields.array[pos1];
-                               td = fld->type;
-                               if(td->type != ARRAY && td->type != SEQUENCE && td->type != STRING){
-                                       //if(flag == 0){
-                                       //  flag = 1;  
-                                       //  structCount++;
-                                       //  if(structCount > 1) fprintf(fp,"\n");
-                                       //}
-                                       fprintf(fp, "\t\t__1->%s = %s;\n", fld->name, fld->name );
-
-                               //if(structCount == 1 && whichTypeFirst == 1)
-                               //  fprintf(fp, "\t__1->%s =  %s;\n",fld->name,fld->name );
-                               //else 
-                               //  fprintf(fp, "\t__%d.%s =  %s;\n",structCount ,fld->name,fld->name);
-                               }
-                               //else flag = 0;
-                       }
-    if(structCount) fprintf(fp,"\n");
-    //set ptr to the end of first struct if needed;
-    //if(structCount + hasStrSeq > 1){
-    //  fprintf(fp,"\n\t\t//set ptr to the end of the first struct\n");
-    //  fprintf(fp,"\t\tptr +=  sizeof(struct %s_%s_1);\n\n",ev->name, facName);
-    //}
+      fprintf(fp, "\t\tptr = (char*)buff + _offset + header_length;\n");
 
     //copy struct, sequence and string to buffer
+    //FIXME : they always come before the structs.
     seqCount = 0;
     strCount = 0;
     flag = 0;
@@ -816,6 +801,76 @@ void generateStructFunc(FILE * fp, char * facName, unsigned long checksum){
                        }
     if(structCount + seqCount > 1) fprintf(fp,"\n");
 
+
+
+
+    //declare a char pointer if needed : starts at the end of the structs.
+    //if(structCount + hasStrSeq > 1) {
+    //  fprintf(fp,"\t\tchar * ptr = (char*)buff + header_length");
+    //  for(pos1=0;pos1<structCount;pos1++){
+    //    fprintf(fp," + sizeof(struct %s_%s_%d)",ev->name, facName,pos1+1);
+    //  }
+    //  if(structCount + hasStrSeq > 1) fprintf(fp,";\n");
+    //}
+
+    // Declare an alias pointer of the struct type to the beginning
+    // of the reserved area, just after the event header.
+    if(ev->type != 0) {
+                       unsigned align = max(alignment, td->alignment);
+      if(align > 1) {
+        fprintf(fp,"\t\tptr+=(%u - ((unsigned int)ptr&(%u-1)))&(%u-1);\n",
+              align, align, align);
+      }
+    
+      fprintf(fp, "\t\t__1 = (struct %s_%s_1 *)(ptr);\n",
+          ev->name, facName);
+    }
+    //allocate memory for new struct and initialize it
+    //if(whichTypeFirst == 1){ //struct first
+      //for(pos1=0;pos1<structCount;pos1++){  
+      //  if(pos1==0) fprintf(fp,
+      //      "\tstruct %s_%s_1 * __1 = (struct %s_%s_1 *)buff;\n",
+      //      ev->name, facName,ev->name, facName);
+  //MD disabled      else fprintf(fp,
+  //          "\tstruct %s_%s_%d  __%d;\n",
+  //          ev->name, facName,pos1+1,pos1+1);
+      //}      
+    //}else if(whichTypeFirst == 2){
+     // for(pos1=0;pos1<structCount;pos1++)
+     //   fprintf(fp,"\tstruct %s_%s_%d  __%d;\n",
+     //       ev->name, facName,pos1+1,pos1+1);
+    //}
+    fprintf(fp,"\n");
+
+    if(structCount) fprintf(fp,"\t\t//initialize structs\n");
+    //flag = 0;
+    //structCount = 0;
+               if(ev->type != 0)
+                       for(pos1 = 0; pos1 < ev->type->fields.position; pos1++){
+                               fld  = (field *)ev->type->fields.array[pos1];
+                               td = fld->type;
+                               if(td->type != ARRAY && td->type != SEQUENCE && td->type != STRING){
+                                       //if(flag == 0){
+                                       //  flag = 1;  
+                                       //  structCount++;
+                                       //  if(structCount > 1) fprintf(fp,"\n");
+                                       //}
+                                       fprintf(fp, "\t\t__1->%s = %s;\n", fld->name, fld->name );
+
+                               //if(structCount == 1 && whichTypeFirst == 1)
+                               //  fprintf(fp, "\t__1->%s =  %s;\n",fld->name,fld->name );
+                               //else 
+                               //  fprintf(fp, "\t__%d.%s =  %s;\n",structCount ,fld->name,fld->name);
+                               }
+                               //else flag = 0;
+                       }
+    if(structCount) fprintf(fp,"\n");
+    //set ptr to the end of first struct if needed;
+    //if(structCount + hasStrSeq > 1){
+    //  fprintf(fp,"\n\t\t//set ptr to the end of the first struct\n");
+    //  fprintf(fp,"\t\tptr +=  sizeof(struct %s_%s_1);\n\n",ev->name, facName);
+    //}
+
     fprintf(fp,"\n");
     fprintf(fp, "\t\t/* Commit the work */\n");
     fprintf(fp, "\t\trelay_commit(channel->rchan->buf[smp_processor_id()],\n"
index 7a8a65937b6f47e77adf691cd97d32936e855f77..b4bd088b5c8fb8e22859d7e20dc6fe0c43b03a96 100644 (file)
@@ -223,6 +223,8 @@ void getEventAttributes(parse_file *in, event *ev)
   char car;
   
   ev->name = NULL;
+  ev->per_trace = 0;
+  ev->per_tracefile = 0;
 
   while(1) {
     token = getToken(in); 
@@ -237,7 +239,12 @@ void getEventAttributes(parse_file *in, event *ev)
       if(car == EOF) in->error(in,"name was expected");
       else if(car == '\"') ev->name = allocAndCopy(getQuotedString(in));
       else ev->name = allocAndCopy(getName(in));
+    } else if(!strcmp("per_trace", token)) {
+      ev->per_trace = 1;
+    } else if(!strcmp("per_tracefile", token)) {
+      ev->per_tracefile = 1;
     }
+
   }
 }
 
index e75f2b5fcd2a5f18ee6a3a90245a1f361048d441..da5a303da5ab4fdfcd9e3b799aeb4984e02b17be 100644 (file)
@@ -126,6 +126,8 @@ typedef struct _event {
   char *name;
   char *description;
   type_descriptor *type; 
+  int  per_trace;   /* Is the event able to be logged to a specific trace ? */
+  int  per_tracefile;  /* Must we log this event in a specific tracefile ? */
 } event;
 
 typedef struct _facility {
This page took 0.027931 seconds and 4 git commands to generate.