diff options
author | Jiri Olsa <jolsa@kernel.org> | 2017-10-11 11:01:53 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-11-16 12:49:47 -0500 |
commit | e1b60b5bd3c7a3f215e79fa911122aba59b3d984 (patch) | |
tree | 20a8bb7fb2097771023d906936391747430e9b67 /tools/perf/ui/browsers/annotate.c | |
parent | 7bcbcd589b15eae849d45540832ba4f9530c778e (diff) |
perf annotate browser: Change offsets to struct annotation_line
Use struct annotation_line as a browser::offsets array entry.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20171011150158.11895-31-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui/browsers/annotate.c')
-rw-r--r-- | tools/perf/ui/browsers/annotate.c | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 657811669a6c..911f06ce0f1b 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -51,7 +51,7 @@ struct annotate_browser { | |||
51 | struct rb_root entries; | 51 | struct rb_root entries; |
52 | struct rb_node *curr_hot; | 52 | struct rb_node *curr_hot; |
53 | struct annotation_line *selection; | 53 | struct annotation_line *selection; |
54 | struct disasm_line **offsets; | 54 | struct annotation_line **offsets; |
55 | struct arch *arch; | 55 | struct arch *arch; |
56 | int nr_events; | 56 | int nr_events; |
57 | u64 start; | 57 | u64 start; |
@@ -303,6 +303,7 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser) | |||
303 | struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); | 303 | struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); |
304 | struct disasm_line *cursor = disasm_line(ab->selection); | 304 | struct disasm_line *cursor = disasm_line(ab->selection); |
305 | struct disasm_line *target; | 305 | struct disasm_line *target; |
306 | struct annotation_line *al; | ||
306 | struct browser_line *btarget, *bcursor; | 307 | struct browser_line *btarget, *bcursor; |
307 | unsigned int from, to; | 308 | unsigned int from, to; |
308 | struct map_symbol *ms = ab->b.priv; | 309 | struct map_symbol *ms = ab->b.priv; |
@@ -316,10 +317,12 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser) | |||
316 | if (!disasm_line__is_valid_jump(cursor, sym)) | 317 | if (!disasm_line__is_valid_jump(cursor, sym)) |
317 | return; | 318 | return; |
318 | 319 | ||
319 | target = ab->offsets[cursor->ops.target.offset]; | 320 | al = ab->offsets[cursor->ops.target.offset]; |
320 | if (!target) | 321 | if (!al) |
321 | return; | 322 | return; |
322 | 323 | ||
324 | target = disasm_line(al); | ||
325 | |||
323 | bcursor = browser_line(cursor); | 326 | bcursor = browser_line(cursor); |
324 | btarget = browser_line(target); | 327 | btarget = browser_line(target); |
325 | 328 | ||
@@ -978,10 +981,10 @@ static void count_and_fill(struct annotate_browser *browser, u64 start, u64 end, | |||
978 | return; | 981 | return; |
979 | 982 | ||
980 | for (offset = start; offset <= end; offset++) { | 983 | for (offset = start; offset <= end; offset++) { |
981 | struct disasm_line *dl = browser->offsets[offset]; | 984 | struct annotation_line *al = browser->offsets[offset]; |
982 | 985 | ||
983 | if (dl) | 986 | if (al) |
984 | dl->al.ipc = ipc; | 987 | al->ipc = ipc; |
985 | } | 988 | } |
986 | } | 989 | } |
987 | } | 990 | } |
@@ -1006,13 +1009,13 @@ static void annotate__compute_ipc(struct annotate_browser *browser, size_t size, | |||
1006 | 1009 | ||
1007 | ch = ¬es->src->cycles_hist[offset]; | 1010 | ch = ¬es->src->cycles_hist[offset]; |
1008 | if (ch && ch->cycles) { | 1011 | if (ch && ch->cycles) { |
1009 | struct disasm_line *dl; | 1012 | struct annotation_line *al; |
1010 | 1013 | ||
1011 | if (ch->have_start) | 1014 | if (ch->have_start) |
1012 | count_and_fill(browser, ch->start, offset, ch); | 1015 | count_and_fill(browser, ch->start, offset, ch); |
1013 | dl = browser->offsets[offset]; | 1016 | al = browser->offsets[offset]; |
1014 | if (dl && ch->num_aggr) | 1017 | if (al && ch->num_aggr) |
1015 | dl->al.cycles = ch->cycles_aggr / ch->num_aggr; | 1018 | al->cycles = ch->cycles_aggr / ch->num_aggr; |
1016 | browser->have_cycles = true; | 1019 | browser->have_cycles = true; |
1017 | } | 1020 | } |
1018 | } | 1021 | } |
@@ -1031,13 +1034,18 @@ static void annotate_browser__mark_jump_targets(struct annotate_browser *browser | |||
1031 | return; | 1034 | return; |
1032 | 1035 | ||
1033 | for (offset = 0; offset < size; ++offset) { | 1036 | for (offset = 0; offset < size; ++offset) { |
1034 | struct disasm_line *dl = browser->offsets[offset], *dlt; | 1037 | struct annotation_line *al = browser->offsets[offset]; |
1038 | struct disasm_line *dl, *dlt; | ||
1035 | struct browser_line *bdlt; | 1039 | struct browser_line *bdlt; |
1036 | 1040 | ||
1041 | dl = disasm_line(al); | ||
1042 | |||
1037 | if (!disasm_line__is_valid_jump(dl, sym)) | 1043 | if (!disasm_line__is_valid_jump(dl, sym)) |
1038 | continue; | 1044 | continue; |
1039 | 1045 | ||
1040 | dlt = browser->offsets[dl->ops.target.offset]; | 1046 | al = browser->offsets[dl->ops.target.offset]; |
1047 | dlt = disasm_line(al); | ||
1048 | |||
1041 | /* | 1049 | /* |
1042 | * FIXME: Oops, no jump target? Buggy disassembler? Or do we | 1050 | * FIXME: Oops, no jump target? Buggy disassembler? Or do we |
1043 | * have to adjust to the previous offset? | 1051 | * have to adjust to the previous offset? |
@@ -1066,7 +1074,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, | |||
1066 | struct perf_evsel *evsel, | 1074 | struct perf_evsel *evsel, |
1067 | struct hist_browser_timer *hbt) | 1075 | struct hist_browser_timer *hbt) |
1068 | { | 1076 | { |
1069 | struct disasm_line *pos; | 1077 | struct annotation_line *al; |
1070 | struct annotation *notes; | 1078 | struct annotation *notes; |
1071 | size_t size; | 1079 | size_t size; |
1072 | struct map_symbol ms = { | 1080 | struct map_symbol ms = { |
@@ -1094,7 +1102,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, | |||
1094 | if (map->dso->annotate_warned) | 1102 | if (map->dso->annotate_warned) |
1095 | return -1; | 1103 | return -1; |
1096 | 1104 | ||
1097 | browser.offsets = zalloc(size * sizeof(struct disasm_line *)); | 1105 | browser.offsets = zalloc(size * sizeof(struct annotation_line *)); |
1098 | if (browser.offsets == NULL) { | 1106 | if (browser.offsets == NULL) { |
1099 | ui__error("Not enough memory!"); | 1107 | ui__error("Not enough memory!"); |
1100 | return -1; | 1108 | return -1; |
@@ -1118,15 +1126,16 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, | |||
1118 | notes = symbol__annotation(sym); | 1126 | notes = symbol__annotation(sym); |
1119 | browser.start = map__rip_2objdump(map, sym->start); | 1127 | browser.start = map__rip_2objdump(map, sym->start); |
1120 | 1128 | ||
1121 | list_for_each_entry(pos, ¬es->src->source, al.node) { | 1129 | list_for_each_entry(al, ¬es->src->source, node) { |
1130 | struct disasm_line *dl = disasm_line(al); | ||
1122 | struct browser_line *bpos; | 1131 | struct browser_line *bpos; |
1123 | size_t line_len = strlen(pos->al.line); | 1132 | size_t line_len = strlen(al->line); |
1124 | 1133 | ||
1125 | if (browser.b.width < line_len) | 1134 | if (browser.b.width < line_len) |
1126 | browser.b.width = line_len; | 1135 | browser.b.width = line_len; |
1127 | bpos = browser_line(pos); | 1136 | bpos = browser_line(dl); |
1128 | bpos->idx = browser.nr_entries++; | 1137 | bpos->idx = browser.nr_entries++; |
1129 | if (pos->al.offset != -1) { | 1138 | if (al->offset != -1) { |
1130 | bpos->idx_asm = browser.nr_asm_entries++; | 1139 | bpos->idx_asm = browser.nr_asm_entries++; |
1131 | /* | 1140 | /* |
1132 | * FIXME: short term bandaid to cope with assembly | 1141 | * FIXME: short term bandaid to cope with assembly |
@@ -1135,8 +1144,8 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, | |||
1135 | * | 1144 | * |
1136 | * E.g. copy_user_generic_unrolled | 1145 | * E.g. copy_user_generic_unrolled |
1137 | */ | 1146 | */ |
1138 | if (pos->al.offset < (s64)size) | 1147 | if (al->offset < (s64)size) |
1139 | browser.offsets[pos->al.offset] = pos; | 1148 | browser.offsets[al->offset] = al; |
1140 | } else | 1149 | } else |
1141 | bpos->idx_asm = -1; | 1150 | bpos->idx_asm = -1; |
1142 | } | 1151 | } |