From: m.liska@foxlink.cz
To: linux-kernel@vger.kernel.org
Cc: linux-perf-users@vger.kernel.org, acme@kernel.org,
irogers@google.com, Martin Liska <martin.liska@hey.com>
Subject: [PATCH] perf script: add --addr2line option
Date: Thu, 18 Jul 2024 16:30:09 +0200 [thread overview]
Message-ID: <20240718143009.197851-1-m.liska@foxlink.cz> (raw)
From: Martin Liska <martin.liska@hey.com>
Similarly to other subcommands (like report, top), it would be handy to
provide a path for addr2line command.
---
tools/perf/Documentation/perf-script.txt | 3 +++
tools/perf/builtin-script.c | 10 +++++++++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index ff086ef05a0c..5abb960c4960 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -369,6 +369,9 @@ OPTIONS
--demangle-kernel::
Demangle kernel symbol names to human readable form (for C++ kernels).
+--addr2line=<path>::
+ Path to addr2line binary.
+
--header
Show perf.data header.
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index c16224b1fef3..301ea1c98e36 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -3897,7 +3897,7 @@ int cmd_script(int argc, const char **argv)
};
struct utsname uts;
char *script_path = NULL;
- const char *dlfilter_file = NULL;
+ const char *dlfilter_file = NULL, *addr2line_path = NULL;
const char **__argv;
int i, j, err = 0;
struct perf_script script = {
@@ -4052,6 +4052,8 @@ int cmd_script(int argc, const char **argv)
"Enable symbol demangling"),
OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel,
"Enable kernel symbol demangling"),
+ OPT_STRING(0, "addr2line", &addr2line_path, "path",
+ "addr2line binary to use for line numbers"),
OPT_STRING(0, "time", &script.time_str, "str",
"Time span of interest (start,stop)"),
OPT_BOOLEAN(0, "inline", &symbol_conf.inline_name,
@@ -4138,6 +4140,12 @@ int cmd_script(int argc, const char **argv)
itrace_synth_opts.callchain_sz > scripting_max_stack)
scripting_max_stack = itrace_synth_opts.callchain_sz;
+ if (addr2line_path) {
+ symbol_conf.addr2line_path = strdup(addr2line_path);
+ if (!symbol_conf.addr2line_path)
+ return -ENOMEM;
+ }
+
/* make sure PERF_EXEC_PATH is set for scripts */
set_argv_exec_path(get_argv_exec_path());
--
2.45.2
next reply other threads:[~2024-07-18 14:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-18 14:30 m.liska [this message]
2024-07-18 15:44 ` Ian Rogers
2024-07-19 10:54 ` Martin Liška
2024-07-19 10:57 ` [PATCH v2] " Martin Liška
2024-08-12 9:42 ` Martin Liška
2024-08-12 13:28 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240718143009.197851-1-m.liska@foxlink.cz \
--to=m.liska@foxlink.cz \
--cc=acme@kernel.org \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=martin.liska@hey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®