On Wednesday 23 April 2014 22:21:07 Andi Kleen wrote:
> Jun Wang <[email protected]> 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
[email protected]
http://milianw.de
--
To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html