Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1339639
| From | Kieran Bingham <kieran.bingham@linaro.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 2/8] scripts/gdb: Provide a kernel list item generators |
| Date | 2016-02-22 16:30 +0100 |
| Message-ID | <r50AX-7F1-33@gated-at.bofh.it> (permalink) |
| References | <r50AW-7F1-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Facilitate linked-list items by providing a generator to return
the dereferenced, and type-cast objects from a kernel linked list
CC: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Kieran Bingham <kieran.bingham@linaro.org>
---
Changes since v1:
* items function removed, and replaced with Jeff Mahoney's cleaner
implementations of list_for_each, and list_for_each_entry
---
scripts/gdb/linux/lists.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/scripts/gdb/linux/lists.py b/scripts/gdb/linux/lists.py
index 3a3775bc162b..9f4503738e26 100644
--- a/scripts/gdb/linux/lists.py
+++ b/scripts/gdb/linux/lists.py
@@ -18,6 +18,26 @@ from linux import utils
list_head = utils.CachedType("struct list_head")
+def list_for_each(head):
+ if head.type == list_head.get_type().pointer():
+ head = head.dereference()
+ elif head.type != list_head.get_type():
+ raise gdb.GdbError("Must be struct list_head not %s" % list_head.type)
+
+ node = head['next'].dereference()
+ while node.address != head.address:
+ yield node.address
+ node = node['next'].dereference()
+
+
+def list_for_each_entry(head, gdbtype, member):
+ for node in list_for_each(head):
+ if node.type != list_head.get_type().pointer():
+ raise TypeError("Type %s found. "
+ "Expected struct list_head *." % node.type)
+ yield utils.container_of(node, gdbtype, member)
+
+
def list_check(head):
nb = 0
if (head.type == list_head.get_type().pointer()):
--
2.5.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCHv2 0/8] gdb/scripts: Linux awareness debug commands Kieran Bingham <kieran.bingham@linaro.org> - 2016-02-22 16:30 +0100
[PATCH 2/8] scripts/gdb: Provide a kernel list item generators Kieran Bingham <kieran.bingham@linaro.org> - 2016-02-22 16:30 +0100
[PATCH 7/8] scripts/gdb: Add mount point list command Kieran Bingham <kieran.bingham@linaro.org> - 2016-02-22 16:30 +0100
[PATCH 8/8] scripts/gdb: Add meminfo command Kieran Bingham <kieran.bingham@linaro.org> - 2016-02-22 16:30 +0100
Re: [PATCH 8/8] scripts/gdb: Add meminfo command Kieran Bingham <kieran.bingham@linaro.org> - 2016-02-24 10:50 +0100
[PATCH 4/8] scripts/gdb: Provide exception catching parser Kieran Bingham <kieran.bingham@linaro.org> - 2016-02-22 16:30 +0100
[PATCH 3/8] scripts/gdb: Convert modules usage to lists functions Kieran Bingham <kieran.bingham@linaro.org> - 2016-02-22 16:30 +0100
[PATCH 5/8] scripts/gdb: Support !CONFIG_MODULES gracefully Kieran Bingham <kieran.bingham@linaro.org> - 2016-02-22 16:30 +0100
Re: [PATCHv2 0/8] gdb/scripts: Linux awareness debug commands Jan Kiszka <jan.kiszka@siemens.com> - 2016-02-29 17:40 +0100
Re: [PATCHv2 0/8] gdb/scripts: Linux awareness debug commands Kieran Bingham <kieran.bingham@linaro.org> - 2016-02-29 18:10 +0100
csiph-web