diff options
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r-- | tools/perf/util/annotate.c | 64 |
1 files changed, 53 insertions, 11 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index ae71325d3dc7..0955cff5b0ef 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -638,7 +638,9 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st | |||
638 | 638 | ||
639 | if (dl->offset != -1) { | 639 | if (dl->offset != -1) { |
640 | const char *path = NULL; | 640 | const char *path = NULL; |
641 | double percent; | 641 | double percent, max_percent = 0.0; |
642 | double *ppercents = &percent; | ||
643 | int i, nr_percent = 1; | ||
642 | const char *color; | 644 | const char *color; |
643 | struct annotation *notes = symbol__annotation(sym); | 645 | struct annotation *notes = symbol__annotation(sym); |
644 | s64 offset = dl->offset; | 646 | s64 offset = dl->offset; |
@@ -647,10 +649,27 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st | |||
647 | 649 | ||
648 | next = disasm__get_next_ip_line(¬es->src->source, dl); | 650 | next = disasm__get_next_ip_line(¬es->src->source, dl); |
649 | 651 | ||
650 | percent = disasm__calc_percent(notes, evsel->idx, offset, | 652 | if (symbol_conf.event_group && |
651 | next ? next->offset : (s64) len, | 653 | perf_evsel__is_group_leader(evsel) && |
652 | &path); | 654 | evsel->nr_members > 1) { |
653 | if (percent < min_pcnt) | 655 | nr_percent = evsel->nr_members; |
656 | ppercents = calloc(nr_percent, sizeof(double)); | ||
657 | if (ppercents == NULL) | ||
658 | return -1; | ||
659 | } | ||
660 | |||
661 | for (i = 0; i < nr_percent; i++) { | ||
662 | percent = disasm__calc_percent(notes, | ||
663 | evsel->idx + i, offset, | ||
664 | next ? next->offset : (s64) len, | ||
665 | &path); | ||
666 | |||
667 | ppercents[i] = percent; | ||
668 | if (percent > max_percent) | ||
669 | max_percent = percent; | ||
670 | } | ||
671 | |||
672 | if (max_percent < min_pcnt) | ||
654 | return -1; | 673 | return -1; |
655 | 674 | ||
656 | if (max_lines && printed >= max_lines) | 675 | if (max_lines && printed >= max_lines) |
@@ -665,7 +684,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st | |||
665 | } | 684 | } |
666 | } | 685 | } |
667 | 686 | ||
668 | color = get_percent_color(percent); | 687 | color = get_percent_color(max_percent); |
669 | 688 | ||
670 | /* | 689 | /* |
671 | * Also color the filename and line if needed, with | 690 | * Also color the filename and line if needed, with |
@@ -681,20 +700,35 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st | |||
681 | } | 700 | } |
682 | } | 701 | } |
683 | 702 | ||
684 | color_fprintf(stdout, color, " %7.2f", percent); | 703 | for (i = 0; i < nr_percent; i++) { |
704 | percent = ppercents[i]; | ||
705 | color = get_percent_color(percent); | ||
706 | color_fprintf(stdout, color, " %7.2f", percent); | ||
707 | } | ||
708 | |||
685 | printf(" : "); | 709 | printf(" : "); |
686 | color_fprintf(stdout, PERF_COLOR_MAGENTA, " %" PRIx64 ":", addr); | 710 | color_fprintf(stdout, PERF_COLOR_MAGENTA, " %" PRIx64 ":", addr); |
687 | color_fprintf(stdout, PERF_COLOR_BLUE, "%s\n", dl->line); | 711 | color_fprintf(stdout, PERF_COLOR_BLUE, "%s\n", dl->line); |
712 | |||
713 | if (ppercents != &percent) | ||
714 | free(ppercents); | ||
715 | |||
688 | } else if (max_lines && printed >= max_lines) | 716 | } else if (max_lines && printed >= max_lines) |
689 | return 1; | 717 | return 1; |
690 | else { | 718 | else { |
719 | int width = 8; | ||
720 | |||
691 | if (queue) | 721 | if (queue) |
692 | return -1; | 722 | return -1; |
693 | 723 | ||
724 | if (symbol_conf.event_group && | ||
725 | perf_evsel__is_group_leader(evsel)) | ||
726 | width *= evsel->nr_members; | ||
727 | |||
694 | if (!*dl->line) | 728 | if (!*dl->line) |
695 | printf(" :\n"); | 729 | printf(" %*s:\n", width, " "); |
696 | else | 730 | else |
697 | printf(" : %s\n", dl->line); | 731 | printf(" %*s: %s\n", width, " ", dl->line); |
698 | } | 732 | } |
699 | 733 | ||
700 | return 0; | 734 | return 0; |
@@ -1077,6 +1111,8 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, | |||
1077 | int printed = 2, queue_len = 0; | 1111 | int printed = 2, queue_len = 0; |
1078 | int more = 0; | 1112 | int more = 0; |
1079 | u64 len; | 1113 | u64 len; |
1114 | int width = 8; | ||
1115 | int namelen; | ||
1080 | 1116 | ||
1081 | filename = strdup(dso->long_name); | 1117 | filename = strdup(dso->long_name); |
1082 | if (!filename) | 1118 | if (!filename) |
@@ -1088,9 +1124,15 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, | |||
1088 | d_filename = basename(filename); | 1124 | d_filename = basename(filename); |
1089 | 1125 | ||
1090 | len = symbol__size(sym); | 1126 | len = symbol__size(sym); |
1127 | namelen = strlen(d_filename); | ||
1128 | |||
1129 | if (symbol_conf.event_group && perf_evsel__is_group_leader(evsel)) | ||
1130 | width *= evsel->nr_members; | ||
1091 | 1131 | ||
1092 | printf(" Percent | Source code & Disassembly of %s\n", d_filename); | 1132 | printf(" %-*.*s| Source code & Disassembly of %s\n", |
1093 | printf("------------------------------------------------\n"); | 1133 | width, width, "Percent", d_filename); |
1134 | printf("-%-*.*s-------------------------------------\n", | ||
1135 | width+namelen, width+namelen, graph_dotted_line); | ||
1094 | 1136 | ||
1095 | if (verbose) | 1137 | if (verbose) |
1096 | symbol__annotate_hits(sym, evsel); | 1138 | symbol__annotate_hits(sym, evsel); |