[flang] Fix crash in HLFIR generation (#118399)
[llvm-project.git] / lldb / examples / python / sources.py
blobcea2fd03344d489ff9dd72ed342ea5c0801a76c8
1 #!/usr/bin/env python
3 import lldb
4 import shlex
7 def dump_module_sources(module, result):
8 if module:
9 print("Module: %s" % (module.file), file=result)
10 for compile_unit in module.compile_units:
11 if compile_unit.file:
12 print(" %s" % (compile_unit.file), file=result)
15 def info_sources(debugger, command, result, dict):
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."""
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)
27 def __lldb_init_module(debugger, dict):
28 # Add any commands contained in this module to LLDB
29 debugger.HandleCommand("command script add -o -f sources.info_sources info_sources")
30 print(
31 'The "info_sources" command has been installed, type "help info_sources" or "info_sources --help" for detailed help.'