diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-04-27 15:35:29 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-04-27 15:35:29 -0400 |
commit | 9d1ef56d571671097f54a5ec31a9b1fb7dc819ed (patch) | |
tree | cbfeda30b6c728561e8a20cde6379f72d496b712 /tools/perf/ui | |
parent | 944e1abed9e1c04e410ddfee849529eedd3e534a (diff) |
perf annotate browser: Show current jump, back or forward
Instead of trying to show the current loop by naively looking for the
next backward jump, just use 'j' to toggle showing arrows connecting
jump with its target.
And do it for forward jumps as well.
Loop detection requires more code to follow the flow control, etc.
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-soahcn1lz2u4wxj31ch0594j@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui')
-rw-r--r-- | tools/perf/ui/browsers/annotate.c | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 4778172683ba..d203dafedeae 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -30,6 +30,7 @@ struct annotate_browser { | |||
30 | int nr_entries; | 30 | int nr_entries; |
31 | bool hide_src_code; | 31 | bool hide_src_code; |
32 | bool use_offset; | 32 | bool use_offset; |
33 | bool jump_arrows; | ||
33 | bool searching_backwards; | 34 | bool searching_backwards; |
34 | u8 offset_width; | 35 | u8 offset_width; |
35 | char search_bf[128]; | 36 | char search_bf[128]; |
@@ -144,56 +145,47 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro | |||
144 | ab->selection = dl; | 145 | ab->selection = dl; |
145 | } | 146 | } |
146 | 147 | ||
147 | static void annotate_browser__draw_current_loop(struct ui_browser *browser) | 148 | static void annotate_browser__draw_current_jump(struct ui_browser *browser) |
148 | { | 149 | { |
149 | struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); | 150 | struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); |
150 | struct map_symbol *ms = browser->priv; | 151 | struct disasm_line *cursor = ab->selection, *target; |
151 | struct symbol *sym = ms->sym; | 152 | struct browser_disasm_line *btarget, *bcursor; |
152 | struct annotation *notes = symbol__annotation(sym); | ||
153 | struct disasm_line *cursor = ab->selection, *pos = cursor, *target; | ||
154 | struct browser_disasm_line *bcursor = disasm_line__browser(cursor), | ||
155 | *btarget, *bpos; | ||
156 | unsigned int from, to, start_width = 2; | 153 | unsigned int from, to, start_width = 2; |
157 | 154 | ||
158 | list_for_each_entry_from(pos, ¬es->src->source, node) { | 155 | if (!cursor->ins || !ins__is_jump(cursor->ins) || |
159 | if (!pos->ins || !ins__is_jump(pos->ins) || | 156 | !disasm_line__has_offset(cursor)) |
160 | !disasm_line__has_offset(pos)) | 157 | return; |
161 | continue; | ||
162 | |||
163 | target = ab->offsets[pos->ops.target.offset]; | ||
164 | if (!target) | ||
165 | continue; | ||
166 | 158 | ||
167 | btarget = disasm_line__browser(target); | 159 | target = ab->offsets[cursor->ops.target.offset]; |
168 | if (btarget->idx <= bcursor->idx) | 160 | if (!target) |
169 | goto found; | 161 | return; |
170 | } | ||
171 | 162 | ||
172 | return; | 163 | bcursor = disasm_line__browser(cursor); |
164 | btarget = disasm_line__browser(target); | ||
173 | 165 | ||
174 | found: | ||
175 | bpos = disasm_line__browser(pos); | ||
176 | if (ab->hide_src_code) { | 166 | if (ab->hide_src_code) { |
177 | from = bpos->idx_asm; | 167 | from = bcursor->idx_asm; |
178 | to = btarget->idx_asm; | 168 | to = btarget->idx_asm; |
179 | } else { | 169 | } else { |
180 | from = (u64)bpos->idx; | 170 | from = (u64)bcursor->idx; |
181 | to = (u64)btarget->idx; | 171 | to = (u64)btarget->idx; |
182 | } | 172 | } |
183 | 173 | ||
184 | ui_browser__set_color(browser, HE_COLORSET_CODE); | 174 | ui_browser__set_color(browser, HE_COLORSET_CODE); |
185 | 175 | ||
186 | if (!bpos->jump_target) | 176 | if (!bcursor->jump_target) |
187 | start_width += ab->offset_width + 1; | 177 | start_width += ab->offset_width + 1; |
188 | 178 | ||
189 | __ui_browser__line_arrow_up(browser, 10, from, to, start_width); | 179 | __ui_browser__line_arrow(browser, 10, from, to, start_width); |
190 | } | 180 | } |
191 | 181 | ||
192 | static unsigned int annotate_browser__refresh(struct ui_browser *browser) | 182 | static unsigned int annotate_browser__refresh(struct ui_browser *browser) |
193 | { | 183 | { |
184 | struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); | ||
194 | int ret = ui_browser__list_head_refresh(browser); | 185 | int ret = ui_browser__list_head_refresh(browser); |
195 | 186 | ||
196 | annotate_browser__draw_current_loop(browser); | 187 | if (ab->jump_arrows) |
188 | annotate_browser__draw_current_jump(browser); | ||
197 | 189 | ||
198 | return ret; | 190 | return ret; |
199 | } | 191 | } |
@@ -628,6 +620,9 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx, | |||
628 | case 'o': | 620 | case 'o': |
629 | self->use_offset = !self->use_offset; | 621 | self->use_offset = !self->use_offset; |
630 | continue; | 622 | continue; |
623 | case 'j': | ||
624 | self->jump_arrows = !self->jump_arrows; | ||
625 | continue; | ||
631 | case '/': | 626 | case '/': |
632 | if (annotate_browser__search(self, delay_secs)) { | 627 | if (annotate_browser__search(self, delay_secs)) { |
633 | show_help: | 628 | show_help: |
@@ -739,6 +734,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, | |||
739 | .use_navkeypressed = true, | 734 | .use_navkeypressed = true, |
740 | }, | 735 | }, |
741 | .use_offset = true, | 736 | .use_offset = true, |
737 | .jump_arrows = true, | ||
742 | }; | 738 | }; |
743 | int ret = -1; | 739 | int ret = -1; |
744 | 740 | ||