public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "Turgis, Frederic" <f-turgis@ti.com>
To: "systemtap@sourceware.org" <systemtap@sourceware.org>
Subject: Function parameters and return probe
Date: Fri, 20 Jan 2012 18:11:00 -0000	[thread overview]
Message-ID: <28BE1A38672C8B4481BB423D0FD1F22E11A6B46D@DNCE03.ent.ti.com> (raw)

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


                 reply	other threads:[~2012-01-20 18:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=28BE1A38672C8B4481BB423D0FD1F22E11A6B46D@DNCE03.ent.ti.com \
    --to=f-turgis@ti.com \
    --cc=systemtap@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).