aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui/browsers/annotate.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2017-11-06 05:56:17 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-11-16 12:49:47 -0500
commit7bcbcd589b15eae849d45540832ba4f9530c778e (patch)
treee2b508aa3875b4d63ea59d2dfd1f633f5882589c /tools/perf/ui/browsers/annotate.c
parentdaf25d4303cbf1795535b6c0b7172ba6f12aa2bd (diff)
perf annotate browser: Change selection to struct annotation_line
Use struct annotation_line as a browser::selection. We want to be able to use the annotate_browser for all sorts of source data, so it needs to be able to work over the generic struct annotation_line. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Andi Kleen <andi@firstfloor.org> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20171106105617.GC20858@krava 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.c63
1 files changed, 34 insertions, 29 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 3691dc8cef4c..657811669a6c 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -47,26 +47,26 @@ static struct annotate_browser_opt {
47struct arch; 47struct arch;
48 48
49struct annotate_browser { 49struct annotate_browser {
50 struct ui_browser b; 50 struct ui_browser b;
51 struct rb_root entries; 51 struct rb_root entries;
52 struct rb_node *curr_hot; 52 struct rb_node *curr_hot;
53 struct disasm_line *selection; 53 struct annotation_line *selection;
54 struct disasm_line **offsets; 54 struct disasm_line **offsets;
55 struct arch *arch; 55 struct arch *arch;
56 int nr_events; 56 int nr_events;
57 u64 start; 57 u64 start;
58 int nr_asm_entries; 58 int nr_asm_entries;
59 int nr_entries; 59 int nr_entries;
60 int max_jump_sources; 60 int max_jump_sources;
61 int nr_jumps; 61 int nr_jumps;
62 bool searching_backwards; 62 bool searching_backwards;
63 bool have_cycles; 63 bool have_cycles;
64 u8 addr_width; 64 u8 addr_width;
65 u8 jumps_width; 65 u8 jumps_width;
66 u8 target_width; 66 u8 target_width;
67 u8 min_addr_width; 67 u8 min_addr_width;
68 u8 max_addr_width; 68 u8 max_addr_width;
69 char search_bf[128]; 69 char search_bf[128];
70}; 70};
71 71
72static inline struct browser_line *browser_line(struct disasm_line *dl) 72static inline struct browser_line *browser_line(struct disasm_line *dl)
@@ -265,7 +265,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
265 } 265 }
266 266
267 if (current_entry) 267 if (current_entry)
268 ab->selection = dl; 268 ab->selection = &dl->al;
269} 269}
270 270
271static bool disasm_line__is_valid_jump(struct disasm_line *dl, struct symbol *sym) 271static bool disasm_line__is_valid_jump(struct disasm_line *dl, struct symbol *sym)
@@ -301,7 +301,8 @@ static bool is_fused(struct annotate_browser *ab, struct disasm_line *cursor)
301static void annotate_browser__draw_current_jump(struct ui_browser *browser) 301static void annotate_browser__draw_current_jump(struct ui_browser *browser)
302{ 302{
303 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); 303 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
304 struct disasm_line *cursor = ab->selection, *target; 304 struct disasm_line *cursor = disasm_line(ab->selection);
305 struct disasm_line *target;
305 struct browser_line *btarget, *bcursor; 306 struct browser_line *btarget, *bcursor;
306 unsigned int from, to; 307 unsigned int from, to;
307 struct map_symbol *ms = ab->b.priv; 308 struct map_symbol *ms = ab->b.priv;
@@ -526,7 +527,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser,
526 struct hist_browser_timer *hbt) 527 struct hist_browser_timer *hbt)
527{ 528{
528 struct map_symbol *ms = browser->b.priv; 529 struct map_symbol *ms = browser->b.priv;
529 struct disasm_line *dl = browser->selection; 530 struct disasm_line *dl = disasm_line(browser->selection);
530 struct annotation *notes; 531 struct annotation *notes;
531 struct addr_map_symbol target = { 532 struct addr_map_symbol target = {
532 .map = ms->map, 533 .map = ms->map,
@@ -584,7 +585,7 @@ struct disasm_line *annotate_browser__find_offset(struct annotate_browser *brows
584 585
585static bool annotate_browser__jump(struct annotate_browser *browser) 586static bool annotate_browser__jump(struct annotate_browser *browser)
586{ 587{
587 struct disasm_line *dl = browser->selection; 588 struct disasm_line *dl = disasm_line(browser->selection);
588 u64 offset; 589 u64 offset;
589 s64 idx; 590 s64 idx;
590 591
@@ -610,7 +611,7 @@ struct disasm_line *annotate_browser__find_string(struct annotate_browser *brows
610 struct map_symbol *ms = browser->b.priv; 611 struct map_symbol *ms = browser->b.priv;
611 struct symbol *sym = ms->sym; 612 struct symbol *sym = ms->sym;
612 struct annotation *notes = symbol__annotation(sym); 613 struct annotation *notes = symbol__annotation(sym);
613 struct disasm_line *pos = browser->selection; 614 struct disasm_line *pos = disasm_line(browser->selection);
614 615
615 *idx = browser->b.index; 616 *idx = browser->b.index;
616 list_for_each_entry_continue(pos, &notes->src->source, al.node) { 617 list_for_each_entry_continue(pos, &notes->src->source, al.node) {
@@ -649,7 +650,7 @@ struct disasm_line *annotate_browser__find_string_reverse(struct annotate_browse
649 struct map_symbol *ms = browser->b.priv; 650 struct map_symbol *ms = browser->b.priv;
650 struct symbol *sym = ms->sym; 651 struct symbol *sym = ms->sym;
651 struct annotation *notes = symbol__annotation(sym); 652 struct annotation *notes = symbol__annotation(sym);
652 struct disasm_line *pos = browser->selection; 653 struct disasm_line *pos = disasm_line(browser->selection);
653 654
654 *idx = browser->b.index; 655 *idx = browser->b.index;
655 list_for_each_entry_continue_reverse(pos, &notes->src->source, al.node) { 656 list_for_each_entry_continue_reverse(pos, &notes->src->source, al.node) {
@@ -882,13 +883,16 @@ show_help:
882 continue; 883 continue;
883 case K_ENTER: 884 case K_ENTER:
884 case K_RIGHT: 885 case K_RIGHT:
886 {
887 struct disasm_line *dl = disasm_line(browser->selection);
888
885 if (browser->selection == NULL) 889 if (browser->selection == NULL)
886 ui_helpline__puts("Huh? No selection. Report to linux-kernel@vger.kernel.org"); 890 ui_helpline__puts("Huh? No selection. Report to linux-kernel@vger.kernel.org");
887 else if (browser->selection->al.offset == -1) 891 else if (browser->selection->offset == -1)
888 ui_helpline__puts("Actions are only available for assembly lines."); 892 ui_helpline__puts("Actions are only available for assembly lines.");
889 else if (!browser->selection->ins.ops) 893 else if (!dl->ins.ops)
890 goto show_sup_ins; 894 goto show_sup_ins;
891 else if (ins__is_ret(&browser->selection->ins)) 895 else if (ins__is_ret(&dl->ins))
892 goto out; 896 goto out;
893 else if (!(annotate_browser__jump(browser) || 897 else if (!(annotate_browser__jump(browser) ||
894 annotate_browser__callq(browser, evsel, hbt))) { 898 annotate_browser__callq(browser, evsel, hbt))) {
@@ -896,6 +900,7 @@ show_sup_ins:
896 ui_helpline__puts("Actions are only available for function call/return & jump/branch instructions."); 900 ui_helpline__puts("Actions are only available for function call/return & jump/branch instructions.");
897 } 901 }
898 continue; 902 continue;
903 }
899 case 't': 904 case 't':
900 if (annotate_browser__opts.show_total_period) { 905 if (annotate_browser__opts.show_total_period) {
901 annotate_browser__opts.show_total_period = false; 906 annotate_browser__opts.show_total_period = false;