Changeset View
Changeset View
Standalone View
Standalone View
debuggers/lldb/formatters/qt.py
Show First 20 Lines • Show All 147 Lines • ▼ Show 20 Line(s) | 146 | if error.Success(): | |||
---|---|---|---|---|---|
148 | return content + tooLarge, pointer, length | 148 | return content + tooLarge, pointer, length | ||
149 | except: | 149 | except: | ||
150 | pass | 150 | pass | ||
151 | return None, 0, 0 | 151 | return None, 0, 0 | ||
152 | 152 | | |||
153 | 153 | | |||
154 | def QStringSummaryProvider(valobj, internal_dict): | 154 | def QStringSummaryProvider(valobj, internal_dict): | ||
155 | if valobj.IsValid(): | 155 | if valobj.IsValid(): | ||
156 | content = valobj.GetChildMemberWithName('(content)') | 156 | # content = valobj.GetChildMemberWithName('(content)') | ||
157 | if content.IsValid(): | 157 | # if content.IsValid(): | ||
158 | summary = content.GetSummary() | 158 | # try: | ||
159 | if summary is not None: | 159 | # error = lldb.SBError() | ||
160 | return summary | 160 | # rawprintable = content.GetData().GetString(error, 0) | ||
161 | # if error.Success(): | ||||
162 | # printable = rawprintable.decode() | ||||
163 | # return quote(printable) | ||||
164 | # except: | ||||
165 | # pass | ||||
166 | | ||||
167 | # FIXME: there's no reliable way to pass data from formatter to | ||||
168 | # summary provider currently. So directly pull data from inferior | ||||
169 | | ||||
161 | # Something wrong with synthetic provider, or | 170 | # Something wrong with synthetic provider, or | ||
162 | # no synthetic provider installed, get the content by ourselves | 171 | # no synthetic provider installed, get the content by ourselves | ||
163 | printable, _, _ = printableQString(valobj) | 172 | printable, _, _ = printableQString(valobj) | ||
164 | if printable is not None: | 173 | if printable is not None: | ||
165 | return quote(printable) | 174 | return quote(printable) | ||
166 | return '<Invalid>' | 175 | return '<Invalid>' | ||
167 | 176 | | |||
168 | 177 | | |||
Show All 11 Lines | 186 | def _update(self): | |||
180 | self._num_children = strLength | 189 | self._num_children = strLength | ||
181 | 190 | | |||
182 | if printable is not None: | 191 | if printable is not None: | ||
183 | for idx in range(0, strLength): | 192 | for idx in range(0, strLength): | ||
184 | var = self.valobj.CreateValueFromAddress('[{}]'.format(idx), | 193 | var = self.valobj.CreateValueFromAddress('[{}]'.format(idx), | ||
185 | dataPointer + idx * self._qchar_size, | 194 | dataPointer + idx * self._qchar_size, | ||
186 | self._qchar_type) | 195 | self._qchar_type) | ||
187 | self._addChild(var) | 196 | self._addChild(var) | ||
188 | quoted_printable_expr = quote(printable) | 197 | # self._addChild(('(content)', quote(printable)), hidden=True) | ||
189 | self._addChild(('(content)', quoted_printable_expr), hidden=True) | | |||
190 | 198 | | |||
191 | 199 | | |||
192 | def QCharSummaryProvider(valobj, internal_dict): | 200 | def QCharSummaryProvider(valobj, internal_dict): | ||
193 | if valobj.IsValid(): | 201 | if valobj.IsValid(): | ||
194 | ucs = valobj.GetChildMemberWithName('ucs').GetValueAsUnsigned(0) | 202 | ucs = valobj.GetChildMemberWithName('ucs').GetValueAsUnsigned(0) | ||
195 | if ucs == 39: | 203 | if ucs == 39: | ||
196 | # for '\'', python returns "'" rather than '\'' | 204 | # for '\'', python returns "'" rather than '\'' | ||
197 | return u"'\\''" | 205 | return u"'\\''" | ||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | 296 | if printable is not None: | |||
289 | for idx in range(0, self._num_children): | 297 | for idx in range(0, self._num_children): | ||
290 | var = self.valobj.CreateValueFromAddress('[{}]'.format(idx), | 298 | var = self.valobj.CreateValueFromAddress('[{}]'.format(idx), | ||
291 | dataPointer + idx * self._char_size, | 299 | dataPointer + idx * self._char_size, | ||
292 | self._char_type) | 300 | self._char_type) | ||
293 | self._addChild(var) | 301 | self._addChild(var) | ||
294 | 302 | | |||
295 | # first replace " to \", and suround by "", no need to escape other things which | 303 | # first replace " to \", and suround by "", no need to escape other things which | ||
296 | # are handled in printableQByteArray. | 304 | # are handled in printableQByteArray. | ||
297 | printable = '"{}"'.format(printable.replace('"', '\\"')) | 305 | printable = b'"{}"'.format(printable.replace(b'"', b'\\"')) | ||
298 | # then we need to quote again, as the quoted_printable_expr is parsed by the lldb to | 306 | self._addChild(('(content)', printable), hidden=True) | ||
299 | # produce the final content, which removes one level of quotation | | |||
300 | quoted_printable_expr = quote(printable) | | |||
301 | self._addChild(('(content)', quoted_printable_expr), hidden=True) | | |||
302 | 307 | | |||
303 | 308 | | |||
304 | class BasicListFormatter(HiddenMemberProvider): | 309 | class BasicListFormatter(HiddenMemberProvider): | ||
305 | """A lldb synthetic provider for QList like types""" | 310 | """A lldb synthetic provider for QList like types""" | ||
306 | 311 | | |||
307 | def __init__(self, valobj, internal_dict, item_typename): | 312 | def __init__(self, valobj, internal_dict, item_typename): | ||
308 | super(BasicListFormatter, self).__init__(valobj, internal_dict) | 313 | super(BasicListFormatter, self).__init__(valobj, internal_dict) | ||
309 | if item_typename is None: | 314 | if item_typename is None: | ||
▲ Show 20 Lines • Show All 590 Lines • ▼ Show 20 Line(s) | 898 | def _update(self): | |||
900 | julianDay = self.valobj.GetChildMemberWithName('jd') | 905 | julianDay = self.valobj.GetChildMemberWithName('jd') | ||
901 | self._addChild(julianDay) | 906 | self._addChild(julianDay) | ||
902 | 907 | | |||
903 | pydate = self.parse(julianDay.GetValueAsUnsigned(0)) | 908 | pydate = self.parse(julianDay.GetValueAsUnsigned(0)) | ||
904 | if pydate is None: | 909 | if pydate is None: | ||
905 | return | 910 | return | ||
906 | # (ISO) | 911 | # (ISO) | ||
907 | iso_str = pydate.isoformat().decode().__repr__()[2:-1] | 912 | iso_str = pydate.isoformat().decode().__repr__()[2:-1] | ||
908 | self._addChild(('(ISO)', quote(iso_str))) | 913 | self._addChild(('(ISO)', iso_str)) | ||
909 | 914 | | |||
910 | # (Locale) | 915 | # (Locale) | ||
911 | locale_encoding = [locale.getlocale()[1]] | 916 | locale_encoding = [locale.getlocale()[1]] | ||
912 | if locale_encoding[0] is None: | 917 | if locale_encoding[0] is None: | ||
913 | locale_encoding = [] | 918 | locale_encoding = [] | ||
914 | locale_str = pydate.strftime('%x').decode(*locale_encoding).__repr__()[2:-1] | 919 | locale_str = pydate.strftime('%x').decode(*locale_encoding).__repr__()[2:-1] | ||
915 | self._addChild(('(Locale)', quote(locale_str))) | 920 | self._addChild(('(Locale)', locale_str)) | ||
916 | 921 | | |||
917 | 922 | | |||
918 | def QDateSummaryProvider(valobj, internal_dict): | 923 | def QDateSummaryProvider(valobj, internal_dict): | ||
919 | if valobj.IsValid(): | 924 | if valobj.IsValid(): | ||
920 | content = valobj.GetChildMemberWithName('(Locale)') | 925 | content = valobj.GetChildMemberWithName('(Locale)') | ||
921 | if content.IsValid(): | 926 | if content.IsValid(): | ||
922 | summary = content.GetSummary() | 927 | summary = content.GetSummary() | ||
923 | if summary is not None: | 928 | if summary is not None: | ||
Show All 38 Lines | 960 | def _update(self): | |||
962 | mds = self.valobj.GetChildMemberWithName('mds') | 967 | mds = self.valobj.GetChildMemberWithName('mds') | ||
963 | self._addChild(mds) | 968 | self._addChild(mds) | ||
964 | 969 | | |||
965 | pytime = self.parse(mds.GetValueAsUnsigned(0)) | 970 | pytime = self.parse(mds.GetValueAsUnsigned(0)) | ||
966 | if pytime is None: | 971 | if pytime is None: | ||
967 | return | 972 | return | ||
968 | # (ISO) | 973 | # (ISO) | ||
969 | iso_str = pytime.isoformat().decode().__repr__()[2:-1] | 974 | iso_str = pytime.isoformat().decode().__repr__()[2:-1] | ||
970 | self._addChild(('(ISO)', quote(iso_str))) | 975 | self._addChild(('(ISO)', iso_str)) | ||
971 | 976 | | |||
972 | # (Locale) | 977 | # (Locale) | ||
973 | locale_encoding = [locale.getlocale()[1]] | 978 | locale_encoding = [locale.getlocale()[1]] | ||
974 | if locale_encoding[0] is None: | 979 | if locale_encoding[0] is None: | ||
975 | locale_encoding = [] | 980 | locale_encoding = [] | ||
976 | locale_str = pytime.strftime('%X').decode(*locale_encoding).__repr__()[2:-1] | 981 | locale_str = pytime.strftime('%X').decode(*locale_encoding).__repr__()[2:-1] | ||
977 | self._addChild(('(Locale)', quote(locale_str))) | 982 | self._addChild(('(Locale)', locale_str)) | ||
978 | 983 | | |||
979 | 984 | | |||
980 | def QTimeSummaryProvider(valobj, internal_dict): | 985 | def QTimeSummaryProvider(valobj, internal_dict): | ||
981 | if valobj.IsValid(): | 986 | if valobj.IsValid(): | ||
982 | content = valobj.GetChildMemberWithName('(Locale)') | 987 | content = valobj.GetChildMemberWithName('(Locale)') | ||
983 | if content.IsValid(): | 988 | if content.IsValid(): | ||
984 | summary = content.GetSummary() | 989 | summary = content.GetSummary() | ||
985 | if summary is not None: | 990 | if summary is not None: | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 1022 | def _update(self): | |||
1028 | 1033 | | |||
1029 | # time tuple in local time and utc time | 1034 | # time tuple in local time and utc time | ||
1030 | local_tt = self.parse(time_t.GetValueAsUnsigned(0)) | 1035 | local_tt = self.parse(time_t.GetValueAsUnsigned(0)) | ||
1031 | utc_tt = self.parse(time_t.GetValueAsUnsigned(0), utc=True) | 1036 | utc_tt = self.parse(time_t.GetValueAsUnsigned(0), utc=True) | ||
1032 | 1037 | | |||
1033 | # (ISO) | 1038 | # (ISO) | ||
1034 | formatted = time.strftime('%Y-%m-%d %H:%M:%S', utc_tt).decode(*locale_encoding).__repr__() | 1039 | formatted = time.strftime('%Y-%m-%d %H:%M:%S', utc_tt).decode(*locale_encoding).__repr__() | ||
1035 | formatted = formatted[2:-1] | 1040 | formatted = formatted[2:-1] | ||
1036 | self._addChild(('(ISO)', quote(formatted))) | 1041 | self._addChild(('(ISO)', formatted)) | ||
1037 | 1042 | | |||
1038 | def locale_fmt(name, tt): | 1043 | def locale_fmt(name, tt): | ||
1039 | formatted = time.strftime('%c', tt).decode(*locale_encoding).__repr__()[2:-1] | 1044 | formatted = time.strftime('%c', tt).decode(*locale_encoding).__repr__()[2:-1] | ||
1040 | self._addChild((name, quote(formatted))) | 1045 | self._addChild((name, formatted)) | ||
1041 | 1046 | | |||
1042 | # (Locale) | 1047 | # (Locale) | ||
1043 | locale_fmt('(Locale)', local_tt) | 1048 | locale_fmt('(Locale)', local_tt) | ||
1044 | 1049 | | |||
1045 | # (UTC) | 1050 | # (UTC) | ||
1046 | locale_fmt('(UTC)', utc_tt) | 1051 | locale_fmt('(UTC)', utc_tt) | ||
1047 | 1052 | | |||
1048 | # FIXME: Calling functions returns incorrect SBValue for complex type in lldb | 1053 | # FIXME: Calling functions returns incorrect SBValue for complex type in lldb | ||
Show All 13 Lines | 1066 | if valobj.IsValid(): | |||
1062 | content = valobj.GetChildMemberWithName('(Locale)') | 1067 | content = valobj.GetChildMemberWithName('(Locale)') | ||
1063 | if content.IsValid(): | 1068 | if content.IsValid(): | ||
1064 | summary = content.GetSummary() | 1069 | summary = content.GetSummary() | ||
1065 | if summary is not None: | 1070 | if summary is not None: | ||
1066 | return summary | 1071 | return summary | ||
1067 | # No synthetic provider installed, get the content by ourselves | 1072 | # No synthetic provider installed, get the content by ourselves | ||
1068 | pytime = QDateTimeFormatter.parse(QDateTimeFormatter.getdata(valobj).GetValueAsUnsigned(0)) | 1073 | pytime = QDateTimeFormatter.parse(QDateTimeFormatter.getdata(valobj).GetValueAsUnsigned(0)) | ||
1069 | if pytime is not None: | 1074 | if pytime is not None: | ||
1070 | return pytime.isoformat().decode().__repr__()[2:-1] | 1075 | formatted = time.strftime('%Y-%m-%d %H:%M:%S', pytime).decode().__repr__() | ||
1076 | formatted = formatted[2:-1] | ||||
1077 | return formatted | ||||
1071 | return None | 1078 | return None | ||
1072 | 1079 | | |||
1073 | 1080 | | |||
1074 | class QUrlFormatter(HiddenMemberProvider): | 1081 | class QUrlFormatter(HiddenMemberProvider): | ||
1075 | """docstring for QUrlFormatter""" | 1082 | """docstring for QUrlFormatter""" | ||
1076 | def __init__(self, valobj, internal_dict): | 1083 | def __init__(self, valobj, internal_dict): | ||
1077 | super(QUrlFormatter, self).__init__(valobj, internal_dict) | 1084 | super(QUrlFormatter, self).__init__(valobj, internal_dict) | ||
1078 | 1085 | | |||
Show All 22 Lines | 1093 | def constructEncoded(port, scheme, username, password, host, path, query, fragment): | |||
1101 | 1108 | | |||
1102 | url = urlunsplit((printableQString(scheme)[0], | 1109 | url = urlunsplit((printableQString(scheme)[0], | ||
1103 | netloc, | 1110 | netloc, | ||
1104 | printableQString(path)[0], | 1111 | printableQString(path)[0], | ||
1105 | printableQString(query)[0], | 1112 | printableQString(query)[0], | ||
1106 | printableQString(fragment)[0])) | 1113 | printableQString(fragment)[0])) | ||
1107 | encoded = None | 1114 | encoded = None | ||
1108 | if len(url) > 0: | 1115 | if len(url) > 0: | ||
1109 | encoded = ('(encoded)', quote(url)) | 1116 | encoded = ('(encoded)', url) | ||
1110 | return (encoded, port, scheme, username, password, host, path, query, fragment) | 1117 | return (encoded, port, scheme, username, password, host, path, query, fragment) | ||
1111 | 1118 | | |||
1112 | # try if there's debug info available | 1119 | # try if there's debug info available | ||
1113 | port = dataobj.GetChildMemberWithName('port') | 1120 | port = dataobj.GetChildMemberWithName('port') | ||
1114 | if port.IsValid(): | 1121 | if port.IsValid(): | ||
1115 | scheme = dataobj.GetChildMemberWithName('scheme') | 1122 | scheme = dataobj.GetChildMemberWithName('scheme') | ||
1116 | username = dataobj.GetChildMemberWithName('userName') | 1123 | username = dataobj.GetChildMemberWithName('userName') | ||
1117 | password = dataobj.GetChildMemberWithName('password') | 1124 | password = dataobj.GetChildMemberWithName('password') | ||
Show All 36 Lines | |||||
1154 | 1161 | | |||
1155 | def parseQt4Data(self, dataobj): | 1162 | def parseQt4Data(self, dataobj): | ||
1156 | def parseComponents(encodedobj): | 1163 | def parseComponents(encodedobj): | ||
1157 | url, _, _ = printableQByteArray(encodedobj) | 1164 | url, _, _ = printableQByteArray(encodedobj) | ||
1158 | if url is None: | 1165 | if url is None: | ||
1159 | return (None,) * 9 | 1166 | return (None,) * 9 | ||
1160 | res = urlsplit(url) | 1167 | res = urlsplit(url) | ||
1161 | port = dataobj.CreateValueFromExpression('(port)', str(res.port if res.port is not None else -1)) | 1168 | port = dataobj.CreateValueFromExpression('(port)', str(res.port if res.port is not None else -1)) | ||
1162 | scheme = ('(scheme)', quote(res.scheme)) | 1169 | scheme = ('(scheme)', res.scheme) | ||
1163 | username = ('(username)', quote(res.username if res.username is not None else '')) | 1170 | username = ('(username)', res.username if res.username is not None else '') | ||
1164 | password = ('(password)', quote(res.password if res.password is not None else '')) | 1171 | password = ('(password)', res.password if res.password is not None else '') | ||
1165 | host = ('(host)', quote(res.hostname if res.hostname is not None else '')) | 1172 | host = ('(host)', res.hostname if res.hostname is not None else '') | ||
1166 | path = ('(path)', quote(res.path)) | 1173 | path = ('(path)', res.path) | ||
1167 | query = ('(query)', quote(res.query)) | 1174 | query = ('(query)', res.query) | ||
1168 | fragment = ('(fragment)', quote(res.fragment)) | 1175 | fragment = ('(fragment)', res.fragment) | ||
1169 | encoded = ('(encoded)', quote(url)) | 1176 | encoded = ('(encoded)', url) | ||
1170 | return (encoded, port, scheme, username, password, host, path, query, fragment) | 1177 | return (encoded, port, scheme, username, password, host, path, query, fragment) | ||
1171 | 1178 | | |||
1172 | encodedOriginal = dataobj.GetChildMemberWithName('encodedOriginal') | 1179 | encodedOriginal = dataobj.GetChildMemberWithName('encodedOriginal') | ||
1173 | if encodedOriginal.IsValid(): | 1180 | if encodedOriginal.IsValid(): | ||
1174 | return parseComponents(encodedOriginal) | 1181 | return parseComponents(encodedOriginal) | ||
1175 | 1182 | | |||
1176 | # if no debug information is available for Qt, try guessing the correct address | 1183 | # if no debug information is available for Qt, try guessing the correct address | ||
1177 | # problem with this is that if QUrlPrivate members get changed, this fails | 1184 | # problem with this is that if QUrlPrivate members get changed, this fails | ||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |