X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Fparser.c;h=6dbf402d76fd4f008f8d8c5cce17378df0617b15;hb=f5d7967f8c41e4f380d3ea7c4304e68ab5bad8ec;hp=b4bd088b5c8fb8e22859d7e20dc6fe0c43b03a96;hpb=90395b4b8344644a20bcf6e912f619e0bba848f9;p=lttv.git diff --git a/ltt/branches/poly/ltt/parser.c b/ltt/branches/poly/ltt/parser.c index b4bd088b..6dbf402d 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. @@ -38,11 +39,23 @@ This program is distributed in the hope that it will be useful, #include #include #include - +#include #include "parser.h" +char *intOutputTypes[] = { + "int8_t", "int16_t", "int32_t", "int64_t" }; + +char *uintOutputTypes[] = { + "uint8_t", "uint16_t", "uint32_t", "uint64_t" }; + +char *floatOutputTypes[] = { + "undef", "undef", "float", "double" }; + + + + /* helper function */ void strupper(char *string) { @@ -55,7 +68,7 @@ void strupper(char *string) } -int getSizeindex(int value) +int getSizeindex(unsigned int value) { switch(value) { case 1: @@ -81,21 +94,13 @@ int getSizeindex(int value) * size *****************************************************************************/ -int getSize(parse_file *in) +unsigned long long int getSize(parse_file_t *in) { char *token; 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; + return strtoull(token, NULL, 0); } in->error(in,"incorrect size specification"); return -1; @@ -109,7 +114,7 @@ int getSize(parse_file *in) * msg : message to be printed ****************************************************************************/ -void error_callback(parse_file *in, char *msg) +void error_callback(parse_file_t *in, char *msg) { if(in) printf("Error in file %s, line %d: %s\n", in->name, in->lineno, msg); @@ -170,14 +175,13 @@ char *allocAndCopy(char *str) * **************************************************************************/ -void getTypeAttributes(parse_file *in, type_descriptor *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; while(1) { token = getToken(in); @@ -198,9 +202,6 @@ void getTypeAttributes(parse_file *in, type_descriptor *t) } else if(!strcmp("size",token)) { getEqual(in); t->size = getSize(in); - } else if(!strcmp("align",token)) { - getEqual(in); - t->alignment = getNumber(in); } } } @@ -217,7 +218,7 @@ void getTypeAttributes(parse_file *in, type_descriptor *t) * **************************************************************************/ -void getEventAttributes(parse_file *in, event *ev) +void getEventAttributes(parse_file_t *in, event_t *ev) { char * token; char car; @@ -260,12 +261,13 @@ void getEventAttributes(parse_file *in, event *ev) * **************************************************************************/ -void getFacilityAttributes(parse_file *in, facility *fac) +void getFacilityAttributes(parse_file_t *in, facility_t *fac) { char * token; char car; fac->name = NULL; + fac->arch = NULL; while(1) { token = getToken(in); @@ -280,7 +282,12 @@ void getFacilityAttributes(parse_file *in, facility *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)); + } } } @@ -296,7 +303,7 @@ void getFacilityAttributes(parse_file *in, facility *fac) * **************************************************************************/ -void getFieldAttributes(parse_file *in, field *f) +void getFieldAttributes(parse_file_t *in, field_t *f) { char * token; char car; @@ -320,7 +327,7 @@ void getFieldAttributes(parse_file *in, field *f) } } -char *getNameAttribute(parse_file *in) +char *getNameAttribute(parse_file_t *in) { char * token; char *name = NULL; @@ -349,7 +356,7 @@ char *getNameAttribute(parse_file *in) //for