Re: HOWTO in wiki: adding custom dtrace probes in the kernel

From: Alexander Leidinger <Alexander_at_Leidinger.net>
Date: Fri, 28 Nov 2008 17:12:43 +0100
Quoting Ivan Voras <ivoras_at_freebsd.org> (from Fri, 28 Nov 2008  
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.  
source_file1 is a module name. Because of lack of a better  
modularisation (in the linuxulator), I use the (a part of) the file  
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  
able to trace. The "entry" and "return" are defacto std for function  
entry and exit. Everything else is up to you. See again i nthe wiki, I  
extended the source code example where the probe is fired with a  
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  
fill with 0 in case we don't want to provide some data. Maybe there's  
a way to provide more arguments if you do it by hand instead of using  
the SDT_PROBE() macro (TODO item added in the wiki to have a look at  
this, feel free to improve the wiki page).

Bye,
Alexander.

-- 
I used to have a drinking problem.
Now I love the stuff.

http://www.Leidinger.net    Alexander _at_ Leidinger.net: PGP ID = B0063FE7
http://www.FreeBSD.org       netchild _at_ FreeBSD.org  : PGP ID = 72077137
Received on Fri Nov 28 2008 - 15:12:56 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:38 UTC