lldb4aoo.py (81712d15) lldb4aoo.py (6f79f796)
1# to activate the AOO-LLDB helper script type the line below into LLDB
2# command script import path-to-script/lldb4aoo.py
3# or activate it automatically by adding the line to ~/.lldbinit
4
5def __lldb_init_module( dbg, dict):
6 # the list of AOO specific types
7 aoo_types = ['rtl_String', 'rtl_uString', '_ByteStringData', '_UniStringData']
8 pimpl_types = ['rtl::OString', 'rtl::OUString', 'ByteString', 'UniString']
9 # register a helper function for each non-trivial type
10 for t in aoo_types:
11 f = 'getinfo_for_' + t.replace( '::', '_')
12 if f in globals():
13 dbg.HandleCommand( 'type summary add %s -v -C yes -F %s.%s' % (t,__name__,f))
14 else:
15 print( 'AOO-LLDB helper function "%s" is not yet defined: '
16 '"%s" types cannot be displayed properly!' % (f,t))
17 # register a generic helper function for pimpl types
18 dbg.HandleCommand( 'type summary add -F %s.%s -v -C yes -n PIMPL %s' % ( __name__,'get_pimpl_info', ' '.join(pimpl_types)))
19
1# to activate the AOO-LLDB helper script type the line below into LLDB
2# command script import path-to-script/lldb4aoo.py
3# or activate it automatically by adding the line to ~/.lldbinit
4
5def __lldb_init_module( dbg, dict):
6 # the list of AOO specific types
7 aoo_types = ['rtl_String', 'rtl_uString', '_ByteStringData', '_UniStringData']
8 pimpl_types = ['rtl::OString', 'rtl::OUString', 'ByteString', 'UniString']
9 # register a helper function for each non-trivial type
10 for t in aoo_types:
11 f = 'getinfo_for_' + t.replace( '::', '_')
12 if f in globals():
13 dbg.HandleCommand( 'type summary add %s -v -C yes -F %s.%s' % (t,__name__,f))
14 else:
15 print( 'AOO-LLDB helper function "%s" is not yet defined: '
16 '"%s" types cannot be displayed properly!' % (f,t))
17 # register a generic helper function for pimpl types
18 dbg.HandleCommand( 'type summary add -F %s.%s -v -C yes -n PIMPL %s' % ( __name__,'get_pimpl_info', ' '.join(pimpl_types)))
19
20 # add info about specific helper methods
21 # assume functions with docstrings are available for general consumption
22 helper_funcs = [v for (k,v) in globals().iteritems() if( not k.startswith('_') and callable(v) and v.__doc__)]
23 if helper_funcs:
24 print( 'Available AOO-specific helper functions:')
25 for hfunc in helper_funcs:
26 shortdesc = hfunc.__doc__.splitlines()[0]
27 print( '\t%s\t# "%s"' %(hfunc.__name__, shortdesc))
28 print( 'Run them with:')
29 for hfunc in helper_funcs[:4]:
30 print( '\tscript %s.%s()' %(__name__, hfunc.__name__))
20
31
32# some helpers for use from interactive LLDB sessions
33
34import lldb
35
36def add_breakpoints():
37 'Setup breakpoints useful for AOO debugging'
38 dbg = lldb.debugger
39 if dbg.GetNumTargets() == 0:
40 return
41 # the list of interesting function breakpoints
42 aoo_breakfn = ['main', '__cxa_call_unexpected', 'objc_exception_throw']
43 aoo_breakfn += ['__cxa_throw']
44 # register breakpoints for function basenames
45 for b in aoo_breakfn:
46 dbg.HandleCommand( 'breakpoint set -b ' + b)
47
48
21# local functions for use by the AOO-type summary providers
22
23def walk_ptrchain( v):
24 info = ''
25 while v.TypeIsPointerType():
26 n = v.GetValueAsUnsigned()
27 if n == 0:
28 info += 'NULL'

--- 46 unchanged lines hidden ---
49# local functions for use by the AOO-type summary providers
50
51def walk_ptrchain( v):
52 info = ''
53 while v.TypeIsPointerType():
54 n = v.GetValueAsUnsigned()
55 if n == 0:
56 info += 'NULL'

--- 46 unchanged lines hidden ---