Commit 57594454 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo
Browse files

perf symbol: Add command line support for addr2line path



Allow addr2line to be set either on the command line or via the
perfconfig file. This doesn't currently work with llvm-addr2line as
the addr2line code emits two things:
1) the address to decode,
2) a bogus ',' value.
The expectation is the bogus value will generate:
??
??:0
that terminates the addr2line reading. However, the output from
llvm-addr2line is a single line with just the input ',' locking up the
addr2line reading that is expecting a second line.

Signed-off-by: default avatarIan Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: German Gomez <german.gomez@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Tom Rix <trix@redhat.com>
Cc: llvm@lists.linux.dev
Link: https://lore.kernel.org/r/20230328235543.1082207-2-irogers@google.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 0b02b47e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -116,6 +116,9 @@ include::itrace.txt[]
-M::
--disassembler-style=:: Set disassembler style for objdump.

--addr2line=<path>::
        Path to addr2line binary.

--objdump=<path>::
        Path to objdump binary.

+3 −0
Original line number Diff line number Diff line
@@ -250,6 +250,9 @@ annotate.*::
	These are in control of addresses, jump function, source code
	in lines of assembly code from a specific program.

	annotate.addr2line::
		addr2line binary to use for file names and line numbers.

	annotate.objdump::
		objdump binary to use for disassembly and annotations.

+3 −0
Original line number Diff line number Diff line
@@ -381,6 +381,9 @@ OPTIONS
	This allows to examine the path the program took to each sample.
	The data collection must have used -b (or -j) and -g.

--addr2line=<path>::
        Path to addr2line binary.

--objdump=<path>::
        Path to objdump binary.

+6 −0
Original line number Diff line number Diff line
@@ -161,6 +161,12 @@ Default is to monitor all CPUS.
-M::
--disassembler-style=:: Set disassembler style for objdump.

--addr2line=<path>::
        Path to addr2line binary.

--objdump=<path>::
        Path to objdump binary.

--prefix=PREFIX::
--prefix-strip=N::
        Remove first N entries from source file path names in executables
+8 −1
Original line number Diff line number Diff line
@@ -517,7 +517,7 @@ int cmd_annotate(int argc, const char **argv)
	struct itrace_synth_opts itrace_synth_opts = {
		.set = 0,
	};
	const char *disassembler_style = NULL, *objdump_path = NULL;
	const char *disassembler_style = NULL, *objdump_path = NULL, *addr2line_path = NULL;
	struct option options[] = {
	OPT_STRING('i', "input", &input_name, "file",
		    "input file name"),
@@ -570,6 +570,8 @@ int cmd_annotate(int argc, const char **argv)
		    "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"),
	OPT_STRING(0, "addr2line", &addr2line_path, "path",
		   "addr2line binary to use for line numbers"),
	OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle,
		    "Enable symbol demangling"),
	OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel,
@@ -629,6 +631,11 @@ int cmd_annotate(int argc, const char **argv)
		if (!annotate.opts.objdump_path)
			return -ENOMEM;
	}
	if (addr2line_path) {
		symbol_conf.addr2line_path = strdup(addr2line_path);
		if (!symbol_conf.addr2line_path)
			return -ENOMEM;
	}

	if (annotate_check_args(&annotate.opts) < 0)
		return -EINVAL;
Loading