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.1.2.2 2007/09/13 15:28:12 das 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    /***************************** cmd probes ******************************/
58    /*
59     *	tcl*:::cmd-entry probe
60     *	    triggered immediately before commmand execution
61     *		arg0: command name			(string)
62     *		arg1: number of arguments		(int)
63     *		arg2: array of command argument objects	(Tcl_Obj**)
64     */
65    probe cmd__entry(char* name, int objc, Tcl_Obj **objv);
66    /*
67     *	tcl*:::cmd-return probe
68     *	    triggered immediately after commmand execution
69     *		arg0: command name			(string)
70     *		arg1: return code			(int)
71     */
72    probe cmd__return(char* name, int code);
73    /*
74     *	tcl*:::cmd-result probe
75     *	    triggered after cmd-return probe and result processing
76     *		arg0: command name			(string)
77     *		arg1: return code			(int)
78     *		arg2: command result			(string)
79     *		arg3: command result object		(Tcl_Obj*)
80     */
81    probe cmd__result(char* name, int code, char* result, Tcl_Obj *resultobj);
82    /*
83     *	tcl*:::cmd-args probe
84     *	    triggered before cmd-entry probe, gives access to string
85     *	    representation of command arguments
86     *		arg0: command name			(string)
87     *		arg1-arg9: command arguments or NULL	(strings)
88     */
89    probe cmd__args(char* name, char* arg1, char* arg2, char* arg3,
90	    char* arg4, char* arg5, char* arg6, char* arg7, char* arg8,
91	    char* arg9);
92
93    /***************************** inst probes *****************************/
94    /*
95     *	tcl*:::inst-start probe
96     *	    triggered immediately before execution of a bytecode
97     *		arg0: bytecode name			(string)
98     *		arg1: depth of stack			(int)
99     *		arg2: top of stack			(Tcl_Obj**)
100     */
101    probe inst__start(char* name, int depth, Tcl_Obj **stack);
102    /*
103     *	tcl*:::inst-done probe
104     *	    triggered immediately after execution of a bytecode
105     *		arg0: bytecode name			(string)
106     *		arg1: depth of stack			(int)
107     *		arg2: top of stack			(Tcl_Obj**)
108     */
109    probe inst__done(char* name, int depth, Tcl_Obj **stack);
110
111    /***************************** obj probes ******************************/
112    /*
113     *	tcl*:::obj-create probe
114     *	    triggered immediately after a new Tcl_Obj has been created
115     *		arg0: object created			(Tcl_Obj*)
116     */
117    probe obj__create(Tcl_Obj* obj);
118    /*
119     *	tcl*:::obj-free probe
120     *	    triggered immediately before a Tcl_Obj is freed
121     *		arg0: object to be freed		(Tcl_Obj*)
122     */
123    probe obj__free(Tcl_Obj* obj);
124
125    /***************************** tcl probes ******************************/
126    /*
127     *	tcl*:::tcl-probe probe
128     *	    triggered when the ::tcl::dtrace command is called
129     *		arg0-arg9: command arguments		(strings)
130     */
131    probe tcl__probe(char* arg0, char* arg1, char* arg2, char* arg3,
132	    char* arg4, char* arg5, char* arg6, char* arg7, char* arg8,
133	    char* arg9);
134};
135
136/*
137 * Tcl types and constants for use in DTrace scripts
138 */
139
140typedef struct Tcl_ObjType {
141    char *name;
142    void *freeIntRepProc;
143    void *dupIntRepProc;
144    void *updateStringProc;
145    void *setFromAnyProc;
146} Tcl_ObjType;
147
148struct Tcl_Obj {
149    int refCount;
150    char *bytes;
151    int length;
152    Tcl_ObjType *typePtr;
153    union {
154	long longValue;
155	double doubleValue;
156	void *otherValuePtr;
157	int64_t wideValue;
158	struct {
159	    void *ptr1;
160	    void *ptr2;
161	} twoPtrValue;
162    } internalRep;
163};
164
165enum return_codes {
166    TCL_OK = 0,
167    TCL_ERROR,
168    TCL_RETURN,
169    TCL_BREAK,
170    TCL_CONTINUE
171};
172
173#pragma D attributes Evolving/Evolving/Common provider tcl provider
174#pragma D attributes Private/Private/Common provider tcl module
175#pragma D attributes Private/Private/Common provider tcl function
176#pragma D attributes Evolving/Evolving/Common provider tcl name
177#pragma D attributes Evolving/Evolving/Common provider tcl args
178
179/*
180 * Local Variables:
181 * mode: c
182 * c-basic-offset: 4
183 * fill-column: 78
184 * End:
185 */
186