Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Nov 2008 17:12:43 +0100
From:      Alexander Leidinger <Alexander@Leidinger.net>
To:        Ivan Voras <ivoras@freebsd.org>
Cc:        freebsd-current@freebsd.org
Subject:   Re: HOWTO in wiki: adding custom dtrace probes in the kernel
Message-ID:  <20081128171243.18141hd28pf4ve00@webmail.leidinger.net>
In-Reply-To: <ggp10c$pdt$1@ger.gmane.org>
References:  <20081128154514.82247fe47bn83lkw@webmail.leidinger.net> <ggp10c$pdt$1@ger.gmane.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Quoting Ivan Voras <ivoras@freebsd.org> (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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081128171243.18141hd28pf4ve00>