diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-08-20 13:26:40 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-08-20 13:26:40 (GMT) |
commit | c171799d5d96360cffe9b8288f18859b5e2d51dd (patch) | |
tree | 5ed15d7e2f386d8badfa9792946f1b732df725e3 /src/script | |
parent | a363adb8974929b1b18e936cb0a7effa3c229f87 (diff) | |
download | Qt-c171799d5d96360cffe9b8288f18859b5e2d51dd.zip Qt-c171799d5d96360cffe9b8288f18859b5e2d51dd.tar.gz Qt-c171799d5d96360cffe9b8288f18859b5e2d51dd.tar.bz2 |
set the current frame when getting callbacks in JSC Debugger
If the debugger stops execution, we want the frame pointer to be
in sync (so we get the full backtrace).
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/api/qscriptengineagent.cpp | 54 | ||||
-rw-r--r-- | src/script/api/qscriptengineagent_p.h | 15 |
2 files changed, 39 insertions, 30 deletions
diff --git a/src/script/api/qscriptengineagent.cpp b/src/script/api/qscriptengineagent.cpp index 4f89e81..ba8e5e9 100644 --- a/src/script/api/qscriptengineagent.cpp +++ b/src/script/api/qscriptengineagent.cpp @@ -42,6 +42,8 @@ #include "config.h" #include "qscriptengineagent.h" #include "qscriptengineagent_p.h" +#include "qscriptengine.h" +#include "qscriptengine_p.h" #include "CodeBlock.h" #include "Instruction.h" @@ -130,47 +132,67 @@ QT_BEGIN_NAMESPACE void QScriptEngineAgentPrivate::attach() { - QScriptEnginePrivate *d = QScriptEnginePrivate::get(engine); - if (d->originalGlobalObject()->debugger()) - d->originalGlobalObject()->setDebugger(0); - JSC::Debugger::attach(d->originalGlobalObject()); + if (engine->originalGlobalObject()->debugger()) + engine->originalGlobalObject()->setDebugger(0); + JSC::Debugger::attach(engine->originalGlobalObject()); } void QScriptEngineAgentPrivate::detach() { - JSC::Debugger::detach(QScriptEnginePrivate::get(engine)->originalGlobalObject()); + JSC::Debugger::detach(engine->originalGlobalObject()); } void QScriptEngineAgentPrivate::exceptionThrow(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, bool hasHandler) { - QScriptValue value(QScriptEnginePrivate::get(engine)->scriptValueFromJSCValue(frame.exception())); + JSC::CallFrame *oldFrame = engine->currentFrame; + engine->currentFrame = frame.callFrame(); + QScriptValue value(engine->scriptValueFromJSCValue(frame.exception())); q_ptr->exceptionThrow(sourceID, value, hasHandler); + engine->currentFrame = oldFrame; }; void QScriptEngineAgentPrivate::exceptionCatch(const JSC::DebuggerCallFrame& frame, intptr_t sourceID) { - QScriptValue value(QScriptEnginePrivate::get(engine)->scriptValueFromJSCValue(frame.exception())); + JSC::CallFrame *oldFrame = engine->currentFrame; + engine->currentFrame = frame.callFrame(); + QScriptValue value(engine->scriptValueFromJSCValue(frame.exception())); q_ptr->exceptionCatch(sourceID, value); + engine->currentFrame = oldFrame; } -void QScriptEngineAgentPrivate::atStatement(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineno, int column) +void QScriptEngineAgentPrivate::atStatement(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno, int column) { + JSC::CallFrame *oldFrame = engine->currentFrame; + engine->currentFrame = frame.callFrame(); q_ptr->positionChange(sourceID, lineno, column); + engine->currentFrame = oldFrame; } void QScriptEngineAgentPrivate::functionExit(const JSC::JSValue& returnValue, intptr_t sourceID) { - QScriptValue result = QScriptEnginePrivate::get(engine)->scriptValueFromJSCValue(returnValue); + QScriptValue result = engine->scriptValueFromJSCValue(returnValue); q_ptr->functionExit(sourceID, result); q_ptr->contextPop(); } void QScriptEngineAgentPrivate::evaluateStop(const JSC::JSValue& returnValue, intptr_t sourceID) { - QScriptValue result = QScriptEnginePrivate::get(engine)->scriptValueFromJSCValue(returnValue); + QScriptValue result = engine->scriptValueFromJSCValue(returnValue); q_ptr->functionExit(sourceID, result); } +void QScriptEngineAgentPrivate::didReachBreakpoint(const JSC::DebuggerCallFrame& frame, + intptr_t sourceID, int lineno, int column) +{ + if (q_ptr->supportsExtension(QScriptEngineAgent::DebuggerInvocationRequest)) { + JSC::CallFrame *oldFrame = engine->currentFrame; + engine->currentFrame = frame.callFrame(); + QList<QVariant> args; + args << qint64(sourceID) << lineno << column; + q_ptr->extension(QScriptEngineAgent::DebuggerInvocationRequest, args); + engine->currentFrame = oldFrame; + } +}; /*! Constructs a QScriptEngineAgent object for the given \a engine. @@ -183,11 +205,8 @@ void QScriptEngineAgentPrivate::evaluateStop(const JSC::JSValue& returnValue, in QScriptEngineAgent::QScriptEngineAgent(QScriptEngine *engine) : d_ptr(new QScriptEngineAgentPrivate()) { - d_ptr->engine = engine; d_ptr->q_ptr = this; - if (engine) { - d_ptr->engine->setAgent(this); - } + d_ptr->engine = QScriptEnginePrivate::get(engine); } /*! @@ -197,7 +216,7 @@ QScriptEngineAgent::QScriptEngineAgent(QScriptEngineAgentPrivate &dd, QScriptEng : d_ptr(&dd) { d_ptr->q_ptr = this; - d_ptr->engine = engine; + d_ptr->engine = QScriptEnginePrivate::get(engine); } /*! @@ -205,8 +224,7 @@ QScriptEngineAgent::QScriptEngineAgent(QScriptEngineAgentPrivate &dd, QScriptEng */ QScriptEngineAgent::~QScriptEngineAgent() { - QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine()); - eng_p->agentDeleted(this); + d_ptr->engine->agentDeleted(this); delete d_ptr; d_ptr = 0; } @@ -470,7 +488,7 @@ QVariant QScriptEngineAgent::extension(Extension extension, QScriptEngine *QScriptEngineAgent::engine() const { Q_D(const QScriptEngineAgent); - return d->engine; + return QScriptEnginePrivate::get(d->engine); } QT_END_NAMESPACE diff --git a/src/script/api/qscriptengineagent_p.h b/src/script/api/qscriptengineagent_p.h index 183a02c..64befc1 100644 --- a/src/script/api/qscriptengineagent_p.h +++ b/src/script/api/qscriptengineagent_p.h @@ -56,8 +56,6 @@ #include <QtCore/qobjectdefs.h> #include "Debugger.h" #include "qscriptengineagent.h" -#include "qscriptengine.h" -#include "qscriptengine_p.h" #include "CallFrame.h" #include "SourceCode.h" @@ -66,7 +64,7 @@ QT_BEGIN_NAMESPACE -class QScriptEngine; +class QScriptEnginePrivate; class QScriptEngineAgent; class Q_SCRIPT_EXPORT QScriptEngineAgentPrivate : public JSC::Debugger @@ -132,14 +130,7 @@ public: }; virtual void functionExit(const JSC::JSValue& returnValue, intptr_t sourceID); //others - virtual void didReachBreakpoint(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno, int column) - { - Q_UNUSED(frame); - QList<QVariant> args; - args << qint64(sourceID) << lineno << column; - if (q_ptr->supportsExtension(QScriptEngineAgent::DebuggerInvocationRequest)) - q_ptr->extension(QScriptEngineAgent::DebuggerInvocationRequest, args); - }; + virtual void didReachBreakpoint(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno, int column); virtual void evaluateStart(intptr_t sourceID) { @@ -147,7 +138,7 @@ public: } virtual void evaluateStop(const JSC::JSValue& returnValue, intptr_t sourceID); - QScriptEngine *engine; + QScriptEnginePrivate *engine; QScriptEngineAgent *q_ptr; }; |