1/*
2 * tclDTrace.d --
3 *
4 *	Tcl DTrace provider.
5 *
6 * Copyright (c) 2007 Daniel A. Steffen <das@users.sourceforge.net>
7 *
8 * See the file "license.terms" for information on usage and redistribution of
9 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
10 *
11 * RCS: @(#) $Id: tclDTrace.d,v 1.2 2007/12/13 15:23:16 dgp Exp $
12 */
13
14typedef struct Tcl_Obj Tcl_Obj;
15
16/*
17 * Tcl DTrace probes
18 */
19
20provider tcl {
21    /***************************** proc probes *****************************/
22    /*
23     *	tcl*:::proc-entry probe
24     *	    triggered immediately before proc bytecode execution
25     *		arg0: proc name				(string)
26     *		arg1: number of arguments		(int)
27     *		arg2: array of proc argument objects	(Tcl_Obj**)
28     */
29    probe proc__entry(char* name, int objc, Tcl_Obj **objv);
30    /*
31     *	tcl*:::proc-return probe
32     *	    triggered immediately after proc bytecode execution
33     *		arg0: proc name				(string)
34     *		arg1: return code			(int)
35     */
36    probe proc__return(char* name, int code);
37    /*
38     *	tcl*:::proc-result probe
39     *	    triggered after proc-return probe and result processing
40     *		arg0: proc name				(string)
41     *		arg1: return code			(int)
42     *		arg2: proc result			(string)
43     *		arg3: proc result object		(Tcl_Obj*)
44     */
45    probe proc__result(char* name, int code, char* result, Tcl_Obj *resultobj);
46    /*
47     *	tcl*:::proc-args probe
48     *	    triggered before proc-entry probe, gives access to string
49     *	    representation of proc arguments
50     *		arg0: proc name				(string)
51     *		arg1-arg9: proc arguments or NULL	(strings)
52     */
53    probe proc__args(char* name, char* arg1, char* arg2, char* arg3,
54	    char* arg4, char* arg5, char* arg6, char* arg7, char* arg8,
55	    char* arg9);
56    /*
57     *	tcl*:::proc-info probe
58     *	    triggered before proc-entry probe, gives access to TIP 280
59     *	    information for the proc invocation (i.e. [info frame 0])
60     *		arg0: TIP 280 cmd			(string)
61     *		arg1: TIP 280 type			(string)
62     *		arg2: TIP 280 proc			(string)
63     *		arg3: TIP 280 file			(string)
64     *		arg4: TIP 280 line			(int)
65     *		arg5: TIP 280 level			(int)
66     */
67    probe proc__info(char* cmd, char* type, char* proc, char* file, int line,
68	    int level);
69
70    /***************************** cmd probes ******************************/
71    /*
72     *	tcl*:::cmd-entry probe
73     *	    triggered immediately before commmand execution
74     *		arg0: command name			(string)
75     *		arg1: number of arguments		(int)
76     *		arg2: array of command argument objects	(Tcl_Obj**)
77     */
78    probe cmd__entry(char* name, int objc, Tcl_Obj **objv);
79    /*
80     *	tcl*:::cmd-return probe
81     *	    triggered immediately after commmand execution
82     *		arg0: command name			(string)
83     *		arg1: return code			(int)
84     */
85    probe cmd__return(char* name, int code);
86    /*
87     *	tcl*:::cmd-result probe
88     *	    triggered after cmd-return probe and result processing
89     *		arg0: command name			(string)
90     *		arg1: return code			(int)
91     *		arg2: command result			(string)
92     *		arg3: command result object		(Tcl_Obj*)
93     */
94    probe cmd__result(char* name, int code, char* result, Tcl_Obj *resultobj);
95    /*
96     *	tcl*:::cmd-args probe
97     *	    triggered before cmd-entry probe, gives access to string
98     *	    representation of command arguments
99     *		arg0: command name			(string)
100     *		arg1-arg9: command arguments or NULL	(strings)
101     */
102    probe cmd__args(char* name, char* arg1, char* arg2, char* arg3,
103	    char* arg4, char* arg5, char* arg6, char* arg7, char* arg8,
104	    char* arg9);
105    /*
106     *	tcl*:::cmd-info probe
107     *	    triggered before cmd-entry probe, gives access to TIP 280
108     *	    information for the command invocation (i.e. [info frame 0])
109     *		arg0: TIP 280 cmd			(string)
110     *		arg1: TIP 280 type			(string)
111     *		arg2: TIP 280 proc			(string)
112     *		arg3: TIP 280 file			(string)
113     *		arg4: TIP 280 line			(int)
114     *		arg5: TIP 280 level			(int)
115     */
116    probe cmd__info(char* cmd, char* type, char* proc, char* file, int line,
117	    int level);
118
119    /***************************** inst probes *****************************/
120    /*
121     *	tcl*:::inst-start probe
122     *	    triggered immediately before execution of a bytecode
123     *		arg0: bytecode name			(string)
124     *		arg1: depth of stack			(int)
125     *		arg2: top of stack			(Tcl_Obj**)
126     */
127    probe inst__start(char* name, int depth, Tcl_Obj **stack);
128    /*
129     *	tcl*:::inst-done probe
130     *	    triggered immediately after execution of a bytecode
131     *		arg0: bytecode name			(string)
132     *		arg1: depth of stack			(int)
133     *		arg2: top of stack			(Tcl_Obj**)
134     */
135    probe inst__done(char* name, int depth, Tcl_Obj **stack);
136
137    /***************************** obj probes ******************************/
138    /*
139     *	tcl*:::obj-create probe
140     *	    triggered immediately after a new Tcl_Obj has been created
141     *		arg0: object created			(Tcl_Obj*)
142     */
143    probe obj__create(Tcl_Obj* obj);
144    /*
145     *	tcl*:::obj-free probe
146     *	    triggered immediately before a Tcl_Obj is freed
147     *		arg0: object to be freed		(Tcl_Obj*)
148     */
149    probe obj__free(Tcl_Obj* obj);
150
151    /***************************** tcl probes ******************************/
152    /*
153     *	tcl*:::tcl-probe probe
154     *	    triggered when the ::tcl::dtrace command is called
155     *		arg0-arg9: command arguments		(strings)
156     */
157    probe tcl__probe(char* arg0, char* arg1, char* arg2, char* arg3,
158	    char* arg4, char* arg5, char* arg6, char* arg7, char* arg8,
159	    char* arg9);
160};
161
162/*
163 * Tcl types and constants for use in DTrace scripts
164 */
165
166typedef struct Tcl_ObjType {
167    char *name;
168    void *freeIntRepProc;
169    void *dupIntRepProc;
170    void *updateStringProc;
171    void *setFromAnyProc;
172} Tcl_ObjType;
173
174struct Tcl_Obj {
175    int refCount;
176    char *bytes;
177    int length;
178    Tcl_ObjType *typePtr;
179    union {
180	long longValue;
181	double doubleValue;
182	void *otherValuePtr;
183	int64_t wideValue;
184	struct {
185	    void *ptr1;
186	    void *ptr2;
187	} twoPtrValue;
188	struct {
189	    void *ptr;
190	    unsigned long value;
191	} ptrAndLongRep;
192    } internalRep;
193};
194
195enum return_codes {
196    TCL_OK = 0,
197    TCL_ERROR,
198    TCL_RETURN,
199    TCL_BREAK,
200    TCL_CONTINUE
201};
202
203#pragma D attributes Evolving/Evolving/Common provider tcl provider
204#pragma D attributes Private/Private/Common provider tcl module
205#pragma D attributes Private/Private/Common provider tcl function
206#pragma D attributes Evolving/Evolving/Common provider tcl name
207#pragma D attributes Evolving/Evolving/Common provider tcl args
208
209/*
210 * Local Variables:
211 * mode: c
212 * c-basic-offset: 4
213 * fill-column: 78
214 * End:
215 */
216