X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=genevent%2Fparser.h;h=a4b3723b094c9c33909afcc9ac700a40137118ae;hb=dd455fb8aa68172162fa7a44c534a405bccf1aa4;hp=661207761223ab1094b91aac5ec3932bcc11f561;hpb=3888436ce256d6b48f9354006a2acc8a25fb6889;p=lttv.git diff --git a/genevent/parser.h b/genevent/parser.h index 66120776..a4b3723b 100644 --- a/genevent/parser.h +++ b/genevent/parser.h @@ -7,27 +7,27 @@ typedef struct _sequence { int size; int position; void **array; -} sequence; +} sequence_t; -void sequence_init(sequence *t); -void sequence_dispose(sequence *t); -void sequence_push(sequence *t, void *elem); -void *sequence_pop(sequence *t); +void sequence_init(sequence_t *t); +void sequence_dispose(sequence_t *t); +void sequence_push(sequence_t *t, void *elem); +void *sequence_pop(sequence_t *t); /* Hash table */ typedef struct _table { - sequence keys; - sequence values; -} table; + sequence_t keys; + sequence_t values; +} table_t; -void table_init(table *t); -void table_dispose(table *t); -void table_insert(table *t, char *key, void *value); -void *table_find(table *t, char *key); -void table_insert_int(table *t, int *key, void *value); -void *table_find_int(table *t, int *key); +void table_init(table_t *t); +void table_dispose(table_t *t); +void table_insert(table_t *t, char *key, void *value); +void *table_find(table_t *t, char *key); +void table_insert_int(table_t *t, int *key, void *value); +void *table_find_int(table_t *t, int *key); /* Token types */ @@ -41,7 +41,7 @@ typedef enum _token_type { QUOTEDSTRING, NUMBER, NAME -} token_type; +} token_type_t; /* State associated with a file being parsed */ @@ -50,26 +50,24 @@ typedef struct _parse_file { FILE * fp; int lineno; char *buffer; - token_type type; + token_type_t type; int unget; void (*error) (struct _parse_file *, char *); -} parse_file; - -void ungetToken(parse_file * in); -char *getToken(parse_file *in); -char *getForwardslash(parse_file *in); -char *getLAnglebracket(parse_file *in); -char *getRAnglebracket(parse_file *in); -char *getQuotedString(parse_file *in); -char *getName(parse_file *in); -int getNumber(parse_file *in); -char *getEqual(parse_file *in); -char seekNextChar(parse_file *in); - -void skipComment(parse_file * in); -void skipEOL(parse_file * in); -int isalpha(char car); -int isalnum(char car); +} parse_file_t; + +void ungetToken(parse_file_t * in); +char *getToken(parse_file_t *in); +char *getForwardslash(parse_file_t *in); +char *getLAnglebracket(parse_file_t *in); +char *getRAnglebracket(parse_file_t *in); +char *getQuotedString(parse_file_t *in); +char *getName(parse_file_t *in); +int getNumber(parse_file_t *in); +char *getEqual(parse_file_t *in); +int seekNextChar(parse_file_t *in); + +void skipComment(parse_file_t * in); +void skipEOL(parse_file_t * in); /* Some constants */ @@ -79,8 +77,20 @@ static const int BUFFER_SIZE = 1024; /* Events data types */ typedef enum _data_type { + INT_FIXED, + UINT_FIXED, + POINTER, + CHAR, + UCHAR, + SHORT, + USHORT, INT, UINT, + LONG, + ULONG, + SIZE_T, + SSIZE_T, + OFF_T, FLOAT, STRING, ENUM, @@ -89,79 +99,94 @@ typedef enum _data_type { STRUCT, UNION, NONE -} data_type; +} data_type_t; - -/* Event type descriptors */ +typedef struct _facility facility_t; +typedef struct _event event_t; typedef struct _type_descriptor { + facility_t *fac; char * type_name; //used for named type - data_type type; + data_type_t type; char *fmt; - int size; - sequence labels; // for enumeration - sequence fields; // for structure - struct _type_descriptor *nested_type; // for array and sequence -} type_descriptor; - - -/* Fields within types */ - + size_t size; + sequence_t labels; // for enumeration + sequence_t labels_values; // for enumeration + sequence_t labels_description; + int already_printed; + sequence_t fields; // for structure, array and sequence (field_t type) + int custom_write; /* Should we use a custom write function ? */ + int network; /* Is the type a in network byte order ? */ +} type_descriptor_t; + + +/* Fields within types or events */ typedef struct _field{ + facility_t *fac; char *name; char *description; - type_descriptor *type; -} field; + type_descriptor_t *type; +} field_t; /* Events definitions */ -typedef struct _event { +struct _event { + facility_t *fac; char *name; char *description; - type_descriptor *type; -} event; + //type_descriptor_t *type; + sequence_t fields; /* event fields */ + 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 ? */ + int param_buffer; /* For userspace tracing : takes a buffer as parameter? */ + int no_instrument_function; + int high_priority; + int force; + int compact_data; +}; -typedef struct _facility { +struct _facility { char * name; + char * capname; + char * arch; + int align; /* Alignment : default 1, 0 no alignment. */ char * description; - sequence events; - sequence unnamed_types; - table named_types; -} facility; - -int getSize(parse_file *in); -unsigned long getTypeChecksum(unsigned long aCrc, type_descriptor * type); + sequence_t events; + sequence_t unnamed_types; //FIXME : remove + table_t named_types; + unsigned int checksum; + int user; /* Is this a userspace facility ? */ +}; -void parseFacility(parse_file *in, facility * fac); -void parseEvent(parse_file *in, event *ev, sequence * unnamed_types, table * named_types); -void parseTypeDefinition(parse_file *in, sequence * unnamed_types, table * named_types); -type_descriptor *parseType(parse_file *in, type_descriptor *t, sequence * unnamed_types, table * named_types); -void parseFields(parse_file *in, type_descriptor *t, sequence * unnamed_types, table * named_types); -void checkNamedTypesImplemented(table * namedTypes); -type_descriptor * find_named_type(char *name, table * named_types); -void generateChecksum(char * facName, unsigned long * checksum, sequence * events); +int getSizeindex(unsigned int value); +unsigned long long int getSize(parse_file_t *in); +unsigned long getTypeChecksum(unsigned long aCrc, type_descriptor_t * type); + +void parseFacility(parse_file_t *in, facility_t * fac); +void parseEvent(facility_t *fac, parse_file_t *in, event_t *ev, sequence_t * unnamed_types, + table_t * named_types); +void parseTypeDefinition(facility_t *fac, parse_file_t *in, + sequence_t * unnamed_types, table_t * named_types); +type_descriptor_t *parseType(facility_t *fac, parse_file_t *in, + type_descriptor_t *t, sequence_t * unnamed_types, table_t * named_types); +void parseFields(facility_t *fac, parse_file_t *in, field_t *f, + sequence_t * unnamed_types, + table_t * named_types, + int tag); +void checkNamedTypesImplemented(table_t * namedTypes); +type_descriptor_t * find_named_type(char *name, table_t * named_types); +void generateChecksum(char * facName, + unsigned int * checksum, sequence_t * events); /* get attributes */ -char * getNameAttribute(parse_file *in); -char * getFormatAttribute(parse_file *in); -int getSizeAttribute(parse_file *in); -int getValueAttribute(parse_file *in); -char * getValueStrAttribute(parse_file *in); - -char * getDescription(parse_file *in); +char * getNameAttribute(parse_file_t *in); +char * getFormatAttribute(parse_file_t *in); +int getSizeAttribute(parse_file_t *in); +int getValueAttribute(parse_file_t *in, long long *value); - -static char *intOutputTypes[] = { - "int8_t", "int16_t", "int32_t", "int64_t", "short int", "int", "long int" }; - -static char *uintOutputTypes[] = { - "uint8_t", "uint16_t", "uint32_t", "uint64_t", "unsigned short int", - "unsigned int", "unsigned long int" }; - -static char *floatOutputTypes[] = { - "undef", "undef", "float", "double", "undef", "float", "double" }; +char * getDescription(parse_file_t *in); /* Dynamic memory allocation and freeing */ @@ -169,11 +194,11 @@ static char *floatOutputTypes[] = { void * memAlloc(int size); char *allocAndCopy(char * str); char *appendString(char *s, char *suffix); -void freeTypes(sequence *t); -void freeType(type_descriptor * td); -void freeEvents(sequence *t); -void freeNamedType(table * t); -void error_callback(parse_file *in, char *msg); +void freeTypes(sequence_t *t); +void freeType(type_descriptor_t * td); +void freeEvents(sequence_t *t); +void freeNamedType(table_t * t); +void error_callback(parse_file_t *in, char *msg); //checksum part @@ -203,4 +228,13 @@ crc32(const char *s) } +extern char *intOutputTypes[]; + +extern char *uintOutputTypes[]; + +extern char *floatOutputTypes[]; + + + + #endif // PARSER_H