[PATCH v2] perf script: add --addr2line option

Martin Liška posted 1 patch 1 year, 4 months ago
tools/perf/Documentation/perf-script.txt | 3 +++
tools/perf/builtin-script.c              | 2 ++
tools/perf/util/symbol_conf.h            | 2 +-
3 files changed, 6 insertions(+), 1 deletion(-)
[PATCH v2] perf script: add --addr2line option
Posted by Martin Liška 1 year, 4 months ago
Similarly to other subcommands (like report, top), it would be handy to
provide a path for addr2line command.

Signed-off-by: Martin Liska <martin.liska@hey.com>
---
 tools/perf/Documentation/perf-script.txt | 3 +++
 tools/perf/builtin-script.c              | 2 ++
 tools/perf/util/symbol_conf.h            | 2 +-
 3 files changed, 6 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..932167b2362b 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -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", &symbol_conf.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,
diff --git a/tools/perf/util/symbol_conf.h b/tools/perf/util/symbol_conf.h
index c114bbceef40..d41b25e10f1b 100644
--- a/tools/perf/util/symbol_conf.h
+++ b/tools/perf/util/symbol_conf.h
@@ -63,7 +63,7 @@ struct symbol_conf {
 			*sym_list_str,
 			*col_width_list_str,
 			*bt_stop_list_str;
-	char		*addr2line_path;
+	const char		*addr2line_path;
 	unsigned long	time_quantum;
        struct strlist	*dso_list,
 			*comm_list,
-- 
2.45.2
Re: [PATCH v2] perf script: add --addr2line option
Posted by Martin Liška 1 year, 4 months ago
@acme: May I please ping this patch?

Thanks,
Martin

On 7/19/24 12:57, Martin Liška wrote:
> Similarly to other subcommands (like report, top), it would be handy to
> provide a path for addr2line command.
> 
> Signed-off-by: Martin Liska <martin.liska@hey.com>
> ---
>  tools/perf/Documentation/perf-script.txt | 3 +++
>  tools/perf/builtin-script.c              | 2 ++
>  tools/perf/util/symbol_conf.h            | 2 +-
>  3 files changed, 6 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..932167b2362b 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -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", &symbol_conf.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,
> diff --git a/tools/perf/util/symbol_conf.h b/tools/perf/util/symbol_conf.h
> index c114bbceef40..d41b25e10f1b 100644
> --- a/tools/perf/util/symbol_conf.h
> +++ b/tools/perf/util/symbol_conf.h
> @@ -63,7 +63,7 @@ struct symbol_conf {
>  			*sym_list_str,
>  			*col_width_list_str,
>  			*bt_stop_list_str;
> -	char		*addr2line_path;
> +	const char		*addr2line_path;
>  	unsigned long	time_quantum;
>         struct strlist	*dso_list,
>  			*comm_list,
Re: [PATCH v2] perf script: add --addr2line option
Posted by Arnaldo Carvalho de Melo 1 year, 4 months ago
On Mon, Aug 12, 2024 at 11:42:31AM +0200, Martin Liška wrote:
> @acme: May I please ping this patch?

Simple enough, merged, thanks for the ping.

- Arnaldo
 
> Thanks,
> Martin
> 
> On 7/19/24 12:57, Martin Liška wrote:
> > Similarly to other subcommands (like report, top), it would be handy to
> > provide a path for addr2line command.
> > 
> > Signed-off-by: Martin Liska <martin.liska@hey.com>
> > ---
> >  tools/perf/Documentation/perf-script.txt | 3 +++
> >  tools/perf/builtin-script.c              | 2 ++
> >  tools/perf/util/symbol_conf.h            | 2 +-
> >  3 files changed, 6 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..932167b2362b 100644
> > --- a/tools/perf/builtin-script.c
> > +++ b/tools/perf/builtin-script.c
> > @@ -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", &symbol_conf.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,
> > diff --git a/tools/perf/util/symbol_conf.h b/tools/perf/util/symbol_conf.h
> > index c114bbceef40..d41b25e10f1b 100644
> > --- a/tools/perf/util/symbol_conf.h
> > +++ b/tools/perf/util/symbol_conf.h
> > @@ -63,7 +63,7 @@ struct symbol_conf {
> >  			*sym_list_str,
> >  			*col_width_list_str,
> >  			*bt_stop_list_str;
> > -	char		*addr2line_path;
> > +	const char		*addr2line_path;
> >  	unsigned long	time_quantum;
> >         struct strlist	*dso_list,
> >  			*comm_list,