mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-19 12:24:34 +08:00
perf annotate: Introduce global annotation_options
The annotation options are to control the behavior of objdump and the output. It's basically used by 'perf annotate' but 'perf report' and 'perf top' can call it on TUI dynamically. But it doesn't need to have a copy of annotation options in many places. As most of the work is done in the util/annotate.c file, add a global variable and set/use it instead of having their own copies. Reviewed-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung 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-2-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
0713ab3bd1
commit
9d03194a36
@ -45,7 +45,6 @@
|
||||
struct perf_annotate {
|
||||
struct perf_tool tool;
|
||||
struct perf_session *session;
|
||||
struct annotation_options opts;
|
||||
#ifdef HAVE_SLANG_SUPPORT
|
||||
bool use_tui;
|
||||
#endif
|
||||
@ -318,9 +317,9 @@ static int hist_entry__tty_annotate(struct hist_entry *he,
|
||||
struct perf_annotate *ann)
|
||||
{
|
||||
if (!ann->use_stdio2)
|
||||
return symbol__tty_annotate(&he->ms, evsel, &ann->opts);
|
||||
return symbol__tty_annotate(&he->ms, evsel, &annotate_opts);
|
||||
|
||||
return symbol__tty_annotate2(&he->ms, evsel, &ann->opts);
|
||||
return symbol__tty_annotate2(&he->ms, evsel, &annotate_opts);
|
||||
}
|
||||
|
||||
static void hists__find_annotations(struct hists *hists,
|
||||
@ -376,14 +375,14 @@ find_next:
|
||||
return;
|
||||
}
|
||||
|
||||
ret = annotate(he, evsel, &ann->opts, NULL);
|
||||
ret = annotate(he, evsel, &annotate_opts, NULL);
|
||||
if (!ret || !ann->skip_missing)
|
||||
return;
|
||||
|
||||
/* skip missing symbols */
|
||||
nd = rb_next(nd);
|
||||
} else if (use_browser == 1) {
|
||||
key = hist_entry__tui_annotate(he, evsel, NULL, &ann->opts);
|
||||
key = hist_entry__tui_annotate(he, evsel, NULL, &annotate_opts);
|
||||
|
||||
switch (key) {
|
||||
case -1:
|
||||
@ -425,9 +424,9 @@ static int __cmd_annotate(struct perf_annotate *ann)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!ann->opts.objdump_path) {
|
||||
if (!annotate_opts.objdump_path) {
|
||||
ret = perf_env__lookup_objdump(&session->header.env,
|
||||
&ann->opts.objdump_path);
|
||||
&annotate_opts.objdump_path);
|
||||
if (ret)
|
||||
goto out;
|
||||
}
|
||||
@ -561,9 +560,9 @@ int cmd_annotate(int argc, const char **argv)
|
||||
"file", "vmlinux pathname"),
|
||||
OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
|
||||
"load module symbols - WARNING: use only with -k and LIVE kernel"),
|
||||
OPT_BOOLEAN('l', "print-line", &annotate.opts.print_lines,
|
||||
OPT_BOOLEAN('l', "print-line", &annotate_opts.print_lines,
|
||||
"print matching source lines (may be slow)"),
|
||||
OPT_BOOLEAN('P', "full-paths", &annotate.opts.full_path,
|
||||
OPT_BOOLEAN('P', "full-paths", &annotate_opts.full_path,
|
||||
"Don't shorten the displayed pathnames"),
|
||||
OPT_BOOLEAN(0, "skip-missing", &annotate.skip_missing,
|
||||
"Skip symbols that cannot be annotated"),
|
||||
@ -574,15 +573,15 @@ int cmd_annotate(int argc, const char **argv)
|
||||
OPT_CALLBACK(0, "symfs", NULL, "directory",
|
||||
"Look for files with symbols relative to this directory",
|
||||
symbol__config_symfs),
|
||||
OPT_BOOLEAN(0, "source", &annotate.opts.annotate_src,
|
||||
OPT_BOOLEAN(0, "source", &annotate_opts.annotate_src,
|
||||
"Interleave source code with assembly code (default)"),
|
||||
OPT_BOOLEAN(0, "asm-raw", &annotate.opts.show_asm_raw,
|
||||
OPT_BOOLEAN(0, "asm-raw", &annotate_opts.show_asm_raw,
|
||||
"Display raw encoding of assembly instructions (default)"),
|
||||
OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style",
|
||||
"Specify disassembler style (e.g. -M intel for intel syntax)"),
|
||||
OPT_STRING(0, "prefix", &annotate.opts.prefix, "prefix",
|
||||
OPT_STRING(0, "prefix", &annotate_opts.prefix, "prefix",
|
||||
"Add prefix to source file path names in programs (with --prefix-strip)"),
|
||||
OPT_STRING(0, "prefix-strip", &annotate.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)"),
|
||||
OPT_STRING(0, "objdump", &objdump_path, "path",
|
||||
"objdump binary to use for disassembly and annotations"),
|
||||
@ -601,7 +600,7 @@ int cmd_annotate(int argc, const char **argv)
|
||||
OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
|
||||
"'always' (default), 'never' or 'auto' only applicable to --stdio mode",
|
||||
stdio__config_color, "always"),
|
||||
OPT_CALLBACK(0, "percent-type", &annotate.opts, "local-period",
|
||||
OPT_CALLBACK(0, "percent-type", &annotate_opts, "local-period",
|
||||
"Set percent type local/global-period/hits",
|
||||
annotate_parse_percent_type),
|
||||
OPT_CALLBACK(0, "percent-limit", &annotate, "percent",
|
||||
@ -617,13 +616,13 @@ int cmd_annotate(int argc, const char **argv)
|
||||
set_option_flag(options, 0, "show-total-period", PARSE_OPT_EXCLUSIVE);
|
||||
set_option_flag(options, 0, "show-nr-samples", PARSE_OPT_EXCLUSIVE);
|
||||
|
||||
annotation_options__init(&annotate.opts);
|
||||
annotation_options__init(&annotate_opts);
|
||||
|
||||
ret = hists__init();
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
annotation_config__init(&annotate.opts);
|
||||
annotation_config__init(&annotate_opts);
|
||||
|
||||
argc = parse_options(argc, argv, options, annotate_usage, 0);
|
||||
if (argc) {
|
||||
@ -638,13 +637,13 @@ int cmd_annotate(int argc, const char **argv)
|
||||
}
|
||||
|
||||
if (disassembler_style) {
|
||||
annotate.opts.disassembler_style = strdup(disassembler_style);
|
||||
if (!annotate.opts.disassembler_style)
|
||||
annotate_opts.disassembler_style = strdup(disassembler_style);
|
||||
if (!annotate_opts.disassembler_style)
|
||||
return -ENOMEM;
|
||||
}
|
||||
if (objdump_path) {
|
||||
annotate.opts.objdump_path = strdup(objdump_path);
|
||||
if (!annotate.opts.objdump_path)
|
||||
annotate_opts.objdump_path = strdup(objdump_path);
|
||||
if (!annotate_opts.objdump_path)
|
||||
return -ENOMEM;
|
||||
}
|
||||
if (addr2line_path) {
|
||||
@ -653,7 +652,7 @@ int cmd_annotate(int argc, const char **argv)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (annotate_check_args(&annotate.opts) < 0)
|
||||
if (annotate_check_args(&annotate_opts) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
#ifdef HAVE_GTK2_SUPPORT
|
||||
@ -734,7 +733,7 @@ out_delete:
|
||||
#ifndef NDEBUG
|
||||
perf_session__delete(annotate.session);
|
||||
#endif
|
||||
annotation_options__exit(&annotate.opts);
|
||||
annotation_options__exit(&annotate_opts);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -57,6 +57,9 @@
|
||||
|
||||
#include <linux/ctype.h>
|
||||
|
||||
/* global annotation options */
|
||||
struct annotation_options annotate_opts;
|
||||
|
||||
static regex_t file_lineno;
|
||||
|
||||
static struct ins_ops *ins__find(struct arch *arch, const char *name);
|
||||
|
@ -105,6 +105,8 @@ struct annotation_options {
|
||||
unsigned int percent_type;
|
||||
};
|
||||
|
||||
extern struct annotation_options annotate_opts;
|
||||
|
||||
enum {
|
||||
ANNOTATION__OFFSET_JUMP_TARGETS = 1,
|
||||
ANNOTATION__OFFSET_CALL,
|
||||
|
Loading…
Reference in New Issue
Block a user