Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1367155

[PATCHv4 03/12] scripts/gdb: Convert modules usage to lists functions

From Kieran Bingham <kieran.bingham@linaro.org>
Newsgroups linux.kernel
Subject [PATCHv4 03/12] scripts/gdb: Convert modules usage to lists functions
Date 2016-03-30 14:10 +0200
Message-ID <rin6H-57W-41@gated-at.bofh.it> (permalink)
References <rin6G-57W-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Simplify the module list functions with the new list_for_each_entry
abstractions

Signed-off-by: Kieran Bingham <kieran.bingham@linaro.org>
---
 scripts/gdb/linux/modules.py | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/scripts/gdb/linux/modules.py b/scripts/gdb/linux/modules.py
index 0a35d6dbfb80..6d9e1199ce57 100644
--- a/scripts/gdb/linux/modules.py
+++ b/scripts/gdb/linux/modules.py
@@ -13,7 +13,7 @@
 
 import gdb
 
-from linux import cpus, utils
+from linux import cpus, utils, lists
 
 
 module_type = utils.CachedType("struct module")
@@ -23,12 +23,9 @@ def module_list():
     global module_type
     module_ptr_type = module_type.get_type().pointer()
     modules = gdb.parse_and_eval("modules")
-    entry = modules['next']
-    end_of_list = modules.address
 
-    while entry != end_of_list:
-        yield utils.container_of(entry, module_ptr_type, "list")
-        entry = entry['next']
+    for module in lists.list_for_each_entry(modules, module_ptr_type, "list"):
+        yield module
 
 
 def find_module_by_name(name):
@@ -80,17 +77,15 @@ class LxLsmod(gdb.Command):
                 size=str(layout['size']),
                 ref=str(module['refcnt']['counter'])))
 
-            source_list = module['source_list']
             t = self._module_use_type.get_type().pointer()
-            entry = source_list['next']
             first = True
-            while entry != source_list.address:
-                use = utils.container_of(entry, t, "source_list")
+            sources = module['source_list']
+            for use in lists.list_for_each_entry(sources, t, "source_list"):
                 gdb.write("{separator}{name}".format(
                     separator=" " if first else ",",
                     name=use['source']['name'].string()))
                 first = False
-                entry = entry['next']
+
             gdb.write("\n")
 
 
-- 
2.5.0

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCHv4 00/12] gdb/scripts: Linux awareness debug commands Kieran Bingham <kieran.bingham@linaro.org> - 2016-03-30 14:10 +0200
  [PATCHv4 10/12] scripts/gdb: Add a Radix Tree Parser Kieran Bingham <kieran.bingham@linaro.org> - 2016-03-30 14:10 +0200
  [PATCHv4 12/12] scripts/gdb: Add lx_thread_info_by_pid helper Kieran Bingham <kieran.bingham@linaro.org> - 2016-03-30 14:10 +0200
  [PATCHv4 05/12] scripts/gdb: Support !CONFIG_MODULES gracefully Kieran Bingham <kieran.bingham@linaro.org> - 2016-03-30 14:10 +0200
  [PATCHv4 09/12] scripts/gdb: Add cpu iterators Kieran Bingham <kieran.bingham@linaro.org> - 2016-03-30 14:10 +0200
  [PATCHv4 01/12] scripts/gdb: Provide linux constants Kieran Bingham <kieran.bingham@linaro.org> - 2016-03-30 14:10 +0200
    Re: [PATCHv4 01/12] scripts/gdb: Provide linux constants Jan Kiszka <jan.kiszka@siemens.com> - 2016-03-30 23:10 +0200
  [PATCHv4 06/12] scripts/gdb: Provide a dentry_name VFS path helper Kieran Bingham <kieran.bingham@linaro.org> - 2016-03-30 14:10 +0200
  [PATCHv4 02/12] scripts/gdb: Provide kernel list item generators Kieran Bingham <kieran.bingham@linaro.org> - 2016-03-30 14:10 +0200
  [PATCHv4 07/12] scripts/gdb: Add io resource readers Kieran Bingham <kieran.bingham@linaro.org> - 2016-03-30 14:10 +0200
  [PATCHv4 08/12] scripts/gdb: Add mount point list command Kieran Bingham <kieran.bingham@linaro.org> - 2016-03-30 14:10 +0200
  [PATCHv4 11/12] scripts/gdb: Add documentation example for radix tree Kieran Bingham <kieran.bingham@linaro.org> - 2016-03-30 14:10 +0200
  [PATCHv4 04/12] scripts/gdb: Provide exception catching parser Kieran Bingham <kieran.bingham@linaro.org> - 2016-03-30 14:10 +0200
  [PATCHv4 03/12] scripts/gdb: Convert modules usage to lists functions Kieran Bingham <kieran.bingham@linaro.org> - 2016-03-30 14:10 +0200

csiph-web