diff options
Diffstat (limited to 'tools/perf/util')
| -rw-r--r-- | tools/perf/util/sort.c | 18 | ||||
| -rw-r--r-- | tools/perf/util/sort.h | 10 | ||||
| -rw-r--r-- | tools/perf/util/thread.c | 11 | ||||
| -rw-r--r-- | tools/perf/util/thread.h | 2 |
4 files changed, 36 insertions, 5 deletions
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 60ced707bd6b..b490354d1b23 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c | |||
| @@ -7,7 +7,8 @@ char default_sort_order[] = "comm,dso,symbol"; | |||
| 7 | char *sort_order = default_sort_order; | 7 | char *sort_order = default_sort_order; |
| 8 | int sort__need_collapse = 0; | 8 | int sort__need_collapse = 0; |
| 9 | int sort__has_parent = 0; | 9 | int sort__has_parent = 0; |
| 10 | int sort_by_sym_first; | 10 | |
| 11 | enum sort_type sort__first_dimension; | ||
| 11 | 12 | ||
| 12 | unsigned int dsos__col_width; | 13 | unsigned int dsos__col_width; |
| 13 | unsigned int comms__col_width; | 14 | unsigned int comms__col_width; |
| @@ -266,9 +267,18 @@ int sort_dimension__add(const char *tok) | |||
| 266 | sort__has_parent = 1; | 267 | sort__has_parent = 1; |
| 267 | } | 268 | } |
| 268 | 269 | ||
| 269 | if (list_empty(&hist_entry__sort_list) && | 270 | if (list_empty(&hist_entry__sort_list)) { |
| 270 | !strcmp(sd->name, "symbol")) | 271 | if (!strcmp(sd->name, "pid")) |
| 271 | sort_by_sym_first = true; | 272 | sort__first_dimension = SORT_PID; |
| 273 | else if (!strcmp(sd->name, "comm")) | ||
| 274 | sort__first_dimension = SORT_COMM; | ||
| 275 | else if (!strcmp(sd->name, "dso")) | ||
| 276 | sort__first_dimension = SORT_DSO; | ||
| 277 | else if (!strcmp(sd->name, "symbol")) | ||
| 278 | sort__first_dimension = SORT_SYM; | ||
| 279 | else if (!strcmp(sd->name, "parent")) | ||
| 280 | sort__first_dimension = SORT_PARENT; | ||
| 281 | } | ||
| 272 | 282 | ||
| 273 | list_add_tail(&sd->entry->list, &hist_entry__sort_list); | 283 | list_add_tail(&sd->entry->list, &hist_entry__sort_list); |
| 274 | sd->taken = 1; | 284 | sd->taken = 1; |
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 24c2b709f0d3..333e664ff45f 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h | |||
| @@ -39,7 +39,7 @@ extern struct sort_entry sort_parent; | |||
| 39 | extern unsigned int dsos__col_width; | 39 | extern unsigned int dsos__col_width; |
| 40 | extern unsigned int comms__col_width; | 40 | extern unsigned int comms__col_width; |
| 41 | extern unsigned int threads__col_width; | 41 | extern unsigned int threads__col_width; |
| 42 | extern int sort_by_sym_first; | 42 | extern enum sort_type sort__first_dimension; |
| 43 | 43 | ||
| 44 | struct hist_entry { | 44 | struct hist_entry { |
| 45 | struct rb_node rb_node; | 45 | struct rb_node rb_node; |
| @@ -54,6 +54,14 @@ struct hist_entry { | |||
| 54 | struct rb_root sorted_chain; | 54 | struct rb_root sorted_chain; |
| 55 | }; | 55 | }; |
| 56 | 56 | ||
| 57 | enum sort_type { | ||
| 58 | SORT_PID, | ||
| 59 | SORT_COMM, | ||
| 60 | SORT_DSO, | ||
| 61 | SORT_SYM, | ||
| 62 | SORT_PARENT | ||
| 63 | }; | ||
| 64 | |||
| 57 | /* | 65 | /* |
| 58 | * configurable sorting bits | 66 | * configurable sorting bits |
| 59 | */ | 67 | */ |
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index f53fad7c0a8d..8cb47f1d8a76 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) | |||
| 33 | return self->comm ? 0 : -ENOMEM; | 33 | return self->comm ? 0 : -ENOMEM; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | int thread__comm_len(struct thread *self) | ||
| 37 | { | ||
| 38 | if (!self->comm_len) { | ||
| 39 | if (!self->comm) | ||
| 40 | return 0; | ||
| 41 | self->comm_len = strlen(self->comm); | ||
| 42 | } | ||
| 43 | |||
| 44 | return self->comm_len; | ||
| 45 | } | ||
| 46 | |||
| 36 | static size_t thread__fprintf(struct thread *self, FILE *fp) | 47 | static size_t thread__fprintf(struct thread *self, FILE *fp) |
| 37 | { | 48 | { |
| 38 | struct rb_node *nd; | 49 | struct rb_node *nd; |
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h index 1abef3b7455d..53addd77ce8f 100644 --- a/tools/perf/util/thread.h +++ b/tools/perf/util/thread.h | |||
| @@ -12,9 +12,11 @@ struct thread { | |||
| 12 | pid_t pid; | 12 | pid_t pid; |
| 13 | char shortname[3]; | 13 | char shortname[3]; |
| 14 | char *comm; | 14 | char *comm; |
| 15 | int comm_len; | ||
| 15 | }; | 16 | }; |
| 16 | 17 | ||
| 17 | int thread__set_comm(struct thread *self, const char *comm); | 18 | int thread__set_comm(struct thread *self, const char *comm); |
| 19 | int thread__comm_len(struct thread *self); | ||
| 18 | struct thread *threads__findnew(pid_t pid); | 20 | struct thread *threads__findnew(pid_t pid); |
| 19 | struct thread *register_idle_thread(void); | 21 | struct thread *register_idle_thread(void); |
| 20 | void thread__insert_map(struct thread *self, struct map *map); | 22 | void thread__insert_map(struct thread *self, struct map *map); |
