diff options
author | Jiri Olsa <jolsa@kernel.org> | 2017-10-11 11:01:54 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-11-16 12:49:48 -0500 |
commit | a5ef27020b4bc0785fabb2591eb670d3bc641257 (patch) | |
tree | 3cb37edc438289f6f39e20cef5c0b3a441bb3999 /tools/perf/ui/browsers/annotate.c | |
parent | e1b60b5bd3c7a3f215e79fa911122aba59b3d984 (diff) |
perf annotate browser: Use struct annotation_line in browser_line
Using struct annotation_line arg in browser_line
function to make it generic.
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-32-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 | 60 |
1 files changed, 28 insertions, 32 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 911f06ce0f1b..fb83deb8c909 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -69,9 +69,12 @@ struct annotate_browser { | |||
69 | char search_bf[128]; | 69 | char search_bf[128]; |
70 | }; | 70 | }; |
71 | 71 | ||
72 | static inline struct browser_line *browser_line(struct disasm_line *dl) | 72 | static inline struct browser_line *browser_line(struct annotation_line *al) |
73 | { | 73 | { |
74 | return (void *) dl - sizeof(struct browser_line); | 74 | void *ptr = al; |
75 | |||
76 | ptr = container_of(al, struct disasm_line, al); | ||
77 | return ptr - sizeof(struct browser_line); | ||
75 | } | 78 | } |
76 | 79 | ||
77 | static bool disasm_line__filter(struct ui_browser *browser __maybe_unused, | 80 | static bool disasm_line__filter(struct ui_browser *browser __maybe_unused, |
@@ -119,7 +122,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int | |||
119 | { | 122 | { |
120 | struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); | 123 | struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); |
121 | struct disasm_line *dl = list_entry(entry, struct disasm_line, al.node); | 124 | struct disasm_line *dl = list_entry(entry, struct disasm_line, al.node); |
122 | struct browser_line *bdl = browser_line(dl); | 125 | struct browser_line *bdl = browser_line(&dl->al); |
123 | bool current_entry = ui_browser__is_current_entry(browser, row); | 126 | bool current_entry = ui_browser__is_current_entry(browser, row); |
124 | bool change_color = (!annotate_browser__opts.hide_src_code && | 127 | bool change_color = (!annotate_browser__opts.hide_src_code && |
125 | (!current_entry || (browser->use_navkeypressed && | 128 | (!current_entry || (browser->use_navkeypressed && |
@@ -302,8 +305,7 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser) | |||
302 | { | 305 | { |
303 | struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); | 306 | struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); |
304 | struct disasm_line *cursor = disasm_line(ab->selection); | 307 | struct disasm_line *cursor = disasm_line(ab->selection); |
305 | struct disasm_line *target; | 308 | struct annotation_line *target; |
306 | struct annotation_line *al; | ||
307 | struct browser_line *btarget, *bcursor; | 309 | struct browser_line *btarget, *bcursor; |
308 | unsigned int from, to; | 310 | unsigned int from, to; |
309 | struct map_symbol *ms = ab->b.priv; | 311 | struct map_symbol *ms = ab->b.priv; |
@@ -317,13 +319,9 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser) | |||
317 | if (!disasm_line__is_valid_jump(cursor, sym)) | 319 | if (!disasm_line__is_valid_jump(cursor, sym)) |
318 | return; | 320 | return; |
319 | 321 | ||
320 | al = ab->offsets[cursor->ops.target.offset]; | 322 | target = ab->offsets[cursor->ops.target.offset]; |
321 | if (!al) | ||
322 | return; | ||
323 | |||
324 | target = disasm_line(al); | ||
325 | 323 | ||
326 | bcursor = browser_line(cursor); | 324 | bcursor = browser_line(&cursor->al); |
327 | btarget = browser_line(target); | 325 | btarget = browser_line(target); |
328 | 326 | ||
329 | if (annotate_browser__opts.hide_src_code) { | 327 | if (annotate_browser__opts.hide_src_code) { |
@@ -422,7 +420,7 @@ static void annotate_browser__set_rb_top(struct annotate_browser *browser, | |||
422 | u32 idx; | 420 | u32 idx; |
423 | 421 | ||
424 | pos = rb_entry(nd, struct disasm_line, al.rb_node); | 422 | pos = rb_entry(nd, struct disasm_line, al.rb_node); |
425 | bpos = browser_line(pos); | 423 | bpos = browser_line(&pos->al); |
426 | 424 | ||
427 | idx = bpos->idx; | 425 | idx = bpos->idx; |
428 | if (annotate_browser__opts.hide_src_code) | 426 | if (annotate_browser__opts.hide_src_code) |
@@ -475,37 +473,37 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, | |||
475 | static bool annotate_browser__toggle_source(struct annotate_browser *browser) | 473 | static bool annotate_browser__toggle_source(struct annotate_browser *browser) |
476 | { | 474 | { |
477 | struct disasm_line *dl; | 475 | struct disasm_line *dl; |
478 | struct browser_line *bdl; | 476 | struct browser_line *bl; |
479 | off_t offset = browser->b.index - browser->b.top_idx; | 477 | off_t offset = browser->b.index - browser->b.top_idx; |
480 | 478 | ||
481 | browser->b.seek(&browser->b, offset, SEEK_CUR); | 479 | browser->b.seek(&browser->b, offset, SEEK_CUR); |
482 | dl = list_entry(browser->b.top, struct disasm_line, al.node); | 480 | dl = list_entry(browser->b.top, struct disasm_line, al.node); |
483 | bdl = browser_line(dl); | 481 | bl = browser_line(&dl->al); |
484 | 482 | ||
485 | if (annotate_browser__opts.hide_src_code) { | 483 | if (annotate_browser__opts.hide_src_code) { |
486 | if (bdl->idx_asm < offset) | 484 | if (bl->idx_asm < offset) |
487 | offset = bdl->idx; | 485 | offset = bl->idx; |
488 | 486 | ||
489 | browser->b.nr_entries = browser->nr_entries; | 487 | browser->b.nr_entries = browser->nr_entries; |
490 | annotate_browser__opts.hide_src_code = false; | 488 | annotate_browser__opts.hide_src_code = false; |
491 | browser->b.seek(&browser->b, -offset, SEEK_CUR); | 489 | browser->b.seek(&browser->b, -offset, SEEK_CUR); |
492 | browser->b.top_idx = bdl->idx - offset; | 490 | browser->b.top_idx = bl->idx - offset; |
493 | browser->b.index = bdl->idx; | 491 | browser->b.index = bl->idx; |
494 | } else { | 492 | } else { |
495 | if (bdl->idx_asm < 0) { | 493 | if (bl->idx_asm < 0) { |
496 | ui_helpline__puts("Only available for assembly lines."); | 494 | ui_helpline__puts("Only available for assembly lines."); |
497 | browser->b.seek(&browser->b, -offset, SEEK_CUR); | 495 | browser->b.seek(&browser->b, -offset, SEEK_CUR); |
498 | return false; | 496 | return false; |
499 | } | 497 | } |
500 | 498 | ||
501 | if (bdl->idx_asm < offset) | 499 | if (bl->idx_asm < offset) |
502 | offset = bdl->idx_asm; | 500 | offset = bl->idx_asm; |
503 | 501 | ||
504 | browser->b.nr_entries = browser->nr_asm_entries; | 502 | browser->b.nr_entries = browser->nr_asm_entries; |
505 | annotate_browser__opts.hide_src_code = true; | 503 | annotate_browser__opts.hide_src_code = true; |
506 | browser->b.seek(&browser->b, -offset, SEEK_CUR); | 504 | browser->b.seek(&browser->b, -offset, SEEK_CUR); |
507 | browser->b.top_idx = bdl->idx_asm - offset; | 505 | browser->b.top_idx = bl->idx_asm - offset; |
508 | browser->b.index = bdl->idx_asm; | 506 | browser->b.index = bl->idx_asm; |
509 | } | 507 | } |
510 | 508 | ||
511 | return true; | 509 | return true; |
@@ -1035,8 +1033,8 @@ static void annotate_browser__mark_jump_targets(struct annotate_browser *browser | |||
1035 | 1033 | ||
1036 | for (offset = 0; offset < size; ++offset) { | 1034 | for (offset = 0; offset < size; ++offset) { |
1037 | struct annotation_line *al = browser->offsets[offset]; | 1035 | struct annotation_line *al = browser->offsets[offset]; |
1038 | struct disasm_line *dl, *dlt; | 1036 | struct disasm_line *dl; |
1039 | struct browser_line *bdlt; | 1037 | struct browser_line *blt; |
1040 | 1038 | ||
1041 | dl = disasm_line(al); | 1039 | dl = disasm_line(al); |
1042 | 1040 | ||
@@ -1044,18 +1042,17 @@ static void annotate_browser__mark_jump_targets(struct annotate_browser *browser | |||
1044 | continue; | 1042 | continue; |
1045 | 1043 | ||
1046 | al = browser->offsets[dl->ops.target.offset]; | 1044 | al = browser->offsets[dl->ops.target.offset]; |
1047 | dlt = disasm_line(al); | ||
1048 | 1045 | ||
1049 | /* | 1046 | /* |
1050 | * FIXME: Oops, no jump target? Buggy disassembler? Or do we | 1047 | * FIXME: Oops, no jump target? Buggy disassembler? Or do we |
1051 | * have to adjust to the previous offset? | 1048 | * have to adjust to the previous offset? |
1052 | */ | 1049 | */ |
1053 | if (dlt == NULL) | 1050 | if (al == NULL) |
1054 | continue; | 1051 | continue; |
1055 | 1052 | ||
1056 | bdlt = browser_line(dlt); | 1053 | blt = browser_line(al); |
1057 | if (++bdlt->jump_sources > browser->max_jump_sources) | 1054 | if (++blt->jump_sources > browser->max_jump_sources) |
1058 | browser->max_jump_sources = bdlt->jump_sources; | 1055 | browser->max_jump_sources = blt->jump_sources; |
1059 | 1056 | ||
1060 | ++browser->nr_jumps; | 1057 | ++browser->nr_jumps; |
1061 | } | 1058 | } |
@@ -1127,13 +1124,12 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, | |||
1127 | browser.start = map__rip_2objdump(map, sym->start); | 1124 | browser.start = map__rip_2objdump(map, sym->start); |
1128 | 1125 | ||
1129 | list_for_each_entry(al, ¬es->src->source, node) { | 1126 | list_for_each_entry(al, ¬es->src->source, node) { |
1130 | struct disasm_line *dl = disasm_line(al); | ||
1131 | struct browser_line *bpos; | 1127 | struct browser_line *bpos; |
1132 | size_t line_len = strlen(al->line); | 1128 | size_t line_len = strlen(al->line); |
1133 | 1129 | ||
1134 | if (browser.b.width < line_len) | 1130 | if (browser.b.width < line_len) |
1135 | browser.b.width = line_len; | 1131 | browser.b.width = line_len; |
1136 | bpos = browser_line(dl); | 1132 | bpos = browser_line(al); |
1137 | bpos->idx = browser.nr_entries++; | 1133 | bpos->idx = browser.nr_entries++; |
1138 | if (al->offset != -1) { | 1134 | if (al->offset != -1) { |
1139 | bpos->idx_asm = browser.nr_asm_entries++; | 1135 | bpos->idx_asm = browser.nr_asm_entries++; |