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.c262
1 files changed, 173 insertions, 89 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 6e0ef79be169..4deea6aaf927 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 }
@@ -79,30 +83,30 @@ static int annotate_browser__set_jumps_percent_color(struct annotate_browser *br
79 return ui_browser__set_color(&browser->b, color); 83 return ui_browser__set_color(&browser->b, color);
80} 84}
81 85
82static void annotate_browser__write(struct ui_browser *self, void *entry, int row) 86static void annotate_browser__write(struct ui_browser *browser, void *entry, int row)
83{ 87{
84 struct annotate_browser *ab = container_of(self, struct annotate_browser, b); 88 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
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(browser, 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 || (browser->use_navkeypressed &&
90 !self->navkeypressed))); 94 !browser->navkeypressed)));
91 int width = self->width, printed; 95 int width = browser->width, printed;
92 char bf[256]; 96 char bf[256];
93 97
94 if (dl->offset != -1 && bdl->percent != 0.0) { 98 if (dl->offset != -1 && bdl->percent != 0.0) {
95 ui_browser__set_percent_color(self, bdl->percent, current_entry); 99 ui_browser__set_percent_color(browser, bdl->percent, current_entry);
96 slsmg_printf("%6.2f ", bdl->percent); 100 slsmg_printf("%6.2f ", bdl->percent);
97 } else { 101 } else {
98 ui_browser__set_percent_color(self, 0, current_entry); 102 ui_browser__set_percent_color(browser, 0, current_entry);
99 slsmg_write_nstring(" ", 7); 103 slsmg_write_nstring(" ", 7);
100 } 104 }
101 105
102 SLsmg_write_char(' '); 106 SLsmg_write_char(' ');
103 107
104 /* The scroll bar isn't being used */ 108 /* The scroll bar isn't being used */
105 if (!self->navkeypressed) 109 if (!browser->navkeypressed)
106 width += 1; 110 width += 1;
107 111
108 if (!*dl->line) 112 if (!*dl->line)
@@ -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,
@@ -131,7 +135,7 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
131 prev = annotate_browser__set_jumps_percent_color(ab, bdl->jump_sources, 135 prev = annotate_browser__set_jumps_percent_color(ab, bdl->jump_sources,
132 current_entry); 136 current_entry);
133 slsmg_write_nstring(bf, printed); 137 slsmg_write_nstring(bf, printed);
134 ui_browser__set_color(self, prev); 138 ui_browser__set_color(browser, prev);
135 } 139 }
136 140
137 printed = scnprintf(bf, sizeof(bf), "%*" PRIx64 ": ", 141 printed = scnprintf(bf, sizeof(bf), "%*" PRIx64 ": ",
@@ -143,19 +147,19 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
143 } 147 }
144 148
145 if (change_color) 149 if (change_color)
146 color = ui_browser__set_color(self, HE_COLORSET_ADDR); 150 color = ui_browser__set_color(browser, HE_COLORSET_ADDR);
147 slsmg_write_nstring(bf, printed); 151 slsmg_write_nstring(bf, printed);
148 if (change_color) 152 if (change_color)
149 ui_browser__set_color(self, color); 153 ui_browser__set_color(browser, color);
150 if (dl->ins && dl->ins->ops->scnprintf) { 154 if (dl->ins && dl->ins->ops->scnprintf) {
151 if (ins__is_jump(dl->ins)) { 155 if (ins__is_jump(dl->ins)) {
152 bool fwd = dl->ops.target.offset > (u64)dl->offset; 156 bool fwd = dl->ops.target.offset > (u64)dl->offset;
153 157
154 ui_browser__write_graph(self, fwd ? SLSMG_DARROW_CHAR : 158 ui_browser__write_graph(browser, fwd ? SLSMG_DARROW_CHAR :
155 SLSMG_UARROW_CHAR); 159 SLSMG_UARROW_CHAR);
156 SLsmg_write_char(' '); 160 SLsmg_write_char(' ');
157 } else if (ins__is_call(dl->ins)) { 161 } else if (ins__is_call(dl->ins)) {
158 ui_browser__write_graph(self, SLSMG_RARROW_CHAR); 162 ui_browser__write_graph(browser, SLSMG_RARROW_CHAR);
159 SLsmg_write_char(' '); 163 SLsmg_write_char(' ');
160 } else { 164 } else {
161 slsmg_write_nstring(" ", 2); 165 slsmg_write_nstring(" ", 2);
@@ -164,12 +168,12 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
164 if (strcmp(dl->name, "retq")) { 168 if (strcmp(dl->name, "retq")) {
165 slsmg_write_nstring(" ", 2); 169 slsmg_write_nstring(" ", 2);
166 } else { 170 } else {
167 ui_browser__write_graph(self, SLSMG_LARROW_CHAR); 171 ui_browser__write_graph(browser, SLSMG_LARROW_CHAR);
168 SLsmg_write_char(' '); 172 SLsmg_write_char(' ');
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);
@@ -272,27 +275,27 @@ static void disasm_rb_tree__insert(struct rb_root *root, struct browser_disasm_l
272 rb_insert_color(&bdl->rb_node, root); 275 rb_insert_color(&bdl->rb_node, root);
273} 276}
274 277
275static void annotate_browser__set_top(struct annotate_browser *self, 278static void annotate_browser__set_top(struct annotate_browser *browser,
276 struct disasm_line *pos, u32 idx) 279 struct disasm_line *pos, u32 idx)
277{ 280{
278 unsigned back; 281 unsigned back;
279 282
280 ui_browser__refresh_dimensions(&self->b); 283 ui_browser__refresh_dimensions(&browser->b);
281 back = self->b.height / 2; 284 back = browser->b.height / 2;
282 self->b.top_idx = self->b.index = idx; 285 browser->b.top_idx = browser->b.index = idx;
283 286
284 while (self->b.top_idx != 0 && back != 0) { 287 while (browser->b.top_idx != 0 && back != 0) {
285 pos = list_entry(pos->node.prev, struct disasm_line, node); 288 pos = list_entry(pos->node.prev, struct disasm_line, node);
286 289
287 if (disasm_line__filter(&self->b, &pos->node)) 290 if (disasm_line__filter(&browser->b, &pos->node))
288 continue; 291 continue;
289 292
290 --self->b.top_idx; 293 --browser->b.top_idx;
291 --back; 294 --back;
292 } 295 }
293 296
294 self->b.top = pos; 297 browser->b.top = pos;
295 self->b.navkeypressed = true; 298 browser->b.navkeypressed = true;
296} 299}
297 300
298static void annotate_browser__set_rb_top(struct annotate_browser *browser, 301static void annotate_browser__set_rb_top(struct annotate_browser *browser,
@@ -300,10 +303,14 @@ static void annotate_browser__set_rb_top(struct annotate_browser *browser,
300{ 303{
301 struct browser_disasm_line *bpos; 304 struct browser_disasm_line *bpos;
302 struct disasm_line *pos; 305 struct disasm_line *pos;
306 u32 idx;
303 307
304 bpos = rb_entry(nd, struct browser_disasm_line, rb_node); 308 bpos = rb_entry(nd, struct browser_disasm_line, rb_node);
305 pos = ((struct disasm_line *)bpos) - 1; 309 pos = ((struct disasm_line *)bpos) - 1;
306 annotate_browser__set_top(browser, pos, bpos->idx); 310 idx = bpos->idx;
311 if (annotate_browser__opts.hide_src_code)
312 idx = bpos->idx_asm;
313 annotate_browser__set_top(browser, pos, idx);
307 browser->curr_hot = nd; 314 browser->curr_hot = nd;
308} 315}
309 316
@@ -343,12 +350,12 @@ static bool annotate_browser__toggle_source(struct annotate_browser *browser)
343 dl = list_entry(browser->b.top, struct disasm_line, node); 350 dl = list_entry(browser->b.top, struct disasm_line, node);
344 bdl = disasm_line__browser(dl); 351 bdl = disasm_line__browser(dl);
345 352
346 if (browser->hide_src_code) { 353 if (annotate_browser__opts.hide_src_code) {
347 if (bdl->idx_asm < offset) 354 if (bdl->idx_asm < offset)
348 offset = bdl->idx; 355 offset = bdl->idx;
349 356
350 browser->b.nr_entries = browser->nr_entries; 357 browser->b.nr_entries = browser->nr_entries;
351 browser->hide_src_code = false; 358 annotate_browser__opts.hide_src_code = false;
352 browser->b.seek(&browser->b, -offset, SEEK_CUR); 359 browser->b.seek(&browser->b, -offset, SEEK_CUR);
353 browser->b.top_idx = bdl->idx - offset; 360 browser->b.top_idx = bdl->idx - offset;
354 browser->b.index = bdl->idx; 361 browser->b.index = bdl->idx;
@@ -363,7 +370,7 @@ static bool annotate_browser__toggle_source(struct annotate_browser *browser)
363 offset = bdl->idx_asm; 370 offset = bdl->idx_asm;
364 371
365 browser->b.nr_entries = browser->nr_asm_entries; 372 browser->b.nr_entries = browser->nr_asm_entries;
366 browser->hide_src_code = true; 373 annotate_browser__opts.hide_src_code = true;
367 browser->b.seek(&browser->b, -offset, SEEK_CUR); 374 browser->b.seek(&browser->b, -offset, SEEK_CUR);
368 browser->b.top_idx = bdl->idx_asm - offset; 375 browser->b.top_idx = bdl->idx_asm - offset;
369 browser->b.index = bdl->idx_asm; 376 browser->b.index = bdl->idx_asm;
@@ -372,6 +379,12 @@ static bool annotate_browser__toggle_source(struct annotate_browser *browser)
372 return true; 379 return true;
373} 380}
374 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
375static bool annotate_browser__callq(struct annotate_browser *browser, 388static bool annotate_browser__callq(struct annotate_browser *browser,
376 int evidx, void (*timer)(void *arg), 389 int evidx, void (*timer)(void *arg),
377 void *arg, int delay_secs) 390 void *arg, int delay_secs)
@@ -574,33 +587,46 @@ bool annotate_browser__continue_search_reverse(struct annotate_browser *browser,
574 return __annotate_browser__search_reverse(browser); 587 return __annotate_browser__search_reverse(browser);
575} 588}
576 589
577static int annotate_browser__run(struct annotate_browser *self, int evidx, 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
603static int annotate_browser__run(struct annotate_browser *browser, int evidx,
578 void(*timer)(void *arg), 604 void(*timer)(void *arg),
579 void *arg, int delay_secs) 605 void *arg, int delay_secs)
580{ 606{
581 struct rb_node *nd = NULL; 607 struct rb_node *nd = NULL;
582 struct map_symbol *ms = self->b.priv; 608 struct map_symbol *ms = browser->b.priv;
583 struct symbol *sym = ms->sym; 609 struct symbol *sym = ms->sym;
584 const char *help = "Press 'h' for help on key bindings"; 610 const char *help = "Press 'h' for help on key bindings";
585 int key; 611 int key;
586 612
587 if (ui_browser__show(&self->b, sym->name, help) < 0) 613 if (ui_browser__show(&browser->b, sym->name, help) < 0)
588 return -1; 614 return -1;
589 615
590 annotate_browser__calc_percent(self, evidx); 616 annotate_browser__calc_percent(browser, evidx);
591 617
592 if (self->curr_hot) { 618 if (browser->curr_hot) {
593 annotate_browser__set_rb_top(self, self->curr_hot); 619 annotate_browser__set_rb_top(browser, browser->curr_hot);
594 self->b.navkeypressed = false; 620 browser->b.navkeypressed = false;
595 } 621 }
596 622
597 nd = self->curr_hot; 623 nd = browser->curr_hot;
598 624
599 while (1) { 625 while (1) {
600 key = ui_browser__run(&self->b, delay_secs); 626 key = ui_browser__run(&browser->b, delay_secs);
601 627
602 if (delay_secs != 0) { 628 if (delay_secs != 0) {
603 annotate_browser__calc_percent(self, evidx); 629 annotate_browser__calc_percent(browser, evidx);
604 /* 630 /*
605 * Current line focus got out of the list of most active 631 * Current line focus got out of the list of most active
606 * lines, NULL it so that if TAB|UNTAB is pressed, we 632 * lines, NULL it so that if TAB|UNTAB is pressed, we
@@ -622,21 +648,21 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx,
622 if (nd != NULL) { 648 if (nd != NULL) {
623 nd = rb_prev(nd); 649 nd = rb_prev(nd);
624 if (nd == NULL) 650 if (nd == NULL)
625 nd = rb_last(&self->entries); 651 nd = rb_last(&browser->entries);
626 } else 652 } else
627 nd = self->curr_hot; 653 nd = browser->curr_hot;
628 break; 654 break;
629 case K_UNTAB: 655 case K_UNTAB:
630 if (nd != NULL) 656 if (nd != NULL)
631 nd = rb_next(nd); 657 nd = rb_next(nd);
632 if (nd == NULL) 658 if (nd == NULL)
633 nd = rb_first(&self->entries); 659 nd = rb_first(&browser->entries);
634 else 660 else
635 nd = self->curr_hot; 661 nd = browser->curr_hot;
636 break; 662 break;
637 case K_F1: 663 case K_F1:
638 case 'h': 664 case 'h':
639 ui_browser__help_window(&self->b, 665 ui_browser__help_window(&browser->b,
640 "UP/DOWN/PGUP\n" 666 "UP/DOWN/PGUP\n"
641 "PGDN/SPACE Navigate\n" 667 "PGDN/SPACE Navigate\n"
642 "q/ESC/CTRL+C Exit\n\n" 668 "q/ESC/CTRL+C Exit\n\n"
@@ -652,57 +678,62 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx,
652 "? Search previous string\n"); 678 "? Search previous string\n");
653 continue; 679 continue;
654 case 'H': 680 case 'H':
655 nd = self->curr_hot; 681 nd = browser->curr_hot;
656 break; 682 break;
657 case 's': 683 case 's':
658 if (annotate_browser__toggle_source(self)) 684 if (annotate_browser__toggle_source(browser))
659 ui_helpline__puts(help); 685 ui_helpline__puts(help);
660 continue; 686 continue;
661 case 'o': 687 case 'o':
662 self->use_offset = !self->use_offset; 688 annotate_browser__opts.use_offset = !annotate_browser__opts.use_offset;
663 if (self->use_offset) 689 annotate_browser__update_addr_width(browser);
664 self->target_width = self->min_addr_width;
665 else
666 self->target_width = self->max_addr_width;
667update_addr_width:
668 self->addr_width = self->target_width;
669 if (self->show_nr_jumps)
670 self->addr_width += self->jumps_width + 1;
671 continue; 690 continue;
672 case 'j': 691 case 'j':
673 self->jump_arrows = !self->jump_arrows; 692 annotate_browser__opts.jump_arrows = !annotate_browser__opts.jump_arrows;
674 continue; 693 continue;
675 case 'J': 694 case 'J':
676 self->show_nr_jumps = !self->show_nr_jumps; 695 annotate_browser__opts.show_nr_jumps = !annotate_browser__opts.show_nr_jumps;
677 goto update_addr_width; 696 annotate_browser__update_addr_width(browser);
697 continue;
678 case '/': 698 case '/':
679 if (annotate_browser__search(self, delay_secs)) { 699 if (annotate_browser__search(browser, delay_secs)) {
680show_help: 700show_help:
681 ui_helpline__puts(help); 701 ui_helpline__puts(help);
682 } 702 }
683 continue; 703 continue;
684 case 'n': 704 case 'n':
685 if (self->searching_backwards ? 705 if (browser->searching_backwards ?
686 annotate_browser__continue_search_reverse(self, delay_secs) : 706 annotate_browser__continue_search_reverse(browser, delay_secs) :
687 annotate_browser__continue_search(self, delay_secs)) 707 annotate_browser__continue_search(browser, delay_secs))
688 goto show_help; 708 goto show_help;
689 continue; 709 continue;
690 case '?': 710 case '?':
691 if (annotate_browser__search_reverse(self, delay_secs)) 711 if (annotate_browser__search_reverse(browser, delay_secs))
692 goto show_help; 712 goto show_help;
693 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++, browser->b.nr_entries,
719 browser->b.height,
720 browser->b.index,
721 browser->b.top_idx,
722 browser->nr_asm_entries);
723 }
724 continue;
694 case K_ENTER: 725 case K_ENTER:
695 case K_RIGHT: 726 case K_RIGHT:
696 if (self->selection == NULL) 727 if (browser->selection == NULL)
697 ui_helpline__puts("Huh? No selection. Report to linux-kernel@vger.kernel.org"); 728 ui_helpline__puts("Huh? No selection. Report to linux-kernel@vger.kernel.org");
698 else if (self->selection->offset == -1) 729 else if (browser->selection->offset == -1)
699 ui_helpline__puts("Actions are only available for assembly lines."); 730 ui_helpline__puts("Actions are only available for assembly lines.");
700 else if (!self->selection->ins) { 731 else if (!browser->selection->ins) {
701 if (strcmp(self->selection->name, "retq")) 732 if (strcmp(browser->selection->name, "retq"))
702 goto show_sup_ins; 733 goto show_sup_ins;
703 goto out; 734 goto out;
704 } else if (!(annotate_browser__jump(self) || 735 } else if (!(annotate_browser__jump(browser) ||
705 annotate_browser__callq(self, evidx, timer, arg, delay_secs))) { 736 annotate_browser__callq(browser, evidx, timer, arg, delay_secs))) {
706show_sup_ins: 737show_sup_ins:
707 ui_helpline__puts("Actions are only available for 'callq', 'retq' & jump instructions."); 738 ui_helpline__puts("Actions are only available for 'callq', 'retq' & jump instructions.");
708 } 739 }
@@ -717,10 +748,10 @@ show_sup_ins:
717 } 748 }
718 749
719 if (nd != NULL) 750 if (nd != NULL)
720 annotate_browser__set_rb_top(self, nd); 751 annotate_browser__set_rb_top(browser, nd);
721 } 752 }
722out: 753out:
723 ui_browser__hide(&self->b); 754 ui_browser__hide(&browser->b);
724 return key; 755 return key;
725} 756}
726 757
@@ -797,8 +828,6 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
797 .priv = &ms, 828 .priv = &ms,
798 .use_navkeypressed = true, 829 .use_navkeypressed = true,
799 }, 830 },
800 .use_offset = true,
801 .jump_arrows = true,
802 }; 831 };
803 int ret = -1; 832 int ret = -1;
804 833
@@ -855,6 +884,12 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
855 browser.b.nr_entries = browser.nr_entries; 884 browser.b.nr_entries = browser.nr_entries;
856 browser.b.entries = &notes->src->source, 885 browser.b.entries = &notes->src->source,
857 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
858 ret = annotate_browser__run(&browser, evidx, timer, arg, delay_secs); 893 ret = annotate_browser__run(&browser, evidx, timer, arg, delay_secs);
859 list_for_each_entry_safe(pos, n, &notes->src->source, node) { 894 list_for_each_entry_safe(pos, n, &notes->src->source, node) {
860 list_del(&pos->node); 895 list_del(&pos->node);
@@ -865,3 +900,52 @@ out_free_offsets:
865 free(browser.offsets); 900 free(browser.offsets);
866 return ret; 901 return ret;
867} 902}
903
904#define ANNOTATE_CFG(n) \
905 { .name = #n, .value = &annotate_browser__opts.n, }
906
907/*
908 * Keep the entries sorted, they are bsearch'ed
909 */
910static struct annotate__config {
911 const char *name;
912 bool *value;
913} annotate__configs[] = {
914 ANNOTATE_CFG(hide_src_code),
915 ANNOTATE_CFG(jump_arrows),
916 ANNOTATE_CFG(show_nr_jumps),
917 ANNOTATE_CFG(use_offset),
918};
919
920#undef ANNOTATE_CFG
921
922static int annotate_config__cmp(const void *name, const void *cfgp)
923{
924 const struct annotate__config *cfg = cfgp;
925
926 return strcmp(name, cfg->name);
927}
928
929static int annotate__config(const char *var, const char *value, void *data __used)
930{
931 struct annotate__config *cfg;
932 const char *name;
933
934 if (prefixcmp(var, "annotate.") != 0)
935 return 0;
936
937 name = var + 9;
938 cfg = bsearch(name, annotate__configs, ARRAY_SIZE(annotate__configs),
939 sizeof(struct annotate__config), annotate_config__cmp);
940
941 if (cfg == NULL)
942 return -1;
943
944 *cfg->value = perf_config_bool(name, value);
945 return 0;
946}
947
948void annotate_browser__init(void)
949{
950 perf_config(annotate__config, NULL);
951}