Commit a9145e67 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

Debugger: Prettify values for enum bitfields



Change-Id: I55329bba1864c9ebbbcb3b3bf1b940346507f8cd
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
parent 4c29a319
......@@ -2730,7 +2730,10 @@ class DumperBase:
if typeobj.code == TypeCodeBitfield:
#warn('BITFIELD VALUE: %s %s' % (value.name, value))
self.putNumChild(0)
self.putValue(value.lvalue)
if typeobj.ltarget and typeobj.ltarget.code == TypeCodeEnum:
self.putValue(typeobj.ltarget.typeData().enumDisplay(value.lvalue, value.laddress))
else:
self.putValue(value.lvalue)
self.putType(typeName)
return
......@@ -3695,15 +3698,16 @@ class DumperBase:
self.registerType(typeId, tdata)
return self.Type(self, typeId)
def createBitfieldType(self, targetTypeId, bitsize):
if not isinstance(targetTypeId, str):
def createBitfieldType(self, targetType, bitsize):
if not isinstance(targetType, self.Type):
error('Expected type in createBitfieldType(), got %s'
% type(targetType))
typeId = '%s:%d' % (targetTypeId, bitsize)
typeId = '%s:%d' % (targetType.typeId, bitsize)
tdata = self.TypeData(self)
tdata.name = '%s : %d' % (targetTypeId, bitsize)
tdata.name = '%s : %d' % (targetType.typeId, bitsize)
tdata.typeId = typeId
tdata.code = TypeCodeBitfield
tdata.ltarget = targetType
tdata.lbitsize = bitsize
self.registerType(typeId, tdata)
return self.Type(self, typeId)
......
......@@ -463,7 +463,8 @@ class Dumper(DumperBase):
if nativeField.bitsize:
val.lvalue = int(nativeMember)
val.laddress = None
val.type = self.createBitfieldType(str(nativeFieldType), nativeField.bitsize)
fieldType = self.fromNativeType(nativeFieldType)
val.type = self.createBitfieldType(fieldType, nativeField.bitsize)
val.isBaseClass = nativeField.is_base_class
val.name = fieldName
return val
......@@ -522,10 +523,11 @@ class Dumper(DumperBase):
else:
bitsize = 8 * nativeFieldType.sizeof
fieldType = self.fromNativeType(nativeFieldType)
if bitsize != nativeFieldType.sizeof * 8:
fieldType = self.createBitfieldType(str(nativeFieldType), bitsize)
fieldType = self.createBitfieldType(fieldType, bitsize)
else:
fieldType = self.fromNativeType(nativeFieldType)
fieldType = fieldType
if nativeValue is None:
extractor = None
......
......@@ -255,7 +255,8 @@ class Dumper(DumperBase):
isBitfield = False
if isBitfield: # Bit fields
fieldType = self.createBitfieldType(self.typeName(nativeFieldType), fieldBitsize)
fieldType = self.createBitfieldType(
self.createType(self.typeName(nativeFieldType)), fieldBitsize)
yield self.Field(self, name=fieldName, type=fieldType,
bitsize=fieldBitsize, bitpos=fieldBitpos)
......
......@@ -5416,7 +5416,7 @@ void tst_Dumpers::dumper_data()
+ Check("s.x", "2", "unsigned int : 3") % NoCdbEngine
+ Check("s.y", "3", "unsigned int : 4") % NoCdbEngine
+ Check("s.z", "39", "unsigned int : 18") % NoCdbEngine
+ Check("s.e", "1", "E : 3") % NoCdbEngine
+ Check("s.e", "V2 (1)", "E : 3") % NoCdbEngine
+ Check("s.x", "2", "unsigned int") % CdbEngine
+ Check("s.y", "3", "unsigned int") % CdbEngine
+ Check("s.z", "39", "unsigned int") % CdbEngine
......
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