.. | .. |
---|
1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
---|
2 | 2 | #include <stdio.h> |
---|
| 3 | +#include <stdlib.h> |
---|
3 | 4 | #include <linux/string.h> |
---|
4 | 5 | |
---|
5 | | -#include "../../util/util.h" |
---|
| 6 | +#include "../../util/callchain.h" |
---|
| 7 | +#include "../../util/debug.h" |
---|
| 8 | +#include "../../util/event.h" |
---|
6 | 9 | #include "../../util/hist.h" |
---|
| 10 | +#include "../../util/map.h" |
---|
| 11 | +#include "../../util/maps.h" |
---|
| 12 | +#include "../../util/symbol.h" |
---|
7 | 13 | #include "../../util/sort.h" |
---|
8 | 14 | #include "../../util/evsel.h" |
---|
9 | 15 | #include "../../util/srcline.h" |
---|
10 | 16 | #include "../../util/string2.h" |
---|
11 | 17 | #include "../../util/thread.h" |
---|
12 | | -#include "../../util/sane_ctype.h" |
---|
| 18 | +#include "../../util/block-info.h" |
---|
| 19 | +#include <linux/ctype.h> |
---|
| 20 | +#include <linux/zalloc.h> |
---|
13 | 21 | |
---|
14 | 22 | static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin) |
---|
15 | 23 | { |
---|
.. | .. |
---|
512 | 520 | * dynamic entries are right-aligned but we want left-aligned |
---|
513 | 521 | * in the hierarchy mode |
---|
514 | 522 | */ |
---|
515 | | - printed += fprintf(fp, "%s%s", sep ?: " ", ltrim(buf)); |
---|
| 523 | + printed += fprintf(fp, "%s%s", sep ?: " ", skip_spaces(buf)); |
---|
516 | 524 | } |
---|
517 | 525 | printed += putc('\n', fp); |
---|
518 | 526 | |
---|
.. | .. |
---|
525 | 533 | |
---|
526 | 534 | out: |
---|
527 | 535 | return printed; |
---|
| 536 | +} |
---|
| 537 | + |
---|
| 538 | +static int hist_entry__block_fprintf(struct hist_entry *he, |
---|
| 539 | + char *bf, size_t size, |
---|
| 540 | + FILE *fp) |
---|
| 541 | +{ |
---|
| 542 | + struct block_hist *bh = container_of(he, struct block_hist, he); |
---|
| 543 | + int ret = 0; |
---|
| 544 | + |
---|
| 545 | + for (unsigned int i = 0; i < bh->block_hists.nr_entries; i++) { |
---|
| 546 | + struct perf_hpp hpp = { |
---|
| 547 | + .buf = bf, |
---|
| 548 | + .size = size, |
---|
| 549 | + .skip = false, |
---|
| 550 | + }; |
---|
| 551 | + |
---|
| 552 | + bh->block_idx = i; |
---|
| 553 | + hist_entry__snprintf(he, &hpp); |
---|
| 554 | + |
---|
| 555 | + if (!hpp.skip) |
---|
| 556 | + ret += fprintf(fp, "%s\n", bf); |
---|
| 557 | + } |
---|
| 558 | + |
---|
| 559 | + return ret; |
---|
| 560 | +} |
---|
| 561 | + |
---|
| 562 | +static int hist_entry__individual_block_fprintf(struct hist_entry *he, |
---|
| 563 | + char *bf, size_t size, |
---|
| 564 | + FILE *fp) |
---|
| 565 | +{ |
---|
| 566 | + int ret = 0; |
---|
| 567 | + |
---|
| 568 | + struct perf_hpp hpp = { |
---|
| 569 | + .buf = bf, |
---|
| 570 | + .size = size, |
---|
| 571 | + .skip = false, |
---|
| 572 | + }; |
---|
| 573 | + |
---|
| 574 | + hist_entry__snprintf(he, &hpp); |
---|
| 575 | + if (!hpp.skip) |
---|
| 576 | + ret += fprintf(fp, "%s\n", bf); |
---|
| 577 | + |
---|
| 578 | + return ret; |
---|
528 | 579 | } |
---|
529 | 580 | |
---|
530 | 581 | static int hist_entry__fprintf(struct hist_entry *he, size_t size, |
---|
.. | .. |
---|
546 | 597 | if (symbol_conf.report_hierarchy) |
---|
547 | 598 | return hist_entry__hierarchy_fprintf(he, &hpp, hists, fp); |
---|
548 | 599 | |
---|
| 600 | + if (symbol_conf.report_block) |
---|
| 601 | + return hist_entry__block_fprintf(he, bf, size, fp); |
---|
| 602 | + |
---|
| 603 | + if (symbol_conf.report_individual_block) |
---|
| 604 | + return hist_entry__individual_block_fprintf(he, bf, size, fp); |
---|
| 605 | + |
---|
549 | 606 | hist_entry__snprintf(he, &hpp); |
---|
550 | 607 | |
---|
551 | 608 | ret = fprintf(fp, "%s\n", bf); |
---|
.. | .. |
---|
562 | 619 | static int print_hierarchy_indent(const char *sep, int indent, |
---|
563 | 620 | const char *line, FILE *fp) |
---|
564 | 621 | { |
---|
| 622 | + int width; |
---|
| 623 | + |
---|
565 | 624 | if (sep != NULL || indent < 2) |
---|
566 | 625 | return 0; |
---|
567 | 626 | |
---|
568 | | - return fprintf(fp, "%-.*s", (indent - 2) * HIERARCHY_INDENT, line); |
---|
| 627 | + width = (indent - 2) * HIERARCHY_INDENT; |
---|
| 628 | + |
---|
| 629 | + return fprintf(fp, "%-*.*s", width, width, line); |
---|
569 | 630 | } |
---|
570 | 631 | |
---|
571 | 632 | static int hists__fprintf_hierarchy_headers(struct hists *hists, |
---|
.. | .. |
---|
583 | 644 | indent = hists->nr_hpp_node; |
---|
584 | 645 | |
---|
585 | 646 | /* preserve max indent depth for column headers */ |
---|
586 | | - print_hierarchy_indent(sep, indent, spaces, fp); |
---|
| 647 | + print_hierarchy_indent(sep, indent, " ", fp); |
---|
587 | 648 | |
---|
588 | 649 | /* the first hpp_list_node is for overhead columns */ |
---|
589 | 650 | fmt_node = list_first_entry(&hists->hpp_formats, |
---|
.. | .. |
---|
612 | 673 | |
---|
613 | 674 | fmt->header(fmt, hpp, hists, 0, NULL); |
---|
614 | 675 | |
---|
615 | | - header_width += fprintf(fp, "%s", trim(hpp->buf)); |
---|
| 676 | + header_width += fprintf(fp, "%s", strim(hpp->buf)); |
---|
616 | 677 | } |
---|
617 | 678 | } |
---|
618 | 679 | |
---|
.. | .. |
---|
788 | 849 | |
---|
789 | 850 | indent = hists__overhead_width(hists) + 4; |
---|
790 | 851 | |
---|
791 | | - for (nd = rb_first(&hists->entries); nd; nd = __rb_hierarchy_next(nd, HMD_FORCE_CHILD)) { |
---|
| 852 | + for (nd = rb_first_cached(&hists->entries); nd; |
---|
| 853 | + nd = __rb_hierarchy_next(nd, HMD_FORCE_CHILD)) { |
---|
792 | 854 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
---|
793 | 855 | float percent; |
---|
794 | 856 | |
---|
795 | 857 | if (h->filtered) |
---|
796 | 858 | continue; |
---|
797 | 859 | |
---|
798 | | - percent = hist_entry__get_percent_limit(h); |
---|
| 860 | + if (symbol_conf.report_individual_block) |
---|
| 861 | + percent = block_info__total_cycles_percent(h); |
---|
| 862 | + else |
---|
| 863 | + percent = hist_entry__get_percent_limit(h); |
---|
| 864 | + |
---|
799 | 865 | if (percent < min_pcnt) |
---|
800 | 866 | continue; |
---|
801 | 867 | |
---|
.. | .. |
---|
811 | 877 | if (!h->leaf && !hist_entry__has_hierarchy_children(h, min_pcnt)) { |
---|
812 | 878 | int depth = hists->nr_hpp_node + h->depth + 1; |
---|
813 | 879 | |
---|
814 | | - print_hierarchy_indent(sep, depth, spaces, fp); |
---|
| 880 | + print_hierarchy_indent(sep, depth, " ", fp); |
---|
815 | 881 | fprintf(fp, "%*sno entry >= %.2f%%\n", indent, "", min_pcnt); |
---|
816 | 882 | |
---|
817 | 883 | if (max_rows && ++nr_rows >= max_rows) |
---|
.. | .. |
---|
819 | 885 | } |
---|
820 | 886 | |
---|
821 | 887 | if (h->ms.map == NULL && verbose > 1) { |
---|
822 | | - map_groups__fprintf(h->thread->mg, fp); |
---|
| 888 | + maps__fprintf(h->thread->maps, fp); |
---|
823 | 889 | fprintf(fp, "%.10s end\n", graph_dotted_line); |
---|
824 | 890 | } |
---|
825 | 891 | } |
---|