perf annotate stdio: Use annotation_options consistently

Accross all the routines, this way we can have eventually have a
consistent set of defaults for all UIs.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.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-6qgtixurjgdk5u0n3rw78ges@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 9132d3d9
...@@ -40,9 +40,8 @@ ...@@ -40,9 +40,8 @@
struct perf_annotate { struct perf_annotate {
struct perf_tool tool; struct perf_tool tool;
struct perf_session *session; struct perf_session *session;
struct annotation_options opts;
bool use_tui, use_stdio, use_stdio2, use_gtk; bool use_tui, use_stdio, use_stdio2, use_gtk;
bool full_paths;
bool print_line;
bool skip_missing; bool skip_missing;
bool has_br_stack; bool has_br_stack;
bool group_set; bool group_set;
...@@ -289,10 +288,9 @@ static int hist_entry__tty_annotate(struct hist_entry *he, ...@@ -289,10 +288,9 @@ static int hist_entry__tty_annotate(struct hist_entry *he,
struct perf_annotate *ann) struct perf_annotate *ann)
{ {
if (!ann->use_stdio2) if (!ann->use_stdio2)
return symbol__tty_annotate(he->ms.sym, he->ms.map, evsel, return symbol__tty_annotate(he->ms.sym, he->ms.map, evsel, &ann->opts);
ann->print_line, ann->full_paths, 0, 0);
return symbol__tty_annotate2(he->ms.sym, he->ms.map, evsel, return symbol__tty_annotate2(he->ms.sym, he->ms.map, evsel, &ann->opts);
ann->print_line, ann->full_paths);
} }
static void hists__find_annotations(struct hists *hists, static void hists__find_annotations(struct hists *hists,
...@@ -476,6 +474,7 @@ int cmd_annotate(int argc, const char **argv) ...@@ -476,6 +474,7 @@ int cmd_annotate(int argc, const char **argv)
.ordered_events = true, .ordered_events = true,
.ordering_requires_timestamps = true, .ordering_requires_timestamps = true,
}, },
.opts = annotation__default_options,
}; };
struct perf_data data = { struct perf_data data = {
.mode = PERF_DATA_MODE_READ, .mode = PERF_DATA_MODE_READ,
...@@ -503,9 +502,9 @@ int cmd_annotate(int argc, const char **argv) ...@@ -503,9 +502,9 @@ int cmd_annotate(int argc, const char **argv)
"file", "vmlinux pathname"), "file", "vmlinux pathname"),
OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules, OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
"load module symbols - WARNING: use only with -k and LIVE kernel"), "load module symbols - WARNING: use only with -k and LIVE kernel"),
OPT_BOOLEAN('l', "print-line", &annotate.print_line, OPT_BOOLEAN('l', "print-line", &annotate.opts.print_lines,
"print matching source lines (may be slow)"), "print matching source lines (may be slow)"),
OPT_BOOLEAN('P', "full-paths", &annotate.full_paths, OPT_BOOLEAN('P', "full-paths", &annotate.opts.full_path,
"Don't shorten the displayed pathnames"), "Don't shorten the displayed pathnames"),
OPT_BOOLEAN(0, "skip-missing", &annotate.skip_missing, OPT_BOOLEAN(0, "skip-missing", &annotate.skip_missing,
"Skip symbols that cannot be annotated"), "Skip symbols that cannot be annotated"),
......
...@@ -243,10 +243,9 @@ static void perf_top__show_details(struct perf_top *top) ...@@ -243,10 +243,9 @@ static void perf_top__show_details(struct perf_top *top)
goto out_unlock; goto out_unlock;
printf("Showing %s for %s\n", perf_evsel__name(top->sym_evsel), symbol->name); printf("Showing %s for %s\n", perf_evsel__name(top->sym_evsel), symbol->name);
printf(" Events Pcnt (>=%d%%)\n", top->sym_pcnt_filter); printf(" Events Pcnt (>=%d%%)\n", top->annotation_opts.min_pcnt);
more = symbol__annotate_printf(symbol, he->ms.map, top->sym_evsel, more = symbol__annotate_printf(symbol, he->ms.map, top->sym_evsel, &top->annotation_opts);
0, top->sym_pcnt_filter, top->print_entries, 4);
if (top->evlist->enabled) { if (top->evlist->enabled) {
if (top->zero) if (top->zero)
...@@ -406,7 +405,7 @@ static void perf_top__print_mapped_keys(struct perf_top *top) ...@@ -406,7 +405,7 @@ static void perf_top__print_mapped_keys(struct perf_top *top)
fprintf(stdout, "\t[f] profile display filter (count). \t(%d)\n", top->count_filter); fprintf(stdout, "\t[f] profile display filter (count). \t(%d)\n", top->count_filter);
fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", top->sym_pcnt_filter); fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", top->annotation_opts.min_pcnt);
fprintf(stdout, "\t[s] annotate symbol. \t(%s)\n", name?: "NULL"); fprintf(stdout, "\t[s] annotate symbol. \t(%s)\n", name?: "NULL");
fprintf(stdout, "\t[S] stop annotation.\n"); fprintf(stdout, "\t[S] stop annotation.\n");
...@@ -509,7 +508,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c) ...@@ -509,7 +508,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c)
prompt_integer(&top->count_filter, "Enter display event count filter"); prompt_integer(&top->count_filter, "Enter display event count filter");
break; break;
case 'F': case 'F':
prompt_percent(&top->sym_pcnt_filter, prompt_percent(&top->annotation_opts.min_pcnt,
"Enter details display event filter (percent)"); "Enter details display event filter (percent)");
break; break;
case 'K': case 'K':
...@@ -1259,7 +1258,7 @@ int cmd_top(int argc, const char **argv) ...@@ -1259,7 +1258,7 @@ int cmd_top(int argc, const char **argv)
.overwrite = 1, .overwrite = 1,
}, },
.max_stack = sysctl__max_stack(), .max_stack = sysctl__max_stack(),
.sym_pcnt_filter = 5, .annotation_opts = annotation__default_options,
.nr_threads_synthesize = UINT_MAX, .nr_threads_synthesize = UINT_MAX,
}; };
struct record_opts *opts = &top.record_opts; struct record_opts *opts = &top.record_opts;
...@@ -1385,6 +1384,9 @@ int cmd_top(int argc, const char **argv) ...@@ -1385,6 +1384,9 @@ int cmd_top(int argc, const char **argv)
if (status < 0) if (status < 0)
return status; return status;
top.annotation_opts.min_pcnt = 5;
top.annotation_opts.context = 4;
top.evlist = perf_evlist__new(); top.evlist = perf_evlist__new();
if (top.evlist == NULL) if (top.evlist == NULL)
return -ENOMEM; return -ENOMEM;
......
...@@ -1985,8 +1985,8 @@ static int annotated_source__addr_fmt_width(struct list_head *lines, u64 start) ...@@ -1985,8 +1985,8 @@ static int annotated_source__addr_fmt_width(struct list_head *lines, u64 start)
} }
int symbol__annotate_printf(struct symbol *sym, struct map *map, int symbol__annotate_printf(struct symbol *sym, struct map *map,
struct perf_evsel *evsel, bool full_paths, struct perf_evsel *evsel,
int min_pcnt, int max_lines, int context) struct annotation_options *opts)
{ {
struct dso *dso = map->dso; struct dso *dso = map->dso;
char *filename; char *filename;
...@@ -1998,6 +1998,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, ...@@ -1998,6 +1998,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
u64 start = map__rip_2objdump(map, sym->start); u64 start = map__rip_2objdump(map, sym->start);
int printed = 2, queue_len = 0, addr_fmt_width; int printed = 2, queue_len = 0, addr_fmt_width;
int more = 0; int more = 0;
bool context = opts->context;
u64 len; u64 len;
int width = symbol_conf.show_total_period ? 12 : 8; int width = symbol_conf.show_total_period ? 12 : 8;
int graph_dotted_len; int graph_dotted_len;
...@@ -2007,7 +2008,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, ...@@ -2007,7 +2008,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
if (!filename) if (!filename)
return -ENOMEM; return -ENOMEM;
if (full_paths) if (opts->full_path)
d_filename = filename; d_filename = filename;
else else
d_filename = basename(filename); d_filename = basename(filename);
...@@ -2042,7 +2043,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, ...@@ -2042,7 +2043,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
} }
err = annotation_line__print(pos, sym, start, evsel, len, err = annotation_line__print(pos, sym, start, evsel, len,
min_pcnt, printed, max_lines, opts->min_pcnt, printed, opts->max_lines,
queue, addr_fmt_width); queue, addr_fmt_width);
switch (err) { switch (err) {
...@@ -2375,20 +2376,19 @@ static void symbol__calc_lines(struct symbol *sym, struct map *map, ...@@ -2375,20 +2376,19 @@ static void symbol__calc_lines(struct symbol *sym, struct map *map,
} }
int symbol__tty_annotate2(struct symbol *sym, struct map *map, int symbol__tty_annotate2(struct symbol *sym, struct map *map,
struct perf_evsel *evsel, bool print_lines, struct perf_evsel *evsel,
bool full_paths) struct annotation_options *opts)
{ {
struct dso *dso = map->dso; struct dso *dso = map->dso;
struct rb_root source_line = RB_ROOT; struct rb_root source_line = RB_ROOT;
struct annotation_options opts = annotation__default_options;
struct annotation *notes = symbol__annotation(sym); struct annotation *notes = symbol__annotation(sym);
char buf[1024]; char buf[1024];
if (symbol__annotate2(sym, map, evsel, &opts, NULL) < 0) if (symbol__annotate2(sym, map, evsel, opts, NULL) < 0)
return -1; return -1;
if (print_lines) { if (opts->print_lines) {
srcline_full_filename = full_paths; srcline_full_filename = opts->full_path;
symbol__calc_lines(sym, map, &source_line); symbol__calc_lines(sym, map, &source_line);
print_summary(&source_line, dso->long_name); print_summary(&source_line, dso->long_name);
} }
...@@ -2403,8 +2403,8 @@ int symbol__tty_annotate2(struct symbol *sym, struct map *map, ...@@ -2403,8 +2403,8 @@ int symbol__tty_annotate2(struct symbol *sym, struct map *map,
} }
int symbol__tty_annotate(struct symbol *sym, struct map *map, int symbol__tty_annotate(struct symbol *sym, struct map *map,
struct perf_evsel *evsel, bool print_lines, struct perf_evsel *evsel,
bool full_paths, int min_pcnt, int max_lines) struct annotation_options *opts)
{ {
struct dso *dso = map->dso; struct dso *dso = map->dso;
struct rb_root source_line = RB_ROOT; struct rb_root source_line = RB_ROOT;
...@@ -2414,14 +2414,13 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map, ...@@ -2414,14 +2414,13 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map,
symbol__calc_percent(sym, evsel); symbol__calc_percent(sym, evsel);
if (print_lines) { if (opts->print_lines) {
srcline_full_filename = full_paths; srcline_full_filename = opts->full_path;
symbol__calc_lines(sym, map, &source_line); symbol__calc_lines(sym, map, &source_line);
print_summary(&source_line, dso->long_name); print_summary(&source_line, dso->long_name);
} }
symbol__annotate_printf(sym, map, evsel, full_paths, symbol__annotate_printf(sym, map, evsel, opts);
min_pcnt, max_lines, 0);
annotated_source__purge(symbol__annotation(sym)->src); annotated_source__purge(symbol__annotation(sym)->src);
......
...@@ -67,12 +67,17 @@ struct annotation_options { ...@@ -67,12 +67,17 @@ struct annotation_options {
bool hide_src_code, bool hide_src_code,
use_offset, use_offset,
jump_arrows, jump_arrows,
print_lines,
full_path,
show_linenr, show_linenr,
show_nr_jumps, show_nr_jumps,
show_nr_samples, show_nr_samples,
show_total_period, show_total_period,
show_minmax_cycle; show_minmax_cycle;
u8 offset_level; u8 offset_level;
int min_pcnt;
int max_lines;
int context;
}; };
enum { enum {
...@@ -328,8 +333,8 @@ int symbol__strerror_disassemble(struct symbol *sym, struct map *map, ...@@ -328,8 +333,8 @@ int symbol__strerror_disassemble(struct symbol *sym, struct map *map,
int errnum, char *buf, size_t buflen); int errnum, char *buf, size_t buflen);
int symbol__annotate_printf(struct symbol *sym, struct map *map, int symbol__annotate_printf(struct symbol *sym, struct map *map,
struct perf_evsel *evsel, bool full_paths, struct perf_evsel *evsel,
int min_pcnt, int max_lines, int context); struct annotation_options *options);
int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp); int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp);
void symbol__annotate_zero_histogram(struct symbol *sym, int evidx); void symbol__annotate_zero_histogram(struct symbol *sym, int evidx);
void symbol__annotate_decay_histogram(struct symbol *sym, int evidx); void symbol__annotate_decay_histogram(struct symbol *sym, int evidx);
...@@ -340,12 +345,10 @@ int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel) ...@@ -340,12 +345,10 @@ int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel)
bool ui__has_annotation(void); bool ui__has_annotation(void);
int symbol__tty_annotate(struct symbol *sym, struct map *map, int symbol__tty_annotate(struct symbol *sym, struct map *map,
struct perf_evsel *evsel, bool print_lines, struct perf_evsel *evsel, struct annotation_options *opts);
bool full_paths, int min_pcnt, int max_lines);
int symbol__tty_annotate2(struct symbol *sym, struct map *map, int symbol__tty_annotate2(struct symbol *sym, struct map *map,
struct perf_evsel *evsel, bool print_lines, struct perf_evsel *evsel, struct annotation_options *opts);
bool full_paths);
#ifdef HAVE_SLANG_SUPPORT #ifdef HAVE_SLANG_SUPPORT
int symbol__tui_annotate(struct symbol *sym, struct map *map, int symbol__tui_annotate(struct symbol *sym, struct map *map,
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#define __PERF_TOP_H 1 #define __PERF_TOP_H 1
#include "tool.h" #include "tool.h"
#include "annotate.h"
#include <linux/types.h> #include <linux/types.h>
#include <stddef.h> #include <stddef.h>
#include <stdbool.h> #include <stdbool.h>
...@@ -16,6 +17,7 @@ struct perf_top { ...@@ -16,6 +17,7 @@ struct perf_top {
struct perf_tool tool; struct perf_tool tool;
struct perf_evlist *evlist; struct perf_evlist *evlist;
struct record_opts record_opts; struct record_opts record_opts;
struct annotation_options annotation_opts;
/* /*
* Symbols will be added here in perf_event__process_sample and will * Symbols will be added here in perf_event__process_sample and will
* get out after decayed. * get out after decayed.
...@@ -35,7 +37,6 @@ struct perf_top { ...@@ -35,7 +37,6 @@ struct perf_top {
struct perf_session *session; struct perf_session *session;
struct winsize winsize; struct winsize winsize;
int realtime_prio; int realtime_prio;
int sym_pcnt_filter;
const char *sym_filter; const char *sym_filter;
float min_percent; float min_percent;
unsigned int nr_threads_synthesize; unsigned int nr_threads_synthesize;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册