diff options
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/sort.c | 27 | ||||
-rw-r--r-- | tools/perf/util/sort.h | 1 |
2 files changed, 23 insertions, 5 deletions
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index b748b02fcb78..5414ba541e47 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c | |||
@@ -99,6 +99,12 @@ sort__comm_collapse(struct hist_entry *left, struct hist_entry *right) | |||
99 | return comm__str(right->comm) - comm__str(left->comm); | 99 | return comm__str(right->comm) - comm__str(left->comm); |
100 | } | 100 | } |
101 | 101 | ||
102 | static int64_t | ||
103 | sort__comm_sort(struct hist_entry *left, struct hist_entry *right) | ||
104 | { | ||
105 | return strcmp(comm__str(right->comm), comm__str(left->comm)); | ||
106 | } | ||
107 | |||
102 | static int hist_entry__comm_snprintf(struct hist_entry *he, char *bf, | 108 | static int hist_entry__comm_snprintf(struct hist_entry *he, char *bf, |
103 | size_t size, unsigned int width) | 109 | size_t size, unsigned int width) |
104 | { | 110 | { |
@@ -109,6 +115,7 @@ struct sort_entry sort_comm = { | |||
109 | .se_header = "Command", | 115 | .se_header = "Command", |
110 | .se_cmp = sort__comm_cmp, | 116 | .se_cmp = sort__comm_cmp, |
111 | .se_collapse = sort__comm_collapse, | 117 | .se_collapse = sort__comm_collapse, |
118 | .se_sort = sort__comm_sort, | ||
112 | .se_snprintf = hist_entry__comm_snprintf, | 119 | .se_snprintf = hist_entry__comm_snprintf, |
113 | .se_width_idx = HISTC_COMM, | 120 | .se_width_idx = HISTC_COMM, |
114 | }; | 121 | }; |
@@ -122,7 +129,7 @@ static int64_t _sort__dso_cmp(struct map *map_l, struct map *map_r) | |||
122 | const char *dso_name_l, *dso_name_r; | 129 | const char *dso_name_l, *dso_name_r; |
123 | 130 | ||
124 | if (!dso_l || !dso_r) | 131 | if (!dso_l || !dso_r) |
125 | return cmp_null(dso_l, dso_r); | 132 | return cmp_null(dso_r, dso_l); |
126 | 133 | ||
127 | if (verbose) { | 134 | if (verbose) { |
128 | dso_name_l = dso_l->long_name; | 135 | dso_name_l = dso_l->long_name; |
@@ -138,7 +145,7 @@ static int64_t _sort__dso_cmp(struct map *map_l, struct map *map_r) | |||
138 | static int64_t | 145 | static int64_t |
139 | sort__dso_cmp(struct hist_entry *left, struct hist_entry *right) | 146 | sort__dso_cmp(struct hist_entry *left, struct hist_entry *right) |
140 | { | 147 | { |
141 | return _sort__dso_cmp(left->ms.map, right->ms.map); | 148 | return _sort__dso_cmp(right->ms.map, left->ms.map); |
142 | } | 149 | } |
143 | 150 | ||
144 | static int _hist_entry__dso_snprintf(struct map *map, char *bf, | 151 | static int _hist_entry__dso_snprintf(struct map *map, char *bf, |
@@ -210,6 +217,15 @@ sort__sym_cmp(struct hist_entry *left, struct hist_entry *right) | |||
210 | return _sort__sym_cmp(left->ms.sym, right->ms.sym); | 217 | return _sort__sym_cmp(left->ms.sym, right->ms.sym); |
211 | } | 218 | } |
212 | 219 | ||
220 | static int64_t | ||
221 | sort__sym_sort(struct hist_entry *left, struct hist_entry *right) | ||
222 | { | ||
223 | if (!left->ms.sym || !right->ms.sym) | ||
224 | return cmp_null(left->ms.sym, right->ms.sym); | ||
225 | |||
226 | return strcmp(right->ms.sym->name, left->ms.sym->name); | ||
227 | } | ||
228 | |||
213 | static int _hist_entry__sym_snprintf(struct map *map, struct symbol *sym, | 229 | static int _hist_entry__sym_snprintf(struct map *map, struct symbol *sym, |
214 | u64 ip, char level, char *bf, size_t size, | 230 | u64 ip, char level, char *bf, size_t size, |
215 | unsigned int width) | 231 | unsigned int width) |
@@ -256,6 +272,7 @@ static int hist_entry__sym_snprintf(struct hist_entry *he, char *bf, | |||
256 | struct sort_entry sort_sym = { | 272 | struct sort_entry sort_sym = { |
257 | .se_header = "Symbol", | 273 | .se_header = "Symbol", |
258 | .se_cmp = sort__sym_cmp, | 274 | .se_cmp = sort__sym_cmp, |
275 | .se_sort = sort__sym_sort, | ||
259 | .se_snprintf = hist_entry__sym_snprintf, | 276 | .se_snprintf = hist_entry__sym_snprintf, |
260 | .se_width_idx = HISTC_SYMBOL, | 277 | .se_width_idx = HISTC_SYMBOL, |
261 | }; | 278 | }; |
@@ -283,7 +300,7 @@ sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right) | |||
283 | map__rip_2objdump(map, right->ip)); | 300 | map__rip_2objdump(map, right->ip)); |
284 | } | 301 | } |
285 | } | 302 | } |
286 | return strcmp(left->srcline, right->srcline); | 303 | return strcmp(right->srcline, left->srcline); |
287 | } | 304 | } |
288 | 305 | ||
289 | static int hist_entry__srcline_snprintf(struct hist_entry *he, char *bf, | 306 | static int hist_entry__srcline_snprintf(struct hist_entry *he, char *bf, |
@@ -311,7 +328,7 @@ sort__parent_cmp(struct hist_entry *left, struct hist_entry *right) | |||
311 | if (!sym_l || !sym_r) | 328 | if (!sym_l || !sym_r) |
312 | return cmp_null(sym_l, sym_r); | 329 | return cmp_null(sym_l, sym_r); |
313 | 330 | ||
314 | return strcmp(sym_l->name, sym_r->name); | 331 | return strcmp(sym_r->name, sym_l->name); |
315 | } | 332 | } |
316 | 333 | ||
317 | static int hist_entry__parent_snprintf(struct hist_entry *he, char *bf, | 334 | static int hist_entry__parent_snprintf(struct hist_entry *he, char *bf, |
@@ -1126,7 +1143,7 @@ __sort_dimension__alloc_hpp(struct sort_dimension *sd) | |||
1126 | 1143 | ||
1127 | hse->hpp.cmp = sd->entry->se_cmp; | 1144 | hse->hpp.cmp = sd->entry->se_cmp; |
1128 | hse->hpp.collapse = sd->entry->se_collapse ? : sd->entry->se_cmp; | 1145 | hse->hpp.collapse = sd->entry->se_collapse ? : sd->entry->se_cmp; |
1129 | hse->hpp.sort = hse->hpp.collapse; | 1146 | hse->hpp.sort = sd->entry->se_sort ? : hse->hpp.collapse; |
1130 | 1147 | ||
1131 | INIT_LIST_HEAD(&hse->hpp.list); | 1148 | INIT_LIST_HEAD(&hse->hpp.list); |
1132 | INIT_LIST_HEAD(&hse->hpp.sort_list); | 1149 | INIT_LIST_HEAD(&hse->hpp.sort_list); |
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 89e5057ca378..f5a831c3d0fb 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h | |||
@@ -182,6 +182,7 @@ struct sort_entry { | |||
182 | 182 | ||
183 | int64_t (*se_cmp)(struct hist_entry *, struct hist_entry *); | 183 | int64_t (*se_cmp)(struct hist_entry *, struct hist_entry *); |
184 | int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *); | 184 | int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *); |
185 | int64_t (*se_sort)(struct hist_entry *, struct hist_entry *); | ||
185 | int (*se_snprintf)(struct hist_entry *he, char *bf, size_t size, | 186 | int (*se_snprintf)(struct hist_entry *he, char *bf, size_t size, |
186 | unsigned int width); | 187 | unsigned int width); |
187 | u8 se_width_idx; | 188 | u8 se_width_idx; |