#include "parser.h"
#include "genevent.h"
+#define max(a,b) ((a)<(b))?(b):(a)
+
/* Named types may be referenced from anywhere */
-facility * fac;
+facility_t * fac;
+
+unsigned alignment = 0;
int main(int argc, char** argv)
{
char *token;
- parse_file in;
+ parse_file_t in;
char buffer[BUFFER_SIZE];
int i;
if(argc < 2){
printf("At least one event definition file is needed\n");
+ printf("You may specify the default alignment for a facility with\n");
+ printf(" -a x , where x is the desired alignment in bytes.\n");
+ printf("The alignment value will affect all the following xml files.\n");
+ printf("i.e. genevent -a 8 core.xml -a 4 kernel.xml is valid.\n");
exit(1);
}
in.error = error_callback;
for(i = 1 ; i < argc ; i++) {
- in.lineno = 0;
- in.name = allocAndCopy(argv[i]);
-
- in.fp = fopen(in.name, "r");
- if(!in.fp ){
- in.error(&in,"cannot open facility input file");
- }
- while(1){
- token = getToken(&in);
- if(in.type == ENDFILE) break;
+ if(strcmp("-a", argv[i])==0) {
+ if(i >= argc-1) {
+ printf("Error : missing argument to -a\n");
+ exit(1);
+ } else i++;
+ alignment = atoi(argv[i]);
+ } else {
+
+ in.lineno = 0;
+ in.name = allocAndCopy(argv[i]);
- if(strcmp(token, "<")) in.error(&in,"not a facility file");
- token = getName(&in);
-
- if(strcmp("facility",token) == 0) {
- fac = memAlloc(sizeof(facility));
- fac->name = NULL;
- fac->description = NULL;
- sequence_init(&(fac->events));
- table_init(&(fac->named_types));
- sequence_init(&(fac->unnamed_types));
-
- parseFacility(&in, fac);
-
- //check if any namedType is not defined
- checkNamedTypesImplemented(&fac->named_types);
- }
- else in.error(&in,"facility token was expected");
-
- generateFile(argv[i]);
-
- free(fac->name);
- free(fac->description);
- freeEvents(&fac->events);
- sequence_dispose(&fac->events);
- freeNamedType(&fac->named_types);
- table_dispose(&fac->named_types);
- freeTypes(&fac->unnamed_types);
- sequence_dispose(&fac->unnamed_types);
- free(fac);
- }
+ in.fp = fopen(in.name, "r");
+ if(!in.fp ){
+ in.error(&in,"cannot open facility input file");
+ }
- free(in.name);
- fclose(in.fp);
+ while(1){
+ token = getToken(&in);
+ if(in.type == ENDFILE) break;
+
+ if(strcmp(token, "<")) in.error(&in,"not a facility file");
+ token = getName(&in);
+
+ if(strcmp("facility",token) == 0) {
+ fac = memAlloc(sizeof(facility_t));
+ fac->name = NULL;
+ fac->description = NULL;
+ sequence_init(&(fac->events));
+ table_init(&(fac->named_types));
+ sequence_init(&(fac->unnamed_types));
+
+ parseFacility(&in, fac);
+
+ //check if any namedType is not defined
+ checkNamedTypesImplemented(&fac->named_types);
+ }
+ else in.error(&in,"facility token was expected");
+
+ generateFile(argv[i]);
+
+ free(fac->name);
+ free(fac->description);
+ freeEvents(&fac->events);
+ sequence_dispose(&fac->events);
+ freeNamedType(&fac->named_types);
+ table_dispose(&fac->named_types);
+ freeTypes(&fac->unnamed_types);
+ sequence_dispose(&fac->unnamed_types);
+ free(fac);
+ }
+ free(in.name);
+ fclose(in.fp);
+ }
}
return 0;
}
*Input Params
* name : name of event definition file
****************************************************************************/
-void generateFile(char *name){
+void generateFile(char *name)
+{
char *loadName, *hName, *hIdName, *cName, *tmp, *tmp2;
FILE * lFp, *hFp, *iFp, *cFp;
int nbEvent;
*Output Params
* nbEvent : number of events in the facility
****************************************************************************/
-void generateEnumEvent(FILE *fp, char *facName, int * nbEvent, unsigned long checksum) {
+void generateEnumEvent(FILE *fp, char *facName, int * nbEvent,
+ unsigned long checksum) {
int pos = 0;
fprintf(fp,"#include <linux/ltt-facilities.h>\n\n");
fprintf(fp,"enum %s_event {\n",facName);
for(pos = 0; pos < fac->events.position;pos++) {
- fprintf(fp,"\tevent_%s", ((event *)(fac->events.array[pos]))->name);
+ fprintf(fp,"\tevent_%s", ((event_t *)(fac->events.array[pos]))->name);
if(pos != fac->events.position-1) fprintf(fp,",\n");
}
fprintf(fp,"\n};\n\n\n");
static void
printStruct(FILE * fp, int len, void ** array, char * name, char * facName,
int * whichTypeFirst, int * hasStrSeq, int * structCount,
- type_descriptor *type)
+ type_descriptor_t *type)
{
int flag = 0;
int pos;
- field * fld;
- type_descriptor * td;
+ field_t * fld;
+ type_descriptor_t * td;
for (pos = 0; pos < len; pos++) {
- fld = (field *)array[pos];
+ fld = (field_t *)array[pos];
td = fld->type;
if( td->type == STRING || td->type == SEQUENCE ||
td->type == ARRAY) {
(*hasStrSeq)++;
- }
-// if (*whichTypeFirst == 0) {
-// *whichTypeFirst = 1; //struct first
-// }
+ } else {
if (flag == 0) {
flag = 1;
-
fprintf(fp,"struct %s_%s",name, facName);
if (structCount) {
fprintf(fp, "_%d {\n",++*structCount);
}
fprintf(fp, "\t%s %s; /* %s */\n",
getTypeStr(td),fld->name,fld->description );
-#if 0
- } else {
- if (*whichTypeFirst == 0) {
- //string or sequence or array first
- *whichTypeFirst = 2;
- }
- (*hasStrSeq)++;
- if(flag) {
- fprintf(fp,"} __attribute__ ((packed));\n\n");
- }
- flag = 0;
}
-#endif //0
}
if(flag) {
- if(type->alignment == 0)
+ unsigned align = max(alignment, type->alignment);
+
+ if(align == 0)
fprintf(fp,"} __attribute__ ((packed));\n\n");
else {
- if(type->alignment != 1 && type->alignment != 2
- && type->alignment != 4 && type->alignment != 8) {
- printf("Wrong alignment %i, using packed.\n", type->alignment);
+ if(align != 1 && align != 2
+ && align != 4 && align != 8) {
+ printf("Wrong alignment %i, using packed.\n", align);
fprintf(fp,"} __attribute__ ((packed));\n\n");
} else
- fprintf(fp,"} __attribute__ ((aligned(%i)));\n\n", type->alignment);
+ fprintf(fp,"} __attribute__ ((aligned(%i)));\n\n", align);
}
}
}
* fp : file to be written to
* fHead : enum type
****************************************************************************/
-void generateEnumDefinition(FILE * fp, type_descriptor * type){
+void generateEnumDefinition(FILE * fp, type_descriptor_t * type){
int pos;
if(type->already_printed) return;
* facName : name of facility
****************************************************************************/
void generateStructFunc(FILE * fp, char * facName, unsigned long checksum){
- event * ev;
- field * fld;
- type_descriptor * td;
+ event_t * ev;
+ field_t * fld;
+ type_descriptor_t * 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];
+ ev = (event_t *) fac->events.array[pos];
//yxx if(ev->nested)continue;
fprintf(fp,"/**** structure and trace function for event: %s ****/\n\n",
ev->name);
//twice.
if(ev->type != 0)
for(pos1 = 0; pos1 < ev->type->fields.position; pos1++){
- fld = (field *)ev->type->fields.array[pos1];
+ fld = (field_t *)ev->type->fields.array[pos1];
if(fld->type->type == ENUM) generateEnumDefinition(fp, fld->type);
}
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];
+ fld = (field_t *)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");
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];
+ fld = (field_t *)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");
fprintf(fp, "\tstruct ltt_trace_struct *trace;\n");
fprintf(fp, "\tunsigned long _flags;\n");
fprintf(fp, "\tvoid *buff;\n");
- fprintf(fp, "\tvoid *old_address;\n");
+ fprintf(fp, "\tunsigned old_offset;\n");
fprintf(fp, "\tunsigned int header_length;\n");
fprintf(fp, "\tunsigned int event_length;\n"); // total size (incl hdr)
fprintf(fp, "\tunsigned int length;\n"); // Size of the event var data.
fprintf(fp, "\tstruct rchan_buf *buf;\n");
fprintf(fp, "\tstruct timeval delta;\n");
fprintf(fp, "\tu64 tsc;\n");
+ fprintf(fp, "\tchar *ptr;\n");
if(ev->type != 0)
fprintf(fp, "\tstruct %s_%s_1* __1;\n\n", ev->name, facName);
fprintf(fp, "\tif(ltt_nesting[smp_processor_id()] > 1) goto unlock;\n");
fprintf(fp, "\tspin_lock(<t_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, <t_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");
* protected event, let's add a memory barrier() to make sure the compiler
* will not reorder this read. */
fprintf(fp, "\t\tdo {\n");
- fprintf(fp, "\t\t\told_address = buf->data + buf->offset;\n");
+ fprintf(fp, "\t\t\told_offset = buf->offset;\n");
fprintf(fp, "\t\t\tbarrier();\n");
- fprintf(fp, "\t\t\tchar *ptr = (char*)old_address;\n");
+ fprintf(fp, "\t\t\tptr = (char*)buf->data + old_offset;\n");
fprintf(fp, "\t\t\theader_length = ltt_get_event_header_data(trace, "
"channel,\n"
- "\t\t\t\t\t\t\t\t\t\told_address, &_offset, &delta, &tsc);\n");
+ "\t\t\t\t\t\t\t\t\t\tptr, &_offset, &delta, &tsc);\n");
fprintf(fp, "\t\t\tptr += _offset + header_length;\n");
for(pos1=0;pos1<structCount;pos1++){
- if(ev->type->alignment > 1) {
+ unsigned align = max(alignment, ev->type->alignment);
+ if(align > 1) {
fprintf(fp,"\t\t\tptr += (%u - ((unsigned int)ptr&(%u-1)))&(%u-1) ;\n",
- ev->type->alignment, ev->type->alignment, ev->type->alignment);
+ align, align, align);
}
fprintf(fp,"\t\t\tptr += sizeof(struct %s_%s_%d);\n",ev->name,
facName,pos1+1);
flag = 0;
if(ev->type != 0)
for(pos1 = 0; pos1 < ev->type->fields.position; pos1++){
- fld = (field *)ev->type->fields.array[pos1];
+ fld = (field_t *)ev->type->fields.array[pos1];
td = fld->type;
if(td->type == SEQUENCE || td->type==STRING || td->type==ARRAY){
if(td->type == SEQUENCE) {
- if(td->alignment > 1) {
- fprintf(fp,"\t\t\tptr += (%u - ((unsigned int)ptr&(%u-1)))&(%u-1)) ;\n",
- td->alignment, td->alignment, td->alignment);
- }
- fprintf(fp,
- "\t\t\tptr += sizeof(%s) + (sizeof(%s) * seqlength_%d);\n",
- uintOutputTypes[td->size], getTypeStr(td), ++seqCount);
+
+ 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\tptr += sizeof(%s);\n",uintOutputTypes[td->size]);
+ if(align > 1) {
+ fprintf(fp,"\t\tptr+=(%u - ((unsigned int)ptr&(%u-1)))&(%u-1);\n",
+ align, align, align);
+ }
+ fprintf(fp,"\t\tptr += sizeof(%s) * seqlength_%d;\n\n",
+ getTypeStr(td), seqCount);
+
} else if(td->type==STRING) {
- if(td->alignment > 1) {
+ unsigned align = max(alignment, td->alignment);
+ if(align > 1) {
fprintf(fp,"\t\t\tptr += (%u - ((unsigned int)ptr&(%u-1)))&(%u-1)) ;\n",
- td->alignment, td->alignment, td->alignment);
+ align, align, align);
}
fprintf(fp,"ptr += strlength_%d + 1;\n",
++strCount);
}
else if(td->type==ARRAY) {
- if(td->alignment > 1) {
+ unsigned align = max(alignment, td->alignment);
+ if(align > 1) {
fprintf(fp,"\t\t\tptr += (%u - ((unsigned int)ptr&(%u-1)))&(%u-1);\n",
- td->alignment, td->alignment, td->alignment);
+ align, align, align);
}
fprintf(fp,"\t\t\tptr += sizeof(%s) * %d;\n",
getTypeStr(td),td->size);
}
}
}
- fprintf(fp,";\n");
-
fprintf(fp, "\t\t\tevent_length = (unsigned long)ptr -"
- "(unsigned long)old_address;\n");
+ "(unsigned long)(buf->data + old_offset);\n");
/* let's put some protection before the cmpxchg : the space reservation and
* the get TSC are not dependant from each other. I don't want the compiler
* _yes_, the compiler could mess it up. */
fprintf(fp, "\t\t\tbarrier();\n");
fprintf(fp, "\t\t\tbuff = relay_reserve(channel->rchan, event_length, "
- "old_address);\n");
+ "old_offset);\n");
fprintf(fp, "\n");
fprintf(fp, "\t\t} while(PTR_ERR(buff) == -EAGAIN);\n");
fprintf(fp, "\n");
/* Write the header */
fprintf(fp, "\n");
- fprintf(fp,"\t\tlength = event_length - header_length;\n");
+ fprintf(fp,"\t\tlength = event_length - _offset - header_length;\n");
fprintf(fp, "\n");
fprintf(fp, "\t\tltt_write_event_header(trace, channel, buff, \n"
"\t\t\t\tltt_facility_%s_%X, event_%s, length, _offset,\n"
fprintf(fp, "\n");
if(ev->type != 0)
- fprintf(fp, "\t\tchar *ptr = (char*)buff + _offset + header_length;\n");
+ 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;
+ structCount = 0;
+ if(ev->type != 0)
+ for(pos1 = 0; pos1 < ev->type->fields.position; pos1++){
+ fld = (field_t *)ev->type->fields.array[pos1];
+ td = fld->type;
+ // if(td->type != STRING && td->type != SEQUENCE && td->type != ARRAY){
+ // if(flag == 0) structCount++;
+ // flag++;
+ // if((structCount > 1 || whichTypeFirst == 2) && flag == 1){
+ // assert(0); // MD : disabled !
+ // fprintf(fp,"\t//copy struct to buffer\n");
+ // fprintf(fp,"\tmemcpy(ptr, &__%d, sizeof(struct %s_%s_%d));\n",
+ // structCount, ev->name, facName,structCount);
+ // fprintf(fp,"\tptr += sizeof(struct %s_%s_%d);\n\n",
+ // ev->name, facName,structCount);
+ // }
+ // }
+ //else if(td->type == SEQUENCE){
+ if(td->type == SEQUENCE){
+ flag = 0;
+ fprintf(fp,"\t\t//copy sequence length and sequence to buffer\n");
+
+ 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*ptr = seqlength_%d;\n",++seqCount);
+ fprintf(fp,"\t\tptr += sizeof(%s);\n",uintOutputTypes[td->size]);
+ if(align > 1) {
+ fprintf(fp,"\t\tptr+=(%u - ((unsigned int)ptr&(%u-1)))&(%u-1);\n",
+ align, align, align);
+ }
+ fprintf(fp,"\t\tmemcpy(ptr, %s, sizeof(%s) * seqlength_%d);\n",
+ fld->name, getTypeStr(td), seqCount);
+ fprintf(fp,"\t\tptr += sizeof(%s) * seqlength_%d;\n\n",
+ getTypeStr(td), seqCount);
+ }
+ else if(td->type==STRING){
+ flag = 0;
+ fprintf(fp,"\t\t//copy string to buffer\n");
+ fprintf(fp,"\t\tif(strlength_%d > 0){\n",++strCount);
+ 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\tmemcpy(ptr, %s, strlength_%d + 1);\n",
+ fld->name, strCount);
+ fprintf(fp,"\t\t\tptr += strlength_%d + 1;\n",strCount);
+ fprintf(fp,"\t\t}else{\n");
+ fprintf(fp,"\t\t\t*ptr = '\\0';\n");
+ fprintf(fp,"\t\t\tptr += 1;\n");
+ fprintf(fp,"\t\t}\n\n");
+ }else if(td->type==ARRAY){
+ flag = 0;
+ fprintf(fp,"\t//copy array to buffer\n");
+ 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,"\tmemcpy(ptr, %s, sizeof(%s) * %d);\n",
+ fld->name, getTypeStr(td), td->size);
+ fprintf(fp,"\tptr += sizeof(%s) * %d;\n\n", getTypeStr(td), td->size);
+ }
+ }
+ 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");
// Declare an alias pointer of the struct type to the beginning
// of the reserved area, just after the event header.
if(ev->type != 0) {
- if(ev->type->alignment > 1) {
+ unsigned align = max(alignment, td->alignment);
+ if(align > 1) {
fprintf(fp,"\t\tptr+=(%u - ((unsigned int)ptr&(%u-1)))&(%u-1);\n",
- ev->type->alignment, ev->type->alignment, ev->type->alignment);
+ align, align, align);
}
fprintf(fp, "\t\t__1 = (struct %s_%s_1 *)(ptr);\n",
//structCount = 0;
if(ev->type != 0)
for(pos1 = 0; pos1 < ev->type->fields.position; pos1++){
- fld = (field *)ev->type->fields.array[pos1];
+ fld = (field_t *)ev->type->fields.array[pos1];
td = fld->type;
if(td->type != ARRAY && td->type != SEQUENCE && td->type != STRING){
//if(flag == 0){
// fprintf(fp,"\t\tptr += sizeof(struct %s_%s_1);\n\n",ev->name, facName);
//}
- //copy struct, sequence and string to buffer
- seqCount = 0;
- strCount = 0;
- 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 != STRING && td->type != SEQUENCE && td->type != ARRAY){
- // if(flag == 0) structCount++;
- // flag++;
- // if((structCount > 1 || whichTypeFirst == 2) && flag == 1){
- // assert(0); // MD : disabled !
- // fprintf(fp,"\t//copy struct to buffer\n");
- // fprintf(fp,"\tmemcpy(ptr, &__%d, sizeof(struct %s_%s_%d));\n",
- // structCount, ev->name, facName,structCount);
- // fprintf(fp,"\tptr += sizeof(struct %s_%s_%d);\n\n",
- // ev->name, facName,structCount);
- // }
- // }
- //else if(td->type == SEQUENCE){
- if(td->type == SEQUENCE){
- flag = 0;
- fprintf(fp,"\t\t//copy sequence length and sequence to buffer\n");
-
- if(td->alignment > 1) {
- fprintf(fp,"\t\tptr+=(%u - ((unsigned int)ptr&(%u-1)))&(%u-1);\n",
- td->alignment, td->alignment, td->alignment);
- }
- fprintf(fp,"\t\t*ptr = seqlength_%d;\n",++seqCount);
- fprintf(fp,"\t\tptr += sizeof(%s);\n",uintOutputTypes[td->size]);
- if(td->alignment > 1) {
- fprintf(fp,"\t\tptr+=(%u - ((unsigned int)ptr&(%u-1)))&(%u-1);\n",
- td->alignment, td->alignment, td->alignment);
- }
- fprintf(fp,"\t\tmemcpy(ptr, %s, sizeof(%s) * seqlength_%d);\n",
- fld->name, getTypeStr(td), seqCount);
- fprintf(fp,"\t\tptr += sizeof(%s) * seqlength_%d;\n\n",
- getTypeStr(td), seqCount);
- }
- else if(td->type==STRING){
- flag = 0;
- fprintf(fp,"\t\t//copy string to buffer\n");
- fprintf(fp,"\t\tif(strlength_%d > 0){\n",++strCount);
- if(td->alignment > 1) {
- fprintf(fp,"\t\tptr+=(%u - ((unsigned int)ptr&(%u-1)))&(%u-1);\n",
- td->alignment, td->alignment, td->alignment);
- }
- fprintf(fp,"\t\t\tmemcpy(ptr, %s, strlength_%d + 1);\n",
- fld->name, strCount);
- fprintf(fp,"\t\t\tptr += strlength_%d + 1;\n",strCount);
- fprintf(fp,"\t\t}else{\n");
- fprintf(fp,"\t\t\t*ptr = '\\0';\n");
- fprintf(fp,"\t\t\tptr += 1;\n");
- fprintf(fp,"\t\t}\n\n");
- }else if(td->type==ARRAY){
- flag = 0;
- fprintf(fp,"\t//copy array to buffer\n");
- if(td->alignment > 1) {
- fprintf(fp,"\t\tptr+=(%u - ((unsigned int)ptr&(%u-1)))&(%u-1);\n",
- td->alignment, td->alignment, td->alignment);
- }
- fprintf(fp,"\tmemcpy(ptr, %s, sizeof(%s) * %d);\n",
- fld->name, getTypeStr(td), td->size);
- fprintf(fp,"\tptr += sizeof(%s) * %d;\n\n", getTypeStr(td), td->size);
- }
- }
- if(structCount + seqCount > 1) fprintf(fp,"\n");
-
fprintf(fp,"\n");
fprintf(fp, "\t\t/* Commit the work */\n");
fprintf(fp, "\t\trelay_commit(channel->rchan->buf[smp_processor_id()],\n"
*Return Values
* char * : type string
****************************************************************************/
-char * getTypeStr(type_descriptor * td){
- type_descriptor * t ;
+char * getTypeStr(type_descriptor_t * td){
+ type_descriptor_t * t ;
switch(td->type){
case INT:
fprintf(fp, "\t.name = ltt_facility_name,\n");
fprintf(fp, "\t.num_events = LTT_FACILITY_NUM_EVENTS,\n");
fprintf(fp, "\t.checksum = LTT_FACILITY_CHECKSUM,\n");
- fprintf(fp, "\t.symbol = SYMBOL_STRING(LTT_FACILITY_SYMBOL)\n");
+ fprintf(fp, "\t.symbol = SYMBOL_STRING(LTT_FACILITY_SYMBOL),\n");
+ fprintf(fp, "\t.alignment = %u\n", alignment); /* default alignment */
fprintf(fp, "};\n");
fprintf(fp, "\n");
fprintf(fp, "#ifndef MODULE\n");
fprintf(fp, "\tprintk(KERN_INFO \"LTT : ltt-facility-%s init dynamic\\n\");\n", filefacname);
fprintf(fp, "\n");
fprintf(fp, "\tLTT_FACILITY_SYMBOL = ltt_facility_dynamic_register(&facility);\n");
- fprintf(fp, "\tLTT_FACILITY_SYMBOL_CHECKSUM = LTT_FACILITY_SYMBOL;\n");
+ fprintf(fp, "\tLTT_FACILITY_CHECKSUM_SYMBOL = LTT_FACILITY_SYMBOL;\n");
fprintf(fp, "\n");
fprintf(fp, "\treturn LTT_FACILITY_SYMBOL;\n");
fprintf(fp, "}\n");