Commit c9a21a87 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf top: Convert to the global annotation_options

Use the global option and drop the local copy.
Reviewed-by: default avatarIan Rogers <irogers@google.com>
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20231128175441.721579-4-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 14953f03
...@@ -147,7 +147,7 @@ static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he) ...@@ -147,7 +147,7 @@ static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he)
return err; return err;
} }
err = symbol__annotate(&he->ms, evsel, &top->annotation_opts, NULL); err = symbol__annotate(&he->ms, evsel, &annotate_opts, NULL);
if (err == 0) { if (err == 0) {
top->sym_filter_entry = he; top->sym_filter_entry = he;
} else { } else {
...@@ -261,9 +261,9 @@ static void perf_top__show_details(struct perf_top *top) ...@@ -261,9 +261,9 @@ static void perf_top__show_details(struct perf_top *top)
goto out_unlock; goto out_unlock;
printf("Showing %s for %s\n", evsel__name(top->sym_evsel), symbol->name); printf("Showing %s for %s\n", evsel__name(top->sym_evsel), symbol->name);
printf(" Events Pcnt (>=%d%%)\n", top->annotation_opts.min_pcnt); printf(" Events Pcnt (>=%d%%)\n", annotate_opts.min_pcnt);
more = symbol__annotate_printf(&he->ms, top->sym_evsel, &top->annotation_opts); more = symbol__annotate_printf(&he->ms, top->sym_evsel, &annotate_opts);
if (top->evlist->enabled) { if (top->evlist->enabled) {
if (top->zero) if (top->zero)
...@@ -450,7 +450,7 @@ static void perf_top__print_mapped_keys(struct perf_top *top) ...@@ -450,7 +450,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->annotation_opts.min_pcnt); fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", annotate_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");
...@@ -553,7 +553,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c) ...@@ -553,7 +553,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->annotation_opts.min_pcnt, prompt_percent(&annotate_opts.min_pcnt,
"Enter details display event filter (percent)"); "Enter details display event filter (percent)");
break; break;
case 'K': case 'K':
...@@ -647,7 +647,7 @@ static void *display_thread_tui(void *arg) ...@@ -647,7 +647,7 @@ static void *display_thread_tui(void *arg)
ret = evlist__tui_browse_hists(top->evlist, help, &hbt, top->min_percent, ret = evlist__tui_browse_hists(top->evlist, help, &hbt, top->min_percent,
&top->session->header.env, !top->record_opts.overwrite, &top->session->header.env, !top->record_opts.overwrite,
&top->annotation_opts); &annotate_opts);
if (ret == K_RELOAD) { if (ret == K_RELOAD) {
top->zero = true; top->zero = true;
goto repeat; goto repeat;
...@@ -1241,9 +1241,9 @@ static int __cmd_top(struct perf_top *top) ...@@ -1241,9 +1241,9 @@ static int __cmd_top(struct perf_top *top)
pthread_t thread, thread_process; pthread_t thread, thread_process;
int ret; int ret;
if (!top->annotation_opts.objdump_path) { if (!annotate_opts.objdump_path) {
ret = perf_env__lookup_objdump(&top->session->header.env, ret = perf_env__lookup_objdump(&top->session->header.env,
&top->annotation_opts.objdump_path); &annotate_opts.objdump_path);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -1536,9 +1536,9 @@ int cmd_top(int argc, const char **argv) ...@@ -1536,9 +1536,9 @@ int cmd_top(int argc, const char **argv)
"only consider symbols in these comms"), "only consider symbols in these comms"),
OPT_STRING(0, "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", OPT_STRING(0, "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
"only consider these symbols"), "only consider these symbols"),
OPT_BOOLEAN(0, "source", &top.annotation_opts.annotate_src, OPT_BOOLEAN(0, "source", &annotate_opts.annotate_src,
"Interleave source code with assembly code (default)"), "Interleave source code with assembly code (default)"),
OPT_BOOLEAN(0, "asm-raw", &top.annotation_opts.show_asm_raw, OPT_BOOLEAN(0, "asm-raw", &annotate_opts.show_asm_raw,
"Display raw encoding of assembly instructions (default)"), "Display raw encoding of assembly instructions (default)"),
OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel, OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel,
"Enable kernel symbol demangling"), "Enable kernel symbol demangling"),
...@@ -1549,9 +1549,9 @@ int cmd_top(int argc, const char **argv) ...@@ -1549,9 +1549,9 @@ int cmd_top(int argc, const char **argv)
"addr2line binary to use for line numbers"), "addr2line binary to use for line numbers"),
OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style", OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style",
"Specify disassembler style (e.g. -M intel for intel syntax)"), "Specify disassembler style (e.g. -M intel for intel syntax)"),
OPT_STRING(0, "prefix", &top.annotation_opts.prefix, "prefix", OPT_STRING(0, "prefix", &annotate_opts.prefix, "prefix",
"Add prefix to source file path names in programs (with --prefix-strip)"), "Add prefix to source file path names in programs (with --prefix-strip)"),
OPT_STRING(0, "prefix-strip", &top.annotation_opts.prefix_strip, "N", OPT_STRING(0, "prefix-strip", &annotate_opts.prefix_strip, "N",
"Strip first N entries of source file path name in programs (with --prefix)"), "Strip first N entries of source file path name in programs (with --prefix)"),
OPT_STRING('u', "uid", &target->uid_str, "user", "user to profile"), OPT_STRING('u', "uid", &target->uid_str, "user", "user to profile"),
OPT_CALLBACK(0, "percent-limit", &top, "percent", OPT_CALLBACK(0, "percent-limit", &top, "percent",
...@@ -1609,10 +1609,10 @@ int cmd_top(int argc, const char **argv) ...@@ -1609,10 +1609,10 @@ int cmd_top(int argc, const char **argv)
if (status < 0) if (status < 0)
return status; return status;
annotation_options__init(&top.annotation_opts); annotation_options__init(&annotate_opts);
top.annotation_opts.min_pcnt = 5; annotate_opts.min_pcnt = 5;
top.annotation_opts.context = 4; annotate_opts.context = 4;
top.evlist = evlist__new(); top.evlist = evlist__new();
if (top.evlist == NULL) if (top.evlist == NULL)
...@@ -1642,13 +1642,13 @@ int cmd_top(int argc, const char **argv) ...@@ -1642,13 +1642,13 @@ int cmd_top(int argc, const char **argv)
usage_with_options(top_usage, options); usage_with_options(top_usage, options);
if (disassembler_style) { if (disassembler_style) {
top.annotation_opts.disassembler_style = strdup(disassembler_style); annotate_opts.disassembler_style = strdup(disassembler_style);
if (!top.annotation_opts.disassembler_style) if (!annotate_opts.disassembler_style)
return -ENOMEM; return -ENOMEM;
} }
if (objdump_path) { if (objdump_path) {
top.annotation_opts.objdump_path = strdup(objdump_path); annotate_opts.objdump_path = strdup(objdump_path);
if (!top.annotation_opts.objdump_path) if (!annotate_opts.objdump_path)
return -ENOMEM; return -ENOMEM;
} }
if (addr2line_path) { if (addr2line_path) {
...@@ -1661,7 +1661,7 @@ int cmd_top(int argc, const char **argv) ...@@ -1661,7 +1661,7 @@ int cmd_top(int argc, const char **argv)
if (status) if (status)
goto out_delete_evlist; goto out_delete_evlist;
if (annotate_check_args(&top.annotation_opts) < 0) if (annotate_check_args(&annotate_opts) < 0)
goto out_delete_evlist; goto out_delete_evlist;
if (!top.evlist->core.nr_entries) { if (!top.evlist->core.nr_entries) {
...@@ -1787,7 +1787,7 @@ int cmd_top(int argc, const char **argv) ...@@ -1787,7 +1787,7 @@ int cmd_top(int argc, const char **argv)
if (status < 0) if (status < 0)
goto out_delete_evlist; goto out_delete_evlist;
annotation_config__init(&top.annotation_opts); annotation_config__init(&annotate_opts);
symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL); symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
status = symbol__init(NULL); status = symbol__init(NULL);
...@@ -1840,7 +1840,7 @@ int cmd_top(int argc, const char **argv) ...@@ -1840,7 +1840,7 @@ int cmd_top(int argc, const char **argv)
out_delete_evlist: out_delete_evlist:
evlist__delete(top.evlist); evlist__delete(top.evlist);
perf_session__delete(top.session); perf_session__delete(top.session);
annotation_options__exit(&top.annotation_opts); annotation_options__exit(&annotate_opts);
return status; return status;
} }
...@@ -21,7 +21,6 @@ struct perf_top { ...@@ -21,7 +21,6 @@ struct perf_top {
struct perf_tool tool; struct perf_tool tool;
struct evlist *evlist, *sb_evlist; struct evlist *evlist, *sb_evlist;
struct record_opts record_opts; struct record_opts record_opts;
struct annotation_options annotation_opts;
struct evswitch evswitch; struct evswitch evswitch;
/* /*
* Symbols will be added here in perf_event__process_sample and will * Symbols will be added here in perf_event__process_sample and will
......
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