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:
@@ -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