Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions | Variables
jsdbgapi.h File Reference
#include "jsapi.h"
#include "jsopcode.h"
#include "jsprvtd.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  JSPropertyDesc
struct  JSPropertyDescArray

Defines

#define JS_IsContructorFrame   JS_IsConstructorFrame
#define JS_SetNewScriptHook   JS_SetNewScriptHookProc
#define JS_SetDestroyScriptHook   JS_SetDestroyScriptHookProc
#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 */
#define JSPD_EXCEPTION   0x40 /* exception occurred fetching the property, */
#define JSPD_ERROR   0x80 /* native getter returned JS_FALSE without */
#define JSFILENAME_NULL   0xffffffff /* null script filename */
#define JSFILENAME_SYSTEM   0x00000001 /* "system" script, see below */

Typedefs

typedef struct JSPropertyDesc JSPropertyDesc
typedef struct JSPropertyDescArray JSPropertyDescArray

Functions

JS_BEGIN_EXTERN_C void js_PatchOpcode (JSContext *cx, JSScript *script, jsbytecode *pc, JSOp op)
 JS_PUBLIC_API (JSBool) JS_SetTrap(JSContext *cx
 JS_PUBLIC_API (JSOp) JS_GetTrapOpcode(JSContext *cx
 JS_PUBLIC_API (void) JS_ClearTrap(JSContext *cx
 JS_PUBLIC_API (JSTrapStatus) JS_HandleTrap(JSContext *cx
void js_MarkWatchPoints (JSContext *cx)
JSScopePropertyjs_FindWatchPoint (JSRuntime *rt, JSScope *scope, jsid id)
JSPropertyOp js_GetWatchedSetter (JSRuntime *rt, JSScope *scope, const JSScopeProperty *sprop)
JSBool JS_DLL_CALLBACK js_watch_set (JSContext *cx, JSObject *obj, jsval id, jsval *vp)
JSBool JS_DLL_CALLBACK js_watch_set_wrapper (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
JSPropertyOp js_WrapWatchedSetter (JSContext *cx, jsid id, uintN attrs, JSPropertyOp setter)
 JS_PUBLIC_API (uintN) JS_PCToLineNumber(JSContext *cx
 JS_PUBLIC_API (jsbytecode *) JS_LineNumberToPC(JSContext *cx
 JS_PUBLIC_API (JSScript *) JS_GetFunctionScript(JSContext *cx
 JS_PUBLIC_API (JSNative) JS_GetFunctionNative(JSContext *cx
 JS_PUBLIC_API (JSPrincipals *) JS_GetScriptPrincipals(JSContext *cx
 JS_PUBLIC_API (JSStackFrame *) JS_FrameIterator(JSContext *cx
 JS_PUBLIC_API (void *) JS_GetFrameAnnotation(JSContext *cx
 JS_PUBLIC_API (JSObject *) JS_GetFrameCalleeObject(JSContext *cx
 Return fp's callee function object (fp->argv[-2]) if it has one.
 JS_PUBLIC_API (JSFunction *) JS_GetFrameFunction(JSContext *cx
 JS_PUBLIC_API (jsval) JS_GetFrameReturnValue(JSContext *cx
 JS_PUBLIC_API (const char *) JS_GetScriptFilename(JSContext *cx
 JS_PUBLIC_API (JSVersion) JS_GetScriptVersion(JSContext *cx
 JS_PUBLIC_API (JSScopeProperty *) JS_PropertyIterator(JSObject *obj
 JS_PUBLIC_API (size_t) JS_GetObjectTotalSize(JSContext *cx
 JS_PUBLIC_API (uint32) JS_GetTopScriptFilenameFlags(JSContext *cx

Variables

JSScriptscript
JSScript jsbytecodepc
JSScript jsbytecode JSTrapHandler handler
JSScript jsbytecode
JSTrapHandler void
closure
JSScript jsbytecode JSTrapHandler * handlerp
JSScript jsbytecode
JSTrapHandler void ** 
closurep
JSScript jsbytecode jsvalrval
JSObjectobj
JSObject jsval id
JSScript uintN lineno
JSFunctionfun
JSStackFrame ** iteratorp
JSStackFramefp
JSStackFrame JSStackFramecaller
JSStackFrame voidannotation
JSNewScriptHook hook
JSNewScriptHook voidcallerdata
JSStackFrame const jscharchars
JSStackFrame const jschar uintN length
JSStackFrame const jschar
uintN const char * 
filename
JSStackFrame const char * bytes
JSObject JSScopePropertysprop
JSObject JSScopeProperty
JSPropertyDesc
pd
JSObject JSPropertyDescArraypda
const char * prefix
const char uint32 flags

Class Documentation

struct JSPropertyDesc

Definition at line 281 of file jsdbgapi.h.

Class Members
jsval alias
uint8 flags
jsval id
uint16 slot
uint8 spare
jsval value
struct JSPropertyDescArray

Definition at line 301 of file jsdbgapi.h.

Collaboration diagram for JSPropertyDescArray:
Class Members
JSPropertyDesc * array
uint32 length

Define Documentation

Definition at line 215 of file jsdbgapi.h.

#define JS_SetDestroyScriptHook   JS_SetDestroyScriptHookProc

Definition at line 256 of file jsdbgapi.h.

#define JS_SetNewScriptHook   JS_SetNewScriptHookProc

Definition at line 255 of file jsdbgapi.h.

#define JSFILENAME_NULL   0xffffffff /* null script filename */

Definition at line 383 of file jsdbgapi.h.

#define JSFILENAME_SYSTEM   0x00000001 /* "system" script, see below */

Definition at line 384 of file jsdbgapi.h.

#define JSPD_ALIAS   0x08 /* property has an alias id */

Definition at line 293 of file jsdbgapi.h.

#define JSPD_ARGUMENT   0x10 /* argument to function */

Definition at line 294 of file jsdbgapi.h.

#define JSPD_ENUMERATE   0x01 /* visible to for/in loop */

Definition at line 290 of file jsdbgapi.h.

#define JSPD_ERROR   0x80 /* native getter returned JS_FALSE without */

Definition at line 298 of file jsdbgapi.h.

#define JSPD_EXCEPTION   0x40 /* exception occurred fetching the property, */

Definition at line 296 of file jsdbgapi.h.

#define JSPD_PERMANENT   0x04 /* property cannot be deleted */

Definition at line 292 of file jsdbgapi.h.

#define JSPD_READONLY   0x02 /* assignment is error */

Definition at line 291 of file jsdbgapi.h.

#define JSPD_VARIABLE   0x20 /* local variable in function */

Definition at line 295 of file jsdbgapi.h.


Typedef Documentation


Function Documentation

JSScopeProperty* js_FindWatchPoint ( JSRuntime rt,
JSScope scope,
jsid  id 
)

Definition at line 341 of file jsdbgapi.c.

{
    JSWatchPoint *wp;

    wp = FindWatchPoint(rt, scope, id);
    if (!wp)
        return NULL;
    return wp->sprop;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSPropertyOp js_GetWatchedSetter ( JSRuntime rt,
JSScope scope,
const JSScopeProperty sprop 
)

Definition at line 352 of file jsdbgapi.c.

{
    JSWatchPoint *wp;

    for (wp = (JSWatchPoint *)rt->watchPointList.next;
         wp != (JSWatchPoint *)&rt->watchPointList;
         wp = (JSWatchPoint *)wp->links.next) {
        if ((!scope || wp->object == scope->object) && wp->sprop == sprop)
            return wp->setter;
    }
    return NULL;
}

Here is the caller graph for this function:

Definition at line 311 of file jsdbgapi.c.

{
    JSRuntime *rt;
    JSWatchPoint *wp;

    rt = cx->runtime;
    for (wp = (JSWatchPoint *)rt->watchPointList.next;
         wp != (JSWatchPoint *)&rt->watchPointList;
         wp = (JSWatchPoint *)wp->links.next) {
        MARK_SCOPE_PROPERTY(cx, wp->sprop);
        if (wp->sprop->attrs & JSPROP_SETTER)
            JS_MarkGCThing(cx, wp->setter, "wp->setter", NULL);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

JS_BEGIN_EXTERN_C void js_PatchOpcode ( JSContext cx,
JSScript script,
jsbytecode pc,
JSOp  op 
)

Definition at line 87 of file jsdbgapi.c.

{
    JSTrap *trap;

    trap = FindTrap(cx->runtime, script, pc);
    if (trap)
        trap->op = op;
    else
        *pc = (jsbytecode)op;
}

Here is the call graph for this function:

Definition at line 58 of file jslog2.c.

{
    JSIntn log2;

    JS_FLOOR_LOG2(log2, n);
    return log2;
}
JS_PUBLIC_API ( JSNative  )

Return fp's callee function object (fp->argv[-2]) if it has one.

JS_PUBLIC_API ( const char *  )
JS_PUBLIC_API ( size_t  )
JSBool JS_DLL_CALLBACK js_watch_set ( JSContext cx,
JSObject obj,
jsval  id,
jsval vp 
)

Definition at line 367 of file jsdbgapi.c.

{
    JSRuntime *rt;
    JSWatchPoint *wp;
    JSScopeProperty *sprop;
    jsval propid, userid;
    JSScope *scope;
    JSBool ok;

    rt = cx->runtime;
    for (wp = (JSWatchPoint *)rt->watchPointList.next;
         wp != (JSWatchPoint *)&rt->watchPointList;
         wp = (JSWatchPoint *)wp->links.next) {
        sprop = wp->sprop;
        if (wp->object == obj && SPROP_USERID(sprop) == id &&
            !(wp->flags & JSWP_HELD)) {
            wp->flags |= JSWP_HELD;

            JS_LOCK_OBJ(cx, obj);
            propid = ID_TO_VALUE(sprop->id);
            userid = (sprop->flags & SPROP_HAS_SHORTID)
                     ? INT_TO_JSVAL(sprop->shortid)
                     : propid;
            scope = OBJ_SCOPE(obj);
            JS_UNLOCK_OBJ(cx, obj);

            /* NB: wp is held, so we can safely dereference it still. */
            ok = wp->handler(cx, obj, propid,
                             SPROP_HAS_VALID_SLOT(sprop, scope)
                             ? OBJ_GET_SLOT(cx, obj, sprop->slot)
                             : JSVAL_VOID,
                             vp, wp->closure);
            if (ok) {
                /*
                 * Create a pseudo-frame for the setter invocation so that any
                 * stack-walking security code under the setter will correctly
                 * identify the guilty party.  So that the watcher appears to
                 * be active to obj_eval and other such code, point frame.pc
                 * at the JSOP_STOP at the end of the script.
                 */
                JSObject *closure;
                JSClass *clasp;
                JSFunction *fun;
                JSScript *script;
                uintN nslots;
                jsval smallv[5];
                jsval *argv;
                JSStackFrame frame;

                closure = (JSObject *) wp->closure;
                clasp = OBJ_GET_CLASS(cx, closure);
                if (clasp == &js_FunctionClass) {
                    fun = (JSFunction *) JS_GetPrivate(cx, closure);
                    script = FUN_SCRIPT(fun);
                } else if (clasp == &js_ScriptClass) {
                    fun = NULL;
                    script = (JSScript *) JS_GetPrivate(cx, closure);
                } else {
                    fun = NULL;
                    script = NULL;
                }

                nslots = 2;
                if (fun) {
                    nslots += fun->nargs;
                    if (FUN_NATIVE(fun))
                        nslots += fun->u.n.extra;
                }

                if (nslots <= JS_ARRAY_LENGTH(smallv)) {
                    argv = smallv;
                } else {
                    argv = JS_malloc(cx, nslots * sizeof(jsval));
                    if (!argv) {
                        DropWatchPoint(cx, wp, JSWP_HELD);
                        return JS_FALSE;
                    }
                }

                argv[0] = OBJECT_TO_JSVAL(closure);
                argv[1] = JSVAL_NULL;
                memset(argv + 2, 0, (nslots - 2) * sizeof(jsval));

                memset(&frame, 0, sizeof(frame));
                frame.script = script;
                if (script) {
                    JS_ASSERT(script->length >= JSOP_STOP_LENGTH);
                    frame.pc = script->code + script->length
                             - JSOP_STOP_LENGTH;
                }
                frame.callee = closure;
                frame.fun = fun;
                frame.argv = argv + 2;
                frame.down = cx->fp;
                frame.scopeChain = OBJ_GET_PARENT(cx, closure);

                cx->fp = &frame;
                ok = !wp->setter ||
                     ((sprop->attrs & JSPROP_SETTER)
                      ? js_InternalCall(cx, obj, OBJECT_TO_JSVAL(wp->setter),
                                        1, vp, vp)
                      : wp->setter(cx, OBJ_THIS_OBJECT(cx, obj), userid, vp));

                /* Evil code can cause us to have an arguments object. */
                if (frame.callobj)
                    ok &= js_PutCallObject(cx, &frame);
                if (frame.argsobj)
                    ok &= js_PutArgsObject(cx, &frame);

                cx->fp = frame.down;
                if (argv != smallv)
                    JS_free(cx, argv);
            }
            return DropWatchPoint(cx, wp, JSWP_HELD) && ok;
        }
    }
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool JS_DLL_CALLBACK js_watch_set_wrapper ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 487 of file jsdbgapi.c.

{
    JSObject *funobj;
    JSFunction *wrapper;
    jsval userid;

    funobj = JSVAL_TO_OBJECT(argv[-2]);
    JS_ASSERT(OBJ_GET_CLASS(cx, funobj) == &js_FunctionClass);
    wrapper = (JSFunction *) JS_GetPrivate(cx, funobj);
    userid = ATOM_KEY(wrapper->atom);
    *rval = argv[0];
    return js_watch_set(cx, obj, userid, rval);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSPropertyOp js_WrapWatchedSetter ( JSContext cx,
jsid  id,
uintN  attrs,
JSPropertyOp  setter 
)

Definition at line 503 of file jsdbgapi.c.

{
    JSAtom *atom;
    JSFunction *wrapper;

    if (!(attrs & JSPROP_SETTER))
        return &js_watch_set;   /* & to silence schoolmarmish MSVC */

    if (JSID_IS_ATOM(id)) {
        atom = JSID_TO_ATOM(id);
    } else if (JSID_IS_INT(id)) {
        atom = js_AtomizeInt(cx, JSID_TO_INT(id), 0);
        if (!atom)
            return NULL;
    } else {
        atom = NULL;
    }
    wrapper = js_NewFunction(cx, NULL, js_watch_set_wrapper, 1, 0,
                             OBJ_GET_PARENT(cx, (JSObject *)setter),
                             atom);
    if (!wrapper)
        return NULL;
    return (JSPropertyOp) wrapper->object;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 187 of file jsdbgapi.h.

Definition at line 274 of file jsdbgapi.h.

Definition at line 181 of file jsdbgapi.h.

JSDestroyScriptHook void* callerdata

Definition at line 259 of file jsdbgapi.h.

Definition at line 268 of file jsdbgapi.h.

JSDebugErrorHook void * closure

Definition at line 55 of file jsdbgapi.h.

JSObject jsval JSWatchPointHandler void ** closurep

Definition at line 62 of file jsdbgapi.h.

Definition at line 268 of file jsdbgapi.h.

Definition at line 381 of file jsdbgapi.h.

Definition at line 151 of file jsdbgapi.h.

Definition at line 132 of file jsdbgapi.h.

JSSourceHandler handler

Definition at line 55 of file jsdbgapi.h.

JSObject jsval JSWatchPointHandler * handlerp

Definition at line 62 of file jsdbgapi.h.

JSDebugErrorHook hook

Definition at line 259 of file jsdbgapi.h.

Definition at line 83 of file jsdbgapi.h.

Definition at line 148 of file jsdbgapi.h.

Definition at line 268 of file jsdbgapi.h.

Definition at line 129 of file jsdbgapi.h.

Definition at line 83 of file jsdbgapi.h.

Definition at line 55 of file jsdbgapi.h.

Definition at line 310 of file jsdbgapi.h.

Definition at line 314 of file jsdbgapi.h.

const char* prefix

Definition at line 381 of file jsdbgapi.h.

Definition at line 72 of file jsdbgapi.h.

Definition at line 55 of file jsdbgapi.h.

Definition at line 310 of file jsdbgapi.h.