From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753728AbcAWPJM (ORCPT ); Sat, 23 Jan 2016 10:09:12 -0500 Received: from david.siemens.de ([192.35.17.14]:58578 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752538AbcAWPJK (ORCPT ); Sat, 23 Jan 2016 10:09:10 -0500 Subject: Re: [PATCH 2/5] scripts/gdb: Provide a kernel list item generator To: Kieran Bingham References: <1453288550-4706-1-git-send-email-kieran.bingham@linaro.org> <1453288550-4706-3-git-send-email-kieran.bingham@linaro.org> Cc: linux-kernel@vger.kernel.org, maxime.coquelin@st.com, peter.griffin@linaro.org, lee.jones@linaro.org From: Jan Kiszka Message-ID: <56A39788.8060409@siemens.com> Date: Sat, 23 Jan 2016 16:08:56 +0100 User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 In-Reply-To: <1453288550-4706-3-git-send-email-kieran.bingham@linaro.org> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > > 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