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