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

@@ -520,6 +520,7 @@ QString WatchItem::toToolTip() const
formatToolTipRow(str, tr("Static Object Size"), tr("%n bytes", nullptr, size));
formatToolTipRow(str, tr("Internal ID"), internalName());
formatToolTipRow(str, tr("Creation Time in ms"), QString::number(int(time * 1000)));
formatToolTipRow(str, tr("Source"), sourceExpression());
str << "</table></body></html>";
return res;
}
@@ -578,6 +579,31 @@ QString WatchItem::expression() const
return name;
}
QString WatchItem::sourceExpression() const
{
const WatchItem *p = parent();
if (!p)
return {}; // Root
const WatchItem *pp = p->parent();
if (!pp)
return {}; // local
const WatchItem *ppp = pp->parent();
if (!ppp)
return name; // local.x -> 'x'
// Enforce some arbitrary, but fixed limit to avoid excessive creation
// of very likely unused strings which are for convenience only.
if (arrayIndex >= 0 && arrayIndex <= 16)
return QString("%1[%2]").arg(p->sourceExpression()).arg(arrayIndex);
if (p->name == '*')
return QString("%1->%2").arg(pp->sourceExpression(), name);
return QString("%1.%2").arg(p->sourceExpression(), name);
}
} // namespace Internal
} // namespace Debugger