Details
-
Bug
-
Resolution: Done
-
Not Evaluated
-
Qt Creator 4.2.1
-
None
-
2b50fec73b7ea9be8005a5abff2f541ead9240a0
Description
considering the C++ code:
struct AA { int a: 1; int b: 7; }
When checking the internal structure of DumperBase.Value for type TypeCodeBitfield, we can notive that: in extract field:
if fieldType.code == TypeCodeBitfield: fieldBitpos -= fieldOffset * 8 ldata = self.data() data = 0 for i in range(fieldSize): data = data << 8 if self.dumper.isBigEndian: byte = ldata[i] else: byte = ldata[fieldOffset + fieldSize - 1 - i] data += ord(byte) data = data >> fieldBitpos data = data & ((1 << fieldBitsize) - 1) val.lvalue = data val.laddress = None return val
Thus the data is coded in the lvalue sub-field at line:
val.lvalue = data
However when accessing to the field thought the Value object (for example value['a'} or value['b'], we properly get a Value sub-field represeting the bit fields.
However, it is not possible to access to the real value using int(value['a'])
Reason is that TypeCodeBitfield type is not handled in the Value.integer()
API.
My suggestion is to change API to
def integer(self): if self.type.code == TypeCodeTypedef: return self.detypedef().integer() ==================== Start Added code ============== if self.type.code == TypeCodeBitfield: return self.lvalue ===================== End added code ============== unsigned = self.type.name.startswith('unsigned') bitsize = self.type.bitsize() return self.extractInteger(bitsize, unsigned)
I am not sure if it is the proper place to fix or in underlying extractInteger() API.
This bug is blocking for processing any pretty printer on data structure having bit fields (boost in particular for me)