forked from qt-creator/qt-creator
QmlInspector: Use categorized debugging
Change-Id: I551d2b65bbd1734847b7e995e0f95e906d116497 Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include <debugger/watchhandler.h>
|
||||
|
||||
#include <qmldebug/qmldebugconstants.h>
|
||||
#include <utils/logging.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/savedaction.h>
|
||||
#include <QElapsedTimer>
|
||||
@@ -47,9 +48,7 @@ using namespace QmlDebug::Constants;
|
||||
namespace Debugger {
|
||||
namespace Internal {
|
||||
|
||||
enum {
|
||||
debug = false
|
||||
};
|
||||
Q_LOGGING_CATEGORY(qmlInspectorLog, "qtc.dbg.qmlinspector")
|
||||
|
||||
/*!
|
||||
* DebuggerAgent updates the watchhandler with the object tree data.
|
||||
@@ -76,9 +75,9 @@ quint32 QmlInspectorAgent::queryExpressionResult(int debugId,
|
||||
if (!m_engineClient)
|
||||
return 0;
|
||||
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << '(' << debugId << expression
|
||||
<< m_engine.debugId() << ')';
|
||||
qCDebug(qmlInspectorLog)
|
||||
<< __FUNCTION__ << '(' << debugId << expression
|
||||
<< m_engine.debugId() << ')';
|
||||
|
||||
return m_engineClient->queryExpressionResult(debugId, expression,
|
||||
m_engine.debugId());
|
||||
@@ -87,8 +86,8 @@ quint32 QmlInspectorAgent::queryExpressionResult(int debugId,
|
||||
void QmlInspectorAgent::assignValue(const WatchData *data,
|
||||
const QString &expr, const QVariant &valueV)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << '(' << data->id << ')' << data->iname;
|
||||
qCDebug(qmlInspectorLog)
|
||||
<< __FUNCTION__ << '(' << data->id << ')' << data->iname;
|
||||
|
||||
if (data->id) {
|
||||
QString val(valueV.toString());
|
||||
@@ -114,8 +113,7 @@ int parentIdForIname(const QByteArray &iname)
|
||||
|
||||
void QmlInspectorAgent::updateWatchData(const WatchData &data)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << '(' << data.id << ')';
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << '(' << data.id << ')';
|
||||
|
||||
if (data.id && !m_fetchDataIds.contains(data.id)) {
|
||||
// objects
|
||||
@@ -126,8 +124,7 @@ void QmlInspectorAgent::updateWatchData(const WatchData &data)
|
||||
|
||||
void QmlInspectorAgent::watchDataSelected(const WatchData *data)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << '(' << data->id << ')';
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << '(' << data->id << ')';
|
||||
|
||||
if (data->id) {
|
||||
QTC_ASSERT(m_debugIdLocations.keys().contains(data->id), return);
|
||||
@@ -137,17 +134,14 @@ void QmlInspectorAgent::watchDataSelected(const WatchData *data)
|
||||
|
||||
bool QmlInspectorAgent::selectObjectInTree(int debugId)
|
||||
{
|
||||
if (debug) {
|
||||
qDebug() << __FUNCTION__ << '(' << debugId << ')';
|
||||
qDebug() << " " << debugId << "already fetched? "
|
||||
<< m_debugIdToIname.contains(debugId);
|
||||
}
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << '(' << debugId << ')' << endl
|
||||
<< " " << debugId << "already fetched? "
|
||||
<< m_debugIdToIname.contains(debugId);
|
||||
|
||||
if (m_debugIdToIname.contains(debugId)) {
|
||||
QByteArray iname = m_debugIdToIname.value(debugId);
|
||||
QTC_ASSERT(iname.startsWith("inspect."), qDebug() << iname);
|
||||
if (debug)
|
||||
qDebug() << " selecting" << iname << "in tree";
|
||||
qCDebug(qmlInspectorLog) << " selecting" << iname << "in tree";
|
||||
m_debuggerEngine->watchHandler()->setCurrentItem(iname);
|
||||
m_objectToSelect = 0;
|
||||
return true;
|
||||
@@ -173,9 +167,9 @@ quint32 QmlInspectorAgent::setBindingForObject(int objectDebugId,
|
||||
QString source,
|
||||
int line)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << '(' << objectDebugId << propertyName
|
||||
<< value.toString() << isLiteralValue << source << line << ')';
|
||||
qCDebug(qmlInspectorLog)
|
||||
<< __FUNCTION__ << '(' << objectDebugId << propertyName
|
||||
<< value.toString() << isLiteralValue << source << line << ')';
|
||||
|
||||
if (objectDebugId == -1)
|
||||
return 0;
|
||||
@@ -205,9 +199,9 @@ quint32 QmlInspectorAgent::setMethodBodyForObject(int objectDebugId,
|
||||
const QString &methodName,
|
||||
const QString &methodBody)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << '(' << objectDebugId
|
||||
<< methodName << methodBody << ')';
|
||||
qCDebug(qmlInspectorLog)
|
||||
<< __FUNCTION__ << '(' << objectDebugId << methodName << methodBody
|
||||
<< ')';
|
||||
|
||||
if (objectDebugId == -1)
|
||||
return 0;
|
||||
@@ -231,9 +225,9 @@ quint32 QmlInspectorAgent::setMethodBodyForObject(int objectDebugId,
|
||||
quint32 QmlInspectorAgent::resetBindingForObject(int objectDebugId,
|
||||
const QString &propertyName)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << '(' << objectDebugId
|
||||
<< propertyName << ')';
|
||||
qCDebug(qmlInspectorLog)
|
||||
<< __FUNCTION__ << '(' << objectDebugId
|
||||
<< propertyName << ')';
|
||||
|
||||
if (objectDebugId == -1)
|
||||
return 0;
|
||||
@@ -332,8 +326,7 @@ QHash<int,QString> QmlInspectorAgent::rootObjectIds() const
|
||||
|
||||
bool QmlInspectorAgent::addObjectWatch(int objectDebugId)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << '(' << objectDebugId << ')';
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << '(' << objectDebugId << ')';
|
||||
|
||||
if (objectDebugId == -1)
|
||||
return false;
|
||||
@@ -362,8 +355,7 @@ bool QmlInspectorAgent::isObjectBeingWatched(int objectDebugId)
|
||||
|
||||
bool QmlInspectorAgent::removeObjectWatch(int objectDebugId)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << '(' << objectDebugId << ')';
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << '(' << objectDebugId << ')';
|
||||
|
||||
if (objectDebugId == -1)
|
||||
return false;
|
||||
@@ -380,8 +372,7 @@ bool QmlInspectorAgent::removeObjectWatch(int objectDebugId)
|
||||
|
||||
void QmlInspectorAgent::removeAllObjectWatches()
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << "()";
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << "()";
|
||||
|
||||
foreach (int watchedObject, m_objectWatches)
|
||||
removeObjectWatch(watchedObject);
|
||||
@@ -448,8 +439,7 @@ void QmlInspectorAgent::updateState()
|
||||
void QmlInspectorAgent::onResult(quint32 queryId, const QVariant &value,
|
||||
const QByteArray &type)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << "() ...";
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << "() ...";
|
||||
|
||||
if (type == "FETCH_OBJECT_R") {
|
||||
log(LogReceive, _("FETCH_OBJECT_R %1").arg(
|
||||
@@ -494,15 +484,13 @@ void QmlInspectorAgent::onResult(quint32 queryId, const QVariant &value,
|
||||
emit expressionResult(queryId, value);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << "done";
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << "done";
|
||||
|
||||
}
|
||||
|
||||
void QmlInspectorAgent::newObject(int engineId, int /*objectId*/, int /*parentId*/)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << "()";
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << "()";
|
||||
|
||||
log(LogReceive, QLatin1String("OBJECT_CREATED"));
|
||||
|
||||
@@ -520,8 +508,9 @@ void QmlInspectorAgent::onValueChanged(int debugId, const QByteArray &propertyNa
|
||||
".[properties]." + propertyName;
|
||||
WatchHandler *watchHandler = m_debuggerEngine->watchHandler();
|
||||
const WatchData *data = watchHandler->findData(iname);
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << '(' << debugId << ')' << iname << value.toString();
|
||||
qCDebug(qmlInspectorLog)
|
||||
<< __FUNCTION__ << '(' << debugId << ')' << iname
|
||||
<< value.toString();
|
||||
if (data) {
|
||||
WatchData d(*data);
|
||||
d.value = value.toString();
|
||||
@@ -531,8 +520,7 @@ void QmlInspectorAgent::onValueChanged(int debugId, const QByteArray &propertyNa
|
||||
|
||||
void QmlInspectorAgent::reloadEngines()
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << "()";
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << "()";
|
||||
|
||||
if (!isConnected())
|
||||
return;
|
||||
@@ -560,8 +548,7 @@ int QmlInspectorAgent::parentIdForObject(int objectDebugId)
|
||||
|
||||
void QmlInspectorAgent::queryEngineContext()
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__;
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__;
|
||||
|
||||
if (!isConnected()
|
||||
|| !debuggerCore()->boolSetting(ShowQmlObjectTree))
|
||||
@@ -575,8 +562,7 @@ void QmlInspectorAgent::queryEngineContext()
|
||||
|
||||
void QmlInspectorAgent::fetchObject(int debugId)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << '(' << debugId << ')';
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << '(' << debugId << ')';
|
||||
|
||||
if (!isConnected()
|
||||
|| !debuggerCore()->boolSetting(ShowQmlObjectTree))
|
||||
@@ -584,9 +570,8 @@ void QmlInspectorAgent::fetchObject(int debugId)
|
||||
|
||||
log(LogSend, QLatin1String("FETCH_OBJECT ") + QString::number(debugId));
|
||||
quint32 queryId = m_engineClient->queryObject(debugId);
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << '(' << debugId << ')'
|
||||
<< " - query id" << queryId;
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << '(' << debugId << ')'
|
||||
<< " - query id" << queryId;
|
||||
m_objectTreeQueryIds << queryId;
|
||||
}
|
||||
|
||||
@@ -595,9 +580,8 @@ void QmlInspectorAgent::fetchContextObjectsForLocation(const QString &file,
|
||||
{
|
||||
// This can be an expensive operation as it may return multiple
|
||||
// objects. Use fetchContextObject() where possible.
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << '(' << file << ':' << lineNumber
|
||||
<< ':' << columnNumber << ')';
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << '(' << file << ':' << lineNumber
|
||||
<< ':' << columnNumber << ')';
|
||||
|
||||
if (!isConnected()
|
||||
|| !debuggerCore()->boolSetting(ShowQmlObjectTree))
|
||||
@@ -607,17 +591,15 @@ void QmlInspectorAgent::fetchContextObjectsForLocation(const QString &file,
|
||||
.arg(QString::number(lineNumber)).arg(QString::number(columnNumber)));
|
||||
quint32 queryId = m_engineClient->queryObjectsForLocation(QFileInfo(file).fileName(),
|
||||
lineNumber, columnNumber);
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << '(' << file << ':' << lineNumber
|
||||
<< ':' << columnNumber << ')' << " - query id" << queryId;
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << '(' << file << ':' << lineNumber
|
||||
<< ':' << columnNumber << ')' << " - query id" << queryId;
|
||||
|
||||
m_objectTreeQueryIds << queryId;
|
||||
}
|
||||
|
||||
void QmlInspectorAgent::updateObjectTree(const ContextReference &context)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << '(' << context << ')';
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << '(' << context << ')';
|
||||
|
||||
if (!isConnected()
|
||||
|| !debuggerCore()->boolSetting(ShowQmlObjectTree))
|
||||
@@ -632,8 +614,7 @@ void QmlInspectorAgent::updateObjectTree(const ContextReference &context)
|
||||
|
||||
void QmlInspectorAgent::verifyAndInsertObjectInTree(const ObjectReference &object)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << '(' << object << ')';
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << '(' << object << ')';
|
||||
|
||||
if (!object.isValid())
|
||||
return;
|
||||
@@ -680,33 +661,32 @@ void QmlInspectorAgent::verifyAndInsertObjectInTree(const ObjectReference &objec
|
||||
|
||||
void QmlInspectorAgent::insertObjectInTree(const ObjectReference &object)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << '(' << object << ')';
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << '(' << object << ')';
|
||||
|
||||
const int objectDebugId = object.debugId();
|
||||
const int parentId = parentIdForIname(m_debugIdToIname.value(objectDebugId));
|
||||
|
||||
QElapsedTimer timeElapsed;
|
||||
QList<WatchData> watchData;
|
||||
if (debug)
|
||||
|
||||
bool printTime = qmlInspectorLog().isDebugEnabled();
|
||||
if (printTime)
|
||||
timeElapsed.start();
|
||||
watchData.append(buildWatchData(object, m_debugIdToIname.value(parentId), true));
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << "Time: Build Watch Data took "
|
||||
<< timeElapsed.elapsed() << " ms";
|
||||
if (debug)
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << "Time: Build Watch Data took "
|
||||
<< timeElapsed.elapsed() << " ms";
|
||||
if (printTime)
|
||||
timeElapsed.start();
|
||||
buildDebugIdHashRecursive(object);
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << "Time: Build Debug Id Hash took "
|
||||
<< timeElapsed.elapsed() << " ms";
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << "Time: Build Debug Id Hash took "
|
||||
<< timeElapsed.elapsed() << " ms";
|
||||
|
||||
WatchHandler *watchHandler = m_debuggerEngine->watchHandler();
|
||||
if (debug)
|
||||
if (printTime)
|
||||
timeElapsed.start();
|
||||
watchHandler->insertData(watchData);
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << "Time: Insertion took " << timeElapsed.elapsed() << " ms";
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << "Time: Insertion took "
|
||||
<< timeElapsed.elapsed() << " ms";
|
||||
|
||||
emit objectTreeUpdated();
|
||||
emit objectFetched(object);
|
||||
@@ -714,8 +694,7 @@ void QmlInspectorAgent::insertObjectInTree(const ObjectReference &object)
|
||||
if (m_debugIdToIname.contains(m_objectToSelect)) {
|
||||
// select item in view
|
||||
QByteArray iname = m_debugIdToIname.value(m_objectToSelect);
|
||||
if (debug)
|
||||
qDebug() << " selecting" << iname << "in tree";
|
||||
qCDebug(qmlInspectorLog) << " selecting" << iname << "in tree";
|
||||
watchHandler->setCurrentItem(iname);
|
||||
m_objectToSelect = -1;
|
||||
}
|
||||
@@ -723,8 +702,7 @@ void QmlInspectorAgent::insertObjectInTree(const ObjectReference &object)
|
||||
|
||||
void QmlInspectorAgent::buildDebugIdHashRecursive(const ObjectReference &ref)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << '(' << ref << ')';
|
||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << '(' << ref << ')';
|
||||
|
||||
QUrl fileUrl = ref.source().url();
|
||||
int lineNum = ref.source().lineNumber();
|
||||
@@ -770,8 +748,7 @@ QList<WatchData> QmlInspectorAgent::buildWatchData(const ObjectReference &obj,
|
||||
const QByteArray &parentIname,
|
||||
bool append)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << __FUNCTION__ << '(' << obj << parentIname << ')';
|
||||
qCDebug(qmlInspectorLog) << '(' << obj << parentIname << ')';
|
||||
|
||||
QList<WatchData> list;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user