Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions
jsdbgapi.c File Reference
#include "jsstddef.h"
#include <string.h>
#include "jstypes.h"
#include "jsutil.h"
#include "jsclist.h"
#include "jsapi.h"
#include "jscntxt.h"
#include "jsconfig.h"
#include "jsdbgapi.h"
#include "jsfun.h"
#include "jsgc.h"
#include "jsinterp.h"
#include "jslock.h"
#include "jsobj.h"
#include "jsopcode.h"
#include "jsscope.h"
#include "jsscript.h"
#include "jsstr.h"
#include "jsemit.h"

Go to the source code of this file.

Classes

struct  JSTrap
struct  JSWatchPoint

Defines

#define JSWP_LIVE   0x1 /* live because set and not cleared */
#define JSWP_HELD   0x2 /* held while running handler/setter */

Typedefs

typedef struct JSTrap JSTrap
typedef struct JSWatchPoint JSWatchPoint

Functions

static JSTrapFindTrap (JSRuntime *rt, JSScript *script, jsbytecode *pc)
void js_PatchOpcode (JSContext *cx, JSScript *script, jsbytecode *pc, JSOp op)
 JS_SetTrap (JSContext *cx, JSScript *script, jsbytecode *pc, JSTrapHandler handler, void *closure)
 JS_GetTrapOpcode (JSContext *cx, JSScript *script, jsbytecode *pc)
static void DestroyTrap (JSContext *cx, JSTrap *trap)
 JS_ClearTrap (JSContext *cx, JSScript *script, jsbytecode *pc, JSTrapHandler *handlerp, void **closurep)
 JS_ClearScriptTraps (JSContext *cx, JSScript *script)
 JS_ClearAllTraps (JSContext *cx)
 JS_HandleTrap (JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval)
 JS_SetInterrupt (JSRuntime *rt, JSTrapHandler handler, void *closure)
 JS_ClearInterrupt (JSRuntime *rt, JSTrapHandler *handlerp, void **closurep)
static JSBool DropWatchPoint (JSContext *cx, JSWatchPoint *wp, uintN flag)
void js_MarkWatchPoints (JSContext *cx)
static JSWatchPointFindWatchPoint (JSRuntime *rt, JSScope *scope, jsid id)
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_SetWatchPoint (JSContext *cx, JSObject *obj, jsval id, JSWatchPointHandler handler, void *closure)
 JS_ClearWatchPoint (JSContext *cx, JSObject *obj, jsval id, JSWatchPointHandler *handlerp, void **closurep)
 JS_ClearWatchPointsForObject (JSContext *cx, JSObject *obj)
 JS_ClearAllWatchPoints (JSContext *cx)
 JS_PCToLineNumber (JSContext *cx, JSScript *script, jsbytecode *pc)
 JS_LineNumberToPC (JSContext *cx, JSScript *script, uintN lineno)
 JS_GetFunctionScript (JSContext *cx, JSFunction *fun)
 JS_GetFunctionNative (JSContext *cx, JSFunction *fun)
 JS_GetScriptPrincipals (JSContext *cx, JSScript *script)
 JS_FrameIterator (JSContext *cx, JSStackFrame **iteratorp)
 JS_GetFrameScript (JSContext *cx, JSStackFrame *fp)
 JS_GetFramePC (JSContext *cx, JSStackFrame *fp)
 JS_GetScriptedCaller (JSContext *cx, JSStackFrame *fp)
 JS_StackFramePrincipals (JSContext *cx, JSStackFrame *fp)
 JS_EvalFramePrincipals (JSContext *cx, JSStackFrame *fp, JSStackFrame *caller)
 JS_GetFrameAnnotation (JSContext *cx, JSStackFrame *fp)
 JS_SetFrameAnnotation (JSContext *cx, JSStackFrame *fp, void *annotation)
 JS_GetFramePrincipalArray (JSContext *cx, JSStackFrame *fp)
 JS_IsNativeFrame (JSContext *cx, JSStackFrame *fp)
 JS_GetFrameObject (JSContext *cx, JSStackFrame *fp)
 JS_GetFrameScopeChain (JSContext *cx, JSStackFrame *fp)
 JS_GetFrameCallObject (JSContext *cx, JSStackFrame *fp)
 JS_GetFrameThis (JSContext *cx, JSStackFrame *fp)
 JS_GetFrameFunction (JSContext *cx, JSStackFrame *fp)
 JS_GetFrameFunctionObject (JSContext *cx, JSStackFrame *fp)
 JS_IsConstructorFrame (JSContext *cx, JSStackFrame *fp)
 JS_GetFrameCalleeObject (JSContext *cx, JSStackFrame *fp)
 JS_IsDebuggerFrame (JSContext *cx, JSStackFrame *fp)
 JS_GetFrameReturnValue (JSContext *cx, JSStackFrame *fp)
 JS_SetFrameReturnValue (JSContext *cx, JSStackFrame *fp, jsval rval)
 JS_GetScriptFilename (JSContext *cx, JSScript *script)
 JS_GetScriptBaseLineNumber (JSContext *cx, JSScript *script)
 JS_GetScriptLineExtent (JSContext *cx, JSScript *script)
 JS_GetScriptVersion (JSContext *cx, JSScript *script)
 JS_SetNewScriptHook (JSRuntime *rt, JSNewScriptHook hook, void *callerdata)
 JS_SetDestroyScriptHook (JSRuntime *rt, JSDestroyScriptHook hook, void *callerdata)
 JS_EvaluateUCInStackFrame (JSContext *cx, JSStackFrame *fp, const jschar *chars, uintN length, const char *filename, uintN lineno, jsval *rval)
 JS_EvaluateInStackFrame (JSContext *cx, JSStackFrame *fp, const char *bytes, uintN length, const char *filename, uintN lineno, jsval *rval)
 JS_PropertyIterator (JSObject *obj, JSScopeProperty **iteratorp)
 JS_GetPropertyDesc (JSContext *cx, JSObject *obj, JSScopeProperty *sprop, JSPropertyDesc *pd)
 JS_GetPropertyDescArray (JSContext *cx, JSObject *obj, JSPropertyDescArray *pda)
 JS_PutPropertyDescArray (JSContext *cx, JSPropertyDescArray *pda)
 JS_SetDebuggerHandler (JSRuntime *rt, JSTrapHandler handler, void *closure)
 JS_SetSourceHandler (JSRuntime *rt, JSSourceHandler handler, void *closure)
 JS_SetExecuteHook (JSRuntime *rt, JSInterpreterHook hook, void *closure)
 JS_SetCallHook (JSRuntime *rt, JSInterpreterHook hook, void *closure)
 JS_SetObjectHook (JSRuntime *rt, JSObjectHook hook, void *closure)
 JS_SetThrowHook (JSRuntime *rt, JSTrapHandler hook, void *closure)
 JS_SetDebugErrorHook (JSRuntime *rt, JSDebugErrorHook hook, void *closure)
 JS_GetObjectTotalSize (JSContext *cx, JSObject *obj)
static size_t GetAtomTotalSize (JSContext *cx, JSAtom *atom)
 JS_GetFunctionTotalSize (JSContext *cx, JSFunction *fun)
 JS_GetScriptTotalSize (JSContext *cx, JSScript *script)
 JS_GetTopScriptFilenameFlags (JSContext *cx, JSStackFrame *fp)
 JS_GetScriptFilenameFlags (JSScript *script)
 JS_FlagScriptFilenamePrefix (JSRuntime *rt, const char *prefix, uint32 flags)
 JS_IsSystemObject (JSContext *cx, JSObject *obj)
 JS_FlagSystemObject (JSContext *cx, JSObject *obj)

Class Documentation

struct JSTrap

Definition at line 63 of file jsdbgapi.c.

Collaboration diagram for JSTrap:
Class Members
void * closure
JSTrapHandler handler
JSCList links
JSOp op
jsbytecode * pc
JSScript * script
struct JSWatchPoint

Definition at line 243 of file jsdbgapi.c.

Collaboration diagram for JSWatchPoint:
Class Members
void * closure
uintN flags
JSWatchPointHandler handler
JSCList links
JSObject * object
JSPropertyOp setter
JSScopeProperty * sprop

Define Documentation

#define JSWP_HELD   0x2 /* held while running handler/setter */

Definition at line 254 of file jsdbgapi.c.

#define JSWP_LIVE   0x1 /* live because set and not cleared */

Definition at line 253 of file jsdbgapi.c.


Typedef Documentation

typedef struct JSTrap JSTrap
typedef struct JSWatchPoint JSWatchPoint

Function Documentation

static void DestroyTrap ( JSContext cx,
JSTrap trap 
) [static]

Definition at line 142 of file jsdbgapi.c.

{
    JS_REMOVE_LINK(&trap->links);
    *trap->pc = (jsbytecode)trap->op;
    js_RemoveRoot(cx->runtime, &trap->closure);
    JS_free(cx, trap);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool DropWatchPoint ( JSContext cx,
JSWatchPoint wp,
uintN  flag 
) [static]

Definition at line 257 of file jsdbgapi.c.

{
    JSBool ok;
    JSScopeProperty *sprop;
    JSObject *pobj;
    JSProperty *prop;
    JSPropertyOp setter;

    ok = JS_TRUE;
    wp->flags &= ~flag;
    if (wp->flags != 0)
        return JS_TRUE;

    /*
     * Remove wp from the list, then if there are no other watchpoints for
     * wp->sprop in any scope, restore wp->sprop->setter from wp.
     */
    JS_REMOVE_LINK(&wp->links);
    sprop = wp->sprop;

    /*
     * If js_ChangeNativePropertyAttrs fails, propagate failure after removing
     * wp->closure's root and freeing wp.
     */
    setter = js_GetWatchedSetter(cx->runtime, NULL, sprop);
    if (!setter) {
        ok = js_LookupProperty(cx, wp->object, sprop->id, &pobj, &prop);

        /*
         * If the property wasn't found on wp->object or didn't exist, then
         * someone else has dealt with this sprop, and we don't need to change
         * the property attributes.
         */
        if (ok && prop) {
            if (pobj == wp->object) {
                JS_ASSERT(OBJ_SCOPE(pobj)->object == pobj);

                sprop = js_ChangeScopePropertyAttrs(cx, OBJ_SCOPE(pobj), sprop,
                                                    0, sprop->attrs,
                                                    sprop->getter,
                                                    wp->setter);
                if (!sprop)
                    ok = JS_FALSE;
            }
            OBJ_DROP_PROPERTY(cx, pobj, prop);
        }
    }

    js_RemoveRoot(cx->runtime, &wp->closure);
    JS_free(cx, wp);
    return ok;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSTrap* FindTrap ( JSRuntime rt,
JSScript script,
jsbytecode pc 
) [static]

Definition at line 73 of file jsdbgapi.c.

{
    JSTrap *trap;

    for (trap = (JSTrap *)rt->trapList.next;
         trap != (JSTrap *)&rt->trapList;
         trap = (JSTrap *)trap->links.next) {
        if (trap->script == script && trap->pc == pc)
            return trap;
    }
    return NULL;
}

Here is the caller graph for this function:

static JSWatchPoint* FindWatchPoint ( JSRuntime rt,
JSScope scope,
jsid  id 
) [static]

Definition at line 327 of file jsdbgapi.c.

{
    JSWatchPoint *wp;

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

Here is the caller graph for this function:

static size_t GetAtomTotalSize ( JSContext cx,
JSAtom atom 
) [static]

Definition at line 1323 of file jsdbgapi.c.

{
    size_t nbytes;

    nbytes = sizeof *atom;
    if (ATOM_IS_STRING(atom)) {
        nbytes += sizeof(JSString);
        nbytes += (ATOM_TO_STRING(atom)->length + 1) * sizeof(jschar);
    } else if (ATOM_IS_DOUBLE(atom)) {
        nbytes += sizeof(jsdouble);
    } else if (ATOM_IS_OBJECT(atom)) {
        nbytes += JS_GetObjectTotalSize(cx, ATOM_TO_OBJECT(atom));
    }
    return nbytes;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 182 of file jsdbgapi.c.

{
    JSRuntime *rt;
    JSTrap *trap, *next;

    rt = cx->runtime;
    for (trap = (JSTrap *)rt->trapList.next;
         trap != (JSTrap *)&rt->trapList;
         trap = next) {
        next = (JSTrap *)trap->links.next;
        DestroyTrap(cx, trap);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 712 of file jsdbgapi.c.

{
    JSRuntime *rt;
    JSWatchPoint *wp, *next;

    rt = cx->runtime;
    for (wp = (JSWatchPoint *)rt->watchPointList.next;
         wp != (JSWatchPoint *)&rt->watchPointList;
         wp = next) {
        next = (JSWatchPoint *)wp->links.next;
        if (!DropWatchPoint(cx, wp, JSWP_LIVE))
            return JS_FALSE;
    }
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JS_ClearInterrupt ( JSRuntime rt,
JSTrapHandler *  handlerp,
void **  closurep 
)

Definition at line 230 of file jsdbgapi.c.

{
    if (handlerp)
        *handlerp = (JSTrapHandler)rt->interruptHandler;
    if (closurep)
        *closurep = rt->interruptHandlerData;
    rt->interruptHandler = 0;
    rt->interruptHandlerData = 0;
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JS_ClearScriptTraps ( JSContext cx,
JSScript script 
)

Definition at line 166 of file jsdbgapi.c.

{
    JSRuntime *rt;
    JSTrap *trap, *next;

    rt = cx->runtime;
    for (trap = (JSTrap *)rt->trapList.next;
         trap != (JSTrap *)&rt->trapList;
         trap = next) {
        next = (JSTrap *)trap->links.next;
        if (trap->script == script)
            DestroyTrap(cx, trap);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

JS_ClearTrap ( JSContext cx,
JSScript script,
jsbytecode pc,
JSTrapHandler *  handlerp,
void **  closurep 
)

Definition at line 151 of file jsdbgapi.c.

{
    JSTrap *trap;

    trap = FindTrap(cx->runtime, script, pc);
    if (handlerp)
        *handlerp = trap ? trap->handler : NULL;
    if (closurep)
        *closurep = trap ? trap->closure : NULL;
    if (trap)
        DestroyTrap(cx, trap);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JS_ClearWatchPoint ( JSContext cx,
JSObject obj,
jsval  id,
JSWatchPointHandler *  handlerp,
void **  closurep 
)

Definition at line 669 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) {
        if (wp->object == obj && SPROP_USERID(wp->sprop) == id) {
            if (handlerp)
                *handlerp = wp->handler;
            if (closurep)
                *closurep = wp->closure;
            return DropWatchPoint(cx, wp, JSWP_LIVE);
        }
    }
    if (handlerp)
        *handlerp = NULL;
    if (closurep)
        *closurep = NULL;
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 695 of file jsdbgapi.c.

{
    JSRuntime *rt;
    JSWatchPoint *wp, *next;

    rt = cx->runtime;
    for (wp = (JSWatchPoint *)rt->watchPointList.next;
         wp != (JSWatchPoint *)&rt->watchPointList;
         wp = next) {
        next = (JSWatchPoint *)wp->links.next;
        if (wp->object == obj && !DropWatchPoint(cx, wp, JSWP_LIVE))
            return JS_FALSE;
    }
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JS_EvalFramePrincipals ( JSContext cx,
JSStackFrame fp,
JSStackFrame caller 
)

Definition at line 816 of file jsdbgapi.c.

{
    JSRuntime *rt;
    JSObject *callee;
    JSPrincipals *principals, *callerPrincipals;

    rt = cx->runtime;
    if (rt->findObjectPrincipals) {
        callee = JSVAL_TO_OBJECT(fp->argv[-2]);
        principals = rt->findObjectPrincipals(cx, callee);
    } else {
        principals = NULL;
    }
    if (!caller)
        return principals;
    callerPrincipals = JS_StackFramePrincipals(cx, caller);
    return (callerPrincipals && principals &&
            callerPrincipals->subsume(callerPrincipals, principals))
           ? principals
           : callerPrincipals;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JS_EvaluateInStackFrame ( JSContext cx,
JSStackFrame fp,
const char *  bytes,
uintN  length,
const char *  filename,
uintN  lineno,
jsval rval 
)

Definition at line 1042 of file jsdbgapi.c.

{
    jschar *chars;
    JSBool ok;
    size_t len = length;

    chars = js_InflateString(cx, bytes, &len);
    if (!chars)
        return JS_FALSE;
    length = (uintN) len;
    ok = JS_EvaluateUCInStackFrame(cx, fp, chars, length, filename, lineno,
                                   rval);
    JS_free(cx, chars);

    return ok;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JS_EvaluateUCInStackFrame ( JSContext cx,
JSStackFrame fp,
const jschar chars,
uintN  length,
const char *  filename,
uintN  lineno,
jsval rval 
)

Definition at line 1005 of file jsdbgapi.c.

{
    JSObject *scobj;
    uint32 flags, options;
    JSScript *script;
    JSBool ok;

    scobj = JS_GetFrameScopeChain(cx, fp);
    if (!scobj)
        return JS_FALSE;

    /*
     * XXX Hack around ancient compiler API to propagate the JSFRAME_SPECIAL
     * flags to the code generator (see js_EmitTree's TOK_SEMI case).
     */
    flags = fp->flags;
    fp->flags |= JSFRAME_DEBUGGER | JSFRAME_EVAL;
    options = cx->options;
    cx->options = options | JSOPTION_COMPILE_N_GO;
    script = JS_CompileUCScriptForPrincipals(cx, scobj,
                                             JS_StackFramePrincipals(cx, fp),
                                             chars, length, filename, lineno);
    fp->flags = flags;
    cx->options = options;
    if (!script)
        return JS_FALSE;

    ok = js_Execute(cx, scobj, script, fp, JSFRAME_DEBUGGER | JSFRAME_EVAL,
                    rval);
    js_DestroyScript(cx, script);
    return ok;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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:

JS_FlagScriptFilenamePrefix ( JSRuntime rt,
const char *  prefix,
uint32  flags 
)

Definition at line 1427 of file jsdbgapi.c.

{
    if (!js_SaveScriptFilenameRT(rt, prefix, flags))
        return JS_FALSE;
    return JS_TRUE;
}

Here is the call graph for this function:

JS_FlagSystemObject ( JSContext cx,
JSObject obj 
)

Definition at line 1441 of file jsdbgapi.c.

{
    uint8 *flagp;

    flagp = js_GetGCThingFlags(obj);
    *flagp |= GCF_SYSTEM;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JS_FrameIterator ( JSContext cx,
JSStackFrame **  iteratorp 
)

Definition at line 766 of file jsdbgapi.c.

{
    *iteratorp = (*iteratorp == NULL) ? cx->fp : (*iteratorp)->down;
    return *iteratorp;
}

Here is the caller graph for this function:

Definition at line 839 of file jsdbgapi.c.

{
    if (fp->annotation && fp->script) {
        JSPrincipals *principals = JS_StackFramePrincipals(cx, fp);

        if (principals && principals->globalPrivilegesEnabled(cx, principals)) {
            /*
             * Give out an annotation only if privileges have not been revoked
             * or disabled globally.
             */
            return fp->annotation;
        }
    }

    return NULL;
}

Here is the call graph for this function:

Definition at line 936 of file jsdbgapi.c.

{
    return fp->argv ? JSVAL_TO_OBJECT(fp->argv[-2]) : NULL;
}

Here is the caller graph for this function:

Definition at line 895 of file jsdbgapi.c.

{
    if (! fp->fun)
        return NULL;

    /* Force creation of argument object if not yet created */
    (void) js_GetArgsObject(cx, fp);

    /*
     * XXX ill-defined: null return here means error was reported, unlike a
     *     null returned above or in the #else
     */
    return js_GetCallObject(cx, fp, NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 918 of file jsdbgapi.c.

{
    return fp->fun;
}

Here is the caller graph for this function:

Definition at line 924 of file jsdbgapi.c.

{
    return fp->argv && fp->fun ? JSVAL_TO_OBJECT(fp->argv[-2]) : NULL;
}

Here is the caller graph for this function:

Definition at line 881 of file jsdbgapi.c.

{
    return fp->scopeChain;
}
JS_GetFramePC ( JSContext cx,
JSStackFrame fp 
)

Definition at line 779 of file jsdbgapi.c.

{
    return fp->pc;
}

Here is the caller graph for this function:

Definition at line 863 of file jsdbgapi.c.

{
    JSPrincipals *principals;

    principals = JS_StackFramePrincipals(cx, fp);
    if (!principals)
        return NULL;
    return principals->getPrincipalArray(cx, principals);
}

Here is the call graph for this function:

Definition at line 948 of file jsdbgapi.c.

{
    return fp->rval;
}

Definition at line 887 of file jsdbgapi.c.

{
    /* Force creation of argument and call objects if not yet created */
    (void) JS_GetFrameCallObject(cx, fp);
    return js_GetScopeChain(cx, fp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 773 of file jsdbgapi.c.

{
    return fp->script;
}

Here is the caller graph for this function:

JS_GetFrameThis ( JSContext cx,
JSStackFrame fp 
)

Definition at line 912 of file jsdbgapi.c.

{
    return fp->thisp;
}

Here is the caller graph for this function:

JS_GetFunctionNative ( JSContext cx,
JSFunction fun 
)

Definition at line 749 of file jsdbgapi.c.

{
    return FUN_NATIVE(fun);
}

Here is the caller graph for this function:

JS_GetFunctionScript ( JSContext cx,
JSFunction fun 
)

Definition at line 743 of file jsdbgapi.c.

{
    return FUN_SCRIPT(fun);
}

Here is the caller graph for this function:

Definition at line 1340 of file jsdbgapi.c.

{
    size_t nbytes;

    nbytes = sizeof *fun;
    if (fun->object)
        nbytes += JS_GetObjectTotalSize(cx, fun->object);
    if (FUN_INTERPRETED(fun))
        nbytes += JS_GetScriptTotalSize(cx, fun->u.i.script);
    if (fun->atom)
        nbytes += GetAtomTotalSize(cx, fun->atom);
    return nbytes;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JS_GetObjectTotalSize ( JSContext cx,
JSObject obj 
)

Definition at line 1306 of file jsdbgapi.c.

{
    size_t nbytes;
    JSScope *scope;

    nbytes = sizeof *obj + obj->map->nslots * sizeof obj->slots[0];
    if (OBJ_IS_NATIVE(obj)) {
        scope = OBJ_SCOPE(obj);
        if (scope->object == obj) {
            nbytes += sizeof *scope;
            nbytes += SCOPE_CAPACITY(scope) * sizeof(JSScopeProperty *);
        }
    }
    return nbytes;
}

Here is the caller graph for this function:

JS_GetPropertyDesc ( JSContext cx,
JSObject obj,
JSScopeProperty sprop,
JSPropertyDesc pd 
)

Definition at line 1091 of file jsdbgapi.c.

{
    JSPropertyOp getter;
    JSScope *scope;
    JSScopeProperty *aprop;
    jsval lastException;
    JSBool wasThrowing;

    pd->id = ID_TO_VALUE(sprop->id);

    wasThrowing = cx->throwing;
    if (wasThrowing) {
        lastException = cx->exception;
        if (JSVAL_IS_GCTHING(lastException) &&
            !js_AddRoot(cx, &lastException, "lastException")) {
                return JS_FALSE;
        }
        cx->throwing = JS_FALSE;
    }

    if (!js_GetProperty(cx, obj, sprop->id, &pd->value)) {
        if (!cx->throwing) {
            pd->flags = JSPD_ERROR;
            pd->value = JSVAL_VOID;
        } else {
            pd->flags = JSPD_EXCEPTION;
            pd->value = cx->exception;
        }
    } else {
        pd->flags = 0;
    }

    cx->throwing = wasThrowing;
    if (wasThrowing) {
        cx->exception = lastException;
        if (JSVAL_IS_GCTHING(lastException))
            js_RemoveRoot(cx->runtime, &lastException);
    }

    getter = sprop->getter;
    pd->flags |= ((sprop->attrs & JSPROP_ENUMERATE) ? JSPD_ENUMERATE : 0)
              | ((sprop->attrs & JSPROP_READONLY)  ? JSPD_READONLY  : 0)
              | ((sprop->attrs & JSPROP_PERMANENT) ? JSPD_PERMANENT : 0)
              | ((getter == js_GetCallVariable)    ? JSPD_VARIABLE  : 0)
              | ((getter == js_GetArgument)        ? JSPD_ARGUMENT  : 0)
              | ((getter == js_GetLocalVariable)   ? JSPD_VARIABLE  : 0);

    /* for Call Object 'real' getter isn't passed in to us */
    if (OBJ_GET_CLASS(cx, obj) == &js_CallClass &&
        getter == js_CallClass.getProperty) {
        /*
         * Property of a heavyweight function's variable object having the
         * class-default getter.  It's either an argument if permanent, or a
         * nested function if impermanent.  Local variables have a special
         * getter (js_GetCallVariable, tested above) and setter, and not the
         * class default.
         */
        pd->flags |= (sprop->attrs & JSPROP_PERMANENT)
                     ? JSPD_ARGUMENT
                     : JSPD_VARIABLE;
    }

    pd->spare = 0;
    pd->slot = (pd->flags & (JSPD_ARGUMENT | JSPD_VARIABLE))
               ? sprop->shortid
               : 0;
    pd->alias = JSVAL_VOID;
    scope = OBJ_SCOPE(obj);
    if (SPROP_HAS_VALID_SLOT(sprop, scope)) {
        for (aprop = SCOPE_LAST_PROP(scope); aprop; aprop = aprop->parent) {
            if (aprop != sprop && aprop->slot == sprop->slot) {
                pd->alias = ID_TO_VALUE(aprop->id);
                break;
            }
        }
    }
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1172 of file jsdbgapi.c.

{
    JSClass *clasp;
    JSScope *scope;
    uint32 i, n;
    JSPropertyDesc *pd;
    JSScopeProperty *sprop;

    clasp = OBJ_GET_CLASS(cx, obj);
    if (!OBJ_IS_NATIVE(obj) || (clasp->flags & JSCLASS_NEW_ENUMERATE)) {
        JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
                             JSMSG_CANT_DESCRIBE_PROPS, clasp->name);
        return JS_FALSE;
    }
    if (!clasp->enumerate(cx, obj))
        return JS_FALSE;

    /* have no props, or object's scope has not mutated from that of proto */
    scope = OBJ_SCOPE(obj);
    if (scope->object != obj || scope->entryCount == 0) {
        pda->length = 0;
        pda->array = NULL;
        return JS_TRUE;
    }

    n = scope->entryCount;
    if (n > scope->map.nslots)
        n = scope->map.nslots;
    pd = (JSPropertyDesc *) JS_malloc(cx, (size_t)n * sizeof(JSPropertyDesc));
    if (!pd)
        return JS_FALSE;
    i = 0;
    for (sprop = SCOPE_LAST_PROP(scope); sprop; sprop = sprop->parent) {
        if (SCOPE_HAD_MIDDLE_DELETE(scope) && !SCOPE_HAS_PROPERTY(scope, sprop))
            continue;
        if (!js_AddRoot(cx, &pd[i].id, NULL))
            goto bad;
        if (!js_AddRoot(cx, &pd[i].value, NULL))
            goto bad;
        if (!JS_GetPropertyDesc(cx, obj, sprop, &pd[i]))
            goto bad;
        if ((pd[i].flags & JSPD_ALIAS) && !js_AddRoot(cx, &pd[i].alias, NULL))
            goto bad;
        if (++i == n)
            break;
    }
    pda->length = i;
    pda->array = pd;
    return JS_TRUE;

bad:
    pda->length = i + 1;
    pda->array = pd;
    JS_PutPropertyDescArray(cx, pda);
    return JS_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JS_GetScriptBaseLineNumber ( JSContext cx,
JSScript script 
)

Definition at line 968 of file jsdbgapi.c.

{
    return script->lineno;
}

Here is the caller graph for this function:

Definition at line 785 of file jsdbgapi.c.

{
    if (!fp)
        fp = cx->fp;
    while ((fp = fp->down) != NULL) {
        if (fp->script)
            return fp;
    }
    return NULL;
}

Here is the caller graph for this function:

JS_GetScriptFilename ( JSContext cx,
JSScript script 
)

Definition at line 962 of file jsdbgapi.c.

{
    return script->filename;
}

Here is the caller graph for this function:

Definition at line 1418 of file jsdbgapi.c.

{
    JS_ASSERT(script);
    if (!script->filename)
        return JSFILENAME_NULL;
    return js_GetScriptFilenameFlags(script->filename);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JS_GetScriptLineExtent ( JSContext cx,
JSScript script 
)

Definition at line 974 of file jsdbgapi.c.

{
    return js_GetScriptLineExtent(script);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JS_GetScriptPrincipals ( JSContext cx,
JSScript script 
)

Definition at line 755 of file jsdbgapi.c.

{
    return script->principals;
}

Here is the caller graph for this function:

JS_GetScriptTotalSize ( JSContext cx,
JSScript script 
)

Definition at line 1357 of file jsdbgapi.c.

{
    size_t nbytes, pbytes;
    JSObject *obj;
    jsatomid i;
    jssrcnote *sn, *notes;
    JSTryNote *tn, *tnotes;
    JSPrincipals *principals;

    nbytes = sizeof *script;
    obj = script->object;
    if (obj)
        nbytes += JS_GetObjectTotalSize(cx, obj);

    nbytes += script->length * sizeof script->code[0];
    nbytes += script->atomMap.length * sizeof script->atomMap.vector[0];
    for (i = 0; i < script->atomMap.length; i++)
        nbytes += GetAtomTotalSize(cx, script->atomMap.vector[i]);

    if (script->filename)
        nbytes += strlen(script->filename) + 1;

    notes = SCRIPT_NOTES(script);
    for (sn = notes; !SN_IS_TERMINATOR(sn); sn = SN_NEXT(sn))
        continue;
    nbytes += (sn - notes + 1) * sizeof *sn;

    tnotes = script->trynotes;
    if (tnotes) {
        for (tn = tnotes; tn->catchStart; tn++)
            continue;
        nbytes += (tn - tnotes + 1) * sizeof *tn;
    }

    principals = script->principals;
    if (principals) {
        JS_ASSERT(principals->refcount);
        pbytes = sizeof *principals;
        if (principals->refcount > 1)
            pbytes = JS_HOWMANY(pbytes, principals->refcount);
        nbytes += pbytes;
    }

    return nbytes;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JS_GetScriptVersion ( JSContext cx,
JSScript script 
)

Definition at line 980 of file jsdbgapi.c.

{
    return script->version & JSVERSION_MASK;
}

Definition at line 1404 of file jsdbgapi.c.

{
    if (!fp)
        fp = cx->fp;
    while (fp) {
        if (fp->script) {
            return JS_GetScriptFilenameFlags(fp->script);
        }
        fp = fp->down;
    }
    return 0;
 }

Here is the call graph for this function:

Here is the caller graph for this function:

JS_GetTrapOpcode ( JSContext cx,
JSScript script,
jsbytecode pc 
)

Definition at line 129 of file jsdbgapi.c.

{
    JSTrap *trap;

    trap = FindTrap(cx->runtime, script, pc);
    if (!trap) {
        JS_ASSERT(0);   /* XXX can't happen */
        return JSOP_LIMIT;
    }
    return trap->op;
}

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:

JS_HandleTrap ( JSContext cx,
JSScript script,
jsbytecode pc,
jsval rval 
)

Definition at line 197 of file jsdbgapi.c.

{
    JSTrap *trap;
    JSTrapStatus status;
    jsint op;

    trap = FindTrap(cx->runtime, script, pc);
    if (!trap) {
        JS_ASSERT(0);   /* XXX can't happen */
        return JSTRAP_ERROR;
    }
    /*
     * It's important that we not use 'trap->' after calling the callback --
     * the callback might remove the trap!
     */
    op = (jsint)trap->op;
    status = trap->handler(cx, script, pc, rval, trap->closure);
    if (status == JSTRAP_CONTINUE) {
        /* By convention, return the true op to the interpreter in rval. */
        *rval = INT_TO_JSVAL(op);
    }
    return status;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 930 of file jsdbgapi.c.

{
    return (fp->flags & JSFRAME_CONSTRUCTING) != 0;
}

Here is the caller graph for this function:

Definition at line 942 of file jsdbgapi.c.

{
    return (fp->flags & JSFRAME_DEBUGGER) != 0;
}

Here is the caller graph for this function:

JS_IsNativeFrame ( JSContext cx,
JSStackFrame fp 
)

Definition at line 874 of file jsdbgapi.c.

{
    return !fp->script;
}

Here is the caller graph for this function:

JS_IsSystemObject ( JSContext cx,
JSObject obj 
)

Definition at line 1435 of file jsdbgapi.c.

{
    return (*js_GetGCThingFlags(obj) & GCF_SYSTEM) != 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JS_LineNumberToPC ( JSContext cx,
JSScript script,
uintN  lineno 
)

Definition at line 737 of file jsdbgapi.c.

{
    return js_LineNumberToPC(script, lineno);
}

Here is the call graph for this function:

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:

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:

JS_PCToLineNumber ( JSContext cx,
JSScript script,
jsbytecode pc 
)

Definition at line 731 of file jsdbgapi.c.

{
    return js_PCToLineNumber(cx, script, pc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JS_PropertyIterator ( JSObject obj,
JSScopeProperty **  iteratorp 
)

Definition at line 1067 of file jsdbgapi.c.

{
    JSScopeProperty *sprop;
    JSScope *scope;

    sprop = *iteratorp;
    scope = OBJ_SCOPE(obj);

    /* XXXbe minor(?) incompatibility: iterate in reverse definition order */
    if (!sprop) {
        sprop = SCOPE_LAST_PROP(scope);
    } else {
        while ((sprop = sprop->parent) != NULL) {
            if (!SCOPE_HAD_MIDDLE_DELETE(scope))
                break;
            if (SCOPE_HAS_PROPERTY(scope, sprop))
                break;
        }
    }
    *iteratorp = sprop;
    return sprop;
}

Definition at line 1230 of file jsdbgapi.c.

{
    JSPropertyDesc *pd;
    uint32 i;

    pd = pda->array;
    for (i = 0; i < pda->length; i++) {
        js_RemoveRoot(cx->runtime, &pd[i].id);
        js_RemoveRoot(cx->runtime, &pd[i].value);
        if (pd[i].flags & JSPD_ALIAS)
            js_RemoveRoot(cx->runtime, &pd[i].alias);
    }
    JS_free(cx, pd);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JS_SetCallHook ( JSRuntime rt,
JSInterpreterHook  hook,
void closure 
)

Definition at line 1272 of file jsdbgapi.c.

{
    rt->callHook = hook;
    rt->callHookData = closure;
    return JS_TRUE;
}

Here is the caller graph for this function:

JS_SetDebugErrorHook ( JSRuntime rt,
JSDebugErrorHook  hook,
void closure 
)

Definition at line 1296 of file jsdbgapi.c.

Here is the caller graph for this function:

JS_SetDebuggerHandler ( JSRuntime rt,
JSTrapHandler  handler,
void closure 
)

Definition at line 1248 of file jsdbgapi.c.

Here is the caller graph for this function:

JS_SetDestroyScriptHook ( JSRuntime rt,
JSDestroyScriptHook  hook,
void callerdata 
)

Definition at line 995 of file jsdbgapi.c.

JS_SetExecuteHook ( JSRuntime rt,
JSInterpreterHook  hook,
void closure 
)

Definition at line 1264 of file jsdbgapi.c.

{
    rt->executeHook = hook;
    rt->executeHookData = closure;
    return JS_TRUE;
}

Here is the caller graph for this function:

JS_SetFrameAnnotation ( JSContext cx,
JSStackFrame fp,
void annotation 
)

Definition at line 857 of file jsdbgapi.c.

JS_SetFrameReturnValue ( JSContext cx,
JSStackFrame fp,
jsval  rval 
)

Definition at line 954 of file jsdbgapi.c.

{
    fp->rval = rval;
}
JS_SetInterrupt ( JSRuntime rt,
JSTrapHandler  handler,
void closure 
)

Definition at line 222 of file jsdbgapi.c.

Here is the caller graph for this function:

JS_SetNewScriptHook ( JSRuntime rt,
JSNewScriptHook  hook,
void callerdata 
)

Definition at line 988 of file jsdbgapi.c.

JS_SetObjectHook ( JSRuntime rt,
JSObjectHook  hook,
void closure 
)

Definition at line 1280 of file jsdbgapi.c.

{
    rt->objectHook = hook;
    rt->objectHookData = closure;
    return JS_TRUE;
}

Here is the caller graph for this function:

JS_SetSourceHandler ( JSRuntime rt,
JSSourceHandler  handler,
void closure 
)

Definition at line 1256 of file jsdbgapi.c.

Here is the caller graph for this function:

JS_SetThrowHook ( JSRuntime rt,
JSTrapHandler  hook,
void closure 
)

Definition at line 1288 of file jsdbgapi.c.

{
    rt->throwHook = hook;
    rt->throwHookData = closure;
    return JS_TRUE;
}

Here is the caller graph for this function:

JS_SetTrap ( JSContext cx,
JSScript script,
jsbytecode pc,
JSTrapHandler  handler,
void closure 
)

Definition at line 99 of file jsdbgapi.c.

{
    JSRuntime *rt;
    JSTrap *trap;

    rt = cx->runtime;
    trap = FindTrap(rt, script, pc);
    if (trap) {
        JS_ASSERT(trap->script == script && trap->pc == pc);
        JS_ASSERT(*pc == JSOP_TRAP);
    } else {
        trap = (JSTrap *) JS_malloc(cx, sizeof *trap);
        if (!trap || !js_AddRoot(cx, &trap->closure, "trap->closure")) {
            if (trap)
                JS_free(cx, trap);
            return JS_FALSE;
        }
        JS_APPEND_LINK(&trap->links, &rt->trapList);
        trap->script = script;
        trap->pc = pc;
        trap->op = (JSOp)*pc;
        *pc = JSOP_TRAP;
    }
    trap->handler = handler;
    trap->closure = closure;
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JS_SetWatchPoint ( JSContext cx,
JSObject obj,
jsval  id,
JSWatchPointHandler  handler,
void closure 
)

Definition at line 529 of file jsdbgapi.c.

{
    JSAtom *atom;
    jsid propid;
    JSObject *pobj;
    JSProperty *prop;
    JSScopeProperty *sprop;
    JSRuntime *rt;
    JSBool ok;
    JSWatchPoint *wp;
    JSPropertyOp watcher;

    if (!OBJ_IS_NATIVE(obj)) {
        JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_WATCH,
                             OBJ_GET_CLASS(cx, obj)->name);
        return JS_FALSE;
    }

    if (JSVAL_IS_INT(id)) {
        propid = INT_JSVAL_TO_JSID(id);
        atom = NULL;
    } else {
        atom = js_ValueToStringAtom(cx, id);
        if (!atom)
            return JS_FALSE;
        propid = ATOM_TO_JSID(atom);
    }

    if (!js_LookupProperty(cx, obj, propid, &pobj, &prop))
        return JS_FALSE;
    sprop = (JSScopeProperty *) prop;
    rt = cx->runtime;
    if (!sprop) {
        /* Check for a deleted symbol watchpoint, which holds its property. */
        sprop = js_FindWatchPoint(rt, OBJ_SCOPE(obj), propid);
        if (!sprop) {
            /* Make a new property in obj so we can watch for the first set. */
            if (!js_DefineProperty(cx, obj, propid, JSVAL_VOID,
                                   NULL, NULL, JSPROP_ENUMERATE,
                                   &prop)) {
                return JS_FALSE;
            }
            sprop = (JSScopeProperty *) prop;
        }
    } else if (pobj != obj) {
        /* Clone the prototype property so we can watch the right object. */
        jsval value;
        JSPropertyOp getter, setter;
        uintN attrs, flags;
        intN shortid;

        if (OBJ_IS_NATIVE(pobj)) {
            value = SPROP_HAS_VALID_SLOT(sprop, OBJ_SCOPE(pobj))
                    ? LOCKED_OBJ_GET_SLOT(pobj, sprop->slot)
                    : JSVAL_VOID;
            getter = sprop->getter;
            setter = sprop->setter;
            attrs = sprop->attrs;
            flags = sprop->flags;
            shortid = sprop->shortid;
        } else {
            if (!OBJ_GET_PROPERTY(cx, pobj, id, &value) ||
                !OBJ_GET_ATTRIBUTES(cx, pobj, id, prop, &attrs)) {
                OBJ_DROP_PROPERTY(cx, pobj, prop);
                return JS_FALSE;
            }
            getter = setter = NULL;
            flags = 0;
            shortid = 0;
        }
        OBJ_DROP_PROPERTY(cx, pobj, prop);

        /* Recall that obj is native, whether or not pobj is native. */
        if (!js_DefineNativeProperty(cx, obj, propid, value, getter, setter,
                                     attrs, flags, shortid, &prop)) {
            return JS_FALSE;
        }
        sprop = (JSScopeProperty *) prop;
    }

    /*
     * At this point, prop/sprop exists in obj, obj is locked, and we must
     * OBJ_DROP_PROPERTY(cx, obj, prop) before returning.
     */
    ok = JS_TRUE;
    wp = FindWatchPoint(rt, OBJ_SCOPE(obj), propid);
    if (!wp) {
        watcher = js_WrapWatchedSetter(cx, propid, sprop->attrs, sprop->setter);
        if (!watcher) {
            ok = JS_FALSE;
            goto out;
        }

        wp = (JSWatchPoint *) JS_malloc(cx, sizeof *wp);
        if (!wp) {
            ok = JS_FALSE;
            goto out;
        }
        wp->handler = NULL;
        wp->closure = NULL;
        ok = js_AddRoot(cx, &wp->closure, "wp->closure");
        if (!ok) {
            JS_free(cx, wp);
            goto out;
        }
        wp->object = obj;
        JS_ASSERT(sprop->setter != js_watch_set || pobj != obj);
        wp->setter = sprop->setter;
        wp->flags = JSWP_LIVE;

        /* XXXbe nest in obj lock here */
        sprop = js_ChangeNativePropertyAttrs(cx, obj, sprop, 0, sprop->attrs,
                                             sprop->getter, watcher);
        if (!sprop) {
            /* Self-link so DropWatchPoint can JS_REMOVE_LINK it. */
            JS_INIT_CLIST(&wp->links);
            DropWatchPoint(cx, wp, JSWP_LIVE);
            ok = JS_FALSE;
            goto out;
        }
        wp->sprop = sprop;

        /*
         * Now that wp is fully initialized, append it to rt's wp list.
         * Because obj is locked we know that no other thread could have added
         * a watchpoint for (obj, propid).
         */
        JS_ASSERT(!FindWatchPoint(rt, OBJ_SCOPE(obj), propid));
        JS_APPEND_LINK(&wp->links, &rt->watchPointList);
    }
    wp->handler = handler;
    wp->closure = closure;

out:
    OBJ_DROP_PROPERTY(cx, obj, prop);
    return ok;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 797 of file jsdbgapi.c.

{
    if (fp->fun) {
        JSRuntime *rt = cx->runtime;

        if (rt->findObjectPrincipals) {
            JSObject *callee = JSVAL_TO_OBJECT(fp->argv[-2]);

            if (fp->fun->object != callee)
                return rt->findObjectPrincipals(cx, callee);
            /* FALL THROUGH */
        }
    }
    if (fp->script)
        return fp->script->principals;
    return NULL;
}

Here is the caller graph for this function:

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: