Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Kieran Bingham and committed by
Linus Torvalds
619ccaf3 a84be61d

+6 -11
+6 -11
scripts/gdb/linux/modules.py
··· 13 13 14 14 import gdb 15 15 16 - from linux import cpus, utils 16 + from linux import cpus, utils, lists 17 17 18 18 19 19 module_type = utils.CachedType("struct module") ··· 23 23 global module_type 24 24 module_ptr_type = module_type.get_type().pointer() 25 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: 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 32 29 33 30 34 31 def find_module_by_name(name): ··· 77 80 size=str(layout['size']), 78 81 ref=str(module['refcnt']['counter'] - 1))) 79 82 80 - source_list = module['source_list'] 81 83 t = self._module_use_type.get_type().pointer() 82 - entry = source_list['next'] 83 84 first = True 84 - while entry != source_list.address: 85 - use = utils.container_of(entry, t, "source_list") 85 + sources = module['source_list'] 86 + for use in lists.list_for_each_entry(sources, t, "source_list"): 86 87 gdb.write("{separator}{name}".format( 87 88 separator=" " if first else ",", 88 89 name=use['source']['name'].string())) 89 90 first = False 90 - entry = entry['next'] 91 + 91 92 gdb.write("\n") 92 93 93 94