add func instrumentation
[lttv.git] / ltt / branches / poly / ltt / parser.c
index 84a0b5f4d273517f6912f22a5129b8b93541921b..28ebaeea9dba2e5a99eac16c404be0f62d81d000 100644 (file)
@@ -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;
 }
@@ -183,6 +198,7 @@ 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); 
@@ -205,7 +221,9 @@ void getTypeAttributes(parse_file_t *in, type_descriptor_t *t,
       t->size = getSize(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;
+               }
 
   }
 }
@@ -271,6 +295,7 @@ void getFacilityAttributes(parse_file_t *in, facility_t *fac)
   
   fac->name = NULL;
   fac->arch = NULL;
+       fac->user = 0;
 
   while(1) {
     token = getToken(in); 
@@ -285,6 +310,8 @@ 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);
@@ -327,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)
@@ -357,21 +384,40 @@ char *getNameAttribute(parse_file_t *in)
 
 
 //for <label name=label_name value=n format="..."/>, 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)
@@ -555,6 +601,8 @@ void parseFields(parse_file_t *in, field_t *f,
                getRAnglebracket(in);
 
                f->description = getDescription(in);
+       } else {
+               f->description = NULL;
        }
 
   //<int size=...>
@@ -727,7 +775,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));
@@ -747,13 +795,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);
+      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;
This page took 0.024245 seconds and 4 git commands to generate.