Debugger: Add an option to show simple values as text annotations

Change-Id: I726d8559d7e28abd776ce483d5f670be5af09412
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2021-01-18 16:30:38 +01:00
parent 0ed99a954b
commit 79ade10c4a
11 changed files with 181 additions and 12 deletions

View File

@@ -38,6 +38,7 @@
#include "memoryagent.h"
#include "registerhandler.h"
#include "simplifytype.h"
#include "sourceutils.h"
#include "watchdelegatewidgets.h"
#include "watchutils.h"
@@ -67,6 +68,7 @@
#include <QJsonArray>
#include <QJsonObject>
#include <QLabel>
#include <QMap>
#include <QMenu>
#include <QMimeData>
#include <QPainter>
@@ -473,6 +475,8 @@ public:
QHash<QString, TypeInfo> m_reportedTypeInfo;
QHash<QString, DisplayFormats> m_reportedTypeFormats; // Type name -> Dumper Formats
QHash<QString, QString> m_valueCache;
Location m_location;
};
WatchModel::WatchModel(WatchHandler *handler, DebuggerEngine *engine)
@@ -518,6 +522,8 @@ WatchModel::WatchModel(WatchHandler *handler, DebuggerEngine *engine)
m_engine, &DebuggerEngine::updateAll);
connect(action(ShowQObjectNames), &SavedAction::valueChanged,
m_engine, &DebuggerEngine::updateAll);
connect(action(UseAnnotationsInMainEditor), &SavedAction::valueChanged,
m_engine, &DebuggerEngine::updateAll);
connect(SessionManager::instance(), &SessionManager::sessionLoaded,
this, &loadSessionData);
@@ -2081,6 +2087,7 @@ void WatchHandler::cleanup()
theTemporaryWatchers.clear();
saveWatchers();
m_model->reinitialize();
Internal::setValueAnnotations(m_model->m_location, {});
emit m_model->updateFinished();
m_model->m_separatedView->hide();
}
@@ -2234,6 +2241,16 @@ void WatchHandler::notifyUpdateFinished()
}
});
QMap<QString, QString> values;
if (boolSetting(UseAnnotationsInMainEditor)) {
m_model->forAllItems([&values](WatchItem *item) {
const QString expr = item->sourceExpression();
if (!expr.isEmpty())
values[expr] = item->value;
});
}
Internal::setValueAnnotations(m_model->m_location, values);
m_model->m_contentsValid = true;
updateLocalsWindow();
m_model->reexpandItems();
@@ -2750,6 +2767,11 @@ void WatchHandler::recordTypeInfo(const GdbMi &typeInfo)
}
}
void WatchHandler::setLocation(const Location &loc)
{
m_model->m_location = loc;
}
/////////////////////////////////////////////////////////////////////
//
// WatchDelegate