perf annotate: Introduce annotation_line__filter()

Out of the TUI logic that allows toggling the presentation of source
code lines.

Will be used in the upcoming --stdio2 mode.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-g0ckz9ajy6unswrv2iy39mxk@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 c298304b
...@@ -48,14 +48,8 @@ static inline struct annotation *browser__annotation(struct ui_browser *browser) ...@@ -48,14 +48,8 @@ static inline struct annotation *browser__annotation(struct ui_browser *browser)
static bool disasm_line__filter(struct ui_browser *browser, void *entry) static bool disasm_line__filter(struct ui_browser *browser, void *entry)
{ {
struct annotation *notes = browser__annotation(browser); struct annotation *notes = browser__annotation(browser);
struct annotation_line *al = list_entry(entry, struct annotation_line, node);
if (notes->options->hide_src_code) { return annotation_line__filter(al, notes);
struct annotation_line *al = list_entry(entry, struct annotation_line, node);
return al->offset == -1;
}
return false;
} }
static int ui_browser__jumps_percent_color(struct ui_browser *browser, int nr, bool current) static int ui_browser__jumps_percent_color(struct ui_browser *browser, int nr, bool current)
...@@ -268,6 +262,7 @@ static void disasm_rb_tree__insert(struct rb_root *root, struct annotation_line ...@@ -268,6 +262,7 @@ static void disasm_rb_tree__insert(struct rb_root *root, struct annotation_line
static void annotate_browser__set_top(struct annotate_browser *browser, static void annotate_browser__set_top(struct annotate_browser *browser,
struct annotation_line *pos, u32 idx) struct annotation_line *pos, u32 idx)
{ {
struct annotation *notes = browser__annotation(&browser->b);
unsigned back; unsigned back;
ui_browser__refresh_dimensions(&browser->b); ui_browser__refresh_dimensions(&browser->b);
...@@ -277,7 +272,7 @@ static void annotate_browser__set_top(struct annotate_browser *browser, ...@@ -277,7 +272,7 @@ static void annotate_browser__set_top(struct annotate_browser *browser,
while (browser->b.top_idx != 0 && back != 0) { while (browser->b.top_idx != 0 && back != 0) {
pos = list_entry(pos->node.prev, struct annotation_line, node); pos = list_entry(pos->node.prev, struct annotation_line, node);
if (disasm_line__filter(&browser->b, &pos->node)) if (annotation_line__filter(pos, notes))
continue; continue;
--browser->b.top_idx; --browser->b.top_idx;
...@@ -440,7 +435,7 @@ struct disasm_line *annotate_browser__find_offset(struct annotate_browser *brows ...@@ -440,7 +435,7 @@ struct disasm_line *annotate_browser__find_offset(struct annotate_browser *brows
list_for_each_entry(pos, &notes->src->source, al.node) { list_for_each_entry(pos, &notes->src->source, al.node) {
if (pos->al.offset == offset) if (pos->al.offset == offset)
return pos; return pos;
if (!disasm_line__filter(&browser->b, &pos->al.node)) if (!annotation_line__filter(&pos->al, notes))
++*idx; ++*idx;
} }
...@@ -477,7 +472,7 @@ struct annotation_line *annotate_browser__find_string(struct annotate_browser *b ...@@ -477,7 +472,7 @@ struct annotation_line *annotate_browser__find_string(struct annotate_browser *b
*idx = browser->b.index; *idx = browser->b.index;
list_for_each_entry_continue(al, &notes->src->source, node) { list_for_each_entry_continue(al, &notes->src->source, node) {
if (disasm_line__filter(&browser->b, &al->node)) if (annotation_line__filter(al, notes))
continue; continue;
++*idx; ++*idx;
...@@ -514,7 +509,7 @@ struct annotation_line *annotate_browser__find_string_reverse(struct annotate_br ...@@ -514,7 +509,7 @@ struct annotation_line *annotate_browser__find_string_reverse(struct annotate_br
*idx = browser->b.index; *idx = browser->b.index;
list_for_each_entry_continue_reverse(al, &notes->src->source, node) { list_for_each_entry_continue_reverse(al, &notes->src->source, node) {
if (disasm_line__filter(&browser->b, &al->node)) if (annotation_line__filter(al, notes))
continue; continue;
--*idx; --*idx;
......
...@@ -215,6 +215,10 @@ static inline int annotation__pcnt_width(struct annotation *notes) ...@@ -215,6 +215,10 @@ static inline int annotation__pcnt_width(struct annotation *notes)
return (notes->options->show_total_period ? 12 : 7) * notes->nr_events; return (notes->options->show_total_period ? 12 : 7) * notes->nr_events;
} }
static inline bool annotation_line__filter(struct annotation_line *al, struct annotation *notes)
{
return notes->options->hide_src_code && al->offset == -1;
}
void annotation__set_offsets(struct annotation *notes, s64 size); void annotation__set_offsets(struct annotation *notes, s64 size);
void annotation__compute_ipc(struct annotation *notes, size_t size); void annotation__compute_ipc(struct annotation *notes, size_t size);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册