From patchwork Thu Mar 3 11:40:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 63473 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2896693lbc; Thu, 3 Mar 2016 03:47:47 -0800 (PST) X-Received: by 10.66.142.168 with SMTP id rx8mr3019773pab.14.1457005667187; Thu, 03 Mar 2016 03:47:47 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 76si846972pfb.3.2016.03.03.03.47.46; Thu, 03 Mar 2016 03:47:47 -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 S1757451AbcCCLrp (ORCPT + 30 others); Thu, 3 Mar 2016 06:47:45 -0500 Received: from mail-wm0-f45.google.com ([74.125.82.45]:36539 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755254AbcCCLlU (ORCPT ); Thu, 3 Mar 2016 06:41:20 -0500 Received: by mail-wm0-f45.google.com with SMTP id n186so127593982wmn.1 for ; Thu, 03 Mar 2016 03:41:20 -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=Sw5PI9wRumR8jncBYT+Nz8c/0rCUqhq73fKboRRpibM4i48TBoL2HKL6gIe6f+sZK5 udIrh3o4aAR8uad5OSvRW3UjVvLC5M2WVVGCj7Oj/NDkkhi6aW5ILMUnRpG6UE5KvsLv tWhmGXdg5acNua6ZK40m6sC/uesuR9k1fH76I= 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=Lvft5L0Kp5ij96TwET+vOH4PJ/AMeADO+gwV3ICfesKxLyaPCkC8iZlraeHpv8IcSN UHD58FW8Vqij4QUiXDiAxiYyeBbbva6ozam8d3U3F8dNHxqLtNzXeI3jQtNvxqdgcSpy gDQcrqDi0pcjsSYsmHa1fiFlTAy+bIUlcOYgN66sHvfKP78RD2tj29ZC0JteblQULdcL T3fKWs+YABQk8e+TwUHZQ3xtx6FD7ywri6uqY2oMjdy5MWiWdAs/ZUvM7V3trT1K4h6N xXKll95rx8Xjhw04P0px+suHrIZC1/MGpctntuBPBhYToy2V9MYclbzn9WA6+EovRvsM x3aQ== X-Gm-Message-State: AD7BkJISgig87LypW0xFrKV9koy+E/vxR5d69HCej/8R62XJkU+Ujb794t8HS91HNrQAX+Tv X-Received: by 10.194.48.111 with SMTP id k15mr2739116wjn.103.1457005279567; Thu, 03 Mar 2016 03:41:19 -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 e19sm8570696wmd.1.2016.03.03.03.41.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Mar 2016 03:41:19 -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: [PATCHv3 03/13] scripts/gdb: Convert modules usage to lists functions Date: Thu, 3 Mar 2016 11:40:57 +0000 Message-Id: <1457005267-843-4-git-send-email-kieran.bingham@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1457005267-843-1-git-send-email-kieran.bingham@linaro.org> References: <1457005267-843-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")