Mikael Ronström
2008-Jun-06 10:43 UTC
[dtrace-discuss] include files and common initialisations
Hi, In MySQL Cluster we have a DTrace probe for signals and signals have numbers which is the parameter to the DTrace scripts. However for the use of the scripts it would be very nice to have the name of the signal instead. So to do this I can obviously initialise an array at BEGIN. However if I want to share this very long initialisation statement in many scripts is there a simple way of doing that. Also can one have several probes on the same entry? Rgrds Mikael
Vladimir Marek
2008-Jun-06 11:03 UTC
[dtrace-discuss] include files and common initialisations
Hi, [...]> So to do this I can obviously initialise an array at BEGIN. However if > I want to share this very long initialisation statement in many > scripts is there a simple way of doing that.Yes, dtrace can use C preprocessor. ============================== dtrace(1M) ============================= -C Run the C preprocessor cpp(1) over D programs before compiling them. You can pass options to the C preproces- sor using the -D, -U, -I, and -H options. You can select the degree of C standard conformance if you use the -X option. For a description of the set of tokens defined by the D compiler when invoking the C preprocessor, see -X. ======================================================================= ==================================== test.d ===================================#include "init.d" =============================================================================== ==================================== init.d ===================================BEGIN { printf ("Doing init\n"); } =============================================================================== $ dtrace -C -I. -s test.d dtrace: script ''test.d'' matched 1 probe CPU ID FUNCTION:NAME 0 1 :BEGIN Doing init I also thought that you could have the parameters in the first line of the script, such as #!/usr/sbin/dtrace -C -I. -s ... But it does not work for me. And there is also no pragma for that. So the only choice would be to wrap the D script into shell script, I''m afraid.> Also can one have several probes on the same entry?Yes HTH -- Vlad -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 193 bytes Desc: not available URL: <http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20080606/a92c72df/attachment.bin>
Mike Shapiro
2008-Jun-06 17:17 UTC
[dtrace-discuss] include files and common initialisations
On Fri, Jun 06, 2008 at 12:43:56PM +0200, Mikael Ronstr?m wrote:> Hi, > In MySQL Cluster we have a DTrace probe for signals and signals have > numbers which > is the parameter to the DTrace scripts. > > However for the use of the scripts it would be very nice to have the > name of the signal instead. > So to do this I can obviously initialise an array at BEGIN. > > However if I want to share this very long initialisation statement in > many scripts is there a simple > way of doing that. Also can one have several probes on the same entry? > > Rgrds MikaelFYI, we already provide all Solaris signal names in /usr/lib/dtrace/signal.d which is included by default. So you can use signal names as identifiers. Example: # dtrace -qn ''BEGIN{printf("%d", SIGKILL);exit(0);}'' 9 -Mike -- Mike Shapiro, Sun Microsystems Fishworks. blogs.sun.com/mws/