diff options
author | Namhyung Kim <namhyung@kernel.org> | 2016-03-07 14:44:48 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-03-08 04:11:20 -0500 |
commit | 2dbbe9f26c082be5aa0e8ba5480e7bac43b2c4f0 (patch) | |
tree | dccf67f5759a3c9cc30fb66c50c96c2fa677d895 | |
parent | a23f37e864609f0887c1cb77c4d5b62586484a61 (diff) |
perf hists: Fix indent for multiple hierarchy sort key
When multiple sort keys are used in a single hierarchy, it should indent
using number of hierarchy levels instead of number of sort keys.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1457361308-514-5-git-send-email-namhyung@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | tools/perf/ui/browsers/hists.c | 23 | ||||
-rw-r--r-- | tools/perf/ui/hist.c | 1 | ||||
-rw-r--r-- | tools/perf/ui/stdio/hist.c | 26 | ||||
-rw-r--r-- | tools/perf/util/hist.h | 1 |
4 files changed, 23 insertions, 28 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 928b4825b752..2f02ce79bd9d 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -1280,7 +1280,7 @@ static int hist_browser__show_entry(struct hist_browser *browser, | |||
1280 | static int hist_browser__show_hierarchy_entry(struct hist_browser *browser, | 1280 | static int hist_browser__show_hierarchy_entry(struct hist_browser *browser, |
1281 | struct hist_entry *entry, | 1281 | struct hist_entry *entry, |
1282 | unsigned short row, | 1282 | unsigned short row, |
1283 | int level, int nr_sort_keys) | 1283 | int level) |
1284 | { | 1284 | { |
1285 | int printed = 0; | 1285 | int printed = 0; |
1286 | int width = browser->b.width; | 1286 | int width = browser->b.width; |
@@ -1294,7 +1294,7 @@ static int hist_browser__show_hierarchy_entry(struct hist_browser *browser, | |||
1294 | .current_entry = current_entry, | 1294 | .current_entry = current_entry, |
1295 | }; | 1295 | }; |
1296 | int column = 0; | 1296 | int column = 0; |
1297 | int hierarchy_indent = (nr_sort_keys - 1) * HIERARCHY_INDENT; | 1297 | int hierarchy_indent = (entry->hists->nr_hpp_node - 2) * HIERARCHY_INDENT; |
1298 | 1298 | ||
1299 | if (current_entry) { | 1299 | if (current_entry) { |
1300 | browser->he_selection = entry; | 1300 | browser->he_selection = entry; |
@@ -1436,8 +1436,7 @@ show_callchain: | |||
1436 | } | 1436 | } |
1437 | 1437 | ||
1438 | static int hist_browser__show_no_entry(struct hist_browser *browser, | 1438 | static int hist_browser__show_no_entry(struct hist_browser *browser, |
1439 | unsigned short row, | 1439 | unsigned short row, int level) |
1440 | int level, int nr_sort_keys) | ||
1441 | { | 1440 | { |
1442 | int width = browser->b.width; | 1441 | int width = browser->b.width; |
1443 | bool current_entry = ui_browser__is_current_entry(&browser->b, row); | 1442 | bool current_entry = ui_browser__is_current_entry(&browser->b, row); |
@@ -1445,6 +1444,7 @@ static int hist_browser__show_no_entry(struct hist_browser *browser, | |||
1445 | int column = 0; | 1444 | int column = 0; |
1446 | int ret; | 1445 | int ret; |
1447 | struct perf_hpp_fmt *fmt; | 1446 | struct perf_hpp_fmt *fmt; |
1447 | int indent = browser->hists->nr_hpp_node - 2; | ||
1448 | 1448 | ||
1449 | if (current_entry) { | 1449 | if (current_entry) { |
1450 | browser->he_selection = NULL; | 1450 | browser->he_selection = NULL; |
@@ -1485,8 +1485,8 @@ static int hist_browser__show_no_entry(struct hist_browser *browser, | |||
1485 | width -= ret; | 1485 | width -= ret; |
1486 | } | 1486 | } |
1487 | 1487 | ||
1488 | ui_browser__write_nstring(&browser->b, "", nr_sort_keys * HIERARCHY_INDENT); | 1488 | ui_browser__write_nstring(&browser->b, "", indent * HIERARCHY_INDENT); |
1489 | width -= nr_sort_keys * HIERARCHY_INDENT; | 1489 | width -= indent * HIERARCHY_INDENT; |
1490 | 1490 | ||
1491 | if (column >= browser->b.horiz_scroll) { | 1491 | if (column >= browser->b.horiz_scroll) { |
1492 | char buf[32]; | 1492 | char buf[32]; |
@@ -1553,7 +1553,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows | |||
1553 | struct perf_hpp_fmt *fmt; | 1553 | struct perf_hpp_fmt *fmt; |
1554 | size_t ret = 0; | 1554 | size_t ret = 0; |
1555 | int column = 0; | 1555 | int column = 0; |
1556 | int nr_sort_keys = hists->nr_sort_keys; | 1556 | int indent = hists->nr_hpp_node - 2; |
1557 | bool first = true; | 1557 | bool first = true; |
1558 | 1558 | ||
1559 | ret = scnprintf(buf, size, " "); | 1559 | ret = scnprintf(buf, size, " "); |
@@ -1577,7 +1577,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows | |||
1577 | } | 1577 | } |
1578 | 1578 | ||
1579 | ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, "%*s", | 1579 | ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, "%*s", |
1580 | (nr_sort_keys - 1) * HIERARCHY_INDENT, ""); | 1580 | indent * HIERARCHY_INDENT, ""); |
1581 | if (advance_hpp_check(&dummy_hpp, ret)) | 1581 | if (advance_hpp_check(&dummy_hpp, ret)) |
1582 | return ret; | 1582 | return ret; |
1583 | 1583 | ||
@@ -1645,7 +1645,6 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser) | |||
1645 | u16 header_offset = 0; | 1645 | u16 header_offset = 0; |
1646 | struct rb_node *nd; | 1646 | struct rb_node *nd; |
1647 | struct hist_browser *hb = container_of(browser, struct hist_browser, b); | 1647 | struct hist_browser *hb = container_of(browser, struct hist_browser, b); |
1648 | int nr_sort = hb->hists->nr_sort_keys; | ||
1649 | 1648 | ||
1650 | if (hb->show_headers) { | 1649 | if (hb->show_headers) { |
1651 | hist_browser__show_headers(hb); | 1650 | hist_browser__show_headers(hb); |
@@ -1672,14 +1671,12 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser) | |||
1672 | 1671 | ||
1673 | if (symbol_conf.report_hierarchy) { | 1672 | if (symbol_conf.report_hierarchy) { |
1674 | row += hist_browser__show_hierarchy_entry(hb, h, row, | 1673 | row += hist_browser__show_hierarchy_entry(hb, h, row, |
1675 | h->depth, | 1674 | h->depth); |
1676 | nr_sort); | ||
1677 | if (row == browser->rows) | 1675 | if (row == browser->rows) |
1678 | break; | 1676 | break; |
1679 | 1677 | ||
1680 | if (h->has_no_entry) { | 1678 | if (h->has_no_entry) { |
1681 | hist_browser__show_no_entry(hb, row, h->depth, | 1679 | hist_browser__show_no_entry(hb, row, h->depth); |
1682 | nr_sort); | ||
1683 | row++; | 1680 | row++; |
1684 | } | 1681 | } |
1685 | } else { | 1682 | } else { |
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 95795ef4209b..f03c4f70438f 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c | |||
@@ -740,6 +740,7 @@ static int add_hierarchy_fmt(struct hists *hists, struct perf_hpp_fmt *fmt) | |||
740 | node->level = fmt->level; | 740 | node->level = fmt->level; |
741 | perf_hpp_list__init(&node->hpp); | 741 | perf_hpp_list__init(&node->hpp); |
742 | 742 | ||
743 | hists->nr_hpp_node++; | ||
743 | list_add_tail(&node->list, &hists->hpp_formats); | 744 | list_add_tail(&node->list, &hists->hpp_formats); |
744 | } | 745 | } |
745 | 746 | ||
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 073642a63cc9..543d7137cc0c 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c | |||
@@ -412,7 +412,7 @@ static int hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp) | |||
412 | 412 | ||
413 | static int hist_entry__hierarchy_fprintf(struct hist_entry *he, | 413 | static int hist_entry__hierarchy_fprintf(struct hist_entry *he, |
414 | struct perf_hpp *hpp, | 414 | struct perf_hpp *hpp, |
415 | int nr_sort_key, struct hists *hists, | 415 | struct hists *hists, |
416 | FILE *fp) | 416 | FILE *fp) |
417 | { | 417 | { |
418 | const char *sep = symbol_conf.field_sep; | 418 | const char *sep = symbol_conf.field_sep; |
@@ -453,7 +453,7 @@ static int hist_entry__hierarchy_fprintf(struct hist_entry *he, | |||
453 | 453 | ||
454 | if (!sep) | 454 | if (!sep) |
455 | ret = scnprintf(hpp->buf, hpp->size, "%*s", | 455 | ret = scnprintf(hpp->buf, hpp->size, "%*s", |
456 | (nr_sort_key - 1) * HIERARCHY_INDENT, ""); | 456 | (hists->nr_hpp_node - 2) * HIERARCHY_INDENT, ""); |
457 | advance_hpp(hpp, ret); | 457 | advance_hpp(hpp, ret); |
458 | 458 | ||
459 | printed += fprintf(fp, "%s", buf); | 459 | printed += fprintf(fp, "%s", buf); |
@@ -504,12 +504,8 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size, | |||
504 | if (size == 0 || size > bfsz) | 504 | if (size == 0 || size > bfsz) |
505 | size = hpp.size = bfsz; | 505 | size = hpp.size = bfsz; |
506 | 506 | ||
507 | if (symbol_conf.report_hierarchy) { | 507 | if (symbol_conf.report_hierarchy) |
508 | int nr_sort = hists->nr_sort_keys; | 508 | return hist_entry__hierarchy_fprintf(he, &hpp, hists, fp); |
509 | |||
510 | return hist_entry__hierarchy_fprintf(he, &hpp, nr_sort, | ||
511 | hists, fp); | ||
512 | } | ||
513 | 509 | ||
514 | hist_entry__snprintf(he, &hpp); | 510 | hist_entry__snprintf(he, &hpp); |
515 | 511 | ||
@@ -521,29 +517,29 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size, | |||
521 | return ret; | 517 | return ret; |
522 | } | 518 | } |
523 | 519 | ||
524 | static int print_hierarchy_indent(const char *sep, int nr_sort, | 520 | static int print_hierarchy_indent(const char *sep, int indent, |
525 | const char *line, FILE *fp) | 521 | const char *line, FILE *fp) |
526 | { | 522 | { |
527 | if (sep != NULL || nr_sort < 1) | 523 | if (sep != NULL || indent < 2) |
528 | return 0; | 524 | return 0; |
529 | 525 | ||
530 | return fprintf(fp, "%-.*s", (nr_sort - 1) * HIERARCHY_INDENT, line); | 526 | return fprintf(fp, "%-.*s", (indent - 2) * HIERARCHY_INDENT, line); |
531 | } | 527 | } |
532 | 528 | ||
533 | static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp, | 529 | static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp, |
534 | const char *sep, FILE *fp) | 530 | const char *sep, FILE *fp) |
535 | { | 531 | { |
536 | bool first = true; | 532 | bool first = true; |
537 | int nr_sort; | 533 | int indent; |
538 | int depth; | 534 | int depth; |
539 | unsigned width = 0; | 535 | unsigned width = 0; |
540 | unsigned header_width = 0; | 536 | unsigned header_width = 0; |
541 | struct perf_hpp_fmt *fmt; | 537 | struct perf_hpp_fmt *fmt; |
542 | 538 | ||
543 | nr_sort = hists->nr_sort_keys; | 539 | indent = hists->nr_hpp_node; |
544 | 540 | ||
545 | /* preserve max indent depth for column headers */ | 541 | /* preserve max indent depth for column headers */ |
546 | print_hierarchy_indent(sep, nr_sort, spaces, fp); | 542 | print_hierarchy_indent(sep, indent, spaces, fp); |
547 | 543 | ||
548 | hists__for_each_format(hists, fmt) { | 544 | hists__for_each_format(hists, fmt) { |
549 | if (perf_hpp__is_sort_entry(fmt) || perf_hpp__is_dynamic_entry(fmt)) | 545 | if (perf_hpp__is_sort_entry(fmt) || perf_hpp__is_dynamic_entry(fmt)) |
@@ -582,7 +578,7 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp, | |||
582 | fprintf(fp, "\n# "); | 578 | fprintf(fp, "\n# "); |
583 | 579 | ||
584 | /* preserve max indent depth for initial dots */ | 580 | /* preserve max indent depth for initial dots */ |
585 | print_hierarchy_indent(sep, nr_sort, dots, fp); | 581 | print_hierarchy_indent(sep, indent, dots, fp); |
586 | 582 | ||
587 | first = true; | 583 | first = true; |
588 | hists__for_each_format(hists, fmt) { | 584 | hists__for_each_format(hists, fmt) { |
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 2209188d729c..2cb017f28f9e 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -80,6 +80,7 @@ struct hists { | |||
80 | struct perf_hpp_list *hpp_list; | 80 | struct perf_hpp_list *hpp_list; |
81 | struct list_head hpp_formats; | 81 | struct list_head hpp_formats; |
82 | int nr_sort_keys; | 82 | int nr_sort_keys; |
83 | int nr_hpp_node; | ||
83 | }; | 84 | }; |
84 | 85 | ||
85 | struct hist_entry_iter; | 86 | struct hist_entry_iter; |