From: compudj Date: Thu, 6 Apr 2006 23:11:34 +0000 (+0000) Subject: remove old genevent X-Git-Tag: v0.12.20~1731 X-Git-Url: https://git.lttng.org/?a=commitdiff_plain;h=df23258963cf0bd38011401b7374f171f1d339ee;p=lttv.git remove old genevent git-svn-id: http://ltt.polymtl.ca/svn@1758 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/genevent/Makefile b/genevent/Makefile deleted file mode 100644 index a1d4c302..00000000 --- a/genevent/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -SHELL = /bin/sh - -CC = gcc - -CFLAGS = -g -o - -all: genevent - -install: genevent - cp -f genevent /usr/local/bin - -genevent:genevent.o parser.o - $(CC) $(CFLAGS) $@ genevent.o parser.o - -genevent.o: genevent.c genevent.h parser.h - $(CC) -g -c genevent.c - -parser.o: parser.c parser.h - $(CC) -g -c parser.c - -.PHONY: clean - -clean: - rm -rf *.o *~ *# genevent - - diff --git a/genevent/README b/genevent/README deleted file mode 100644 index 6db15030..00000000 --- a/genevent/README +++ /dev/null @@ -1,45 +0,0 @@ - -Mathieu Desnoyers -- September 2005 - -The 'genevent' program parses event descriptions and generates -the inline functions to record events in the kernel. - -Right now, the program can only parse simple structure, if a -structure has a nested structure, it will not work. - -Genevent will soon go through a rewrite, but for now, the strings should be put -*** AT THE END *** of a structure : they will be put there anyways. - -There are several files in the directory: - genevent.c, genevent.h, crc32.tab, parser.c and parser.h - -In fact, crc32.tab, parser.c and parser.h are the same files as -those in LTT library. - -'core.xml' is an example event description file. - -Here is a brief description of how to use genevent. - -make -make install - - -* Add new events to the kernel with genevent - -su - -cd /usr/local/share/LinuxTraceToolkitViewer/facilities -cp process.xml yourfacility.xml - * edit yourfacility.xml to fit your needs. -cd /tmp -/usr/local/bin/genevent /usr/local/share/LinuxTraceToolkitViewer/yourfacility.xml -cp ltt-facility-yourfacility.h ltt-facility-id-yourfacility.h \ - /usr/src/linux-2.6.12-rc4-mm2-lttng-0.2/include/linux/ltt -cp ltt-facility-loader-yourfacility.c ltt-facility-loader-yourfacility.h \ - /usr/src/linux-2.6.12-rc4-mm2-lttng-0.2/ltt - * edit the kernel file you want to instrument - - Add #include at the beginning - of the file. - - Add a call to the tracing functions. See their names and parameters in - /usr/src/linux-2.6.12-rc4-mm2-lttng-0.2/include/linux/ltt/ltt-facility-yourfacility.h - - diff --git a/genevent/crc32.tab b/genevent/crc32.tab deleted file mode 100644 index d0174ad6..00000000 --- a/genevent/crc32.tab +++ /dev/null @@ -1,52 +0,0 @@ - 0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U, - 0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U, - 0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U, - 0x90bf1d91U, 0x1db71064U, 0x6ab020f2U, 0xf3b97148U, 0x84be41deU, - 0x1adad47dU, 0x6ddde4ebU, 0xf4d4b551U, 0x83d385c7U, 0x136c9856U, - 0x646ba8c0U, 0xfd62f97aU, 0x8a65c9ecU, 0x14015c4fU, 0x63066cd9U, - 0xfa0f3d63U, 0x8d080df5U, 0x3b6e20c8U, 0x4c69105eU, 0xd56041e4U, - 0xa2677172U, 0x3c03e4d1U, 0x4b04d447U, 0xd20d85fdU, 0xa50ab56bU, - 0x35b5a8faU, 0x42b2986cU, 0xdbbbc9d6U, 0xacbcf940U, 0x32d86ce3U, - 0x45df5c75U, 0xdcd60dcfU, 0xabd13d59U, 0x26d930acU, 0x51de003aU, - 0xc8d75180U, 0xbfd06116U, 0x21b4f4b5U, 0x56b3c423U, 0xcfba9599U, - 0xb8bda50fU, 0x2802b89eU, 0x5f058808U, 0xc60cd9b2U, 0xb10be924U, - 0x2f6f7c87U, 0x58684c11U, 0xc1611dabU, 0xb6662d3dU, 0x76dc4190U, - 0x01db7106U, 0x98d220bcU, 0xefd5102aU, 0x71b18589U, 0x06b6b51fU, - 0x9fbfe4a5U, 0xe8b8d433U, 0x7807c9a2U, 0x0f00f934U, 0x9609a88eU, - 0xe10e9818U, 0x7f6a0dbbU, 0x086d3d2dU, 0x91646c97U, 0xe6635c01U, - 0x6b6b51f4U, 0x1c6c6162U, 0x856530d8U, 0xf262004eU, 0x6c0695edU, - 0x1b01a57bU, 0x8208f4c1U, 0xf50fc457U, 0x65b0d9c6U, 0x12b7e950U, - 0x8bbeb8eaU, 0xfcb9887cU, 0x62dd1ddfU, 0x15da2d49U, 0x8cd37cf3U, - 0xfbd44c65U, 0x4db26158U, 0x3ab551ceU, 0xa3bc0074U, 0xd4bb30e2U, - 0x4adfa541U, 0x3dd895d7U, 0xa4d1c46dU, 0xd3d6f4fbU, 0x4369e96aU, - 0x346ed9fcU, 0xad678846U, 0xda60b8d0U, 0x44042d73U, 0x33031de5U, - 0xaa0a4c5fU, 0xdd0d7cc9U, 0x5005713cU, 0x270241aaU, 0xbe0b1010U, - 0xc90c2086U, 0x5768b525U, 0x206f85b3U, 0xb966d409U, 0xce61e49fU, - 0x5edef90eU, 0x29d9c998U, 0xb0d09822U, 0xc7d7a8b4U, 0x59b33d17U, - 0x2eb40d81U, 0xb7bd5c3bU, 0xc0ba6cadU, 0xedb88320U, 0x9abfb3b6U, - 0x03b6e20cU, 0x74b1d29aU, 0xead54739U, 0x9dd277afU, 0x04db2615U, - 0x73dc1683U, 0xe3630b12U, 0x94643b84U, 0x0d6d6a3eU, 0x7a6a5aa8U, - 0xe40ecf0bU, 0x9309ff9dU, 0x0a00ae27U, 0x7d079eb1U, 0xf00f9344U, - 0x8708a3d2U, 0x1e01f268U, 0x6906c2feU, 0xf762575dU, 0x806567cbU, - 0x196c3671U, 0x6e6b06e7U, 0xfed41b76U, 0x89d32be0U, 0x10da7a5aU, - 0x67dd4accU, 0xf9b9df6fU, 0x8ebeeff9U, 0x17b7be43U, 0x60b08ed5U, - 0xd6d6a3e8U, 0xa1d1937eU, 0x38d8c2c4U, 0x4fdff252U, 0xd1bb67f1U, - 0xa6bc5767U, 0x3fb506ddU, 0x48b2364bU, 0xd80d2bdaU, 0xaf0a1b4cU, - 0x36034af6U, 0x41047a60U, 0xdf60efc3U, 0xa867df55U, 0x316e8eefU, - 0x4669be79U, 0xcb61b38cU, 0xbc66831aU, 0x256fd2a0U, 0x5268e236U, - 0xcc0c7795U, 0xbb0b4703U, 0x220216b9U, 0x5505262fU, 0xc5ba3bbeU, - 0xb2bd0b28U, 0x2bb45a92U, 0x5cb36a04U, 0xc2d7ffa7U, 0xb5d0cf31U, - 0x2cd99e8bU, 0x5bdeae1dU, 0x9b64c2b0U, 0xec63f226U, 0x756aa39cU, - 0x026d930aU, 0x9c0906a9U, 0xeb0e363fU, 0x72076785U, 0x05005713U, - 0x95bf4a82U, 0xe2b87a14U, 0x7bb12baeU, 0x0cb61b38U, 0x92d28e9bU, - 0xe5d5be0dU, 0x7cdcefb7U, 0x0bdbdf21U, 0x86d3d2d4U, 0xf1d4e242U, - 0x68ddb3f8U, 0x1fda836eU, 0x81be16cdU, 0xf6b9265bU, 0x6fb077e1U, - 0x18b74777U, 0x88085ae6U, 0xff0f6a70U, 0x66063bcaU, 0x11010b5cU, - 0x8f659effU, 0xf862ae69U, 0x616bffd3U, 0x166ccf45U, 0xa00ae278U, - 0xd70dd2eeU, 0x4e048354U, 0x3903b3c2U, 0xa7672661U, 0xd06016f7U, - 0x4969474dU, 0x3e6e77dbU, 0xaed16a4aU, 0xd9d65adcU, 0x40df0b66U, - 0x37d83bf0U, 0xa9bcae53U, 0xdebb9ec5U, 0x47b2cf7fU, 0x30b5ffe9U, - 0xbdbdf21cU, 0xcabac28aU, 0x53b39330U, 0x24b4a3a6U, 0xbad03605U, - 0xcdd70693U, 0x54de5729U, 0x23d967bfU, 0xb3667a2eU, 0xc4614ab8U, - 0x5d681b02U, 0x2a6f2b94U, 0xb40bbe37U, 0xc30c8ea1U, 0x5a05df1bU, - 0x2d02ef8dU diff --git a/genevent/genevent.c b/genevent/genevent.c deleted file mode 100644 index b809a830..00000000 --- a/genevent/genevent.c +++ /dev/null @@ -1,1108 +0,0 @@ -/* - -genevent.c: Generate helper declarations and functions to trace events - from an event description file. - -Copyright (C) 2002, Xianxiu Yang -Copyright (C) 2002, Michel Dagenais - -This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* This program reads the ".event" event definitions input files - specified as command line arguments and generates corresponding - ".c" and ".h" files required to trace such events in the kernel. - - The program uses a very simple tokenizer, called from a hand written - recursive descent parser to fill a data structure describing the events. - The result is a sequence of events definitions which refer to type - definitions. - - A table of named types is maintained to allow refering to types by name - when the same type is used at several places. Finally a sequence of - all types is maintained to facilitate the freeing of all type - information when the processing of an ".event" file is finished. */ - -#include -#include -#include -#include -#include -#include -#include - -#include "parser.h" -#include "genevent.h" - -#define max(a,b) ((a)<(b))?(b):(a) - -/* Named types may be referenced from anywhere */ - -facility_t * fac; - -unsigned alignment = 0; - -int main(int argc, char** argv) -{ - char *token; - 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.buffer = buffer; - in.error = error_callback; - - for(i = 1 ; i < argc ; i++) { - - 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]); - - 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(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; -} - - -/***************************************************************************** - *Function name - * generateFile : generate .c and .h file - *Input Params - * name : name of event definition file - ****************************************************************************/ -void generateFile(char *name) -{ - char *loadName, *hName, *hIdName, *cName, *tmp, *tmp2; - FILE * lFp, *hFp, *iFp, *cFp; - int nbEvent; - unsigned long checksum=0; - - //remove .xml if it exists - tmp = &name[strlen(name)-4]; - if(strcmp(tmp, ".xml") == 0){ - *tmp = '\0'; - } - - tmp = strrchr(name,'/'); - if(tmp){ - tmp++; - }else{ - tmp = name; - } - - loadName = appendString("ltt-facility-loader-", tmp); - tmp2 = appendString(loadName,".h"); - free(loadName); - loadName = tmp2; - hName = appendString("ltt-facility-", tmp); - tmp2 = appendString(hName,".h"); - free(hName); - hName = tmp2; - hIdName = appendString("ltt-facility-id-", tmp); - tmp2 = appendString(hIdName,".h"); - free(hIdName); - hIdName = tmp2; - cName = appendString("ltt-facility-loader-", tmp); - tmp2 = appendString(cName,".c"); - free(cName); - cName = tmp2; - lFp = fopen(loadName,"w"); - if(!lFp){ - printf("Cannot open the file : %s\n",loadName); - exit(1); - } - - hFp = fopen(hName,"w"); - if(!hFp){ - printf("Cannot open the file : %s\n",hName); - exit(1); - } - - iFp = fopen(hIdName,"w"); - if(!iFp){ - printf("Cannot open the file : %s\n",hIdName); - exit(1); - } - - cFp = fopen(cName,"w"); - if(!cFp){ - printf("Cannot open the file : %s\n",cName); - exit(1); - } - - free(loadName); - free(hName); - free(hIdName); - free(cName); - - generateChecksum(fac->name, &checksum, &(fac->events)); - - /* generate .h file, event enumeration then structures and functions */ - fprintf(iFp, "#ifndef _LTT_FACILITY_ID_%s_H_\n",fac->capname); - fprintf(iFp, "#define _LTT_FACILITY_ID_%s_H_\n\n",fac->capname); - fprintf(iFp, "#ifdef CONFIG_LTT\n"); - generateEnumEvent(iFp, fac->name, &nbEvent, checksum); - fprintf(iFp, "#endif //CONFIG_LTT\n"); - fprintf(iFp, "#endif //_LTT_FACILITY_ID_%s_H_\n",fac->capname); - - - fprintf(hFp, "#ifndef _LTT_FACILITY_%s_H_\n",fac->capname); - fprintf(hFp, "#define _LTT_FACILITY_%s_H_\n\n",fac->capname); - //fprintf(hFp, "#ifdef CONFIG_LTT\n"); - generateTypeDefs(hFp, fac->name); - generateStructFunc(hFp, fac->name,checksum); - //fprintf(hFp, "#endif //CONFIG_LTT\n"); - fprintf(hFp, "#endif //_LTT_FACILITY_%s_H_\n",fac->capname); - - /* generate .h file, calls to register the facility at init time */ - generateLoaderfile(lFp,fac->name,nbEvent,checksum,fac->capname); - - // create ltt-facility-loader-facname.c - generateCfile(cFp, tmp); - - fclose(hFp); - fclose(iFp); - fclose(lFp); - fclose(cFp); - -} - - -/***************************************************************************** - *Function name - * generateEnumEvent : output event enum to .h file - *Input Params - * fp : file to be written to - * facName : name of facility - *Output Params - * nbEvent : number of events in the facility - ****************************************************************************/ -void generateEnumEvent(FILE *fp, char *facName, int * nbEvent, - unsigned long checksum) { - int pos = 0; - - fprintf(fp,"#include \n\n"); - - fprintf(fp,"/**** facility handle ****/\n\n"); - fprintf(fp,"extern ltt_facility_t ltt_facility_%s_%X;\n",facName, checksum); - fprintf(fp,"extern ltt_facility_t ltt_facility_%s;\n\n\n",facName, checksum); - - fprintf(fp,"/**** event type ****/\n\n"); - fprintf(fp,"enum %s_event {\n",facName); - - for(pos = 0; pos < fac->events.position;pos++) { - 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"); - - // fprintf(fp,"/**** number of events in the facility ****/\n\n"); - // fprintf(fp,"int nbEvents_%s = %d;\n\n\n",facName, fac->events.position); - *nbEvent = fac->events.position; -} - - -/***************************************************************************** - *Function name - * printStruct : Generic struct printing function - *Input Params - * fp : file to be written to - * len : number of fields - * array : array of field info - * name : basic struct name - * facName : name of facility - * whichTypeFirst : struct or array/sequence first - * hasStrSeq : string or sequence present? - * structCount : struct postfix - ****************************************************************************/ - -static void -printStruct(FILE * fp, int len, void ** array, char * name, char * facName, - int * whichTypeFirst, int * hasStrSeq, int * structCount, - type_descriptor_t *type) -{ - int flag = 0; - int pos; - field_t * fld; - type_descriptor_t * td; - - for (pos = 0; pos < len; pos++) { - fld = (field_t *)array[pos]; - td = fld->type; - if( td->type == STRING || td->type == SEQUENCE || - td->type == ARRAY) { - (*hasStrSeq)++; - } else { - if (flag == 0) { - flag = 1; - fprintf(fp,"struct %s_%s",name, facName); - if (structCount) { - fprintf(fp, "_%d {\n",++*structCount); - } else { - fprintf(fp, " {\n"); - } - } - fprintf(fp, "\t%s %s; /* %s */\n", - getTypeStr(td),fld->name,fld->description ); - } - } - - if(flag) { - unsigned align = max(alignment, type->alignment); - - if(align == 0) - fprintf(fp,"} __attribute__ ((packed));\n\n"); - else { - 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", align); - } - } -} - - -/***************************************************************************** - *Function name - * generateHfile : Create the typedefs - *Input Params - * fp : file to be written to - ****************************************************************************/ -void -generateTypeDefs(FILE * fp, char *facName) -{ - int pos, tmp = 1; - - fprintf(fp,"#include \n"); - fprintf(fp,"#include \n"); - fprintf(fp,"#include \n\n", facName); - fprintf(fp,"#include \n"); - -#if 0 //broken - fprintf(fp, "/**** Basic Type Definitions ****/\n\n"); - - for (pos = 0; pos < fac->named_types.values.position; pos++) { - type_descriptor * type = - (type_descriptor*)fac->named_types.values.array[pos]; - printStruct(fp, type->fields.position, type->fields.array, - "", type->type_name, &tmp, &tmp, NULL); - fprintf(fp, "typedef struct _%s %s;\n\n", - type->type_name, type->type_name); - } -#endif //0 -} - - -/***************************************************************************** - *Function name - * generateEnumDefinition: generate enum definition if it exists - *Input Params - * fp : file to be written to - * fHead : enum type - ****************************************************************************/ -void generateEnumDefinition(FILE * fp, type_descriptor_t * type){ - int pos; - - if(type->already_printed) return; - - fprintf(fp,"enum {\n"); - for(pos = 0; pos < type->labels.position; pos++){ - fprintf(fp,"\tLTT_ENUM_%s", type->labels.array[pos]); - if (pos != type->labels.position - 1) fprintf(fp,","); - if(type->labels_description.array[pos] != NULL) - fprintf(fp,"\t/* %s */\n",type->labels_description.array[pos]); - else - fprintf(fp,"\n"); - } - fprintf(fp,"};\n\n\n"); - - type->already_printed = 1; -} - -/***************************************************************************** - *Function name - * generateStrucTFunc: output structure and function to .h file - *Input Params - * fp : file to be written to - * facName : name of facility - ****************************************************************************/ -void generateStructFunc(FILE * fp, char * facName, unsigned long checksum){ - 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_t *) fac->events.array[pos]; - //yxx if(ev->nested)continue; - fprintf(fp,"/**** structure and trace function for event: %s ****/\n\n", - ev->name); - //if(ev->type == 0){ // event without type - // fprintf(fp,"static inline void trace_%s_%s(void){\n",facName,ev->name); - // fprintf(fp,"\tltt_log_event(ltt_facility_%s_%X, event_%s, 0, NULL);\n", - // facName,checksum,ev->name); - // fprintf(fp,"};\n\n\n"); - // continue; - //} - - //if fields contain enum, print out enum definition - //MD : fixed in generateEnumDefinition to do not print the same enum - //twice. - if(ev->type != 0) - for(pos1 = 0; pos1 < ev->type->fields.position; pos1++){ - fld = (field_t *)ev->type->fields.array[pos1]; - if(fld->type->type == ENUM) generateEnumDefinition(fp, fld->type); - } - - //default: no string, array or sequence in the event - hasStrSeq = 0; - whichTypeFirst = 0; - structCount = 0; - - //structure for kernel - if(ev->type != 0) - printStruct(fp, ev->type->fields.position, ev->type->fields.array, - ev->name, facName, &whichTypeFirst, &hasStrSeq, &structCount, - ev->type); - - - //trace function : function name and parameters : stub function. - seqCount = 0; - strCount = 0; - fprintf(fp, "#ifndef CONFIG_LTT\n"); - fprintf(fp,"static inline void trace_%s_%s(",facName,ev->name); - - 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_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); - args_empty = 0; - }else if(td->type == SEQUENCE){ - fprintf(fp,"%s seqlength_%d, %s * %s", - uintOutputTypes[td->size], ++seqCount,getTypeStr(td), fld->name); - 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"); - - //trace function : function name and parameters - seqCount = 0; - strCount = 0; - fprintf(fp,"static inline void trace_%s_%s(",facName,ev->name); - - 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_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); - args_empty = 0; - }else if(td->type == SEQUENCE){ - fprintf(fp,"%s seqlength_%d, %s * %s", - uintOutputTypes[td->size], ++seqCount,getTypeStr(td), fld->name); - 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"); - - //allocate buffer - // MD no more need. fprintf(fp,"\tchar buff[buflength];\n"); - // write directly to the channel - fprintf(fp, "\tunsigned int index;\n"); - fprintf(fp, "\tstruct ltt_channel_struct *channel;\n"); - fprintf(fp, "\tstruct ltt_trace_struct *trace;\n"); - fprintf(fp, "\tvoid *buff;\n"); - fprintf(fp, "\tunsigned int slot_size;\n"); // total size (incl hdr) - fprintf(fp, "\tunsigned int data_size;\n"); // Size of the event var data. - fprintf(fp, "\tunsigned int before_hdr_pad;\n");// Dynamic padding before event header - fprintf(fp, "\tunsigned int after_hdr_pad;\n"); // Dynamic padding after event header - 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); - - /* Warning : this is done prior to taking locks : - * setting this value must be done at the end of the trace activation. - * (we don't care for trace removal, as the list of traces is protected : it - * just won't iterate on any trace). */ - fprintf(fp, - "\tif(ltt_traces.num_active_traces == 0) return;\n\n"); - - /* Calculate event variable len + event alignment offset. - * Assume that the padding for alignment starts at a void* - * address. */ - fprintf(fp, "\t\tdata_size = 0;\n"); - - for(pos1=0;pos1type->alignment > 1) { - fprintf(fp,"\t\t\tdata_size += ltt_align(data_size, %u);\n", - ev->type->alignment); - } - fprintf(fp,"\t\t\tdata_size += sizeof(struct %s_%s_%d);\n", - ev->name,facName,pos1+1); -// if(pos1 != structCount-1) fprintf(fp," + "); - } - - //length of buffer : length of all arrays, sequences and strings - seqCount = 0; - strCount = 0; - flag = 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 == SEQUENCE || td->type==STRING || td->type==ARRAY){ - if(td->type == SEQUENCE) { - - if(td->alignment > 1) { - fprintf(fp,"\t\t\tdata_size += ltt_align(data_size, %u);\n", - td->alignment); - } - fprintf(fp,"\t\t\tdata_size += sizeof(%s);\n", - uintOutputTypes[td->size]); - - if(td->alignment > 1) { - fprintf(fp,"\t\tdata_size += ltt_align(data_size, %u);\n", - td->alignment); - } - fprintf(fp,"\t\tdata_size += sizeof(%s) * seqlength_%d;\n", - getTypeStr(td), seqCount); - - } else if(td->type==STRING) { - if(td->alignment > 1) { - fprintf(fp,"\t\tdata_size += ltt_align(data_size, %u);\n", - td->alignment); - } - strCount++; - fprintf(fp,"\t\tdata_size += strlength_%d + 1;\n", - strCount); - } - else if(td->type==ARRAY) { - if(td->alignment > 1) { - fprintf(fp,"\t\tdata_size += ltt_align(data_size, %u);\n", - td->alignment); - } - fprintf(fp,"\t\tdata_size += sizeof(%s) * %d;\n", - getTypeStr(td), td->size); - - if(structCount == 0) flag = 1; - } - } - } - - /* We use preempt_disable instead of rcu_read_lock because we want to - * use preempt_enable_no_resched : the only way to be called from the - * scheduler code safely! */ - fprintf(fp, "\tpreempt_disable();\n\n"); - fprintf(fp, "\tltt_nesting[smp_processor_id()]++;\n"); - fprintf(fp, "\tif(ltt_nesting[smp_processor_id()] > 1) goto unlock;\n"); - - 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_rcu(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"); - - fprintf(fp, "\t\tchannel = ltt_get_channel_from_index(trace, index);\n"); - fprintf(fp, "\t\tbuf = channel->rchan->buf[smp_processor_id()];\n"); - fprintf(fp, "\n"); - - - /* Relay reserve */ - fprintf(fp, "\t\tslot_size = 0;\n"); - fprintf(fp, "\t\tbuff = ltt_reserve_slot(trace, buf, event_length, &slot_size, &tsc,\n" - "\t\t&before_hdr_pad, &after_hdr_pad);\n"); - /* If error, return */ - fprintf(fp, "if(!buff) return;\n"); - - /* write data */ - - /* Write the header */ - /* FIXME : delta is not set ! */ - fprintf(fp, "\n"); - fprintf(fp, "\t\tltt_write_event_header(trace, channel, buff, \n" - "\t\t\t\tltt_facility_%s_%X, event_%s, data_size, before_hdr_pad,\n" - "\t\t\t\t&delta, &tsc);\n", - facName, checksum, ev->name); - fprintf(fp, "\n"); - - if(ev->type != 0) { - fprintf(fp,"\t\tptr = (char*)buff + before_hdr_pad + header_length + after_hdr_pad;\n"); - - /* Write structures */ - for(pos1=0;pos1type->alignment > 1) { - fprintf(fp,"\t\tptr += ltt_align((unsigned long)ptr, %u);\n", - ev->type->alignment); - } - fprintf(fp,"\t\t__%d = (struct %s_%s_%d *)(ptr);\n", - pos1+1, ev->name,facName,pos1+1); - - fprintf(fp,"\t\t/* initialize structs */\n"); - - for(pos1 = 0; pos1 < ev->type->fields.position; pos1++){ - fld = (field_t *)ev->type->fields.array[pos1]; - td = fld->type; - if(td->type != ARRAY && td->type != SEQUENCE && td->type != STRING){ - fprintf(fp, "\t\t__%d->%s = %s;\n", pos1+1, fld->name, fld->name); - } - } - if(structCount) 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;pos1name, 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;pos1name, 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;pos1name, 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_t *)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"); - - - //copy 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_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"); - - - - - /* commit */ - ltt_commit_slot(buf, buff, slot_size); - - - - -#if 0 - fprintf(fp, "\t\tdo {\n"); - fprintf(fp, "\t\t\told_offset = buf->offset;\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\tptr, &_offset, &delta, &tsc);\n"); - - fprintf(fp, "\t\t\tptr += _offset + header_length;\n"); - - fprintf(fp, "\t\t\tbuff = relay_reserve(channel->rchan, event_length, " - "old_offset);\n"); - fprintf(fp, "\n"); - fprintf(fp, "\t\t} while(PTR_ERR(buff) == -EAGAIN);\n"); - fprintf(fp, "\n"); - - - /* Reserve the channel */ - //fprintf(fp, "\t\tbuff = relay_reserve(channel->rchan, event_length);\n"); - fprintf(fp, "\t\tif(buff == NULL) {\n"); - fprintf(fp, "\t\t\t/* Buffer is full*/\n"); - fprintf(fp, "\t\t\t/* for debug BUG(); */\n"); // DEBUG! - fprintf(fp, "\t\t\tchannel->events_lost[smp_processor_id()]++;\n"); - fprintf(fp, "\t\t\tbreak;\n"); /* don't commit a NULL reservation! */ - fprintf(fp, "\t\t}\n"); - - /* DEBUG */ - //fprintf(fp, "\t\tif(resret == 1) {\n"); - //fprintf(fp, "printk(\"f%%lu e\%%u \", ltt_facility_%s_%X, event_%s);", - // facName, checksum, ev->name); - //fprintf(fp, "\t\t}\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" - "\t\t\t\tbuff, event_length);\n"); - fprintf(fp, "\t\tltt_write_commit_counter(" - "channel->rchan->buf[smp_processor_id()],\n" - "\t\t\t\tbuff);\n"); -#endif //0 - - /* End of traces iteration */ - fprintf(fp, "\t}\n\n"); - - fprintf(fp, "\n"); - - fprintf(fp, "unlock:\n"); - fprintf(fp, "\tltt_nesting[smp_processor_id()]--;\n"); - fprintf(fp, "\tpreempt_enable_no_resched();\n"); - //fprintf(fp, "\tpreempt_check_resched();\n"); - - //call trace function - //fprintf(fp,"\n\t//call trace function\n"); - //fprintf(fp,"\tltt_log_event(ltt_facility_%s_%X, %s, bufLength, buff);\n",facName,checksum,ev->name); - fprintf(fp,"}\n"); - fprintf(fp, "#endif //CONFIG_LTT\n\n"); - } - -} - -/***************************************************************************** - *Function name - * getTypeStr : generate type string - *Input Params - * td : a type descriptor - *Return Values - * char * : type string - ****************************************************************************/ -char * getTypeStr(type_descriptor_t * td){ - type_descriptor_t * t ; - - switch(td->type){ - case INT: - return intOutputTypes[td->size]; - case UINT: - return uintOutputTypes[td->size]; - case POINTER: - return "void *"; - case LONG: - return "long"; - case ULONG: - return "unsigned long"; - case SIZE_T: - return "size_t"; - case SSIZE_T: - return "ssize_t"; - case OFF_T: - return "off_t"; - case FLOAT: - return floatOutputTypes[td->size]; - case STRING: - return "const char"; - case ENUM: - return uintOutputTypes[td->size]; - case ARRAY: - case SEQUENCE: - t = td->nested_type; - switch(t->type){ - case INT: - return intOutputTypes[t->size]; - case UINT: - return uintOutputTypes[t->size]; - case POINTER: - return "void *"; - case LONG: - return "long"; - case ULONG: - return "unsigned long"; - case SIZE_T: - return "size_t"; - case SSIZE_T: - return "ssize_t"; - case OFF_T: - return "off_t"; - case FLOAT: - return floatOutputTypes[t->size]; - case STRING: - return "const char"; - case ENUM: - return uintOutputTypes[t->size]; - default : - error_callback(NULL,"Nested struct is not supportted"); - break; - } - break; - case STRUCT: //for now we do not support nested struct - error_callback(NULL,"Nested struct is not supportted"); - break; - default: - error_callback(NULL,"No type information"); - break; - } - return NULL; -} - -/***************************************************************************** - *Function name - * generateLoaderfile: generate a facility loaded .h file - *Input Params - * fp : file to be written to - * facName : name of facility - * nbEvent : number of events in the facility - * checksum : checksum for the facility - ****************************************************************************/ -void generateLoaderfile(FILE * fp, char * facName, int nbEvent, unsigned long checksum, char *capname){ - fprintf(fp, "#ifndef _LTT_FACILITY_LOADER_%s_H_\n",capname); - fprintf(fp, "#define _LTT_FACILITY_LOADER_%s_H_\n\n",capname); - fprintf(fp,"#include \n", facName, checksum); - fprintf(fp,"ltt_facility_t\tltt_facility_%s;\n", facName, checksum); - fprintf(fp,"ltt_facility_t\tltt_facility_%s_%X;\n\n", facName, checksum); - - fprintf(fp,"#define LTT_FACILITY_SYMBOL\t\t\t\t\t\t\tltt_facility_%s\n", - facName); - fprintf(fp,"#define LTT_FACILITY_CHECKSUM_SYMBOL\t\tltt_facility_%s_%X\n", - facName, checksum); - fprintf(fp,"#define LTT_FACILITY_CHECKSUM\t\t\t\t\t\t0x%X\n", checksum); - fprintf(fp,"#define LTT_FACILITY_NAME\t\t\t\t\t\t\t\t\"%s\"\n", facName); - fprintf(fp,"#define LTT_FACILITY_NUM_EVENTS\t\t\t\t\t%d\n\n", nbEvent); - fprintf(fp, "#endif //_LTT_FACILITY_LOADER_%s_H_\n",capname); -} - -void generateCfile(FILE * fp, char * filefacname){ - - fprintf(fp, "/*\n"); - fprintf(fp, " * ltt-facility-loader-%s.c\n", filefacname); - fprintf(fp, " *\n"); - fprintf(fp, " * (C) Copyright 2005 - \n"); - fprintf(fp, " * Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca)\n"); - fprintf(fp, " *\n"); - fprintf(fp, " * Contains the LTT facility loader.\n"); - fprintf(fp, " *\n"); - fprintf(fp, " */\n"); - fprintf(fp, "\n"); - fprintf(fp, "\n"); - fprintf(fp, "#include \n"); - fprintf(fp, "#include \n"); - fprintf(fp, "#include \n"); - fprintf(fp, "#include \n"); - fprintf(fp, "#include \"ltt-facility-loader-%s.h\"\n", filefacname); - fprintf(fp, "\n"); - fprintf(fp, "\n"); - fprintf(fp, "#ifdef CONFIG_LTT\n"); - fprintf(fp, "\n"); - fprintf(fp, "EXPORT_SYMBOL(LTT_FACILITY_SYMBOL);\n"); - fprintf(fp, "EXPORT_SYMBOL(LTT_FACILITY_CHECKSUM_SYMBOL);\n"); - fprintf(fp, "\n"); - fprintf(fp, "static const char ltt_facility_name[] = LTT_FACILITY_NAME;\n"); - fprintf(fp, "\n"); - fprintf(fp, "#define SYMBOL_STRING(sym) #sym\n"); - fprintf(fp, "\n"); - fprintf(fp, "static struct ltt_facility facility = {\n"); - 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.alignment = %u\n", alignment); /* default alignment */ - fprintf(fp, "};\n"); - fprintf(fp, "\n"); - fprintf(fp, "#ifndef MODULE\n"); - fprintf(fp, "\n"); - fprintf(fp, "/* Built-in facility. */\n"); - fprintf(fp, "\n"); - fprintf(fp, "static int __init facility_init(void)\n"); - fprintf(fp, "{\n"); - fprintf(fp, "\tprintk(KERN_INFO \"LTT : ltt-facility-%s init in kernel\\n\");\n", filefacname); - fprintf(fp, "\n"); - fprintf(fp, "\tLTT_FACILITY_SYMBOL = ltt_facility_builtin_register(&facility);\n"); - fprintf(fp, "\tLTT_FACILITY_CHECKSUM_SYMBOL = LTT_FACILITY_SYMBOL;\n"); - fprintf(fp, "\t\n"); - fprintf(fp, "\treturn LTT_FACILITY_SYMBOL;\n"); - fprintf(fp, "}\n"); - fprintf(fp, "__initcall(facility_init);\n"); - fprintf(fp, "\n"); - fprintf(fp, "\n"); - fprintf(fp, "\n"); - fprintf(fp, "#else \n"); - fprintf(fp, "\n"); - fprintf(fp, "/* Dynamic facility. */\n"); - fprintf(fp, "\n"); - fprintf(fp, "static int __init facility_init(void)\n"); - fprintf(fp, "{\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_CHECKSUM_SYMBOL = LTT_FACILITY_SYMBOL;\n"); - fprintf(fp, "\n"); - fprintf(fp, "\treturn LTT_FACILITY_SYMBOL;\n"); - fprintf(fp, "}\n"); - fprintf(fp, "\n"); - fprintf(fp, "static void __exit facility_exit(void)\n"); - fprintf(fp, "{\n"); - fprintf(fp, "\tint err;\n"); - fprintf(fp, "\n"); - fprintf(fp, "\terr = ltt_facility_dynamic_unregister(LTT_FACILITY_SYMBOL);\n"); - fprintf(fp, "\tif(err != 0)\n"); - fprintf(fp, "\t\tprintk(KERN_ERR \"LTT : Error in unregistering facility.\\n\");\n"); - fprintf(fp, "\n"); - fprintf(fp, "}\n"); - fprintf(fp, "\n"); - fprintf(fp, "module_init(facility_init)\n"); - fprintf(fp, "module_exit(facility_exit)\n"); - fprintf(fp, "\n"); - fprintf(fp, "\n"); - fprintf(fp, "MODULE_LICENSE(\"GPL\");\n"); - fprintf(fp, "MODULE_AUTHOR(\"Mathieu Desnoyers\");\n"); - fprintf(fp, "MODULE_DESCRIPTION(\"Linux Trace Toolkit Facility\");\n"); - fprintf(fp, "\n"); - fprintf(fp, "#endif //MODULE\n"); - fprintf(fp, "\n"); - fprintf(fp, "#endif //CONFIG_LTT\n"); -} - - diff --git a/genevent/genevent.h b/genevent/genevent.h deleted file mode 100644 index 0e594d62..00000000 --- a/genevent/genevent.h +++ /dev/null @@ -1,12 +0,0 @@ - -void generateFile(char * file); -void generateHfile(FILE *); -void generateCfile(FILE * fp, char * facName); -void generateTypeDefs(FILE *, char *facName); -void generateEnumEvent(FILE * fp,char * facName, int * nbEvent, unsigned long checksum); -void generateStructFunc(FILE * fp, char * facName, unsigned long checksum); -void generateLoaderfile(FILE * fp, char * facName, int nbEvent, unsigned long checksum, char *capname); -void generateEnumDefinition(FILE * fp, type_descriptor_t * fHead); -char * getTypeStr(type_descriptor_t * td); - - diff --git a/genevent/parser.c b/genevent/parser.c deleted file mode 100644 index aa87db95..00000000 --- a/genevent/parser.c +++ /dev/null @@ -1,1397 +0,0 @@ -/* - -parser.c: Generate helper declarations and functions to trace events - from an event description file. - -Copyright (C) 2002, Xianxiu Yang -Copyright (C) 2002, Michel Dagenais -This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* This program reads the ".xml" event definitions input files - and constructs structure for each event. - - The program uses a very simple tokenizer, called from a hand written - recursive descent parser to fill a data structure describing the events. - The result is a sequence of events definitions which refer to type - definitions. - - A table of named types is maintained to allow refering to types by name - when the same type is used at several places. Finally a sequence of - all types is maintained to facilitate the freeing of all type - information when the processing of an ".xml" file is finished. */ - -#include -#include -#include -#include -#include -#include - - -#include "parser.h" - - -/* helper function */ -void strupper(char *string) -{ - char *ptr = string; - - while(*ptr != '\0') { - *ptr = toupper(*ptr); - ptr++; - } -} - - -int getSizeindex(int value) -{ - switch(value) { - case 1: - return 0; - case 2: - return 1; - case 4: - return 2; - case 8: - return 3; - default: - printf("Error : unknown value size %d\n", value); - exit(-1); - } -} - -/***************************************************************************** - *Function name - * getSize : translate from string to integer - *Input params - * in : input file handle - *Return values - * size - *****************************************************************************/ - -int getSize(parse_file_t *in) -{ - char *token; - - token = getToken(in); - if(in->type == NUMBER) { - if(strcmp(token,"1") == 0) return 0; - else if(strcmp(token,"2") == 0) return 1; - else if(strcmp(token,"4") == 0) return 2; - else if(strcmp(token,"8") == 0) return 3; - } - else if(in->type == NAME) { - if(strcmp(token,"short") == 0) return 4; - else if(strcmp(token,"medium") == 0) return 5; - else if(strcmp(token,"long") == 0) return 6; - } - in->error(in,"incorrect size specification"); - return -1; -} - -/***************************************************************************** - *Function name - * error_callback : print out error info - *Input params - * in : input file handle - * msg : message to be printed - ****************************************************************************/ - -void error_callback(parse_file_t *in, char *msg) -{ - if(in) - printf("Error in file %s, line %d: %s\n", in->name, in->lineno, msg); - else - printf("%s\n",msg); - assert(0); - exit(1); -} - -/***************************************************************************** - *Function name - * memAlloc : allocate memory - *Input params - * size : required memory size - *return value - * void * : pointer to allocate memory or NULL - ****************************************************************************/ - -void * memAlloc(int size) -{ - void * addr; - if(size == 0) return NULL; - addr = malloc(size); - if(!addr){ - printf("Failed to allocate memory"); - exit(1); - } - return addr; -} - -/***************************************************************************** - *Function name - * allocAndCopy : allocate memory and initialize it - *Input params - * str : string to be put in memory - *return value - * char * : pointer to allocate memory or NULL - ****************************************************************************/ - -char *allocAndCopy(char *str) -{ - char * addr; - if(str == NULL) return NULL; - addr = (char *)memAlloc(strlen(str)+1); - strcpy(addr,str); - return addr; -} - -/************************************************************************** - * Function : - * getTypeAttributes - * Description : - * Read the attribute from the input file. - * - * Parameters : - * in , input file handle. - * t , the type descriptor to fill. - * - **************************************************************************/ - -void getTypeAttributes(parse_file_t *in, type_descriptor_t *t) -{ - char * token; - char car; - - t->fmt = NULL; - t->size = -1; - t->alignment = 0; - - while(1) { - token = getToken(in); - if(strcmp("/",token) == 0 || strcmp(">",token) == 0){ - ungetToken(in); - break; - } - - if(!strcmp("format",token)) { - getEqual(in); - t->fmt = allocAndCopy(getQuotedString(in)); - //} else if(!strcmp("name",token)) { - // getEqual(in); - // car = seekNextChar(in); - // if(car == EOF) in->error(in,"name was expected"); - // else if(car == '\"') t->type_name = allocAndCopy(getQuotedString(in)); - // else t->type_name = allocAndCopy(getName(in)); - } else if(!strcmp("size",token)) { - getEqual(in); - t->size = getSize(in); - } else if(!strcmp("align",token)) { - getEqual(in); - t->alignment = getNumber(in); - } - } -} - -/************************************************************************** - * Function : - * getEventAttributes - * Description : - * Read the attribute from the input file. - * - * Parameters : - * in , input file handle. - * ev , the event to fill. - * - **************************************************************************/ - -void getEventAttributes(parse_file_t *in, event_t *ev) -{ - char * token; - char car; - - ev->name = NULL; - ev->per_trace = 0; - ev->per_tracefile = 0; - - while(1) { - token = getToken(in); - if(strcmp("/",token) == 0 || strcmp(">",token) == 0){ - ungetToken(in); - break; - } - - if(!strcmp("name",token)) { - getEqual(in); - car = seekNextChar(in); - 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; - } - - } -} - -/************************************************************************** - * Function : - * getFacilityAttributes - * Description : - * Read the attribute from the input file. - * - * Parameters : - * in , input file handle. - * fac , the facility to fill. - * - **************************************************************************/ - -void getFacilityAttributes(parse_file_t *in, facility_t *fac) -{ - char * token; - char car; - - fac->name = NULL; - - while(1) { - token = getToken(in); - if(strcmp("/",token) == 0 || strcmp(">",token) == 0){ - ungetToken(in); - break; - } - - if(!strcmp("name",token)) { - getEqual(in); - car = seekNextChar(in); - if(car == EOF) in->error(in,"name was expected"); - else if(car == '\"') fac->name = allocAndCopy(getQuotedString(in)); - else fac->name = allocAndCopy(getName(in)); - } - } -} - -/************************************************************************** - * Function : - * getFieldAttributes - * Description : - * Read the attribute from the input file. - * - * Parameters : - * in , input file handle. - * f , the field to fill. - * - **************************************************************************/ - -void getFieldAttributes(parse_file_t *in, field_t *f) -{ - char * token; - char car; - - f->name = NULL; - - while(1) { - token = getToken(in); - if(strcmp("/",token) == 0 || strcmp(">",token) == 0){ - ungetToken(in); - break; - } - - if(!strcmp("name",token)) { - getEqual(in); - car = seekNextChar(in); - if(car == EOF) in->error(in,"name was expected"); - else if(car == '\"') f->name = allocAndCopy(getQuotedString(in)); - else f->name = allocAndCopy(getName(in)); - } - } -} - -char *getNameAttribute(parse_file_t *in) -{ - char * token; - char *name = NULL; - char car; - - while(1) { - token = getToken(in); - if(strcmp("/",token) == 0 || strcmp(">",token) == 0){ - ungetToken(in); - break; - } - - if(!strcmp("name",token)) { - getEqual(in); - car = seekNextChar(in); - if(car == EOF) in->error(in,"name was expected"); - else if(car == '\"') name = allocAndCopy(getQuotedString(in)); - else name = allocAndCopy(getName(in)); - } - } - if(name == NULL) in->error(in, "Name was expected"); - return name; - -} - - - -//for