From 57594454ceb92defaa0707cf29289f0c3c266ede Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Tue, 28 Mar 2023 16:55:43 -0700 Subject: 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: Ian Rogers Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Andres Freund Cc: German Gomez Cc: Ingo Molnar Cc: James Clark Cc: Jiri Olsa Cc: Kan Liang Cc: Mark Rutland Cc: Namhyung Kim Cc: Nathan Chancellor Cc: Nick Desaulniers Cc: Peter Zijlstra Cc: Sandipan Das Cc: Tom Rix Cc: llvm@lists.linux.dev Link: https://lore.kernel.org/r/20230328235543.1082207-2-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-report.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tools/perf/builtin-report.c') diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 15b0cf649e1a..4011abc03d0d 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -1226,7 +1226,7 @@ int cmd_report(int argc, const char **argv) }; char *sort_order_help = sort_help("sort by key(s):"); char *field_order_help = sort_help("output field(s): overhead period sample "); - const char *disassembler_style = NULL, *objdump_path = NULL; + const char *disassembler_style = NULL, *objdump_path = NULL, *addr2line_path = NULL; const struct option options[] = { OPT_STRING('i', "input", &input_name, "file", "input file name"), @@ -1344,6 +1344,8 @@ int cmd_report(int argc, const char **argv) "add last branch records to call history"), 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, "Disable symbol demangling"), OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel, @@ -1430,6 +1432,11 @@ int cmd_report(int argc, const char **argv) if (!report.annotation_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(&report.annotation_opts) < 0) { ret = -EINVAL; -- cgit