From owner-freebsd-current@FreeBSD.ORG Fri Nov 28 16:12:56 2008 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A0E051065672; Fri, 28 Nov 2008 16:12:56 +0000 (UTC) (envelope-from alexander@leidinger.net) Received: from redbull.bpaserver.net (redbullneu.bpaserver.net [213.198.78.217]) by mx1.freebsd.org (Postfix) with ESMTP id 3271A8FC20; Fri, 28 Nov 2008 16:12:56 +0000 (UTC) (envelope-from alexander@leidinger.net) Received: from outgoing.leidinger.net (pD9E2CE0A.dip.t-dialin.net [217.226.206.10]) by redbull.bpaserver.net (Postfix) with ESMTP id 696A02E0A5; Fri, 28 Nov 2008 17:12:51 +0100 (CET) Received: from webmail.leidinger.net (webmail.leidinger.net [192.168.1.102]) by outgoing.leidinger.net (Postfix) with ESMTP id BB15E18461; Fri, 28 Nov 2008 17:12:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=Leidinger.net; s=outgoing-alex; t=1227888763; bh=xBV/e86ZCfzqG2wi6Vt8Wbonv42hBHIyP AOv+MQ5hBg=; h=Message-ID:Date:From:To:Cc:Subject:References: In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=CHDtN/nKCre4o2+yro2qa2izKmX0MM+Wu8ddgnRT5qxFBhdMNdjUHxVlx3drCMs0u rVVLNxHMlCdQX6EuhQIZrsYwwLArhbaLCRGrm+cAX/BU5K+kL3yvn1009HeQCKsRT9V QR+EUN1+/gnEUhltHCAo+an8+69yQqp3BPAl3kxxC6EHSLodK0Kv+JBc3GO4RPfW5A8 1CuppIJCvZfu9Lag86JBt5d4I5i1Zw23k2VKrItRpKWbFYF4MDkbYR5IENf0RjmrTAM jMyC8EC+XEdlPOQEoQM4mgnz447iZ7jC+FPLIEjTnnczxqhBVs70KINcjxhrGQSF7mz /JDk6vCiw== Received: (from www@localhost) by webmail.leidinger.net (8.14.2/8.13.8/Submit) id mASGCh0R055919; Fri, 28 Nov 2008 17:12:43 +0100 (CET) (envelope-from Alexander@Leidinger.net) Received: from pslux.cec.eu.int (pslux.cec.eu.int [158.169.9.14]) by webmail.leidinger.net (Horde Framework) with HTTP; Fri, 28 Nov 2008 17:12:43 +0100 Message-ID: <20081128171243.18141hd28pf4ve00@webmail.leidinger.net> X-Priority: 3 (Normal) Date: Fri, 28 Nov 2008 17:12:43 +0100 From: Alexander Leidinger To: Ivan Voras References: <20081128154514.82247fe47bn83lkw@webmail.leidinger.net> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; DelSp="Yes"; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable User-Agent: Internet Messaging Program (IMP) H3 (4.3) / FreeBSD-8.0 X-BPAnet-MailScanner-Information: Please contact the ISP for more information X-MailScanner-ID: 696A02E0A5.E2F28 X-BPAnet-MailScanner: Found to be clean X-BPAnet-MailScanner-SpamCheck: not spam, ORDB-RBL, SpamAssassin (not cached, score=-14.9, required 6, BAYES_00 -15.00, DKIM_SIGNED 0.00, DKIM_VERIFIED -0.00, RDNS_DYNAMIC 0.10) X-BPAnet-MailScanner-From: alexander@leidinger.net X-Spam-Status: No Cc: freebsd-current@freebsd.org Subject: Re: HOWTO in wiki: adding custom dtrace probes in the kernel X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Nov 2008 16:12:56 -0000 Quoting Ivan Voras (from Fri, 28 Nov 2008 =20 15:59:23 +0100): > Alexander Leidinger wrote: >> Hi, >> >> while working on adding dtrace probes to the linuxulator, I thought it >> may be interesting for some people to know how to do this, so I added >> some text/examples into the wiki how to add static dtrace probes in the >> kernel: >> http://wiki.freebsd.org/HOWTO-dtrace-sdt >> >> If you are interested in the great debugging possibilities of dtrace, >> don't be afraid to add some probes to the kernel. It's cheap and easy. > > Great, thank you! > > I have some questions about the document: > > Can you document a bit more the construction of the probe: Done in the wiki. Quick answers inline. > SDT_PROBE_DEFINE(foobar, source_file1, foo, entry); > SDT_PROBE_ARGTYPE(foobar, source_file1, foo, entry, 0, "int"); > SDT_PROBE_ARGTYPE(foobar, source_file1, foo, entry, 1, "const char *"); > SDT_PROBE_DEFINE(foobar, source_file1, foo, return); > SDT_PROBE_ARGTYPE(foobar, source_file1, foo, return, 0, "int"); > > What is the meaning of "source_file1" and "foo"? Foo is the function name you want to instrument with probes. =20 source_file1 is a module name. Because of lack of a better =20 modularisation (in the linuxulator), I use the (a part of) the file =20 name in my linuxulator patches. The wiki contains more info now. > SDT_PROBE_DEFINE(foobar, source_file2, bar, entry); > SDT_PROBE_DEFINE(foobar, source_file2, bar, my_error_condition_name); > SDT_PROBE_DEFINE(foobar, source_file2, bar, return); > > Here: what is my_error_condition_name? A name you come up with for a specific error condition you want to be =20 able to trace. The "entry" and "return" are defacto std for function =20 entry and exit. Everything else is up to you. See again i nthe wiki, I =20 extended the source code example where the probe is fired with a =20 comment). > SDT_PROBE(foobar, source_file1, foo, entry, a, b, 0, 0, 0); > > Here: why are the last three arguments zeroes? From the context it looks > like it should be possible to trace an arbitrary number of data - here > a,b. Is the number of arguments implicitly constructed from the probe > definition (STD_PROBE_ARGTYPE(...0...), STD_PROBE_ARGTYPE(...1...))? SDT_PROBE() is a macro with a fixed number of macros, so we have to =20 fill with 0 in case we don't want to provide some data. Maybe there's =20 a way to provide more arguments if you do it by hand instead of using =20 the SDT_PROBE() macro (TODO item added in the wiki to have a look at =20 this, feel free to improve the wiki page). Bye, Alexander. --=20 I used to have a drinking problem. Now I love the stuff. http://www.Leidinger.net Alexander @ Leidinger.net: PGP ID =3D B0063FE7 http://www.FreeBSD.org netchild @ FreeBSD.org : PGP ID =3D 72077137