Fix Debug.Frame.prototype.older to skip non-debuggee stack frames.
authorJason Orendorff <jorendorff@mozilla.com>
Mon, 16 May 2011 17:56:22 -0500
changeset 74810 aaec89b3971836d24f133a4073d9b690958584d5
parent 74809 2a7cbe40d6284ede0a25eb1bddfb4c9e99696a9f
child 74811 be12caeb033ae18a50ab90393e80e3eb25d29c96
push idunknown
push userunknown
push dateunknown
milestone6.0a1
Fix Debug.Frame.prototype.older to skip non-debuggee stack frames.
js/src/jsdbg.cpp
js/src/jsdbg.h
--- a/js/src/jsdbg.cpp
+++ b/js/src/jsdbg.cpp
@@ -864,19 +864,20 @@ DebugFrame_getThis(JSContext *cx, uintN 
     }
     return Debug::fromChildJSObject(thisobj)->wrapDebuggeeValue(cx, vp);
 }
 
 static JSBool
 DebugFrame_getOlder(JSContext *cx, uintN argc, Value *vp)
 {
     THIS_FRAME(cx, vp, "get this", thisobj, thisfp);
+    Debug *dbg = Debug::fromChildJSObject(thisobj);
     for (StackFrame *fp = thisfp->prev(); fp; fp = fp->prev()) {
-        if (!fp->isDummyFrame())
-            return Debug::fromChildJSObject(thisobj)->getScriptFrame(cx, fp, vp);
+        if (!fp->isDummyFrame() && dbg->observesFrame(fp))
+            return dbg->getScriptFrame(cx, fp, vp);
     }
     vp->setNull();
     return true;
 }
 
 JSBool
 DebugFrame_getArguments(JSContext *cx, uintN argc, Value *vp)
 {
--- a/js/src/jsdbg.h
+++ b/js/src/jsdbg.h
@@ -98,19 +98,16 @@ class Debug {
     static void slowPathLeaveStackFrame(JSContext *cx);
 
     typedef bool (Debug::*DebugObservesMethod)() const;
     typedef JSTrapStatus (Debug::*DebugHandleMethod)(JSContext *, Value *) const;
     static JSTrapStatus dispatchHook(JSContext *cx, js::Value *vp,
                                      DebugObservesMethod observesEvent,
                                      DebugHandleMethod handleEvent);
 
-    inline bool observesScope(JSObject *obj) const;
-    inline bool observesFrame(StackFrame *fp) const;
-
     bool observesDebuggerStatement() const;
     JSTrapStatus handleDebuggerStatement(JSContext *cx, Value *vp);
 
     bool observesThrow() const;
     JSTrapStatus handleThrow(JSContext *cx, Value *vp);
 
   public:
     Debug(JSObject *dbg, JSObject *hooks, JSCompartment *compartment);
@@ -144,16 +141,19 @@ class Debug {
     void detachFrom(JSCompartment *c);
 
     static inline void leaveStackFrame(JSContext *cx);
     static inline JSTrapStatus onDebuggerStatement(JSContext *cx, js::Value *vp);
     static inline JSTrapStatus onThrow(JSContext *cx, js::Value *vp);
 
     /**************************************** Functions for use by jsdbg.cpp. */
 
+    inline bool observesScope(JSObject *obj) const;
+    inline bool observesFrame(StackFrame *fp) const;
+
     // Precondition: *vp is a value from a debuggee compartment and cx is in
     // the debugger's compartment.
     //
     // Wrap *vp for the debugger compartment, wrap it in a Debug.Object if it's
     // an object, store the result in *vp, and return true.
     //
     bool wrapDebuggeeValue(JSContext *cx, Value *vp);