aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/debugger
diff options
context:
space:
mode:
authorAurindam Jana <aurindam.jana@nokia.com>2011-11-10 15:59:05 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-14 04:51:21 +0100
commit0f2188361b996c4d8b8901412cdcebf35bad1e53 (patch)
tree1d5d5c9344d8b2464ed792560b96821f4d59b611 /src/declarative/debugger
parentf1bcbd1ebae5d7b894b4da51fd82de0d0d58e99d (diff)
QV8Engine: Console APIs, Extend functionality
Added console.trace, console.profile, console.profileEnd. Change-Id: Icc38ddd550989eaba0085ece120695a13ec17322 Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Diffstat (limited to 'src/declarative/debugger')
-rw-r--r--src/declarative/debugger/qdeclarativedebugtrace.cpp98
-rw-r--r--src/declarative/debugger/qdeclarativedebugtrace_p.h16
2 files changed, 81 insertions, 33 deletions
diff --git a/src/declarative/debugger/qdeclarativedebugtrace.cpp b/src/declarative/debugger/qdeclarativedebugtrace.cpp
index c28a61227c..f3f8156dc9 100644
--- a/src/declarative/debugger/qdeclarativedebugtrace.cpp
+++ b/src/declarative/debugger/qdeclarativedebugtrace.cpp
@@ -98,57 +98,86 @@ void QDeclarativeDebugTrace::initialize()
traceInstance();
}
+bool QDeclarativeDebugTrace::startProfiling()
+{
+ return traceInstance()->startProfilingImpl();
+}
+
+bool QDeclarativeDebugTrace::stopProfiling()
+{
+ return traceInstance()->stopProfilingImpl();
+}
+
void QDeclarativeDebugTrace::addEvent(EventType t)
{
- if (QDeclarativeDebugService::isDebuggingEnabled())
- traceInstance()->addEventImpl(t);
+ traceInstance()->addEventImpl(t);
}
void QDeclarativeDebugTrace::startRange(RangeType t)
{
- if (QDeclarativeDebugService::isDebuggingEnabled())
- traceInstance()->startRangeImpl(t);
+ traceInstance()->startRangeImpl(t);
}
void QDeclarativeDebugTrace::rangeData(RangeType t, const QString &data)
{
- if (QDeclarativeDebugService::isDebuggingEnabled())
- traceInstance()->rangeDataImpl(t, data);
+ traceInstance()->rangeDataImpl(t, data);
}
void QDeclarativeDebugTrace::rangeData(RangeType t, const QUrl &data)
{
- if (QDeclarativeDebugService::isDebuggingEnabled())
- traceInstance()->rangeDataImpl(t, data);
+ traceInstance()->rangeDataImpl(t, data);
}
void QDeclarativeDebugTrace::rangeLocation(RangeType t, const QString &fileName, int line)
{
- if (QDeclarativeDebugService::isDebuggingEnabled())
- traceInstance()->rangeLocationImpl(t, fileName, line);
+ traceInstance()->rangeLocationImpl(t, fileName, line);
}
void QDeclarativeDebugTrace::rangeLocation(RangeType t, const QUrl &fileName, int line)
{
- if (QDeclarativeDebugService::isDebuggingEnabled())
- traceInstance()->rangeLocationImpl(t, fileName, line);
+ traceInstance()->rangeLocationImpl(t, fileName, line);
}
void QDeclarativeDebugTrace::endRange(RangeType t)
{
- if (QDeclarativeDebugService::isDebuggingEnabled())
- traceInstance()->endRangeImpl(t);
+ traceInstance()->endRangeImpl(t);
}
void QDeclarativeDebugTrace::animationFrame(qint64 delta)
{
- Q_ASSERT(QDeclarativeDebugService::isDebuggingEnabled());
traceInstance()->animationFrameImpl(delta);
}
+void QDeclarativeDebugTrace::sendProfilingData()
+{
+ traceInstance()->sendMessages();
+}
+
+bool QDeclarativeDebugTrace::startProfilingImpl()
+{
+ bool success = false;
+ if (!profilingEnabled()) {
+ setProfilingEnabled(true);
+ addEventImpl(StartTrace);
+ success = true;
+ }
+ return success;
+}
+
+bool QDeclarativeDebugTrace::stopProfilingImpl()
+{
+ bool success = false;
+ if (profilingEnabled()) {
+ addEventImpl(EndTrace);
+ setProfilingEnabled(false);
+ success = true;
+ }
+ return success;
+}
+
void QDeclarativeDebugTrace::addEventImpl(EventType event)
{
- if (status() != Enabled || !m_enabled)
+ if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled)
return;
QDeclarativeDebugData ed = {m_timer.nsecsElapsed(), (int)Event, (int)event, QString(), -1, 0, 0};
@@ -157,7 +186,7 @@ void QDeclarativeDebugTrace::addEventImpl(EventType event)
void QDeclarativeDebugTrace::startRangeImpl(RangeType range)
{
- if (status() != Enabled || !m_enabled)
+ if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled)
return;
QDeclarativeDebugData rd = {m_timer.nsecsElapsed(), (int)RangeStart, (int)range, QString(), -1, 0, 0};
@@ -166,7 +195,7 @@ void QDeclarativeDebugTrace::startRangeImpl(RangeType range)
void QDeclarativeDebugTrace::rangeDataImpl(RangeType range, const QString &rData)
{
- if (status() != Enabled || !m_enabled)
+ if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled)
return;
QDeclarativeDebugData rd = {m_timer.nsecsElapsed(), (int)RangeData, (int)range, rData, -1, 0, 0};
@@ -175,7 +204,7 @@ void QDeclarativeDebugTrace::rangeDataImpl(RangeType range, const QString &rData
void QDeclarativeDebugTrace::rangeDataImpl(RangeType range, const QUrl &rData)
{
- if (status() != Enabled || !m_enabled)
+ if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled)
return;
QDeclarativeDebugData rd = {m_timer.nsecsElapsed(), (int)RangeData, (int)range, rData.toString(QUrl::FormattingOption(0x100)), -1, 0, 0};
@@ -184,7 +213,7 @@ void QDeclarativeDebugTrace::rangeDataImpl(RangeType range, const QUrl &rData)
void QDeclarativeDebugTrace::rangeLocationImpl(RangeType range, const QString &fileName, int line)
{
- if (status() != Enabled || !m_enabled)
+ if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled)
return;
QDeclarativeDebugData rd = {m_timer.nsecsElapsed(), (int)RangeLocation, (int)range, fileName, line, 0, 0};
@@ -193,7 +222,7 @@ void QDeclarativeDebugTrace::rangeLocationImpl(RangeType range, const QString &f
void QDeclarativeDebugTrace::rangeLocationImpl(RangeType range, const QUrl &fileName, int line)
{
- if (status() != Enabled || !m_enabled)
+ if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled)
return;
QDeclarativeDebugData rd = {m_timer.nsecsElapsed(), (int)RangeLocation, (int)range, fileName.toString(QUrl::FormattingOption(0x100)), line, 0, 0};
@@ -202,7 +231,7 @@ void QDeclarativeDebugTrace::rangeLocationImpl(RangeType range, const QUrl &file
void QDeclarativeDebugTrace::endRangeImpl(RangeType range)
{
- if (status() != Enabled || !m_enabled)
+ if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled)
return;
QDeclarativeDebugData rd = {m_timer.nsecsElapsed(), (int)RangeEnd, (int)range, QString(), -1, 0, 0};
@@ -211,7 +240,8 @@ void QDeclarativeDebugTrace::endRangeImpl(RangeType range)
void QDeclarativeDebugTrace::animationFrameImpl(qint64 delta)
{
- if (status() != Enabled || !m_enabled)
+ Q_ASSERT(QDeclarativeDebugService::isDebuggingEnabled());
+ if (!m_enabled)
return;
int animCount = QUnifiedTimer::instance()->runningAnimationCount();
@@ -234,6 +264,16 @@ void QDeclarativeDebugTrace::processMessage(const QDeclarativeDebugData &message
m_data.append(message);
}
+bool QDeclarativeDebugTrace::profilingEnabled()
+{
+ return m_enabled;
+}
+
+void QDeclarativeDebugTrace::setProfilingEnabled(bool enable)
+{
+ m_enabled = enable;
+}
+
/*
Send the messages queued up by processMessage
*/
@@ -262,15 +302,11 @@ void QDeclarativeDebugTrace::messageReceived(const QByteArray &message)
m_messageReceived = true;
- if (m_enabled != enabled) {
- if (enabled) {
- m_enabled = true;
- addEventImpl(StartTrace);
- } else {
- addEventImpl(EndTrace);
- m_enabled = false;
+ if (enabled) {
+ startProfilingImpl();
+ } else {
+ if (stopProfilingImpl())
sendMessages();
- }
}
}
diff --git a/src/declarative/debugger/qdeclarativedebugtrace_p.h b/src/declarative/debugger/qdeclarativedebugtrace_p.h
index bcea4d07a5..a52c3eaa26 100644
--- a/src/declarative/debugger/qdeclarativedebugtrace_p.h
+++ b/src/declarative/debugger/qdeclarativedebugtrace_p.h
@@ -119,8 +119,9 @@ public:
static void initialize();
+ static bool startProfiling();
+ static bool stopProfiling();
static void addEvent(EventType);
-
static void startRange(RangeType);
static void rangeData(RangeType, const QString &);
static void rangeData(RangeType, const QUrl &);
@@ -129,11 +130,17 @@ public:
static void endRange(RangeType);
static void animationFrame(qint64);
+ static void sendProfilingData();
+
QDeclarativeDebugTrace();
~QDeclarativeDebugTrace();
+
protected:
virtual void messageReceived(const QByteArray &);
+
private:
+ bool startProfilingImpl();
+ bool stopProfilingImpl();
void addEventImpl(EventType);
void startRangeImpl(RangeType);
void rangeDataImpl(RangeType, const QString &);
@@ -142,8 +149,13 @@ private:
void rangeLocationImpl(RangeType, const QUrl &, int);
void endRangeImpl(RangeType);
void animationFrameImpl(qint64);
- void processMessage(const QDeclarativeDebugData &);
+
+ bool profilingEnabled();
+ void setProfilingEnabled(bool enable);
void sendMessages();
+ void processMessage(const QDeclarativeDebugData &);
+
+private:
QElapsedTimer m_timer;
bool m_enabled;
bool m_messageReceived;