Skip to content

Commit 619ccaf

Browse files
kbinghamtorvalds
authored andcommitted
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>
1 parent a84be61 commit 619ccaf

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

‎scripts/gdb/linux/modules.py‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import gdb
1515

16-
from linux import cpus, utils
16+
from linux import cpus, utils, lists
1717

1818

1919
module_type = utils.CachedType("struct module")
@@ -23,12 +23,9 @@ def module_list():
2323
global module_type
2424
module_ptr_type = module_type.get_type().pointer()
2525
modules = gdb.parse_and_eval("modules")
26-
entry = modules['next']
27-
end_of_list = modules.address
2826

29-
while entry != end_of_list:
30-
yield utils.container_of(entry, module_ptr_type, "list")
31-
entry = entry['next']
27+
for module in lists.list_for_each_entry(modules, module_ptr_type, "list"):
28+
yield module
3229

3330

3431
def find_module_by_name(name):
@@ -80,17 +77,15 @@ def invoke(self, arg, from_tty):
8077
size=str(layout['size']),
8178
ref=str(module['refcnt']['counter'] - 1)))
8279

83-
source_list = module['source_list']
8480
t = self._module_use_type.get_type().pointer()
85-
entry = source_list['next']
8681
first = True
87-
while entry != source_list.address:
88-
use = utils.container_of(entry, t, "source_list")
82+
sources = module['source_list']
83+
for use in lists.list_for_each_entry(sources, t, "source_list"):
8984
gdb.write("{separator}{name}".format(
9085
separator=" " if first else ",",
9186
name=use['source']['name'].string()))
9287
first = False
93-
entry = entry['next']
88+
9489
gdb.write("\n")
9590

9691

0 commit comments

Comments
 (0)