summaryrefslogtreecommitdiff
path: root/tools/perf/util
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/sort.c18
-rw-r--r--tools/perf/util/sort.h10
-rw-r--r--tools/perf/util/thread.c11
-rw-r--r--tools/perf/util/thread.h2
4 files changed, 36 insertions, 5 deletions
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 60ced70..b490354 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -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;
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 24c2b70..333e664 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -39,7 +39,7 @@ extern struct sort_entry sort_parent;
extern unsigned int dsos__col_width;
extern unsigned int comms__col_width;
extern unsigned int threads__col_width;
-extern int sort_by_sym_first;
+extern enum sort_type sort__first_dimension;
struct hist_entry {
struct rb_node rb_node;
@@ -54,6 +54,14 @@ struct hist_entry {
struct rb_root sorted_chain;
};
+enum sort_type {
+ SORT_PID,
+ SORT_COMM,
+ SORT_DSO,
+ SORT_SYM,
+ SORT_PARENT
+};
+
/*
* configurable sorting bits
*/
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index f53fad7..8cb47f1 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -33,6 +33,17 @@ int thread__set_comm(struct thread *self, const char *comm)
return self->comm ? 0 : -ENOMEM;
}
+int thread__comm_len(struct thread *self)
+{
+ if (!self->comm_len) {
+ if (!self->comm)
+ return 0;
+ self->comm_len = strlen(self->comm);
+ }
+
+ return self->comm_len;
+}
+
static size_t thread__fprintf(struct thread *self, FILE *fp)
{
struct rb_node *nd;
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index 1abef3b..53addd7 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -12,9 +12,11 @@ struct thread {
pid_t pid;
char shortname[3];
char *comm;
+ int comm_len;
};
int thread__set_comm(struct thread *self, const char *comm);
+int thread__comm_len(struct thread *self);
struct thread *threads__findnew(pid_t pid);
struct thread *register_idle_thread(void);
void thread__insert_map(struct thread *self, struct map *map);