linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Milian Wolff <mail@milianw.de>
To: linux-perf-users@vger.kernel.org
Subject: Re: access function parameters with DWARF-less perf probing
Date: Tue, 29 Apr 2014 17:48:48 +0200	[thread overview]
Message-ID: <1580318.2NC4tQu7qN@milian-kdab2> (raw)
In-Reply-To: <87iopzb8vw.fsf@tassilo.jf.intel.com>

On Wednesday 23 April 2014 22:21:07 Andi Kleen wrote:
> Jun Wang <junwang123@gmail.com> writes:
> > Hi Everyone,
> > 
> > With systemTap, in the absence of debugging information (DWARF), one
> > can access function parameters using (positional) numbers. Can the
> > same be done with `perf`?
> > Why? I'm trying to capture variables in a kernel function but I don't
> > have an good perf with DWARF support and there is are significant
> > challenges to build one due to the relatively old distro.
> 
> You can specify the registers according to the ABI.
> di = 1. arg, si = 2nd arg etc.

As I did not directly figure out how one can make use of this, here's what I 
found out:

You'll have to define a tracepoint which catches the function callback:

perf probe -x /usr/lib/libc.so.6 --add malloc="malloc size=%di"

Then, you can access the argument, e.g. perf script -g for a perf.data 
generated with the above tracepoint will contain something like this:

def probe_libc__malloc(event_name, context, common_cpu,
        common_secs, common_nsecs, common_pid, common_comm,
        __probe_ip, size):

Note the "size" argument. Similarly, you could catch the return value like 
this:

perf probe -x /usr/lib/libc.so.6 --add malloc_return="malloc%return 
ret=\$retval"

leading to:

def probe_libc__malloc_return(event_name, context, common_cpu,
        common_secs, common_nsecs, common_pid, common_comm,
        __probe_func, __probe_ret_ip, ret):

Bye
-- 
Milian Wolff
mail@milianw.de
http://milianw.de

      parent reply	other threads:[~2014-04-29 15:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-22 17:31 access function parameters with DWARF-less perf probing Jun Wang
2014-04-24  5:21 ` Andi Kleen
2014-04-24 14:12   ` David Ahern
2014-04-30 18:47     ` Jun Wang
2014-04-29 15:48   ` Milian Wolff [this message]

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=1580318.2NC4tQu7qN@milian-kdab2 \
    --to=mail@milianw.de \
    --cc=linux-perf-users@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).