perf report: Fix cut'n'paste error recently introduced
[deliverable/linux.git] / tools / perf / util / sort.c
index 60ced707bd6b5a88993fb206e098fe1fcee9cd72..cff1c316fa910648cc53328494c03a8b53809ea3 100644 (file)
@@ -7,7 +7,8 @@ char            default_sort_order[] = "comm,dso,symbol";
 char           *sort_order = default_sort_order;
 int            sort__need_collapse = 0;
 int            sort__has_parent = 0;
-int            sort_by_sym_first;
+
+enum sort_type sort__first_dimension;
 
 unsigned int dsos__col_width;
 unsigned int comms__col_width;
@@ -266,9 +267,18 @@ int sort_dimension__add(const char *tok)
                        sort__has_parent = 1;
                }
 
-               if (list_empty(&hist_entry__sort_list) &&
-                   !strcmp(sd->name, "symbol"))
-                       sort_by_sym_first = true;
+               if (list_empty(&hist_entry__sort_list)) {
+                       if (!strcmp(sd->name, "pid"))
+                               sort__first_dimension = SORT_PID;
+                       else if (!strcmp(sd->name, "comm"))
+                               sort__first_dimension = SORT_COMM;
+                       else if (!strcmp(sd->name, "dso"))
+                               sort__first_dimension = SORT_DSO;
+                       else if (!strcmp(sd->name, "symbol"))
+                               sort__first_dimension = SORT_SYM;
+                       else if (!strcmp(sd->name, "parent"))
+                               sort__first_dimension = SORT_PARENT;
+               }
 
                list_add_tail(&sd->entry->list, &hist_entry__sort_list);
                sd->taken = 1;
@@ -278,3 +288,18 @@ int sort_dimension__add(const char *tok)
 
        return -ESRCH;
 }
+
+void setup_sorting(const char * const usagestr[], const struct option *opts)
+{
+       char *tmp, *tok, *str = strdup(sort_order);
+
+       for (tok = strtok_r(str, ", ", &tmp);
+                       tok; tok = strtok_r(NULL, ", ", &tmp)) {
+               if (sort_dimension__add(tok) < 0) {
+                       error("Unknown --sort key: `%s'", tok);
+                       usage_with_options(usagestr, opts);
+               }
+       }
+
+       free(str);
+}
This page took 0.036602 seconds and 5 git commands to generate.