mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org,
	Kieran Bingham <kieran.bingham@linaro.org>,
	Jeff Mahoney <jeffm@suse.com>
Subject: [PATCH 03/18] scripts/gdb: Provide kernel list item generators
Date: Tue, 10 May 2016 09:39:28 +0200	[thread overview]
Message-ID: <2b0998564e6e5abe53585d466f87e491331fd2a4.1462865983.git.jan.kiszka@siemens.com> (raw)
In-Reply-To: <cover.1462865983.git.jan.kiszka@siemens.com>
In-Reply-To: <cover.1462865983.git.jan.kiszka@siemens.com>

From: Kieran Bingham <kieran.bingham@linaro.org>

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>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 scripts/gdb/linux/lists.py | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/scripts/gdb/linux/lists.py b/scripts/gdb/linux/lists.py
index 3a3775b..2f335fb 100644
--- a/scripts/gdb/linux/lists.py
+++ b/scripts/gdb/linux/lists.py
@@ -18,6 +18,27 @@ 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 {}"
+                           .format(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 {} found. Expected struct list_head *."
+                            .format(node.type))
+        yield utils.container_of(node, gdbtype, member)
+
+
 def list_check(head):
     nb = 0
     if (head.type == list_head.get_type().pointer()):
-- 
2.1.4

  parent reply	other threads:[~2016-05-10  7:46 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-10  7:39 [PATCH 00/18] scripts/gdb: Updates for 4.7 Jan Kiszka
2016-05-10  7:39 ` [PATCH 01/18] scripts/gdb: Adjust module reference counter reported by lx-lsmod Jan Kiszka
2016-05-10  7:39 ` [PATCH 02/18] scripts/gdb: Provide linux constants Jan Kiszka
2016-05-10  7:39 ` Jan Kiszka [this message]
2016-05-10  7:39 ` [PATCH 04/18] scripts/gdb: Convert modules usage to lists functions Jan Kiszka
2016-05-10  7:39 ` [PATCH 05/18] scripts/gdb: Provide exception catching parser Jan Kiszka
2016-05-10  7:39 ` [PATCH 06/18] scripts/gdb: Support !CONFIG_MODULES gracefully Jan Kiszka
2016-05-10  7:39 ` [PATCH 07/18] scripts/gdb: Provide a dentry_name VFS path helper Jan Kiszka
2016-05-10  7:39 ` [PATCH 08/18] scripts/gdb: Add io resource readers Jan Kiszka
2016-05-10  7:39 ` [PATCH 09/18] scripts/gdb: Add mount point list command Jan Kiszka
2016-05-10  7:39 ` [PATCH 10/18] scripts/gdb: Add cpu iterators Jan Kiszka
2016-05-10  7:39 ` [PATCH 11/18] scripts/gdb: Cast CPU numbers to integer Jan Kiszka
2016-05-10  7:39 ` [PATCH 12/18] scripts/gdb: Add a Radix Tree Parser Jan Kiszka
2016-05-10  7:39 ` [PATCH 13/18] scripts/gdb: Add documentation example for radix tree Jan Kiszka
2016-05-10  7:39 ` [PATCH 14/18] scripts/gdb: Add lx_thread_info_by_pid helper Jan Kiszka
2016-05-10  7:39 ` [PATCH 15/18] scripts/gdb: Improve types abstraction for gdb python scripts Jan Kiszka
2016-05-10  7:39 ` [PATCH 16/18] scripts/gdb: Fix issue with dmesg.py and python 3.X Jan Kiszka
2016-05-10  7:39 ` [PATCH 17/18] scripts/gdb: decode bytestream on dmesg for Python3 Jan Kiszka
2016-05-10  7:39 ` [PATCH 18/18] MAINTAINERS: Add co-maintainer for scripts/gdb Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2b0998564e6e5abe53585d466f87e491331fd2a4.1462865983.git.jan.kiszka@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=akpm@linux-foundation.org \
    --cc=jeffm@suse.com \
    --cc=kieran.bingham@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®