aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui/browsers/annotate.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-05-29 21:42:18 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-05-29 21:42:18 -0400
commit05e8b0804ec423a440882e7adecb36e7ac43e56f (patch)
tree1cefdeac3112e790afc275d9e57cd56674084fa4 /tools/perf/ui/browsers/annotate.c
parentc323cf0400c1fed853738e6d81e83c6ac7ff5105 (diff)
perf ui browser: Stop using 'self'
Stop using this python/OOP convention, doesn't really helps. Will do more from time to time till we get it cleaned up in all of /perf. Suggested-by: Thomas Gleixner <tglx@linutronix.de> 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-5dyxyb8o0gf4yndk27kafbd1@git.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.c122
1 files changed, 61 insertions, 61 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 77b5b1280834..4deea6aaf927 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -83,30 +83,30 @@ static int annotate_browser__set_jumps_percent_color(struct annotate_browser *br
83 return ui_browser__set_color(&browser->b, color); 83 return ui_browser__set_color(&browser->b, color);
84} 84}
85 85
86static 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)
87{ 87{
88 struct annotate_browser *ab = container_of(self, struct annotate_browser, b); 88 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
89 struct disasm_line *dl = list_entry(entry, struct disasm_line, node); 89 struct disasm_line *dl = list_entry(entry, struct disasm_line, node);
90 struct browser_disasm_line *bdl = disasm_line__browser(dl); 90 struct browser_disasm_line *bdl = disasm_line__browser(dl);
91 bool current_entry = ui_browser__is_current_entry(self, row); 91 bool current_entry = ui_browser__is_current_entry(browser, row);
92 bool change_color = (!annotate_browser__opts.hide_src_code && 92 bool change_color = (!annotate_browser__opts.hide_src_code &&
93 (!current_entry || (self->use_navkeypressed && 93 (!current_entry || (browser->use_navkeypressed &&
94 !self->navkeypressed))); 94 !browser->navkeypressed)));
95 int width = self->width, printed; 95 int width = browser->width, printed;
96 char bf[256]; 96 char bf[256];
97 97
98 if (dl->offset != -1 && bdl->percent != 0.0) { 98 if (dl->offset != -1 && bdl->percent != 0.0) {
99 ui_browser__set_percent_color(self, bdl->percent, current_entry); 99 ui_browser__set_percent_color(browser, bdl->percent, current_entry);
100 slsmg_printf("%6.2f ", bdl->percent); 100 slsmg_printf("%6.2f ", bdl->percent);
101 } else { 101 } else {
102 ui_browser__set_percent_color(self, 0, current_entry); 102 ui_browser__set_percent_color(browser, 0, current_entry);
103 slsmg_write_nstring(" ", 7); 103 slsmg_write_nstring(" ", 7);
104 } 104 }
105 105
106 SLsmg_write_char(' '); 106 SLsmg_write_char(' ');
107 107
108 /* The scroll bar isn't being used */ 108 /* The scroll bar isn't being used */
109 if (!self->navkeypressed) 109 if (!browser->navkeypressed)
110 width += 1; 110 width += 1;
111 111
112 if (!*dl->line) 112 if (!*dl->line)
@@ -135,7 +135,7 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
135 prev = annotate_browser__set_jumps_percent_color(ab, bdl->jump_sources, 135 prev = annotate_browser__set_jumps_percent_color(ab, bdl->jump_sources,
136 current_entry); 136 current_entry);
137 slsmg_write_nstring(bf, printed); 137 slsmg_write_nstring(bf, printed);
138 ui_browser__set_color(self, prev); 138 ui_browser__set_color(browser, prev);
139 } 139 }
140 140
141 printed = scnprintf(bf, sizeof(bf), "%*" PRIx64 ": ", 141 printed = scnprintf(bf, sizeof(bf), "%*" PRIx64 ": ",
@@ -147,19 +147,19 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
147 } 147 }
148 148
149 if (change_color) 149 if (change_color)
150 color = ui_browser__set_color(self, HE_COLORSET_ADDR); 150 color = ui_browser__set_color(browser, HE_COLORSET_ADDR);
151 slsmg_write_nstring(bf, printed); 151 slsmg_write_nstring(bf, printed);
152 if (change_color) 152 if (change_color)
153 ui_browser__set_color(self, color); 153 ui_browser__set_color(browser, color);
154 if (dl->ins && dl->ins->ops->scnprintf) { 154 if (dl->ins && dl->ins->ops->scnprintf) {
155 if (ins__is_jump(dl->ins)) { 155 if (ins__is_jump(dl->ins)) {
156 bool fwd = dl->ops.target.offset > (u64)dl->offset; 156 bool fwd = dl->ops.target.offset > (u64)dl->offset;
157 157
158 ui_browser__write_graph(self, fwd ? SLSMG_DARROW_CHAR : 158 ui_browser__write_graph(browser, fwd ? SLSMG_DARROW_CHAR :
159 SLSMG_UARROW_CHAR); 159 SLSMG_UARROW_CHAR);
160 SLsmg_write_char(' '); 160 SLsmg_write_char(' ');
161 } else if (ins__is_call(dl->ins)) { 161 } else if (ins__is_call(dl->ins)) {
162 ui_browser__write_graph(self, SLSMG_RARROW_CHAR); 162 ui_browser__write_graph(browser, SLSMG_RARROW_CHAR);
163 SLsmg_write_char(' '); 163 SLsmg_write_char(' ');
164 } else { 164 } else {
165 slsmg_write_nstring(" ", 2); 165 slsmg_write_nstring(" ", 2);
@@ -168,7 +168,7 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
168 if (strcmp(dl->name, "retq")) { 168 if (strcmp(dl->name, "retq")) {
169 slsmg_write_nstring(" ", 2); 169 slsmg_write_nstring(" ", 2);
170 } else { 170 } else {
171 ui_browser__write_graph(self, SLSMG_LARROW_CHAR); 171 ui_browser__write_graph(browser, SLSMG_LARROW_CHAR);
172 SLsmg_write_char(' '); 172 SLsmg_write_char(' ');
173 } 173 }
174 } 174 }
@@ -275,27 +275,27 @@ static void disasm_rb_tree__insert(struct rb_root *root, struct browser_disasm_l
275 rb_insert_color(&bdl->rb_node, root); 275 rb_insert_color(&bdl->rb_node, root);
276} 276}
277 277
278static void annotate_browser__set_top(struct annotate_browser *self, 278static void annotate_browser__set_top(struct annotate_browser *browser,
279 struct disasm_line *pos, u32 idx) 279 struct disasm_line *pos, u32 idx)
280{ 280{
281 unsigned back; 281 unsigned back;
282 282
283 ui_browser__refresh_dimensions(&self->b); 283 ui_browser__refresh_dimensions(&browser->b);
284 back = self->b.height / 2; 284 back = browser->b.height / 2;
285 self->b.top_idx = self->b.index = idx; 285 browser->b.top_idx = browser->b.index = idx;
286 286
287 while (self->b.top_idx != 0 && back != 0) { 287 while (browser->b.top_idx != 0 && back != 0) {
288 pos = list_entry(pos->node.prev, struct disasm_line, node); 288 pos = list_entry(pos->node.prev, struct disasm_line, node);
289 289
290 if (disasm_line__filter(&self->b, &pos->node)) 290 if (disasm_line__filter(&browser->b, &pos->node))
291 continue; 291 continue;
292 292
293 --self->b.top_idx; 293 --browser->b.top_idx;
294 --back; 294 --back;
295 } 295 }
296 296
297 self->b.top = pos; 297 browser->b.top = pos;
298 self->b.navkeypressed = true; 298 browser->b.navkeypressed = true;
299} 299}
300 300
301static void annotate_browser__set_rb_top(struct annotate_browser *browser, 301static void annotate_browser__set_rb_top(struct annotate_browser *browser,
@@ -600,33 +600,33 @@ static void annotate_browser__update_addr_width(struct annotate_browser *browser
600 browser->addr_width += browser->jumps_width + 1; 600 browser->addr_width += browser->jumps_width + 1;
601} 601}
602 602
603static int annotate_browser__run(struct annotate_browser *self, int evidx, 603static int annotate_browser__run(struct annotate_browser *browser, int evidx,
604 void(*timer)(void *arg), 604 void(*timer)(void *arg),
605 void *arg, int delay_secs) 605 void *arg, int delay_secs)
606{ 606{
607 struct rb_node *nd = NULL; 607 struct rb_node *nd = NULL;
608 struct map_symbol *ms = self->b.priv; 608 struct map_symbol *ms = browser->b.priv;
609 struct symbol *sym = ms->sym; 609 struct symbol *sym = ms->sym;
610 const char *help = "Press 'h' for help on key bindings"; 610 const char *help = "Press 'h' for help on key bindings";
611 int key; 611 int key;
612 612
613 if (ui_browser__show(&self->b, sym->name, help) < 0) 613 if (ui_browser__show(&browser->b, sym->name, help) < 0)
614 return -1; 614 return -1;
615 615
616 annotate_browser__calc_percent(self, evidx); 616 annotate_browser__calc_percent(browser, evidx);
617 617
618 if (self->curr_hot) { 618 if (browser->curr_hot) {
619 annotate_browser__set_rb_top(self, self->curr_hot); 619 annotate_browser__set_rb_top(browser, browser->curr_hot);
620 self->b.navkeypressed = false; 620 browser->b.navkeypressed = false;
621 } 621 }
622 622
623 nd = self->curr_hot; 623 nd = browser->curr_hot;
624 624
625 while (1) { 625 while (1) {
626 key = ui_browser__run(&self->b, delay_secs); 626 key = ui_browser__run(&browser->b, delay_secs);
627 627
628 if (delay_secs != 0) { 628 if (delay_secs != 0) {
629 annotate_browser__calc_percent(self, evidx); 629 annotate_browser__calc_percent(browser, evidx);
630 /* 630 /*
631 * Current line focus got out of the list of most active 631 * Current line focus got out of the list of most active
632 * lines, NULL it so that if TAB|UNTAB is pressed, we 632 * lines, NULL it so that if TAB|UNTAB is pressed, we
@@ -648,21 +648,21 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx,
648 if (nd != NULL) { 648 if (nd != NULL) {
649 nd = rb_prev(nd); 649 nd = rb_prev(nd);
650 if (nd == NULL) 650 if (nd == NULL)
651 nd = rb_last(&self->entries); 651 nd = rb_last(&browser->entries);
652 } else 652 } else
653 nd = self->curr_hot; 653 nd = browser->curr_hot;
654 break; 654 break;
655 case K_UNTAB: 655 case K_UNTAB:
656 if (nd != NULL) 656 if (nd != NULL)
657 nd = rb_next(nd); 657 nd = rb_next(nd);
658 if (nd == NULL) 658 if (nd == NULL)
659 nd = rb_first(&self->entries); 659 nd = rb_first(&browser->entries);
660 else 660 else
661 nd = self->curr_hot; 661 nd = browser->curr_hot;
662 break; 662 break;
663 case K_F1: 663 case K_F1:
664 case 'h': 664 case 'h':
665 ui_browser__help_window(&self->b, 665 ui_browser__help_window(&browser->b,
666 "UP/DOWN/PGUP\n" 666 "UP/DOWN/PGUP\n"
667 "PGDN/SPACE Navigate\n" 667 "PGDN/SPACE Navigate\n"
668 "q/ESC/CTRL+C Exit\n\n" 668 "q/ESC/CTRL+C Exit\n\n"
@@ -678,62 +678,62 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx,
678 "? Search previous string\n"); 678 "? Search previous string\n");
679 continue; 679 continue;
680 case 'H': 680 case 'H':
681 nd = self->curr_hot; 681 nd = browser->curr_hot;
682 break; 682 break;
683 case 's': 683 case 's':
684 if (annotate_browser__toggle_source(self)) 684 if (annotate_browser__toggle_source(browser))
685 ui_helpline__puts(help); 685 ui_helpline__puts(help);
686 continue; 686 continue;
687 case 'o': 687 case 'o':
688 annotate_browser__opts.use_offset = !annotate_browser__opts.use_offset; 688 annotate_browser__opts.use_offset = !annotate_browser__opts.use_offset;
689 annotate_browser__update_addr_width(self); 689 annotate_browser__update_addr_width(browser);
690 continue; 690 continue;
691 case 'j': 691 case 'j':
692 annotate_browser__opts.jump_arrows = !annotate_browser__opts.jump_arrows; 692 annotate_browser__opts.jump_arrows = !annotate_browser__opts.jump_arrows;
693 continue; 693 continue;
694 case 'J': 694 case 'J':
695 annotate_browser__opts.show_nr_jumps = !annotate_browser__opts.show_nr_jumps; 695 annotate_browser__opts.show_nr_jumps = !annotate_browser__opts.show_nr_jumps;
696 annotate_browser__update_addr_width(self); 696 annotate_browser__update_addr_width(browser);
697 continue; 697 continue;
698 case '/': 698 case '/':
699 if (annotate_browser__search(self, delay_secs)) { 699 if (annotate_browser__search(browser, delay_secs)) {
700show_help: 700show_help:
701 ui_helpline__puts(help); 701 ui_helpline__puts(help);
702 } 702 }
703 continue; 703 continue;
704 case 'n': 704 case 'n':
705 if (self->searching_backwards ? 705 if (browser->searching_backwards ?
706 annotate_browser__continue_search_reverse(self, delay_secs) : 706 annotate_browser__continue_search_reverse(browser, delay_secs) :
707 annotate_browser__continue_search(self, delay_secs)) 707 annotate_browser__continue_search(browser, delay_secs))
708 goto show_help; 708 goto show_help;
709 continue; 709 continue;
710 case '?': 710 case '?':
711 if (annotate_browser__search_reverse(self, delay_secs)) 711 if (annotate_browser__search_reverse(browser, delay_secs))
712 goto show_help; 712 goto show_help;
713 continue; 713 continue;
714 case 'D': { 714 case 'D': {
715 static int seq; 715 static int seq;
716 ui_helpline__pop(); 716 ui_helpline__pop();
717 ui_helpline__fpush("%d: nr_ent=%d, height=%d, idx=%d, top_idx=%d, nr_asm_entries=%d", 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, 718 seq++, browser->b.nr_entries,
719 self->b.height, 719 browser->b.height,
720 self->b.index, 720 browser->b.index,
721 self->b.top_idx, 721 browser->b.top_idx,
722 self->nr_asm_entries); 722 browser->nr_asm_entries);
723 } 723 }
724 continue; 724 continue;
725 case K_ENTER: 725 case K_ENTER:
726 case K_RIGHT: 726 case K_RIGHT:
727 if (self->selection == NULL) 727 if (browser->selection == NULL)
728 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");
729 else if (self->selection->offset == -1) 729 else if (browser->selection->offset == -1)
730 ui_helpline__puts("Actions are only available for assembly lines."); 730 ui_helpline__puts("Actions are only available for assembly lines.");
731 else if (!self->selection->ins) { 731 else if (!browser->selection->ins) {
732 if (strcmp(self->selection->name, "retq")) 732 if (strcmp(browser->selection->name, "retq"))
733 goto show_sup_ins; 733 goto show_sup_ins;
734 goto out; 734 goto out;
735 } else if (!(annotate_browser__jump(self) || 735 } else if (!(annotate_browser__jump(browser) ||
736 annotate_browser__callq(self, evidx, timer, arg, delay_secs))) { 736 annotate_browser__callq(browser, evidx, timer, arg, delay_secs))) {
737show_sup_ins: 737show_sup_ins:
738 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.");
739 } 739 }
@@ -748,10 +748,10 @@ show_sup_ins:
748 } 748 }
749 749
750 if (nd != NULL) 750 if (nd != NULL)
751 annotate_browser__set_rb_top(self, nd); 751 annotate_browser__set_rb_top(browser, nd);
752 } 752 }
753out: 753out:
754 ui_browser__hide(&self->b); 754 ui_browser__hide(&browser->b);
755 return key; 755 return key;
756} 756}
757 757