2011-02-03 05:06:21 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2013-04-16 13:47:10 -07:00
|
|
|
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-08-26 19:05:20 -07:00
|
|
|
#ifndef js_OldDebugAPI_h
|
|
|
|
#define js_OldDebugAPI_h
|
2013-08-08 21:30:15 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
* JS debugger API.
|
|
|
|
*/
|
2013-07-23 17:34:18 -07:00
|
|
|
|
2013-09-19 12:24:53 -07:00
|
|
|
#include "mozilla/NullPtr.h"
|
2014-01-17 10:09:38 -08:00
|
|
|
|
2014-02-25 07:43:14 -08:00
|
|
|
#include "jsapi.h"
|
2013-07-25 22:52:58 -07:00
|
|
|
#include "jsbytecode.h"
|
2013-07-25 22:52:59 -07:00
|
|
|
|
2013-08-26 19:05:19 -07:00
|
|
|
#include "js/CallArgs.h"
|
2013-08-27 19:59:14 -07:00
|
|
|
#include "js/TypeDecls.h"
|
2013-08-26 19:05:19 -07:00
|
|
|
|
2013-07-25 22:52:59 -07:00
|
|
|
class JSAtom;
|
2013-08-26 19:05:19 -07:00
|
|
|
class JSFreeOp;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-02-07 03:21:12 -08:00
|
|
|
namespace js {
|
|
|
|
class StackFrame;
|
|
|
|
class ScriptFrameIter;
|
|
|
|
}
|
2013-07-25 21:23:14 -07:00
|
|
|
|
2014-01-07 16:53:17 -08:00
|
|
|
// Raw JSScript* because this needs to be callable from a signal handler.
|
|
|
|
extern JS_PUBLIC_API(unsigned)
|
|
|
|
JS_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc);
|
|
|
|
|
2014-02-25 07:43:14 -08:00
|
|
|
extern JS_PUBLIC_API(const char *)
|
|
|
|
JS_GetScriptFilename(JSScript *script);
|
|
|
|
|
2011-02-03 05:06:21 -08:00
|
|
|
namespace JS {
|
|
|
|
|
2014-01-07 16:53:17 -08:00
|
|
|
class FrameDescription
|
2012-08-15 17:28:33 -07:00
|
|
|
{
|
2014-01-07 16:53:17 -08:00
|
|
|
public:
|
2014-02-07 03:21:12 -08:00
|
|
|
explicit FrameDescription(const js::ScriptFrameIter& iter);
|
|
|
|
|
2014-01-07 16:53:17 -08:00
|
|
|
unsigned lineno() {
|
|
|
|
if (!linenoComputed) {
|
|
|
|
lineno_ = JS_PCToLineNumber(nullptr, script_, pc_);
|
|
|
|
linenoComputed = true;
|
|
|
|
}
|
|
|
|
return lineno_;
|
|
|
|
}
|
|
|
|
|
2014-02-25 07:43:14 -08:00
|
|
|
const char *filename() const {
|
|
|
|
return JS_GetScriptFilename(script_);
|
2014-01-07 16:53:17 -08:00
|
|
|
}
|
|
|
|
|
2014-02-25 07:43:14 -08:00
|
|
|
JSFlatString *funDisplayName() const {
|
|
|
|
return funDisplayName_ ? JS_ASSERT_STRING_IS_FLAT(funDisplayName_) : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Both these locations should be traced during GC but otherwise not used;
|
|
|
|
// they are implementation details.
|
|
|
|
Heap<JSScript*> &markedLocation1() {
|
|
|
|
return script_;
|
|
|
|
}
|
|
|
|
Heap<JSString*> &markedLocation2() {
|
|
|
|
return funDisplayName_;
|
2014-01-07 16:53:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2014-01-07 16:53:17 -08:00
|
|
|
Heap<JSScript*> script_;
|
2014-02-25 07:43:14 -08:00
|
|
|
Heap<JSString*> funDisplayName_;
|
2014-01-07 16:53:17 -08:00
|
|
|
jsbytecode *pc_;
|
|
|
|
unsigned lineno_;
|
|
|
|
bool linenoComputed;
|
2012-08-15 17:28:33 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct StackDescription
|
|
|
|
{
|
|
|
|
unsigned nframes;
|
|
|
|
FrameDescription *frames;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(StackDescription *)
|
|
|
|
DescribeStack(JSContext *cx, unsigned maxFrames);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
|
|
|
FreeStackDescription(JSContext *cx, StackDescription *desc);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(char *)
|
2013-08-08 15:53:04 -07:00
|
|
|
FormatStackDump(JSContext *cx, char *buf, bool showArgs, bool showLocals, bool showThisProps);
|
2012-08-15 17:28:33 -07:00
|
|
|
|
2014-01-07 16:53:17 -08:00
|
|
|
} // namespace JS
|
2011-02-03 05:06:21 -08:00
|
|
|
|
2013-12-06 15:03:08 -08:00
|
|
|
# ifdef JS_DEBUG
|
2013-08-26 19:05:19 -07:00
|
|
|
JS_FRIEND_API(void) js_DumpValue(const JS::Value &val);
|
2011-10-04 07:06:54 -07:00
|
|
|
JS_FRIEND_API(void) js_DumpId(jsid id);
|
2013-09-19 12:24:53 -07:00
|
|
|
JS_FRIEND_API(void) js_DumpStackFrame(JSContext *cx, js::StackFrame *start = nullptr);
|
2012-08-29 18:04:42 -07:00
|
|
|
# endif
|
2012-08-27 13:32:51 -07:00
|
|
|
|
|
|
|
JS_FRIEND_API(void)
|
|
|
|
js_DumpBacktrace(JSContext *cx);
|
|
|
|
|
2013-08-08 21:30:15 -07:00
|
|
|
typedef enum JSTrapStatus {
|
|
|
|
JSTRAP_ERROR,
|
|
|
|
JSTRAP_CONTINUE,
|
|
|
|
JSTRAP_RETURN,
|
|
|
|
JSTRAP_THROW,
|
|
|
|
JSTRAP_LIMIT
|
|
|
|
} JSTrapStatus;
|
|
|
|
|
|
|
|
typedef JSTrapStatus
|
2013-08-26 19:05:19 -07:00
|
|
|
(* JSTrapHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, JS::Value *rval,
|
|
|
|
JS::Value closure);
|
2013-08-08 21:30:15 -07:00
|
|
|
|
|
|
|
typedef JSTrapStatus
|
2013-08-26 19:05:19 -07:00
|
|
|
(* JSInterruptHook)(JSContext *cx, JSScript *script, jsbytecode *pc, JS::Value *rval,
|
2013-08-08 21:30:15 -07:00
|
|
|
void *closure);
|
|
|
|
|
|
|
|
typedef JSTrapStatus
|
2013-08-26 19:05:19 -07:00
|
|
|
(* JSDebuggerHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, JS::Value *rval,
|
2013-08-08 21:30:15 -07:00
|
|
|
void *closure);
|
|
|
|
|
|
|
|
typedef JSTrapStatus
|
2013-08-26 19:05:19 -07:00
|
|
|
(* JSThrowHook)(JSContext *cx, JSScript *script, jsbytecode *pc, JS::Value *rval,
|
2013-08-08 21:30:15 -07:00
|
|
|
void *closure);
|
|
|
|
|
|
|
|
typedef bool
|
2013-08-26 19:05:19 -07:00
|
|
|
(* JSWatchPointHandler)(JSContext *cx, JSObject *obj, jsid id, JS::Value old,
|
|
|
|
JS::Value *newp, void *closure);
|
2013-08-08 21:30:15 -07:00
|
|
|
|
|
|
|
/* called just after script creation */
|
|
|
|
typedef void
|
|
|
|
(* JSNewScriptHook)(JSContext *cx,
|
|
|
|
const char *filename, /* URL of script */
|
|
|
|
unsigned lineno, /* first line */
|
|
|
|
JSScript *script,
|
|
|
|
JSFunction *fun,
|
|
|
|
void *callerdata);
|
|
|
|
|
|
|
|
/* called just before script destruction */
|
|
|
|
typedef void
|
|
|
|
(* JSDestroyScriptHook)(JSFreeOp *fop,
|
|
|
|
JSScript *script,
|
|
|
|
void *callerdata);
|
|
|
|
|
|
|
|
typedef void
|
|
|
|
(* JSSourceHandler)(const char *filename, unsigned lineno, const jschar *str,
|
|
|
|
size_t length, void **listenerTSData, void *closure);
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-27 13:32:51 -07:00
|
|
|
extern JS_PUBLIC_API(JSCompartment *)
|
|
|
|
JS_EnterCompartmentOfScript(JSContext *cx, JSScript *target);
|
2011-02-03 05:06:21 -08:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(JSString *)
|
2014-01-17 10:09:38 -08:00
|
|
|
JS_DecompileScript(JSContext *cx, JS::HandleScript script, const char *name, unsigned indent);
|
2011-02-03 05:06:21 -08:00
|
|
|
|
2010-10-30 09:13:02 -07: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)
|
2013-08-08 15:53:04 -07:00
|
|
|
JS_SetRuntimeDebugMode(JSRuntime *rt, bool debug);
|
2010-10-30 09:13:02 -07:00
|
|
|
|
2010-08-05 17:15:49 -07: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. */
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
2010-08-05 17:15:49 -07:00
|
|
|
JS_GetDebugMode(JSContext *cx);
|
|
|
|
|
2012-05-14 16:46:51 -07:00
|
|
|
/*
|
|
|
|
* Turn on/off debugging mode for all compartments. This returns false if any code
|
|
|
|
* from any of the runtime's compartments is running or on the stack.
|
|
|
|
*/
|
2013-08-08 15:53:04 -07:00
|
|
|
JS_FRIEND_API(bool)
|
|
|
|
JS_SetDebugModeForAllCompartments(JSContext *cx, bool debug);
|
2012-05-14 16:46:51 -07:00
|
|
|
|
2011-01-20 22:10:54 -08:00
|
|
|
/*
|
2011-05-20 15:08:23 -07: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-20 22:10:54 -08:00
|
|
|
*/
|
2013-08-08 15:53:04 -07:00
|
|
|
JS_FRIEND_API(bool)
|
|
|
|
JS_SetDebugModeForCompartment(JSContext *cx, JSCompartment *comp, bool debug);
|
2010-08-05 17:15:49 -07:00
|
|
|
|
2011-01-20 22:10:54 -08:00
|
|
|
/*
|
|
|
|
* Turn on/off debugging mode for a context's compartment.
|
|
|
|
*/
|
2013-08-08 15:53:04 -07:00
|
|
|
JS_FRIEND_API(bool)
|
|
|
|
JS_SetDebugMode(JSContext *cx, bool debug);
|
2010-08-05 17:15:49 -07:00
|
|
|
|
2010-11-16 15:18:35 -08:00
|
|
|
/* Turn on single step mode. */
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
|
|
|
JS_SetSingleStepMode(JSContext *cx, JSScript *script, bool singleStep);
|
2010-11-16 15:18:35 -08:00
|
|
|
|
2010-04-30 17:34:54 -07:00
|
|
|
/* The closure argument will be marked. */
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
2007-03-22 10:30:00 -07:00
|
|
|
JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
|
2013-08-26 19:05:19 -07:00
|
|
|
JSTrapHandler handler, JS::Value closure);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
|
|
|
JS_ClearTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
|
2013-08-26 19:05:19 -07:00
|
|
|
JSTrapHandler *handlerp, JS::Value *closurep);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
2013-06-12 14:17:55 -07:00
|
|
|
JS_ClearScriptTraps(JSRuntime *rt, JSScript *script);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
2011-06-28 14:06:34 -07:00
|
|
|
JS_ClearAllTrapsForCompartment(JSContext *cx);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
2010-04-30 17:34:54 -07:00
|
|
|
JS_SetInterrupt(JSRuntime *rt, JSInterruptHook handler, void *closure);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
2010-04-30 17:34:54 -07:00
|
|
|
JS_ClearInterrupt(JSRuntime *rt, JSInterruptHook *handlerp, void **closurep);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
2014-03-17 09:17:58 -07:00
|
|
|
JS_SetWatchPoint(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
|
|
|
|
JSWatchPointHandler handler, JS::HandleObject closure);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
2010-07-14 23:19:36 -07:00
|
|
|
JS_ClearWatchPoint(JSContext *cx, JSObject *obj, jsid id,
|
2010-08-19 18:02:17 -07:00
|
|
|
JSWatchPointHandler *handlerp, JSObject **closurep);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
2007-03-22 10:30:00 -07:00
|
|
|
JS_ClearWatchPointsForObject(JSContext *cx, JSObject *obj);
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(jsbytecode *)
|
2012-02-28 15:11:11 -08:00
|
|
|
JS_LineNumberToPC(JSContext *cx, JSScript *script, unsigned lineno);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-10-15 15:21:51 -07:00
|
|
|
extern JS_PUBLIC_API(jsbytecode *)
|
|
|
|
JS_EndPC(JSContext *cx, JSScript *script);
|
|
|
|
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
2011-03-03 10:11:54 -08:00
|
|
|
JS_GetLinePCs(JSContext *cx, JSScript *script,
|
2012-02-28 15:11:11 -08:00
|
|
|
unsigned startLine, unsigned maxLines,
|
|
|
|
unsigned* count, unsigned** lines, jsbytecode*** pcs);
|
2011-03-03 10:11:54 -08:00
|
|
|
|
2012-02-28 15:11:11 -08:00
|
|
|
extern JS_PUBLIC_API(unsigned)
|
2010-07-14 23:19:36 -07:00
|
|
|
JS_GetFunctionArgumentCount(JSContext *cx, JSFunction *fun);
|
|
|
|
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
2010-07-14 23:19:36 -07:00
|
|
|
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.
|
|
|
|
*/
|
2012-01-11 00:23:05 -08:00
|
|
|
extern JS_PUBLIC_API(uintptr_t *)
|
2010-07-14 23:19:36 -07:00
|
|
|
JS_GetFunctionLocalNameArray(JSContext *cx, JSFunction *fun, void **markp);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(JSAtom *)
|
2012-01-11 00:23:05 -08:00
|
|
|
JS_LocalNameToAtom(uintptr_t w);
|
2010-07-14 23:19:36 -07:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(JSString *)
|
|
|
|
JS_AtomKey(JSAtom *atom);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
|
|
|
JS_ReleaseFunctionLocalNameArray(JSContext *cx, void *mark);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
extern JS_PUBLIC_API(JSScript *)
|
2014-03-17 09:17:58 -07:00
|
|
|
JS_GetFunctionScript(JSContext *cx, JS::HandleFunction fun);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(JSNative)
|
|
|
|
JS_GetFunctionNative(JSContext *cx, JSFunction *fun);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(JSPrincipals *)
|
2012-02-13 05:10:04 -08:00
|
|
|
JS_GetScriptPrincipals(JSScript *script);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-06-27 17:42:53 -07:00
|
|
|
extern JS_PUBLIC_API(JSPrincipals *)
|
2012-02-13 05:10:04 -08:00
|
|
|
JS_GetScriptOriginPrincipals(JSScript *script);
|
2011-06-27 17:42:53 -07:00
|
|
|
|
2011-12-07 13:41:27 -08:00
|
|
|
JS_PUBLIC_API(JSFunction *)
|
|
|
|
JS_GetScriptFunction(JSContext *cx, JSScript *script);
|
|
|
|
|
2011-11-28 07:43:31 -08:00
|
|
|
extern JS_PUBLIC_API(JSObject *)
|
|
|
|
JS_GetParentOrScopeChain(JSContext *cx, JSObject *obj);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/************************************************************************/
|
2011-12-20 17:42:45 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is almost JS_GetClass(obj)->name except that certain debug-only
|
|
|
|
* proxies are made transparent. In particular, this function turns the class
|
|
|
|
* of any scope (returned via JS_GetFrameScopeChain or JS_GetFrameCalleeObject)
|
|
|
|
* from "Proxy" to "Call", "Block", "With" etc.
|
|
|
|
*/
|
|
|
|
extern JS_PUBLIC_API(const char *)
|
|
|
|
JS_GetDebugClassName(JSObject *obj);
|
|
|
|
|
|
|
|
/************************************************************************/
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-07-29 08:44:45 -07:00
|
|
|
extern JS_PUBLIC_API(const jschar *)
|
|
|
|
JS_GetScriptSourceMap(JSContext *cx, JSScript *script);
|
|
|
|
|
2012-02-28 15:11:11 -08:00
|
|
|
extern JS_PUBLIC_API(unsigned)
|
2007-03-22 10:30:00 -07:00
|
|
|
JS_GetScriptBaseLineNumber(JSContext *cx, JSScript *script);
|
|
|
|
|
2012-02-28 15:11:11 -08:00
|
|
|
extern JS_PUBLIC_API(unsigned)
|
2007-03-22 10:30:00 -07:00
|
|
|
JS_GetScriptLineExtent(JSContext *cx, JSScript *script);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(JSVersion)
|
|
|
|
JS_GetScriptVersion(JSContext *cx, JSScript *script);
|
|
|
|
|
2013-04-23 04:58:24 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
|
|
|
JS_GetScriptIsSelfHosted(JSScript *script);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
/*
|
2013-08-08 21:30:15 -07:00
|
|
|
* Hook setters for script creation and destruction. These macros provide
|
|
|
|
* binary compatibility and newer, shorter synonyms.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
#define JS_SetNewScriptHook JS_SetNewScriptHookProc
|
|
|
|
#define JS_SetDestroyScriptHook JS_SetDestroyScriptHookProc
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
|
|
|
JS_SetNewScriptHook(JSRuntime *rt, JSNewScriptHook hook, void *callerdata);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
|
|
|
JS_SetDestroyScriptHook(JSRuntime *rt, JSDestroyScriptHook hook,
|
|
|
|
void *callerdata);
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
typedef struct JSPropertyDesc {
|
2013-08-26 19:05:19 -07:00
|
|
|
JS::Value id; /* primary id, atomized string, or int */
|
|
|
|
JS::Value value; /* property value */
|
Bug 708735 - Use <stdint.h> types in JSAPI and throughout SpiderMonkey. Continue to provide the {u,}int{8,16,32,64} and JS{Uint,Int}{8,16,32,64} integer types through a single header, however, for a simpler backout strategy -- and also to ease the transition for embedders. r=timeless on switching the jsd API to use the <stdint.h> types, r=luke, r=dmandelin
2011-12-08 19:54:10 -08:00
|
|
|
uint8_t flags; /* flags, see below */
|
|
|
|
uint8_t spare; /* unused */
|
2013-08-26 19:05:19 -07:00
|
|
|
JS::Value alias; /* alias id if JSPD_ALIAS flag */
|
2007-03-22 10:30:00 -07:00
|
|
|
} 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_EXCEPTION 0x40 /* exception occurred fetching the property, */
|
|
|
|
/* value is exception */
|
2013-08-06 23:59:54 -07:00
|
|
|
#define JSPD_ERROR 0x80 /* native getter returned false without */
|
2007-03-22 10:30:00 -07:00
|
|
|
/* throwing an exception */
|
|
|
|
|
|
|
|
typedef struct JSPropertyDescArray {
|
Bug 708735 - Use <stdint.h> types in JSAPI and throughout SpiderMonkey. Continue to provide the {u,}int{8,16,32,64} and JS{Uint,Int}{8,16,32,64} integer types through a single header, however, for a simpler backout strategy -- and also to ease the transition for embedders. r=timeless on switching the jsd API to use the <stdint.h> types, r=luke, r=dmandelin
2011-12-08 19:54:10 -08:00
|
|
|
uint32_t length; /* number of elements in array */
|
2007-03-22 10:30:00 -07:00
|
|
|
JSPropertyDesc *array; /* alloc'd by Get, freed by Put */
|
|
|
|
} JSPropertyDescArray;
|
|
|
|
|
2010-08-29 11:57:08 -07:00
|
|
|
typedef struct JSScopeProperty JSScopeProperty;
|
|
|
|
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
2014-03-17 09:17:58 -07:00
|
|
|
JS_GetPropertyDescArray(JSContext *cx, JS::HandleObject obj, JSPropertyDescArray *pda);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
|
|
|
JS_PutPropertyDescArray(JSContext *cx, JSPropertyDescArray *pda);
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
2013-01-25 00:49:29 -08:00
|
|
|
/*
|
|
|
|
* JSAbstractFramePtr is the public version of AbstractFramePtr, a pointer to a
|
|
|
|
* StackFrame or baseline JIT frame.
|
|
|
|
*/
|
|
|
|
class JS_PUBLIC_API(JSAbstractFramePtr)
|
|
|
|
{
|
|
|
|
uintptr_t ptr_;
|
2013-12-06 09:42:08 -08:00
|
|
|
jsbytecode *pc_;
|
2013-01-25 00:49:29 -08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
JSAbstractFramePtr()
|
2013-12-06 09:42:08 -08:00
|
|
|
: ptr_(0), pc_(nullptr)
|
2013-01-25 00:49:29 -08:00
|
|
|
{ }
|
|
|
|
|
|
|
|
public:
|
2013-12-06 09:42:08 -08:00
|
|
|
JSAbstractFramePtr(void *raw, jsbytecode *pc);
|
2013-01-25 00:49:29 -08:00
|
|
|
|
|
|
|
uintptr_t raw() const { return ptr_; }
|
2013-12-06 09:42:08 -08:00
|
|
|
jsbytecode *pc() const { return pc_; }
|
2013-01-25 00:49:29 -08:00
|
|
|
|
|
|
|
operator bool() const { return !!ptr_; }
|
|
|
|
|
|
|
|
JSObject *scopeChain(JSContext *cx);
|
|
|
|
JSObject *callObject(JSContext *cx);
|
|
|
|
|
|
|
|
JSFunction *maybeFun();
|
|
|
|
JSScript *script();
|
|
|
|
|
2013-02-12 12:27:02 -08:00
|
|
|
bool getThisValue(JSContext *cx, JS::MutableHandleValue thisv);
|
2013-01-25 00:49:29 -08:00
|
|
|
|
|
|
|
bool isDebuggerFrame();
|
|
|
|
|
|
|
|
bool evaluateInStackFrame(JSContext *cx,
|
|
|
|
const char *bytes, unsigned length,
|
|
|
|
const char *filename, unsigned lineno,
|
2013-02-12 12:27:02 -08:00
|
|
|
JS::MutableHandleValue rval);
|
2013-01-25 00:49:29 -08:00
|
|
|
|
|
|
|
bool evaluateUCInStackFrame(JSContext *cx,
|
|
|
|
const jschar *chars, unsigned length,
|
|
|
|
const char *filename, unsigned lineno,
|
2013-02-12 12:27:02 -08:00
|
|
|
JS::MutableHandleValue rval);
|
2013-01-25 00:49:29 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
class JS_PUBLIC_API(JSNullFramePtr) : public JSAbstractFramePtr
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
JSNullFramePtr()
|
|
|
|
: JSAbstractFramePtr()
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This class does not work when IonMonkey is active. It's only used by jsd,
|
|
|
|
* which can only be used when IonMonkey is disabled.
|
|
|
|
*
|
|
|
|
* To find the calling script and line number, use JS_DescribeSciptedCaller.
|
|
|
|
* To summarize the call stack, use JS::DescribeStack.
|
|
|
|
*/
|
|
|
|
class JS_PUBLIC_API(JSBrokenFrameIterator)
|
|
|
|
{
|
|
|
|
void *data_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
JSBrokenFrameIterator(JSContext *cx);
|
|
|
|
~JSBrokenFrameIterator();
|
|
|
|
|
|
|
|
bool done() const;
|
|
|
|
JSBrokenFrameIterator& operator++();
|
|
|
|
|
|
|
|
JSAbstractFramePtr abstractFramePtr() const;
|
|
|
|
jsbytecode *pc() const;
|
|
|
|
|
|
|
|
bool isConstructing() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This hook captures high level script execution and function calls (JS or
|
|
|
|
* native). It is used by JS_SetExecuteHook to hook top level scripts and by
|
|
|
|
* JS_SetCallHook to hook function calls. It will get called twice per script
|
|
|
|
* or function call: just before execution begins and just after it finishes.
|
|
|
|
* In both cases the 'current' frame is that of the executing code.
|
|
|
|
*
|
2013-08-06 23:59:54 -07:00
|
|
|
* The 'before' param is true for the hook invocation before the execution
|
|
|
|
* and false for the invocation after the code has run.
|
2013-01-25 00:49:29 -08:00
|
|
|
*
|
|
|
|
* The 'ok' param is significant only on the post execution invocation to
|
|
|
|
* signify whether or not the code completed 'normally'.
|
|
|
|
*
|
|
|
|
* The 'closure' param is as passed to JS_SetExecuteHook or JS_SetCallHook
|
|
|
|
* for the 'before'invocation, but is whatever value is returned from that
|
|
|
|
* invocation for the 'after' invocation. Thus, the hook implementor *could*
|
|
|
|
* allocate a structure in the 'before' invocation and return a pointer to that
|
|
|
|
* structure. The pointer would then be handed to the hook for the 'after'
|
|
|
|
* invocation. Alternately, the 'before' could just return the same value as
|
|
|
|
* in 'closure' to cause the 'after' invocation to be called with the same
|
|
|
|
* 'closure' value as the 'before'.
|
|
|
|
*
|
2013-09-19 12:24:53 -07:00
|
|
|
* Returning nullptr in the 'before' hook will cause the 'after' hook *not* to
|
2013-01-25 00:49:29 -08:00
|
|
|
* be called.
|
|
|
|
*/
|
|
|
|
typedef void *
|
|
|
|
(* JSInterpreterHook)(JSContext *cx, JSAbstractFramePtr frame, bool isConstructing,
|
2013-08-08 15:53:04 -07:00
|
|
|
bool before, bool *ok, void *closure);
|
2013-01-25 00:49:29 -08:00
|
|
|
|
2013-08-08 15:53:04 -07:00
|
|
|
typedef bool
|
2013-01-25 00:49:29 -08:00
|
|
|
(* JSDebugErrorHook)(JSContext *cx, const char *message, JSErrorReport *report,
|
|
|
|
void *closure);
|
|
|
|
|
|
|
|
typedef struct JSDebugHooks {
|
|
|
|
JSInterruptHook interruptHook;
|
|
|
|
void *interruptHookData;
|
|
|
|
JSNewScriptHook newScriptHook;
|
|
|
|
void *newScriptHookData;
|
|
|
|
JSDestroyScriptHook destroyScriptHook;
|
|
|
|
void *destroyScriptHookData;
|
|
|
|
JSDebuggerHandler debuggerHandler;
|
|
|
|
void *debuggerHandlerData;
|
|
|
|
JSSourceHandler sourceHandler;
|
|
|
|
void *sourceHandlerData;
|
|
|
|
JSInterpreterHook executeHook;
|
|
|
|
void *executeHookData;
|
|
|
|
JSInterpreterHook callHook;
|
|
|
|
void *callHookData;
|
|
|
|
JSThrowHook throwHook;
|
|
|
|
void *throwHookData;
|
|
|
|
JSDebugErrorHook debugErrorHook;
|
|
|
|
void *debugErrorHookData;
|
|
|
|
} JSDebugHooks;
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
2010-04-30 17:34:54 -07:00
|
|
|
JS_SetDebuggerHandler(JSRuntime *rt, JSDebuggerHandler hook, void *closure);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
2007-03-22 10:30:00 -07:00
|
|
|
JS_SetSourceHandler(JSRuntime *rt, JSSourceHandler handler, void *closure);
|
|
|
|
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
2007-03-22 10:30:00 -07:00
|
|
|
JS_SetExecuteHook(JSRuntime *rt, JSInterpreterHook hook, void *closure);
|
|
|
|
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
2007-03-22 10:30:00 -07:00
|
|
|
JS_SetCallHook(JSRuntime *rt, JSInterpreterHook hook, void *closure);
|
|
|
|
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
2010-04-30 17:34:54 -07:00
|
|
|
JS_SetThrowHook(JSRuntime *rt, JSThrowHook hook, void *closure);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
2007-03-22 10:30:00 -07:00
|
|
|
JS_SetDebugErrorHook(JSRuntime *rt, JSDebugErrorHook hook, void *closure);
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
2009-11-13 09:04:23 -08:00
|
|
|
extern JS_PUBLIC_API(const JSDebugHooks *)
|
2007-06-14 23:44:18 -07:00
|
|
|
JS_GetGlobalDebugHooks(JSRuntime *rt);
|
|
|
|
|
2011-07-26 15:56:09 -07:00
|
|
|
/**
|
|
|
|
* Add various profiling-related functions as properties of the given object.
|
|
|
|
*/
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
2011-01-14 17:58:40 -08:00
|
|
|
JS_DefineProfilingFunctions(JSContext *cx, JSObject *obj);
|
2008-01-16 12:42:50 -08:00
|
|
|
|
2011-07-27 16:03:34 -07:00
|
|
|
/* Defined in vm/Debugger.cpp. */
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_PUBLIC_API(bool)
|
2014-03-17 09:17:58 -07:00
|
|
|
JS_DefineDebuggerObject(JSContext *cx, JS::HandleObject obj);
|
2011-04-14 13:41:31 -07:00
|
|
|
|
2011-11-10 12:34:24 -08:00
|
|
|
extern JS_PUBLIC_API(void)
|
|
|
|
JS_DumpPCCounts(JSContext *cx, JSScript *script);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
|
|
|
JS_DumpCompartmentPCCounts(JSContext *cx);
|
|
|
|
|
2013-08-08 21:30:15 -07:00
|
|
|
namespace js {
|
|
|
|
extern JS_FRIEND_API(bool)
|
|
|
|
CanCallContextDebugHandler(JSContext *cx);
|
|
|
|
}
|
|
|
|
|
2012-03-06 15:33:12 -08:00
|
|
|
/* Call the context debug handler on the topmost scripted frame. */
|
2013-08-08 15:53:04 -07:00
|
|
|
extern JS_FRIEND_API(bool)
|
2012-03-06 15:33:12 -08:00
|
|
|
js_CallContextDebugHandler(JSContext *cx);
|
|
|
|
|
2013-08-26 19:05:20 -07:00
|
|
|
#endif /* js_OldDebugAPI_h */
|