perf trace: Add flag/symbolic format_flags
[deliverable/linux.git] / tools / perf / util / trace-event-parse.c
index 4b61b497040ef71f39639e801fbd45432219fc23..85d7163a9fd4456bf0943ac690f54f1a66a54e77 100644 (file)
@@ -48,6 +48,11 @@ static unsigned long long input_buf_siz;
 
 static int cpus;
 static int long_size;
+static int is_flag_field;
+static int is_symbolic_field;
+
+static struct format_field *
+find_any_field(struct event *event, const char *name);
 
 static void init_input_buf(char *buf, unsigned long long size)
 {
@@ -286,16 +291,19 @@ void parse_ftrace_printk(char *file, unsigned int size __unused)
        char *line;
        char *next = NULL;
        char *addr_str;
-       char *fmt;
        int i;
 
        line = strtok_r(file, "\n", &next);
        while (line) {
+               addr_str = strsep(&line, ":");
+               if (!line) {
+                       warning("error parsing print strings");
+                       break;
+               }
                item = malloc_or_die(sizeof(*item));
-               addr_str = strtok_r(line, ":", &fmt);
                item->addr = strtoull(addr_str, NULL, 16);
                /* fmt still has a space, skip it */
-               item->printk = strdup(fmt+1);
+               item->printk = strdup(line+1);
                item->next = list;
                list = item;
                line = strtok_r(NULL, "\n", &next);
@@ -938,7 +946,8 @@ static int event_read_fields(struct event *event, struct format_field **fields)
                        if (read_expect_type(EVENT_ITEM, &token))
                                goto fail;
 
-                       /* add signed type */
+                       if (strtoul(token, NULL, 0))
+                               field->flags |= FIELD_IS_SIGNED;
 
                        free_token(token);
                        if (read_expected(EVENT_OP, ";") < 0)
@@ -1297,6 +1306,16 @@ process_entry(struct event *event __unused, struct print_arg *arg,
        arg->type = PRINT_FIELD;
        arg->field.name = field;
 
+       if (is_flag_field) {
+               arg->field.field = find_any_field(event, arg->field.name);
+               arg->field.field->flags |= FIELD_IS_FLAG;
+               is_flag_field = 0;
+       } else if (is_symbolic_field) {
+               arg->field.field = find_any_field(event, arg->field.name);
+               arg->field.field->flags |= FIELD_IS_SYMBOLIC;
+               is_symbolic_field = 0;
+       }
+
        type = read_token(&token);
        *tok = token;
 
@@ -1664,9 +1683,11 @@ process_arg_token(struct event *event, struct print_arg *arg,
                        type = process_entry(event, arg, &token);
                } else if (strcmp(token, "__print_flags") == 0) {
                        free_token(token);
+                       is_flag_field = 1;
                        type = process_flags(event, arg, &token);
                } else if (strcmp(token, "__print_symbolic") == 0) {
                        free_token(token);
+                       is_symbolic_field = 1;
                        type = process_symbols(event, arg, &token);
                } else if (strcmp(token, "__get_str") == 0) {
                        free_token(token);
This page took 0.028054 seconds and 5 git commands to generate.