From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Daniel Shaulov <daniel.shaulov@gmail.com>
Cc: Daniel Shaulov <daniel.shaulov@granulate.io>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Thomas Richter <tmricht@linux.ibm.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf probe: Add support for DW_OP_call_frame_cfa vars
Date: Thu, 2 Apr 2020 15:49:43 -0300 [thread overview]
Message-ID: <20200402184943.GB23243@kernel.org> (raw)
In-Reply-To: <20200401161954.44640-1-daniel.shaulov@granulate.io>
Em Wed, Apr 01, 2020 at 07:19:52PM +0300, Daniel Shaulov escreveu:
> Add support for probes on variables with DW_OP_call_frame_cfa
> as the dwarf operation in the debug info.
>
> Some compilers (specifically Golang compiler) output
> DW_OP_call_frame_cfa instead of DW_OP_fbreg for variables
> on the stack. If DW_OP_call_frame_cfa is the only expression
> than it is the same as DW_OP_fbreg with an offset of zero.
> In the case of the Golang compiler, DW_OP_call_frame_cfa may
> be followed by DW_OP_consts, with a number and than DW_OP_plus.
> This trio is the same as DW_OP_fbreg with the number from
> DW_OP_consts as the offset.
>
> With this change, probing on functions in Golang with variables works.
Masami, can I have your Reviewed-by, please?
Daniel, next time please consider providing precise steps to show what
wasn't working and then how the patch solves the problem, i.e. get some
go program, show the command lines used to build, probe, etc.
- Arnaldo
> Signed-off-by: Daniel Shaulov <daniel.shaulov@granulate.io>
> ---
> tools/perf/util/probe-finder.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
> index e4cff49384f4..866b17aea263 100644
> --- a/tools/perf/util/probe-finder.c
> +++ b/tools/perf/util/probe-finder.c
> @@ -240,11 +240,23 @@ static int convert_variable_location(Dwarf_Die *vr_die, Dwarf_Addr addr,
> }
>
> /* If this is based on frame buffer, set the offset */
> - if (op->atom == DW_OP_fbreg) {
> + if (op->atom == DW_OP_fbreg || op->atom == DW_OP_call_frame_cfa) {
> if (fb_ops == NULL)
> return -ENOTSUP;
> ref = true;
> - offs = op->number;
> + if (op->atom == DW_OP_fbreg) {
> + offs = op->number;
> + } else if (nops == 3) {
> + /*
> + * In the case of DW_OP_call_frame_cfa, we either have
> + * an offset of 0 or we have two more expressions that
> + * add a const
> + */
> + if ((op + 1)->atom != DW_OP_consts ||
> + (op + 2)->atom != DW_OP_plus)
> + return -ENOTSUP;
> + offs = (op + 1)->number;
> + }
> op = &fb_ops[0];
> }
>
> --
> 2.22.0
>
--
- Arnaldo
next prev parent reply other threads:[~2020-04-02 18:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-01 16:19 [PATCH] perf probe: Add support for DW_OP_call_frame_cfa vars Daniel Shaulov
2020-04-02 18:49 ` Arnaldo Carvalho de Melo [this message]
2020-04-02 20:25 ` Daniel Shaulov
2020-04-03 5:39 ` Masami Hiramatsu
2020-04-03 13:02 ` Arnaldo Carvalho de Melo
2020-04-03 17:59 ` Daniel Shaulov
2020-04-03 5:43 ` Masami Hiramatsu
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=20200402184943.GB23243@kernel.org \
--to=arnaldo.melo@gmail.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=daniel.shaulov@gmail.com \
--cc=daniel.shaulov@granulate.io \
--cc=gregkh@linuxfoundation.org \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=tmricht@linux.ibm.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