From: Brendan Gregg <brendan.d.gregg@gmail.com>
To: David Ahern <dsahern@gmail.com>
Cc: "linux-perf-use." <linux-perf-users@vger.kernel.org>
Subject: Re: kprobe string
Date: Wed, 16 Jul 2014 23:29:10 -0700 [thread overview]
Message-ID: <CAE40pdefmx7trDyWnix1tPXNQBeO-cE8-6-p68tojuXry-LGXQ@mail.gmail.com> (raw)
In-Reply-To: <53C753DE.6080306@gmail.com>
G'Day David,
On Wed, Jul 16, 2014 at 9:41 PM, David Ahern <dsahern@gmail.com> wrote:
>
>
> On 07/16/2014 06:51 PM, Brendan Gregg wrote:
>>
>> G'Day,
>>
>> I'm not sure where else to ask this; I don't think this functionality
>> is in perf_events yet...
>>
>> kprobes is supposed to be able to handle string arguments, but I've
>> not been able to find a single working example. I'm trying (on 3.16):
>>
>> # cd /sys/kernel/debug/tracing
>> # echo 'r:getname getname $retval:string' > kprobe_events
>> -bash: echo: write error: Invalid argument
>> # echo 'p:myprobe do_sys_open %dx:string' > kprobe_events
>> -bash: echo: write error: Invalid argument
>>
>> I'm following the syntax in Documentation/trace/kprobetrace.txt by
>> Masami Hiramatsu, and it is recognizing "string". But I'm getting
>> these errors:
>>
>> # dmesg | tail -4
>> [98021.813560] string type has no corresponding fetch method.
>> [98021.813564] Parse error at argument[0]. (-22)
>> [98705.956199] string type has no corresponding fetch method.
>> [98705.956203] Parse error at argument[0]. (-22)
>>
>> Anyone seen this work? I'm checking the source... Thanks in advance,
>
>
> Have you seen this:
> https://lkml.org/lkml/2014/6/19/698
>
Thanks! (I'm trying to keep up with all the perf messages on lkml, but
missed this.)
So, perf can already do this?? And it's the same syntax (":string") as kprobes?
I just tried it out (on 3.14.5):
# perf probe 'getname filename:string'
Added new event:
[...]
# perf record -e probe:getname -a sleep 5
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.234 MB perf.data (~10241 samples) ]
# perf script
perf 13587 [000] 3576718.127120: probe:getname:
(ffffffff811bbd20)
filename_string="/home/bgregg-testtest/libexec/perf-core/sleep"
perf 13587 [000] 3576718.127142: probe:getname:
(ffffffff811bbd20) filename_string="/usr/local/sbin/sleep"
perf 13587 [000] 3576718.127151: probe:getname:
(ffffffff811bbd20) filename_string="/usr/local/bin/sleep"
perf 13587 [000] 3576718.127159: probe:getname:
(ffffffff811bbd20) filename_string="/usr/sbin/sleep"
perf 13587 [000] 3576718.127170: probe:getname:
(ffffffff811bbd20) filename_string="/usr/bin/sleep"
perf 13587 [000] 3576718.127180: probe:getname:
(ffffffff811bbd20) filename_string="/sbin/sleep"
perf 13587 [000] 3576718.127189: probe:getname:
(ffffffff811bbd20) filename_string="/bin/sleep"
sleep 13587 [000] 3576718.162025: probe:getname:
(ffffffff811bbd20) filename_string="/etc/ld.so.cache"
sleep 13587 [000] 3576718.162057: probe:getname:
(ffffffff811bbd20) filename_string="/lib/x86_64-linux-gnu/libc.so.6"
[...]
Wow.
Ok, so that's one solution! :-)
It does need debuginfo, which is a bit of a problem here (the Netflix
cloud, where instances are created and destroyed quickly, so they are
optimized to be small).
I did try just using the return value, which does work without
debuginfo, however, the :string modifier doesn't work. Eg, trying:
# perf probe 'getname%return $retval:string'
Added new event:
Failed to write event: Invalid argument
Error: Failed to add events. (-1)
$retval really is a string (well, it's a struct filename *, where the
first member is a char *, so close enough), so perhaps perf could
enhanced to allow this, and I'd be able to trace strings without
debuginfo. (Unless there's another workaround.)
So tools/perf/Documentation/perf-probe.txt does at least explain when
:string won't work: "You can specify 'string' type only for the local
variable or structure member which is an array of or a pointer to
'char' or 'unsigned char' type." I wonder if kprobes has this
restriction as well.
thanks,
Brendan
--
http://www.brendangregg.com
next prev parent reply other threads:[~2014-07-17 6:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-17 0:51 kprobe string Brendan Gregg
2014-07-17 4:41 ` David Ahern
2014-07-17 6:29 ` Brendan Gregg [this message]
2014-07-17 7:24 ` Namhyung Kim
2014-07-17 8:23 ` Brendan Gregg
2014-07-21 1:20 ` Brendan Gregg
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=CAE40pdefmx7trDyWnix1tPXNQBeO-cE8-6-p68tojuXry-LGXQ@mail.gmail.com \
--to=brendan.d.gregg@gmail.com \
--cc=dsahern@gmail.com \
--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).