Author: hdu
Date: Wed Feb 20 14:36:06 2013
New Revision: 1448186

URL: http://svn.apache.org/r1448186
Log:
add LLDB helper script to allow more enjoyable AOO debugging sessions

Added:
    openoffice/trunk/main/solenv/inc/lldb4aoo.py

Added: openoffice/trunk/main/solenv/inc/lldb4aoo.py
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/solenv/inc/lldb4aoo.py?rev=1448186&view=auto
==============================================================================
--- openoffice/trunk/main/solenv/inc/lldb4aoo.py (added)
+++ openoffice/trunk/main/solenv/inc/lldb4aoo.py Wed Feb 20 14:36:06 2013
@@ -0,0 +1,82 @@
+# to activate run the command below when inside lldb
+#   command script import /tools/lldb4aoo.py
+# or add the line to ~/.lldbinit to always activate it
+
+def __lldb_init_module( dbg, dict):
+       # the list of AOO specific types
+       aoo_types = ['rtl_String', 'rtl::OString', 'rtl_uString', 
'rtl::OUString',
+                   '_ByteStringData', '_UniStringData', 'ByteString', 
'UniString']
+       # register a helper function for each type
+       for t in aoo_types:
+               f = 'getinfo_for_' + t.replace( '::', '_')
+               if f in globals():
+                       dbg.HandleCommand( 'type summary add %s -F %s.%s' % 
(t,__name__,f))
+               else:
+                       print( 'AOO-LLDB helper function "%s" is not yet 
defined: "%s" types cannot be displayed properly!' % (f,t))
+
+       # perform some goodies if the process is ready to run or already running
+       if dbg.GetNumTargets() > 0:
+               # the list of interesting function breakpoints
+               aoo_breakfn = ['main', '__cxa_call_unexpected', 
'objc_exception_throw']
+               aoo_breakfn += ['__cxa_throw']
+               # register the function breakpoints
+               for t in aoo_breakfn:
+                       dbg.HandleCommand( 'breakpoint set -n ' + t)
+
+
+# definitions for individual LLDB type summary helpers 
+
+def getinfo_for_rtl_String( valobj, dict):
+       while valobj.TypeIsPointerType():
+               valobj = valobj.Dereference()
+       r = valobj.GetChildMemberWithName('refCount').GetValueAsSigned()
+       l = valobj.GetChildMemberWithName('length').GetValueAsSigned()
+       a = 
valobj.GetChildMemberWithName('buffer').AddressOf().GetPointeeData(0,l)
+       s = ''.join([chr(x) for x in a.uint8s])                                
+       return '{refs=%d, len=%d, str="%s"}'%(r,l,s)
+       return info
+
+def getinfo_for_rtl_uString( valobj, dict):
+       while valobj.TypeIsPointerType():
+               valobj = valobj.Dereference()
+       r = valobj.GetChildMemberWithName('refCount').GetValueAsSigned()
+       l = valobj.GetChildMemberWithName('length').GetValueAsSigned()
+       a = 
valobj.GetChildMemberWithName('buffer').AddressOf().GetPointeeData(0,l)
+       s = (u''.join([unichr(x) for x in a.uint16s])).encode('utf-8')
+       return '{refs=%d, len=%d, str="%s"}'%(r,l,s)
+
+def getinfo_for_rtl__ByteStringData( valobj, dict):
+       while valobj.TypeIsPointerType():
+               valobj = valobj.Dereference()
+       r = valobj.GetChildMemberWithName('mnRefCount').GetValueAsSigned()
+       l = valobj.GetChildMemberWithName('mnLen').GetValueAsSigned()
+       a = 
valobj.GetChildMemberWithName('maStr').AddressOf().GetPointeeData(0,l)
+       s = ''.join([chr(x) for x in a.uint8s])                                
+       return '{refs=%d, len=%d, str="%s"}'%(r,l,s)
+
+def getinfo_for_rtl__UniStringData( valobj, dict):
+       while valobj.TypeIsPointerType():
+               valobj = valobj.Dereference()
+       r = valobj.GetChildMemberWithName('mnRefCount').GetValueAsSigned()
+       l = valobj.GetChildMemberWithName('mnLen').GetValueAsSigned()
+       a = 
valobj.GetChildMemberWithName('maStr').AddressOf().GetPointeeData(0,l)
+       s = (u''.join([unichr(x) for x in a.uint16s])).encode('utf-8')
+       return '{refs=%d, len=%d, str="%s"}'%(r,l,s)
+
+
+def getinfo_for_rtl_OString( valobj, dict):
+       d = valobj.GetChildMemberWithName('pData')
+       return d.Dereference()
+
+def getinfo_for_rtl_OUString( valobj, dict):
+       d = valobj.GetChildMemberWithName('pData')
+       return d.Dereference()
+
+def getinfo_for_rtl_ByteString( valobj, dict):
+       d = valobj.GetChildMemberWithName('mpData')
+       return d.Dereference()
+
+def getinfo_for_rtl_UniString( valobj, dict):
+       d = valobj.GetChildMemberWithName('mpData')
+       return d.Dereference()
+


Reply via email to