From patchwork Wed Jan 20 11:15:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 60033 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp3109648lbb; Wed, 20 Jan 2016 03:17:25 -0800 (PST) X-Received: by 10.66.120.77 with SMTP id la13mr51849819pab.74.1453288645014; Wed, 20 Jan 2016 03:17:25 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d29si54619142pfj.73.2016.01.20.03.17.24; Wed, 20 Jan 2016 03:17:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964874AbcATLRX (ORCPT + 29 others); Wed, 20 Jan 2016 06:17:23 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:37878 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935248AbcATLQ1 (ORCPT ); Wed, 20 Jan 2016 06:16:27 -0500 Received: by mail-wm0-f51.google.com with SMTP id n5so23642069wmn.0 for ; Wed, 20 Jan 2016 03:16:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bIkBi9DmIBQLpxPCAD0huM6y+UL6gkJebFUHwfORUqg=; b=LcQbayxJ6Q84/POd4SFaGsY4NwuebwpUvKOv9vr+WjJN8MnR581H+V3JFNX9CGiKqD Yd1qWT1rRI+AMrcZXmxVJ/vZK0GAMMT7FOfrsOBpVuubookOjNcqx3543uSL2jelrggV 4zLk7OTURJnPU7KgBlybpbNTAUDsqIBIN5ktI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bIkBi9DmIBQLpxPCAD0huM6y+UL6gkJebFUHwfORUqg=; b=BM+OHpdG66DJcz2mpbsXklx4Er+2J//YobY5uGGltVT0Ghea4D+KlCebKrCcL++TcZ x9dlwiEO7o067w8d+JGYvIfHE2dgOVfnPSQthA1PTiP7riCsXawQzsAkifCidTcrEIXI whKxsHnEijBA+9Szge2ylrCFCAkBUMckdFn3NAvRjITtxHKGS0pr2CZ1MIdpw2fIwTzr AcxjsqEqihx7KeJ5pd/sZCB52PItjkUOI5yqdYrQr76V3+ivuovsMH4VE7dSgJ25QWsW bsNISmyHOhMtUoq589fdjX33DhdK0NbUSH6hEyFnfkqrneVTOvRccieAncN9A07TbZqj WkTw== X-Gm-Message-State: ALoCoQmSLHSP4RH0dtmduYWXFpHmaNdOgwPm87rvi7oRXLptLAVZ8TIuwEbTH7/oXkmb0bB8l4RC54a6Mtmk54kJHD2U/kXe9g== X-Received: by 10.194.242.67 with SMTP id wo3mr34324036wjc.180.1453288586521; Wed, 20 Jan 2016 03:16:26 -0800 (PST) Received: from localhost.localdomain (cpc87017-aztw30-2-0-cust65.18-1.cable.virginm.net. [92.232.232.66]) by smtp.gmail.com with ESMTPSA id bg1sm28398065wjc.27.2016.01.20.03.16.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Jan 2016 03:16:26 -0800 (PST) From: Kieran Bingham To: jan.kiszka@siemens.com Cc: Kieran Bingham , 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 Message-Id: <1453288550-4706-3-git-send-email-kieran.bingham@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1453288550-4706-1-git-send-email-kieran.bingham@linaro.org> References: <1453288550-4706-1-git-send-email-kieran.bingham@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- 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(+) -- 2.5.0 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()):