Commit 5e5e5337 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Debugger: Fix up titles/tooltips of memory views.

parent dd0203e9
...@@ -211,6 +211,8 @@ enum ModelRoles ...@@ -211,6 +211,8 @@ enum ModelRoles
LocalsExpressionRole, LocalsExpressionRole,
LocalsRawExpressionRole, LocalsRawExpressionRole,
LocalsExpandedRole, // The preferred expanded state to the view LocalsExpandedRole, // The preferred expanded state to the view
LocalsRawTypeRole, // Raw type name
LocalsTypeRole, // Display type name
LocalsTypeFormatListRole, LocalsTypeFormatListRole,
LocalsTypeFormatRole, // Used to communicate alternative formats to the view LocalsTypeFormatRole, // Used to communicate alternative formats to the view
LocalsIndividualFormatRole, LocalsIndividualFormatRole,
......
...@@ -626,7 +626,7 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const ...@@ -626,7 +626,7 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
} }
case Qt::DisplayRole: { case Qt::DisplayRole: {
const QByteArray ns = engine()->qtNamespace(); const QByteArray qtNameSpace = engine()->qtNamespace();
QString result; QString result;
switch (idx.column()) { switch (idx.column()) {
case 0: case 0:
...@@ -635,18 +635,18 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const ...@@ -635,18 +635,18 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
else if (data.name == QLatin1String("*") && item->parent) else if (data.name == QLatin1String("*") && item->parent)
result = QLatin1Char('*') + item->parent->name; result = QLatin1Char('*') + item->parent->name;
else else
result = removeInitialNamespace(data.name, ns); result = removeInitialNamespace(data.name, qtNameSpace);
break; break;
case 1: case 1:
result = removeInitialNamespace(truncateValue( result = removeInitialNamespace(truncateValue(
formattedValue(data, itemFormat(data))), ns); formattedValue(data, itemFormat(data))), qtNameSpace);
if (data.referencingAddress) { if (data.referencingAddress) {
result += QLatin1String(" @"); result += QLatin1String(" @");
result += QString::fromLatin1(data.hexAddress()); result += QString::fromLatin1(data.hexAddress());
} }
break; break;
case 2: case 2:
result = removeNamespaces(displayType(data), ns); result = removeNamespaces(displayType(data), qtNameSpace);
break; break;
default: default:
break; break;
...@@ -722,7 +722,10 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const ...@@ -722,7 +722,10 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
type = type.left(pos); type = type.left(pos);
return m_handler->m_reportedTypeFormats.value(type); return m_handler->m_reportedTypeFormats.value(type);
} }
case LocalsTypeRole:
return removeNamespaces(displayType(data), engine()->qtNamespace());
case LocalsRawTypeRole:
return QString::fromLatin1(data.type);
case LocalsTypeFormatRole: case LocalsTypeFormatRole:
return m_handler->m_typeFormats.value(data.type, -1); return m_handler->m_typeFormats.value(data.type, -1);
......
...@@ -148,6 +148,8 @@ static inline quint64 pointerValueOf(const QModelIndex &m) ...@@ -148,6 +148,8 @@ static inline quint64 pointerValueOf(const QModelIndex &m)
{ return m.data(LocalsPointerValueRole).toULongLong(); } { return m.data(LocalsPointerValueRole).toULongLong(); }
static inline QString nameOf(const QModelIndex &m) static inline QString nameOf(const QModelIndex &m)
{ return m.data().toString(); } { return m.data().toString(); }
static inline QString typeOf(const QModelIndex &m)
{ return m.data(LocalsTypeRole).toString(); }
static inline uint sizeOf(const QModelIndex &m) static inline uint sizeOf(const QModelIndex &m)
{ return m.data(LocalsSizeRole).toUInt(); } { return m.data(LocalsSizeRole).toUInt(); }
...@@ -159,6 +161,18 @@ static inline uint sizeOf(const QModelIndex &m) ...@@ -159,6 +161,18 @@ static inline uint sizeOf(const QModelIndex &m)
typedef QPair<int, QString> ColorNumberToolTipPair; typedef QPair<int, QString> ColorNumberToolTipPair;
typedef QVector<ColorNumberToolTipPair> ColorNumberToolTipVector; typedef QVector<ColorNumberToolTipPair> ColorNumberToolTipVector;
static inline QString variableToolTip(const QString &name,
const QString &type,
quint64 offset)
{
return offset ?
//: HTML tooltip of a variable in the memory editor
WatchWindow::tr("<i>%1</i> %2 at #%3").
arg(type, name).arg(offset) :
//: HTML tooltip of a variable in the memory editor
WatchWindow::tr("<i>%1</i> %2").arg(type, name);
}
static int memberVariableRecursion(const QModelIndex &m, static int memberVariableRecursion(const QModelIndex &m,
const QString &name, const QString &name,
quint64 start, quint64 end, quint64 start, quint64 end,
...@@ -178,7 +192,8 @@ static int memberVariableRecursion(const QModelIndex &m, ...@@ -178,7 +192,8 @@ static int memberVariableRecursion(const QModelIndex &m,
&& (childAddress + childSize) <= end) { // Non-static, within area? && (childAddress + childSize) <= end) { // Non-static, within area?
const QString childName = nameRoot + nameOf(childIndex); const QString childName = nameRoot + nameOf(childIndex);
const quint64 childOffset = childAddress - start; const quint64 childOffset = childAddress - start;
const QString toolTip = WatchWindow::tr("%1 at #%2").arg(childName).arg(childOffset); const QString toolTip
= variableToolTip(childName, typeOf(childIndex), childOffset);
const ColorNumberToolTipPair colorNumberNamePair((*colorNumberIn)++, toolTip); const ColorNumberToolTipPair colorNumberNamePair((*colorNumberIn)++, toolTip);
const ColorNumberToolTipVector::iterator begin = cnmv->begin() + childOffset; const ColorNumberToolTipVector::iterator begin = cnmv->begin() + childOffset;
qFill(begin, begin + childSize, colorNumberNamePair); qFill(begin, begin + childSize, colorNumberNamePair);
...@@ -240,7 +255,8 @@ static inline MemoryMarkupList ...@@ -240,7 +255,8 @@ static inline MemoryMarkupList
MemoryMarkupList result; MemoryMarkupList result;
const QString name = nameOf(m); const QString name = nameOf(m);
int colorNumber = 0; int colorNumber = 0;
ColorNumberToolTipVector ranges(size, ColorNumberToolTipPair(colorNumber, name)); const QString rootToolTip = variableToolTip(name, typeOf(m), 0);
ColorNumberToolTipVector ranges(size, ColorNumberToolTipPair(colorNumber, rootToolTip));
const int childCount = memberVariableRecursion(m, name, address, address + size, &colorNumber, &ranges); const int childCount = memberVariableRecursion(m, name, address, address + size, &colorNumber, &ranges);
if (sizeIsEstimate && !childCount) if (sizeIsEstimate && !childCount)
return result; // Fixme: Exact size not known, no point in filling if no children. return result; // Fixme: Exact size not known, no point in filling if no children.
...@@ -319,7 +335,9 @@ static void addVariableMemoryView(DebuggerEngine *engine, ...@@ -319,7 +335,9 @@ static void addVariableMemoryView(DebuggerEngine *engine,
const QList<MemoryMarkup> markup = const QList<MemoryMarkup> markup =
variableMemoryMarkup(m, address, size, sizeIsEstimate, background); variableMemoryMarkup(m, address, size, sizeIsEstimate, background);
const unsigned flags = separateView ? (DebuggerEngine::MemoryView|DebuggerEngine::MemoryReadOnly) : 0; const unsigned flags = separateView ? (DebuggerEngine::MemoryView|DebuggerEngine::MemoryReadOnly) : 0;
const QString title = WatchWindow::tr("Memory at Variable '%1' (0x%2)").arg(nameOf(m)).arg(address, 0, 16); const QString title = deferencePointer ?
WatchWindow::tr("Memory Referenced by Pointer '%1' (0x%2)").arg(nameOf(m)).arg(address, 0, 16) :
WatchWindow::tr("Memory at Variable '%1' (0x%2)").arg(nameOf(m)).arg(address, 0, 16);
engine->openMemoryView(address, flags, markup, p, title, parent); engine->openMemoryView(address, flags, markup, p, title, parent);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment