2013-09-05 01:31:40 +08:00
#!/usr/bin/python
import lldb
import shlex
2016-09-07 04:57:50 +08:00
2013-09-05 01:31:40 +08:00
def dump_module_sources ( module , result ) :
if module :
print >> result , " Module: %s " % ( module . file )
for compile_unit in module . compile_units :
if compile_unit . file :
print >> result , " %s " % ( compile_unit . file )
2016-09-07 04:57:50 +08:00
2013-09-05 01:31:40 +08:00
def info_sources ( debugger , command , result , dict ) :
2016-09-07 04:57:50 +08:00
description = ''' This command will dump all compile units in any modules that are listed as arguments, or for all modules if no arguments are supplied. '''
2013-09-05 01:31:40 +08:00
module_names = shlex . split ( command )
target = debugger . GetSelectedTarget ( )
if module_names :
for module_name in module_names :
dump_module_sources ( target . module [ module_name ] , result )
else :
for module in target . modules :
dump_module_sources ( module , result )
2016-09-07 04:57:50 +08:00
def __lldb_init_module ( debugger , dict ) :
2013-09-05 01:31:40 +08:00
# Add any commands contained in this module to LLDB
2016-09-07 04:57:50 +08:00
debugger . HandleCommand (
' command script add -f sources.info_sources info_sources ' )
2013-09-05 01:31:40 +08:00
print ' The " info_sources " command has been installed, type " help info_sources " or " info_sources --help " for detailed help. '