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:
|
||||
return QStringLiteral("DebugMessages,QmlDebugger,V8Debugger,QmlInspector");
|
||||
case QmlProfilerServices:
|
||||
return QStringLiteral("CanvasFrameRate,EngineControl");
|
||||
return QStringLiteral("CanvasFrameRate,EngineControl,DebugMessages");
|
||||
case QmlNativeDebuggerServices:
|
||||
return QStringLiteral("NativeQmlDebugger");
|
||||
default:
|
||||
|
@@ -45,6 +45,7 @@ enum Message {
|
||||
PixmapCacheEvent,
|
||||
SceneGraphFrame,
|
||||
MemoryAllocation,
|
||||
DebugMessage,
|
||||
|
||||
MaximumMessage
|
||||
};
|
||||
@@ -148,6 +149,7 @@ enum ProfileFeature {
|
||||
ProfileBinding,
|
||||
ProfileHandlingSignal,
|
||||
ProfileInputEvents,
|
||||
ProfileDebugMessages,
|
||||
|
||||
MaximumProfileFeature
|
||||
};
|
||||
|
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "qmlprofilertraceclient.h"
|
||||
#include "qmlenginecontrolclient.h"
|
||||
#include "qdebugmessageclient.h"
|
||||
|
||||
namespace QmlDebug {
|
||||
|
||||
@@ -53,6 +54,7 @@ public:
|
||||
|
||||
QmlProfilerTraceClient *q;
|
||||
QmlEngineControlClient engineControl;
|
||||
QScopedPointer<QDebugMessageClient> messageClient;
|
||||
qint64 inProgressRanges;
|
||||
QStack<qint64> rangeStartTimes[MaximumRangeType];
|
||||
QStack<QString> rangeDatas[MaximumRangeType];
|
||||
@@ -86,7 +88,7 @@ QmlProfilerTraceClient::QmlProfilerTraceClient(QmlDebugConnection *client, quint
|
||||
: QmlDebugClient(QLatin1String("CanvasFrameRate"), client)
|
||||
, d(new QmlProfilerTraceClientPrivate(this, client))
|
||||
{
|
||||
d->requestedFeatures = features;
|
||||
setRequestedFeatures(features);
|
||||
connect(&d->engineControl, &QmlEngineControlClient::engineAboutToBeAdded,
|
||||
this, &QmlProfilerTraceClient::sendRecordingStatus);
|
||||
}
|
||||
@@ -152,6 +154,19 @@ quint64 QmlProfilerTraceClient::recordedFeatures() const
|
||||
void QmlProfilerTraceClient::setRequestedFeatures(quint64 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)
|
||||
|
@@ -266,8 +266,11 @@ void QmlProfilerDataModel::addQmlEvent(QmlDebug::Message message, QmlDebug::Rang
|
||||
Q_D(QmlProfilerDataModel);
|
||||
QString displayName;
|
||||
|
||||
QmlEventTypeData typeData(displayName, location, message, rangeType, detailType, data);
|
||||
QmlEventData eventData(startTime, duration, -1, ndata1, ndata2, ndata3, ndata4, ndata5);
|
||||
QmlEventTypeData typeData(displayName, location, message, rangeType, detailType,
|
||||
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);
|
||||
if (it != d->eventTypeIds.end()) {
|
||||
|
@@ -45,7 +45,7 @@
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
static const char *ProfileFeatureNames[QmlDebug::MaximumProfileFeature] = {
|
||||
static const char *ProfileFeatureNames[] = {
|
||||
QT_TRANSLATE_NOOP("MainView", "JavaScript"),
|
||||
QT_TRANSLATE_NOOP("MainView", "Memory Usage"),
|
||||
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", "Binding"),
|
||||
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) :
|
||||
QObject(parent), m_startTime(-1), m_endTime(-1)
|
||||
|
@@ -65,7 +65,8 @@ static const char *MESSAGE_STRINGS[] = {
|
||||
"Complete",
|
||||
"PixmapCache",
|
||||
"SceneGraph",
|
||||
"MemoryAllocation"
|
||||
"MemoryAllocation",
|
||||
"DebugMessage"
|
||||
};
|
||||
|
||||
Q_STATIC_ASSERT(sizeof(MESSAGE_STRINGS) == QmlDebug::MaximumMessage * sizeof(const char *));
|
||||
@@ -226,6 +227,8 @@ QmlDebug::ProfileFeature featureFromEvent(const QmlProfilerDataModel::QmlEventTy
|
||||
return ProfileSceneGraph;
|
||||
case MemoryAllocation:
|
||||
return ProfileMemory;
|
||||
case DebugMessage:
|
||||
return ProfileDebugMessages;
|
||||
default:
|
||||
return MaximumProfileFeature;
|
||||
}
|
||||
@@ -235,8 +238,6 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream)
|
||||
{
|
||||
QTC_ASSERT(stream.name() == _("eventData"), return);
|
||||
|
||||
QXmlStreamAttributes attributes = stream.attributes();
|
||||
|
||||
int eventIndex = -1;
|
||||
QmlProfilerDataModel::QmlEventTypeData event = {
|
||||
QString(), // displayname
|
||||
@@ -327,7 +328,8 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream)
|
||||
elementName == _("sgEventType") ||
|
||||
elementName == _("memoryEventType") ||
|
||||
elementName == _("mouseEvent") ||
|
||||
elementName == _("keyEvent")) {
|
||||
elementName == _("keyEvent") ||
|
||||
elementName == _("level")) {
|
||||
event.detailType = readData.toInt();
|
||||
break;
|
||||
}
|
||||
@@ -417,6 +419,8 @@ void QmlProfilerFileReader::loadProfilerDataModel(QXmlStreamReader &stream)
|
||||
range.setNumericData(1, attributes.value(_("data1")).toLongLong());
|
||||
if (attributes.hasAttribute(_("data2")))
|
||||
range.setNumericData(2, attributes.value(_("data2")).toLongLong());
|
||||
if (attributes.hasAttribute(_("text")))
|
||||
range.setStringData(attributes.value(_("text")).toString());
|
||||
|
||||
range.setTypeIndex(attributes.value(_("eventIndex")).toInt());
|
||||
|
||||
@@ -585,6 +589,8 @@ void QmlProfilerFileWriter::save(QIODevice *device)
|
||||
stream.writeTextElement(_("sgEventType"), QString::number(event.detailType));
|
||||
} else if (event.message == MemoryAllocation) {
|
||||
stream.writeTextElement(_("memoryEventType"), QString::number(event.detailType));
|
||||
} else if (event.message == DebugMessage) {
|
||||
stream.writeTextElement(_("level"), QString::number(event.detailType));
|
||||
}
|
||||
stream.writeEndElement();
|
||||
incrementProgress();
|
||||
@@ -652,6 +658,9 @@ void QmlProfilerFileWriter::save(QIODevice *device)
|
||||
if (event.message == MemoryAllocation)
|
||||
stream.writeAttribute(_("amount"), QString::number(range.numericData(0)));
|
||||
|
||||
if (event.message == DebugMessage)
|
||||
stream.writeAttribute(_("text"), range.stringData());
|
||||
|
||||
stream.writeEndElement();
|
||||
incrementProgress();
|
||||
}
|
||||
|
Reference in New Issue
Block a user