This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Function parameters and return probe


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]