Debugger: Change/improve LLDB display of enums in some cases

This fixes the Internal2, EnumFlags and EnumInClass tests on Linux.

The values lose now the previously hand-crafted Class:: prefixes,
but the context is clear from the type column, and it's what LLDB
developers (and potentially users) consider normal.

Change-Id: I09e41f7b4fb4f078ef3f535fe650d06e7c2a0331
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
hjk
2020-12-11 08:42:58 +01:00
parent 0a20b8e7de
commit d4ed07eb87
2 changed files with 17 additions and 16 deletions

View File

@@ -219,16 +219,14 @@ class Dumper(DumperBase):
if code == lldb.eTypeClassEnumeration:
intval = nativeValue.GetValueAsSigned()
if hasattr(nativeType, 'get_enum_members_array'):
for enumMember in nativeType.get_enum_members_array():
# Even when asking for signed we get unsigned with LLDB 3.8.
diff = enumMember.GetValueAsSigned() - intval
mask = (1 << nativeType.GetByteSize() * 8) - 1
if diff & mask == 0:
path = nativeType.GetName().split('::')
path[-1] = enumMember.GetName()
val.ldisplay = '%s (%d)' % ('::'.join(path), intval)
val.ldisplay = '%d' % intval
display = str(nativeValue).split(' = ')
if len(display) == 2:
verbose = display[1]
if '|' in verbose and not verbose.startswith('('):
verbose = '(' + verbose + ')'
else:
verbose = intval
val.ldisplay = '%s (%d)' % (verbose, intval)
elif code in (lldb.eTypeClassComplexInteger, lldb.eTypeClassComplexFloat):
val.ldisplay = str(nativeValue.GetValue())
#elif code == lldb.eTypeClassArray:

View File

@@ -5905,7 +5905,7 @@ void tst_Dumpers::dumper_data()
"Flags fone = one;\n"
"Flags fthree = (Flags)(one|two);\n"
"Flags fmixed = (Flags)(two|8);\n"
"Flags fbad = (Flags)(24);",
"Flags fbad = (Flags)(8);",
"&fone, &fthree, &fmixed, &fbad")
@@ -5913,8 +5913,10 @@ void tst_Dumpers::dumper_data()
+ Check("fone", "one (1)", "Flags")
+ Check("fthree", "(one | two) (3)", "Flags")
+ Check("fmixed", "(two | unknown: 8) (10)", "Flags")
+ Check("fbad", "(unknown: 24) (24)", "Flags");
// There are optional 'unknown:' prefixes and possibly hex
// displays for the unknown flags.
+ Check("fmixed", ValuePattern("(two \\| .*8) (10)"), "Flags")
+ Check("fbad", ValuePattern(".*8.* (.*8)"), "Flags");
QTest::newRow("EnumInClass")
@@ -5933,9 +5935,10 @@ void tst_Dumpers::dumper_data()
+ NoCdbEngine
+ Check("e.e1", "(E::b1 | E::c1) (3)", "E::Enum1")
+ Check("e.e2", "(E::b2 | E::c2) (3)", "E::Enum2")
+ Check("e.e3", "(E::b3 | E::c3) (3)", "E::Enum3");
// GDB prefixes with E::, LLDB not.
+ Check("e.e1", ValuePattern("(.*b1 \\| .*c1) (3)"), "E::Enum1")
+ Check("e.e2", ValuePattern("(.*b2 \\| .*c2) (3)"), "E::Enum2")
+ Check("e.e3", ValuePattern("(.*b3 \\| .*c3) (3)"), "E::Enum3");
QTest::newRow("QSizePolicy")