diff options
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r-- | tools/perf/util/annotate.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index d33fe937e6f1..7eac5f0895ee 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include "symbol.h" | 14 | #include "symbol.h" |
15 | #include "debug.h" | 15 | #include "debug.h" |
16 | #include "annotate.h" | 16 | #include "annotate.h" |
17 | #include "evsel.h" | ||
17 | #include <pthread.h> | 18 | #include <pthread.h> |
18 | #include <linux/bitops.h> | 19 | #include <linux/bitops.h> |
19 | 20 | ||
@@ -603,7 +604,7 @@ struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disa | |||
603 | } | 604 | } |
604 | 605 | ||
605 | static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 start, | 606 | static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 start, |
606 | int evidx, u64 len, int min_pcnt, int printed, | 607 | struct perf_evsel *evsel, u64 len, int min_pcnt, int printed, |
607 | int max_lines, struct disasm_line *queue) | 608 | int max_lines, struct disasm_line *queue) |
608 | { | 609 | { |
609 | static const char *prev_line; | 610 | static const char *prev_line; |
@@ -616,7 +617,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st | |||
616 | const char *color; | 617 | const char *color; |
617 | struct annotation *notes = symbol__annotation(sym); | 618 | struct annotation *notes = symbol__annotation(sym); |
618 | struct source_line *src_line = notes->src->lines; | 619 | struct source_line *src_line = notes->src->lines; |
619 | struct sym_hist *h = annotation__histogram(notes, evidx); | 620 | struct sym_hist *h = annotation__histogram(notes, evsel->idx); |
620 | s64 offset = dl->offset; | 621 | s64 offset = dl->offset; |
621 | const u64 addr = start + offset; | 622 | const u64 addr = start + offset; |
622 | struct disasm_line *next; | 623 | struct disasm_line *next; |
@@ -648,7 +649,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st | |||
648 | list_for_each_entry_from(queue, ¬es->src->source, node) { | 649 | list_for_each_entry_from(queue, ¬es->src->source, node) { |
649 | if (queue == dl) | 650 | if (queue == dl) |
650 | break; | 651 | break; |
651 | disasm_line__print(queue, sym, start, evidx, len, | 652 | disasm_line__print(queue, sym, start, evsel, len, |
652 | 0, 0, 1, NULL); | 653 | 0, 0, 1, NULL); |
653 | } | 654 | } |
654 | } | 655 | } |
@@ -935,7 +936,8 @@ static void symbol__free_source_line(struct symbol *sym, int len) | |||
935 | 936 | ||
936 | /* Get the filename:line for the colored entries */ | 937 | /* Get the filename:line for the colored entries */ |
937 | static int symbol__get_source_line(struct symbol *sym, struct map *map, | 938 | static int symbol__get_source_line(struct symbol *sym, struct map *map, |
938 | int evidx, struct rb_root *root, int len, | 939 | struct perf_evsel *evsel, |
940 | struct rb_root *root, int len, | ||
939 | const char *filename) | 941 | const char *filename) |
940 | { | 942 | { |
941 | u64 start; | 943 | u64 start; |
@@ -943,7 +945,7 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map, | |||
943 | char cmd[PATH_MAX * 2]; | 945 | char cmd[PATH_MAX * 2]; |
944 | struct source_line *src_line; | 946 | struct source_line *src_line; |
945 | struct annotation *notes = symbol__annotation(sym); | 947 | struct annotation *notes = symbol__annotation(sym); |
946 | struct sym_hist *h = annotation__histogram(notes, evidx); | 948 | struct sym_hist *h = annotation__histogram(notes, evsel->idx); |
947 | struct rb_root tmp_root = RB_ROOT; | 949 | struct rb_root tmp_root = RB_ROOT; |
948 | 950 | ||
949 | if (!h->sum) | 951 | if (!h->sum) |
@@ -1018,10 +1020,10 @@ static void print_summary(struct rb_root *root, const char *filename) | |||
1018 | } | 1020 | } |
1019 | } | 1021 | } |
1020 | 1022 | ||
1021 | static void symbol__annotate_hits(struct symbol *sym, int evidx) | 1023 | static void symbol__annotate_hits(struct symbol *sym, struct perf_evsel *evsel) |
1022 | { | 1024 | { |
1023 | struct annotation *notes = symbol__annotation(sym); | 1025 | struct annotation *notes = symbol__annotation(sym); |
1024 | struct sym_hist *h = annotation__histogram(notes, evidx); | 1026 | struct sym_hist *h = annotation__histogram(notes, evsel->idx); |
1025 | u64 len = symbol__size(sym), offset; | 1027 | u64 len = symbol__size(sym), offset; |
1026 | 1028 | ||
1027 | for (offset = 0; offset < len; ++offset) | 1029 | for (offset = 0; offset < len; ++offset) |
@@ -1031,9 +1033,9 @@ static void symbol__annotate_hits(struct symbol *sym, int evidx) | |||
1031 | printf("%*s: %" PRIu64 "\n", BITS_PER_LONG / 2, "h->sum", h->sum); | 1033 | printf("%*s: %" PRIu64 "\n", BITS_PER_LONG / 2, "h->sum", h->sum); |
1032 | } | 1034 | } |
1033 | 1035 | ||
1034 | int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx, | 1036 | int symbol__annotate_printf(struct symbol *sym, struct map *map, |
1035 | bool full_paths, int min_pcnt, int max_lines, | 1037 | struct perf_evsel *evsel, bool full_paths, |
1036 | int context) | 1038 | int min_pcnt, int max_lines, int context) |
1037 | { | 1039 | { |
1038 | struct dso *dso = map->dso; | 1040 | struct dso *dso = map->dso; |
1039 | char *filename; | 1041 | char *filename; |
@@ -1060,7 +1062,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx, | |||
1060 | printf("------------------------------------------------\n"); | 1062 | printf("------------------------------------------------\n"); |
1061 | 1063 | ||
1062 | if (verbose) | 1064 | if (verbose) |
1063 | symbol__annotate_hits(sym, evidx); | 1065 | symbol__annotate_hits(sym, evsel); |
1064 | 1066 | ||
1065 | list_for_each_entry(pos, ¬es->src->source, node) { | 1067 | list_for_each_entry(pos, ¬es->src->source, node) { |
1066 | if (context && queue == NULL) { | 1068 | if (context && queue == NULL) { |
@@ -1068,7 +1070,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx, | |||
1068 | queue_len = 0; | 1070 | queue_len = 0; |
1069 | } | 1071 | } |
1070 | 1072 | ||
1071 | switch (disasm_line__print(pos, sym, start, evidx, len, | 1073 | switch (disasm_line__print(pos, sym, start, evsel, len, |
1072 | min_pcnt, printed, max_lines, | 1074 | min_pcnt, printed, max_lines, |
1073 | queue)) { | 1075 | queue)) { |
1074 | case 0: | 1076 | case 0: |
@@ -1163,9 +1165,9 @@ size_t disasm__fprintf(struct list_head *head, FILE *fp) | |||
1163 | return printed; | 1165 | return printed; |
1164 | } | 1166 | } |
1165 | 1167 | ||
1166 | int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx, | 1168 | int symbol__tty_annotate(struct symbol *sym, struct map *map, |
1167 | bool print_lines, bool full_paths, int min_pcnt, | 1169 | struct perf_evsel *evsel, bool print_lines, |
1168 | int max_lines) | 1170 | bool full_paths, int min_pcnt, int max_lines) |
1169 | { | 1171 | { |
1170 | struct dso *dso = map->dso; | 1172 | struct dso *dso = map->dso; |
1171 | const char *filename = dso->long_name; | 1173 | const char *filename = dso->long_name; |
@@ -1178,12 +1180,12 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx, | |||
1178 | len = symbol__size(sym); | 1180 | len = symbol__size(sym); |
1179 | 1181 | ||
1180 | if (print_lines) { | 1182 | if (print_lines) { |
1181 | symbol__get_source_line(sym, map, evidx, &source_line, | 1183 | symbol__get_source_line(sym, map, evsel, &source_line, |
1182 | len, filename); | 1184 | len, filename); |
1183 | print_summary(&source_line, filename); | 1185 | print_summary(&source_line, filename); |
1184 | } | 1186 | } |
1185 | 1187 | ||
1186 | symbol__annotate_printf(sym, map, evidx, full_paths, | 1188 | symbol__annotate_printf(sym, map, evsel, full_paths, |
1187 | min_pcnt, max_lines, 0); | 1189 | min_pcnt, max_lines, 0); |
1188 | if (print_lines) | 1190 | if (print_lines) |
1189 | symbol__free_source_line(sym, len); | 1191 | symbol__free_source_line(sym, len); |