From eaa0ad5325c8f3af5f1de8ccd6a81d9599e07e51 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowacki Date: Fri, 21 Aug 2009 11:02:19 +0200 Subject: JSC::Debugger fix. Events exceptionThrow and functionExit modification JSC::Debugger::exceptionThrow event was moved _before_ stacks unwinding so there is possibility to check stack state before it's deletion. Missing functionExit event was added in Interpreter::unwind() Reviewed-by: Kent Hansen --- .../JavaScriptCore/interpreter/Interpreter.cpp | 36 ++++++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp b/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp index c78466e..3af4a29 100644 --- a/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp @@ -471,9 +471,12 @@ NEVER_INLINE bool Interpreter::unwindCallFrame(CallFrame*& callFrame, JSValue ex if (Debugger* debugger = callFrame->dynamicGlobalObject()->debugger()) { DebuggerCallFrame debuggerCallFrame(callFrame, exceptionValue); - if (callFrame->callee()) + if (callFrame->callee()) { debugger->returnEvent(debuggerCallFrame, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->lastLine()); - else +#ifdef QT_BUILD_SCRIPT_LIB + debugger->functionExit(exceptionValue, codeBlock->ownerNode()->sourceID()); +#endif + } else debugger->didExecuteProgram(debuggerCallFrame, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->lastLine()); } @@ -575,19 +578,32 @@ NEVER_INLINE HandlerInfo* Interpreter::throwException(CallFrame*& callFrame, JSV // Calculate an exception handler vPC, unwinding call frames as necessary. HandlerInfo* handler = 0; - while (!(handler = codeBlock->handlerForBytecodeOffset(bytecodeOffset))) { - if (!unwindCallFrame(callFrame, exceptionValue, bytecodeOffset, codeBlock)) { + #ifdef QT_BUILD_SCRIPT_LIB - if (debugger) - debugger->exceptionThrow(DebuggerCallFrame(callFrame, exceptionValue), codeBlock->ownerNode()->sourceID(),false); -#endif - return 0; + //try to find handler + bool hasHandler = true; + CallFrame *callFrameTemp = callFrame; + unsigned bytecodeOffsetTemp = bytecodeOffset; + CodeBlock *codeBlockTemp = codeBlock; + while (!(handler = codeBlockTemp->handlerForBytecodeOffset(bytecodeOffsetTemp))) { + callFrameTemp = callFrameTemp->callerFrame(); + if (callFrameTemp->hasHostCallFrameFlag()) { + hasHandler = false; + break; + } else { + codeBlockTemp = callFrameTemp->codeBlock(); + bytecodeOffsetTemp = bytecodeOffsetForPC(callFrameTemp, codeBlockTemp, callFrameTemp->returnPC()); } } -#ifdef QT_BUILD_SCRIPT_LIB if (debugger) - debugger->exceptionThrow(DebuggerCallFrame(callFrame, exceptionValue), codeBlock->ownerNode()->sourceID(),true); + debugger->exceptionThrow(DebuggerCallFrame(callFrame, exceptionValue), codeBlock->ownerNode()->sourceID(), hasHandler); #endif + + while (!(handler = codeBlock->handlerForBytecodeOffset(bytecodeOffset))) { + if (!unwindCallFrame(callFrame, exceptionValue, bytecodeOffset, codeBlock)) { + return 0; + } + } // Now unwind the scope chain within the exception handler's call frame. ScopeChainNode* scopeChain = callFrame->scopeChain(); -- cgit v0.12