|
|
1.1 root 1: /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2: *
3: * The contents of this file are subject to the Netscape Public
4: * License Version 1.1 (the "License"); you may not use this file
5: * except in compliance with the License. You may obtain a copy of
6: * the License at http://www.mozilla.org/NPL/
7: *
8: * Software distributed under the License is distributed on an "AS
9: * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10: * implied. See the License for the specific language governing
11: * rights and limitations under the License.
12: *
13: * The Original Code is Mozilla Communicator client code, released
14: * March 31, 1998.
15: *
16: * The Initial Developer of the Original Code is Netscape
17: * Communications Corporation. Portions created by Netscape are
18: * Copyright (C) 1998 Netscape Communications Corporation. All
19: * Rights Reserved.
20: *
21: * Contributor(s):
22: *
23: * Alternatively, the contents of this file may be used under the
24: * terms of the GNU Public License (the "GPL"), in which case the
25: * provisions of the GPL are applicable instead of those above.
26: * If you wish to allow use of your version of this file only
27: * under the terms of the GPL and not to allow others to use your
28: * version of this file under the NPL, indicate your decision by
29: * deleting the provisions above and replace them with the notice
30: * and other provisions required by the GPL. If you do not delete
31: * the provisions above, a recipient may use your version of this
32: * file under either the NPL or the GPL.
33: */
34:
35: #ifndef jsdbgapi_h___
36: #define jsdbgapi_h___
37: /*
38: * JS debugger API.
39: */
40: #include "jsapi.h"
41: #include "jsopcode.h"
42: #include "jsprvtd.h"
43:
44: JS_BEGIN_EXTERN_C
45:
46: extern void
47: js_PatchOpcode(JSContext *cx, JSScript *script, jsbytecode *pc, JSOp op);
48:
49: extern JS_PUBLIC_API(JSBool)
50: JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
51: JSTrapHandler handler, void *closure);
52:
53: extern JS_PUBLIC_API(JSOp)
54: JS_GetTrapOpcode(JSContext *cx, JSScript *script, jsbytecode *pc);
55:
56: extern JS_PUBLIC_API(void)
57: JS_ClearTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
58: JSTrapHandler *handlerp, void **closurep);
59:
60: extern JS_PUBLIC_API(void)
61: JS_ClearScriptTraps(JSContext *cx, JSScript *script);
62:
63: extern JS_PUBLIC_API(void)
64: JS_ClearAllTraps(JSContext *cx);
65:
66: extern JS_PUBLIC_API(JSTrapStatus)
67: JS_HandleTrap(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval);
68:
69: extern JS_PUBLIC_API(JSBool)
70: JS_SetInterrupt(JSRuntime *rt, JSTrapHandler handler, void *closure);
71:
72: extern JS_PUBLIC_API(JSBool)
73: JS_ClearInterrupt(JSRuntime *rt, JSTrapHandler *handlerp, void **closurep);
74:
75: /************************************************************************/
76:
77: extern JS_PUBLIC_API(JSBool)
78: JS_SetWatchPoint(JSContext *cx, JSObject *obj, jsval id,
79: JSWatchPointHandler handler, void *closure);
80:
81: extern JS_PUBLIC_API(JSBool)
82: JS_ClearWatchPoint(JSContext *cx, JSObject *obj, jsval id,
83: JSWatchPointHandler *handlerp, void **closurep);
84:
85: extern JS_PUBLIC_API(JSBool)
86: JS_ClearWatchPointsForObject(JSContext *cx, JSObject *obj);
87:
88: extern JS_PUBLIC_API(JSBool)
89: JS_ClearAllWatchPoints(JSContext *cx);
90:
91: #ifdef JS_HAS_OBJ_WATCHPOINT
92: /*
93: * Hide these non-API function prototypes by testing whether the internal
94: * header file "jsconfig.h" has been included.
95: */
96: extern void
97: js_MarkWatchPoints(JSRuntime *rt);
98:
99: extern JSScopeProperty *
100: js_FindWatchPoint(JSRuntime *rt, JSScope *scope, jsid id);
101:
102: extern JSPropertyOp
103: js_GetWatchedSetter(JSRuntime *rt, JSScope *scope,
104: const JSScopeProperty *sprop);
105:
106: extern JSBool JS_DLL_CALLBACK
107: js_watch_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
108:
109: extern JSBool JS_DLL_CALLBACK
110: js_watch_set_wrapper(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
111: jsval *rval);
112:
113: extern JSPropertyOp
114: js_WrapWatchedSetter(JSContext *cx, jsid id, uintN attrs, JSPropertyOp setter);
115:
116: #endif /* JS_HAS_OBJ_WATCHPOINT */
117:
118: /************************************************************************/
119:
120: extern JS_PUBLIC_API(uintN)
121: JS_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc);
122:
123: extern JS_PUBLIC_API(jsbytecode *)
124: JS_LineNumberToPC(JSContext *cx, JSScript *script, uintN lineno);
125:
126: extern JS_PUBLIC_API(JSScript *)
127: JS_GetFunctionScript(JSContext *cx, JSFunction *fun);
128:
129: extern JS_PUBLIC_API(JSPrincipals *)
130: JS_GetScriptPrincipals(JSContext *cx, JSScript *script);
131:
132: /*
133: * Stack Frame Iterator
134: *
135: * Used to iterate through the JS stack frames to extract
136: * information from the frames.
137: */
138:
139: extern JS_PUBLIC_API(JSStackFrame *)
140: JS_FrameIterator(JSContext *cx, JSStackFrame **iteratorp);
141:
142: extern JS_PUBLIC_API(JSScript *)
143: JS_GetFrameScript(JSContext *cx, JSStackFrame *fp);
144:
145: extern JS_PUBLIC_API(jsbytecode *)
146: JS_GetFramePC(JSContext *cx, JSStackFrame *fp);
147:
148: extern JS_PUBLIC_API(JSBool)
149: JS_IsNativeFrame(JSContext *cx, JSStackFrame *fp);
150:
151: extern JS_PUBLIC_API(void *)
152: JS_GetFrameAnnotation(JSContext *cx, JSStackFrame *fp);
153:
154: extern JS_PUBLIC_API(void)
155: JS_SetFrameAnnotation(JSContext *cx, JSStackFrame *fp, void *annotation);
156:
157: extern JS_PUBLIC_API(void *)
158: JS_GetFramePrincipalArray(JSContext *cx, JSStackFrame *fp);
159:
160: /* this is deprecated, use JS_GetFrameScopeChain instead */
161: extern JS_PUBLIC_API(JSObject *)
162: JS_GetFrameObject(JSContext *cx, JSStackFrame *fp);
163:
164: extern JS_PUBLIC_API(JSObject *)
165: JS_GetFrameScopeChain(JSContext *cx, JSStackFrame *fp);
166:
167: extern JS_PUBLIC_API(JSObject *)
168: JS_GetFrameCallObject(JSContext *cx, JSStackFrame *fp);
169:
170: extern JS_PUBLIC_API(JSObject *)
171: JS_GetFrameThis(JSContext *cx, JSStackFrame *fp);
172:
173: extern JS_PUBLIC_API(JSFunction *)
174: JS_GetFrameFunction(JSContext *cx, JSStackFrame *fp);
175:
176: extern JS_PUBLIC_API(JSObject *)
177: JS_GetFrameFunctionObject(JSContext *cx, JSStackFrame *fp);
178:
179: /* XXXrginda Initially published with typo */
180: #define JS_IsContructorFrame JS_IsConstructorFrame
181: extern JS_PUBLIC_API(JSBool)
182: JS_IsConstructorFrame(JSContext *cx, JSStackFrame *fp);
183:
184: extern JS_PUBLIC_API(JSBool)
185: JS_IsDebuggerFrame(JSContext *cx, JSStackFrame *fp);
186:
187: extern JS_PUBLIC_API(jsval)
188: JS_GetFrameReturnValue(JSContext *cx, JSStackFrame *fp);
189:
190: extern JS_PUBLIC_API(void)
191: JS_SetFrameReturnValue(JSContext *cx, JSStackFrame *fp, jsval rval);
192:
193: /************************************************************************/
194:
195: extern JS_PUBLIC_API(const char *)
196: JS_GetScriptFilename(JSContext *cx, JSScript *script);
197:
198: extern JS_PUBLIC_API(uintN)
199: JS_GetScriptBaseLineNumber(JSContext *cx, JSScript *script);
200:
201: extern JS_PUBLIC_API(uintN)
202: JS_GetScriptLineExtent(JSContext *cx, JSScript *script);
203:
204: extern JS_PUBLIC_API(JSVersion)
205: JS_GetScriptVersion(JSContext *cx, JSScript *script);
206:
207: /************************************************************************/
208:
209: /*
210: * Hook setters for script creation and destruction, see jsprvtd.h for the
211: * typedefs. These macros provide binary compatibility and newer, shorter
212: * synonyms.
213: */
214: #define JS_SetNewScriptHook JS_SetNewScriptHookProc
215: #define JS_SetDestroyScriptHook JS_SetDestroyScriptHookProc
216:
217: extern JS_PUBLIC_API(void)
218: JS_SetNewScriptHook(JSRuntime *rt, JSNewScriptHook hook, void *callerdata);
219:
220: extern JS_PUBLIC_API(void)
221: JS_SetDestroyScriptHook(JSRuntime *rt, JSDestroyScriptHook hook,
222: void *callerdata);
223:
224: /************************************************************************/
225:
226: extern JS_PUBLIC_API(JSBool)
227: JS_EvaluateUCInStackFrame(JSContext *cx, JSStackFrame *fp,
228: const jschar *bytes, uintN length,
229: const char *filename, uintN lineno,
230: jsval *rval);
231:
232: extern JS_PUBLIC_API(JSBool)
233: JS_EvaluateInStackFrame(JSContext *cx, JSStackFrame *fp,
234: const char *bytes, uintN length,
235: const char *filename, uintN lineno,
236: jsval *rval);
237:
238: /************************************************************************/
239:
240: typedef struct JSPropertyDesc {
241: jsval id; /* primary id, a string or int */
242: jsval value; /* property value */
243: uint8 flags; /* flags, see below */
244: uint8 spare; /* unused */
245: uint16 slot; /* argument/variable slot */
246: jsval alias; /* alias id if JSPD_ALIAS flag */
247: } JSPropertyDesc;
248:
249: #define JSPD_ENUMERATE 0x01 /* visible to for/in loop */
250: #define JSPD_READONLY 0x02 /* assignment is error */
251: #define JSPD_PERMANENT 0x04 /* property cannot be deleted */
252: #define JSPD_ALIAS 0x08 /* property has an alias id */
253: #define JSPD_ARGUMENT 0x10 /* argument to function */
254: #define JSPD_VARIABLE 0x20 /* local variable in function */
255: #define JSPD_EXCEPTION 0x40 /* exception occurred fetching the property, */
256: /* value is exception */
257: #define JSPD_ERROR 0x80 /* native getter returned JS_FALSE without */
258: /* throwing an exception */
259:
260: typedef struct JSPropertyDescArray {
261: uint32 length; /* number of elements in array */
262: JSPropertyDesc *array; /* alloc'd by Get, freed by Put */
263: } JSPropertyDescArray;
264:
265: extern JS_PUBLIC_API(JSScopeProperty *)
266: JS_PropertyIterator(JSObject *obj, JSScopeProperty **iteratorp);
267:
268: extern JS_PUBLIC_API(JSBool)
269: JS_GetPropertyDesc(JSContext *cx, JSObject *obj, JSScopeProperty *sprop,
270: JSPropertyDesc *pd);
271:
272: extern JS_PUBLIC_API(JSBool)
273: JS_GetPropertyDescArray(JSContext *cx, JSObject *obj, JSPropertyDescArray *pda);
274:
275: extern JS_PUBLIC_API(void)
276: JS_PutPropertyDescArray(JSContext *cx, JSPropertyDescArray *pda);
277:
278: /************************************************************************/
279:
280: extern JS_PUBLIC_API(JSBool)
281: JS_SetDebuggerHandler(JSRuntime *rt, JSTrapHandler handler, void *closure);
282:
283: extern JS_PUBLIC_API(JSBool)
284: JS_SetSourceHandler(JSRuntime *rt, JSSourceHandler handler, void *closure);
285:
286: extern JS_PUBLIC_API(JSBool)
287: JS_SetExecuteHook(JSRuntime *rt, JSInterpreterHook hook, void *closure);
288:
289: extern JS_PUBLIC_API(JSBool)
290: JS_SetCallHook(JSRuntime *rt, JSInterpreterHook hook, void *closure);
291:
292: extern JS_PUBLIC_API(JSBool)
293: JS_SetObjectHook(JSRuntime *rt, JSObjectHook hook, void *closure);
294:
295: extern JS_PUBLIC_API(JSBool)
296: JS_SetThrowHook(JSRuntime *rt, JSTrapHandler hook, void *closure);
297:
298: extern JS_PUBLIC_API(JSBool)
299: JS_SetDebugErrorHook(JSRuntime *rt, JSDebugErrorHook hook, void *closure);
300:
301: /************************************************************************/
302:
303: extern JS_PUBLIC_API(size_t)
304: JS_GetObjectTotalSize(JSContext *cx, JSObject *obj);
305:
306: extern JS_PUBLIC_API(size_t)
307: JS_GetFunctionTotalSize(JSContext *cx, JSFunction *fun);
308:
309: extern JS_PUBLIC_API(size_t)
310: JS_GetScriptTotalSize(JSContext *cx, JSScript *script);
311:
312: JS_END_EXTERN_C
313:
314: #endif /* jsdbgapi_h___ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.