[JAEGER] Facilitate iteration over all JSStackFrames in the current stack. r=luke

This commit is contained in:
Andrew Drake 2010-06-23 21:59:23 -07:00
parent 0800a12fa5
commit 8619e4fd69
2 changed files with 49 additions and 3 deletions

View File

@ -508,6 +508,39 @@ FrameRegsIter::operator++()
return *this;
}
JS_REQUIRES_STACK
AllFramesIter::AllFramesIter(JSContext *cx)
{
JS_ASSERT(CURRENT_THREAD_IS_ME(cx->thread));
curcs = cx->stack()->getCurrentCallStack();
if (!curcs) {
curfp = NULL;
return;
}
curfp = curcs->getCurrentFrame();
}
AllFramesIter &
AllFramesIter::operator++()
{
JS_ASSERT(CURRENT_THREAD_IS_ME(cx->thread));
JS_ASSERT(!done());
if (curfp == curcs->getInitialFrame()) {
curcs = curcs->getPreviousInThread();
if (curcs)
curfp = curcs->getCurrentFrame();
else
curfp = NULL;
} else {
curfp = curfp->down;
}
return *this;
}
bool
JSThreadData::init()
{

View File

@ -651,9 +651,6 @@ class StackSpace
inline Value *firstUnused() const;
inline void assertIsCurrent(JSContext *cx) const;
#ifdef DEBUG
CallStack *getCurrentCallStack() const { return currentCallStack; }
#endif
/*
* Allocate nvals on the top of the stack, report error on failure.
@ -780,6 +777,8 @@ class StackSpace
/* Our privates leak into xpconnect, which needs a public symbol. */
JS_REQUIRES_STACK
JS_FRIEND_API(bool) pushInvokeArgsFriendAPI(JSContext *, uintN, InvokeArgsGuard &);
CallStack *getCurrentCallStack() const { return currentCallStack; }
};
JS_STATIC_ASSERT(StackSpace::CAPACITY_VALS % StackSpace::COMMIT_VALS == 0);
@ -812,6 +811,20 @@ class FrameRegsIter
jsbytecode *pc() const { return curpc; }
};
class AllFramesIter
{
CallStack *curcs;
JSStackFrame *curfp;
public:
JS_REQUIRES_STACK AllFramesIter(JSContext *cx);
bool done() const { return curfp == NULL; }
AllFramesIter &operator++();
JSStackFrame *fp() const { return curfp; }
};
/* Holds the number of recording attemps for an address. */
typedef HashMap<jsbytecode*,
size_t,