Commit a5ef2702 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

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: default avatarJiri 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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e1b60b5b
...@@ -69,9 +69,12 @@ struct annotate_browser { ...@@ -69,9 +69,12 @@ struct annotate_browser {
char search_bf[128]; char search_bf[128];
}; };
static inline struct browser_line *browser_line(struct disasm_line *dl) static inline struct browser_line *browser_line(struct annotation_line *al)
{ {
return (void *) dl - sizeof(struct browser_line); void *ptr = al;
ptr = container_of(al, struct disasm_line, al);
return ptr - sizeof(struct browser_line);
} }
static bool disasm_line__filter(struct ui_browser *browser __maybe_unused, 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,7 +122,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
{ {
struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
struct disasm_line *dl = list_entry(entry, struct disasm_line, al.node); struct disasm_line *dl = list_entry(entry, struct disasm_line, al.node);
struct browser_line *bdl = browser_line(dl); struct browser_line *bdl = browser_line(&dl->al);
bool current_entry = ui_browser__is_current_entry(browser, row); bool current_entry = ui_browser__is_current_entry(browser, row);
bool change_color = (!annotate_browser__opts.hide_src_code && bool change_color = (!annotate_browser__opts.hide_src_code &&
(!current_entry || (browser->use_navkeypressed && (!current_entry || (browser->use_navkeypressed &&
...@@ -302,8 +305,7 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser) ...@@ -302,8 +305,7 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser)
{ {
struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
struct disasm_line *cursor = disasm_line(ab->selection); struct disasm_line *cursor = disasm_line(ab->selection);
struct disasm_line *target; struct annotation_line *target;
struct annotation_line *al;
struct browser_line *btarget, *bcursor; struct browser_line *btarget, *bcursor;
unsigned int from, to; unsigned int from, to;
struct map_symbol *ms = ab->b.priv; struct map_symbol *ms = ab->b.priv;
...@@ -317,13 +319,9 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser) ...@@ -317,13 +319,9 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser)
if (!disasm_line__is_valid_jump(cursor, sym)) if (!disasm_line__is_valid_jump(cursor, sym))
return; return;
al = ab->offsets[cursor->ops.target.offset]; target = ab->offsets[cursor->ops.target.offset];
if (!al)
return;
target = disasm_line(al);
bcursor = browser_line(cursor); bcursor = browser_line(&cursor->al);
btarget = browser_line(target); btarget = browser_line(target);
if (annotate_browser__opts.hide_src_code) { if (annotate_browser__opts.hide_src_code) {
...@@ -422,7 +420,7 @@ static void annotate_browser__set_rb_top(struct annotate_browser *browser, ...@@ -422,7 +420,7 @@ static void annotate_browser__set_rb_top(struct annotate_browser *browser,
u32 idx; u32 idx;
pos = rb_entry(nd, struct disasm_line, al.rb_node); pos = rb_entry(nd, struct disasm_line, al.rb_node);
bpos = browser_line(pos); bpos = browser_line(&pos->al);
idx = bpos->idx; idx = bpos->idx;
if (annotate_browser__opts.hide_src_code) if (annotate_browser__opts.hide_src_code)
...@@ -475,37 +473,37 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, ...@@ -475,37 +473,37 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,
static bool annotate_browser__toggle_source(struct annotate_browser *browser) static bool annotate_browser__toggle_source(struct annotate_browser *browser)
{ {
struct disasm_line *dl; struct disasm_line *dl;
struct browser_line *bdl; struct browser_line *bl;
off_t offset = browser->b.index - browser->b.top_idx; off_t offset = browser->b.index - browser->b.top_idx;
browser->b.seek(&browser->b, offset, SEEK_CUR); browser->b.seek(&browser->b, offset, SEEK_CUR);
dl = list_entry(browser->b.top, struct disasm_line, al.node); dl = list_entry(browser->b.top, struct disasm_line, al.node);
bdl = browser_line(dl); bl = browser_line(&dl->al);
if (annotate_browser__opts.hide_src_code) { if (annotate_browser__opts.hide_src_code) {
if (bdl->idx_asm < offset) if (bl->idx_asm < offset)
offset = bdl->idx; offset = bl->idx;
browser->b.nr_entries = browser->nr_entries; browser->b.nr_entries = browser->nr_entries;
annotate_browser__opts.hide_src_code = false; annotate_browser__opts.hide_src_code = false;
browser->b.seek(&browser->b, -offset, SEEK_CUR); browser->b.seek(&browser->b, -offset, SEEK_CUR);
browser->b.top_idx = bdl->idx - offset; browser->b.top_idx = bl->idx - offset;
browser->b.index = bdl->idx; browser->b.index = bl->idx;
} else { } else {
if (bdl->idx_asm < 0) { if (bl->idx_asm < 0) {
ui_helpline__puts("Only available for assembly lines."); ui_helpline__puts("Only available for assembly lines.");
browser->b.seek(&browser->b, -offset, SEEK_CUR); browser->b.seek(&browser->b, -offset, SEEK_CUR);
return false; return false;
} }
if (bdl->idx_asm < offset) if (bl->idx_asm < offset)
offset = bdl->idx_asm; offset = bl->idx_asm;
browser->b.nr_entries = browser->nr_asm_entries; browser->b.nr_entries = browser->nr_asm_entries;
annotate_browser__opts.hide_src_code = true; annotate_browser__opts.hide_src_code = true;
browser->b.seek(&browser->b, -offset, SEEK_CUR); browser->b.seek(&browser->b, -offset, SEEK_CUR);
browser->b.top_idx = bdl->idx_asm - offset; browser->b.top_idx = bl->idx_asm - offset;
browser->b.index = bdl->idx_asm; browser->b.index = bl->idx_asm;
} }
return true; return true;
...@@ -1035,8 +1033,8 @@ static void annotate_browser__mark_jump_targets(struct annotate_browser *browser ...@@ -1035,8 +1033,8 @@ static void annotate_browser__mark_jump_targets(struct annotate_browser *browser
for (offset = 0; offset < size; ++offset) { for (offset = 0; offset < size; ++offset) {
struct annotation_line *al = browser->offsets[offset]; struct annotation_line *al = browser->offsets[offset];
struct disasm_line *dl, *dlt; struct disasm_line *dl;
struct browser_line *bdlt; struct browser_line *blt;
dl = disasm_line(al); dl = disasm_line(al);
...@@ -1044,18 +1042,17 @@ static void annotate_browser__mark_jump_targets(struct annotate_browser *browser ...@@ -1044,18 +1042,17 @@ static void annotate_browser__mark_jump_targets(struct annotate_browser *browser
continue; continue;
al = browser->offsets[dl->ops.target.offset]; al = browser->offsets[dl->ops.target.offset];
dlt = disasm_line(al);
/* /*
* FIXME: Oops, no jump target? Buggy disassembler? Or do we * FIXME: Oops, no jump target? Buggy disassembler? Or do we
* have to adjust to the previous offset? * have to adjust to the previous offset?
*/ */
if (dlt == NULL) if (al == NULL)
continue; continue;
bdlt = browser_line(dlt); blt = browser_line(al);
if (++bdlt->jump_sources > browser->max_jump_sources) if (++blt->jump_sources > browser->max_jump_sources)
browser->max_jump_sources = bdlt->jump_sources; browser->max_jump_sources = blt->jump_sources;
++browser->nr_jumps; ++browser->nr_jumps;
} }
...@@ -1127,13 +1124,12 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, ...@@ -1127,13 +1124,12 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map,
browser.start = map__rip_2objdump(map, sym->start); browser.start = map__rip_2objdump(map, sym->start);
list_for_each_entry(al, &notes->src->source, node) { list_for_each_entry(al, &notes->src->source, node) {
struct disasm_line *dl = disasm_line(al);
struct browser_line *bpos; struct browser_line *bpos;
size_t line_len = strlen(al->line); size_t line_len = strlen(al->line);
if (browser.b.width < line_len) if (browser.b.width < line_len)
browser.b.width = line_len; browser.b.width = line_len;
bpos = browser_line(dl); bpos = browser_line(al);
bpos->idx = browser.nr_entries++; bpos->idx = browser.nr_entries++;
if (al->offset != -1) { if (al->offset != -1) {
bpos->idx_asm = browser.nr_asm_entries++; bpos->idx_asm = browser.nr_asm_entries++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment