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'
15 def rtl_uString_summary(valobj
, dict):
16 # print "valobj = " + str(valobj) + ", valobj.GetData() = " + str(valobj.GetData()) + ", valobj.GetTypeName() = " + str(valobj.GetTypeName())
18 # As we don't use --skip-pointers when doing the "type summary add" for this function,
19 # the value to be printed might actually be a pointer to a rtl_uString. Weird, huh?
20 if valobj
.TypeIsPointerType():
21 return rtl_uString_summary(valobj
.Dereference(), dict)
23 length
= valobj
.GetChildMemberWithName('length').GetValueAsUnsigned(0)
24 buffer = valobj
.GetChildMemberWithName('buffer')
26 buffer_ptr
= buffer.AddressOf();
28 return sal_unicode_string(buffer_ptr
, length
)
30 def rtl_OUString_summary(valobj
, dict):
31 return rtl_uString_summary(valobj
.GetChildMemberWithName('pData'), dict)
33 def UniStringData_summary(valobj
, dict):
34 if valobj
.TypeIsPointerType():
35 return UniStringData_summary(valobj
.Dereference(), dict)
37 length
= valobj
.GetChildMemberWithName('mnLen').GetValueAsUnsigned(0)
38 buffer = valobj
.GetChildMemberWithName('maStr')
40 buffer_ptr
= buffer.AddressOf();
42 return sal_unicode_string(buffer_ptr
, length
)
44 def String_summary(valobj
, dict):
45 return UniStringData_summary(valobj
.GetChildMemberWithName('mpData'), dict)
47 def sal_unicode_string(buffer_ptr
, length
):
53 c
= buffer_ptr
.GetPointeeData(i
, 1).GetUnsignedInt16(e
, 0)
65 s
= s
+ '\\{:03o}'.format(c
)
69 s
= s
+ '\\u{:04x}'.format(c
)
75 # Automatically install the above summary functions when this is loaded
76 def __lldb_init_module(debugger
, dict):
77 debugger
.HandleCommand("type summary add --skip-references --python-function LO.rtl_uString_summary rtl_uString")
78 debugger
.HandleCommand("type summary add --skip-pointers --skip-references --python-function LO.rtl_OUString_summary rtl::OUString")
79 debugger
.HandleCommand("type summary add --skip-references --python-function LO.UniStringData_summary UniStringData")
80 debugger
.HandleCommand("type summary add --skip-pointers --skip-references --python-function LO.String_summary String")
82 # vim:set shiftwidth=4 softtabstop=4 expandtab: