aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-05-29 20:24:05 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-05-29 20:24:05 -0400
commite9823b21bab7ff0c39e14a7a970a40fad74ce778 (patch)
tree98687e9352b0975bac871654e2846a2eb3921ca7 /tools/perf/ui
parenta44b45f236dd1c1a8caccf9a078adf2941a20267 (diff)
perf annotate browser: Make feature toggles global
So that when navigating to another function from a call site or when going to another annotation browser thru the main report/top browser the options (hide source code, jump arrows, jumpy lines, etc) remains the last ones selected. 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-0h0tah1zj59p01581snjufne@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.c101
1 files changed, 66 insertions, 35 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index aaf36ce0b6fe..02afa036dfa9 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -19,6 +19,16 @@ struct browser_disasm_line {
19 int jump_sources; 19 int jump_sources;
20}; 20};
21 21
22static struct annotate_browser_opt {
23 bool hide_src_code,
24 use_offset,
25 jump_arrows,
26 show_nr_jumps;
27} annotate_browser__opts = {
28 .use_offset = true,
29 .jump_arrows = true,
30};
31
22struct annotate_browser { 32struct annotate_browser {
23 struct ui_browser b; 33 struct ui_browser b;
24 struct rb_root entries; 34 struct rb_root entries;
@@ -30,10 +40,6 @@ struct annotate_browser {
30 int nr_entries; 40 int nr_entries;
31 int max_jump_sources; 41 int max_jump_sources;
32 int nr_jumps; 42 int nr_jumps;
33 bool hide_src_code;
34 bool use_offset;
35 bool jump_arrows;
36 bool show_nr_jumps;
37 bool searching_backwards; 43 bool searching_backwards;
38 u8 addr_width; 44 u8 addr_width;
39 u8 jumps_width; 45 u8 jumps_width;
@@ -48,11 +54,9 @@ static inline struct browser_disasm_line *disasm_line__browser(struct disasm_lin
48 return (struct browser_disasm_line *)(dl + 1); 54 return (struct browser_disasm_line *)(dl + 1);
49} 55}
50 56
51static bool disasm_line__filter(struct ui_browser *browser, void *entry) 57static bool disasm_line__filter(struct ui_browser *browser __used, void *entry)
52{ 58{
53 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); 59 if (annotate_browser__opts.hide_src_code) {
54
55 if (ab->hide_src_code) {
56 struct disasm_line *dl = list_entry(entry, struct disasm_line, node); 60 struct disasm_line *dl = list_entry(entry, struct disasm_line, node);
57 return dl->offset == -1; 61 return dl->offset == -1;
58 } 62 }
@@ -85,7 +89,7 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
85 struct disasm_line *dl = list_entry(entry, struct disasm_line, node); 89 struct disasm_line *dl = list_entry(entry, struct disasm_line, node);
86 struct browser_disasm_line *bdl = disasm_line__browser(dl); 90 struct browser_disasm_line *bdl = disasm_line__browser(dl);
87 bool current_entry = ui_browser__is_current_entry(self, row); 91 bool current_entry = ui_browser__is_current_entry(self, row);
88 bool change_color = (!ab->hide_src_code && 92 bool change_color = (!annotate_browser__opts.hide_src_code &&
89 (!current_entry || (self->use_navkeypressed && 93 (!current_entry || (self->use_navkeypressed &&
90 !self->navkeypressed))); 94 !self->navkeypressed)));
91 int width = self->width, printed; 95 int width = self->width, printed;
@@ -116,14 +120,14 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
116 u64 addr = dl->offset; 120 u64 addr = dl->offset;
117 int color = -1; 121 int color = -1;
118 122
119 if (!ab->use_offset) 123 if (!annotate_browser__opts.use_offset)
120 addr += ab->start; 124 addr += ab->start;
121 125
122 if (!ab->use_offset) { 126 if (!annotate_browser__opts.use_offset) {
123 printed = scnprintf(bf, sizeof(bf), "%" PRIx64 ": ", addr); 127 printed = scnprintf(bf, sizeof(bf), "%" PRIx64 ": ", addr);
124 } else { 128 } else {
125 if (bdl->jump_sources) { 129 if (bdl->jump_sources) {
126 if (ab->show_nr_jumps) { 130 if (annotate_browser__opts.show_nr_jumps) {
127 int prev; 131 int prev;
128 printed = scnprintf(bf, sizeof(bf), "%*d ", 132 printed = scnprintf(bf, sizeof(bf), "%*d ",
129 ab->jumps_width, 133 ab->jumps_width,
@@ -169,7 +173,7 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
169 } 173 }
170 } 174 }
171 175
172 disasm_line__scnprintf(dl, bf, sizeof(bf), !ab->use_offset); 176 disasm_line__scnprintf(dl, bf, sizeof(bf), !annotate_browser__opts.use_offset);
173 slsmg_write_nstring(bf, width - 10 - printed); 177 slsmg_write_nstring(bf, width - 10 - printed);
174 } 178 }
175 179
@@ -184,7 +188,7 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser)
184 struct browser_disasm_line *btarget, *bcursor; 188 struct browser_disasm_line *btarget, *bcursor;
185 unsigned int from, to; 189 unsigned int from, to;
186 190
187 if (!cursor->ins || !ins__is_jump(cursor->ins) || 191 if (!cursor || !cursor->ins || !ins__is_jump(cursor->ins) ||
188 !disasm_line__has_offset(cursor)) 192 !disasm_line__has_offset(cursor))
189 return; 193 return;
190 194
@@ -195,7 +199,7 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser)
195 bcursor = disasm_line__browser(cursor); 199 bcursor = disasm_line__browser(cursor);
196 btarget = disasm_line__browser(target); 200 btarget = disasm_line__browser(target);
197 201
198 if (ab->hide_src_code) { 202 if (annotate_browser__opts.hide_src_code) {
199 from = bcursor->idx_asm; 203 from = bcursor->idx_asm;
200 to = btarget->idx_asm; 204 to = btarget->idx_asm;
201 } else { 205 } else {
@@ -209,10 +213,9 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser)
209 213
210static unsigned int annotate_browser__refresh(struct ui_browser *browser) 214static unsigned int annotate_browser__refresh(struct ui_browser *browser)
211{ 215{
212 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
213 int ret = ui_browser__list_head_refresh(browser); 216 int ret = ui_browser__list_head_refresh(browser);
214 217
215 if (ab->jump_arrows) 218 if (annotate_browser__opts.jump_arrows)
216 annotate_browser__draw_current_jump(browser); 219 annotate_browser__draw_current_jump(browser);
217 220
218 ui_browser__set_color(browser, HE_COLORSET_NORMAL); 221 ui_browser__set_color(browser, HE_COLORSET_NORMAL);
@@ -305,7 +308,7 @@ static void annotate_browser__set_rb_top(struct annotate_browser *browser,
305 bpos = rb_entry(nd, struct browser_disasm_line, rb_node); 308 bpos = rb_entry(nd, struct browser_disasm_line, rb_node);
306 pos = ((struct disasm_line *)bpos) - 1; 309 pos = ((struct disasm_line *)bpos) - 1;
307 idx = bpos->idx; 310 idx = bpos->idx;
308 if (browser->hide_src_code) 311 if (annotate_browser__opts.hide_src_code)
309 idx = bpos->idx_asm; 312 idx = bpos->idx_asm;
310 annotate_browser__set_top(browser, pos, idx); 313 annotate_browser__set_top(browser, pos, idx);
311 browser->curr_hot = nd; 314 browser->curr_hot = nd;
@@ -347,12 +350,12 @@ static bool annotate_browser__toggle_source(struct annotate_browser *browser)
347 dl = list_entry(browser->b.top, struct disasm_line, node); 350 dl = list_entry(browser->b.top, struct disasm_line, node);
348 bdl = disasm_line__browser(dl); 351 bdl = disasm_line__browser(dl);
349 352
350 if (browser->hide_src_code) { 353 if (annotate_browser__opts.hide_src_code) {
351 if (bdl->idx_asm < offset) 354 if (bdl->idx_asm < offset)
352 offset = bdl->idx; 355 offset = bdl->idx;
353 356
354 browser->b.nr_entries = browser->nr_entries; 357 browser->b.nr_entries = browser->nr_entries;
355 browser->hide_src_code = false; 358 annotate_browser__opts.hide_src_code = false;
356 browser->b.seek(&browser->b, -offset, SEEK_CUR); 359 browser->b.seek(&browser->b, -offset, SEEK_CUR);
357 browser->b.top_idx = bdl->idx - offset; 360 browser->b.top_idx = bdl->idx - offset;
358 browser->b.index = bdl->idx; 361 browser->b.index = bdl->idx;
@@ -367,7 +370,7 @@ static bool annotate_browser__toggle_source(struct annotate_browser *browser)
367 offset = bdl->idx_asm; 370 offset = bdl->idx_asm;
368 371
369 browser->b.nr_entries = browser->nr_asm_entries; 372 browser->b.nr_entries = browser->nr_asm_entries;
370 browser->hide_src_code = true; 373 annotate_browser__opts.hide_src_code = true;
371 browser->b.seek(&browser->b, -offset, SEEK_CUR); 374 browser->b.seek(&browser->b, -offset, SEEK_CUR);
372 browser->b.top_idx = bdl->idx_asm - offset; 375 browser->b.top_idx = bdl->idx_asm - offset;
373 browser->b.index = bdl->idx_asm; 376 browser->b.index = bdl->idx_asm;
@@ -376,6 +379,12 @@ static bool annotate_browser__toggle_source(struct annotate_browser *browser)
376 return true; 379 return true;
377} 380}
378 381
382static void annotate_browser__init_asm_mode(struct annotate_browser *browser)
383{
384 ui_browser__reset_index(&browser->b);
385 browser->b.nr_entries = browser->nr_asm_entries;
386}
387
379static bool annotate_browser__callq(struct annotate_browser *browser, 388static bool annotate_browser__callq(struct annotate_browser *browser,
380 int evidx, void (*timer)(void *arg), 389 int evidx, void (*timer)(void *arg),
381 void *arg, int delay_secs) 390 void *arg, int delay_secs)
@@ -578,6 +587,19 @@ bool annotate_browser__continue_search_reverse(struct annotate_browser *browser,
578 return __annotate_browser__search_reverse(browser); 587 return __annotate_browser__search_reverse(browser);
579} 588}
580 589
590static void annotate_browser__update_addr_width(struct annotate_browser *browser)
591{
592 if (annotate_browser__opts.use_offset)
593 browser->target_width = browser->min_addr_width;
594 else
595 browser->target_width = browser->max_addr_width;
596
597 browser->addr_width = browser->target_width;
598
599 if (annotate_browser__opts.show_nr_jumps)
600 browser->addr_width += browser->jumps_width + 1;
601}
602
581static int annotate_browser__run(struct annotate_browser *self, int evidx, 603static int annotate_browser__run(struct annotate_browser *self, int evidx,
582 void(*timer)(void *arg), 604 void(*timer)(void *arg),
583 void *arg, int delay_secs) 605 void *arg, int delay_secs)
@@ -663,22 +685,16 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx,
663 ui_helpline__puts(help); 685 ui_helpline__puts(help);
664 continue; 686 continue;
665 case 'o': 687 case 'o':
666 self->use_offset = !self->use_offset; 688 annotate_browser__opts.use_offset = !annotate_browser__opts.use_offset;
667 if (self->use_offset) 689 annotate_browser__update_addr_width(self);
668 self->target_width = self->min_addr_width;
669 else
670 self->target_width = self->max_addr_width;
671update_addr_width:
672 self->addr_width = self->target_width;
673 if (self->show_nr_jumps)
674 self->addr_width += self->jumps_width + 1;
675 continue; 690 continue;
676 case 'j': 691 case 'j':
677 self->jump_arrows = !self->jump_arrows; 692 annotate_browser__opts.jump_arrows = !annotate_browser__opts.jump_arrows;
678 continue; 693 continue;
679 case 'J': 694 case 'J':
680 self->show_nr_jumps = !self->show_nr_jumps; 695 annotate_browser__opts.show_nr_jumps = !annotate_browser__opts.show_nr_jumps;
681 goto update_addr_width; 696 annotate_browser__update_addr_width(self);
697 continue;
682 case '/': 698 case '/':
683 if (annotate_browser__search(self, delay_secs)) { 699 if (annotate_browser__search(self, delay_secs)) {
684show_help: 700show_help:
@@ -695,6 +711,17 @@ show_help:
695 if (annotate_browser__search_reverse(self, delay_secs)) 711 if (annotate_browser__search_reverse(self, delay_secs))
696 goto show_help; 712 goto show_help;
697 continue; 713 continue;
714 case 'D': {
715 static int seq;
716 ui_helpline__pop();
717 ui_helpline__fpush("%d: nr_ent=%d, height=%d, idx=%d, top_idx=%d, nr_asm_entries=%d",
718 seq++, self->b.nr_entries,
719 self->b.height,
720 self->b.index,
721 self->b.top_idx,
722 self->nr_asm_entries);
723 }
724 continue;
698 case K_ENTER: 725 case K_ENTER:
699 case K_RIGHT: 726 case K_RIGHT:
700 if (self->selection == NULL) 727 if (self->selection == NULL)
@@ -801,8 +828,6 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
801 .priv = &ms, 828 .priv = &ms,
802 .use_navkeypressed = true, 829 .use_navkeypressed = true,
803 }, 830 },
804 .use_offset = true,
805 .jump_arrows = true,
806 }; 831 };
807 int ret = -1; 832 int ret = -1;
808 833
@@ -859,6 +884,12 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
859 browser.b.nr_entries = browser.nr_entries; 884 browser.b.nr_entries = browser.nr_entries;
860 browser.b.entries = &notes->src->source, 885 browser.b.entries = &notes->src->source,
861 browser.b.width += 18; /* Percentage */ 886 browser.b.width += 18; /* Percentage */
887
888 if (annotate_browser__opts.hide_src_code)
889 annotate_browser__init_asm_mode(&browser);
890
891 annotate_browser__update_addr_width(&browser);
892
862 ret = annotate_browser__run(&browser, evidx, timer, arg, delay_secs); 893 ret = annotate_browser__run(&browser, evidx, timer, arg, delay_secs);
863 list_for_each_entry_safe(pos, n, &notes->src->source, node) { 894 list_for_each_entry_safe(pos, n, &notes->src->source, node) {
864 list_del(&pos->node); 895 list_del(&pos->node);