From 6f9fe35b91440a1e139072783bbe57ed9dda7923 Mon Sep 17 00:00:00 2001 From: Nikita Kobzev Date: Sat, 18 May 2024 22:07:12 +0300 Subject: [PATCH] QString and QByteArray render improvements --- python/lldb/qt6renderer/qarraydatapointer.py | 3 +++ python/lldb/qt6renderer/qbytearray.py | 2 +- python/lldb/qt6renderer/qstring.py | 9 +++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/python/lldb/qt6renderer/qarraydatapointer.py b/python/lldb/qt6renderer/qarraydatapointer.py index d1c8d3c..d7cc060 100644 --- a/python/lldb/qt6renderer/qarraydatapointer.py +++ b/python/lldb/qt6renderer/qarraydatapointer.py @@ -54,6 +54,9 @@ def update(self): self._values[self._num_data_fields] = size self._bump_field_counter() + if size.GetValueAsSigned() <= 0: + return False + d_d = d.GetChildMemberWithName('d') if d_d.GetValueAsUnsigned(): diff --git a/python/lldb/qt6renderer/qbytearray.py b/python/lldb/qt6renderer/qbytearray.py index 17c3481..ceeaaf5 100644 --- a/python/lldb/qt6renderer/qbytearray.py +++ b/python/lldb/qt6renderer/qbytearray.py @@ -17,7 +17,7 @@ def qbytearray_string_summary(valobj: SBValue): return '""' size = sb_size.GetValueAsSigned() - if not size: + if size <= 0: return '""' sb_raw = valobj.GetChildMemberWithName(QArrayDataPointerSynth.PROP_RAW_DATA) diff --git a/python/lldb/qt6renderer/qstring.py b/python/lldb/qt6renderer/qstring.py index 59231ee..525d4f7 100644 --- a/python/lldb/qt6renderer/qstring.py +++ b/python/lldb/qt6renderer/qstring.py @@ -8,14 +8,19 @@ def qstring_summary_no_quotes(valobj: SBValue) -> str: return '' size = sb_size.GetValueAsSigned() - if not size: + if size <= 0: return '' sb_raw = valobj.GetChildMemberWithName(QArrayDataPointerSynth.PROP_RAW_DATA) if not sb_raw: return '' - data = sb_raw.GetPointeeData(0, size).sint16s + # QString is char16_t in the C++ code. + # But Python goes wild when string bytes have higher order values, like 65533, + # because sint16 of such values get interpreted as negative numbers and Python + # is unable to convert them to chars. + + data = sb_raw.GetPointeeData(0, size).uint16s result = '' for code in data: