diff options
| author | Kieran Bingham <kieran.bingham@linaro.org> | 2016-05-23 19:24:45 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-23 20:04:14 -0400 |
| commit | 619ccaf3e94958485fd237000c24e06bce686bd2 (patch) | |
| tree | cd6b96e67536750fc550ad4daba2730aea2b65e1 /scripts/gdb | |
| parent | a84be61d0e38034634e7cbe076179cc6f1c16d22 (diff) | |
scripts/gdb: convert modules usage to lists functions
Simplify the module list functions with the new list_for_each_entry
abstractions
Link: http://lkml.kernel.org/r/ad0101c9391088608166fcec26af179868973d86.1462865983.git.jan.kiszka@siemens.com
Signed-off-by: Kieran Bingham <kieran.bingham@linaro.org>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/gdb')
| -rw-r--r-- | scripts/gdb/linux/modules.py | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/scripts/gdb/linux/modules.py b/scripts/gdb/linux/modules.py index 38f5d17044c5..62557ddf56f1 100644 --- a/scripts/gdb/linux/modules.py +++ b/scripts/gdb/linux/modules.py | |||
| @@ -13,7 +13,7 @@ | |||
| 13 | 13 | ||
| 14 | import gdb | 14 | import gdb |
| 15 | 15 | ||
| 16 | from linux import cpus, utils | 16 | from linux import cpus, utils, lists |
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | module_type = utils.CachedType("struct module") | 19 | module_type = utils.CachedType("struct module") |
| @@ -23,12 +23,9 @@ def module_list(): | |||
| 23 | global module_type | 23 | global module_type |
| 24 | module_ptr_type = module_type.get_type().pointer() | 24 | module_ptr_type = module_type.get_type().pointer() |
| 25 | modules = gdb.parse_and_eval("modules") | 25 | modules = gdb.parse_and_eval("modules") |
| 26 | entry = modules['next'] | ||
| 27 | end_of_list = modules.address | ||
| 28 | 26 | ||
| 29 | while entry != end_of_list: | 27 | for module in lists.list_for_each_entry(modules, module_ptr_type, "list"): |
| 30 | yield utils.container_of(entry, module_ptr_type, "list") | 28 | yield module |
| 31 | entry = entry['next'] | ||
| 32 | 29 | ||
| 33 | 30 | ||
| 34 | def find_module_by_name(name): | 31 | def find_module_by_name(name): |
| @@ -80,17 +77,15 @@ class LxLsmod(gdb.Command): | |||
| 80 | size=str(layout['size']), | 77 | size=str(layout['size']), |
| 81 | ref=str(module['refcnt']['counter'] - 1))) | 78 | ref=str(module['refcnt']['counter'] - 1))) |
| 82 | 79 | ||
| 83 | source_list = module['source_list'] | ||
| 84 | t = self._module_use_type.get_type().pointer() | 80 | t = self._module_use_type.get_type().pointer() |
| 85 | entry = source_list['next'] | ||
| 86 | first = True | 81 | first = True |
| 87 | while entry != source_list.address: | 82 | sources = module['source_list'] |
| 88 | use = utils.container_of(entry, t, "source_list") | 83 | for use in lists.list_for_each_entry(sources, t, "source_list"): |
| 89 | gdb.write("{separator}{name}".format( | 84 | gdb.write("{separator}{name}".format( |
| 90 | separator=" " if first else ",", | 85 | separator=" " if first else ",", |
| 91 | name=use['source']['name'].string())) | 86 | name=use['source']['name'].string())) |
| 92 | first = False | 87 | first = False |
| 93 | entry = entry['next'] | 88 | |
| 94 | gdb.write("\n") | 89 | gdb.write("\n") |
| 95 | 90 | ||
| 96 | 91 | ||
