forked from qt-creator/qt-creator
QmlProfiler: Include debug messages in trace
A separate model will show them in the timeline for better orientation. Change-Id: I537bac82ddef6a8bcc64ae403731512f8edcc9db Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
@@ -50,7 +50,7 @@ static inline QString qmlDebugServices(QmlDebugServicesPreset preset)
|
|||||||
case QmlDebuggerServices:
|
case QmlDebuggerServices:
|
||||||
return QStringLiteral("DebugMessages,QmlDebugger,V8Debugger,QmlInspector");
|
return QStringLiteral("DebugMessages,QmlDebugger,V8Debugger,QmlInspector");
|
||||||
case QmlProfilerServices:
|
case QmlProfilerServices:
|
||||||
return QStringLiteral("CanvasFrameRate,EngineControl");
|
return QStringLiteral("CanvasFrameRate,EngineControl,DebugMessages");
|
||||||
case QmlNativeDebuggerServices:
|
case QmlNativeDebuggerServices:
|
||||||
return QStringLiteral("NativeQmlDebugger");
|
return QStringLiteral("NativeQmlDebugger");
|
||||||
default:
|
default:
|
||||||
|
@@ -45,6 +45,7 @@ enum Message {
|
|||||||
PixmapCacheEvent,
|
PixmapCacheEvent,
|
||||||
SceneGraphFrame,
|
SceneGraphFrame,
|
||||||
MemoryAllocation,
|
MemoryAllocation,
|
||||||
|
DebugMessage,
|
||||||
|
|
||||||
MaximumMessage
|
MaximumMessage
|
||||||
};
|
};
|
||||||
@@ -148,6 +149,7 @@ enum ProfileFeature {
|
|||||||
ProfileBinding,
|
ProfileBinding,
|
||||||
ProfileHandlingSignal,
|
ProfileHandlingSignal,
|
||||||
ProfileInputEvents,
|
ProfileInputEvents,
|
||||||
|
ProfileDebugMessages,
|
||||||
|
|
||||||
MaximumProfileFeature
|
MaximumProfileFeature
|
||||||
};
|
};
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "qmlprofilertraceclient.h"
|
#include "qmlprofilertraceclient.h"
|
||||||
#include "qmlenginecontrolclient.h"
|
#include "qmlenginecontrolclient.h"
|
||||||
|
#include "qdebugmessageclient.h"
|
||||||
|
|
||||||
namespace QmlDebug {
|
namespace QmlDebug {
|
||||||
|
|
||||||
@@ -53,6 +54,7 @@ public:
|
|||||||
|
|
||||||
QmlProfilerTraceClient *q;
|
QmlProfilerTraceClient *q;
|
||||||
QmlEngineControlClient engineControl;
|
QmlEngineControlClient engineControl;
|
||||||
|
QScopedPointer<QDebugMessageClient> messageClient;
|
||||||
qint64 inProgressRanges;
|
qint64 inProgressRanges;
|
||||||
QStack<qint64> rangeStartTimes[MaximumRangeType];
|
QStack<qint64> rangeStartTimes[MaximumRangeType];
|
||||||
QStack<QString> rangeDatas[MaximumRangeType];
|
QStack<QString> rangeDatas[MaximumRangeType];
|
||||||
@@ -86,7 +88,7 @@ QmlProfilerTraceClient::QmlProfilerTraceClient(QmlDebugConnection *client, quint
|
|||||||
: QmlDebugClient(QLatin1String("CanvasFrameRate"), client)
|
: QmlDebugClient(QLatin1String("CanvasFrameRate"), client)
|
||||||
, d(new QmlProfilerTraceClientPrivate(this, client))
|
, d(new QmlProfilerTraceClientPrivate(this, client))
|
||||||
{
|
{
|
||||||
d->requestedFeatures = features;
|
setRequestedFeatures(features);
|
||||||
connect(&d->engineControl, &QmlEngineControlClient::engineAboutToBeAdded,
|
connect(&d->engineControl, &QmlEngineControlClient::engineAboutToBeAdded,
|
||||||
this, &QmlProfilerTraceClient::sendRecordingStatus);
|
this, &QmlProfilerTraceClient::sendRecordingStatus);
|
||||||
}
|
}
|
||||||
@@ -152,6 +154,19 @@ quint64 QmlProfilerTraceClient::recordedFeatures() const
|
|||||||
void QmlProfilerTraceClient::setRequestedFeatures(quint64 features)
|
void QmlProfilerTraceClient::setRequestedFeatures(quint64 features)
|
||||||
{
|
{
|
||||||
d->requestedFeatures = features;
|
d->requestedFeatures = features;
|
||||||
|
if (features & static_cast<quint64>(1) << ProfileDebugMessages) {
|
||||||
|
d->messageClient.reset(new QDebugMessageClient(connection()));
|
||||||
|
connect(d->messageClient.data(), &QDebugMessageClient::message, this, [this](QtMsgType type,
|
||||||
|
const QString &text, const QmlDebug::QDebugContextInfo &context)
|
||||||
|
{
|
||||||
|
emit this->rangedEvent(QmlDebug::DebugMessage, QmlDebug::MaximumRangeType,
|
||||||
|
type, context.timestamp, 0, text,
|
||||||
|
QmlDebug::QmlEventLocation(context.file, context.line, 1), 0, 0,
|
||||||
|
0, 0, 0);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
d->messageClient.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerTraceClient::setFlushInterval(quint32 flushInterval)
|
void QmlProfilerTraceClient::setFlushInterval(quint32 flushInterval)
|
||||||
|
@@ -266,8 +266,11 @@ void QmlProfilerDataModel::addQmlEvent(QmlDebug::Message message, QmlDebug::Rang
|
|||||||
Q_D(QmlProfilerDataModel);
|
Q_D(QmlProfilerDataModel);
|
||||||
QString displayName;
|
QString displayName;
|
||||||
|
|
||||||
QmlEventTypeData typeData(displayName, location, message, rangeType, detailType, data);
|
QmlEventTypeData typeData(displayName, location, message, rangeType, detailType,
|
||||||
QmlEventData eventData(startTime, duration, -1, ndata1, ndata2, ndata3, ndata4, ndata5);
|
message == QmlDebug::DebugMessage ? QString() : data);
|
||||||
|
QmlEventData eventData = (message == QmlDebug::DebugMessage) ?
|
||||||
|
QmlEventData(startTime, duration, -1, data) :
|
||||||
|
QmlEventData(startTime, duration, -1, ndata1, ndata2, ndata3, ndata4, ndata5);
|
||||||
|
|
||||||
QHash<QmlEventTypeData, int>::Iterator it = d->eventTypeIds.find(typeData);
|
QHash<QmlEventTypeData, int>::Iterator it = d->eventTypeIds.find(typeData);
|
||||||
if (it != d->eventTypeIds.end()) {
|
if (it != d->eventTypeIds.end()) {
|
||||||
|
@@ -45,7 +45,7 @@
|
|||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
static const char *ProfileFeatureNames[QmlDebug::MaximumProfileFeature] = {
|
static const char *ProfileFeatureNames[] = {
|
||||||
QT_TRANSLATE_NOOP("MainView", "JavaScript"),
|
QT_TRANSLATE_NOOP("MainView", "JavaScript"),
|
||||||
QT_TRANSLATE_NOOP("MainView", "Memory Usage"),
|
QT_TRANSLATE_NOOP("MainView", "Memory Usage"),
|
||||||
QT_TRANSLATE_NOOP("MainView", "Pixmap Cache"),
|
QT_TRANSLATE_NOOP("MainView", "Pixmap Cache"),
|
||||||
@@ -56,9 +56,12 @@ static const char *ProfileFeatureNames[QmlDebug::MaximumProfileFeature] = {
|
|||||||
QT_TRANSLATE_NOOP("MainView", "Creating"),
|
QT_TRANSLATE_NOOP("MainView", "Creating"),
|
||||||
QT_TRANSLATE_NOOP("MainView", "Binding"),
|
QT_TRANSLATE_NOOP("MainView", "Binding"),
|
||||||
QT_TRANSLATE_NOOP("MainView", "Handling Signal"),
|
QT_TRANSLATE_NOOP("MainView", "Handling Signal"),
|
||||||
QT_TRANSLATE_NOOP("MainView", "Input Events")
|
QT_TRANSLATE_NOOP("MainView", "Input Events"),
|
||||||
|
QT_TRANSLATE_NOOP("MainView", "Debug Messages")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_STATIC_ASSERT(sizeof(ProfileFeatureNames) == sizeof(char *) * QmlDebug::MaximumProfileFeature);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
QmlProfilerTraceTime::QmlProfilerTraceTime(QObject *parent) :
|
QmlProfilerTraceTime::QmlProfilerTraceTime(QObject *parent) :
|
||||||
QObject(parent), m_startTime(-1), m_endTime(-1)
|
QObject(parent), m_startTime(-1), m_endTime(-1)
|
||||||
|
@@ -65,7 +65,8 @@ static const char *MESSAGE_STRINGS[] = {
|
|||||||
"Complete",
|
"Complete",
|
||||||
"PixmapCache",
|
"PixmapCache",
|
||||||
"SceneGraph",
|
"SceneGraph",
|
||||||
"MemoryAllocation"
|
"MemoryAllocation",
|
||||||
|
"DebugMessage"
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_STATIC_ASSERT(sizeof(MESSAGE_STRINGS) == QmlDebug::MaximumMessage * sizeof(const char *));
|
Q_STATIC_ASSERT(sizeof(MESSAGE_STRINGS) == QmlDebug::MaximumMessage * sizeof(const char *));
|
||||||
@@ -226,6 +227,8 @@ QmlDebug::ProfileFeature featureFromEvent(const QmlProfilerDataModel::QmlEventTy
|
|||||||
return ProfileSceneGraph;
|
return ProfileSceneGraph;
|
||||||
case MemoryAllocation:
|
case MemoryAllocation:
|
||||||
return ProfileMemory;
|
return ProfileMemory;
|
||||||
|
case DebugMessage:
|
||||||
|
return ProfileDebugMessages;
|
||||||
default:
|
default:
|
||||||
return MaximumProfileFeature;
|
return MaximumProfileFeature;
|
||||||
}
|
}
|
||||||
@@ -235,8 +238,6 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream)
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(stream.name() == _("eventData"), return);
|
QTC_ASSERT(stream.name() == _("eventData"), return);
|
||||||
|
|
||||||
QXmlStreamAttributes attributes = stream.attributes();
|
|
||||||
|
|
||||||
int eventIndex = -1;
|
int eventIndex = -1;
|
||||||
QmlProfilerDataModel::QmlEventTypeData event = {
|
QmlProfilerDataModel::QmlEventTypeData event = {
|
||||||
QString(), // displayname
|
QString(), // displayname
|
||||||
@@ -327,7 +328,8 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream)
|
|||||||
elementName == _("sgEventType") ||
|
elementName == _("sgEventType") ||
|
||||||
elementName == _("memoryEventType") ||
|
elementName == _("memoryEventType") ||
|
||||||
elementName == _("mouseEvent") ||
|
elementName == _("mouseEvent") ||
|
||||||
elementName == _("keyEvent")) {
|
elementName == _("keyEvent") ||
|
||||||
|
elementName == _("level")) {
|
||||||
event.detailType = readData.toInt();
|
event.detailType = readData.toInt();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -417,6 +419,8 @@ void QmlProfilerFileReader::loadProfilerDataModel(QXmlStreamReader &stream)
|
|||||||
range.setNumericData(1, attributes.value(_("data1")).toLongLong());
|
range.setNumericData(1, attributes.value(_("data1")).toLongLong());
|
||||||
if (attributes.hasAttribute(_("data2")))
|
if (attributes.hasAttribute(_("data2")))
|
||||||
range.setNumericData(2, attributes.value(_("data2")).toLongLong());
|
range.setNumericData(2, attributes.value(_("data2")).toLongLong());
|
||||||
|
if (attributes.hasAttribute(_("text")))
|
||||||
|
range.setStringData(attributes.value(_("text")).toString());
|
||||||
|
|
||||||
range.setTypeIndex(attributes.value(_("eventIndex")).toInt());
|
range.setTypeIndex(attributes.value(_("eventIndex")).toInt());
|
||||||
|
|
||||||
@@ -585,6 +589,8 @@ void QmlProfilerFileWriter::save(QIODevice *device)
|
|||||||
stream.writeTextElement(_("sgEventType"), QString::number(event.detailType));
|
stream.writeTextElement(_("sgEventType"), QString::number(event.detailType));
|
||||||
} else if (event.message == MemoryAllocation) {
|
} else if (event.message == MemoryAllocation) {
|
||||||
stream.writeTextElement(_("memoryEventType"), QString::number(event.detailType));
|
stream.writeTextElement(_("memoryEventType"), QString::number(event.detailType));
|
||||||
|
} else if (event.message == DebugMessage) {
|
||||||
|
stream.writeTextElement(_("level"), QString::number(event.detailType));
|
||||||
}
|
}
|
||||||
stream.writeEndElement();
|
stream.writeEndElement();
|
||||||
incrementProgress();
|
incrementProgress();
|
||||||
@@ -652,6 +658,9 @@ void QmlProfilerFileWriter::save(QIODevice *device)
|
|||||||
if (event.message == MemoryAllocation)
|
if (event.message == MemoryAllocation)
|
||||||
stream.writeAttribute(_("amount"), QString::number(range.numericData(0)));
|
stream.writeAttribute(_("amount"), QString::number(range.numericData(0)));
|
||||||
|
|
||||||
|
if (event.message == DebugMessage)
|
||||||
|
stream.writeAttribute(_("text"), range.stringData());
|
||||||
|
|
||||||
stream.writeEndElement();
|
stream.writeEndElement();
|
||||||
incrementProgress();
|
incrementProgress();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user