X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Fparser.c;h=ba331e9edb88ae9da88a97545bb05c94e8f81c59;hb=4a6829e2f886c2b3aa8d9ec4e0142ef5edb390d6;hp=921c559ae5fed7e131107fc14f79db99d33b6fce;hpb=743e50fd0105daeea4804d68989965399bf3a4d3;p=lttv.git
diff --git a/ltt/branches/poly/ltt/parser.c b/ltt/branches/poly/ltt/parser.c
index 921c559a..ba331e9e 100644
--- a/ltt/branches/poly/ltt/parser.c
+++ b/ltt/branches/poly/ltt/parser.c
@@ -97,11 +97,26 @@ int getSizeindex(unsigned int value)
unsigned long long int getSize(parse_file_t *in)
{
char *token;
+ int has_quotes = 0;
+ unsigned long long int ret;
token = getToken(in);
+ if(token[0] == '"') {
+ has_quotes = 1;
+ token = getToken(in);
+ }
if(in->type == NUMBER) {
- return strtoull(token, NULL, 0);
- }
+ ret = strtoull(token, NULL, 0);
+ } else {
+ goto error;
+ }
+ if(has_quotes) {
+ token = getToken(in);
+ if(token[0] != '"') goto error;
+ }
+
+ return ret;
+error:
in->error(in,"incorrect size specification");
return -1;
}
@@ -182,6 +197,8 @@ void getTypeAttributes(parse_file_t *in, type_descriptor_t *t,
t->fmt = NULL;
t->size = 0;
+ t->custom_write = 0;
+ t->network = 0;
while(1) {
token = getToken(in);
@@ -202,7 +219,11 @@ 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;
+ } else if(!strcmp("network", token)) {
+ t->network = 1;
+ }
}
}
@@ -226,6 +247,7 @@ void getEventAttributes(parse_file_t *in, event_t *ev)
ev->name = NULL;
ev->per_trace = 0;
ev->per_tracefile = 0;
+ ev->param_buffer = 0;
while(1) {
token = getToken(in);
@@ -244,7 +266,9 @@ void getEventAttributes(parse_file_t *in, event_t *ev)
ev->per_trace = 1;
} else if(!strcmp("per_tracefile", token)) {
ev->per_tracefile = 1;
- }
+ } else if(!strcmp("param_buffer", token)) {
+ ev->param_buffer = 1;
+ }
}
}
@@ -267,6 +291,8 @@ void getFacilityAttributes(parse_file_t *in, facility_t *fac)
char car;
fac->name = NULL;
+ fac->arch = NULL;
+ fac->user = 0;
while(1) {
token = getToken(in);
@@ -281,7 +307,14 @@ 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));
- }
+ if(!strncmp(fac->name, "user_", sizeof("user_")) == 0)
+ fac->user = 1;
+ } else if(!strcmp("arch", token)) {
+ getEqual(in);
+ car = seekNextChar(in);
+ if(car == '\"') fac->name = allocAndCopy(getQuotedString(in));
+ else fac->arch = allocAndCopy(getName(in));
+ }
}
}
@@ -318,7 +351,7 @@ void getFieldAttributes(parse_file_t *in, field_t *f)
else if(car == '\"') f->name = allocAndCopy(getQuotedString(in));
else f->name = allocAndCopy(getName(in));
}
- }
+ }
}
char *getNameAttribute(parse_file_t *in)
@@ -329,42 +362,59 @@ 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;
-
}
//for , value is an option
-char * getValueStrAttribute(parse_file_t *in)
+//Return value : 0 : no value, 1 : has a value
+int getValueAttribute(parse_file_t *in, long long *value)
{
char * token;
+ int has_quotes = 0;
token = getToken(in);
if(strcmp("/",token) == 0){
ungetToken(in);
- return NULL;
+ return 0;
}
if(strcmp("value",token))in->error(in,"value was expected");
getEqual(in);
token = getToken(in);
- if(in->type != NUMBER) in->error(in,"number was expected");
- return token;
+
+ if(token[0] == '"') {
+ has_quotes = 1;
+ token = getToken(in);
+ }
+ if(in->type == NUMBER) {
+ *value = strtoll(token, NULL, 0);
+ } else {
+ goto error;
+ }
+ if(has_quotes) {
+ token = getToken(in);
+ if(token[0] != '"') goto error;
+ }
+ return 1;
+
+error:
+ in->error(in,"incorrect size specification");
+ return 0;
}
char * getDescription(parse_file_t *in)
@@ -420,7 +470,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 +598,8 @@ void parseFields(parse_file_t *in, field_t *f,
getRAnglebracket(in);
f->description = getDescription(in);
+ } else {
+ f->description = NULL;
}
//
@@ -674,8 +726,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); //
@@ -720,7 +772,7 @@ type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType,
}
else if(strcmp(token,"enum") == 0) {
char * str;
- int value = -1;
+ long long value = -1;
t->type = ENUM;
sequence_init(&(t->labels));
@@ -740,13 +792,15 @@ type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType,
token = getToken(in); //"label" or "/"
while(strcmp("label",token) == 0){
int *label_value = malloc(sizeof(int));
+ int has_value = 0;
+ long long loc_value;
- str = allocAndCopy(getNameAttribute(in));
- token = getValueStrAttribute(in);
+ str = allocAndCopy(getNameAttribute(in));
+ has_value = getValueAttribute(in, &loc_value);
sequence_push(&(t->labels),str);
- if(token) value = strtol(token, NULL, 0);
+ if(has_value) value = loc_value;
else value++;
*label_value = value;
@@ -972,7 +1026,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 +1209,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;
}
@@ -1487,7 +1542,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 +1606,3 @@ char *appendString(char *s, char *suffix)
strcat(tmp,suffix);
return tmp;
}
-
-