2011-02-03 13:06:21 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2010-06-10 17:48:59 +00:00
|
|
|
* vim: set ts=8 sw=4 et tw=99:
|
1998-03-28 02:44:41 +00:00
|
|
|
*
|
2003-11-15 00:11:16 +00:00
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-03-28 02:44:41 +00:00
|
|
|
*
|
2003-11-15 00:11:16 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-03-28 02:44:41 +00:00
|
|
|
*
|
2001-09-20 00:02:59 +00:00
|
|
|
* The Original Code is Mozilla Communicator client code, released
|
|
|
|
* March 31, 1998.
|
1999-09-28 23:12:09 +00:00
|
|
|
*
|
2003-11-15 00:11:16 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-09-28 23:12:09 +00:00
|
|
|
*
|
2003-11-02 01:04:50 +00:00
|
|
|
* Contributor(s):
|
2011-07-29 15:44:45 +00:00
|
|
|
* Nick Fitzgerald <nfitzgerald@mozilla.com>
|
1999-09-28 23:12:09 +00:00
|
|
|
*
|
2003-11-15 00:11:16 +00:00
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-03-28 02:44:41 +00:00
|
|
|
|
|
|
|
#ifndef jsdbgapi_h___
|
|
|
|
#define jsdbgapi_h___
|
|
|
|
/*
|
|
|
|
* JS debugger API.
|
|
|
|
*/
|
|
|
|
#include "jsapi.h"
|
|
|
|
#include "jsopcode.h"
|
|
|
|
#include "jsprvtd.h"
|
|
|
|
|
1998-10-14 10:22:38 +00:00
|
|
|
JS_BEGIN_EXTERN_C
|
1998-03-28 02:44:41 +00:00
|
|
|
|
2011-02-03 13:06:21 +00:00
|
|
|
extern JS_PUBLIC_API(JSCrossCompartmentCall *)
|
|
|
|
JS_EnterCrossCompartmentCallScript(JSContext *cx, JSScript *target);
|
|
|
|
|
2011-07-27 19:33:33 +00:00
|
|
|
extern JS_PUBLIC_API(JSCrossCompartmentCall *)
|
|
|
|
JS_EnterCrossCompartmentCallStackFrame(JSContext *cx, JSStackFrame *target);
|
|
|
|
|
2011-02-03 13:06:21 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
JS_END_EXTERN_C
|
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
|
|
|
class JS_PUBLIC_API(AutoEnterScriptCompartment)
|
|
|
|
{
|
2011-07-27 19:33:33 +00:00
|
|
|
protected:
|
2011-02-03 13:06:21 +00:00
|
|
|
JSCrossCompartmentCall *call;
|
|
|
|
|
|
|
|
public:
|
|
|
|
AutoEnterScriptCompartment() : call(NULL) {}
|
|
|
|
|
|
|
|
bool enter(JSContext *cx, JSScript *target);
|
|
|
|
|
|
|
|
bool entered() const { return call != NULL; }
|
|
|
|
|
|
|
|
~AutoEnterScriptCompartment() {
|
|
|
|
if (call && call != reinterpret_cast<JSCrossCompartmentCall*>(1))
|
|
|
|
JS_LeaveCrossCompartmentCall(call);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-07-27 19:33:33 +00:00
|
|
|
class JS_PUBLIC_API(AutoEnterFrameCompartment) : public AutoEnterScriptCompartment
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool enter(JSContext *cx, JSStackFrame *target);
|
|
|
|
};
|
|
|
|
|
2011-02-03 13:06:21 +00:00
|
|
|
} /* namespace JS */
|
|
|
|
|
2011-10-04 14:06:54 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
JS_FRIEND_API(void) js_DumpChars(const jschar *s, size_t n);
|
|
|
|
JS_FRIEND_API(void) js_DumpString(JSString *str);
|
|
|
|
JS_FRIEND_API(void) js_DumpAtom(JSAtom *atom);
|
|
|
|
JS_FRIEND_API(void) js_DumpObject(JSObject *obj);
|
|
|
|
JS_FRIEND_API(void) js_DumpValue(const js::Value &val);
|
|
|
|
JS_FRIEND_API(void) js_DumpId(jsid id);
|
|
|
|
JS_FRIEND_API(void) js_DumpStackFrame(JSContext *cx, js::StackFrame *start = NULL);
|
|
|
|
#endif
|
|
|
|
|
2011-02-03 13:06:21 +00:00
|
|
|
JS_BEGIN_EXTERN_C
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(JSString *)
|
|
|
|
JS_DecompileScript(JSContext *cx, JSScript *script, const char *name, uintN indent);
|
|
|
|
|
2010-10-30 16:13:02 +00:00
|
|
|
/*
|
|
|
|
* Currently, we only support runtime-wide debugging. In the future, we should
|
|
|
|
* be able to support compartment-wide debugging.
|
|
|
|
*/
|
|
|
|
extern JS_PUBLIC_API(void)
|
|
|
|
JS_SetRuntimeDebugMode(JSRuntime *rt, JSBool debug);
|
|
|
|
|
2010-08-06 00:15:49 +00:00
|
|
|
/*
|
|
|
|
* Debug mode is a compartment-wide mode that enables a debugger to attach
|
|
|
|
* to and interact with running methodjit-ed frames. In particular, it causes
|
|
|
|
* every function to be compiled as if an eval was present (so eval-in-frame)
|
|
|
|
* can work, and it ensures that functions can be re-JITed for other debug
|
|
|
|
* features. In general, it is not safe to interact with frames that were live
|
|
|
|
* before debug mode was enabled. For this reason, it is also not safe to
|
|
|
|
* enable debug mode while frames are live.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Get current state of debugging mode. */
|
|
|
|
extern JS_PUBLIC_API(JSBool)
|
|
|
|
JS_GetDebugMode(JSContext *cx);
|
|
|
|
|
2011-01-21 06:10:54 +00:00
|
|
|
/*
|
2011-05-20 22:08:23 +00:00
|
|
|
* Turn on/off debugging mode for a single compartment. This should only be
|
|
|
|
* used when no code from this compartment is running or on the stack in any
|
|
|
|
* thread.
|
2011-01-21 06:10:54 +00:00
|
|
|
*/
|
|
|
|
JS_FRIEND_API(JSBool)
|
|
|
|
JS_SetDebugModeForCompartment(JSContext *cx, JSCompartment *comp, JSBool debug);
|
2010-08-06 00:15:49 +00:00
|
|
|
|
2011-01-21 06:10:54 +00:00
|
|
|
/*
|
|
|
|
* Turn on/off debugging mode for a context's compartment.
|
|
|
|
*/
|
|
|
|
JS_FRIEND_API(JSBool)
|
2010-08-06 00:15:49 +00:00
|
|
|
JS_SetDebugMode(JSContext *cx, JSBool debug);
|
|
|
|
|
2010-11-16 23:18:35 +00:00
|
|
|
/* Turn on single step mode. */
|
|
|
|
extern JS_PUBLIC_API(JSBool)
|
|
|
|
JS_SetSingleStepMode(JSContext *cx, JSScript *script, JSBool singleStep);
|
|
|
|
|
2010-05-01 00:34:54 +00:00
|
|
|
/* The closure argument will be marked. */
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
|
2010-05-01 00:34:54 +00:00
|
|
|
JSTrapHandler handler, jsval closure);
|
1998-03-28 02:44:41 +00:00
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(void)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_ClearTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
|
2010-05-01 00:34:54 +00:00
|
|
|
JSTrapHandler *handlerp, jsval *closurep);
|
1998-03-28 02:44:41 +00:00
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(void)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_ClearScriptTraps(JSContext *cx, JSScript *script);
|
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(void)
|
2011-06-28 21:06:34 +00:00
|
|
|
JS_ClearAllTrapsForCompartment(JSContext *cx);
|
1998-03-28 02:44:41 +00:00
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
2010-05-01 00:34:54 +00:00
|
|
|
JS_SetInterrupt(JSRuntime *rt, JSInterruptHook handler, void *closure);
|
1998-03-28 02:44:41 +00:00
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
2010-05-01 00:34:54 +00:00
|
|
|
JS_ClearInterrupt(JSRuntime *rt, JSInterruptHook *handlerp, void **closurep);
|
1998-03-28 02:44:41 +00:00
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
2010-07-15 06:19:36 +00:00
|
|
|
JS_SetWatchPoint(JSContext *cx, JSObject *obj, jsid id,
|
2010-08-20 01:02:17 +00:00
|
|
|
JSWatchPointHandler handler, JSObject *closure);
|
1998-03-28 02:44:41 +00:00
|
|
|
|
2002-02-23 03:49:27 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
2010-07-15 06:19:36 +00:00
|
|
|
JS_ClearWatchPoint(JSContext *cx, JSObject *obj, jsid id,
|
2010-08-20 01:02:17 +00:00
|
|
|
JSWatchPointHandler *handlerp, JSObject **closurep);
|
1998-03-28 02:44:41 +00:00
|
|
|
|
2002-02-23 03:49:27 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_ClearWatchPointsForObject(JSContext *cx, JSObject *obj);
|
|
|
|
|
2002-02-23 03:49:27 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_ClearAllWatchPoints(JSContext *cx);
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(uintN)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc);
|
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(jsbytecode *)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_LineNumberToPC(JSContext *cx, JSScript *script, uintN lineno);
|
|
|
|
|
2010-10-15 22:21:51 +00:00
|
|
|
extern JS_PUBLIC_API(jsbytecode *)
|
|
|
|
JS_EndPC(JSContext *cx, JSScript *script);
|
|
|
|
|
2011-03-03 18:11:54 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
|
|
|
JS_GetLinePCs(JSContext *cx, JSScript *script,
|
|
|
|
uintN startLine, uintN maxLines,
|
|
|
|
uintN* count, uintN** lines, jsbytecode*** pcs);
|
|
|
|
|
2010-07-15 06:19:36 +00:00
|
|
|
extern JS_PUBLIC_API(uintN)
|
|
|
|
JS_GetFunctionArgumentCount(JSContext *cx, JSFunction *fun);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(JSBool)
|
|
|
|
JS_FunctionHasLocalNames(JSContext *cx, JSFunction *fun);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* N.B. The mark is in the context temp pool and thus the caller must take care
|
|
|
|
* to call JS_ReleaseFunctionLocalNameArray in a LIFO manner (wrt to any other
|
|
|
|
* call that may use the temp pool.
|
|
|
|
*/
|
|
|
|
extern JS_PUBLIC_API(jsuword *)
|
|
|
|
JS_GetFunctionLocalNameArray(JSContext *cx, JSFunction *fun, void **markp);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(JSAtom *)
|
|
|
|
JS_LocalNameToAtom(jsuword w);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(JSString *)
|
|
|
|
JS_AtomKey(JSAtom *atom);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
|
|
|
JS_ReleaseFunctionLocalNameArray(JSContext *cx, void *mark);
|
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(JSScript *)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_GetFunctionScript(JSContext *cx, JSFunction *fun);
|
|
|
|
|
2005-05-04 06:28:36 +00:00
|
|
|
extern JS_PUBLIC_API(JSNative)
|
|
|
|
JS_GetFunctionNative(JSContext *cx, JSFunction *fun);
|
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(JSPrincipals *)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_GetScriptPrincipals(JSContext *cx, JSScript *script);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stack Frame Iterator
|
|
|
|
*
|
|
|
|
* Used to iterate through the JS stack frames to extract
|
|
|
|
* information from the frames.
|
|
|
|
*/
|
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(JSStackFrame *)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_FrameIterator(JSContext *cx, JSStackFrame **iteratorp);
|
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(JSScript *)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_GetFrameScript(JSContext *cx, JSStackFrame *fp);
|
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(jsbytecode *)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_GetFramePC(JSContext *cx, JSStackFrame *fp);
|
|
|
|
|
2003-11-02 01:04:50 +00:00
|
|
|
/*
|
|
|
|
* Get the closest scripted frame below fp. If fp is null, start from cx->fp.
|
|
|
|
*/
|
|
|
|
extern JS_PUBLIC_API(JSStackFrame *)
|
|
|
|
JS_GetScriptedCaller(JSContext *cx, JSStackFrame *fp);
|
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(void *)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_GetFrameAnnotation(JSContext *cx, JSStackFrame *fp);
|
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(void)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_SetFrameAnnotation(JSContext *cx, JSStackFrame *fp, void *annotation);
|
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(void *)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_GetFramePrincipalArray(JSContext *cx, JSStackFrame *fp);
|
|
|
|
|
2003-11-02 01:04:50 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
2010-08-16 19:35:04 +00:00
|
|
|
JS_IsScriptFrame(JSContext *cx, JSStackFrame *fp);
|
2003-11-02 01:04:50 +00:00
|
|
|
|
1998-10-14 10:22:38 +00:00
|
|
|
extern JS_PUBLIC_API(JSObject *)
|
|
|
|
JS_GetFrameScopeChain(JSContext *cx, JSStackFrame *fp);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(JSObject *)
|
|
|
|
JS_GetFrameCallObject(JSContext *cx, JSStackFrame *fp);
|
|
|
|
|
2010-10-12 18:50:03 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
|
|
|
JS_GetFrameThis(JSContext *cx, JSStackFrame *fp, jsval *thisv);
|
1998-03-28 02:44:41 +00:00
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(JSFunction *)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_GetFrameFunction(JSContext *cx, JSStackFrame *fp);
|
|
|
|
|
2000-04-14 03:14:53 +00:00
|
|
|
extern JS_PUBLIC_API(JSObject *)
|
|
|
|
JS_GetFrameFunctionObject(JSContext *cx, JSStackFrame *fp);
|
|
|
|
|
2011-11-28 15:43:31 +00:00
|
|
|
extern JS_PUBLIC_API(JSObject *)
|
|
|
|
JS_GetParentOrScopeChain(JSContext *cx, JSObject *obj);
|
|
|
|
|
2002-02-14 07:52:02 +00:00
|
|
|
/* XXXrginda Initially published with typo */
|
|
|
|
#define JS_IsContructorFrame JS_IsConstructorFrame
|
1998-10-14 10:22:38 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
2002-02-14 07:52:02 +00:00
|
|
|
JS_IsConstructorFrame(JSContext *cx, JSStackFrame *fp);
|
1998-10-14 10:22:38 +00:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(JSBool)
|
|
|
|
JS_IsDebuggerFrame(JSContext *cx, JSStackFrame *fp);
|
|
|
|
|
2011-05-11 16:11:40 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
|
|
|
JS_IsGlobalFrame(JSContext *cx, JSStackFrame *fp);
|
|
|
|
|
1998-10-14 10:22:38 +00:00
|
|
|
extern JS_PUBLIC_API(jsval)
|
|
|
|
JS_GetFrameReturnValue(JSContext *cx, JSStackFrame *fp);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
|
|
|
JS_SetFrameReturnValue(JSContext *cx, JSStackFrame *fp, jsval rval);
|
|
|
|
|
2005-09-02 18:21:23 +00:00
|
|
|
/**
|
2010-08-01 16:58:03 +00:00
|
|
|
* Return fp's callee function object (fp->callee) if it has one. Note that
|
|
|
|
* this API cannot fail. A null return means "no callee": fp is a global or
|
|
|
|
* eval-from-global frame, not a call frame.
|
|
|
|
*
|
|
|
|
* This API began life as an infallible getter, but now it can return either:
|
|
|
|
*
|
|
|
|
* 1. An optimized closure that was compiled assuming the function could not
|
|
|
|
* escape and be called from sites the compiler could not see.
|
|
|
|
*
|
|
|
|
* 2. A "joined function object", an optimization whereby SpiderMonkey avoids
|
|
|
|
* creating fresh function objects for every evaluation of a function
|
|
|
|
* expression that is used only once by a consumer that either promises to
|
|
|
|
* clone later when asked for the value or that cannot leak the value.
|
|
|
|
*
|
|
|
|
* Because Mozilla's Gecko embedding of SpiderMonkey (and no doubt other
|
|
|
|
* embeddings) calls this API in potentially performance-sensitive ways (e.g.
|
|
|
|
* in nsContentUtils::GetDocumentFromCaller), we are leaving this API alone. It
|
|
|
|
* may now return an unwrapped non-escaping optimized closure, or a joined
|
|
|
|
* function object. Such optimized objects may work well if called from the
|
|
|
|
* correct context, never mutated or compared for identity, etc.
|
|
|
|
*
|
|
|
|
* However, if you really need to get the same callee object that JS code would
|
|
|
|
* see, which means undoing the optimizations, where an undo attempt can fail,
|
|
|
|
* then use JS_GetValidFrameCalleeObject.
|
2005-09-02 18:21:23 +00:00
|
|
|
*/
|
|
|
|
extern JS_PUBLIC_API(JSObject *)
|
|
|
|
JS_GetFrameCalleeObject(JSContext *cx, JSStackFrame *fp);
|
|
|
|
|
2010-08-01 16:58:03 +00:00
|
|
|
/**
|
|
|
|
* Return fp's callee function object after running the deferred closure
|
|
|
|
* cloning "method read barrier". This API can fail! If the frame has no
|
|
|
|
* callee, this API returns true with JSVAL_IS_VOID(*vp).
|
|
|
|
*/
|
|
|
|
extern JS_PUBLIC_API(JSBool)
|
|
|
|
JS_GetValidFrameCalleeObject(JSContext *cx, JSStackFrame *fp, jsval *vp);
|
|
|
|
|
1998-03-28 02:44:41 +00:00
|
|
|
/************************************************************************/
|
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(const char *)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_GetScriptFilename(JSContext *cx, JSScript *script);
|
|
|
|
|
2011-07-29 15:44:45 +00:00
|
|
|
extern JS_PUBLIC_API(const jschar *)
|
|
|
|
JS_GetScriptSourceMap(JSContext *cx, JSScript *script);
|
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(uintN)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_GetScriptBaseLineNumber(JSContext *cx, JSScript *script);
|
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(uintN)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_GetScriptLineExtent(JSContext *cx, JSScript *script);
|
|
|
|
|
2002-02-27 09:17:21 +00:00
|
|
|
extern JS_PUBLIC_API(JSVersion)
|
|
|
|
JS_GetScriptVersion(JSContext *cx, JSScript *script);
|
2003-11-02 01:04:50 +00:00
|
|
|
|
1998-03-28 02:44:41 +00:00
|
|
|
/************************************************************************/
|
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
/*
|
|
|
|
* Hook setters for script creation and destruction, see jsprvtd.h for the
|
|
|
|
* typedefs. These macros provide binary compatibility and newer, shorter
|
|
|
|
* synonyms.
|
|
|
|
*/
|
|
|
|
#define JS_SetNewScriptHook JS_SetNewScriptHookProc
|
|
|
|
#define JS_SetDestroyScriptHook JS_SetDestroyScriptHookProc
|
1998-03-28 02:44:41 +00:00
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(void)
|
|
|
|
JS_SetNewScriptHook(JSRuntime *rt, JSNewScriptHook hook, void *callerdata);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
|
|
|
JS_SetDestroyScriptHook(JSRuntime *rt, JSDestroyScriptHook hook,
|
2004-12-09 01:32:19 +00:00
|
|
|
void *callerdata);
|
1998-03-28 02:44:41 +00:00
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
2001-05-04 23:03:11 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
|
|
|
JS_EvaluateUCInStackFrame(JSContext *cx, JSStackFrame *fp,
|
2006-02-05 04:15:22 +00:00
|
|
|
const jschar *chars, uintN length,
|
2001-05-04 23:03:11 +00:00
|
|
|
const char *filename, uintN lineno,
|
|
|
|
jsval *rval);
|
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_EvaluateInStackFrame(JSContext *cx, JSStackFrame *fp,
|
2004-12-09 01:32:19 +00:00
|
|
|
const char *bytes, uintN length,
|
|
|
|
const char *filename, uintN lineno,
|
|
|
|
jsval *rval);
|
1998-03-28 02:44:41 +00:00
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
typedef struct JSPropertyDesc {
|
2010-07-15 06:19:36 +00:00
|
|
|
jsval id; /* primary id, atomized string, or int */
|
1998-03-28 02:44:41 +00:00
|
|
|
jsval value; /* property value */
|
|
|
|
uint8 flags; /* flags, see below */
|
|
|
|
uint8 spare; /* unused */
|
|
|
|
uint16 slot; /* argument/variable slot */
|
|
|
|
jsval alias; /* alias id if JSPD_ALIAS flag */
|
|
|
|
} JSPropertyDesc;
|
|
|
|
|
|
|
|
#define JSPD_ENUMERATE 0x01 /* visible to for/in loop */
|
|
|
|
#define JSPD_READONLY 0x02 /* assignment is error */
|
|
|
|
#define JSPD_PERMANENT 0x04 /* property cannot be deleted */
|
|
|
|
#define JSPD_ALIAS 0x08 /* property has an alias id */
|
|
|
|
#define JSPD_ARGUMENT 0x10 /* argument to function */
|
|
|
|
#define JSPD_VARIABLE 0x20 /* local variable in function */
|
2002-03-16 01:56:19 +00:00
|
|
|
#define JSPD_EXCEPTION 0x40 /* exception occurred fetching the property, */
|
|
|
|
/* value is exception */
|
|
|
|
#define JSPD_ERROR 0x80 /* native getter returned JS_FALSE without */
|
|
|
|
/* throwing an exception */
|
1998-03-28 02:44:41 +00:00
|
|
|
|
|
|
|
typedef struct JSPropertyDescArray {
|
|
|
|
uint32 length; /* number of elements in array */
|
|
|
|
JSPropertyDesc *array; /* alloc'd by Get, freed by Put */
|
|
|
|
} JSPropertyDescArray;
|
|
|
|
|
2010-08-29 18:57:08 +00:00
|
|
|
typedef struct JSScopeProperty JSScopeProperty;
|
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(JSScopeProperty *)
|
|
|
|
JS_PropertyIterator(JSObject *obj, JSScopeProperty **iteratorp);
|
1998-03-28 02:44:41 +00:00
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
2010-08-29 18:57:08 +00:00
|
|
|
JS_GetPropertyDesc(JSContext *cx, JSObject *obj, JSScopeProperty *shape,
|
2004-12-09 01:32:19 +00:00
|
|
|
JSPropertyDesc *pd);
|
1998-03-28 02:44:41 +00:00
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_GetPropertyDescArray(JSContext *cx, JSObject *obj, JSPropertyDescArray *pda);
|
|
|
|
|
1998-04-24 00:31:11 +00:00
|
|
|
extern JS_PUBLIC_API(void)
|
1998-03-28 02:44:41 +00:00
|
|
|
JS_PutPropertyDescArray(JSContext *cx, JSPropertyDescArray *pda);
|
|
|
|
|
1998-07-31 00:07:22 +00:00
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(JSBool)
|
2010-05-01 00:34:54 +00:00
|
|
|
JS_SetDebuggerHandler(JSRuntime *rt, JSDebuggerHandler hook, void *closure);
|
1998-07-31 00:07:22 +00:00
|
|
|
|
1998-10-14 10:22:38 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
|
|
|
JS_SetSourceHandler(JSRuntime *rt, JSSourceHandler handler, void *closure);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(JSBool)
|
|
|
|
JS_SetExecuteHook(JSRuntime *rt, JSInterpreterHook hook, void *closure);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(JSBool)
|
|
|
|
JS_SetCallHook(JSRuntime *rt, JSInterpreterHook hook, void *closure);
|
|
|
|
|
1998-11-05 00:08:43 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
2010-05-01 00:34:54 +00:00
|
|
|
JS_SetThrowHook(JSRuntime *rt, JSThrowHook hook, void *closure);
|
1998-11-05 00:08:43 +00:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(JSBool)
|
|
|
|
JS_SetDebugErrorHook(JSRuntime *rt, JSDebugErrorHook hook, void *closure);
|
|
|
|
|
2001-02-02 20:52:06 +00:00
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(size_t)
|
|
|
|
JS_GetObjectTotalSize(JSContext *cx, JSObject *obj);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(size_t)
|
|
|
|
JS_GetFunctionTotalSize(JSContext *cx, JSFunction *fun);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(size_t)
|
|
|
|
JS_GetScriptTotalSize(JSContext *cx, JSScript *script);
|
|
|
|
|
2005-05-20 03:12:22 +00:00
|
|
|
/*
|
2007-11-14 00:50:17 +00:00
|
|
|
* Return true if obj is a "system" object, that is, one created by
|
|
|
|
* JS_NewSystemObject with the system flag set and not JS_NewObject.
|
|
|
|
*
|
2011-10-10 18:41:03 +00:00
|
|
|
* What "system" means is up to the API client.
|
2005-05-20 03:12:22 +00:00
|
|
|
*/
|
|
|
|
extern JS_PUBLIC_API(JSBool)
|
|
|
|
JS_IsSystemObject(JSContext *cx, JSObject *obj);
|
|
|
|
|
|
|
|
/*
|
2010-06-04 23:32:10 +00:00
|
|
|
* Mark an object as being a system object. This should be called immediately
|
|
|
|
* after allocating the object. A system object is an object for which
|
|
|
|
* JS_IsSystemObject returns true.
|
2005-05-20 03:12:22 +00:00
|
|
|
*/
|
2010-06-04 23:32:10 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
|
|
|
JS_MakeSystemObject(JSContext *cx, JSObject *obj);
|
2005-05-20 03:12:22 +00:00
|
|
|
|
2007-06-15 06:44:18 +00:00
|
|
|
/************************************************************************/
|
|
|
|
|
2010-09-13 16:38:22 +00:00
|
|
|
extern JS_FRIEND_API(void)
|
|
|
|
js_RevertVersion(JSContext *cx);
|
|
|
|
|
2009-11-13 17:04:23 +00:00
|
|
|
extern JS_PUBLIC_API(const JSDebugHooks *)
|
2007-06-15 06:44:18 +00:00
|
|
|
JS_GetGlobalDebugHooks(JSRuntime *rt);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(JSDebugHooks *)
|
2009-11-13 17:04:23 +00:00
|
|
|
JS_SetContextDebugHooks(JSContext *cx, const JSDebugHooks *hooks);
|
2007-06-15 06:44:18 +00:00
|
|
|
|
2010-01-20 20:54:34 +00:00
|
|
|
/* Disable debug hooks for this context. */
|
|
|
|
extern JS_PUBLIC_API(JSDebugHooks *)
|
|
|
|
JS_ClearContextDebugHooks(JSContext *cx);
|
|
|
|
|
2011-07-26 22:56:09 +00:00
|
|
|
/**
|
|
|
|
* Start any profilers that are available and have been configured on for this
|
|
|
|
* platform. This is NOT thread safe.
|
|
|
|
*
|
|
|
|
* The profileName is used by some profilers to describe the current profiling
|
|
|
|
* run. It may be used for part of the filename of the output, but the
|
|
|
|
* specifics depend on the profiler. Many profilers will ignore it. Passing in
|
|
|
|
* NULL is legal; some profilers may use it to output to stdout or similar.
|
|
|
|
*
|
|
|
|
* Returns true if no profilers fail to start.
|
|
|
|
*/
|
2008-03-24 08:06:39 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
2011-07-26 22:56:09 +00:00
|
|
|
JS_StartProfiling(const char *profileName);
|
2008-03-24 08:06:39 +00:00
|
|
|
|
2011-07-26 22:56:09 +00:00
|
|
|
/**
|
|
|
|
* Stop any profilers that were previously started with JS_StartProfiling.
|
|
|
|
* Returns true if no profilers fail to stop.
|
|
|
|
*/
|
|
|
|
extern JS_PUBLIC_API(JSBool)
|
|
|
|
JS_StopProfiling(const char *profileName);
|
2008-03-24 08:06:39 +00:00
|
|
|
|
2011-07-26 22:56:09 +00:00
|
|
|
/**
|
|
|
|
* Write the current profile data to the given file, if applicable to whatever
|
|
|
|
* profiler is being used.
|
|
|
|
*/
|
|
|
|
extern JS_PUBLIC_API(JSBool)
|
|
|
|
JS_DumpProfile(const char *outfile, const char *profileName);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pause currently active profilers (only supported by some profilers). Returns
|
|
|
|
* whether any profilers failed to pause. (Profilers that do not support
|
|
|
|
* pause/resume do not count.)
|
|
|
|
*/
|
|
|
|
extern JS_PUBLIC_API(JSBool)
|
|
|
|
JS_PauseProfilers(const char *profileName);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resume suspended profilers
|
|
|
|
*/
|
|
|
|
extern JS_PUBLIC_API(JSBool)
|
|
|
|
JS_ResumeProfilers(const char *profileName);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add various profiling-related functions as properties of the given object.
|
|
|
|
*/
|
2008-03-24 08:06:39 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
2011-01-15 01:58:40 +00:00
|
|
|
JS_DefineProfilingFunctions(JSContext *cx, JSObject *obj);
|
2008-01-16 20:42:50 +00:00
|
|
|
|
2011-07-27 23:03:34 +00:00
|
|
|
/* Defined in vm/Debugger.cpp. */
|
2011-04-14 20:41:31 +00:00
|
|
|
extern JS_PUBLIC_API(JSBool)
|
2011-07-05 12:48:26 +00:00
|
|
|
JS_DefineDebuggerObject(JSContext *cx, JSObject *obj);
|
2011-04-14 20:41:31 +00:00
|
|
|
|
2011-07-26 22:56:09 +00:00
|
|
|
/**
|
|
|
|
* The profiling API calls are not able to report errors, so they use a
|
|
|
|
* thread-unsafe global memory buffer to hold the last error encountered. This
|
|
|
|
* should only be called after something returns false.
|
|
|
|
*/
|
|
|
|
JS_PUBLIC_API(const char *)
|
|
|
|
JS_UnsafeGetLastProfilingError();
|
|
|
|
|
2008-07-08 22:58:08 +00:00
|
|
|
#ifdef MOZ_CALLGRIND
|
|
|
|
|
|
|
|
extern JS_FRIEND_API(JSBool)
|
2011-07-26 22:56:09 +00:00
|
|
|
js_StopCallgrind();
|
2008-07-08 22:58:08 +00:00
|
|
|
|
|
|
|
extern JS_FRIEND_API(JSBool)
|
2011-07-26 22:56:09 +00:00
|
|
|
js_StartCallgrind();
|
2008-07-08 22:58:08 +00:00
|
|
|
|
|
|
|
extern JS_FRIEND_API(JSBool)
|
2011-07-26 22:56:09 +00:00
|
|
|
js_DumpCallgrind(const char *outfile);
|
2008-07-08 22:58:08 +00:00
|
|
|
|
|
|
|
#endif /* MOZ_CALLGRIND */
|
|
|
|
|
2008-07-29 22:19:26 +00:00
|
|
|
#ifdef MOZ_VTUNE
|
|
|
|
|
2011-07-26 22:56:09 +00:00
|
|
|
extern JS_FRIEND_API(bool)
|
|
|
|
js_StartVtune(const char *profileName);
|
2008-07-29 22:19:26 +00:00
|
|
|
|
2011-07-26 22:56:09 +00:00
|
|
|
extern JS_FRIEND_API(bool)
|
|
|
|
js_StopVtune();
|
2008-07-29 22:19:26 +00:00
|
|
|
|
2011-07-26 22:56:09 +00:00
|
|
|
extern JS_FRIEND_API(bool)
|
|
|
|
js_PauseVtune();
|
2008-07-29 22:19:26 +00:00
|
|
|
|
2011-07-26 22:56:09 +00:00
|
|
|
extern JS_FRIEND_API(bool)
|
|
|
|
js_ResumeVtune();
|
2008-07-29 22:19:26 +00:00
|
|
|
|
|
|
|
#endif /* MOZ_VTUNE */
|
|
|
|
|
2011-05-10 18:26:39 +00:00
|
|
|
extern JS_PUBLIC_API(void)
|
2011-07-26 22:56:09 +00:00
|
|
|
JS_DumpBytecode(JSContext *cx, JSScript *script);
|
2011-05-10 18:26:39 +00:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
2011-07-26 22:56:09 +00:00
|
|
|
JS_DumpCompartmentBytecode(JSContext *cx);
|
2011-05-10 18:26:39 +00:00
|
|
|
|
2011-11-10 20:34:24 +00:00
|
|
|
extern JS_PUBLIC_API(void)
|
|
|
|
JS_DumpPCCounts(JSContext *cx, JSScript *script);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
|
|
|
JS_DumpCompartmentPCCounts(JSContext *cx);
|
|
|
|
|
2011-10-04 14:06:54 +00:00
|
|
|
extern JS_PUBLIC_API(JSObject *)
|
|
|
|
JS_UnwrapObject(JSObject *obj);
|
|
|
|
|
1998-10-14 10:22:38 +00:00
|
|
|
JS_END_EXTERN_C
|
1998-03-28 02:44:41 +00:00
|
|
|
|
|
|
|
#endif /* jsdbgapi_h___ */
|