From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9628 invoked by alias); 20 Jan 2012 18:11:21 -0000 Received: (qmail 9616 invoked by uid 22791); 20 Jan 2012 18:11:19 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,LOTS_OF_MONEY,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from bear.ext.ti.com (HELO bear.ext.ti.com) (192.94.94.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 20 Jan 2012 18:11:05 +0000 Received: from dlep26.itg.ti.com ([157.170.170.121]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id q0KIB1e9019968 for ; Fri, 20 Jan 2012 12:11:04 -0600 Received: from DNCE72.ent.ti.com (localhost [127.0.0.1]) by dlep26.itg.ti.com (8.13.8/8.13.8) with ESMTP id q0KIB1ih015189 for ; Fri, 20 Jan 2012 12:11:01 -0600 (CST) Received: from DNCE03.ent.ti.com ([fe80::19cb:d761:16a6:9b51]) by DNCE72.ent.ti.com ([fe80::8e3:61e5:a5b9:593c%23]) with mapi id 14.01.0323.003; Fri, 20 Jan 2012 19:11:00 +0100 From: "Turgis, Frederic" To: "systemtap@sourceware.org" Subject: Function parameters and return probe Date: Fri, 20 Jan 2012 18:11:00 -0000 Message-ID: <28BE1A38672C8B4481BB423D0FD1F22E11A6B46D@DNCE03.ent.ti.com> x-exclaimer-md-config: f9c360f5-3d1e-4c3c-8703-f45bf52eff6b Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2012-q1/txt/msg00025.txt.bz2 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", ) Table is given just after with details below (done from looking at generate= d 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 savin= g 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 pa= rameters. 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 e= xit. I was expecting addr to be fetched at entry and y at exit so I got foo= led until I read generated C code. Be careful !! - @cast($addr, "struct zzz")->x->y: I expected it to be as above but no, ad= dr is fetched at entry, dereferencing happens at exit. This is generally wh= at I want. I think that explains some trick I did in the past without under= standing 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 st= orage 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 b= y 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