tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / solenv / lldb / libreoffice / LO.py
blob22cb8c927184e0d8e009c21a3db53ac11dfefb06
1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # To use, add something like this to your ~/.lldbinit:
11 # command script import '~/lo/sim/solenv/lldb/libreoffice/LO.py'
13 import lldb
15 def rtl_String_summary(valobj, dict):
16 if valobj.TypeIsPointerType():
17 return rtl_String_summary(valobj.Dereference(), dict)
19 length = valobj.GetChildMemberWithName('length').GetValueAsUnsigned(0)
20 buffer = valobj.GetChildMemberWithName('buffer')
21 buffer_ptr = buffer.AddressOf()
23 # return '"' + buffer_ptr.GetPointeeData(0, length).GetString(lldb.SBError(), 0) + '"'
24 return sal_ascii_string(buffer_ptr, length)
26 def rtl_OString_summary(valobj, dict):
27 return rtl_String_summary(valobj.GetChildMemberWithName('pData'), dict)
29 def sal_ascii_string(buffer_ptr, length):
30 e = lldb.SBError()
32 s = '"'
33 i = 0
34 while i < length:
35 c = buffer_ptr.GetPointeeData(i, 1).GetUnsignedInt8(e, 0)
36 if c == ord('"'):
37 s = s + '\\"'
38 elif c == ord('\\'):
39 s = s + '\\\\'
40 elif c == ord('\n'):
41 s = s + '\\n'
42 elif c == ord('\r'):
43 s = s + '\\r'
44 elif c == ord('\t'):
45 s = s + '\\t'
46 elif c < ord(' '):
47 s = s + '\\{:03o}'.format(c)
48 elif c < 127:
49 s = s + chr(c)
50 else:
51 s = s + '\\u{:04x}'.format(c)
52 i = i + 1
53 s = s + '"'
55 return s
57 def rtl_uString_summary(valobj, dict):
58 # print "valobj = " + str(valobj) + ", valobj.GetData() = " + str(valobj.GetData()) + ", valobj.GetTypeName() = " + str(valobj.GetTypeName())
60 # As we don't use --skip-pointers when doing the "type summary add" for this function,
61 # the value to be printed might actually be a pointer to a rtl_uString. Weird, huh?
62 if valobj.TypeIsPointerType():
63 return rtl_uString_summary(valobj.Dereference(), dict)
65 length = valobj.GetChildMemberWithName('length').GetValueAsUnsigned(0)
66 buffer = valobj.GetChildMemberWithName('buffer')
68 buffer_ptr = buffer.AddressOf()
70 return sal_unicode_string(buffer_ptr, length)
72 def rtl_OUString_summary(valobj, dict):
73 return rtl_uString_summary(valobj.GetChildMemberWithName('pData'), dict)
75 def sal_unicode_string(buffer_ptr, length):
76 e = lldb.SBError()
78 s = '"'
79 i = 0
80 while i < length:
81 c = buffer_ptr.GetPointeeData(i, 1).GetUnsignedInt16(e, 0)
82 if c == ord('"'):
83 s = s + '\\"'
84 elif c == ord('\\'):
85 s = s + '\\\\'
86 elif c == ord('\n'):
87 s = s + '\\n'
88 elif c == ord('\r'):
89 s = s + '\\r'
90 elif c == ord('\t'):
91 s = s + '\\t'
92 elif c < ord(' '):
93 s = s + '\\{:03o}'.format(c)
94 elif c < 127:
95 s = s + chr(c)
96 else:
97 s = s + '\\u{:04x}'.format(c)
98 i = i + 1
99 s = s + '"'
101 return s
103 # Automatically install the above summary functions when this is loaded
104 def __lldb_init_module(debugger, dict):
105 debugger.HandleCommand("type summary add --skip-references --python-function LO.rtl_String_summary rtl_String")
106 debugger.HandleCommand("type summary add --skip-pointers --skip-references --python-function LO.rtl_OString_summary rtl::OString")
107 debugger.HandleCommand("type summary add --skip-references --python-function LO.rtl_uString_summary rtl_uString")
108 debugger.HandleCommand("type summary add --skip-pointers --skip-references --python-function LO.rtl_OUString_summary rtl::OUString")
110 # vim:set shiftwidth=4 softtabstop=4 expandtab: