From patchwork Mon Feb 22 15:24:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 62593 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1303796lbl; Mon, 22 Feb 2016 07:26:27 -0800 (PST) X-Received: by 10.98.17.28 with SMTP id z28mr39267472pfi.38.1456154786912; Mon, 22 Feb 2016 07:26:26 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 21si40291378pfj.62.2016.02.22.07.26.26; Mon, 22 Feb 2016 07:26:26 -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 S1753897AbcBVP0X (ORCPT + 30 others); Mon, 22 Feb 2016 10:26:23 -0500 Received: from mail-wm0-f52.google.com ([74.125.82.52]:37091 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753058AbcBVPY0 (ORCPT ); Mon, 22 Feb 2016 10:24:26 -0500 Received: by mail-wm0-f52.google.com with SMTP id g62so168758392wme.0 for ; Mon, 22 Feb 2016 07:24:25 -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=osNh/viVgZij6cCLBjpN9T3p3sZjokhriJ6Cqd9w42U=; b=G+SiR5Ca+kDubN+fe2LYzcERiXwtKmUfw1tF0/q1OOaZOErw0/paF32B1ITwHPbzfQ GGEfs3CdeOlIJuALhIiWOY5BH+LeIZWGRrO3YFosi/D3BzPW+b1AfmabDCVr+6QEVCKm zcgEkfEHTrpTxtsNShoCzJveMd3h7WlmMUx+g= 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=osNh/viVgZij6cCLBjpN9T3p3sZjokhriJ6Cqd9w42U=; b=iKlRXyY16OdSRS2t+h+7dWy5UIxENpiP16NLrhtWsYaUl6qVet1NHRJxzZcFy+xzDm EL0nM17fkd837e+mq6zZbjTX1X/GLHP87nyPjxpAocnvZ57a1kSL4gbppfRAe8xwLfM1 yc4jl6IOGZtSLI7xQwcIHNxI99AiOK2aVGyHyzxNnTvchpgeRSF5z5G2a0RInGOcwV/b DHyL3aC6msWgwodWxooGhWQC2+HIZ3SstdBt6Osf+my9wCJCtglaVGX25KCwgWxF/Qzy WfrQhzQrnimGTqchdagRgx6KMxFbDGw79AP5c/VkaTPMqGRmNCOnK3aziXJMHuq9U0Mh fnpg== X-Gm-Message-State: AG10YOSAtkIiUXRhFVPJMI0GgpUkM7b+u+3kf/GL83QORNeyiCTLdxWt/FUiMuk4ZGozp6iJ X-Received: by 10.194.63.75 with SMTP id e11mr28111156wjs.79.1456154665242; Mon, 22 Feb 2016 07:24:25 -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 w66sm21557528wmd.2.2016.02.22.07.24.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Feb 2016 07:24:24 -0800 (PST) From: Kieran Bingham To: jan.kiszka@siemens.com, linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, peter.griffin@linaro.org, maxime.coquelin@st.com, Kieran Bingham Subject: [PATCH 3/8] scripts/gdb: Convert modules usage to lists functions Date: Mon, 22 Feb 2016 15:24:07 +0000 Message-Id: <1456154652-29023-4-git-send-email-kieran.bingham@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456154652-29023-1-git-send-email-kieran.bingham@linaro.org> References: <1456154652-29023-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 Simplify the module list functions with the new list_for_each_entry abstractions Signed-off-by: Kieran Bingham --- scripts/gdb/linux/modules.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) -- 2.5.0 diff --git a/scripts/gdb/linux/modules.py b/scripts/gdb/linux/modules.py index 25db8cff44a2..571489b3b9c2 100644 --- a/scripts/gdb/linux/modules.py +++ b/scripts/gdb/linux/modules.py @@ -13,7 +13,7 @@ import gdb -from linux import cpus, utils +from linux import cpus, utils, lists module_type = utils.CachedType("struct module") @@ -23,12 +23,9 @@ def module_list(): global module_type module_ptr_type = module_type.get_type().pointer() modules = gdb.parse_and_eval("modules") - entry = modules['next'] - end_of_list = modules.address - while entry != end_of_list: - yield utils.container_of(entry, module_ptr_type, "list") - entry = entry['next'] + for module in lists.list_for_each_entry(modules, module_ptr_type, "list"): + yield module def find_module_by_name(name): @@ -79,17 +76,15 @@ class LxLsmod(gdb.Command): size=str(module['core_size']), ref=str(module['refcnt']['counter']))) - source_list = module['source_list'] t = self._module_use_type.get_type().pointer() - entry = source_list['next'] first = True - while entry != source_list.address: - use = utils.container_of(entry, t, "source_list") + sources = module['source_list'] + for use in lists.list_for_each_entry(sources, t, "source_list"): gdb.write("{separator}{name}".format( separator=" " if first else ",", name=use['source']['name'].string())) first = False - entry = entry['next'] + gdb.write("\n")