-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathqstring.py
More file actions
22 lines (19 loc) · 872 Bytes
/
qstring.py
File metadata and controls
22 lines (19 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import lldb
def utf16string_summary(value, *rest):
d = value.GetChildMemberWithName("d")
length = d.GetChildMemberWithName("size").GetValueAsSigned()
offset = d.GetChildMemberWithName("offset").GetValueAsSigned()
address = d.GetValueAsUnsigned() + offset
if length == 0:
return '""'
error = lldb.SBError()
# UTF-16, so we multiply length by 2
bytes = value.GetProcess().ReadMemory(address, length * 2, error)
if bytes is None:
return '""'
return '"%s"' % (bytes.decode('utf-16').encode('utf-8'))
def __lldb_init_module(debugger, *rest):
print "registering QString"
summary = lldb.SBTypeSummary.CreateWithFunctionName("qstring.utf16string_summary")
summary.SetOptions(lldb.eTypeOptionHideChildren)
debugger.GetDefaultCategory().AddTypeSummary( lldb.SBTypeNameSpecifier("QString", False), summary )