X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;ds=sidebyside;f=ltt%2Fbranches%2Fpoly%2Fltt%2Fparser.c;h=55d7c96cce9f945aa7becd4eea3a7a88b2afd8ac;hb=1524480763993efe79685e6aa26db055ae8ed99a;hp=2316299249c680dd4acaa9c13faf14261469785d;hpb=f104d082727461632e7a5cc1d2a854f0ad66db07;p=lttv.git diff --git a/ltt/branches/poly/ltt/parser.c b/ltt/branches/poly/ltt/parser.c index 23162992..55d7c96c 100644 --- a/ltt/branches/poly/ltt/parser.c +++ b/ltt/branches/poly/ltt/parser.c @@ -182,6 +182,7 @@ void getTypeAttributes(parse_file_t *in, type_descriptor_t *t, t->fmt = NULL; t->size = 0; + t->custom_write = 0; while(1) { token = getToken(in); @@ -202,6 +203,8 @@ void getTypeAttributes(parse_file_t *in, type_descriptor_t *t, } else if(!strcmp("size",token)) { getEqual(in); t->size = getSize(in); + } else if(!strcmp("custom_write", token)) { + t->custom_write = 1; } } } @@ -267,6 +270,7 @@ void getFacilityAttributes(parse_file_t *in, facility_t *fac) char car; fac->name = NULL; + fac->arch = NULL; while(1) { token = getToken(in); @@ -281,7 +285,12 @@ void getFacilityAttributes(parse_file_t *in, facility_t *fac) if(car == EOF) in->error(in,"name was expected"); else if(car == '\"') fac->name = allocAndCopy(getQuotedString(in)); else fac->name = allocAndCopy(getName(in)); - } + } else if(!strcmp("arch", token)) { + getEqual(in); + car = seekNextChar(in); + if(car == '\"') fac->name = allocAndCopy(getQuotedString(in)); + else fac->arch = allocAndCopy(getName(in)); + } } } @@ -329,22 +338,20 @@ char *getNameAttribute(parse_file_t *in) 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)); + } else { + ungetToken(in); + break; } + } if(name == NULL) in->error(in, "Name was expected"); return name; - } @@ -420,7 +427,7 @@ void parseFacility(parse_file_t *in, facility_t * fac) getFacilityAttributes(in, fac); if(fac->name == NULL) in->error(in, "Attribute not named"); - + fac->capname = allocAndCopy(fac->name); strupper(fac->capname); getRAnglebracket(in); @@ -548,6 +555,8 @@ void parseFields(parse_file_t *in, field_t *f, getRAnglebracket(in); f->description = getDescription(in); + } else { + f->description = NULL; } // @@ -674,8 +683,8 @@ type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType, else if(strcmp(token,"sequence") == 0) { t->type = SEQUENCE; sequence_init(&(t->fields)); - //getTypeAttributes(in, t, unnamed_types, named_types); - //getForwardslash(in); + getTypeAttributes(in, t, unnamed_types, named_types); + getForwardslash(in); getRAnglebracket(in); // //getLAnglebracket(in); // @@ -741,7 +750,7 @@ type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType, while(strcmp("label",token) == 0){ int *label_value = malloc(sizeof(int)); - str = allocAndCopy(getNameAttribute(in)); + str = allocAndCopy(getNameAttribute(in)); token = getValueStrAttribute(in); sequence_push(&(t->labels),str); @@ -784,29 +793,29 @@ type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType, } else if(strcmp(token,"char") == 0) { t->type = CHAR; - t->size = 1; getTypeAttributes(in, t, unnamed_types, named_types); + t->size = 1; getForwardslash(in); getRAnglebracket(in); } else if(strcmp(token,"uchar") == 0) { t->type = UCHAR; - t->size = 1; getTypeAttributes(in, t, unnamed_types, named_types); + t->size = 1; getForwardslash(in); getRAnglebracket(in); } else if(strcmp(token,"short") == 0) { t->type = SHORT; - t->size = 2; getTypeAttributes(in, t, unnamed_types, named_types); + t->size = 2; getForwardslash(in); getRAnglebracket(in); } else if(strcmp(token,"ushort") == 0) { t->type = USHORT; - t->size = 2; getTypeAttributes(in, t, unnamed_types, named_types); + t->size = 2; getForwardslash(in); getRAnglebracket(in); } @@ -972,7 +981,8 @@ char *getName(parse_file_t * in) char *token; token = getToken(in); - if(in->type != NAME) in->error(in,"Name token was expected"); + // Optional descriptions + // if(in->type != NAME) in->error(in,"Name token was expected"); return token; } @@ -1154,11 +1164,11 @@ char *getToken(parse_file_t * in) if(pos == BUFFER_SIZE) in->error(in, "number token too large"); in->type = NUMBER; } - else if(isalpha(car)) { + else if(isalnum(car) || car == '_' || car == '-') { in->buffer[0] = car; pos = 1; while((car = getc(fp)) != EOF && pos < BUFFER_SIZE) { - if(!(isalnum(car) || car == '_')) { + if(!(isalnum(car) || car == '_' || car == '-')) { ungetc(car,fp); break; } @@ -1239,12 +1249,13 @@ void generateChecksum(char* facName, unsigned long crc ; int pos; event_t * ev; + unsigned int i; crc = crc32(facName); for(pos = 0; pos < events->position; pos++){ ev = (event_t *)(events->array[pos]); crc = partial_crc32(ev->name, crc); - for(unsigned int i = 0; i < ev->fields.position; i++) { + for(i = 0; i < ev->fields.position; i++) { field_t *f = (field_t*)ev->fields.array[i]; crc = partial_crc32(f->name, crc); crc = getTypeChecksum(crc, f->type); @@ -1343,8 +1354,7 @@ unsigned long getTypeChecksum(unsigned long aCrc, type_descriptor_t * type) flag = 1; break; case SEQUENCE: - sprintf(buf,"%zu", type->size); - str = appendString("sequence ",buf); + str = allocAndCopy("sequence "); flag = 1; break; case STRUCT: @@ -1487,7 +1497,8 @@ void sequence_push(sequence_t *t, void *elem) void *sequence_pop(sequence_t *t) { - return t->array[t->position--]; + if(t->position == 0) printf("Error : trying to pop an empty sequence"); + return t->array[--t->position]; } @@ -1550,5 +1561,3 @@ char *appendString(char *s, char *suffix) strcat(tmp,suffix); return tmp; } - -