[Mono-dev] Mono preview 2.0 binary and DTrace

Andreas Färber andreas.faerber at web.de
Sun Aug 3 15:57:34 EDT 2008


Hi Boris,

Am 03.08.2008 um 17:32 schrieb Boris Dušek:

> On Sat, Aug 2, 2008 at 6:30 PM, Andreas Färber  
> <andreas.faerber at web.de> wrote:
>>> I grabbed the Mono Preview 2.0 installer for OS X and wanted to test
>>> new DTrace probes mentioned in Release Notes[1], but it did not  
>>> work.
>>
>> Just to be sure, how did you test? As described in mono's man page?
>
> With the same command that worked with mono that I compiled myself.
> (with one difference - I used '/path/to/mono' for customly compiled
> mono since my install prefix binary dir was not in $PATH):
>
> boris at Pioneer:~/Documents/dev/mono/usr/bin$ sudo dtrace -P
> mono'$target' -l -c mono
>   ID   PROVIDER            MODULE                          FUNCTION  
> NAME
> dtrace: failed to match mono3618:::: No probe matches description
>
> boris at Pioneer:~/Documents/dev/mono/usr/bin$ sudo dtrace -P
> mono'$target' -l -c ./mono
>   ID   PROVIDER            MODULE                          FUNCTION  
> NAME
> 20188   mono3620              mono                   mono_gc_collect  
> gc-begin
> 20189   mono3620              mono                   mono_gc_collect  
> gc-end
> 21858   mono3620              mono               mini_method_compile
> method-compile-begin
> 21859   mono3620              mono               mini_method_compile
> method-compile-end
> 21860   mono3620              mono                         mini_init
> ves-init-begin
> 21861   mono3620              mono                         mini_init
> ves-init-end

Looks right.

> btw. while we are at it, is it already possible now or do you plan to
> add jstack support (so that the names of ".NET functions" appear
> instead of addresses of frames for the part inside mono runtime?)
>
> right now, with this Hello World program:
>
> class Test {
>    public static void Main(string[] args) {
>        System.Console.WriteLine("Hello from C#");
>    }
> }
>
> and this tracing script (tracing usermode stack at every write  
> syscall):
>
> syscall::write:entry
> /pid == $target/
> {
>    trace(arg0);
>    jstack();
> }
>
> I get this output which makes me believe it's either not implemented
> or I am doing something wrong (both writes are to fd 1 = stderr):
>
> boris at Pioneer:~/Documents/dev/mono/usr/bin$
> DYLD_LIBRARY_PATH=`pwd`/../lib sudo dtrace -s tracemono.d -c './mono
> /Users/boris/Test.exe'
> dtrace: script 'tracemono.d' matched 1 probe
> Hello from C#
> dtrace: pid 1528 has exited
> CPU     ID                    FUNCTION:NAME
>  1  17600                      write:entry                 1
>              libSystem.B.dylib`write$UNIX2003+0xa
>              mono`ves_icall_System_IO_MonoIO_Write+0x66
>              0x7d6084
>              0x7d5d60
>              0x7d5bae
>              0x7d5ae6
>              0x7cc8cd
>              0x7d4ed8
>              0x7d4e6e
>              0x7d4df8
>              0x7d4db6
>              0x7ca289
>              0x7ca24b
>              0x7ca1ce
>              mono`mono_runtime_exec_main+0xfe
>              mono`mono_runtime_run_main+0x153
>              mono`mono_main+0x1360
>              mono`start+0x36
>              0x2
>
>  1  17600                      write:entry                 1
>              libSystem.B.dylib`write$UNIX2003+0xa
>              mono`ves_icall_System_IO_MonoIO_Write+0x66
>              0x7d6084
>              0x7d5d60
>              0x7d5bae
>              0x7d5ae6
>              0x7cc8cd
>              0x7d63bf
>              0x7d61bd
>              0x7d614e
>              0x7d6128
>              0x7d4e0a
>              0x7d4db6
>              0x7ca289
>              0x7ca24b
>              0x7ca1ce
>              mono`mono_runtime_exec_main+0xfe
>              mono`mono_runtime_run_main+0x153
>              mono`mono_main+0x1360
>              mono`start+0x36
>              0x2
>
> Tracing Java in this way yields empty trace, so probably it's me doing
> something stupid.

DTrace support has been a recurrently requested feature for about two  
years now. I'm happy that I got it working so far! :)

All current DTrace features are documented in mono's man page, that is  
the six probes. I don't pretend that this is in any way conclusive,  
there are many more probes and features imaginable, some listed as a  
roadmap in the to-be Wiki documentation, see attached. Suggestions and  
contributions always welcome. The current probes are meant to allow a  
little profiling of the runtime, and were a convenient way for me to  
trace what the runtime would be doing if my ppc64 port were working...

I haven't used jstack() yet and would need to look it up in the  
documentation. It sounds non-trivial to implement compared to probes.

What I will be looking into next is method-enter/method-exit probes  
for tracing managed function flow, but it seems more complicated (the  
JIT would need to always emit a call to a helper function, supplying  
it the data to conditionally pass out - otherwise the dynamic part of  
DTrace wouldn't work) and thus cannot be on by default for performance  
reasons, just like in Java.

Andreas
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: DTrace.txt
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080803/31827b55/attachment.txt 
-------------- next part --------------





More information about the Mono-devel-list mailing list