diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2011-01-21 03:48:36 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2011-01-25 00:46:39 (GMT) |
commit | d7a95474fad9d5ddcc9c9a7473a49644c03e0f7a (patch) | |
tree | 01b2548950dc26cbc31c1e9879b2d09720435796 /src | |
parent | 1873b12eb8f5175aa852341a7055add77b6fcc80 (diff) | |
download | Qt-d7a95474fad9d5ddcc9c9a7473a49644c03e0f7a.zip Qt-d7a95474fad9d5ddcc9c9a7473a49644c03e0f7a.tar.gz Qt-d7a95474fad9d5ddcc9c9a7473a49644c03e0f7a.tar.bz2 |
Add location information for tracing.
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/debugger/qdeclarativedebugtrace.cpp | 42 | ||||
-rw-r--r-- | src/declarative/debugger/qdeclarativedebugtrace_p.h | 12 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativebinding.cpp | 1 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeboundsignal.cpp | 10 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeengine.cpp | 10 |
5 files changed, 63 insertions, 12 deletions
diff --git a/src/declarative/debugger/qdeclarativedebugtrace.cpp b/src/declarative/debugger/qdeclarativedebugtrace.cpp index 9fa1f5b..4bad405 100644 --- a/src/declarative/debugger/qdeclarativedebugtrace.cpp +++ b/src/declarative/debugger/qdeclarativedebugtrace.cpp @@ -58,6 +58,8 @@ QByteArray QDeclarativeDebugData::toByteArray() const ds << time << messageType << detailType; if (messageType == (int)QDeclarativeDebugTrace::RangeData) ds << detailData; + if (messageType == (int)QDeclarativeDebugTrace::RangeLocation) + ds << detailData << line; return data; } @@ -92,6 +94,18 @@ void QDeclarativeDebugTrace::rangeData(RangeType t, const QUrl &data) traceInstance()->rangeDataImpl(t, data); } +void QDeclarativeDebugTrace::rangeLocation(RangeType t, const QString &fileName, int line) +{ + if (QDeclarativeDebugService::isDebuggingEnabled()) + traceInstance()->rangeLocationImpl(t, fileName, line); +} + +void QDeclarativeDebugTrace::rangeLocation(RangeType t, const QUrl &fileName, int line) +{ + if (QDeclarativeDebugService::isDebuggingEnabled()) + traceInstance()->rangeLocationImpl(t, fileName, line); +} + void QDeclarativeDebugTrace::endRange(RangeType t) { if (QDeclarativeDebugService::isDebuggingEnabled()) @@ -103,7 +117,7 @@ void QDeclarativeDebugTrace::addEventImpl(EventType event) if (status() != Enabled || !m_enabled) return; - QDeclarativeDebugData ed = {m_timer.elapsed(), (int)Event, (int)event, QString()}; + QDeclarativeDebugData ed = {m_timer.elapsed(), (int)Event, (int)event, QString(), -1}; processMessage(ed); } @@ -112,7 +126,7 @@ void QDeclarativeDebugTrace::startRangeImpl(RangeType range) if (status() != Enabled || !m_enabled) return; - QDeclarativeDebugData rd = {m_timer.elapsed(), (int)RangeStart, (int)range, QString()}; + QDeclarativeDebugData rd = {m_timer.elapsed(), (int)RangeStart, (int)range, QString(), -1}; processMessage(rd); } @@ -121,7 +135,7 @@ void QDeclarativeDebugTrace::rangeDataImpl(RangeType range, const QString &rData if (status() != Enabled || !m_enabled) return; - QDeclarativeDebugData rd = {m_timer.elapsed(), (int)RangeData, (int)range, rData}; + QDeclarativeDebugData rd = {m_timer.elapsed(), (int)RangeData, (int)range, rData, -1}; processMessage(rd); } @@ -130,7 +144,25 @@ void QDeclarativeDebugTrace::rangeDataImpl(RangeType range, const QUrl &rData) if (status() != Enabled || !m_enabled) return; - QDeclarativeDebugData rd = {m_timer.elapsed(), (int)RangeData, (int)range, rData.toEncoded(QUrl::FormattingOption(0x100))}; + QDeclarativeDebugData rd = {m_timer.elapsed(), (int)RangeData, (int)range, rData.toEncoded(QUrl::FormattingOption(0x100)), -1}; + processMessage(rd); +} + +void QDeclarativeDebugTrace::rangeLocationImpl(RangeType range, const QString &fileName, int line) +{ + if (status() != Enabled || !m_enabled) + return; + + QDeclarativeDebugData rd = {m_timer.elapsed(), (int)RangeLocation, (int)range, fileName, line}; + processMessage(rd); +} + +void QDeclarativeDebugTrace::rangeLocationImpl(RangeType range, const QUrl &fileName, int line) +{ + if (status() != Enabled || !m_enabled) + return; + + QDeclarativeDebugData rd = {m_timer.elapsed(), (int)RangeLocation, (int)range, fileName.toEncoded(QUrl::FormattingOption(0x100)), line}; processMessage(rd); } @@ -139,7 +171,7 @@ void QDeclarativeDebugTrace::endRangeImpl(RangeType range) if (status() != Enabled || !m_enabled) return; - QDeclarativeDebugData rd = {m_timer.elapsed(), (int)RangeEnd, (int)range, QString()}; + QDeclarativeDebugData rd = {m_timer.elapsed(), (int)RangeEnd, (int)range, QString(), -1}; processMessage(rd); } diff --git a/src/declarative/debugger/qdeclarativedebugtrace_p.h b/src/declarative/debugger/qdeclarativedebugtrace_p.h index 39268fe..ae0653e 100644 --- a/src/declarative/debugger/qdeclarativedebugtrace_p.h +++ b/src/declarative/debugger/qdeclarativedebugtrace_p.h @@ -54,13 +54,14 @@ struct QDeclarativeDebugData qint64 time; int messageType; int detailType; - QString detailData; + + //### + QString detailData; //used by RangeData and RangeLocation + int line; //used by RangeLocation QByteArray toByteArray() const; }; -Q_DECLARE_TYPEINFO(QDeclarativeDebugData,Q_PRIMITIVE_TYPE); - class QUrl; class Q_AUTOTEST_EXPORT QDeclarativeDebugTrace : public QDeclarativeDebugService { @@ -69,6 +70,7 @@ public: Event, RangeStart, RangeData, + RangeLocation, RangeEnd, Complete, @@ -98,6 +100,8 @@ public: static void startRange(RangeType); static void rangeData(RangeType, const QString &); static void rangeData(RangeType, const QUrl &); + static void rangeLocation(RangeType, const QString &, int); + static void rangeLocation(RangeType, const QUrl &, int); static void endRange(RangeType); QDeclarativeDebugTrace(); @@ -108,6 +112,8 @@ private: void startRangeImpl(RangeType); void rangeDataImpl(RangeType, const QString &); void rangeDataImpl(RangeType, const QUrl &); + void rangeLocationImpl(RangeType, const QString &, int); + void rangeLocationImpl(RangeType, const QUrl &, int); void endRangeImpl(RangeType); void processMessage(const QDeclarativeDebugData &); void sendMessages(); diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp index bd1ac5a..b2d0738 100644 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ b/src/declarative/qml/qdeclarativebinding.cpp @@ -298,6 +298,7 @@ public: { QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::Binding); QDeclarativeDebugTrace::rangeData(QDeclarativeDebugTrace::Binding, bind->expression()); + QDeclarativeDebugTrace::rangeLocation(QDeclarativeDebugTrace::Binding, bind->sourceFile(), bind->lineNumber()); } ~QDeclarativeBindingProfiler() diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp index 9b7e570..d5c9bfc 100644 --- a/src/declarative/qml/qdeclarativeboundsignal.cpp +++ b/src/declarative/qml/qdeclarativeboundsignal.cpp @@ -51,6 +51,7 @@ #include "private/qdeclarativeglobal_p.h" #include "private/qdeclarativedebugtrace_p.h" +#include <QtCore/qstringbuilder.h> #include <QtCore/qdebug.h> QT_BEGIN_NAMESPACE @@ -166,8 +167,13 @@ QDeclarativeBoundSignal *QDeclarativeBoundSignal::cast(QObject *o) int QDeclarativeBoundSignal::qt_metacall(QMetaObject::Call c, int id, void **a) { if (c == QMetaObject::InvokeMetaMethod && id == evaluateIdx) { - QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::HandlingSignal); - QDeclarativeDebugTrace::rangeData(QDeclarativeDebugTrace::HandlingSignal, QLatin1String(m_signal.signature()) + QLatin1String(": ") + (m_expression ? m_expression->expression() : QLatin1String(""))); + if (!m_expression) + return -1; + if (QDeclarativeDebugService::isDebuggingEnabled()) { + QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::HandlingSignal); + QDeclarativeDebugTrace::rangeData(QDeclarativeDebugTrace::HandlingSignal, QLatin1String(m_signal.signature()) % QLatin1String(": ") % m_expression->expression()); + QDeclarativeDebugTrace::rangeLocation(QDeclarativeDebugTrace::HandlingSignal, m_expression->sourceFile(), m_expression->lineNumber()); + } m_isEvaluating = true; if (!m_paramsValid) { if (!m_signal.parameterTypes().isEmpty()) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 0f3f20c..99a098e 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -964,8 +964,14 @@ Q_AUTOTEST_EXPORT void qmlExecuteDeferred(QObject *object) QDeclarativeData *data = QDeclarativeData::get(object); if (data && data->deferredComponent) { - QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::Creating); - QDeclarativeDebugTrace::rangeData(QDeclarativeDebugTrace::Creating, QLatin1String("Deferred Creation:") + object->metaObject()->className()); + if (QDeclarativeDebugService::isDebuggingEnabled()) { + QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::Creating); + QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject()); + QString typeName = type ? QLatin1String(type->qmlTypeName()) : QString::fromLatin1(object->metaObject()->className()); + QDeclarativeDebugTrace::rangeData(QDeclarativeDebugTrace::Creating, typeName); + if (data->outerContext) + QDeclarativeDebugTrace::rangeLocation(QDeclarativeDebugTrace::Creating, data->outerContext->url, data->lineNumber); + } QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(data->context->engine); QDeclarativeComponentPrivate::ConstructionState state; |