Browse Source

perf annotate: Adopt anotation options from symbol_conf

Continuing to group annotation options in an annotation specific struct.

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-astei92tzxp4yccag5pxb2h7@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Arnaldo Carvalho de Melo 7 years ago
parent
commit
1eddd9e410

+ 2 - 2
tools/perf/builtin-annotate.c

@@ -515,9 +515,9 @@ int cmd_annotate(int argc, const char **argv)
 	OPT_CALLBACK(0, "symfs", NULL, "directory",
 	OPT_CALLBACK(0, "symfs", NULL, "directory",
 		     "Look for files with symbols relative to this directory",
 		     "Look for files with symbols relative to this directory",
 		     symbol__config_symfs),
 		     symbol__config_symfs),
-	OPT_BOOLEAN(0, "source", &symbol_conf.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", &symbol_conf.annotate_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_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)"),

+ 4 - 2
tools/perf/builtin-report.c

@@ -71,6 +71,7 @@ struct report {
 	bool			group_set;
 	bool			group_set;
 	int			max_stack;
 	int			max_stack;
 	struct perf_read_values	show_threads_values;
 	struct perf_read_values	show_threads_values;
+	struct annotation_options annotation_opts;
 	const char		*pretty_printing_style;
 	const char		*pretty_printing_style;
 	const char		*cpu_list;
 	const char		*cpu_list;
 	const char		*symbol_filter_str;
 	const char		*symbol_filter_str;
@@ -988,6 +989,7 @@ int cmd_report(int argc, const char **argv)
 		.max_stack		 = PERF_MAX_STACK_DEPTH,
 		.max_stack		 = PERF_MAX_STACK_DEPTH,
 		.pretty_printing_style	 = "normal",
 		.pretty_printing_style	 = "normal",
 		.socket_filter		 = -1,
 		.socket_filter		 = -1,
+		.annotation_opts	 = annotation__default_options,
 	};
 	};
 	const struct option options[] = {
 	const struct option options[] = {
 	OPT_STRING('i', "input", &input_name, "file",
 	OPT_STRING('i', "input", &input_name, "file",
@@ -1077,9 +1079,9 @@ int cmd_report(int argc, const char **argv)
 		   "list of cpus to profile"),
 		   "list of cpus to profile"),
 	OPT_BOOLEAN('I', "show-info", &report.show_full_info,
 	OPT_BOOLEAN('I', "show-info", &report.show_full_info,
 		    "Display extended information about perf.data file"),
 		    "Display extended information about perf.data file"),
-	OPT_BOOLEAN(0, "source", &symbol_conf.annotate_src,
+	OPT_BOOLEAN(0, "source", &report.annotation_opts.annotate_src,
 		    "Interleave source code with assembly code (default)"),
 		    "Interleave source code with assembly code (default)"),
-	OPT_BOOLEAN(0, "asm-raw", &symbol_conf.annotate_asm_raw,
+	OPT_BOOLEAN(0, "asm-raw", &report.annotation_opts.show_asm_raw,
 		    "Display raw encoding of assembly instructions (default)"),
 		    "Display raw encoding of assembly instructions (default)"),
 	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)"),

+ 2 - 2
tools/perf/builtin-top.c

@@ -1340,9 +1340,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", &symbol_conf.annotate_src,
+	OPT_BOOLEAN(0, "source", &top.annotation_opts.annotate_src,
 		    "Interleave source code with assembly code (default)"),
 		    "Interleave source code with assembly code (default)"),
-	OPT_BOOLEAN(0, "asm-raw", &symbol_conf.annotate_asm_raw,
+	OPT_BOOLEAN(0, "asm-raw", &top.annotation_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"),

+ 4 - 2
tools/perf/util/annotate.c

@@ -47,6 +47,7 @@
 struct annotation_options annotation__default_options = {
 struct annotation_options annotation__default_options = {
 	.use_offset     = true,
 	.use_offset     = true,
 	.jump_arrows    = true,
 	.jump_arrows    = true,
+	.annotate_src	= true,
 	.offset_level	= ANNOTATION__OFFSET_JUMP_TARGETS,
 	.offset_level	= ANNOTATION__OFFSET_JUMP_TARGETS,
 };
 };
 
 
@@ -1609,6 +1610,7 @@ fallback:
 
 
 static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
 static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
 {
 {
+	struct annotation_options *opts = args->options;
 	struct map *map = args->ms.map;
 	struct map *map = args->ms.map;
 	struct dso *dso = map->dso;
 	struct dso *dso = map->dso;
 	char *command;
 	char *command;
@@ -1661,8 +1663,8 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
 		 disassembler_style ? disassembler_style : "",
 		 disassembler_style ? disassembler_style : "",
 		 map__rip_2objdump(map, sym->start),
 		 map__rip_2objdump(map, sym->start),
 		 map__rip_2objdump(map, sym->end),
 		 map__rip_2objdump(map, sym->end),
-		 symbol_conf.annotate_asm_raw ? "" : "--no-show-raw",
-		 symbol_conf.annotate_src ? "-S" : "",
+		 opts->show_asm_raw ? "" : "--no-show-raw",
+		 opts->annotate_src ? "-S" : "",
 		 symfs_filename, symfs_filename);
 		 symfs_filename, symfs_filename);
 
 
 	if (err < 0) {
 	if (err < 0) {

+ 3 - 1
tools/perf/util/annotate.h

@@ -73,7 +73,9 @@ struct annotation_options {
 	     show_nr_jumps,
 	     show_nr_jumps,
 	     show_nr_samples,
 	     show_nr_samples,
 	     show_total_period,
 	     show_total_period,
-	     show_minmax_cycle;
+	     show_minmax_cycle,
+	     show_asm_raw,
+	     annotate_src;
 	u8   offset_level;
 	u8   offset_level;
 	int  min_pcnt;
 	int  min_pcnt;
 	int  max_lines;
 	int  max_lines;

+ 0 - 1
tools/perf/util/symbol.c

@@ -40,7 +40,6 @@ char **vmlinux_path;
 struct symbol_conf symbol_conf = {
 struct symbol_conf symbol_conf = {
 	.use_modules		= true,
 	.use_modules		= true,
 	.try_vmlinux_path	= true,
 	.try_vmlinux_path	= true,
-	.annotate_src		= true,
 	.demangle		= true,
 	.demangle		= true,
 	.demangle_kernel	= false,
 	.demangle_kernel	= false,
 	.cumulate_callchain	= true,
 	.cumulate_callchain	= true,

+ 0 - 2
tools/perf/util/symbol.h

@@ -108,8 +108,6 @@ struct symbol_conf {
 			show_cpu_utilization,
 			show_cpu_utilization,
 			initialized,
 			initialized,
 			kptr_restrict,
 			kptr_restrict,
-			annotate_asm_raw,
-			annotate_src,
 			event_group,
 			event_group,
 			demangle,
 			demangle,
 			demangle_kernel,
 			demangle_kernel,