From 6fec99fd1fc256437c5c651209084f479005a7a7 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 20 Aug 2009 15:55:13 +0200 Subject: provide line number information for innermost call frame For the innermost frame, we don't have a returnPC, so use the line number that was last passed to the engine agent. --- src/script/api/qscriptcontextinfo.cpp | 3 +++ src/script/api/qscriptengine.cpp | 1 + src/script/api/qscriptengine_p.h | 1 + src/script/api/qscriptengineagent.cpp | 6 ++++++ 4 files changed, 11 insertions(+) diff --git a/src/script/api/qscriptcontextinfo.cpp b/src/script/api/qscriptcontextinfo.cpp index 04c26e2..0049680 100644 --- a/src/script/api/qscriptcontextinfo.cpp +++ b/src/script/api/qscriptcontextinfo.cpp @@ -175,6 +175,9 @@ QScriptContextInfoPrivate::QScriptContextInfoPrivate(const QScriptContext *conte returnPC - codeBlock->instructions().begin() -1); } } + } else { + // An agent might have provided the line number. + lineNumber = QScript::scriptEngineFromExec(frame)->agentLineNumber; } // Get the filename and the scriptId: diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 32c63ab..c7729d7 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -830,6 +830,7 @@ QScriptEnginePrivate::QScriptEnginePrivate() originalGlobalObjectProxy = 0; activeAgent = 0; + agentLineNumber = -1; processEventsInterval = -1; } diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index cf773b6..8a7dd1a 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -239,6 +239,7 @@ public: QList ownedAgents; QScriptEngineAgent *activeAgent; + int agentLineNumber; QHash keepAliveValues; QHash m_typeInfos; int processEventsInterval; diff --git a/src/script/api/qscriptengineagent.cpp b/src/script/api/qscriptengineagent.cpp index ba8e5e9..6417ed8 100644 --- a/src/script/api/qscriptengineagent.cpp +++ b/src/script/api/qscriptengineagent.cpp @@ -163,9 +163,12 @@ void QScriptEngineAgentPrivate::exceptionCatch(const JSC::DebuggerCallFrame& fra void QScriptEngineAgentPrivate::atStatement(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno, int column) { JSC::CallFrame *oldFrame = engine->currentFrame; + int oldAgentLineNumber = engine->agentLineNumber; engine->currentFrame = frame.callFrame(); + engine->agentLineNumber = lineno; q_ptr->positionChange(sourceID, lineno, column); engine->currentFrame = oldFrame; + engine->agentLineNumber = oldAgentLineNumber; } void QScriptEngineAgentPrivate::functionExit(const JSC::JSValue& returnValue, intptr_t sourceID) @@ -186,11 +189,14 @@ void QScriptEngineAgentPrivate::didReachBreakpoint(const JSC::DebuggerCallFrame& { if (q_ptr->supportsExtension(QScriptEngineAgent::DebuggerInvocationRequest)) { JSC::CallFrame *oldFrame = engine->currentFrame; + int oldAgentLineNumber = engine->agentLineNumber; engine->currentFrame = frame.callFrame(); + engine->agentLineNumber = lineno; QList args; args << qint64(sourceID) << lineno << column; q_ptr->extension(QScriptEngineAgent::DebuggerInvocationRequest, args); engine->currentFrame = oldFrame; + engine->agentLineNumber = oldAgentLineNumber; } }; -- cgit v0.12