jdtrace Example

jdtrace

 is a Java program that emulates dtrace(1M) using the Java DTrace API.  It currently supports the following options:

    Usage: java JDTrace ~[-32|-64~] ~[-CeFlqvVwZ~] ~[-b bufsz~] ~[-c cmd~] ~[-D name~[=def~]~]
        ~[-I path~] ~[-L path~] ~[-o output~] ~[-p pid~] ~[-s script~] ~[-U name~]
        ~[-x opt~[=val~]~] ~[-X a|c|s|t~]
    
        ~[-P provider ~[~[ predicate ~] action ~]~]
        ~[-m ~[ provider: ~] module ~[~[ predicate ~] action ~]~]
        ~[-f ~[~[ provider: ~] module: ~] func ~[~[ predicate ~] action ~]~]
        ~[-n ~[~[~[ provider: ~] module: ~] func: ~] name ~[~[ predicate ~] action ~]~]
        ~[-i probe-id ~[~[ predicate ~] action ~]~] ~[ args ... ~]  
        predicate -> '/' D-expression '/'
           action -> '{' D-statements '}'
    
        \-32 generate 32-bit D programs
        \-64 generate 64-bit D programs
    
        \-b  set trace buffer size
        \-c  run specified command and exit upon its completion
        \-C  run cpp(1) preprocessor on script files
        \-D  define symbol when invoking preprocessor
        \-e  exit after compiling request but prior to enabling probes
        \-f  enable or list probes matching the specified function name
        \-F  coalesce trace output by function
        \-i  enable or list probes matching the specified probe id
        \-I  add include directory to preprocessor search path
        \-l  list probes matching specified criteria
        \-L  add library directory to library search path
        \-m  enable or list probes matching the specified module name
        \-n  enable or list probes matching the specified probe name
        \-o  set output file
        \-p  grab specified process-ID and cache its symbol tables
        \-P  enable or list probes matching the specified provider name
        \-q  set quiet mode (only output explicitly traced data)
        \-s  enable or list probes according to the specified D script
        \-U  undefine symbol when invoking preprocessor
        \-v  set verbose mode (report stability attributes, arguments)
        \-V  report DTrace API version
        \-w  permit destructive actions
        \-x  enable or modify compiler and tracing options
        \-X  specify ISO C conformance settings for preprocessor
        \-Z  permit probe descriptions that match zero probes
    
        To run remotely use the "host" option with -x:
                \-xhost=<hostname> ~[ -xport=<port-number> ~]
    
        To log PrintaRecord, set this environment variable:
                JDTRACE~_LOGGING~_LEVEL=FINE
        To log ProbeData, set JDTRACE~_LOGGING~_LEVEL=FINER

Other than the initial 'j', you run it just like dtrace(1M), for example:

`jdtrace -n 'syscall:::entry { @[execname] = count(); }' -n 'tick-1sec { printa(@); clear(@); }' ==== Requirements jdtrace requires that you [[install Chime>>../../install]] version 1.4.15 (30 Oct 2006) or later. Specifically, it requires /usr/share/lib/java/dtrace.jar (Solaris Nevada build 50 or later) /opt/OSOL0chime/lib/java/gnu.getopt.jar
/opt/OSOL0chime/lib/java/dtracex.jar Note that although Chime requires Solaris Nevada build 35 or later, jdtrace requires **build 50** or later. ==== Source Here is the jdtrace source (licensed under [[CDDL>>Main.opensolaris_license]]): > [[jdtrace.tar>>attach:jdtrace.tar]] Extracting the tar creates a jdtrace directory with the following files: jdtrace/
jdtrace/jdtrace.c
jdtrace/Makefile
jdtrace/opensolaris.license.txt
jdtrace/JDTrace.java
jdtrace/jdtrace.jar-manifest ==== Building jdtrace Simply run > make in the extracted directory. The Makefile also supports the clean and clobber targets. ==== Notes jdtrace makes it possible to test the Java DTrace API using the existing DTrace test suite. I hope it also provides useful examples of how to access common DTrace functionality using the API. jdtrace` uses GNU Getopt in Java (source code included with Chime).

last modified by admin on 2009/10/26 12:41
Collectives
Project


© Sun Microsystems Inc. 2009
XWiki Enterprise 1.8.2.19075 - Documentation
Terms Of Use | Privacy | Trademarks | Copyright Policy | Site Guidelines | Site map | Help
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Use.