diff options
Diffstat (limited to 'tools/perf/ui/stdio/hist.c')
-rw-r--r-- | tools/perf/ui/stdio/hist.c | 82 |
1 files changed, 45 insertions, 37 deletions
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index f04a63112079..89d8441f9890 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c | |||
@@ -373,7 +373,8 @@ static size_t hist_entry_callchain__fprintf(struct hist_entry *he, | |||
373 | return 0; | 373 | return 0; |
374 | } | 374 | } |
375 | 375 | ||
376 | static int hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp) | 376 | int __hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp, |
377 | struct perf_hpp_list *hpp_list) | ||
377 | { | 378 | { |
378 | const char *sep = symbol_conf.field_sep; | 379 | const char *sep = symbol_conf.field_sep; |
379 | struct perf_hpp_fmt *fmt; | 380 | struct perf_hpp_fmt *fmt; |
@@ -384,7 +385,7 @@ static int hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp) | |||
384 | if (symbol_conf.exclude_other && !he->parent) | 385 | if (symbol_conf.exclude_other && !he->parent) |
385 | return 0; | 386 | return 0; |
386 | 387 | ||
387 | hists__for_each_format(he->hists, fmt) { | 388 | perf_hpp_list__for_each_format(hpp_list, fmt) { |
388 | if (perf_hpp__should_skip(fmt, he->hists)) | 389 | if (perf_hpp__should_skip(fmt, he->hists)) |
389 | continue; | 390 | continue; |
390 | 391 | ||
@@ -410,6 +411,11 @@ static int hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp) | |||
410 | return hpp->buf - start; | 411 | return hpp->buf - start; |
411 | } | 412 | } |
412 | 413 | ||
414 | static int hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp) | ||
415 | { | ||
416 | return __hist_entry__snprintf(he, hpp, he->hists->hpp_list); | ||
417 | } | ||
418 | |||
413 | static int hist_entry__hierarchy_fprintf(struct hist_entry *he, | 419 | static int hist_entry__hierarchy_fprintf(struct hist_entry *he, |
414 | struct perf_hpp *hpp, | 420 | struct perf_hpp *hpp, |
415 | struct hists *hists, | 421 | struct hists *hists, |
@@ -528,8 +534,8 @@ static int print_hierarchy_indent(const char *sep, int indent, | |||
528 | return fprintf(fp, "%-.*s", (indent - 2) * HIERARCHY_INDENT, line); | 534 | return fprintf(fp, "%-.*s", (indent - 2) * HIERARCHY_INDENT, line); |
529 | } | 535 | } |
530 | 536 | ||
531 | static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp, | 537 | static int hists__fprintf_hierarchy_headers(struct hists *hists, |
532 | const char *sep, FILE *fp) | 538 | struct perf_hpp *hpp, FILE *fp) |
533 | { | 539 | { |
534 | bool first_node, first_col; | 540 | bool first_node, first_col; |
535 | int indent; | 541 | int indent; |
@@ -538,6 +544,7 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp, | |||
538 | unsigned header_width = 0; | 544 | unsigned header_width = 0; |
539 | struct perf_hpp_fmt *fmt; | 545 | struct perf_hpp_fmt *fmt; |
540 | struct perf_hpp_list_node *fmt_node; | 546 | struct perf_hpp_list_node *fmt_node; |
547 | const char *sep = symbol_conf.field_sep; | ||
541 | 548 | ||
542 | indent = hists->nr_hpp_node; | 549 | indent = hists->nr_hpp_node; |
543 | 550 | ||
@@ -549,7 +556,7 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp, | |||
549 | struct perf_hpp_list_node, list); | 556 | struct perf_hpp_list_node, list); |
550 | 557 | ||
551 | perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) { | 558 | perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) { |
552 | fmt->header(fmt, hpp, hists); | 559 | fmt->header(fmt, hpp, hists, 0, NULL); |
553 | fprintf(fp, "%s%s", hpp->buf, sep ?: " "); | 560 | fprintf(fp, "%s%s", hpp->buf, sep ?: " "); |
554 | } | 561 | } |
555 | 562 | ||
@@ -569,7 +576,7 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp, | |||
569 | header_width += fprintf(fp, "+"); | 576 | header_width += fprintf(fp, "+"); |
570 | first_col = false; | 577 | first_col = false; |
571 | 578 | ||
572 | fmt->header(fmt, hpp, hists); | 579 | fmt->header(fmt, hpp, hists, 0, NULL); |
573 | 580 | ||
574 | header_width += fprintf(fp, "%s", trim(hpp->buf)); | 581 | header_width += fprintf(fp, "%s", trim(hpp->buf)); |
575 | } | 582 | } |
@@ -623,20 +630,28 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp, | |||
623 | return 2; | 630 | return 2; |
624 | } | 631 | } |
625 | 632 | ||
626 | static int | 633 | static void fprintf_line(struct hists *hists, struct perf_hpp *hpp, |
627 | hists__fprintf_hierarchy_headers(struct hists *hists, | 634 | int line, FILE *fp) |
628 | struct perf_hpp *hpp, | ||
629 | FILE *fp) | ||
630 | { | 635 | { |
631 | struct perf_hpp_list_node *fmt_node; | ||
632 | struct perf_hpp_fmt *fmt; | 636 | struct perf_hpp_fmt *fmt; |
637 | const char *sep = symbol_conf.field_sep; | ||
638 | bool first = true; | ||
639 | int span = 0; | ||
633 | 640 | ||
634 | list_for_each_entry(fmt_node, &hists->hpp_formats, list) { | 641 | hists__for_each_format(hists, fmt) { |
635 | perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) | 642 | if (perf_hpp__should_skip(fmt, hists)) |
636 | perf_hpp__reset_width(fmt, hists); | 643 | continue; |
637 | } | 644 | |
645 | if (!first && !span) | ||
646 | fprintf(fp, "%s", sep ?: " "); | ||
647 | else | ||
648 | first = false; | ||
649 | |||
650 | fmt->header(fmt, hpp, hists, line, &span); | ||
638 | 651 | ||
639 | return print_hierarchy_header(hists, hpp, symbol_conf.field_sep, fp); | 652 | if (!span) |
653 | fprintf(fp, "%s", hpp->buf); | ||
654 | } | ||
640 | } | 655 | } |
641 | 656 | ||
642 | static int | 657 | static int |
@@ -644,28 +659,23 @@ hists__fprintf_standard_headers(struct hists *hists, | |||
644 | struct perf_hpp *hpp, | 659 | struct perf_hpp *hpp, |
645 | FILE *fp) | 660 | FILE *fp) |
646 | { | 661 | { |
662 | struct perf_hpp_list *hpp_list = hists->hpp_list; | ||
647 | struct perf_hpp_fmt *fmt; | 663 | struct perf_hpp_fmt *fmt; |
648 | unsigned int width; | 664 | unsigned int width; |
649 | const char *sep = symbol_conf.field_sep; | 665 | const char *sep = symbol_conf.field_sep; |
650 | bool first = true; | 666 | bool first = true; |
651 | 667 | int line; | |
652 | hists__for_each_format(hists, fmt) { | 668 | |
653 | if (perf_hpp__should_skip(fmt, hists)) | 669 | for (line = 0; line < hpp_list->nr_header_lines; line++) { |
654 | continue; | 670 | /* first # is displayed one level up */ |
655 | 671 | if (line) | |
656 | if (!first) | 672 | fprintf(fp, "# "); |
657 | fprintf(fp, "%s", sep ?: " "); | 673 | fprintf_line(hists, hpp, line, fp); |
658 | else | 674 | fprintf(fp, "\n"); |
659 | first = false; | ||
660 | |||
661 | fmt->header(fmt, hpp, hists); | ||
662 | fprintf(fp, "%s", hpp->buf); | ||
663 | } | 675 | } |
664 | 676 | ||
665 | fprintf(fp, "\n"); | ||
666 | |||
667 | if (sep) | 677 | if (sep) |
668 | return 1; | 678 | return hpp_list->nr_header_lines; |
669 | 679 | ||
670 | first = true; | 680 | first = true; |
671 | 681 | ||
@@ -689,12 +699,12 @@ hists__fprintf_standard_headers(struct hists *hists, | |||
689 | 699 | ||
690 | fprintf(fp, "\n"); | 700 | fprintf(fp, "\n"); |
691 | fprintf(fp, "#\n"); | 701 | fprintf(fp, "#\n"); |
692 | return 3; | 702 | return hpp_list->nr_header_lines + 2; |
693 | } | 703 | } |
694 | 704 | ||
695 | static int hists__fprintf_headers(struct hists *hists, FILE *fp) | 705 | int hists__fprintf_headers(struct hists *hists, FILE *fp) |
696 | { | 706 | { |
697 | char bf[96]; | 707 | char bf[1024]; |
698 | struct perf_hpp dummy_hpp = { | 708 | struct perf_hpp dummy_hpp = { |
699 | .buf = bf, | 709 | .buf = bf, |
700 | .size = sizeof(bf), | 710 | .size = sizeof(bf), |
@@ -713,7 +723,6 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, | |||
713 | int max_cols, float min_pcnt, FILE *fp, | 723 | int max_cols, float min_pcnt, FILE *fp, |
714 | bool use_callchain) | 724 | bool use_callchain) |
715 | { | 725 | { |
716 | struct perf_hpp_fmt *fmt; | ||
717 | struct rb_node *nd; | 726 | struct rb_node *nd; |
718 | size_t ret = 0; | 727 | size_t ret = 0; |
719 | const char *sep = symbol_conf.field_sep; | 728 | const char *sep = symbol_conf.field_sep; |
@@ -724,8 +733,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, | |||
724 | 733 | ||
725 | init_rem_hits(); | 734 | init_rem_hits(); |
726 | 735 | ||
727 | hists__for_each_format(hists, fmt) | 736 | hists__reset_column_width(hists); |
728 | perf_hpp__reset_width(fmt, hists); | ||
729 | 737 | ||
730 | if (symbol_conf.col_width_list_str) | 738 | if (symbol_conf.col_width_list_str) |
731 | perf_hpp__set_user_width(symbol_conf.col_width_list_str); | 739 | perf_hpp__set_user_width(symbol_conf.col_width_list_str); |