update lttctl
[lttv.git] / trunk / lttv / ltt / marker.c
index ce1fc86863f0f9f093820cffe8506ff7914b5200..3737f0aa615f03d7f4cedc4183b853a3b4d47023 100644 (file)
@@ -47,10 +47,6 @@ static inline const char *parse_trace_type(struct marker_info *info,
   /* parse attributes. */
   repeat:
     switch (*fmt) {
-      case 'b':
-        *attributes |= LTT_ATTRIBUTE_COMPACT;
-        ++fmt;
-        goto repeat;
       case 'n':
         *attributes |= LTT_ATTRIBUTE_NETWORK_BYTE_ORDER;
         ++fmt;
@@ -62,7 +58,7 @@ static inline const char *parse_trace_type(struct marker_info *info,
   if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' ||
       *fmt =='Z' || *fmt == 'z' || *fmt == 't' ||
       *fmt == 'S' || *fmt == '1' || *fmt == '2' ||
-      *fmt == '4' || *fmt == 8) {
+      *fmt == '4' || *fmt == '8') {
     qualifier = *fmt;
     ++fmt;
     if (qualifier == 'l' && *fmt == 'l') {
@@ -143,7 +139,7 @@ parse_end:
 __attribute__((no_instrument_function))
 static inline const char *parse_c_type(struct marker_info *info,
     const char *fmt,
-    char *c_size, enum ltt_type *c_type)
+    char *c_size, enum ltt_type *c_type, GString *field_fmt)
 {
   int qualifier;    /* 'h', 'l', or 'L' for integer fields */
         /* 'z' support added 23/7/1999 S.H.    */
@@ -158,6 +154,7 @@ static inline const char *parse_c_type(struct marker_info *info,
       case ' ':
       case '#':
       case '0':
+        g_string_append_c(field_fmt, *fmt);
         ++fmt;
         goto repeat;
     }
@@ -179,6 +176,7 @@ static inline const char *parse_c_type(struct marker_info *info,
     case 'c':
       *c_type = LTT_TYPE_UNSIGNED_INT;
       *c_size = sizeof(unsigned char);
+      g_string_append_c(field_fmt, *fmt);
       goto parse_end;
     case 's':
       *c_type = LTT_TYPE_STRING;
@@ -190,11 +188,17 @@ static inline const char *parse_c_type(struct marker_info *info,
     case 'd':
     case 'i':
       *c_type = LTT_TYPE_SIGNED_INT;
+      g_string_append_c(field_fmt, 'l');
+      g_string_append_c(field_fmt, 'l');
+      g_string_append_c(field_fmt, *fmt);
       break;
     case 'o':
     case 'u':
     case 'x':
     case 'X':
+      g_string_append_c(field_fmt, 'l');
+      g_string_append_c(field_fmt, 'l');
+      g_string_append_c(field_fmt, *fmt);
       *c_type = LTT_TYPE_UNSIGNED_INT;
       break;
     default:
@@ -231,7 +235,7 @@ static inline long add_type(struct marker_info *info,
     long offset, const char *name,
     char trace_size, enum ltt_type trace_type,
     char c_size, enum ltt_type c_type, unsigned long attributes,
-    unsigned int field_count)
+    unsigned int field_count, GString *field_fmt)
 {
   struct marker_field *field;
   char tmpname[MAX_NAME_LEN];
@@ -246,6 +250,7 @@ static inline long add_type(struct marker_info *info,
     field->name = g_quark_from_string(tmpname);
   }
   field->type = trace_type;
+  field->fmt = g_string_new(field_fmt->str);
 
   switch (trace_type) {
   case LTT_TYPE_SIGNED_INT:
@@ -253,6 +258,8 @@ static inline long add_type(struct marker_info *info,
   case LTT_TYPE_POINTER:
     field->size = trace_size;
     field->alignment = trace_size;
+    info->largest_align = max((guint8)field->alignment,
+                              (guint8)info->largest_align);
     field->attributes = attributes;
     if (offset == -1) {
       field->offset = -1;
@@ -274,7 +281,7 @@ static inline long add_type(struct marker_info *info,
       field->static_offset = 1;
     return -1;
   default:
-    g_error("Unexpected type"); //FIXME: compact type
+    g_error("Unexpected type");
     return 0;
   }
 }
@@ -311,7 +318,7 @@ long marker_update_fields_offsets(struct marker_info *info, const char *data)
       // not aligning on pointer size, breaking genevent backward compatibility.
       break;
     default:
-      g_error("Unexpected type"); //FIXME: compact type
+      g_error("Unexpected type");
       return -1;
     }
   }
@@ -329,6 +336,7 @@ static void format_parse(const char *fmt, struct marker_info *info)
   const char *name_begin = NULL, *name_end = NULL;
   char *name = NULL;
   unsigned int field_count = 1;
+  GString *field_fmt = g_string_new("");
 
   name_begin = fmt;
   for (; *fmt ; ++fmt) {
@@ -336,18 +344,24 @@ static void format_parse(const char *fmt, struct marker_info *info)
     case '#':
       /* tracetypes (#) */
       ++fmt;      /* skip first '#' */
-      if (*fmt == '#')  /* Escaped ## */
+      if (*fmt == '#') {  /* Escaped ## */
+        g_string_append_c(field_fmt, *fmt);
+        g_string_append_c(field_fmt, *fmt);
         break;
+      }
       attributes = 0;
       fmt = parse_trace_type(info, fmt, &trace_size, &trace_type,
         &attributes);
       break;
     case '%':
       /* c types (%) */
+      g_string_append_c(field_fmt, *fmt);
       ++fmt;      /* skip first '%' */
-      if (*fmt == '%')  /* Escaped %% */
+      if (*fmt == '%') {  /* Escaped %% */
+        g_string_append_c(field_fmt, *fmt);
         break;
-      fmt = parse_c_type(info, fmt, &c_size, &c_type);
+      }
+      fmt = parse_c_type(info, fmt, &c_size, &c_type, field_fmt);
       /*
        * Output c types if no trace types has been
        * specified.
@@ -360,9 +374,11 @@ static void format_parse(const char *fmt, struct marker_info *info)
         trace_type = LTT_TYPE_STRING;
       /* perform trace write */
       offset = add_type(info, offset, name, trace_size,
-            trace_type, c_size, c_type, attributes, field_count++);
+            trace_type, c_size, c_type, attributes, field_count++,
+           field_fmt);
       trace_size = c_size = 0;
       trace_type = c_size = LTT_TYPE_NONE;
+      g_string_truncate(field_fmt, 0);
       attributes = 0;
       name_begin = NULL;
       if (name) {
@@ -371,6 +387,7 @@ static void format_parse(const char *fmt, struct marker_info *info)
       }
       break;
     case ' ':
+      g_string_truncate(field_fmt, 0);
       if (!name_end && name_begin) {
         name_end = fmt;
         if (name)
@@ -381,6 +398,7 @@ static void format_parse(const char *fmt, struct marker_info *info)
       }
       break;  /* Skip white spaces */
     default:
+      g_string_append_c(field_fmt, *fmt);
       if (!name_begin) {
         name_begin = fmt;
         name_end = NULL;
@@ -390,6 +408,7 @@ static void format_parse(const char *fmt, struct marker_info *info)
   info->size = offset;
   if (name)
     g_free(name);
+  g_string_free(field_fmt, TRUE);
 }
 
 int marker_parse_format(const char *format, struct marker_info *info)
@@ -451,6 +470,7 @@ int marker_id_event(LttTrace *trace, GQuark name, guint16 id,
   info->fields = NULL;
   info->next = NULL;
   info->format = marker_get_format_from_name(trace, name);
+  info->largest_align = 1;
   if (info->format && marker_parse_format(info->format, info))
       g_error("Error parsing marker format \"%s\" for marker \"%s\"",
         info->format, g_quark_to_string(name));
@@ -491,13 +511,19 @@ int allocate_marker_data(LttTrace *trace)
 
 void destroy_marker_data(LttTrace *trace)
 {
-  unsigned int i;
+  unsigned int i, j;
   struct marker_info *info;
+  struct marker_field *field;
 
   for (i=0; i<trace->markers->len; i++) {
     info = &g_array_index(trace->markers, struct marker_info, i);
-    if (info->fields)
+    if (info->fields) {
+      for (j = 0; j < info->fields->len; j++) {
+        field = &g_array_index(info->fields, struct marker_field, j);
+       g_string_free(field->fmt, TRUE);
+      }
       g_array_free(info->fields, TRUE);
+    }
   }
   g_array_free(trace->markers, TRUE);
   g_hash_table_destroy(trace->markers_hash);
This page took 0.028295 seconds and 4 git commands to generate.