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_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
):
35 c
= buffer_ptr
.GetPointeeData(i
, 1).GetUnsignedInt8(e
, 0)
47 s
= s
+ '\\{:03o}'.format(c
)
51 s
= s
+ '\\u{:04x}'.format(c
)
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
):
81 c
= buffer_ptr
.GetPointeeData(i
, 1).GetUnsignedInt16(e
, 0)
93 s
= s
+ '\\{:03o}'.format(c
)
97 s
= s
+ '\\u{:04x}'.format(c
)
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: