enable code for alignment and write
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 1 Dec 2005 20:02:57 +0000 (20:02 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 1 Dec 2005 20:02:57 +0000 (20:02 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1352 04897980-b3bd-0310-b5e0-8ef037075253

genevent-new/genevent.c
genevent-new/parser.c
genevent-new/test.xml

index e54398acfd44ce3882755ed7c7026577f53b37dd..1013d92fe95aa6e37130a992697389d6b6f3601b 100644 (file)
@@ -543,11 +543,13 @@ int print_type_alignment(type_descriptor_t * td, FILE *fd, unsigned int tabs,
                 * the array. */
                if((basename_len != 0)
                                && (basename[basename_len-1] != '_'
+                               && field_name != NULL
                                && (field_name[0] != '\0'))) {
                        strncat(basename, "_", PATH_MAX - basename_len);
                        basename_len = strlen(basename);
                }
-               strncat(basename, field_name, PATH_MAX - basename_len);
+               if(field_name != NULL)
+                       strncat(basename, field_name, PATH_MAX - basename_len);
        }
        
        switch(td->type) {
@@ -664,17 +666,17 @@ int print_type_write(type_descriptor_t * td, FILE *fd, unsigned int tabs,
                        break;
                case SEQUENCE:
                        print_tabs(tabs, fd);
-                       fprintf(fd, "lttng_write_%s(buffer, to_base, to, from, len, obj->%s)", basename,
+                       fprintf(fd, "lttng_write_%s(buffer, to_base, to, from, len, &obj->%s)", basename,
                                        field_name);
                        break;
                case STRUCT:
                        print_tabs(tabs, fd);
-                       fprintf(fd, "lttng_write_struct_%s(buffer, to_base, to, from, len, obj->%s)", basename,
+                       fprintf(fd, "lttng_write_struct_%s(buffer, to_base, to, from, len, &obj->%s)", basename,
                                        field_name);
                        break;
                case UNION:
                        print_tabs(tabs, fd);
-                       fprintf(fd, "lttng_write_union_%s(buffer, to_base, to, from, len, obj->%s)", basename,
+                       fprintf(fd, "lttng_write_union_%s(buffer, to_base, to, from, len, &obj->%s)", basename,
                                        field_name);
                        break;
                case ARRAY:
@@ -825,6 +827,7 @@ int print_type_alignment_fct(type_descriptor_t * td, FILE *fd,
                        break;
                default:
                        printf("print_type_alignment_fct : type has no alignment function.\n");
+                       return 0;
                        break;
        }
 
@@ -868,25 +871,34 @@ int print_type_write_fct(type_descriptor_t * td, FILE *fd, unsigned int tabs,
                strncat(basename, field_name, PATH_MAX - basename_len);
        }
        
+       switch(td->type) {
+               case SEQUENCE:
+               case STRUCT:
+               case UNION:
+               case ARRAY:
+                       break;
+               default:
+                       printf("print_type_write_fct : type has no write function.\n");
+                       return 0;
+                       break;
+       }
+       
        /* Print header */
        switch(td->type) {
                case SEQUENCE:
-                       fprintf(fd, "static inline size_t lttng_get_alignment_sequence_%s(\n",
+                       fprintf(fd, "static inline void lttng_write_sequence_%s(\n",
                                        basename);
-
-                       fprintf(fd, "lttng_get_alignment_sequence_%s(&obj->%s)", basename,
-                                       field_name);
                        break;
                case STRUCT:
-                       fprintf(fd, "lttng_get_alignment_struct_%s(&obj->%s)", basename,
+                       fprintf(fd, "static inline void lttng_write_struct_%s(\n", basename,
                                        field_name);
                        break;
                case UNION:
-                       fprintf(fd, "lttng_get_alignment_union_%s(&obj->%s)", basename,
+                       fprintf(fd, "static inline void lttng_write_union_%s(\n", basename,
                                        field_name);
                        break;
                case ARRAY:
-                       fprintf(fd, "lttng_get_alignment_array_%s(obj->%s)", basename,
+                       fprintf(fd, "static inline void lttng_write_array_%s(\n", basename,
                                        field_name);
                        break;
                default:
@@ -959,7 +971,7 @@ int print_type_write_fct(type_descriptor_t * td, FILE *fd, unsigned int tabs,
        }
        
        print_tabs(1, fd);
-       fprintf(fd, "align = \n");
+       fprintf(fd, "align = ");
        if(print_type_alignment(td, fd, 0, basename, field_name)) return 1;
        fprintf(fd, ";\n");
        fprintf(fd, "\n");
@@ -1346,6 +1358,12 @@ int print_log_header_types(facility_t *fac, FILE *fd)
                /* For each named type, print the definition */
                if((print_type_declaration(types->array[i], fd,
                                                0, "", ""))) return 1;
+               /* Print also the align function */
+               if((print_type_alignment_fct(types->array[i], fd,
+                                               0, "", ""))) return 1;
+               /* Print also the write function */
+               if((print_type_write_fct(types->array[i], fd,
+                                               0, "", ""))) return 1;
        }
        return 0;
 }
@@ -1372,9 +1390,15 @@ int print_log_header_events(facility_t *fac, FILE *fd)
                        /* For each unnamed type, print the definition */
                        field_t *f = (field_t*)event->fields.array[j];
                        type_descriptor_t *t = f->type;
-                       if(t->type_name == NULL)
+                       if(t->type_name == NULL) {
                                if((print_type_declaration(t, fd, 0, basename, f->name))) return 1;
+                               /* Print also the align function */
+                               if((print_type_alignment_fct(t, fd, 0, basename, f->name))) return 1;
+                               /* Print also the write function */
+                               if((print_type_write_fct(t, fd, 0, basename, f->name))) return 1;
+                       }
                }
+
                fprintf(fd, "\n");
 
                fprintf(fd, "/* Event %s logging function */\n",
index 48f3bdcf6cd75965b28c4e78cdc158dcf5a62d27..425d390cfa9745bddce0bdf286ddfeb4fcb8811c 100644 (file)
@@ -901,16 +901,22 @@ type_descriptor_t * find_named_type(char *name, table_t * named_types)
   type_descriptor_t *t;
 
   t = table_find(named_types,name);
-  if(t == NULL) {
-    t = (type_descriptor_t *)memAlloc(sizeof(type_descriptor_t));
-    t->type_name = allocAndCopy(name);
-    t->type = NONE;
-    t->fmt = NULL;
-    table_insert(named_types,t->type_name,t);
-    //    table_insert(named_types,allocAndCopy(name),t);
-  }
+
   return t;
-}  
+}
+
+type_descriptor_t * create_named_type(char *name, table_t * named_types)
+{
+  type_descriptor_t *t;
+
+       t = (type_descriptor_t *)memAlloc(sizeof(type_descriptor_t));
+       t->type_name = allocAndCopy(name);
+       t->type = NONE;
+       t->fmt = NULL;
+       table_insert(named_types,t->type_name,t);
+       //    table_insert(named_types,allocAndCopy(name),t);
+       return t;
+}
 
 /*****************************************************************************
  *Function name
@@ -929,7 +935,7 @@ void parseTypeDefinition(parse_file_t * in, sequence_t * unnamed_types,
 
   token = getNameAttribute(in);
   if(token == NULL) in->error(in, "Type has empty name");
-  t = find_named_type(token, named_types);
+  t = create_named_type(token, named_types);
 
   if(t->type != NONE) in->error(in,"redefinition of named type");
   getRAnglebracket(in); //<type name=type_name>
index 343c4625324a766969b3599f24ca889bb008b7f9..5b870f83c4676b6d545f7c1250ad9e5204fd812b 100644 (file)
@@ -1,6 +1,57 @@
 <facility name=test>
   <description>The kernel facility has events related to kernel execution status.</description>
 
+
+  <type name=tasklet_priority>
+    <enum>
+      <label name=LOW value=0/> <description>Low priority tasklet</description>
+      <label name=HIGH value=1/> <description>High priority tasklet</description>
+    </enum>
+  </type>
+
+  <type name=irq_mode>
+    <enum>
+      <label name=user value=0/> <description>User context</description>
+      <label name=kernel value=1/> <description>Kernel context</description>
+    </enum>
+  </type>
+       
+       <type name=mystruct2>
+               <struct>
+      <field name="irq_id"> <description>IRQ number</description> <uint size=4/> </field>
+      <field name="mode"> <description>Are we executing kernel code</description> <typeref name=irq_mode/> </field>
+               </struct>
+       </type>
+
+       <type name=mystruct>
+               <struct>
+      <field name="irq_id"> <description>IRQ number</description> <uint size=4/> </field>
+      <field name="mode"> <description>Are we executing kernel code</description> <typeref name=irq_mode/> </field>
+                       
+                       <field name="teststr"><typeref name=mystruct2/></field>
+                       <field name="myarray">
+                       <array size=10/>
+                       <uint_fixed size=8/>
+                       </array>
+                       </field>
+                       <field name="mysequence">
+                       <sequence>
+                               <uint>
+                               <float size=8/>
+                       </sequence>
+                       </field>
+                       <field name="myunion">
+                       <union>
+                               <field name="myfloat"><float size=8/></field>
+                               <field name="myulong"><ulong></field>
+                       </union>
+                       </field>
+               </struct>
+       </type>
+
+
+
+
   <event name=syscall_entry>
     <description>System call entry</description>
     <field name="syscall_id"> <description>Syscall entry number in entry.S</description> <uint size=1/> </field>
        </field>
        </event>
 
-  <type name=tasklet_priority>
-    <enum>
-      <label name=LOW value=0/> <description>Low priority tasklet</description>
-      <label name=HIGH value=1/> <description>High priority tasklet</description>
-    </enum>
-  </type>
-
-  <type name=irq_mode>
-    <enum>
-      <label name=user value=0/> <description>User context</description>
-      <label name=kernel value=1/> <description>Kernel context</description>
-    </enum>
-  </type>
-       
-       <type name=mystruct2>
-               <struct>
-      <field name="irq_id"> <description>IRQ number</description> <uint size=4/> </field>
-      <field name="mode"> <description>Are we executing kernel code</description> <typeref name=irq_mode/> </field>
-                       <field name="teststr1"> <typeref name=mystruct/> </field>
-               </struct>
-       </type>
-
-       <type name=mystruct>
-               <struct>
-      <field name="irq_id"> <description>IRQ number</description> <uint size=4/> </field>
-      <field name="mode"> <description>Are we executing kernel code</description> <typeref name=irq_mode/> </field>
-                       
-                       <field name="teststr"><typeref name=mystruct2/></field>
-                       <field name="myarray">
-                       <array size=10/>
-                       <uint_fixed size=8/>
-                       </array>
-                       </field>
-                       <field name="mysequence">
-                       <sequence>
-                               <uint>
-                               <float size=8/>
-                       </sequence>
-                       </field>
-                       <field name="myunion">
-                       <union>
-                               <field name="myfloat"><float size=8/></field>
-                               <field name="myulong"><ulong></field>
-                       </union>
-                       </field>
-               </struct>
-       </type>
-
 </facility>
This page took 0.028333 seconds and 4 git commands to generate.