This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: trace function argument
On Tue, Jun 16, 2009 at 12:31:26PM +0200, Christian Kaiser wrote:
> Ananth N Mavinakayanahalli wrote:
>> On Tue, Jun 16, 2009 at 11:47:08AM +0200, Christian Kaiser wrote:
>>> Ananth N Mavinakayanahalli wrote:
>>>> On Tue, Jun 16, 2009 at 11:08:35AM +0200, Christian Kaiser wrote:
>>>> With debuginfoless kernels, you can do pretty much what you cite with
>>>> DTrace above.
>>> I am not sure if I understand you right. If I can do pretty much the
>>> same, how is it working then? Let's take your example from above. How can
>>> I print out 'clone_flags' with debuginfoless kernels?
>> With debuginfoless kernels, you can't refer to variables by name, rather
>> using arg1, arg2, etc. See tapset/<arch>/registers.stp for more
>> information. For eg:
>> $ stap -ve 'probe kprobe.function("do_fork") { printf("clone_flags =
>> %x\n", ulong_arg(1)) exit() }'
>> Pass 1: parsed user script and 53 library script(s) in 300usr/0sys/306real
>> ms.
>> Pass 2: analyzed script: 1 probe(s), 4 function(s), 1 embed(s), 0
>> global(s) in 0usr/0sys/4real ms.
>> Pass 3: translated to C into
>> "/tmp/stapnc3ps4/stap_21b73cfa060f885eb93a27cf4013ed70_2418.c" in
>> 0usr/0sys/0real ms.
>> Pass 4: compiled C into "stap_21b73cfa060f885eb93a27cf4013ed70_2418.ko" in
>> 1490usr/230sys/1711real ms.
>> Pass 5: starting run.
>> clone_flags = 1200011
>> Pass 5: run completed in 10usr/30sys/2234real ms.
>
> Ok, so 'arg0' for dtrace is 'ulong_arg(1)' for systemtap. That was unclear
> to me!
To be clearer, its <type>_arg(<argnum>) as Mark pointed out in his
email. So, int_arg(x), long_arg(x), s32_arg(x), pointer_arg(x), etc.,
are all available for use.
Happy hacking!
Ananth