summaryrefslogtreecommitdiffstats
path: root/src/declarative/debugger/qjsdebuggeragent.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2011-06-21 14:38:44 (GMT)
committerKai Koehne <kai.koehne@nokia.com>2011-06-22 08:05:33 (GMT)
commitd349c879e1d55e4cd2b7d31c08e2796c0fec4020 (patch)
treef1e5ba4f3d71f3ef607e1b81ba53c506963eb41e /src/declarative/debugger/qjsdebuggeragent.cpp
parent6cb43a9b72c67b71409a59fdeb419f390441f0c7 (diff)
downloadQt-d349c879e1d55e4cd2b7d31c08e2796c0fec4020.zip
Qt-d349c879e1d55e4cd2b7d31c08e2796c0fec4020.tar.gz
Qt-d349c879e1d55e4cd2b7d31c08e2796c0fec4020.tar.bz2
QDeclarativeDebug: Add code coverage information
Add messages to track the lines of JavaScript that are executed. Patch done by Janne Virranmaki <ext-janne.1.virranmaki@nokia.com> Reviewed-by: kkoehne
Diffstat (limited to 'src/declarative/debugger/qjsdebuggeragent.cpp')
-rw-r--r--src/declarative/debugger/qjsdebuggeragent.cpp42
1 files changed, 36 insertions, 6 deletions
diff --git a/src/declarative/debugger/qjsdebuggeragent.cpp b/src/declarative/debugger/qjsdebuggeragent.cpp
index dff637b..683032b 100644
--- a/src/declarative/debugger/qjsdebuggeragent.cpp
+++ b/src/declarative/debugger/qjsdebuggeragent.cpp
@@ -41,6 +41,7 @@
#include "private/qjsdebuggeragent_p.h"
#include "private/qdeclarativedebughelper_p.h"
+#include "private/qjsdebugservice_p.h"
#include <QtCore/qdatetime.h>
#include <QtCore/qcoreapplication.h>
@@ -56,7 +57,7 @@ class QJSDebuggerAgentPrivate
{
public:
QJSDebuggerAgentPrivate(QJSDebuggerAgent *q)
- : q(q), state(NoState), isInitialized(false)
+ : q(q), state(NoState), isInitialized(false), coverageEnabled(false)
{}
void continueExec();
@@ -80,6 +81,7 @@ public:
QStringList watchExpressions;
QSet<qint64> knownObjectIds;
bool isInitialized;
+ bool coverageEnabled;
};
namespace {
@@ -261,6 +263,12 @@ bool QJSDebuggerAgent::isInitialized() const
return d->isInitialized;
}
+void QJSDebuggerAgent::setCoverageEnabled(bool enabled)
+{
+ d->isInitialized = true;
+ d->coverageEnabled = enabled;
+}
+
void QJSDebuggerAgent::setBreakpoints(const JSAgentBreakpoints &breakpoints)
{
d->breakpoints = breakpoints;
@@ -417,10 +425,16 @@ void QJSDebuggerAgent::setProperty(qint64 objectId,
\reimp
*/
void QJSDebuggerAgent::scriptLoad(qint64 id, const QString &program,
- const QString &fileName, int)
+ const QString &fileName, int baseLineNumber)
{
- Q_UNUSED(program);
d->filenames.insert(id, fileName);
+
+ if (d->coverageEnabled) {
+ JSAgentCoverageData rd = {"COVERAGE", QJSDebugService::instance()->m_timer.elapsed(), (int)CoverageScriptLoad,
+ id, program, fileName, baseLineNumber,
+ 0, 0, QString()};
+ QJSDebugService::instance()->processMessage(rd);
+ }
}
/*!
@@ -450,8 +464,14 @@ void QJSDebuggerAgent::contextPop()
*/
void QJSDebuggerAgent::functionEntry(qint64 scriptId)
{
- Q_UNUSED(scriptId);
d->stepDepth++;
+
+ if (d->coverageEnabled) {
+ JSAgentCoverageData rd = {"COVERAGE", QJSDebugService::instance()->m_timer.elapsed(), (int)CoverageFuncEntry,
+ scriptId, QString(), QString(), 0, 0, 0, QString()};
+ QJSDebugService::instance()->processMessage(rd);
+ QJSDebugService::instance()->m_timer.restart();
+ }
}
/*!
@@ -459,9 +479,13 @@ void QJSDebuggerAgent::functionEntry(qint64 scriptId)
*/
void QJSDebuggerAgent::functionExit(qint64 scriptId, const QScriptValue &returnValue)
{
- Q_UNUSED(scriptId);
- Q_UNUSED(returnValue);
d->stepDepth--;
+
+ if (d->coverageEnabled) {
+ JSAgentCoverageData rd = {"COVERAGE", QJSDebugService::instance()->m_timer.elapsed(), (int)CoverageFuncExit,
+ scriptId, QString(), QString(), 0, 0, 0, returnValue.toString()};
+ QJSDebugService::instance()->processMessage(rd);
+ }
}
/*!
@@ -470,6 +494,12 @@ void QJSDebuggerAgent::functionExit(qint64 scriptId, const QScriptValue &returnV
void QJSDebuggerAgent::positionChange(qint64 scriptId, int lineNumber, int columnNumber)
{
d->positionChange(scriptId, lineNumber, columnNumber);
+
+ if (d->coverageEnabled) {
+ JSAgentCoverageData rd = {"COVERAGE", QJSDebugService::instance()->m_timer.elapsed(), (int)CoveragePosChange,
+ scriptId, QString(), QString(), 0, lineNumber, columnNumber, QString()};
+ QJSDebugService::instance()->processMessage(rd);
+ }
}
void QJSDebuggerAgentPrivate::positionChange(qint64 scriptId, int lineNumber, int columnNumber)