Browse Source

perf tools: Disable kernel symbol demangling by default

Some Linux symbols (for example __vt_event_wait) are interpreted by the
demangler as C++ mangled names, which of course they aren't.

Disable kernel symbol demangling by default to avoid this, and allow
enabling it with a new option --demangle-kernel for those who wish it.

Reported-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1410581705-26968-1-git-send-email-avi@cloudius-systems.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Avi Kivity 11 years ago
parent
commit
763122ade7

+ 3 - 0
tools/perf/Documentation/perf-probe.txt

@@ -104,6 +104,9 @@ OPTIONS
 	Specify path to the executable or shared library file for user
 	Specify path to the executable or shared library file for user
 	space tracing. Can also be used with --funcs option.
 	space tracing. Can also be used with --funcs option.
 
 
+--demangle-kernel::
+	Demangle kernel symbols.
+
 In absence of -m/-x options, perf probe checks if the first argument after
 In absence of -m/-x options, perf probe checks if the first argument after
 the options is an absolute path name. If its an absolute path, perf probe
 the options is an absolute path name. If its an absolute path, perf probe
 uses it as a target module/target user space binary to probe.
 uses it as a target module/target user space binary to probe.

+ 3 - 0
tools/perf/Documentation/perf-report.txt

@@ -276,6 +276,9 @@ OPTIONS
 	Demangle symbol names to human readable form. It's enabled by default,
 	Demangle symbol names to human readable form. It's enabled by default,
 	disable with --no-demangle.
 	disable with --no-demangle.
 
 
+--demangle-kernel::
+	Demangle kernel symbol names to human readable form (for C++ kernels).
+
 --mem-mode::
 --mem-mode::
 	Use the data addresses of samples in addition to instruction addresses
 	Use the data addresses of samples in addition to instruction addresses
 	to build the histograms.  To generate meaningful output, the perf.data
 	to build the histograms.  To generate meaningful output, the perf.data

+ 3 - 0
tools/perf/Documentation/perf-top.txt

@@ -98,6 +98,9 @@ Default is to monitor all CPUS.
 --hide_user_symbols::
 --hide_user_symbols::
         Hide user symbols.
         Hide user symbols.
 
 
+--demangle-kernel::
+        Demangle kernel symbols.
+
 -D::
 -D::
 --dump-symtab::
 --dump-symtab::
         Dump the symbol table used for profiling.
         Dump the symbol table used for profiling.

+ 2 - 0
tools/perf/builtin-probe.c

@@ -376,6 +376,8 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
 			"target executable name or path", opt_set_target),
 			"target executable name or path", opt_set_target),
 	OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle,
 	OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle,
 		    "Disable symbol demangling"),
 		    "Disable symbol demangling"),
+	OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel,
+		    "Enable kernel symbol demangling"),
 	OPT_END()
 	OPT_END()
 	};
 	};
 	int ret;
 	int ret;

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

@@ -680,6 +680,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 		   "objdump binary to use for disassembly and annotations"),
 		   "objdump binary to use for disassembly and annotations"),
 	OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle,
 	OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle,
 		    "Disable symbol demangling"),
 		    "Disable symbol demangling"),
+	OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel,
+		    "Enable kernel symbol demangling"),
 	OPT_BOOLEAN(0, "mem-mode", &report.mem_mode, "mem access profile"),
 	OPT_BOOLEAN(0, "mem-mode", &report.mem_mode, "mem access profile"),
 	OPT_CALLBACK(0, "percent-limit", &report, "percent",
 	OPT_CALLBACK(0, "percent-limit", &report, "percent",
 		     "Don't show entries under that percent", parse_percent_limit),
 		     "Don't show entries under that percent", parse_percent_limit),

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

@@ -1142,6 +1142,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
 		    "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", &symbol_conf.annotate_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,
+		    "Enable kernel symbol demangling"),
 	OPT_STRING(0, "objdump", &objdump_path, "path",
 	OPT_STRING(0, "objdump", &objdump_path, "path",
 		    "objdump binary to use for disassembly and annotations"),
 		    "objdump binary to use for disassembly and annotations"),
 	OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style",
 	OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style",

+ 6 - 1
tools/perf/util/symbol-elf.c

@@ -680,6 +680,11 @@ static u64 ref_reloc(struct kmap *kmap)
 	return 0;
 	return 0;
 }
 }
 
 
+static bool want_demangle(bool is_kernel_sym)
+{
+	return is_kernel_sym ? symbol_conf.demangle_kernel : symbol_conf.demangle;
+}
+
 int dso__load_sym(struct dso *dso, struct map *map,
 int dso__load_sym(struct dso *dso, struct map *map,
 		  struct symsrc *syms_ss, struct symsrc *runtime_ss,
 		  struct symsrc *syms_ss, struct symsrc *runtime_ss,
 		  symbol_filter_t filter, int kmodule)
 		  symbol_filter_t filter, int kmodule)
@@ -938,7 +943,7 @@ new_symbol:
 		 * DWARF DW_compile_unit has this, but we don't always have access
 		 * DWARF DW_compile_unit has this, but we don't always have access
 		 * to it...
 		 * to it...
 		 */
 		 */
-		if (symbol_conf.demangle) {
+		if (want_demangle(dso->kernel || kmodule)) {
 			int demangle_flags = DMGL_NO_OPTS;
 			int demangle_flags = DMGL_NO_OPTS;
 			if (verbose)
 			if (verbose)
 				demangle_flags = DMGL_PARAMS | DMGL_ANSI;
 				demangle_flags = DMGL_PARAMS | DMGL_ANSI;

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

@@ -34,6 +34,7 @@ struct symbol_conf symbol_conf = {
 	.try_vmlinux_path	= true,
 	.try_vmlinux_path	= true,
 	.annotate_src		= true,
 	.annotate_src		= true,
 	.demangle		= true,
 	.demangle		= true,
+	.demangle_kernel	= false,
 	.cumulate_callchain	= true,
 	.cumulate_callchain	= true,
 	.show_hist_headers	= true,
 	.show_hist_headers	= true,
 	.symfs			= "",
 	.symfs			= "",

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

@@ -120,6 +120,7 @@ struct symbol_conf {
 			annotate_src,
 			annotate_src,
 			event_group,
 			event_group,
 			demangle,
 			demangle,
+			demangle_kernel,
 			filter_relative,
 			filter_relative,
 			show_hist_headers;
 			show_hist_headers;
 	const char	*vmlinux_name,
 	const char	*vmlinux_name,