mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kieran Bingham <kieran.bingham@linaro.org>
To: jan.kiszka@siemens.com
Cc: Kieran Bingham <kieran.bingham@linaro.org>,
	linux-kernel@vger.kernel.org, maxime.coquelin@st.com,
	peter.griffin@linaro.org, lee.jones@linaro.org
Subject: [PATCH 2/5] scripts/gdb: Provide a kernel list item generator
Date: Wed, 20 Jan 2016 11:15:47 +0000	[thread overview]
Message-ID: <1453288550-4706-3-git-send-email-kieran.bingham@linaro.org> (raw)
In-Reply-To: <1453288550-4706-1-git-send-email-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

Signed-off-by: Kieran Bingham <kieran.bingham@linaro.org>
---

This is quite a useful wrapper to faciliate looping on lists.
It is sort of equivalent to the list_for_each_entry macro.

Let me know if it should be renamed, or live elsewhere.

 scripts/gdb/linux/lists.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/scripts/gdb/linux/lists.py b/scripts/gdb/linux/lists.py
index 3a3775bc162b..d2c6ce165cb1 100644
--- a/scripts/gdb/linux/lists.py
+++ b/scripts/gdb/linux/lists.py
@@ -18,6 +18,15 @@ from linux import utils
 list_head = utils.CachedType("struct list_head")
 
 
+def items(list_type, list_location, item_list):
+    """items Generator return items from a kernel linked list"""
+    item_list_head = item_list
+    next_item = item_list_head['next'].dereference()
+    while next_item != item_list_head:
+        yield utils.container_of(next_item, list_type, list_location)
+        next_item = next_item['next'].dereference()
+
+
 def list_check(head):
     nb = 0
     if (head.type == list_head.get_type().pointer()):
-- 
2.5.0

  parent reply	other threads:[~2016-01-20 11:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-20 11:15 [RFC PATCH 0/5] scripts/gdb: Linux awareness debug commands Kieran Bingham
2016-01-20 11:15 ` [PATCH 1/5] scripts/gdb: Provide linux constants Kieran Bingham
2016-01-23 15:05   ` Jan Kiszka
2016-01-24  0:11     ` Kieran Bingham
2016-01-20 11:15 ` Kieran Bingham [this message]
2016-01-23 15:08   ` [PATCH 2/5] scripts/gdb: Provide a kernel list item generator Jan Kiszka
2016-01-24  0:15     ` Kieran Bingham
2016-01-20 11:15 ` [PATCH 3/5] scripts/gdb: Add io resource readers Kieran Bingham
2016-01-23 15:12   ` Jan Kiszka
2016-01-24  0:17     ` Kieran Bingham
2016-01-20 11:15 ` [PATCH 4/5] scripts/gdb: Add mount point list command Kieran Bingham
2016-01-20 11:42   ` Jan Kiszka
2016-01-20 11:51     ` Kieran Bingham
2016-01-20 12:08       ` Jan Kiszka
2016-01-23 12:34   ` Jan Kiszka
2016-01-23 15:27   ` Jan Kiszka
2016-01-24  0:24     ` Kieran Bingham
2016-01-20 11:15 ` [PATCH 5/5] scripts/gdb: Add meminfo command Kieran Bingham
2016-01-23 15:21   ` Jan Kiszka
2016-01-24  0:30     ` Kieran Bingham

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=1453288550-4706-3-git-send-email-kieran.bingham@linaro.org \
    --to=kieran.bingham@linaro.org \
    --cc=jan.kiszka@siemens.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.coquelin@st.com \
    --cc=peter.griffin@linaro.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®