* 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) {
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:
break;
default:
printf("print_type_alignment_fct : type has no alignment function.\n");
+ return 0;
break;
}
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:
}
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");
/* 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;
}
/* 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",
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
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>
<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>