Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / jsdbgapi.h
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  * vim: set ts=8 sw=4 et tw=99:
3  *
4  * ***** BEGIN LICENSE BLOCK *****
5  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is Mozilla Communicator client code, released
18  * March 31, 1998.
19  *
20  * The Initial Developer of the Original Code is
21  * Netscape Communications Corporation.
22  * Portions created by the Initial Developer are Copyright (C) 1998
23  * the Initial Developer. All Rights Reserved.
24  *
25  * Contributor(s):
26  *
27  * Alternatively, the contents of this file may be used under the terms of
28  * either of the GNU General Public License Version 2 or later (the "GPL"),
29  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30  * in which case the provisions of the GPL or the LGPL are applicable instead
31  * of those above. If you wish to allow use of your version of this file only
32  * under the terms of either the GPL or the LGPL, and not to allow others to
33  * use your version of this file under the terms of the MPL, indicate your
34  * decision by deleting the provisions above and replace them with the notice
35  * and other provisions required by the GPL or the LGPL. If you do not delete
36  * the provisions above, a recipient may use your version of this file under
37  * the terms of any one of the MPL, the GPL or the LGPL.
38  *
39  * ***** END LICENSE BLOCK ***** */
40
41 #ifndef jsdbgapi_h___
42 #define jsdbgapi_h___
43 /*
44  * JS debugger API.
45  */
46 #include "jsapi.h"
47 #include "jsopcode.h"
48 #include "jsprvtd.h"
49
50 JS_BEGIN_EXTERN_C
51
52 extern JS_PUBLIC_API(JSCrossCompartmentCall *)
53 JS_EnterCrossCompartmentCallScript(JSContext *cx, JSScript *target);
54
55 #ifdef __cplusplus
56 JS_END_EXTERN_C
57
58 namespace JS {
59
60 class JS_PUBLIC_API(AutoEnterScriptCompartment)
61 {
62     JSCrossCompartmentCall *call;
63
64   public:
65     AutoEnterScriptCompartment() : call(NULL) {}
66
67     bool enter(JSContext *cx, JSScript *target);
68
69     bool entered() const { return call != NULL; }
70
71     ~AutoEnterScriptCompartment() {
72         if (call && call != reinterpret_cast<JSCrossCompartmentCall*>(1))
73             JS_LeaveCrossCompartmentCall(call);
74     }
75 };
76
77 } /* namespace JS */
78
79 JS_BEGIN_EXTERN_C
80 #endif
81
82 extern JS_PUBLIC_API(JSScript *)
83 JS_GetScriptFromObject(JSObject *scriptObject);
84
85 extern JS_PUBLIC_API(JSString *)
86 JS_DecompileScript(JSContext *cx, JSScript *script, const char *name, uintN indent);
87
88 /*
89  * Currently, we only support runtime-wide debugging. In the future, we should
90  * be able to support compartment-wide debugging.
91  */
92 extern JS_PUBLIC_API(void)
93 JS_SetRuntimeDebugMode(JSRuntime *rt, JSBool debug);
94
95 /*
96  * Debug mode is a compartment-wide mode that enables a debugger to attach
97  * to and interact with running methodjit-ed frames. In particular, it causes
98  * every function to be compiled as if an eval was present (so eval-in-frame)
99  * can work, and it ensures that functions can be re-JITed for other debug
100  * features. In general, it is not safe to interact with frames that were live
101  * before debug mode was enabled. For this reason, it is also not safe to
102  * enable debug mode while frames are live.
103  */
104
105 /* Get current state of debugging mode. */
106 extern JS_PUBLIC_API(JSBool)
107 JS_GetDebugMode(JSContext *cx);
108
109 /*
110  * Turn on/off debugging mode for a single compartment. This must be
111  * called from the main thread and the compartment must be associated
112  * with the main thread.
113  */
114 JS_FRIEND_API(JSBool)
115 JS_SetDebugModeForCompartment(JSContext *cx, JSCompartment *comp, JSBool debug);
116
117 /*
118  * Turn on/off debugging mode for a context's compartment.
119  */
120 JS_FRIEND_API(JSBool)
121 JS_SetDebugMode(JSContext *cx, JSBool debug);
122
123 /* Turn on single step mode. Requires debug mode. */
124 extern JS_FRIEND_API(JSBool)
125 js_SetSingleStepMode(JSContext *cx, JSScript *script, JSBool singleStep);
126
127 /* Turn on single step mode. */
128 extern JS_PUBLIC_API(JSBool)
129 JS_SetSingleStepMode(JSContext *cx, JSScript *script, JSBool singleStep);
130
131 /*
132  * Unexported library-private helper used to unpatch all traps in a script.
133  * Returns script->code if script has no traps, else a JS_malloc'ed copy of
134  * script->code which the caller must JS_free, or null on JS_malloc OOM.
135  */
136 extern jsbytecode *
137 js_UntrapScriptCode(JSContext *cx, JSScript *script);
138
139 /* The closure argument will be marked. */
140 extern JS_PUBLIC_API(JSBool)
141 JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
142            JSTrapHandler handler, jsval closure);
143
144 extern JS_PUBLIC_API(JSOp)
145 JS_GetTrapOpcode(JSContext *cx, JSScript *script, jsbytecode *pc);
146
147 extern JS_PUBLIC_API(void)
148 JS_ClearTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
149              JSTrapHandler *handlerp, jsval *closurep);
150
151 extern JS_PUBLIC_API(void)
152 JS_ClearScriptTraps(JSContext *cx, JSScript *script);
153
154 extern JS_PUBLIC_API(void)
155 JS_ClearAllTraps(JSContext *cx);
156
157 extern JS_PUBLIC_API(JSTrapStatus)
158 JS_HandleTrap(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval);
159
160 extern JS_PUBLIC_API(JSBool)
161 JS_SetInterrupt(JSRuntime *rt, JSInterruptHook handler, void *closure);
162
163 extern JS_PUBLIC_API(JSBool)
164 JS_ClearInterrupt(JSRuntime *rt, JSInterruptHook *handlerp, void **closurep);
165
166 /************************************************************************/
167
168 extern JS_PUBLIC_API(JSBool)
169 JS_SetWatchPoint(JSContext *cx, JSObject *obj, jsid id,
170                  JSWatchPointHandler handler, JSObject *closure);
171
172 extern JS_PUBLIC_API(JSBool)
173 JS_ClearWatchPoint(JSContext *cx, JSObject *obj, jsid id,
174                    JSWatchPointHandler *handlerp, JSObject **closurep);
175
176 extern JS_PUBLIC_API(JSBool)
177 JS_ClearWatchPointsForObject(JSContext *cx, JSObject *obj);
178
179 extern JS_PUBLIC_API(JSBool)
180 JS_ClearAllWatchPoints(JSContext *cx);
181
182 #ifdef JS_HAS_OBJ_WATCHPOINT
183 /*
184  * Hide these non-API function prototypes by testing whether the internal
185  * header file "jsversion.h" has been included.
186  */
187 extern void
188 js_TraceWatchPoints(JSTracer *trc, JSObject *obj);
189
190 extern void
191 js_SweepWatchPoints(JSContext *cx);
192
193 #ifdef __cplusplus
194
195 extern JSBool
196 js_watch_set(JSContext *cx, JSObject *obj, jsid id, JSBool strict, js::Value *vp);
197
198 namespace js {
199
200 bool
201 IsWatchedProperty(JSContext *cx, const Shape *shape);
202
203 }
204
205 #endif
206
207 #endif /* JS_HAS_OBJ_WATCHPOINT */
208
209 /************************************************************************/
210
211 extern JS_PUBLIC_API(uintN)
212 JS_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc);
213
214 extern JS_PUBLIC_API(jsbytecode *)
215 JS_LineNumberToPC(JSContext *cx, JSScript *script, uintN lineno);
216
217 extern JS_PUBLIC_API(jsbytecode *)
218 JS_EndPC(JSContext *cx, JSScript *script);
219
220 extern JS_PUBLIC_API(uintN)
221 JS_GetFunctionArgumentCount(JSContext *cx, JSFunction *fun);
222
223 extern JS_PUBLIC_API(JSBool)
224 JS_FunctionHasLocalNames(JSContext *cx, JSFunction *fun);
225
226 /*
227  * N.B. The mark is in the context temp pool and thus the caller must take care
228  * to call JS_ReleaseFunctionLocalNameArray in a LIFO manner (wrt to any other
229  * call that may use the temp pool.
230  */
231 extern JS_PUBLIC_API(jsuword *)
232 JS_GetFunctionLocalNameArray(JSContext *cx, JSFunction *fun, void **markp);
233
234 extern JS_PUBLIC_API(JSAtom *)
235 JS_LocalNameToAtom(jsuword w);
236
237 extern JS_PUBLIC_API(JSString *)
238 JS_AtomKey(JSAtom *atom);
239
240 extern JS_PUBLIC_API(void)
241 JS_ReleaseFunctionLocalNameArray(JSContext *cx, void *mark);
242
243 extern JS_PUBLIC_API(JSScript *)
244 JS_GetFunctionScript(JSContext *cx, JSFunction *fun);
245
246 extern JS_PUBLIC_API(JSNative)
247 JS_GetFunctionNative(JSContext *cx, JSFunction *fun);
248
249 extern JS_PUBLIC_API(JSPrincipals *)
250 JS_GetScriptPrincipals(JSContext *cx, JSScript *script);
251
252 /*
253  * Stack Frame Iterator
254  *
255  * Used to iterate through the JS stack frames to extract
256  * information from the frames.
257  */
258
259 extern JS_PUBLIC_API(JSStackFrame *)
260 JS_FrameIterator(JSContext *cx, JSStackFrame **iteratorp);
261
262 extern JS_PUBLIC_API(JSScript *)
263 JS_GetFrameScript(JSContext *cx, JSStackFrame *fp);
264
265 extern JS_PUBLIC_API(jsbytecode *)
266 JS_GetFramePC(JSContext *cx, JSStackFrame *fp);
267
268 /*
269  * Get the closest scripted frame below fp.  If fp is null, start from cx->fp.
270  */
271 extern JS_PUBLIC_API(JSStackFrame *)
272 JS_GetScriptedCaller(JSContext *cx, JSStackFrame *fp);
273
274 /*
275  * Return a weak reference to fp's principals.  A null return does not denote
276  * an error, it means there are no principals.
277  */
278 extern JSPrincipals *
279 js_StackFramePrincipals(JSContext *cx, JSStackFrame *fp);
280
281 JSPrincipals *
282 js_EvalFramePrincipals(JSContext *cx, JSObject *callee, JSStackFrame *caller);
283
284 extern JS_PUBLIC_API(void *)
285 JS_GetFrameAnnotation(JSContext *cx, JSStackFrame *fp);
286
287 extern JS_PUBLIC_API(void)
288 JS_SetFrameAnnotation(JSContext *cx, JSStackFrame *fp, void *annotation);
289
290 extern JS_PUBLIC_API(void *)
291 JS_GetFramePrincipalArray(JSContext *cx, JSStackFrame *fp);
292
293 extern JS_PUBLIC_API(JSBool)
294 JS_IsScriptFrame(JSContext *cx, JSStackFrame *fp);
295
296 /* this is deprecated, use JS_GetFrameScopeChain instead */
297 extern JS_PUBLIC_API(JSObject *)
298 JS_GetFrameObject(JSContext *cx, JSStackFrame *fp);
299
300 extern JS_PUBLIC_API(JSObject *)
301 JS_GetFrameScopeChain(JSContext *cx, JSStackFrame *fp);
302
303 extern JS_PUBLIC_API(JSObject *)
304 JS_GetFrameCallObject(JSContext *cx, JSStackFrame *fp);
305
306 extern JS_PUBLIC_API(JSBool)
307 JS_GetFrameThis(JSContext *cx, JSStackFrame *fp, jsval *thisv);
308
309 extern JS_PUBLIC_API(JSFunction *)
310 JS_GetFrameFunction(JSContext *cx, JSStackFrame *fp);
311
312 extern JS_PUBLIC_API(JSObject *)
313 JS_GetFrameFunctionObject(JSContext *cx, JSStackFrame *fp);
314
315 /* XXXrginda Initially published with typo */
316 #define JS_IsContructorFrame JS_IsConstructorFrame
317 extern JS_PUBLIC_API(JSBool)
318 JS_IsConstructorFrame(JSContext *cx, JSStackFrame *fp);
319
320 extern JS_PUBLIC_API(JSBool)
321 JS_IsDebuggerFrame(JSContext *cx, JSStackFrame *fp);
322
323 extern JS_PUBLIC_API(jsval)
324 JS_GetFrameReturnValue(JSContext *cx, JSStackFrame *fp);
325
326 extern JS_PUBLIC_API(void)
327 JS_SetFrameReturnValue(JSContext *cx, JSStackFrame *fp, jsval rval);
328
329 /**
330  * Return fp's callee function object (fp->callee) if it has one. Note that
331  * this API cannot fail. A null return means "no callee": fp is a global or
332  * eval-from-global frame, not a call frame.
333  *
334  * This API began life as an infallible getter, but now it can return either:
335  *
336  * 1. An optimized closure that was compiled assuming the function could not
337  *    escape and be called from sites the compiler could not see.
338  *
339  * 2. A "joined function object", an optimization whereby SpiderMonkey avoids
340  *    creating fresh function objects for every evaluation of a function
341  *    expression that is used only once by a consumer that either promises to
342  *    clone later when asked for the value or that cannot leak the value.
343  *
344  * Because Mozilla's Gecko embedding of SpiderMonkey (and no doubt other
345  * embeddings) calls this API in potentially performance-sensitive ways (e.g.
346  * in nsContentUtils::GetDocumentFromCaller), we are leaving this API alone. It
347  * may now return an unwrapped non-escaping optimized closure, or a joined
348  * function object. Such optimized objects may work well if called from the
349  * correct context, never mutated or compared for identity, etc.
350  *
351  * However, if you really need to get the same callee object that JS code would
352  * see, which means undoing the optimizations, where an undo attempt can fail,
353  * then use JS_GetValidFrameCalleeObject.
354  */
355 extern JS_PUBLIC_API(JSObject *)
356 JS_GetFrameCalleeObject(JSContext *cx, JSStackFrame *fp);
357
358 /**
359  * Return fp's callee function object after running the deferred closure
360  * cloning "method read barrier". This API can fail! If the frame has no
361  * callee, this API returns true with JSVAL_IS_VOID(*vp).
362  */
363 extern JS_PUBLIC_API(JSBool)
364 JS_GetValidFrameCalleeObject(JSContext *cx, JSStackFrame *fp, jsval *vp);
365
366 /************************************************************************/
367
368 extern JS_PUBLIC_API(const char *)
369 JS_GetScriptFilename(JSContext *cx, JSScript *script);
370
371 extern JS_PUBLIC_API(uintN)
372 JS_GetScriptBaseLineNumber(JSContext *cx, JSScript *script);
373
374 extern JS_PUBLIC_API(uintN)
375 JS_GetScriptLineExtent(JSContext *cx, JSScript *script);
376
377 extern JS_PUBLIC_API(JSVersion)
378 JS_GetScriptVersion(JSContext *cx, JSScript *script);
379
380 /************************************************************************/
381
382 /*
383  * Hook setters for script creation and destruction, see jsprvtd.h for the
384  * typedefs.  These macros provide binary compatibility and newer, shorter
385  * synonyms.
386  */
387 #define JS_SetNewScriptHook     JS_SetNewScriptHookProc
388 #define JS_SetDestroyScriptHook JS_SetDestroyScriptHookProc
389
390 extern JS_PUBLIC_API(void)
391 JS_SetNewScriptHook(JSRuntime *rt, JSNewScriptHook hook, void *callerdata);
392
393 extern JS_PUBLIC_API(void)
394 JS_SetDestroyScriptHook(JSRuntime *rt, JSDestroyScriptHook hook,
395                         void *callerdata);
396
397 /************************************************************************/
398
399 extern JS_PUBLIC_API(JSBool)
400 JS_EvaluateUCInStackFrame(JSContext *cx, JSStackFrame *fp,
401                           const jschar *chars, uintN length,
402                           const char *filename, uintN lineno,
403                           jsval *rval);
404
405 extern JS_PUBLIC_API(JSBool)
406 JS_EvaluateInStackFrame(JSContext *cx, JSStackFrame *fp,
407                         const char *bytes, uintN length,
408                         const char *filename, uintN lineno,
409                         jsval *rval);
410
411 /************************************************************************/
412
413 typedef struct JSPropertyDesc {
414     jsval           id;         /* primary id, atomized string, or int */
415     jsval           value;      /* property value */
416     uint8           flags;      /* flags, see below */
417     uint8           spare;      /* unused */
418     uint16          slot;       /* argument/variable slot */
419     jsval           alias;      /* alias id if JSPD_ALIAS flag */
420 } JSPropertyDesc;
421
422 #define JSPD_ENUMERATE  0x01    /* visible to for/in loop */
423 #define JSPD_READONLY   0x02    /* assignment is error */
424 #define JSPD_PERMANENT  0x04    /* property cannot be deleted */
425 #define JSPD_ALIAS      0x08    /* property has an alias id */
426 #define JSPD_ARGUMENT   0x10    /* argument to function */
427 #define JSPD_VARIABLE   0x20    /* local variable in function */
428 #define JSPD_EXCEPTION  0x40    /* exception occurred fetching the property, */
429                                 /* value is exception */
430 #define JSPD_ERROR      0x80    /* native getter returned JS_FALSE without */
431                                 /* throwing an exception */
432
433 typedef struct JSPropertyDescArray {
434     uint32          length;     /* number of elements in array */
435     JSPropertyDesc  *array;     /* alloc'd by Get, freed by Put */
436 } JSPropertyDescArray;
437
438 typedef struct JSScopeProperty JSScopeProperty;
439
440 extern JS_PUBLIC_API(JSScopeProperty *)
441 JS_PropertyIterator(JSObject *obj, JSScopeProperty **iteratorp);
442
443 extern JS_PUBLIC_API(JSBool)
444 JS_GetPropertyDesc(JSContext *cx, JSObject *obj, JSScopeProperty *shape,
445                    JSPropertyDesc *pd);
446
447 extern JS_PUBLIC_API(JSBool)
448 JS_GetPropertyDescArray(JSContext *cx, JSObject *obj, JSPropertyDescArray *pda);
449
450 extern JS_PUBLIC_API(void)
451 JS_PutPropertyDescArray(JSContext *cx, JSPropertyDescArray *pda);
452
453 /************************************************************************/
454
455 extern JS_PUBLIC_API(JSBool)
456 JS_SetDebuggerHandler(JSRuntime *rt, JSDebuggerHandler hook, void *closure);
457
458 extern JS_PUBLIC_API(JSBool)
459 JS_SetSourceHandler(JSRuntime *rt, JSSourceHandler handler, void *closure);
460
461 extern JS_PUBLIC_API(JSBool)
462 JS_SetExecuteHook(JSRuntime *rt, JSInterpreterHook hook, void *closure);
463
464 extern JS_PUBLIC_API(JSBool)
465 JS_SetCallHook(JSRuntime *rt, JSInterpreterHook hook, void *closure);
466
467 extern JS_PUBLIC_API(JSBool)
468 JS_SetThrowHook(JSRuntime *rt, JSThrowHook hook, void *closure);
469
470 extern JS_PUBLIC_API(JSBool)
471 JS_SetDebugErrorHook(JSRuntime *rt, JSDebugErrorHook hook, void *closure);
472
473 /************************************************************************/
474
475 extern JS_PUBLIC_API(size_t)
476 JS_GetObjectTotalSize(JSContext *cx, JSObject *obj);
477
478 extern JS_PUBLIC_API(size_t)
479 JS_GetFunctionTotalSize(JSContext *cx, JSFunction *fun);
480
481 extern JS_PUBLIC_API(size_t)
482 JS_GetScriptTotalSize(JSContext *cx, JSScript *script);
483
484 /*
485  * Get the top-most running script on cx starting from fp, or from the top of
486  * cx's frame stack if fp is null, and return its script filename flags.  If
487  * the script has a null filename member, return JSFILENAME_NULL.
488  */
489 extern JS_PUBLIC_API(uint32)
490 JS_GetTopScriptFilenameFlags(JSContext *cx, JSStackFrame *fp);
491
492 /*
493  * Get the script filename flags for the script.  If the script doesn't have a
494  * filename, return JSFILENAME_NULL.
495  */
496 extern JS_PUBLIC_API(uint32)
497 JS_GetScriptFilenameFlags(JSScript *script);
498
499 /*
500  * Associate flags with a script filename prefix in rt, so that any subsequent
501  * script compilation will inherit those flags if the script's filename is the
502  * same as prefix, or if prefix is a substring of the script's filename.
503  *
504  * The API defines only one flag bit, JSFILENAME_SYSTEM, leaving the remaining
505  * 31 bits up to the API client to define.  The union of all 32 bits must not
506  * be a legal combination, however, in order to preserve JSFILENAME_NULL as a
507  * unique value.  API clients may depend on JSFILENAME_SYSTEM being a set bit
508  * in JSFILENAME_NULL -- a script with a null filename member is presumed to
509  * be a "system" script.
510  */
511 extern JS_PUBLIC_API(JSBool)
512 JS_FlagScriptFilenamePrefix(JSRuntime *rt, const char *prefix, uint32 flags);
513
514 #define JSFILENAME_NULL         0xffffffff      /* null script filename */
515 #define JSFILENAME_SYSTEM       0x00000001      /* "system" script, see below */
516 #define JSFILENAME_PROTECTED    0x00000002      /* scripts need protection */
517
518 /*
519  * Return true if obj is a "system" object, that is, one created by
520  * JS_NewSystemObject with the system flag set and not JS_NewObject.
521  *
522  * What "system" means is up to the API client, but it can be used to implement
523  * access control policies based on script filenames and their prefixes, using
524  * JS_FlagScriptFilenamePrefix and JS_GetTopScriptFilenameFlags.
525  */
526 extern JS_PUBLIC_API(JSBool)
527 JS_IsSystemObject(JSContext *cx, JSObject *obj);
528
529 /*
530  * Mark an object as being a system object. This should be called immediately
531  * after allocating the object. A system object is an object for which
532  * JS_IsSystemObject returns true.
533  */
534 extern JS_PUBLIC_API(JSBool)
535 JS_MakeSystemObject(JSContext *cx, JSObject *obj);
536
537 /************************************************************************/
538
539 extern JS_PUBLIC_API(JSObject *)
540 JS_UnwrapObject(JSContext *cx, JSObject *obj);
541
542 /************************************************************************/
543
544 extern JS_FRIEND_API(void)
545 js_RevertVersion(JSContext *cx);
546
547 extern JS_PUBLIC_API(const JSDebugHooks *)
548 JS_GetGlobalDebugHooks(JSRuntime *rt);
549
550 extern JS_PUBLIC_API(JSDebugHooks *)
551 JS_SetContextDebugHooks(JSContext *cx, const JSDebugHooks *hooks);
552
553 /* Disable debug hooks for this context. */
554 extern JS_PUBLIC_API(JSDebugHooks *)
555 JS_ClearContextDebugHooks(JSContext *cx);
556
557 extern JS_PUBLIC_API(JSBool)
558 JS_StartProfiling();
559
560 extern JS_PUBLIC_API(void)
561 JS_StopProfiling();
562
563 extern JS_PUBLIC_API(JSBool)
564 JS_DefineProfilingFunctions(JSContext *cx, JSObject *obj);
565
566 #ifdef MOZ_CALLGRIND
567
568 extern JS_FRIEND_API(JSBool)
569 js_StopCallgrind(JSContext *cx, uintN argc, jsval *vp);
570
571 extern JS_FRIEND_API(JSBool)
572 js_StartCallgrind(JSContext *cx, uintN argc, jsval *vp);
573
574 extern JS_FRIEND_API(JSBool)
575 js_DumpCallgrind(JSContext *cx, uintN argc, jsval *vp);
576
577 #endif /* MOZ_CALLGRIND */
578
579 #ifdef MOZ_VTUNE
580
581 extern JS_FRIEND_API(JSBool)
582 js_StartVtune(JSContext *cx, uintN argc, jsval *vp);
583
584 extern JS_FRIEND_API(JSBool)
585 js_StopVtune(JSContext *cx, uintN argc, jsval *vp);
586
587 extern JS_FRIEND_API(JSBool)
588 js_PauseVtune(JSContext *cx, uintN argc, jsval *vp);
589
590 extern JS_FRIEND_API(JSBool)
591 js_ResumeVtune(JSContext *cx, uintN argc, jsval *vp);
592
593 #endif /* MOZ_VTUNE */
594
595 #ifdef MOZ_TRACEVIS
596 extern JS_FRIEND_API(JSBool)
597 js_InitEthogram(JSContext *cx, uintN argc, jsval *vp);
598 extern JS_FRIEND_API(JSBool)
599 js_ShutdownEthogram(JSContext *cx, uintN argc, jsval *vp);
600 #endif /* MOZ_TRACEVIS */
601
602 #ifdef MOZ_TRACE_JSCALLS
603 typedef void (*JSFunctionCallback)(const JSFunction *fun,
604                                    const JSScript *scr,
605                                    const JSContext *cx,
606                                    int entering);
607
608 /*
609  * The callback is expected to be quick and noninvasive. It should not
610  * trigger interrupts, turn on debugging, or produce uncaught JS
611  * exceptions. The state of the stack and registers in the context
612  * cannot be relied upon, since this callback may be invoked directly
613  * from either JIT. The 'entering' field means we are entering a
614  * function if it is positive, leaving a function if it is zero or
615  * negative.
616  */
617 extern JS_PUBLIC_API(void)
618 JS_SetFunctionCallback(JSContext *cx, JSFunctionCallback fcb);
619
620 extern JS_PUBLIC_API(JSFunctionCallback)
621 JS_GetFunctionCallback(JSContext *cx);
622 #endif /* MOZ_TRACE_JSCALLS */
623
624 JS_END_EXTERN_C
625
626 #endif /* jsdbgapi_h___ */