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
+6
View File
@@ -1312,6 +1312,11 @@ class DumperBase():
savedCurrentChildType = self.currentChildType
self.currentChildType = innerType.name
derefValue.name = '*'
derefValue.autoDerefCount = value.autoDerefCount + 1
if derefValue.type.code != TypeCode.Pointer:
self.putField('autoderefcount', '{}'.format(derefValue.autoDerefCount))
self.putItem(derefValue)
self.currentChildType = savedCurrentChildType
@@ -2920,6 +2925,7 @@ class DumperBase():
self.targetValue = None # For references.
self.isBaseClass = None
self.nativeValue = None
self.autoDerefCount = 0
def copy(self):
val = self.dumper.Value(self.dumper)