1*515bc8c1Sserge-sans-paille#!/usr/bin/env python 2525cd59fSSerge Gueltonfrom __future__ import print_function 36a23d212SGreg Clayton 46a23d212SGreg Claytonimport lldb 56a23d212SGreg Claytonimport shlex 66a23d212SGreg Clayton 7b9c1b51eSKate Stone 86a23d212SGreg Claytondef dump_module_sources(module, result): 96a23d212SGreg Clayton if module: 10525cd59fSSerge Guelton print("Module: %s" % (module.file), file=result) 116a23d212SGreg Clayton for compile_unit in module.compile_units: 126a23d212SGreg Clayton if compile_unit.file: 13525cd59fSSerge Guelton print(" %s" % (compile_unit.file), file=result) 146a23d212SGreg Clayton 15b9c1b51eSKate Stone 166a23d212SGreg Claytondef info_sources(debugger, command, result, dict): 176a23d212SGreg Clayton 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.''' 186a23d212SGreg Clayton module_names = shlex.split(command) 196a23d212SGreg Clayton target = debugger.GetSelectedTarget() 206a23d212SGreg Clayton if module_names: 216a23d212SGreg Clayton for module_name in module_names: 226a23d212SGreg Clayton dump_module_sources(target.module[module_name], result) 236a23d212SGreg Clayton else: 246a23d212SGreg Clayton for module in target.modules: 256a23d212SGreg Clayton dump_module_sources(module, result) 266a23d212SGreg Clayton 276a23d212SGreg Clayton 286a23d212SGreg Claytondef __lldb_init_module(debugger, dict): 296a23d212SGreg Clayton # Add any commands contained in this module to LLDB 30b9c1b51eSKate Stone debugger.HandleCommand( 31b9c1b51eSKate Stone 'command script add -f sources.info_sources info_sources') 32525cd59fSSerge Guelton print('The "info_sources" command has been installed, type "help info_sources" or "info_sources --help" for detailed help.') 33