annotate lldb/examples/python/sources.py @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents 1f2b6ac9f198
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
1 #!/usr/bin/env python
150
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 import lldb
anatofuz
parents:
diff changeset
4 import shlex
anatofuz
parents:
diff changeset
5
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 def dump_module_sources(module, result):
anatofuz
parents:
diff changeset
8 if module:
anatofuz
parents:
diff changeset
9 print("Module: %s" % (module.file), file=result)
anatofuz
parents:
diff changeset
10 for compile_unit in module.compile_units:
anatofuz
parents:
diff changeset
11 if compile_unit.file:
anatofuz
parents:
diff changeset
12 print(" %s" % (compile_unit.file), file=result)
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14
anatofuz
parents:
diff changeset
15 def info_sources(debugger, command, result, dict):
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
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."""
150
anatofuz
parents:
diff changeset
17 module_names = shlex.split(command)
anatofuz
parents:
diff changeset
18 target = debugger.GetSelectedTarget()
anatofuz
parents:
diff changeset
19 if module_names:
anatofuz
parents:
diff changeset
20 for module_name in module_names:
anatofuz
parents:
diff changeset
21 dump_module_sources(target.module[module_name], result)
anatofuz
parents:
diff changeset
22 else:
anatofuz
parents:
diff changeset
23 for module in target.modules:
anatofuz
parents:
diff changeset
24 dump_module_sources(module, result)
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 def __lldb_init_module(debugger, dict):
anatofuz
parents:
diff changeset
28 # Add any commands contained in this module to LLDB
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
29 debugger.HandleCommand("command script add -o -f sources.info_sources info_sources")
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
30 print(
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
31 'The "info_sources" command has been installed, type "help info_sources" or "info_sources --help" for detailed help.'
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
32 )