public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Function parameters and return probe
@ 2012-01-20 18:11 Turgis, Frederic
  0 siblings, 0 replies; only message in thread
From: Turgis, Frederic @ 2012-01-20 18:11 UTC (permalink / raw)
  To: systemtap

Hi,

Goal of this message is to summarize what values we fetch at function entry/exit when we use a function parameter in a return probe. As an example:
- void f(struct xxx *addr)
- probe kernel.function("f").return { printf("%p\n", <some code/syntax using addr>)


Table is given just after with details below (done from looking at generated C code, please tell me if something looks wrong, I will recheck. Or other syntax to check):

Function entry                  Function exit
--------------------------------------------------------------
$addr
$addr->x->y                             @cast($addr, "struct zzz")->x->y
                                        @cast(@entry($addr), "struct zzz")->x->y
$addr[0]                                custom_function($addr)


As a reminder: " A new operator @entry is available for automatically saving an expression at entry time for use in a .return probe.
   probe foo.return { println(get_cycles() - @entry(get_cycles())) }"


DETAILS:
- $addr: C code will include a function entry probe that fetches and stores the value of addr. It makes sense, function execution does not preserve parameters. This exact value is then printed in return probe.

- $addr->x->y: same as above, i.e. you get y value at function entry, not exit. I was expecting addr to be fetched at entry and y at exit so I got fooled until I read generated C code. Be careful !!

- @cast($addr, "struct zzz")->x->y: I expected it to be as above but no, addr is fetched at entry, dereferencing happens at exit. This is generally what I want. I think that explains some trick I did in the past without understanding it:
   * probe kernel.function("videobuf_dqbuf").return
   * use @cast($q, "videobuf_queue")->bufs[@cast($b, "v4l2_buffer")->index]->baddr) instead of $q->bufs[$b->index]->baddr

- @cast(@entry($addr), "struct zzz")->x->y: it does as above except that storage method is using a _stp_map_set_iii()

- $addr[0], $addr[1], ...: like $addr->x->y. In the case I want content at function exit, I am manually derefencing array through guru code executed by return probe.
printf("%u %u\n", custom_get_0($addr), custom_get_1($addr)) and not printf("%u %u\n", $handles[0], $handles[1])


Regards
Fred


Frederic Turgis
OMAP Platform Business Unit - OMAP System Engineering - Platform Enablement - System Multimedia


Texas Instruments France SA, 821 Avenue Jack Kilby, 06270 Villeneuve Loubet. 036 420 040 R.C.S Antibes. Capital de EUR 753.920


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-01-20 18:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-20 18:11 Function parameters and return probe Turgis, Frederic

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 read-only IMAP folder(s) and NNTP newsgroup(s).