1#!/usr/bin/env python 2from __future__ import print_function 3 4import lldb 5import shlex 6 7 8def dump_module_sources(module, result): 9 if module: 10 print("Module: %s" % (module.file), file=result) 11 for compile_unit in module.compile_units: 12 if compile_unit.file: 13 print(" %s" % (compile_unit.file), file=result) 14 15 16def info_sources(debugger, command, result, dict): 17 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.''' 18 module_names = shlex.split(command) 19 target = debugger.GetSelectedTarget() 20 if module_names: 21 for module_name in module_names: 22 dump_module_sources(target.module[module_name], result) 23 else: 24 for module in target.modules: 25 dump_module_sources(module, result) 26 27 28def __lldb_init_module(debugger, dict): 29 # Add any commands contained in this module to LLDB 30 debugger.HandleCommand( 31 'command script add -f sources.info_sources info_sources') 32 print('The "info_sources" command has been installed, type "help info_sources" or "info_sources --help" for detailed help.') 33