X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=genevent-new%2Fparser.c;h=d76f13b74c3c4081ae1a804847bed039807a0ee1;hb=34a97fdc8a1c40616f352c4a20273038c1bd3eda;hp=a2a07e212c054adaca1dea3b9e95152b6a3f91aa;hpb=a67cd958dd88555bd8f2352d8ecfe2bc678e9d6f;p=lttv.git
diff --git a/genevent-new/parser.c b/genevent-new/parser.c
index a2a07e21..d76f13b7 100644
--- a/genevent-new/parser.c
+++ b/genevent-new/parser.c
@@ -3,14 +3,15 @@
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
+ Copyright (C) 2005, Mathieu Desnoyers
+ 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.
+ 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
+ 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.
@@ -96,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;
}
@@ -181,7 +197,8 @@ void getTypeAttributes(parse_file_t *in, type_descriptor_t *t,
t->fmt = NULL;
t->size = 0;
- t->alignment = 0;
+ t->custom_write = 0;
+ t->network = 0;
while(1) {
token = getToken(in);
@@ -202,10 +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("align",token)) {
- getEqual(in);
- t->alignment = getNumber(in);
- }
+ } else if(!strcmp("custom_write", token)) {
+ t->custom_write = 1;
+ } else if(!strcmp("network", token)) {
+ t->network = 1;
+ }
}
}
@@ -229,6 +247,8 @@ void getEventAttributes(parse_file_t *in, event_t *ev)
ev->name = NULL;
ev->per_trace = 0;
ev->per_tracefile = 0;
+ ev->param_buffer = 0;
+ ev->no_instrument_function = 0;
while(1) {
token = getToken(in);
@@ -247,7 +267,11 @@ 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;
+ } else if(!strcmp("no_instrument_function", token)) {
+ ev->no_instrument_function = 1;
+ }
}
}
@@ -270,6 +294,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);
@@ -284,7 +310,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_")-1))
+ 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));
+ }
}
}
@@ -321,7 +354,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)
@@ -332,42 +365,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)
@@ -423,7 +473,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);
@@ -551,17 +601,14 @@ void parseFields(parse_file_t *in, field_t *f,
getRAnglebracket(in);
f->description = getDescription(in);
+ } else {
+ f->description = NULL;
}
//
getLAnglebracket(in);
f->type = parseType(in,NULL, unnamed_types, named_types);
- /* Those will be set later by preset_field_type_size */
- f->fixed_root = FIELD_UNKNOWN;
- f->fixed_parent = FIELD_UNKNOWN;
- f->fixed_size = FIELD_UNKNOWN;
-
if(tag) {
getLAnglebracket(in);
getForwardslash(in);
@@ -664,7 +711,7 @@ type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType,
getForwardslash(in);
getRAnglebracket(in); //
- getLAnglebracket(in); //
+ //getLAnglebracket(in); //
/* subfield */
f = (field_t *)memAlloc(sizeof(field_t));
sequence_push(&(t->fields),f);
@@ -682,17 +729,17 @@ 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); //
+ //getLAnglebracket(in); //
/* subfield */
f = (field_t *)memAlloc(sizeof(field_t));
sequence_push(&(t->fields),f);
parseFields(in, f, unnamed_types, named_types, 0);
- getLAnglebracket(in); //
+ //getLAnglebracket(in); //
/* subfield */
f = (field_t *)memAlloc(sizeof(field_t));
sequence_push(&(t->fields),f);
@@ -727,34 +774,40 @@ type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType,
getRAnglebracket(in); //
}
else if(strcmp(token,"enum") == 0) {
- char * str, *str1;
+ char * str;
+ long long value = -1;
+
t->type = ENUM;
sequence_init(&(t->labels));
+ sequence_init(&(t->labels_values));
sequence_init(&(t->labels_description));
t->already_printed = 0;
getTypeAttributes(in, t, unnamed_types, named_types);
//if(t->size == 0) in->error(in, "Sequence has empty size");
- //Mathieu : we fix enum size to 4 bytes. GCC is always like this.
+ //Mathieu : we fix enum size to target int size. GCC is always like this.
//fox copy optimisation.
- if(t->size != 0) in->error(in, "Enum has fixed size of 4.");
- t->size = 4;
+ if(t->size != 0) in->error(in, "Enum has fixed size of target int.");
+ t->size = 0;
getRAnglebracket(in);
//