diff options
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/ui/hist.c | 36 | ||||
-rw-r--r-- | tools/perf/ui/stdio/hist.c | 22 | ||||
-rw-r--r-- | tools/perf/util/sort.c | 35 |
3 files changed, 43 insertions, 50 deletions
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index b114c6668865..61cf31e094f3 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c | |||
@@ -459,47 +459,29 @@ next: | |||
459 | } | 459 | } |
460 | } | 460 | } |
461 | 461 | ||
462 | int hist_entry__sort_snprintf(struct hist_entry *he, char *s, size_t size, | ||
463 | struct hists *hists) | ||
464 | { | ||
465 | const char *sep = symbol_conf.field_sep; | ||
466 | struct sort_entry *se; | ||
467 | int ret = 0; | ||
468 | |||
469 | list_for_each_entry(se, &hist_entry__sort_list, list) { | ||
470 | if (se->elide) | ||
471 | continue; | ||
472 | |||
473 | ret += scnprintf(s + ret, size - ret, "%s", sep ?: " "); | ||
474 | ret += se->se_snprintf(he, s + ret, size - ret, | ||
475 | hists__col_len(hists, se->se_width_idx)); | ||
476 | } | ||
477 | |||
478 | return ret; | ||
479 | } | ||
480 | |||
481 | /* | 462 | /* |
482 | * See hists__fprintf to match the column widths | 463 | * See hists__fprintf to match the column widths |
483 | */ | 464 | */ |
484 | unsigned int hists__sort_list_width(struct hists *hists) | 465 | unsigned int hists__sort_list_width(struct hists *hists) |
485 | { | 466 | { |
486 | struct perf_hpp_fmt *fmt; | 467 | struct perf_hpp_fmt *fmt; |
487 | struct sort_entry *se; | 468 | int ret = 0; |
488 | int i = 0, ret = 0; | 469 | bool first = true; |
489 | struct perf_hpp dummy_hpp; | 470 | struct perf_hpp dummy_hpp; |
490 | 471 | ||
491 | perf_hpp__for_each_format(fmt) { | 472 | perf_hpp__for_each_format(fmt) { |
492 | if (i) | 473 | if (perf_hpp__should_skip(fmt)) |
474 | continue; | ||
475 | |||
476 | if (first) | ||
477 | first = false; | ||
478 | else | ||
493 | ret += 2; | 479 | ret += 2; |
494 | 480 | ||
495 | ret += fmt->width(fmt, &dummy_hpp, hists_to_evsel(hists)); | 481 | ret += fmt->width(fmt, &dummy_hpp, hists_to_evsel(hists)); |
496 | } | 482 | } |
497 | 483 | ||
498 | list_for_each_entry(se, &hist_entry__sort_list, list) | 484 | if (verbose && sort__has_sym) /* Addr + origin */ |
499 | if (!se->elide) | ||
500 | ret += 2 + hists__col_len(hists, se->se_width_idx); | ||
501 | |||
502 | if (verbose) /* Addr + origin */ | ||
503 | ret += 3 + BITS_PER_LONG / 4; | 485 | ret += 3 + BITS_PER_LONG / 4; |
504 | 486 | ||
505 | return ret; | 487 | return ret; |
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index cfcd3f6fd1c5..9f57991025a9 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c | |||
@@ -183,7 +183,8 @@ static size_t callchain__fprintf_graph(FILE *fp, struct rb_root *root, | |||
183 | * the symbol. No need to print it otherwise it appears as | 183 | * the symbol. No need to print it otherwise it appears as |
184 | * displayed twice. | 184 | * displayed twice. |
185 | */ | 185 | */ |
186 | if (!i++ && sort__first_dimension == SORT_SYM) | 186 | if (!i++ && field_order == NULL && |
187 | sort_order && !prefixcmp(sort_order, "sym")) | ||
187 | continue; | 188 | continue; |
188 | if (!printed) { | 189 | if (!printed) { |
189 | ret += callchain__fprintf_left_margin(fp, left_margin); | 190 | ret += callchain__fprintf_left_margin(fp, left_margin); |
@@ -296,13 +297,20 @@ static size_t hist_entry__callchain_fprintf(struct hist_entry *he, | |||
296 | int left_margin = 0; | 297 | int left_margin = 0; |
297 | u64 total_period = hists->stats.total_period; | 298 | u64 total_period = hists->stats.total_period; |
298 | 299 | ||
299 | if (sort__first_dimension == SORT_COMM) { | 300 | if (field_order == NULL && (sort_order == NULL || |
300 | struct sort_entry *se = list_first_entry(&hist_entry__sort_list, | 301 | !prefixcmp(sort_order, "comm"))) { |
301 | typeof(*se), list); | 302 | struct perf_hpp_fmt *fmt; |
302 | left_margin = hists__col_len(hists, se->se_width_idx); | 303 | |
303 | left_margin -= thread__comm_len(he->thread); | 304 | perf_hpp__for_each_format(fmt) { |
304 | } | 305 | if (!perf_hpp__is_sort_entry(fmt)) |
306 | continue; | ||
305 | 307 | ||
308 | /* must be 'comm' sort entry */ | ||
309 | left_margin = fmt->width(fmt, NULL, hists_to_evsel(hists)); | ||
310 | left_margin -= thread__comm_len(he->thread); | ||
311 | break; | ||
312 | } | ||
313 | } | ||
306 | return hist_entry_callchain__fprintf(he, total_period, left_margin, fp); | 314 | return hist_entry_callchain__fprintf(he, total_period, left_margin, fp); |
307 | } | 315 | } |
308 | 316 | ||
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 9bee7288465f..d9132069d3b1 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c | |||
@@ -22,9 +22,6 @@ int sort__has_sym = 0; | |||
22 | int sort__has_dso = 0; | 22 | int sort__has_dso = 0; |
23 | enum sort_mode sort__mode = SORT_MODE__NORMAL; | 23 | enum sort_mode sort__mode = SORT_MODE__NORMAL; |
24 | 24 | ||
25 | enum sort_type sort__first_dimension; | ||
26 | |||
27 | LIST_HEAD(hist_entry__sort_list); | ||
28 | 25 | ||
29 | static int repsep_snprintf(char *bf, size_t size, const char *fmt, ...) | 26 | static int repsep_snprintf(char *bf, size_t size, const char *fmt, ...) |
30 | { | 27 | { |
@@ -1190,7 +1187,7 @@ static int __sort_dimension__add_hpp_output(struct sort_dimension *sd) | |||
1190 | return 0; | 1187 | return 0; |
1191 | } | 1188 | } |
1192 | 1189 | ||
1193 | static int __sort_dimension__add(struct sort_dimension *sd, enum sort_type idx) | 1190 | static int __sort_dimension__add(struct sort_dimension *sd) |
1194 | { | 1191 | { |
1195 | if (sd->taken) | 1192 | if (sd->taken) |
1196 | return 0; | 1193 | return 0; |
@@ -1201,10 +1198,6 @@ static int __sort_dimension__add(struct sort_dimension *sd, enum sort_type idx) | |||
1201 | if (sd->entry->se_collapse) | 1198 | if (sd->entry->se_collapse) |
1202 | sort__need_collapse = 1; | 1199 | sort__need_collapse = 1; |
1203 | 1200 | ||
1204 | if (list_empty(&hist_entry__sort_list)) | ||
1205 | sort__first_dimension = idx; | ||
1206 | |||
1207 | list_add_tail(&sd->entry->list, &hist_entry__sort_list); | ||
1208 | sd->taken = 1; | 1201 | sd->taken = 1; |
1209 | 1202 | ||
1210 | return 0; | 1203 | return 0; |
@@ -1268,7 +1261,7 @@ int sort_dimension__add(const char *tok) | |||
1268 | sort__has_dso = 1; | 1261 | sort__has_dso = 1; |
1269 | } | 1262 | } |
1270 | 1263 | ||
1271 | return __sort_dimension__add(sd, i); | 1264 | return __sort_dimension__add(sd); |
1272 | } | 1265 | } |
1273 | 1266 | ||
1274 | for (i = 0; i < ARRAY_SIZE(hpp_sort_dimensions); i++) { | 1267 | for (i = 0; i < ARRAY_SIZE(hpp_sort_dimensions); i++) { |
@@ -1292,7 +1285,7 @@ int sort_dimension__add(const char *tok) | |||
1292 | if (sd->entry == &sort_sym_from || sd->entry == &sort_sym_to) | 1285 | if (sd->entry == &sort_sym_from || sd->entry == &sort_sym_to) |
1293 | sort__has_sym = 1; | 1286 | sort__has_sym = 1; |
1294 | 1287 | ||
1295 | __sort_dimension__add(sd, i + __SORT_BRANCH_STACK); | 1288 | __sort_dimension__add(sd); |
1296 | return 0; | 1289 | return 0; |
1297 | } | 1290 | } |
1298 | 1291 | ||
@@ -1308,7 +1301,7 @@ int sort_dimension__add(const char *tok) | |||
1308 | if (sd->entry == &sort_mem_daddr_sym) | 1301 | if (sd->entry == &sort_mem_daddr_sym) |
1309 | sort__has_sym = 1; | 1302 | sort__has_sym = 1; |
1310 | 1303 | ||
1311 | __sort_dimension__add(sd, i + __SORT_MEMORY_MODE); | 1304 | __sort_dimension__add(sd); |
1312 | return 0; | 1305 | return 0; |
1313 | } | 1306 | } |
1314 | 1307 | ||
@@ -1395,7 +1388,8 @@ static void sort_entry__setup_elide(struct sort_entry *se, | |||
1395 | 1388 | ||
1396 | void sort__setup_elide(FILE *output) | 1389 | void sort__setup_elide(FILE *output) |
1397 | { | 1390 | { |
1398 | struct sort_entry *se; | 1391 | struct perf_hpp_fmt *fmt; |
1392 | struct hpp_sort_entry *hse; | ||
1399 | 1393 | ||
1400 | sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, | 1394 | sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, |
1401 | "dso", output); | 1395 | "dso", output); |
@@ -1436,13 +1430,22 @@ void sort__setup_elide(FILE *output) | |||
1436 | * It makes no sense to elide all of sort entries. | 1430 | * It makes no sense to elide all of sort entries. |
1437 | * Just revert them to show up again. | 1431 | * Just revert them to show up again. |
1438 | */ | 1432 | */ |
1439 | list_for_each_entry(se, &hist_entry__sort_list, list) { | 1433 | perf_hpp__for_each_format(fmt) { |
1440 | if (!se->elide) | 1434 | if (!perf_hpp__is_sort_entry(fmt)) |
1435 | continue; | ||
1436 | |||
1437 | hse = container_of(fmt, struct hpp_sort_entry, hpp); | ||
1438 | if (!hse->se->elide) | ||
1441 | return; | 1439 | return; |
1442 | } | 1440 | } |
1443 | 1441 | ||
1444 | list_for_each_entry(se, &hist_entry__sort_list, list) | 1442 | perf_hpp__for_each_format(fmt) { |
1445 | se->elide = false; | 1443 | if (!perf_hpp__is_sort_entry(fmt)) |
1444 | continue; | ||
1445 | |||
1446 | hse = container_of(fmt, struct hpp_sort_entry, hpp); | ||
1447 | hse->se->elide = false; | ||
1448 | } | ||
1446 | } | 1449 | } |
1447 | 1450 | ||
1448 | static int output_field_add(char *tok) | 1451 | static int output_field_add(char *tok) |