diff options
author | Jiri Olsa <jolsa@kernel.org> | 2017-10-11 11:01:26 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-11-13 07:39:57 -0500 |
commit | d5490b9647e6e41b203186ed0d73b4103f139fda (patch) | |
tree | ea6b969cfc4d91ac645d6cb310af428bd523b9c5 /tools/perf/ui/browsers/annotate.c | |
parent | a17c4ca0ddef659d33fb6661995bd74e1a6a6101 (diff) |
perf annotate: Move line/offset into annotation_line struct
Move the line/line_nr/offset menbers to the annotation_line struct to be
used as generic members for any annotation source.
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/20171011150158.11895-4-jolsa@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.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index a8c2f7405a41..73d921c3e3ec 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -84,8 +84,9 @@ static bool disasm_line__filter(struct ui_browser *browser __maybe_unused, | |||
84 | void *entry) | 84 | void *entry) |
85 | { | 85 | { |
86 | if (annotate_browser__opts.hide_src_code) { | 86 | if (annotate_browser__opts.hide_src_code) { |
87 | struct disasm_line *dl = list_entry(entry, struct disasm_line, al.node); | 87 | struct annotation_line *al = list_entry(entry, struct annotation_line, node); |
88 | return dl->offset == -1; | 88 | |
89 | return al->offset == -1; | ||
89 | } | 90 | } |
90 | 91 | ||
91 | return false; | 92 | return false; |
@@ -141,7 +142,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int | |||
141 | percent_max = bdl->samples[i].percent; | 142 | percent_max = bdl->samples[i].percent; |
142 | } | 143 | } |
143 | 144 | ||
144 | if ((row == 0) && (dl->offset == -1 || percent_max == 0.0)) { | 145 | if ((row == 0) && (dl->al.offset == -1 || percent_max == 0.0)) { |
145 | if (ab->have_cycles) { | 146 | if (ab->have_cycles) { |
146 | if (dl->ipc == 0.0 && dl->cycles == 0) | 147 | if (dl->ipc == 0.0 && dl->cycles == 0) |
147 | show_title = true; | 148 | show_title = true; |
@@ -149,7 +150,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int | |||
149 | show_title = true; | 150 | show_title = true; |
150 | } | 151 | } |
151 | 152 | ||
152 | if (dl->offset != -1 && percent_max != 0.0) { | 153 | if (dl->al.offset != -1 && percent_max != 0.0) { |
153 | for (i = 0; i < ab->nr_events; i++) { | 154 | for (i = 0; i < ab->nr_events; i++) { |
154 | ui_browser__set_percent_color(browser, | 155 | ui_browser__set_percent_color(browser, |
155 | bdl->samples[i].percent, | 156 | bdl->samples[i].percent, |
@@ -199,19 +200,19 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int | |||
199 | if (!browser->navkeypressed) | 200 | if (!browser->navkeypressed) |
200 | width += 1; | 201 | width += 1; |
201 | 202 | ||
202 | if (!*dl->line) | 203 | if (!*dl->al.line) |
203 | ui_browser__write_nstring(browser, " ", width - pcnt_width - cycles_width); | 204 | ui_browser__write_nstring(browser, " ", width - pcnt_width - cycles_width); |
204 | else if (dl->offset == -1) { | 205 | else if (dl->al.offset == -1) { |
205 | if (dl->line_nr && annotate_browser__opts.show_linenr) | 206 | if (dl->al.line_nr && annotate_browser__opts.show_linenr) |
206 | printed = scnprintf(bf, sizeof(bf), "%-*d ", | 207 | printed = scnprintf(bf, sizeof(bf), "%-*d ", |
207 | ab->addr_width + 1, dl->line_nr); | 208 | ab->addr_width + 1, dl->al.line_nr); |
208 | else | 209 | else |
209 | printed = scnprintf(bf, sizeof(bf), "%*s ", | 210 | printed = scnprintf(bf, sizeof(bf), "%*s ", |
210 | ab->addr_width, " "); | 211 | ab->addr_width, " "); |
211 | ui_browser__write_nstring(browser, bf, printed); | 212 | ui_browser__write_nstring(browser, bf, printed); |
212 | ui_browser__write_nstring(browser, dl->line, width - printed - pcnt_width - cycles_width + 1); | 213 | ui_browser__write_nstring(browser, dl->al.line, width - printed - pcnt_width - cycles_width + 1); |
213 | } else { | 214 | } else { |
214 | u64 addr = dl->offset; | 215 | u64 addr = dl->al.offset; |
215 | int color = -1; | 216 | int color = -1; |
216 | 217 | ||
217 | if (!annotate_browser__opts.use_offset) | 218 | if (!annotate_browser__opts.use_offset) |
@@ -247,7 +248,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int | |||
247 | ui_browser__set_color(browser, color); | 248 | ui_browser__set_color(browser, color); |
248 | if (dl->ins.ops && dl->ins.ops->scnprintf) { | 249 | if (dl->ins.ops && dl->ins.ops->scnprintf) { |
249 | if (ins__is_jump(&dl->ins)) { | 250 | if (ins__is_jump(&dl->ins)) { |
250 | bool fwd = dl->ops.target.offset > dl->offset; | 251 | bool fwd = dl->ops.target.offset > dl->al.offset; |
251 | 252 | ||
252 | ui_browser__write_graph(browser, fwd ? SLSMG_DARROW_CHAR : | 253 | ui_browser__write_graph(browser, fwd ? SLSMG_DARROW_CHAR : |
253 | SLSMG_UARROW_CHAR); | 254 | SLSMG_UARROW_CHAR); |
@@ -452,7 +453,7 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, | |||
452 | double max_percent = 0.0; | 453 | double max_percent = 0.0; |
453 | int i; | 454 | int i; |
454 | 455 | ||
455 | if (pos->offset == -1) { | 456 | if (pos->al.offset == -1) { |
456 | RB_CLEAR_NODE(&bpos->rb_node); | 457 | RB_CLEAR_NODE(&bpos->rb_node); |
457 | continue; | 458 | continue; |
458 | } | 459 | } |
@@ -464,8 +465,8 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, | |||
464 | 465 | ||
465 | bpos->samples[i].percent = disasm__calc_percent(notes, | 466 | bpos->samples[i].percent = disasm__calc_percent(notes, |
466 | evsel->idx + i, | 467 | evsel->idx + i, |
467 | pos->offset, | 468 | pos->al.offset, |
468 | next ? next->offset : len, | 469 | next ? next->al.offset : len, |
469 | &path, &sample); | 470 | &path, &sample); |
470 | bpos->samples[i].he = sample; | 471 | bpos->samples[i].he = sample; |
471 | 472 | ||
@@ -590,7 +591,7 @@ struct disasm_line *annotate_browser__find_offset(struct annotate_browser *brows | |||
590 | 591 | ||
591 | *idx = 0; | 592 | *idx = 0; |
592 | list_for_each_entry(pos, ¬es->src->source, al.node) { | 593 | list_for_each_entry(pos, ¬es->src->source, al.node) { |
593 | if (pos->offset == offset) | 594 | if (pos->al.offset == offset) |
594 | return pos; | 595 | return pos; |
595 | if (!disasm_line__filter(&browser->b, &pos->al.node)) | 596 | if (!disasm_line__filter(&browser->b, &pos->al.node)) |
596 | ++*idx; | 597 | ++*idx; |
@@ -636,7 +637,7 @@ struct disasm_line *annotate_browser__find_string(struct annotate_browser *brows | |||
636 | 637 | ||
637 | ++*idx; | 638 | ++*idx; |
638 | 639 | ||
639 | if (pos->line && strstr(pos->line, s) != NULL) | 640 | if (pos->al.line && strstr(pos->al.line, s) != NULL) |
640 | return pos; | 641 | return pos; |
641 | } | 642 | } |
642 | 643 | ||
@@ -675,7 +676,7 @@ struct disasm_line *annotate_browser__find_string_reverse(struct annotate_browse | |||
675 | 676 | ||
676 | --*idx; | 677 | --*idx; |
677 | 678 | ||
678 | if (pos->line && strstr(pos->line, s) != NULL) | 679 | if (pos->al.line && strstr(pos->al.line, s) != NULL) |
679 | return pos; | 680 | return pos; |
680 | } | 681 | } |
681 | 682 | ||
@@ -901,7 +902,7 @@ show_help: | |||
901 | case K_RIGHT: | 902 | case K_RIGHT: |
902 | if (browser->selection == NULL) | 903 | if (browser->selection == NULL) |
903 | ui_helpline__puts("Huh? No selection. Report to linux-kernel@vger.kernel.org"); | 904 | ui_helpline__puts("Huh? No selection. Report to linux-kernel@vger.kernel.org"); |
904 | else if (browser->selection->offset == -1) | 905 | else if (browser->selection->al.offset == -1) |
905 | ui_helpline__puts("Actions are only available for assembly lines."); | 906 | ui_helpline__puts("Actions are only available for assembly lines."); |
906 | else if (!browser->selection->ins.ops) | 907 | else if (!browser->selection->ins.ops) |
907 | goto show_sup_ins; | 908 | goto show_sup_ins; |
@@ -1136,13 +1137,13 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, | |||
1136 | 1137 | ||
1137 | list_for_each_entry(pos, ¬es->src->source, al.node) { | 1138 | list_for_each_entry(pos, ¬es->src->source, al.node) { |
1138 | struct browser_disasm_line *bpos; | 1139 | struct browser_disasm_line *bpos; |
1139 | size_t line_len = strlen(pos->line); | 1140 | size_t line_len = strlen(pos->al.line); |
1140 | 1141 | ||
1141 | if (browser.b.width < line_len) | 1142 | if (browser.b.width < line_len) |
1142 | browser.b.width = line_len; | 1143 | browser.b.width = line_len; |
1143 | bpos = disasm_line__browser(pos); | 1144 | bpos = disasm_line__browser(pos); |
1144 | bpos->idx = browser.nr_entries++; | 1145 | bpos->idx = browser.nr_entries++; |
1145 | if (pos->offset != -1) { | 1146 | if (pos->al.offset != -1) { |
1146 | bpos->idx_asm = browser.nr_asm_entries++; | 1147 | bpos->idx_asm = browser.nr_asm_entries++; |
1147 | /* | 1148 | /* |
1148 | * FIXME: short term bandaid to cope with assembly | 1149 | * FIXME: short term bandaid to cope with assembly |
@@ -1151,8 +1152,8 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, | |||
1151 | * | 1152 | * |
1152 | * E.g. copy_user_generic_unrolled | 1153 | * E.g. copy_user_generic_unrolled |
1153 | */ | 1154 | */ |
1154 | if (pos->offset < (s64)size) | 1155 | if (pos->al.offset < (s64)size) |
1155 | browser.offsets[pos->offset] = pos; | 1156 | browser.offsets[pos->al.offset] = pos; |
1156 | } else | 1157 | } else |
1157 | bpos->idx_asm = -1; | 1158 | bpos->idx_asm = -1; |
1158 | } | 1159 | } |