aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/gdb/linux/modules.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/gdb/linux/modules.py')
-rw-r--r--scripts/gdb/linux/modules.py17
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
14import gdb 14import gdb
15 15
16from linux import cpus, utils 16from linux import cpus, utils, lists
17 17
18 18
19module_type = utils.CachedType("struct module") 19module_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
34def find_module_by_name(name): 31def 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