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


Groups > linux.kernel > #1313129 > unrolled thread

[PATCH 2/5] scripts/gdb: Provide a kernel list item generator

Started byKieran Bingham <kieran.bingham@linaro.org>
First post2016-01-20 12:20 +0100
Last post2016-01-24 01:20 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/5] scripts/gdb: Provide a kernel list item generator Kieran Bingham <kieran.bingham@linaro.org> - 2016-01-20 12:20 +0100
    Re: [PATCH 2/5] scripts/gdb: Provide a kernel list item generator Jan Kiszka <jan.kiszka@siemens.com> - 2016-01-23 16:10 +0100
      Re: [PATCH 2/5] scripts/gdb: Provide a kernel list item generator Kieran Bingham <kieran.bingham@linaro.org> - 2016-01-24 01:20 +0100

#1313129 — [PATCH 2/5] scripts/gdb: Provide a kernel list item generator

FromKieran Bingham <kieran.bingham@linaro.org>
Date2016-01-20 12:20 +0100
Subject[PATCH 2/5] scripts/gdb: Provide a kernel list item generator
Message-ID<qSYXT-5Aj-9@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1315658

FromJan Kiszka <jan.kiszka@siemens.com>
Date2016-01-23 16:10 +0100
Message-ID<qU7Z9-4tS-19@gated-at.bofh.it>
In reply to#1313129
On 2016-01-20 12:15, Kieran Bingham wrote:
> 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.

Location is fine. Maybe call it list_items?

> 
>  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()):
> 

Could you apply it on existing list iterations? module_list() seems like
a candidate, e.g.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux

[toc] | [prev] | [next] | [standalone]


#1315788

FromKieran Bingham <kieran.bingham@linaro.org>
Date2016-01-24 01:20 +0100
Message-ID<qUgzn-54S-1@gated-at.bofh.it>
In reply to#1315658

On 23/01/16 15:08, Jan Kiszka wrote:
> On 2016-01-20 12:15, Kieran Bingham wrote:
>> 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.
> 
> Location is fine. Maybe call it list_items?
> 
>>
>>  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()):
>>
> 
> Could you apply it on existing list iterations? module_list() seems like
> a candidate, e.g.

Yes, It probably is. I'll update, and add a patch to my series, and
check to see if there are any more.
--
Kieran

> 
> Jan
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web