aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui/browsers/annotate.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/ui/browsers/annotate.c')
-rw-r--r--tools/perf/ui/browsers/annotate.c61
1 files changed, 57 insertions, 4 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index c3fc6f39f90..9e3310cd02c 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -94,13 +94,13 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
94 addr += ab->start; 94 addr += ab->start;
95 95
96 if (!ab->use_offset) { 96 if (!ab->use_offset) {
97 printed = scnprintf(bf, sizeof(bf), "%" PRIx64 ":", addr); 97 printed = scnprintf(bf, sizeof(bf), " %" PRIx64 ":", addr);
98 } else { 98 } else {
99 if (bdl->jump_target) { 99 if (bdl->jump_target) {
100 printed = scnprintf(bf, sizeof(bf), "%*" PRIx64 ":", 100 printed = scnprintf(bf, sizeof(bf), " %*" PRIx64 ":",
101 ab->offset_width, addr); 101 ab->offset_width, addr);
102 } else { 102 } else {
103 printed = scnprintf(bf, sizeof(bf), "%*s ", 103 printed = scnprintf(bf, sizeof(bf), " %*s ",
104 ab->offset_width, " "); 104 ab->offset_width, " ");
105 } 105 }
106 } 106 }
@@ -141,6 +141,59 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
141 ab->selection = dl; 141 ab->selection = dl;
142} 142}
143 143
144static void annotate_browser__draw_current_loop(struct ui_browser *browser)
145{
146 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
147 struct map_symbol *ms = browser->priv;
148 struct symbol *sym = ms->sym;
149 struct annotation *notes = symbol__annotation(sym);
150 struct disasm_line *cursor = ab->selection, *pos = cursor, *target;
151 struct browser_disasm_line *bcursor = disasm_line__browser(cursor),
152 *btarget, *bpos;
153 unsigned int from, to, start_width = 2;
154
155 list_for_each_entry_from(pos, &notes->src->source, node) {
156 if (!pos->ins || !ins__is_jump(pos->ins))
157 continue;
158
159 target = ab->offsets[pos->ops.target];
160 if (!target)
161 continue;
162
163 btarget = disasm_line__browser(target);
164 if (btarget->idx <= bcursor->idx)
165 goto found;
166 }
167
168 return;
169
170found:
171 bpos = disasm_line__browser(pos);
172 if (ab->hide_src_code) {
173 from = bpos->idx_asm;
174 to = btarget->idx_asm;
175 } else {
176 from = (u64)bpos->idx;
177 to = (u64)btarget->idx;
178 }
179
180 ui_browser__set_color(browser, HE_COLORSET_CODE);
181
182 if (!bpos->jump_target)
183 start_width += ab->offset_width + 1;
184
185 __ui_browser__line_arrow_up(browser, 10, from, to, start_width);
186}
187
188static unsigned int annotate_browser__refresh(struct ui_browser *browser)
189{
190 int ret = ui_browser__list_head_refresh(browser);
191
192 annotate_browser__draw_current_loop(browser);
193
194 return ret;
195}
196
144static double disasm_line__calc_percent(struct disasm_line *dl, struct symbol *sym, int evidx) 197static double disasm_line__calc_percent(struct disasm_line *dl, struct symbol *sym, int evidx)
145{ 198{
146 double percent = 0.0; 199 double percent = 0.0;
@@ -666,7 +719,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
666 }; 719 };
667 struct annotate_browser browser = { 720 struct annotate_browser browser = {
668 .b = { 721 .b = {
669 .refresh = ui_browser__list_head_refresh, 722 .refresh = annotate_browser__refresh,
670 .seek = ui_browser__list_head_seek, 723 .seek = ui_browser__list_head_seek,
671 .write = annotate_browser__write, 724 .write = annotate_browser__write,
672 .filter = disasm_line__filter, 725 .filter = disasm_line__filter,