xref: /aoo42x/main/solenv/inc/lldb4aoo.py (revision 0d72dfe8)
1f174ccd1SHerbert Dürr# to activate run the command below when inside lldb
2f174ccd1SHerbert Dürr#   command script import /tools/lldb4aoo.py
3f174ccd1SHerbert Dürr# or add the line to ~/.lldbinit to always activate it
4f174ccd1SHerbert Dürr
5f174ccd1SHerbert Dürrdef __lldb_init_module( dbg, dict):
6f174ccd1SHerbert Dürr	# the list of AOO specific types
7f174ccd1SHerbert Dürr	aoo_types = ['rtl_String', 'rtl::OString', 'rtl_uString', 'rtl::OUString',
8f174ccd1SHerbert Dürr		    '_ByteStringData', '_UniStringData', 'ByteString', 'UniString']
9f174ccd1SHerbert Dürr	# register a helper function for each type
10f174ccd1SHerbert Dürr	for t in aoo_types:
11f174ccd1SHerbert Dürr		f = 'getinfo_for_' + t.replace( '::', '_')
12f174ccd1SHerbert Dürr		if f in globals():
13f174ccd1SHerbert Dürr			dbg.HandleCommand( 'type summary add %s -F %s.%s' % (t,__name__,f))
14f174ccd1SHerbert Dürr		else:
15f174ccd1SHerbert Dürr			print( 'AOO-LLDB helper function "%s" is not yet defined: "%s" types cannot be displayed properly!' % (f,t))
16f174ccd1SHerbert Dürr
17f174ccd1SHerbert Dürr	# perform some goodies if the process is ready to run or already running
18f174ccd1SHerbert Dürr	if dbg.GetNumTargets() > 0:
19f174ccd1SHerbert Dürr		# the list of interesting function breakpoints
20f174ccd1SHerbert Dürr		aoo_breakfn = ['main', '__cxa_call_unexpected', 'objc_exception_throw']
21f174ccd1SHerbert Dürr		aoo_breakfn += ['__cxa_throw']
22f174ccd1SHerbert Dürr		# register the function breakpoints
23f174ccd1SHerbert Dürr		for t in aoo_breakfn:
24f174ccd1SHerbert Dürr			dbg.HandleCommand( 'breakpoint set -n ' + t)
25f174ccd1SHerbert Dürr
26f174ccd1SHerbert Dürr
27f174ccd1SHerbert Dürr# definitions for individual LLDB type summary helpers
28f174ccd1SHerbert Dürr
29f174ccd1SHerbert Dürrdef getinfo_for_rtl_String( valobj, dict):
30f174ccd1SHerbert Dürr	while valobj.TypeIsPointerType():
31f174ccd1SHerbert Dürr		valobj = valobj.Dereference()
32f174ccd1SHerbert Dürr	r = valobj.GetChildMemberWithName('refCount').GetValueAsSigned()
33f174ccd1SHerbert Dürr	l = valobj.GetChildMemberWithName('length').GetValueAsSigned()
34f174ccd1SHerbert Dürr	a = valobj.GetChildMemberWithName('buffer').AddressOf().GetPointeeData(0,l)
35f174ccd1SHerbert Dürr	s = ''.join([chr(x) for x in a.uint8s])
36f174ccd1SHerbert Dürr	return '{refs=%d, len=%d, str="%s"}'%(r,l,s)
37f174ccd1SHerbert Dürr	return info
38f174ccd1SHerbert Dürr
39f174ccd1SHerbert Dürrdef getinfo_for_rtl_uString( valobj, dict):
40f174ccd1SHerbert Dürr	while valobj.TypeIsPointerType():
41f174ccd1SHerbert Dürr		valobj = valobj.Dereference()
42f174ccd1SHerbert Dürr	r = valobj.GetChildMemberWithName('refCount').GetValueAsSigned()
43f174ccd1SHerbert Dürr	l = valobj.GetChildMemberWithName('length').GetValueAsSigned()
44f174ccd1SHerbert Dürr	a = valobj.GetChildMemberWithName('buffer').AddressOf().GetPointeeData(0,l)
45f174ccd1SHerbert Dürr	s = (u''.join([unichr(x) for x in a.uint16s])).encode('utf-8')
46f174ccd1SHerbert Dürr	return '{refs=%d, len=%d, str="%s"}'%(r,l,s)
47f174ccd1SHerbert Dürr
48*0d72dfe8SHerbert Dürrdef getinfo_for__ByteStringData( valobj, dict):
49f174ccd1SHerbert Dürr	while valobj.TypeIsPointerType():
50f174ccd1SHerbert Dürr		valobj = valobj.Dereference()
51f174ccd1SHerbert Dürr	r = valobj.GetChildMemberWithName('mnRefCount').GetValueAsSigned()
52f174ccd1SHerbert Dürr	l = valobj.GetChildMemberWithName('mnLen').GetValueAsSigned()
53f174ccd1SHerbert Dürr	a = valobj.GetChildMemberWithName('maStr').AddressOf().GetPointeeData(0,l)
54f174ccd1SHerbert Dürr	s = ''.join([chr(x) for x in a.uint8s])
55f174ccd1SHerbert Dürr	return '{refs=%d, len=%d, str="%s"}'%(r,l,s)
56f174ccd1SHerbert Dürr
57*0d72dfe8SHerbert Dürrdef getinfo_for__UniStringData( valobj, dict):
58f174ccd1SHerbert Dürr	while valobj.TypeIsPointerType():
59f174ccd1SHerbert Dürr		valobj = valobj.Dereference()
60f174ccd1SHerbert Dürr	r = valobj.GetChildMemberWithName('mnRefCount').GetValueAsSigned()
61f174ccd1SHerbert Dürr	l = valobj.GetChildMemberWithName('mnLen').GetValueAsSigned()
62f174ccd1SHerbert Dürr	a = valobj.GetChildMemberWithName('maStr').AddressOf().GetPointeeData(0,l)
63f174ccd1SHerbert Dürr	s = (u''.join([unichr(x) for x in a.uint16s])).encode('utf-8')
64f174ccd1SHerbert Dürr	return '{refs=%d, len=%d, str="%s"}'%(r,l,s)
65f174ccd1SHerbert Dürr
66f174ccd1SHerbert Dürr
67f174ccd1SHerbert Dürrdef getinfo_for_rtl_OString( valobj, dict):
68f174ccd1SHerbert Dürr	d = valobj.GetChildMemberWithName('pData')
69f174ccd1SHerbert Dürr	return d.Dereference()
70f174ccd1SHerbert Dürr
71f174ccd1SHerbert Dürrdef getinfo_for_rtl_OUString( valobj, dict):
72f174ccd1SHerbert Dürr	d = valobj.GetChildMemberWithName('pData')
73f174ccd1SHerbert Dürr	return d.Dereference()
74f174ccd1SHerbert Dürr
75*0d72dfe8SHerbert Dürrdef getinfo_for_ByteString( valobj, dict):
76f174ccd1SHerbert Dürr	d = valobj.GetChildMemberWithName('mpData')
77f174ccd1SHerbert Dürr	return d.Dereference()
78f174ccd1SHerbert Dürr
79*0d72dfe8SHerbert Dürrdef getinfo_for_UniString( valobj, dict):
80f174ccd1SHerbert Dürr	d = valobj.GetChildMemberWithName('mpData')
81f174ccd1SHerbert Dürr	return d.Dereference()
82f174ccd1SHerbert Dürr
83