forked from qt-creator/qt-creator
Debugger: Robustify QEvent dumpers
There's no need to go through unknown enum sizes here, they are known. Also, make it work for namespaced Qt. Avoid casts to typedefs. Change-Id: I9c6fc44a03a0c245f05957306a129f6902f8cf85 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
@@ -2931,8 +2931,8 @@ class DumperBase:
|
|||||||
% (self.name, self.type.name, self.lbitsize, self.lbitpos,
|
% (self.name, self.type.name, self.lbitsize, self.lbitpos,
|
||||||
self.dumper.hexencode(self.ldata), addr)
|
self.dumper.hexencode(self.ldata), addr)
|
||||||
|
|
||||||
def displayEnum(self, form='%d'):
|
def displayEnum(self, form='%d', bitsize=None):
|
||||||
intval = self.integer()
|
intval = self.integer(bitsize)
|
||||||
dd = self.type.typeData().enumDisplay
|
dd = self.type.typeData().enumDisplay
|
||||||
if dd is None:
|
if dd is None:
|
||||||
return str(intval)
|
return str(intval)
|
||||||
@@ -2957,7 +2957,7 @@ class DumperBase:
|
|||||||
return self.detypedef().pointer()
|
return self.detypedef().pointer()
|
||||||
return self.extractInteger(self.dumper.ptrSize() * 8, True)
|
return self.extractInteger(self.dumper.ptrSize() * 8, True)
|
||||||
|
|
||||||
def integer(self):
|
def integer(self, bitsize=None):
|
||||||
if self.type.code == TypeCodeTypedef:
|
if self.type.code == TypeCodeTypedef:
|
||||||
return self.detypedef().integer()
|
return self.detypedef().integer()
|
||||||
elif self.type.code == TypeCodeBitfield:
|
elif self.type.code == TypeCodeBitfield:
|
||||||
@@ -2966,6 +2966,7 @@ class DumperBase:
|
|||||||
unsigned = self.type.name == 'unsigned' \
|
unsigned = self.type.name == 'unsigned' \
|
||||||
or self.type.name.startswith('unsigned ') \
|
or self.type.name.startswith('unsigned ') \
|
||||||
or self.type.name.find(' unsigned ') != -1
|
or self.type.name.find(' unsigned ') != -1
|
||||||
|
if bitsize is None:
|
||||||
bitsize = self.type.bitsize()
|
bitsize = self.type.bitsize()
|
||||||
return self.extractInteger(bitsize, unsigned)
|
return self.extractInteger(bitsize, unsigned)
|
||||||
|
|
||||||
|
@@ -492,15 +492,15 @@ def qdump__QEvent(d, value):
|
|||||||
with Children(d):
|
with Children(d):
|
||||||
# Add a sub-item with the event type.
|
# Add a sub-item with the event type.
|
||||||
with SubItem(d, '[type]'):
|
with SubItem(d, '[type]'):
|
||||||
(vtable, privateD, t) = value.split("pp{ushort}")
|
(vtable, privateD, t, flags) = value.split("pp{short}{short}")
|
||||||
event_type_name = "QEvent::Type"
|
event_type_name = d.qtNamespace() + "QEvent::Type"
|
||||||
type_value = t.cast(event_type_name)
|
type_value = t.cast(event_type_name)
|
||||||
d.putValue(type_value.displayEnum('0x%04x'))
|
d.putValue(type_value.displayEnum('0x%04x', bitsize=16))
|
||||||
d.putType(event_type_name)
|
d.putType(event_type_name)
|
||||||
d.putNumChild(0)
|
d.putNumChild(0)
|
||||||
|
|
||||||
# Show the rest of the class fields as usual.
|
# Show the rest of the class fields as usual.
|
||||||
d.putFields(value, dumpBase=True)
|
d.putFields(value)
|
||||||
|
|
||||||
def qdump__QKeyEvent(d, value):
|
def qdump__QKeyEvent(d, value):
|
||||||
# QEvent fields
|
# QEvent fields
|
||||||
@@ -531,9 +531,9 @@ def qdump__QKeyEvent(d, value):
|
|||||||
#data = d.encodeString(txt)
|
#data = d.encodeString(txt)
|
||||||
key_txt_utf8 = d.encodeStringUtf8(txt)
|
key_txt_utf8 = d.encodeStringUtf8(txt)
|
||||||
|
|
||||||
k_type_name = "Qt::Key"
|
k_type_name = d.qtNamespace() + "Qt::Key"
|
||||||
k_casted_to_enum_value = k.cast(k_type_name)
|
k_cast_to_enum_value = k.cast(k_type_name)
|
||||||
k_name = k_casted_to_enum_value.displayEnum()
|
k_name = k_cast_to_enum_value.displayEnum(bitsize=32)
|
||||||
matches = re.search(r'Key_(\w+)', k_name)
|
matches = re.search(r'Key_(\w+)', k_name)
|
||||||
if matches:
|
if matches:
|
||||||
k_name = matches.group(1)
|
k_name = matches.group(1)
|
||||||
@@ -587,8 +587,8 @@ def qdump__QKeyEvent(d, value):
|
|||||||
with Children(d):
|
with Children(d):
|
||||||
# Add a sub-item with the enum name and value.
|
# Add a sub-item with the enum name and value.
|
||||||
with SubItem(d, '[{}]'.format(k_type_name)):
|
with SubItem(d, '[{}]'.format(k_type_name)):
|
||||||
k_casted_to_enum_value = k.cast(k_type_name)
|
k_cast_to_enum_value = k.cast(k_type_name)
|
||||||
d.putValue(k_casted_to_enum_value.displayEnum('0x%04x'))
|
d.putValue(k_cast_to_enum_value.displayEnum('0x%04x', bitsize=32))
|
||||||
d.putType(k_type_name)
|
d.putType(k_type_name)
|
||||||
d.putNumChild(0)
|
d.putNumChild(0)
|
||||||
|
|
||||||
@@ -756,7 +756,7 @@ def qdump__QFlags(d, value):
|
|||||||
i = value.split('{int}')[0]
|
i = value.split('{int}')[0]
|
||||||
enumType = value.type[0]
|
enumType = value.type[0]
|
||||||
v = i.cast(enumType.name)
|
v = i.cast(enumType.name)
|
||||||
d.putValue(v.displayEnum('0x%04x'))
|
d.putValue(v.displayEnum('0x%04x', bitsize=32))
|
||||||
d.putNumChild(0)
|
d.putNumChild(0)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user