Debugger: Prepend '*'s for autodereferenced pointers

If automatic dereferencing of pointers is enabled, the
"Value" and "Type" columns for pointers hold the values for
the dereferenced pointers.

In order to have a consistent behavior for the "Name" column
as well, prepend '*'s to indicate that the variable/expression
has actually been dereferenced.
Add parantheses around the original expression if it doesn't
match a simple regex for variable names, to avoid that the
leading '*' changes the meaning of the expression
(so e.g. a dereferenced 'somepointer + 1' is displayed
as  '*(somepointer + 1)' rather than '*somepointer + 1').

This introduces a new 'autoderefcount' field to propagate the
information how many levels of dereferencing have taken
place from the Python to the C++ side, which is then
used to add the leading '*'s for the display name.

Fixes: QTCREATORBUG-20907
Change-Id: Ia9a41cb42e25ba72a6d980a765dbe2b454deb8c8
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Michael Weghorn
2021-02-17 08:40:48 +01:00
parent c6493e170f
commit f4dc3fd5c5
4 changed files with 29 additions and 0 deletions

View File

@@ -115,6 +115,7 @@ WatchItem::WatchItem() :
wantsChildren(false),
valueEnabled(true),
valueEditable(true),
autoDerefCount(0),
outdated(false)
{
}
@@ -388,6 +389,14 @@ void WatchItem::parseHelper(const GdbMi &input, bool maySort)
else if (mi.data() == "false")
valueEditable = false;
mi = input["autoderefcount"];
if (mi.isValid()) {
bool ok = false;
uint derefCount = mi.data().toUInt(&ok);
if (ok)
autoDerefCount = derefCount;
}
mi = input["numchild"]; // GDB/MI
if (mi.isValid())
setHasChildren(mi.toInt() > 0);