diff options
Diffstat (limited to 'scripts/gdb/linux/modules.py')
-rw-r--r-- | scripts/gdb/linux/modules.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/scripts/gdb/linux/modules.py b/scripts/gdb/linux/modules.py index 0a35d6dbfb80..441b23239896 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") |
@@ -21,14 +21,14 @@ module_type = utils.CachedType("struct module") | |||
21 | 21 | ||
22 | def module_list(): | 22 | def module_list(): |
23 | global module_type | 23 | global module_type |
24 | modules = utils.gdb_eval_or_none("modules") | ||
25 | if modules is None: | ||
26 | return | ||
27 | |||
24 | module_ptr_type = module_type.get_type().pointer() | 28 | module_ptr_type = module_type.get_type().pointer() |
25 | modules = gdb.parse_and_eval("modules") | ||
26 | entry = modules['next'] | ||
27 | end_of_list = modules.address | ||
28 | 29 | ||
29 | while entry != end_of_list: | 30 | for module in lists.list_for_each_entry(modules, module_ptr_type, "list"): |
30 | yield utils.container_of(entry, module_ptr_type, "list") | 31 | yield module |
31 | entry = entry['next'] | ||
32 | 32 | ||
33 | 33 | ||
34 | def find_module_by_name(name): | 34 | def find_module_by_name(name): |
@@ -78,19 +78,17 @@ class LxLsmod(gdb.Command): | |||
78 | address=str(layout['base']).split()[0], | 78 | address=str(layout['base']).split()[0], |
79 | name=module['name'].string(), | 79 | name=module['name'].string(), |
80 | size=str(layout['size']), | 80 | size=str(layout['size']), |
81 | ref=str(module['refcnt']['counter']))) | 81 | ref=str(module['refcnt']['counter'] - 1))) |
82 | 82 | ||
83 | source_list = module['source_list'] | ||
84 | t = self._module_use_type.get_type().pointer() | 83 | t = self._module_use_type.get_type().pointer() |
85 | entry = source_list['next'] | ||
86 | first = True | 84 | first = True |
87 | while entry != source_list.address: | 85 | sources = module['source_list'] |
88 | use = utils.container_of(entry, t, "source_list") | 86 | for use in lists.list_for_each_entry(sources, t, "source_list"): |
89 | gdb.write("{separator}{name}".format( | 87 | gdb.write("{separator}{name}".format( |
90 | separator=" " if first else ",", | 88 | separator=" " if first else ",", |
91 | name=use['source']['name'].string())) | 89 | name=use['source']['name'].string())) |
92 | first = False | 90 | first = False |
93 | entry = entry['next'] | 91 | |
94 | gdb.write("\n") | 92 | gdb.write("\n") |
95 | 93 | ||
96 | 94 | ||