X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Fparser.c;h=1ab1b73bf7bf256ac23f468d95482c31584cfc33;hb=f5eafc51d456f751a9c22e7d62b1f5c74b84c15f;hp=795b3f96f4ba0d5a8be7be6ab666c293c5b2c16b;hpb=a0c1f62260816bb15c0ba8e88b10c223087b4f32;p=lttv.git
diff --git a/ltt/branches/poly/ltt/parser.c b/ltt/branches/poly/ltt/parser.c
index 795b3f96..1ab1b73b 100644
--- a/ltt/branches/poly/ltt/parser.c
+++ b/ltt/branches/poly/ltt/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.
@@ -43,15 +44,14 @@ This program is distributed in the hope that it will be useful,
#include "parser.h"
-static char *intOutputTypes[] = {
- "int8_t", "int16_t", "int32_t", "int64_t", "short int", "int", "long int" };
+char *intOutputTypes[] = {
+ "int8_t", "int16_t", "int32_t", "int64_t" };
-static char *uintOutputTypes[] = {
- "uint8_t", "uint16_t", "uint32_t", "uint64_t", "unsigned short int",
- "unsigned int", "unsigned long int" };
+char *uintOutputTypes[] = {
+ "uint8_t", "uint16_t", "uint32_t", "uint64_t" };
-static char *floatOutputTypes[] = {
- "undef", "undef", "float", "double", "undef", "float", "double" };
+char *floatOutputTypes[] = {
+ "undef", "undef", "float", "double" };
@@ -68,7 +68,7 @@ void strupper(char *string)
}
-int getSizeindex(int value)
+int getSizeindex(unsigned int value)
{
switch(value) {
case 1:
@@ -94,22 +94,33 @@ int getSizeindex(int value)
* size
*****************************************************************************/
-int getSize(parse_file_t *in)
+unsigned long long int getSize(parse_file_t *in)
{
- char *token;
+ char *token, *token2;
+ unsigned long long int ret;
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;
+
+
+ if(in->type == QUOTEDSTRING) {
+ in->type = NUMBER;
+ token2 = token;
+ do {
+ if (!isdigit(*token2)) {
+ in->type = QUOTEDSTRING;
+ break;
+ }
+ } while (*(++token2) != '\0');
}
+
+ if(in->type == NUMBER) {
+ ret = strtoull(token, NULL, 0);
+ } else {
+ goto error;
+ }
+
+ return ret;
+error:
in->error(in,"incorrect size specification");
return -1;
}
@@ -183,13 +194,16 @@ char *allocAndCopy(char *str)
*
**************************************************************************/
-void getTypeAttributes(parse_file_t *in, type_descriptor_t *t)
+void getTypeAttributes(parse_file_t *in, type_descriptor_t *t,
+ sequence_t * unnamed_types, table_t * named_types)
{
char * token;
+ char car;
t->fmt = NULL;
- t->size = -1;
- t->alignment = 0;
+ t->size = 0;
+ t->custom_write = 0;
+ t->network = 0;
while(1) {
token = getToken(in);
@@ -210,11 +224,28 @@ 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("byte_order",token)) {
+ getEqual(in);
+ car = seekNextChar(in);
+ if(car == EOF) in->error(in,"byte order was expected (network?)");
+ else if(car == '\"') token = getQuotedString(in);
+ else token = getName(in);
+ if(!strcmp("network", token)) {
+ t->network = 1;
+ }
+ } else if(!strcmp("write",token)) {
+ getEqual(in);
+ car = seekNextChar(in);
+ if(car == EOF) in->error(in,"write type was expected (custom?)");
+ else if(car == '\"') token = getQuotedString(in);
+ else token = getName(in);
+ if(!strcmp("custom", token)) {
+ t->custom_write = 1;
+ }
+ }
+ }
}
/**************************************************************************
@@ -237,6 +268,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);
@@ -251,12 +284,30 @@ void getEventAttributes(parse_file_t *in, event_t *ev)
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;
+ } else if(!strcmp("scope", token)) {
+ getEqual(in);
+ car = seekNextChar(in);
+ if(car == EOF) in->error(in,"scope was expected");
+ else if(car == '\"') token = getQuotedString(in);
+ else token = getName(in);
+ if(!strcmp(token, "trace")) ev->per_trace = 1;
+ else if(!strcmp(token, "tracefile")) ev->per_tracefile = 1;
+ } else if(!strcmp("param", token)) {
+ getEqual(in);
+ car = seekNextChar(in);
+ if(car == EOF) in->error(in,"parameter type was expected");
+ else if(car == '\"') token = getQuotedString(in);
+ else token = getName(in);
+ if(!strcmp(token, "buffer")) ev->param_buffer = 1;
+ } else if(!strcmp("attribute", token)) {
+ getEqual(in);
+ car = seekNextChar(in);
+ if(car == EOF) in->error(in,"attribute was expected");
+ else if(car == '\"') token = getQuotedString(in);
+ else token = getName(in);
+ if(!strcmp(token, "no_instrument_function"))
+ ev->no_instrument_function = 1;
}
-
}
}
@@ -278,6 +329,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);
@@ -292,7 +345,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->arch = allocAndCopy(getQuotedString(in));
+ else fac->arch = allocAndCopy(getName(in));
+ }
}
}
@@ -329,7 +389,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)
@@ -340,42 +400,60 @@ 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)
+//for